@cluesmith/codev 3.2.4 → 3.3.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 (394) hide show
  1. package/dashboard-dist/assets/index-BZRTEMtH.css +32 -0
  2. package/dashboard-dist/assets/{index-BZ1x7x1X.js → index-D3XaKpZW.js} +46 -44
  3. package/dashboard-dist/assets/index-D3XaKpZW.js.map +1 -0
  4. package/dashboard-dist/index.html +2 -2
  5. package/dist/agent-farm/cli.d.ts.map +1 -1
  6. package/dist/agent-farm/cli.js +154 -0
  7. package/dist/agent-farm/cli.js.map +1 -1
  8. package/dist/agent-farm/commands/cleanup.d.ts.map +1 -1
  9. package/dist/agent-farm/commands/cleanup.js +16 -0
  10. package/dist/agent-farm/commands/cleanup.js.map +1 -1
  11. package/dist/agent-farm/commands/inbox.d.ts +42 -0
  12. package/dist/agent-farm/commands/inbox.d.ts.map +1 -0
  13. package/dist/agent-farm/commands/inbox.js +129 -0
  14. package/dist/agent-farm/commands/inbox.js.map +1 -0
  15. package/dist/agent-farm/commands/interrupt.d.ts +20 -0
  16. package/dist/agent-farm/commands/interrupt.d.ts.map +1 -0
  17. package/dist/agent-farm/commands/interrupt.js +65 -0
  18. package/dist/agent-farm/commands/interrupt.js.map +1 -0
  19. package/dist/agent-farm/commands/reset/constants.d.ts +52 -0
  20. package/dist/agent-farm/commands/reset/constants.d.ts.map +1 -0
  21. package/dist/agent-farm/commands/reset/constants.js +52 -0
  22. package/dist/agent-farm/commands/reset/constants.js.map +1 -0
  23. package/dist/agent-farm/commands/reset/context.d.ts +230 -0
  24. package/dist/agent-farm/commands/reset/context.d.ts.map +1 -0
  25. package/dist/agent-farm/commands/reset/context.js +428 -0
  26. package/dist/agent-farm/commands/reset/context.js.map +1 -0
  27. package/dist/agent-farm/commands/reset/index.d.ts +192 -0
  28. package/dist/agent-farm/commands/reset/index.d.ts.map +1 -0
  29. package/dist/agent-farm/commands/reset/index.js +488 -0
  30. package/dist/agent-farm/commands/reset/index.js.map +1 -0
  31. package/dist/agent-farm/commands/reset/receipt.d.ts +97 -0
  32. package/dist/agent-farm/commands/reset/receipt.d.ts.map +1 -0
  33. package/dist/agent-farm/commands/reset/receipt.js +149 -0
  34. package/dist/agent-farm/commands/reset/receipt.js.map +1 -0
  35. package/dist/agent-farm/commands/reset/reorient.d.ts +117 -0
  36. package/dist/agent-farm/commands/reset/reorient.d.ts.map +1 -0
  37. package/dist/agent-farm/commands/reset/reorient.js +313 -0
  38. package/dist/agent-farm/commands/reset/reorient.js.map +1 -0
  39. package/dist/agent-farm/commands/reset.d.ts +34 -0
  40. package/dist/agent-farm/commands/reset.d.ts.map +1 -0
  41. package/dist/agent-farm/commands/reset.js +309 -0
  42. package/dist/agent-farm/commands/reset.js.map +1 -0
  43. package/dist/agent-farm/commands/send.d.ts.map +1 -1
  44. package/dist/agent-farm/commands/send.js +49 -8
  45. package/dist/agent-farm/commands/send.js.map +1 -1
  46. package/dist/agent-farm/commands/spawn-worktree.d.ts +105 -6
  47. package/dist/agent-farm/commands/spawn-worktree.d.ts.map +1 -1
  48. package/dist/agent-farm/commands/spawn-worktree.js +289 -66
  49. package/dist/agent-farm/commands/spawn-worktree.js.map +1 -1
  50. package/dist/agent-farm/commands/spawn.d.ts.map +1 -1
  51. package/dist/agent-farm/commands/spawn.js +13 -1
  52. package/dist/agent-farm/commands/spawn.js.map +1 -1
  53. package/dist/agent-farm/commands/status.d.ts.map +1 -1
  54. package/dist/agent-farm/commands/status.js +80 -8
  55. package/dist/agent-farm/commands/status.js.map +1 -1
  56. package/dist/agent-farm/commands/tower.d.ts.map +1 -1
  57. package/dist/agent-farm/commands/tower.js +13 -0
  58. package/dist/agent-farm/commands/tower.js.map +1 -1
  59. package/dist/agent-farm/db/index.d.ts +1 -1
  60. package/dist/agent-farm/db/index.d.ts.map +1 -1
  61. package/dist/agent-farm/db/index.js +80 -1
  62. package/dist/agent-farm/db/index.js.map +1 -1
  63. package/dist/agent-farm/db/mailbox.d.ts +222 -0
  64. package/dist/agent-farm/db/mailbox.d.ts.map +1 -0
  65. package/dist/agent-farm/db/mailbox.js +304 -0
  66. package/dist/agent-farm/db/mailbox.js.map +1 -0
  67. package/dist/agent-farm/db/schema.d.ts +1 -1
  68. package/dist/agent-farm/db/schema.d.ts.map +1 -1
  69. package/dist/agent-farm/db/schema.js +35 -0
  70. package/dist/agent-farm/db/schema.js.map +1 -1
  71. package/dist/agent-farm/db/types.d.ts +45 -0
  72. package/dist/agent-farm/db/types.d.ts.map +1 -1
  73. package/dist/agent-farm/db/types.js.map +1 -1
  74. package/dist/agent-farm/lib/builder-lookup.d.ts +1 -1
  75. package/dist/agent-farm/lib/builder-lookup.js +2 -2
  76. package/dist/agent-farm/lib/builder-lookup.js.map +1 -1
  77. package/dist/agent-farm/lib/reconnect-backoff.d.ts +64 -0
  78. package/dist/agent-farm/lib/reconnect-backoff.d.ts.map +1 -0
  79. package/dist/agent-farm/lib/reconnect-backoff.js +57 -0
  80. package/dist/agent-farm/lib/reconnect-backoff.js.map +1 -0
  81. package/dist/agent-farm/lib/tower-client.d.ts +16 -6
  82. package/dist/agent-farm/lib/tower-client.d.ts.map +1 -1
  83. package/dist/agent-farm/lib/tower-client.js +37 -6
  84. package/dist/agent-farm/lib/tower-client.js.map +1 -1
  85. package/dist/agent-farm/lib/tunnel-client.d.ts +69 -1
  86. package/dist/agent-farm/lib/tunnel-client.d.ts.map +1 -1
  87. package/dist/agent-farm/lib/tunnel-client.js +225 -30
  88. package/dist/agent-farm/lib/tunnel-client.js.map +1 -1
  89. package/dist/agent-farm/servers/canvas-relay.d.ts +60 -0
  90. package/dist/agent-farm/servers/canvas-relay.d.ts.map +1 -0
  91. package/dist/agent-farm/servers/canvas-relay.js +376 -0
  92. package/dist/agent-farm/servers/canvas-relay.js.map +1 -0
  93. package/dist/agent-farm/servers/cron-delivery.d.ts +72 -0
  94. package/dist/agent-farm/servers/cron-delivery.d.ts.map +1 -0
  95. package/dist/agent-farm/servers/cron-delivery.js +80 -0
  96. package/dist/agent-farm/servers/cron-delivery.js.map +1 -0
  97. package/dist/agent-farm/servers/delayed-send.d.ts +85 -0
  98. package/dist/agent-farm/servers/delayed-send.d.ts.map +1 -0
  99. package/dist/agent-farm/servers/delayed-send.js +165 -0
  100. package/dist/agent-farm/servers/delayed-send.js.map +1 -0
  101. package/dist/agent-farm/servers/gate-profiles.d.ts +67 -0
  102. package/dist/agent-farm/servers/gate-profiles.d.ts.map +1 -0
  103. package/dist/agent-farm/servers/gate-profiles.js +113 -0
  104. package/dist/agent-farm/servers/gate-profiles.js.map +1 -0
  105. package/dist/agent-farm/servers/mailbox-delivery.d.ts +370 -0
  106. package/dist/agent-farm/servers/mailbox-delivery.d.ts.map +1 -0
  107. package/dist/agent-farm/servers/mailbox-delivery.js +617 -0
  108. package/dist/agent-farm/servers/mailbox-delivery.js.map +1 -0
  109. package/dist/agent-farm/servers/mailbox-wiring.d.ts +125 -0
  110. package/dist/agent-farm/servers/mailbox-wiring.d.ts.map +1 -0
  111. package/dist/agent-farm/servers/mailbox-wiring.js +425 -0
  112. package/dist/agent-farm/servers/mailbox-wiring.js.map +1 -0
  113. package/dist/agent-farm/servers/message-write.d.ts +53 -1
  114. package/dist/agent-farm/servers/message-write.d.ts.map +1 -1
  115. package/dist/agent-farm/servers/message-write.js +63 -0
  116. package/dist/agent-farm/servers/message-write.js.map +1 -1
  117. package/dist/agent-farm/servers/overview.d.ts +19 -0
  118. package/dist/agent-farm/servers/overview.d.ts.map +1 -1
  119. package/dist/agent-farm/servers/overview.js +100 -4
  120. package/dist/agent-farm/servers/overview.js.map +1 -1
  121. package/dist/agent-farm/servers/render-gate.d.ts +141 -0
  122. package/dist/agent-farm/servers/render-gate.d.ts.map +1 -0
  123. package/dist/agent-farm/servers/render-gate.js +251 -0
  124. package/dist/agent-farm/servers/render-gate.js.map +1 -0
  125. package/dist/agent-farm/servers/session-submit.d.ts +90 -0
  126. package/dist/agent-farm/servers/session-submit.d.ts.map +1 -0
  127. package/dist/agent-farm/servers/session-submit.js +127 -0
  128. package/dist/agent-farm/servers/session-submit.js.map +1 -0
  129. package/dist/agent-farm/servers/tower-cron.d.ts +10 -7
  130. package/dist/agent-farm/servers/tower-cron.d.ts.map +1 -1
  131. package/dist/agent-farm/servers/tower-cron.js +58 -53
  132. package/dist/agent-farm/servers/tower-cron.js.map +1 -1
  133. package/dist/agent-farm/servers/tower-instances.d.ts +14 -2
  134. package/dist/agent-farm/servers/tower-instances.d.ts.map +1 -1
  135. package/dist/agent-farm/servers/tower-instances.js +78 -16
  136. package/dist/agent-farm/servers/tower-instances.js.map +1 -1
  137. package/dist/agent-farm/servers/tower-messages.d.ts +38 -1
  138. package/dist/agent-farm/servers/tower-messages.d.ts.map +1 -1
  139. package/dist/agent-farm/servers/tower-messages.js +106 -1
  140. package/dist/agent-farm/servers/tower-messages.js.map +1 -1
  141. package/dist/agent-farm/servers/tower-routes.d.ts +16 -4
  142. package/dist/agent-farm/servers/tower-routes.d.ts.map +1 -1
  143. package/dist/agent-farm/servers/tower-routes.js +826 -145
  144. package/dist/agent-farm/servers/tower-routes.js.map +1 -1
  145. package/dist/agent-farm/servers/tower-server.js +188 -34
  146. package/dist/agent-farm/servers/tower-server.js.map +1 -1
  147. package/dist/agent-farm/servers/tower-terminals.d.ts +23 -2
  148. package/dist/agent-farm/servers/tower-terminals.d.ts.map +1 -1
  149. package/dist/agent-farm/servers/tower-terminals.js +134 -127
  150. package/dist/agent-farm/servers/tower-terminals.js.map +1 -1
  151. package/dist/agent-farm/servers/tower-tunnel.d.ts.map +1 -1
  152. package/dist/agent-farm/servers/tower-tunnel.js +63 -4
  153. package/dist/agent-farm/servers/tower-tunnel.js.map +1 -1
  154. package/dist/agent-farm/servers/tower-types.d.ts +2 -1
  155. package/dist/agent-farm/servers/tower-types.d.ts.map +1 -1
  156. package/dist/agent-farm/servers/tower-utils.d.ts +64 -1
  157. package/dist/agent-farm/servers/tower-utils.d.ts.map +1 -1
  158. package/dist/agent-farm/servers/tower-utils.js +168 -1
  159. package/dist/agent-farm/servers/tower-utils.js.map +1 -1
  160. package/dist/agent-farm/servers/tower-websocket.d.ts +6 -1
  161. package/dist/agent-farm/servers/tower-websocket.d.ts.map +1 -1
  162. package/dist/agent-farm/servers/tower-websocket.js +95 -57
  163. package/dist/agent-farm/servers/tower-websocket.js.map +1 -1
  164. package/dist/agent-farm/servers/write-queue.d.ts +35 -0
  165. package/dist/agent-farm/servers/write-queue.d.ts.map +1 -0
  166. package/dist/agent-farm/servers/write-queue.js +56 -0
  167. package/dist/agent-farm/servers/write-queue.js.map +1 -0
  168. package/dist/agent-farm/types.d.ts +39 -0
  169. package/dist/agent-farm/types.d.ts.map +1 -1
  170. package/dist/agent-farm/utils/agent-names.d.ts +2 -2
  171. package/dist/agent-farm/utils/agent-names.d.ts.map +1 -1
  172. package/dist/agent-farm/utils/agent-names.js +3 -3
  173. package/dist/agent-farm/utils/agent-names.js.map +1 -1
  174. package/dist/agent-farm/utils/architect-name.d.ts +2 -2
  175. package/dist/agent-farm/utils/architect-name.d.ts.map +1 -1
  176. package/dist/agent-farm/utils/architect-name.js +3 -3
  177. package/dist/agent-farm/utils/architect-name.js.map +1 -1
  178. package/dist/agent-farm/utils/config.d.ts +13 -0
  179. package/dist/agent-farm/utils/config.d.ts.map +1 -1
  180. package/dist/agent-farm/utils/config.js +33 -1
  181. package/dist/agent-farm/utils/config.js.map +1 -1
  182. package/dist/agent-farm/utils/harness.d.ts +103 -7
  183. package/dist/agent-farm/utils/harness.d.ts.map +1 -1
  184. package/dist/agent-farm/utils/harness.js +126 -19
  185. package/dist/agent-farm/utils/harness.js.map +1 -1
  186. package/dist/agent-farm/utils/message-format.d.ts +8 -0
  187. package/dist/agent-farm/utils/message-format.d.ts.map +1 -1
  188. package/dist/agent-farm/utils/message-format.js +20 -0
  189. package/dist/agent-farm/utils/message-format.js.map +1 -1
  190. package/dist/agent-farm/utils/server-utils.d.ts +80 -4
  191. package/dist/agent-farm/utils/server-utils.d.ts.map +1 -1
  192. package/dist/agent-farm/utils/server-utils.js +286 -5
  193. package/dist/agent-farm/utils/server-utils.js.map +1 -1
  194. package/dist/cli.d.ts.map +1 -1
  195. package/dist/cli.js +6 -32
  196. package/dist/cli.js.map +1 -1
  197. package/dist/commands/consult/cli-options.d.ts +34 -0
  198. package/dist/commands/consult/cli-options.d.ts.map +1 -0
  199. package/dist/commands/consult/cli-options.js +67 -0
  200. package/dist/commands/consult/cli-options.js.map +1 -0
  201. package/dist/commands/consult/index.d.ts +56 -2
  202. package/dist/commands/consult/index.d.ts.map +1 -1
  203. package/dist/commands/consult/index.js +272 -28
  204. package/dist/commands/consult/index.js.map +1 -1
  205. package/dist/commands/consult/metrics.d.ts +42 -0
  206. package/dist/commands/consult/metrics.d.ts.map +1 -1
  207. package/dist/commands/consult/metrics.js +129 -9
  208. package/dist/commands/consult/metrics.js.map +1 -1
  209. package/dist/commands/doctor.d.ts.map +1 -1
  210. package/dist/commands/doctor.js +71 -19
  211. package/dist/commands/doctor.js.map +1 -1
  212. package/dist/commands/porch/checks.d.ts +23 -0
  213. package/dist/commands/porch/checks.d.ts.map +1 -1
  214. package/dist/commands/porch/checks.js +60 -0
  215. package/dist/commands/porch/checks.js.map +1 -1
  216. package/dist/commands/porch/config.d.ts +20 -0
  217. package/dist/commands/porch/config.d.ts.map +1 -1
  218. package/dist/commands/porch/config.js +20 -0
  219. package/dist/commands/porch/config.js.map +1 -1
  220. package/dist/commands/porch/index.js +21 -28
  221. package/dist/commands/porch/index.js.map +1 -1
  222. package/dist/commands/porch/next.d.ts.map +1 -1
  223. package/dist/commands/porch/next.js +2 -41
  224. package/dist/commands/porch/next.js.map +1 -1
  225. package/dist/lib/config.d.ts +69 -3
  226. package/dist/lib/config.d.ts.map +1 -1
  227. package/dist/lib/config.js +67 -3
  228. package/dist/lib/config.js.map +1 -1
  229. package/dist/lib/consult-lanes.d.ts +149 -0
  230. package/dist/lib/consult-lanes.d.ts.map +1 -0
  231. package/dist/lib/consult-lanes.js +360 -0
  232. package/dist/lib/consult-lanes.js.map +1 -0
  233. package/dist/lib/forge-contracts.d.ts +9 -0
  234. package/dist/lib/forge-contracts.d.ts.map +1 -1
  235. package/dist/lib/forge-contracts.js.map +1 -1
  236. package/dist/lib/github.d.ts +15 -1
  237. package/dist/lib/github.d.ts.map +1 -1
  238. package/dist/lib/github.js +18 -1
  239. package/dist/lib/github.js.map +1 -1
  240. package/dist/lib/prompt-behavior-metrics.d.ts +67 -0
  241. package/dist/lib/prompt-behavior-metrics.d.ts.map +1 -0
  242. package/dist/lib/prompt-behavior-metrics.js +290 -0
  243. package/dist/lib/prompt-behavior-metrics.js.map +1 -0
  244. package/dist/lib/skeleton.d.ts +22 -1
  245. package/dist/lib/skeleton.d.ts.map +1 -1
  246. package/dist/lib/skeleton.js +120 -0
  247. package/dist/lib/skeleton.js.map +1 -1
  248. package/dist/lib/test-env.d.ts +74 -0
  249. package/dist/lib/test-env.d.ts.map +1 -0
  250. package/dist/lib/test-env.js +92 -0
  251. package/dist/lib/test-env.js.map +1 -0
  252. package/dist/terminal/attach-replay.d.ts +39 -0
  253. package/dist/terminal/attach-replay.d.ts.map +1 -0
  254. package/dist/terminal/attach-replay.js +76 -0
  255. package/dist/terminal/attach-replay.js.map +1 -0
  256. package/dist/terminal/pty-manager.d.ts +2 -0
  257. package/dist/terminal/pty-manager.d.ts.map +1 -1
  258. package/dist/terminal/pty-manager.js +51 -23
  259. package/dist/terminal/pty-manager.js.map +1 -1
  260. package/dist/terminal/pty-session.d.ts +201 -1
  261. package/dist/terminal/pty-session.d.ts.map +1 -1
  262. package/dist/terminal/pty-session.js +327 -46
  263. package/dist/terminal/pty-session.js.map +1 -1
  264. package/dist/terminal/ring-buffer.d.ts +39 -6
  265. package/dist/terminal/ring-buffer.d.ts.map +1 -1
  266. package/dist/terminal/ring-buffer.js +74 -6
  267. package/dist/terminal/ring-buffer.js.map +1 -1
  268. package/dist/terminal/session-manager.d.ts +53 -0
  269. package/dist/terminal/session-manager.d.ts.map +1 -1
  270. package/dist/terminal/session-manager.js +94 -9
  271. package/dist/terminal/session-manager.js.map +1 -1
  272. package/dist/terminal/session-screen.d.ts +116 -0
  273. package/dist/terminal/session-screen.d.ts.map +1 -0
  274. package/dist/terminal/session-screen.js +180 -0
  275. package/dist/terminal/session-screen.js.map +1 -0
  276. package/dist/terminal/shellper-main.js +2 -1
  277. package/dist/terminal/shellper-main.js.map +1 -1
  278. package/dist/terminal/shellper-process.d.ts +1 -1
  279. package/dist/terminal/shellper-process.d.ts.map +1 -1
  280. package/dist/terminal/shellper-process.js +17 -8
  281. package/dist/terminal/shellper-process.js.map +1 -1
  282. package/dist/terminal/shellper-replay-buffer.d.ts +69 -7
  283. package/dist/terminal/shellper-replay-buffer.d.ts.map +1 -1
  284. package/dist/terminal/shellper-replay-buffer.js +167 -31
  285. package/dist/terminal/shellper-replay-buffer.js.map +1 -1
  286. package/package.json +13 -8
  287. package/scripts/forge/gitea/pr-view.sh +4 -1
  288. package/scripts/forge/github/pr-view.sh +1 -1
  289. package/scripts/forge/gitlab/pr-view.sh +4 -1
  290. package/skeleton/.claude/skills/afx/SKILL.md +68 -1
  291. package/skeleton/.claude/skills/arch-init/SKILL.md +22 -9
  292. package/skeleton/.claude/skills/arch-save/SKILL.md +183 -0
  293. package/skeleton/.claude/skills/codev/SKILL.md +31 -0
  294. package/skeleton/.claude/skills/runnable-worktrees/SKILL.md +119 -0
  295. package/skeleton/.codex/skills/afx/SKILL.md +68 -1
  296. package/skeleton/.codex/skills/arch-init/SKILL.md +22 -9
  297. package/skeleton/.codex/skills/arch-save/SKILL.md +183 -0
  298. package/skeleton/.codex/skills/codev/SKILL.md +31 -0
  299. package/skeleton/.codex/skills/runnable-worktrees/SKILL.md +119 -0
  300. package/skeleton/protocols/air/builder-prompt.md +28 -47
  301. package/skeleton/protocols/air/consult-types/impl-review.md +17 -34
  302. package/skeleton/protocols/air/consult-types/pr-review.md +14 -37
  303. package/skeleton/protocols/air/prompts/implement.md +20 -73
  304. package/skeleton/protocols/air/prompts/pr.md +22 -54
  305. package/skeleton/protocols/air/protocol.md +40 -71
  306. package/skeleton/protocols/aspir/builder-prompt.md +29 -66
  307. package/skeleton/protocols/aspir/consult-types/impl-review.md +17 -44
  308. package/skeleton/protocols/aspir/consult-types/phase-review.md +17 -44
  309. package/skeleton/protocols/aspir/consult-types/plan-review.md +14 -38
  310. package/skeleton/protocols/aspir/consult-types/pr-review.md +13 -39
  311. package/skeleton/protocols/aspir/consult-types/spec-review.md +13 -33
  312. package/skeleton/protocols/aspir/prompts/implement.md +27 -196
  313. package/skeleton/protocols/aspir/prompts/plan.md +21 -85
  314. package/skeleton/protocols/aspir/prompts/review.md +29 -228
  315. package/skeleton/protocols/aspir/prompts/specify.md +25 -111
  316. package/skeleton/protocols/aspir/protocol.json +10 -0
  317. package/skeleton/protocols/aspir/protocol.md +36 -82
  318. package/skeleton/protocols/bugfix/builder-prompt.md +23 -45
  319. package/skeleton/protocols/bugfix/consult-types/impl-review.md +21 -45
  320. package/skeleton/protocols/bugfix/consult-types/pr-review.md +18 -52
  321. package/skeleton/protocols/bugfix/prompts/fix.md +16 -61
  322. package/skeleton/protocols/bugfix/prompts/investigate.md +18 -62
  323. package/skeleton/protocols/bugfix/prompts/pr.md +22 -57
  324. package/skeleton/protocols/bugfix/protocol.md +44 -50
  325. package/skeleton/protocols/experiment/builder-prompt.md +25 -58
  326. package/skeleton/protocols/experiment/protocol.md +22 -188
  327. package/skeleton/protocols/experiment/templates/notes.md +11 -71
  328. package/skeleton/protocols/maintain/builder-prompt.md +24 -45
  329. package/skeleton/protocols/maintain/consult-types/impl-review.md +17 -44
  330. package/skeleton/protocols/maintain/consult-types/pr-review.md +13 -39
  331. package/skeleton/protocols/maintain/prompts/maintain.md +1 -1
  332. package/skeleton/protocols/maintain/protocol.md +32 -266
  333. package/skeleton/protocols/maintain/templates/maintenance-run.md +11 -0
  334. package/skeleton/protocols/pir/builder-prompt.md +31 -64
  335. package/skeleton/protocols/pir/consult-types/impl-review.md +17 -50
  336. package/skeleton/protocols/pir/consult-types/pr-review.md +11 -40
  337. package/skeleton/protocols/pir/prompts/implement.md +2 -3
  338. package/skeleton/protocols/pir/prompts/plan.md +1 -4
  339. package/skeleton/protocols/pir/prompts/review.md +2 -2
  340. package/skeleton/protocols/pir/protocol.md +54 -177
  341. package/skeleton/protocols/research/builder-prompt.md +27 -58
  342. package/skeleton/protocols/research/protocol.md +28 -153
  343. package/skeleton/protocols/spike/builder-prompt.md +30 -48
  344. package/skeleton/protocols/spike/protocol.md +24 -107
  345. package/skeleton/protocols/spike/templates/findings.md +9 -39
  346. package/skeleton/protocols/spir/builder-prompt.md +33 -62
  347. package/skeleton/protocols/spir/consult-types/impl-review.md +17 -44
  348. package/skeleton/protocols/spir/consult-types/phase-review.md +17 -44
  349. package/skeleton/protocols/spir/consult-types/plan-review.md +14 -38
  350. package/skeleton/protocols/spir/consult-types/pr-review.md +13 -39
  351. package/skeleton/protocols/spir/consult-types/spec-review.md +13 -33
  352. package/skeleton/protocols/spir/prompts/implement.md +26 -195
  353. package/skeleton/protocols/spir/prompts/plan.md +20 -84
  354. package/skeleton/protocols/spir/prompts/review.md +28 -227
  355. package/skeleton/protocols/spir/prompts/specify.md +24 -110
  356. package/skeleton/protocols/spir/protocol.json +10 -0
  357. package/skeleton/protocols/spir/protocol.md +84 -633
  358. package/skeleton/protocols/spir/templates/plan.md +28 -147
  359. package/skeleton/protocols/spir/templates/review.md +21 -80
  360. package/skeleton/protocols/spir/templates/spec.md +24 -118
  361. package/skeleton/resources/commands/agent-farm.md +262 -0
  362. package/skeleton/resources/commands/consult.md +236 -8
  363. package/skeleton/resources/commands/overview.md +1 -0
  364. package/skeleton/roles/architect.md +67 -317
  365. package/skeleton/roles/builder.md +76 -191
  366. package/skeleton/templates/AGENTS.md +2 -0
  367. package/skeleton/templates/CLAUDE.md +2 -0
  368. package/templates/3d-viewer.html +32 -4
  369. package/templates/open.html +58 -12
  370. package/templates/tower.html +65 -9
  371. package/templates/vendor/three-3MFLoader.js +1478 -0
  372. package/templates/vendor/three-STLLoader.js +410 -0
  373. package/templates/vendor/three-TrackballControls.js +828 -0
  374. package/templates/vendor/three-fflate.module.js +2474 -0
  375. package/templates/vendor/three.module.js +53044 -0
  376. package/dashboard-dist/assets/index-BZ1x7x1X.js.map +0 -1
  377. package/dashboard-dist/assets/index-DB1KBSNE.css +0 -32
  378. package/dist/agent-farm/servers/send-buffer.d.ts +0 -59
  379. package/dist/agent-farm/servers/send-buffer.d.ts.map +0 -1
  380. package/dist/agent-farm/servers/send-buffer.js +0 -116
  381. package/dist/agent-farm/servers/send-buffer.js.map +0 -1
  382. package/skeleton/porch/prompts/defend.md +0 -108
  383. package/skeleton/porch/prompts/diagnose.md +0 -70
  384. package/skeleton/porch/prompts/evaluate.md +0 -132
  385. package/skeleton/porch/prompts/fix.md +0 -59
  386. package/skeleton/porch/prompts/implement.md +0 -88
  387. package/skeleton/porch/prompts/plan.md +0 -74
  388. package/skeleton/porch/prompts/pr.md +0 -84
  389. package/skeleton/porch/prompts/review.md +0 -249
  390. package/skeleton/porch/prompts/specify.md +0 -53
  391. package/skeleton/porch/prompts/test.md +0 -63
  392. package/skeleton/protocols/aspir/templates/plan.md +0 -184
  393. package/skeleton/protocols/aspir/templates/review.md +0 -120
  394. package/skeleton/protocols/aspir/templates/spec.md +0 -154
@@ -0,0 +1,428 @@
1
+ /**
2
+ * Builder context resolution for `afx refresh` (Spec 1273, phase 4).
3
+ *
4
+ * Invariant R3 requires a re-orientation carrying protocol, mode, worktree,
5
+ * branch, project identity and porch re-entry. The first draft of the plan
6
+ * assumed the builder registry held those facts. **It does not**, and the gap is
7
+ * silent rather than obvious:
8
+ *
9
+ * - `builders.protocol_name` is NULL for spec-type builders. `spawn.ts` never
10
+ * passes `protocolName` on that path (only the `protocol`-type spawn does),
11
+ * so every SPIR/ASPIR lane — precisely the long-running builders this feature
12
+ * exists for — has NULL there. Reading `db/schema.ts` shows the column and
13
+ * looks fine; the persistence path is where the truth is.
14
+ * - Mode is not persisted at all. `resolveMode` computes it at spawn from flags
15
+ * plus protocol defaults and discards it, so a spawn-time `--soft` cannot be
16
+ * recovered afterwards by recomputation.
17
+ * - Harness comes from workspace config, which can change while a builder runs,
18
+ * so config is not authoritative for a *running* builder.
19
+ *
20
+ * So this module reads the worktree, which holds all of it authoritatively:
21
+ * porch's `status.yaml` (protocol, phase), `.builder-prompt.txt` (the literal
22
+ * `## Mode:` line the builder was given), and `.builder-start.sh` (the launch
23
+ * line of the process actually running).
24
+ *
25
+ * Every chain ends in a **loud abort**, never a default. A guessed protocol or
26
+ * mode would produce a plausible-looking re-orientation that quietly reframes the
27
+ * builder — the exact drift R3 exists to prevent.
28
+ */
29
+ import { join } from 'node:path';
30
+ import { parseAgentName } from '../../utils/agent-names.js';
31
+ import { BUILTIN_HARNESSES, getBuiltinHarness, buildCustomHarnessProvider, } from '../../utils/harness.js';
32
+ /** Thrown when a fact cannot be established. Never swallowed into a default. */
33
+ export class ContextResolutionError extends Error {
34
+ constructor(message) {
35
+ super(message);
36
+ this.name = 'ContextResolutionError';
37
+ }
38
+ }
39
+ /**
40
+ * Project ids this builder could legitimately own, most specific first.
41
+ *
42
+ * Three forms, because porch names projects differently per lane:
43
+ * - the issue number, for issue-driven lanes;
44
+ * - the builder id itself — `spawn.ts` passes `builderId` as the porch project
45
+ * id on the `--task` path;
46
+ * - the builder id with its protocol prefix stripped (`aspir-1273` → `1273`),
47
+ * which is how spec-driven lanes are named.
48
+ */
49
+ export function candidateProjectIds(identity) {
50
+ const out = [];
51
+ if (identity.issueNumber)
52
+ out.push(identity.issueNumber);
53
+ // The raw registry id, INCLUDING any `builder-` prefix. `spawn --task
54
+ // --protocol X` passes `builderId` straight to `porch init`
55
+ // (`spawn.ts:548`), and `initPorchInWorktree` keeps dashes when sanitising
56
+ // (`spawn-worktree.ts:472`), so that lane's porch project id really is
57
+ // `builder-task-<id>`. Omitting this form orphaned it: porch resolved to
58
+ // null, and the builder was re-oriented as protocol TASK with no porch
59
+ // re-entry — a silently degraded frame rather than a loud failure.
60
+ out.push(identity.builderId);
61
+ // And without the prefix, which is how spec/bugfix lanes are named.
62
+ const bare = identity.builderId.replace(/^builder-/, '');
63
+ if (bare !== identity.builderId)
64
+ out.push(bare);
65
+ const dash = bare.indexOf('-');
66
+ if (dash > 0)
67
+ out.push(bare.slice(dash + 1));
68
+ return out.filter(v => v !== '');
69
+ }
70
+ /**
71
+ * Compare ids ignoring case and leading zeros.
72
+ *
73
+ * Case: the registry lowercases builder ids while worktree and directory names
74
+ * preserve the original (`builder-task-re_v` vs `.builders/task-RE_V`). macOS
75
+ * hides that; a case-sensitive filesystem would not.
76
+ * Leading zeros: project dirs use `0087-…` while porch ids and CLI arguments use
77
+ * `87` (`afx cleanup -p 466` vs `0466` is the same long-standing split).
78
+ */
79
+ function normalizeId(value) {
80
+ return value.trim().toLowerCase().replace(/^0+(?=\d)/, '');
81
+ }
82
+ function claimStrength(dir, statusId, identity) {
83
+ const rawId = normalizeId(identity.builderId);
84
+ if (statusId && normalizeId(statusId) === rawId && !/^\d+$/.test(rawId))
85
+ return 'strong';
86
+ const wanted = candidateProjectIds(identity).map(normalizeId);
87
+ // A status.yaml that STATES its id is authoritative about what it is. If that
88
+ // id does not claim this builder, the directory name cannot overrule it —
89
+ // `codev/projects/1273-old/` holding `id: '999'` belongs to 999, whatever the
90
+ // directory is called. Falling through to the name here let a renamed or
91
+ // recycled directory claim a builder, and manufactured false ambiguities
92
+ // alongside the real project.
93
+ if (statusId)
94
+ return wanted.includes(normalizeId(statusId)) ? 'weak' : 'none';
95
+ // Directory-name fallback applies ONLY when the file states no id at all.
96
+ const dirNorm = normalizeId(dir);
97
+ return wanted.some(c => dirNorm === c || dirNorm.startsWith(`${c}-`)) ? 'weak' : 'none';
98
+ }
99
+ export function readPorchContext(fs, worktree, identity) {
100
+ const projectsDir = join(worktree, 'codev', 'projects');
101
+ const dirs = fs.listDirs(projectsDir);
102
+ if (!dirs || dirs.length === 0)
103
+ return null;
104
+ // The protocol the builder id claims, used to corroborate weak (number-only)
105
+ // matches. Absent for ids that are not in canonical form, in which case a weak
106
+ // match cannot be corroborated and is not trusted.
107
+ const expectedProtocol = parseAgentName(identity.builderId)?.protocol ?? null;
108
+ const strong = [];
109
+ const weak = [];
110
+ for (const dir of dirs) {
111
+ const statusPath = join(projectsDir, dir, 'status.yaml');
112
+ const content = fs.read(statusPath);
113
+ if (content === null)
114
+ continue;
115
+ const protocol = matchScalar(content, 'protocol');
116
+ const phase = matchScalar(content, 'phase');
117
+ const id = matchScalar(content, 'id');
118
+ if (!protocol || !phase)
119
+ continue;
120
+ const claim = claimStrength(dir, id, identity);
121
+ if (claim === 'none')
122
+ continue;
123
+ const currentPlanPhase = matchScalar(content, 'current_plan_phase');
124
+ const ctx = {
125
+ projectId: id ?? dir.split('-')[0],
126
+ projectName: dir,
127
+ protocol,
128
+ phase,
129
+ currentPlanPhase: currentPlanPhase && currentPlanPhase !== 'null' ? currentPlanPhase : null,
130
+ statusPath,
131
+ };
132
+ if (claim === 'strong') {
133
+ strong.push(ctx);
134
+ continue;
135
+ }
136
+ // A weak match must agree with the protocol the builder id declares.
137
+ // Without this, `builder-bugfix-799` adopts the PIR project that happens to
138
+ // share the number — wrong protocol, wrong porch id, and silently so.
139
+ //
140
+ // And when the id is not in canonical form there IS no protocol to
141
+ // corroborate against, so the claim cannot be trusted at all. The previous
142
+ // version's comment said exactly that while the code did the opposite —
143
+ // `if (expectedProtocol && mismatch) continue` let every weak claim through
144
+ // whenever `expectedProtocol` was null. A legacy or noncanonical builder
145
+ // could adopt any historical project sharing its tail.
146
+ if (!expectedProtocol)
147
+ continue;
148
+ if (protocol.toLowerCase() !== expectedProtocol.toLowerCase())
149
+ continue;
150
+ weak.push(ctx);
151
+ }
152
+ const matches = strong.length > 0 ? strong : weak;
153
+ if (matches.length === 0)
154
+ return null;
155
+ if (matches.length > 1) {
156
+ // Never pick one arbitrarily — that is the bug this whole function exists to
157
+ // fix, and picking the "least wrong" of several is the same mistake with
158
+ // better manners.
159
+ throw new ContextResolutionError(`Ambiguous porch project for '${identity.builderId}': ${matches
160
+ .map(m => `${m.projectName} (${m.protocol})`)
161
+ .join(', ')} all claim it. Refusing to guess which one governs this builder.`);
162
+ }
163
+ return matches[0];
164
+ }
165
+ /** Read a top-level scalar from porch's status.yaml, stripping quotes. */
166
+ function matchScalar(content, key) {
167
+ const m = content.match(new RegExp(`^${key}:\\s*(.+)$`, 'm'));
168
+ if (!m)
169
+ return null;
170
+ const raw = m[1].trim().replace(/^['"]|['"]$/g, '');
171
+ return raw === '' ? null : raw;
172
+ }
173
+ /**
174
+ * The protocol recorded in status.yaml, if there is one.
175
+ *
176
+ * Reads through `readPorchContext` rather than re-scanning the project dirs, so
177
+ * the two cannot disagree about which status.yaml is authoritative. Worktrees
178
+ * routinely hold MANY project directories here (porch history is committed to
179
+ * `main`), which is exactly why both go through one identity-aware selector.
180
+ */
181
+ export function protocolFromStatus(fs, worktree, identity) {
182
+ return readPorchContext(fs, worktree, identity)?.protocol ?? null;
183
+ }
184
+ // ============================================================================
185
+ // Mode
186
+ // ============================================================================
187
+ /**
188
+ * Read the mode the builder was actually told it was running in.
189
+ *
190
+ * The spawn prompt renders a literal `## Mode: STRICT` heading, and `--resume`
191
+ * does not rewrite the prompt file, so this stays correct across resumes. It is
192
+ * a stronger source than recomputing `resolveMode`, which cannot recover a
193
+ * spawn-time `--soft` from protocol defaults.
194
+ */
195
+ export function modeFromBuilderPrompt(fs, worktree) {
196
+ const content = fs.read(join(worktree, '.builder-prompt.txt'));
197
+ if (content === null)
198
+ return null;
199
+ const m = content.match(/^##\s*Mode:\s*(STRICT|SOFT)\s*$/im);
200
+ if (!m)
201
+ return null;
202
+ return m[1].toLowerCase();
203
+ }
204
+ /**
205
+ * Recover an issue number from a porch project id.
206
+ *
207
+ * Porch ids are not uniformly numeric. PIR and SPIR use the bare issue number;
208
+ * **BUGFIX deliberately uses `<prefix>-<N>`** (`spawn.ts:817`, "historical, kept
209
+ * untouched"). A strict `/^\d+$/` guard therefore threw away BUGFIX's issue
210
+ * identity whenever the registry row lacked one — and on BUGFIX the issue body
211
+ * IS the spec, so the re-orientation lost the requirements it was meant to carry.
212
+ *
213
+ * Accepts a bare number or a canonical `<word>-<number>`; rejects anything else,
214
+ * so an ad-hoc task id (`builder-task-abc`) still cannot masquerade as an issue.
215
+ */
216
+ export function issueNumberFromPorchId(projectId) {
217
+ if (!projectId)
218
+ return undefined;
219
+ if (/^\d+$/.test(projectId))
220
+ return projectId;
221
+ const m = projectId.match(/^[a-z]+-(\d+)$/i);
222
+ return m ? m[1] : undefined;
223
+ }
224
+ // ============================================================================
225
+ // Harness
226
+ // ============================================================================
227
+ /**
228
+ * Identify the harness from the worktree's launch script.
229
+ *
230
+ * Per-builder ground truth: the script is what the running process was started
231
+ * with, so it stays right even if workspace config changed since the spawn.
232
+ */
233
+ export function harnessFromLaunchScript(fs, worktree, customHarnesses) {
234
+ const content = fs.read(join(worktree, '.builder-start.sh'));
235
+ if (content === null)
236
+ return null;
237
+ // Custom names first: a project may define a custom harness whose name
238
+ // contains a builtin's (e.g. "claude-experimental"), and the more specific
239
+ // match is the right one.
240
+ const names = new Set([
241
+ ...Object.keys(customHarnesses ?? {}),
242
+ ...Object.keys(BUILTIN_HARNESSES),
243
+ ]);
244
+ for (const line of content.split('\n')) {
245
+ const command = commandNameOf(line);
246
+ if (command && names.has(command))
247
+ return command;
248
+ }
249
+ return null;
250
+ }
251
+ /**
252
+ * The command a shell line invokes, or null if the line invokes nothing.
253
+ *
254
+ * Matching on **command position** rather than searching the whole line for a
255
+ * harness name: a substring search would report a false positive on a line like
256
+ * `if [ "$HARNESS" = "codex" ]`, and naming the wrong harness would either refuse
257
+ * a resettable builder or — worse — approve typing into one that cannot be reset.
258
+ */
259
+ function commandNameOf(line) {
260
+ let rest = line.trim();
261
+ if (!rest || rest.startsWith('#'))
262
+ return null;
263
+ // Strip shell control keywords that can prefix a command on the same line.
264
+ rest = rest.replace(/^(?:while|until|if|then|else|elif|do|done|fi|exec|command|nohup)\s+/, '');
265
+ // Strip leading `VAR=value ` environment assignments.
266
+ while (/^[A-Za-z_][A-Za-z0-9_]*=/.test(rest)) {
267
+ const space = rest.indexOf(' ');
268
+ if (space === -1)
269
+ return null; // a bare assignment invokes nothing
270
+ rest = rest.slice(space + 1).trimStart();
271
+ }
272
+ const first = rest.split(/\s+/)[0];
273
+ if (!first || first.includes('='))
274
+ return null;
275
+ // Basename, so `/usr/local/bin/claude` resolves like `claude`, with any
276
+ // surrounding quotes removed.
277
+ const base = first.replace(/^['"]|['"]$/g, '').split('/').pop();
278
+ return base && base !== '' ? base : null;
279
+ }
280
+ /**
281
+ * Map a harness name to its provider, honouring project-defined custom harnesses.
282
+ *
283
+ * Custom harnesses resolve to a real provider rather than failing as
284
+ * "unrecognisable", so the refusal a project sees is the accurate one — *this
285
+ * harness cannot reset in-session* — instead of a misleading "unknown harness".
286
+ * `buildCustomHarnessProvider` does not set `supportsContextReset`, so custom
287
+ * harnesses are unsupported by default; letting one declare support would be a
288
+ * one-field addition to `CustomHarnessConfig`, deliberately out of scope here.
289
+ */
290
+ export function harnessProviderFor(harnessName, customHarnesses) {
291
+ // Own-property lookup (see getBuiltinHarness): `harnessName` comes from a running
292
+ // builder's launch script — a user-controlled key — so a bare index could hand
293
+ // back an inherited Object member as a bogus provider.
294
+ const builtin = getBuiltinHarness(harnessName);
295
+ if (builtin)
296
+ return builtin;
297
+ if (customHarnesses && harnessName in customHarnesses) {
298
+ return buildCustomHarnessProvider(customHarnesses[harnessName]);
299
+ }
300
+ return null;
301
+ }
302
+ /**
303
+ * Derive artifact identity from the porch project.
304
+ *
305
+ * Porch names its project dir `<id>-<title>`, and spec/plan files share that
306
+ * stem by convention (`codev/specs/<id>-<title>.md`). Paths are returned only
307
+ * when the file exists.
308
+ */
309
+ export function artifactPaths(fs, worktree, porch) {
310
+ if (!porch)
311
+ return { specName: null, specPath: null, planPath: null };
312
+ const specName = porch.projectName;
313
+ const specRel = join('codev', 'specs', `${specName}.md`);
314
+ const planRel = join('codev', 'plans', `${specName}.md`);
315
+ return {
316
+ specName,
317
+ specPath: fs.exists(join(worktree, specRel)) ? specRel : null,
318
+ planPath: fs.exists(join(worktree, planRel)) ? planRel : null,
319
+ };
320
+ }
321
+ /**
322
+ * Resolve everything the re-orientation needs, or throw.
323
+ *
324
+ * Deliberately does NOT consult `builders.protocol_name`: it is NULL for
325
+ * spec-type builders, so a reader who "fixed" this to use the registry would
326
+ * break exactly the lanes the feature targets while the code looked more correct.
327
+ */
328
+ export function resolveBuilderContext(options) {
329
+ const { fs, builderId, worktree, branch, issueNumber, taskText, modeOverride, customHarnesses } = options;
330
+ if (!fs.exists(worktree)) {
331
+ throw new ContextResolutionError(`Worktree not found for '${builderId}': ${worktree}. The builder's registry row may be stale.`);
332
+ }
333
+ // Resolved once, with identity, and reused for both the protocol chain and
334
+ // the result. Two independent scans could disagree about which project is
335
+ // this builder's — the exact ambiguity the identity match exists to remove.
336
+ const identity = { builderId, issueNumber };
337
+ const porch = readPorchContext(fs, worktree, identity);
338
+ // --- Protocol: status.yaml → builder id → abort -------------------------
339
+ let protocol = porch?.protocol ?? null;
340
+ let protocolSource = 'status.yaml';
341
+ if (!protocol) {
342
+ const parsed = parseAgentName(builderId);
343
+ if (parsed) {
344
+ protocol = parsed.protocol;
345
+ protocolSource = 'builder-id';
346
+ }
347
+ }
348
+ if (!protocol) {
349
+ throw new ContextResolutionError(`Cannot determine the protocol for '${builderId}': no porch status.yaml under ${worktree}/codev/projects, ` +
350
+ `and the builder id is not in canonical 'builder-<protocol>-<id>' form. ` +
351
+ `Refusing to re-orient a builder without naming its protocol.`);
352
+ }
353
+ // --- Mode: flag → .builder-prompt.txt → abort ---------------------------
354
+ const promptMode = modeFromBuilderPrompt(fs, worktree);
355
+ // Positive evidence, not a negative inference: a bare `--task` spawn writes a
356
+ // prompt with no `## Mode:` heading, while `--task --protocol X` renders the
357
+ // full template (built BEFORE porch init, so it survives a failed init).
358
+ const isBareTask = Boolean(taskText) && promptMode === null;
359
+ let mode = modeOverride ?? null;
360
+ let modeSource = 'flag';
361
+ if (!mode) {
362
+ mode = promptMode;
363
+ modeSource = 'builder-prompt';
364
+ }
365
+ if (!mode && isBareTask) {
366
+ // A `--task` spawn writes a bare prompt with no `## Mode:` heading, so this
367
+ // lane could never auto-detect and every `afx refresh <task>` hard-errored.
368
+ //
369
+ // Defaulting to SOFT is not a guess dressed up as a fact: "strict" means
370
+ // *porch orchestrates this builder*, and a builder with no porch project
371
+ // cannot be strict. The source is recorded as `task-default` so the report
372
+ // says where it came from rather than implying the worktree stated it.
373
+ //
374
+ // Scoped deliberately to the no-porch case. A porch-driven builder missing
375
+ // its `## Mode:` line is a genuine ambiguity and still aborts below.
376
+ mode = 'soft';
377
+ modeSource = 'task-default';
378
+ }
379
+ if (!mode) {
380
+ throw new ContextResolutionError(`Cannot determine the mode (strict/soft) for '${builderId}': no '## Mode:' line in ` +
381
+ `${join(worktree, '.builder-prompt.txt')}, and this builder is not the bare ad-hoc-task ` +
382
+ `lane that defaults to soft (no task text, or a rendered protocol template). ` +
383
+ `Mode is not persisted anywhere else — pass --mode strict or --mode soft explicitly.`);
384
+ }
385
+ // --- Harness: .builder-start.sh → provider → capability check → abort ---
386
+ const harnessName = harnessFromLaunchScript(fs, worktree, customHarnesses);
387
+ if (!harnessName) {
388
+ throw new ContextResolutionError(`Cannot determine the harness for '${builderId}': no recognisable launch command in ` +
389
+ `${join(worktree, '.builder-start.sh')}. Refusing to type into a terminal whose agent is unknown.`);
390
+ }
391
+ const harness = harnessProviderFor(harnessName, customHarnesses);
392
+ if (!harness) {
393
+ throw new ContextResolutionError(`Harness '${harnessName}' is not a known provider — it is neither built in nor defined under ` +
394
+ `"harness" in .codev/config.json. Refusing to type into a terminal whose agent is unknown.`);
395
+ }
396
+ if (!harness.supportsContextReset) {
397
+ throw new ContextResolutionError(`Harness '${harnessName}' has no in-session context reset, so 'afx refresh' cannot clear this ` +
398
+ `builder's context. Only the claude harness supports it today. ` +
399
+ `To give this builder a fresh window, stop it and respawn without --resume.`);
400
+ }
401
+ const { specName, specPath, planPath } = artifactPaths(fs, worktree, porch);
402
+ return {
403
+ builderId,
404
+ worktree,
405
+ branch,
406
+ protocol,
407
+ protocolSource,
408
+ mode,
409
+ modeSource,
410
+ harnessName,
411
+ harness,
412
+ porch,
413
+ specName,
414
+ specPath,
415
+ planPath,
416
+ // Issue-driven protocols name the porch project after the issue, so the
417
+ // project id is the correct value when the registry row has none — but ONLY
418
+ // when it is actually an issue number. The `--task --protocol` lane's porch
419
+ // id is `builder-task-<id>`, which would render `- Issue: #builder-task-abc`
420
+ // and an unfollowable `gh issue view builder-task-abc` in the
421
+ // re-orientation. A fabricated issue reference is worse than none: it sends
422
+ // a freshly-reset builder to look up requirements that do not exist.
423
+ issueNumber: issueNumber ?? issueNumberFromPorchId(porch?.projectId),
424
+ taskText,
425
+ isBareTask,
426
+ };
427
+ }
428
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../../../src/agent-farm/commands/reset/context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,0BAA0B,GAG3B,MAAM,wBAAwB,CAAC;AAgFhC,gFAAgF;AAChF,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAC/C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACvC,CAAC;CACF;AA0CD;;;;;;;;;GASG;AACH,MAAM,UAAU,mBAAmB,CAAC,QAA8B;IAChE,MAAM,GAAG,GAAa,E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B,EAAE,CAAC;QAClC,MAAM,IAAI,sBAAsB,CAC9B,YAAY,WAAW,wEAAwE;YAC7F,gEAAgE;YAChE,4EAA4E,CAC/E,CAAC;IACJ,CAAC;IAED,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,aAAa,CAAC,EAAE,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;IAE5E,OAAO;QACL,SAAS;QACT,QAAQ;QACR,MAAM;QACN,QAAQ;QACR,cAAc;QACd,IAAI;QACJ,UAAU;QACV,WAAW;QACX,OAAO;QACP,KAAK;QACL,QAAQ;QACR,QAAQ;QACR,QAAQ;QACR,wEAAwE;QACxE,4EAA4E;QAC5E,4EAA4E;QAC5E,6EAA6E;QAC7E,8DAA8D;QAC9D,4EAA4E;QAC5E,qEAAqE;QACrE,WAAW,EAAE,WAAW,IAAI,sBAAsB,CAAC,KAAK,EAAE,SAAS,CAAC;QACpE,QAAQ;QACR,UAAU;KACX,CAAC;AACJ,CAAC"}
@@ -0,0 +1,192 @@
1
+ /**
2
+ * Reset orchestrator — the `afx refresh` state machine (Spec 1273).
3
+ *
4
+ * Composes the verified parts from phases 1–5 into the flow the architect ran by
5
+ * hand on 2026-07-27: request save-state → verify the receipt → wait for the
6
+ * turn to end → `/clear` → re-orient.
7
+ *
8
+ * ## Why this is a state machine over injected ports
9
+ *
10
+ * Reset is destructive in a way almost nothing else in Agent Farm is: `/clear`
11
+ * discards a builder's entire conversation, and there is no undo. Every safety
12
+ * property is therefore an ORDERING property — "the clear never happens before
13
+ * X" — and ordering is exactly what is hardest to prove by reading code.
14
+ *
15
+ * So the orchestrator does two things no ordinary command does:
16
+ *
17
+ * 1. Every externally-visible action goes through a port (`clock`, `fs`,
18
+ * `sendMessage`, `sendRaw`, `sendEscape`). Nothing here touches Tower, a
19
+ * PTY or the filesystem directly.
20
+ * 2. Every action is appended to an ordered **step log** before it is
21
+ * performed.
22
+ *
23
+ * The invariant tests then assert over that log — that `clear` never appears
24
+ * without `assemble` before it, that `escalate-esc` never precedes
25
+ * `receipt-accepted`, that an aborted run contains no `clear` at all. That turns
26
+ * "impossible by construction" from a claim in a comment into something a test
27
+ * can fail on.
28
+ *
29
+ * ## The invariants, and where each is enforced
30
+ *
31
+ * - **R1** (never clear without a saved re-orientation): `runReset` assembles and
32
+ * writes `.builder-reorient.md` at step 2, before any destructive step exists
33
+ * in the log. Assembly failure returns before the request is even sent.
34
+ * - **R2** (never clear without a verified receipt): the poll loop only leaves
35
+ * `awaiting-receipt` on `accepted`; every other exit path returns an aborted
36
+ * result.
37
+ * - **R3** (complete-or-abort re-orientation): delegated wholesale to
38
+ * `assembleReorientation`, which throws rather than emitting a partial frame.
39
+ * - **R4** (never clear a builder mid-turn): quiescence is a bounded wait, then
40
+ * at most ONE ESC escalation, then a second bounded wait. Still not quiet
41
+ * aborts — there is deliberately no third attempt and no "clear anyway".
42
+ */
43
+ import type { ResolvedBuilderContext } from './context.js';
44
+ import { type IssuePayload, type ReorientationPayload, type ResumeNoticePort, type SpawnPromptPort } from './reorient.js';
45
+ import { type ReceiptFsPort } from './receipt.js';
46
+ /** Filesystem surface. Superset of the receipt gate's, plus the R1 write. */
47
+ export interface ResetFsPort extends ReceiptFsPort {
48
+ write(path: string, content: string): void;
49
+ }
50
+ /** Wall clock and sleep, injected so tests run instantly and deterministically. */
51
+ export interface ClockPort {
52
+ now(): number;
53
+ sleep(ms: number): Promise<void>;
54
+ }
55
+ /** What the orchestrator can observe about the target terminal. */
56
+ export interface TerminalObservation {
57
+ exists: boolean;
58
+ /**
59
+ * Epoch ms of the last PTY output (phase 2).
60
+ *
61
+ * `undefined` means the Tower serving this terminal predates the field — NOT
62
+ * "no output ever". The quiescence gate refuses to proceed on `undefined`
63
+ * rather than treating it as 0, which would read as "silent since 1970" and
64
+ * clear a builder mid-turn. That is the exact R4 violation this field exists
65
+ * to prevent.
66
+ */
67
+ lastDataAt?: number;
68
+ /**
69
+ * Whether input can actually reach the process right now.
70
+ *
71
+ * `undefined` means an older Tower did not report it. Unlike `lastDataAt`,
72
+ * absence here is NOT treated as a refusal, and the asymmetry is deliberate:
73
+ * an unobservable turn state leads to a SILENT, destructive failure (clearing
74
+ * a builder mid-turn), whereas an unobservable write path leads to a LOUD,
75
+ * harmless one (the first send throws). Refuse only what fails quietly.
76
+ */
77
+ writable?: boolean;
78
+ }
79
+ /**
80
+ * The three ways to reach a terminal, kept as three distinct operations.
81
+ *
82
+ * They are separate methods rather than one `write(data, mode)` because the
83
+ * underlying transports are genuinely different and confusing two of them is
84
+ * silent. Tower's `escape` route calls `writeEscapeToSession`, which writes a
85
+ * hardcoded ESC and **ignores the message body entirely**
86
+ * (`servers/message-write.ts:46`). So a single `writeRaw(data)` bound to
87
+ * `escape: true` would deliver an ESC when asked to type `/clear` — the command
88
+ * would appear to succeed, the terminal would go quiet, and no context would be
89
+ * cleared. Splitting the port makes that mistake unrepresentable.
90
+ */
91
+ export interface TerminalPort {
92
+ observe(): Promise<TerminalObservation>;
93
+ /** Deliver a normal, formatted message (the save request, the re-orientation). */
94
+ sendMessage(message: string): Promise<void>;
95
+ /**
96
+ * Type unformatted text into the PTY (Tower's `raw: true`).
97
+ *
98
+ * This is how `/clear` is delivered — as literal typed input, which is what
99
+ * the verified manual recipe used (`afx send <builder> --raw '/clear'`).
100
+ */
101
+ sendRaw(text: string): Promise<void>;
102
+ /** Send a bare ESC keystroke (Tower's `escape: true`; phase 1's path). */
103
+ sendEscape(): Promise<void>;
104
+ /**
105
+ * Recent terminal output plus the buffer's total line count, for best-effort
106
+ * clear confirmation. Null when this Tower cannot serve it.
107
+ *
108
+ * `total` is what makes confirmation trustworthy. A refresh writes into this
109
+ * same terminal — the save request, the re-orientation — so any pattern matched
110
+ * against the whole buffer eventually collides with its OWN text. (It did,
111
+ * twice: first the echoed `/clear`, then the save request's header, which read
112
+ * "CONTEXT RESET INCOMING" before #1489.) Snapshotting `total` before the clear
113
+ * lets the check read only what the harness emitted AFTERWARDS.
114
+ */
115
+ readOutput?(): Promise<{
116
+ lines: string[];
117
+ total: number;
118
+ } | null>;
119
+ }
120
+ /**
121
+ * Every externally-visible action, in order.
122
+ *
123
+ * The names are part of the test contract — the invariant assertions match on
124
+ * them — so renaming one is an API change, not a cosmetic edit.
125
+ */
126
+ export type ResetStepName = 'resolve' | 'assemble' | 'write-reorient-file' | 'interrupt-first' | 'send-save-request' | 'receipt-accepted' | 'quiescent' | 'escalate-esc' | 'clear' | 'clear-confirmed' | 'clear-unconfirmed' | 'send-reorientation';
127
+ export interface ResetStep {
128
+ name: ResetStepName;
129
+ at: number;
130
+ detail?: string;
131
+ }
132
+ export type ResetOutcome = 'completed' | 'aborted' | 'dry-run';
133
+ export interface ResetResult {
134
+ outcome: ResetOutcome;
135
+ steps: ResetStep[];
136
+ /** Populated on `aborted`. Names the gate that failed, never just "failed". */
137
+ abortReason?: string;
138
+ nonce: string;
139
+ statePath: string;
140
+ reorientPath: string;
141
+ payload?: ReorientationPayload;
142
+ /**
143
+ * The exact save-state request the builder is asked to act on.
144
+ *
145
+ * Exposed rather than kept internal because `--dry-run` must be able to print
146
+ * it. The request is what the whole R2 gate is verifying compliance with, so
147
+ * "what exactly will the builder be told to write" is the single most useful
148
+ * thing a dry run can show — and it cannot be shown if the orchestrator keeps
149
+ * it to itself.
150
+ */
151
+ saveRequest: string;
152
+ /** Size of the accepted state file, for the report. */
153
+ stateBytes?: number;
154
+ }
155
+ /** Thrown for conditions that must stop the run before anything is touched. */
156
+ export declare class ResetPreflightError extends Error {
157
+ constructor(message: string);
158
+ }
159
+ export interface RunResetOptions {
160
+ context: ResolvedBuilderContext;
161
+ fs: ResetFsPort;
162
+ clock: ClockPort;
163
+ terminal: TerminalPort;
164
+ buildSpawnPrompt: SpawnPromptPort;
165
+ buildResumeNotice?: ResumeNoticePort;
166
+ issue?: IssuePayload;
167
+ /** Architect addendum from `--note` / `--file`. */
168
+ addendum?: string;
169
+ /** Print the plan and touch nothing. */
170
+ dryRun?: boolean;
171
+ /** ESC before the save request, for a builder already wedged mid-turn. */
172
+ interruptFirst?: boolean;
173
+ receiptTimeoutMs?: number;
174
+ pollIntervalMs?: number;
175
+ minBytes?: number;
176
+ stabilityWindowMs?: number;
177
+ quietWindowMs?: number;
178
+ quiesceTimeoutMs?: number;
179
+ quiescePostEscalationTimeoutMs?: number;
180
+ /** Override for the state-file name. Validated to stay inside the worktree. */
181
+ stateFileName?: string;
182
+ }
183
+ export declare function runReset(options: RunResetOptions): Promise<ResetResult>;
184
+ /**
185
+ * Render the step log as the run report.
186
+ *
187
+ * Each line carries its EVIDENCE, not just a tick. "Receipt accepted" alone is
188
+ * the kind of reassurance that hides a stale file; "accepted — 8,432 bytes
189
+ * carrying nonce a1b2c3" is checkable.
190
+ */
191
+ export declare function formatResetReport(result: ResetResult): string;
192
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/agent-farm/commands/reset/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAEH,OAAO,KAAK,EACV,sBAAsB,EACvB,MAAM,cAAc,CAAC;AACtB,OAAO,EAGL,KAAK,YAAY,EACjB,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACrB,MAAM,eAAe,CAAC;AACvB,OAAO,EAML,KAAK,aAAa,EAEnB,MAAM,cAAc,CAAC;AAgBtB,6EAA6E;AAC7E,MAAM,WAAW,WAAY,SAAQ,aAAa;IAChD,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5C;AAED,mFAAmF;AACnF,MAAM,WAAW,SAAS;IACxB,GAAG,IAAI,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAClC;AAED,mEAAmE;AACnE,MAAM,WAAW,mBAAmB;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