@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,15 @@
1
+ import { assertSettingsKnobUsable } from "../../../../config/settings/disease.js";
2
+ import { loadKeiyakuSettings } from "../../../../config/settings/loader.js";
3
+ import { loadAkumaCatalog } from "../../../../config/akuma-loader.js";
4
+ import { textResponse } from "../../../render/shared.js";
5
+ import { projectDirectory } from "../../shared.js";
6
+ import { renderAkumaList } from "../../akuma.js";
7
+ export const handler = async (_stdin, flags) => {
8
+ const cwd = await projectDirectory(flags);
9
+ const loaded = await loadKeiyakuSettings(cwd);
10
+ // Role markers need settings pointers; catalog consumers keep legacy agents disease actionable.
11
+ assertSettingsKnobUsable(loaded, "agents");
12
+ assertSettingsKnobUsable(loaded, "default");
13
+ assertSettingsKnobUsable(loaded, "reviewer");
14
+ return textResponse(renderAkumaList(await loadAkumaCatalog(cwd), loaded.providerInstances, loaded.knobs));
15
+ };
@@ -0,0 +1,9 @@
1
+ export const meta = {
2
+ command: "akuma ls",
3
+ summary: "List Akuma profiles",
4
+ usage: ["keiyaku akuma ls [-C|--cwd DIR] [--repo DIR]"],
5
+ stdin: "none",
6
+ flags: ["cwd", "repo"],
7
+ purpose: "List configured helper profiles.",
8
+ notes: ["Project profiles override user profiles, which override builtins."],
9
+ };
@@ -0,0 +1,34 @@
1
+ import { FlowError } from "../../../../flow-error.js";
2
+ import { assertSettingsKnobUsable } from "../../../../config/settings/disease.js";
3
+ import { loadKeiyakuSettings } from "../../../../config/settings/loader.js";
4
+ import { loadAkumaCatalog } from "../../../../config/akuma-loader.js";
5
+ import { readProjectionStatusBoard } from "../../../../core/projection-status.js";
6
+ import { isResponseArtifactId } from "../../../../core/response-artifact-id.js";
7
+ import { textResponse } from "../../../render/shared.js";
8
+ import { renderProjectionStatusSection } from "../../../render/status.js";
9
+ import { projectDirectory } from "../../shared.js";
10
+ import { renderAkumaShow } from "../../akuma.js";
11
+ const NONTERMINAL_PROJECTION_STATES = new Set([
12
+ "minting",
13
+ "startup-timeout",
14
+ "unknown",
15
+ "out",
16
+ "lost",
17
+ ]);
18
+ export const handler = async (_stdin, flags, _signal, positional) => {
19
+ const [name] = positional;
20
+ if (!name)
21
+ throw new FlowError("EMPTY_PARAM", "akuma view requires an Akuma name");
22
+ if (isResponseArtifactId(name)) {
23
+ throw new FlowError("EMPTY_PARAM", `artifact ${name} is a response artifact; akuma view expects an Akuma profile name`);
24
+ }
25
+ const cwd = await projectDirectory(flags);
26
+ const loaded = await loadKeiyakuSettings(cwd);
27
+ assertSettingsKnobUsable(loaded, "agents");
28
+ assertSettingsKnobUsable(loaded, "default");
29
+ assertSettingsKnobUsable(loaded, "reviewer");
30
+ const profile = renderAkumaShow(await loadAkumaCatalog(cwd), loaded.providerInstances, loaded.knobs, name).trimEnd();
31
+ const rows = (readProjectionStatusBoard(cwd, Date.now(), { showAll: true })?.rows ?? []).filter((row) => row.akuma === name && NONTERMINAL_PROJECTION_STATES.has(row.state));
32
+ const projections = renderProjectionStatusSection({ rows }).trimEnd();
33
+ return textResponse(projections ? `${profile}\n\n${projections}` : profile);
34
+ };
@@ -0,0 +1,8 @@
1
+ export const meta = {
2
+ command: "akuma view",
3
+ summary: "View one Akuma profile",
4
+ usage: ["keiyaku akuma view NAME [-C|--cwd DIR] [--repo DIR]"],
5
+ stdin: "none",
6
+ flags: ["cwd", "repo"],
7
+ purpose: "Read one configured helper profile and its current nonterminal projections.",
8
+ };
@@ -1,4 +1,4 @@
1
- import { resolveDefaultAgentName, resolveReviewerAgentName, } from "../../config/settings.js";
1
+ import { resolveDefaultAgentName, resolveReviewerAgentName } from "../../config/settings/knobs.js";
2
2
  import { FlowError } from "../../flow-error.js";
3
3
  import { nativePolicyOwnership } from "../../config/provider-policy-ownership.js";
4
4
  function formatRoleMarkers(settings, name) {
@@ -0,0 +1,10 @@
1
+ import { amendKeiyaku } from "../../../../core/amend.js";
2
+ import { buildAmendInput } from "../../../../core/command-io.js";
3
+ import { buildAmendResponse } from "../../../render/arc.js";
4
+ import { renderCoreResult } from "../../../render/shared.js";
5
+ import { effectiveDirectory, repositoryDirectory } from "../../shared.js";
6
+ export const handler = async (stdin, flags) => {
7
+ const parsed = buildAmendInput(stdin, effectiveDirectory(flags), flags.contractId, flags.contractAddressSource);
8
+ const cwd = await repositoryDirectory(flags);
9
+ return renderCoreResult(amendKeiyaku({ ...parsed, cwd }), buildAmendResponse);
10
+ };
@@ -0,0 +1,12 @@
1
+ export const meta = {
2
+ command: "amend",
3
+ summary: "Record an amendment",
4
+ usage: [
5
+ "keiyaku amend [-C|--cwd DIR] [--repo DIR] [--contract ADDR] < amendment.md",
6
+ "keiyaku @addr amend [-C|--cwd DIR] [--repo DIR] < amendment.md",
7
+ ],
8
+ stdin: "required",
9
+ flags: ["cwd", "repo", "contract"],
10
+ purpose: "Append a prose amendment and optional structured scope delta.",
11
+ completionRank: 8,
12
+ };
@@ -0,0 +1,9 @@
1
+ import { arcKeiyaku, buildArcInput } from "../../../../core/arc.js";
2
+ import { buildArcResponse } from "../../../render/arc.js";
3
+ import { renderCoreResult } from "../../../render/shared.js";
4
+ import { effectiveDirectory, repositoryDirectory } from "../../shared.js";
5
+ export const handler = async (stdin, flags) => {
6
+ const parsed = buildArcInput(stdin, effectiveDirectory(flags), flags.waivePaths, flags.contractId, flags.contractAddressSource);
7
+ const cwd = await repositoryDirectory(flags);
8
+ return renderCoreResult(arcKeiyaku({ ...parsed, cwd }), buildArcResponse);
9
+ };
@@ -0,0 +1,26 @@
1
+ export const meta = {
2
+ command: "arc",
3
+ summary: "Optional iteration; seals current intent first",
4
+ usage: [
5
+ "keiyaku arc [-C|--cwd DIR] [--repo DIR] [--contract ADDR] [--waive PATH] < arc.md",
6
+ "keiyaku @addr arc [-C|--cwd DIR] [--repo DIR] [--waive PATH] < arc.md",
7
+ ],
8
+ stdin: "required",
9
+ flags: ["cwd", "repo", "contract", "waive"],
10
+ purpose: "Optional iteration boundary: record the next title, objective, and brief, and seal the current intent first.",
11
+ input: [
12
+ "# <arc title>",
13
+ "",
14
+ "## Objective",
15
+ "<what this arc should accomplish>",
16
+ "",
17
+ "## Brief",
18
+ "<scope, constraints, relevant files, instructions>",
19
+ ],
20
+ notes: [
21
+ "An empty seal is valid.",
22
+ "The command does not create delivery commits.",
23
+ "The first explicit arc seals a0; later arcs seal the previous open explicit arc.",
24
+ ],
25
+ completionRank: 1,
26
+ };
@@ -0,0 +1,23 @@
1
+ import { bindContract } from "../../../../core/bind.js";
2
+ import { defaultActorClock } from "../../../../core/command-io.js";
3
+ import { writeDraftArtifact } from "../../../draft-artifact.js";
4
+ import { buildBindDraftResponse, buildBindResponse, textResponse } from "../../../render/shared.js";
5
+ import { repositoryDirectory } from "../../shared.js";
6
+ export const handler = async (stdin, flags) => {
7
+ if (flags.dryRun) {
8
+ return textResponse(stdin);
9
+ }
10
+ const cwd = await repositoryDirectory(flags);
11
+ if (flags.draftOnly) {
12
+ return buildBindDraftResponse(await writeDraftArtifact({ cwd, title: "bind-draft", content: stdin }));
13
+ }
14
+ const result = await bindContract({
15
+ cwd, draft: stdin, ...defaultActorClock(), workspace: "worktree",
16
+ after: flags.after ?? [], exclusive: flags.exclusive,
17
+ ...(flags.bindTaskId === undefined ? {} : { taskId: flags.bindTaskId }),
18
+ onProgress: (line) => {
19
+ process.stdout.write(`${line}\n`);
20
+ },
21
+ });
22
+ return buildBindResponse(result, cwd);
23
+ };
@@ -0,0 +1,30 @@
1
+ export const meta = {
2
+ command: "bind",
3
+ summary: "Create a contract ledger and workspace files",
4
+ usage: [
5
+ "keiyaku bind [-C|--cwd DIR] [--repo DIR] [--task ID] < keiyaku.md",
6
+ "keiyaku bind [-C|--cwd DIR] [--repo DIR] [--task ID] --place NAME --objective TEXT --scope GLOB --checks CHECK [--dry-run]",
7
+ ],
8
+ stdin: "optional",
9
+ flags: ["cwd", "repo", "after", "exclusive", "draft-only", "place", "objective", "scope", "checks", "task", "dry-run"],
10
+ // contract is parseable only so the mouth can reject it with bind-specific copy.
11
+ parseFlags: ["cwd", "repo", "contract", "after", "exclusive", "draft-only", "place", "objective", "scope", "checks", "task", "dry-run"],
12
+ purpose: "Bind a Keiyaku from a contract draft.",
13
+ input: [
14
+ "# <name>",
15
+ "",
16
+ "## Objective",
17
+ "<what the commission should accomplish>",
18
+ "",
19
+ "## Scope",
20
+ "- <glob>",
21
+ "",
22
+ "## Checks",
23
+ "- <acceptance check>",
24
+ ],
25
+ notes: [
26
+ "bind creates a commission and does not accept @addr or --contract.",
27
+ "Use either stdin Markdown or all four domain flags; they cannot be combined.",
28
+ ],
29
+ completionRank: 0,
30
+ };
@@ -0,0 +1,16 @@
1
+ import { meta as bindMeta } from "./bind/meta.js";
2
+ import { meta as arcMeta } from "./arc/meta.js";
3
+ import { meta as logMeta } from "./log/meta.js";
4
+ import { meta as amendMeta } from "./amend/meta.js";
5
+ import { meta as renewMeta } from "./renew/meta.js";
6
+ import { meta as petitionMeta } from "./petition/meta.js";
7
+ import { meta as forfeitMeta } from "./forfeit/meta.js";
8
+ export const contractCatalog = [
9
+ { meta: bindMeta, load: () => import("./bind/handler.js") },
10
+ { meta: arcMeta, load: () => import("./arc/handler.js") },
11
+ { meta: logMeta, load: () => import("./log/handler.js") },
12
+ { meta: amendMeta, load: () => import("./amend/handler.js") },
13
+ { meta: renewMeta, load: () => import("./renew/handler.js") },
14
+ { meta: petitionMeta, load: () => import("./petition/handler.js") },
15
+ { meta: forfeitMeta, load: () => import("./forfeit/handler.js") },
16
+ ];
@@ -0,0 +1,13 @@
1
+ import { resolveContractAddress, withResolvedAddress } from "../../../../core/addressing.js";
2
+ import { defaultActorClock } from "../../../../core/command-io.js";
3
+ import { forfeitContractCommand } from "../../../../core/forfeit.js";
4
+ import { buildForfeitResponse } from "../../../render/shared.js";
5
+ import { repositoryDirectory } from "../../shared.js";
6
+ export const handler = async (_stdin, flags) => {
7
+ const cwd = await repositoryDirectory(flags);
8
+ const address = await resolveContractAddress(cwd, flags.contractId, flags.contractAddressSource);
9
+ return await withResolvedAddress(address, async () => buildForfeitResponse({
10
+ ...await forfeitContractCommand({ cwd, contractId: address.binding.commissionId, ...defaultActorClock(), note: flags.reason }),
11
+ address,
12
+ }));
13
+ };
@@ -0,0 +1,12 @@
1
+ export const meta = {
2
+ command: "forfeit",
3
+ summary: "Forfeit an addressed contract",
4
+ usage: [
5
+ "keiyaku forfeit [-C|--cwd DIR] [--repo DIR] [--contract ADDR] [--reason TEXT]",
6
+ "keiyaku @addr forfeit [-C|--cwd DIR] [--repo DIR] [--reason TEXT]",
7
+ ],
8
+ stdin: "none",
9
+ flags: ["cwd", "repo", "contract", "reason"],
10
+ purpose: "Record an abandoned contract without sealing it.",
11
+ completionRank: 11,
12
+ };
@@ -0,0 +1,12 @@
1
+ import { resolveContractAddress, withResolvedAddress } from "../../../../core/addressing.js";
2
+ import { readContractLog } from "../../../../core/log.js";
3
+ import { buildLogResponse } from "../../../render/misc.js";
4
+ import { repositoryDirectory } from "../../shared.js";
5
+ export const handler = async (_stdin, flags) => {
6
+ const cwd = await repositoryDirectory(flags);
7
+ const address = await resolveContractAddress(cwd, flags.contractId, flags.contractAddressSource);
8
+ return await withResolvedAddress(address, async () => {
9
+ const result = await readContractLog({ cwd, contractId: address.binding.commissionId });
10
+ return buildLogResponse({ ...result, address });
11
+ });
12
+ };
@@ -0,0 +1,12 @@
1
+ export const meta = {
2
+ command: "log",
3
+ summary: "Render a contract ledger",
4
+ usage: [
5
+ "keiyaku log [-C|--cwd DIR] [--repo DIR] [--contract ADDR]",
6
+ "keiyaku @addr log [-C|--cwd DIR] [--repo DIR]",
7
+ ],
8
+ stdin: "none",
9
+ flags: ["cwd", "repo", "contract"],
10
+ purpose: "Read a contract ledger.",
11
+ completionRank: 5,
12
+ };
@@ -0,0 +1,26 @@
1
+ import { FlowError } from "../../../../flow-error.js";
2
+ import { resolveContractAddress, withResolvedAddress } from "../../../../core/addressing.js";
3
+ import { buildPetitionClaimInput } from "../../../../core/petition.js";
4
+ import { previewPetition } from "../../../../core/petition-preview.js";
5
+ import { petitionKeiyaku } from "../../../../core/petition-run.js";
6
+ import { buildPetitionClaimResponse, buildPetitionPreviewResponse } from "../../../render/petition.js";
7
+ import { repositoryDirectory } from "../../shared.js";
8
+ export const handler = async (stdin, flags, signal) => {
9
+ if (flags.json && !flags.dryRun) {
10
+ throw new FlowError("EMPTY_PARAM", "petition --json requires --dry-run");
11
+ }
12
+ const cwd = await repositoryDirectory(flags);
13
+ const address = await resolveContractAddress(cwd, flags.contractId, flags.contractAddressSource);
14
+ return await withResolvedAddress(address, async () => {
15
+ const input = buildPetitionClaimInput({ cwd, contractId: address.binding.commissionId, stdin, signal, waivePaths: flags.waivePaths });
16
+ if (flags.dryRun) {
17
+ return buildPetitionPreviewResponse(await previewPetition({
18
+ cwd,
19
+ contractId: address.binding.commissionId,
20
+ oath: input.oath,
21
+ waivePaths: flags.waivePaths,
22
+ }), flags.json === true);
23
+ }
24
+ return buildPetitionClaimResponse({ ...await petitionKeiyaku(input), address }, input);
25
+ });
26
+ };
@@ -0,0 +1,23 @@
1
+ export const meta = {
2
+ command: "petition",
3
+ summary: "Run or preview the gated settlement pipeline",
4
+ usage: [
5
+ "keiyaku petition [-C|--cwd DIR] [--repo DIR] [--contract ADDR] [--waive PATH] [< petition.md]",
6
+ "keiyaku @<id> petition [-C|--cwd DIR] [--repo DIR] [--waive PATH] [< petition.md]",
7
+ "keiyaku @<id> petition --dry-run [--json] [< petition.md]",
8
+ ],
9
+ stdin: "optional",
10
+ flags: ["cwd", "repo", "contract", "waive", "dry-run", "json"],
11
+ purpose: "Seal the current a0 or open explicit arc, queue the contract, and run verdict and claim processing; dry-run previews deterministic gates without mutation.",
12
+ input: [
13
+ "## Oath",
14
+ "<free first-person attestation>",
15
+ ],
16
+ notes: [
17
+ "Petition stdin is optional at the command mouth; a missing, empty, or blank oath is rejected by the settlement gate with OATH_MISSING.",
18
+ "The machine checks only that the oath is present. Accepted oath text is persisted in the petition entry and hidden from the reviewer.",
19
+ "Base drift requires explicit `keiyaku renew` before petition.",
20
+ "Dry-run never runs verification or review and exits 0, 1, or 2.",
21
+ ],
22
+ completionRank: 10,
23
+ };
@@ -0,0 +1,10 @@
1
+ import { resolveContractAddress } from "../../../../core/addressing.js";
2
+ import { renewKeiyaku } from "../../../../core/renew.js";
3
+ import { buildRenewResponse } from "../../../render/arc.js";
4
+ import { renderCoreResult } from "../../../render/shared.js";
5
+ import { repositoryDirectory } from "../../shared.js";
6
+ export const handler = async (_stdin, flags) => {
7
+ const cwd = await repositoryDirectory(flags);
8
+ const address = await resolveContractAddress(cwd, flags.contractId, flags.contractAddressSource);
9
+ return renderCoreResult(renewKeiyaku({ cwd, address, waivePaths: flags.waivePaths }), buildRenewResponse);
10
+ };
@@ -0,0 +1,17 @@
1
+ export const meta = {
2
+ command: "renew",
3
+ summary: "Rewrite delivery onto the current base",
4
+ usage: [
5
+ "keiyaku renew [-C|--cwd DIR] [--repo DIR] [--contract ADDR] [--waive PATH]",
6
+ "keiyaku @<id> renew [-C|--cwd DIR] [--repo DIR] [--waive PATH]",
7
+ ],
8
+ stdin: "none",
9
+ flags: ["cwd", "repo", "contract", "waive"],
10
+ purpose: "Capture receipts, rewrite delivery onto the default branch, then seal the current a0 or open explicit arc and record the renewal.",
11
+ notes: [
12
+ "After an explicit arc closes, refuses loose commits until another arc is open.",
13
+ "Refuses while an Akuma is in flight.",
14
+ "Conflicts restore the worktree without ledger writes.",
15
+ ],
16
+ completionRank: 9,
17
+ };
@@ -0,0 +1,39 @@
1
+ import { runCallAndPersist } from "../../../../core/call-persist.js";
2
+ import { projectionDir } from "../../../../core/projection-core.js";
3
+ import { waitForProjection } from "../../../../core/projection-wait.js";
4
+ import { buildCallResponse, renderAdoptedLaunchReceipt } from "../../../render/call.js";
5
+ import { buildWaitResponse } from "../../../render/wait.js";
6
+ import { buildCallInput, projectDirectory } from "../../shared.js";
7
+ export const handler = async (stdin, flags, signal) => {
8
+ const outcome = await runCallAndPersist({
9
+ ...buildCallInput(stdin, flags, "call"),
10
+ // Bounded outer join: same durable launch/adoption as detach, without core's unbounded join.
11
+ ...(flags.timeoutMs !== undefined ? { detach: true } : {}),
12
+ signal,
13
+ ...(!flags.detach
14
+ ? {
15
+ onLaunch: ({ address, projection }) => {
16
+ process.stdout.write(`${renderAdoptedLaunchReceipt(address, projection.id, projection.alias, projection.previousAliasTarget)}\n`);
17
+ },
18
+ }
19
+ : {}),
20
+ });
21
+ if (flags.timeoutMs !== undefined) {
22
+ const projection = outcome.result.projection;
23
+ if (!projection)
24
+ throw new Error("call --wait requires projection facts after launch");
25
+ return buildWaitResponse(projection.id, await waitForProjection({
26
+ projectionDirectory: projectionDir(await projectDirectory(flags), projection.id),
27
+ timeoutMs: flags.timeoutMs,
28
+ signal,
29
+ }), { alias: projection.alias });
30
+ }
31
+ if (outcome.result.foregroundWait && outcome.result.projection) {
32
+ return buildWaitResponse(outcome.result.projection.id, outcome.result.foregroundWait, { alias: outcome.result.projection.alias });
33
+ }
34
+ return buildCallResponse(outcome.result, {
35
+ responsePath: outcome.responsePath,
36
+ artifactId: outcome.artifactId,
37
+ addressPlacement: flags.detach ? "stdout" : "none",
38
+ });
39
+ };
@@ -0,0 +1,9 @@
1
+ export const meta = {
2
+ command: "call",
3
+ summary: "Start an Akuma helper session",
4
+ usage: ["keiyaku call NAME [--wait DURATION] <BODY|->"],
5
+ stdin: "none",
6
+ flags: ["cwd", "repo", "contract", "akuma", "model", "effort", "incognito", "bare", "detach", "alias", "wait"],
7
+ purpose: "Run a scoped helper task.",
8
+ completionRank: 2,
9
+ };
@@ -0,0 +1,14 @@
1
+ import { meta as callMeta } from "./call/meta.js";
2
+ import { meta as reviveMeta } from "./revive/meta.js";
3
+ import { meta as waitMeta } from "./wait/meta.js";
4
+ import { meta as tellMeta } from "./tell/meta.js";
5
+ import { meta as killMeta } from "./kill/meta.js";
6
+ import { meta as statusMeta } from "./status/meta.js";
7
+ export const projectionCatalog = [
8
+ { meta: callMeta, load: () => import("./call/handler.js") },
9
+ { meta: reviveMeta, load: () => import("./revive/handler.js") },
10
+ { meta: waitMeta, load: () => import("./wait/handler.js") },
11
+ { meta: tellMeta, load: () => import("./tell/handler.js") },
12
+ { meta: killMeta, load: () => import("./kill/handler.js") },
13
+ { meta: statusMeta, load: () => import("./status/handler.js") },
14
+ ];
@@ -0,0 +1,35 @@
1
+ import { FlowError } from "../../../../flow-error.js";
2
+ import { resolveContractAddress, withResolvedAddress, } from "../../../../core/addressing.js";
3
+ import { projectionDir } from "../../../../core/projection-core.js";
4
+ import { killProjectionGeneration } from "../../../../core/projection-kill.js";
5
+ import { waitForProjection } from "../../../../core/projection-wait.js";
6
+ import { resolveProjectionAddress } from "../../../projection-address.js";
7
+ import { textResponse } from "../../../render/shared.js";
8
+ import { buildWaitResponse } from "../../../render/wait.js";
9
+ import { projectDirectory, repositoryDirectory } from "../../shared.js";
10
+ export const handler = async (_stdin, flags, signal, positional) => {
11
+ const cwd = flags.contractId ? await repositoryDirectory(flags) : await projectDirectory(flags);
12
+ const [projectionAddress] = positional;
13
+ if (!projectionAddress)
14
+ throw new FlowError("EMPTY_PARAM", "kill requires a projection address");
15
+ const address = flags.contractId ? await resolveContractAddress(cwd, flags.contractId, flags.contractAddressSource) : undefined;
16
+ const operation = async () => {
17
+ const projection = await resolveProjectionAddress({
18
+ cwd,
19
+ address: projectionAddress,
20
+ scope: address,
21
+ verb: "kill",
22
+ });
23
+ const directory = projectionDir(cwd, projection.id);
24
+ const result = killProjectionGeneration(directory);
25
+ if (result.status === "already-closed") {
26
+ return textResponse(`· ${projection.id} already closed`);
27
+ }
28
+ if (flags.timeoutMs === undefined) {
29
+ return textResponse(`✓ kill ${projection.id}\n» keiyaku wait ${projection.id}`);
30
+ }
31
+ // Accepted with --wait: no acceptance receipt or address preamble.
32
+ return buildWaitResponse(projection.id, await waitForProjection({ projectionDirectory: directory, timeoutMs: flags.timeoutMs, signal }), { alias: projection.alias });
33
+ };
34
+ return address ? await withResolvedAddress(address, operation) : await operation();
35
+ };
@@ -0,0 +1,11 @@
1
+ export const meta = {
2
+ command: "kill",
3
+ summary: "Stop the current projection generation",
4
+ usage: [
5
+ "keiyaku kill <projection-address> [--wait DURATION]",
6
+ "keiyaku @addr kill <projection-address> [--wait DURATION]",
7
+ ],
8
+ stdin: "none",
9
+ flags: ["cwd", "repo", "contract", "wait"],
10
+ purpose: "Terminate the current generation while keeping the projection identity and tell ledger.",
11
+ };
@@ -0,0 +1,53 @@
1
+ import * as fs from "node:fs/promises";
2
+ import { FlowError } from "../../../../flow-error.js";
3
+ import { buildArtifactResolutionAttempt, } from "../../../../core/addressing.js";
4
+ import { runCallAndPersist } from "../../../../core/call-persist.js";
5
+ import { locateResponseArtifact, reconcileResponseArtifactCatalog, } from "../../../../core/transcripts.js";
6
+ import { isGitRepo } from "../../../../git/branches.js";
7
+ import { stableRepoRoot } from "../../../../core/worktree-path.js";
8
+ import { buildCallResponse } from "../../../render/call.js";
9
+ import { buildCallInput, effectiveDirectory, projectDirectory, revivePrompt } from "../../shared.js";
10
+ export const handler = async (stdin, flags, signal, positional) => {
11
+ const cwd = effectiveDirectory(flags);
12
+ const artifactCwd = await projectDirectory(flags);
13
+ const artifactId = positional[0];
14
+ const isRepo = await isGitRepo(artifactCwd);
15
+ const responseStoreCwd = isRepo ? await stableRepoRoot(artifactCwd) : await fs.realpath(artifactCwd);
16
+ try {
17
+ await reconcileResponseArtifactCatalog(responseStoreCwd);
18
+ }
19
+ catch {
20
+ // The catalog is disposable and cannot make an otherwise valid revive fail.
21
+ }
22
+ const artifact = await locateResponseArtifact({
23
+ cwd: responseStoreCwd,
24
+ artifactId,
25
+ attempt: buildArtifactResolutionAttempt({
26
+ repo: isRepo
27
+ ? { kind: "repository", stableRoot: responseStoreCwd }
28
+ : { kind: "user" },
29
+ workdir: cwd,
30
+ supplied: artifactId,
31
+ inference: ["response artifact identity lookup"],
32
+ }),
33
+ });
34
+ let executionCwd;
35
+ let repo;
36
+ if (artifact.provenance.authority.kind === "repository") {
37
+ executionCwd = artifact.storageRoot;
38
+ repo = flags.repo ? responseStoreCwd : undefined;
39
+ }
40
+ else {
41
+ if (!("workdir" in artifact.provenance.evidence)) {
42
+ throw new FlowError("INVALID_RESPONSE_PATH", `Invalid response artifact '${artifactId}': field 'provenance.evidence.workdir' is missing.`);
43
+ }
44
+ executionCwd = artifact.provenance.evidence.workdir;
45
+ repo = undefined;
46
+ }
47
+ const outcome = await runCallAndPersist({
48
+ ...buildCallInput(revivePrompt(stdin), { ...flags, cwd: executionCwd, repo }, "revive"),
49
+ reviveArtifact: artifact,
50
+ signal,
51
+ });
52
+ return buildCallResponse(outcome.result, { responsePath: outcome.responsePath, artifactId: outcome.artifactId, addressPlacement: "footer" });
53
+ };
@@ -0,0 +1,9 @@
1
+ export const meta = {
2
+ command: "revive",
3
+ summary: "Revive an Akuma helper session",
4
+ usage: ["keiyaku revive ARTIFACT [BODY|-]"],
5
+ stdin: "none",
6
+ flags: ["cwd", "repo", "model", "effort"],
7
+ purpose: "Continue a persisted helper session.",
8
+ completionRank: 4,
9
+ };
@@ -0,0 +1,23 @@
1
+ import { readKanshiBoard } from "../../../../core/status/board.js";
2
+ import { normalizeTargetRef } from "../../../../core/target-ref.js";
3
+ import { isProjectionId } from "../../../../core/projection-core.js";
4
+ import { FlowError } from "../../../../flow-error.js";
5
+ import { renderProjectionFilteredStatus, renderStatusBoard } from "../../../render/status.js";
6
+ import { textResponse } from "../../../render/shared.js";
7
+ import { projectDirectory } from "../../shared.js";
8
+ export const handler = async (_stdin, flags, _signal, positional) => {
9
+ // Status is read-only and must open outside Git. projectDirectory still
10
+ // honors --repo as a repository coordinate when the operator names one.
11
+ const cwd = await projectDirectory(flags);
12
+ const target = flags.target === undefined ? undefined : normalizeTargetRef(flags.target);
13
+ const board = await readKanshiBoard(cwd, Date.now(), {
14
+ ...(target === undefined ? {} : { target }),
15
+ showAllProjections: flags.all === true || positional.length === 1,
16
+ });
17
+ const [projectionId] = positional;
18
+ if (projectionId === undefined)
19
+ return textResponse(renderStatusBoard(board));
20
+ if (!isProjectionId(projectionId))
21
+ throw new FlowError("EMPTY_PARAM", `invalid projection id: ${projectionId}`);
22
+ return textResponse(renderProjectionFilteredStatus(board, projectionId));
23
+ };
@@ -0,0 +1,9 @@
1
+ export const meta = {
2
+ command: "status",
3
+ summary: "Show the Kanshi board",
4
+ usage: ["keiyaku status [PROJECTION] [-C|--cwd DIR] [--repo DIR] [--target REF] [--all]"],
5
+ stdin: "none",
6
+ flags: ["cwd", "repo", "target", "all"],
7
+ purpose: "Read the Kanshi board or filter it to one projection without mutation.",
8
+ completionRank: 14,
9
+ };
@@ -0,0 +1,34 @@
1
+ import { FlowError } from "../../../../flow-error.js";
2
+ import { resolveContractAddress, withResolvedAddress, } from "../../../../core/addressing.js";
3
+ import { projectionDir, writeInboxTell } from "../../../../core/projection-core.js";
4
+ import { assertTellEffortSupported, tellProjection } from "../../../../core/projection-wake.js";
5
+ import { waitForProjection } from "../../../../core/projection-wait.js";
6
+ import { resolveProjectionAddress } from "../../../projection-address.js";
7
+ import { prependAddressReceipt } from "../../../render/address.js";
8
+ import { textResponse } from "../../../render/shared.js";
9
+ import { buildWaitResponse } from "../../../render/wait.js";
10
+ import { projectDirectory, repositoryDirectory } from "../../shared.js";
11
+ export const handler = async (body, flags, signal, positional) => {
12
+ const cwd = flags.contractId ? await repositoryDirectory(flags) : await projectDirectory(flags);
13
+ const projectionAddress = positional[0];
14
+ if (!projectionAddress)
15
+ throw new FlowError("EMPTY_PARAM", "tell requires a projection address and message");
16
+ const address = flags.contractId ? await resolveContractAddress(cwd, flags.contractId, flags.contractAddressSource) : undefined;
17
+ const operation = async () => {
18
+ const projection = await resolveProjectionAddress({
19
+ cwd,
20
+ address: projectionAddress,
21
+ scope: address,
22
+ verb: "tell",
23
+ });
24
+ const directory = projectionDir(cwd, projection.id);
25
+ assertTellEffortSupported(directory, flags.effort);
26
+ // Mailbox first: do not inspect phase before this immutable write.
27
+ writeInboxTell(directory, body, Date.now(), { effort: flags.effort });
28
+ await tellProjection(directory, flags.effort);
29
+ if (flags.timeoutMs === undefined)
30
+ return textResponse("");
31
+ return prependAddressReceipt(buildWaitResponse(projection.id, await waitForProjection({ projectionDirectory: directory, timeoutMs: flags.timeoutMs, signal }), { alias: projection.alias }), address, { projectionId: projection.id, projectionAlias: projection.alias });
32
+ };
33
+ return address ? await withResolvedAddress(address, operation) : await operation();
34
+ };
@@ -0,0 +1,9 @@
1
+ export const meta = {
2
+ command: "tell",
3
+ summary: "Send intent to a projection mailbox",
4
+ usage: ["keiyaku tell PROJECTION [--wait DURATION] [--] <BODY|->"],
5
+ stdin: "none",
6
+ flags: ["cwd", "repo", "contract", "effort", "wait"],
7
+ purpose: "Write intent to the mailbox and wake only when eligible.",
8
+ completionRank: 3,
9
+ };