@imdeadpool/guardex 7.0.43 → 7.1.0

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 (63) hide show
  1. package/README.md +26 -0
  2. package/package.json +2 -1
  3. package/skills/gx-act/SKILL.md +82 -0
  4. package/src/agents/inspect.js +17 -4
  5. package/src/agents/launch.js +10 -1
  6. package/src/agents/status.js +9 -6
  7. package/src/budget/index.js +2 -1
  8. package/src/cli/args.js +52 -2
  9. package/src/cli/commands/agents.js +364 -0
  10. package/src/cli/commands/bootstrap.js +92 -0
  11. package/src/cli/commands/branch.js +127 -0
  12. package/src/cli/commands/claude.js +674 -0
  13. package/src/cli/commands/doctor.js +268 -0
  14. package/src/cli/commands/finish.js +26 -0
  15. package/src/cli/commands/mcp.js +122 -0
  16. package/src/cli/commands/misc.js +304 -0
  17. package/src/cli/commands/pr.js +439 -0
  18. package/src/cli/commands/prompt.js +92 -0
  19. package/src/cli/commands/release.js +305 -0
  20. package/src/cli/commands/report.js +244 -0
  21. package/src/cli/commands/review.js +32 -0
  22. package/src/cli/commands/setup.js +242 -0
  23. package/src/cli/commands/status.js +338 -0
  24. package/src/cli/commands/watch.js +234 -0
  25. package/src/cli/main.js +68 -3726
  26. package/src/cli/shared/repo-env.js +161 -0
  27. package/src/cli/shared/sandbox.js +417 -0
  28. package/src/cli/shared/scaffolding.js +535 -0
  29. package/src/cli/shared/toolchain-shims.js +420 -0
  30. package/src/context.js +229 -11
  31. package/src/core/runtime.js +6 -1
  32. package/src/doctor/index.js +42 -13
  33. package/src/finish/index.js +147 -5
  34. package/src/finish/preflight.js +177 -0
  35. package/src/finish/review-gate.js +182 -0
  36. package/src/git/index.js +446 -4
  37. package/src/hooks/index.js +0 -64
  38. package/src/mcp/collect.js +370 -0
  39. package/src/mcp/server.js +157 -0
  40. package/src/output/index.js +67 -1
  41. package/src/pr-review.js +23 -0
  42. package/src/pr.js +381 -0
  43. package/src/sandbox/index.js +13 -2
  44. package/src/scaffold/agent-worktree-prep.js +213 -0
  45. package/src/scaffold/index.js +108 -10
  46. package/src/speckit/index.js +226 -0
  47. package/src/terminal/index.js +1 -76
  48. package/src/terminal/tmux.js +0 -1
  49. package/src/toolchain/index.js +20 -0
  50. package/templates/AGENTS.monorepo-apps.md +26 -0
  51. package/templates/AGENTS.multiagent-safety.md +61 -347
  52. package/templates/AGENTS.multiagent-safety.min.md +11 -0
  53. package/templates/codex/skills/gx-act/SKILL.md +82 -0
  54. package/templates/githooks/pre-commit +22 -19
  55. package/templates/scripts/agent-branch-finish.sh +8 -30
  56. package/templates/scripts/agent-branch-merge.sh +4 -1
  57. package/templates/scripts/agent-branch-start.sh +88 -3
  58. package/templates/scripts/agent-preflight.sh +31 -5
  59. package/templates/scripts/agent-worktree-prune.sh +1 -1
  60. package/templates/scripts/codex-agent.sh +0 -91
  61. package/src/agents/detect.js +0 -160
  62. package/src/cockpit/keybindings.js +0 -224
  63. 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
21
+ Lightweight escape prefixes: `quick:`, `simple:`, `tiny:`, `minor:`, `small:`, `just:`, `only:`.
64
22
 
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
- ```
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.
104
24
 
105
- Use exactly these fields for handoff-style notes:
25
+ ### Isolation (the load-bearing rule)
106
26
 
107
- - `branch`
108
- - `task`
109
- - `blocker`
110
- - `next`
111
- - `evidence`
112
-
113
- Do not store long proof dumps, stale narrative, or full logs in notepads. Put bulky proof in OpenSpec artifacts, PRs, or command output.
114
-
115
- ### Token / context budget
116
-
117
- Default: less word, same proof.
118
-
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.
206
-
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.
33
+ Then `cd` into the printed worktree path. Every subsequent git command runs from inside that worktree.
208
34
 
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>
42
+ git checkout <ref> git switch <ref>
43
+ git switch -c ... git checkout -b ...
44
+ git worktree add <p> <agent-branch>
221
45
  ```
222
46
 
223
- Allowed on primary:
47
+ Allowed on primary: `git fetch`, `git pull --ff-only`. Anything else needs `gx branch start` first.
224
48
 
225
- ```bash
226
- git fetch
227
- git pull --ff-only
228
- ```
229
-
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.
231
-
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.
282
-
283
- Use `.omx/notepad.md` only when Colony is unavailable or the lane explicitly depends on legacy OMX state.
71
+ ### Handoff format
284
72
 
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:
338
-
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
- ```
116
+ Every completion handoff includes: branch, task, files changed, behavior touched, verification commands + results, PR URL, merge state, sandbox cleanup state, risks/follow-ups.
350
117
 
351
- If blocked, use:
118
+ Blocked? Use:
352
119
 
353
120
  ```text
354
121
  BLOCKED:
@@ -359,89 +126,36 @@ 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.
377
-
378
- ### OpenSpec
379
-
380
- OpenSpec is the source of truth for change-driven repo work.
381
-
382
- For change-driven tasks, keep:
129
+ ### Verification gates
383
130
 
384
- ```text
385
- openspec/changes/<slug>/tasks.md
386
- ```
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.
387
132
 
388
- current during work, not batched at the end.
133
+ ### Open questions
389
134
 
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.
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.
391
136
 
392
- Validate specs before archive:
137
+ ### Optional companion tooling (use if installed)
393
138
 
394
- ```bash
395
- openspec validate --specs
396
- ```
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.
397
142
 
398
- Never archive unverified work.
143
+ ### Token / context budget
399
144
 
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.
145
+ Default: less word, same proof.
401
146
 
402
- For `T2` / `T3` lanes, keep proposal, spec, design, and tasks live while implementing.
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.
403
153
 
404
154
  ### Version bumps
405
155
 
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.
156
+ 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
157
 
433
158
  ### What not to put in this file
434
159
 
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
-
160
+ 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
161
  <!-- 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.
@@ -108,6 +108,18 @@ case "$codex_require_agent_branch" in
108
108
  *) should_require_codex_agent_branch=1 ;;
109
109
  esac
110
110
 
111
+ # General lockdown knob (applies to ALL agent sessions, not just Codex).
112
+ # Default OFF: any branch that is not a protected base is an acceptable agent
113
+ # branch, so `vendor/x`, `feat/y`, or any ad-hoc name commits without ceremony.
114
+ # Set GUARDEX_REQUIRE_AGENT_BRANCH=1 (or `git config multiagent.requireAgentBranch
115
+ # true`) to force agent commits back onto the agent/* namespace.
116
+ require_agent_branch_raw="${GUARDEX_REQUIRE_AGENT_BRANCH:-$(git config --get multiagent.requireAgentBranch || true)}"
117
+ require_agent_branch="$(printf '%s' "$require_agent_branch_raw" | tr '[:upper:]' '[:lower:]')"
118
+ should_require_agent_branch=0
119
+ case "$require_agent_branch" in
120
+ 1|true|yes|on) should_require_agent_branch=1 ;;
121
+ esac
122
+
111
123
  is_codex_managed_only_commit_on_protected=0
112
124
  if [[ "$is_codex_session" == "1" && "$is_protected_branch" == "1" ]]; then
113
125
  deleted_paths="$(git diff --cached --name-only --diff-filter=D)"
@@ -138,8 +150,6 @@ if [[ "$should_require_codex_agent_branch" == "1" && "${GUARDEX_ALLOW_CODEX_ON_N
138
150
  GitGuardex requires Codex work to run from an isolated agent/* branch.
139
151
  Start the sub-branch/worktree with:
140
152
  gx branch start "<task-or-plan>" "<agent-name>"
141
- Or manually:
142
- gx branch start "<task-or-plan>" "<agent-name>"
143
153
  Then commit from the created agent/* branch.
144
154
 
145
155
  Temporary bypass (not recommended):
@@ -147,19 +157,10 @@ Temporary bypass (not recommended):
147
157
  MSG
148
158
  exit 1
149
159
  fi
150
-
151
- cat >&2 <<'MSG'
152
- [codex-branch-guard] Codex agent commit blocked on non-agent branch.
153
- Use isolated branch/worktree first:
154
- gx branch start "<task-or-plan>" "<agent-name>"
155
- Then commit from the created agent/* branch.
156
-
157
- Temporary bypass (not recommended):
158
- GUARDEX_ALLOW_CODEX_ON_NON_AGENT=1 git commit ...
159
- Disable this rule for a repo (not recommended):
160
- git config multiagent.codexRequireAgentBranch false
161
- MSG
162
- exit 1
160
+ # Non-protected branches (vendor/, feat/, any ad-hoc name) are fine for
161
+ # Codex too — being OFF a protected base is the only load-bearing rule.
162
+ # Re-impose the agent/* requirement with GUARDEX_REQUIRE_AGENT_BRANCH=1
163
+ # (handled by the general lockdown gate below).
163
164
  fi
164
165
  fi
165
166
 
@@ -192,15 +193,17 @@ MSG
192
193
  exit 1
193
194
  fi
194
195
 
195
- if [[ "$is_agent_session" == "1" && "$branch" != agent/* ]]; then
196
+ if [[ "$is_agent_session" == "1" && "$branch" != agent/* && "$should_require_agent_branch" == "1" ]]; then
196
197
  cat >&2 <<'MSG'
197
- [agent-branch-guard] Agent commits must run on dedicated agent/* branches.
198
+ [agent-branch-guard] Lockdown mode: agent commits must run on dedicated agent/* branches.
199
+ GUARDEX_REQUIRE_AGENT_BRANCH (or multiagent.requireAgentBranch) is enabled.
198
200
  Start an agent branch first:
199
201
  gx branch start "<task-or-plan>" "<agent-name>"
200
202
  Then commit on that branch.
201
203
 
202
- Temporary bypass (not recommended):
203
- ALLOW_COMMIT_ON_PROTECTED_BRANCH=1 git commit ...
204
+ Relax (any non-protected branch is normally fine):
205
+ unset GUARDEX_REQUIRE_AGENT_BRANCH
206
+ # or: git config multiagent.requireAgentBranch false
204
207
  MSG
205
208
  exit 1
206
209
  fi