@astrosheep/keiyaku 4.0.3 → 4.0.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 (238) 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 +4 -4
  5. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-akuma/SKILL.md +1 -1
  6. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-bind/SKILL.md +15 -1
  7. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-task/SKILL.md +3 -1
  8. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-workflow/SKILL.md +34 -13
  9. package/build/src/akuma/akuma.d.ts +34 -12
  10. package/build/src/akuma/akuma.js +118 -63
  11. package/build/src/akuma/allowed.d.ts +7 -0
  12. package/build/src/akuma/allowed.js +33 -0
  13. package/build/src/akuma/archetype.d.ts +7 -4
  14. package/build/src/akuma/archetype.js +15 -16
  15. package/build/src/akuma/body.d.ts +6 -1
  16. package/build/src/akuma/body.js +36 -27
  17. package/build/src/akuma/heart/facts.d.ts +82 -14
  18. package/build/src/akuma/heart/index.d.ts +5 -18
  19. package/build/src/akuma/heart/index.js +14 -84
  20. package/build/src/akuma/heart/request-authority.d.ts +12 -0
  21. package/build/src/akuma/heart/request-authority.js +119 -0
  22. package/build/src/akuma/heart/request-rows.d.ts +16 -0
  23. package/build/src/akuma/heart/request-rows.js +88 -0
  24. package/build/src/akuma/heart/rows.d.ts +1 -26
  25. package/build/src/akuma/heart/rows.js +0 -50
  26. package/build/src/akuma/heart/schema.d.ts +1 -1
  27. package/build/src/akuma/heart/schema.js +22 -10
  28. package/build/src/akuma/heart/soul.js +2 -36
  29. package/build/src/akuma/heart/storage.d.ts +1 -0
  30. package/build/src/akuma/heart/storage.js +15 -0
  31. package/build/src/akuma/heart/timeline.d.ts +1 -5
  32. package/build/src/akuma/heart/timeline.js +8 -17
  33. package/build/src/akuma/index.d.ts +5 -2
  34. package/build/src/akuma/index.js +1 -0
  35. package/build/src/akuma/projection.d.ts +17 -3
  36. package/build/src/akuma/projection.js +40 -3
  37. package/build/src/akuma/provider-recipe.js +1 -11
  38. package/build/src/akuma/provider.d.ts +2 -7
  39. package/build/src/akuma/provider.js +2 -1
  40. package/build/src/akuma/providers/acp/core.d.ts +3 -1
  41. package/build/src/akuma/providers/acp/core.js +10 -6
  42. package/build/src/akuma/providers/acp/events.d.ts +11 -3
  43. package/build/src/akuma/providers/acp/events.js +78 -4
  44. package/build/src/akuma/providers/acp/index.js +0 -1
  45. package/build/src/akuma/providers/claude/events.js +62 -3
  46. package/build/src/akuma/providers/claude/index.d.ts +0 -4
  47. package/build/src/akuma/providers/claude/index.js +7 -3
  48. package/build/src/akuma/providers/codex-app-server/events.js +1 -13
  49. package/build/src/akuma/providers/codex-app-server/index.d.ts +2 -27
  50. package/build/src/akuma/providers/codex-app-server/index.js +0 -2
  51. package/build/src/akuma/providers/grok-build/index.d.ts +2 -1
  52. package/build/src/akuma/providers/grok-build/index.js +72 -3
  53. package/build/src/akuma/providers/opencode-sdk/events.js +71 -6
  54. package/build/src/akuma/providers/opencode-sdk/index.d.ts +2 -28
  55. package/build/src/akuma/providers/opencode-sdk/index.js +8 -4
  56. package/build/src/akuma/providers/opencode-sdk/session.d.ts +1 -1
  57. package/build/src/akuma/providers/opencode-sdk/session.js +1 -1
  58. package/build/src/akuma/providers/pi/events.js +17 -3
  59. package/build/src/akuma/providers/pi/index.js +11 -4
  60. package/build/src/akuma/providers/unified-patch.d.ts +4 -0
  61. package/build/src/akuma/providers/unified-patch.js +14 -0
  62. package/build/src/akuma/publication.d.ts +1 -1
  63. package/build/src/akuma/publication.js +1 -1
  64. package/build/src/akuma/request-serve.d.ts +87 -0
  65. package/build/src/akuma/request-serve.js +484 -0
  66. package/build/src/akuma/request-wire.d.ts +124 -0
  67. package/build/src/akuma/request-wire.js +380 -0
  68. package/build/src/akuma/requests.d.ts +41 -41
  69. package/build/src/akuma/requests.js +75 -374
  70. package/build/src/akuma-body.d.ts +8 -0
  71. package/build/src/akuma-body.js +84 -0
  72. package/build/src/body/arc.js +4 -29
  73. package/build/src/body/decode.js +5 -39
  74. package/build/src/body/envelope.d.ts +7 -0
  75. package/build/src/body/envelope.js +37 -0
  76. package/build/src/cli/accepted.d.ts +4 -1
  77. package/build/src/cli/accepted.js +39 -9
  78. package/build/src/cli/commands/akuma-invoke.d.ts +8 -7
  79. package/build/src/cli/commands/akuma-invoke.js +18 -10
  80. package/build/src/cli/commands/akuma.d.ts +11 -2
  81. package/build/src/cli/commands/akuma.js +67 -28
  82. package/build/src/cli/commands/amend.d.ts +1 -1
  83. package/build/src/cli/commands/amend.js +1 -1
  84. package/build/src/cli/commands/contract.d.ts +8 -8
  85. package/build/src/cli/commands/contract.js +3 -3
  86. package/build/src/cli/commands/install.js +2 -2
  87. package/build/src/cli/commands/task-invoke.js +98 -9
  88. package/build/src/cli/commands/task-query.d.ts +1 -1
  89. package/build/src/cli/commands/task-query.js +11 -5
  90. package/build/src/cli/coordinates.d.ts +2 -0
  91. package/build/src/cli/coordinates.js +12 -5
  92. package/build/src/cli/invoke.d.ts +1 -0
  93. package/build/src/cli/invoke.js +116 -75
  94. package/build/src/cli/main.d.ts +2 -0
  95. package/build/src/cli/main.js +29 -4
  96. package/build/src/cli/parse.d.ts +3 -2
  97. package/build/src/cli/parse.js +25 -8
  98. package/build/src/cli/render/akuma.d.ts +2 -2
  99. package/build/src/cli/render/akuma.js +138 -24
  100. package/build/src/cli/render/audit.js +18 -8
  101. package/build/src/cli/render/contract.d.ts +2 -0
  102. package/build/src/cli/render/contract.js +243 -36
  103. package/build/src/cli/render/kanshi.js +64 -29
  104. package/build/src/cli/render/receipt.d.ts +2 -1
  105. package/build/src/cli/render/receipt.js +37 -2
  106. package/build/src/cli/render/terminal.d.ts +0 -2
  107. package/build/src/cli/render/terminal.js +0 -29
  108. package/build/src/cli/render/text.js +3 -1
  109. package/build/src/cli/result.d.ts +52 -9
  110. package/build/src/cli/selectors.d.ts +1 -0
  111. package/build/src/cli/selectors.js +9 -6
  112. package/build/src/contract-worktree.d.ts +1 -2
  113. package/build/src/contract-worktree.js +7 -9
  114. package/build/src/core/facts/codec.js +9 -0
  115. package/build/src/core/facts/fold.js +13 -1
  116. package/build/src/core/facts/types.d.ts +8 -1
  117. package/build/src/core/subject.js +4 -3
  118. package/build/src/core/verbs/placement.d.ts +9 -1
  119. package/build/src/core/verbs/placement.js +24 -6
  120. package/build/src/core/verbs/reintegrate.d.ts +13 -0
  121. package/build/src/core/verbs/reintegrate.js +24 -0
  122. package/build/src/dispatch/index.d.ts +1 -1
  123. package/build/src/dispatch/index.js +50 -39
  124. package/build/src/git/admission.d.ts +2 -1
  125. package/build/src/git/hooks.d.ts +0 -4
  126. package/build/src/git/hooks.js +0 -36
  127. package/build/src/git/integration.d.ts +7 -8
  128. package/build/src/git/integration.js +62 -9
  129. package/build/src/git/observe.d.ts +2 -1
  130. package/build/src/git/observe.js +6 -5
  131. package/build/src/git/process.d.ts +26 -0
  132. package/build/src/git/process.js +94 -0
  133. package/build/src/git/read-observation.d.ts +2 -1
  134. package/build/src/git/read-observation.js +3 -2
  135. package/build/src/git/reconcile.d.ts +8 -2
  136. package/build/src/git/reconcile.js +63 -14
  137. package/build/src/git/repository.d.ts +2 -29
  138. package/build/src/git/repository.js +4 -118
  139. package/build/src/git/scratch.d.ts +1 -1
  140. package/build/src/git/scratch.js +1 -1
  141. package/build/src/git/target-placement.d.ts +1 -1
  142. package/build/src/git/target-placement.js +9 -7
  143. package/build/src/git/tender.d.ts +20 -5
  144. package/build/src/git/tender.js +45 -13
  145. package/build/src/git/terminal-seal.d.ts +16 -2
  146. package/build/src/git/terminal-seal.js +15 -5
  147. package/build/src/git/workspace.d.ts +2 -1
  148. package/build/src/git/workspace.js +13 -5
  149. package/build/src/index.d.ts +1 -2
  150. package/build/src/index.js +1 -1
  151. package/build/src/kanshi/index.d.ts +1 -1
  152. package/build/src/kanshi/index.js +1 -1
  153. package/build/src/kanshi/read.d.ts +9 -1
  154. package/build/src/kanshi/read.js +91 -37
  155. package/build/src/kanshi/report.d.ts +1 -0
  156. package/build/src/library/address.d.ts +5 -14
  157. package/build/src/library/address.js +27 -23
  158. package/build/src/library/akuma-creation.d.ts +4 -2
  159. package/build/src/library/akuma-creation.js +43 -26
  160. package/build/src/library/audit.d.ts +2 -1
  161. package/build/src/library/audit.js +1 -1
  162. package/build/src/library/bind.d.ts +2 -1
  163. package/build/src/library/bind.js +4 -4
  164. package/build/src/library/catalog.d.ts +1 -2
  165. package/build/src/library/catalog.js +11 -6
  166. package/build/src/library/configuration.d.ts +5 -1
  167. package/build/src/library/configuration.js +71 -18
  168. package/build/src/library/contract.d.ts +70 -3
  169. package/build/src/library/contract.js +213 -27
  170. package/build/src/library/delivery.d.ts +1 -1
  171. package/build/src/library/fleet.d.ts +70 -12
  172. package/build/src/library/fleet.js +236 -56
  173. package/build/src/library/input.d.ts +0 -1
  174. package/build/src/library/input.js +1 -5
  175. package/build/src/library/keiyaku.d.ts +4 -4
  176. package/build/src/library/keiyaku.js +1 -2
  177. package/build/src/library/mutation.d.ts +2 -1
  178. package/build/src/library/reconcile.d.ts +2 -1
  179. package/build/src/library/reconcile.js +3 -1
  180. package/build/src/library/region.d.ts +1 -1
  181. package/build/src/library/repo.d.ts +3 -1
  182. package/build/src/library/repo.js +8 -4
  183. package/build/src/protocol/abandon.d.ts +9 -0
  184. package/build/src/protocol/abandon.js +15 -0
  185. package/build/src/protocol/amend.d.ts +16 -0
  186. package/build/src/protocol/amend.js +77 -0
  187. package/build/src/protocol/arc.d.ts +6 -0
  188. package/build/src/protocol/arc.js +12 -0
  189. package/build/src/protocol/attempt.d.ts +2 -1
  190. package/build/src/protocol/audit.d.ts +53 -0
  191. package/build/src/protocol/audit.js +140 -0
  192. package/build/src/protocol/bind.d.ts +2 -3
  193. package/build/src/protocol/bind.js +2 -16
  194. package/build/src/protocol/completion.d.ts +32 -0
  195. package/build/src/protocol/completion.js +130 -0
  196. package/build/src/protocol/deliver.d.ts +37 -0
  197. package/build/src/protocol/deliver.js +160 -0
  198. package/build/src/protocol/intent.d.ts +1 -1
  199. package/build/src/protocol/intent.js +1 -1
  200. package/build/src/protocol/operations.d.ts +65 -198
  201. package/build/src/protocol/operations.js +21 -634
  202. package/build/src/protocol/placement.d.ts +4 -13
  203. package/build/src/protocol/placement.js +3 -15
  204. package/build/src/protocol/read/status.d.ts +4 -2
  205. package/build/src/protocol/read/status.js +27 -15
  206. package/build/src/protocol/reconcile.d.ts +35 -0
  207. package/build/src/protocol/reconcile.js +41 -0
  208. package/build/src/protocol/reintegrate.d.ts +31 -0
  209. package/build/src/protocol/reintegrate.js +74 -0
  210. package/build/src/protocol/review.d.ts +33 -0
  211. package/build/src/protocol/review.js +148 -0
  212. package/build/src/protocol/run.d.ts +1 -1
  213. package/build/src/runtime/proc/run.d.ts +1 -0
  214. package/build/src/runtime/proc/run.js +9 -2
  215. package/build/src/settlement/fence.d.ts +1 -1
  216. package/build/src/settlement/holder.d.ts +1 -1
  217. package/build/src/settlement/settle.d.ts +2 -1
  218. package/build/src/settlement/settle.js +4 -1
  219. package/build/src/task/board.d.ts +18 -4
  220. package/build/src/task/board.js +73 -29
  221. package/build/src/task/compose.d.ts +1 -1
  222. package/build/src/task/compose.js +11 -4
  223. package/build/src/task/index.d.ts +4 -4
  224. package/build/src/task/index.js +8 -131
  225. package/build/src/task/input.d.ts +18 -0
  226. package/build/src/task/input.js +189 -0
  227. package/build/src/task/mutation.d.ts +39 -0
  228. package/build/src/task/mutation.js +85 -0
  229. package/build/src/task/operations.d.ts +4 -19
  230. package/build/src/task/operations.js +64 -18
  231. package/build/src/task/query.d.ts +9 -2
  232. package/build/src/task/query.js +32 -64
  233. package/build/src/task/store.js +0 -2
  234. package/build/src/verification/execution.d.ts +1 -1
  235. package/build/src/verification/execution.js +2 -1
  236. package/build/src/workspace-place.d.ts +1 -4
  237. package/build/src/workspace-place.js +0 -15
  238. package/package.json +5 -3
@@ -4,15 +4,15 @@ export const AMEND_MINIMAL_STDIN_HELP = [
4
4
  " <complete replacement>",
5
5
  ].join("\n");
6
6
  export const CONTRACT_COMMAND_SPECS = {
7
- bind: { positional: "none", stdin: "required", flags: { actor: "value", task: "value", target: "value", here: "boolean", after: "repeat-value", gates: "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: "required", flags: { actor: "value", after: "repeat-value", "clear-after": "boolean", gates: "value", json: "boolean" }, usage: "amend [<contract>|@<contract>] [--after <kei/...> ... | --clear-after] [--gates <name>] [--actor <actor>] [--json] -", purpose: "Apply stdin amendment operations to one Contract." },
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
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
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
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
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
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
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." },
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
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
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
18
  settings: { positional: "none", stdin: "none", flags: { json: "boolean" }, usage: "settings [--json]", purpose: "Read user and project Settings resources." },
@@ -1,6 +1,6 @@
1
1
  import { dirname, resolve } from "node:path";
2
2
  import { fileURLToPath } from "node:url";
3
- import { runProcess } from "../../runtime/proc/run.js";
3
+ import { runCrossPlatformProcess } from "../../runtime/proc/run.js";
4
4
  import { CliUsageError, usageLine, withJsonAutomationHelp } from "../usage.js";
5
5
  export const HARNESS_NAMES = ["codex", "claude", "opencode", "pi"];
6
6
  export const INSTALL_USAGE = "install <codex|claude|opencode|pi> [--json]\n install --all [--json]";
@@ -80,7 +80,7 @@ function diagnostic(argv, outcome) {
80
80
  export function installAssetsRoot() {
81
81
  return ASSET_ROOT;
82
82
  }
83
- export async function installHarnesses(harnesses, environment, runner = runProcess) {
83
+ export async function installHarnesses(harnesses, environment, runner = runCrossPlatformProcess) {
84
84
  const results = [];
85
85
  for (const harness of harnesses) {
86
86
  let failure;
@@ -1,4 +1,6 @@
1
1
  import { Tasks, } from "../../task/index.js";
2
+ import { injectedBodyRequests, requestBodyTask } from "../../akuma/requests.js";
3
+ import { decodeTaskMutationRequest } from "../../task/mutation.js";
2
4
  function value(command, name) {
3
5
  const item = command.flags[name];
4
6
  return typeof item === "string" ? item : undefined;
@@ -54,6 +56,82 @@ async function invokeUpdate(tasks, command, readStdin) {
54
56
  ...(addRelates === undefined ? {} : { addRelates }), ...(dropRelates === undefined ? {} : { dropRelates }),
55
57
  });
56
58
  }
59
+ async function addMutationRequest(command, input) {
60
+ const selectedNamespace = namespace(value(command, "namespace"));
61
+ if (command.stdin === "document")
62
+ return { action: "task.addDocument", input: {
63
+ markdown: await input.readStdin(),
64
+ ...(selectedNamespace === undefined ? {} : { namespace: selectedNamespace }),
65
+ } };
66
+ const body = value(command, "body"), note = value(command, "note");
67
+ const initialState = state(value(command, "state")), selectedPriority = priority(value(command, "priority"));
68
+ const needs = ids(values(command, "needs")), parent = value(command, "parent");
69
+ const supersedes = ids(values(command, "supersedes")), relates = ids(values(command, "relates"));
70
+ return { action: "task.add", input: {
71
+ title: command.positionals[0], ...(selectedNamespace === undefined ? {} : { namespace: selectedNamespace }),
72
+ ...(body === undefined ? {} : { body }), ...(note === undefined ? {} : { note }),
73
+ ...(initialState === undefined ? {} : { state: initialState }),
74
+ ...(selectedPriority === undefined ? {} : { priority: selectedPriority }),
75
+ ...(needs === undefined ? {} : { needs }), ...(parent === undefined ? {} : { parent: parent }),
76
+ ...(supersedes === undefined ? {} : { supersedes }), ...(relates === undefined ? {} : { relates }),
77
+ } };
78
+ }
79
+ async function updateMutationRequest(command, input) {
80
+ const body = command.stdin === "body" ? await input.readStdin() : value(command, "body");
81
+ const appendBody = command.stdin === "append" ? await input.readStdin() : value(command, "append");
82
+ const note = command.stdin === "note" ? await input.readStdin() : value(command, "note");
83
+ const title = value(command, "title"), selectedPriority = priority(value(command, "priority"));
84
+ const addNeeds = ids(values(command, "needs")), dropNeeds = ids(values(command, "drop-needs"));
85
+ const parent = value(command, "parent"), addSupersedes = ids(values(command, "supersedes"));
86
+ const dropSupersedes = ids(values(command, "drop-supersedes")), addRelates = ids(values(command, "relates"));
87
+ const dropRelates = ids(values(command, "drop-relates"));
88
+ return { action: "task.update", id: command.positionals[0], input: {
89
+ ...(title === undefined ? {} : { title }), ...(body === undefined ? {} : { body }),
90
+ ...(appendBody === undefined ? {} : { appendBody }), ...(note === undefined ? {} : { note }),
91
+ ...(selectedPriority === undefined ? {} : { priority: selectedPriority }),
92
+ ...(addNeeds === undefined ? {} : { addNeeds }), ...(dropNeeds === undefined ? {} : { dropNeeds }),
93
+ ...(command.flags["no-parent"] === true ? { parent: null }
94
+ : parent === undefined ? {} : { parent: parent }),
95
+ ...(addSupersedes === undefined ? {} : { addSupersedes }),
96
+ ...(dropSupersedes === undefined ? {} : { dropSupersedes }),
97
+ ...(addRelates === undefined ? {} : { addRelates }), ...(dropRelates === undefined ? {} : { dropRelates }),
98
+ } };
99
+ }
100
+ function lifecycleMutationRequest(command) {
101
+ const id = command.positionals[0];
102
+ switch (command.action) {
103
+ case "start": return { action: "task.start", id };
104
+ case "stop": return { action: "task.stop", id };
105
+ case "resume": return { action: "task.resume", id };
106
+ case "hold": return { action: "task.hold", ids: command.positionals };
107
+ case "done": return { action: "task.done", ids: command.positionals, ...(value(command, "note") === undefined ? {} : { note: value(command, "note") }) };
108
+ case "drop": return { action: "task.drop", ids: command.positionals, ...(value(command, "note") === undefined ? {} : { note: value(command, "note") }) };
109
+ default: throw new Error(`task action cannot forward: ${command.action}`);
110
+ }
111
+ }
112
+ async function mutationRequest(command, input) {
113
+ if (command.action === "add")
114
+ return await addMutationRequest(command, input);
115
+ if (command.action === "compose")
116
+ return { action: "task.compose", markdown: await input.readStdin() };
117
+ if (command.action === "update")
118
+ return await updateMutationRequest(command, input);
119
+ return lifecycleMutationRequest(command);
120
+ }
121
+ function validatedMutationRequest(request) {
122
+ switch (request.action) {
123
+ case "task.add":
124
+ case "task.addDocument": return decodeTaskMutationRequest(request.action, { input: request.input });
125
+ case "task.compose": return decodeTaskMutationRequest(request.action, { markdown: request.markdown });
126
+ case "task.update": return decodeTaskMutationRequest(request.action, { id: request.id, input: request.input });
127
+ case "task.start":
128
+ case "task.stop":
129
+ case "task.resume": return decodeTaskMutationRequest(request.action, { id: request.id });
130
+ case "task.hold": return decodeTaskMutationRequest(request.action, { ids: request.ids });
131
+ case "task.done":
132
+ case "task.drop": return decodeTaskMutationRequest(request.action, { ids: request.ids, ...(request.note === undefined ? {} : { note: request.note }) });
133
+ }
134
+ }
57
135
  async function invokeRead(tasks, command) {
58
136
  const id = command.positionals[0];
59
137
  switch (command.action) {
@@ -97,15 +175,7 @@ function missingWorld(command) {
97
175
  }
98
176
  return missing(command.positionals[0]);
99
177
  }
100
- export async function invokeTask(command, input) {
101
- let world = input.world;
102
- if (world === null && (command.action === "add" || command.action === "compose"
103
- || (command.action === "namespace" && command.positionals.length > 0))) {
104
- world = await input.establish();
105
- }
106
- if (world === null)
107
- return missingWorld(command);
108
- const tasks = Tasks.of(world);
178
+ async function invokeLocalMutation(tasks, command, input) {
109
179
  if (isWorldObservation(command))
110
180
  return observeWorldRead(tasks, command);
111
181
  if (command.action === "show" || command.action === "tree")
@@ -138,3 +208,22 @@ export async function invokeTask(command, input) {
138
208
  default: throw new Error(`task action has no invocation: ${command.action}`);
139
209
  }
140
210
  }
211
+ function establishesWorld(command) {
212
+ return command.action === "add" || command.action === "compose"
213
+ || (command.action === "namespace" && command.positionals.length > 0);
214
+ }
215
+ function forwardsMutation(command) {
216
+ return command.action !== "show" && command.action !== "tree"
217
+ && command.action !== "namespace" && !isWorldObservation(command);
218
+ }
219
+ export async function invokeTask(command, input) {
220
+ const world = input.world ?? (establishesWorld(command) ? await input.establish() : null);
221
+ if (world === null)
222
+ return missingWorld(command);
223
+ const requests = injectedBodyRequests();
224
+ if (requests !== null && forwardsMutation(command)) {
225
+ const request = validatedMutationRequest(await mutationRequest(command, input));
226
+ return await requestBodyTask({ directory: requests, world, request });
227
+ }
228
+ return await invokeLocalMutation(Tasks.of(world), command, input);
229
+ }
@@ -1,4 +1,4 @@
1
- import type { TaskQueryExpression } from "../../task/index.js";
1
+ import { type TaskQueryExpression } from "../../task/index.js";
2
2
  export type { TaskQueryExpression } from "../../task/index.js";
3
3
  export declare function parseTaskQueryExpression(source: string): TaskQueryExpression;
4
4
  export declare function validateTaskLimit(source: string): void;
@@ -1,3 +1,4 @@
1
+ import { TASK_RELATION_PREDICATE_FIELDS, } from "../../task/index.js";
1
2
  import { MAX_TASK_LIMIT, normalizeTaskQuery } from "../../task/query.js";
2
3
  function syntax(message, offset) { throw new Error(`${message} at column ${offset + 1}`); }
3
4
  function scanString(source, offset) {
@@ -133,7 +134,15 @@ function parseTextPredicate(field, operator, value) {
133
134
  return { field, operator: selected, value: value.value };
134
135
  }
135
136
  function parseRelationPredicate(field, operator, value) {
136
- return { field, operator: equalityOperator(operator, field), value: canonicalTaskId(value, field) };
137
+ const relationField = TASK_RELATION_PREDICATE_FIELDS.find((candidate) => candidate === field.value);
138
+ if (relationField === undefined) {
139
+ syntax(`unknown query field ${JSON.stringify(field.value)}`, field.offset);
140
+ }
141
+ return {
142
+ field: relationField,
143
+ operator: equalityOperator(operator, relationField),
144
+ value: canonicalTaskId(value, relationField),
145
+ };
137
146
  }
138
147
  function parseBooleanPredicate(field, operator, value) {
139
148
  return { field, operator: equalityOperator(operator, field), value: boolean(value) };
@@ -216,14 +225,11 @@ class Parser {
216
225
  operator: equalityOperator(operator, "parent"),
217
226
  value: value.value === "none" ? null : canonicalTaskId(value, "parent"),
218
227
  };
219
- case "under": return parseRelationPredicate("under", operator, value);
220
- case "needs": return parseRelationPredicate("needs", operator, value);
221
- case "blocks": return parseRelationPredicate("blocks", operator, value);
222
228
  case "ready": return parseBooleanPredicate("ready", operator, value);
223
229
  case "blocked": return parseBooleanPredicate("blocked", operator, value);
224
230
  case "created": return parseTimestampPredicate("created", operator, value);
225
231
  case "updated": return parseTimestampPredicate("updated", operator, value);
226
- default: return syntax(`unknown query field ${JSON.stringify(field.value)}`, field.offset);
232
+ default: return parseRelationPredicate(field, operator, value);
227
233
  }
228
234
  }
229
235
  }
@@ -3,6 +3,7 @@ import { type WorldRoot } from "../world.js";
3
3
  import { type ParsedCommand } from "./parse.js";
4
4
  export type CliCoordinates = Readonly<{
5
5
  cwd: string;
6
+ cwdSource: "input" | "process";
6
7
  repo?: Repo;
7
8
  world: WorldRoot | null;
8
9
  candidateWorld: WorldRoot | null;
@@ -12,6 +13,7 @@ export type CliCoordinateInput = Readonly<{
12
13
  processCwd?: string;
13
14
  cwd?: string;
14
15
  repo?: string;
16
+ gitPath?: string;
15
17
  command: ParsedCommand;
16
18
  }>;
17
19
  export declare function assertExplicitRepoUse(command: ParsedCommand, repo: string | undefined): void;
@@ -11,9 +11,12 @@ async function canonicalInvocationCwd(input) {
11
11
  throw new CliUsageError(`invocation cwd is not an existing directory: ${input}`);
12
12
  }
13
13
  }
14
- async function discoverRepoAt(coordinate) {
14
+ async function discoverRepoAt(coordinate, gitPath) {
15
15
  try {
16
- return { kind: "present", repo: await Repo.at({ path: coordinate }) };
16
+ return {
17
+ kind: "present",
18
+ repo: await Repo.at({ path: coordinate, ...(gitPath === undefined ? {} : { gitPath }) }),
19
+ };
17
20
  }
18
21
  catch (error) {
19
22
  if (error instanceof NoGitWorldError)
@@ -38,8 +41,11 @@ function repoPolicy(command) {
38
41
  return { use: command.query.kind === "contracts" ? "required" : "none", acceptsExplicit: false };
39
42
  case "status":
40
43
  case "tell":
41
- case "history":
42
44
  return { use: "optional", acceptsExplicit: false };
45
+ case "history":
46
+ return "contract" in command
47
+ ? { use: "required", acceptsExplicit: true }
48
+ : { use: "optional", acceptsExplicit: false };
43
49
  case "fork":
44
50
  return { use: "optional", acceptsExplicit: true };
45
51
  case "wait":
@@ -103,15 +109,16 @@ async function resolveWorld(cwd, repo) {
103
109
  export async function resolveCliCoordinates(input) {
104
110
  const processCwd = resolve(input.processCwd ?? ".");
105
111
  const cwd = await canonicalInvocationCwd(resolve(processCwd, input.cwd ?? "."));
106
- const invocationRepo = await discoverRepoAt(cwd);
112
+ const invocationRepo = await discoverRepoAt(cwd, input.gitPath);
107
113
  const selectedRepo = input.repo === undefined
108
114
  ? invocationRepo
109
- : await discoverRepoAt(resolve(cwd, input.repo));
115
+ : await discoverRepoAt(resolve(cwd, input.repo), input.gitPath);
110
116
  const worldRepo = invocationRepo.kind === "present" ? invocationRepo.repo : undefined;
111
117
  const repo = repoFor(repoPolicy(input.command).use, selectedRepo);
112
118
  const world = await resolveWorld(cwd, worldRepo);
113
119
  return {
114
120
  cwd,
121
+ cwdSource: input.cwd === undefined ? "process" : "input",
115
122
  ...(repo === undefined ? {} : { repo }),
116
123
  world: world.root,
117
124
  candidateWorld: world.candidate,
@@ -10,6 +10,7 @@ type InvokeRuntime = Readonly<{
10
10
  environment?: NodeJS.ProcessEnv;
11
11
  readStdin?: () => Promise<string>;
12
12
  actor?: ActorId;
13
+ onOperationStart?: () => void;
13
14
  }>;
14
15
  export type SettingsInvocationResult = Readonly<{
15
16
  kind: "settings";