@astrosheep/keiyaku 4.0.5 → 4.1.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 (166) hide show
  1. package/build/integrations/marketplace/plugins/keiyaku/.claude-plugin/plugin.json +1 -1
  2. package/build/integrations/marketplace/plugins/keiyaku/.codex-plugin/plugin.json +1 -1
  3. package/build/integrations/marketplace/plugins/keiyaku/package.json +1 -1
  4. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku/SKILL.md +1 -1
  5. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-akuma/SKILL.md +15 -7
  6. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-bind/SKILL.md +5 -3
  7. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-workflow/SKILL.md +10 -4
  8. package/build/src/akuma/akuma.d.ts +2 -0
  9. package/build/src/akuma/akuma.js +26 -3
  10. package/build/src/akuma/archetype.d.ts +3 -1
  11. package/build/src/akuma/archetype.js +19 -7
  12. package/build/src/akuma/body-turn.d.ts +64 -0
  13. package/build/src/akuma/body-turn.js +449 -0
  14. package/build/src/akuma/body.d.ts +3 -7
  15. package/build/src/akuma/body.js +9 -420
  16. package/build/src/akuma/heart/facts.d.ts +2 -0
  17. package/build/src/akuma/heart/facts.js +3 -1
  18. package/build/src/akuma/heart/index.js +12 -2
  19. package/build/src/akuma/heart/rows.js +4 -1
  20. package/build/src/akuma/heart/schema.d.ts +1 -1
  21. package/build/src/akuma/heart/schema.js +3 -2
  22. package/build/src/akuma/heart/timeline.d.ts +1 -0
  23. package/build/src/akuma/heart/timeline.js +19 -0
  24. package/build/src/akuma/nuke.d.ts +2 -0
  25. package/build/src/akuma/nuke.js +152 -0
  26. package/build/src/akuma/provider-recipe.d.ts +2 -0
  27. package/build/src/akuma/provider-recipe.js +10 -0
  28. package/build/src/akuma/provider.d.ts +3 -1
  29. package/build/src/akuma/providers/acp/config.d.ts +10 -0
  30. package/build/src/akuma/providers/acp/config.js +45 -0
  31. package/build/src/akuma/providers/acp/core.d.ts +5 -2
  32. package/build/src/akuma/providers/acp/core.js +35 -16
  33. package/build/src/akuma/providers/acp/index.d.ts +1 -8
  34. package/build/src/akuma/providers/acp/index.js +10 -39
  35. package/build/src/akuma/providers/claude/index.d.ts +1 -1
  36. package/build/src/akuma/providers/claude/index.js +14 -5
  37. package/build/src/akuma/providers/codex-app-server/index.js +9 -1
  38. package/build/src/akuma/providers/grok-build/index.js +16 -2
  39. package/build/src/akuma/providers/index.d.ts +3 -2
  40. package/build/src/akuma/providers/index.js +37 -37
  41. package/build/src/akuma/providers/opencode-sdk/index.js +9 -0
  42. package/build/src/akuma/providers/opencode-sdk/session.d.ts +1 -1
  43. package/build/src/akuma/providers/opencode-sdk/session.js +1 -1
  44. package/build/src/akuma/providers/pi/index.d.ts +1 -1
  45. package/build/src/akuma/providers/pi/index.js +30 -12
  46. package/build/src/akuma/request-serve.d.ts +1 -0
  47. package/build/src/akuma/request-serve.js +31 -31
  48. package/build/src/akuma/request-wire.d.ts +3 -2
  49. package/build/src/akuma/request-wire.js +5 -2
  50. package/build/src/akuma-body.js +15 -1
  51. package/build/src/alias/index.d.ts +1 -0
  52. package/build/src/alias/index.js +34 -1
  53. package/build/src/body/amend.js +0 -9
  54. package/build/src/body/region.js +2 -2
  55. package/build/src/cli/accepted.js +6 -0
  56. package/build/src/cli/commands/akuma-invoke.js +1 -0
  57. package/build/src/cli/commands/akuma.d.ts +1 -0
  58. package/build/src/cli/commands/akuma.js +11 -8
  59. package/build/src/cli/commands/contract.d.ts +28 -15
  60. package/build/src/cli/commands/contract.js +34 -18
  61. package/build/src/cli/commands/install.d.ts +2 -2
  62. package/build/src/cli/commands/install.js +6 -6
  63. package/build/src/cli/commands/nuke.d.ts +10 -0
  64. package/build/src/cli/commands/nuke.js +20 -0
  65. package/build/src/cli/commands/task-invoke.d.ts +19 -1
  66. package/build/src/cli/commands/task-invoke.js +63 -29
  67. package/build/src/cli/commands/task-query.d.ts +2 -2
  68. package/build/src/cli/commands/task-query.js +1 -2
  69. package/build/src/cli/commands/task.js +30 -22
  70. package/build/src/cli/coordinates.d.ts +5 -2
  71. package/build/src/cli/coordinates.js +5 -52
  72. package/build/src/cli/invoke.d.ts +5 -4
  73. package/build/src/cli/invoke.js +89 -59
  74. package/build/src/cli/main.d.ts +0 -2
  75. package/build/src/cli/main.js +4 -140
  76. package/build/src/cli/parse.d.ts +15 -2
  77. package/build/src/cli/parse.js +73 -8
  78. package/build/src/cli/render/akuma.js +95 -49
  79. package/build/src/cli/render/catalog.js +5 -1
  80. package/build/src/cli/render/contract.js +72 -49
  81. package/build/src/cli/render/kanshi.js +157 -99
  82. package/build/src/cli/render/nuke.d.ts +3 -0
  83. package/build/src/cli/render/nuke.js +8 -0
  84. package/build/src/cli/render/receipt.d.ts +1 -0
  85. package/build/src/cli/render/receipt.js +18 -14
  86. package/build/src/cli/render/refusal.d.ts +2 -1
  87. package/build/src/cli/render/refusal.js +37 -0
  88. package/build/src/cli/render/task.js +63 -11
  89. package/build/src/cli/render/text.js +6 -1
  90. package/build/src/cli/result.d.ts +28 -2
  91. package/build/src/cli/runtime.d.ts +2 -0
  92. package/build/src/cli/runtime.js +140 -0
  93. package/build/src/cli/usage.d.ts +0 -2
  94. package/build/src/cli/usage.js +0 -4
  95. package/build/src/contract-worktree.d.ts +26 -12
  96. package/build/src/contract-worktree.js +119 -64
  97. package/build/src/git/hooks.d.ts +2 -0
  98. package/build/src/git/hooks.js +34 -1
  99. package/build/src/git/integration.d.ts +4 -0
  100. package/build/src/git/integration.js +38 -0
  101. package/build/src/git/nuke.d.ts +2 -0
  102. package/build/src/git/nuke.js +92 -0
  103. package/build/src/git/process.d.ts +2 -0
  104. package/build/src/git/repository.js +4 -1
  105. package/build/src/git/target-placement.d.ts +2 -1
  106. package/build/src/git/target-placement.js +6 -7
  107. package/build/src/git/tender.d.ts +14 -2
  108. package/build/src/git/tender.js +45 -6
  109. package/build/src/git/workspace.d.ts +3 -0
  110. package/build/src/kanshi/read.js +37 -13
  111. package/build/src/kanshi/report.d.ts +2 -1
  112. package/build/src/library/akuma-creation.d.ts +1 -0
  113. package/build/src/library/akuma-creation.js +8 -1
  114. package/build/src/library/audit.d.ts +1 -0
  115. package/build/src/library/audit.js +1 -0
  116. package/build/src/library/continuation.d.ts +26 -0
  117. package/build/src/library/continuation.js +78 -0
  118. package/build/src/library/contract.d.ts +14 -8
  119. package/build/src/library/contract.js +82 -35
  120. package/build/src/library/delivery.d.ts +18 -11
  121. package/build/src/library/keiyaku.d.ts +5 -1
  122. package/build/src/library/keiyaku.js +2 -0
  123. package/build/src/library/mutation.d.ts +1 -0
  124. package/build/src/library/mutation.js +14 -4
  125. package/build/src/library/nuke.d.ts +14 -0
  126. package/build/src/library/nuke.js +54 -0
  127. package/build/src/library/reconcile.js +5 -2
  128. package/build/src/library/refusal.d.ts +10 -1
  129. package/build/src/library/repo.d.ts +1 -0
  130. package/build/src/library/repo.js +2 -0
  131. package/build/src/protocol/audit.js +12 -5
  132. package/build/src/protocol/completion.d.ts +11 -1
  133. package/build/src/protocol/completion.js +68 -15
  134. package/build/src/protocol/deliver.d.ts +25 -3
  135. package/build/src/protocol/deliver.js +148 -14
  136. package/build/src/protocol/intent.d.ts +1 -0
  137. package/build/src/protocol/intent.js +7 -1
  138. package/build/src/protocol/operations.d.ts +36 -4
  139. package/build/src/protocol/operations.js +2 -2
  140. package/build/src/protocol/placement.d.ts +9 -1
  141. package/build/src/protocol/placement.js +5 -4
  142. package/build/src/protocol/read/status.d.ts +16 -4
  143. package/build/src/protocol/read/status.js +54 -12
  144. package/build/src/protocol/review.d.ts +1 -0
  145. package/build/src/protocol/review.js +8 -0
  146. package/build/src/runtime/proc/run.js +9 -5
  147. package/build/src/settlement/settle.js +1 -2
  148. package/build/src/task/board.d.ts +21 -2
  149. package/build/src/task/board.js +25 -12
  150. package/build/src/task/compose.d.ts +1 -1
  151. package/build/src/task/compose.js +2 -7
  152. package/build/src/task/context.d.ts +14 -2
  153. package/build/src/task/context.js +30 -7
  154. package/build/src/task/identity.js +14 -4
  155. package/build/src/task/index.d.ts +7 -5
  156. package/build/src/task/index.js +21 -18
  157. package/build/src/task/mutation.d.ts +7 -2
  158. package/build/src/task/mutation.js +14 -6
  159. package/build/src/task/operations.d.ts +14 -7
  160. package/build/src/task/operations.js +37 -50
  161. package/build/src/task/query.js +2 -2
  162. package/build/src/task/store.d.ts +3 -0
  163. package/build/src/task/store.js +21 -2
  164. package/build/src/workspace-place.d.ts +2 -0
  165. package/build/src/workspace-place.js +27 -1
  166. package/package.json +1 -1
@@ -5,8 +5,8 @@ export type ContractCommandSpec = Readonly<{
5
5
  flags: Readonly<Record<string, ContractFlagKind>>;
6
6
  usage: string;
7
7
  purpose: string;
8
+ help?: string;
8
9
  }>;
9
- export declare const AMEND_MINIMAL_STDIN_HELP: string;
10
10
  export declare const CONTRACT_COMMAND_SPECS: {
11
11
  readonly bind: {
12
12
  readonly positional: "none";
@@ -20,7 +20,7 @@ export declare const CONTRACT_COMMAND_SPECS: {
20
20
  readonly gates: "raw-value";
21
21
  readonly json: "boolean";
22
22
  };
23
- readonly usage: "bind [--task <task/...>] [--target <ref>] [--here] [--after <kei/...> ...] [--gates <name,...>] [--actor <actor>] [--json] -";
23
+ readonly usage: "bind [--task <task/...>] [--target <ref>] [--here] [--after <kei/...> ...] [--gates <name,...>] [--actor <actor>] -";
24
24
  readonly purpose: "Create one Contract from stdin Markdown.";
25
25
  };
26
26
  readonly amend: {
@@ -33,8 +33,9 @@ export declare const CONTRACT_COMMAND_SPECS: {
33
33
  readonly gates: "raw-value";
34
34
  readonly json: "boolean";
35
35
  };
36
- readonly usage: "amend [<contract>|@<contract>] [--after <kei/...> ... | --clear-after] [--gates <name,...>] [--actor <actor>] [--json] [-]";
36
+ readonly usage: "amend [<contract>|@<contract>] [--after <kei/...> ... | --clear-after] [--gates <name,...>] [--actor <actor>] [-]";
37
37
  readonly purpose: "Amend one Contract's document operations or structured terms.";
38
+ readonly help: string;
38
39
  };
39
40
  readonly deliver: {
40
41
  readonly positional: "optional";
@@ -43,10 +44,12 @@ export declare const CONTRACT_COMMAND_SPECS: {
43
44
  readonly actor: "value";
44
45
  readonly message: "value";
45
46
  readonly "include-dirty": "boolean";
47
+ readonly "materialize-conflict": "boolean";
46
48
  readonly json: "boolean";
47
49
  };
48
- readonly usage: "deliver [<contract>|@<contract>] [--message <text>] [--include-dirty] [--actor <actor>] [--json]";
49
- readonly purpose: "Deliver one Contract candidate.";
50
+ readonly usage: "deliver [<contract>|@<contract>] [--message <text>] [--include-dirty] [--materialize-conflict] [--actor <actor>]";
51
+ readonly purpose: "Deliver one Contract candidate from the appointed worktree.";
52
+ readonly help: string;
50
53
  };
51
54
  readonly review: {
52
55
  readonly positional: "optional";
@@ -58,7 +61,7 @@ export declare const CONTRACT_COMMAND_SPECS: {
58
61
  readonly summary: "value";
59
62
  readonly json: "boolean";
60
63
  };
61
- readonly usage: "review [<contract>|@<contract>] (--satisfied | --unsatisfied) (--summary <text> | -) [--actor <actor>] [--json]";
64
+ readonly usage: "review [<contract>|@<contract>] (--satisfied | --unsatisfied) (--summary <text> | -) [--actor <actor>]";
62
65
  readonly purpose: "Record one review verdict.";
63
66
  };
64
67
  readonly arc: {
@@ -68,7 +71,7 @@ export declare const CONTRACT_COMMAND_SPECS: {
68
71
  readonly actor: "value";
69
72
  readonly json: "boolean";
70
73
  };
71
- readonly usage: "arc [<contract>|@<contract>] [--actor <actor>] [--json] -";
74
+ readonly usage: "arc [<contract>|@<contract>] [--actor <actor>] -";
72
75
  readonly purpose: "Record stdin arc Markdown for one Contract.";
73
76
  };
74
77
  readonly abandon: {
@@ -79,7 +82,7 @@ export declare const CONTRACT_COMMAND_SPECS: {
79
82
  readonly note: "value";
80
83
  readonly json: "boolean";
81
84
  };
82
- readonly usage: "abandon [<contract>|@<contract>] [--note <text>] [--actor <actor>] [--json]";
85
+ readonly usage: "abandon [<contract>|@<contract>] [--note <text>] [--actor <actor>]";
83
86
  readonly purpose: "Abandon one Contract with an optional note.";
84
87
  };
85
88
  readonly status: {
@@ -88,7 +91,7 @@ export declare const CONTRACT_COMMAND_SPECS: {
88
91
  readonly flags: {
89
92
  readonly json: "boolean";
90
93
  };
91
- readonly usage: "status [<contract>|@name|<aku/...>] [--json]";
94
+ readonly usage: "status [<contract>|@name|<aku/...>]";
92
95
  readonly purpose: "Read the world status board or one Contract projection.";
93
96
  };
94
97
  readonly show: {
@@ -97,7 +100,7 @@ export declare const CONTRACT_COMMAND_SPECS: {
97
100
  readonly flags: {
98
101
  readonly json: "boolean";
99
102
  };
100
- readonly usage: "show [<contract>|@<contract>] [--json]";
103
+ readonly usage: "show [<contract>|@<contract>]";
101
104
  readonly purpose: "Read one Contract guidance projection.";
102
105
  };
103
106
  readonly ls: {
@@ -106,7 +109,7 @@ export declare const CONTRACT_COMMAND_SPECS: {
106
109
  readonly flags: {
107
110
  readonly json: "boolean";
108
111
  };
109
- readonly usage: "ls task[/] [--json]\n keiyaku ls kei[/] [--json]\n keiyaku ls aku[/] [--json]\n keiyaku ls aku/<akuma>[/] [--json]\n keiyaku ls \"aku/*/*\" [--json]";
112
+ readonly usage: "ls task[/]\n keiyaku ls kei[/]\n keiyaku ls aku[/]\n keiyaku ls aku/<akuma>[/]\n keiyaku ls \"aku/*/*\"";
110
113
  readonly purpose: "List one identity directory.";
111
114
  };
112
115
  readonly audit: {
@@ -118,7 +121,7 @@ export declare const CONTRACT_COMMAND_SPECS: {
118
121
  readonly actor: "value";
119
122
  readonly json: "boolean";
120
123
  };
121
- readonly usage: "audit [<contract>|@<contract>] [--include-dirty] [--diff] [--actor <actor>] [--json]";
124
+ readonly usage: "audit [<contract>|@<contract>] [--include-dirty] [--diff] [--actor <actor>]";
122
125
  readonly purpose: "Ask what candidate preparation, Verification, and target placement would do.";
123
126
  };
124
127
  readonly reconcile: {
@@ -128,16 +131,26 @@ export declare const CONTRACT_COMMAND_SPECS: {
128
131
  readonly "retry-hooks": "boolean";
129
132
  readonly json: "boolean";
130
133
  };
131
- readonly usage: "reconcile [<contract>|@<contract>] [--retry-hooks] [--json]";
134
+ readonly usage: "reconcile [<contract>|@<contract>] [--retry-hooks]";
132
135
  readonly purpose: "Reconcile one Contract or the invocation world.";
133
136
  };
137
+ readonly nuke: {
138
+ readonly positional: "none";
139
+ readonly stdin: "none";
140
+ readonly flags: {
141
+ readonly confirm: "value";
142
+ readonly json: "boolean";
143
+ };
144
+ readonly usage: "nuke [--confirm <WorldRoot>] [--json]";
145
+ readonly purpose: "Remove Keiyaku-owned data from one confirmed World.";
146
+ };
134
147
  readonly settings: {
135
148
  readonly positional: "none";
136
149
  readonly stdin: "none";
137
150
  readonly flags: {
138
151
  readonly json: "boolean";
139
152
  };
140
- readonly usage: "settings [--json]";
153
+ readonly usage: "settings";
141
154
  readonly purpose: "Read user and project Settings resources.";
142
155
  };
143
156
  readonly region: {
@@ -148,7 +161,7 @@ export declare const CONTRACT_COMMAND_SPECS: {
148
161
  readonly path: "value";
149
162
  readonly json: "boolean";
150
163
  };
151
- readonly usage: "region [<contract>] [--overlap] [--json]\n region --path <repo-relative-path> [--json]";
164
+ readonly usage: "region [<contract>] [--overlap]\n region --path <repo-relative-path>";
152
165
  readonly purpose: "Read active declared Contract Regions.";
153
166
  };
154
167
  };
@@ -1,20 +1,36 @@
1
- export const AMEND_MINIMAL_STDIN_HELP = [
2
- "minimal stdin:",
3
- " ## Replace: Design",
4
- " <complete replacement>",
5
- ].join("\n");
6
1
  export const CONTRACT_COMMAND_SPECS = {
7
- bind: { positional: "none", stdin: "required", flags: { actor: "value", task: "value", target: "value", here: "boolean", after: "repeat-value", gates: "raw-value", json: "boolean" }, usage: "bind [--task <task/...>] [--target <ref>] [--here] [--after <kei/...> ...] [--gates <name,...>] [--actor <actor>] [--json] -", purpose: "Create one Contract from stdin Markdown." },
8
- amend: { positional: "optional", stdin: "optional", flags: { actor: "value", after: "repeat-value", "clear-after": "boolean", gates: "raw-value", json: "boolean" }, usage: "amend [<contract>|@<contract>] [--after <kei/...> ... | --clear-after] [--gates <name,...>] [--actor <actor>] [--json] [-]", purpose: "Amend one Contract's document operations or structured terms." },
9
- deliver: { positional: "optional", stdin: "none", flags: { actor: "value", message: "value", "include-dirty": "boolean", json: "boolean" }, usage: "deliver [<contract>|@<contract>] [--message <text>] [--include-dirty] [--actor <actor>] [--json]", purpose: "Deliver one Contract candidate." },
10
- review: { positional: "optional", stdin: "optional", flags: { actor: "value", satisfied: "boolean", unsatisfied: "boolean", summary: "value", json: "boolean" }, usage: "review [<contract>|@<contract>] (--satisfied | --unsatisfied) (--summary <text> | -) [--actor <actor>] [--json]", purpose: "Record one review verdict." },
11
- arc: { positional: "optional", stdin: "required", flags: { actor: "value", json: "boolean" }, usage: "arc [<contract>|@<contract>] [--actor <actor>] [--json] -", purpose: "Record stdin arc Markdown for one Contract." },
12
- abandon: { positional: "optional", stdin: "none", flags: { actor: "value", note: "value", json: "boolean" }, usage: "abandon [<contract>|@<contract>] [--note <text>] [--actor <actor>] [--json]", purpose: "Abandon one Contract with an optional note." },
13
- status: { positional: "optional", stdin: "none", flags: { json: "boolean" }, usage: "status [<contract>|@name|<aku/...>] [--json]", purpose: "Read the world status board or one Contract projection." },
14
- show: { positional: "optional", stdin: "none", flags: { json: "boolean" }, usage: "show [<contract>|@<contract>] [--json]", purpose: "Read one Contract guidance projection." },
15
- ls: { positional: "optional", stdin: "none", flags: { json: "boolean" }, usage: "ls task[/] [--json]\n keiyaku ls kei[/] [--json]\n keiyaku ls aku[/] [--json]\n keiyaku ls aku/<akuma>[/] [--json]\n keiyaku ls \"aku/*/*\" [--json]", purpose: "List one identity directory." },
16
- audit: { positional: "optional", stdin: "none", flags: { "include-dirty": "boolean", diff: "boolean", actor: "value", json: "boolean" }, usage: "audit [<contract>|@<contract>] [--include-dirty] [--diff] [--actor <actor>] [--json]", purpose: "Ask what candidate preparation, Verification, and target placement would do." },
17
- reconcile: { positional: "optional", stdin: "none", flags: { "retry-hooks": "boolean", json: "boolean" }, usage: "reconcile [<contract>|@<contract>] [--retry-hooks] [--json]", purpose: "Reconcile one Contract or the invocation world." },
18
- settings: { positional: "none", stdin: "none", flags: { json: "boolean" }, usage: "settings [--json]", purpose: "Read user and project Settings resources." },
19
- region: { positional: "optional", stdin: "none", flags: { overlap: "boolean", path: "value", json: "boolean" }, usage: "region [<contract>] [--overlap] [--json]\n region --path <repo-relative-path> [--json]", purpose: "Read active declared Contract Regions." },
2
+ bind: { positional: "none", stdin: "required", flags: { actor: "value", task: "value", target: "value", here: "boolean", after: "repeat-value", gates: "raw-value", json: "boolean" }, usage: "bind [--task <task/...>] [--target <ref>] [--here] [--after <kei/...> ...] [--gates <name,...>] [--actor <actor>] -", purpose: "Create one Contract from stdin Markdown." },
3
+ amend: {
4
+ positional: "optional", stdin: "optional", flags: { actor: "value", after: "repeat-value", "clear-after": "boolean", gates: "raw-value", json: "boolean" }, usage: "amend [<contract>|@<contract>] [--after <kei/...> ... | --clear-after] [--gates <name,...>] [--actor <actor>] [-]", purpose: "Amend one Contract's document operations or structured terms.",
5
+ help: [
6
+ " ## Replace: Context|Objective|Design|Region|Criteria|Verification|<extension>",
7
+ " ## Append: Context|Objective|Design|Criteria|<extension>",
8
+ " ## Add: Criteria|<new-extension-title>",
9
+ " ## Update: <existing-extension-title>",
10
+ " ## Remove: Criterion <existing-title>",
11
+ " ## Remove: <existing-extension-title>",
12
+ ].join("\n"),
13
+ },
14
+ deliver: {
15
+ positional: "optional", stdin: "none", flags: { actor: "value", message: "value", "include-dirty": "boolean", "materialize-conflict": "boolean", json: "boolean" }, usage: "deliver [<contract>|@<contract>] [--message <text>] [--include-dirty] [--materialize-conflict] [--actor <actor>]", purpose: "Deliver one Contract candidate from the appointed worktree.",
16
+ help: [
17
+ " --include-dirty Capture the complete non-ignored worktree tree as the",
18
+ " candidate; stages nothing, commits nothing. Refused",
19
+ " while unmerged paths exist.",
20
+ " --materialize-conflict After a conflict result, project the judged targetHead",
21
+ " into the worktree as an uncommitted merge. Not a",
22
+ " delivery: resolve, stage, deliver again.",
23
+ ].join("\n"),
24
+ },
25
+ review: { positional: "optional", stdin: "optional", flags: { actor: "value", satisfied: "boolean", unsatisfied: "boolean", summary: "value", json: "boolean" }, usage: "review [<contract>|@<contract>] (--satisfied | --unsatisfied) (--summary <text> | -) [--actor <actor>]", purpose: "Record one review verdict." },
26
+ arc: { positional: "optional", stdin: "required", flags: { actor: "value", json: "boolean" }, usage: "arc [<contract>|@<contract>] [--actor <actor>] -", purpose: "Record stdin arc Markdown for one Contract." },
27
+ abandon: { positional: "optional", stdin: "none", flags: { actor: "value", note: "value", json: "boolean" }, usage: "abandon [<contract>|@<contract>] [--note <text>] [--actor <actor>]", purpose: "Abandon one Contract with an optional note." },
28
+ status: { positional: "optional", stdin: "none", flags: { json: "boolean" }, usage: "status [<contract>|@name|<aku/...>]", purpose: "Read the world status board or one Contract projection." },
29
+ show: { positional: "optional", stdin: "none", flags: { json: "boolean" }, usage: "show [<contract>|@<contract>]", purpose: "Read one Contract guidance projection." },
30
+ ls: { positional: "optional", stdin: "none", flags: { json: "boolean" }, usage: "ls task[/]\n keiyaku ls kei[/]\n keiyaku ls aku[/]\n keiyaku ls aku/<akuma>[/]\n keiyaku ls \"aku/*/*\"", purpose: "List one identity directory." },
31
+ audit: { positional: "optional", stdin: "none", flags: { "include-dirty": "boolean", diff: "boolean", actor: "value", json: "boolean" }, usage: "audit [<contract>|@<contract>] [--include-dirty] [--diff] [--actor <actor>]", purpose: "Ask what candidate preparation, Verification, and target placement would do." },
32
+ reconcile: { positional: "optional", stdin: "none", flags: { "retry-hooks": "boolean", json: "boolean" }, usage: "reconcile [<contract>|@<contract>] [--retry-hooks]", purpose: "Reconcile one Contract or the invocation world." },
33
+ nuke: { positional: "none", stdin: "none", flags: { confirm: "value", json: "boolean" }, usage: "nuke [--confirm <WorldRoot>] [--json]", purpose: "Remove Keiyaku-owned data from one confirmed World." },
34
+ settings: { positional: "none", stdin: "none", flags: { json: "boolean" }, usage: "settings", purpose: "Read user and project Settings resources." },
35
+ region: { positional: "optional", stdin: "none", flags: { overlap: "boolean", path: "value", json: "boolean" }, usage: "region [<contract>] [--overlap]\n region --path <repo-relative-path>", purpose: "Read active declared Contract Regions." },
20
36
  };
@@ -1,4 +1,4 @@
1
- import { type ProcessInput, type ProcessOutcome } from "../../runtime/proc/run.js";
1
+ import type { ProcessInput, ProcessOutcome } from "../../runtime/proc/run.js";
2
2
  export declare const HARNESS_NAMES: readonly ["codex", "claude", "opencode", "pi"];
3
3
  export type HarnessName = typeof HARNESS_NAMES[number];
4
4
  export type ParsedInstallCommand = Readonly<{
@@ -16,7 +16,7 @@ export type InstallInvocationResult = Readonly<{
16
16
  results: readonly HarnessInstallResult[];
17
17
  }>;
18
18
  export type InstallRunner = (input: ProcessInput) => Promise<ProcessOutcome>;
19
- export declare const INSTALL_USAGE = "install <codex|claude|opencode|pi> [--json]\n install --all [--json]";
19
+ export declare const INSTALL_USAGE = "install <codex|claude|opencode|pi>\n install --all";
20
20
  export declare function parseInstallCommand(argv: readonly string[]): ParsedInstallCommand;
21
21
  export declare function renderInstallHelp(): string;
22
22
  export declare function installAssetsRoot(): string;
@@ -1,9 +1,8 @@
1
1
  import { dirname, resolve } from "node:path";
2
2
  import { fileURLToPath } from "node:url";
3
- import { runCrossPlatformProcess } from "../../runtime/proc/run.js";
4
- import { CliUsageError, usageLine, withJsonAutomationHelp } from "../usage.js";
3
+ import { CliUsageError, usageLine } from "../usage.js";
5
4
  export const HARNESS_NAMES = ["codex", "claude", "opencode", "pi"];
6
- export const INSTALL_USAGE = "install <codex|claude|opencode|pi> [--json]\n install --all [--json]";
5
+ export const INSTALL_USAGE = "install <codex|claude|opencode|pi>\n install --all";
7
6
  function isHarness(value) {
8
7
  return value !== undefined && HARNESS_NAMES.includes(value);
9
8
  }
@@ -43,7 +42,7 @@ export function parseInstallCommand(argv) {
43
42
  };
44
43
  }
45
44
  export function renderInstallHelp() {
46
- return withJsonAutomationHelp(`Install the Keiyaku skills into one or more agent harnesses.\n\n${usageLine(INSTALL_USAGE)}`);
45
+ return `Install the Keiyaku skills into one or more agent harnesses.\n\n${usageLine(INSTALL_USAGE)}`;
47
46
  }
48
47
  const INSTALL_TIMEOUT_MS = 5 * 60 * 1000;
49
48
  const ASSET_ROOT = resolve(dirname(fileURLToPath(import.meta.url)), "../../../integrations/marketplace");
@@ -80,12 +79,13 @@ function diagnostic(argv, outcome) {
80
79
  export function installAssetsRoot() {
81
80
  return ASSET_ROOT;
82
81
  }
83
- export async function installHarnesses(harnesses, environment, runner = runCrossPlatformProcess) {
82
+ export async function installHarnesses(harnesses, environment, runner) {
83
+ const run = runner ?? (await import("../../runtime/proc/run.js")).runCrossPlatformProcess;
84
84
  const results = [];
85
85
  for (const harness of harnesses) {
86
86
  let failure;
87
87
  for (const argv of recipes(harness)) {
88
- const detail = diagnostic(argv, await runner({ argv, env: environment, timeoutMs: INSTALL_TIMEOUT_MS }));
88
+ const detail = diagnostic(argv, await run({ argv, env: environment, timeoutMs: INSTALL_TIMEOUT_MS }));
89
89
  if (detail.length > 0) {
90
90
  failure = detail;
91
91
  break;
@@ -0,0 +1,10 @@
1
+ import { type NukeResult } from "../../index.js";
2
+ import type { WorldRoot } from "../../world.js";
3
+ import { type ParsedCommand } from "../parse.js";
4
+ import type { InvocationResult } from "../result.js";
5
+ export declare function invokeNuke(command: Extract<ParsedCommand, {
6
+ command: "nuke";
7
+ }>, world: WorldRoot | null): Promise<Readonly<{
8
+ kind: "nuke";
9
+ result: NukeResult;
10
+ }> | InvocationResult>;
@@ -0,0 +1,20 @@
1
+ import { Keiyaku, KeiyakuRefused } from "../../index.js";
2
+ import { CliUsageError } from "../parse.js";
3
+ export async function invokeNuke(command, world) {
4
+ if (world === null)
5
+ throw new CliUsageError("no Keiyaku world contains the invocation cwd");
6
+ try {
7
+ return {
8
+ kind: "nuke",
9
+ result: await Keiyaku.nuke({
10
+ world,
11
+ ...(command.confirm === undefined ? {} : { confirm: command.confirm }),
12
+ }),
13
+ };
14
+ }
15
+ catch (error) {
16
+ if (error instanceof KeiyakuRefused)
17
+ return { kind: "refused", verb: "nuke", refusal: error.refusal };
18
+ throw error;
19
+ }
20
+ }
@@ -1,7 +1,10 @@
1
1
  import { type BlockedTaskList, type TaskBatchResult, type TaskCompositionResult, type TaskDecompositionTree, type TaskDetail, type TaskDoctorReport, type TaskList, type TaskMutationResult, type TaskNamespaceResult, type TaskQueryResult, type TaskUpdateResult } from "../../task/index.js";
2
2
  import type { ParsedTaskCommand } from "./task.js";
3
3
  import type { WorldRoot } from "../../world.js";
4
- export type TaskInvocationResult = TaskMutationResult | TaskUpdateResult | TaskBatchResult | TaskCompositionResult | TaskDetail | TaskList | BlockedTaskList | TaskQueryResult | TaskDecompositionTree | TaskDoctorReport | TaskNamespaceResult | TaskWorldObservation;
4
+ export type TaskShowResult = TaskDetail | readonly TaskDetail[] | Extract<TaskMutationResult, {
5
+ kind: "refused";
6
+ }>;
7
+ export type TaskInvocationResult = TaskMutationResult | TaskUpdateResult | TaskBatchResult | TaskCompositionResult | TaskShowResult | TaskList | BlockedTaskList | TaskQueryResult | TaskDecompositionTree | TaskDoctorReport | TaskNamespaceResult | TaskWorldObservation;
5
8
  type TaskWorldRead = TaskList | BlockedTaskList | TaskQueryResult | TaskDoctorReport;
6
9
  export type TaskWorldObservation = Readonly<{
7
10
  kind: "present";
@@ -16,9 +19,24 @@ export type TaskWorldObservation = Readonly<{
16
19
  }>;
17
20
  type TaskInput = Readonly<{
18
21
  world: WorldRoot | null;
22
+ context: Readonly<{
23
+ directory: string;
24
+ boundary: string;
25
+ }>;
19
26
  establish(): Promise<WorldRoot>;
20
27
  readStdin(): Promise<string>;
21
28
  actor?: string;
22
29
  }>;
30
+ export declare function invokeTaskFromEdge(input: Readonly<{
31
+ parsed: ParsedTaskCommand;
32
+ world: WorldRoot | null;
33
+ context: Readonly<{
34
+ directory: string;
35
+ boundary: string;
36
+ }>;
37
+ establish: () => Promise<WorldRoot>;
38
+ readStdin: () => Promise<string>;
39
+ actor: string | undefined;
40
+ }>): Promise<TaskInvocationResult>;
23
41
  export declare function invokeTask(command: ParsedTaskCommand, input: TaskInput): Promise<TaskInvocationResult>;
24
42
  export {};
@@ -1,6 +1,24 @@
1
- import { Tasks, } from "../../task/index.js";
1
+ import { Tasks, observeTaskDetails, } from "../../task/index.js";
2
2
  import { injectedBodyRequests, requestBodyTask } from "../../akuma/requests.js";
3
3
  import { decodeTaskMutationRequest } from "../../task/mutation.js";
4
+ import { resolveTaskNamespaceContext, writeTaskNamespaceContext } from "../../task/context.js";
5
+ import { CliUsageError } from "../usage.js";
6
+ export async function invokeTaskFromEdge(input) {
7
+ try {
8
+ return await invokeTask(input.parsed, {
9
+ world: input.world,
10
+ context: input.context,
11
+ establish: input.establish,
12
+ readStdin: input.readStdin,
13
+ ...(input.actor === undefined ? {} : { actor: input.actor }),
14
+ });
15
+ }
16
+ catch (error) {
17
+ if (error instanceof TypeError)
18
+ throw new CliUsageError(error.message);
19
+ throw error;
20
+ }
21
+ }
4
22
  function value(command, name) {
5
23
  const item = command.flags[name];
6
24
  return typeof item === "string" ? item : undefined;
@@ -19,8 +37,8 @@ function priority(raw) {
19
37
  function state(raw) { return raw; }
20
38
  function ids(items) { return items; }
21
39
  function limit(command) { const raw = value(command, "limit"); return raw === undefined ? undefined : Number(raw); }
22
- async function invokeAdd(tasks, command, input) {
23
- const selectedNamespace = namespace(value(command, "namespace"));
40
+ async function invokeAdd(tasks, command, input, current) {
41
+ const selectedNamespace = namespace(value(command, "namespace")) ?? current;
24
42
  const actor = input.actor;
25
43
  if (command.stdin === "document") {
26
44
  return tasks.addDocument({
@@ -56,19 +74,19 @@ async function invokeUpdate(tasks, command, readStdin) {
56
74
  ...(addRelates === undefined ? {} : { addRelates }), ...(dropRelates === undefined ? {} : { dropRelates }),
57
75
  });
58
76
  }
59
- async function addMutationRequest(command, input) {
60
- const selectedNamespace = namespace(value(command, "namespace"));
77
+ async function addMutationRequest(command, input, current) {
78
+ const selectedNamespace = namespace(value(command, "namespace")) ?? current;
61
79
  if (command.stdin === "document")
62
80
  return { action: "task.addDocument", input: {
63
81
  markdown: await input.readStdin(),
64
- ...(selectedNamespace === undefined ? {} : { namespace: selectedNamespace }),
82
+ namespace: selectedNamespace,
65
83
  } };
66
84
  const body = value(command, "body"), note = value(command, "note");
67
85
  const initialState = state(value(command, "state")), selectedPriority = priority(value(command, "priority"));
68
86
  const needs = ids(values(command, "needs")), parent = value(command, "parent");
69
87
  const supersedes = ids(values(command, "supersedes")), relates = ids(values(command, "relates"));
70
88
  return { action: "task.add", input: {
71
- title: command.positionals[0], ...(selectedNamespace === undefined ? {} : { namespace: selectedNamespace }),
89
+ title: command.positionals[0], namespace: selectedNamespace,
72
90
  ...(body === undefined ? {} : { body }), ...(note === undefined ? {} : { note }),
73
91
  ...(initialState === undefined ? {} : { state: initialState }),
74
92
  ...(selectedPriority === undefined ? {} : { priority: selectedPriority }),
@@ -109,11 +127,11 @@ function lifecycleMutationRequest(command) {
109
127
  default: throw new Error(`task action cannot forward: ${command.action}`);
110
128
  }
111
129
  }
112
- async function mutationRequest(command, input) {
130
+ async function mutationRequest(command, input, current) {
113
131
  if (command.action === "add")
114
- return await addMutationRequest(command, input);
132
+ return await addMutationRequest(command, input, current);
115
133
  if (command.action === "compose")
116
- return { action: "task.compose", markdown: await input.readStdin() };
134
+ return { action: "task.compose", markdown: await input.readStdin(), namespace: current };
117
135
  if (command.action === "update")
118
136
  return await updateMutationRequest(command, input);
119
137
  return lifecycleMutationRequest(command);
@@ -122,7 +140,7 @@ function validatedMutationRequest(request) {
122
140
  switch (request.action) {
123
141
  case "task.add":
124
142
  case "task.addDocument": return decodeTaskMutationRequest(request.action, { input: request.input });
125
- case "task.compose": return decodeTaskMutationRequest(request.action, { markdown: request.markdown });
143
+ case "task.compose": return decodeTaskMutationRequest(request.action, { markdown: request.markdown, namespace: request.namespace });
126
144
  case "task.update": return decodeTaskMutationRequest(request.action, { id: request.id, input: request.input });
127
145
  case "task.start":
128
146
  case "task.stop":
@@ -132,17 +150,23 @@ function validatedMutationRequest(request) {
132
150
  case "task.drop": return decodeTaskMutationRequest(request.action, { ids: request.ids, ...(request.note === undefined ? {} : { note: request.note }) });
133
151
  }
134
152
  }
135
- async function invokeRead(tasks, command) {
153
+ function readScope(command, current) {
154
+ return command.flags.world === true ? { scope: "world" } : { namespace: current ?? [] };
155
+ }
156
+ async function invokeRead(tasks, command, current) {
136
157
  const id = command.positionals[0];
137
158
  switch (command.action) {
138
159
  case "show": {
139
- const detail = await tasks.task({ id }).read();
140
- return detail ?? { kind: "refused", refusal: { kind: "task-missing", taskId: id } };
160
+ const ids = command.positionals.map((taskId) => tasks.task({ id: taskId }).id);
161
+ const observed = await observeTaskDetails(tasks.root, ids);
162
+ if (observed.kind !== "accepted")
163
+ return observed;
164
+ return command.output === "json" || observed.value.length > 1 ? observed.value : observed.value[0];
141
165
  }
142
- case "ls": return tasks.list({ selection: command.flags.all === true ? "all" : command.flags.closed === true ? "closed" : "active", ...(command.flags.world === true ? { scope: "world" } : {}), ...(limit(command) === undefined ? {} : { limit: limit(command) }) });
143
- case "ready": return tasks.ready({ ...(command.flags.world === true ? { scope: "world" } : {}), ...(value(command, "parent") === undefined ? {} : { parent: value(command, "parent") }), ...(limit(command) === undefined ? {} : { limit: limit(command) }) });
144
- case "blocked": return tasks.blocked({ ...(command.flags.world === true ? { scope: "world" } : {}), ...(value(command, "parent") === undefined ? {} : { parent: value(command, "parent") }), ...(limit(command) === undefined ? {} : { limit: limit(command) }) });
145
- case "query": return tasks.query({ ...(command.where === undefined ? {} : { where: command.where }), ...(command.flags.world === true ? { scope: "world" } : {}), ...(value(command, "sort") === undefined ? {} : { sort: value(command, "sort") }), ...(limit(command) === undefined ? {} : { limit: limit(command) }) });
166
+ case "ls": return tasks.list({ selection: command.flags.all === true ? "all" : command.flags.closed === true ? "closed" : "active", ...readScope(command, current), ...(limit(command) === undefined ? {} : { limit: limit(command) }) });
167
+ case "ready": return tasks.ready({ ...readScope(command, current), ...(value(command, "parent") === undefined ? {} : { parent: value(command, "parent") }), ...(limit(command) === undefined ? {} : { limit: limit(command) }) });
168
+ case "blocked": return tasks.blocked({ ...readScope(command, current), ...(value(command, "parent") === undefined ? {} : { parent: value(command, "parent") }), ...(limit(command) === undefined ? {} : { limit: limit(command) }) });
169
+ case "query": return tasks.query({ ...(command.where === undefined ? {} : { where: command.where }), ...readScope(command, current), ...(value(command, "sort") === undefined ? {} : { sort: value(command, "sort") }), ...(limit(command) === undefined ? {} : { limit: limit(command) }) });
146
170
  case "tree": return tasks.task({ id }).tree();
147
171
  case "doctor": return tasks.doctor();
148
172
  default: throw new Error(`task action is not a read: ${command.action}`);
@@ -153,9 +177,9 @@ function isWorldObservation(command) {
153
177
  || command.action === "query" || command.action === "doctor";
154
178
  }
155
179
  function diagnostic(error) { return error instanceof Error ? error.message : String(error); }
156
- async function observeWorldRead(tasks, command) {
180
+ async function observeWorldRead(tasks, command, current) {
157
181
  try {
158
- return { kind: "present", value: await invokeRead(tasks, command) };
182
+ return { kind: "present", value: await invokeRead(tasks, command, current) };
159
183
  }
160
184
  catch (error) {
161
185
  return { kind: "failed", failure: { message: diagnostic(error) } };
@@ -175,13 +199,13 @@ function missingWorld(command) {
175
199
  }
176
200
  return missing(command.positionals[0]);
177
201
  }
178
- async function invokeLocalMutation(tasks, command, input) {
202
+ async function invokeLocalMutation(tasks, command, input, current) {
179
203
  if (isWorldObservation(command))
180
- return observeWorldRead(tasks, command);
204
+ return observeWorldRead(tasks, command, current);
181
205
  if (command.action === "show" || command.action === "tree")
182
- return invokeRead(tasks, command);
206
+ return invokeRead(tasks, command, current);
183
207
  if (command.action === "add")
184
- return await invokeAdd(tasks, command, input);
208
+ return await invokeAdd(tasks, command, input, current ?? []);
185
209
  if (command.action === "update")
186
210
  return await invokeUpdate(tasks, command, input.readStdin);
187
211
  const id = command.positionals[0];
@@ -201,10 +225,10 @@ async function invokeLocalMutation(tasks, command, input) {
201
225
  case "namespace": {
202
226
  const selected = namespace(command.positionals[0]);
203
227
  if (selected !== undefined)
204
- await tasks.setNamespace({ namespace: selected });
205
- return tasks.namespace();
228
+ await writeTaskNamespaceContext(input.context.directory, selected);
229
+ return { kind: "accepted", value: selected ?? current ?? [] };
206
230
  }
207
- case "compose": return tasks.compose({ markdown: await input.readStdin(), ...(input.actor === undefined ? {} : { actor: input.actor }) });
231
+ case "compose": return tasks.compose({ markdown: await input.readStdin(), namespace: current ?? [], ...(input.actor === undefined ? {} : { actor: input.actor }) });
208
232
  default: throw new Error(`task action has no invocation: ${command.action}`);
209
233
  }
210
234
  }
@@ -220,10 +244,20 @@ export async function invokeTask(command, input) {
220
244
  const world = input.world ?? (establishesWorld(command) ? await input.establish() : null);
221
245
  if (world === null)
222
246
  return missingWorld(command);
247
+ const tasks = Tasks.of(world);
248
+ const contextSensitive = command.action === "namespace" || command.action === "add" || command.action === "compose"
249
+ || ((command.action === "ls" || command.action === "ready" || command.action === "blocked" || command.action === "query") && command.flags.world !== true);
250
+ let current;
251
+ if (contextSensitive) {
252
+ const resolved = await resolveTaskNamespaceContext(input.context);
253
+ if (typeof resolved === "object" && "kind" in resolved)
254
+ return { kind: "refused", refusal: resolved };
255
+ current = resolved;
256
+ }
223
257
  const requests = injectedBodyRequests();
224
258
  if (requests !== null && forwardsMutation(command)) {
225
- const request = validatedMutationRequest(await mutationRequest(command, input));
259
+ const request = validatedMutationRequest(await mutationRequest(command, input, current ?? []));
226
260
  return await requestBodyTask({ directory: requests, world, request });
227
261
  }
228
- return await invokeLocalMutation(Tasks.of(world), command, input);
262
+ return await invokeLocalMutation(tasks, command, input, current);
229
263
  }
@@ -1,5 +1,5 @@
1
- import { type TaskQueryExpression } from "../../task/index.js";
2
- export type { TaskQueryExpression } from "../../task/index.js";
1
+ import { type TaskQueryExpression } from "../../task/query.js";
2
+ export type { TaskQueryExpression } from "../../task/query.js";
3
3
  export declare function parseTaskQueryExpression(source: string): TaskQueryExpression;
4
4
  export declare function validateTaskLimit(source: string): void;
5
5
  export declare function validateTaskParent(source: string): void;
@@ -1,5 +1,4 @@
1
- import { TASK_RELATION_PREDICATE_FIELDS, } from "../../task/index.js";
2
- import { MAX_TASK_LIMIT, normalizeTaskQuery } from "../../task/query.js";
1
+ import { MAX_TASK_LIMIT, TASK_RELATION_PREDICATE_FIELDS, normalizeTaskQuery, } from "../../task/query.js";
3
2
  function syntax(message, offset) { throw new Error(`${message} at column ${offset + 1}`); }
4
3
  function scanString(source, offset) {
5
4
  let index = offset + 1;
@@ -1,4 +1,4 @@
1
- import { CliUsageError, isBlankInput, usageLine, withJsonAutomationHelp } from "../usage.js";
1
+ import { CliUsageError, isBlankInput, usageLine } from "../usage.js";
2
2
  import { parseTaskQueryExpression, validateTaskLimit, validateTaskParent, } from "./task-query.js";
3
3
  const COMMON = { json: "boolean" };
4
4
  const TASK_COMMAND_SPECS = {
@@ -9,18 +9,18 @@ const TASK_COMMAND_SPECS = {
9
9
  [--note <text>] [--actor <actor>]
10
10
  [--needs <TaskId>]... [--parent <TaskId>]
11
11
  [--supersedes <TaskId>]... [--relates <TaskId>]...
12
- [--body <text>] [--json]
13
- task add [--namespace <ns>] [--actor <actor>] [--json] -`,
12
+ [--body <text>]
13
+ task add [--namespace <ns>] [--actor <actor>] -`,
14
14
  purpose: "Create one Task from flags or a canonical stdin document.",
15
15
  },
16
- show: { arity: [1, 1], flags: COMMON, usage: "task show <TaskId> [--json]", purpose: "Read one Task and its relationships." },
17
- ls: { arity: [0, 0], flags: { ...COMMON, closed: "boolean", all: "boolean", world: "boolean", limit: "value" }, usage: "task ls [--closed | --all] [--world] [--limit <n>] [--json]", purpose: "List Tasks in the selected scope." },
18
- ready: { arity: [0, 0], flags: { ...COMMON, world: "boolean", parent: "value", limit: "value" }, usage: "task ready [--world] [--parent <TaskId>] [--limit <n>] [--json]", purpose: "List open Tasks whose every need is terminal." },
19
- blocked: { arity: [0, 0], flags: { ...COMMON, world: "boolean", parent: "value", limit: "value" }, usage: "task blocked [--world] [--parent <TaskId>] [--limit <n>] [--json]", purpose: "List Tasks blocked by dependencies." },
16
+ show: { arity: [1, Number.POSITIVE_INFINITY], flags: COMMON, usage: "task show <TaskId>...", purpose: "Read one or more Tasks and their relationships." },
17
+ ls: { arity: [0, 0], flags: { ...COMMON, closed: "boolean", all: "boolean", world: "boolean", limit: "value" }, usage: "task ls [--closed | --all] [--world] [--limit <n>]", purpose: "List Tasks in the selected scope." },
18
+ ready: { arity: [0, 0], flags: { ...COMMON, world: "boolean", parent: "value", limit: "value" }, usage: "task ready [--world] [--parent <TaskId>] [--limit <n>]", purpose: "List open Tasks whose every need is terminal." },
19
+ blocked: { arity: [0, 0], flags: { ...COMMON, world: "boolean", parent: "value", limit: "value" }, usage: "task blocked [--world] [--parent <TaskId>] [--limit <n>]", purpose: "List Tasks blocked by dependencies." },
20
20
  query: { arity: [0, 0], flags: { ...COMMON, where: "value", world: "boolean", sort: "value", limit: "value" }, usage: `task query [--where <expression>] [--world]
21
- [--sort priority|created|updated|id] [--limit <n>] [--json]`, purpose: "Query Task facts with a typed boolean expression." },
22
- tree: { arity: [1, 1], flags: COMMON, usage: "task tree <TaskId> [--json]", purpose: "Read one Task parent decomposition tree." },
23
- doctor: { arity: [0, 0], flags: COMMON, usage: "task doctor [--json]", purpose: "Inspect Task authority without repairing it." },
21
+ [--sort priority|created|updated|id] [--limit <n>]`, purpose: "Query Task facts with a typed boolean expression." },
22
+ tree: { arity: [1, 1], flags: COMMON, usage: "task tree <TaskId>", purpose: "Read one Task parent decomposition tree." },
23
+ doctor: { arity: [0, 0], flags: COMMON, usage: "task doctor", purpose: "Inspect Task authority without repairing it." },
24
24
  update: {
25
25
  arity: [1, 1], flags: { ...COMMON, title: "value", body: "value", append: "value", note: "value", priority: "value", needs: "repeat", "drop-needs": "repeat", parent: "value", "no-parent": "boolean", supersedes: "repeat", "drop-supersedes": "repeat", relates: "repeat", "drop-relates": "repeat" },
26
26
  usage: `task update <TaskId> [--title <text>] [--body <text>|- | --append <text>|-]
@@ -28,17 +28,17 @@ task add [--namespace <ns>] [--actor <actor>] [--json] -`,
28
28
  [--priority 0..3] [--needs <TaskId>]... [--drop-needs <TaskId>]...
29
29
  [--parent <TaskId> | --no-parent]
30
30
  [--supersedes <TaskId>]... [--drop-supersedes <TaskId>]...
31
- [--relates <TaskId>]... [--drop-relates <TaskId>]... [--json]`,
31
+ [--relates <TaskId>]... [--drop-relates <TaskId>]...`,
32
32
  purpose: "Apply one or more patches to a Task.",
33
33
  },
34
- start: { arity: [1, 1], flags: COMMON, usage: "task start <TaskId> [--json]", purpose: "Move one open Task into progress." },
35
- stop: { arity: [1, 1], flags: COMMON, usage: "task stop <TaskId> [--json]", purpose: "Return one in-progress Task to open." },
36
- hold: { arity: [1, Number.POSITIVE_INFINITY], flags: COMMON, usage: "task hold <TaskId>... [--json]", purpose: "Put one or more Tasks on hold." },
37
- resume: { arity: [1, 1], flags: COMMON, usage: "task resume <TaskId> [--json]", purpose: "Return one held Task to open." },
38
- done: { arity: [1, Number.POSITIVE_INFINITY], flags: { ...COMMON, note: "value" }, usage: "task done <TaskId>... [--note <text>] [--json]", purpose: "Mark one or more Tasks done." },
39
- drop: { arity: [1, Number.POSITIVE_INFINITY], flags: { ...COMMON, note: "value" }, usage: "task drop <TaskId>... [--note <text>] [--json]", purpose: "Drop one or more Tasks." },
40
- namespace: { arity: [0, 1], flags: COMMON, usage: "task namespace [<namespace>] [--json]", purpose: "Read or replace the current Task namespace." },
41
- compose: { arity: [0, 0], stdin: "compose", flags: { ...COMMON, actor: "value" }, usage: "task compose [--actor <actor>] [--json] -", purpose: "Admit Task documents independently; partial admission has no cross-file atomicity or rollback." },
34
+ start: { arity: [1, 1], flags: COMMON, usage: "task start <TaskId>", purpose: "Move one open Task into progress." },
35
+ stop: { arity: [1, 1], flags: COMMON, usage: "task stop <TaskId>", purpose: "Return one in-progress Task to open." },
36
+ hold: { arity: [1, Number.POSITIVE_INFINITY], flags: COMMON, usage: "task hold <TaskId>...", purpose: "Put one or more Tasks on hold." },
37
+ resume: { arity: [1, 1], flags: COMMON, usage: "task resume <TaskId>", purpose: "Return one held Task to open." },
38
+ done: { arity: [1, Number.POSITIVE_INFINITY], flags: { ...COMMON, note: "value" }, usage: "task done <TaskId>... [--note <text>]", purpose: "Mark one or more Tasks done." },
39
+ drop: { arity: [1, Number.POSITIVE_INFINITY], flags: { ...COMMON, note: "value" }, usage: "task drop <TaskId>... [--note <text>]", purpose: "Drop one or more Tasks." },
40
+ namespace: { arity: [0, 1], flags: COMMON, usage: "task namespace [<namespace>]", purpose: "Read or replace the current Task namespace." },
41
+ compose: { arity: [0, 0], stdin: "compose", flags: { ...COMMON, actor: "value" }, usage: "task compose [--actor <actor>] -", purpose: "Admit Task documents independently; partial admission has no cross-file atomicity or rollback." },
42
42
  };
43
43
  export function isTaskAction(value) {
44
44
  return value !== undefined && Object.hasOwn(TASK_COMMAND_SPECS, value);
@@ -46,14 +46,22 @@ export function isTaskAction(value) {
46
46
  export function renderTaskHelp(action) {
47
47
  if (action !== undefined) {
48
48
  const spec = TASK_COMMAND_SPECS[action];
49
- return withJsonAutomationHelp(`${spec.purpose}\n\n${usageLine(spec.usage)}`);
49
+ const queryGuide = action === "query" ? [
50
+ "",
51
+ "fields: state priority title id parent under needs blocks ready blocked created updated",
52
+ "operators: = != < > <= >= ~ and or not ( )",
53
+ "examples:",
54
+ " keiyaku task query --where 'priority <= 1 and ready' --world",
55
+ " keiyaku task query --where 'updated < 2026-08-06T00:00:00.000Z' --world",
56
+ ].join("\n") : "";
57
+ return `${spec.purpose}\n\n${usageLine(spec.usage)}${queryGuide}`;
50
58
  }
51
- return withJsonAutomationHelp([
59
+ return [
52
60
  "usage: keiyaku task <command> ...",
53
61
  "",
54
62
  "commands:",
55
63
  ...Object.values(TASK_COMMAND_SPECS).flatMap((spec) => spec.usage.split("\n").map((line) => ` ${line}`).concat(` ${spec.purpose}`)),
56
- ].join("\n"));
64
+ ].join("\n");
57
65
  }
58
66
  export function renderTaskUsage(action) {
59
67
  return usageLine(TASK_COMMAND_SPECS[action].usage);