Skip to content

Commit 236f25f

Browse files
committed
feat: scope resource directories by environment (dev/stg/prod)
RESOURCES_DIR now resolves to resources/<env>/ so push/pull only operate on the active environment's files. Fixes a pull.ts bug where hardcoded paths broke locally-changed-file detection.
1 parent 8fa11b8 commit 236f25f

36 files changed

Lines changed: 441 additions & 216 deletions

File tree

.cursor/rules/changelog-updates.mdc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
---
2-
description: Require changelog updates for significant config changes
2+
description: Require changelog updates for significant config changes in customer deployments
33
alwaysApply: true
44
---
55

66
# Changelog Update Requirement
77

8-
When making significant configuration changes, update `docs/changelog.md` in the same change.
8+
This rule applies to **customer deployment clones** of the gitops repo, not the root template repo itself.
9+
10+
**How to tell the difference:** If `docs/changelog.md` still contains the placeholder section header `## YYYY-MM-DD`, this is the unmodified template and you should NOT update the changelog. Once that placeholder has been replaced with real dated entries, this is a customer deployment and the rule below applies.
11+
12+
When making significant configuration changes in a customer deployment, update `docs/changelog.md` in the same change.
913

1014
Significant changes include:
1115
- Assistant changes (prompt/body/frontmatter updates)

AGENTS.md

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,26 @@ This project manages **Vapi voice agent configurations** as code. All resources
66

77
**Prompt quality:** Whenever you create a new assistant or change an existing assistant’s system prompt, read **`docs/Vapi Prompt Optimization Guide.md`** first. It goes deeper on structure, voice constraints, tool usage, and evaluation than the summary in this file.
88

9+
**Environment-scoped resources:** Resources live in `resources/<env>/` (e.g. `resources/dev/`, `resources/prod/`). Each environment directory is isolated — `push:dev` only touches `resources/dev/`, `push:prod` only touches `resources/prod/`. See **`docs/environment-scoped-resources.md`** for the full promotion workflow and rationale.
10+
911
---
1012

1113
## Quick Reference
1214

1315
| I want to... | What to do |
1416
|-------------------------------------|-----------------------------------------------------------------|
15-
| Edit an assistant's system prompt | Edit the markdown body in `resources/assistants/<name>.md` |
17+
| Edit an assistant's system prompt | Edit the markdown body in `resources/<env>/assistants/<name>.md` |
1618
| Change assistant settings | Edit the YAML frontmatter in the same `.md` file |
17-
| Add a new tool | Create `resources/tools/<name>.yml` |
18-
| Add a new assistant | Create `resources/assistants/<name>.md` |
19-
| Create a multi-agent squad | Create `resources/squads/<name>.yml` |
20-
| Add post-call analysis | Create `resources/structuredOutputs/<name>.yml` |
21-
| Write test simulations | Create files under `resources/simulations/` |
19+
| Add a new tool | Create `resources/<env>/tools/<name>.yml` |
20+
| Add a new assistant | Create `resources/<env>/assistants/<name>.md` |
21+
| Create a multi-agent squad | Create `resources/<env>/squads/<name>.yml` |
22+
| Add post-call analysis | Create `resources/<env>/structuredOutputs/<name>.yml` |
23+
| Write test simulations | Create files under `resources/<env>/simulations/` |
24+
| Promote resources across envs | Copy files from `resources/dev/` to `resources/stg/` or `resources/prod/` |
2225
| Test webhook event delivery locally | Run `npm run mock:webhook` and tunnel with ngrok |
23-
| Track significant config updates | Update `docs/changelog.md` |
2426
| Push changes to Vapi | `npm run push:dev` or `npm run push:prod` |
2527
| Pull latest from Vapi | `npm run pull:dev` or `npm run pull:dev:force` |
26-
| Push only one file | `npm run push:dev resources/assistants/my-agent.md` |
28+
| Push only one file | `npm run push:dev resources/dev/assistants/my-agent.md` |
2729
| Test a call | `npm run call:dev -- -a <assistant-name>` |
2830

2931
---
@@ -32,19 +34,21 @@ This project manages **Vapi voice agent configurations** as code. All resources
3234

3335
```
3436
docs/
35-
├── Vapi Prompt Optimization Guide.md # In-depth prompt authoring (use when creating or editing assistants)
36-
└── changelog.md # Significant resource/config changes over time
37+
├── Vapi Prompt Optimization Guide.md # In-depth prompt authoring
38+
├── environment-scoped-resources.md # Environment isolation & promotion workflow
39+
└── changelog.md # Template for tracking per-customer config changes
3740
3841
resources/
39-
├── assistants/ # Voice agent definitions (.md or .yml)
40-
├── tools/ # Tool/function definitions (.yml)
41-
├── structuredOutputs/ # Post-call analysis schemas (.yml)
42-
├── squads/ # Multi-agent squad configs (.yml)
43-
└── simulations/ # Test infrastructure
44-
├── personalities/ # Simulated caller personas (.yml)
45-
├── scenarios/ # Test case scripts (.yml)
46-
├── tests/ # Simulation runs (.yml)
47-
└── suites/ # Grouped simulation batches (.yml)
42+
├── dev/ # Dev environment resources (push:dev reads here)
43+
│ ├── assistants/
44+
│ ├── tools/
45+
│ ├── squads/
46+
│ ├── structuredOutputs/
47+
│ └── simulations/
48+
├── stg/ # Staging environment resources (push:stg reads here)
49+
│ └── (same structure)
50+
└── prod/ # Production environment resources (push:prod reads here)
51+
└── (same structure)
4852
4953
scripts/
5054
└── mock-vapi-webhook-server.ts # Local webhook receiver for server message testing
@@ -58,7 +62,7 @@ scripts/
5862

5963
Assistants are voice agents that handle phone calls. They are defined as **Markdown files with YAML frontmatter**.
6064

61-
**File:** `resources/assistants/<name>.md`
65+
**File:** `resources/<env>/assistants/<name>.md`
6266

6367
```markdown
6468
---
@@ -266,7 +270,7 @@ artifactPlan:
266270

267271
Tools are functions the assistant can call during a conversation.
268272

269-
**File:** `resources/tools/<name>.yml`
273+
**File:** `resources/<env>/tools/<name>.yml`
270274

271275
#### Function Tool (calls a webhook)
272276

@@ -365,7 +369,7 @@ function:
365369

366370
Structured outputs extract data from call transcripts after the call ends. They run LLM analysis on the conversation.
367371

368-
**File:** `resources/structuredOutputs/<name>.yml`
372+
**File:** `resources/<env>/structuredOutputs/<name>.yml`
369373

370374
#### Boolean Output (yes/no evaluation)
371375

@@ -446,12 +450,12 @@ schema:
446450

447451
Squads define multi-agent systems where assistants can hand off to each other.
448452

449-
**File:** `resources/squads/<name>.yml`
453+
**File:** `resources/<env>/squads/<name>.yml`
450454

451455
```yaml
452456
name: My Squad
453457
members:
454-
- assistantId: intake-agent-a1b2c3d4 # References resources/assistants/<id>.md
458+
- assistantId: intake-agent-a1b2c3d4 # References resources/<env>/assistants/<id>.md
455459
assistantOverrides: # Override assistant settings within this squad
456460
metadata:
457461
position: # Visual position in dashboard editor
@@ -678,7 +682,7 @@ npm run pull:dev # Pull from Vapi (preserve local changes)
678682
npm run pull:dev:force # Pull from Vapi (overwrite everything)
679683
npm run push:dev # Push all local changes to Vapi
680684
npm run push:dev assistants # Push only assistants
681-
npm run push:dev resources/assistants/my-agent.md # Push single file
685+
npm run push:dev resources/dev/assistants/my-agent.md # Push single file
682686
683687
# Testing
684688
npm run call:dev -- -a <assistant-name> # Call an assistant via WebSocket

CLAUDE.md

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,3 @@ When both files exist, follow both. If guidance overlaps, treat `AGENTS.md` as t
1111

1212
1. Read `AGENTS.md` first.
1313
2. Then read this file (`CLAUDE.md`) for additional policy constraints.
14-
15-
## Changelog Discipline
16-
17-
Always update `docs/changelog.md` when making significant configuration changes.
18-
19-
Significant changes include:
20-
- Assistant updates (prompt or YAML frontmatter)
21-
- Tool updates (new tools, changed parameters, changed behavior)
22-
- Squad updates (members, handoffs, overrides)
23-
- Other behavior-impacting resource changes (structured outputs, simulations)
24-
25-
Each changelog update should state:
26-
- Date (`YYYY-MM-DD`)
27-
- Files/resources changed
28-
- Why the change was made
29-
- Expected impact

README.md

Lines changed: 36 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ Manage Vapi resources via Git using YAML/Markdown as the source-of-truth.
4040
## How to Use This Repo
4141

4242
1. **Sync from Vapi first** using `pull` so local files reflect platform state.
43-
2. **Edit declarative resources** in `resources/` (`.md` assistants, `.yml` tools/squads/etc.).
43+
2. **Edit declarative resources** in `resources/<env>/` (`.md` assistants, `.yml` tools/squads/etc.).
4444
3. **Push selectively while iterating** (resource type or file path), then run a full push before release.
45-
4. **Promote by environment** (`dev` -> `stg` -> `prod`) using the same resource files with environment-specific state and credentials.
45+
4. **Promote by environment** (`dev` -> `stg` -> `prod`) by copying files between `resources/dev/`, `resources/stg/`, and `resources/prod/`.
4646

4747
Use:
4848
- `pull` when Vapi might have changed
@@ -117,11 +117,13 @@ npm run push:dev
117117
Promotion example:
118118

119119
```bash
120-
# After validating in dev, promote selectively to staging
121-
npm run push:stg resources/squads/your-squad.yml
120+
# After validating in dev, copy to staging and push
121+
cp resources/dev/squads/your-squad.yml resources/stg/squads/
122+
npm run push:stg
122123

123124
# Promote to prod when ready
124-
npm run push:prod resources/squads/your-squad.yml
125+
cp resources/stg/squads/your-squad.yml resources/prod/squads/
126+
npm run push:prod
125127
```
126128

127129
#### Pulling Without Losing Local Work
@@ -133,7 +135,7 @@ By default, `pull` preserves any files you've locally modified or deleted:
133135

134136
npm run pull:dev
135137
# ⏭️ my-assistant (locally changed, skipping)
136-
# ✨ new-tool -> resources/tools/new-tool.yml
138+
# ✨ new-tool -> resources/dev/tools/new-tool.yml
137139
# Your edits are preserved, new platform resources are downloaded
138140
```
139141

@@ -156,7 +158,7 @@ npm run pull:dev
156158
git diff
157159

158160
# Accept platform changes for a specific file
159-
git checkout -- resources/tools/some-tool.yml
161+
git checkout -- resources/dev/tools/some-tool.yml
160162
```
161163

162164
### Selective Push (Partial Sync)
@@ -180,17 +182,17 @@ npm run push:dev simulationSuites
180182

181183
```bash
182184
# Push a single file
183-
npm run push:dev resources/assistants/my-assistant.md
185+
npm run push:dev resources/dev/assistants/my-assistant.md
184186

185187
# Push multiple files
186-
npm run push:dev resources/assistants/booking.md resources/tools/my-tool.yml
188+
npm run push:dev resources/dev/assistants/booking.md resources/dev/tools/my-tool.yml
187189
```
188190

189191
#### Combined
190192

191193
```bash
192194
# Push specific file within a type
193-
npm run push:dev assistants resources/assistants/booking.md
195+
npm run push:dev assistants resources/dev/assistants/booking.md
194196
```
195197

196198
**Note:** Partial pushes skip deletion checks. Run full `npm run push:dev` to sync deletions.
@@ -202,7 +204,7 @@ Partial push is ideal for promoting specific squads or assistants to staging/pro
202204
```bash
203205
# Push a single squad to staging — tools, structured outputs, and
204206
# assistants are created automatically if they don't exist yet
205-
npm run push:stg resources/squads/everblue-voice-squad-20374c37.yml
207+
npm run push:stg resources/stg/squads/everblue-voice-squad-20374c37.yml
206208

207209
# Push assistants to prod — missing tools and structured outputs
208210
# are auto-applied first so references resolve correctly
@@ -257,7 +259,8 @@ The mock server exposes:
257259
vapi-gitops/
258260
├── docs/
259261
│ ├── Vapi Prompt Optimization Guide.md # Prompt authoring reference
260-
│ └── changelog.md # Significant change log
262+
│ ├── environment-scoped-resources.md # Env isolation & promotion workflow
263+
│ └── changelog.md # Template for per-customer change tracking
261264
├── src/
262265
│ ├── pull.ts # Pull platform state (with git stash/pop merge)
263266
│ ├── push.ts # Push local state to platform
@@ -272,15 +275,16 @@ vapi-gitops/
272275
│ ├── credentials.ts # Credential resolution (name ↔ UUID)
273276
│ └── delete.ts # Deletion & orphan checks
274277
├── resources/
275-
│ ├── assistants/ # Assistant files (.md or .yml)
276-
│ ├── tools/ # Tool YAML files
277-
│ ├── structuredOutputs/ # Structured output YAML files
278-
│ ├── squads/ # Squad YAML files
279-
│ └── simulations/ # Simulation resources
280-
│ ├── personalities/ # Personality YAML files
281-
│ ├── scenarios/ # Scenario YAML files
282-
│ ├── tests/ # Simulation YAML files
283-
│ └── suites/ # Simulation suite YAML files
278+
│ ├── dev/ # Dev environment resources (push:dev reads here)
279+
│ │ ├── assistants/
280+
│ │ ├── tools/
281+
│ │ ├── squads/
282+
│ │ ├── structuredOutputs/
283+
│ │ └── simulations/
284+
│ ├── stg/ # Staging resources (push:stg reads here)
285+
│ │ └── (same structure)
286+
│ └── prod/ # Production resources (push:prod reads here)
287+
│ └── (same structure)
284288
├── scripts/
285289
│ └── mock-vapi-webhook-server.ts # Local server message receiver
286290
├── .env.example # Example env var file
@@ -440,7 +444,7 @@ simulationIds:
440444

441445
**Option 1: With System Prompt (recommended)**
442446

443-
Create `resources/assistants/my-assistant.md`:
447+
Create `resources/dev/assistants/my-assistant.md`:
444448

445449
```markdown
446450
---
@@ -461,7 +465,7 @@ Instructions for the assistant...
461465

462466
**Option 2: Without System Prompt**
463467

464-
Create `resources/assistants/my-assistant.yml`:
468+
Create `resources/dev/assistants/my-assistant.yml`:
465469

466470
```yaml
467471
name: My Assistant
@@ -481,7 +485,7 @@ npm run push:dev
481485

482486
### How to Add a Tool
483487

484-
Create `resources/tools/my-tool.yml`:
488+
Create `resources/dev/tools/my-tool.yml`:
485489

486490
```yaml
487491
type: function
@@ -507,29 +511,29 @@ Use the **filename without extension** as the resource ID:
507511
# In an assistant
508512
model:
509513
toolIds:
510-
- my-tool # → resources/tools/my-tool.yml
511-
- utils/helper-tool # → resources/tools/utils/helper-tool.yml
514+
- my-tool # → resources/<env>/tools/my-tool.yml
515+
- utils/helper-tool # → resources/<env>/tools/utils/helper-tool.yml
512516
artifactPlan:
513517
structuredOutputIds:
514-
- call-summary # → resources/structuredOutputs/call-summary.yml
518+
- call-summary # → resources/<env>/structuredOutputs/call-summary.yml
515519
```
516520

517521
```yaml
518522
# In a squad
519523
members:
520-
- assistantId: intake-agent # → resources/assistants/intake-agent.md
524+
- assistantId: intake-agent # → resources/<env>/assistants/intake-agent.md
521525
```
522526

523527
```yaml
524528
# In a simulation
525-
personalityId: skeptical-sam # → resources/simulations/personalities/skeptical-sam.yml
526-
scenarioId: happy-path # → resources/simulations/scenarios/happy-path.yml
529+
personalityId: skeptical-sam # → resources/<env>/simulations/personalities/skeptical-sam.yml
530+
scenarioId: happy-path # → resources/<env>/simulations/scenarios/happy-path.yml
527531
```
528532

529533
### How to Delete a Resource
530534

531535
1. **Remove references** to the resource from other files
532-
2. **Delete the file**: `rm resources/tools/my-tool.yml`
536+
2. **Delete the file**: `rm resources/dev/tools/my-tool.yml`
533537
3. **Push**: `npm run push:dev`
534538

535539
The engine will:
@@ -543,7 +547,7 @@ The engine will:
543547
Create subdirectories for multi-tenant or feature organization:
544548

545549
```
546-
resources/
550+
resources/<env>/
547551
├── assistants/
548552
│ ├── shared/
549553
│ │ └── fallback.md

docs/changelog.md

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,29 @@
11
# Changelog
22

3-
Use this file to track meaningful configuration changes to assistants, tools, squads, and related resources.
3+
Track meaningful configuration changes to assistants, tools, squads, and related resources here.
4+
5+
This is a **template file**. When you clone this repo for a customer project, replace the example section below with real entries to start tracking changes specific to that deployment.
46

57
## How To Use
68

79
- Add a new dated section at the top for each meaningful change set.
810
- Include what changed, why it changed, and expected impact.
911
- Group entries by resource type when possible.
12+
- Remove the `YYYY-MM-DD` example section once you add your first real entry.
1013

1114
---
1215

1316
## YYYY-MM-DD
1417

1518
### Added
16-
- [assistants] Added `resources/assistants/example-agent.md` for new intake flow.
19+
- [assistants] Added `resources/<env>/assistants/example-agent.md` for new intake flow.
1720

1821
### Changed
19-
- [tools] Updated `resources/tools/example-tool.yml` parameters to include `reasonCode`.
20-
- [squads] Updated `resources/squads/example-squad.yml` handoff routing logic.
22+
- [tools] Updated `resources/<env>/tools/example-tool.yml` parameters to include `reasonCode`.
23+
- [squads] Updated `resources/<env>/squads/example-squad.yml` handoff routing logic.
2124

2225
### Fixed
23-
- [assistants] Corrected prompt guardrails in `resources/assistants/example-agent.md`.
26+
- [assistants] Corrected prompt guardrails in `resources/<env>/assistants/example-agent.md`.
2427

2528
### Notes
2629
- Follow-up action or migration notes (if any).
27-
28-
---
29-
30-
## 2026-03-25
31-
32-
### Added
33-
- [testing] Added `scripts/mock-vapi-webhook-server.ts` to receive and inspect webhook events locally.
34-
- [tooling] Added `npm run mock:webhook` for quickly running the local webhook receiver.
35-
36-
### Changed
37-
- [docs] Updated `AGENTS.md` mock-server guidance to include core `serverMessages` event types (`speech-update`, `status-update`, `end-of-call-report`) and `ngrok` tunnel usage for local callback testing.
38-
39-
### Notes
40-
- The mock server includes `GET /health`, `GET /events`, and `POST /webhook` routes.
41-
- `tool-calls` requests receive a basic mocked `results` response to keep test flows unblocked.

0 commit comments

Comments
 (0)