@astrosheep/keiyaku 2.9.2 → 2.9.4

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 (238) hide show
  1. package/build/.tsbuildinfo +1 -1
  2. package/build/agents/call-terms.js +13 -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 +25 -222
  6. package/build/agents/harness/index.js +3 -1
  7. package/build/agents/harness/outcome.js +47 -4
  8. package/build/agents/harness/projection.js +42 -59
  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 +50 -53
  21. package/build/agents/providers/codex-app-server/events.js +67 -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/registration.js +145 -0
  36. package/build/agents/providers/pi/session-schema.js +6 -0
  37. package/build/agents/providers/pi/terms.js +1 -0
  38. package/build/agents/providers/registration.js +7 -0
  39. package/build/agents/providers/registry.js +76 -0
  40. package/build/agents/selector.js +2 -29
  41. package/build/agents/types.js +8 -0
  42. package/build/artifact-directories.js +22 -0
  43. package/build/cli/commands/akuma/akuma/handler.js +1 -1
  44. package/build/cli/commands/akuma/view/handler.js +5 -4
  45. package/build/cli/commands/akuma.js +6 -0
  46. package/build/cli/commands/contract/amend/handler.js +8 -2
  47. package/build/cli/commands/contract/arc/handler.js +7 -1
  48. package/build/cli/commands/contract/bind/handler.js +4 -3
  49. package/build/cli/commands/contract/bind/meta.js +34 -7
  50. package/build/cli/commands/contract/forfeit/handler.js +4 -4
  51. package/build/cli/commands/contract/log/handler.js +3 -3
  52. package/build/cli/commands/contract/petition/handler.js +4 -6
  53. package/build/cli/commands/contract/renew/handler.js +20 -6
  54. package/build/cli/commands/contract/renew/meta.js +5 -4
  55. package/build/cli/commands/metadata.js +58 -0
  56. package/build/cli/commands/projection/call/handler.js +6 -5
  57. package/build/cli/commands/projection/kill/handler.js +16 -32
  58. package/build/cli/commands/projection/shared.js +28 -0
  59. package/build/cli/commands/projection/status/handler.js +1 -1
  60. package/build/cli/commands/projection/tell/handler.js +14 -30
  61. package/build/cli/commands/projection/wait/handler.js +45 -22
  62. package/build/cli/commands/projection/wait/meta.js +7 -2
  63. package/build/cli/commands/registry.js +2 -54
  64. package/build/cli/commands/shared.js +10 -7
  65. package/build/cli/commands/skills/install/handler.js +2 -5
  66. package/build/cli/commands/skills/skills/handler.js +1 -1
  67. package/build/cli/commands/task/add/handler.js +5 -13
  68. package/build/cli/commands/task/catalog.js +2 -2
  69. package/build/cli/commands/task/done/handler.js +4 -8
  70. package/build/cli/commands/task/drop/handler.js +3 -6
  71. package/build/cli/commands/task/ls/handler.js +3 -5
  72. package/build/cli/commands/task/shared.js +14 -4
  73. package/build/cli/commands/task/{view → show}/handler.js +7 -8
  74. package/build/cli/commands/task/show/meta.js +8 -0
  75. package/build/cli/commands/task/start/handler.js +3 -6
  76. package/build/cli/commands/task/stop/handler.js +4 -8
  77. package/build/cli/commands/task/task/handler.js +1 -1
  78. package/build/cli/commands/task/update/handler.js +4 -8
  79. package/build/cli/completion.js +1 -1
  80. package/build/cli/flags.js +19 -3
  81. package/build/cli/help.js +4 -11
  82. package/build/cli/index.js +57 -83
  83. package/build/cli/missing-subcommand.js +7 -0
  84. package/build/cli/parse-flags.js +14 -5
  85. package/build/cli/parse-metadata.js +3 -3
  86. package/build/cli/parse-selectors.js +1 -1
  87. package/build/cli/parse.js +21 -0
  88. package/build/cli/projection-address.js +7 -12
  89. package/build/cli/render/address.js +41 -37
  90. package/build/cli/render/arc.js +24 -12
  91. package/build/cli/render/call.js +11 -5
  92. package/build/cli/render/errors.js +36 -1
  93. package/build/cli/render/format.js +4 -0
  94. package/build/cli/render/kanshi.js +6 -12
  95. package/build/cli/render/kill.js +9 -0
  96. package/build/cli/render/misc.js +55 -12
  97. package/build/cli/render/petition.js +20 -15
  98. package/build/cli/render/projection-activity.js +3 -0
  99. package/build/cli/render/shared.js +60 -21
  100. package/build/cli/render/skills.js +10 -0
  101. package/build/cli/render/status.js +37 -14
  102. package/build/cli/render/success-response.js +77 -0
  103. package/build/cli/render/task.js +54 -14
  104. package/build/cli/render/tell.js +5 -0
  105. package/build/cli/render/terminal-failure.js +58 -0
  106. package/build/cli/render/types.js +1 -0
  107. package/build/cli/render/wait.js +38 -36
  108. package/build/cli/types.js +1 -1
  109. package/build/config/akuma-loader.js +0 -5
  110. package/build/config/env-keys.js +1 -1
  111. package/build/config/provider-policy-ownership.js +3 -32
  112. package/build/config/settings/disease.js +8 -1
  113. package/build/config/settings/loader.js +11 -3
  114. package/build/config/settings/provider-instance-fields.js +51 -0
  115. package/build/config/settings/schema.js +6 -176
  116. package/build/core/addressing.js +66 -16
  117. package/build/core/amend.js +135 -18
  118. package/build/core/arc.js +19 -67
  119. package/build/core/bind.js +82 -35
  120. package/build/core/call/call.js +15 -9
  121. package/build/core/call/context.js +6 -51
  122. package/build/core/call/execution.js +21 -22
  123. package/build/core/call/prompt.js +14 -1
  124. package/build/core/command-markdown.js +45 -0
  125. package/build/core/context.js +13 -7
  126. package/build/core/contract-view.js +20 -3
  127. package/build/core/draft.js +123 -16
  128. package/build/core/forfeit.js +5 -2
  129. package/build/core/hints.js +1 -75
  130. package/build/core/identifier-slug.js +66 -0
  131. package/build/core/ids.js +25 -11
  132. package/build/core/ledger.js +20 -68
  133. package/build/core/markdown/parser.js +0 -68
  134. package/build/core/markdown/render.js +68 -0
  135. package/build/core/markdown/sections.js +2 -1
  136. package/build/core/outcome-base.js +4 -0
  137. package/build/core/projection/generation/database.js +2 -38
  138. package/build/core/projection/generation/model.js +42 -1
  139. package/build/core/{projection-generation-continuation.js → projection/generation/projection-generation-continuation.js} +3 -3
  140. package/build/core/{projection-generation-execution.js → projection/generation/projection-generation-execution.js} +19 -49
  141. package/build/core/{projection-generation-identity.js → projection/generation/projection-generation-identity.js} +2 -2
  142. package/build/core/{projection-generation-launcher.js → projection/generation/projection-generation-launcher.js} +5 -3
  143. package/build/core/{projection-generation-process.js → projection/generation/projection-generation-process.js} +2 -1
  144. package/build/core/{projection-generation-runner.js → projection/generation/projection-generation-runner.js} +18 -3
  145. package/build/core/projection/generation/store.js +2 -2
  146. package/build/core/projection/generation/transitions.js +1 -1
  147. package/build/core/projection/index.js +27 -0
  148. package/build/core/{projection-activity.js → projection/projection-activity.js} +12 -0
  149. package/build/core/{projection-alias.js → projection/projection-alias.js} +14 -19
  150. package/build/core/projection/projection-coordinate.js +61 -0
  151. package/build/core/{projection-core.js → projection/projection-core.js} +9 -9
  152. package/build/core/{projection-execution-observer.js → projection/projection-execution-observer.js} +2 -57
  153. package/build/core/{projection-identity.js → projection/projection-identity.js} +1 -1
  154. package/build/core/{projection-kill.js → projection/projection-kill.js} +1 -1
  155. package/build/core/{projection-life-observer.js → projection/projection-life-observer.js} +1 -1
  156. package/build/core/{projection-mint.js → projection/projection-mint.js} +10 -10
  157. package/build/core/{projection-status.js → projection/projection-status.js} +98 -25
  158. package/build/core/projection/projection-terminal-failure.js +104 -0
  159. package/build/core/projection/projection-wait.js +278 -0
  160. package/build/core/projection/projection-wake.js +203 -0
  161. package/build/core/provider-loader-ports.js +4 -0
  162. package/build/core/ref-log.js +65 -40
  163. package/build/core/registry.js +63 -10
  164. package/build/core/renew-session.js +128 -0
  165. package/build/core/renew.js +426 -99
  166. package/build/core/scope.js +143 -66
  167. package/build/core/seal.js +139 -35
  168. package/build/core/{claim-delivery.js → settlement/claim-delivery.js} +9 -14
  169. package/build/core/{claim.js → settlement/claim.js} +32 -8
  170. package/build/core/settlement/index.js +19 -0
  171. package/build/core/{petition-claim-gates.js → settlement/petition-claim-gates.js} +22 -18
  172. package/build/core/{petition-forfeit.js → settlement/petition-forfeit.js} +2 -2
  173. package/build/core/{petition-head-guard.js → settlement/petition-head-guard.js} +2 -2
  174. package/build/core/settlement/petition-io.js +1 -0
  175. package/build/core/{petition-preview.js → settlement/petition-preview.js} +1 -1
  176. package/build/core/{petition.js → settlement/petition.js} +12 -10
  177. package/build/core/settlement/queue-read-model.js +143 -0
  178. package/build/core/settlement/queue-seat-allocation.js +156 -0
  179. package/build/core/settlement/queue.js +6 -0
  180. package/build/core/settlement/settlement.js +295 -0
  181. package/build/core/{verdict.js → settlement/verdict.js} +9 -37
  182. package/build/core/status/board.js +24 -23
  183. package/build/core/status/ledger-batch.js +158 -0
  184. package/build/core/status/reconciliation.js +10 -4
  185. package/build/core/stored-agent-event.js +3 -0
  186. package/build/core/task/board.js +40 -4
  187. package/build/core/task/commands.js +30 -21
  188. package/build/core/task/index.js +12 -0
  189. package/build/core/task/settlement-git.js +157 -65
  190. package/build/core/task/settlement-policy.js +54 -24
  191. package/build/core/task/task-contract.js +370 -0
  192. package/build/core/{task-doctor.js → task/task-doctor.js} +1 -1
  193. package/build/core/{task-git-actor.js → task/task-git-actor.js} +5 -10
  194. package/build/core/{task-git-runtime.js → task/task-git-runtime.js} +3 -3
  195. package/build/core/{task-git-store.js → task/task-git-store.js} +92 -29
  196. package/build/core/task/task-repository.js +1 -0
  197. package/build/core/{task-store-repository.js → task/task-store-repository.js} +5 -4
  198. package/build/core/task/task-store.js +1 -0
  199. package/build/core/{task-worktree.js → task/task-worktree.js} +2 -1
  200. package/build/core/task/task.js +5 -0
  201. package/build/core/task/tree.js +37 -0
  202. package/build/core/task/validation.js +5 -2
  203. package/build/core/transcripts.js +15 -3
  204. package/build/core/worktree-path.js +43 -28
  205. package/build/flow-error.js +85 -39
  206. package/build/fs/durability.js +27 -0
  207. package/build/fs/path-coordinate.js +16 -0
  208. package/build/generated/version.js +3 -2
  209. package/build/git/branches.js +2 -1
  210. package/build/git/core.js +106 -2
  211. package/build/git/path-coordinate.js +17 -0
  212. package/build/git/refs.js +57 -0
  213. package/build/git/streaming-batch.js +301 -0
  214. package/build/git/worktree.js +65 -0
  215. package/build/index.js +3 -3
  216. package/build/keiyaku.js +2 -36
  217. package/package.json +4 -10
  218. package/skills/keiyaku/SKILL.md +3 -2
  219. package/skills/keiyaku-akuma/SKILL.md +10 -6
  220. package/skills/keiyaku-task/SKILL.md +1 -1
  221. package/skills/keiyaku-workflow/SKILL.md +25 -4
  222. package/build/agents/providers/codex-sdk.js +0 -329
  223. package/build/cli/commands/task/view/meta.js +0 -8
  224. package/build/core/command-io.js +0 -174
  225. package/build/core/path-coordinate.js +0 -27
  226. package/build/core/petition-claim.js +0 -117
  227. package/build/core/petition-run.js +0 -83
  228. package/build/core/projection-coordinate.js +0 -63
  229. package/build/core/projection-wait.js +0 -165
  230. package/build/core/projection-wake.js +0 -136
  231. package/build/core/queue.js +0 -343
  232. package/build/core/task-contract.js +0 -237
  233. package/build/core/task.js +0 -4
  234. /package/build/{core/task-repository.js → agents/launch-snapshot/types.js} +0 -0
  235. /package/build/{core/task-store.js → agents/providers/claude-agent-sdk/terms.js} +0 -0
  236. /package/build/core/{projection-generation-runtime.js → projection/generation/projection-generation-runtime.js} +0 -0
  237. /package/build/core/{projection-life-protocol.js → projection/projection-life-protocol.js} +0 -0
  238. /package/build/core/{projection-runner-lock.js → projection/projection-runner-lock.js} +0 -0
@@ -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
10
  stdin: "none",
9
- flags: ["cwd", "repo", "contract", "timeout"],
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
  };
@@ -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
  };
@@ -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";
1
+ import { createTask, resolveTaskCreator, } from "../../../../core/task/index.js";
2
+ import { parseTaskAddInput, runTaskMutationCommand } from "../shared.js";
9
3
  export const handler = async (stdin, flags, _signal, positional) => {
10
- const cwd = effectiveDirectory(flags);
11
4
  const input = parseTaskAddInput(positional[0] === "-" ? stdin : positional[0]);
12
- const task = await createTask(await openTaskCommandRepository(cwd), {
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
  };
@@ -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") },
@@ -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);
@@ -1,6 +1,3 @@
1
- import { openTaskCommandRepository } from "../../../../core/task-git-runtime.js";
2
- import { dropTask } from "../../../../core/task.js";
3
- import { renderTaskMutationRow } from "../../../render/task.js";
4
- import { textResponse } from "../../../render/shared.js";
5
- import { effectiveDirectory } from "../../shared.js";
6
- export const handler = async (_stdin, flags, _signal, positional) => textResponse(renderTaskMutationRow(await dropTask(await openTaskCommandRepository(effectiveDirectory(flags)), positional[0])));
1
+ import { dropTask } from "../../../../core/task/index.js";
2
+ import { runTaskMutationCommand } from "../shared.js";
3
+ export const handler = async (_stdin, flags, _signal, positional) => runTaskMutationCommand(flags, (repository) => dropTask(repository, positional[0]));
@@ -1,11 +1,9 @@
1
- import { openTaskCommandRepository } from "../../../../core/task-git-runtime.js";
2
- import { readTaskBoard } from "../../../../core/task.js";
1
+ import { readTaskBoard } from "../../../../core/task/index.js";
3
2
  import { renderTaskList, renderTaskListJson } from "../../../render/task.js";
4
3
  import { textResponse } from "../../../render/shared.js";
5
- import { effectiveDirectory } from "../../shared.js";
6
- import { taskJsonText, taskSelection } from "../shared.js";
4
+ import { taskJsonText, taskSelection, withTaskCommandRepository } from "../shared.js";
7
5
  export const handler = async (_stdin, flags) => {
8
- const board = await readTaskBoard(await openTaskCommandRepository(effectiveDirectory(flags)));
6
+ const board = await withTaskCommandRepository(flags, (repository) => readTaskBoard(repository));
9
7
  const selection = taskSelection(flags);
10
8
  return textResponse(flags.json
11
9
  ? taskJsonText(renderTaskListJson(board.tasks, selection))
@@ -1,8 +1,18 @@
1
1
  import * as path from "node:path";
2
2
  import { FlowError } from "../../../flow-error.js";
3
- import { readTaskDoctor, taskCommandContractId } from "../../../core/task-git-runtime.js";
4
- import { deriveTaskDisplay, renderTaskList, } from "../../render/task.js";
5
- import { parseTaskDocument, } from "../../../core/task.js";
3
+ import { isTaskId, openTaskCommandRepository, parseTaskDocument, readTaskDoctor, taskCommandContractId, } from "../../../core/task/index.js";
4
+ import { deriveTaskDisplay, renderTaskList, renderTaskMutationRow, } from "../../render/task.js";
5
+ import { textResponse } from "../../render/shared.js";
6
+ import { effectiveDirectory } from "../shared.js";
7
+ /** Open the task command repository for flags.cwd and run the verb. */
8
+ export async function withTaskCommandRepository(flags, run) {
9
+ const cwd = effectiveDirectory(flags);
10
+ return run(await openTaskCommandRepository(cwd), cwd);
11
+ }
12
+ /** Shared shell: open repository → mutate → renderTaskMutationRow receipt. */
13
+ export async function runTaskMutationCommand(flags, mutate) {
14
+ return textResponse(renderTaskMutationRow(await withTaskCommandRepository(flags, mutate)));
15
+ }
6
16
  export function parseTaskAddInput(input) {
7
17
  if (!input.trim())
8
18
  throw new FlowError("EMPTY_PARAM", "task add input cannot be blank");
@@ -49,7 +59,7 @@ function renderTaskDiseaseRows(diseases, documents) {
49
59
  for (const disease of diseases) {
50
60
  if (disease.code === "invalid_document") {
51
61
  const name = path.basename(disease.path).replace(/\.md$/, "");
52
- if (/^k-[0-9a-f]{12}$/.test(name))
62
+ if (isTaskId(name))
53
63
  rows.push(`! ${name} invalid front matter — quarantined`);
54
64
  continue;
55
65
  }
@@ -1,14 +1,13 @@
1
1
  import { FlowError } from "../../../../flow-error.js";
2
- import { openTaskCommandRepository } from "../../../../core/task-git-runtime.js";
3
- import { readTaskBoard, resolveTaskReadId } from "../../../../core/task.js";
2
+ import { buildTaskTree, readTaskBoard, resolveTaskReadId, } from "../../../../core/task/index.js";
4
3
  import { renderTaskShow, renderTaskShowJson } from "../../../render/task.js";
5
4
  import { textResponse } from "../../../render/shared.js";
6
- import { effectiveDirectory } from "../../shared.js";
7
- import { taskJsonText } from "../shared.js";
8
- export const handler = async (_stdin, flags, _signal, positional) => {
9
- const board = await readTaskBoard(await openTaskCommandRepository(effectiveDirectory(flags)));
5
+ import { taskJsonText, withTaskCommandRepository } from "../shared.js";
6
+ export const handler = async (_stdin, flags, _signal, positional) => withTaskCommandRepository(flags, async (repository) => {
7
+ const board = await readTaskBoard(repository);
10
8
  const task = board.byId.get(resolveTaskReadId(board, positional[0]));
11
9
  if (!task)
12
10
  throw new FlowError("INTERNAL_STATE", "resolved task disappeared from the board");
13
- return textResponse(flags.json ? taskJsonText(renderTaskShowJson(task)) : renderTaskShow(task));
14
- };
11
+ const tree = buildTaskTree(board, task.id);
12
+ return textResponse(flags.json ? taskJsonText(renderTaskShowJson(task, tree)) : renderTaskShow(task, tree));
13
+ });
@@ -0,0 +1,8 @@
1
+ export const meta = {
2
+ command: "task show",
3
+ summary: "Show one task and its children tree",
4
+ usage: ["keiyaku task show [-C|--cwd DIR] ID [--json]"],
5
+ stdin: "none",
6
+ flags: ["cwd", "json"],
7
+ purpose: "Read one task and every descendant linked by parent edges.",
8
+ };
@@ -1,6 +1,3 @@
1
- import { openTaskCommandRepository } from "../../../../core/task-git-runtime.js";
2
- import { startTask } from "../../../../core/task.js";
3
- import { renderTaskMutationRow } from "../../../render/task.js";
4
- import { textResponse } from "../../../render/shared.js";
5
- import { effectiveDirectory } from "../../shared.js";
6
- export const handler = async (_stdin, flags, _signal, positional) => textResponse(renderTaskMutationRow(await startTask(await openTaskCommandRepository(effectiveDirectory(flags)), positional[0], new Date())));
1
+ import { startTask } from "../../../../core/task/index.js";
2
+ import { runTaskMutationCommand } from "../shared.js";
3
+ export const handler = async (_stdin, flags, _signal, positional) => runTaskMutationCommand(flags, (repository) => startTask(repository, positional[0], new Date()));
@@ -1,15 +1,11 @@
1
- import { openTaskCommandRepository } from "../../../../core/task-git-runtime.js";
2
- import { stopTask } from "../../../../core/task.js";
3
- import { renderTaskMutationRow } from "../../../render/task.js";
4
- import { textResponse } from "../../../render/shared.js";
1
+ import { stopTask } 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, "stop");
12
- return textResponse(renderTaskMutationRow(await stopTask(await openTaskCommandRepository(cwd), positional[0])));
7
+ await rejectBareContractTaskState(effectiveDirectory(flags), "stop");
8
+ return await runTaskMutationCommand(flags, (repository) => stopTask(repository, positional[0]));
13
9
  }
14
10
  catch (error) {
15
11
  return mutationSelectionMessage(error);
@@ -1,4 +1,4 @@
1
- import { missingSubcommandError } from "../../../help.js";
1
+ import { missingSubcommandError } from "../../../missing-subcommand.js";
2
2
  import { TASK_SUBCOMMANDS } from "../../../types.js";
3
3
  export const handler = async () => {
4
4
  throw missingSubcommandError("task", TASK_SUBCOMMANDS);
@@ -1,11 +1,8 @@
1
- import { openTaskCommandRepository } from "../../../../core/task-git-runtime.js";
2
- import { updateTask } from "../../../../core/task.js";
3
- import { renderTaskMutationRow } from "../../../render/task.js";
4
- import { textResponse } from "../../../render/shared.js";
5
- import { effectiveDirectory } from "../../shared.js";
1
+ import { updateTask } from "../../../../core/task/index.js";
2
+ import { runTaskMutationCommand } from "../shared.js";
6
3
  export const handler = async (stdin, flags, _signal, positional) => {
7
4
  const body = flags.taskBody === "-" ? stdin : flags.taskBody;
8
- const task = await updateTask(await openTaskCommandRepository(effectiveDirectory(flags)), positional[0], {
5
+ return runTaskMutationCommand(flags, (repository) => updateTask(repository, positional[0], {
9
6
  ...(flags.taskTitle === undefined ? {} : { title: flags.taskTitle }),
10
7
  ...(body === undefined ? {} : { body }),
11
8
  ...(flags.taskPri === undefined ? {} : { pri: flags.taskPri }),
@@ -13,6 +10,5 @@ export const handler = async (stdin, flags, _signal, positional) => {
13
10
  ...(flags.taskDropNeeds === undefined ? {} : { dropNeeds: flags.taskDropNeeds }),
14
11
  ...(flags.taskParent !== undefined ? { parent: flags.taskParent } : flags.taskNoParent ? { parent: null } : {}),
15
12
  ...(flags.taskFrom === undefined ? {} : { from: flags.taskFrom }),
16
- });
17
- return textResponse(renderTaskMutationRow(task));
13
+ }));
18
14
  };
@@ -2,7 +2,7 @@ import { assertSettingsKnobUsable } from "../config/settings/disease.js";
2
2
  import { loadKeiyakuSettings } from "../config/settings/loader.js";
3
3
  import { loadAkumaCatalog } from "../config/akuma-loader.js";
4
4
  import { listContractIds } from "../core/ledger.js";
5
- import { allCommandMetadata, getCommandMetadata } from "./commands/registry.js";
5
+ import { allCommandMetadata, getCommandMetadata } from "./commands/metadata.js";
6
6
  function topLevelCommands() {
7
7
  return allCommandMetadata()
8
8
  .filter((meta) => meta.completionRank !== undefined)
@@ -4,12 +4,12 @@ export const FLAG_SPECS = {
4
4
  cwd: {
5
5
  kind: "value",
6
6
  placeholder: "DIR",
7
- description: "Select the effective command directory (-C/--cwd). Defaults to the process working directory.",
7
+ description: "Select the effective command directory (-C/--cwd). Defaults to the process working directory; the repository is inferred from here unless --repo is set.",
8
8
  },
9
9
  repo: {
10
10
  kind: "value",
11
11
  placeholder: "DIR",
12
- description: "Select the repository that supplies contract ledgers.",
12
+ description: "Override the repository inferred from the effective directory. Needed only when the contract ledger lives in a different repository; the same value as -C is always redundant.",
13
13
  },
14
14
  contract: {
15
15
  kind: "value",
@@ -46,6 +46,10 @@ export const FLAG_SPECS = {
46
46
  placeholder: "DURATION",
47
47
  description: "Wait at most a positive duration such as 45s, 5m, or 2h (maximum 24h).",
48
48
  },
49
+ any: {
50
+ kind: "boolean",
51
+ description: "For a projection set, return when the first observed member reaches a terminal state.",
52
+ },
49
53
  wait: {
50
54
  kind: "value",
51
55
  placeholder: "DURATION",
@@ -57,7 +61,7 @@ export const FLAG_SPECS = {
57
61
  },
58
62
  bare: {
59
63
  kind: "boolean",
60
- description: "Skip contract attachment; Akuma, history, sandbox, credentials, projection, and repository policy remain active.",
64
+ description: "Explicitly select standalone execution (also the default without --contract); history, sandbox, credentials, projection, and repository policy remain active.",
61
65
  },
62
66
  detach: {
63
67
  kind: "boolean",
@@ -119,6 +123,18 @@ export const FLAG_SPECS = {
119
123
  placeholder: "PATH",
120
124
  description: "Allow one explicit out-of-scope path for this seal. May be repeated.",
121
125
  },
126
+ resolve: {
127
+ kind: "boolean",
128
+ description: "Open a durable Keiyaku-owned renew recovery session when the rewrite conflicts.",
129
+ },
130
+ continue: {
131
+ kind: "boolean",
132
+ description: "Continue the open Keiyaku-owned renew recovery session.",
133
+ },
134
+ abort: {
135
+ kind: "boolean",
136
+ description: "Restore and remove the open Keiyaku-owned renew recovery session.",
137
+ },
122
138
  shell: {
123
139
  kind: "value",
124
140
  placeholder: "SHELL",
package/build/cli/help.js CHANGED
@@ -1,11 +1,5 @@
1
- import { FlowError } from "../flow-error.js";
2
- import { allCommandMetadata, getCommandMetadata } from "./commands/registry.js";
3
- export function formatSubcommandList(subcommands) {
4
- return subcommands.length < 2 ? (subcommands[0] ?? "") : `${subcommands.slice(0, -1).join(", ")} or ${subcommands.at(-1)}`;
5
- }
6
- export function missingSubcommandError(name, subcommands) {
7
- return new FlowError("EMPTY_PARAM", `${name} requires subcommand: ${formatSubcommandList(subcommands)}`);
8
- }
1
+ import { CLI_COMMAND_METADATA, getCommandMetadata } from "./commands/metadata.js";
2
+ export { formatSubcommandList, missingSubcommandError } from "./missing-subcommand.js";
9
3
  function indent(lines) {
10
4
  return lines.map((line) => line ? ` ${line}` : "");
11
5
  }
@@ -21,15 +15,14 @@ function flagUsage(name, specs) {
21
15
  }
22
16
  return spec?.kind === "value" ? `--${name} ${spec.placeholder ?? "VALUE"}` : `--${name}`;
23
17
  }
24
- /** Metadata keyed by command; key order matches the historical CLI_COMMAND_METADATA object. */
25
- export const CLI_COMMAND_METADATA = Object.fromEntries(allCommandMetadata().map((meta) => [meta.command, meta]));
18
+ export { CLI_COMMAND_METADATA };
26
19
  export function renderCliCommandHelp(_command, spec, flagSpecs) {
27
20
  const lines = ["Keiyaku command help", "", `${spec.command} - ${spec.summary}`, ""];
28
21
  section(lines, "Usage:", spec.usage);
29
22
  section(lines, "Purpose:", [spec.purpose]);
30
23
  section(lines, "Subcommands:", spec.subcommands);
31
24
  section(lines, "Input:", spec.input);
32
- section(lines, "Options:", spec.flags.map((name) => `${flagUsage(name, flagSpecs)} ${flagSpecs[name]?.description ?? ""}`));
25
+ section(lines, "Options:", spec.flags.map((name) => `${flagUsage(name, flagSpecs)} ${spec.flagDescriptions?.[name] ?? flagSpecs[name]?.description ?? ""}`));
33
26
  section(lines, "Notes:", spec.notes);
34
27
  section(lines, "Examples:", spec.examples);
35
28
  return lines.join("\n").trimEnd();