@imdeadpool/guardex 7.0.43 → 7.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/README.md +35 -0
  2. package/package.json +4 -1
  3. package/scripts/prepublish-bump-version.js +191 -0
  4. package/skills/gx-act/SKILL.md +82 -0
  5. package/src/agents/activity.js +279 -0
  6. package/src/agents/inspect.js +17 -4
  7. package/src/agents/launch.js +10 -1
  8. package/src/agents/status.js +9 -6
  9. package/src/budget/index.js +2 -1
  10. package/src/cli/args.js +118 -5
  11. package/src/cli/commands/agents.js +381 -0
  12. package/src/cli/commands/bootstrap.js +92 -0
  13. package/src/cli/commands/branch.js +127 -0
  14. package/src/cli/commands/claude.js +674 -0
  15. package/src/cli/commands/doctor.js +268 -0
  16. package/src/cli/commands/finish.js +26 -0
  17. package/src/cli/commands/mcp.js +122 -0
  18. package/src/cli/commands/misc.js +304 -0
  19. package/src/cli/commands/pr.js +439 -0
  20. package/src/cli/commands/prompt.js +92 -0
  21. package/src/cli/commands/release.js +305 -0
  22. package/src/cli/commands/report.js +244 -0
  23. package/src/cli/commands/review.js +32 -0
  24. package/src/cli/commands/setup.js +242 -0
  25. package/src/cli/commands/status.js +338 -0
  26. package/src/cli/commands/watch.js +234 -0
  27. package/src/cli/main.js +68 -3726
  28. package/src/cli/shared/repo-env.js +161 -0
  29. package/src/cli/shared/sandbox.js +417 -0
  30. package/src/cli/shared/scaffolding.js +535 -0
  31. package/src/cli/shared/toolchain-shims.js +420 -0
  32. package/src/context.js +229 -11
  33. package/src/core/runtime.js +6 -1
  34. package/src/doctor/index.js +42 -13
  35. package/src/finish/index.js +147 -5
  36. package/src/finish/preflight.js +177 -0
  37. package/src/finish/review-gate.js +182 -0
  38. package/src/git/index.js +446 -4
  39. package/src/hooks/index.js +0 -64
  40. package/src/mcp/collect.js +394 -0
  41. package/src/mcp/server.js +163 -0
  42. package/src/output/index.js +67 -1
  43. package/src/pr-review.js +23 -0
  44. package/src/pr.js +381 -0
  45. package/src/sandbox/index.js +13 -2
  46. package/src/scaffold/agent-worktree-prep.js +220 -0
  47. package/src/scaffold/index.js +108 -10
  48. package/src/scaffold/provision-config.js +314 -0
  49. package/src/speckit/index.js +226 -0
  50. package/src/terminal/index.js +1 -76
  51. package/src/terminal/kitty.js +20 -0
  52. package/src/terminal/tmux.js +9 -1
  53. package/src/toolchain/index.js +20 -0
  54. package/templates/AGENTS.monorepo-apps.md +26 -0
  55. package/templates/AGENTS.multiagent-safety.md +68 -344
  56. package/templates/AGENTS.multiagent-safety.min.md +11 -0
  57. package/templates/codex/skills/gx-act/SKILL.md +82 -0
  58. package/templates/githooks/pre-commit +22 -19
  59. package/templates/scripts/agent-branch-finish.sh +17 -33
  60. package/templates/scripts/agent-branch-merge.sh +4 -1
  61. package/templates/scripts/agent-branch-start.sh +115 -6
  62. package/templates/scripts/agent-file-locks.py +245 -50
  63. package/templates/scripts/agent-preflight.sh +31 -5
  64. package/templates/scripts/agent-worktree-prune.sh +1 -1
  65. package/templates/scripts/codex-agent.sh +0 -91
  66. package/src/agents/detect.js +0 -160
  67. package/src/cockpit/keybindings.js +0 -224
  68. package/src/cockpit/layout.js +0 -224
@@ -1,37 +1,16 @@
1
1
  <!-- multiagent-safety:START -->
2
- ## Multi-Agent Execution Contract: Guardex + Colony
2
+ ## Multi-Agent Execution Contract
3
3
 
4
- ### Repo toggle
4
+ ### Toggle
5
5
 
6
- Guardex is enabled by default.
7
-
8
- If the repo-root `.env` sets any of these values, treat this entire Guardex contract as disabled for the repo:
9
-
10
- ```text
11
- GUARDEX_ON=0
12
- GUARDEX_ON=false
13
- GUARDEX_ON=no
14
- GUARDEX_ON=off
15
- ```
16
-
17
- When disabled, do not require Guardex worktrees, lock claims, completion flow, or OpenSpec workflow until `GUARDEX_ON` is re-enabled.
18
-
19
- To explicitly enable:
20
-
21
- ```text
22
- GUARDEX_ON=1
23
- ```
6
+ Guardex is enabled by default. Disable via repo-root `.env` with `GUARDEX_ON=0|false|no|off`. Re-enable with `GUARDEX_ON=1`.
24
7
 
25
8
  ### Core rules
26
9
 
27
- - Work from an `agent/*` branch and worktree, never directly on the protected base branch.
28
- - Claim files before edits.
29
- - Use Colony for coordination before falling back to OMX state/notepad.
30
- - Prefer fff MCP tools for file search whenever available; do not route file search through RTK when fff can answer it.
31
- - Use OpenSpec for durable behavior contracts and change-driven work.
32
- - Keep outputs compact: less word, same proof.
33
- - Commit, push, and open/update a PR for completed work unless the user explicitly says to keep it local.
34
- - Do not embed stale memory dumps, generated status snapshots, PR transcripts, session history, or long logs in this file.
10
+ - Work from an `agent/*` branch + worktree. **Never** edit the protected base directly.
11
+ - Claim files before editing. Confirm a path is in your claim before deleting it.
12
+ - Commit, push, and open/update a PR for completed work unless the user says keep-local.
13
+ - Keep outputs and notes compact. Less word, same proof.
35
14
 
36
15
  ### Task-size routing
37
16
 
@@ -39,256 +18,65 @@ Small tasks stay direct and caveman-only.
39
18
 
40
19
  For typos, single-file tweaks, one-liners, version bumps, comment-only changes, or similarly bounded asks, solve directly and do not escalate into heavy orchestration just because a keyword appears.
41
20
 
42
- Treat these prefixes as explicit lightweight escape hatches:
43
-
44
- - `quick:`
45
- - `simple:`
46
- - `tiny:`
47
- - `minor:`
48
- - `small:`
49
- - `just:`
50
- - `only:`
51
-
52
- Promote to full Guardex / OMX orchestration only when scope grows into:
53
-
54
- - multi-file behavior change
55
- - API/schema work
56
- - refactor
57
- - migration
58
- - architecture
59
- - cross-cutting scope
60
- - long prompt
61
- - multi-agent execution
62
-
63
- ### Colony coordination loop
64
-
65
- Use Colony as the primary coordination surface.
66
-
67
- On every startup, resume, follow-up, or "continue" request, run this order:
68
-
69
- 1. `mcp__colony__hivemind_context`
70
- 2. `mcp__colony__attention_inbox`
71
- 3. `mcp__colony__task_ready_for_agent`
72
- 4. `mcp__colony__search` only when prior decisions, earlier lanes, file history, or error context matter.
73
-
74
- Rules:
75
-
76
- - Use `task_ready_for_agent` to choose work.
77
- - Use `task_list` only for browsing/debugging. Do not use `task_list` as the normal work picker.
78
- - If an agent reaches for `task_list` repeatedly while choosing work, stop and call `task_ready_for_agent` instead. `task_list` is an inventory tool, not a scheduler.
79
- - Before editing files on an active task, call `task_claim_file` for each touched file.
80
- - Use `task_post` for task-thread notes, decisions, blockers, and working-state updates.
81
- - Use `task_message` / `task_messages` for directed agent-to-agent communication.
82
- - Use `get_observations` only after compact Colony tools return IDs worth hydrating.
83
-
84
- Fallback:
85
-
86
- - Colony is considered unavailable only when the MCP namespace is missing, the tool call fails, or the installed Colony server does not expose the required tool.
87
- - If `attention_inbox` or `task_ready_for_agent` is missing, fall back to `hivemind_context`, then `task_list`, then hydrate only the relevant task IDs.
88
- - Do not skip Colony just because OMX state exists. OMX is fallback, not the first coordination source.
89
- - Read `.omx/state` and `.omx/notepad.md` only when Colony is unavailable, missing the needed state, or the task explicitly depends on legacy OMX state.
90
- - Keep `.omx/notepad.md` lean: live handoffs only.
91
-
92
- ### Working-state notes
93
-
94
- Colony is preferred over generic notepad state.
95
-
96
- A working-state note should be task-scoped, searchable, and useful to another agent resuming the lane.
97
-
98
- When saving progress, use a task-scoped Colony note when possible:
99
-
100
- ```text
101
- task_post kind=note
102
- content="branch=<branch>; task=<task>; blocker=<blocker>; next=<next>; evidence=<path|command|PR|spec>"
103
- ```
104
-
105
- Use exactly these fields for handoff-style notes:
106
-
107
- - `branch`
108
- - `task`
109
- - `blocker`
110
- - `next`
111
- - `evidence`
21
+ Lightweight escape prefixes: `quick:`, `simple:`, `tiny:`, `minor:`, `small:`, `just:`, `only:`.
112
22
 
113
- Do not store long proof dumps, stale narrative, or full logs in notepads. Put bulky proof in OpenSpec artifacts, PRs, or command output.
23
+ Promote to full Guardex / OMX orchestration only when scope grows into multi-file behavior change, API/schema work, refactor, migration, architecture, cross-cutting scope, long prompt, or multi-agent execution.
114
24
 
115
- ### Token / context budget
116
-
117
- Default: less word, same proof.
25
+ ### Isolation (the load-bearing rule)
118
26
 
119
- - For prompts about `token inefficiency`, `reviewer mode`, `minimal token overhead`, or session waste patterns, switch into low-overhead mode.
120
- - Plan in at most 4 bullets.
121
- - Execute by phase.
122
- - Batch related reads and commands.
123
- - Avoid duplicate reads and interactive loops.
124
- - Keep outputs compact.
125
- - Verify once per phase.
126
- - Low output alone is not a defect. A bounded run that finishes in roughly <=10 steps is usually fine.
127
- - Low output spread across 20+ steps with rising per-turn input is fragmentation and should be treated as context growth first.
128
- - Startup / resume summaries stay tiny: `branch`, `task`, `blocker`, `next`, and `evidence`.
129
- - Front-load scaffold/path discovery into one grouped inspection pass. Avoid serial `ls` / `find` / `rg` / `cat` retries that rediscover the same path state.
130
- - Treat repeated `write_stdin`, repeated `sed` / `cat` peeks, and tiny diagnostic follow-up checks as strong negative signals.
131
- - If a session turns fragmented, collapse back to inspect once, patch once, verify once, and summarize once.
132
- - Tool / hook summaries stay tiny: command, status, last meaningful lines only. Drop routine hook boilerplate.
133
- - Keep raw terminal interaction out of long-lived context. For `write_stdin` or interactive babysitting, retain only process, action sent, current result, and next action.
134
- - Keep execution log separate from reasoning context: full commands/stdout belong in logs, while prompt context keeps only the latest 1-2 checkpoints plus the newest tool-result summary.
135
- - Treat local edit/commit, remote publish/PR, CI diagnosis, and cleanup as bounded phases.
136
- - Do not spend fresh narration or approval turns on obvious safe follow-ons inside an already authorized phase unless the risk changes.
137
-
138
- ### RTK command compression
139
-
140
- When `rtk` is available, prefer it for noisy shell discovery and verification. For file search, fff MCP takes precedence whenever available.
141
-
142
- - Files: `rtk ls .`, `rtk read <file>`, `rtk read <file> -l aggressive`, `rtk smart <file>`, `rtk find "<glob>" .`, `rtk grep "<pattern>" .`, `rtk diff <a> <b>`.
143
- - Git and GitHub: `rtk git status`, `rtk git diff`, `rtk git log -n 10`, `rtk gh pr list`, `rtk gh pr view <id>`.
144
- - Tests and builds: `rtk test <cmd>`, `rtk err <cmd>`, `rtk jest`, `rtk vitest`, `rtk playwright test`, `rtk pytest`, `rtk cargo test`, `rtk tsc`, `rtk lint`.
145
- - Runtime and data probes: `rtk docker ps`, `rtk docker logs <container>`, `rtk kubectl pods`, `rtk json <file>`, `rtk log <file>`, `rtk curl <url>`.
146
- - Savings checks: `rtk gain`, `rtk discover`, and `rtk session`.
147
- - Use `rtk proxy <command>` only when raw passthrough is required.
148
- - Do not wrap machine-readable commands with RTK when code parses stdout (`--porcelain`, `--json`, NUL-delimited output, or exact stdout contracts).
149
- - If `rtk` is missing, use raw commands and summarize only meaningful lines.
150
-
151
- ### FFF file search
152
-
153
- Use the fff MCP tools for all file search operations instead of default tools, including RTK shell wrappers.
154
-
155
- If fff MCP tools are unavailable in the current client, fall back to `rtk grep`, `rtk find`, `rtk ls`, or `rg` and keep output compact.
156
-
157
- ### Caveman style
158
-
159
- Commentary and progress updates use smart-caveman `ultra` by default:
160
-
161
- - Answer order stays fixed: answer first, cause next, fix or next step last.
162
- - drop filler
163
- - use fragments when clear
164
- - answer first
165
- - cause next
166
- - fix or next step last
167
-
168
- Keep exact literals unchanged:
169
-
170
- - code
171
- - commands
172
- - file paths
173
- - flags
174
- - env vars
175
- - URLs
176
- - numbers
177
- - timestamps
178
- - error text
179
-
180
- Switch back to `lite` or normal wording for:
181
-
182
- - security warnings
183
- - irreversible actions
184
- - privacy/compliance notes
185
- - ordered instructions where fragments may confuse
186
- - confused users
187
- - commits
188
- - PR text
189
- - specs
190
- - logs
191
- - blocker evidence
192
-
193
- Never caveman-compress commands, file paths, specs, logs, or blocker evidence.
194
-
195
- ### Isolation
196
-
197
- Every task runs on a dedicated `agent/*` branch and worktree.
198
-
199
- Start with:
27
+ Every task = one `agent/*` branch + worktree. Start with:
200
28
 
201
29
  ```bash
202
30
  gx branch start "<task>" "<agent-name>"
203
31
  ```
204
32
 
205
- Treat the base branch (`main` / `dev`) as read-only while an agent branch is active.
33
+ Then `cd` into the printed worktree path. Every subsequent git command runs from inside that worktree.
206
34
 
207
- For every new task, including follow-up work in the same chat/session, if an assigned agent sub-branch/worktree is already open, continue in that sub-branch instead of creating a fresh lane unless the user explicitly redirects scope.
208
-
209
- Never implement directly on the local/base branch checkout. Keep it unchanged and perform all edits in the agent sub-branch/worktree.
35
+ If a worktree is already open for this chat/session, **continue in it** instead of spawning a fresh lane unless the user redirects scope.
210
36
 
211
37
  ### Primary-tree lock
212
38
 
213
39
  On the primary checkout, do not run:
214
40
 
215
41
  ```bash
216
- git checkout <ref>
217
- git switch <ref>
218
- git switch -c ...
219
- git checkout -b ...
220
- git worktree add <path> <existing-agent-branch>
221
- ```
222
-
223
- Allowed on primary:
224
-
225
- ```bash
226
- git fetch
227
- git pull --ff-only
42
+ git checkout <ref> git switch <ref>
43
+ git switch -c ... git checkout -b ...
44
+ git worktree add <p> <agent-branch>
228
45
  ```
229
46
 
230
- To work on any `agent/*` branch, run `gx branch start ...` first, then `cd` into the printed worktree path and run every subsequent git command from inside that worktree.
47
+ Allowed on primary: `git fetch`, `git pull --ff-only`. Anything else needs `gx branch start` first.
231
48
 
232
- If you are about to type `git checkout agent/...` or `git switch agent/...` from the primary checkout, stop. That is the mistake that flips primary onto an agent branch.
49
+ If you are about to type `git checkout agent/...` from the primary checkout, **stop** — that is the mistake that flips primary onto an agent branch.
233
50
 
234
51
  ### Dirty-tree rule
235
52
 
236
- Finish or stash edits inside the worktree they belong to before any branch switch on primary.
53
+ Finish or stash edits inside the worktree they belong to before any branch switch on primary. The post-checkout guard may auto-stash a dirty primary tree as `guardex-auto-revert <ts> <prev>-><new>` — that is a safety net, not a workflow.
237
54
 
238
- The post-checkout guard may auto-stash a dirty primary tree as:
239
-
240
- ```text
241
- guardex-auto-revert <ts> <prev>-><new>
242
- ```
243
-
244
- That is a safety net, not a workflow. Do not rely on it routinely.
245
-
246
- Recover stashed changes with:
247
-
248
- ```bash
249
- git stash list | grep 'guardex-auto-revert'
250
- ```
55
+ Recover: `git stash list | grep 'guardex-auto-revert'`.
251
56
 
252
57
  ### Ownership
253
58
 
254
- Before editing, claim files.
255
-
256
- Preferred Colony path when on an active task:
257
-
258
- ```text
259
- mcp__colony__task_claim_file
260
- ```
261
-
262
- Guardex lock path:
59
+ Before editing, claim files:
263
60
 
264
61
  ```bash
265
62
  gx locks claim --branch "<agent-branch>" <file...>
266
63
  ```
267
64
 
268
- Before deleting, confirm the path is in your claim.
269
-
270
- Do not edit outside your scope unless reassigned.
271
-
272
- If another agent owns or recently touched nearby code:
273
-
274
- 1. read latest Colony context
275
- 2. post a handoff or question
65
+ If another agent owns nearby code:
66
+ 1. read the latest context for that lane
67
+ 2. post a handoff / question
276
68
  3. avoid reverting unrelated changes
277
69
  4. report conflicts instead of overwriting
278
70
 
279
- ### Handoff gate
280
-
281
- Before editing, post a one-line handoff note through Colony `task_post` when a task is active.
71
+ ### Handoff format
282
72
 
283
- Use `.omx/notepad.md` only when Colony is unavailable or the lane explicitly depends on legacy OMX state.
284
-
285
- Handoff shape:
73
+ When posting handoff or working-state notes (`.omx/notepad.md`, PR description, or whichever coordination surface the repo uses), use these fields:
286
74
 
287
75
  ```text
288
76
  branch=<branch>; task=<task>; blocker=<blocker>; next=<next>; evidence=<path|command|PR|spec>
289
77
  ```
290
78
 
291
- Re-read latest Colony context before replacing another agent's code.
79
+ No long proof dumps, no stale narrative, no full logs. Bulky proof goes in OpenSpec artifacts, PRs, or command output.
292
80
 
293
81
  ### Completion
294
82
 
@@ -296,59 +84,38 @@ Finish with:
296
84
 
297
85
  ```bash
298
86
  gx branch finish --branch "<agent-branch>" --via-pr --wait-for-merge --cleanup
299
- ```
300
-
301
- or:
302
-
303
- ```bash
87
+ # or:
304
88
  gx finish --all
305
89
  ```
306
90
 
307
- Task is complete only when:
91
+ Task scaffolds and manual task edits must include a final completion/cleanup section that ends with PR merge + sandbox cleanup and records PR URL + final `MERGED` evidence.
92
+
93
+ Task is complete only when **all six** are true:
308
94
 
309
- 1. changes are committed
310
- 2. branch is pushed
311
- 3. PR URL is recorded
312
- 4. PR state is `MERGED`
313
- 5. sandbox worktree is pruned
95
+ 1. changes committed
96
+ 2. branch pushed
97
+ 3. PR URL recorded
98
+ 4. PR state = `MERGED`
99
+ 5. sandbox worktree pruned
314
100
  6. final handoff records proof
315
101
 
316
- If anything blocks, append a `BLOCKED:` note and stop. Do not half-finish.
102
+ If blocked, append a `BLOCKED:` note and stop. Do not half-finish.
317
103
 
318
- OMX completion policy: when a task is done, the agent must run `gx branch finish --branch "<agent-branch>" --via-pr --wait-for-merge --cleanup` (or `gx finish --all`) instead of standalone `git push` / `gh pr` commands. The finish flow owns commit, push, PR creation/update, merge wait, and sandbox cleanup.
104
+ Use the finish flow instead of standalone `git push` / `gh pr` commands. The finish flow owns commit, push, PR creation/update, merge wait, and sandbox cleanup; standalone fallbacks strand PR / merge / cleanup state.
319
105
 
320
- External approval boundary:
106
+ ### External approval boundary
321
107
 
322
- - Guardex cannot bypass Codex host approval prompts or external-remote policy decisions.
323
- - When the host blocks a publish or finish command, request approval for the narrow `gx branch finish ...` command, or for the exact session wrapper that invokes it, and continue after approval.
324
- - Do not replace the finish flow with repeated standalone `git push` / `gh pr` attempts. That increases approval churn and can strand PR, merge, or cleanup state.
108
+ Guardex cannot bypass Codex host approval prompts or external-remote policy decisions. When the host blocks a publish or finish command, request approval for the narrow `gx branch finish ...` command, or for the exact session wrapper that invokes it, and continue after approval. Do not replace the finish flow with repeated standalone `git push` / `gh pr` attempts — that increases approval churn and can strand state.
325
109
 
326
110
  ### Parallel safety
327
111
 
328
- Assume other agents edit nearby.
329
-
330
- - Never revert unrelated changes.
331
- - Never simplify or delete critical shared paths without explicit request and regression coverage.
332
- - Report conflicts in the handoff.
333
- - Prefer compatibility-preserving changes over endpoint-specific rewrites when other agents may be changing adjacent systems.
112
+ Assume other agents edit nearby. Never revert unrelated changes. Never simplify or delete critical shared paths without explicit request + regression coverage. Prefer compatibility-preserving changes when adjacent systems may be in motion.
334
113
 
335
114
  ### Reporting
336
115
 
337
- Every completion handoff includes:
116
+ Every completion handoff includes: branch, task, files changed, behavior touched, verification commands + results, PR URL, merge state, sandbox cleanup state, risks/follow-ups.
338
117
 
339
- ```text
340
- branch
341
- task
342
- files changed
343
- behavior touched
344
- verification commands/results
345
- PR URL
346
- merge state
347
- sandbox cleanup state
348
- risks/follow-ups
349
- ```
350
-
351
- If blocked, use:
118
+ Blocked? Use:
352
119
 
353
120
  ```text
354
121
  BLOCKED:
@@ -359,89 +126,46 @@ next=<next>
359
126
  evidence=<path|command|PR|spec>
360
127
  ```
361
128
 
362
- ### Open questions
363
-
364
- If Codex/Claude hits an unresolved question, branching decision, or blocker that should survive chat, record it in:
365
-
366
- ```text
367
- openspec/plan/<plan-slug>/open-questions.md
368
- ```
369
-
370
- as an unchecked item:
371
-
372
- ```md
373
- - [ ] Question or blocker...
374
- ```
375
-
376
- Resolve it in-place when answered instead of burying it in chat-only notes.
129
+ ### Verification gates
377
130
 
378
- ### OpenSpec
131
+ Before claiming completion, run the narrowest meaningful verification (`pnpm test`, `pnpm typecheck`, `pnpm lint`, etc. — whatever fits the touched area). Do not claim green without command output evidence. If a command can't run, record command / reason / risk / next.
379
132
 
380
- OpenSpec is the source of truth for change-driven repo work.
133
+ ### Open questions
381
134
 
382
- For change-driven tasks, keep:
135
+ Persist unresolved questions or blockers into `openspec/plan/<plan-slug>/open-questions.md` as unchecked items. Resolve in-place rather than burying in chat.
383
136
 
384
- ```text
385
- openspec/changes/<slug>/tasks.md
386
- ```
137
+ ### Optional companion tooling (use if installed)
387
138
 
388
- current during work, not batched at the end.
139
+ - **fff MCP** (file search): prefer for all file search; fall back to `rtk grep`/`rtk find` or `rg`.
140
+ - **rtk** (shell compression): wrap noisy discovery (`rtk ls`/`grep`/`find`/`read`), git/gh (`rtk git status`/`gh pr list`), and verification (`rtk tsc`/`lint`/`test`). Do **not** wrap machine-readable commands (`--porcelain`, `--json`, exact stdout contracts).
141
+ - **OpenSpec**: keep `openspec/changes/<slug>/tasks.md` current during work, not batched. Validate with `openspec validate --specs` before archive.
389
142
 
390
- Task scaffolds and manual task edits must include a final completion/cleanup section that ends with PR merge + sandbox cleanup and records PR URL + final `MERGED` evidence.
143
+ ### Token / context budget
391
144
 
392
- Validate specs before archive:
145
+ Default: less word, same proof.
393
146
 
394
- ```bash
395
- openspec validate --specs
396
- ```
147
+ - Plan in ≤4 bullets, execute by phase, batch reads/commands.
148
+ - Verify once per phase. A bounded ≤10-step run is fine.
149
+ - 20+ steps with rising per-turn input = fragmentation → collapse to inspect once, patch once, verify once, summarize once.
150
+ - Startup/resume summaries stay tiny: `branch`, `task`, `blocker`, `next`, `evidence`.
151
+ - Keep raw terminal interaction out of long-lived context: retain only process, action sent, current result, next action.
152
+ - Full commands/stdout belong in logs; prompt context keeps only the latest 1–2 checkpoints plus the newest tool-result summary.
397
153
 
398
- Never archive unverified work.
154
+ ### Multi-agent token efficiency
399
155
 
400
- For `T0` / small `T1` lanes, use the compact Colony spec path when available. One Colony handoff plus `colony-spec.md` is enough. Do not create proposal/spec/tasks unless the task grows.
156
+ Fan-out saves tokens only when each agent has a narrow job and returns a compact result. When reviewing or implementing here:
401
157
 
402
- For `T2` / `T3` lanes, keep proposal, spec, design, and tasks live while implementing.
158
+ - **Scout, then implement.** A cheap-model subagent locates the 3-5 files that matter and returns a summary; edit those inline. Don't read 20+ files in the main context to find the 4 that count.
159
+ - **One agent, one job.** Each subagent gets a single objective and returns one output (analyze OR fix), not a muddle of both.
160
+ - **Review by parallel role.** Run correctness / security / consistency reviewers in parallel and synthesize — cheaper and sharper than one reviewer holding the whole diff. The finish review-gate is the place for it.
161
+ - **Route models to task weight.** scan/explore/draft → cheap (e.g. `haiku`); implement/debug → mid (`sonnet`); architecture/complex review → top (`opus`). `CLAUDE_CODE_SUBAGENT_MODEL` sets the subagent tier.
162
+ - **Don't fan out trivial work.** One-file tweaks and bounded edits stay direct (see Task-size routing) — a subagent's setup cost only pays off on a wide read or review surface.
403
163
 
404
164
  ### Version bumps
405
165
 
406
- If a change bumps a published version, the same PR records release notes in the appropriate OpenSpec artifact or release-note mechanism for the repo.
407
-
408
- Do not edit `CHANGELOG.md` directly unless the repo explicitly requires manual changelog edits.
409
-
410
- ### Verification gates
411
-
412
- Before claiming completion, run the narrowest meaningful verification for the touched area.
413
-
414
- Examples:
415
-
416
- ```bash
417
- pnpm test
418
- pnpm typecheck
419
- pnpm lint
420
- ```
421
-
422
- If a command cannot run, record:
423
-
424
- ```text
425
- command
426
- reason it could not run
427
- risk
428
- next
429
- ```
430
-
431
- Do not claim green verification without command output evidence.
166
+ If a change bumps a published version, the same PR records release notes in the appropriate OpenSpec artifact or release-note mechanism for the repo. Do not edit `CHANGELOG.md` directly unless the repo explicitly requires manual changelog edits.
432
167
 
433
168
  ### What not to put in this file
434
169
 
435
- Do not embed:
436
-
437
- - stale memory dumps
438
- - PR transcripts
439
- - long logs
440
- - generated status snapshots
441
- - session history
442
- - full OpenSpec examples
443
- - repeated copies of long workflow docs
444
-
445
- Keep this section as the hard multi-agent contract. Put long examples and recovery docs in repo-specific workflow docs.
446
-
170
+ No stale memory dumps, PR transcripts, long logs, generated status snapshots, session history, full OpenSpec examples, or duplicate workflow docs. This block is the hard contract — long examples and recovery docs live in repo-specific workflow files.
447
171
  <!-- multiagent-safety:END -->
@@ -0,0 +1,11 @@
1
+ <!-- multiagent-safety:START -->
2
+ ## Multi-Agent Safety (minimal)
3
+
4
+ Guardex is enabled by default. Disable via repo-root `.env` with `GUARDEX_ON=0`.
5
+
6
+ - Work from an `agent/*` branch + worktree — never edit the protected base (`main`/`dev`) directly. Start with `gx branch start "<task>" "<agent-name>"`, then `cd` into the printed worktree.
7
+ - Claim files before editing: `gx locks claim --branch "<agent-branch>" <file...>`.
8
+ - Finish completed work via PR + cleanup: `gx branch finish --branch "<agent-branch>" --via-pr --wait-for-merge --cleanup` (or `gx finish --all`).
9
+
10
+ Want the full multi-agent contract (Colony coordination, OpenSpec, token discipline, recovery)? Run `gx setup --contract`.
11
+ <!-- multiagent-safety:END -->
@@ -0,0 +1,82 @@
1
+ ---
2
+ name: gx-act
3
+ description: "Run GitHub Actions workflows locally with nektos/act before pushing, so CI failures are caught on the laptop and the PR can be squash-merged on the first remote run."
4
+ ---
5
+
6
+ # gx-act — local GitHub Actions
7
+
8
+ Use whenever a change touches code that would trigger CI on GitHub. Run the workflows locally with `act` first; only push the branch when the local run is green, then squash-merge the PR on GitHub.
9
+
10
+ ## When to invoke
11
+
12
+ - Before `gx pr open` / `gx pr sync` / `gx branch finish --via-pr`.
13
+ - Before re-pushing after a CI failure.
14
+ - When iterating on `.github/workflows/*.yml` itself.
15
+
16
+ ## Install `act`
17
+
18
+ `act` requires Docker (or Podman). Check the binary:
19
+
20
+ ```sh
21
+ command -v act || echo "act not installed"
22
+ ```
23
+
24
+ Install one way:
25
+
26
+ ```sh
27
+ # Linux/macOS via the upstream installer
28
+ curl -fsSL https://raw.githubusercontent.com/nektos/act/master/install.sh | bash -s -- -b "$HOME/.local/bin"
29
+
30
+ # macOS via Homebrew
31
+ brew install act
32
+
33
+ # Arch
34
+ sudo pacman -S act
35
+
36
+ # Or use the GitHub CLI extension
37
+ gh extension install https://github.com/nektos/gh-act
38
+ ```
39
+
40
+ Upstream: https://github.com/nektos/act
41
+
42
+ ## Quick commands
43
+
44
+ ```sh
45
+ # List jobs the local runner would execute for the push event
46
+ act -l
47
+
48
+ # Run the default push workflows (what GitHub runs on a normal push)
49
+ act push
50
+
51
+ # Run a specific event
52
+ act pull_request
53
+ act workflow_dispatch -W .github/workflows/release.yml
54
+
55
+ # Run a single job
56
+ act -j test
57
+
58
+ # Pin a runner image (medium is the act default; large matches real GH closer)
59
+ act -P ubuntu-latest=catthehacker/ubuntu:act-latest
60
+
61
+ # Pass secrets / env without committing them
62
+ act -s GITHUB_TOKEN="$GITHUB_TOKEN" --env-file .env.act
63
+
64
+ # Reuse containers between runs (faster iteration)
65
+ act --reuse
66
+ ```
67
+
68
+ ## Workflow (local CI → squash-merge on GitHub)
69
+
70
+ 1. Implement the change in the agent worktree.
71
+ 2. `act -l` to confirm which jobs will fire for the event you care about.
72
+ 3. `act push` (or the specific event/job) until it is green locally.
73
+ 4. `gx branch finish --branch "<agent-branch>" --base main --via-pr --wait-for-merge --cleanup`.
74
+ - Or `gx pr open` then `gx pr sync --auto-merge --merge-strategy squash` for explicit PR control.
75
+ 5. On GitHub: squash-merge once the remote run mirrors the local one.
76
+
77
+ ## Notes
78
+
79
+ - `act` does not reproduce GitHub-hosted services exactly (no real secrets, different runner image, no concurrency groups). Treat a green `act` run as a strong signal, not a proof — the remote run is still authoritative.
80
+ - Keep `act` config in `.actrc` at the repo root so every agent uses the same runner image.
81
+ - If a workflow uses `GITHUB_TOKEN` for API calls, pass a PAT via `-s GITHUB_TOKEN=...`; do not commit it.
82
+ - Add `.actrc`, `.cache/act`, and any `act`-specific event payloads to `.gitignore` if they appear.