@cluesmith/codev 3.2.2 → 3.2.4

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 (175) hide show
  1. package/dashboard-dist/assets/index-BZ1x7x1X.js.map +1 -1
  2. package/dist/agent-farm/cli.d.ts.map +1 -1
  3. package/dist/agent-farm/cli.js +31 -0
  4. package/dist/agent-farm/cli.js.map +1 -1
  5. package/dist/agent-farm/commands/attach.js +2 -2
  6. package/dist/agent-farm/commands/attach.js.map +1 -1
  7. package/dist/agent-farm/commands/send.d.ts +2 -2
  8. package/dist/agent-farm/commands/send.js +3 -3
  9. package/dist/agent-farm/commands/send.js.map +1 -1
  10. package/dist/agent-farm/commands/setup.d.ts +4 -1
  11. package/dist/agent-farm/commands/setup.d.ts.map +1 -1
  12. package/dist/agent-farm/commands/setup.js +8 -4
  13. package/dist/agent-farm/commands/setup.js.map +1 -1
  14. package/dist/agent-farm/commands/spawn-worktree.d.ts +11 -0
  15. package/dist/agent-farm/commands/spawn-worktree.d.ts.map +1 -1
  16. package/dist/agent-farm/commands/spawn-worktree.js +64 -16
  17. package/dist/agent-farm/commands/spawn-worktree.js.map +1 -1
  18. package/dist/agent-farm/commands/status.d.ts.map +1 -1
  19. package/dist/agent-farm/commands/status.js +26 -2
  20. package/dist/agent-farm/commands/status.js.map +1 -1
  21. package/dist/agent-farm/commands/tower-sweep-husks.d.ts +6 -0
  22. package/dist/agent-farm/commands/tower-sweep-husks.d.ts.map +1 -0
  23. package/dist/agent-farm/commands/tower-sweep-husks.js +77 -0
  24. package/dist/agent-farm/commands/tower-sweep-husks.js.map +1 -0
  25. package/dist/agent-farm/commands/tower.d.ts.map +1 -1
  26. package/dist/agent-farm/commands/tower.js +34 -0
  27. package/dist/agent-farm/commands/tower.js.map +1 -1
  28. package/dist/agent-farm/commands/whoami.d.ts +65 -0
  29. package/dist/agent-farm/commands/whoami.d.ts.map +1 -0
  30. package/dist/agent-farm/commands/whoami.js +196 -0
  31. package/dist/agent-farm/commands/whoami.js.map +1 -0
  32. package/dist/agent-farm/commands/workspace-recover.d.ts +31 -0
  33. package/dist/agent-farm/commands/workspace-recover.d.ts.map +1 -1
  34. package/dist/agent-farm/commands/workspace-recover.js +70 -30
  35. package/dist/agent-farm/commands/workspace-recover.js.map +1 -1
  36. package/dist/agent-farm/db/index.d.ts.map +1 -1
  37. package/dist/agent-farm/db/index.js +8 -2
  38. package/dist/agent-farm/db/index.js.map +1 -1
  39. package/dist/agent-farm/lib/tower-client.d.ts +1 -1
  40. package/dist/agent-farm/lib/tower-client.d.ts.map +1 -1
  41. package/dist/agent-farm/lib/tower-client.js.map +1 -1
  42. package/dist/agent-farm/servers/architect-session-holder.d.ts +133 -0
  43. package/dist/agent-farm/servers/architect-session-holder.d.ts.map +1 -0
  44. package/dist/agent-farm/servers/architect-session-holder.js +268 -0
  45. package/dist/agent-farm/servers/architect-session-holder.js.map +1 -0
  46. package/dist/agent-farm/servers/process-census.d.ts +41 -0
  47. package/dist/agent-farm/servers/process-census.d.ts.map +1 -0
  48. package/dist/agent-farm/servers/process-census.js +62 -0
  49. package/dist/agent-farm/servers/process-census.js.map +1 -0
  50. package/dist/agent-farm/servers/send-buffer.d.ts.map +1 -1
  51. package/dist/agent-farm/servers/send-buffer.js +13 -0
  52. package/dist/agent-farm/servers/send-buffer.js.map +1 -1
  53. package/dist/agent-farm/servers/session-log-sweep.d.ts +93 -0
  54. package/dist/agent-farm/servers/session-log-sweep.d.ts.map +1 -0
  55. package/dist/agent-farm/servers/session-log-sweep.js +165 -0
  56. package/dist/agent-farm/servers/session-log-sweep.js.map +1 -0
  57. package/dist/agent-farm/servers/shellper-husk-sweep.d.ts +87 -0
  58. package/dist/agent-farm/servers/shellper-husk-sweep.d.ts.map +1 -0
  59. package/dist/agent-farm/servers/shellper-husk-sweep.js +129 -0
  60. package/dist/agent-farm/servers/shellper-husk-sweep.js.map +1 -0
  61. package/dist/agent-farm/servers/tower-instances.d.ts.map +1 -1
  62. package/dist/agent-farm/servers/tower-instances.js +203 -36
  63. package/dist/agent-farm/servers/tower-instances.js.map +1 -1
  64. package/dist/agent-farm/servers/tower-routes.d.ts.map +1 -1
  65. package/dist/agent-farm/servers/tower-routes.js +147 -4
  66. package/dist/agent-farm/servers/tower-routes.js.map +1 -1
  67. package/dist/agent-farm/servers/tower-server.js +95 -1
  68. package/dist/agent-farm/servers/tower-server.js.map +1 -1
  69. package/dist/agent-farm/servers/tower-terminals.d.ts.map +1 -1
  70. package/dist/agent-farm/servers/tower-terminals.js +66 -8
  71. package/dist/agent-farm/servers/tower-terminals.js.map +1 -1
  72. package/dist/agent-farm/servers/tower-utils.d.ts +106 -4
  73. package/dist/agent-farm/servers/tower-utils.d.ts.map +1 -1
  74. package/dist/agent-farm/servers/tower-utils.js +155 -19
  75. package/dist/agent-farm/servers/tower-utils.js.map +1 -1
  76. package/dist/agent-farm/state.d.ts +13 -1
  77. package/dist/agent-farm/state.d.ts.map +1 -1
  78. package/dist/agent-farm/state.js +17 -2
  79. package/dist/agent-farm/state.js.map +1 -1
  80. package/dist/agent-farm/utils/claude-session-discovery.d.ts +12 -0
  81. package/dist/agent-farm/utils/claude-session-discovery.d.ts.map +1 -1
  82. package/dist/agent-farm/utils/claude-session-discovery.js +42 -4
  83. package/dist/agent-farm/utils/claude-session-discovery.js.map +1 -1
  84. package/dist/agent-farm/utils/harness.d.ts +15 -3
  85. package/dist/agent-farm/utils/harness.d.ts.map +1 -1
  86. package/dist/agent-farm/utils/harness.js +4 -1
  87. package/dist/agent-farm/utils/harness.js.map +1 -1
  88. package/dist/commands/adopt.d.ts +3 -2
  89. package/dist/commands/adopt.d.ts.map +1 -1
  90. package/dist/commands/adopt.js +7 -6
  91. package/dist/commands/adopt.js.map +1 -1
  92. package/dist/commands/consult/agy-auth-cache.d.ts +97 -0
  93. package/dist/commands/consult/agy-auth-cache.d.ts.map +1 -0
  94. package/dist/commands/consult/agy-auth-cache.js +320 -0
  95. package/dist/commands/consult/agy-auth-cache.js.map +1 -0
  96. package/dist/commands/consult/index.d.ts.map +1 -1
  97. package/dist/commands/consult/index.js +59 -0
  98. package/dist/commands/consult/index.js.map +1 -1
  99. package/dist/commands/doctor.d.ts +28 -0
  100. package/dist/commands/doctor.d.ts.map +1 -1
  101. package/dist/commands/doctor.js +187 -3
  102. package/dist/commands/doctor.js.map +1 -1
  103. package/dist/commands/init.d.ts +3 -2
  104. package/dist/commands/init.d.ts.map +1 -1
  105. package/dist/commands/init.js +7 -6
  106. package/dist/commands/init.js.map +1 -1
  107. package/dist/commands/porch/index.d.ts.map +1 -1
  108. package/dist/commands/porch/index.js +11 -8
  109. package/dist/commands/porch/index.js.map +1 -1
  110. package/dist/commands/update.d.ts +4 -4
  111. package/dist/commands/update.d.ts.map +1 -1
  112. package/dist/commands/update.js +9 -11
  113. package/dist/commands/update.js.map +1 -1
  114. package/dist/lib/config.d.ts +1 -0
  115. package/dist/lib/config.d.ts.map +1 -1
  116. package/dist/lib/config.js.map +1 -1
  117. package/dist/lib/default-branch.d.ts +1 -1
  118. package/dist/lib/default-branch.js +1 -1
  119. package/dist/lib/gitignore.d.ts +25 -2
  120. package/dist/lib/gitignore.d.ts.map +1 -1
  121. package/dist/lib/gitignore.js +70 -0
  122. package/dist/lib/gitignore.js.map +1 -1
  123. package/dist/lib/migration-backup-audit.d.ts +64 -0
  124. package/dist/lib/migration-backup-audit.d.ts.map +1 -0
  125. package/dist/lib/migration-backup-audit.js +145 -0
  126. package/dist/lib/migration-backup-audit.js.map +1 -0
  127. package/dist/lib/protocol-drift-audit.d.ts +118 -0
  128. package/dist/lib/protocol-drift-audit.d.ts.map +1 -0
  129. package/dist/lib/protocol-drift-audit.js +217 -0
  130. package/dist/lib/protocol-drift-audit.js.map +1 -0
  131. package/dist/lib/scaffold.d.ts +10 -3
  132. package/dist/lib/scaffold.d.ts.map +1 -1
  133. package/dist/lib/scaffold.js +29 -26
  134. package/dist/lib/scaffold.js.map +1 -1
  135. package/dist/terminal/pty-manager.d.ts +7 -0
  136. package/dist/terminal/pty-manager.d.ts.map +1 -1
  137. package/dist/terminal/pty-manager.js +16 -0
  138. package/dist/terminal/pty-manager.js.map +1 -1
  139. package/dist/terminal/pty-session.d.ts +25 -4
  140. package/dist/terminal/pty-session.d.ts.map +1 -1
  141. package/dist/terminal/pty-session.js +83 -11
  142. package/dist/terminal/pty-session.js.map +1 -1
  143. package/dist/terminal/session-manager.d.ts +109 -0
  144. package/dist/terminal/session-manager.d.ts.map +1 -1
  145. package/dist/terminal/session-manager.js +314 -45
  146. package/dist/terminal/session-manager.js.map +1 -1
  147. package/dist/terminal/shellper-client.d.ts +19 -4
  148. package/dist/terminal/shellper-client.d.ts.map +1 -1
  149. package/dist/terminal/shellper-client.js +70 -8
  150. package/dist/terminal/shellper-client.js.map +1 -1
  151. package/dist/terminal/shellper-process.d.ts.map +1 -1
  152. package/dist/terminal/shellper-process.js +20 -5
  153. package/dist/terminal/shellper-process.js.map +1 -1
  154. package/dist/terminal/shellper-protocol.d.ts +40 -2
  155. package/dist/terminal/shellper-protocol.d.ts.map +1 -1
  156. package/dist/terminal/shellper-protocol.js +72 -5
  157. package/dist/terminal/shellper-protocol.js.map +1 -1
  158. package/package.json +8 -8
  159. package/skeleton/.claude/skills/afx/SKILL.md +13 -0
  160. package/skeleton/.claude/skills/arch-init/SKILL.md +122 -0
  161. package/skeleton/.claude/skills/codev/SKILL.md +2 -2
  162. package/skeleton/.codex/skills/afx/SKILL.md +157 -0
  163. package/skeleton/.codex/skills/arch-init/SKILL.md +122 -0
  164. package/skeleton/.codex/skills/codev/SKILL.md +59 -0
  165. package/skeleton/.codex/skills/consult/SKILL.md +96 -0
  166. package/skeleton/.codex/skills/generate-image/SKILL.md +45 -0
  167. package/skeleton/.codex/skills/porch/SKILL.md +60 -0
  168. package/skeleton/.codex/skills/update-arch-docs/SKILL.md +132 -0
  169. package/skeleton/protocols/pir/prompts/implement.md +1 -1
  170. package/skeleton/protocols/pir/prompts/review.md +1 -1
  171. package/skeleton/protocols/pir/protocol.md +3 -3
  172. package/skeleton/resources/commands/agent-farm.md +89 -0
  173. package/skeleton/resources/commands/codev.md +5 -0
  174. package/skeleton/resources/commands/consult.md +26 -0
  175. package/skeleton/roles/architect.md +11 -0
@@ -0,0 +1,60 @@
1
+ ---
2
+ name: porch
3
+ description: Protocol orchestrator CLI — drives SPIR, ASPIR, AIR, and BUGFIX protocols via a state machine. ALWAYS check this skill before running any `porch` command. Use when you need to check project status, approve gates, signal phase completion, or manage protocol state. Also use when a builder asks about gate approvals or phase transitions.
4
+ ---
5
+
6
+ # porch - Protocol Orchestrator
7
+
8
+ Porch manages the state machine behind development protocols. It tracks phases, gates, consultations, and transitions.
9
+
10
+ ## Commands
11
+
12
+ ```
13
+ porch status [id] Show current project state and phase
14
+ porch run [id] Run the protocol loop (strict mode)
15
+ porch next [id] Get next tasks as JSON
16
+ porch done [id] Signal current phase is complete
17
+ porch check [id] Run checks for current phase
18
+ porch gate [id] Request human approval at a gate
19
+ porch approve <id> <gate> --a-human-explicitly-approved-this
20
+ porch rollback <id> <phase> Rewind to an earlier phase
21
+ porch init <protocol> <id> <name> Initialize a new project
22
+ ```
23
+
24
+ Project ID auto-detects from worktree path when inside a builder worktree.
25
+
26
+ ## Gate approvals
27
+
28
+ Gates are human-only approval checkpoints. The `--a-human-explicitly-approved-this` flag is **required** — it exists to prevent AI agents from auto-approving.
29
+
30
+ | Gate | Protocol | When |
31
+ |------|----------|------|
32
+ | `spec-approval` | SPIR | After spec is written |
33
+ | `plan-approval` | SPIR | After plan is written |
34
+ | `pr` | SPIR, AIR | After PR is created |
35
+
36
+ ```bash
37
+ porch approve 42 spec-approval --a-human-explicitly-approved-this
38
+ porch approve 42 plan-approval --a-human-explicitly-approved-this
39
+ porch approve 42 pr --a-human-explicitly-approved-this
40
+ ```
41
+
42
+ **ASPIR and BUGFIX have no spec/plan gates** — they run autonomously through those phases.
43
+
44
+ ## Checking pending gates
45
+
46
+ ```bash
47
+ porch pending # List all gates waiting for approval
48
+ ```
49
+
50
+ ## Critical rules
51
+
52
+ - **Builders must NEVER call `porch approve`** — only humans approve gates
53
+ - **Never edit `status.yaml` directly** — porch manages all state
54
+ - Builders signal completion with `porch done`, not `porch approve`
55
+ - `porch run` is for strict mode only — soft mode builders follow the protocol document manually
56
+ - When running `porch approve` from the architect, use a subshell if you need worktree context: `(cd /path/to/worktree && porch approve ...)`
57
+
58
+ ## State storage
59
+
60
+ Project state lives in `codev/projects/<id>-<name>/status.yaml`, managed automatically by porch. The status file tracks current phase, gate states, consultation results, and timestamps.
@@ -0,0 +1,132 @@
1
+ ---
2
+ name: update-arch-docs
3
+ description: "Audit, prune, and update the project's governance docs — the COLD reference archives `codev/resources/arch.md` and `codev/resources/lessons-learned.md` AND their always-on HOT companions `codev/resources/arch-critical.md` and `codev/resources/lessons-critical.md` (Spec 987, hot/cold two-tier model). Use this skill when running MAINTAIN's arch-doc step, or when asked to update / audit / prune any of those four files. It polices the hot-tier cap (capped facts/lessons + a bounded cold-doc map), enforces displacement (demote to cold when full), keeps each hot file's map accurate, and is opinionated about what NOT to put in each tier (per-spec changelogs, exhaustive enumerations, aspirational state). Two modes: diff-mode (apply a specific change) and audit-mode (propose cuts with reasons). Edits files directly via normal file-edit tooling; no destructive shell commands."
4
+ ---
5
+
6
+ # update-arch-docs
7
+
8
+ This skill maintains the project's governance docs, each split into **two tiers** (Spec 987):
9
+
10
+ - **COLD reference archives** — `codev/resources/arch.md` (architecture) and `codev/resources/lessons-learned.md` (durable wisdom). Full, on-demand; grepped/read for depth.
11
+ - **HOT always-on companions** — `codev/resources/arch-critical.md` and `codev/resources/lessons-critical.md`. Tiny, **hard-capped**, **always injected** into every porch prompt and into CLAUDE.md/AGENTS.md. Each holds capped facts/lessons **plus a bounded "consult when…" map** of its cold doc's top-level topics.
12
+
13
+ It is invoked by the MAINTAIN protocol's documentation step, and ad-hoc whenever someone updates, audits, or prunes any of these files. The skill is opinionated about *what does not belong* in each tier and **polices the hot-tier cap, displacement, and map accuracy**. Use it whenever a doc change touches any of the four files.
14
+
15
+ ## What this skill does NOT do
16
+
17
+ These are the patterns that have, in practice, caused arch.md and lessons-learned.md to grow without bound. Treat them as bright-line rejections during both audit-mode and diff-mode work.
18
+
19
+ ### In arch.md
20
+
21
+ - **Per-file enumerations** that go stale the moment they're written. Document the *shape* of a directory and the handful of load-bearing files; do not list every file. `git ls-files` is authoritative; the doc is for orientation.
22
+ - **Per-spec changelog sections** ("Spec 0042 added X, Spec 0073 changed Y"). Architecture is current state, not history. The git log + the spec/review documents own the changelog framing.
23
+ - **Specs/plans tables** that mirror the contents of `codev/specs/` and `codev/plans/`. These are duplicative and rot quickly. Link to the directory; do not paginate it into the doc.
24
+ - **Aspirational state** ("we plan to…", "in the next phase we'll…"). That belongs in the relevant meta-spec or roadmap doc, not in the architecture body. arch.md describes what *is*, not what *might be*.
25
+ - **Date-stamped narrative** ("As of 2026-Q2, the system uses…"). Dates make the doc look fresh while making it harder to maintain. Use git log + commit dates for temporal context.
26
+ - **Duplication of meta-spec content**. If a subsystem has its own meta-spec under `codev/architecture/<domain>.md` or under `codev/specs/`, arch.md should carry a 1-paragraph summary plus a pointer — not a copy.
27
+ - **Retired-component graveyards**. When a component is removed, delete its section. `git log` retains history; an arch.md that describes things that no longer exist is misleading.
28
+
29
+ ### In the HOT files (`arch-critical.md`, `lessons-critical.md`)
30
+
31
+ These are capped, always-on, and **behavior-changers only**. Bright-line rejections:
32
+
33
+ - **Anything over the cap.** Each hot file fits in a handful of lines (≈10 single-line facts/lessons + a cold-doc map of ≈12 top-level topics, ≤35 lines). To add an entry, **demote** a weaker one into the cold doc (displacement) — never grow the hot file.
34
+ - **Spec-narrow recipes / reference detail.** Those go in the COLD archive (reference), never the hot file.
35
+ - **A full/auto table of contents** in the cold-doc map. The map lists only **top-level** cold-doc sections, each with a one-line "consult when…" — never every entry.
36
+ - **Multi-paragraph entries.** One line each.
37
+
38
+ ### In the COLD archives (`arch.md`, `lessons-learned.md`)
39
+
40
+ These are the on-demand **reference**. They may hold spec-narrow recipes and deeper detail — the anti-accretion discipline lives in the hot cap, not here. Still avoid:
41
+
42
+ - **Multi-paragraph lesson entries**. Split or compress to 1–3 sentences.
43
+ - **Duplicate adjacent entries**. Fold variations of the same lesson into one.
44
+ - **Spec-numbered narrative framing** ("Lesson from #0468:…"). State the general principle; link the review if needed.
45
+
46
+ ### In either file (process)
47
+
48
+ - **Destructive shell commands**. The skill must not invoke `rm -rf`, `git rm`, or destructive `sed` scripts. All edits go through the normal Edit tool. The MAINTAIN PR diff is the human-confirmation step; that's enough.
49
+
50
+ ## arch.md vs. lessons-learned.md (two-doc framing)
51
+
52
+ Treat the two files as siblings with different purposes. When in doubt about which file a fact belongs in, route by purpose:
53
+
54
+ | Purpose | Goes in |
55
+ |---|---|
56
+ | Current system shape — services, transports, key mental models | `arch.md` |
57
+ | Mechanism for a unique subsystem | `arch.md` (subsystem section) — or its own meta-spec if the mechanism is large enough to warrant one, with arch.md keeping a 1-paragraph summary + pointer |
58
+ | Pointers ("see meta-spec X for details") | `arch.md` |
59
+ | A durable engineering pattern that applies across multiple specs | `lessons-learned.md` |
60
+ | A system-shape surprise verified-wrong in production ("looks like X but isn't") | `arch.md` § "Verified-Wrong Assumptions" — *not* lessons-learned.md, because it's a property of the system, not a general pattern |
61
+
62
+ The "system-shape surprise" routing is the one most often gotten wrong. If a future reader needs to know "the system *looks* like X but actually does Y", that is system shape and lives in arch.md. If they need to know "we learned that doing X is generally a bad idea", that is engineering wisdom and lives in lessons-learned.md.
63
+
64
+ That arch-vs-lessons routing is the **cold-tier** axis. **Orthogonal to it is the hot/cold axis**: once you know a fact is architecture (or a lesson), decide whether it is *behavior-changing enough* to earn a slot in the capped hot companion, or whether it is reference detail for the cold archive.
65
+
66
+ ## Hot tier: cap, displacement, and map accuracy
67
+
68
+ The hot files (`arch-critical.md`, `lessons-critical.md`) are the behavior-changers, and their value depends on staying tiny. When MAINTAIN runs — or any update touches them — enforce:
69
+
70
+ - **Cap.** Each hot file fits in a handful of lines: ≈10 single-line facts/lessons **plus** a cold-doc map of ≈12 top-level topics, ≤35 lines total. If an addition would exceed the cap, **demote** the weakest existing entry into the corresponding cold doc rather than growing the hot file. The cap is load-bearing: it is what keeps the hot tier cheap enough to inject into *every* prompt.
71
+ - **Map accuracy (bounded AND accurate).** Each hot file ends with a "Map of <cold doc> (consult when…)" listing only the cold doc's **top-level** sections, each with a one-line "consult when…". As cold-doc sections are added / renamed / removed, update the map to match — but keep it top-level only; never expand it into a full table of contents (that re-creates the accretion the hot tier exists to avoid).
72
+ - **Behavior-changers only.** A hot entry must be something that should change a decision up front. Reference detail, recipes, and one-offs belong in the cold archive — demote on sight.
73
+
74
+ ## Sizing by purpose, not by line count
75
+
76
+ There is no line-count budget for either file. The right size for each section is determined by what the section needs to do. If a subsystem genuinely has unique mechanism that takes 80 lines to explain clearly, 80 lines is the right size. If a subsystem can be described in 5 lines and a pointer to a meta-spec, 5 lines is right.
77
+
78
+ What's *wrong* is bulk that comes from any of the patterns in "What this skill does NOT do" above. Strip those, and the file's size will land where it belongs.
79
+
80
+ When proposing a section, ask: "Could a future reader skip this section without losing anything load-bearing?" If yes, the section should not exist. The doc's purpose is orientation, not completeness.
81
+
82
+ ## Mode: diff-mode (apply a specific change)
83
+
84
+ Use diff-mode when the request is specific: "add a section about the new caching layer," "update the Glossary entry for Tower," "remove the reference to the deleted dashboard-server."
85
+
86
+ In diff-mode:
87
+
88
+ 1. Find the smallest section that needs to change.
89
+ 2. Apply the change via the Edit tool.
90
+ 3. If the change adds new content, run a quick sanity check against "What this skill does NOT do" before saving — make sure the new content is current state, not aspirational; not duplicative of a meta-spec; not a per-spec changelog entry.
91
+ 4. Surface the resulting diff for review.
92
+
93
+ Diff-mode is fast. It is the right mode for ~80% of post-MAINTAIN documentation work.
94
+
95
+ ## Mode: audit-mode (identify what to cut)
96
+
97
+ Use audit-mode when the request is general: "the doc feels stale," "MAINTAIN says it's time to prune," "review arch.md against the principles."
98
+
99
+ In audit-mode:
100
+
101
+ 1. Read the file end-to-end.
102
+ 2. For each section in arch.md, run through the per-section pruning checklist (from the MAINTAIN protocol):
103
+ - Does it describe *current state*? If aspirational, the section moves to a meta-spec; the arch.md keeps a 1-paragraph summary + pointer (or nothing, if the meta-spec stands on its own).
104
+ - Does it duplicate a meta-spec? If yes, replace with a 1-paragraph summary + pointer.
105
+ - Is it a per-file enumeration that's gone stale? If yes, prune to the directory shape + a few key files.
106
+ - Is it a changelog/narrative section ("Spec 0042 added X")? If yes, absorb the architecturally-relevant facts and remove the spec-numbered framing.
107
+ - Is the component still alive? If retired, delete the section entirely.
108
+ 3. For each entry in the COLD `lessons-learned.md`, run the per-entry checklist:
109
+ - Is it terse (1–3 sentences)? If multi-paragraph, split or compress.
110
+ - Is the topic section the right one? If filed under "Architecture (continued)" or a spec-numbered section, move it to the right topical home.
111
+ - Is it a duplicate of an adjacent entry? If yes, fold them.
112
+ - (Spec-narrow recipes are **kept** here as reference — do not cut them just for being spec-narrow. Anti-accretion now lives in the hot cap, not in the cold archive.)
113
+
114
+ Then audit each **HOT** file (`arch-critical.md`, `lessons-critical.md`):
115
+ - **Cap**: within ≈10 entries + a ≈12-topic map, ≤35 lines? If over, **demote** the weakest entries into the cold doc.
116
+ - **Map accuracy**: does every map topic name a real top-level cold-doc section, and is any new/renamed section reflected? Fix drift; keep the map top-level only.
117
+ - **Behavior-changers only**: demote any reference detail that crept in.
118
+ 4. **When in doubt, KEEP.** This rule comes from the MAINTAIN protocol and applies in audit-mode too. A confident cut is better than three speculative ones. Bias toward fewer, higher-confidence proposals with clear rationale; do not chase a maximum cut count.
119
+ 5. Apply the cuts via the Edit tool — the skill does not produce a "candidate-cuts list and stop." The diff *is* the proposal. The MAINTAIN PR review is the human-confirmation step.
120
+ 6. Surface a short reason alongside each cut in the run file (`codev/maintain/NNNN.md`) so PR reviewers can evaluate intent ("removed because: per-spec changelog framing"; "compressed because: duplicates the orchestrator meta-spec").
121
+
122
+ Audit-mode is slower than diff-mode and produces larger diffs. Reserve it for explicit audit invocations, not for routine doc updates.
123
+
124
+ ## Output contract
125
+
126
+ The skill commits to the following:
127
+
128
+ - It edits the four governance files — `codev/resources/arch.md` / `arch-critical.md` and `codev/resources/lessons-learned.md` / `lessons-critical.md` — directly via the Edit tool.
129
+ - It does not invoke destructive shell commands (no `rm -rf`, no `git rm`, no destructive `sed`). File deletions happen only through Edit removing the relevant content; whole-file removal would be a structural change that is out of scope for this skill.
130
+ - In audit-mode, every removal is paired with a one-line reason in the MAINTAIN run file's `## Audit Findings` section. Rationale lives there so reviewers can evaluate intent without re-deriving it from the diff.
131
+ - The skill does not modify other files (specs, plans, reviews, source code). If a fact belongs somewhere else, the skill flags it; it does not move it.
132
+ - The skill does not edit live arch.md or lessons-learned.md content as a side effect of being read or invoked — only when the user/MAINTAIN protocol explicitly asks for an update or audit.
@@ -121,7 +121,7 @@ When the gate goes pending, output a short prose summary in the pane to orient t
121
121
  >
122
122
  > **Things to look at**: tricky spots, platform-specific behavior, anything you want the reviewer to focus on.
123
123
  >
124
- > **How to test locally**: VSCode → right-click builder → **Run Dev Server**, or `afx dev pir-{{project_id}}`. View diff via VSCode → **View Diff** (auto-detects the repo's default branch).
124
+ > **How to test locally**: VSCode → right-click builder → **Run Dev**, or `afx dev pir-{{project_id}}`. View diff via VSCode → **View Diff** (auto-detects the repo's default branch).
125
125
  >
126
126
  > Ready for review — type feedback here, or approve with `porch approve {{project_id}} dev-approval --a-human-explicitly-approved-this` (Cmd+K G in VSCode).
127
127
 
@@ -75,7 +75,7 @@ Tricky spots the PR reviewer should focus on. Honest — if a section was hard t
75
75
  For reviewers pulling the branch:
76
76
 
77
77
  - **View diff**: VSCode sidebar → right-click builder pir-{{project_id}} → **Review Diff** (auto-detects the repo's default branch)
78
- - **Run dev server**: VSCode sidebar → **Run Dev Server**, or `afx dev pir-{{project_id}}`
78
+ - **Run dev**: VSCode sidebar → **Run Dev**, or `afx dev pir-{{project_id}}`
79
79
  - **What to verify**: <bullet list mapped to the plan's Test Plan>
80
80
 
81
81
  ## Flaky Tests (if any)
@@ -83,10 +83,10 @@ The builder:
83
83
 
84
84
  **The reviewer's killer move**: run the worktree locally.
85
85
 
86
- - VSCode: right-click the builder in the Codev sidebar → **Run Dev Server** (spawns `afx dev <builder-id>` via Tower)
86
+ - VSCode: right-click the builder in the Codev sidebar → **Run Dev** (spawns `afx dev <builder-id>` via Tower)
87
87
  - CLI: `afx dev <builder-id>`
88
88
 
89
- The dev server uses **the same ports and URLs as main** intentionally (OAuth callbacks, CORS, cookie scoping all depend on consistent origins). Only one dev env runs at a time; stop main's `pnpm dev` before starting the worktree's, or use VSCode's **Stop Dev Server** to swap.
89
+ The dev process uses **the same ports and URLs as main** intentionally (OAuth callbacks, CORS, cookie scoping all depend on consistent origins). Only one dev env runs at a time; stop main's `pnpm dev` before starting the worktree's, or use VSCode's **Stop Dev** to swap.
90
90
 
91
91
  Reviewer tests the change on real devices / browsers / simulators. When satisfied, approves via Cmd+K G or:
92
92
 
@@ -134,7 +134,7 @@ This means typed input in the builder pane reaches the live Claude session immed
134
134
 
135
135
  ## Configuration
136
136
 
137
- PIR uses the same `.codev/config.json` configuration as other protocols. The `worktree` block (from Issue 689) enables the at-gate dev-server review flow:
137
+ PIR uses the same `.codev/config.json` configuration as other protocols. The `worktree` block (from Issue 689) enables the at-gate dev review flow:
138
138
 
139
139
  ```json
140
140
  {
@@ -237,6 +237,65 @@ Status values:
237
237
 
238
238
  ---
239
239
 
240
+ ### afx whoami
241
+
242
+ Report this terminal's agent identity — workspace, type, and name — from
243
+ Tower/global.db's perspective.
244
+
245
+ ```bash
246
+ afx whoami
247
+ afx whoami --json
248
+ ```
249
+
250
+ **Description:**
251
+
252
+ Resolves who the current terminal's agent is. Identity precedence:
253
+
254
+ 1. **Builder worktree** — when CWD is inside `.builders/<id>/`, the canonical
255
+ builder id is verified against `global.db` (the same resolution `afx send`
256
+ uses). An unverifiable worktree identity is an error, never a fallthrough
257
+ to the next signal.
258
+ 2. **`CODEV_ARCHITECT_NAME`** — the env var Tower injects into architect
259
+ terminals.
260
+ 3. **Unknown** — exits non-zero with an explanation. There is no implicit
261
+ fallback to `main` (issue #1094: unverified identities misroute messages).
262
+
263
+ Works without Tower running (reads `global.db` read-only).
264
+
265
+ **Example output (architect terminal):**
266
+
267
+ ```
268
+ workspace: codev
269
+ type: architect
270
+ name: main
271
+ ```
272
+
273
+ **Example output (builder worktree):**
274
+
275
+ ```
276
+ workspace: codev
277
+ type: builder
278
+ name: builder-spir-984
279
+ architect: main
280
+ ```
281
+
282
+ The `architect:` line is the builder's spawning architect; it is omitted when
283
+ not recorded (legacy rows).
284
+
285
+ **JSON output:**
286
+
287
+ ```bash
288
+ afx whoami --json
289
+ # {"workspace":"codev","type":"builder","name":"builder-spir-984","architect":"main"}
290
+ ```
291
+
292
+ On failure, `--json` prints `{"error":"..."}` to stdout (the human-readable
293
+ explanation still goes to stderr) and exits 1.
294
+
295
+ **Exit codes:** `0` identity resolved; `1` identity unknown or unverifiable.
296
+
297
+ ---
298
+
240
299
  ### afx cleanup
241
300
 
242
301
  Clean up a builder worktree and branch.
@@ -549,6 +608,36 @@ Customize commands via `.codev/config.json` at the project root:
549
608
  }
550
609
  ```
551
610
 
611
+ ### Porch Gate Artifact Auto-Open
612
+
613
+ When Porch requests a specification, plan, or review gate, it automatically
614
+ opens the phase artifact in Tower. This is enabled when the setting is unset or
615
+ `true`. Set `porch.autoOpenArtifacts` to `false` to prevent that automatic
616
+ `afx open` action:
617
+
618
+ ```json
619
+ {
620
+ "porch": {
621
+ "autoOpenArtifacts": false
622
+ }
623
+ }
624
+ ```
625
+
626
+ This setting controls only Porch's automatic gate artifact opens. A manual
627
+ `afx open <path>` still creates a Tower file tab and follows the dashboard's
628
+ normal focus behavior.
629
+
630
+ You can set the preference globally in `~/.codev/config.json`, for the team in
631
+ the project's committed `.codev/config.json`, or per engineer and project in
632
+ the gitignored `.codev/config.local.json`. Project settings override global
633
+ settings, and project-local settings override both.
634
+
635
+ When the main workspace has `.codev/config.local.json`, Agent Farm copies it
636
+ into each builder during spawn and `afx setup`. The builder receives a managed
637
+ regular-file snapshot rather than a write-through symlink, so builder edits
638
+ cannot change the main workspace's personal config. Running `afx setup` again
639
+ refreshes the snapshot from the main workspace.
640
+
552
641
  Or override via CLI flags:
553
642
 
554
643
  ```bash
@@ -102,6 +102,11 @@ Verifies that all required dependencies are installed and properly configured:
102
102
  - Gemini (Antigravity CLI, `agy`)
103
103
  - Codex (`@openai/codex`)
104
104
 
105
+ **Migration Backups (report-only):**
106
+ - Leftover copies of pre-migration state — whole-directory `~/.agent-farm.bak-*` / `~/agent-farm-db-backup-*` copies and the `*.pre-merge-<timestamp>` renames left by `afx db consolidate` — listed with age and size on disk.
107
+ - Nothing reaps these automatically, so doctor surfaces each one together with the exact `rm -rf` command and leaves the decision to you. It never deletes anything.
108
+ - Backups younger than 7 days are listed but not counted as warnings; the section is omitted entirely when there are none.
109
+
105
110
  **Exit Codes:**
106
111
  - `0` - All OK or warnings only
107
112
  - `1` - Required dependencies missing
@@ -170,6 +170,32 @@ Configure auth:
170
170
  - Gemini (`agy`): **OAuth / subscription** — run `agy` once and sign in (no API key). If `agy`
171
171
  is missing or unauthenticated, the gemini lane skips non-blockingly (the run proceeds without it).
172
172
 
173
+ #### agy auth-state cache (unauthenticated tab burst)
174
+
175
+ An unauthenticated `agy` opens an OAuth browser tab *before* it prints the URL
176
+ Codev detects, so the lane cannot suppress the tab after spawning — only by not
177
+ spawning. Since a CMAP round is several independent `consult` processes, this used
178
+ to strand one tab per consult (#1077).
179
+
180
+ Codev keeps a shared auth verdict in `~/.cache/codev/agy-auth.json` (0600,
181
+ honours `XDG_CACHE_HOME`). The first call probes; the rest read the verdict and
182
+ short-circuit, so **an unauthenticated agy is spawned at most once per TTL
183
+ window** instead of once per consult. A file lock keeps parallel consults from
184
+ probing simultaneously. `codev doctor`'s agy check shares the same cache.
185
+
186
+ Verdicts expire on their own — sign in with `agy` in another terminal and the lane
187
+ recovers within the unauth TTL, no cache clearing required. The cache only ever
188
+ suppresses a lane on positive "signed out" evidence; anything ambiguous falls
189
+ through to a normal spawn.
190
+
191
+ | Variable | Default | Purpose |
192
+ |---|---|---|
193
+ | `CODEV_AGY_AUTH_CACHE_TTL_UNAUTH_MS` | `300000` (5 min) | How long a "signed out" verdict is trusted — the sign-in recovery window. |
194
+ | `CODEV_AGY_AUTH_CACHE_TTL_AUTH_MS` | `1800000` (30 min) | How long a "signed in" verdict is trusted. |
195
+ | `CODEV_AGY_AUTH_CACHE_WAIT_MS` | `6000` | How long a consult waits for another process's in-flight probe before proceeding anyway. |
196
+ | `CODEV_AGY_AUTH_CACHE_DIR` | `~/.cache/codev` | Cache location (mainly for tests). |
197
+ | `CODEV_AGY_AUTH_CACHE_DISABLE` | unset | `1` restores the always-spawn behaviour. |
198
+
173
199
  ### Claude auth: subscription vs. metered API
174
200
 
175
201
  `consult -m claude` runs on the Claude Agent SDK. When `CLAUDE_CODE_OAUTH_TOKEN`
@@ -170,6 +170,17 @@ gh pr view <N> --json files | jq '.files[].path' # See which subsystems
170
170
  - **Medium**: SPIR features, new commands, refactors touching 3+ files
171
171
  - **High**: Protocol changes, porch state machine, Tower architecture, security model
172
172
 
173
+ #### Presenting the decision to the human (PRFT)
174
+
175
+ When you bring a fix to the human for a decision — a merge word, a `pr` gate, a dev-approval — present it **unprompted** in PRFT form, whatever the risk tier:
176
+
177
+ - **Problem** — the user-visible symptom, in a sentence or two.
178
+ - **Root Cause** — the verified mechanism. Verify it yourself; a builder's summary is evidence, not ground truth.
179
+ - **Fix** — what changed and why it's safe.
180
+ - **Testing** — the evidence: suites run, live verification, CI state.
181
+
182
+ Keep each part tight and lead with it — don't bury the decision under process narration. The human should be able to say yes or no from your message alone, without opening the diff.
183
+
173
184
  #### Step 3: Execute Review
174
185
 
175
186
  **Low risk** — no external models needed: