Skip to content

Commit b60b1e3

Browse files
committed
docs(readme): add suggested workflows; promote apply over push; document all scripts
1 parent 0528bcc commit b60b1e3

1 file changed

Lines changed: 123 additions & 9 deletions

File tree

README.md

Lines changed: 123 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,19 @@ Every command works in two modes:
6868
- **Interactive** — run without arguments, get prompted for org and resources
6969
- **Direct** — pass an org slug and flags for scripting / CI
7070

71-
| Command | Interactive | Direct | Description |
71+
| Command | Interactive | Direct | One-liner |
7272
| --- | --- | --- | --- |
73-
| `npm run setup` ||| First-time org setup wizard |
74-
| `npm run pull` || `npm run pull -- <org> [flags]` | Pull remote resources locally |
75-
| `npm run push` || `npm run push -- <org> [flags]` | Push local resources to Vapi |
76-
| `npm run apply` || `npm run apply -- <org> [--force]` | Pull → Merge → Push in one shot |
77-
| `npm run call` || `npm run call -- <org> -a <name>` | Start a WebSocket call |
78-
| `npm run cleanup` || `npm run cleanup -- <org> [--force --confirm <org>]` | Delete orphaned remote resources (destructive run requires `--confirm <org>`) |
79-
| `npm run build` ||| Type-check the codebase |
80-
| `npm test` ||| Run regression tests (`node:test`) |
73+
| `npm run setup` ||| First-time org wizard — creates `.env.<org>` and `resources/<org>/`. |
74+
| `npm run validate` || `npm run validate -- <org>` | Schema-check local YAML/MD with no network call. **Run before every `apply`.** |
75+
| `npm run apply` || `npm run apply -- <org> [--force]` | **Default deploy verb.** Pull → merge → push in one safe pass; resilient against dashboard drift. |
76+
| `npm run pull` || `npm run pull -- <org> [flags]` | Fetch remote state into local files / state file. Local-first by default — won't clobber local edits. |
77+
| `npm run push` || `npm run push -- <org> [flags]` | Raw push without a pre-pull. **Skip unless you just ran `pull` and are certain state is fresh** — otherwise prefer `apply`. |
78+
| `npm run cleanup` || `npm run cleanup -- <org> [--force --confirm <org>]` | Inspect (default) or delete orphaned remote resources. Destructive run requires `--confirm <org>`. |
79+
| `npm run rollback` || `npm run rollback -- <org> --list` or `--to <ISO>` | Restore from a snapshot in `.vapi-state.<org>.snapshots/` (one is written before every push/apply). |
80+
| `npm run call` || `npm run call -- <org> -a <name>` or `-s <squad>` | Start an interactive WebSocket call against an assistant or squad. |
81+
| `npm run sim` || `npm run sim -- <org> --suite <name> --target <name>` | Run a simulation suite (or specific simulations) against a deployed assistant/squad. |
82+
| `npm run build` ||| Type-check the codebase (`tsc --noEmit`). |
83+
| `npm test` ||| Run regression tests (`node:test`). |
8184

8285
### Interactive Mode
8386

@@ -145,6 +148,117 @@ npm run call -- my-org -s my-squad
145148

146149
---
147150

151+
## Suggested Workflows
152+
153+
Recipes for common situations. Each one is the safe path — there are faster shortcuts, but use them only when you understand the trade-offs. The single most important habit: **prefer `apply` over `push`**, because `apply` refreshes platform state before mutating, protecting you against dashboard edits made between your last pull and your push.
154+
155+
### Daily edit-and-deploy
156+
157+
```bash
158+
# 1. Schema-check locally first — fails fast on YAML shape errors, no network needed.
159+
npm run validate -- <org>
160+
161+
# 2. Deploy via apply: pulls latest platform state, merges with your local
162+
# changes, then pushes the merged result. Safe against drift.
163+
npm run apply -- <org>
164+
```
165+
166+
### Iterating on a single file
167+
168+
```bash
169+
npm run validate -- <org>
170+
npm run apply -- <org> resources/<org>/assistants/my-agent.md
171+
```
172+
173+
`apply` accepts the same path-scoping as `push`, so you get safety + targeted scope in one command.
174+
175+
### First push into a fresh org
176+
177+
```bash
178+
# Interactive wizard — pick "no resources" if you'll author from scratch.
179+
npm run setup
180+
181+
# Drop your YAML/MD files into resources/<org>/, then:
182+
npm run validate -- <org>
183+
npm run apply -- <org>
184+
```
185+
186+
On a fresh org, `apply`'s pull phase bootstraps `.vapi-state.<org>.json` from the empty dashboard before pushing your local creates.
187+
188+
### Pulling without losing local work
189+
190+
```bash
191+
# Local-first by default — won't overwrite locally modified files.
192+
npm run pull -- <org>
193+
194+
# State-only refresh — re-sync UUID mappings without writing resource files locally.
195+
npm run pull -- <org> --bootstrap
196+
197+
# Pull a single known remote resource by UUID.
198+
npm run pull -- <org> --type assistants --id <uuid>
199+
```
200+
201+
### Live testing what you just deployed
202+
203+
```bash
204+
# Interactive WebSocket call — speak/listen from the terminal.
205+
npm run call -- <org> -a <assistant-name>
206+
npm run call -- <org> -s <squad-name>
207+
208+
# Automated simulation suite against the deployed resource.
209+
npm run sim -- <org> --suite <suite-name> --target <assistant-name>
210+
```
211+
212+
### Recovering from a bad deploy
213+
214+
```bash
215+
# Every push/apply writes a snapshot first. List them:
216+
npm run rollback -- <org> --list
217+
218+
# Re-apply a specific snapshot to undo a deploy:
219+
npm run rollback -- <org> --to <ISO-timestamp>
220+
```
221+
222+
### Cleaning up orphaned dashboard resources
223+
224+
```bash
225+
# Dry-run by default — shows what would be deleted, makes no changes.
226+
npm run cleanup -- <org>
227+
228+
# Destructive run — requires explicit confirmation:
229+
npm run cleanup -- <org> --force --confirm <org>
230+
```
231+
232+
**Surgical alternative when the orphan set includes Vapi-default fixtures** (e.g. the seven undeletable stock simulation personalities — see `docs/learnings/simulations.md`): delete individual resources via direct API call, then refresh state:
233+
234+
```bash
235+
curl -X DELETE -H "Authorization: Bearer $VAPI_TOKEN" \
236+
https://api.vapi.ai/assistant/<orphan-uuid>
237+
npm run pull -- <org> --bootstrap
238+
```
239+
240+
This avoids `--force` halting on the first immortal-default 404.
241+
242+
### When to use raw `push` instead of `apply`
243+
244+
Almost never. The only honest case: you just ran `pull`, nothing else has touched the dashboard since, and you need to skip the merge pass for speed. In any multi-developer environment, default to `apply`.
245+
246+
If you do use `push`, dry-run it first:
247+
248+
```bash
249+
npm run push -- <org> --dry-run
250+
```
251+
252+
### Pre-flight checklist before any deploy
253+
254+
1. `git status` — uncommitted changes are intentional?
255+
2. `npm run validate -- <org>` — schema clean?
256+
3. `npm run apply -- <org>` (or `apply -- <org> <path>` for single-file)
257+
4. After: verify with `npm run call -- <org> -a <name>` or a `npm run sim` suite
258+
5. If something looks wrong: `npm run rollback -- <org> --list`
259+
260+
---
261+
148262
## Organization-Based Structure
149263

150264
Resources are scoped by organization (not fixed `dev`/`stg`/`prod` names). Each org gets:

0 commit comments

Comments
 (0)