@astrosheep/keiyaku 2.8.4 → 2.9.0

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 (229) hide show
  1. package/README.md +35 -15
  2. package/build/.tsbuildinfo +1 -1
  3. package/build/agents/{call-terms_v2.js → call-terms.js} +12 -8
  4. package/build/agents/harness/control-types.js +1 -0
  5. package/build/agents/harness/execution-handle.js +23 -3
  6. package/build/agents/harness/index.js +6 -607
  7. package/build/agents/harness/outcome.js +141 -0
  8. package/build/agents/harness/projection.js +310 -0
  9. package/build/agents/harness/router.js +201 -0
  10. package/build/agents/harness/runtime.js +2 -1
  11. package/build/agents/{launch-snapshot_v2.js → launch-snapshot/model.js} +69 -74
  12. package/build/agents/launch-snapshot/resolve.js +72 -0
  13. package/build/agents/opencode-sdk.js +24 -3
  14. package/build/agents/providers/{claude-agent-sdk.js → claude-agent-sdk/adapter.js} +46 -368
  15. package/build/agents/providers/claude-agent-sdk/events.js +218 -0
  16. package/build/agents/providers/claude-agent-sdk/session.js +158 -0
  17. package/build/agents/providers/codex-app-server/adapter.js +347 -0
  18. package/build/agents/providers/codex-app-server/events.js +352 -0
  19. package/build/agents/providers/codex-app-server/session.js +266 -0
  20. package/build/agents/providers/codex-sdk.js +23 -5
  21. package/build/agents/providers/opencode-sdk/adapter.js +344 -0
  22. package/build/agents/providers/opencode-sdk/events.js +354 -0
  23. package/build/agents/providers/opencode-sdk/session.js +180 -0
  24. package/build/agents/providers/pi/adapter.js +269 -0
  25. package/build/agents/providers/pi/checkpoint.js +41 -0
  26. package/build/agents/providers/pi/events.js +282 -0
  27. package/build/agents/{selector_v2.js → selector.js} +8 -6
  28. package/build/cli/commands/akuma/akuma/handler.js +4 -0
  29. package/build/cli/commands/akuma/akuma/meta.js +16 -0
  30. package/build/cli/commands/akuma/catalog.js +8 -0
  31. package/build/cli/commands/akuma/list/handler.js +15 -0
  32. package/build/cli/commands/akuma/list/meta-ls.js +9 -0
  33. package/build/cli/commands/akuma/view/handler.js +34 -0
  34. package/build/cli/commands/akuma/view/meta.js +8 -0
  35. package/build/cli/commands/akuma.js +1 -1
  36. package/build/cli/commands/contract/amend/handler.js +10 -0
  37. package/build/cli/commands/contract/amend/meta.js +12 -0
  38. package/build/cli/commands/contract/arc/handler.js +9 -0
  39. package/build/cli/commands/contract/arc/meta.js +26 -0
  40. package/build/cli/commands/contract/bind/handler.js +23 -0
  41. package/build/cli/commands/contract/bind/meta.js +30 -0
  42. package/build/cli/commands/contract/catalog.js +16 -0
  43. package/build/cli/commands/contract/forfeit/handler.js +13 -0
  44. package/build/cli/commands/contract/forfeit/meta.js +12 -0
  45. package/build/cli/commands/contract/log/handler.js +12 -0
  46. package/build/cli/commands/contract/log/meta.js +12 -0
  47. package/build/cli/commands/contract/petition/handler.js +26 -0
  48. package/build/cli/commands/contract/petition/meta.js +23 -0
  49. package/build/cli/commands/contract/renew/handler.js +10 -0
  50. package/build/cli/commands/contract/renew/meta.js +17 -0
  51. package/build/cli/commands/projection/call/handler.js +39 -0
  52. package/build/cli/commands/projection/call/meta.js +9 -0
  53. package/build/cli/commands/projection/catalog.js +14 -0
  54. package/build/cli/commands/projection/kill/handler.js +35 -0
  55. package/build/cli/commands/projection/kill/meta.js +11 -0
  56. package/build/cli/commands/projection/revive/handler.js +53 -0
  57. package/build/cli/commands/projection/revive/meta.js +9 -0
  58. package/build/cli/commands/projection/status/handler.js +23 -0
  59. package/build/cli/commands/projection/status/meta.js +9 -0
  60. package/build/cli/commands/projection/tell/handler.js +34 -0
  61. package/build/cli/commands/projection/tell/meta.js +9 -0
  62. package/build/cli/commands/projection/wait/handler.js +21 -0
  63. package/build/cli/commands/projection/wait/meta.js +11 -0
  64. package/build/cli/commands/registry.js +100 -0
  65. package/build/cli/commands/shared.js +71 -0
  66. package/build/cli/commands/skills/catalog.js +6 -0
  67. package/build/cli/commands/skills/install/handler.js +10 -0
  68. package/build/cli/commands/skills/install/meta.js +9 -0
  69. package/build/cli/commands/skills/skills/handler.js +4 -0
  70. package/build/cli/commands/skills/skills/meta.js +10 -0
  71. package/build/cli/commands/system/catalog.js +8 -0
  72. package/build/cli/commands/system/completion/handler.js +10 -0
  73. package/build/cli/commands/system/completion/meta.js +9 -0
  74. package/build/cli/commands/system/dump-env/handler.js +3 -0
  75. package/build/cli/commands/system/dump-env/meta.js +10 -0
  76. package/build/cli/commands/system/guide/handler.js +4 -0
  77. package/build/cli/commands/system/guide/meta.js +9 -0
  78. package/build/cli/commands/task/add/handler.js +21 -0
  79. package/build/cli/commands/task/add/meta.js +8 -0
  80. package/build/cli/commands/task/catalog.js +22 -0
  81. package/build/cli/commands/task/doctor/handler.js +4 -0
  82. package/build/cli/commands/task/doctor/meta.js +8 -0
  83. package/build/cli/commands/task/done/handler.js +17 -0
  84. package/build/cli/commands/task/done/meta.js +8 -0
  85. package/build/cli/commands/task/drop/handler.js +6 -0
  86. package/build/cli/commands/task/drop/meta.js +8 -0
  87. package/build/cli/commands/task/ls/handler.js +13 -0
  88. package/build/cli/commands/task/ls/meta.js +8 -0
  89. package/build/cli/commands/task/shared.js +131 -0
  90. package/build/cli/commands/task/start/handler.js +6 -0
  91. package/build/cli/commands/task/start/meta.js +8 -0
  92. package/build/cli/commands/task/stop/handler.js +17 -0
  93. package/build/cli/commands/task/stop/meta.js +8 -0
  94. package/build/cli/commands/task/task/handler.js +5 -0
  95. package/build/cli/commands/task/task/meta.js +11 -0
  96. package/build/cli/commands/task/update/handler.js +18 -0
  97. package/build/cli/commands/task/update/meta.js +8 -0
  98. package/build/cli/commands/task/view/handler.js +14 -0
  99. package/build/cli/commands/task/view/meta.js +8 -0
  100. package/build/cli/completion.js +26 -27
  101. package/build/cli/flags.js +79 -2
  102. package/build/cli/help.js +27 -49
  103. package/build/cli/index.js +121 -374
  104. package/build/cli/output-stream-error-policy.js +17 -0
  105. package/build/cli/parse.js +159 -72
  106. package/build/cli/projection-address.js +5 -0
  107. package/build/cli/render/arc.js +1 -1
  108. package/build/cli/render/errors.js +4 -3
  109. package/build/cli/render/format.js +14 -0
  110. package/build/cli/render/kanshi.js +106 -0
  111. package/build/cli/render/petition.js +24 -1
  112. package/build/cli/render/projection-activity.js +5 -1
  113. package/build/cli/render/shared.js +2 -2
  114. package/build/cli/render/status.js +79 -13
  115. package/build/cli/render/task.js +113 -0
  116. package/build/cli/render/wait.js +23 -3
  117. package/build/cli/types.js +1 -1
  118. package/build/config/{akuma-loader_v2.js → akuma-loader.js} +2 -2
  119. package/build/config/env.js +9 -4
  120. package/build/config/settings/disease.js +26 -0
  121. package/build/config/settings/knobs.js +8 -0
  122. package/build/config/settings/loader.js +244 -0
  123. package/build/config/settings/schema.js +276 -0
  124. package/build/core/addressing.js +1 -1
  125. package/build/core/amend.js +3 -3
  126. package/build/core/arc.js +5 -4
  127. package/build/core/bind-workspace.js +123 -0
  128. package/build/core/bind.js +75 -155
  129. package/build/core/call/call.js +224 -0
  130. package/build/core/call/context.js +238 -0
  131. package/build/core/call/execution.js +217 -0
  132. package/build/core/call/prompt.js +42 -0
  133. package/build/core/call/reference.js +24 -0
  134. package/build/core/call-persist.js +1 -1
  135. package/build/core/claim-delivery.js +247 -0
  136. package/build/core/claim.js +39 -277
  137. package/build/core/context.js +2 -1
  138. package/build/core/{render.js → contract-view.js} +12 -140
  139. package/build/core/draft.js +107 -9
  140. package/build/core/entry.js +9 -1
  141. package/build/core/execution-coordinate.js +4 -20
  142. package/build/core/execution-pact.js +16 -31
  143. package/build/core/forfeit.js +35 -22
  144. package/build/core/hints.js +2 -2
  145. package/build/core/log.js +2 -2
  146. package/build/core/petition-claim-gates.js +8 -6
  147. package/build/core/petition-preview.js +97 -0
  148. package/build/core/petition-run.js +3 -2
  149. package/build/core/petition.js +39 -26
  150. package/build/core/projection/generation/database.js +306 -0
  151. package/build/core/projection/generation/identity.js +84 -0
  152. package/build/core/projection/generation/model.js +201 -0
  153. package/build/core/projection/generation/store.js +73 -0
  154. package/build/core/projection/generation/transitions.js +258 -0
  155. package/build/core/projection/heart.js +0 -307
  156. package/build/core/projection/tell/database.js +109 -0
  157. package/build/core/projection/tell/model.js +97 -0
  158. package/build/core/{projection-tells.js → projection/tell/store.js} +3 -158
  159. package/build/core/projection-activity.js +23 -2
  160. package/build/core/projection-core.js +2 -1
  161. package/build/core/projection-execution-observer.js +259 -0
  162. package/build/core/projection-generation-continuation.js +1 -1
  163. package/build/core/projection-generation-execution.js +90 -20
  164. package/build/core/projection-generation-launcher.js +1 -1
  165. package/build/core/projection-generation-runner.js +198 -4
  166. package/build/core/projection-identity.js +1 -1
  167. package/build/core/projection-kill.js +50 -17
  168. package/build/core/projection-life-observer.js +1 -1
  169. package/build/core/projection-life-protocol.js +10 -0
  170. package/build/core/projection-mint.js +1 -1
  171. package/build/core/projection-status.js +45 -32
  172. package/build/core/projection-wait.js +12 -2
  173. package/build/core/projection-wake.js +5 -2
  174. package/build/core/{queue_v2.js → queue.js} +2 -1
  175. package/build/core/registry.js +1 -1
  176. package/build/core/renew.js +7 -7
  177. package/build/core/response-artifact-catalog-sqlite.js +112 -0
  178. package/build/core/response-artifact-catalog.js +7 -0
  179. package/build/core/seal.js +44 -16
  180. package/build/core/status/board.js +286 -0
  181. package/build/core/status/drift.js +99 -0
  182. package/build/core/status/lifecycle.js +84 -0
  183. package/build/core/status/reconciliation.js +131 -0
  184. package/build/core/stored-agent-event.js +28 -4
  185. package/build/core/target-ref.js +10 -0
  186. package/build/core/task/board.js +175 -0
  187. package/build/core/task/commands.js +211 -0
  188. package/build/core/task/document.js +189 -0
  189. package/build/core/task/model.js +1 -0
  190. package/build/core/task/settlement-git.js +207 -0
  191. package/build/core/task/settlement-policy.js +82 -0
  192. package/build/core/task/source-board.js +84 -0
  193. package/build/core/task/source-model.js +1 -0
  194. package/build/core/task/validation.js +44 -0
  195. package/build/core/task-contract.js +224 -0
  196. package/build/core/task-doctor.js +14 -0
  197. package/build/core/task-git-actor.js +38 -0
  198. package/build/core/task-git-runtime.js +34 -0
  199. package/build/core/task-git-store.js +375 -0
  200. package/build/core/task-repository.js +1 -0
  201. package/build/core/task-store-repository.js +86 -0
  202. package/build/core/task-store.js +1 -0
  203. package/build/core/task-worktree.js +51 -0
  204. package/build/core/task.js +4 -0
  205. package/build/core/transcripts.js +138 -56
  206. package/build/core/validation.js +17 -0
  207. package/build/core/verdict.js +2 -2
  208. package/build/core/worktree-path.js +24 -6
  209. package/build/flow-error.js +3 -2
  210. package/build/generated/version.js +1 -1
  211. package/build/git/commits.js +3 -0
  212. package/build/git/diff/parsers.js +0 -94
  213. package/build/index.js +2 -0
  214. package/build/keiyaku-constants.js +2 -0
  215. package/build/keiyaku.js +4 -3
  216. package/package.json +3 -2
  217. package/skills/keiyaku/SKILL.md +1 -1
  218. package/skills/keiyaku-akuma/SKILL.md +11 -6
  219. package/build/agents/harness/pump.js +0 -158
  220. package/build/agents/providers/codex-app-server.js +0 -864
  221. package/build/agents/providers/opencode-sdk.js +0 -363
  222. package/build/agents/providers/pi.js +0 -557
  223. package/build/config/settings.js +0 -533
  224. package/build/core/call.js +0 -686
  225. package/build/core/projection/generation.js +0 -412
  226. package/build/core/projection/identity.js +0 -81
  227. package/build/core/projection/mint.js +0 -174
  228. package/build/core/projection-generation-store.js +0 -707
  229. package/build/core/status.js +0 -539
@@ -0,0 +1,11 @@
1
+ import { TASK_SUBCOMMANDS } from "../../../types.js";
2
+ export const meta = {
3
+ command: "task",
4
+ summary: "Manage lightweight repository tasks",
5
+ usage: ["keiyaku task <subcommand>"],
6
+ stdin: "none",
7
+ flags: [],
8
+ purpose: "Manage the file-backed task board.",
9
+ subcommands: TASK_SUBCOMMANDS,
10
+ completionRank: 15,
11
+ };
@@ -0,0 +1,18 @@
1
+ import { openTaskCommandRepository } from "../../../../core/task-git-runtime.js";
2
+ import { updateTask } from "../../../../core/task.js";
3
+ import { renderTaskMutationRow } from "../../../render/task.js";
4
+ import { textResponse } from "../../../render/shared.js";
5
+ import { effectiveDirectory } from "../../shared.js";
6
+ export const handler = async (stdin, flags, _signal, positional) => {
7
+ const body = flags.taskBody === "-" ? stdin : flags.taskBody;
8
+ const task = await updateTask(await openTaskCommandRepository(effectiveDirectory(flags)), positional[0], {
9
+ ...(flags.taskTitle === undefined ? {} : { title: flags.taskTitle }),
10
+ ...(body === undefined ? {} : { body }),
11
+ ...(flags.taskPri === undefined ? {} : { pri: flags.taskPri }),
12
+ ...(flags.taskNeeds === undefined ? {} : { addNeeds: flags.taskNeeds }),
13
+ ...(flags.taskDropNeeds === undefined ? {} : { dropNeeds: flags.taskDropNeeds }),
14
+ ...(flags.taskParent !== undefined ? { parent: flags.taskParent } : flags.taskNoParent ? { parent: null } : {}),
15
+ ...(flags.taskFrom === undefined ? {} : { from: flags.taskFrom }),
16
+ });
17
+ return textResponse(renderTaskMutationRow(task));
18
+ };
@@ -0,0 +1,8 @@
1
+ export const meta = {
2
+ command: "task update",
3
+ summary: "Update task facts",
4
+ usage: ["keiyaku task update [-C|--cwd DIR] ID [--title TEXT] [--body TEXT|-] [--pri 0-3] [--needs ID] [--drop-needs ID] [--parent ID|--no-parent] [--from ID]"],
5
+ stdin: "none",
6
+ flags: ["cwd", "title", "body", "pri", "needs", "drop-needs", "parent", "no-parent", "from"],
7
+ purpose: "Change mutable task facts.",
8
+ };
@@ -0,0 +1,14 @@
1
+ import { FlowError } from "../../../../flow-error.js";
2
+ import { openTaskCommandRepository } from "../../../../core/task-git-runtime.js";
3
+ import { readTaskBoard, resolveTaskReadId } from "../../../../core/task.js";
4
+ import { renderTaskShow, renderTaskShowJson } from "../../../render/task.js";
5
+ import { textResponse } from "../../../render/shared.js";
6
+ import { effectiveDirectory } from "../../shared.js";
7
+ import { taskJsonText } from "../shared.js";
8
+ export const handler = async (_stdin, flags, _signal, positional) => {
9
+ const board = await readTaskBoard(await openTaskCommandRepository(effectiveDirectory(flags)));
10
+ const task = board.byId.get(resolveTaskReadId(board, positional[0]));
11
+ if (!task)
12
+ throw new FlowError("INTERNAL_STATE", "resolved task disappeared from the board");
13
+ return textResponse(flags.json ? taskJsonText(renderTaskShowJson(task)) : renderTaskShow(task));
14
+ };
@@ -0,0 +1,8 @@
1
+ export const meta = {
2
+ command: "task view",
3
+ summary: "View one task",
4
+ usage: ["keiyaku task view [-C|--cwd DIR] ID [--json]"],
5
+ stdin: "none",
6
+ flags: ["cwd", "json"],
7
+ purpose: "Read one task from the working-tree board.",
8
+ };
@@ -1,24 +1,23 @@
1
- import { assertSettingsKnobUsable, loadKeiyakuSettings } from "../config/settings.js";
2
- import { loadAkumaCatalogV2 } from "../config/akuma-loader_v2.js";
1
+ import { assertSettingsKnobUsable } from "../config/settings/disease.js";
2
+ import { loadKeiyakuSettings } from "../config/settings/loader.js";
3
+ import { loadAkumaCatalog } from "../config/akuma-loader.js";
3
4
  import { listContractIds } from "../core/ledger.js";
4
- const TOP_LEVEL_COMMANDS = [
5
- "bind",
6
- "arc",
7
- "call",
8
- "tell",
9
- "revive",
10
- "log",
11
- "akuma",
12
- "skills",
13
- "amend",
14
- "renew",
15
- "petition",
16
- "forfeit",
17
- "guide",
18
- "completion",
19
- "status",
20
- "dump-env",
21
- ];
5
+ import { allCommandMetadata, getCommandMetadata } from "./commands/registry.js";
6
+ function topLevelCommands() {
7
+ return allCommandMetadata()
8
+ .filter((meta) => meta.completionRank !== undefined)
9
+ .slice()
10
+ .sort((a, b) => {
11
+ const rankDelta = (a.completionRank ?? 0) - (b.completionRank ?? 0);
12
+ if (rankDelta !== 0)
13
+ return rankDelta;
14
+ return a.command < b.command ? -1 : a.command > b.command ? 1 : 0;
15
+ })
16
+ .map((meta) => meta.command);
17
+ }
18
+ function subcommandsFor(parent) {
19
+ return [...(getCommandMetadata(parent).subcommands ?? [])];
20
+ }
22
21
  function filterPrefix(items, word) {
23
22
  return items.filter((item) => item.startsWith(word));
24
23
  }
@@ -28,7 +27,7 @@ async function contractAddressCandidates(cwd, word) {
28
27
  async function akumaCandidates(cwd, word) {
29
28
  const loaded = await loadKeiyakuSettings(cwd);
30
29
  assertSettingsKnobUsable(loaded, "agents");
31
- return filterPrefix(Object.keys((await loadAkumaCatalogV2(cwd)).selected), word);
30
+ return filterPrefix(Object.keys((await loadAkumaCatalog(cwd)).selected), word);
32
31
  }
33
32
  export async function renderCompletionCandidates(input) {
34
33
  const word = input.word ?? "";
@@ -38,16 +37,16 @@ export async function renderCompletionCandidates(input) {
38
37
  if (input.previous === "call") {
39
38
  return filterPrefix([...(await akumaCandidates(input.cwd, word)), "--alias"], word).join("\n");
40
39
  }
41
- if (input.previous === "show") {
42
- return (await akumaCandidates(input.cwd, word)).join("\n");
43
- }
44
40
  if (input.previous === "akuma") {
45
- return filterPrefix(["list", "ls", "show"], word).join("\n");
41
+ return filterPrefix(subcommandsFor("akuma"), word).join("\n");
46
42
  }
47
43
  if (input.previous === "skills") {
48
- return filterPrefix(["install"], word).join("\n");
44
+ return filterPrefix(subcommandsFor("skills"), word).join("\n");
45
+ }
46
+ if (input.previous === "task") {
47
+ return filterPrefix(subcommandsFor("task"), word).join("\n");
49
48
  }
50
- return filterPrefix(TOP_LEVEL_COMMANDS, word).join("\n");
49
+ return filterPrefix(topLevelCommands(), word).join("\n");
51
50
  }
52
51
  export function renderCompletionScript(shell = "bash") {
53
52
  if (shell === "zsh") {
@@ -46,6 +46,11 @@ export const FLAG_SPECS = {
46
46
  placeholder: "DURATION",
47
47
  description: "Wait at most a positive duration such as 45s, 5m, or 2h (maximum 24h).",
48
48
  },
49
+ wait: {
50
+ kind: "value",
51
+ placeholder: "DURATION",
52
+ description: "After acceptance, wait at most a positive duration for the projection (maximum 24h).",
53
+ },
49
54
  incognito: {
50
55
  kind: "boolean",
51
56
  description: "Do not persist response history and do not allow revive.",
@@ -66,6 +71,31 @@ export const FLAG_SPECS = {
66
71
  kind: "boolean",
67
72
  description: "Reject bind if any active contract already exists.",
68
73
  },
74
+ place: {
75
+ kind: "value",
76
+ placeholder: "NAME",
77
+ description: "Set the H1 contract name for flag-generated bind Markdown.",
78
+ },
79
+ objective: {
80
+ kind: "value",
81
+ placeholder: "TEXT",
82
+ description: "Set the objective for flag-generated bind Markdown.",
83
+ },
84
+ scope: {
85
+ kind: "value",
86
+ placeholder: "GLOB",
87
+ description: "Set the single scope pattern for flag-generated bind Markdown.",
88
+ },
89
+ checks: {
90
+ kind: "value",
91
+ placeholder: "CHECK",
92
+ description: "Set the single acceptance check for flag-generated bind Markdown.",
93
+ },
94
+ task: {
95
+ kind: "value",
96
+ placeholder: "ID",
97
+ description: "Promote one ready task into the contract being bound.",
98
+ },
69
99
  after: {
70
100
  kind: "value",
71
101
  placeholder: "ID",
@@ -82,7 +112,7 @@ export const FLAG_SPECS = {
82
112
  },
83
113
  "dry-run": {
84
114
  kind: "boolean",
85
- description: "Preview claim effects without changing refs, ledgers, queue, registry, or worktrees.",
115
+ description: "Preview bind input or petition preflight without mutation.",
86
116
  },
87
117
  waive: {
88
118
  kind: "value",
@@ -115,7 +145,54 @@ export const FLAG_SPECS = {
115
145
  },
116
146
  all: {
117
147
  kind: "boolean",
118
- description: "Show all retained Akuma projections while preserving status priority order.",
148
+ description: "Show all retained items instead of the default filtered view.",
149
+ },
150
+ json: {
151
+ kind: "boolean",
152
+ description: "Render task data as JSON.",
153
+ },
154
+ done: {
155
+ kind: "boolean",
156
+ description: "Show terminal tasks.",
157
+ },
158
+ pri: {
159
+ kind: "value",
160
+ placeholder: "0-3",
161
+ description: "Set task priority from 0 through 3.",
162
+ },
163
+ needs: {
164
+ kind: "value",
165
+ placeholder: "ID",
166
+ description: "Add a task dependency. May be repeated.",
167
+ },
168
+ "drop-needs": {
169
+ kind: "value",
170
+ placeholder: "ID",
171
+ description: "Remove a task dependency. May be repeated.",
172
+ },
173
+ parent: {
174
+ kind: "value",
175
+ placeholder: "ID",
176
+ description: "Set the parent task.",
177
+ },
178
+ "no-parent": {
179
+ kind: "boolean",
180
+ description: "Clear the parent task.",
181
+ },
182
+ from: {
183
+ kind: "value",
184
+ placeholder: "ID",
185
+ description: "Add a discovery-lineage task. May be repeated.",
186
+ },
187
+ title: {
188
+ kind: "value",
189
+ placeholder: "TEXT",
190
+ description: "Replace the task title.",
191
+ },
192
+ body: {
193
+ kind: "value",
194
+ placeholder: "TEXT|-",
195
+ description: "Replace the task body; literal - reads stdin.",
119
196
  },
120
197
  };
121
198
  export const CONTROL_FLAGS = new Set(Object.keys(FLAG_SPECS));
package/build/cli/help.js CHANGED
@@ -1,40 +1,11 @@
1
1
  import { FlowError } from "../flow-error.js";
2
- function command(name, summary, usage, stdin, flags, purpose, extra = {}) {
3
- return { command: name, summary, usage, stdin, flags, purpose, ...extra };
2
+ import { allCommandMetadata, getCommandMetadata } from "./commands/registry.js";
3
+ export function formatSubcommandList(subcommands) {
4
+ return subcommands.length < 2 ? (subcommands[0] ?? "") : `${subcommands.slice(0, -1).join(", ")} or ${subcommands.at(-1)}`;
5
+ }
6
+ export function missingSubcommandError(name, subcommands) {
7
+ return new FlowError("EMPTY_PARAM", `${name} requires subcommand: ${formatSubcommandList(subcommands)}`);
4
8
  }
5
- export const CLI_COMMAND_METADATA = {
6
- bind: command("bind", "Create a contract ledger and workspace files", ["keiyaku bind [-C|--cwd DIR] [--repo DIR] < keiyaku.md"], "required", ["cwd", "repo", "after", "exclusive", "draft-only"], "Bind a Keiyaku from a contract draft.", {
7
- notes: ["bind creates a commission and does not accept @addr or --contract."],
8
- }),
9
- arc: command("arc", "Open the next arc and seal the current arc", ["keiyaku arc [-C|--cwd DIR] [--repo DIR] [--contract ADDR] [--waive PATH] < arc.md", "keiyaku @addr arc [-C|--cwd DIR] [--repo DIR] [--waive PATH] < arc.md"], "required", ["cwd", "repo", "contract", "waive"], "Record the next title, objective, and brief. An open arc is sealed first.", {
10
- input: ["# <arc title>", "", "## Objective", "<what this arc should accomplish>", "", "## Brief", "<scope, constraints, relevant files, instructions>"],
11
- notes: ["An empty seal is valid.", "The command does not create delivery commits."],
12
- }),
13
- call: command("call", "Start an Akuma helper session", ["keiyaku call NAME [--alias WORD] [prompt|-]", "keiyaku call NAME --detach [prompt|-]", "keiyaku @addr call NAME [prompt|-]", "keiyaku call NAME --contract ADDR [prompt|-]"], "none", ["cwd", "repo", "contract", "akuma", "model", "effort", "incognito", "bare", "detach", "alias"], "Run a scoped helper task."),
14
- revive: command("revive", "Revive an Akuma helper session", ["keiyaku revive ARTIFACT_ID"], "none", ["cwd", "repo", "model", "effort"], "Continue a persisted helper session."),
15
- wait: command("wait", "Wait for an akuma projection", ["keiyaku wait <projection-address> [--timeout DURATION]", "keiyaku @addr wait <projection-address> [--timeout DURATION]"], "none", ["cwd", "repo", "contract", "timeout"], "Read an akuma projection until its outcome is available, or show a timeout snapshot."),
16
- tell: command("tell", "Send intent to a projection mailbox", ["keiyaku tell [--effort LEVEL] PROJECTION MESSAGE", "keiyaku @addr tell [--effort LEVEL] PROJECTION MESSAGE"], "none", ["cwd", "repo", "contract", "effort"], "Write intent to the mailbox and wake only when eligible."),
17
- kill: command("kill", "Stop the current projection generation", ["keiyaku kill <projection-address>", "keiyaku @addr kill <projection-address>"], "none", ["cwd", "repo", "contract"], "Terminate the current generation while keeping the projection identity and tell ledger."),
18
- log: command("log", "Render a contract ledger", ["keiyaku log [-C|--cwd DIR] [--repo DIR] [--contract ADDR]", "keiyaku @addr log [-C|--cwd DIR] [--repo DIR]"], "none", ["cwd", "repo", "contract"], "Read a contract ledger."),
19
- akuma: command("akuma", "Inspect Akuma profiles", ["keiyaku akuma list|show"], "none", [], "Inspect configured helper profiles.", {
20
- subcommands: ["list", "ls", "show"],
21
- notes: ["Define user profiles in <KEIYAKU_HOME>/akuma/<name>.md.", "Define project profiles in .keiyaku/akuma/<name>.md.", "See README Configuration for the Markdown frontmatter format."],
22
- examples: ["keiyaku akuma list", "keiyaku akuma show akuma-codex"],
23
- }),
24
- "akuma ls": command("akuma ls", "List Akuma profiles", ["keiyaku akuma ls [-C|--cwd DIR] [--repo DIR]"], "none", ["cwd", "repo"], "List configured helper profiles.", { notes: ["Project profiles override user profiles, which override builtins."] }),
25
- "akuma list": command("akuma list", "List Akuma profiles", ["keiyaku akuma list [-C|--cwd DIR] [--repo DIR]"], "none", ["cwd", "repo"], "List configured helper profiles.", { notes: ["Project profiles override user profiles, which override builtins."] }),
26
- "akuma show": command("akuma show", "Show an Akuma profile", ["keiyaku akuma show NAME [-C|--cwd DIR] [--repo DIR]"], "none", ["cwd", "repo"], "Show one configured helper profile.", { notes: ["The output identifies the winning source and normalized provider configuration."] }),
27
- skills: command("skills", "Install official skills", ["keiyaku skills install"], "none", [], "Install bundled official Keiyaku skills into supported agent skill directories.", { subcommands: ["install"] }),
28
- "skills install": command("skills install", "Install the official Keiyaku skills", ["keiyaku skills install [-f|--force]"], "none", ["force"], "Install the bundled official Keiyaku skills into supported agent skill directories.", { notes: ["Force permits replacement of foreign collisions."] }),
29
- amend: command("amend", "Record an amendment", ["keiyaku amend [-C|--cwd DIR] [--repo DIR] [--contract ADDR] < amendment.md", "keiyaku @addr amend [-C|--cwd DIR] [--repo DIR] < amendment.md"], "required", ["cwd", "repo", "contract"], "Append a prose amendment and optional structured scope delta."),
30
- renew: command("renew", "Rewrite delivery onto the current base", ["keiyaku renew [-C|--cwd DIR] [--repo DIR] [--contract ADDR] [--waive PATH]", "keiyaku @<id> renew [-C|--cwd DIR] [--repo DIR] [--waive PATH]"], "none", ["cwd", "repo", "contract", "waive"], "Capture receipts, rewrite delivery onto the default branch, then seal and record the renewal.", { notes: ["Refuses loose commits without an open arc.", "Refuses while an Akuma is in flight.", "Conflicts restore the worktree without ledger writes."] }),
31
- petition: command("petition", "Run the gated settlement pipeline", ["keiyaku petition [-C|--cwd DIR] [--repo DIR] [--contract ADDR] [--waive PATH]", "keiyaku @<id> petition [-C|--cwd DIR] [--repo DIR] [--waive PATH]"], "none", ["cwd", "repo", "contract", "waive"], "Seal an open arc, queue the contract, and run verdict and claim processing.", { notes: ["Base drift requires explicit `keiyaku renew` before petition."] }),
32
- forfeit: command("forfeit", "Forfeit an addressed contract", ["keiyaku forfeit [-C|--cwd DIR] [--repo DIR] [--contract ADDR] [--reason TEXT]", "keiyaku @addr forfeit [-C|--cwd DIR] [--repo DIR] [--reason TEXT]"], "none", ["cwd", "repo", "contract", "reason"], "Record an abandoned contract without sealing it."),
33
- guide: command("guide", "Print the Keiyaku guide", ["keiyaku guide"], "none", [], "Print workflow guidance."),
34
- completion: command("completion", "Print shell completion", ["keiyaku completion [--shell bash|zsh]"], "none", ["cwd", "repo", "shell", "word", "previous", "complete"], "Print command and address candidates."),
35
- status: command("status", "Show the Kanshi board", ["keiyaku status [-C|--cwd DIR] [--repo DIR] [--target REF] [--all]"], "none", ["cwd", "repo", "target", "all"], "Read contract, queue, and projection facts without mutation."),
36
- "dump-env": command("dump-env", "Print the environment template", ["keiyaku dump-env"], "none", [], "Print supported environment keys.", { notes: ["Keiyaku loads <KEIYAKU_HOME>/.env, then .keiyaku/.env; process environment values win."] }),
37
- };
38
9
  function indent(lines) {
39
10
  return lines.map((line) => line ? ` ${line}` : "");
40
11
  }
@@ -50,16 +21,13 @@ function flagUsage(name, specs) {
50
21
  }
51
22
  return spec?.kind === "value" ? `--${name} ${spec.placeholder ?? "VALUE"}` : `--${name}`;
52
23
  }
53
- export function formatSubcommandList(subcommands) {
54
- return subcommands.length < 2 ? (subcommands[0] ?? "") : `${subcommands.slice(0, -1).join(", ")} or ${subcommands.at(-1)}`;
55
- }
56
- export function missingSubcommandError(name, subcommands) {
57
- return new FlowError("EMPTY_PARAM", `${name} requires subcommand: ${formatSubcommandList(subcommands)}`);
58
- }
24
+ /** Metadata keyed by command; key order matches the historical CLI_COMMAND_METADATA object. */
25
+ export const CLI_COMMAND_METADATA = Object.fromEntries(allCommandMetadata().map((meta) => [meta.command, meta]));
59
26
  export function renderCliCommandHelp(_command, spec, flagSpecs) {
60
27
  const lines = ["Keiyaku command help", "", `${spec.command} - ${spec.summary}`, ""];
61
28
  section(lines, "Usage:", spec.usage);
62
29
  section(lines, "Purpose:", [spec.purpose]);
30
+ section(lines, "Subcommands:", spec.subcommands);
63
31
  section(lines, "Input:", spec.input);
64
32
  section(lines, "Options:", spec.flags.map((name) => `${flagUsage(name, flagSpecs)} ${flagSpecs[name]?.description ?? ""}`));
65
33
  section(lines, "Notes:", spec.notes);
@@ -75,11 +43,12 @@ export function renderCliHelp(version) {
75
43
  " keiyaku @<commission> <command> [flags]",
76
44
  "",
77
45
  "Flow:",
78
- " bind -> arc -> delivery work -> arc | renew | petition",
46
+ " bind -> delivery work -> petition",
47
+ " optional: arc -> delivery work -> arc; renew on base drift",
79
48
  "",
80
49
  "Commands:",
81
50
  " bind Create a contract ledger and workspace files.",
82
- " arc Open the next arc; seals an open arc first.",
51
+ " arc Optional iteration; seals current intent first.",
83
52
  " renew Rewrite delivery onto the current base and seal it.",
84
53
  " call Start an Akuma helper session.",
85
54
  " wait Wait for an akuma projection.",
@@ -95,16 +64,19 @@ export function renderCliHelp(version) {
95
64
  " guide Print workflow guidance.",
96
65
  " completion Print shell completion.",
97
66
  " status Render the Kanshi board.",
67
+ " task Manage lightweight repository tasks.",
98
68
  " dump-env Print the environment template.",
99
69
  "",
100
70
  "Input:",
71
+ " <> means required; [] means optional.",
101
72
  " bind, arc, and amend read Markdown from stdin.",
102
- " call and revive read a prompt argument or stdin.",
73
+ " call and tell require literal BODY or `-`; only literal `-` opens stdin.",
74
+ " revive accepts an artifact plus optional BODY or `-`; only literal `-` opens stdin.",
103
75
  "",
104
76
  "Configuration:",
105
77
  " Akuma profiles <KEIYAKU_HOME>/akuma/*.md or .keiyaku/akuma/*.md",
106
78
  " Settings <KEIYAKU_HOME>/settings.json or .keiyaku/settings.json",
107
- " Inspect keiyaku akuma list | keiyaku akuma show NAME",
79
+ " Inspect keiyaku akuma ls | keiyaku akuma view NAME",
108
80
  " Environment keiyaku dump-env",
109
81
  " Full format README Configuration",
110
82
  ].join("\n");
@@ -114,13 +86,19 @@ export function buildKeiyakuGuide(version) {
114
86
  `# Keiyaku Guide (v${version})`,
115
87
  "",
116
88
  "## Workflow",
117
- "`bind -> arc -> delivery work -> arc | renew | petition`",
89
+ "`bind -> delivery work -> petition`",
90
+ "optional: `arc -> delivery work -> arc`; renew on base drift",
118
91
  "",
119
- "- `arc` records intent and seals the prior open arc automatically.",
120
- "- `renew` captures old receipts before rewriting delivery onto the default branch.",
121
- "- `petition` seals an open arc, requires a fresh base, and starts settlement.",
92
+ "- `bind` supplies derived default intent a0.",
93
+ "- `arc` is an optional iteration boundary, not admission; the first explicit arc seals a0, and later arcs seal the previous open explicit arc.",
94
+ "- `renew` seals the current a0 or open explicit arc after a successful refresh onto the default branch.",
95
+ "- `petition` seals the current a0 or open explicit arc and starts settlement.",
96
+ "- After an explicit arc closes, loose commits require another arc before renew or petition.",
122
97
  "- `call` and `revive` provide helper execution without changing the ledger lifecycle.",
123
98
  "- `skills install` installs the bundled official Keiyaku skills into supported agent skill directories; force permits replacement of foreign collisions.",
124
99
  "- `status` is read-only and reports next actions, drift, queue state, and projections.",
125
100
  ].join("\n");
126
101
  }
102
+ export function commandMetadata(command) {
103
+ return getCommandMetadata(command);
104
+ }