@astrosheep/keiyaku 4.0.0 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (241) hide show
  1. package/README.md +2 -9
  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 +11 -3
  7. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-akuma/SKILL.md +9 -6
  8. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-bind/SKILL.md +94 -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 +162 -45
  12. package/build/src/akuma/akuma.d.ts +33 -25
  13. package/build/src/akuma/akuma.js +93 -61
  14. package/build/src/akuma/archetype.d.ts +8 -0
  15. package/build/src/akuma/archetype.js +28 -9
  16. package/build/src/akuma/body.js +196 -84
  17. package/build/src/akuma/coordinate.d.ts +9 -0
  18. package/build/src/akuma/coordinate.js +22 -0
  19. package/build/src/akuma/heart/facts.d.ts +67 -15
  20. package/build/src/akuma/heart/facts.js +3 -3
  21. package/build/src/akuma/heart/index.d.ts +41 -29
  22. package/build/src/akuma/heart/index.js +72 -193
  23. package/build/src/akuma/heart/rows.d.ts +30 -53
  24. package/build/src/akuma/heart/rows.js +91 -111
  25. package/build/src/akuma/heart/schema.d.ts +1 -1
  26. package/build/src/akuma/heart/schema.js +55 -8
  27. package/build/src/akuma/heart/storage.d.ts +33 -0
  28. package/build/src/akuma/heart/storage.js +164 -0
  29. package/build/src/akuma/heart/tells.d.ts +12 -0
  30. package/build/src/akuma/heart/tells.js +79 -0
  31. package/build/src/akuma/heart/timeline.d.ts +15 -0
  32. package/build/src/akuma/heart/timeline.js +86 -0
  33. package/build/src/akuma/index.d.ts +4 -2
  34. package/build/src/akuma/index.js +1 -1
  35. package/build/src/akuma/projection.d.ts +97 -0
  36. package/build/src/akuma/projection.js +145 -0
  37. package/build/src/akuma/provider.d.ts +57 -11
  38. package/build/src/akuma/provider.js +57 -37
  39. package/build/src/akuma/providers/{claude.d.ts → claude/events.d.ts} +9 -41
  40. package/build/src/akuma/providers/claude/events.js +185 -0
  41. package/build/src/akuma/providers/claude/index.d.ts +46 -0
  42. package/build/src/akuma/providers/claude/index.js +265 -0
  43. package/build/src/akuma/providers/claude/input.d.ts +13 -0
  44. package/build/src/akuma/providers/claude/input.js +109 -0
  45. package/build/src/akuma/providers/codex-app-server/events.d.ts +1 -1
  46. package/build/src/akuma/providers/codex-app-server/events.js +12 -12
  47. package/build/src/akuma/providers/codex-app-server/index.d.ts +13 -11
  48. package/build/src/akuma/providers/codex-app-server/index.js +73 -22
  49. package/build/src/akuma/providers/index.js +22 -8
  50. package/build/src/akuma/providers/opencode-sdk/events.d.ts +48 -0
  51. package/build/src/akuma/providers/opencode-sdk/events.js +116 -0
  52. package/build/src/akuma/providers/opencode-sdk/index.d.ts +32 -0
  53. package/build/src/akuma/providers/opencode-sdk/index.js +203 -0
  54. package/build/src/akuma/providers/opencode-sdk/session.d.ts +41 -0
  55. package/build/src/akuma/providers/opencode-sdk/session.js +62 -0
  56. package/build/src/akuma/providers/pi/events.d.ts +33 -0
  57. package/build/src/akuma/providers/pi/events.js +128 -0
  58. package/build/src/akuma/providers/pi/index.d.ts +11 -0
  59. package/build/src/akuma/providers/pi/index.js +162 -0
  60. package/build/src/akuma/requests.d.ts +1 -0
  61. package/build/src/akuma/requests.js +5 -2
  62. package/build/src/alias/index.d.ts +4 -3
  63. package/build/src/alias/index.js +2 -3
  64. package/build/src/body/render.js +2 -1
  65. package/build/src/body/shape.js +7 -1
  66. package/build/src/body/verification.js +19 -4
  67. package/build/src/cli/accepted.d.ts +2 -0
  68. package/build/src/cli/accepted.js +2 -1
  69. package/build/src/cli/commands/akuma-invoke.d.ts +42 -18
  70. package/build/src/cli/commands/akuma-invoke.js +94 -50
  71. package/build/src/cli/commands/akuma.d.ts +15 -7
  72. package/build/src/cli/commands/akuma.js +94 -56
  73. package/build/src/cli/commands/contract.d.ts +142 -0
  74. package/build/src/cli/commands/contract.js +14 -0
  75. package/build/src/cli/commands/install.js +2 -0
  76. package/build/src/cli/commands/task-invoke.d.ts +3 -1
  77. package/build/src/cli/commands/task-invoke.js +27 -2
  78. package/build/src/cli/commands/task.js +2 -2
  79. package/build/src/cli/invoke.d.ts +6 -1
  80. package/build/src/cli/invoke.js +241 -43
  81. package/build/src/cli/main.js +20 -1
  82. package/build/src/cli/parse.d.ts +13 -116
  83. package/build/src/cli/parse.js +51 -78
  84. package/build/src/cli/render/akuma-tool.d.ts +2 -0
  85. package/build/src/cli/render/akuma-tool.js +6 -2
  86. package/build/src/cli/render/akuma.d.ts +2 -1
  87. package/build/src/cli/render/akuma.js +157 -217
  88. package/build/src/cli/render/catalog.d.ts +2 -0
  89. package/build/src/cli/render/catalog.js +16 -0
  90. package/build/src/cli/render/contract.d.ts +1 -1
  91. package/build/src/cli/render/contract.js +38 -5
  92. package/build/src/cli/render/kanshi.js +53 -5
  93. package/build/src/cli/render/refusal.js +17 -0
  94. package/build/src/cli/render/terminal.d.ts +13 -0
  95. package/build/src/cli/render/terminal.js +75 -0
  96. package/build/src/cli/render/text.js +5 -0
  97. package/build/src/cli/result.d.ts +15 -3
  98. package/build/src/contract-worktree.d.ts +43 -0
  99. package/build/src/contract-worktree.js +213 -0
  100. package/build/src/coordination/durable-file.d.ts +3 -0
  101. package/build/src/coordination/durable-file.js +44 -1
  102. package/build/src/core/facts/codec.js +23 -4
  103. package/build/src/core/facts/eligibility.d.ts +1 -10
  104. package/build/src/core/facts/eligibility.js +0 -49
  105. package/build/src/core/facts/observation.d.ts +3 -0
  106. package/build/src/core/facts/observation.js +12 -0
  107. package/build/src/core/facts/types.d.ts +10 -3
  108. package/build/src/core/subject.js +2 -2
  109. package/build/src/core/verbs/amend.js +12 -16
  110. package/build/src/core/verbs/bind.js +2 -16
  111. package/build/src/core/verbs/deliver.js +20 -4
  112. package/build/src/core/verbs/placement.js +3 -8
  113. package/build/src/dispatch/index.d.ts +3 -1
  114. package/build/src/dispatch/index.js +14 -5
  115. package/build/src/duration.d.ts +10 -0
  116. package/build/src/duration.js +22 -0
  117. package/build/src/git/admission.d.ts +2 -2
  118. package/build/src/git/admission.js +26 -16
  119. package/build/src/git/hooks.d.ts +15 -0
  120. package/build/src/git/hooks.js +57 -5
  121. package/build/src/git/identity.d.ts +5 -1
  122. package/build/src/git/identity.js +23 -4
  123. package/build/src/git/integration.d.ts +49 -0
  124. package/build/src/git/integration.js +214 -0
  125. package/build/src/git/observe.d.ts +25 -13
  126. package/build/src/git/observe.js +175 -72
  127. package/build/src/git/read-observation.d.ts +41 -0
  128. package/build/src/git/read-observation.js +361 -0
  129. package/build/src/git/reconcile.d.ts +15 -5
  130. package/build/src/git/reconcile.js +238 -85
  131. package/build/src/git/repository.d.ts +19 -4
  132. package/build/src/git/repository.js +77 -43
  133. package/build/src/git/scratch.d.ts +13 -0
  134. package/build/src/git/scratch.js +66 -0
  135. package/build/src/git/target-placement.d.ts +56 -0
  136. package/build/src/git/target-placement.js +255 -0
  137. package/build/src/git/tender.d.ts +48 -0
  138. package/build/src/git/tender.js +82 -0
  139. package/build/src/git/terminal-seal.d.ts +24 -0
  140. package/build/src/git/terminal-seal.js +87 -0
  141. package/build/src/git/tree.d.ts +2 -2
  142. package/build/src/git/tree.js +4 -0
  143. package/build/src/git/workspace.d.ts +21 -0
  144. package/build/src/git/workspace.js +104 -0
  145. package/build/src/identity/selector.d.ts +6 -0
  146. package/build/src/identity/selector.js +19 -0
  147. package/build/src/index.d.ts +4 -2
  148. package/build/src/index.js +2 -1
  149. package/build/src/kanshi/index.d.ts +1 -1
  150. package/build/src/kanshi/read.d.ts +5 -2
  151. package/build/src/kanshi/read.js +154 -45
  152. package/build/src/kanshi/report.d.ts +31 -6
  153. package/build/src/kanshi/select.js +1 -1
  154. package/build/src/library/address.d.ts +48 -0
  155. package/build/src/library/address.js +134 -0
  156. package/build/src/library/akuma-creation.d.ts +10 -6
  157. package/build/src/library/akuma-creation.js +12 -11
  158. package/build/src/library/bind.d.ts +21 -0
  159. package/build/src/library/bind.js +56 -0
  160. package/build/src/library/catalog.d.ts +58 -0
  161. package/build/src/library/catalog.js +72 -0
  162. package/build/src/library/configuration.d.ts +6 -15
  163. package/build/src/library/configuration.js +14 -17
  164. package/build/src/library/contract.d.ts +21 -46
  165. package/build/src/library/contract.js +193 -183
  166. package/build/src/library/delivery.d.ts +23 -0
  167. package/build/src/library/delivery.js +21 -0
  168. package/build/src/library/fleet.d.ts +65 -0
  169. package/build/src/library/fleet.js +189 -0
  170. package/build/src/library/input.d.ts +3 -0
  171. package/build/src/library/input.js +19 -0
  172. package/build/src/library/keiyaku.d.ts +16 -2
  173. package/build/src/library/keiyaku.js +11 -1
  174. package/build/src/library/mutation.d.ts +38 -0
  175. package/build/src/library/mutation.js +39 -0
  176. package/build/src/library/refusal.d.ts +21 -0
  177. package/build/src/library/refusal.js +29 -0
  178. package/build/src/library/region.d.ts +2 -1
  179. package/build/src/library/region.js +3 -3
  180. package/build/src/library/repo.d.ts +4 -1
  181. package/build/src/library/repo.js +31 -16
  182. package/build/src/protocol/attempt.d.ts +16 -3
  183. package/build/src/protocol/attempt.js +39 -8
  184. package/build/src/protocol/bind.d.ts +9 -2
  185. package/build/src/protocol/bind.js +47 -39
  186. package/build/src/protocol/intent.d.ts +42 -18
  187. package/build/src/protocol/intent.js +36 -75
  188. package/build/src/protocol/operations.d.ts +93 -35
  189. package/build/src/protocol/operations.js +235 -123
  190. package/build/src/protocol/outcome.d.ts +7 -2
  191. package/build/src/protocol/outcome.js +9 -3
  192. package/build/src/protocol/placement.d.ts +30 -0
  193. package/build/src/protocol/placement.js +114 -0
  194. package/build/src/protocol/read/audit.d.ts +9 -3
  195. package/build/src/protocol/read/audit.js +25 -9
  196. package/build/src/protocol/read/documents.d.ts +2 -2
  197. package/build/src/protocol/read/documents.js +4 -4
  198. package/build/src/protocol/read/status.d.ts +11 -5
  199. package/build/src/protocol/read/status.js +28 -15
  200. package/build/src/protocol/run.d.ts +49 -7
  201. package/build/src/protocol/run.js +53 -25
  202. package/build/src/runtime/proc/line-rpc.d.ts +1 -0
  203. package/build/src/runtime/proc/line-rpc.js +21 -0
  204. package/build/src/runtime/proc/run.d.ts +18 -2
  205. package/build/src/runtime/proc/run.js +34 -8
  206. package/build/src/settings.d.ts +6 -0
  207. package/build/src/settings.js +29 -14
  208. package/build/src/settlement/fence.d.ts +9 -0
  209. package/build/src/settlement/fence.js +23 -0
  210. package/build/src/settlement/holder.d.ts +25 -4
  211. package/build/src/settlement/holder.js +102 -28
  212. package/build/src/settlement/settle.d.ts +8 -0
  213. package/build/src/settlement/settle.js +102 -28
  214. package/build/src/task/board.d.ts +20 -2
  215. package/build/src/task/board.js +11 -1
  216. package/build/src/task/compose.d.ts +2 -2
  217. package/build/src/task/compose.js +2 -2
  218. package/build/src/task/context.js +2 -7
  219. package/build/src/task/index.d.ts +9 -9
  220. package/build/src/task/index.js +15 -12
  221. package/build/src/task/operations.d.ts +31 -12
  222. package/build/src/task/operations.js +8 -4
  223. package/build/src/task/store.d.ts +4 -6
  224. package/build/src/task/store.js +3 -3
  225. package/build/src/verification/declaration.d.ts +1 -0
  226. package/build/src/verification/execution.d.ts +49 -0
  227. package/build/src/verification/execution.js +104 -0
  228. package/build/src/world.d.ts +13 -0
  229. package/build/src/world.js +103 -0
  230. package/package.json +7 -4
  231. package/build/src/akuma/activity.d.ts +0 -66
  232. package/build/src/akuma/activity.js +0 -139
  233. package/build/src/akuma/providers/claude.js +0 -305
  234. package/build/src/context-root.d.ts +0 -4
  235. package/build/src/context-root.js +0 -15
  236. package/build/src/git/delivery.d.ts +0 -20
  237. package/build/src/git/delivery.js +0 -109
  238. package/build/src/git/verification.d.ts +0 -14
  239. package/build/src/git/verification.js +0 -56
  240. package/build/src/verification/producer.d.ts +0 -23
  241. package/build/src/verification/producer.js +0 -54
package/README.md CHANGED
@@ -1,16 +1,9 @@
1
- # Keiyaku v4
1
+ # Keiyaku
2
2
 
3
- Keiyaku v4 is a clean implementation of an agent-facing contract workflow.
3
+ Keiyaku is an agent-facing contract workflow.
4
4
 
5
5
  The first milestone is intentionally narrow: a Git-backed facts kernel with
6
6
  per-contract append-only journals, Git-tree evidence, atomic path-set CAS,
7
7
  and tests that prove clone and garbage-collection durability.
8
8
 
9
9
  No v3 runtime code is wired into this repository.
10
-
11
- ## Install
12
-
13
- ```sh
14
- npm install -g @astrosheep/keiyaku
15
- keiyaku --help
16
- ```
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "keiyaku",
3
- "version": "0.1.0",
4
- "description": "Use the Keiyaku v4 contract, task, and Akuma CLI.",
3
+ "version": "0.1.0+codex.20260813114301",
4
+ "description": "Use the Keiyaku contract, task, and Akuma CLI.",
5
5
  "author": { "name": "Keiyaku" },
6
6
  "skills": "./skills/"
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "keiyaku",
3
- "version": "0.1.0",
4
- "description": "Use the Keiyaku v4 contract, task, and Akuma CLI.",
3
+ "version": "0.1.0+codex.20260813114301",
4
+ "description": "Use the Keiyaku contract, task, and Akuma CLI.",
5
5
  "author": {
6
6
  "name": "Keiyaku"
7
7
  },
@@ -9,10 +9,10 @@
9
9
  "interface": {
10
10
  "displayName": "Keiyaku",
11
11
  "shortDescription": "Use Keiyaku in Codex.",
12
- "longDescription": "Keiyaku adds the v4 agent-facing workflow CLI.",
12
+ "longDescription": "Keiyaku adds the agent-facing workflow CLI.",
13
13
  "developerName": "Keiyaku",
14
14
  "category": "Productivity",
15
15
  "capabilities": [],
16
- "defaultPrompt": "Use Keiyaku v4 to coordinate this work."
16
+ "defaultPrompt": "Use Keiyaku to coordinate this work."
17
17
  }
18
18
  }
@@ -1,11 +1,11 @@
1
1
  import { readFile } from "node:fs/promises";
2
2
  import { fileURLToPath } from "node:url";
3
3
 
4
- const skills = ["keiyaku", "keiyaku-task", "keiyaku-workflow", "keiyaku-akuma"]
4
+ const skills = ["keiyaku", "keiyaku-task", "keiyaku-bind", "keiyaku-workflow", "keiyaku-akuma"]
5
5
  .map((name) => fileURLToPath(new URL(`./skills/${name}/SKILL.md`, import.meta.url)));
6
6
 
7
7
  export default {
8
- id: "keiyaku-v4",
8
+ id: "keiyaku",
9
9
  server: async () => ({
10
10
  config: async (config) => {
11
11
  const instructions = config.instructions ?? (config.instructions = []);
@@ -1,6 +1,6 @@
1
1
  {
2
- "name": "keiyaku-v4-harness",
3
- "version": "0.1.0",
2
+ "name": "keiyaku-harness",
3
+ "version": "0.1.0+codex.20260813114301",
4
4
  "type": "module",
5
5
  "main": "./opencode.js",
6
6
  "keywords": ["pi-package"],
@@ -11,24 +11,32 @@ read `<command> --help` before using flags.
11
11
  ## Model
12
12
 
13
13
  - `task` is planning; see `keiyaku-task`.
14
- - A Contract is delivery authority; see `keiyaku-workflow`.
14
+ - A Contract is delivery authority; see `keiyaku-bind` to author and bind one,
15
+ then `keiyaku-workflow` for the remaining lifecycle.
15
16
  - An Akuma is a callable worker; see `keiyaku-akuma`.
16
17
 
18
+ Settings owns named gate sets. Omitting `--gates` selects `gates.default`, or
19
+ freezes an empty gate list when that entry is absent. `--gates <name>` selects
20
+ one configured set; it does not add a literal gate word.
21
+
17
22
  ## Quick Start
18
23
 
19
24
  ```bash
20
25
  keiyaku -C <repo> task add "title"
21
26
  keiyaku -C <repo> task start <task-id>
22
- keiyaku -C <repo> bind -
27
+ keiyaku -C <repo> bind [--task <task-id>] -
23
28
  keiyaku -C <repo> status
24
29
  keiyaku -C <repo> deliver [<contract>|@<contract>]
25
30
  keiyaku -C <repo> review [<contract>|@<contract>] --satisfied
26
31
  ```
27
32
 
28
33
  ```bash
29
- keiyaku -C <repo> call <akuma> [--contract <kei/...>] [--alias @name] [--workdir <path>] [--wait [--timeout <duration>] | -d | --detach] [--json] -
34
+ keiyaku -C <cwd> call <akuma> [--contract <kei/...>] [--alias @name] [--wait [--timeout <duration>] | -d | --detach] [--json] -
30
35
  keiyaku -C <repo> wait <aku/...>
31
36
  keiyaku -C <repo> tell <aku/...> -
32
37
  ```
33
38
 
39
+ `-C` is the invocation and Akuma execution cwd. Add `--repo <path>` only when
40
+ a Contract or Dispatch reader must use a different Git repository.
41
+
34
42
  Use text by default; add `--json` when a script needs structured output.
@@ -11,22 +11,25 @@ An Akuma is a durable callable worker projection. Its complete id is
11
11
  ## Choose A Verb
12
12
 
13
13
  ```bash
14
- keiyaku -C <repo> call <akuma> [--contract <kei/...>] [--alias @name] [--workdir <path>] [--wait [--timeout <duration>] | -d | --detach] [--json] -
14
+ keiyaku -C <cwd> call <akuma> [--contract <kei/...>] [--alias @name] [--wait [--timeout <duration>] | -d | --detach] [--json] -
15
15
  keiyaku -C <repo> wait <aku/...> [--timeout <duration>]
16
16
  keiyaku -C <repo> tell <aku/...> -
17
- keiyaku -C <repo> interrupt <aku/...> -
17
+ keiyaku -C <repo> tell <aku/...> --interrupt -
18
18
  keiyaku -C <repo> history <aku/...>
19
19
  keiyaku -C <repo> fork <aku/...> --at <historyId>
20
20
  keiyaku -C <repo> kill <aku/...>
21
21
  ```
22
22
 
23
23
  `call` starts from an Archetype, requires a final stdin body, and waits up to
24
- five minutes by default. Use `-d` or `--detach` to return after birth. `tell` continues
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
25
27
  the same projection, including after it has answered. `fork` starts a child
26
28
  from one exact retained answered-turn coordinate and leaves the source alone.
27
- `interrupt` puts down the current body synchronously, then records the tell;
28
- it is not terminal kill. `kill` records death and returns typed physical
29
- evidence.
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.
30
33
 
31
34
  ## Observe
32
35
 
@@ -0,0 +1,94 @@
1
+ ---
2
+ name: keiyaku-bind
3
+ description: Author and bind one Keiyaku delivery Contract. Use when deciding whether a bounded delivery is ready for Contract terms, writing those terms for an implementer, binding an existing Task with `bind --task`, choosing bind inputs, or interpreting the bind receipt and worktree handoff.
4
+ ---
5
+
6
+ # Keiyaku Bind
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>
30
+
31
+ ## Context
32
+ <established facts that frame the decision>
33
+
34
+ ## Objective
35
+ <one observable delivery outcome>
36
+
37
+ ## Design
38
+ <ownership, boundaries, and constraints a test-green candidate could violate>
39
+
40
+ ## Region
41
+ ```
42
+ <expected write surface>
43
+ ```
44
+
45
+ ## Criteria
46
+ ### <criterion title>
47
+ <one decidable acceptance condition>
48
+
49
+ ## Verification
50
+ ```bash
51
+ <optional executable check>
52
+ ```
53
+ ~~~
54
+
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.
59
+
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:
73
+
74
+ ```bash
75
+ keiyaku -C <repo> bind - < CONTRACT.md
76
+ keiyaku -C <repo> bind --task <task/...> - < CONTRACT.md
77
+ ```
78
+
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.
81
+
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.
85
+
86
+ ## Read The Receipt
87
+
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.
93
+
94
+ Continue the delivery with `keiyaku-workflow`.
@@ -0,0 +1,4 @@
1
+ interface:
2
+ display_name: "Keiyaku Bind"
3
+ short_description: "Author and bind a delivery Contract."
4
+ default_prompt: "Use $keiyaku-bind to author and bind this delivery."
@@ -7,7 +7,13 @@ description: "Use when planning work in a Keiyaku v4 repo: add tasks, wire depen
7
7
 
8
8
  Task is a directory-context planning product. It is separate from Contract
9
9
  delivery and Akuma execution. A task records intent; `start` does not execute
10
- it and no task command binds a Contract.
10
+ it and no task command binds a Contract. Task use is optional: create one only
11
+ when planning needs a durable reader such as priority, dependencies, readiness,
12
+ or coordination across deliveries. Do not create one as boilerplate before
13
+ binding a Contract. Contract `bind --task <task/...>` optionally associates an
14
+ existing Task through Settlement-owned TaskHolder: claim settles the current
15
+ held Task to `done`, and abandon releases it. Task Markdown carries no Contract
16
+ field.
11
17
 
12
18
  ## Lifecycle
13
19
 
@@ -55,8 +61,37 @@ keiyaku task update <task-id> --title <text>
55
61
  keiyaku task namespace [<namespace>]
56
62
  ```
57
63
 
58
- Use `--json` on any command when a script must inspect the typed result. Use
59
- `task compose -` for one atomic tree/graph edit; read its command help for the
60
- composition grammar. Relations are explicit facts: `needs` orders work,
61
- `parent` groups it, `supersedes` navigates replacement, and `relates` does not
62
- affect readiness.
64
+ Use `--json` on any command when a script must inspect the typed result.
65
+ Relations are explicit facts: `needs` orders work, `parent` groups it,
66
+ `supersedes` navigates replacement, and `relates` does not affect readiness.
67
+
68
+ ## Batch Create Or Modify
69
+
70
+ Use `task compose -` to create and modify multiple Tasks in one planning
71
+ document:
72
+
73
+ ```bash
74
+ keiyaku task compose - <<'EOF'
75
+ ns=feature
76
+ + Parent pri=0
77
+ Parent body.
78
+ + Child needs=@task/existing
79
+ @task/existing pri=1 relates+=@task/other
80
+ Replacement body.
81
+ EOF
82
+ ```
83
+
84
+ - Optional first line `ns=<segment/...>` selects the allocation namespace;
85
+ `ns=` selects root.
86
+ - `+ <title>` creates a Task. `@task/<id>` modifies an existing Task.
87
+ - Two spaces of indentation assign the preceding shallower Task as `parent`.
88
+ - Inline assignments are `pri=`, `parent=`, `needs=`, `supersedes=`, and
89
+ `relates=`. Relation values are comma-separated `@task/...` references.
90
+ - `=` replaces or clears a field. `+=` appends only to `needs`, `supersedes`,
91
+ or `relates`.
92
+ - Prose after a node replaces its body; bare `body=` clears it. Prefix body
93
+ lines beginning with `+ `, `@task/`, or `\` with one `\`.
94
+
95
+ Compose does not change Task lifecycle state. Each changed Task is admitted
96
+ independently; an incomplete result returns a canonical draft for the remaining
97
+ batch.
@@ -5,68 +5,185 @@ description: Use when authoring, binding, delivering, reviewing, amending, audit
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: write what done
9
+ means, bind it, work in the worktree the receipt names, and deliver. When
10
+ every declared gate is current, the result lands on the target ref. This is
11
+ the whole trip from current work to `claimed`.
12
12
 
13
- ## Lifecycle
13
+ ## How The Delivery Moves
14
14
 
15
15
  ```text
16
- bind -> waiting | bound -> pending delivery -> claimed
17
- \-> abandoned
16
+ contract document -> bind -> work in the Contract worktree -> deliver
17
+ -> review gates -> placement -> claimed
18
+ \-> abandoned
18
19
  ```
19
20
 
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.
21
+ The lifecycle is `waiting -> bound -> pending-delivery -> claimed | abandoned`;
22
+ the last two are terminal. `--after` prerequisites hold a Contract at
23
+ `waiting`; it becomes `bound` automatically once they are satisfied. You never
24
+ push it through states by hand: `deliver` and satisfied reviews request
25
+ placement, and placement claims when the gates allow it.
26
26
 
27
27
  ## Bind
28
28
 
29
- Write one canonical Contract document to stdin and bind it:
29
+ Use `keiyaku-bind` to decide readiness, author one bounded Contract, choose
30
+ bind inputs, and read the receipt. Continue here from that receipt.
31
+
32
+ ## Work In The Contract Worktree
33
+
34
+ Change and test code in the worktree the bind receipt names. `deliver` accepts
35
+ a clean worktree by default. You may commit first, or explicitly include all
36
+ non-ignored staged, unstaged, and untracked final bytes with
37
+ `deliver --include-dirty`. Check where you are at any point:
30
38
 
31
39
  ```bash
32
- keiyaku bind -
33
- keiyaku bind --target <ref> -
34
- keiyaku bind --here -
35
- keiyaku bind --after <kei/...> --gates <name> -
40
+ keiyaku status [<contract>|@<contract>]
36
41
  ```
37
42
 
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.
43
+ `status` shows the lifecycle state, the candidate, and one mark per gate: `✓`
44
+ current satisfied, `!` current unsatisfied, `?` stale because the patch or
45
+ document changed after the evidence, and `○` missing.
46
+
47
+ ## Commission A Contract
48
+
49
+ When another agent will fulfill or review the Contract, the commissioning
50
+ harness must pass one explicit seat and one exact worktree. `--contract` or an
51
+ equivalent association identifies the Contract; it does not appoint a seat.
52
+ Never ask the worker to infer either value.
53
+
54
+ Use this minimum handoff in the dispatch body, regardless of harness:
55
+
56
+ ```text
57
+ Contract: kei/...
58
+ Seat: Deliverer | Reviewer
59
+ Worktree: /absolute/path/from-the-bind-receipt
60
+ Read first:
61
+ - .keiyaku/KEIYAKU.md
62
+ - <owner documents governing this delivery>
63
+ - <source files named or selected from the Contract Region for this work>
64
+ Objective:
65
+ <bounded assignment>
66
+ ```
67
+
68
+ Every `Read first` path is relative to `Worktree` unless it is absolute. The
69
+ worker starts by reading `.keiyaku/KEIYAKU.md` in that worktree, confirms its
70
+ frontmatter names `Contract`, then reads the listed owner documents and source
71
+ files before acting. Do not substitute a generic repository tour for the files
72
+ that actually govern the assignment.
73
+
74
+ A `Deliverer` implements and verifies the terms, keeps all work in `Worktree`,
75
+ and reports the candidate, checks run, and unmet terms. A `Reviewer` reads the
76
+ same worktree and Contract, judges the current candidate with direct evidence,
77
+ and does not modify it. If `Seat`, `Worktree`, or the required reading list is
78
+ missing or contradictory, the worker stops and asks the caller instead of
79
+ guessing.
42
80
 
43
- ## Work And Acceptance
81
+ ## Arcs For Large Deliveries
82
+
83
+ When one Contract carries several coherent chunks, record each chunk as an arc
84
+ before moving to the next:
44
85
 
45
86
  ```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>]
87
+ keiyaku arc <contract> -
88
+ ```
89
+
90
+ The stdin body is the arc's Markdown; see `arc --help` for its shape. Arcs
91
+ narrate one delivery; they do not split acceptance. Work that needs its own
92
+ independent acceptance is a new Contract, not an arc.
93
+
94
+ ## Amend Or Start Over
95
+
96
+ Use `amend` when a discovery during the same delivery changes terms but the
97
+ original Objective, Design, and acceptance boundary still truthfully describe
98
+ the result:
99
+
100
+ ```bash
101
+ keiyaku amend <contract> -
54
102
  ```
55
103
 
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.
104
+ See `amend --help` for the operation grammar. If the objective or boundary
105
+ itself changed, `abandon` with a note and bind a new Contract; do not steer an
106
+ old Contract onto a different delivery.
107
+
108
+ ## Deliver
109
+
110
+ ```bash
111
+ keiyaku deliver <contract>
112
+ ```
113
+
114
+ `deliver` tenders the clean `HEAD`, runs the declared `Verification`, records
115
+ the candidate, and requests placement. If the workspace is dirty, the refusal
116
+ lists staged, unstaged, and untracked paths, a short statistic, and the
117
+ `--include-dirty` option. Use that option only when the complete current
118
+ workspace is the intended delivery; dirty submodule internals cannot be
119
+ included. Read the receipt:
120
+
121
+ - When every gate is current, the receipt shows placement and `claimed`; the
122
+ delivery is done.
123
+ - When a gate is not current, the receipt shows the recorded candidate and the
124
+ placement stop. This is not a failed delivery. The Contract stays
125
+ `pending-delivery` while you complete the gates.
126
+
127
+ Verification declarations may set an individual timeout in the fence info
128
+ string, using an explicit duration unit such as `bash timeout=5m`. Omit the
129
+ attribute for an unbounded declaration; there is no Verification-wide timeout.
130
+
131
+ ## Review Gates
132
+
133
+ A `reviewed` gate wants a recorded judgment of the current patch:
134
+
135
+ ```bash
136
+ keiyaku review <contract> --satisfied --summary "<conclusion>"
137
+ keiyaku review <contract> --unsatisfied --summary "<finding>"
138
+ ```
139
+
140
+ Have an independent reviewer read the exact Contract worktree first; the
141
+ `review` command records the gate-visible verdict. `--satisfied` requests
142
+ placement. If the same patch is already delivered and the other gates are
143
+ current, the receipt shows `claimed`. Review works before or after deliver.
144
+ When the reviewed projection includes ordinary dirty workspace bytes, the
145
+ review receipt discloses those paths and stats; delivery still needs
146
+ `deliver --include-dirty` before those bytes become the candidate.
147
+
148
+ Fixing findings changes the patch, which turns earlier evidence stale (`?` in
149
+ `status`): review the current patch again. Record `--unsatisfied` only when the
150
+ negative judgment should remain in Contract history.
151
+
152
+ ## Target Placement
153
+
154
+ Placement follows the Git mental model you already have:
155
+
156
+ - Delivering from a managed worktree to a checked-out target behaves like a
157
+ merge. Non-overlapping staged, unstaged, and untracked files in that checkout
158
+ are preserved. A staged path refuses only when Git cannot carry it through
159
+ the predecessor-to-candidate merge; overlapping worktree changes and
160
+ colliding untracked files also refuse. The receipt lists the exact paths.
161
+ The deliver or review you just ran still counts: the recorded candidate and
162
+ any `✓ reviewed` verdict are kept, but nothing claims and nothing moves.
163
+ The target ref, its checkout, and your bytes stay exactly where they were,
164
+ and the Contract stays `pending-delivery`.
165
+ - A `--here` Contract behaves like a commit with gates: it lands on the current
166
+ branch and cannot deliver to a foreign checked-out target.
167
+
168
+ After a refusal, handle the listed paths, then `deliver` again or record a
169
+ satisfied review; either command requests placement again.
170
+
171
+ ## Observe, Recover, Or End
172
+
173
+ ```bash
174
+ keiyaku audit <contract> [--show-diff-body] # report only; never places
175
+ keiyaku reconcile <contract> # finish accepted lagging effects
176
+ keiyaku abandon <contract> --note "<why>" # terminal; target untouched
177
+ ```
62
178
 
63
- ## Terminal Choice
179
+ `audit` is one aggregate read of the document, candidate diff, Verification,
180
+ gates, and target status. `reconcile` completes physical effects of already
181
+ accepted placements; it does not retry an ordinary placement refusal.
182
+ `abandon` ends the Contract and never touches the target.
64
183
 
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.
184
+ ## Routine Output
70
185
 
71
- Use default text output for routine observation. Add `--json` when a script
72
- needs the public result without renderer-specific text.
186
+ Use default text output for normal operation and `--json` only when a script
187
+ needs the public result. Use the complete `kei/...` ID, or `@...` inside a
188
+ managed worktree. When a flag or stdin form is unclear, read that command's
189
+ `--help` instead of guessing.
@@ -1,7 +1,8 @@
1
1
  import { type AkumaLife, type CollarProbe, 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;
@@ -11,14 +12,14 @@ export type AkumaListRow = Readonly<{
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
+ collar: CollarProbe;
19
+ timeline: ActivitySnapshot;
20
+ strandedReason?: "resume-unsupported";
20
21
  }>;
21
- export type { ActivityHistory, ActivityRow, ActivitySnapshot } from "./activity.js";
22
+ export type { ActivityHistory, ActivityRow, ActivitySnapshot, ActivitySnapshotEntry } from "./projection.js";
22
23
  export type UnbornAkumaListRow = Readonly<{
23
24
  id: AkuId;
24
25
  life: "unborn" | "stillborn";
@@ -31,25 +32,26 @@ export type AkumaList = Readonly<{
31
32
  rows: readonly (AkumaListRow | UnbornAkumaListRow)[];
32
33
  searched: readonly string[];
33
34
  }>;
34
- export type TellReceipt = Readonly<{
35
- id: string;
36
- state: "recorded";
35
+ export type AkumaListInput = Readonly<{
36
+ archetype?: string;
37
+ }>;
38
+ export type TellResult = Readonly<{
39
+ admission: Readonly<{
40
+ tellId: string;
41
+ fact: "recorded";
42
+ }>;
37
43
  wake: "spawned" | Readonly<{
38
44
  kind: "failed";
39
45
  diagnostic: string;
40
46
  }>;
41
47
  }>;
42
48
  export type InterruptReceipt = Readonly<{
43
- kind: "dead";
44
- }> | Readonly<{
45
49
  kind: "unstoppable";
46
50
  evidence: "no-collar" | "collar-unverifiable" | "unavailable" | "alive-after-sigkill" | "leash-held-after-put-down";
47
51
  }> | Readonly<{
48
52
  kind: "interrupted";
49
53
  putDown: "was-idle" | "self-aborted" | "collar";
50
- tell: TellReceipt | Readonly<{
51
- kind: "refused-dead";
52
- }>;
54
+ tell: TellResult;
53
55
  }>;
54
56
  export type ForkReceipt = Readonly<{
55
57
  kind: "forked";
@@ -73,10 +75,12 @@ export declare class AkumaNotBornError extends Error {
73
75
  readonly kind = "akuma-not-born";
74
76
  constructor(id: AkuId);
75
77
  }
78
+ /** Package-internal compact observation for action feedback. */
79
+ export declare function readActionFeedbackStatus(worldPath: WorldRoot, id: AkuId): AkumaStatus;
76
80
  export declare class AkumaHandle {
77
81
  readonly id: AkuId;
78
82
  private readonly worldPath;
79
- constructor(id: AkuId, worldPath: string);
83
+ constructor(id: AkuId, worldPath: WorldRoot);
80
84
  private get paths();
81
85
  status(): AkumaStatus;
82
86
  history(input?: Readonly<{
@@ -87,22 +91,26 @@ export declare class AkumaHandle {
87
91
  wait(predicate?: (status: AkumaStatus) => boolean, options?: Readonly<{
88
92
  timeoutMs?: number;
89
93
  }>): Promise<AkumaStatus>;
90
- tell(body: string): Promise<TellReceipt>;
94
+ tell(body: string): Promise<TellResult>;
91
95
  interrupt(body: string): Promise<InterruptReceipt>;
92
96
  fork(input: Readonly<{
93
97
  at: string;
94
98
  }>): Promise<ForkReceipt>;
95
99
  kill(): Promise<KillEvidence>;
96
- lastAnswer(): string;
100
+ lastAnswer(): LastAnswer;
97
101
  }
102
+ export type LastAnswer = Readonly<{
103
+ kind: "answer";
104
+ answer: string;
105
+ }> | Readonly<{
106
+ kind: "no-answer";
107
+ }>;
98
108
  export declare class Akuma {
99
109
  private readonly path;
100
- private readonly settings;
110
+ private readonly configuredSettings?;
101
111
  private constructor();
102
- static at(input: Readonly<{
103
- path: string;
104
- settings?: Settings;
105
- }>): Akuma;
112
+ static of(root: WorldRoot, settings?: Settings): Akuma;
113
+ private settings;
106
114
  of(input: Readonly<{
107
115
  id: string;
108
116
  }>): AkumaHandle;
@@ -112,5 +120,5 @@ export declare class Akuma {
112
120
  body: string;
113
121
  cwd?: string;
114
122
  }>): Promise<AkumaHandle>;
115
- list(): AkumaList;
123
+ list(input?: AkumaListInput): AkumaList;
116
124
  }