Skip to content

Commit 822411b

Browse files
committed
docs(agents): add sync-command safety hierarchy; promote apply over push
1 parent b60b1e3 commit 822411b

1 file changed

Lines changed: 49 additions & 4 deletions

File tree

AGENTS.md

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,57 @@ If you're unsure where something goes, default to `docs/learnings/`. The README
6060
| Add post-call analysis | Create `resources/<org>/structuredOutputs/<name>.yml` |
6161
| Write test simulations | Create files under `resources/<org>/simulations/` |
6262
| Promote resources across orgs | Copy files between `resources/<org-a>/` and `resources/<org-b>/` |
63-
| Push changes to Vapi | `npm run push -- <org>` |
63+
| Deploy local changes (default) | `npm run apply -- <org>` — pull → merge → push, safe against dashboard drift |
64+
| Pre-flight schema check (no network) | `npm run validate -- <org>` — run before every `apply` |
6465
| Pull latest from Vapi | `npm run pull -- <org>`, `--force`, or `--bootstrap` |
6566
| Pull one known remote resource | `npm run pull -- <org> --type assistants --id <uuid>` |
66-
| Push only one file | `npm run push -- <org> resources/<org>/assistants/my-agent.md` |
67-
| Push multiple specific files | `npm run push -- <org> <path1> <path2>` (one state-file rewrite at the end) |
68-
| Test a call | `npm run call -- <org> -a <assistant-name>` |
67+
| Deploy a single file | `npm run apply -- <org> resources/<org>/assistants/my-agent.md` |
68+
| Recover from a bad deploy | `npm run rollback -- <org> --list` then `--to <ISO-timestamp>` |
69+
| Raw push (no pre-pull) | `npm run push -- <org>` — see safety hierarchy below; rarely the right call |
70+
| Test a call | `npm run call -- <org> -a <assistant-name>` or `-s <squad-name>` |
71+
| Run a simulation suite | `npm run sim -- <org> --suite <name> --target <assistant-name>` |
72+
73+
---
74+
75+
## Choosing a sync command (safety hierarchy)
76+
77+
Three commands deploy changes to the Vapi platform. Pick the safest one that fits the task. **`apply` is the default.**
78+
79+
### `npm run apply -- <org>` — DEFAULT deploy verb
80+
81+
Pulls the platform's current state, merges with your local files, then pushes the merged result. This protects you from racing dashboard edits made between your last pull and your push. Use this for ~99% of deployments.
82+
83+
```bash
84+
npm run validate -- <org> # schema check first, no network call
85+
npm run apply -- <org> # full-org apply
86+
npm run apply -- <org> <path-to-file> # single-file apply (same safety, scoped diff)
87+
```
88+
89+
### `npm run validate -- <org>` — pre-flight schema check
90+
91+
Runs the engine's local validators against every YAML/MD file in the org without any network call. Catches shape errors (missing required fields, wrong types, stale tool references) before they burn a deploy. **Run before every `apply`.**
92+
93+
### `npm run push -- <org>` — raw push, no pre-pull
94+
95+
Skips the merge pass. Only use when (a) you literally just ran `pull` and (b) you're certain no one has touched the dashboard since. In a multi-developer environment or when dashboard editors are in play, default to `apply` instead. Stale local state can clobber recent dashboard edits or PATCH against UUIDs that no longer exist.
96+
97+
If you do use `push`, dry-run first: `npm run push -- <org> --dry-run`.
98+
99+
### After-the-fact safety
100+
101+
- **`npm run rollback -- <org> --list`** — every push/apply writes a state snapshot to `.vapi-state.<org>.snapshots/` before mutating. `--to <ISO-timestamp>` re-applies a specific snapshot, effectively undoing the deploy.
102+
- **`npm run cleanup -- <org>`** (no `--force`) — enumerate orphaned dashboard resources without deleting. Destructive run is double-gated: requires `--force --confirm <org>`.
103+
- **Surgical alternative to `--force` cleanup:** when the orphan set includes Vapi-default fixtures (see `docs/learnings/simulations.md` — the seven immortal stock personalities), delete individual resources via `curl -X DELETE` against the API, then `npm run pull -- <org> --bootstrap` to refresh state. `--force` halts on the first immortal-default 404 and exits non-zero.
104+
105+
### Pre-flight checklist (memorize this loop)
106+
107+
1. `git status` — uncommitted changes are intentional?
108+
2. `npm run validate -- <org>` — schema clean?
109+
3. `npm run apply -- <org>` (or `apply -- <org> <path>` for single-file)
110+
4. Verify with `npm run call -- <org> -a <name>` and/or `npm run sim -- <org> --suite <name> --target <name>`
111+
5. If something looks wrong: `npm run rollback -- <org> --list``--to <timestamp>`
112+
113+
**Why this matters:** the gitops engine tracks resource UUIDs in `.vapi-state.<org>.json`. Bare `push` trusts that file is current. If the dashboard has changed since your last pull — someone edited an assistant in the UI, a teammate ran a different push, a structured output got linked via another path — your local state can be stale by minutes. `apply` refreshes state before mutating, eliminating that entire class of race.
69114

70115
---
71116

0 commit comments

Comments
 (0)