@astrosheep/keiyaku 2.9.3 → 2.9.5

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 (282) hide show
  1. package/build/.tsbuildinfo +1 -1
  2. package/build/agents/call-terms.js +14 -94
  3. package/build/agents/harness/activity-values.js +16 -0
  4. package/build/agents/harness/event-persistence.js +218 -0
  5. package/build/agents/harness/execution-handle.js +26 -222
  6. package/build/agents/harness/index.js +3 -1
  7. package/build/agents/harness/outcome.js +68 -5
  8. package/build/agents/harness/projection.js +179 -124
  9. package/build/agents/harness/provider-adapter.js +58 -0
  10. package/build/agents/harness/router.js +11 -187
  11. package/build/agents/harness/runtime.js +17 -4
  12. package/build/agents/harness/session.js +15 -0
  13. package/build/agents/launch-snapshot/model.js +15 -236
  14. package/build/agents/launch-snapshot/parse-helpers.js +114 -0
  15. package/build/agents/launch-snapshot/resolve.js +17 -43
  16. package/build/agents/opencode-sdk.js +45 -12
  17. package/build/agents/providers/claude-agent-sdk/adapter.js +6 -17
  18. package/build/agents/providers/claude-agent-sdk/registration.js +214 -0
  19. package/build/agents/providers/claude-agent-sdk/session-schema.js +2 -0
  20. package/build/agents/providers/codex-app-server/adapter.js +82 -53
  21. package/build/agents/providers/codex-app-server/events.js +90 -11
  22. package/build/agents/providers/codex-app-server/identity.js +1 -0
  23. package/build/agents/providers/codex-app-server/policy.js +29 -0
  24. package/build/agents/providers/codex-app-server/registration.js +248 -0
  25. package/build/agents/providers/codex-app-server/session-schema.js +6 -0
  26. package/build/agents/providers/codex-app-server/session.js +23 -17
  27. package/build/agents/providers/codex-app-server/terms.js +1 -0
  28. package/build/agents/providers/opencode-sdk/adapter.js +94 -50
  29. package/build/agents/providers/opencode-sdk/events.js +8 -4
  30. package/build/agents/providers/opencode-sdk/registration.js +135 -0
  31. package/build/agents/providers/opencode-sdk/session-schema.js +2 -0
  32. package/build/agents/providers/opencode-sdk/session.js +21 -14
  33. package/build/agents/providers/opencode-sdk/terms.js +1 -0
  34. package/build/agents/providers/pi/adapter.js +36 -30
  35. package/build/agents/providers/pi/events.js +4 -3
  36. package/build/agents/providers/pi/registration.js +145 -0
  37. package/build/agents/providers/pi/session-schema.js +6 -0
  38. package/build/agents/providers/pi/terms.js +1 -0
  39. package/build/agents/providers/registration.js +7 -0
  40. package/build/agents/providers/registry.js +76 -0
  41. package/build/agents/selector.js +2 -29
  42. package/build/agents/types.js +10 -0
  43. package/build/artifact-directories.js +22 -0
  44. package/build/cli/commands/akuma/akuma/handler.js +1 -1
  45. package/build/cli/commands/akuma/akuma/meta.js +1 -1
  46. package/build/cli/commands/akuma/list/meta-ls.js +1 -1
  47. package/build/cli/commands/akuma/view/handler.js +5 -4
  48. package/build/cli/commands/akuma/view/meta.js +1 -1
  49. package/build/cli/commands/akuma.js +6 -0
  50. package/build/cli/commands/contract/amend/handler.js +8 -2
  51. package/build/cli/commands/contract/amend/meta.js +4 -4
  52. package/build/cli/commands/contract/arc/handler.js +8 -2
  53. package/build/cli/commands/contract/arc/meta.js +4 -4
  54. package/build/cli/commands/contract/audit/handler.js +16 -0
  55. package/build/cli/commands/contract/audit/meta.js +16 -0
  56. package/build/cli/commands/contract/bind/handler.js +4 -3
  57. package/build/cli/commands/contract/bind/meta.js +44 -8
  58. package/build/cli/commands/contract/catalog.js +2 -0
  59. package/build/cli/commands/contract/forfeit/handler.js +4 -4
  60. package/build/cli/commands/contract/forfeit/meta.js +1 -1
  61. package/build/cli/commands/contract/log/handler.js +3 -3
  62. package/build/cli/commands/contract/log/meta.js +1 -1
  63. package/build/cli/commands/contract/petition/handler.js +5 -8
  64. package/build/cli/commands/contract/petition/meta.js +6 -6
  65. package/build/cli/commands/contract/renew/handler.js +20 -6
  66. package/build/cli/commands/contract/renew/meta.js +6 -5
  67. package/build/cli/commands/metadata.js +59 -0
  68. package/build/cli/commands/projection/call/handler.js +6 -5
  69. package/build/cli/commands/projection/call/meta.js +4 -1
  70. package/build/cli/commands/projection/kill/handler.js +16 -32
  71. package/build/cli/commands/projection/kill/meta.js +1 -1
  72. package/build/cli/commands/projection/revive/meta.js +4 -1
  73. package/build/cli/commands/projection/shared.js +28 -0
  74. package/build/cli/commands/projection/status/handler.js +1 -1
  75. package/build/cli/commands/projection/status/meta.js +1 -1
  76. package/build/cli/commands/projection/tell/handler.js +14 -30
  77. package/build/cli/commands/projection/tell/meta.js +4 -1
  78. package/build/cli/commands/projection/wait/handler.js +45 -22
  79. package/build/cli/commands/projection/wait/meta.js +8 -3
  80. package/build/cli/commands/registry.js +2 -54
  81. package/build/cli/commands/shared.js +10 -7
  82. package/build/cli/commands/skills/install/handler.js +2 -5
  83. package/build/cli/commands/skills/install/meta.js +1 -1
  84. package/build/cli/commands/skills/skills/handler.js +1 -1
  85. package/build/cli/commands/skills/skills/meta.js +1 -1
  86. package/build/cli/commands/system/completion/meta.js +1 -1
  87. package/build/cli/commands/system/dump-env/meta.js +1 -1
  88. package/build/cli/commands/system/guide/meta.js +1 -1
  89. package/build/cli/commands/task/add/handler.js +7 -15
  90. package/build/cli/commands/task/add/meta.js +4 -1
  91. package/build/cli/commands/task/catalog.js +2 -2
  92. package/build/cli/commands/task/doctor/meta.js +1 -1
  93. package/build/cli/commands/task/done/handler.js +4 -8
  94. package/build/cli/commands/task/done/meta.js +1 -1
  95. package/build/cli/commands/task/drop/handler.js +3 -6
  96. package/build/cli/commands/task/drop/meta.js +1 -1
  97. package/build/cli/commands/task/ls/handler.js +12 -8
  98. package/build/cli/commands/task/ls/meta.js +3 -3
  99. package/build/cli/commands/task/shared.js +14 -4
  100. package/build/cli/commands/task/{view → show}/handler.js +7 -8
  101. package/build/cli/commands/task/show/meta.js +8 -0
  102. package/build/cli/commands/task/start/handler.js +3 -6
  103. package/build/cli/commands/task/start/meta.js +1 -1
  104. package/build/cli/commands/task/stop/handler.js +4 -8
  105. package/build/cli/commands/task/stop/meta.js +1 -1
  106. package/build/cli/commands/task/task/handler.js +1 -1
  107. package/build/cli/commands/task/task/meta.js +1 -1
  108. package/build/cli/commands/task/update/handler.js +6 -11
  109. package/build/cli/commands/task/update/meta.js +4 -1
  110. package/build/cli/completion.js +1 -1
  111. package/build/cli/flags.js +37 -6
  112. package/build/cli/help.js +7 -14
  113. package/build/cli/index.js +112 -154
  114. package/build/cli/missing-subcommand.js +7 -0
  115. package/build/cli/output-stream-error-policy.js +19 -5
  116. package/build/cli/parse-flags.js +33 -7
  117. package/build/cli/parse-metadata.js +3 -9
  118. package/build/cli/parse-selectors.js +2 -1
  119. package/build/cli/parse.js +35 -5
  120. package/build/cli/projection-address.js +12 -12
  121. package/build/cli/render/address.js +41 -37
  122. package/build/cli/render/arc.js +24 -12
  123. package/build/cli/render/audit.js +121 -0
  124. package/build/cli/render/call.js +11 -5
  125. package/build/cli/render/errors.js +36 -1
  126. package/build/cli/render/format.js +4 -0
  127. package/build/cli/render/kanshi.js +6 -12
  128. package/build/cli/render/kill.js +9 -0
  129. package/build/cli/render/misc.js +58 -13
  130. package/build/cli/render/petition.js +20 -15
  131. package/build/cli/render/projection-activity.js +15 -6
  132. package/build/cli/render/shared.js +60 -21
  133. package/build/cli/render/skills.js +10 -0
  134. package/build/cli/render/status.js +56 -23
  135. package/build/cli/render/success-response.js +78 -0
  136. package/build/cli/render/task.js +66 -57
  137. package/build/cli/render/tell.js +5 -0
  138. package/build/cli/render/terminal-failure.js +63 -0
  139. package/build/cli/render/types.js +1 -0
  140. package/build/cli/render/wait.js +68 -38
  141. package/build/cli/types.js +1 -1
  142. package/build/config/akuma-loader.js +0 -5
  143. package/build/config/env-keys.js +3 -1
  144. package/build/config/env.js +3 -0
  145. package/build/config/provider-policy-ownership.js +3 -32
  146. package/build/config/settings/disease.js +8 -1
  147. package/build/config/settings/loader.js +11 -3
  148. package/build/config/settings/provider-instance-fields.js +51 -0
  149. package/build/config/settings/schema.js +6 -176
  150. package/build/core/addressing.js +66 -16
  151. package/build/core/amend.js +61 -18
  152. package/build/core/arc.js +33 -73
  153. package/build/core/audit.js +650 -0
  154. package/build/core/bind.js +82 -35
  155. package/build/core/call/call.js +15 -9
  156. package/build/core/call/context.js +6 -51
  157. package/build/core/call/execution.js +22 -22
  158. package/build/core/call/prompt.js +14 -1
  159. package/build/core/command-markdown.js +45 -0
  160. package/build/core/context.js +13 -7
  161. package/build/core/contract-view.js +22 -6
  162. package/build/core/draft.js +139 -19
  163. package/build/core/entry.js +3 -4
  164. package/build/core/forfeit.js +5 -2
  165. package/build/core/hints.js +1 -75
  166. package/build/core/identifier-slug.js +66 -0
  167. package/build/core/ids.js +25 -11
  168. package/build/core/ledger.js +20 -68
  169. package/build/core/markdown/lex.js +2 -1
  170. package/build/core/markdown/parser.js +0 -68
  171. package/build/core/markdown/render.js +68 -0
  172. package/build/core/markdown/sections.js +2 -1
  173. package/build/core/outcome-base.js +4 -0
  174. package/build/core/projection/generation/database.js +41 -52
  175. package/build/core/projection/generation/model.js +63 -2
  176. package/build/core/{projection-generation-continuation.js → projection/generation/projection-generation-continuation.js} +3 -3
  177. package/build/core/{projection-generation-execution.js → projection/generation/projection-generation-execution.js} +36 -53
  178. package/build/core/{projection-generation-identity.js → projection/generation/projection-generation-identity.js} +2 -2
  179. package/build/core/{projection-generation-launcher.js → projection/generation/projection-generation-launcher.js} +9 -7
  180. package/build/core/{projection-generation-process.js → projection/generation/projection-generation-process.js} +2 -1
  181. package/build/core/{projection-generation-runner.js → projection/generation/projection-generation-runner.js} +19 -3
  182. package/build/core/projection/generation/store.js +3 -3
  183. package/build/core/projection/generation/transitions.js +19 -3
  184. package/build/core/projection/index.js +27 -0
  185. package/build/core/{projection-activity.js → projection/projection-activity.js} +12 -0
  186. package/build/core/{projection-alias.js → projection/projection-alias.js} +13 -13
  187. package/build/core/projection/projection-coordinate.js +61 -0
  188. package/build/core/{projection-core.js → projection/projection-core.js} +9 -9
  189. package/build/core/{projection-execution-observer.js → projection/projection-execution-observer.js} +37 -78
  190. package/build/core/{projection-identity.js → projection/projection-identity.js} +1 -1
  191. package/build/core/{projection-kill.js → projection/projection-kill.js} +1 -1
  192. package/build/core/{projection-life-observer.js → projection/projection-life-observer.js} +16 -2
  193. package/build/core/{projection-mint.js → projection/projection-mint.js} +10 -10
  194. package/build/core/{projection-status.js → projection/projection-status.js} +163 -45
  195. package/build/core/projection/projection-terminal-failure.js +106 -0
  196. package/build/core/projection/projection-wait.js +275 -0
  197. package/build/core/projection/projection-wake.js +227 -0
  198. package/build/core/provider-loader-ports.js +4 -0
  199. package/build/core/ref-log.js +65 -40
  200. package/build/core/registry.js +63 -10
  201. package/build/core/renew-session.js +128 -0
  202. package/build/core/renew.js +448 -102
  203. package/build/core/scope.js +272 -68
  204. package/build/core/seal.js +165 -40
  205. package/build/core/{claim-delivery.js → settlement/claim-delivery.js} +8 -8
  206. package/build/core/{claim.js → settlement/claim.js} +32 -8
  207. package/build/core/settlement/index.js +19 -0
  208. package/build/core/{petition-claim-gates.js → settlement/petition-claim-gates.js} +24 -49
  209. package/build/core/{petition-forfeit.js → settlement/petition-forfeit.js} +2 -2
  210. package/build/core/{petition-head-guard.js → settlement/petition-head-guard.js} +2 -2
  211. package/build/core/settlement/petition-io.js +1 -0
  212. package/build/core/{petition-preview.js → settlement/petition-preview.js} +2 -2
  213. package/build/core/{petition.js → settlement/petition.js} +21 -12
  214. package/build/core/settlement/queue-read-model.js +143 -0
  215. package/build/core/settlement/queue-seat-allocation.js +156 -0
  216. package/build/core/settlement/queue.js +6 -0
  217. package/build/core/settlement/settlement.js +288 -0
  218. package/build/core/{verdict.js → settlement/verdict.js} +9 -37
  219. package/build/core/settlement/verification.js +59 -0
  220. package/build/core/status/board.js +62 -41
  221. package/build/core/status/ledger-batch.js +158 -0
  222. package/build/core/status/reconciliation.js +10 -4
  223. package/build/core/stored-agent-event.js +6 -2
  224. package/build/core/task/board.js +41 -4
  225. package/build/core/task/commands.js +45 -28
  226. package/build/core/task/document.js +5 -0
  227. package/build/core/task/index.js +12 -0
  228. package/build/core/task/model.js +8 -1
  229. package/build/core/task/query.js +172 -0
  230. package/build/core/task/settlement-git.js +265 -74
  231. package/build/core/task/settlement-policy.js +67 -29
  232. package/build/core/task/source-board.js +1 -0
  233. package/build/core/task/task-contract.js +444 -0
  234. package/build/core/{task-doctor.js → task/task-doctor.js} +1 -1
  235. package/build/core/{task-git-actor.js → task/task-git-actor.js} +5 -10
  236. package/build/core/{task-git-runtime.js → task/task-git-runtime.js} +3 -3
  237. package/build/core/{task-git-store.js → task/task-git-store.js} +90 -19
  238. package/build/core/task/task-repository.js +1 -0
  239. package/build/core/{task-store-repository.js → task/task-store-repository.js} +6 -4
  240. package/build/core/task/task-store.js +1 -0
  241. package/build/core/{task-worktree.js → task/task-worktree.js} +2 -1
  242. package/build/core/task/task.js +7 -0
  243. package/build/core/task/tree.js +37 -0
  244. package/build/core/task/validation.js +5 -2
  245. package/build/core/transcripts.js +15 -3
  246. package/build/core/worktree-path.js +43 -28
  247. package/build/flow-error.js +83 -39
  248. package/build/fs/path-coordinate.js +16 -0
  249. package/build/generated/version.js +3 -2
  250. package/build/git/branches.js +2 -1
  251. package/build/git/core.js +106 -2
  252. package/build/git/diff/parsers.js +23 -13
  253. package/build/git/diff/structured.js +127 -0
  254. package/build/git/path-coordinate.js +17 -0
  255. package/build/git/refs.js +57 -0
  256. package/build/git/streaming-batch.js +301 -0
  257. package/build/git/worktree.js +65 -0
  258. package/build/index.js +9 -9
  259. package/build/keiyaku.js +2 -36
  260. package/build/telemetry/logger.js +4 -2
  261. package/package.json +4 -10
  262. package/skills/keiyaku/SKILL.md +5 -4
  263. package/skills/keiyaku-akuma/SKILL.md +25 -11
  264. package/skills/keiyaku-task/SKILL.md +17 -8
  265. package/skills/keiyaku-workflow/SKILL.md +58 -9
  266. package/build/agents/providers/codex-sdk.js +0 -329
  267. package/build/cli/commands/task/view/meta.js +0 -8
  268. package/build/core/command-io.js +0 -174
  269. package/build/core/path-coordinate.js +0 -27
  270. package/build/core/petition-claim.js +0 -117
  271. package/build/core/petition-run.js +0 -83
  272. package/build/core/projection-coordinate.js +0 -63
  273. package/build/core/projection-wait.js +0 -165
  274. package/build/core/projection-wake.js +0 -136
  275. package/build/core/queue.js +0 -343
  276. package/build/core/task-contract.js +0 -237
  277. package/build/core/task.js +0 -4
  278. /package/build/{core/task-repository.js → agents/launch-snapshot/types.js} +0 -0
  279. /package/build/{core/task-store.js → agents/providers/claude-agent-sdk/terms.js} +0 -0
  280. /package/build/core/{projection-generation-runtime.js → projection/generation/projection-generation-runtime.js} +0 -0
  281. /package/build/core/{projection-life-protocol.js → projection/projection-life-protocol.js} +0 -0
  282. /package/build/core/{projection-runner-lock.js → projection/projection-runner-lock.js} +0 -0
@@ -1,6 +1,6 @@
1
1
  import { runCallAndPersist } from "../../../../core/call-persist.js";
2
- import { projectionDir } from "../../../../core/projection-core.js";
3
- import { waitForProjection } from "../../../../core/projection-wait.js";
2
+ import { projectionDir } from "../../../../core/projection/index.js";
3
+ import { waitForProjection } from "../../../../core/projection/index.js";
4
4
  import { buildCallResponse, renderAdoptedLaunchReceipt } from "../../../render/call.js";
5
5
  import { buildWaitResponse } from "../../../render/wait.js";
6
6
  import { buildCallInput } from "../../shared.js";
@@ -12,8 +12,8 @@ export const handler = async (stdin, flags, signal) => {
12
12
  signal,
13
13
  ...(!flags.detach
14
14
  ? {
15
- onLaunch: ({ address, projection }) => {
16
- process.stdout.write(`${renderAdoptedLaunchReceipt(address, projection.id, projection.alias, projection.previousAliasTarget)}\n`);
15
+ onLaunch: ({ address, projection, akumaName }) => {
16
+ process.stdout.write(`${renderAdoptedLaunchReceipt(address, projection.id, projection.alias, projection.previousAliasTarget, akumaName)}\n`);
17
17
  },
18
18
  }
19
19
  : {}),
@@ -25,8 +25,9 @@ export const handler = async (stdin, flags, signal) => {
25
25
  const projectionRoot = outcome.result.address.repo.kind === "repository"
26
26
  ? outcome.result.address.repo.stableRoot
27
27
  : flags.cwd ?? process.cwd();
28
+ const projectionDirectory = await projectionDir(projectionRoot, projection.id);
28
29
  return buildWaitResponse(projection.id, await waitForProjection({
29
- projectionDirectory: projectionDir(projectionRoot, projection.id),
30
+ projectionDirectory,
30
31
  timeoutMs: flags.timeoutMs,
31
32
  signal,
32
33
  }), { alias: projection.alias });
@@ -2,7 +2,10 @@ export const meta = {
2
2
  command: "call",
3
3
  summary: "Start an Akuma helper session",
4
4
  usage: ["keiyaku call NAME [--wait DURATION] <BODY|->"],
5
- stdin: "none",
5
+ stdin: {
6
+ mode: "argument",
7
+ selector: { kind: "positional", index: 0, required: true, rejectBlank: true },
8
+ },
6
9
  flags: ["cwd", "repo", "contract", "akuma", "model", "effort", "incognito", "bare", "detach", "alias", "wait"],
7
10
  purpose: "Run a scoped helper task.",
8
11
  completionRank: 2,
@@ -1,37 +1,21 @@
1
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";
2
+ import { killProjectionGeneration } from "../../../../core/projection/index.js";
3
+ import { waitForProjection } from "../../../../core/projection/index.js";
4
+ import { buildKillAcceptedResponse, buildKillAlreadyClosedResponse } from "../../../render/kill.js";
8
5
  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
12
- ? await repositoryDirectory(flags, "kill contract addressing")
13
- : await projectDirectory(flags, "kill");
6
+ import { resolveProjectionCommandTarget, runProjectionCommand, } from "../shared.js";
7
+ export const handler = async (_stdin, flags, signal, positional) => runProjectionCommand(flags, "kill", async (ctx) => {
14
8
  const [projectionAddress] = positional;
15
9
  if (!projectionAddress)
16
10
  throw new FlowError("EMPTY_PARAM", "kill requires a projection address");
17
- const address = flags.contractId ? await resolveContractAddress(cwd, flags.contractId, flags.contractAddressSource) : undefined;
18
- const operation = async () => {
19
- const projection = await resolveProjectionAddress({
20
- cwd,
21
- address: projectionAddress,
22
- scope: address,
23
- verb: "kill",
24
- });
25
- const directory = projectionDir(cwd, projection.id);
26
- const result = killProjectionGeneration(directory);
27
- if (result.status === "already-closed") {
28
- return textResponse(`· ${projection.id} already closed`);
29
- }
30
- if (flags.timeoutMs === undefined) {
31
- return textResponse(`✓ kill ${projection.id}\n» keiyaku wait ${projection.id}`);
32
- }
33
- // Accepted with --wait: no acceptance receipt or address preamble.
34
- return buildWaitResponse(projection.id, await waitForProjection({ projectionDirectory: directory, timeoutMs: flags.timeoutMs, signal }), { alias: projection.alias });
35
- };
36
- return address ? await withResolvedAddress(address, operation) : await operation();
37
- };
11
+ const projection = await resolveProjectionCommandTarget(ctx, projectionAddress, "kill");
12
+ const result = killProjectionGeneration(projection.directory);
13
+ if (result.status === "already-closed") {
14
+ return buildKillAlreadyClosedResponse(projection.id);
15
+ }
16
+ if (flags.timeoutMs === undefined) {
17
+ return buildKillAcceptedResponse(projection.id);
18
+ }
19
+ // Accepted with --wait: no acceptance receipt or address preamble.
20
+ return buildWaitResponse(projection.id, await waitForProjection({ projectionDirectory: projection.directory, timeoutMs: flags.timeoutMs, signal }), { alias: projection.alias });
21
+ });
@@ -5,7 +5,7 @@ export const meta = {
5
5
  "keiyaku kill <projection-address> [--wait DURATION]",
6
6
  "keiyaku @addr kill <projection-address> [--wait DURATION]",
7
7
  ],
8
- stdin: "none",
8
+ stdin: { mode: "argument" },
9
9
  flags: ["cwd", "repo", "contract", "wait"],
10
10
  purpose: "Terminate the current generation while keeping the projection identity and tell ledger.",
11
11
  };
@@ -2,7 +2,10 @@ export const meta = {
2
2
  command: "revive",
3
3
  summary: "Revive an Akuma helper session",
4
4
  usage: ["keiyaku revive ARTIFACT [BODY|-]"],
5
- stdin: "none",
5
+ stdin: {
6
+ mode: "argument",
7
+ selector: { kind: "positional", index: 1, required: false, rejectBlank: true },
8
+ },
6
9
  flags: ["cwd", "repo", "model", "effort"],
7
10
  purpose: "Continue a persisted helper session.",
8
11
  completionRank: 4,
@@ -0,0 +1,28 @@
1
+ import { resolveContractAddress, withResolvedAddress, } from "../../../core/addressing.js";
2
+ import { projectionDir } from "../../../core/projection/index.js";
3
+ import { resolveProjectionAddress, } from "../../projection-address.js";
4
+ import { projectDirectory, repositoryDirectory } from "../shared.js";
5
+ /** Resolve cwd + optional contract address, then run the verb under that carrier. */
6
+ export async function runProjectionCommand(flags, verb, operation) {
7
+ const cwd = flags.contractId
8
+ ? await repositoryDirectory(flags, `${verb} contract addressing`)
9
+ : await projectDirectory(flags, verb);
10
+ const address = flags.contractId
11
+ ? await resolveContractAddress(cwd, flags.contractId, flags.contractAddressSource)
12
+ : undefined;
13
+ const run = () => operation({ cwd, address });
14
+ return address ? await withResolvedAddress(address, run) : await run();
15
+ }
16
+ export function resolveProjectionCommandAddress(ctx, projectionAddress, verb) {
17
+ return resolveProjectionAddress({
18
+ cwd: ctx.cwd,
19
+ address: projectionAddress,
20
+ scope: ctx.address,
21
+ verb,
22
+ });
23
+ }
24
+ export async function resolveProjectionCommandTarget(ctx, projectionAddress, verb) {
25
+ const projection = await resolveProjectionCommandAddress(ctx, projectionAddress, verb);
26
+ const directory = await projectionDir(ctx.cwd, projection.id);
27
+ return { ...projection, directory };
28
+ }
@@ -1,6 +1,6 @@
1
1
  import { readKanshiBoard } from "../../../../core/status/board.js";
2
2
  import { normalizeTargetRef } from "../../../../core/target-ref.js";
3
- import { isProjectionId } from "../../../../core/projection-core.js";
3
+ import { isProjectionId } from "../../../../core/projection/index.js";
4
4
  import { FlowError } from "../../../../flow-error.js";
5
5
  import { renderProjectionFilteredStatus, renderStatusBoard } from "../../../render/status.js";
6
6
  import { textResponse } from "../../../render/shared.js";
@@ -2,7 +2,7 @@ export const meta = {
2
2
  command: "status",
3
3
  summary: "Show the Kanshi board",
4
4
  usage: ["keiyaku status [PROJECTION] [-C|--cwd DIR] [--repo DIR] [--target REF] [--all]"],
5
- stdin: "none",
5
+ stdin: { mode: "argument" },
6
6
  flags: ["cwd", "repo", "target", "all"],
7
7
  purpose: "Read the Kanshi board or filter it to one projection without mutation.",
8
8
  completionRank: 14,
@@ -1,36 +1,20 @@
1
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";
2
+ import { assertTellEffortSupported, tellProjection, writeInboxTell } from "../../../../core/projection/index.js";
3
+ import { waitForProjection } from "../../../../core/projection/index.js";
7
4
  import { prependAddressReceipt } from "../../../render/address.js";
8
- import { textResponse } from "../../../render/shared.js";
5
+ import { buildSilentTellResponse } from "../../../render/tell.js";
9
6
  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
13
- ? await repositoryDirectory(flags, "tell contract addressing")
14
- : await projectDirectory(flags, "tell");
7
+ import { resolveProjectionCommandTarget, runProjectionCommand, } from "../shared.js";
8
+ export const handler = async (body, flags, signal, positional) => runProjectionCommand(flags, "tell", async (ctx) => {
15
9
  const projectionAddress = positional[0];
16
10
  if (!projectionAddress)
17
11
  throw new FlowError("EMPTY_PARAM", "tell requires a projection address and message");
18
- const address = flags.contractId ? await resolveContractAddress(cwd, flags.contractId, flags.contractAddressSource) : undefined;
19
- const operation = async () => {
20
- const projection = await resolveProjectionAddress({
21
- cwd,
22
- address: projectionAddress,
23
- scope: address,
24
- verb: "tell",
25
- });
26
- const directory = projectionDir(cwd, projection.id);
27
- assertTellEffortSupported(directory, flags.effort);
28
- // Mailbox first: do not inspect phase before this immutable write.
29
- writeInboxTell(directory, body, Date.now(), { effort: flags.effort });
30
- await tellProjection(directory, flags.effort);
31
- if (flags.timeoutMs === undefined)
32
- return textResponse("");
33
- return prependAddressReceipt(buildWaitResponse(projection.id, await waitForProjection({ projectionDirectory: directory, timeoutMs: flags.timeoutMs, signal }), { alias: projection.alias }), address, { projectionId: projection.id, projectionAlias: projection.alias });
34
- };
35
- return address ? await withResolvedAddress(address, operation) : await operation();
36
- };
12
+ const projection = await resolveProjectionCommandTarget(ctx, projectionAddress, "tell");
13
+ assertTellEffortSupported(projection.directory, flags.effort);
14
+ // Address admission and any effort validation precede the durable mailbox write.
15
+ writeInboxTell(projection.directory, body, Date.now(), { effort: flags.effort });
16
+ await tellProjection(projection.directory, projection.id, flags.effort);
17
+ if (flags.timeoutMs === undefined)
18
+ return buildSilentTellResponse();
19
+ return prependAddressReceipt(buildWaitResponse(projection.id, await waitForProjection({ projectionDirectory: projection.directory, timeoutMs: flags.timeoutMs, signal }), { alias: projection.alias }), ctx.address, { projectionId: projection.id, projectionAlias: projection.alias });
20
+ });
@@ -2,7 +2,10 @@ export const meta = {
2
2
  command: "tell",
3
3
  summary: "Send intent to a projection mailbox",
4
4
  usage: ["keiyaku tell PROJECTION [--wait DURATION] [--] <BODY|->"],
5
- stdin: "none",
5
+ stdin: {
6
+ mode: "argument",
7
+ selector: { kind: "positional", index: 1, required: true, rejectBlank: true },
8
+ },
6
9
  flags: ["cwd", "repo", "contract", "effort", "wait"],
7
10
  purpose: "Write intent to the mailbox and wake only when eligible.",
8
11
  completionRank: 3,
@@ -1,23 +1,46 @@
1
- import { resolveContractAddress, withResolvedAddress, } from "../../../../core/addressing.js";
2
- import { projectionDir } from "../../../../core/projection-core.js";
3
- import { waitForProjection } from "../../../../core/projection-wait.js";
4
- import { resolveProjectionAddress } from "../../../projection-address.js";
1
+ import { projectionDir } from "../../../../core/projection/index.js";
2
+ import { snapshotCommissionProjectionIds, waitForProjection, waitForProjectionSet } from "../../../../core/projection/index.js";
3
+ import { FlowError } from "../../../../flow-error.js";
5
4
  import { prependAddressReceipt } from "../../../render/address.js";
6
- import { buildWaitResponse } from "../../../render/wait.js";
7
- import { projectDirectory, repositoryDirectory } from "../../shared.js";
8
- export const handler = async (_stdin, flags, signal, positional) => {
9
- const cwd = flags.contractId
10
- ? await repositoryDirectory(flags, "wait contract addressing")
11
- : await projectDirectory(flags, "wait");
12
- const address = flags.contractId ? await resolveContractAddress(cwd, flags.contractId, flags.contractAddressSource) : undefined;
13
- const operation = async () => {
14
- const projection = await resolveProjectionAddress({
15
- cwd,
16
- address: positional[0],
17
- scope: address,
18
- verb: "wait",
19
- });
20
- return prependAddressReceipt(buildWaitResponse(projection.id, await waitForProjection({ projectionDirectory: projectionDir(cwd, projection.id), timeoutMs: flags.timeoutMs, signal }), { alias: projection.alias }), address, { projectionId: projection.id, projectionAlias: projection.alias });
21
- };
22
- return address ? await withResolvedAddress(address, operation) : await operation();
23
- };
5
+ import { buildProjectionWaitSetResponse, buildWaitResponse } from "../../../render/wait.js";
6
+ import { resolveProjectionCommandAddress, resolveProjectionCommandTarget, runProjectionCommand, } from "../shared.js";
7
+ import { WAIT_SET_SELECTION_ERROR } from "./meta.js";
8
+ export const handler = async (_stdin, flags, signal, positional) => runProjectionCommand(flags, "wait", async (ctx) => {
9
+ // Selection modes only govern admitted sets with more than one explicit member.
10
+ if (positional.length === 1) {
11
+ const projection = await resolveProjectionCommandTarget(ctx, positional[0], "wait");
12
+ return prependAddressReceipt(buildWaitResponse(projection.id, await waitForProjection({
13
+ projectionDirectory: projection.directory,
14
+ timeoutMs: flags.timeoutMs,
15
+ signal,
16
+ }), { alias: projection.alias }), ctx.address, { projectionId: projection.id, projectionAlias: projection.alias });
17
+ }
18
+ const selected = [];
19
+ if (positional.length === 0) {
20
+ if (ctx.address?.binding.kind === "commission") {
21
+ selected.push(...await snapshotCommissionProjectionIds(ctx.cwd, ctx.address.binding.commissionId));
22
+ }
23
+ }
24
+ else {
25
+ // Resolve in argument order so multiple bad coordinates have one stable failure.
26
+ for (const projectionAddress of positional) {
27
+ selected.push((await resolveProjectionCommandAddress(ctx, projectionAddress, "wait")).id);
28
+ }
29
+ }
30
+ const ids = [...new Set(selected)].sort();
31
+ if (ids.length === 0) {
32
+ throw new FlowError("EMPTY_PARAM", "wait commission snapshot contains no projections");
33
+ }
34
+ if (!flags.any && !flags.all) {
35
+ throw new FlowError("EMPTY_PARAM", WAIT_SET_SELECTION_ERROR);
36
+ }
37
+ return prependAddressReceipt(buildProjectionWaitSetResponse(await waitForProjectionSet({
38
+ projections: await Promise.all(ids.map(async (id) => ({
39
+ id,
40
+ projectionDirectory: await projectionDir(ctx.cwd, id),
41
+ }))),
42
+ selection: flags.any ? "any" : "all",
43
+ timeoutMs: flags.timeoutMs,
44
+ signal,
45
+ })), ctx.address);
46
+ });
@@ -1,11 +1,16 @@
1
+ export const WAIT_SET_SELECTION_ERROR = "wait requires exactly one of --any or --all when selecting multiple projections";
1
2
  export const meta = {
2
3
  command: "wait",
3
4
  summary: "Wait for an akuma projection",
4
5
  usage: [
5
6
  "keiyaku wait <projection-address> [--timeout DURATION]",
6
- "keiyaku @addr wait <projection-address> [--timeout DURATION]",
7
+ "keiyaku wait <projection-address> <projection-address>... (--any|--all) [--timeout DURATION]",
8
+ "keiyaku @addr wait [<projection-address>...] (--any|--all) [--timeout DURATION]",
7
9
  ],
8
- stdin: "none",
9
- flags: ["cwd", "repo", "contract", "timeout"],
10
+ stdin: { mode: "argument" },
11
+ flags: ["cwd", "repo", "contract", "timeout", "any", "all"],
12
+ flagDescriptions: {
13
+ all: "For a projection set, return only after every admitted member reaches a terminal state.",
14
+ },
10
15
  purpose: "Read an akuma projection until its outcome is available, or show a timeout snapshot.",
11
16
  };
@@ -5,40 +5,7 @@ import { akumaCatalog } from "./akuma/catalog.js";
5
5
  import { skillsCatalog } from "./skills/catalog.js";
6
6
  import { systemCatalog } from "./system/catalog.js";
7
7
  import { taskCatalog } from "./task/catalog.js";
8
- /** Stable metadata key order consumed by help and tests. */
9
- const METADATA_ORDER = [
10
- "bind",
11
- "arc",
12
- "call",
13
- "revive",
14
- "wait",
15
- "tell",
16
- "kill",
17
- "log",
18
- "akuma",
19
- "akuma ls",
20
- "akuma view",
21
- "skills",
22
- "skills install",
23
- "amend",
24
- "renew",
25
- "petition",
26
- "forfeit",
27
- "guide",
28
- "completion",
29
- "status",
30
- "task",
31
- "task add",
32
- "task view",
33
- "task ls",
34
- "task start",
35
- "task stop",
36
- "task done",
37
- "task drop",
38
- "task update",
39
- "task doctor",
40
- "dump-env",
41
- ];
8
+ import { COMMAND_METADATA_ORDER } from "./metadata.js";
42
9
  function buildRegistry(catalogs) {
43
10
  const registrations = catalogs.flat();
44
11
  const byCommand = new Map();
@@ -50,7 +17,7 @@ function buildRegistry(catalogs) {
50
17
  byCommand.set(command, registration);
51
18
  }
52
19
  const registry = {};
53
- for (const command of METADATA_ORDER) {
20
+ for (const command of COMMAND_METADATA_ORDER) {
54
21
  const registration = byCommand.get(command);
55
22
  if (!registration) {
56
23
  throw new FlowError("INTERNAL_STATE", `missing CLI command registration: ${command}`);
@@ -72,28 +39,9 @@ const REGISTRY = buildRegistry([
72
39
  systemCatalog,
73
40
  taskCatalog,
74
41
  ]);
75
- /** Longest multi-token match first; same token count keeps METADATA_ORDER. */
76
- function deriveParseOrder(order) {
77
- return [...order].sort((a, b) => {
78
- const tokenDelta = b.split(" ").length - a.split(" ").length;
79
- if (tokenDelta !== 0)
80
- return tokenDelta;
81
- return order.indexOf(a) - order.indexOf(b);
82
- });
83
- }
84
- const PARSE_ORDER = deriveParseOrder(METADATA_ORDER);
85
42
  export function getCommandRegistration(command) {
86
43
  return REGISTRY[command];
87
44
  }
88
- export function getCommandMetadata(command) {
89
- return REGISTRY[command].meta;
90
- }
91
- export function allCommandMetadata() {
92
- return METADATA_ORDER.map((command) => REGISTRY[command].meta);
93
- }
94
- export function commandParseOrder() {
95
- return PARSE_ORDER;
96
- }
97
45
  export async function loadCommandHandler(command) {
98
46
  const module = await REGISTRY[command].load();
99
47
  return module.handler;
@@ -1,8 +1,9 @@
1
1
  import { FlowError } from "../../flow-error.js";
2
2
  import { AddressResolutionError, buildResolutionAttempt, } from "../../core/addressing.js";
3
+ import { normalizeFilesystemCoordinate } from "../../fs/path-coordinate.js";
3
4
  import { assertGitObservation, observeGitRepository } from "../../git/branches.js";
4
5
  import { stableRepoRoot } from "../../core/worktree-path.js";
5
- import { assertProjectionAlias } from "../../core/projection-alias.js";
6
+ import { assertProjectionAlias } from "../../core/projection/index.js";
6
7
  export function titleFromCallPrompt(prompt) {
7
8
  const firstLine = prompt
8
9
  .split(/\r?\n/)
@@ -15,15 +16,15 @@ export function titleFromCallPrompt(prompt) {
15
16
  export function repositoryCoordinateFromAddress(address) {
16
17
  return address?.repo.kind === "repository" ? address.repo.stableRoot : undefined;
17
18
  }
18
- export function buildCallInput(content, flags, mode = "call") {
19
- const cwd = flags.cwd ?? process.cwd();
19
+ export function buildCallInput(content, flags, mode = "call", platform = process.platform) {
20
+ const cwd = effectiveDirectory(flags, platform);
20
21
  const task = content.trim();
21
22
  if (!task) {
22
23
  throw new FlowError("EMPTY_PARAM", `${mode} body cannot be empty`);
23
24
  }
24
25
  return {
25
26
  cwd,
26
- repo: flags.repo,
27
+ repo: flags.repo === undefined ? undefined : normalizeFilesystemCoordinate(flags.repo, platform),
27
28
  mode,
28
29
  contractId: flags.contractId,
29
30
  contractAddressSource: flags.contractAddressSource,
@@ -41,11 +42,13 @@ export function buildCallInput(content, flags, mode = "call") {
41
42
  export function revivePrompt(stdin) {
42
43
  return stdin.trim() ? stdin : "Continue from the previous response.";
43
44
  }
44
- export function effectiveDirectory(flags) {
45
- return flags.cwd ?? process.cwd();
45
+ export function effectiveDirectory(flags, platform = process.platform) {
46
+ return normalizeFilesystemCoordinate(flags.cwd ?? process.cwd(), platform);
46
47
  }
47
48
  export async function repositoryDirectory(flags, operation) {
48
- const candidate = flags.repo ?? effectiveDirectory(flags);
49
+ const candidate = flags.repo === undefined
50
+ ? effectiveDirectory(flags)
51
+ : normalizeFilesystemCoordinate(flags.repo);
49
52
  if (assertGitObservation(await observeGitRepository(candidate), operation) === "non-repository") {
50
53
  if (flags.contractId) {
51
54
  const asTyped = flags.contractAddressSource === "at-address"
@@ -1,10 +1,7 @@
1
1
  import { installOfficialSkills } from "../../../skills-install.js";
2
+ import { renderSkillsInstallReceipt } from "../../../render/skills.js";
2
3
  import { textResponse } from "../../../render/shared.js";
3
4
  export const handler = async (_stdin, flags) => {
4
5
  const result = await installOfficialSkills(flags.force);
5
- return textResponse([
6
- "Installed official Keiyaku skills:",
7
- ...result.targets.map((target) => `- ${target.path} -> ${target.source} (${target.status})`),
8
- ...(result.warnings.length > 0 ? ["", "## Warning", ...result.warnings.map((warning) => `- ${warning}`)] : []),
9
- ].join("\n"));
6
+ return textResponse(renderSkillsInstallReceipt(result));
10
7
  };
@@ -2,7 +2,7 @@ export const meta = {
2
2
  command: "skills install",
3
3
  summary: "Install the official Keiyaku skills",
4
4
  usage: ["keiyaku skills install [-f|--force]"],
5
- stdin: "none",
5
+ stdin: { mode: "argument" },
6
6
  flags: ["force"],
7
7
  purpose: "Install the bundled official Keiyaku skills into supported agent skill directories.",
8
8
  notes: ["Force permits replacement of foreign collisions."],
@@ -1,4 +1,4 @@
1
- import { missingSubcommandError } from "../../../help.js";
1
+ import { missingSubcommandError } from "../../../missing-subcommand.js";
2
2
  export const handler = async () => {
3
3
  throw missingSubcommandError("skills", ["install"]);
4
4
  };
@@ -2,7 +2,7 @@ export const meta = {
2
2
  command: "skills",
3
3
  summary: "Install official skills",
4
4
  usage: ["keiyaku skills install"],
5
- stdin: "none",
5
+ stdin: { mode: "argument" },
6
6
  flags: [],
7
7
  purpose: "Install bundled official Keiyaku skills into supported agent skill directories.",
8
8
  subcommands: ["install"],
@@ -2,7 +2,7 @@ export const meta = {
2
2
  command: "completion",
3
3
  summary: "Print shell completion",
4
4
  usage: ["keiyaku completion [--shell bash|zsh]"],
5
- stdin: "none",
5
+ stdin: { mode: "argument" },
6
6
  flags: ["cwd", "repo", "shell", "word", "previous", "complete"],
7
7
  purpose: "Print command and address candidates.",
8
8
  completionRank: 13,
@@ -2,7 +2,7 @@ export const meta = {
2
2
  command: "dump-env",
3
3
  summary: "Print the environment template",
4
4
  usage: ["keiyaku dump-env"],
5
- stdin: "none",
5
+ stdin: { mode: "argument" },
6
6
  flags: [],
7
7
  purpose: "Print supported environment keys.",
8
8
  notes: ["Keiyaku loads <KEIYAKU_HOME>/.env, then .keiyaku/.env; process environment values win."],
@@ -2,7 +2,7 @@ export const meta = {
2
2
  command: "guide",
3
3
  summary: "Print the Keiyaku guide",
4
4
  usage: ["keiyaku guide"],
5
- stdin: "none",
5
+ stdin: { mode: "argument" },
6
6
  flags: [],
7
7
  purpose: "Print workflow guidance.",
8
8
  completionRank: 12,
@@ -1,21 +1,13 @@
1
- import { randomBytes } from "node:crypto";
2
- import { resolveTaskCreator } from "../../../../core/task-git-actor.js";
3
- import { openTaskCommandRepository } from "../../../../core/task-git-runtime.js";
4
- import { createTask } from "../../../../core/task.js";
5
- import { renderTaskMutationRow } from "../../../render/task.js";
6
- import { textResponse } from "../../../render/shared.js";
7
- import { effectiveDirectory } from "../../shared.js";
8
- import { parseTaskAddInput } from "../shared.js";
9
- export const handler = async (stdin, flags, _signal, positional) => {
10
- const cwd = effectiveDirectory(flags);
11
- const input = parseTaskAddInput(positional[0] === "-" ? stdin : positional[0]);
12
- const task = await createTask(await openTaskCommandRepository(cwd), {
1
+ import { createTask, resolveTaskCreator, } from "../../../../core/task/index.js";
2
+ import { parseTaskAddInput, runTaskMutationCommand } from "../shared.js";
3
+ export const handler = async (stdin, flags) => {
4
+ const input = parseTaskAddInput(stdin);
5
+ return runTaskMutationCommand(flags, async (repository, cwd) => createTask(repository, {
13
6
  ...input,
14
- creator: resolveTaskCreator(cwd),
7
+ creator: await resolveTaskCreator(cwd),
15
8
  ...(flags.taskPri === undefined ? {} : { pri: flags.taskPri }),
16
9
  needs: flags.taskNeeds ?? [],
17
10
  parent: flags.taskParent ?? null,
18
11
  from: flags.taskFrom ?? [],
19
- }, { randomBytes, now: () => new Date() });
20
- return textResponse(renderTaskMutationRow(task));
12
+ }, { now: () => new Date() }));
21
13
  };
@@ -2,7 +2,10 @@ export const meta = {
2
2
  command: "task add",
3
3
  summary: "Add a task",
4
4
  usage: ["keiyaku task add [-C|--cwd DIR] [--needs ID] [--parent ID] [--from ID] [--pri 0-3] <BODY|->"],
5
- stdin: "none",
5
+ stdin: {
6
+ mode: "argument",
7
+ selector: { kind: "positional", index: 0, required: true, rejectBlank: true },
8
+ },
6
9
  flags: ["cwd", "needs", "parent", "from", "pri"],
7
10
  purpose: "Create a lightweight task from a title and optional body.",
8
11
  };
@@ -1,6 +1,6 @@
1
1
  import { meta as taskMeta } from "./task/meta.js";
2
2
  import { meta as addMeta } from "./add/meta.js";
3
- import { meta as viewMeta } from "./view/meta.js";
3
+ import { meta as showMeta } from "./show/meta.js";
4
4
  import { meta as lsMeta } from "./ls/meta.js";
5
5
  import { meta as startMeta } from "./start/meta.js";
6
6
  import { meta as stopMeta } from "./stop/meta.js";
@@ -11,7 +11,7 @@ import { meta as doctorMeta } from "./doctor/meta.js";
11
11
  export const taskCatalog = [
12
12
  { meta: taskMeta, load: () => import("./task/handler.js") },
13
13
  { meta: addMeta, load: () => import("./add/handler.js") },
14
- { meta: viewMeta, load: () => import("./view/handler.js") },
14
+ { meta: showMeta, load: () => import("./show/handler.js") },
15
15
  { meta: lsMeta, load: () => import("./ls/handler.js") },
16
16
  { meta: startMeta, load: () => import("./start/handler.js") },
17
17
  { meta: stopMeta, load: () => import("./stop/handler.js") },
@@ -2,7 +2,7 @@ export const meta = {
2
2
  command: "task doctor",
3
3
  summary: "Diagnose the task board",
4
4
  usage: ["keiyaku task doctor [-C|--cwd DIR]"],
5
- stdin: "none",
5
+ stdin: { mode: "argument" },
6
6
  flags: ["cwd"],
7
7
  purpose: "Report task state counts, supported board diseases, and lock state without repair.",
8
8
  };
@@ -1,15 +1,11 @@
1
- import { openTaskCommandRepository } from "../../../../core/task-git-runtime.js";
2
- import { doneTask } from "../../../../core/task.js";
3
- import { renderTaskMutationRow } from "../../../render/task.js";
4
- import { textResponse } from "../../../render/shared.js";
1
+ import { doneTask } from "../../../../core/task/index.js";
5
2
  import { effectiveDirectory } from "../../shared.js";
6
- import { mutationSelectionMessage, rejectBareContractTaskState } from "../shared.js";
3
+ import { mutationSelectionMessage, rejectBareContractTaskState, runTaskMutationCommand } from "../shared.js";
7
4
  export const handler = async (_stdin, flags, _signal, positional) => {
8
5
  try {
9
- const cwd = effectiveDirectory(flags);
10
6
  if (positional[0] === undefined)
11
- await rejectBareContractTaskState(cwd, "done");
12
- return textResponse(renderTaskMutationRow(await doneTask(await openTaskCommandRepository(cwd), positional[0])));
7
+ await rejectBareContractTaskState(effectiveDirectory(flags), "done");
8
+ return await runTaskMutationCommand(flags, (repository) => doneTask(repository, positional[0]));
13
9
  }
14
10
  catch (error) {
15
11
  return mutationSelectionMessage(error);