@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
@@ -0,0 +1,6 @@
1
+ import { appendTaskNote, resolveTaskCreator } from "../../../../core/task/index.js";
2
+ import { runTaskMutationCommand } from "../shared.js";
3
+ export const handler = async (stdin, flags, _signal, positional) => runTaskMutationCommand(flags, async (repository, cwd) => appendTaskNote(repository, positional[0], {
4
+ actor: await resolveTaskCreator(cwd),
5
+ text: stdin,
6
+ }));
@@ -0,0 +1,11 @@
1
+ export const meta = {
2
+ command: "task note",
3
+ summary: "Append an immutable task note",
4
+ usage: ["keiyaku task note [-C|--cwd DIR] [--contract ADDR] COORDINATE TEXT|-"],
5
+ stdin: {
6
+ mode: "argument",
7
+ selector: { kind: "positional", index: 1, required: true, rejectBlank: true },
8
+ },
9
+ flags: ["cwd", "contract"],
10
+ purpose: "Record an append-only task journal fact.",
11
+ };
@@ -1,8 +1,8 @@
1
1
  export const meta = {
2
2
  command: "task resume",
3
3
  summary: "Resume a task on hold",
4
- usage: ["keiyaku task resume [-C|--cwd DIR] COORDINATE"],
4
+ usage: ["keiyaku task resume [-C|--cwd DIR] [--contract ADDR] COORDINATE"],
5
5
  stdin: { mode: "argument" },
6
- flags: ["cwd"],
6
+ flags: ["cwd", "contract"],
7
7
  purpose: "Return an on-hold task to open.",
8
8
  };
@@ -1,30 +1,44 @@
1
1
  import { FlowError } from "../../../flow-error.js";
2
+ import { attachAddressCarrier, resolveExplicitContractAddressFromRead } from "../../../core/addressing.js";
3
+ import { readRepositoryLifecycle } from "../../../core/repository-ledger/read-model.js";
4
+ import { findRegisteredContractWorktreePathFromModel, stableRepoRoot } from "../../../core/worktree-path.js";
2
5
  import { openTaskCommandRepository, parseTaskDocument, readTaskDoctor, taskCoordinateFromSourcePath, } from "../../../core/task/index.js";
3
6
  import { deriveTaskDisplay, renderTaskList, renderTaskMutationRow, } from "../../render/task.js";
4
7
  import { textResponse } from "../../render/shared.js";
5
8
  import { effectiveDirectory } from "../shared.js";
6
- /** Open the task command repository for flags.cwd and run the verb. */
7
- export async function withTaskCommandRepository(flags, run) {
9
+ /** Resolve --contract to its one ledger-owned checkout before task access. */
10
+ export async function taskCommandDirectory(flags) {
8
11
  const cwd = effectiveDirectory(flags);
12
+ if (flags.contractId === undefined)
13
+ return cwd;
14
+ const stableRoot = await stableRepoRoot(cwd);
15
+ const admitted = resolveExplicitContractAddressFromRead({
16
+ read: await readRepositoryLifecycle(stableRoot),
17
+ stableRoot,
18
+ workdir: cwd,
19
+ raw: flags.contractId,
20
+ source: flags.contractAddressSource ?? "explicit-flag",
21
+ });
22
+ const worktree = admitted.model.resources.worktree;
23
+ const lifecycle = admitted.model.phase;
24
+ if (!worktree || worktree.state !== "held") {
25
+ throw attachAddressCarrier(new FlowError("CONTRACT_WORKSPACE_UNAVAILABLE", `contract ${admitted.model.contract} has no materialized workspace for task commands (${lifecycle})`, { facts: { kind: "task_contract_workspace", contractId: admitted.model.contract, lifecycle, reason: "not-materialized" } }), admitted.address);
26
+ }
27
+ const registered = await findRegisteredContractWorktreePathFromModel(stableRoot, admitted.model);
28
+ if (!registered) {
29
+ throw attachAddressCarrier(new FlowError("CONTRACT_WORKSPACE_UNAVAILABLE", `contract ${admitted.model.contract} worktree is not a verified ledger-owned materialized checkout`, { facts: { kind: "task_contract_workspace", contractId: admitted.model.contract, lifecycle, reason: "unregistered" } }), admitted.address);
30
+ }
31
+ return registered;
32
+ }
33
+ /** Open the selected task command repository and run the verb. */
34
+ export async function withTaskCommandRepository(flags, run) {
35
+ const cwd = await taskCommandDirectory(flags);
9
36
  return run(await openTaskCommandRepository(cwd), cwd);
10
37
  }
11
38
  /** Shared shell: open repository → mutate → renderTaskMutationRow receipt. */
12
39
  export async function runTaskMutationCommand(flags, mutate) {
13
40
  return textResponse(renderTaskMutationRow(await withTaskCommandRepository(flags, mutate)));
14
41
  }
15
- export function parseTaskAddInput(input) {
16
- if (!input.trim())
17
- throw new FlowError("EMPTY_PARAM", "task add input cannot be blank");
18
- const lines = input.split(/\r?\n/);
19
- const firstLine = lines[0]?.startsWith("# ") ? lines[0].slice(2) : lines[0];
20
- const title = firstLine?.trim() ?? "";
21
- if (!title)
22
- throw new FlowError("EMPTY_PARAM", "task title cannot be blank");
23
- if (lines.length > 1 && lines[1].trim() !== "") {
24
- throw new FlowError("EMPTY_PARAM", "task add body must follow the title after a blank line");
25
- }
26
- return { title, body: lines.slice(2).join("\n") };
27
- }
28
42
  export function taskSelection(flags) {
29
43
  return flags.all ? "all" : flags.done ? "done" : "default";
30
44
  }
@@ -1,8 +1,8 @@
1
1
  export const meta = {
2
2
  command: "task show",
3
3
  summary: "Show one task and its children tree",
4
- usage: ["keiyaku task show [-C|--cwd DIR] COORDINATE [--json]"],
4
+ usage: ["keiyaku task show [-C|--cwd DIR] [--contract ADDR] COORDINATE [--json]"],
5
5
  stdin: { mode: "argument" },
6
- flags: ["cwd", "json"],
6
+ flags: ["cwd", "contract", "json"],
7
7
  purpose: "Read one task and every descendant linked by parent edges.",
8
8
  };
@@ -1,8 +1,8 @@
1
1
  export const meta = {
2
2
  command: "task start",
3
3
  summary: "Start a task",
4
- usage: ["keiyaku task start [-C|--cwd DIR] COORDINATE"],
4
+ usage: ["keiyaku task start [-C|--cwd DIR] [--contract ADDR] COORDINATE"],
5
5
  stdin: { mode: "argument" },
6
- flags: ["cwd"],
6
+ flags: ["cwd", "contract"],
7
7
  purpose: "Move an open task to in_progress.",
8
8
  };
@@ -1,8 +1,8 @@
1
1
  export const meta = {
2
2
  command: "task stop",
3
3
  summary: "Stop a task",
4
- usage: ["keiyaku task stop [-C|--cwd DIR] [COORDINATE]"],
4
+ usage: ["keiyaku task stop [-C|--cwd DIR] [--contract ADDR] [COORDINATE]"],
5
5
  stdin: { mode: "argument" },
6
- flags: ["cwd"],
6
+ flags: ["cwd", "contract"],
7
7
  purpose: "Return an in-progress task to open.",
8
8
  };
@@ -1,11 +1,12 @@
1
+ export const TASK_UPDATE_EXPLICIT_CHANGE_ERROR = "task update requires an explicit change: --title, --body TEXT or --body -, --append TEXT|-, --pri, --needs/--drop-needs, --parent/--no-parent, --from, --supersedes/--drop-supersedes, or --relates-to/--drop-relates-to";
1
2
  export const meta = {
2
3
  command: "task update",
3
4
  summary: "Update task facts",
4
- usage: ["keiyaku task update [-C|--cwd DIR] COORDINATE [--title TEXT] [--body TEXT|-|--append TEXT|-] [--pri 0-3] [--needs COORDINATE] [--drop-needs COORDINATE] [--parent COORDINATE|--no-parent] [--from COORDINATE] [--supersedes COORDINATE] [--drop-supersedes COORDINATE] [--relates-to COORDINATE] [--drop-relates-to COORDINATE] [--json]"],
5
+ usage: ["keiyaku task update [-C|--cwd DIR] [--contract ADDR] COORDINATE [--title TEXT] [--body TEXT|-|--append TEXT|-] [--pri 0-3] [--needs COORDINATE] [--drop-needs COORDINATE] [--parent COORDINATE|--no-parent] [--from COORDINATE] [--supersedes COORDINATE] [--drop-supersedes COORDINATE] [--relates-to COORDINATE] [--drop-relates-to COORDINATE] [--json]"],
5
6
  stdin: {
6
7
  mode: "argument",
7
8
  selector: { kind: "flag", names: ["taskBody", "taskAppend"], required: false, rejectBlank: false },
8
9
  },
9
- flags: ["cwd", "title", "body", "append", "pri", "needs", "drop-needs", "parent", "no-parent", "from", "supersedes", "drop-supersedes", "relates-to", "drop-relates-to", "json"],
10
+ flags: ["cwd", "contract", "title", "body", "append", "pri", "needs", "drop-needs", "parent", "no-parent", "from", "supersedes", "drop-supersedes", "relates-to", "drop-relates-to", "json"],
10
11
  purpose: "Change mutable task facts.",
11
12
  };
@@ -0,0 +1,43 @@
1
+ import { readVerificationRun, requestVerificationRunCancellation, VerificationRunUnknownError, VerificationRunWaitTimeoutError, waitForVerificationRun, } from "../../../core/settlement/verification.js";
2
+ import { FlowError } from "../../../flow-error.js";
3
+ import { renderVerificationCli, verificationCancelModel, verificationStatusModel, verificationWaitModel, verificationWaitTimeoutModel, } from "../../render/verification.js";
4
+ import { projectDirectory } from "../shared.js";
5
+ export const handler = async (_stdin, flags, signal, positional) => {
6
+ const [operation, runId, ...extra] = positional;
7
+ if (!operation || !runId || extra.length > 0) {
8
+ throw new FlowError("EMPTY_PARAM", "verification requires wait, status, or cancel followed by one VerificationRun id");
9
+ }
10
+ // Honor --repo through the shared repository-resolution primitive.
11
+ const root = await projectDirectory(flags, "verification");
12
+ const json = flags.json === true;
13
+ if (operation === "wait") {
14
+ try {
15
+ // Observation only: timeout/abort end wait without requesting cancellation.
16
+ const terminal = await waitForVerificationRun({ root, runId, timeoutMs: flags.timeoutMs, signal });
17
+ return renderVerificationCli(verificationWaitModel(runId, terminal), json);
18
+ }
19
+ catch (error) {
20
+ if (error instanceof VerificationRunUnknownError) {
21
+ throw new FlowError("UNKNOWN_ADDRESS", error.message);
22
+ }
23
+ if (!(error instanceof VerificationRunWaitTimeoutError))
24
+ throw error;
25
+ return renderVerificationCli(verificationWaitTimeoutModel(runId), json);
26
+ }
27
+ }
28
+ if (operation === "status") {
29
+ const run = readVerificationRun(root, runId);
30
+ if (!run)
31
+ throw new FlowError("UNKNOWN_ADDRESS", `verification run '${runId}' does not exist`);
32
+ return renderVerificationCli(verificationStatusModel(run), json);
33
+ }
34
+ if (operation === "cancel") {
35
+ // Explicit cancel is the only mutating verification CLI path.
36
+ if (!readVerificationRun(root, runId)) {
37
+ throw new FlowError("UNKNOWN_ADDRESS", `verification run '${runId}' does not exist`);
38
+ }
39
+ const accepted = requestVerificationRunCancellation(root, runId);
40
+ return renderVerificationCli(verificationCancelModel(runId, accepted), json);
41
+ }
42
+ throw new FlowError("INVALID_USAGE", "verification operation must be wait, status, or cancel");
43
+ };
@@ -0,0 +1,13 @@
1
+ export const meta = {
2
+ command: "verification",
3
+ summary: "Observe or cancel one durable VerificationRun",
4
+ usage: [
5
+ "keiyaku verification wait RUN_ID [-C|--cwd DIR] [--repo DIR] [--timeout DURATION] [--json]",
6
+ "keiyaku verification cancel RUN_ID [-C|--cwd DIR] [--repo DIR] [--json]",
7
+ "keiyaku verification status RUN_ID [-C|--cwd DIR] [--repo DIR] [--json]",
8
+ ],
9
+ stdin: { mode: "argument" },
10
+ flags: ["cwd", "repo", "timeout", "json"],
11
+ purpose: "Rejoin, inspect, or request cancellation of an addressable VerificationRun without inspecting runtime SQLite directly.",
12
+ completionRank: 11,
13
+ };
@@ -19,8 +19,8 @@ function topLevelCommands() {
19
19
  function subcommandsFor(parent) {
20
20
  return [...(getCommandMetadata(parent).subcommands ?? [])];
21
21
  }
22
- function topLevelOptionsFor(command) {
23
- const metadata = allCommandMetadata().find((meta) => meta.command === command && !command.includes(" "));
22
+ function optionsForCommandContext(context) {
23
+ const metadata = allCommandMetadata().find((meta) => meta.command === context);
24
24
  return metadata ? metadata.flags.map((flag) => `--${flag}`) : [];
25
25
  }
26
26
  function filterPrefix(items, word) {
@@ -40,22 +40,24 @@ export async function renderCompletionCandidates(input) {
40
40
  if (word.startsWith("@")) {
41
41
  return (await contractAddressCandidates(input.cwd, word)).join("\n");
42
42
  }
43
- if (input.previous === "call") {
43
+ const previous = input.previous ?? "";
44
+ const previousWord = previous.split(/\s+/).at(-1) ?? "";
45
+ if (previous === "call") {
44
46
  return filterPrefix([...(await akumaCandidates(input.cwd, word)), "--alias"], word).join("\n");
45
47
  }
46
- if (input.previous === "akuma") {
48
+ if (previous === "akuma") {
47
49
  return filterPrefix(subcommandsFor("akuma"), word).join("\n");
48
50
  }
49
- if (input.previous === "skills") {
51
+ if (previous === "skills") {
50
52
  return filterPrefix(subcommandsFor("skills"), word).join("\n");
51
53
  }
52
- if (input.previous === "task") {
54
+ if (previous === "task") {
53
55
  return filterPrefix(subcommandsFor("task"), word).join("\n");
54
56
  }
55
- if (input.previous === "--filter") {
57
+ if (previousWord === "--filter") {
56
58
  return filterPrefix([TASK_FILTER_COMPLETION], word).join("\n");
57
59
  }
58
- const options = input.previous ? topLevelOptionsFor(input.previous) : [];
60
+ const options = previous ? optionsForCommandContext(previous) : [];
59
61
  if (options.length > 0) {
60
62
  return filterPrefix(options, word).join("\n");
61
63
  }
@@ -66,8 +68,9 @@ export function renderCompletionScript(shell = "bash") {
66
68
  return [
67
69
  "#compdef keiyaku",
68
70
  "_keiyaku() {",
69
- " local -a candidates",
70
- " candidates=(${(f)\"$(keiyaku completion --complete --word=\"${words[CURRENT]}\" --previous=\"${words[CURRENT-1]}\" 2>/dev/null)\"})",
71
+ " local -a candidates context",
72
+ " context=\"${(j: :)words[2,CURRENT-1]}\"",
73
+ " candidates=(${(f)\"$(keiyaku completion --complete --word=\"${words[CURRENT]}\" --previous=\"${context}\" 2>/dev/null)\"})",
71
74
  " compadd -- $candidates",
72
75
  "}",
73
76
  "_keiyaku \"$@\"",
@@ -75,13 +78,13 @@ export function renderCompletionScript(shell = "bash") {
75
78
  }
76
79
  return [
77
80
  "_keiyaku_completion() {",
78
- " local cur prev",
81
+ " local cur context",
79
82
  " cur=\"${COMP_WORDS[COMP_CWORD]}\"",
80
- " prev=\"${COMP_WORDS[COMP_CWORD-1]}\"",
83
+ " context=\"${COMP_WORDS[*]:1:$((COMP_CWORD - 1))}\"",
81
84
  " COMPREPLY=()",
82
85
  " while IFS= read -r candidate; do",
83
86
  " COMPREPLY+=(\"$candidate\")",
84
- " done < <(keiyaku completion --complete --word=\"$cur\" --previous=\"$prev\" 2>/dev/null)",
87
+ " done < <(keiyaku completion --complete --word=\"$cur\" --previous=\"$context\" 2>/dev/null)",
85
88
  "}",
86
89
  "complete -F _keiyaku_completion keiyaku",
87
90
  ].join("\n");
@@ -47,6 +47,11 @@ export const FLAG_SPECS = {
47
47
  placeholder: "DURATION",
48
48
  description: "Wait at most a positive duration such as 45s, 5m, or 2h (maximum 24h).",
49
49
  },
50
+ entry: {
51
+ kind: "value",
52
+ placeholder: "N",
53
+ description: "Select one zero-based retained history entry from an addressed projection.",
54
+ },
50
55
  any: {
51
56
  kind: "boolean",
52
57
  description: "For a projection set, return when the first observed member reaches a terminal state.",
@@ -58,7 +63,7 @@ export const FLAG_SPECS = {
58
63
  },
59
64
  incognito: {
60
65
  kind: "boolean",
61
- description: "Do not persist response history and do not allow revive.",
66
+ description: "Do not persist response history and do not allow fork.",
62
67
  },
63
68
  bare: {
64
69
  kind: "boolean",
@@ -103,7 +108,7 @@ export const FLAG_SPECS = {
103
108
  scope: {
104
109
  kind: "value",
105
110
  placeholder: "GLOB",
106
- description: "Set the single scope pattern for flag-generated bind Markdown.",
111
+ description: "Add an ordered scope pattern to flag-generated bind Markdown. May be repeated.",
107
112
  },
108
113
  criteria: {
109
114
  kind: "value",
@@ -138,6 +143,10 @@ export const FLAG_SPECS = {
138
143
  kind: "boolean",
139
144
  description: "Preview bind input or petition preflight without mutation.",
140
145
  },
146
+ check: {
147
+ kind: "boolean",
148
+ description: "Derive and render the task composition without changing the board or Git state.",
149
+ },
141
150
  "append-scope": {
142
151
  kind: "value",
143
152
  placeholder: "PATTERN",
@@ -147,6 +156,10 @@ export const FLAG_SPECS = {
147
156
  kind: "boolean",
148
157
  description: "Renew onto the current target before petitioning.",
149
158
  },
159
+ audit: {
160
+ kind: "boolean",
161
+ description: "Run the ordinary read-only audit after a completed renew.",
162
+ },
150
163
  continue: {
151
164
  kind: "boolean",
152
165
  description: "Continue from the derived renew conflict scratch.",
@@ -187,11 +200,29 @@ export const FLAG_SPECS = {
187
200
  kind: "boolean",
188
201
  description: "Render structured data as JSON.",
189
202
  },
203
+ limit: {
204
+ kind: "value",
205
+ placeholder: "COUNT",
206
+ description: "Limit terminal rows in the Akuma roster.",
207
+ },
208
+ offset: {
209
+ kind: "value",
210
+ placeholder: "COUNT",
211
+ description: "Skip terminal rows in the Akuma roster.",
212
+ },
213
+ raw: {
214
+ kind: "boolean",
215
+ description: "Include retained raw event bodies when inspecting one history entry.",
216
+ },
190
217
  "diff-budget": {
191
218
  kind: "value",
192
219
  placeholder: "BYTES",
193
220
  description: "Set the audit raw-diff presentation budget in bytes.",
194
221
  },
222
+ "skip-diff-body": {
223
+ kind: "boolean",
224
+ description: "Suppress raw diff hunk bodies from the human audit presentation without changing audit evidence or checks.",
225
+ },
195
226
  done: {
196
227
  kind: "boolean",
197
228
  description: "Show terminal tasks.",
@@ -209,51 +240,51 @@ export const FLAG_SPECS = {
209
240
  pri: {
210
241
  kind: "value",
211
242
  placeholder: "0-3",
212
- description: "Set task priority from 0 through 3.",
243
+ description: "Set task priority: 0 (highest) through 3 (lowest).",
213
244
  },
214
245
  needs: {
215
246
  kind: "value",
216
247
  placeholder: "ID",
217
- description: "Add a task dependency. May be repeated.",
248
+ description: "Order execution: this task needs another task first. May be repeated.",
218
249
  },
219
250
  "drop-needs": {
220
251
  kind: "value",
221
252
  placeholder: "ID",
222
- description: "Remove a task dependency. May be repeated.",
253
+ description: "Remove an execution-ordering dependency. May be repeated.",
223
254
  },
224
255
  parent: {
225
256
  kind: "value",
226
257
  placeholder: "ID",
227
- description: "Set the parent task.",
258
+ description: "Organize task hierarchy under a parent task.",
228
259
  },
229
260
  "no-parent": {
230
261
  kind: "boolean",
231
- description: "Clear the parent task.",
262
+ description: "Clear the hierarchy parent task.",
232
263
  },
233
264
  from: {
234
265
  kind: "value",
235
266
  placeholder: "ID",
236
- description: "Add a discovery-lineage task. May be repeated.",
267
+ description: "Record work discovered while doing another task. May be repeated.",
237
268
  },
238
269
  supersedes: {
239
270
  kind: "value",
240
271
  placeholder: "ID",
241
- description: "Record that this task supersedes another task. May be repeated.",
272
+ description: "Record that this task replaces another task. May be repeated.",
242
273
  },
243
274
  "drop-supersedes": {
244
275
  kind: "value",
245
276
  placeholder: "ID",
246
- description: "Remove a supersedes relation. May be repeated.",
277
+ description: "Remove a replacement relation. May be repeated.",
247
278
  },
248
279
  "relates-to": {
249
280
  kind: "value",
250
281
  placeholder: "ID",
251
- description: "Record related work. May be repeated.",
282
+ description: "Record a thematic relation without ordering or replacement. May be repeated.",
252
283
  },
253
284
  "drop-relates-to": {
254
285
  kind: "value",
255
286
  placeholder: "ID",
256
- description: "Remove a related-work relation. May be repeated.",
287
+ description: "Remove a thematic relation. May be repeated.",
257
288
  },
258
289
  title: {
259
290
  kind: "value",
@@ -270,6 +301,11 @@ export const FLAG_SPECS = {
270
301
  placeholder: "TEXT|-",
271
302
  description: "Append a Markdown paragraph to the task body; literal - reads stdin.",
272
303
  },
304
+ note: {
305
+ kind: "value",
306
+ placeholder: "TEXT|-",
307
+ description: "Append an immutable task note; literal - reads stdin.",
308
+ },
273
309
  };
274
310
  export const CONTROL_FLAGS = new Set(Object.keys(FLAG_SPECS));
275
311
  export const VALUE_FLAGS = new Set(Object.entries(FLAG_SPECS)
package/build/cli/help.js CHANGED
@@ -25,7 +25,7 @@ export function renderCliCommandHelp(_command, spec, flagSpecs) {
25
25
  section(lines, "Purpose:", [spec.purpose]);
26
26
  section(lines, "Subcommands:", spec.subcommands);
27
27
  section(lines, "Input:", spec.input);
28
- section(lines, "Options:", spec.flags.map((name) => `${flagUsage(name, flagSpecs)} ${spec.flagDescriptions?.[name] ?? flagSpecs[name]?.description ?? ""}`));
28
+ section(lines, "Options:", spec.flags.map((name) => `${spec.flagUsages?.[name] ?? flagUsage(name, flagSpecs)} ${spec.flagDescriptions?.[name] ?? flagSpecs[name]?.description ?? ""}`));
29
29
  section(lines, "Notes:", spec.notes);
30
30
  section(lines, "Examples:", spec.examples);
31
31
  return lines.join("\n").trimEnd();
@@ -39,27 +39,27 @@ export function renderCliHelp(version) {
39
39
  " keiyaku @<commission> <command> [flags]",
40
40
  "",
41
41
  "Flow:",
42
- " bind -> delivery work -> petition",
43
- " optional: arc -> delivery work -> arc; renew on base drift",
42
+ " bind -> make and commit changes -> petition",
43
+ " optional: arc -> make and commit changes -> arc; renew when the target moves",
44
44
  "",
45
45
  "Commands:",
46
- " bind Create a contract ledger and workspace files.",
47
- " arc Optional iteration; seals current intent first.",
48
- " renew Rewrite delivery onto the current base and seal it.",
49
- " call Start an Akuma helper session.",
50
- " wait Wait for an akuma projection.",
51
- " revive Revive an Akuma helper session.",
52
- " tell Send intent to an Akuma projection.",
53
- " kill Stop the current Akuma generation.",
54
- " log Render a contract ledger.",
55
- " akuma Inspect helper profiles.",
46
+ " bind Create a contract and its workspace.",
47
+ " arc Seal the current stage and begin another.",
48
+ " renew Refresh committed changes onto the contract target.",
49
+ " call Start an Akuma projection.",
50
+ " wait Wait for a projection.",
51
+ " fork Start a projection from a response artifact.",
52
+ " tell Send a message to a projection.",
53
+ " kill Stop a projection's active run.",
54
+ " log Show a contract history.",
55
+ " akuma Inspect available Akuma definitions.",
56
56
  " skills Install bundled official skills.",
57
57
  " amend Record an amendment.",
58
- " petition Run settlement processing.",
59
- " forfeit Forfeit an addressed contract.",
58
+ " petition Ask Keiyaku to settle a contract.",
59
+ " forfeit End a contract without claiming it.",
60
60
  " guide Print workflow guidance.",
61
61
  " completion Print shell completion.",
62
- " status Render the Kanshi board.",
62
+ " status Show contracts, tasks, and projections that need attention.",
63
63
  " task Manage lightweight repository tasks.",
64
64
  " dump-env Print the environment template.",
65
65
  "",
@@ -67,12 +67,12 @@ export function renderCliHelp(version) {
67
67
  " <> means required; [] means optional.",
68
68
  " bind, arc, amend, and petition read document stdin only when literal `-` selects it.",
69
69
  " call and tell require literal BODY or `-`; literal `-` selects stdin.",
70
- " revive accepts an artifact plus optional BODY or `-`; unselected stdin is ignored.",
70
+ " fork accepts an artifact plus optional BODY or `-`; unselected stdin is ignored.",
71
71
  "",
72
72
  "Configuration:",
73
- " Akuma profiles <KEIYAKU_HOME>/akuma/*.md or .keiyaku/akuma/*.md",
73
+ " Akuma definitions <KEIYAKU_HOME>/akuma/*.md or .keiyaku/akuma/*.md",
74
74
  " Settings <KEIYAKU_HOME>/settings.json or .keiyaku/settings.json",
75
- " Inspect keiyaku akuma ls | keiyaku akuma show NAME",
75
+ " Inspect keiyaku akuma list | keiyaku akuma show NAME",
76
76
  " Environment keiyaku dump-env",
77
77
  " Full format README Configuration",
78
78
  ].join("\n");
@@ -81,18 +81,17 @@ export function buildKeiyakuGuide(version) {
81
81
  return [
82
82
  `# Keiyaku Guide (v${version})`,
83
83
  "",
84
- "## Workflow",
85
- "`bind -> delivery work -> petition`",
86
- "optional: `arc -> delivery work -> arc`; renew on base drift",
84
+ "A task is a planning item: it does not create a workspace or start work.",
85
+ "A contract is one bounded delivery with its own workspace. It begins bound and ends claimed when settlement lands it, or forfeited when it is ended without a claim.",
86
+ "An Akuma is a callable worker definition. A projection is one run of an Akuma.",
87
87
  "",
88
- "- `bind` supplies derived default intent a0.",
89
- "- `arc` is an optional iteration boundary, not admission; the first explicit arc seals a0, and later arcs seal the previous open explicit arc.",
90
- "- `renew` seals the current a0 or open explicit arc after a successful refresh onto the default branch.",
91
- "- `petition` seals the current a0 or open explicit arc and starts settlement.",
92
- "- After an explicit arc closes, loose commits require another arc before renew or petition.",
93
- "- `call` and `revive` provide helper execution without changing the ledger lifecycle.",
94
- "- `skills install` installs the bundled official Keiyaku skills into supported agent skill directories; force permits replacement of foreign collisions.",
95
- "- `status` is read-only and reports next actions, drift, queue state, and projections.",
88
+ "`bind -> make and commit changes -> petition`",
89
+ "",
90
+ "Binding a contract establishes its first delivery stage. A `seal` records that stage's committed changes and scope at a lifecycle boundary.",
91
+ "`arc` is an optional boundary: it seals the current stage and opens the next. Use arcs only for successive stages of one contract and one final settlement; they do not create separately claimable work.",
92
+ "When the contract target moves, `renew` refreshes the committed changes onto it and seals the refreshed current stage.",
93
+ "`petition` seals the current stage, runs the contract's settlement checks, and claims the contract only when they pass. If a settlement gate fails, the contract is not claimed; address the reported problem and petition again.",
94
+ "Use separate tasks and contracts for work with separate acceptance, ownership, or waiting needs. `status` shows the work that needs attention.",
96
95
  ].join("\n");
97
96
  }
98
97
  export function commandMetadata(command) {
@@ -37,10 +37,10 @@ function prepareBindInput(stdin, flags, selectsStdin) {
37
37
  const nonblankStdin = stdin.trim().length > 0;
38
38
  const domainFlags = hasBindDomainFlags(flags);
39
39
  if (flags.dryRun && flags.draftOnly) {
40
- throw new FlowError("EMPTY_PARAM", "--dry-run cannot be combined with --draft-only");
40
+ throw new FlowError("INVALID_USAGE", "--dry-run cannot be combined with --draft-only");
41
41
  }
42
42
  if (selectsStdin && domainFlags) {
43
- throw new FlowError("EMPTY_PARAM", "bind accepts either stdin Markdown or domain flags, not both");
43
+ throw new FlowError("INVALID_USAGE", "bind accepts either stdin Markdown or domain flags, not both");
44
44
  }
45
45
  if (domainFlags) {
46
46
  const missing = [];
@@ -74,7 +74,10 @@ function prepareBindInput(stdin, flags, selectsStdin) {
74
74
  if (flags.bindTaskIds !== undefined && flags.bindTaskIds.length > 0) {
75
75
  return "";
76
76
  }
77
- throw new FlowError("EMPTY_PARAM", `No Markdown input received on stdin.\n\nExample:\n ${usageExample("bind")}`);
77
+ const message = selectsStdin
78
+ ? `No Markdown input received on stdin.\n\nExample:\n ${usageExample("bind")}`
79
+ : "bind requires literal '-' for Markdown input or the required domain flags";
80
+ throw new FlowError(selectsStdin ? "STDIN_EMPTY" : "EMPTY_PARAM", message);
78
81
  }
79
82
  return stdin;
80
83
  }
@@ -217,9 +220,6 @@ async function resolveCliInput(parsed) {
217
220
  const selected = selectedArgument(parsed);
218
221
  const token = selected?.token;
219
222
  const selectsStdin = token === "-";
220
- if (selectsStdin && process.stdin.isTTY) {
221
- throw new FlowError("EMPTY_PARAM", `${parsed.command} literal '-' requires piped stdin`);
222
- }
223
223
  const piped = selectsStdin ? await readStdin() : "";
224
224
  const input = selectsStdin ? piped : token ?? "";
225
225
  if (stdinMeta.selector?.required && token === undefined) {
@@ -231,8 +231,14 @@ async function resolveCliInput(parsed) {
231
231
  if (token !== undefined && stdinMeta.selector?.rejectBlank && !input.trim()) {
232
232
  const message = stdinMeta.mode === "document"
233
233
  ? `No Markdown input received on stdin.\n\nExample:\n ${usageExample(parsed.command)}`
234
- : `${parsed.command} body cannot be empty`;
235
- throw new FlowError("EMPTY_PARAM", message);
234
+ : selectsStdin
235
+ ? parsed.command === "task add"
236
+ ? "task add received no task document on stdin"
237
+ : `${parsed.command} received no body on stdin`
238
+ : parsed.command === "task add"
239
+ ? "task add title cannot be empty"
240
+ : `${parsed.command} body cannot be empty`;
241
+ throw new FlowError(selectsStdin ? "STDIN_EMPTY" : "EMPTY_PARAM", message);
236
242
  }
237
243
  return { stdin: input, flags: selected?.replace(input) ?? parsed.flags, selectsStdin };
238
244
  }