@@ -8,7 +8,7 @@ Manage Vapi resources via Git using YAML/Markdown as the source-of-truth.
88| ---| ---| ---|
99| ** History** | Limited visibility of who changed what | Full git history with blame |
1010| ** Review** | Changes go live immediately (can break things) | PR review before deploy |
11- | ** Rollback** | Manual recreation | ` git revert ` + apply |
11+ | ** Rollback** | Manual recreation | ` git revert ` + push |
1212| ** Environments** | Tedious to copy-paste between envs | Same config, different state files |
1313| ** Collaboration** | One person at a time. Need to duplicate assistants, tools, etc. | Team can collaborate and use git branching |
1414| ** Reproducibility** | "It worked on my assistant!" | Declarative, version-controlled |
@@ -19,7 +19,7 @@ Manage Vapi resources via Git using YAML/Markdown as the source-of-truth.
1919- ** Audit Trail** — Every change is a commit with author, timestamp, and reason
2020- ** Code Review** — Catch misconfigurations before they hit production
2121- ** Environment Parity** — Dev, staging, and prod stay in sync
22- - ** No Drift** — Git is the truth; manual console changes get overwritten
22+ - ** No Drift** — Pull merges platform changes; push makes git the truth
2323- ** Automation Ready** — Plug into CI/CD pipelines
2424
2525### Supported Resources
@@ -62,62 +62,101 @@ echo "VAPI_TOKEN=your-token-here" > .env.dev
6262| Command | Description |
6363| ---------| -------------|
6464| ` npm run build ` | Type-check the codebase |
65- | ` npm run pull:dev ` | Pull resources from Vapi to local files |
66- | ` npm run pull:prod ` | Pull resources from prod |
67- | ` npm run apply:dev ` | Push all local files to Vapi (dev) |
68- | ` npm run apply:prod ` | Push all local files to Vapi (prod) |
69- | ` npm run apply:dev assistants ` | Push only assistants (dev) |
70- | ` npm run apply:dev tools ` | Push only tools (dev) |
65+ | ` npm run pull:dev ` | Pull platform state, merge with local changes |
66+ | ` npm run pull:prod ` | Pull from prod, merge with local changes |
67+ | ` npm run push:dev ` | Push local files to Vapi (dev) |
68+ | ` npm run push:prod ` | Push local files to Vapi (prod) |
69+ | ` npm run apply:dev ` | Pull → Merge → Push in one shot (dev) |
70+ | ` npm run apply:prod ` | Pull → Merge → Push in one shot (prod) |
71+ | ` npm run push:dev assistants ` | Push only assistants (dev) |
72+ | ` npm run push:dev tools ` | Push only tools (dev) |
7173| ` npm run call:dev -- -a <name> ` | Start a WebSocket call to an assistant (dev) |
7274| ` npm run call:dev -- -s <name> ` | Start a WebSocket call to a squad (dev) |
7375
7476### Basic Workflow
7577
7678``` bash
77- # Pull existing resources from Vapi
79+ # First time: pull existing resources from Vapi
7880npm run pull:dev
7981
82+ # Commit the initial state
83+ git add . && git commit -m " initial pull"
84+
8085# Make changes to YAML/MD files...
8186
82- # Push changes back to Vapi
87+ # Safe sync: pull latest platform changes, merge, push
8388npm run apply:dev
8489```
8590
86- ### Selective Apply (Partial Sync)
91+ #### Pull → Edit → Push (manual two-step)
92+
93+ If you want more control over each step:
94+
95+ ``` bash
96+ # Pull platform state (auto-merges with your local changes via git stash/pop)
97+ npm run pull:dev
98+
99+ # Review the merged result, make further edits...
100+
101+ # Push to platform
102+ npm run push:dev
103+ ```
104+
105+ #### Handling Merge Conflicts
106+
107+ If platform changes conflict with your local edits, ` pull ` will leave standard git conflict markers in the affected files and exit:
108+
109+ ``` bash
110+ npm run pull:dev
111+ # ⚠️ Merge conflicts detected!
112+
113+ # See which files have conflicts
114+ git diff --name-only --diff-filter=U
115+
116+ # Edit files to resolve conflicts (remove <<<< ==== >>>> markers)
117+
118+ # Push resolved state
119+ npm run push:dev
120+
121+ # Clean up the stash
122+ git stash drop
123+ ```
124+
125+ ### Selective Push (Partial Sync)
87126
88127Push only specific resources instead of syncing everything:
89128
90129#### By Resource Type
91130
92131``` bash
93- npm run apply :dev assistants
94- npm run apply :dev tools
95- npm run apply :dev squads
96- npm run apply :dev structuredOutputs
97- npm run apply :dev personalities
98- npm run apply :dev scenarios
99- npm run apply :dev simulations
100- npm run apply :dev simulationSuites
132+ npm run push :dev assistants
133+ npm run push :dev tools
134+ npm run push :dev squads
135+ npm run push :dev structuredOutputs
136+ npm run push :dev personalities
137+ npm run push :dev scenarios
138+ npm run push :dev simulations
139+ npm run push :dev simulationSuites
101140```
102141
103142#### By Specific File(s)
104143
105144``` bash
106145# Push a single file
107- npm run apply :dev resources/assistants/my-assistant.md
146+ npm run push :dev resources/assistants/my-assistant.md
108147
109148# Push multiple files
110- npm run apply :dev resources/assistants/booking.md resources/tools/my-tool.yml
149+ npm run push :dev resources/assistants/booking.md resources/tools/my-tool.yml
111150```
112151
113152#### Combined
114153
115154``` bash
116155# Push specific file within a type
117- npm run apply :dev assistants resources/assistants/booking.md
156+ npm run push :dev assistants resources/assistants/booking.md
118157```
119158
120- ** Note:** Partial applies skip deletion checks. Run full ` npm run apply :dev ` to sync deletions.
159+ ** Note:** Partial pushes skip deletion checks. Run full ` npm run push :dev ` to sync deletions.
121160
122161---
123162
@@ -126,8 +165,9 @@ npm run apply:dev assistants resources/assistants/booking.md
126165```
127166vapi-gitops/
128167├── src/
129- │ ├── apply.ts # Apply entry point & functions
130- │ ├── pull.ts # Pull entry point & functions
168+ │ ├── pull.ts # Pull platform state (with git stash/pop merge)
169+ │ ├── push.ts # Push local state to platform
170+ │ ├── apply.ts # Orchestrator: pull → merge → push
131171│ ├── call.ts # WebSocket call script
132172│ ├── types.ts # TypeScript interfaces
133173│ ├── config.ts # Environment & configuration
@@ -333,10 +373,10 @@ model:
333373 provider: openai
334374` ` `
335375
336- Then apply :
376+ Then push :
337377
338378` ` ` bash
339- npm run apply :dev
379+ npm run push :dev
340380` ` `
341381
342382# ## How to Add a Tool
@@ -390,7 +430,7 @@ scenarioId: happy-path # → resources/simulations/scenarios/happy-pat
390430
3914311. **Remove references** to the resource from other files
3924322. **Delete the file** : ` rm resources/tools/my-tool.yml`
393- 3. **Apply ** : ` npm run apply :dev`
433+ 3. **Push ** : ` npm run push :dev`
394434
395435The engine will :
396436- Detect the resource is in state but not in filesystem
@@ -429,6 +469,33 @@ model:
429469
430470# # How the Engine Works
431471
472+ # ## Sync Workflow
473+
474+ The engine uses git's merge capabilities to safely combine local and platform changes :
475+
476+ ` ` `
477+ ┌─────────┐ ┌──────────┐ ┌──────────┐
478+ │ pull │ ──▸ │ merge │ ──▸ │ push │
479+ │ platform │ │ (git │ │ to │
480+ │ state │ │ stash/ │ │ platform │
481+ │ │ │ pop) │ │ │
482+ └─────────┘ └──────────┘ └──────────┘
483+ ` ` `
484+
485+ **`pull`** does the heavy lifting:
486+ 1. Detects local uncommitted changes → `git stash`
487+ 2. Downloads fresh platform state (overwrites resource files)
488+ 3. Reapplies local changes on top → `git stash pop`
489+ 4. Git's three-way merge reconciles both sets of changes
490+ 5. If conflicts : leaves standard `<<<<<<<` markers, exits for manual resolution
491+ 6. If clean : working tree has merged files ready to push
492+
493+ **`push`** is the engine — reads local files and syncs them to the platform.
494+
495+ **`apply`** is the convenience wrapper — runs `pull` then `push` in sequence. Stops if pull has conflicts.
496+
497+ > **Note:** `pull` requires a git repo with at least one commit. Without git, it falls back to a simple overwrite (no merge support).
498+
432499# ## Processing Order
433500
434501**Pull** (dependency order):
@@ -441,7 +508,7 @@ model:
4415087. Simulations
4425098. Simulation Suites
443510
444- **Apply ** (dependency order):
511+ **Push ** (dependency order):
4455121. Tools → 2. Structured Outputs → 3. Assistants → 4. Squads
4465135. Personalities → 6. Scenarios → 7. Simulations → 8. Simulation Suites
447514
@@ -519,15 +586,15 @@ The referenced resource doesn't exist. Check:
519586
5205871. Find which resources reference it (shown in error)
5215882. Remove the references
522- 3. Apply again
589+ 3. Push again
5235904. Then delete the resource file
524591
525592# ## Resource not updating
526593
527594Check the state file has correct UUID :
5285951. Open `.vapi-state.{env}.json`
5295962. Find the resource entry
530- 3. If incorrect, delete entry and re-run apply
597+ 3. If incorrect, delete entry and re-run push
531598
532599# ## "property X should not exist" API errors
533600
0 commit comments