@astrosheep/keiyaku 4.0.0 → 4.0.2

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 (308) hide show
  1. package/README.md +133 -8
  2. package/build/integrations/marketplace/plugins/keiyaku/.claude-plugin/plugin.json +2 -2
  3. package/build/integrations/marketplace/plugins/keiyaku/.codex-plugin/plugin.json +4 -4
  4. package/build/integrations/marketplace/plugins/keiyaku/opencode.js +2 -2
  5. package/build/integrations/marketplace/plugins/keiyaku/package.json +2 -2
  6. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku/SKILL.md +13 -5
  7. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-akuma/SKILL.md +91 -32
  8. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-bind/SKILL.md +134 -0
  9. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-bind/agents/openai.yaml +4 -0
  10. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-task/SKILL.md +41 -6
  11. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-workflow/SKILL.md +262 -46
  12. package/build/src/akuma/abort.d.ts +2 -0
  13. package/build/src/akuma/abort.js +50 -0
  14. package/build/src/akuma/akuma.d.ts +50 -33
  15. package/build/src/akuma/akuma.js +175 -127
  16. package/build/src/akuma/archetype.d.ts +14 -5
  17. package/build/src/akuma/archetype.js +85 -39
  18. package/build/src/akuma/body.d.ts +3 -5
  19. package/build/src/akuma/body.js +490 -183
  20. package/build/src/akuma/coordinate.d.ts +9 -0
  21. package/build/src/akuma/coordinate.js +22 -0
  22. package/build/src/akuma/heart/facts.d.ts +88 -45
  23. package/build/src/akuma/heart/facts.js +19 -8
  24. package/build/src/akuma/heart/index.d.ts +64 -55
  25. package/build/src/akuma/heart/index.js +172 -252
  26. package/build/src/akuma/heart/rows.d.ts +38 -83
  27. package/build/src/akuma/heart/rows.js +117 -155
  28. package/build/src/akuma/heart/schema.d.ts +1 -1
  29. package/build/src/akuma/heart/schema.js +61 -22
  30. package/build/src/akuma/heart/soul.d.ts +8 -0
  31. package/build/src/akuma/heart/soul.js +136 -0
  32. package/build/src/akuma/heart/storage.d.ts +47 -0
  33. package/build/src/akuma/heart/storage.js +224 -0
  34. package/build/src/akuma/heart/tells.d.ts +12 -0
  35. package/build/src/akuma/heart/tells.js +79 -0
  36. package/build/src/akuma/heart/timeline.d.ts +15 -0
  37. package/build/src/akuma/heart/timeline.js +86 -0
  38. package/build/src/akuma/identity.d.ts +2 -2
  39. package/build/src/akuma/identity.js +9 -9
  40. package/build/src/akuma/index.d.ts +10 -3
  41. package/build/src/akuma/index.js +7 -1
  42. package/build/src/akuma/projection.d.ts +176 -0
  43. package/build/src/akuma/projection.js +256 -0
  44. package/build/src/akuma/provider-recipe.d.ts +24 -0
  45. package/build/src/akuma/provider-recipe.js +100 -0
  46. package/build/src/akuma/provider.d.ts +67 -13
  47. package/build/src/akuma/provider.js +172 -105
  48. package/build/src/akuma/providers/acp/core.d.ts +19 -0
  49. package/build/src/akuma/providers/acp/core.js +159 -0
  50. package/build/src/akuma/providers/acp/events.d.ts +20 -0
  51. package/build/src/akuma/providers/acp/events.js +73 -0
  52. package/build/src/akuma/providers/acp/index.d.ts +12 -0
  53. package/build/src/akuma/providers/acp/index.js +94 -0
  54. package/build/src/akuma/providers/{claude.d.ts → claude/events.d.ts} +9 -41
  55. package/build/src/akuma/providers/claude/events.js +238 -0
  56. package/build/src/akuma/providers/claude/index.d.ts +47 -0
  57. package/build/src/akuma/providers/claude/index.js +279 -0
  58. package/build/src/akuma/providers/claude/input.d.ts +13 -0
  59. package/build/src/akuma/providers/claude/input.js +109 -0
  60. package/build/src/akuma/providers/codex-app-server/events.d.ts +1 -1
  61. package/build/src/akuma/providers/codex-app-server/events.js +15 -12
  62. package/build/src/akuma/providers/codex-app-server/index.d.ts +15 -13
  63. package/build/src/akuma/providers/codex-app-server/index.js +77 -33
  64. package/build/src/akuma/providers/grok-build/index.d.ts +4 -0
  65. package/build/src/akuma/providers/grok-build/index.js +70 -0
  66. package/build/src/akuma/providers/index.d.ts +5 -3
  67. package/build/src/akuma/providers/index.js +35 -56
  68. package/build/src/akuma/providers/opencode-sdk/events.d.ts +54 -0
  69. package/build/src/akuma/providers/opencode-sdk/events.js +235 -0
  70. package/build/src/akuma/providers/opencode-sdk/index.d.ts +33 -0
  71. package/build/src/akuma/providers/opencode-sdk/index.js +308 -0
  72. package/build/src/akuma/providers/opencode-sdk/session.d.ts +26 -0
  73. package/build/src/akuma/providers/opencode-sdk/session.js +63 -0
  74. package/build/src/akuma/providers/pi/events.d.ts +33 -0
  75. package/build/src/akuma/providers/pi/events.js +166 -0
  76. package/build/src/akuma/providers/pi/index.d.ts +11 -0
  77. package/build/src/akuma/providers/pi/index.js +191 -0
  78. package/build/src/akuma/publication.d.ts +3 -3
  79. package/build/src/akuma/publication.js +28 -40
  80. package/build/src/akuma/requests.d.ts +9 -6
  81. package/build/src/akuma/requests.js +95 -65
  82. package/build/src/alias/index.d.ts +4 -3
  83. package/build/src/alias/index.js +12 -13
  84. package/build/src/body/decode.js +7 -1
  85. package/build/src/body/region.d.ts +2 -0
  86. package/build/src/body/region.js +77 -7
  87. package/build/src/body/render.js +2 -1
  88. package/build/src/body/shape.js +7 -1
  89. package/build/src/body/verification.js +19 -4
  90. package/build/src/cli/accepted.d.ts +18 -12
  91. package/build/src/cli/accepted.js +73 -34
  92. package/build/src/cli/actor.js +3 -3
  93. package/build/src/cli/commands/akuma-invoke.d.ts +44 -19
  94. package/build/src/cli/commands/akuma-invoke.js +101 -52
  95. package/build/src/cli/commands/akuma.d.ts +27 -9
  96. package/build/src/cli/commands/akuma.js +151 -80
  97. package/build/src/cli/commands/contract.d.ts +155 -0
  98. package/build/src/cli/commands/contract.js +20 -0
  99. package/build/src/cli/commands/install.js +2 -0
  100. package/build/src/cli/commands/task-invoke.d.ts +19 -4
  101. package/build/src/cli/commands/task-invoke.js +65 -17
  102. package/build/src/cli/commands/task-query.d.ts +5 -0
  103. package/build/src/cli/commands/task-query.js +247 -0
  104. package/build/src/cli/commands/task.d.ts +3 -1
  105. package/build/src/cli/commands/task.js +52 -14
  106. package/build/src/cli/coordinates.d.ts +18 -0
  107. package/build/src/cli/coordinates.js +120 -0
  108. package/build/src/cli/draft.d.ts +8 -0
  109. package/build/src/cli/draft.js +96 -0
  110. package/build/src/cli/invoke.d.ts +9 -3
  111. package/build/src/cli/invoke.js +287 -108
  112. package/build/src/cli/main.js +54 -7
  113. package/build/src/cli/parse.d.ts +21 -117
  114. package/build/src/cli/parse.js +79 -84
  115. package/build/src/cli/render/akuma-tool-command.d.ts +6 -0
  116. package/build/src/cli/render/akuma-tool-command.js +144 -0
  117. package/build/src/cli/render/akuma-tool.d.ts +4 -2
  118. package/build/src/cli/render/akuma-tool.js +35 -5
  119. package/build/src/cli/render/akuma.d.ts +3 -1
  120. package/build/src/cli/render/akuma.js +247 -212
  121. package/build/src/cli/render/audit.d.ts +3 -0
  122. package/build/src/cli/render/audit.js +104 -0
  123. package/build/src/cli/render/catalog.d.ts +2 -0
  124. package/build/src/cli/render/catalog.js +16 -0
  125. package/build/src/cli/render/contract.d.ts +3 -3
  126. package/build/src/cli/render/contract.js +200 -54
  127. package/build/src/cli/render/kanshi.js +272 -129
  128. package/build/src/cli/render/receipt.d.ts +19 -0
  129. package/build/src/cli/render/receipt.js +106 -0
  130. package/build/src/cli/render/refusal.d.ts +16 -2
  131. package/build/src/cli/render/refusal.js +88 -3
  132. package/build/src/cli/render/region.d.ts +2 -0
  133. package/build/src/cli/render/region.js +17 -0
  134. package/build/src/cli/render/task.d.ts +2 -1
  135. package/build/src/cli/render/task.js +223 -60
  136. package/build/src/cli/render/terminal.d.ts +20 -0
  137. package/build/src/cli/render/terminal.js +121 -0
  138. package/build/src/cli/render/text.js +11 -3
  139. package/build/src/cli/result.d.ts +126 -19
  140. package/build/src/cli/usage.d.ts +1 -0
  141. package/build/src/cli/usage.js +3 -0
  142. package/build/src/contract-worktree.d.ts +44 -0
  143. package/build/src/contract-worktree.js +251 -0
  144. package/build/src/coordination/durable-file.d.ts +5 -1
  145. package/build/src/coordination/durable-file.js +57 -10
  146. package/build/src/coordination/sqlite-transaction-lock.d.ts +4 -0
  147. package/build/src/coordination/sqlite-transaction-lock.js +22 -5
  148. package/build/src/core/facts/codec.js +23 -4
  149. package/build/src/core/facts/eligibility.d.ts +1 -10
  150. package/build/src/core/facts/eligibility.js +0 -49
  151. package/build/src/core/facts/fold.js +1 -6
  152. package/build/src/core/facts/gate.d.ts +1 -0
  153. package/build/src/core/facts/gate.js +1 -0
  154. package/build/src/core/facts/observation.d.ts +3 -0
  155. package/build/src/core/facts/observation.js +12 -0
  156. package/build/src/core/facts/types.d.ts +10 -3
  157. package/build/src/core/subject.js +2 -2
  158. package/build/src/core/verbs/amend.d.ts +1 -1
  159. package/build/src/core/verbs/amend.js +3 -18
  160. package/build/src/core/verbs/bind.js +2 -16
  161. package/build/src/core/verbs/deliver.d.ts +1 -1
  162. package/build/src/core/verbs/deliver.js +14 -4
  163. package/build/src/core/verbs/placement.d.ts +1 -1
  164. package/build/src/core/verbs/placement.js +7 -9
  165. package/build/src/dispatch/index.d.ts +5 -3
  166. package/build/src/dispatch/index.js +30 -21
  167. package/build/src/duration.d.ts +10 -0
  168. package/build/src/duration.js +22 -0
  169. package/build/src/git/admission.d.ts +2 -2
  170. package/build/src/git/admission.js +33 -23
  171. package/build/src/git/hooks.d.ts +15 -0
  172. package/build/src/git/hooks.js +70 -18
  173. package/build/src/git/identity.d.ts +5 -1
  174. package/build/src/git/identity.js +23 -4
  175. package/build/src/git/integration.d.ts +48 -0
  176. package/build/src/git/integration.js +250 -0
  177. package/build/src/git/observe.d.ts +29 -15
  178. package/build/src/git/observe.js +185 -76
  179. package/build/src/git/read-observation.d.ts +41 -0
  180. package/build/src/git/read-observation.js +361 -0
  181. package/build/src/git/reconcile.d.ts +17 -5
  182. package/build/src/git/reconcile.js +305 -109
  183. package/build/src/git/repository.d.ts +41 -18
  184. package/build/src/git/repository.js +220 -114
  185. package/build/src/git/scratch.d.ts +17 -0
  186. package/build/src/git/scratch.js +73 -0
  187. package/build/src/git/target-placement.d.ts +92 -0
  188. package/build/src/git/target-placement.js +375 -0
  189. package/build/src/git/tender.d.ts +49 -0
  190. package/build/src/git/tender.js +63 -0
  191. package/build/src/git/terminal-seal.d.ts +24 -0
  192. package/build/src/git/terminal-seal.js +89 -0
  193. package/build/src/git/tree.d.ts +2 -2
  194. package/build/src/git/tree.js +4 -0
  195. package/build/src/git/workspace.d.ts +53 -0
  196. package/build/src/git/workspace.js +139 -0
  197. package/build/src/identity/selector.d.ts +6 -0
  198. package/build/src/identity/selector.js +19 -0
  199. package/build/src/index.d.ts +4 -2
  200. package/build/src/index.js +2 -1
  201. package/build/src/kanshi/index.d.ts +2 -2
  202. package/build/src/kanshi/index.js +1 -1
  203. package/build/src/kanshi/read.d.ts +7 -3
  204. package/build/src/kanshi/read.js +245 -45
  205. package/build/src/kanshi/report.d.ts +81 -6
  206. package/build/src/kanshi/select.d.ts +5 -0
  207. package/build/src/kanshi/select.js +33 -1
  208. package/build/src/library/address.d.ts +57 -0
  209. package/build/src/library/address.js +165 -0
  210. package/build/src/library/akuma-creation.d.ts +16 -7
  211. package/build/src/library/akuma-creation.js +96 -22
  212. package/build/src/library/audit.d.ts +18 -0
  213. package/build/src/library/audit.js +44 -0
  214. package/build/src/library/bind.d.ts +21 -0
  215. package/build/src/library/bind.js +56 -0
  216. package/build/src/library/catalog.d.ts +58 -0
  217. package/build/src/library/catalog.js +69 -0
  218. package/build/src/library/configuration.d.ts +6 -15
  219. package/build/src/library/configuration.js +14 -17
  220. package/build/src/library/contract.d.ts +23 -49
  221. package/build/src/library/contract.js +171 -185
  222. package/build/src/library/delivery.d.ts +24 -0
  223. package/build/src/library/delivery.js +21 -0
  224. package/build/src/library/fleet.d.ts +65 -0
  225. package/build/src/library/fleet.js +153 -0
  226. package/build/src/library/input.d.ts +3 -0
  227. package/build/src/library/input.js +19 -0
  228. package/build/src/library/keiyaku.d.ts +18 -3
  229. package/build/src/library/keiyaku.js +12 -1
  230. package/build/src/library/mutation.d.ts +39 -0
  231. package/build/src/library/mutation.js +37 -0
  232. package/build/src/library/reconcile.d.ts +29 -0
  233. package/build/src/library/reconcile.js +179 -0
  234. package/build/src/library/refusal.d.ts +21 -0
  235. package/build/src/library/refusal.js +29 -0
  236. package/build/src/library/region.d.ts +14 -1
  237. package/build/src/library/region.js +18 -4
  238. package/build/src/library/repo.d.ts +4 -13
  239. package/build/src/library/repo.js +14 -24
  240. package/build/src/protocol/attempt.d.ts +16 -3
  241. package/build/src/protocol/attempt.js +41 -10
  242. package/build/src/protocol/bind.d.ts +9 -2
  243. package/build/src/protocol/bind.js +48 -40
  244. package/build/src/protocol/intent.d.ts +57 -20
  245. package/build/src/protocol/intent.js +55 -79
  246. package/build/src/protocol/operations.d.ts +152 -43
  247. package/build/src/protocol/operations.js +482 -166
  248. package/build/src/protocol/outcome.d.ts +14 -3
  249. package/build/src/protocol/outcome.js +11 -3
  250. package/build/src/protocol/placement.d.ts +41 -0
  251. package/build/src/protocol/placement.js +147 -0
  252. package/build/src/protocol/read/documents.d.ts +2 -2
  253. package/build/src/protocol/read/documents.js +4 -4
  254. package/build/src/protocol/read/status.d.ts +18 -5
  255. package/build/src/protocol/read/status.js +73 -13
  256. package/build/src/protocol/run.d.ts +49 -7
  257. package/build/src/protocol/run.js +53 -25
  258. package/build/src/runtime/proc/line-rpc.d.ts +4 -8
  259. package/build/src/runtime/proc/line-rpc.js +22 -28
  260. package/build/src/runtime/proc/run.d.ts +23 -21
  261. package/build/src/runtime/proc/run.js +123 -89
  262. package/build/src/runtime/proc/stdio.d.ts +18 -0
  263. package/build/src/runtime/proc/stdio.js +58 -0
  264. package/build/src/settings.d.ts +7 -1
  265. package/build/src/settings.js +32 -17
  266. package/build/src/settlement/fence.d.ts +5 -0
  267. package/build/src/settlement/fence.js +14 -0
  268. package/build/src/settlement/holder.d.ts +35 -4
  269. package/build/src/settlement/holder.js +127 -28
  270. package/build/src/settlement/settle.d.ts +9 -1
  271. package/build/src/settlement/settle.js +74 -37
  272. package/build/src/task/board.d.ts +23 -5
  273. package/build/src/task/board.js +17 -10
  274. package/build/src/task/compose.d.ts +2 -2
  275. package/build/src/task/compose.js +18 -10
  276. package/build/src/task/context.d.ts +3 -3
  277. package/build/src/task/context.js +15 -20
  278. package/build/src/task/document.d.ts +2 -1
  279. package/build/src/task/document.js +15 -5
  280. package/build/src/task/index.d.ts +27 -15
  281. package/build/src/task/index.js +57 -35
  282. package/build/src/task/operations.d.ts +38 -13
  283. package/build/src/task/operations.js +80 -46
  284. package/build/src/task/query.d.ts +67 -0
  285. package/build/src/task/query.js +279 -0
  286. package/build/src/task/store.d.ts +5 -7
  287. package/build/src/task/store.js +43 -28
  288. package/build/src/verification/declaration.d.ts +1 -0
  289. package/build/src/verification/execution.d.ts +51 -0
  290. package/build/src/verification/execution.js +108 -0
  291. package/build/src/workspace-place.d.ts +41 -0
  292. package/build/src/workspace-place.js +386 -0
  293. package/build/src/world.d.ts +24 -0
  294. package/build/src/world.js +136 -0
  295. package/package.json +8 -4
  296. package/build/src/akuma/activity.d.ts +0 -66
  297. package/build/src/akuma/activity.js +0 -139
  298. package/build/src/akuma/providers/claude.js +0 -305
  299. package/build/src/context-root.d.ts +0 -4
  300. package/build/src/context-root.js +0 -15
  301. package/build/src/git/delivery.d.ts +0 -20
  302. package/build/src/git/delivery.js +0 -109
  303. package/build/src/git/verification.d.ts +0 -14
  304. package/build/src/git/verification.js +0 -56
  305. package/build/src/protocol/read/audit.d.ts +0 -25
  306. package/build/src/protocol/read/audit.js +0 -39
  307. package/build/src/verification/producer.d.ts +0 -23
  308. package/build/src/verification/producer.js +0 -54
@@ -1,72 +1,288 @@
1
1
  ---
2
2
  name: keiyaku-workflow
3
- description: Use when authoring, binding, delivering, reviewing, amending, auditing, or abandoning a Keiyaku v4 Contract.
3
+ description: Use when authoring, binding, auditing, delivering, reviewing, amending, or abandoning a Keiyaku v4 Contract.
4
4
  ---
5
5
 
6
6
  # Keiyaku Workflow
7
7
 
8
- A Contract is one delivery authority. Its document is ordinary input until
9
- `bind` admits it; the bound Contract owns its coordinates, terms, prerequisite
10
- snapshot, candidate, reviews, gates, and terminal decision. Task planning and
11
- Akuma execution remain separate products.
8
+ A Contract turns one bounded delivery into acceptable terms: bind it, work in
9
+ the appointed worktree, audit the Contract, deliver, then review. When every
10
+ declared gate is current, the result lands on the target ref.
12
11
 
13
- ## Lifecycle
12
+ ## How The Delivery Moves
14
13
 
15
14
  ```text
16
- bind -> waiting | bound -> pending delivery -> claimed
17
- \-> abandoned
15
+ contract document -> bind -> work -> audit -> deliver -> review gates
16
+ -> placement -> claimed
17
+ \-> abandoned
18
18
  ```
19
19
 
20
- `claimed` and `abandoned` are terminal. A prerequisite `after` list is ordered
21
- and immutable after `bound`; `amend` can replace terms and change prerequisites
22
- only before they are consumed. `deliver` tenders current worktree bytes.
23
- `review --satisfied` records testimony and requests placement; placement claims
24
- only when every declared gate is current. `review --unsatisfied` records
25
- judgment without claiming. `audit` observes and never places.
20
+ The lifecycle is `waiting -> bound -> pending-delivery -> claimed | abandoned`;
21
+ the last two are terminal. Reserve `--after` for true logical ordering: one
22
+ Contract's result must ultimately build on another's settled outcome, or their
23
+ intended work has a large or irreconcilable interaction that should be
24
+ sequenced. Ordinary Region overlap is not enough. Small overlaps may proceed
25
+ under Git's optimistic write model and be resolved manually or by a delegated
26
+ worker. At runtime prerequisites are placement obligations, not a delivery
27
+ admission gate: a Contract may record `bound` and deliver before they claim,
28
+ while placement waits for the current prerequisites and declared gates. Active
29
+ terms may amend `--after` after `bound` or `deliver`; terminal Contracts remain
30
+ immutable. You never push it through states by hand: `deliver` and satisfied
31
+ reviews request placement, and placement claims when every prerequisite and
32
+ gate allows it.
26
33
 
27
34
  ## Bind
28
35
 
29
- Write one canonical Contract document to stdin and bind it:
36
+ Use `keiyaku-bind` to decide readiness, author one bounded Contract, choose
37
+ bind inputs, and read the receipt. Continue here from that receipt.
38
+
39
+ ## Work In The Contract Worktree
40
+
41
+ Change and test code in the worktree the bind receipt names. `deliver` accepts
42
+ a clean worktree by default. You may commit first, or explicitly include all
43
+ non-ignored staged, unstaged, and untracked final bytes with
44
+ `deliver --include-dirty`.
45
+
46
+ ## Regain The Picture
47
+
48
+ Rebuild state from reads, not memory — after a compact, a handoff, or any
49
+ surprising receipt, read before acting:
50
+
51
+ ```bash
52
+ keiyaku status # the whole board
53
+ keiyaku status <contract> # lifecycle, candidate, one mark per gate
54
+ keiyaku show <contract> # the exact current Contract terms
55
+ keiyaku region # every active Contract's declared surfaces
56
+ keiyaku region <contract> # one Contract's declared intent
57
+ keiyaku region --overlap # which declared intents intersect
58
+ keiyaku region --path <path> # which active Contracts declare this path
59
+ ```
60
+
61
+ `status` marks each gate: `✓` current satisfied, `!` current unsatisfied, `?`
62
+ stale because the patch or document changed after the evidence, `○` missing.
63
+ A Region is a Contract's declared write intent — not ownership, not a gate,
64
+ and not a Git conflict. Read the world before decomposing or commissioning
65
+ into an occupied repository; read `--overlap` before choosing a landing order
66
+ or an `--after` edge; read `--path` before touching a file that may belong to
67
+ another lane. Regions are declarations only, a coarse planning signal: actual
68
+ touched paths and conflicts remain Git's.
69
+
70
+ ## Commission A Contract
71
+
72
+ When another agent will fulfill or review the Contract, the commissioning
73
+ harness must pass one explicit seat and one exact worktree. `--contract` or an
74
+ equivalent association identifies the Contract; it does not appoint a seat.
75
+ Never ask the worker to infer either value.
76
+
77
+ Use this minimum handoff in the dispatch body, regardless of harness:
78
+
79
+ ```text
80
+ Contract: kei/...
81
+ Seat: Deliverer | Reviewer
82
+ Worktree: /absolute/path/from-the-bind-receipt
83
+ Read first:
84
+ - .keiyaku/KEIYAKU.md
85
+ - <owner documents governing this delivery>
86
+ - <source files named or selected from the Contract Region for this work>
87
+ Objective:
88
+ <bounded assignment>
89
+ ```
90
+
91
+ Every `Read first` path is relative to `Worktree` unless it is absolute. The
92
+ worker starts by reading `.keiyaku/KEIYAKU.md` in that worktree, confirms its
93
+ frontmatter names `Contract`, then reads the listed owner documents and source
94
+ files before acting. Do not substitute a generic repository tour for the files
95
+ that actually govern the assignment.
96
+
97
+ A `Deliverer` implements and verifies the terms in `Worktree`. Commission a
98
+ `Reviewer` after delivery. The reviewer inspects the complete current Contract
99
+ worktree snapshot, not a worker report or named candidate commit, and does not
100
+ modify it. Missing or contradictory seat, worktree, or reading list means stop
101
+ and ask.
102
+
103
+ Observe commissioned workers through their Contract association instead of
104
+ collecting Aku ids by hand:
30
105
 
31
106
  ```bash
32
- keiyaku bind -
33
- keiyaku bind --target <ref> -
34
- keiyaku bind --here -
35
- keiyaku bind --after <kei/...> --gates <name> -
107
+ keiyaku wait kei/<contract> --all --timeout 5m
108
+ keiyaku wait kei/<first> kei/<second> --any --timeout 5m
36
109
  ```
37
110
 
38
- The document owns the delivery objective, design, scope, criteria, and optional
39
- verification declaration. Use the exact `bind --help` grammar; do not invent
40
- identity or timestamps. A successful receipt is the source of the complete
41
- Contract coordinate and any managed worktree facts.
111
+ A Contract selector snapshots its dispatched workers when the command starts.
112
+ Use `--all` to wait for every selected worker or `--any` to return when one
113
+ finishes; an expanded set with more than one worker requires an explicit mode.
114
+
115
+ ## Decompose Complex Work
116
+
117
+ Complex Keiyaku should be divided along independently acceptable delivery
118
+ boundaries. Use judgment to find those boundaries from the work's objectives,
119
+ dependencies, Regions, and acceptance criteria; raw size or file count is not
120
+ the test. Give each resulting Contract coherent terms. Connect them with
121
+ `--after` only when one must proceed from another's settled result or their
122
+ intended work is unsafe to run concurrently.
42
123
 
43
- ## Work And Acceptance
124
+ When a complex Keiyaku cannot be split without breaking one acceptance
125
+ boundary, organize its fulfillment into arcs. Do not hand the whole
126
+ undifferentiated Contract to one Deliverer and trust one pass to finish it.
127
+ Record and work one current chapter at a time.
128
+
129
+ An arc is a chapter as in a work of literature: one named part of the
130
+ delivery's story, not a task list, progress slice, or claim that the work is
131
+ mechanically sequential. Its title names the chapter, Objective states that
132
+ chapter's aim, and Brief commissions work for that chapter. When an Arc is
133
+ active, stay within that current chapter. `.keiyaku/KEIYAKU.md` renders the
134
+ current Arc.
135
+ Record the next chapter before entering it:
44
136
 
45
137
  ```bash
46
- keiyaku status [<contract>|@<contract>]
47
- keiyaku amend [<contract>|@<contract>] -
48
- keiyaku arc [<contract>|@<contract>] -
49
- keiyaku deliver [<contract>|@<contract>]
50
- keiyaku review [<contract>|@<contract>] --satisfied
51
- keiyaku review [<contract>|@<contract>] --unsatisfied
52
- keiyaku audit [<contract>|@<contract>] [--show-diff-body]
53
- keiyaku reconcile [<contract>|@<contract>]
138
+ keiyaku arc <contract> - <<'KEIYAKU'
139
+ # <chapter title>
140
+
141
+ ## Objective
142
+ <nonblank objective>
143
+
144
+ ## Brief
145
+ <nonblank dispatch brief>
146
+ KEIYAKU
54
147
  ```
55
148
 
56
- Use complete `kei/...` IDs or `@...` managed-worktree references. Omitted
57
- selectors are contextual only when the CLI reports exactly one active
58
- worktree contract. `amend` reads amendment operations, `arc` reads arc
59
- Markdown, and both require their final `-`; `deliver`, `review`, `audit`, and
60
- `reconcile` do not read an unselected stdin body. `review --summary <text>` is
61
- opaque testimony and is mutually exclusive with review stdin.
149
+ All chapters live inside that Contract's single delivery and acceptance
150
+ boundary. The document grammar authority is `docs/document.md`.
151
+
152
+ ## Amend Or Start Over
153
+
154
+ Use `amend` when a discovery during the same delivery changes terms but the
155
+ original Objective, Design, and acceptance boundary still truthfully describe
156
+ the result:
157
+
158
+ ```bash
159
+ keiyaku amend <contract> -
160
+ ```
161
+
162
+ See `amend --help` for the operation grammar. If the objective or boundary
163
+ itself changed, `abandon` with a note and bind a new Contract; do not steer an
164
+ old Contract onto a different delivery.
165
+
166
+ ## Audit Before Delivery
167
+
168
+ Audit is how you see a delivery before it exists:
169
+
170
+ ```bash
171
+ keiyaku audit <contract> --diff
172
+ ```
173
+
174
+ Audit answers three already-adjudicated questions: candidate, Verification,
175
+ and target. It uses the same candidate preparation as deliver, shows the
176
+ prospective identity and optional requested diff, and runs declared
177
+ Verification against that candidate. A terminal run records ordinary
178
+ subject-bound `verified` testimony; it does not record a delivery or request
179
+ placement. Read those three answers instead of trusting a worker's completion
180
+ report.
181
+
182
+ ## Deliver
183
+
184
+ Deliver when the worktree content is the candidate you intend to land:
185
+
186
+ ```bash
187
+ keiyaku deliver <contract>
188
+ ```
189
+
190
+ `deliver` freshly tenders the clean `HEAD`, records the candidate, and requests
191
+ placement. When a current audit attestation names the identical integration
192
+ snapshot and Verification segment, deliver reuses it; otherwise it runs the
193
+ declarations. Worktree, target, policy, document, Verification, or
194
+ snapshot-producing option changes prevent reuse. If the workspace is dirty, the refusal
195
+ lists staged, unstaged, and untracked paths, a short statistic, and the
196
+ `--include-dirty` option. Use that option only when the complete current
197
+ workspace is the intended delivery; dirty submodule internals cannot be
198
+ included. Read the receipt:
199
+
200
+ - When every gate is current, the receipt shows placement and `claimed`; the
201
+ delivery is done.
202
+ - When a gate is not current, the receipt shows the recorded candidate and the
203
+ placement stop. This is not a failed delivery. The Contract stays
204
+ `pending-delivery` while you complete the gates.
205
+ - A lag row reports an accepted physical effect that has not finished. The
206
+ delivery stands; `reconcile` completes the effect later. It never changes
207
+ the verdict.
208
+
209
+ ## Review Gates
210
+
211
+ A `reviewed` gate wants a recorded judgment of the current patch:
212
+
213
+ ```bash
214
+ keiyaku review <contract> --satisfied --summary "<conclusion>"
215
+ keiyaku review <contract> --unsatisfied --summary "<finding>"
216
+ ```
217
+
218
+ Have an independent reviewer inspect the delivered Contract worktree snapshot.
219
+ The `review` command records the verdict. `--satisfied` requests placement; if
220
+ the other gates are current, the receipt shows `claimed`.
221
+
222
+ Fixing findings changes the patch and makes earlier evidence stale (`?` in
223
+ `status`). Audit the rework, deliver it, then review again. Record
224
+ `--unsatisfied` only when the negative judgment should remain in Contract
225
+ history.
226
+
227
+ ## When Multiple Contracts Overlap On One Target
228
+
229
+ When active Contracts write a shared surface, landing order is a coordinator
230
+ judgment, not Contract state. Keep the decision in the workflow skill; do not
231
+ persist a train or add a second placement authority.
232
+
233
+ - `audit` and a reviewer's report are preliminary. `review --satisfied` is
234
+ authoritative gate testimony: it requests placement and claims when
235
+ delivery, prerequisites, and all gates are current. Record it only when the
236
+ reviewed bytes are intended to land now.
237
+ - Before recording a satisfied review, or delivering a Contract with no
238
+ declared gates, ask whether the exact patch will survive until placement. A
239
+ pure rebase whose `ChangeId` is unchanged keeps the existing review current;
240
+ do not re-review content addressing kept alive. Conflict resolution that
241
+ changes the `ChangeId` makes earlier testimony stale and requires a fresh
242
+ review against the resolved candidate.
243
+ - For Contracts known to overlap, resolve the current-target integration before
244
+ the authoritative review. Preliminary feedback may happen earlier, but it
245
+ is not a satisfied gate until its reviewed patch is the candidate intended
246
+ for placement. Land overlapping Contracts one at a time; let independent,
247
+ non-overlapping Contracts proceed without ceremony. Treat overlap as a
248
+ planning signal, not a correctness verdict.
249
+ - After target movement, a changed candidate, or a placement refusal, read the
250
+ current Contract facts again. Recompute the next landing judgment from those
251
+ facts; do not rely on a remembered queue or promise exactly one rebase.
252
+
253
+ ## Target Placement
254
+
255
+ Placement follows the Git mental model you already have:
256
+
257
+ - Delivering from a managed worktree to a checked-out target behaves like a
258
+ merge. Non-overlapping staged, unstaged, and untracked files in that checkout
259
+ are preserved. A staged path refuses only when Git cannot carry it through
260
+ the predecessor-to-candidate merge; overlapping worktree changes and
261
+ colliding untracked files also refuse. The receipt lists the exact paths.
262
+ The deliver or review you just ran still counts: the recorded candidate and
263
+ any `✓ reviewed` verdict are kept, but nothing claims and nothing moves.
264
+ The target ref, its checkout, and your bytes stay exactly where they were,
265
+ and the Contract stays `pending-delivery`.
266
+ - A `--here` Contract behaves like a commit with gates: it lands on the current
267
+ branch and cannot deliver to a foreign checked-out target.
268
+
269
+ After a refusal, handle the listed paths, then `deliver` again or record a
270
+ satisfied review; either command requests placement again.
271
+
272
+ ## Recover Or End
273
+
274
+ ```bash
275
+ keiyaku reconcile <contract> # finish accepted lagging effects
276
+ keiyaku abandon <contract> --note "<why>" # terminal; target untouched
277
+ ```
62
278
 
63
- ## Terminal Choice
279
+ `reconcile` completes physical effects of already accepted placements; it does
280
+ not retry an ordinary placement refusal. `abandon` ends the Contract and never
281
+ touches the target.
64
282
 
65
- `abandon [<contract>|@<contract>] [--note <text>]` writes the terminal
66
- abandoned fact and does not touch a target ref. There is no `petition`, `claim`,
67
- `forfeit`, `renew`, or `bind --task` command in v4. A successful placement
68
- produces the claimed terminal state; inspect the typed result and decide what
69
- to do next.
283
+ ## Routine Output
70
284
 
71
- Use default text output for routine observation. Add `--json` when a script
72
- needs the public result without renderer-specific text.
285
+ Use default text output for normal operation and `--json` only when a script
286
+ needs the public result. Use the complete `kei/...` ID, or `@...` inside a
287
+ managed worktree. When a flag or stdin form is unclear, read that command's
288
+ `--help` instead of guessing.
@@ -0,0 +1,2 @@
1
+ export declare function abortable<T>(operation: Promise<T>, signal: AbortSignal, disposeLate?: (value: T) => Promise<void> | void): Promise<T>;
2
+ export declare function abortableDelay(milliseconds: number, signal?: AbortSignal): Promise<void>;
@@ -0,0 +1,50 @@
1
+ export function abortable(operation, signal, disposeLate) {
2
+ signal.throwIfAborted();
3
+ return new Promise((resolve, reject) => {
4
+ let aborted = false;
5
+ const abort = () => {
6
+ aborted = true;
7
+ if (disposeLate === undefined)
8
+ reject(signal.reason);
9
+ };
10
+ signal.addEventListener("abort", abort, { once: true });
11
+ if (signal.aborted)
12
+ abort();
13
+ void operation.then(async (value) => {
14
+ signal.removeEventListener("abort", abort);
15
+ if (!aborted) {
16
+ resolve(value);
17
+ return;
18
+ }
19
+ try {
20
+ await disposeLate?.(value);
21
+ }
22
+ catch (error) {
23
+ reject(error);
24
+ return;
25
+ }
26
+ reject(signal.reason);
27
+ }, (error) => {
28
+ signal.removeEventListener("abort", abort);
29
+ reject(aborted ? signal.reason : error);
30
+ });
31
+ });
32
+ }
33
+ export function abortableDelay(milliseconds, signal) {
34
+ if (signal === undefined)
35
+ return new Promise((resolve) => setTimeout(resolve, milliseconds));
36
+ signal.throwIfAborted();
37
+ return new Promise((resolve, reject) => {
38
+ const timeout = setTimeout(() => {
39
+ signal.removeEventListener("abort", abort);
40
+ resolve();
41
+ }, milliseconds);
42
+ const abort = () => {
43
+ clearTimeout(timeout);
44
+ reject(signal.reason);
45
+ };
46
+ signal.addEventListener("abort", abort, { once: true });
47
+ if (signal.aborted)
48
+ abort();
49
+ });
50
+ }
@@ -1,24 +1,26 @@
1
- import { type AkumaLife, type CollarProbe, type KillEvidence, type ResumeCoordinate, type Soul } from "./heart/index.js";
1
+ import { type AkumaLife, type KillEvidence, type ResumeCoordinate, type Soul } from "./heart/index.js";
2
2
  import { type AkuId } from "./identity.js";
3
- import { type ActivityHistory, type ActivitySnapshot } from "./activity.js";
3
+ import { type ActivityHistory, type ActivitySnapshot } from "./projection.js";
4
4
  import { type Settings } from "../settings.js";
5
+ import type { WorldRoot } from "../world.js";
5
6
  export type AkumaListRow = Readonly<{
6
7
  id: AkuId;
7
8
  archetype: string;
8
9
  description?: string;
9
10
  life: AkumaLife;
10
- collar: CollarProbe;
11
+ lifeAt: string | null;
11
12
  confinement: Soul["confinement"];
12
13
  pending: readonly string[];
13
14
  }>;
14
- export type AkumaStatus = AkumaListRow & Readonly<{
15
- answer?: string;
16
- answerHistoryId?: string;
17
- failure?: string;
18
- outcomeAt?: string;
19
- activity: ActivitySnapshot;
15
+ export type AkumaStatus = Readonly<{
16
+ id: AkuId;
17
+ life: AkumaLife;
18
+ readonly?: Soul["readonly"];
19
+ timeline: ActivitySnapshot;
20
+ strandedReason?: "resume-unsupported";
20
21
  }>;
21
- export type { ActivityHistory, ActivityRow, ActivitySnapshot } from "./activity.js";
22
+ export type { ReadonlyRestraint } from "./provider-recipe.js";
23
+ export type * from "./projection.js";
22
24
  export type UnbornAkumaListRow = Readonly<{
23
25
  id: AkuId;
24
26
  life: "unborn" | "stillborn";
@@ -31,25 +33,26 @@ export type AkumaList = Readonly<{
31
33
  rows: readonly (AkumaListRow | UnbornAkumaListRow)[];
32
34
  searched: readonly string[];
33
35
  }>;
34
- export type TellReceipt = Readonly<{
35
- id: string;
36
- state: "recorded";
36
+ export type AkumaListInput = Readonly<{
37
+ archetype?: string;
38
+ }>;
39
+ export type TellResult = Readonly<{
40
+ admission: Readonly<{
41
+ tellId: string;
42
+ fact: "recorded";
43
+ }>;
37
44
  wake: "spawned" | Readonly<{
38
45
  kind: "failed";
39
46
  diagnostic: string;
40
47
  }>;
41
48
  }>;
42
49
  export type InterruptReceipt = Readonly<{
43
- kind: "dead";
44
- }> | Readonly<{
45
- kind: "unstoppable";
46
- evidence: "no-collar" | "collar-unverifiable" | "unavailable" | "alive-after-sigkill" | "leash-held-after-put-down";
50
+ kind: "unavailable";
51
+ evidence: "hung" | "untidy" | "unavailable";
47
52
  }> | Readonly<{
48
53
  kind: "interrupted";
49
- putDown: "was-idle" | "self-aborted" | "collar";
50
- tell: TellReceipt | Readonly<{
51
- kind: "refused-dead";
52
- }>;
54
+ putDown: "was-idle" | "self-aborted";
55
+ tell: TellResult;
53
56
  }>;
54
57
  export type ForkReceipt = Readonly<{
55
58
  kind: "forked";
@@ -73,44 +76,58 @@ export declare class AkumaNotBornError extends Error {
73
76
  readonly kind = "akuma-not-born";
74
77
  constructor(id: AkuId);
75
78
  }
79
+ /** Package-internal action observation; it uses the same snapshot selector as status. */
80
+ export declare function readActionFeedbackStatus(worldPath: WorldRoot, id: AkuId): Promise<AkumaStatus>;
81
+ export type BudgetedStatusObservation = Readonly<{
82
+ status: AkumaStatus;
83
+ ordinarySelected: number;
84
+ }>;
85
+ /** Package-internal budgeted observation; Fleet allocates, Akuma still selects. */
86
+ export declare function readBudgetedStatus(worldPath: WorldRoot, id: AkuId, input: Readonly<{
87
+ ordinaryBudget: number;
88
+ }>): Promise<BudgetedStatusObservation>;
76
89
  export declare class AkumaHandle {
77
90
  readonly id: AkuId;
78
91
  private readonly worldPath;
79
- constructor(id: AkuId, worldPath: string);
92
+ constructor(id: AkuId, worldPath: WorldRoot);
80
93
  private get paths();
81
- status(): AkumaStatus;
94
+ status(): Promise<AkumaStatus>;
82
95
  history(input?: Readonly<{
83
96
  before?: number;
84
97
  since?: number;
85
98
  limit?: number;
86
- }>): ActivityHistory;
99
+ }>): Promise<ActivityHistory>;
87
100
  wait(predicate?: (status: AkumaStatus) => boolean, options?: Readonly<{
88
101
  timeoutMs?: number;
89
102
  }>): Promise<AkumaStatus>;
90
- tell(body: string): Promise<TellReceipt>;
103
+ tell(body: string): Promise<TellResult>;
91
104
  interrupt(body: string): Promise<InterruptReceipt>;
92
105
  fork(input: Readonly<{
93
106
  at: string;
94
107
  }>): Promise<ForkReceipt>;
95
108
  kill(): Promise<KillEvidence>;
96
- lastAnswer(): string;
109
+ lastAnswer(): Promise<LastAnswer>;
97
110
  }
111
+ export type LastAnswer = Readonly<{
112
+ kind: "answer";
113
+ answer: string;
114
+ }> | Readonly<{
115
+ kind: "no-answer";
116
+ }>;
98
117
  export declare class Akuma {
99
118
  private readonly path;
100
- private readonly settings;
119
+ private readonly configuredSettings?;
101
120
  private constructor();
102
- static at(input: Readonly<{
103
- path: string;
104
- settings?: Settings;
105
- }>): Akuma;
121
+ static of(root: WorldRoot, settings?: Settings): Akuma;
122
+ private settings;
106
123
  of(input: Readonly<{
107
124
  id: string;
108
125
  }>): AkumaHandle;
109
- listArchetypes(): readonly string[];
126
+ listArchetypes(): Promise<readonly string[]>;
110
127
  call(input: Readonly<{
111
128
  archetype: string;
112
129
  body: string;
113
130
  cwd?: string;
114
131
  }>): Promise<AkumaHandle>;
115
- list(): AkumaList;
132
+ list(input?: AkumaListInput): Promise<AkumaList>;
116
133
  }