@astrosheep/keiyaku 4.0.1 → 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 (245) hide show
  1. package/README.md +137 -5
  2. package/build/integrations/marketplace/plugins/keiyaku/.claude-plugin/plugin.json +1 -1
  3. package/build/integrations/marketplace/plugins/keiyaku/.codex-plugin/plugin.json +1 -1
  4. package/build/integrations/marketplace/plugins/keiyaku/package.json +1 -1
  5. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku/SKILL.md +3 -3
  6. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-akuma/SKILL.md +91 -35
  7. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-bind/SKILL.md +98 -58
  8. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-workflow/SKILL.md +152 -53
  9. package/build/src/akuma/abort.d.ts +2 -0
  10. package/build/src/akuma/abort.js +50 -0
  11. package/build/src/akuma/akuma.d.ts +23 -14
  12. package/build/src/akuma/akuma.js +120 -104
  13. package/build/src/akuma/archetype.d.ts +7 -6
  14. package/build/src/akuma/archetype.js +68 -41
  15. package/build/src/akuma/body.d.ts +3 -5
  16. package/build/src/akuma/body.js +408 -213
  17. package/build/src/akuma/heart/facts.d.ts +25 -34
  18. package/build/src/akuma/heart/facts.js +18 -7
  19. package/build/src/akuma/heart/index.d.ts +39 -42
  20. package/build/src/akuma/heart/index.js +134 -93
  21. package/build/src/akuma/heart/rows.d.ts +9 -31
  22. package/build/src/akuma/heart/rows.js +26 -44
  23. package/build/src/akuma/heart/schema.d.ts +1 -1
  24. package/build/src/akuma/heart/schema.js +7 -15
  25. package/build/src/akuma/heart/soul.d.ts +8 -0
  26. package/build/src/akuma/heart/soul.js +136 -0
  27. package/build/src/akuma/heart/storage.d.ts +28 -14
  28. package/build/src/akuma/heart/storage.js +86 -26
  29. package/build/src/akuma/identity.d.ts +2 -2
  30. package/build/src/akuma/identity.js +9 -9
  31. package/build/src/akuma/index.d.ts +6 -1
  32. package/build/src/akuma/index.js +6 -0
  33. package/build/src/akuma/projection.d.ts +117 -38
  34. package/build/src/akuma/projection.js +208 -97
  35. package/build/src/akuma/provider-recipe.d.ts +24 -0
  36. package/build/src/akuma/provider-recipe.js +100 -0
  37. package/build/src/akuma/provider.d.ts +12 -4
  38. package/build/src/akuma/provider.js +117 -70
  39. package/build/src/akuma/providers/acp/core.d.ts +19 -0
  40. package/build/src/akuma/providers/acp/core.js +159 -0
  41. package/build/src/akuma/providers/acp/events.d.ts +20 -0
  42. package/build/src/akuma/providers/acp/events.js +73 -0
  43. package/build/src/akuma/providers/acp/index.d.ts +12 -0
  44. package/build/src/akuma/providers/acp/index.js +94 -0
  45. package/build/src/akuma/providers/claude/events.js +66 -13
  46. package/build/src/akuma/providers/claude/index.d.ts +2 -1
  47. package/build/src/akuma/providers/claude/index.js +35 -21
  48. package/build/src/akuma/providers/codex-app-server/events.js +4 -1
  49. package/build/src/akuma/providers/codex-app-server/index.d.ts +3 -3
  50. package/build/src/akuma/providers/codex-app-server/index.js +24 -31
  51. package/build/src/akuma/providers/grok-build/index.d.ts +4 -0
  52. package/build/src/akuma/providers/grok-build/index.js +70 -0
  53. package/build/src/akuma/providers/index.d.ts +5 -3
  54. package/build/src/akuma/providers/index.js +24 -59
  55. package/build/src/akuma/providers/opencode-sdk/events.d.ts +40 -34
  56. package/build/src/akuma/providers/opencode-sdk/events.js +220 -101
  57. package/build/src/akuma/providers/opencode-sdk/index.d.ts +3 -2
  58. package/build/src/akuma/providers/opencode-sdk/index.js +233 -128
  59. package/build/src/akuma/providers/opencode-sdk/session.d.ts +11 -26
  60. package/build/src/akuma/providers/opencode-sdk/session.js +10 -9
  61. package/build/src/akuma/providers/pi/events.js +49 -11
  62. package/build/src/akuma/providers/pi/index.d.ts +1 -1
  63. package/build/src/akuma/providers/pi/index.js +50 -21
  64. package/build/src/akuma/publication.d.ts +3 -3
  65. package/build/src/akuma/publication.js +28 -40
  66. package/build/src/akuma/requests.d.ts +9 -7
  67. package/build/src/akuma/requests.js +92 -65
  68. package/build/src/alias/index.d.ts +2 -2
  69. package/build/src/alias/index.js +10 -10
  70. package/build/src/body/decode.js +7 -1
  71. package/build/src/body/region.d.ts +2 -0
  72. package/build/src/body/region.js +77 -7
  73. package/build/src/cli/accepted.d.ts +17 -13
  74. package/build/src/cli/accepted.js +72 -34
  75. package/build/src/cli/actor.js +3 -3
  76. package/build/src/cli/commands/akuma-invoke.d.ts +4 -3
  77. package/build/src/cli/commands/akuma-invoke.js +14 -9
  78. package/build/src/cli/commands/akuma.d.ts +13 -3
  79. package/build/src/cli/commands/akuma.js +67 -34
  80. package/build/src/cli/commands/contract.d.ts +18 -5
  81. package/build/src/cli/commands/contract.js +9 -3
  82. package/build/src/cli/commands/task-invoke.d.ts +17 -4
  83. package/build/src/cli/commands/task-invoke.js +43 -20
  84. package/build/src/cli/commands/task-query.d.ts +5 -0
  85. package/build/src/cli/commands/task-query.js +247 -0
  86. package/build/src/cli/commands/task.d.ts +3 -1
  87. package/build/src/cli/commands/task.js +51 -13
  88. package/build/src/cli/coordinates.d.ts +18 -0
  89. package/build/src/cli/coordinates.js +120 -0
  90. package/build/src/cli/draft.d.ts +8 -0
  91. package/build/src/cli/draft.js +96 -0
  92. package/build/src/cli/invoke.d.ts +4 -3
  93. package/build/src/cli/invoke.js +160 -179
  94. package/build/src/cli/main.js +34 -6
  95. package/build/src/cli/parse.d.ts +9 -2
  96. package/build/src/cli/parse.js +29 -7
  97. package/build/src/cli/render/akuma-tool-command.d.ts +6 -0
  98. package/build/src/cli/render/akuma-tool-command.js +144 -0
  99. package/build/src/cli/render/akuma-tool.d.ts +2 -2
  100. package/build/src/cli/render/akuma-tool.js +30 -4
  101. package/build/src/cli/render/akuma.d.ts +1 -0
  102. package/build/src/cli/render/akuma.js +211 -116
  103. package/build/src/cli/render/audit.d.ts +3 -0
  104. package/build/src/cli/render/audit.js +104 -0
  105. package/build/src/cli/render/contract.d.ts +3 -3
  106. package/build/src/cli/render/contract.js +192 -79
  107. package/build/src/cli/render/kanshi.js +263 -168
  108. package/build/src/cli/render/receipt.d.ts +19 -0
  109. package/build/src/cli/render/receipt.js +106 -0
  110. package/build/src/cli/render/refusal.d.ts +16 -2
  111. package/build/src/cli/render/refusal.js +88 -20
  112. package/build/src/cli/render/region.d.ts +2 -0
  113. package/build/src/cli/render/region.js +17 -0
  114. package/build/src/cli/render/task.d.ts +2 -1
  115. package/build/src/cli/render/task.js +223 -60
  116. package/build/src/cli/render/terminal.d.ts +7 -0
  117. package/build/src/cli/render/terminal.js +46 -0
  118. package/build/src/cli/render/text.js +6 -3
  119. package/build/src/cli/result.d.ts +115 -20
  120. package/build/src/cli/usage.d.ts +1 -0
  121. package/build/src/cli/usage.js +3 -0
  122. package/build/src/contract-worktree.d.ts +6 -5
  123. package/build/src/contract-worktree.js +95 -57
  124. package/build/src/coordination/durable-file.d.ts +4 -3
  125. package/build/src/coordination/durable-file.js +29 -25
  126. package/build/src/coordination/sqlite-transaction-lock.d.ts +4 -0
  127. package/build/src/coordination/sqlite-transaction-lock.js +22 -5
  128. package/build/src/core/facts/fold.js +1 -6
  129. package/build/src/core/facts/gate.d.ts +1 -0
  130. package/build/src/core/facts/gate.js +1 -0
  131. package/build/src/core/verbs/amend.d.ts +1 -1
  132. package/build/src/core/verbs/amend.js +0 -11
  133. package/build/src/core/verbs/deliver.d.ts +1 -1
  134. package/build/src/core/verbs/deliver.js +1 -7
  135. package/build/src/core/verbs/placement.d.ts +1 -1
  136. package/build/src/core/verbs/placement.js +4 -1
  137. package/build/src/dispatch/index.d.ts +2 -2
  138. package/build/src/dispatch/index.js +17 -17
  139. package/build/src/git/admission.d.ts +1 -1
  140. package/build/src/git/admission.js +11 -11
  141. package/build/src/git/hooks.js +13 -13
  142. package/build/src/git/integration.d.ts +14 -15
  143. package/build/src/git/integration.js +80 -44
  144. package/build/src/git/observe.d.ts +5 -3
  145. package/build/src/git/observe.js +18 -12
  146. package/build/src/git/read-observation.js +9 -9
  147. package/build/src/git/reconcile.d.ts +2 -0
  148. package/build/src/git/reconcile.js +138 -95
  149. package/build/src/git/repository.d.ts +27 -19
  150. package/build/src/git/repository.js +155 -83
  151. package/build/src/git/scratch.d.ts +7 -3
  152. package/build/src/git/scratch.js +44 -37
  153. package/build/src/git/target-placement.d.ts +40 -4
  154. package/build/src/git/target-placement.js +221 -101
  155. package/build/src/git/tender.d.ts +6 -5
  156. package/build/src/git/tender.js +24 -43
  157. package/build/src/git/terminal-seal.d.ts +1 -1
  158. package/build/src/git/terminal-seal.js +7 -5
  159. package/build/src/git/workspace.d.ts +36 -4
  160. package/build/src/git/workspace.js +53 -18
  161. package/build/src/identity/selector.js +1 -1
  162. package/build/src/index.d.ts +3 -3
  163. package/build/src/index.js +1 -1
  164. package/build/src/kanshi/index.d.ts +2 -2
  165. package/build/src/kanshi/index.js +1 -1
  166. package/build/src/kanshi/read.d.ts +2 -1
  167. package/build/src/kanshi/read.js +118 -27
  168. package/build/src/kanshi/report.d.ts +50 -0
  169. package/build/src/kanshi/select.d.ts +5 -0
  170. package/build/src/kanshi/select.js +32 -0
  171. package/build/src/library/address.d.ts +12 -3
  172. package/build/src/library/address.js +77 -46
  173. package/build/src/library/akuma-creation.d.ts +6 -1
  174. package/build/src/library/akuma-creation.js +86 -13
  175. package/build/src/library/audit.d.ts +18 -0
  176. package/build/src/library/audit.js +44 -0
  177. package/build/src/library/bind.js +4 -4
  178. package/build/src/library/catalog.d.ts +1 -1
  179. package/build/src/library/catalog.js +5 -8
  180. package/build/src/library/contract.d.ts +5 -6
  181. package/build/src/library/contract.js +11 -35
  182. package/build/src/library/delivery.d.ts +2 -1
  183. package/build/src/library/fleet.d.ts +2 -2
  184. package/build/src/library/fleet.js +35 -71
  185. package/build/src/library/keiyaku.d.ts +3 -2
  186. package/build/src/library/keiyaku.js +1 -0
  187. package/build/src/library/mutation.d.ts +7 -6
  188. package/build/src/library/mutation.js +23 -25
  189. package/build/src/library/reconcile.d.ts +29 -0
  190. package/build/src/library/reconcile.js +179 -0
  191. package/build/src/library/region.d.ts +12 -0
  192. package/build/src/library/region.js +15 -1
  193. package/build/src/library/repo.d.ts +4 -16
  194. package/build/src/library/repo.js +13 -38
  195. package/build/src/protocol/attempt.js +6 -6
  196. package/build/src/protocol/bind.js +4 -4
  197. package/build/src/protocol/intent.d.ts +15 -2
  198. package/build/src/protocol/intent.js +21 -6
  199. package/build/src/protocol/operations.d.ts +73 -22
  200. package/build/src/protocol/operations.js +292 -88
  201. package/build/src/protocol/outcome.d.ts +9 -3
  202. package/build/src/protocol/outcome.js +3 -1
  203. package/build/src/protocol/placement.d.ts +15 -4
  204. package/build/src/protocol/placement.js +58 -25
  205. package/build/src/protocol/read/status.d.ts +8 -1
  206. package/build/src/protocol/read/status.js +61 -14
  207. package/build/src/runtime/proc/line-rpc.d.ts +3 -8
  208. package/build/src/runtime/proc/line-rpc.js +16 -43
  209. package/build/src/runtime/proc/run.d.ts +15 -29
  210. package/build/src/runtime/proc/run.js +113 -105
  211. package/build/src/runtime/proc/stdio.d.ts +18 -0
  212. package/build/src/runtime/proc/stdio.js +58 -0
  213. package/build/src/settings.d.ts +2 -2
  214. package/build/src/settings.js +8 -8
  215. package/build/src/settlement/fence.d.ts +0 -4
  216. package/build/src/settlement/fence.js +0 -9
  217. package/build/src/settlement/holder.d.ts +11 -1
  218. package/build/src/settlement/holder.js +25 -0
  219. package/build/src/settlement/settle.d.ts +1 -1
  220. package/build/src/settlement/settle.js +52 -89
  221. package/build/src/task/board.d.ts +3 -3
  222. package/build/src/task/board.js +6 -9
  223. package/build/src/task/compose.d.ts +1 -1
  224. package/build/src/task/compose.js +18 -10
  225. package/build/src/task/context.d.ts +3 -3
  226. package/build/src/task/context.js +14 -14
  227. package/build/src/task/document.d.ts +2 -1
  228. package/build/src/task/document.js +15 -5
  229. package/build/src/task/index.d.ts +19 -7
  230. package/build/src/task/index.js +42 -23
  231. package/build/src/task/operations.d.ts +15 -9
  232. package/build/src/task/operations.js +78 -48
  233. package/build/src/task/query.d.ts +67 -0
  234. package/build/src/task/query.js +279 -0
  235. package/build/src/task/store.d.ts +2 -2
  236. package/build/src/task/store.js +40 -25
  237. package/build/src/verification/execution.d.ts +4 -2
  238. package/build/src/verification/execution.js +9 -5
  239. package/build/src/workspace-place.d.ts +41 -0
  240. package/build/src/workspace-place.js +386 -0
  241. package/build/src/world.d.ts +13 -2
  242. package/build/src/world.js +81 -48
  243. package/package.json +3 -2
  244. package/build/src/protocol/read/audit.d.ts +0 -31
  245. package/build/src/protocol/read/audit.js +0 -55
package/README.md CHANGED
@@ -1,9 +1,141 @@
1
1
  # Keiyaku
2
2
 
3
- Keiyaku is an agent-facing contract workflow.
3
+ **Keiyaku is not designed for you, but for your frontier model.**
4
4
 
5
- The first milestone is intentionally narrow: a Git-backed facts kernel with
6
- per-contract append-only journals, Git-tree evidence, atomic path-set CAS,
7
- and tests that prove clone and garbage-collection durability.
5
+ **Current world:** frontier models are formidable and expensive. Cheap
6
+ models work fine, but they drift, and they always report success. And
7
+ human attention is the scarcest of the three.
8
8
 
9
- No v3 runtime code is wired into this repository.
9
+ So Keiyaku gives each of the three the right job.
10
+
11
+ **The frontier gets an exoskeleton, not a cage.** It breaks goals apart,
12
+ authors explicit contracts, commands a fleet in parallel. Its limited
13
+ context goes to decision-grade signal — the state of every contract,
14
+ never individual workers. A worker can drift, stall, or lie; a contract
15
+ cannot.
16
+
17
+ **The workers get contracts, not trust.** Terms in bytes before the
18
+ first edit; every delivery judged mechanically against the diff.
19
+ Whatever drifted or lied never reaches the board.
20
+
21
+ **You step back.** Delegate when possible — by default, everything goes
22
+ to the frontier; the verbs are its to type. Steer when necessary — the
23
+ top was never handed over. The wheel stays yours.
24
+
25
+ ---
26
+
27
+ ## What a contract looks like
28
+
29
+ ```markdown
30
+ # Ship typed Task query
31
+
32
+ ## Context
33
+ Task reads scan documents ad hoc.
34
+
35
+ ## Objective
36
+ One typed query surface over the whole board.
37
+
38
+ ## Design
39
+ A single evaluator over persisted facts.
40
+
41
+ ## Region
42
+ ```
43
+ src/task/**
44
+ tests/task-*.test.ts
45
+ ```
46
+
47
+ ## Criteria
48
+ ### Query is typed
49
+ The CLI parses a predicate; the evaluator never sees a raw shell string.
50
+
51
+ ### Reads stay Task-owned
52
+ Query reads only Task facts. No Contract. No Akuma.
53
+
54
+ ## Verification
55
+ ```bash
56
+ npm test
57
+ ```
58
+ ```
59
+
60
+ ## What a deal looks like
61
+
62
+ ```bash
63
+ keiyaku bind - < keiyaku.md # terms written; an isolated worktree appears
64
+ keiyaku call worker - # a worker goes in
65
+ keiyaku deliver # tendered; Verification runs; gates judge
66
+ keiyaku review --satisfied # attested; main moves with a commit receipt
67
+ ```
68
+
69
+ ## What the journal records
70
+
71
+ One real deal, pulled from this repo's own journal:
72
+
73
+ ```text
74
+ $ keiyaku audit kei/add-acp-provider-and-grok-build-profile
75
+
76
+ accepted audit kei/add-acp-provider-and-grok-build-profile head=0508f7eb9cb738bcab06060b13ff1a96d36e3754
77
+ report {"reworks":1,"reviews":2,"timeline":[
78
+ {"kind":"bind","at":"2026-08-14T08:18:36.224Z"},
79
+ {"kind":"deliver","at":"2026-08-14T13:02:08.339Z"},
80
+ {"kind":"attestation","gate":"reviewed","verdict":"unsatisfied","summary":
81
+ "Implementation review found no blocking code issues; authenticated official
82
+ Grok smoke remains unavailable because this host has no grok binary."},
83
+ {"kind":"attestation","gate":"verified","verdict":"satisfied","summary":"[1 bash exit 0] …"}]}
84
+ ```
85
+
86
+ The review said no — with a reason, in bytes, on the journal. The deal
87
+ did not land until the gates had current evidence.
88
+
89
+ ## The board
90
+
91
+ `keiyaku status` is the one screen. A slice of this repository, right now:
92
+
93
+ ```text
94
+ kanshi ─ 7 keiyaku · 18 akuma · 286 task ─ /Users/astrosheep/Developer/keiyaku-v4 main 9cfdca6017633e51827b9b2eba3c76a7fe08e05f
95
+
96
+ keiyaku 7
97
+ ⧗ kei/add-acp-provider-and-grok-build-profile pending-delivery
98
+ worktree · integration c5cafef6 · -> refs/heads/main
99
+ ! reviewed
100
+ ⧗ kei/align-task-cli-truth-promises waiting
101
+ ? reviewed
102
+ held by task/align-task-cli-truth-promises-for-ready-compose
103
+
104
+ akuma 18
105
+ ● aku/expert-akuma/a7aafc9e running
106
+ alias @process-custody-lead
107
+ keiyaku kei/make-process-custody-capability-honest (active)
108
+ ○ aku/design-akuma/cc53ef08 asleep
109
+ alias @timeline-design
110
+ ? aku/grok/95d90b7d stranded
111
+ alias @acp-provider-impl
112
+
113
+ task 8 · 5 ready · 2 held
114
+ ● task/align-task-cli-truth-promises-for-ready-compose in_progress
115
+ Align Task CLI truth promises for ready compose and world absence
116
+ P0 · keiyaku kei/align-task-cli-truth-promises (active)
117
+ ```
118
+
119
+ Marks accelerate scanning; the words carry the state.
120
+
121
+ ## The worker
122
+
123
+ ```markdown
124
+ ---
125
+ provider: claude-agent-sdk
126
+ model: claude-sonnet-4-5
127
+ access: write
128
+ description: Repository implementation agent
129
+ ---
130
+ Make scoped changes and run relevant tests.
131
+ ```
132
+
133
+ One Markdown file, one worker. `keiyaku call worker` summons it.
134
+
135
+ ## Install
136
+
137
+ ```bash
138
+ npm install -g @astrosheep/keiyaku
139
+ ```
140
+
141
+ Node ≥ 22.19. Product law lives in [`docs/`](docs/README.md).
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "keiyaku",
3
- "version": "0.1.0+codex.20260813114301",
3
+ "version": "0.1.0+codex.20260815181541",
4
4
  "description": "Use the Keiyaku contract, task, and Akuma CLI.",
5
5
  "author": { "name": "Keiyaku" },
6
6
  "skills": "./skills/"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "keiyaku",
3
- "version": "0.1.0+codex.20260813114301",
3
+ "version": "0.1.0+codex.20260815181541",
4
4
  "description": "Use the Keiyaku contract, task, and Akuma CLI.",
5
5
  "author": {
6
6
  "name": "Keiyaku"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "keiyaku-harness",
3
- "version": "0.1.0+codex.20260813114301",
3
+ "version": "0.1.0+codex.20260815181541",
4
4
  "type": "module",
5
5
  "main": "./opencode.js",
6
6
  "keywords": ["pi-package"],
@@ -31,9 +31,9 @@ keiyaku -C <repo> review [<contract>|@<contract>] --satisfied
31
31
  ```
32
32
 
33
33
  ```bash
34
- keiyaku -C <cwd> call <akuma> [--contract <kei/...>] [--alias @name] [--wait [--timeout <duration>] | -d | --detach] [--json] -
35
- keiyaku -C <repo> wait <aku/...>
36
- keiyaku -C <repo> tell <aku/...> -
34
+ keiyaku -C <cwd> call <akuma-name> [--contract <kei/...>] [--alias @name] [--wait <duration> | -d | --detach] [--json] (<prompt> | -)
35
+ keiyaku -C <repo> wait <akuma-selector>... [--any | --all]
36
+ keiyaku -C <repo> tell <aku/...|@alias> (<prompt> | -)
37
37
  ```
38
38
 
39
39
  `-C` is the invocation and Akuma execution cwd. Add `--repo <path>` only when
@@ -5,49 +5,105 @@ description: Use when delegating work to, supervising, steering, inspecting, for
5
5
 
6
6
  # Keiyaku Akuma
7
7
 
8
- An Akuma is a durable callable worker projection. Its complete id is
9
- `aku/<archetype>/<hex8>`; keep that id for recovery.
8
+ An Akuma is a durable callable worker. Its complete identity is
9
+ `aku/<archetype>/<hex8>` keep it; it is how you address the same worker
10
+ later. An Alias is a movable world-local selector usable wherever a direct id
11
+ is accepted; the identity underneath never changes.
10
12
 
11
- ## Choose A Verb
13
+ ## Start One
12
14
 
13
15
  ```bash
14
- keiyaku -C <cwd> call <akuma> [--contract <kei/...>] [--alias @name] [--wait [--timeout <duration>] | -d | --detach] [--json] -
15
- keiyaku -C <repo> wait <aku/...> [--timeout <duration>]
16
- keiyaku -C <repo> tell <aku/...> -
17
- keiyaku -C <repo> tell <aku/...> --interrupt -
18
- keiyaku -C <repo> history <aku/...>
19
- keiyaku -C <repo> fork <aku/...> --at <historyId>
20
- keiyaku -C <repo> kill <aku/...>
16
+ keiyaku -C <cwd> call <akuma-name> [--alias @name] [--wait <duration> | -d | --detach] [--json] (<prompt> | -)
21
17
  ```
22
18
 
23
- `call` starts from an Archetype, requires a final stdin body, and waits up to
24
- five minutes by default. Its execution cwd is exactly `-C` (or the process cwd
25
- when omitted). Use `--repo <path>` only with a Contract or Dispatch reader that
26
- must use a different Git repository. Use `-d` or `--detach` to return after birth. `tell` continues
27
- the same projection, including after it has answered. `fork` starts a child
28
- from one exact retained answered-turn coordinate and leaves the source alone.
29
- `tell --interrupt` puts down the current Body synchronously, then records the
30
- Tell for its successor. `kill` stops the current Body while preserving the
31
- Akuma's Heart, session, history, pending Tells, and Body Requests; a later Tell
32
- wakes the same Akuma.
19
+ Give the worker's initial prompt as one argument (quote it when it contains
20
+ spaces), or use final `-` to read it from stdin. These forms are mutually
21
+ exclusive. Decide up front whether you will stay:
33
22
 
34
- ## Observe
23
+ - The default observes up to five minutes and writes the complete answer when
24
+ it arrives inside that window. `--wait <duration>` replaces that window.
25
+ - `-d` / `--detach` returns right after birth with the AkuId. Use it when the
26
+ work outlives your attention; come back with `wait`.
27
+
28
+ `--alias @name` assigns that world-local selector to the born Akuma. If the
29
+ Alias already points elsewhere, it moves to the born Akuma. The worker's
30
+ execution cwd is exactly `-C <path>`, or your own cwd when `-C` is omitted.
31
+
32
+ ## Archetypes
33
+
34
+ An Archetype is a Markdown file at `~/.keiyaku/akuma/<name>.md`. Its
35
+ frontmatter selects the provider and may declare `model`, `effort`,
36
+ `readonly`, `network`, and `description`; the body is an optional system
37
+ prompt, and an empty body keeps the harness default. Write a new one when no
38
+ existing file grants the permissions and stance the work needs; a worker never
39
+ outgrows its Archetype mid-life.
40
+
41
+ ## Watch
42
+
43
+ ```bash
44
+ keiyaku status # deep fleet observation
45
+ keiyaku status <aku/...|@alias> # one worker's snapshot
46
+ keiyaku ls aku/ # shallow catalog; also aku/<archetype>/ and "aku/*/*"
47
+ keiyaku wait <selector>... [--any | --all] [--timeout <duration>] [--json]
48
+ ```
49
+
50
+ `wait` accepts complete ids, aliases, and Akuma globs, resolved once into a
51
+ stable deduplicated set. One member needs no mode; two or more require exactly
52
+ one of `--any` or `--all`. A timeout returns the current real snapshot — never
53
+ a fabricated timeout state — and `--any` leaves the unfinished members
54
+ running.
55
+
56
+ ## Steer
35
57
 
36
58
  ```bash
37
- keiyaku -C <repo> status
38
- keiyaku -C <repo> status <aku/...>
39
- keiyaku -C <repo> wait <aku/...> --timeout 5m
40
- keiyaku -C <repo> history <aku/...> --before <index>
41
- keiyaku -C <repo> history <aku/...> --since <index>
42
- keiyaku -C <repo> history <aku/...> --last
59
+ keiyaku tell <aku/...|@alias> (<prompt> | -)
60
+ keiyaku tell <aku/...|@alias> --interrupt (<prompt> | -)
43
61
  ```
44
62
 
45
- Bare `status` shows the compact fleet. Exact `status <aku/...>` and `wait`
46
- share the public status carrier; a wait timeout returns the current snapshot,
47
- not a fabricated timeout state. History cursors are persistent activity
48
- sequences and `--before`/`--since` are exclusive. `--last` writes only the
49
- complete answer bytes. Use `--json` when a script needs the typed values.
63
+ Give `tell` one prompt argument (quote it when it contains spaces) or final `-`
64
+ for stdin, never both.
65
+ `tell` continues the same worker: it steers a live Body in place, or when
66
+ none is running, including after an answer records the message durably and
67
+ wakes a successor. `tell --interrupt` puts down the current Body synchronously
68
+ first, then hands the message to the successor; it is not a kill. Choose plain
69
+ `tell` when the current attempt should finish with your guidance folded in;
70
+ choose `--interrupt` when the current attempt itself is the problem.
71
+
72
+ ## Take The Answer
73
+
74
+ ```bash
75
+ keiyaku history <aku/...|@alias> --last
76
+ keiyaku history <aku/...|@alias> [--before <N> | --since <N>] [--limit <N>]
77
+ ```
78
+
79
+ `--last` writes exactly the complete answer bytes of the latest answered turn
80
+ and says so plainly when no answer exists yet. Snapshot rows elsewhere may
81
+ clip long text; the terminal answer from `call`/`wait` and the bytes from
82
+ `--last` are never clipped — when you need the full result, take it from one
83
+ of those. Cursor reads page the activity timeline; `--before` and `--since`
84
+ are exclusive sequence cursors. `--limit` defaults to 50 and accepts at most
85
+ 5000 semantic rows.
86
+
87
+ ## Stop
88
+
89
+ ```bash
90
+ keiyaku kill <selector>...
91
+ ```
92
+
93
+ `kill` accepts the same id, alias, and glob selectors as `wait`. It stops the
94
+ current Body and records that it did; everything else survives — Heart,
95
+ session, history, pending Tells, and Body Requests — so a later `tell` wakes
96
+ the same worker where it left off. Killing pauses a worker; nothing is
97
+ deleted.
98
+
99
+ ## Branch
100
+
101
+ ```bash
102
+ keiyaku fork <aku/...|@alias> --at <historyId> [--alias @name]
103
+ ```
50
104
 
51
- Read the exact command help for duration syntax and provider-specific Archetype
52
- configuration. Do not use old `follow`, plural wait, `--after`, or `--at`
53
- index forms; they are not root commands.
105
+ `fork` starts a child from one exact retained answered-turn coordinate and
106
+ leaves the source untouched. It is a provider capability, not a guarantee:
107
+ when the provider cannot fork from that turn, the command refuses rather than
108
+ fabricating a fresh start. Take the `historyId` from `history` output; it must
109
+ name an answered turn.
@@ -5,90 +5,130 @@ description: Author and bind one Keiyaku delivery Contract. Use when deciding wh
5
5
 
6
6
  # Keiyaku Bind
7
7
 
8
- Use bind when the work is a delivery decision rather than an investigation.
9
- The objective and delivery boundary should be clear, the expected write surface
10
- should be truthful, and every criterion should be decidable without inventing
11
- taste at review time. Investigate first when a plausible unresolved fact could
12
- change the objective, governing design, criteria, or delivery boundary.
13
-
14
- ## Author The Terms
15
-
16
- Write for the implementer and reviewer. Include facts they cannot safely
17
- recover locally: the owner, boundary, data-flow direction, commit point, single
18
- authority, and forbidden parallel shapes. Leave ordinary helper names and
19
- equivalent local control flow to the implementation.
20
-
21
- A design statement earns its place when a test-green candidate could violate
22
- it. A criterion names one observable condition that can accept or reject the
23
- candidate. Keep the Region truthful and no broader than the intended write
24
- surface.
25
-
26
- Start from this complete shape:
27
-
28
- ~~~markdown
29
- # <delivery name>
8
+ A Contract records a decision that already exists; writing terms does not
9
+ produce one. You supply **all high-level design and public-surface facts this
10
+ Keiyaku creates or changes**, and **all** pseudocode where ordering matters.
11
+ The worker is a cheap executor: every choice you leave open, it resolves —
12
+ possibly the way you like least, discovered at review and billed at review
13
+ prices.
14
+
15
+ ## Before You Bind
16
+
17
+ Bind is the last step of an investigation, never the first step of an idea.
18
+
19
+ - Design the delivery to the depth you could implement it yourself, against
20
+ the code as it is — not as you remember it. An unknown surfacing while
21
+ you design is the next investigation, not a detail for the worker.
22
+ - Walk the implementation path once, end to end. A step you cannot walk is
23
+ an unresolved fact.
24
+ - Observe active Contracts whose Regions intersect yours. Region overlap is a
25
+ prompt signal only; it does not by itself imply a logical conflict. The
26
+ caller decides autonomously whether to proceed in parallel or serialize.
27
+ - A decision settled elsewhere binds only its explicit words; converting it
28
+ into concrete shape is your job, and a question it left open goes back to
29
+ its decider, never to the worker.
30
+ - If the delivery must land documentation, you can draft its exact sentence
31
+ now. Cannot draft means unresolved design — "the worker will sort out the
32
+ docs" is a design gap in disguise.
33
+
34
+ Split complex work wherever independently acceptable delivery boundaries
35
+ exist. When a complex Keiyaku cannot be split without breaking one acceptance
36
+ boundary, bind one Contract and plan its fulfillment as explicit arcs. Treat
37
+ each arc as a chapter as in a work of literature, not as a task sequence.
38
+ Commission one current chapter at a time; never hand the whole undifferentiated
39
+ Contract to one Deliverer and trust it to finish everything in one pass.
40
+ Continue with `keiyaku-workflow` for the arc document and command.
41
+
42
+ Two tests close the gate:
43
+
44
+ - **Substitution.** Two workers who never met each deliver test-green from
45
+ your terms. If any external reader could tell the deliveries apart, that
46
+ fact is undecided — decide it and write it.
47
+ - **Rework.** For each blank: "if the worker picks what I like least, do I
48
+ demand rework?" Yes — write it. No — write nothing.
49
+
50
+ Public — anything visible outside the diff — is always yours to pin.
51
+ Private — helper names, decomposition, control flow — is the worker's;
52
+ its freedom comes from your genuine indifference, not from omission.
53
+
54
+ ## Author And Bind
55
+
56
+ `keiyaku -C <repo> bind --help` lists the options; only the heredoc is
57
+ stdin. Each section states what it must contain:
58
+
59
+ ~~~~bash
60
+ keiyaku -C <repo> bind - <<'KEIYAKU'
61
+ # <Delivery name — one decision, active voice; source of the kei/... identity>
30
62
 
31
63
  ## Context
32
- <established facts that frame the decision>
64
+ <Premises: coordinates of the governing decision or document, and facts a
65
+ reader would otherwise re-derive wrongly. Never narrative. If Objective and
66
+ Design read the same without a sentence here, delete it.>
33
67
 
34
68
  ## Objective
35
- <one observable delivery outcome>
69
+ <One observable end-state, judged done/not-done without reading Design.
70
+ If "and" joins independently acceptable outcomes, bind two Contracts. A
71
+ single outcome may still require several arcs during fulfillment.>
36
72
 
37
73
  ## Design
38
- <ownership, boundaries, and constraints a test-green candidate could violate>
74
+ <The closed decisions. A statement belongs here exactly when a test-green
75
+ candidate could still violate it: which module owns the change; the exact
76
+ public surface — each type with its fields, each verb with its success,
77
+ refusal, and error arms and their reason words; the persisted format; which
78
+ way data flows and where it commits or refuses; which parallel shapes are
79
+ forbidden. Helper names and equivalent control flow do not belong here —
80
+ they are the worker's.>
81
+
82
+ ```text
83
+ <pseudocode — only where ordering matters>
84
+ ```
39
85
 
40
86
  ## Region
41
87
  ```
42
- <expected write surface>
88
+ <intended write patterns — planning evidence for overlap detection, never
89
+ ownership or the exact diff. Narrow enough that overlap is a real signal;
90
+ directory patterns end with `/`.>
43
91
  ```
44
92
 
45
93
  ## Criteria
46
- ### <criterion title>
47
- <one decidable acceptance condition>
94
+ ### <one observable condition>
95
+ <One accept/reject observation with its method: run this, observe that.
96
+ Decidable without consulting you.>
48
97
 
49
98
  ## Verification
50
- ```bash
51
- <optional executable check>
99
+ ```bash timeout=<honest bound>
100
+ <commands runnable exactly as written>
52
101
  ```
53
- ~~~
102
+ KEIYAKU
103
+ ~~~~
54
104
 
55
- Use an H1 title and the H2 sections shown above. `Verification` is optional.
56
- When a declaration needs a limit, put an explicit duration such as
57
- `bash timeout=5m` in its fence info string; omit it for an unbounded declaration.
58
- Keep extra rationale and investigation logs out of the Contract.
105
+ Each declaration may set an individual timeout in its fence info string, using
106
+ an explicit duration unit such as `bash timeout=5m`. Omit it for an unbounded
107
+ declaration; there is no Verification-wide timeout.
59
108
 
60
- ## Bind
61
-
62
- Inspect the actual command surface before choosing inputs:
63
-
64
- ```bash
65
- keiyaku -C <repo> bind --help
66
- ```
67
-
68
- Bind the complete document through stdin. A Task is optional: a Contract is
69
- complete delivery authority on its own, and ordinary bounded delivery does not
70
- require creating planning state first. Use `--task` only when an existing Task
71
- already carries real scheduling, dependency, or coordination value and this
72
- Contract is specifically its delivery:
109
+ For a saved document:
73
110
 
74
111
  ```bash
75
112
  keiyaku -C <repo> bind - < CONTRACT.md
76
113
  keiyaku -C <repo> bind --task <task/...> - < CONTRACT.md
77
114
  ```
78
115
 
79
- Do not create a Task merely to make `bind --task` available or to mirror the
80
- Contract objective. That adds a second lifecycle with no planning reader.
116
+ Use `--task` only for an existing Task with scheduling or dependency value;
117
+ do not create one just to mirror the Contract.
118
+
119
+ ## Authority Order
120
+
121
+ > Settled upstream decisions and their documentation → this Contract → worker
122
+ > brief (zero authority) → review evidence (witnessed fact, never law).
81
123
 
82
- Use `bind --help` as the installed command authority for optional target,
83
- workspace, prerequisite, gate-set, actor, and JSON inputs. Do not guess flags
84
- from an older installation or repository checkout.
124
+ Gaps flow upstream, never down: a design gap found by a worker or reviewer
125
+ returns to you, never filled silently downstream.
85
126
 
86
127
  ## Read The Receipt
87
128
 
88
- Treat the receipt as the handoff. Keep the complete `kei/...` identity, work in
89
- the reported managed worktree when one was created, and retain the target and
90
- gate facts it reports. A waiting receipt means prerequisites remain; it is not
91
- a second authoring workflow. A post-admission lag does not erase the admitted
92
- Contract; read the typed facts, effects, and lag before acting.
129
+ Treat the receipt as the handoff. Keep the complete `kei/...` identity, work
130
+ in the reported managed worktree when one was created, and retain the target
131
+ and gate facts it reports. A waiting receipt means prerequisites remain; it
132
+ is not a second authoring workflow.
93
133
 
94
134
  Continue the delivery with `keiyaku-workflow`.