@astrosheep/keiyaku 2.9.11 → 2.9.13

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 (218) hide show
  1. package/README.md +79 -85
  2. package/build/.tsbuildinfo +1 -1
  3. package/build/agents/call-terms.js +1 -0
  4. package/build/agents/providers/claude-agent-sdk/adapter.js +17 -4
  5. package/build/cli/commands/akuma/akuma/handler.js +2 -1
  6. package/build/cli/commands/akuma/akuma/meta.js +4 -3
  7. package/build/cli/commands/akuma/catalog.js +2 -0
  8. package/build/cli/commands/akuma/list/handler.js +1 -1
  9. package/build/cli/commands/akuma/list/meta-list.js +12 -0
  10. package/build/cli/commands/akuma/list/meta-ls.js +2 -2
  11. package/build/cli/commands/akuma.js +5 -0
  12. package/build/cli/commands/contract/amend/meta.js +4 -3
  13. package/build/cli/commands/contract/arc/meta.js +2 -0
  14. package/build/cli/commands/contract/audit/handler.js +28 -2
  15. package/build/cli/commands/contract/audit/meta.js +4 -3
  16. package/build/cli/commands/contract/bind/meta.js +4 -4
  17. package/build/cli/commands/contract/petition/handler.js +2 -1
  18. package/build/cli/commands/contract/petition/meta.js +2 -2
  19. package/build/cli/commands/contract/renew/handler.js +44 -3
  20. package/build/cli/commands/contract/renew/meta.js +5 -4
  21. package/build/cli/commands/metadata.js +14 -10
  22. package/build/cli/commands/projection/call/handler.js +1 -1
  23. package/build/cli/commands/projection/call/meta.js +1 -1
  24. package/build/cli/commands/projection/catalog.js +2 -2
  25. package/build/cli/commands/projection/{revive → fork}/handler.js +10 -5
  26. package/build/cli/commands/projection/fork/meta.js +12 -0
  27. package/build/cli/commands/projection/history/handler.js +46 -2
  28. package/build/cli/commands/projection/history/meta.js +3 -3
  29. package/build/cli/commands/projection/kill/handler.js +4 -5
  30. package/build/cli/commands/projection/kill/meta.js +2 -2
  31. package/build/cli/commands/projection/status/handler.js +29 -13
  32. package/build/cli/commands/projection/status/meta.js +14 -3
  33. package/build/cli/commands/projection/tell/handler.js +8 -4
  34. package/build/cli/commands/projection/tell/meta.js +1 -1
  35. package/build/cli/commands/projection/wait/handler.js +45 -20
  36. package/build/cli/commands/projection/wait/meta.js +1 -1
  37. package/build/cli/commands/shared.js +2 -2
  38. package/build/cli/commands/system/catalog.js +2 -0
  39. package/build/cli/commands/task/add/handler.js +28 -12
  40. package/build/cli/commands/task/add/meta.js +18 -6
  41. package/build/cli/commands/task/catalog.js +4 -0
  42. package/build/cli/commands/task/compose/handler.js +18 -0
  43. package/build/cli/commands/task/compose/meta.js +10 -0
  44. package/build/cli/commands/task/doctor/handler.js +2 -3
  45. package/build/cli/commands/task/doctor/meta.js +2 -2
  46. package/build/cli/commands/task/done/meta.js +2 -2
  47. package/build/cli/commands/task/drop/handler.js +7 -2
  48. package/build/cli/commands/task/drop/meta.js +6 -3
  49. package/build/cli/commands/task/hold/meta.js +2 -2
  50. package/build/cli/commands/task/log/meta.js +2 -2
  51. package/build/cli/commands/task/ls/meta.js +2 -2
  52. package/build/cli/commands/task/note/handler.js +6 -0
  53. package/build/cli/commands/task/note/meta.js +11 -0
  54. package/build/cli/commands/task/resume/meta.js +2 -2
  55. package/build/cli/commands/task/shared.js +29 -15
  56. package/build/cli/commands/task/show/meta.js +2 -2
  57. package/build/cli/commands/task/start/meta.js +2 -2
  58. package/build/cli/commands/task/stop/meta.js +2 -2
  59. package/build/cli/commands/task/update/meta.js +3 -2
  60. package/build/cli/commands/verification/handler.js +43 -0
  61. package/build/cli/commands/verification/meta.js +13 -0
  62. package/build/cli/completion.js +16 -13
  63. package/build/cli/flags.js +48 -12
  64. package/build/cli/help.js +29 -30
  65. package/build/cli/index.js +14 -8
  66. package/build/cli/parse-flags.js +60 -21
  67. package/build/cli/parse-metadata.js +10 -4
  68. package/build/cli/parse-selectors.js +22 -4
  69. package/build/cli/parse.js +43 -30
  70. package/build/cli/projection-address.js +7 -7
  71. package/build/cli/render/arc.js +12 -3
  72. package/build/cli/render/audit.js +2 -2
  73. package/build/cli/render/call.js +4 -4
  74. package/build/cli/render/kanshi.js +122 -85
  75. package/build/cli/render/misc.js +2 -2
  76. package/build/cli/render/petition.js +16 -1
  77. package/build/cli/render/projection-history.js +17 -4
  78. package/build/cli/render/shared.js +5 -5
  79. package/build/cli/render/status-indicator.js +47 -0
  80. package/build/cli/render/status.js +106 -76
  81. package/build/cli/render/success-response.js +20 -5
  82. package/build/cli/render/task.js +33 -5
  83. package/build/cli/render/tell.js +10 -4
  84. package/build/cli/render/tool-command-normalization.js +137 -0
  85. package/build/cli/render/tool-presentation.js +2 -1
  86. package/build/cli/render/verification.js +23 -0
  87. package/build/cli/render/wait.js +101 -33
  88. package/build/cli/types.js +2 -1
  89. package/build/config/akuma-loader.js +21 -1
  90. package/build/config/settings/knobs.js +7 -1
  91. package/build/config/settings/schema.js +10 -5
  92. package/build/core/addressing.js +3 -3
  93. package/build/core/amend.js +102 -17
  94. package/build/core/arc.js +4 -4
  95. package/build/core/audit/candidate.js +10 -18
  96. package/build/core/audit/coordinates.js +12 -17
  97. package/build/core/audit/evidence.js +6 -4
  98. package/build/core/audit/facade.js +3 -3
  99. package/build/core/audit/report.js +1 -1
  100. package/build/core/bind-reconciliation.js +42 -23
  101. package/build/core/bind.js +182 -81
  102. package/build/core/call/call.js +6 -7
  103. package/build/core/call/context.js +46 -33
  104. package/build/core/call/execution.js +21 -6
  105. package/build/core/call/prompt.js +11 -42
  106. package/build/core/contract-carrier-runtime.js +209 -105
  107. package/build/core/contract-carrier.js +156 -73
  108. package/build/core/contract-view.js +43 -6
  109. package/build/core/contract.js +2 -1
  110. package/build/core/derived-replay.js +168 -35
  111. package/build/core/draft.js +60 -27
  112. package/build/core/forfeit.js +1 -1
  113. package/build/core/lifecycle-history.js +13 -0
  114. package/build/core/lifecycle-recovery.js +32 -27
  115. package/build/core/lifecycle-runner.js +14 -14
  116. package/build/core/log.js +1 -1
  117. package/build/core/outcome-base.js +2 -2
  118. package/build/core/projection/akuma-name.js +43 -0
  119. package/build/core/projection/generation/database.js +141 -79
  120. package/build/core/projection/generation/ledger.js +91 -0
  121. package/build/core/projection/generation/model.js +19 -14
  122. package/build/core/projection/generation/projection-generation-continuation.js +1 -1
  123. package/build/core/projection/generation/projection-generation-doorbell.js +88 -0
  124. package/build/core/projection/generation/projection-generation-execution.js +24 -0
  125. package/build/core/projection/generation/projection-generation-identity.js +4 -0
  126. package/build/core/projection/generation/projection-generation-launcher.js +72 -138
  127. package/build/core/projection/generation/projection-generation-process.js +16 -15
  128. package/build/core/projection/generation/projection-generation-runner.js +132 -76
  129. package/build/core/projection/generation/projection-generation-runtime.js +10 -61
  130. package/build/core/projection/generation/protocol.js +68 -0
  131. package/build/core/projection/generation/store.js +17 -7
  132. package/build/core/projection/generation/transitions.js +24 -14
  133. package/build/core/projection/index.js +5 -5
  134. package/build/core/projection/projection-core.js +6 -2
  135. package/build/core/projection/projection-execution-observer.js +1 -1
  136. package/build/core/projection/projection-history.js +8 -8
  137. package/build/core/projection/projection-kill.js +20 -10
  138. package/build/core/projection/projection-life-observer.js +8 -8
  139. package/build/core/projection/projection-mint.js +6 -8
  140. package/build/core/projection/projection-status-observation.js +77 -8
  141. package/build/core/projection/projection-status.js +151 -4
  142. package/build/core/projection/projection-wait.js +48 -29
  143. package/build/core/projection/projection-wake.js +28 -88
  144. package/build/core/projection/tell/launch-store.js +1 -1
  145. package/build/core/projection/tell/store.js +1 -1
  146. package/build/core/renew-build.js +204 -74
  147. package/build/core/renew-plan.js +34 -9
  148. package/build/core/renew-rewrite.js +56 -15
  149. package/build/core/renew.js +39 -35
  150. package/build/core/repository-ledger/accepted-fold-read.js +6 -3
  151. package/build/core/repository-ledger/claim-evidence.js +1 -1
  152. package/build/core/repository-ledger/codec.js +11 -5
  153. package/build/core/repository-ledger/current-state-store.js +464 -349
  154. package/build/core/repository-ledger/fold-repository.js +5 -6
  155. package/build/core/repository-ledger/identity.js +60 -0
  156. package/build/core/repository-ledger/inventory.js +3 -3
  157. package/build/core/repository-ledger/read-model.js +57 -9
  158. package/build/core/repository-ledger/write-transaction.js +24 -17
  159. package/build/core/run-control/connection-bound-close.js +41 -0
  160. package/build/core/run-control/detached-lease-bootstrap.js +208 -0
  161. package/build/core/run-control/detached-process.js +14 -0
  162. package/build/core/run-control/index.js +6 -0
  163. package/build/core/{process-group.js → run-control/process-tree.js} +1 -1
  164. package/build/core/run-control/runner-lease.js +172 -0
  165. package/build/core/run-control/sqlite-process-lifetime-lock.js +174 -0
  166. package/build/core/seal.js +44 -32
  167. package/build/core/settlement/claim-delivery.js +22 -9
  168. package/build/core/settlement/claim.js +8 -6
  169. package/build/core/settlement/petition-claim-gates.js +9 -8
  170. package/build/core/settlement/petition-head-guard.js +5 -6
  171. package/build/core/settlement/petition-preview.js +21 -5
  172. package/build/core/settlement/petition.js +51 -17
  173. package/build/core/settlement/settlement.js +20 -15
  174. package/build/core/settlement/verdict.js +2 -2
  175. package/build/core/settlement/verification.js +492 -364
  176. package/build/core/status/board.js +184 -75
  177. package/build/core/status/drift.js +8 -10
  178. package/build/core/task/board.js +1 -0
  179. package/build/core/task/commands.js +25 -0
  180. package/build/core/task/compose.js +328 -0
  181. package/build/core/task/document.js +102 -39
  182. package/build/core/task/index.js +4 -3
  183. package/build/core/task/settlement-git.js +70 -30
  184. package/build/core/task/settlement-policy.js +27 -14
  185. package/build/core/task/source-board.js +1 -0
  186. package/build/core/task/task-bind-preparation.js +59 -9
  187. package/build/core/task/task-contract.js +2 -2
  188. package/build/core/task/task-git-store.js +1 -0
  189. package/build/core/task/task-store-repository.js +2 -0
  190. package/build/core/task/task.js +2 -2
  191. package/build/core/transcripts.js +4 -4
  192. package/build/core/verification-declaration.js +95 -0
  193. package/build/core/worktree-bootstrap.js +1 -1
  194. package/build/core/worktree-path.js +7 -11
  195. package/build/flow-error.js +15 -2
  196. package/build/generated/version.js +2 -2
  197. package/build/git/branches.js +41 -70
  198. package/build/git/commits.js +92 -21
  199. package/build/git/core.js +9 -161
  200. package/build/git/diff/preview.js +4 -4
  201. package/build/git/diff/read.js +4 -4
  202. package/build/git/diff/structured.js +5 -5
  203. package/build/git/process.js +229 -0
  204. package/build/git/refs.js +30 -5
  205. package/build/git/staging.js +39 -115
  206. package/build/git/streaming-batch.js +9 -16
  207. package/build/git/worktree.js +104 -91
  208. package/build/index.js +7 -0
  209. package/package.json +2 -2
  210. package/skills/keiyaku-akuma/SKILL.md +27 -21
  211. package/skills/keiyaku-task/SKILL.md +61 -5
  212. package/skills/keiyaku-workflow/SKILL.md +81 -26
  213. package/build/cli/commands/projection/revive/meta.js +0 -12
  214. package/build/core/projection/projection-life-protocol.js +0 -115
  215. package/build/core/projection/projection-runner-lock.js +0 -382
  216. package/build/core/projection/tell/database.js +0 -127
  217. package/build/core/settlement/verification-coordination.js +0 -305
  218. package/build/core/settlement/verification-supervisor.js +0 -275
package/README.md CHANGED
@@ -2,97 +2,90 @@
2
2
 
3
3
  契約 — a contract.
4
4
 
5
- Keiyaku is a CLI for coding agents. Not a developer tool with AI features: the
6
- intended reader of every command, receipt, and error message is a model. If a
7
- human is typing `keiyaku` by hand, something upstream has already gone wrong.
8
-
9
- The premise is old. Work you delegate to something more capable than
10
- accountable should be written down first. So here, a change begins as a
11
- contract, runs on an isolated branch, and lands only after settlement. The
12
- workers are called akuma 悪魔, devils. This is not branding. It is a
13
- reminder of the failure mode.
5
+ Keiyaku is an AI-first CLI: its user is a coding agent. Not a human writing
6
+ specs for an agent to implement an agent delegating to other agents,
7
+ running the whole loop itself: writing the terms, calling the worker,
8
+ supervising the run, settling the outcome.
9
+
10
+ That is why it is a contract system rather than a spec system. A spec relies
11
+ on someone with judgment reading it charitably; here both the worker and the
12
+ judge are models, and a model honors what you wrote, not what you meant. So
13
+ terms are binding, the worker — an akuma (悪魔, demon) — runs on an isolated
14
+ branch, gates and a reviewer judge the diff against the criteria alone, and
15
+ settlement is mechanical: the change lands on main with a commit-hash
16
+ receipt, or the branch is deleted. No human needs to be in the loop for any
17
+ step; nothing depends on anyone eyeballing anything.
14
18
 
15
19
  ```bash
16
20
  npm install -g @astrosheep/keiyaku
17
21
  ```
18
22
 
19
- Node ≥ 22.19, inside a git repository, with a clean worktree.
23
+ Node ≥ 22.19, inside a git repository with a clean worktree.
20
24
 
21
- ## Shape of a deal
25
+ ## One deal, end to end
22
26
 
23
- ```text
24
- task ─── bind ─── call ─── petition ─── claim
25
- ```
27
+ ```bash
28
+ # Write the terms: Title, Context, Objective, Design & Approach, Scope, Criteria.
29
+ # The criteria are read by the letter — precision goes here, not in prompts.
30
+ keiyaku bind - < contract.md
31
+
32
+ # Put an akuma on it. It works alone in the contract's own worktree.
33
+ keiyaku call worker-akuma --detach "fulfill the contract"
26
34
 
27
- `bind` opens a contract Title, Context, Objective, Design, Scope,
28
- Criteria and an isolated branch. A devil honors the letter of the criteria,
29
- not their spirit; the contract is where precision happens.
35
+ # It runs for as long as it needs. You are not its babysitter —
36
+ # but you can be:
37
+ keiyaku wait worker-akuma/3f21ab9e --timeout 10m
38
+ keiyaku tell worker-akuma/3f21ab9e "criteria 3 also covers the CLI output"
39
+ keiyaku kill worker-akuma/3f21ab9e # death is not an error state
30
40
 
31
- `call` projects a devil into the contract's worktree. While it runs: `tell` it
32
- things, `wait` on it, `kill` it. A finished run leaves an artifact; `revive`
33
- starts a new devil from one.
41
+ # Ask for judgment: gates run, a reviewer akuma reads the diff
42
+ # against the criteria.
43
+ keiyaku petition
34
44
 
35
- `petition` seals the delivery and enters settlement. Gates run, a reviewer
36
- reads, and then exactly one of two things happens: claim, and it lands on
37
- main — or forfeit, and the branch is gone. There is no third outcome and no
38
- quiet one.
45
+ # claim → the change lands on main, with a commit-hash receipt
46
+ # forfeit the branch is deleted; partial fulfillment is forfeiture
47
+ ```
39
48
 
40
- ## What state looks like
49
+ Every step appends to the contract's ledger. `keiyaku log` replays any deal,
50
+ finished or dead, from its receipts.
41
51
 
42
- `keiyaku status` renders the watchtower — 監視, kanshi. This is real output
43
- from this repository:
52
+ ## The board
53
+
54
+ `keiyaku status` is the one screen of state. Real output:
44
55
 
45
56
  ```text
46
57
  kanshi ─────────────────────────────────────────────────────── 現世 b4c38cc
47
58
 
48
- keiyaku 2
49
- □ fridge Add task arrange for atomic existing-task reorganization ▲2 · open 27m
50
- □ hermitcrab Let task commands select a contract workspace bound 8m
59
+ marks ● active · … starting · ⧗ waiting · ○ ready · ‖ paused · ✓ success · × stopped · ! failed/broken · ? unknown
51
60
 
52
- akuma 2
53
- worker-default/e03addad compose-impl @fridge up 27m · active 2s
54
- 09:12│ told “Root review found contract-significant gaps. Continue …” 5m12s…
55
- ⋮ 12 more
56
- 09:17│ said “The grouped verifier stream detached again, so I’m rerunning …”
57
- │ ran $ node --test tests/unit/task-compose.test.ts — 38s
58
- + 10 failed · 159 done · 4 killed
61
+ keiyaku 2
62
+ fridge Add task arrange for atomic existing-task reorganization waiting on task-reorganization.01J8TEST · active 27m
63
+ hermitcrab Let task commands select a contract workspace bound 8m
59
64
 
60
65
  task 120
61
- P1 centralize-repository-ledger-test-construction in_progress · active 14h
62
- P0 windows-common-commands-must-eliminate-git-proc… in_progress · active 3d
63
- + 108 ready · 9 blocked
66
+ in_progress P1 centralize-repository-ledger-test-construction last update 14h ago
67
+ on_hold P0 windows-common-commands-must-eliminate-git-proc last update 3d ago
68
+ + 108 ready · 9 blocked · 1 on hold
69
+
70
+ akuma 2/2
71
+ running 1/1
72
+ ● worker-default/e03addad @fridge out · running for 27m · last activity 2s ago
73
+ recent terminal 1/1
74
+ ! worker-default/64b92f01 failed 5m ago · ran 12m · last activity 5m ago
75
+ full roster: keiyaku status --akuma
64
76
  ```
65
77
 
66
- The rendering is itself under contract. `◆` may only mean a projection asserted
67
- alive liveness is never inferred from output freshness. `⋮ 12 more` counts
68
- exactly twelve omitted rows. Durations are measured, exit codes are real, and a
69
- command that never finished says `never finished`. An agent parses this screen
70
- without heuristics because every glyph has one meaning, in writing, in
71
- [`docs/keiyaku-v3/product/ui-copy.md`](docs/keiyaku-v3/product/ui-copy.md).
72
-
73
- ## Surface
74
-
75
- | | |
76
- | --- | --- |
77
- | contract | `bind` `arc` `amend` `renew` `audit` `petition` `forfeit` `log` |
78
- | devils | `call` `tell` `wait` `kill` `revive` `status` `history` |
79
- | roster | `akuma list` `akuma show` |
80
- | tasks | `task add/show/ls/log/start/stop/hold/resume/done/drop/update/doctor` |
81
- | system | `guide` `completion` `dump-env` |
82
-
83
- Conventions an agent can rely on everywhere: a literal `-` selects stdin for
84
- long bodies; `--json` exists where structure matters; a rejected command names
85
- the legal grammar instead of guessing intent; `keiyaku <cmd> --help` is the
86
- single source of syntax.
78
+ The indicator grammar is shared across contracts, Akuma, and tasks; every row
79
+ still names its exact state. `⧗` appears only with a typed wait reason, never
80
+ because work is old or behind its target. Terminal failure is factual state; it
81
+ does not by itself mean `needs attention` or an actionable obligation.
82
+ Durations are measured, exit codes are real, and drift is reported as `behind
83
+ <ref> by <count>`, never as a `renew` recommendation.
87
84
 
88
- Tasks are a file-backed board inside the repository. Dependencies keep their
89
- distinct meanings — `parent`, `needs`, `supersedes`, `relates-to` — and every
90
- mutation is validated and micro-committed on its own.
85
+ ## An akuma is one Markdown file
91
86
 
92
- ## A devil is one file
93
-
94
- Filename is the name. Frontmatter selects the provider. The body is the
95
- instructions.
87
+ Filename is the name, frontmatter picks the provider and model, the body is
88
+ the standing instructions. That's all it takes to make one callable.
96
89
 
97
90
  ```markdown
98
91
  ---
@@ -104,11 +97,11 @@ Make scoped changes and run relevant tests.
104
97
  ```
105
98
 
106
99
  Providers: `codex-sdk`, `codex-app-server`, `claude-agent-sdk`,
107
- `opencode-sdk`, `pi`. Resolution is builtin, then `<KEIYAKU_HOME>/akuma/`,
108
- then `.keiyaku/akuma/`; a higher layer replaces the file whole, never
109
- field-merges.
100
+ `opencode-sdk`, `pi` one contract can be worked by any of them, and a
101
+ finished run leaves an artifact that `fork` can continue from, even across
102
+ sessions.
110
103
 
111
- `.keiyaku/settings.json` selects roles and gates, nothing else:
104
+ `.keiyaku/settings.json` assigns roles and gates:
112
105
 
113
106
  ```json
114
107
  {
@@ -118,25 +111,26 @@ field-merges.
118
111
  }
119
112
  ```
120
113
 
121
- ## What it writes
114
+ ## And the rest
122
115
 
123
116
  | | |
124
117
  | --- | --- |
125
- | `KEIYAKU.md` | the active contract |
126
- | `.keiyaku/` | devils, settings, task board, response history |
118
+ | contract | `bind` `arc` `amend` `renew` `audit` `petition` `forfeit` `log` |
119
+ | akuma | `call` `tell` `wait` `kill` `fork` `status` `history` |
120
+ | tasks | `task add/show/ls/log/start/stop/hold/resume/done/drop/update/doctor` |
121
+ | system | `guide` `completion` `dump-env` |
127
122
 
128
- ```gitignore
129
- .keiyaku/draft/
130
- .keiyaku/response/
131
- ```
123
+ `keiyaku task` is a file-backed planning board for work that isn't worth a
124
+ contract yet — typed dependencies, one micro-commit per change, promotion
125
+ into a contract when it's ready.
132
126
 
133
- ## Law
127
+ Conventions hold everywhere: a literal `-` reads stdin for long bodies,
128
+ `--json` where structure matters, and a rejected command states the legal
129
+ grammar instead of guessing intent. State lives in `KEIYAKU.md` (the active
130
+ contract) and `.keiyaku/` (akuma, settings, task board, history).
134
131
 
135
- Product and architecture law is registered in
136
- [`docs/keiyaku-v3/`](docs/keiyaku-v3/README.md). A document is normative only
137
- if the registry lists it; age, location, and confident prose grant nothing.
132
+ Full product documentation: [`docs/keiyaku-v3/`](docs/keiyaku-v3/README.md).
138
133
 
139
- Keiyaku is early and experimental. Breaking changes are intentional, and the
140
- current version is the only version.
134
+ Keiyaku is early and experimental breaking changes are intentional.
141
135
 
142
136
  MIT.