harnery 0.30.0 → 0.31.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 (517) hide show
  1. package/README.md +4 -4
  2. package/dist/commander.d.ts +8 -0
  3. package/dist/commander.d.ts.map +1 -1
  4. package/dist/commander.js +14 -13
  5. package/dist/commands/adapter.d.ts +12 -0
  6. package/dist/commands/adapter.d.ts.map +1 -0
  7. package/dist/commands/{harness.js → adapter.js} +35 -35
  8. package/dist/commands/agents.d.ts +3 -2
  9. package/dist/commands/agents.d.ts.map +1 -1
  10. package/dist/commands/agents.js +185 -74
  11. package/dist/commands/artifacts.d.ts +4 -0
  12. package/dist/commands/artifacts.d.ts.map +1 -0
  13. package/dist/commands/artifacts.js +143 -0
  14. package/dist/commands/backup.d.ts +1 -1
  15. package/dist/commands/backup.d.ts.map +1 -1
  16. package/dist/commands/backup.js +5 -2
  17. package/dist/commands/browse.d.ts.map +1 -1
  18. package/dist/commands/browse.js +310 -7
  19. package/dist/commands/checkpoint.d.ts +12 -0
  20. package/dist/commands/checkpoint.d.ts.map +1 -0
  21. package/dist/commands/checkpoint.js +162 -0
  22. package/dist/commands/context.d.ts +2 -2
  23. package/dist/commands/context.d.ts.map +1 -1
  24. package/dist/commands/context.js +3 -151
  25. package/dist/commands/decision.d.ts.map +1 -1
  26. package/dist/commands/decision.js +31 -7
  27. package/dist/commands/deinit.d.ts +2 -2
  28. package/dist/commands/deinit.js +15 -15
  29. package/dist/commands/doctor.js +23 -23
  30. package/dist/commands/governor.d.ts +4 -0
  31. package/dist/commands/governor.d.ts.map +1 -0
  32. package/dist/commands/{supervisor.js → governor.js} +133 -108
  33. package/dist/commands/grep.d.ts +1 -1
  34. package/dist/commands/grep.d.ts.map +1 -1
  35. package/dist/commands/grep.js +19 -2
  36. package/dist/commands/init.d.ts +12 -12
  37. package/dist/commands/init.d.ts.map +1 -1
  38. package/dist/commands/init.js +44 -30
  39. package/dist/commands/{session.d.ts → journal.d.ts} +2 -2
  40. package/dist/commands/journal.d.ts.map +1 -0
  41. package/dist/commands/{scratch.js → journal.js} +47 -47
  42. package/dist/commands/policy.js +1 -1
  43. package/dist/commands/presence.js +2 -2
  44. package/dist/commands/sync.d.ts +1 -1
  45. package/dist/commands/sync.js +3 -3
  46. package/dist/commands/tunnel.d.ts +16 -0
  47. package/dist/commands/tunnel.d.ts.map +1 -1
  48. package/dist/commands/tunnel.js +213 -27
  49. package/dist/commands/web-fetch.js +1 -1
  50. package/dist/commands/web.d.ts +19 -0
  51. package/dist/commands/web.d.ts.map +1 -1
  52. package/dist/commands/web.js +51 -0
  53. package/dist/commands/work.d.ts.map +1 -1
  54. package/dist/commands/work.js +38 -22
  55. package/dist/commands/workflow.d.ts.map +1 -1
  56. package/dist/commands/workflow.js +35 -28
  57. package/dist/core/{harnesses → adapters}/attest-projection.d.ts +2 -2
  58. package/dist/core/adapters/attest-projection.d.ts.map +1 -0
  59. package/dist/core/{harnesses → adapters}/attest.d.ts +16 -16
  60. package/dist/core/adapters/attest.d.ts.map +1 -0
  61. package/dist/core/{harnesses → adapters}/attest.js +9 -9
  62. package/dist/core/{harnesses → adapters}/attestation.d.ts +16 -16
  63. package/dist/core/adapters/attestation.d.ts.map +1 -0
  64. package/dist/core/{harnesses → adapters}/attestation.js +20 -20
  65. package/dist/core/{harnesses → adapters}/bench.d.ts +12 -12
  66. package/dist/core/adapters/bench.d.ts.map +1 -0
  67. package/dist/core/{harnesses → adapters}/bench.js +12 -12
  68. package/dist/core/adapters/index.d.ts +13 -0
  69. package/dist/core/adapters/index.d.ts.map +1 -0
  70. package/dist/core/adapters/index.js +6 -0
  71. package/dist/core/{harnesses → adapters}/profiles.d.ts +11 -11
  72. package/dist/core/adapters/profiles.d.ts.map +1 -0
  73. package/dist/core/{harnesses → adapters}/profiles.js +11 -11
  74. package/dist/core/adapters/registry.d.ts +15 -0
  75. package/dist/core/adapters/registry.d.ts.map +1 -0
  76. package/dist/core/{harnesses → adapters}/registry.js +11 -11
  77. package/dist/core/{harnesses → adapters}/types.d.ts +23 -23
  78. package/dist/core/adapters/types.d.ts.map +1 -0
  79. package/dist/core/{harnesses → adapters}/types.js +1 -1
  80. package/dist/core/agents/canonical-emit.d.ts +9 -14
  81. package/dist/core/agents/canonical-emit.d.ts.map +1 -1
  82. package/dist/core/agents/canonical-emit.js +15 -44
  83. package/dist/core/agents/cli-emit.js +1 -1
  84. package/dist/core/agents/cli.js +30 -26
  85. package/dist/core/agents/codex-replay.d.ts +1 -1
  86. package/dist/core/agents/codex-replay.js +6 -6
  87. package/dist/core/agents/coord-bin.d.ts +33 -0
  88. package/dist/core/agents/coord-bin.d.ts.map +1 -0
  89. package/dist/core/agents/coord-bin.js +89 -0
  90. package/dist/core/agents/coord-client.d.ts +78 -8
  91. package/dist/core/agents/coord-client.d.ts.map +1 -1
  92. package/dist/core/agents/coord-client.js +303 -75
  93. package/dist/core/agents/events/consume.d.ts +1 -1
  94. package/dist/core/agents/events/emit.d.ts +5 -6
  95. package/dist/core/agents/events/emit.d.ts.map +1 -1
  96. package/dist/core/agents/events/emit.js +2 -2
  97. package/dist/core/agents/paths.d.ts +5 -2
  98. package/dist/core/agents/paths.d.ts.map +1 -1
  99. package/dist/core/agents/paths.js +7 -13
  100. package/dist/core/agents/render/prompt-context.d.ts +21 -9
  101. package/dist/core/agents/render/prompt-context.d.ts.map +1 -1
  102. package/dist/core/agents/render/prompt-context.js +82 -30
  103. package/dist/core/agents/render/session-context.d.ts +1 -1
  104. package/dist/core/agents/render/session-context.js +5 -5
  105. package/dist/core/agents/rules/claim-conflict.d.ts +2 -6
  106. package/dist/core/agents/rules/claim-conflict.d.ts.map +1 -1
  107. package/dist/core/agents/rules/claim-conflict.js +1 -1
  108. package/dist/core/agents/rules/commit-conflict.js +98 -22
  109. package/dist/core/agents/rules/stop-hook.d.ts +9 -9
  110. package/dist/core/agents/rules/stop-hook.d.ts.map +1 -1
  111. package/dist/core/agents/rules/stop-hook.js +23 -5
  112. package/dist/core/agents/rules/verdict.d.ts +14 -0
  113. package/dist/core/agents/rules/verdict.d.ts.map +1 -0
  114. package/dist/core/agents/rules/verdict.js +1 -0
  115. package/dist/core/agents/session-events.js +3 -3
  116. package/dist/core/agents/state/council.d.ts +1 -1
  117. package/dist/core/agents/state/council.js +1 -1
  118. package/dist/core/agents/state/heartbeat-projector.d.ts +3 -2
  119. package/dist/core/agents/state/heartbeat-projector.d.ts.map +1 -1
  120. package/dist/core/agents/state/heartbeat-projector.js +14 -10
  121. package/dist/core/agents/state/heartbeat-writer.d.ts +1 -1
  122. package/dist/core/agents/state/heartbeat-writer.js +12 -12
  123. package/dist/core/agents/state/{scratch.d.ts → journal.d.ts} +7 -7
  124. package/dist/core/agents/state/{scratch.d.ts.map → journal.d.ts.map} +1 -1
  125. package/dist/core/agents/state/{scratch.js → journal.js} +12 -12
  126. package/dist/core/agents/state/pidmap.d.ts +28 -4
  127. package/dist/core/agents/state/pidmap.d.ts.map +1 -1
  128. package/dist/core/agents/state/pidmap.js +130 -15
  129. package/dist/core/agents/state/proc-start.d.ts +95 -0
  130. package/dist/core/agents/state/proc-start.d.ts.map +1 -0
  131. package/dist/core/agents/state/proc-start.js +199 -0
  132. package/dist/core/agents/state/shell-mutation.d.ts +1 -1
  133. package/dist/core/agents/state/shell-mutation.js +1 -1
  134. package/dist/core/agents/state/stale-sweep.js +7 -7
  135. package/dist/core/artifacts/index.d.ts +86 -0
  136. package/dist/core/artifacts/index.d.ts.map +1 -0
  137. package/dist/core/artifacts/index.js +421 -0
  138. package/dist/core/config.d.ts +9 -2
  139. package/dist/core/config.d.ts.map +1 -1
  140. package/dist/core/config.js +26 -2
  141. package/dist/core/context/index.d.ts +12 -12
  142. package/dist/core/context/index.js +10 -10
  143. package/dist/core/governor/adapter-spread.d.ts +52 -0
  144. package/dist/core/governor/adapter-spread.d.ts.map +1 -0
  145. package/dist/core/governor/adapter-spread.js +52 -0
  146. package/dist/core/governor/index.d.ts +7 -0
  147. package/dist/core/governor/index.d.ts.map +1 -0
  148. package/dist/core/governor/index.js +6 -0
  149. package/dist/core/governor/plan-api.d.ts +38 -0
  150. package/dist/core/governor/plan-api.d.ts.map +1 -0
  151. package/dist/core/governor/plan-api.js +83 -0
  152. package/dist/core/governor/plan-read.d.ts +5 -0
  153. package/dist/core/governor/plan-read.d.ts.map +1 -0
  154. package/dist/core/{supervisor → governor}/plan-read.js +66 -52
  155. package/dist/core/{supervisor → governor}/plan-types.d.ts +57 -56
  156. package/dist/core/governor/plan-types.d.ts.map +1 -0
  157. package/dist/core/{supervisor → governor}/plan-types.js +4 -4
  158. package/dist/core/governor/planning.d.ts +48 -0
  159. package/dist/core/governor/planning.d.ts.map +1 -0
  160. package/dist/core/{supervisor → governor}/planning.js +125 -94
  161. package/dist/core/governor/read.d.ts +6 -0
  162. package/dist/core/governor/read.d.ts.map +1 -0
  163. package/dist/core/governor/read.js +4 -0
  164. package/dist/core/governor/runner.d.ts +37 -0
  165. package/dist/core/governor/runner.d.ts.map +1 -0
  166. package/dist/core/{supervisor → governor}/runner.js +15 -15
  167. package/dist/core/governor/service-read.d.ts +6 -0
  168. package/dist/core/governor/service-read.d.ts.map +1 -0
  169. package/dist/core/{supervisor → governor}/service-read.js +12 -12
  170. package/dist/core/governor/service.d.ts +114 -0
  171. package/dist/core/governor/service.d.ts.map +1 -0
  172. package/dist/core/{supervisor → governor}/service.js +57 -57
  173. package/dist/core/governor/state.d.ts +116 -0
  174. package/dist/core/governor/state.d.ts.map +1 -0
  175. package/dist/core/{supervisor → governor}/state.js +228 -108
  176. package/dist/core/hooks/adapter/detect.d.ts +9 -0
  177. package/dist/core/hooks/{harness → adapter}/detect.d.ts.map +1 -1
  178. package/dist/core/hooks/{harness → adapter}/detect.js +8 -8
  179. package/dist/core/hooks/{harness → adapter}/events.d.ts +15 -14
  180. package/dist/core/hooks/adapter/events.d.ts.map +1 -0
  181. package/dist/core/hooks/{harness → adapter}/events.js +5 -5
  182. package/dist/core/hooks/{harness → adapter}/output.d.ts +20 -14
  183. package/dist/core/hooks/adapter/output.d.ts.map +1 -0
  184. package/dist/core/hooks/{harness → adapter}/output.js +30 -22
  185. package/dist/core/hooks/{harness → adapter}/parse.d.ts +5 -5
  186. package/dist/core/hooks/{harness → adapter}/parse.d.ts.map +1 -1
  187. package/dist/core/hooks/{harness → adapter}/parse.js +4 -4
  188. package/dist/core/hooks/{harness → adapter}/wiring.d.ts +15 -15
  189. package/dist/core/hooks/{harness → adapter}/wiring.d.ts.map +1 -1
  190. package/dist/core/hooks/{harness → adapter}/wiring.js +13 -13
  191. package/dist/core/hooks/cli.d.ts +3 -3
  192. package/dist/core/hooks/cli.js +187 -162
  193. package/dist/core/hooks/effects/image-capture.d.ts +5 -5
  194. package/dist/core/hooks/effects/image-capture.d.ts.map +1 -1
  195. package/dist/core/hooks/effects/image-capture.js +3 -3
  196. package/dist/core/hooks/effects/index.d.ts +12 -12
  197. package/dist/core/hooks/effects/index.d.ts.map +1 -1
  198. package/dist/core/hooks/effects/index.js +19 -19
  199. package/dist/core/hooks/events/emit.d.ts +2 -2
  200. package/dist/core/hooks/events/emit.d.ts.map +1 -1
  201. package/dist/core/hooks/events/emit.js +1 -1
  202. package/dist/core/hooks/events/rotate.js +1 -1
  203. package/dist/core/hooks/events/schema.d.ts +13 -5
  204. package/dist/core/hooks/events/schema.d.ts.map +1 -1
  205. package/dist/core/hooks/guard-path.d.ts +2 -2
  206. package/dist/core/hooks/guard-path.js +2 -2
  207. package/dist/core/hooks/index.d.ts +1 -1
  208. package/dist/core/hooks/index.d.ts.map +1 -1
  209. package/dist/core/hooks/resolve/anchor.d.ts +14 -5
  210. package/dist/core/hooks/resolve/anchor.d.ts.map +1 -1
  211. package/dist/core/hooks/resolve/anchor.js +64 -7
  212. package/dist/core/hooks/resolve/coord-root.d.ts +16 -11
  213. package/dist/core/hooks/resolve/coord-root.d.ts.map +1 -1
  214. package/dist/core/hooks/resolve/coord-root.js +18 -43
  215. package/dist/core/hooks/resolve/intent.js +1 -1
  216. package/dist/core/hooks/resolve/owner.d.ts +1 -1
  217. package/dist/core/hooks/resolve/owner.d.ts.map +1 -1
  218. package/dist/core/hooks/resolve/owner.js +11 -5
  219. package/dist/core/{scratch → journal}/index.d.ts +25 -25
  220. package/dist/core/{scratch → journal}/index.d.ts.map +1 -1
  221. package/dist/core/{scratch → journal}/index.js +38 -38
  222. package/dist/core/policy/evaluate.d.ts +1 -1
  223. package/dist/core/policy/evaluate.d.ts.map +1 -1
  224. package/dist/core/policy/evaluate.js +7 -7
  225. package/dist/core/policy/types.d.ts +3 -3
  226. package/dist/core/policy/types.d.ts.map +1 -1
  227. package/dist/core/work/state.d.ts +12 -4
  228. package/dist/core/work/state.d.ts.map +1 -1
  229. package/dist/core/work/state.js +50 -17
  230. package/dist/core/workflow/adapters.d.ts +17 -0
  231. package/dist/core/workflow/adapters.d.ts.map +1 -0
  232. package/dist/core/workflow/adapters.js +21 -0
  233. package/dist/core/workflow/approvals.js +6 -6
  234. package/dist/core/workflow/billing.d.ts +9 -9
  235. package/dist/core/workflow/billing.js +9 -9
  236. package/dist/core/workflow/child-env.d.ts +10 -2
  237. package/dist/core/workflow/child-env.d.ts.map +1 -1
  238. package/dist/core/workflow/child-env.js +12 -4
  239. package/dist/core/workflow/engine.d.ts +15 -5
  240. package/dist/core/workflow/engine.d.ts.map +1 -1
  241. package/dist/core/workflow/engine.js +138 -83
  242. package/dist/core/workflow/evidence-preflight.d.ts +24 -0
  243. package/dist/core/workflow/evidence-preflight.d.ts.map +1 -0
  244. package/dist/core/workflow/evidence-preflight.js +134 -0
  245. package/dist/core/workflow/index.d.ts +1 -1
  246. package/dist/core/workflow/index.d.ts.map +1 -1
  247. package/dist/core/workflow/proof.d.ts +11 -5
  248. package/dist/core/workflow/proof.d.ts.map +1 -1
  249. package/dist/core/workflow/proof.js +45 -36
  250. package/dist/core/workflow/run-state.d.ts +1 -1
  251. package/dist/core/workflow/run-state.js +7 -7
  252. package/dist/core/workflow/sandbox-projection.d.ts +6 -6
  253. package/dist/core/workflow/sandbox-projection.d.ts.map +1 -1
  254. package/dist/core/workflow/sandbox-projection.js +11 -11
  255. package/dist/core/workflow/spawn-claude.d.ts +3 -3
  256. package/dist/core/workflow/spawn-claude.d.ts.map +1 -1
  257. package/dist/core/workflow/spawn-claude.js +9 -6
  258. package/dist/core/workflow/spawn-codex.d.ts +4 -4
  259. package/dist/core/workflow/spawn-codex.d.ts.map +1 -1
  260. package/dist/core/workflow/spawn-codex.js +9 -6
  261. package/dist/core/workflow/spawn-cursor.d.ts +4 -4
  262. package/dist/core/workflow/spawn-cursor.d.ts.map +1 -1
  263. package/dist/core/workflow/spawn-cursor.js +9 -6
  264. package/dist/core/workflow/spawn-failure.d.ts +1 -1
  265. package/dist/core/workflow/spawn-failure.js +1 -1
  266. package/dist/core/workflow/specialists.js +2 -2
  267. package/dist/core/workflow/{journal.d.ts → transcript.d.ts} +8 -8
  268. package/dist/core/workflow/transcript.d.ts.map +1 -0
  269. package/dist/core/workflow/{journal.js → transcript.js} +14 -14
  270. package/dist/core/workflow/types.d.ts +98 -51
  271. package/dist/core/workflow/types.d.ts.map +1 -1
  272. package/dist/core/workflow/types.js +11 -1
  273. package/dist/core/workflow/validate.d.ts +1 -1
  274. package/dist/core/workflow/validate.js +1 -1
  275. package/dist/core/workflow/workspaces/cancellation.js +2 -2
  276. package/dist/core/workflow/workspaces/cleanup.js +2 -2
  277. package/dist/core/workflow/workspaces/execution.js +6 -6
  278. package/dist/core/workflow/workspaces/inspect.js +9 -9
  279. package/dist/core/workflow/workspaces/integration.js +14 -14
  280. package/dist/core/workflow/workspaces/lifecycle.d.ts +1 -1
  281. package/dist/core/workflow/workspaces/lifecycle.d.ts.map +1 -1
  282. package/dist/core/workflow/workspaces/lifecycle.js +9 -9
  283. package/dist/core/workflow/workspaces/local-git.d.ts.map +1 -1
  284. package/dist/core/workflow/workspaces/local-git.js +39 -5
  285. package/dist/core/workflow/workspaces/recovery.js +3 -3
  286. package/dist/core/workflow/workspaces/state.d.ts +1 -1
  287. package/dist/core/workflow/workspaces/state.d.ts.map +1 -1
  288. package/dist/core/workflow/workspaces/state.js +3 -3
  289. package/dist/core/workflow/workspaces/types.d.ts +1 -1
  290. package/dist/core/workflow/workspaces/types.d.ts.map +1 -1
  291. package/dist/lib/browser/asserts.d.ts +28 -0
  292. package/dist/lib/browser/asserts.d.ts.map +1 -0
  293. package/dist/lib/browser/asserts.js +152 -0
  294. package/dist/lib/browser/client.d.ts +49 -0
  295. package/dist/lib/browser/client.d.ts.map +1 -1
  296. package/dist/lib/browser/client.js +155 -14
  297. package/dist/lib/browser/content-checks.d.ts +108 -0
  298. package/dist/lib/browser/content-checks.d.ts.map +1 -0
  299. package/dist/lib/browser/content-checks.js +474 -0
  300. package/dist/lib/browser/critique.d.ts +91 -0
  301. package/dist/lib/browser/critique.d.ts.map +1 -0
  302. package/dist/lib/browser/critique.js +167 -0
  303. package/dist/lib/browser/geometry.d.ts +32 -0
  304. package/dist/lib/browser/geometry.d.ts.map +1 -1
  305. package/dist/lib/browser/geometry.js +244 -1
  306. package/dist/lib/browser/index.d.ts +4 -1
  307. package/dist/lib/browser/index.d.ts.map +1 -1
  308. package/dist/lib/browser/index.js +2 -0
  309. package/dist/lib/claude-desktop.d.ts.map +1 -1
  310. package/dist/lib/claude-desktop.js +4 -1
  311. package/dist/lib/context/index.js +9 -2
  312. package/dist/lib/council/index.d.ts +6 -6
  313. package/dist/lib/council/index.d.ts.map +1 -1
  314. package/dist/lib/council/index.js +8 -8
  315. package/dist/lib/identities/assume.d.ts +2 -2
  316. package/dist/lib/identities/assume.js +7 -7
  317. package/dist/lib/instructions/apply.d.ts +3 -3
  318. package/dist/lib/instructions/apply.d.ts.map +1 -1
  319. package/dist/lib/instructions/apply.js +75 -27
  320. package/dist/lib/instructions/host-addendum.d.ts +54 -0
  321. package/dist/lib/instructions/host-addendum.d.ts.map +1 -0
  322. package/dist/lib/instructions/host-addendum.js +107 -0
  323. package/dist/lib/instructions/templates.d.ts +10 -3
  324. package/dist/lib/instructions/templates.d.ts.map +1 -1
  325. package/dist/lib/instructions/templates.js +41 -12
  326. package/dist/lib/machine.d.ts +2 -2
  327. package/dist/lib/machine.js +2 -2
  328. package/package.json +26 -21
  329. package/schemas/config.schema.json +26 -1
  330. package/src/commander.ts +22 -13
  331. package/src/commands/{harness.ts → adapter.ts} +46 -46
  332. package/src/commands/agents.ts +200 -78
  333. package/src/commands/artifacts.ts +168 -0
  334. package/src/commands/backup.ts +47 -33
  335. package/src/commands/browse.ts +438 -2
  336. package/src/commands/checkpoint.ts +196 -0
  337. package/src/commands/context.ts +3 -176
  338. package/src/commands/decision.ts +41 -7
  339. package/src/commands/deinit.ts +16 -16
  340. package/src/commands/doctor.ts +28 -28
  341. package/src/commands/{supervisor.ts → governor.ts} +184 -154
  342. package/src/commands/grep.ts +19 -2
  343. package/src/commands/init.ts +50 -34
  344. package/src/commands/{scratch.ts → journal.ts} +60 -60
  345. package/src/commands/policy.ts +1 -1
  346. package/src/commands/presence.ts +2 -2
  347. package/src/commands/sync.ts +3 -3
  348. package/src/commands/tunnel.ts +256 -38
  349. package/src/commands/web-fetch.ts +1 -1
  350. package/src/commands/web.ts +56 -1
  351. package/src/commands/work.ts +50 -35
  352. package/src/commands/workflow.ts +43 -34
  353. package/src/core/{harnesses → adapters}/attest-projection.ts +2 -2
  354. package/src/core/{harnesses → adapters}/attest.ts +27 -27
  355. package/src/core/{harnesses → adapters}/attestation.ts +41 -41
  356. package/src/core/{harnesses → adapters}/bench.ts +34 -43
  357. package/src/core/adapters/index.ts +56 -0
  358. package/src/core/{harnesses → adapters}/profiles.ts +16 -16
  359. package/src/core/{harnesses → adapters}/registry.ts +23 -23
  360. package/src/core/{harnesses → adapters}/types.ts +23 -23
  361. package/src/core/agents/canonical-emit.ts +16 -43
  362. package/src/core/agents/cli-emit.ts +1 -1
  363. package/src/core/agents/cli.ts +30 -28
  364. package/src/core/agents/codex-replay.ts +6 -6
  365. package/src/core/agents/coord-bin.ts +92 -0
  366. package/src/core/agents/coord-client.ts +302 -78
  367. package/src/core/agents/events/consume.ts +1 -1
  368. package/src/core/agents/events/emit.ts +7 -6
  369. package/src/core/agents/paths.ts +7 -11
  370. package/src/core/agents/render/prompt-context.ts +107 -31
  371. package/src/core/agents/render/session-context.ts +6 -6
  372. package/src/core/agents/rules/claim-conflict.ts +4 -7
  373. package/src/core/agents/rules/commit-conflict.ts +103 -22
  374. package/src/core/agents/rules/stop-hook.ts +33 -17
  375. package/src/core/agents/rules/verdict.ts +13 -0
  376. package/src/core/agents/session-events.ts +4 -4
  377. package/src/core/agents/state/council.ts +1 -1
  378. package/src/core/agents/state/heartbeat-projector.ts +16 -12
  379. package/src/core/agents/state/heartbeat-writer.ts +12 -12
  380. package/src/core/agents/state/{scratch.ts → journal.ts} +12 -12
  381. package/src/core/agents/state/pidmap.ts +130 -15
  382. package/src/core/agents/state/proc-start.ts +208 -0
  383. package/src/core/agents/state/shell-mutation.ts +1 -1
  384. package/src/core/agents/state/stale-sweep.ts +7 -7
  385. package/src/core/artifacts/index.ts +557 -0
  386. package/src/core/config.ts +30 -2
  387. package/src/core/context/index.ts +15 -15
  388. package/src/core/governor/adapter-spread.ts +82 -0
  389. package/src/core/governor/index.ts +91 -0
  390. package/src/core/governor/plan-api.ts +115 -0
  391. package/src/core/{supervisor → governor}/plan-read.ts +112 -97
  392. package/src/core/{supervisor → governor}/plan-types.ts +59 -56
  393. package/src/core/{supervisor → governor}/planning.ts +223 -192
  394. package/src/core/governor/read.ts +59 -0
  395. package/src/core/{supervisor → governor}/runner.ts +39 -39
  396. package/src/core/{supervisor → governor}/service-read.ts +22 -22
  397. package/src/core/{supervisor → governor}/service.ts +117 -119
  398. package/src/core/{supervisor → governor}/state.ts +325 -167
  399. package/src/core/hooks/adapter/detect.ts +30 -0
  400. package/src/core/hooks/{harness → adapter}/events.ts +16 -14
  401. package/src/core/hooks/{harness → adapter}/output.ts +31 -23
  402. package/src/core/hooks/{harness → adapter}/parse.ts +5 -5
  403. package/src/core/hooks/{harness → adapter}/wiring.ts +21 -21
  404. package/src/core/hooks/cli.ts +197 -173
  405. package/src/core/hooks/effects/image-capture.ts +6 -6
  406. package/src/core/hooks/effects/index.ts +19 -19
  407. package/src/core/hooks/events/emit.ts +3 -3
  408. package/src/core/hooks/events/rotate.ts +1 -1
  409. package/src/core/hooks/events/schema.ts +15 -7
  410. package/src/core/hooks/guard-path.ts +2 -2
  411. package/src/core/hooks/index.ts +1 -1
  412. package/src/core/hooks/resolve/anchor.ts +63 -8
  413. package/src/core/hooks/resolve/coord-root.ts +18 -40
  414. package/src/core/hooks/resolve/intent.ts +1 -1
  415. package/src/core/hooks/resolve/owner.ts +11 -5
  416. package/src/core/{scratch → journal}/index.ts +53 -53
  417. package/src/core/policy/evaluate.ts +8 -8
  418. package/src/core/policy/types.ts +3 -3
  419. package/src/core/work/state.ts +65 -23
  420. package/src/core/workflow/adapters.ts +33 -0
  421. package/src/core/workflow/approvals.ts +7 -7
  422. package/src/core/workflow/billing.ts +12 -12
  423. package/src/core/workflow/child-env.ts +13 -4
  424. package/src/core/workflow/engine.ts +155 -90
  425. package/src/core/workflow/evidence-preflight.ts +165 -0
  426. package/src/core/workflow/index.ts +3 -3
  427. package/src/core/workflow/proof.ts +60 -50
  428. package/src/core/workflow/run-state.ts +7 -7
  429. package/src/core/workflow/sandbox-projection.ts +16 -16
  430. package/src/core/workflow/spawn-claude.ts +13 -10
  431. package/src/core/workflow/spawn-codex.ts +13 -10
  432. package/src/core/workflow/spawn-cursor.ts +13 -10
  433. package/src/core/workflow/spawn-failure.ts +1 -1
  434. package/src/core/workflow/specialists.ts +2 -2
  435. package/src/core/workflow/{journal.ts → transcript.ts} +16 -16
  436. package/src/core/workflow/types.ts +108 -51
  437. package/src/core/workflow/validate.ts +1 -1
  438. package/src/core/workflow/workspaces/cancellation.ts +2 -2
  439. package/src/core/workflow/workspaces/cleanup.ts +2 -2
  440. package/src/core/workflow/workspaces/execution.ts +6 -6
  441. package/src/core/workflow/workspaces/inspect.ts +14 -11
  442. package/src/core/workflow/workspaces/integration.ts +18 -14
  443. package/src/core/workflow/workspaces/lifecycle.ts +10 -10
  444. package/src/core/workflow/workspaces/local-git.ts +47 -5
  445. package/src/core/workflow/workspaces/recovery.ts +3 -3
  446. package/src/core/workflow/workspaces/state.ts +4 -3
  447. package/src/core/workflow/workspaces/types.ts +1 -1
  448. package/src/lib/browser/asserts.ts +177 -0
  449. package/src/lib/browser/client.ts +189 -14
  450. package/src/lib/browser/content-checks.ts +571 -0
  451. package/src/lib/browser/critique.ts +231 -0
  452. package/src/lib/browser/geometry.ts +297 -1
  453. package/src/lib/browser/index.ts +34 -0
  454. package/src/lib/claude-desktop.ts +4 -1
  455. package/src/lib/context/index.ts +11 -1
  456. package/src/lib/council/index.ts +9 -9
  457. package/src/lib/identities/assume.ts +7 -7
  458. package/src/lib/instructions/apply.ts +87 -25
  459. package/src/lib/instructions/host-addendum.ts +126 -0
  460. package/src/lib/instructions/templates.ts +44 -15
  461. package/src/lib/machine.ts +2 -2
  462. package/dist/commands/harness.d.ts +0 -12
  463. package/dist/commands/harness.d.ts.map +0 -1
  464. package/dist/commands/scratch.d.ts +0 -4
  465. package/dist/commands/scratch.d.ts.map +0 -1
  466. package/dist/commands/session.d.ts.map +0 -1
  467. package/dist/commands/session.js +0 -162
  468. package/dist/commands/supervisor.d.ts +0 -4
  469. package/dist/commands/supervisor.d.ts.map +0 -1
  470. package/dist/core/harnesses/attest-projection.d.ts.map +0 -1
  471. package/dist/core/harnesses/attest.d.ts.map +0 -1
  472. package/dist/core/harnesses/attestation.d.ts.map +0 -1
  473. package/dist/core/harnesses/bench.d.ts.map +0 -1
  474. package/dist/core/harnesses/index.d.ts +0 -13
  475. package/dist/core/harnesses/index.d.ts.map +0 -1
  476. package/dist/core/harnesses/index.js +0 -6
  477. package/dist/core/harnesses/profiles.d.ts.map +0 -1
  478. package/dist/core/harnesses/registry.d.ts +0 -15
  479. package/dist/core/harnesses/registry.d.ts.map +0 -1
  480. package/dist/core/harnesses/types.d.ts.map +0 -1
  481. package/dist/core/hooks/harness/detect.d.ts +0 -9
  482. package/dist/core/hooks/harness/events.d.ts.map +0 -1
  483. package/dist/core/hooks/harness/output.d.ts.map +0 -1
  484. package/dist/core/supervisor/index.d.ts +0 -7
  485. package/dist/core/supervisor/index.d.ts.map +0 -1
  486. package/dist/core/supervisor/index.js +0 -6
  487. package/dist/core/supervisor/plan-api.d.ts +0 -23
  488. package/dist/core/supervisor/plan-api.d.ts.map +0 -1
  489. package/dist/core/supervisor/plan-api.js +0 -50
  490. package/dist/core/supervisor/plan-read.d.ts +0 -5
  491. package/dist/core/supervisor/plan-read.d.ts.map +0 -1
  492. package/dist/core/supervisor/plan-types.d.ts.map +0 -1
  493. package/dist/core/supervisor/planning.d.ts +0 -33
  494. package/dist/core/supervisor/planning.d.ts.map +0 -1
  495. package/dist/core/supervisor/read.d.ts +0 -6
  496. package/dist/core/supervisor/read.d.ts.map +0 -1
  497. package/dist/core/supervisor/read.js +0 -4
  498. package/dist/core/supervisor/runner.d.ts +0 -37
  499. package/dist/core/supervisor/runner.d.ts.map +0 -1
  500. package/dist/core/supervisor/service-read.d.ts +0 -6
  501. package/dist/core/supervisor/service-read.d.ts.map +0 -1
  502. package/dist/core/supervisor/service.d.ts +0 -114
  503. package/dist/core/supervisor/service.d.ts.map +0 -1
  504. package/dist/core/supervisor/state.d.ts +0 -95
  505. package/dist/core/supervisor/state.d.ts.map +0 -1
  506. package/dist/core/workflow/harnesses.d.ts +0 -17
  507. package/dist/core/workflow/harnesses.d.ts.map +0 -1
  508. package/dist/core/workflow/harnesses.js +0 -21
  509. package/dist/core/workflow/journal.d.ts.map +0 -1
  510. package/src/commands/session.ts +0 -187
  511. package/src/core/harnesses/index.ts +0 -56
  512. package/src/core/hooks/harness/detect.ts +0 -30
  513. package/src/core/supervisor/index.ts +0 -89
  514. package/src/core/supervisor/plan-api.ts +0 -73
  515. package/src/core/supervisor/read.ts +0 -59
  516. package/src/core/workflow/harnesses.ts +0 -33
  517. /package/dist/core/{harnesses → adapters}/attest-projection.js +0 -0
@@ -0,0 +1,12 @@
1
+ import type { Command } from "commander";
2
+ import type { EmitContext, HarneryProgramContext } from "../commander.js";
3
+ /**
4
+ * `harn checkpoint`: durable context continuity across compaction.
5
+ *
6
+ * A checkpoint captures enough of the current work that a fresh generation of
7
+ * the same session can resume it after the adapter compacts or restarts.
8
+ * `create` writes a capsule, `show` prints the latest one, `status` reports the
9
+ * phase, generation, and whatever context telemetry the adapter supplied.
10
+ */
11
+ export declare function registerCheckpointCommand(program: Command, emit: EmitContext, context?: HarneryProgramContext): void;
12
+ //# sourceMappingURL=checkpoint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkpoint.d.ts","sourceRoot":"","sources":["../../src/commands/checkpoint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAU1E;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,WAAW,EACjB,OAAO,CAAC,EAAE,qBAAqB,GAC9B,IAAI,CA2HN"}
@@ -0,0 +1,162 @@
1
+ import { monorepoRoot, readHeartbeat, resolveOwner } from "../core/agents/index.js";
2
+ import { checkpointContext, readContextState, readLatestCapsule, } from "../core/context/index.js";
3
+ /**
4
+ * `harn checkpoint`: durable context continuity across compaction.
5
+ *
6
+ * A checkpoint captures enough of the current work that a fresh generation of
7
+ * the same session can resume it after the adapter compacts or restarts.
8
+ * `create` writes a capsule, `show` prints the latest one, `status` reports the
9
+ * phase, generation, and whatever context telemetry the adapter supplied.
10
+ */
11
+ export function registerCheckpointCommand(program, emit, context) {
12
+ const command = program
13
+ .command("checkpoint")
14
+ .description("Durable context-continuity capsules: create one, show the latest, or report continuity phase.")
15
+ .option("--json", "Structured JSON output");
16
+ command
17
+ .command("status")
18
+ .description("Show context-continuity phase, generation, and latest telemetry")
19
+ .option("--session <id>", "Session id (defaults to the current agent heartbeat)")
20
+ .option("--instance <id>", "Agent instance id (defaults to the current owner)")
21
+ .option("--json", "Structured JSON output")
22
+ .action((opts) => {
23
+ try {
24
+ const json = opts.json || Boolean(command.opts().json);
25
+ const identity = resolveContinuityIdentity(context, opts);
26
+ const state = readContextState(identity.coordRoot, identity.sessionId);
27
+ if (json) {
28
+ emit.config({ format: "json" });
29
+ emit.data({ state, identity });
30
+ return;
31
+ }
32
+ if (!state) {
33
+ emit.text(`No context continuity state for session ${identity.sessionId}.\n`);
34
+ return;
35
+ }
36
+ const sample = state.latest_context;
37
+ const usage = sample
38
+ ? `${sample.used_tokens ?? "?"}/${sample.window_tokens ?? "?"} tokens${sample.used_percent === undefined ? "" : ` (${sample.used_percent}%)`}`
39
+ : "not reported by adapter";
40
+ emit.text(`${[
41
+ `Session: ${state.session_id}`,
42
+ `Phase: ${state.phase}`,
43
+ `Generation: ${state.generation}`,
44
+ `Telemetry: ${usage}`,
45
+ `Capsule: ${state.latest_capsule ?? "none"}`,
46
+ state.degraded_reason ? `Degraded: ${state.degraded_reason}` : "",
47
+ ]
48
+ .filter(Boolean)
49
+ .join("\n")}\n`);
50
+ }
51
+ catch (err) {
52
+ emitCommandError(emit, "checkpoint_status_failed", err);
53
+ }
54
+ });
55
+ command
56
+ .command("create")
57
+ .description("Create a durable context-continuity capsule for the current work")
58
+ .option("--session <id>", "Session id (defaults to the current agent heartbeat)")
59
+ .option("--instance <id>", "Agent instance id (defaults to the current owner)")
60
+ .option("--adapter <id>", "claude-code, codex, or cursor (inferred from heartbeat)")
61
+ .option("--reason <reason>", "manual, pressure, pre_compact, or session_end", "manual")
62
+ .option("--note <text>", "Short continuation note for the recovered agent")
63
+ .option("--json", "Structured JSON output")
64
+ .action((opts) => {
65
+ try {
66
+ const json = opts.json || Boolean(command.opts().json);
67
+ const reason = parseCheckpointReason(opts.reason);
68
+ const identity = resolveContinuityIdentity(context, opts);
69
+ if (!identity.adapter) {
70
+ throw new Error("could not infer the adapter; pass --adapter claude-code|codex|cursor");
71
+ }
72
+ const result = checkpointContext(identity.coordRoot, {
73
+ sessionId: identity.sessionId,
74
+ instanceId: identity.instanceId,
75
+ adapter: identity.adapter,
76
+ cwd: context?.repoRoot ?? process.cwd(),
77
+ reason,
78
+ continuationNote: opts.note,
79
+ });
80
+ const output = {
81
+ capsule_id: result.capsule.capsule_id,
82
+ generation: result.capsule.generation,
83
+ path: result.state.latest_capsule,
84
+ phase: result.state.phase,
85
+ reused: result.reused,
86
+ };
87
+ if (json) {
88
+ emit.config({ format: "json" });
89
+ emit.data(output);
90
+ return;
91
+ }
92
+ emit.text(`Checkpointed context generation ${output.generation}: ${output.path ?? result.path}\n`);
93
+ }
94
+ catch (err) {
95
+ emitCommandError(emit, "checkpoint_create_failed", err);
96
+ }
97
+ });
98
+ command
99
+ .command("show")
100
+ .description("Show the latest durable context-continuity capsule")
101
+ .option("--session <id>", "Session id (defaults to the current agent heartbeat)")
102
+ .option("--instance <id>", "Agent instance id (defaults to the current owner)")
103
+ .option("--json", "Structured JSON output")
104
+ .action((opts) => {
105
+ try {
106
+ const json = opts.json || Boolean(command.opts().json);
107
+ const identity = resolveContinuityIdentity(context, opts);
108
+ const capsule = readLatestCapsule(identity.coordRoot, identity.sessionId);
109
+ if (!capsule) {
110
+ throw new Error(`no context capsule exists for session ${identity.sessionId}`);
111
+ }
112
+ if (json)
113
+ emit.config({ format: "json" });
114
+ emit.data(capsule);
115
+ }
116
+ catch (err) {
117
+ emitCommandError(emit, "checkpoint_show_failed", err);
118
+ }
119
+ });
120
+ }
121
+ function resolveContinuityIdentity(context, opts) {
122
+ const coordRoot = context?.resolveCoordRoot?.() ?? context?.repoRoot ?? monorepoRoot();
123
+ if (!coordRoot)
124
+ throw new Error("could not resolve a project containing .harnery/");
125
+ const instanceId = opts.instance ?? resolveOwner();
126
+ if (!instanceId) {
127
+ throw new Error("could not resolve the current agent; pass --instance and --session");
128
+ }
129
+ const heartbeat = readHeartbeat(instanceId);
130
+ const sessionId = opts.session ?? heartbeat?.session_id ?? instanceId;
131
+ const adapter = opts.adapter
132
+ ? parseAdapter(opts.adapter)
133
+ : adapterFromPlatform(heartbeat?.platform);
134
+ return { coordRoot, instanceId, sessionId, adapter };
135
+ }
136
+ function adapterFromPlatform(platform) {
137
+ if (platform === "claude_code" || platform === "claude-code")
138
+ return "claude-code";
139
+ if (platform === "cursor")
140
+ return "cursor";
141
+ if (platform === "codex")
142
+ return "codex";
143
+ return null;
144
+ }
145
+ function parseAdapter(value) {
146
+ if (value === "claude-code" || value === "codex" || value === "cursor")
147
+ return value;
148
+ throw new Error(`invalid adapter "${value}"; expected claude-code, codex, or cursor`);
149
+ }
150
+ function parseCheckpointReason(value) {
151
+ if (value === "manual" ||
152
+ value === "pressure" ||
153
+ value === "pre_compact" ||
154
+ value === "session_end") {
155
+ return value;
156
+ }
157
+ throw new Error(`invalid reason "${value}"; expected manual, pressure, pre_compact, or session_end`);
158
+ }
159
+ function emitCommandError(emit, code, err) {
160
+ emit.error({ code, message: err instanceof Error ? err.message : String(err) });
161
+ emit.setExitCode(1);
162
+ }
@@ -1,11 +1,11 @@
1
1
  import type { Command } from "commander";
2
2
  import type { EmitContext, HarneryProgramContext } from "../commander.js";
3
3
  /**
4
- * `harn context`: one-shot orientation snapshot.
4
+ * `harn agents context`: one-shot orientation snapshot.
5
5
  *
6
6
  * Aggregates self / time / repo / commits / submodules / peers (default) plus
7
7
  * opt-in services. Useful at session start, post-compaction, or before
8
8
  * dispatching subagents. Fail-open per section.
9
9
  */
10
- export declare function registerContextCommand(program: Command, emit: EmitContext, context?: HarneryProgramContext): void;
10
+ export declare function registerContextCommand(parent: Command, emit: EmitContext, context?: HarneryProgramContext): void;
11
11
  //# sourceMappingURL=context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/commands/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAiB1E;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,WAAW,EACjB,OAAO,CAAC,EAAE,qBAAqB,GAC9B,IAAI,CAqKN"}
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/commands/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAS1E;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,OAAO,EACf,IAAI,EAAE,WAAW,EACjB,OAAO,CAAC,EAAE,qBAAqB,GAC9B,IAAI,CAiDN"}
@@ -1,15 +1,13 @@
1
- import { monorepoRoot, readHeartbeat, resolveOwner } from "../core/agents/index.js";
2
- import { checkpointContext, readContextState, readLatestCapsule, } from "../core/context/index.js";
3
1
  import { buildContext, DEFAULT_SECTIONS, OPT_IN_SECTIONS, } from "../lib/context/index.js";
4
2
  /**
5
- * `harn context`: one-shot orientation snapshot.
3
+ * `harn agents context`: one-shot orientation snapshot.
6
4
  *
7
5
  * Aggregates self / time / repo / commits / submodules / peers (default) plus
8
6
  * opt-in services. Useful at session start, post-compaction, or before
9
7
  * dispatching subagents. Fail-open per section.
10
8
  */
11
- export function registerContextCommand(program, emit, context) {
12
- const command = program
9
+ export function registerContextCommand(parent, emit, context) {
10
+ parent
13
11
  .command("context")
14
12
  .description(`One-shot orientation snapshot: self, repo, submodules, peers, recent commits. Default sections: ${DEFAULT_SECTIONS.join(" / ")}. Opt-in: ${OPT_IN_SECTIONS.join(" / ")}.`)
15
13
  .option("--section <name>", `Limit to specific sections (comma-list or repeated; valid: ${[...DEFAULT_SECTIONS, ...OPT_IN_SECTIONS].join(", ")})`, collectSections, [])
@@ -39,152 +37,6 @@ export function registerContextCommand(program, emit, context) {
39
37
  process.exit(1);
40
38
  }
41
39
  });
42
- command
43
- .command("status")
44
- .description("Show context-continuity phase, generation, and latest telemetry")
45
- .option("--session <id>", "Session id (defaults to the current agent heartbeat)")
46
- .option("--instance <id>", "Agent instance id (defaults to the current owner)")
47
- .option("--json", "Structured JSON output")
48
- .action((opts) => {
49
- try {
50
- const json = opts.json || Boolean(command.opts().json);
51
- const identity = resolveContinuityIdentity(context, opts);
52
- const state = readContextState(identity.coordRoot, identity.sessionId);
53
- if (json) {
54
- emit.config({ format: "json" });
55
- emit.data({ state, identity });
56
- return;
57
- }
58
- if (!state) {
59
- emit.text(`No context continuity state for session ${identity.sessionId}.\n`);
60
- return;
61
- }
62
- const sample = state.latest_context;
63
- const usage = sample
64
- ? `${sample.used_tokens ?? "?"}/${sample.window_tokens ?? "?"} tokens${sample.used_percent === undefined ? "" : ` (${sample.used_percent}%)`}`
65
- : "not reported by harness";
66
- emit.text(`${[
67
- `Session: ${state.session_id}`,
68
- `Phase: ${state.phase}`,
69
- `Generation: ${state.generation}`,
70
- `Telemetry: ${usage}`,
71
- `Capsule: ${state.latest_capsule ?? "none"}`,
72
- state.degraded_reason ? `Degraded: ${state.degraded_reason}` : "",
73
- ]
74
- .filter(Boolean)
75
- .join("\n")}\n`);
76
- }
77
- catch (err) {
78
- emitCommandError(emit, "context_status_failed", err);
79
- }
80
- });
81
- command
82
- .command("checkpoint")
83
- .description("Create a durable context-continuity capsule for the current work")
84
- .option("--session <id>", "Session id (defaults to the current agent heartbeat)")
85
- .option("--instance <id>", "Agent instance id (defaults to the current owner)")
86
- .option("--harness <id>", "claude-code, codex, or cursor (inferred from heartbeat)")
87
- .option("--reason <reason>", "manual, pressure, pre_compact, or session_end", "manual")
88
- .option("--note <text>", "Short continuation note for the recovered agent")
89
- .option("--json", "Structured JSON output")
90
- .action((opts) => {
91
- try {
92
- const json = opts.json || Boolean(command.opts().json);
93
- const reason = parseCheckpointReason(opts.reason);
94
- const identity = resolveContinuityIdentity(context, opts);
95
- if (!identity.harness) {
96
- throw new Error("could not infer the harness; pass --harness claude-code|codex|cursor");
97
- }
98
- const result = checkpointContext(identity.coordRoot, {
99
- sessionId: identity.sessionId,
100
- instanceId: identity.instanceId,
101
- harness: identity.harness,
102
- cwd: context?.repoRoot ?? process.cwd(),
103
- reason,
104
- continuationNote: opts.note,
105
- });
106
- const output = {
107
- capsule_id: result.capsule.capsule_id,
108
- generation: result.capsule.generation,
109
- path: result.state.latest_capsule,
110
- phase: result.state.phase,
111
- reused: result.reused,
112
- };
113
- if (json) {
114
- emit.config({ format: "json" });
115
- emit.data(output);
116
- return;
117
- }
118
- emit.text(`Checkpointed context generation ${output.generation}: ${output.path ?? result.path}\n`);
119
- }
120
- catch (err) {
121
- emitCommandError(emit, "context_checkpoint_failed", err);
122
- }
123
- });
124
- command
125
- .command("show")
126
- .description("Show the latest durable context-continuity capsule")
127
- .option("--session <id>", "Session id (defaults to the current agent heartbeat)")
128
- .option("--instance <id>", "Agent instance id (defaults to the current owner)")
129
- .option("--json", "Structured JSON output")
130
- .action((opts) => {
131
- try {
132
- const json = opts.json || Boolean(command.opts().json);
133
- const identity = resolveContinuityIdentity(context, opts);
134
- const capsule = readLatestCapsule(identity.coordRoot, identity.sessionId);
135
- if (!capsule) {
136
- throw new Error(`no context capsule exists for session ${identity.sessionId}`);
137
- }
138
- if (json)
139
- emit.config({ format: "json" });
140
- emit.data(capsule);
141
- }
142
- catch (err) {
143
- emitCommandError(emit, "context_show_failed", err);
144
- }
145
- });
146
- }
147
- function resolveContinuityIdentity(context, opts) {
148
- const coordRoot = context?.resolveCoordRoot?.() ?? context?.repoRoot ?? monorepoRoot();
149
- if (!coordRoot)
150
- throw new Error("could not resolve a project containing .harnery/");
151
- const instanceId = opts.instance ?? resolveOwner();
152
- if (!instanceId) {
153
- throw new Error("could not resolve the current agent; pass --instance and --session");
154
- }
155
- const heartbeat = readHeartbeat(instanceId);
156
- const sessionId = opts.session ?? heartbeat?.session_id ?? instanceId;
157
- const harness = opts.harness
158
- ? parseHarness(opts.harness)
159
- : harnessFromPlatform(heartbeat?.platform);
160
- return { coordRoot, instanceId, sessionId, harness };
161
- }
162
- function harnessFromPlatform(platform) {
163
- if (platform === "claude_code" || platform === "claude-code")
164
- return "claude-code";
165
- if (platform === "cursor")
166
- return "cursor";
167
- if (platform === "codex")
168
- return "codex";
169
- return null;
170
- }
171
- function parseHarness(value) {
172
- if (value === "claude-code" || value === "codex" || value === "cursor")
173
- return value;
174
- throw new Error(`invalid harness "${value}"; expected claude-code, codex, or cursor`);
175
- }
176
- function parseCheckpointReason(value) {
177
- if (value === "manual" ||
178
- value === "pressure" ||
179
- value === "pre_compact" ||
180
- value === "session_end") {
181
- return value;
182
- }
183
- throw new Error(`invalid reason "${value}"; expected manual, pressure, pre_compact, or session_end`);
184
- }
185
- function emitCommandError(emit, code, err) {
186
- emit.error({ code, message: err instanceof Error ? err.message : String(err) });
187
- emit.setExitCode(1);
188
40
  }
189
41
  function collectSections(value, prev) {
190
42
  const all = [...DEFAULT_SECTIONS, ...OPT_IN_SECTIONS];
@@ -1 +1 @@
1
- {"version":3,"file":"decision.d.ts","sourceRoot":"","sources":["../../src/commands/decision.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AA6CnD,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,GAAG,IAAI,CAgStF"}
1
+ {"version":3,"file":"decision.d.ts","sourceRoot":"","sources":["../../src/commands/decision.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AA6CnD,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,GAAG,IAAI,CAsTtF"}
@@ -1,5 +1,5 @@
1
1
  import { existsSync, readFileSync } from "node:fs";
2
- import { emitCanonical, monorepoRoot, normalizeHarness, readHeartbeat, resolveOwner, } from "../core/agents/index.js";
2
+ import { emitCanonical, monorepoRoot, normalizeAdapter, readHeartbeat, resolveOwner, } from "../core/agents/index.js";
3
3
  import { resolveBinName } from "../core/config.js";
4
4
  import { archiveDecision, claimDecision, DECISION_STAKES, fileDecision, isStakes, isStatus, isTier, isVerdict, listDecisions, reopenDecision, resolveDecision, reviewDecision, searchDecisions, showDecision, supersedeDecision, triageDecision, wontfixDecision, } from "../lib/decision/index.js";
5
5
  /**
@@ -72,23 +72,39 @@ export function registerDecisionCommand(program, emitParam) {
72
72
  .option("--stakes <small|medium|high>", "Filter by stakes")
73
73
  .option("--open", "Only non-terminal decisions (the live queue)")
74
74
  .option("--archived", "Include archived (graduated/terminal) decisions")
75
+ .option("--waiting", "Only what a human still has to rule on: tier 2, unresolved. Oldest-first within stakes.")
75
76
  .action((opts) => {
76
77
  const coordRoot = coordRootOrExit();
77
78
  const status = opts.status ? parseStatus(opts.status) : undefined;
78
79
  const tier = opts.tier !== undefined ? parseTier(opts.tier) : undefined;
79
80
  const stakes = opts.stakes ? parseStakes(opts.stakes) : undefined;
80
- const rows = listDecisions(coordRoot, {
81
+ if (opts.waiting && tier !== undefined && tier !== 2) {
82
+ return fail("bad_request", "--waiting is tier 2 by definition; drop --tier or pass --tier 2");
83
+ }
84
+ let rows = listDecisions(coordRoot, {
81
85
  status,
82
- tier,
86
+ tier: opts.waiting ? 2 : tier,
83
87
  stakes,
84
- openOnly: opts.open,
85
- includeArchived: opts.archived,
88
+ // --waiting implies the live queue: an archived or resolved decision is
89
+ // not waiting on anyone.
90
+ openOnly: opts.open || opts.waiting,
91
+ includeArchived: opts.waiting ? false : opts.archived,
86
92
  }).map(summarize);
93
+ if (opts.waiting) {
94
+ rows = rows.filter((r) => !r.resolved).sort(byStakesThenAge);
95
+ }
87
96
  emit.data({
88
97
  rows,
89
98
  meta: {
90
99
  total: rows.length,
91
- filter: { status, tier, stakes, open: !!opts.open, archived: !!opts.archived },
100
+ filter: {
101
+ status,
102
+ tier: opts.waiting ? 2 : tier,
103
+ stakes,
104
+ open: !!(opts.open || opts.waiting),
105
+ archived: opts.waiting ? false : !!opts.archived,
106
+ waiting: !!opts.waiting,
107
+ },
92
108
  },
93
109
  });
94
110
  });
@@ -319,6 +335,14 @@ function collect(value, previous) {
319
335
  return previous.concat([value]);
320
336
  }
321
337
  /** Compact row for list/search output — the full manifest is available via `show`. */
338
+ const WAITING_STAKES_RANK = { high: 3, medium: 2, small: 1 };
339
+ /** Highest stakes first, longest-open breaking ties. Stakes leads because it is
340
+ * the filer's own triage signal; age breaks ties so a question nobody has
341
+ * answered in three weeks does not sit behind an equally-weighted fresh one. */
342
+ function byStakesThenAge(a, b) {
343
+ const rank = (WAITING_STAKES_RANK[String(b.stakes)] ?? 1) - (WAITING_STAKES_RANK[String(a.stakes)] ?? 1);
344
+ return rank !== 0 ? rank : String(a.filed_at ?? "").localeCompare(String(b.filed_at ?? ""));
345
+ }
322
346
  function summarize(m) {
323
347
  return {
324
348
  decision_id: m.decision_id,
@@ -348,7 +372,7 @@ function emitDecisionEvent(type, data) {
348
372
  type,
349
373
  owner,
350
374
  session: hb?.session_id ?? owner,
351
- harness: normalizeHarness(hb?.platform),
375
+ adapter: normalizeAdapter(hb?.platform),
352
376
  data,
353
377
  });
354
378
  }
@@ -2,11 +2,11 @@
2
2
  * `harn deinit`: reverse what `harn init` wired into a project.
3
3
  *
4
4
  * `init` makes two kinds of change outside the harnery package:
5
- * 1. Merges `agent-hook` entries into the harness settings file
5
+ * 1. Merges `agent-hook` entries into the adapter settings file
6
6
  * (Claude Code `.claude/settings.json`, Cursor `.cursor/hooks.json`, or
7
7
  * Codex `.codex/hooks.json`).
8
8
  * 2. Creates the `.harnery/` coord root (runtime state: events, councils,
9
- * identities, scratch) and stamps the host bin name into
9
+ * identities, journal) and stamps the host bin name into
10
10
  * `.harnery/config.jsonc`.
11
11
  *
12
12
  * `deinit` undoes (1) by default: it removes only harnery's hook entries from
@@ -2,11 +2,11 @@
2
2
  * `harn deinit`: reverse what `harn init` wired into a project.
3
3
  *
4
4
  * `init` makes two kinds of change outside the harnery package:
5
- * 1. Merges `agent-hook` entries into the harness settings file
5
+ * 1. Merges `agent-hook` entries into the adapter settings file
6
6
  * (Claude Code `.claude/settings.json`, Cursor `.cursor/hooks.json`, or
7
7
  * Codex `.codex/hooks.json`).
8
8
  * 2. Creates the `.harnery/` coord root (runtime state: events, councils,
9
- * identities, scratch) and stamps the host bin name into
9
+ * identities, journal) and stamps the host bin name into
10
10
  * `.harnery/config.jsonc`.
11
11
  *
12
12
  * `deinit` undoes (1) by default: it removes only harnery's hook entries from
@@ -30,7 +30,7 @@ import { existsSync, readFileSync, rmSync, writeFileSync } from "node:fs";
30
30
  import { relative, resolve } from "node:path";
31
31
  import { createInterface } from "node:readline";
32
32
  import { DEFAULT_BIN_NAME } from "../core/config.js";
33
- import { HARNESS_SPECS } from "../core/hooks/harness/events.js";
33
+ import { ADAPTER_SPECS } from "../core/hooks/adapter/events.js";
34
34
  import { removeInstructions } from "../lib/instructions/apply.js";
35
35
  import { unwireHooks } from "./init.js";
36
36
  export function registerDeinitCommand(program, emit, binName) {
@@ -41,19 +41,19 @@ export function registerDeinitCommand(program, emit, binName) {
41
41
  const standalone = !binName || binName === DEFAULT_BIN_NAME;
42
42
  program
43
43
  .command("deinit")
44
- .description("Reverse `harn init`: remove harnery's hook entries from the harness " +
44
+ .description("Reverse `harn init`: remove harnery's hook entries from the adapter " +
45
45
  "settings file (keeps any others). Pass --purge-state to also delete the " +
46
46
  ".harnery/ coord root (on a terminal it asks first). Idempotent; use " +
47
47
  "--dry-run to preview.")
48
- .option("--harness <id>", "claude-code | cursor | codex", "claude-code")
48
+ .option("--adapter <id>", "claude-code | cursor | codex", "claude-code")
49
49
  .option("--dry-run", "Show what would change without writing")
50
50
  .option("--project-root <path>", "Project root (default: git toplevel, else cwd)")
51
51
  .option("--purge-state", "Also delete the .harnery/ coord root (runtime state, destructive)")
52
52
  .action(async (opts) => {
53
- const harness = opts.harness;
54
- const spec = HARNESS_SPECS[harness];
53
+ const adapter = opts.adapter;
54
+ const spec = ADAPTER_SPECS[adapter];
55
55
  if (!spec) {
56
- emit.text(`Unknown harness '${opts.harness}'. Expected: claude-code | cursor | codex.`);
56
+ emit.text(`Unknown adapter '${opts.adapter}'. Expected: claude-code | cursor | codex.`);
57
57
  emit.setExitCode(1);
58
58
  return;
59
59
  }
@@ -73,7 +73,7 @@ export function registerDeinitCommand(program, emit, binName) {
73
73
  })) {
74
74
  purgeState = await confirmDeleteState(coordDir);
75
75
  }
76
- // ── 1. unwire harness hooks ────────────────────────────────────────────
76
+ // ── 1. unwire adapter hooks ────────────────────────────────────────────
77
77
  const settingsPath = resolve(projectRoot, spec.settingsFile);
78
78
  if (!existsSync(settingsPath)) {
79
79
  actions.push(`· ${rel(projectRoot, settingsPath)} doesn't exist; no hooks to remove`);
@@ -93,7 +93,7 @@ export function registerDeinitCommand(program, emit, binName) {
93
93
  if (removed === 0) {
94
94
  actions.push(`· no harnery hooks found in ${rel(projectRoot, settingsPath)}`);
95
95
  }
96
- else if (harnessOnly(settings)) {
96
+ else if (adapterOnly(settings)) {
97
97
  // Nothing left but what init itself put there (no hooks, at most a
98
98
  // version key), so remove the file rather than leave an empty shell.
99
99
  if (dryRun) {
@@ -115,7 +115,7 @@ export function registerDeinitCommand(program, emit, binName) {
115
115
  }
116
116
  }
117
117
  // ── 1b. agent-facing instructions block + skills ───────────────────────
118
- const removed = removeInstructions(projectRoot, { harness, dryRun });
118
+ const removed = removeInstructions(projectRoot, { adapter, dryRun });
119
119
  actions.push(...removed.actions, ...removed.warnings.map((w) => `! ${w}`));
120
120
  // ── 2. coord root (opt-in; destructive) ────────────────────────────────
121
121
  if (purgeState) {
@@ -123,7 +123,7 @@ export function registerDeinitCommand(program, emit, binName) {
123
123
  actions.push("· .harnery/ doesn't exist; nothing to purge");
124
124
  }
125
125
  else if (dryRun) {
126
- actions.push("+ would delete .harnery/ and all coord state (events, councils, scratch)");
126
+ actions.push("+ would delete .harnery/ and all coord state (events, councils, journal)");
127
127
  }
128
128
  else {
129
129
  rmSync(coordDir, { recursive: true, force: true });
@@ -160,7 +160,7 @@ export function engineRemovalHint() {
160
160
  /** Mirror scripts/teardown.sh's wording: explain what .harnery/ holds, then ask. */
161
161
  function confirmDeleteState(coordDir) {
162
162
  process.stdout.write("\nharnery saved this project's coordination history in .harnery/\n" +
163
- "(its event log, councils, agent identities, and scratchpads):\n" +
163
+ "(its event log, councils, agent identities, and journals):\n" +
164
164
  ` ${coordDir}\n` +
165
165
  "Unwiring leaves that in place. Deleting it can't be undone.\n");
166
166
  return confirm("Delete this project's harnery history too? [y/N]");
@@ -176,7 +176,7 @@ function confirm(question) {
176
176
  });
177
177
  }
178
178
  /** True when an unwired settings object holds nothing but (optionally) `version`. */
179
- function harnessOnly(settings) {
179
+ function adapterOnly(settings) {
180
180
  const keys = Object.keys(settings);
181
181
  return keys.length === 0 || (keys.length === 1 && keys[0] === "version");
182
182
  }
@@ -184,7 +184,7 @@ function render(projectRoot, dryRun, actions, hint) {
184
184
  const head = dryRun ? "harn deinit (dry run): no changes written" : "harn deinit";
185
185
  const tail = dryRun
186
186
  ? "\nRe-run without --dry-run to apply."
187
- : "\nDone. harnery hooks are unwired; restart your harness session to drop them.";
187
+ : "\nDone. harnery hooks are unwired; restart your adapter session to drop them.";
188
188
  const hintBlock = hint ? `\n\n${hint}` : "";
189
189
  return `${head}\n root: ${projectRoot}\n${actions.map((a) => ` ${a}`).join("\n")}${tail}${hintBlock}`;
190
190
  }