@astrosheep/keiyaku 4.1.0 → 4.1.2

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 (278) hide show
  1. package/README.md +1 -1
  2. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku/SKILL.md +3 -0
  3. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-akuma/SKILL.md +3 -0
  4. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-workflow/SKILL.md +3 -6
  5. package/build/src/akuma/akuma-errors.d.ts +6 -0
  6. package/build/src/akuma/akuma-errors.js +9 -0
  7. package/build/src/akuma/akuma-handle.d.ts +39 -0
  8. package/build/src/akuma/akuma-handle.js +263 -0
  9. package/build/src/akuma/akuma-observe.d.ts +19 -0
  10. package/build/src/akuma/akuma-observe.js +74 -0
  11. package/build/src/akuma/akuma-product-symbols.d.ts +1 -0
  12. package/build/src/akuma/akuma-product-symbols.js +1 -0
  13. package/build/src/akuma/akuma-product.d.ts +18 -0
  14. package/build/src/akuma/akuma-product.js +154 -0
  15. package/build/src/akuma/akuma.d.ts +37 -81
  16. package/build/src/akuma/akuma.js +39 -447
  17. package/build/src/akuma/allowed.d.ts +1 -0
  18. package/build/src/akuma/allowed.js +6 -0
  19. package/build/src/akuma/archetype.js +8 -5
  20. package/build/src/akuma/body-supervisor.d.ts +26 -0
  21. package/build/src/akuma/body-supervisor.js +89 -0
  22. package/build/src/akuma/body.d.ts +45 -4
  23. package/build/src/akuma/body.js +145 -35
  24. package/build/src/akuma/coordinate.js +17 -7
  25. package/build/src/akuma/heart/facts.js +1 -1
  26. package/build/src/akuma/heart/index.d.ts +1 -1
  27. package/build/src/akuma/heart/index.js +2 -4
  28. package/build/src/akuma/heart/request-authority.js +4 -4
  29. package/build/src/akuma/heart/request-rows.js +27 -16
  30. package/build/src/akuma/heart/rows.js +79 -41
  31. package/build/src/akuma/heart/soul.js +1 -1
  32. package/build/src/akuma/heart/storage.d.ts +1 -0
  33. package/build/src/akuma/heart/storage.js +76 -11
  34. package/build/src/akuma/heart/tells.js +35 -18
  35. package/build/src/akuma/heart/timeline.js +19 -11
  36. package/build/src/akuma/identity.d.ts +1 -0
  37. package/build/src/akuma/identity.js +1 -0
  38. package/build/src/akuma/index.d.ts +3 -3
  39. package/build/src/akuma/index.js +1 -1
  40. package/build/src/akuma/nuke.js +106 -14
  41. package/build/src/akuma/projection-read.d.ts +17 -0
  42. package/build/src/akuma/projection-read.js +135 -0
  43. package/build/src/akuma/projection.d.ts +1 -16
  44. package/build/src/akuma/projection.js +77 -154
  45. package/build/src/akuma/provider-recipe.js +11 -5
  46. package/build/src/akuma/provider.js +105 -62
  47. package/build/src/akuma/providers/acp/config.js +5 -6
  48. package/build/src/akuma/providers/acp/core.js +17 -10
  49. package/build/src/akuma/providers/acp/events.js +38 -29
  50. package/build/src/akuma/providers/acp/index.js +13 -9
  51. package/build/src/akuma/providers/claude/events.js +8 -12
  52. package/build/src/akuma/providers/claude/index.d.ts +1 -0
  53. package/build/src/akuma/providers/claude/index.js +55 -26
  54. package/build/src/akuma/providers/claude/input.js +6 -2
  55. package/build/src/akuma/providers/codex-app-server/events.js +61 -36
  56. package/build/src/akuma/providers/codex-app-server/index.js +25 -13
  57. package/build/src/akuma/providers/grok-build/index.js +22 -25
  58. package/build/src/akuma/providers/index.js +2 -18
  59. package/build/src/akuma/providers/opencode-sdk/events.js +32 -18
  60. package/build/src/akuma/providers/opencode-sdk/index.js +26 -17
  61. package/build/src/akuma/providers/opencode-sdk/session.js +21 -5
  62. package/build/src/akuma/providers/pi/events.js +26 -19
  63. package/build/src/akuma/providers/pi/index.js +58 -40
  64. package/build/src/akuma/publication.js +9 -9
  65. package/build/src/akuma/request-execution.d.ts +6 -0
  66. package/build/src/akuma/request-execution.js +86 -0
  67. package/build/src/akuma/request-serve.d.ts +12 -1
  68. package/build/src/akuma/request-serve.js +19 -122
  69. package/build/src/akuma/request-wire.d.ts +2 -2
  70. package/build/src/akuma/request-wire.js +75 -102
  71. package/build/src/akuma/requests.js +2 -2
  72. package/build/src/akuma/{body-turn.d.ts → turn-drive.d.ts} +2 -25
  73. package/build/src/akuma/{body-turn.js → turn-drive.js} +20 -103
  74. package/build/src/akuma-body.js +6 -5
  75. package/build/src/body/amend.d.ts +4 -1
  76. package/build/src/body/amend.js +14 -6
  77. package/build/src/body/decode.js +2 -4
  78. package/build/src/body/envelope.js +2 -4
  79. package/build/src/body/region.d.ts +1 -2
  80. package/build/src/body/region.js +2 -70
  81. package/build/src/body/render.js +17 -12
  82. package/build/src/body/shape.js +1 -7
  83. package/build/src/cli/accepted.d.ts +1 -1
  84. package/build/src/cli/accepted.js +8 -1
  85. package/build/src/cli/commands/akuma-invoke.js +18 -6
  86. package/build/src/cli/commands/akuma.d.ts +0 -6
  87. package/build/src/cli/commands/akuma.js +11 -24
  88. package/build/src/cli/commands/amend.d.ts +2 -2
  89. package/build/src/cli/commands/amend.js +2 -4
  90. package/build/src/cli/commands/bind.d.ts +4 -4
  91. package/build/src/cli/commands/bind.js +16 -6
  92. package/build/src/cli/commands/contract-invoke.d.ts +25 -0
  93. package/build/src/cli/commands/contract-invoke.js +193 -0
  94. package/build/src/cli/commands/contract.d.ts +109 -10
  95. package/build/src/cli/commands/contract.js +339 -16
  96. package/build/src/cli/commands/install.d.ts +1 -1
  97. package/build/src/cli/commands/install.js +23 -15
  98. package/build/src/cli/commands/task-invoke.js +187 -67
  99. package/build/src/cli/commands/task-query.js +48 -24
  100. package/build/src/cli/commands/task.js +150 -38
  101. package/build/src/cli/coordinates.js +2 -4
  102. package/build/src/cli/invoke.js +92 -208
  103. package/build/src/cli/main.js +4 -2
  104. package/build/src/cli/parse.d.ts +3 -90
  105. package/build/src/cli/parse.js +27 -233
  106. package/build/src/cli/render/akuma-activity.d.ts +38 -0
  107. package/build/src/cli/render/akuma-activity.js +362 -0
  108. package/build/src/cli/render/akuma-tool-command.js +6 -7
  109. package/build/src/cli/render/akuma-tool.js +10 -8
  110. package/build/src/cli/render/akuma.d.ts +1 -1
  111. package/build/src/cli/render/akuma.js +61 -353
  112. package/build/src/cli/render/audit.js +5 -15
  113. package/build/src/cli/render/board.d.ts +1 -0
  114. package/build/src/cli/render/board.js +17 -0
  115. package/build/src/cli/render/catalog.js +81 -8
  116. package/build/src/cli/render/contract-history.d.ts +2 -0
  117. package/build/src/cli/render/contract-history.js +83 -0
  118. package/build/src/cli/render/contract-observation.d.ts +10 -0
  119. package/build/src/cli/render/contract-observation.js +58 -0
  120. package/build/src/cli/render/contract.d.ts +1 -2
  121. package/build/src/cli/render/contract.js +41 -142
  122. package/build/src/cli/render/kanshi.js +239 -215
  123. package/build/src/cli/render/receipt.js +2 -9
  124. package/build/src/cli/render/refusal.js +10 -15
  125. package/build/src/cli/render/region.js +22 -6
  126. package/build/src/cli/render/settings.js +4 -4
  127. package/build/src/cli/render/task.js +34 -14
  128. package/build/src/cli/render/terminal.js +16 -5
  129. package/build/src/cli/result.d.ts +3 -3
  130. package/build/src/cli/runtime.d.ts +6 -1
  131. package/build/src/cli/runtime.js +84 -63
  132. package/build/src/cli/selectors.js +2 -4
  133. package/build/src/cli/usage.js +6 -5
  134. package/build/src/contract-worktree.d.ts +1 -23
  135. package/build/src/contract-worktree.js +79 -155
  136. package/build/src/coordination/durable-file.js +7 -3
  137. package/build/src/coordination/sqlite-transaction-lock.js +29 -12
  138. package/build/src/core/facts/codec.js +7 -3
  139. package/build/src/core/facts/types.d.ts +1 -1
  140. package/build/src/core/subject.js +16 -9
  141. package/build/src/core/verbs/abandon.d.ts +1 -1
  142. package/build/src/core/verbs/abandon.js +1 -1
  143. package/build/src/core/verbs/amend.d.ts +1 -1
  144. package/build/src/core/verbs/amend.js +7 -7
  145. package/build/src/core/verbs/attestation.js +4 -1
  146. package/build/src/core/verbs/bind.d.ts +1 -1
  147. package/build/src/core/verbs/bind.js +1 -1
  148. package/build/src/core/verbs/placement.d.ts +1 -1
  149. package/build/src/core/verbs/placement.js +10 -8
  150. package/build/src/dispatch/index.js +8 -6
  151. package/build/src/duration.js +5 -1
  152. package/build/src/git/admission.js +5 -3
  153. package/build/src/git/hooks.d.ts +8 -0
  154. package/build/src/git/hooks.js +63 -14
  155. package/build/src/git/identity.js +1 -4
  156. package/build/src/git/integration.d.ts +2 -3
  157. package/build/src/git/integration.js +32 -39
  158. package/build/src/git/nuke.d.ts +1 -1
  159. package/build/src/git/nuke.js +110 -57
  160. package/build/src/git/observe.d.ts +13 -1
  161. package/build/src/git/observe.js +51 -44
  162. package/build/src/git/process.js +4 -2
  163. package/build/src/git/read-observation.js +10 -8
  164. package/build/src/git/reconcile.d.ts +22 -2
  165. package/build/src/git/reconcile.js +38 -274
  166. package/build/src/git/repository.d.ts +2 -0
  167. package/build/src/git/repository.js +13 -22
  168. package/build/src/git/scratch.d.ts +8 -5
  169. package/build/src/git/scratch.js +29 -2
  170. package/build/src/git/target-placement.d.ts +9 -10
  171. package/build/src/git/target-placement.js +59 -62
  172. package/build/src/git/tender.js +13 -46
  173. package/build/src/git/terminal-reconcile.d.ts +21 -0
  174. package/build/src/git/terminal-reconcile.js +278 -0
  175. package/build/src/git/terminal-seal.js +15 -12
  176. package/build/src/git/tree.js +5 -2
  177. package/build/src/git/workspace.d.ts +24 -2
  178. package/build/src/git/workspace.js +120 -16
  179. package/build/src/identity/coordinates.js +3 -1
  180. package/build/src/identity/selector.js +6 -3
  181. package/build/src/kanshi/fleet.d.ts +6 -0
  182. package/build/src/kanshi/fleet.js +27 -0
  183. package/build/src/kanshi/index.d.ts +1 -1
  184. package/build/src/kanshi/read.js +60 -48
  185. package/build/src/kanshi/report.d.ts +11 -23
  186. package/build/src/kanshi/select.js +25 -24
  187. package/build/src/library/address.d.ts +2 -1
  188. package/build/src/library/address.js +7 -8
  189. package/build/src/library/akuma-creation.js +20 -12
  190. package/build/src/library/audit.d.ts +0 -1
  191. package/build/src/library/audit.js +1 -2
  192. package/build/src/library/bind.d.ts +53 -5
  193. package/build/src/library/bind.js +98 -22
  194. package/build/src/library/catalog.d.ts +1 -0
  195. package/build/src/library/catalog.js +6 -3
  196. package/build/src/library/configuration.js +3 -1
  197. package/build/src/library/continuation.d.ts +15 -4
  198. package/build/src/library/continuation.js +24 -16
  199. package/build/src/library/contract-bind.d.ts +26 -0
  200. package/build/src/library/contract-bind.js +106 -0
  201. package/build/src/library/contract-operations.d.ts +77 -0
  202. package/build/src/library/contract-operations.js +130 -0
  203. package/build/src/library/contract-types.d.ts +95 -0
  204. package/build/src/library/contract-types.js +1 -0
  205. package/build/src/library/contract.d.ts +19 -154
  206. package/build/src/library/contract.js +46 -261
  207. package/build/src/library/fleet.d.ts +1 -1
  208. package/build/src/library/fleet.js +19 -11
  209. package/build/src/library/input.d.ts +2 -0
  210. package/build/src/library/input.js +14 -0
  211. package/build/src/library/keiyaku.d.ts +8 -7
  212. package/build/src/library/keiyaku.js +3 -3
  213. package/build/src/library/nuke.js +14 -5
  214. package/build/src/library/reconcile.d.ts +9 -4
  215. package/build/src/library/reconcile.js +30 -24
  216. package/build/src/library/refusal.d.ts +13 -5
  217. package/build/src/library/refusal.js +7 -0
  218. package/build/src/library/region.d.ts +8 -7
  219. package/build/src/library/region.js +31 -11
  220. package/build/src/library/repo.js +2 -2
  221. package/build/src/markdown/lex.js +9 -2
  222. package/build/src/markdown/parse.js +11 -7
  223. package/build/src/markdown/query.js +4 -2
  224. package/build/src/protocol/amend.js +3 -1
  225. package/build/src/protocol/attempt.d.ts +7 -3
  226. package/build/src/protocol/attempt.js +9 -5
  227. package/build/src/protocol/audit.d.ts +1 -1
  228. package/build/src/protocol/audit.js +4 -14
  229. package/build/src/protocol/bind.d.ts +19 -6
  230. package/build/src/protocol/bind.js +28 -13
  231. package/build/src/protocol/completion.d.ts +0 -1
  232. package/build/src/protocol/completion.js +1 -3
  233. package/build/src/protocol/deliver.d.ts +1 -3
  234. package/build/src/protocol/deliver.js +15 -39
  235. package/build/src/protocol/intent.d.ts +1 -0
  236. package/build/src/protocol/intent.js +9 -7
  237. package/build/src/protocol/operations.d.ts +3 -7
  238. package/build/src/protocol/operations.js +5 -3
  239. package/build/src/protocol/placement.d.ts +0 -1
  240. package/build/src/protocol/placement.js +6 -6
  241. package/build/src/protocol/read/observation.d.ts +11 -0
  242. package/build/src/protocol/read/observation.js +37 -0
  243. package/build/src/protocol/read/status.d.ts +23 -12
  244. package/build/src/protocol/read/status.js +90 -72
  245. package/build/src/protocol/reconcile.d.ts +1 -0
  246. package/build/src/protocol/reconcile.js +2 -3
  247. package/build/src/protocol/reintegrate.js +1 -1
  248. package/build/src/protocol/review.d.ts +0 -1
  249. package/build/src/protocol/review.js +15 -22
  250. package/build/src/protocol/run.d.ts +1 -0
  251. package/build/src/protocol/run.js +4 -5
  252. package/build/src/runtime/proc/launch.d.ts +33 -0
  253. package/build/src/runtime/proc/launch.js +98 -0
  254. package/build/src/runtime/proc/line-rpc.js +9 -3
  255. package/build/src/runtime/proc/run.d.ts +12 -6
  256. package/build/src/runtime/proc/run.js +78 -21
  257. package/build/src/runtime/proc/stdio.js +7 -10
  258. package/build/src/settings.js +6 -2
  259. package/build/src/settlement/holder.js +13 -10
  260. package/build/src/settlement/settle.js +39 -6
  261. package/build/src/task/board.js +12 -6
  262. package/build/src/task/compose.js +85 -22
  263. package/build/src/task/context.js +21 -8
  264. package/build/src/task/document.js +46 -10
  265. package/build/src/task/identity.js +5 -2
  266. package/build/src/task/index.d.ts +0 -1
  267. package/build/src/task/index.js +119 -34
  268. package/build/src/task/input.js +29 -7
  269. package/build/src/task/mutation.js +61 -19
  270. package/build/src/task/operations.d.ts +6 -1
  271. package/build/src/task/operations.js +83 -29
  272. package/build/src/task/query.js +55 -26
  273. package/build/src/task/store.d.ts +3 -1
  274. package/build/src/task/store.js +81 -17
  275. package/build/src/verification/execution.js +14 -11
  276. package/build/src/workspace-place.js +19 -7
  277. package/build/src/world.js +16 -6
  278. package/package.json +8 -3
@@ -1,4 +1,5 @@
1
- import { Tasks, observeTaskDetails, } from "../../task/index.js";
1
+ import { Tasks, } from "../../task/index.js";
2
+ import { observeTaskDetails } from "../../task/operations.js";
2
3
  import { injectedBodyRequests, requestBodyTask } from "../../akuma/requests.js";
3
4
  import { decodeTaskMutationRequest } from "../../task/mutation.js";
4
5
  import { resolveTaskNamespaceContext, writeTaskNamespaceContext } from "../../task/context.js";
@@ -27,16 +28,25 @@ function values(command, name) {
27
28
  const item = command.flags[name];
28
29
  return Array.isArray(item) ? item : undefined;
29
30
  }
30
- function namespace(raw) { return raw === undefined ? undefined : raw === "/" ? [] : raw.split("/"); }
31
+ function namespace(raw) {
32
+ return raw === undefined ? undefined : raw === "/" ? [] : raw.split("/");
33
+ }
31
34
  function priority(raw) {
32
35
  if (raw === undefined)
33
36
  return undefined;
34
37
  const number = Number(raw);
35
38
  return number;
36
39
  }
37
- function state(raw) { return raw; }
38
- function ids(items) { return items; }
39
- function limit(command) { const raw = value(command, "limit"); return raw === undefined ? undefined : Number(raw); }
40
+ function state(raw) {
41
+ return raw;
42
+ }
43
+ function ids(items) {
44
+ return items;
45
+ }
46
+ function limit(command) {
47
+ const raw = value(command, "limit");
48
+ return raw === undefined ? undefined : Number(raw);
49
+ }
40
50
  async function invokeAdd(tasks, command, input, current) {
41
51
  const selectedNamespace = namespace(value(command, "namespace")) ?? current;
42
52
  const actor = input.actor;
@@ -51,10 +61,16 @@ async function invokeAdd(tasks, command, input, current) {
51
61
  const needs = ids(values(command, "needs")), parent = value(command, "parent");
52
62
  const supersedes = ids(values(command, "supersedes")), relates = ids(values(command, "relates"));
53
63
  return tasks.add({
54
- title: command.positionals[0], ...(selectedNamespace === undefined ? {} : { namespace: selectedNamespace }),
55
- ...(body === undefined ? {} : { body }), ...(note === undefined ? {} : { note }), ...(initialState === undefined ? {} : { state: initialState }), ...(selectedPriority === undefined ? {} : { priority: selectedPriority }),
56
- ...(needs === undefined ? {} : { needs }), ...(parent === undefined ? {} : { parent: parent }),
57
- ...(supersedes === undefined ? {} : { supersedes }), ...(relates === undefined ? {} : { relates }),
64
+ title: command.positionals[0],
65
+ ...(selectedNamespace === undefined ? {} : { namespace: selectedNamespace }),
66
+ ...(body === undefined ? {} : { body }),
67
+ ...(note === undefined ? {} : { note }),
68
+ ...(initialState === undefined ? {} : { state: initialState }),
69
+ ...(selectedPriority === undefined ? {} : { priority: selectedPriority }),
70
+ ...(needs === undefined ? {} : { needs }),
71
+ ...(parent === undefined ? {} : { parent: parent }),
72
+ ...(supersedes === undefined ? {} : { supersedes }),
73
+ ...(relates === undefined ? {} : { relates }),
58
74
  ...(actor === undefined ? {} : { actor }),
59
75
  });
60
76
  }
@@ -67,32 +83,53 @@ async function invokeUpdate(tasks, command, readStdin) {
67
83
  const dropSupersedes = ids(values(command, "drop-supersedes")), addRelates = ids(values(command, "relates"));
68
84
  const dropRelates = ids(values(command, "drop-relates"));
69
85
  return tasks.task({ id: command.positionals[0] }).update({
70
- ...(title === undefined ? {} : { title }), ...(body === undefined ? {} : { body }), ...(appendBody === undefined ? {} : { appendBody }), ...(note === undefined ? {} : { note }),
71
- ...(selectedPriority === undefined ? {} : { priority: selectedPriority }), ...(addNeeds === undefined ? {} : { addNeeds }),
72
- ...(dropNeeds === undefined ? {} : { dropNeeds }), ...(command.flags["no-parent"] === true ? { parent: null } : parent === undefined ? {} : { parent: parent }),
73
- ...(addSupersedes === undefined ? {} : { addSupersedes }), ...(dropSupersedes === undefined ? {} : { dropSupersedes }),
74
- ...(addRelates === undefined ? {} : { addRelates }), ...(dropRelates === undefined ? {} : { dropRelates }),
86
+ ...(title === undefined ? {} : { title }),
87
+ ...(body === undefined ? {} : { body }),
88
+ ...(appendBody === undefined ? {} : { appendBody }),
89
+ ...(note === undefined ? {} : { note }),
90
+ ...(selectedPriority === undefined ? {} : { priority: selectedPriority }),
91
+ ...(addNeeds === undefined ? {} : { addNeeds }),
92
+ ...(dropNeeds === undefined ? {} : { dropNeeds }),
93
+ ...(command.flags["no-parent"] === true
94
+ ? { parent: null }
95
+ : parent === undefined
96
+ ? {}
97
+ : { parent: parent }),
98
+ ...(addSupersedes === undefined ? {} : { addSupersedes }),
99
+ ...(dropSupersedes === undefined ? {} : { dropSupersedes }),
100
+ ...(addRelates === undefined ? {} : { addRelates }),
101
+ ...(dropRelates === undefined ? {} : { dropRelates }),
75
102
  });
76
103
  }
77
104
  async function addMutationRequest(command, input, current) {
78
105
  const selectedNamespace = namespace(value(command, "namespace")) ?? current;
79
106
  if (command.stdin === "document")
80
- return { action: "task.addDocument", input: {
107
+ return {
108
+ action: "task.addDocument",
109
+ input: {
81
110
  markdown: await input.readStdin(),
82
111
  namespace: selectedNamespace,
83
- } };
112
+ },
113
+ };
84
114
  const body = value(command, "body"), note = value(command, "note");
85
115
  const initialState = state(value(command, "state")), selectedPriority = priority(value(command, "priority"));
86
116
  const needs = ids(values(command, "needs")), parent = value(command, "parent");
87
117
  const supersedes = ids(values(command, "supersedes")), relates = ids(values(command, "relates"));
88
- return { action: "task.add", input: {
89
- title: command.positionals[0], namespace: selectedNamespace,
90
- ...(body === undefined ? {} : { body }), ...(note === undefined ? {} : { note }),
118
+ return {
119
+ action: "task.add",
120
+ input: {
121
+ title: command.positionals[0],
122
+ namespace: selectedNamespace,
123
+ ...(body === undefined ? {} : { body }),
124
+ ...(note === undefined ? {} : { note }),
91
125
  ...(initialState === undefined ? {} : { state: initialState }),
92
126
  ...(selectedPriority === undefined ? {} : { priority: selectedPriority }),
93
- ...(needs === undefined ? {} : { needs }), ...(parent === undefined ? {} : { parent: parent }),
94
- ...(supersedes === undefined ? {} : { supersedes }), ...(relates === undefined ? {} : { relates }),
95
- } };
127
+ ...(needs === undefined ? {} : { needs }),
128
+ ...(parent === undefined ? {} : { parent: parent }),
129
+ ...(supersedes === undefined ? {} : { supersedes }),
130
+ ...(relates === undefined ? {} : { relates }),
131
+ },
132
+ };
96
133
  }
97
134
  async function updateMutationRequest(command, input) {
98
135
  const body = command.stdin === "body" ? await input.readStdin() : value(command, "body");
@@ -103,28 +140,54 @@ async function updateMutationRequest(command, input) {
103
140
  const parent = value(command, "parent"), addSupersedes = ids(values(command, "supersedes"));
104
141
  const dropSupersedes = ids(values(command, "drop-supersedes")), addRelates = ids(values(command, "relates"));
105
142
  const dropRelates = ids(values(command, "drop-relates"));
106
- return { action: "task.update", id: command.positionals[0], input: {
107
- ...(title === undefined ? {} : { title }), ...(body === undefined ? {} : { body }),
108
- ...(appendBody === undefined ? {} : { appendBody }), ...(note === undefined ? {} : { note }),
143
+ return {
144
+ action: "task.update",
145
+ id: command.positionals[0],
146
+ input: {
147
+ ...(title === undefined ? {} : { title }),
148
+ ...(body === undefined ? {} : { body }),
149
+ ...(appendBody === undefined ? {} : { appendBody }),
150
+ ...(note === undefined ? {} : { note }),
109
151
  ...(selectedPriority === undefined ? {} : { priority: selectedPriority }),
110
- ...(addNeeds === undefined ? {} : { addNeeds }), ...(dropNeeds === undefined ? {} : { dropNeeds }),
111
- ...(command.flags["no-parent"] === true ? { parent: null }
112
- : parent === undefined ? {} : { parent: parent }),
152
+ ...(addNeeds === undefined ? {} : { addNeeds }),
153
+ ...(dropNeeds === undefined ? {} : { dropNeeds }),
154
+ ...(command.flags["no-parent"] === true
155
+ ? { parent: null }
156
+ : parent === undefined
157
+ ? {}
158
+ : { parent: parent }),
113
159
  ...(addSupersedes === undefined ? {} : { addSupersedes }),
114
160
  ...(dropSupersedes === undefined ? {} : { dropSupersedes }),
115
- ...(addRelates === undefined ? {} : { addRelates }), ...(dropRelates === undefined ? {} : { dropRelates }),
116
- } };
161
+ ...(addRelates === undefined ? {} : { addRelates }),
162
+ ...(dropRelates === undefined ? {} : { dropRelates }),
163
+ },
164
+ };
117
165
  }
118
166
  function lifecycleMutationRequest(command) {
119
167
  const id = command.positionals[0];
120
168
  switch (command.action) {
121
- case "start": return { action: "task.start", id };
122
- case "stop": return { action: "task.stop", id };
123
- case "resume": return { action: "task.resume", id };
124
- case "hold": return { action: "task.hold", ids: command.positionals };
125
- case "done": return { action: "task.done", ids: command.positionals, ...(value(command, "note") === undefined ? {} : { note: value(command, "note") }) };
126
- case "drop": return { action: "task.drop", ids: command.positionals, ...(value(command, "note") === undefined ? {} : { note: value(command, "note") }) };
127
- default: throw new Error(`task action cannot forward: ${command.action}`);
169
+ case "start":
170
+ return { action: "task.start", id };
171
+ case "stop":
172
+ return { action: "task.stop", id };
173
+ case "resume":
174
+ return { action: "task.resume", id };
175
+ case "hold":
176
+ return { action: "task.hold", ids: command.positionals };
177
+ case "done":
178
+ return {
179
+ action: "task.done",
180
+ ids: command.positionals,
181
+ ...(value(command, "note") === undefined ? {} : { note: value(command, "note") }),
182
+ };
183
+ case "drop":
184
+ return {
185
+ action: "task.drop",
186
+ ids: command.positionals,
187
+ ...(value(command, "note") === undefined ? {} : { note: value(command, "note") }),
188
+ };
189
+ default:
190
+ throw new Error(`task action cannot forward: ${command.action}`);
128
191
  }
129
192
  }
130
193
  async function mutationRequest(command, input, current) {
@@ -139,15 +202,24 @@ async function mutationRequest(command, input, current) {
139
202
  function validatedMutationRequest(request) {
140
203
  switch (request.action) {
141
204
  case "task.add":
142
- case "task.addDocument": return decodeTaskMutationRequest(request.action, { input: request.input });
143
- case "task.compose": return decodeTaskMutationRequest(request.action, { markdown: request.markdown, namespace: request.namespace });
144
- case "task.update": return decodeTaskMutationRequest(request.action, { id: request.id, input: request.input });
205
+ case "task.addDocument":
206
+ return decodeTaskMutationRequest(request.action, { input: request.input });
207
+ case "task.compose":
208
+ return decodeTaskMutationRequest(request.action, { markdown: request.markdown, namespace: request.namespace });
209
+ case "task.update":
210
+ return decodeTaskMutationRequest(request.action, { id: request.id, input: request.input });
145
211
  case "task.start":
146
212
  case "task.stop":
147
- case "task.resume": return decodeTaskMutationRequest(request.action, { id: request.id });
148
- case "task.hold": return decodeTaskMutationRequest(request.action, { ids: request.ids });
213
+ case "task.resume":
214
+ return decodeTaskMutationRequest(request.action, { id: request.id });
215
+ case "task.hold":
216
+ return decodeTaskMutationRequest(request.action, { ids: request.ids });
149
217
  case "task.done":
150
- case "task.drop": return decodeTaskMutationRequest(request.action, { ids: request.ids, ...(request.note === undefined ? {} : { note: request.note }) });
218
+ case "task.drop":
219
+ return decodeTaskMutationRequest(request.action, {
220
+ ids: request.ids,
221
+ ...(request.note === undefined ? {} : { note: request.note }),
222
+ });
151
223
  }
152
224
  }
153
225
  function readScope(command, current) {
@@ -163,23 +235,52 @@ async function invokeRead(tasks, command, current) {
163
235
  return observed;
164
236
  return command.output === "json" || observed.value.length > 1 ? observed.value : observed.value[0];
165
237
  }
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) }) });
170
- case "tree": return tasks.task({ id }).tree();
171
- case "doctor": return tasks.doctor();
172
- default: throw new Error(`task action is not a read: ${command.action}`);
238
+ case "ls":
239
+ return tasks.list({
240
+ selection: command.flags.all === true ? "all" : command.flags.closed === true ? "closed" : "active",
241
+ ...readScope(command, current),
242
+ ...(limit(command) === undefined ? {} : { limit: limit(command) }),
243
+ });
244
+ case "ready":
245
+ return tasks.ready({
246
+ ...readScope(command, current),
247
+ ...(value(command, "parent") === undefined ? {} : { parent: value(command, "parent") }),
248
+ ...(limit(command) === undefined ? {} : { limit: limit(command) }),
249
+ });
250
+ case "blocked":
251
+ return tasks.blocked({
252
+ ...readScope(command, current),
253
+ ...(value(command, "parent") === undefined ? {} : { parent: value(command, "parent") }),
254
+ ...(limit(command) === undefined ? {} : { limit: limit(command) }),
255
+ });
256
+ case "query":
257
+ return tasks.query({
258
+ ...(command.where === undefined ? {} : { where: command.where }),
259
+ ...readScope(command, current),
260
+ ...(value(command, "sort") === undefined ? {} : { sort: value(command, "sort") }),
261
+ ...(limit(command) === undefined ? {} : { limit: limit(command) }),
262
+ });
263
+ case "tree":
264
+ return tasks.task({ id }).tree();
265
+ case "doctor":
266
+ return tasks.doctor();
267
+ default:
268
+ throw new Error(`task action is not a read: ${command.action}`);
173
269
  }
174
270
  }
175
271
  function isWorldObservation(command) {
176
- return command.action === "ls" || command.action === "ready" || command.action === "blocked"
177
- || command.action === "query" || command.action === "doctor";
272
+ return (command.action === "ls" ||
273
+ command.action === "ready" ||
274
+ command.action === "blocked" ||
275
+ command.action === "query" ||
276
+ command.action === "doctor");
277
+ }
278
+ function diagnostic(error) {
279
+ return error instanceof Error ? error.message : String(error);
178
280
  }
179
- function diagnostic(error) { return error instanceof Error ? error.message : String(error); }
180
281
  async function observeWorldRead(tasks, command, current) {
181
282
  try {
182
- return { kind: "present", value: await invokeRead(tasks, command, current) };
283
+ return { kind: "present", value: (await invokeRead(tasks, command, current)) };
183
284
  }
184
285
  catch (error) {
185
286
  return { kind: "failed", failure: { message: diagnostic(error) } };
@@ -210,10 +311,14 @@ async function invokeLocalMutation(tasks, command, input, current) {
210
311
  return await invokeUpdate(tasks, command, input.readStdin);
211
312
  const id = command.positionals[0];
212
313
  switch (command.action) {
213
- case "start": return tasks.task({ id }).start();
214
- case "stop": return tasks.task({ id }).stop();
215
- case "resume": return tasks.task({ id }).resume();
216
- case "hold": return tasks.batch({ verb: "hold", ids: command.positionals });
314
+ case "start":
315
+ return tasks.task({ id }).start();
316
+ case "stop":
317
+ return tasks.task({ id }).stop();
318
+ case "resume":
319
+ return tasks.task({ id }).resume();
320
+ case "hold":
321
+ return tasks.batch({ verb: "hold", ids: command.positionals });
217
322
  case "done": {
218
323
  const note = value(command, "note");
219
324
  return tasks.batch({ verb: "done", ids: command.positionals, ...(note === undefined ? {} : { note }) });
@@ -228,25 +333,40 @@ async function invokeLocalMutation(tasks, command, input, current) {
228
333
  await writeTaskNamespaceContext(input.context.directory, selected);
229
334
  return { kind: "accepted", value: selected ?? current ?? [] };
230
335
  }
231
- case "compose": return tasks.compose({ markdown: await input.readStdin(), namespace: current ?? [], ...(input.actor === undefined ? {} : { actor: input.actor }) });
232
- default: throw new Error(`task action has no invocation: ${command.action}`);
336
+ case "compose":
337
+ return tasks.compose({
338
+ markdown: await input.readStdin(),
339
+ namespace: current ?? [],
340
+ ...(input.actor === undefined ? {} : { actor: input.actor }),
341
+ });
342
+ default:
343
+ throw new Error(`task action has no invocation: ${command.action}`);
233
344
  }
234
345
  }
235
346
  function establishesWorld(command) {
236
- return command.action === "add" || command.action === "compose"
237
- || (command.action === "namespace" && command.positionals.length > 0);
347
+ return (command.action === "add" ||
348
+ command.action === "compose" ||
349
+ (command.action === "namespace" && command.positionals.length > 0));
238
350
  }
239
351
  function forwardsMutation(command) {
240
- return command.action !== "show" && command.action !== "tree"
241
- && command.action !== "namespace" && !isWorldObservation(command);
352
+ return (command.action !== "show" &&
353
+ command.action !== "tree" &&
354
+ command.action !== "namespace" &&
355
+ !isWorldObservation(command));
242
356
  }
243
357
  export async function invokeTask(command, input) {
244
358
  const world = input.world ?? (establishesWorld(command) ? await input.establish() : null);
245
359
  if (world === null)
246
360
  return missingWorld(command);
247
361
  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);
362
+ const contextSensitive = command.action === "namespace" ||
363
+ command.action === "add" ||
364
+ command.action === "compose" ||
365
+ ((command.action === "ls" ||
366
+ command.action === "ready" ||
367
+ command.action === "blocked" ||
368
+ command.action === "query") &&
369
+ command.flags.world !== true);
250
370
  let current;
251
371
  if (contextSensitive) {
252
372
  const resolved = await resolveTaskNamespaceContext(input.context);
@@ -257,7 +377,7 @@ export async function invokeTask(command, input) {
257
377
  const requests = injectedBodyRequests();
258
378
  if (requests !== null && forwardsMutation(command)) {
259
379
  const request = validatedMutationRequest(await mutationRequest(command, input, current ?? []));
260
- return await requestBodyTask({ directory: requests, world, request });
380
+ return (await requestBodyTask({ directory: requests, world, request }));
261
381
  }
262
382
  return await invokeLocalMutation(tasks, command, input, current);
263
383
  }
@@ -1,9 +1,11 @@
1
1
  import { MAX_TASK_LIMIT, TASK_RELATION_PREDICATE_FIELDS, normalizeTaskQuery, } from "../../task/query.js";
2
- function syntax(message, offset) { throw new Error(`${message} at column ${offset + 1}`); }
2
+ function syntax(message, offset) {
3
+ throw new Error(`${message} at column ${offset + 1}`);
4
+ }
3
5
  function scanString(source, offset) {
4
6
  let index = offset + 1;
5
7
  let value = "";
6
- while (index < source.length && source[index] !== "\"") {
8
+ while (index < source.length && source[index] !== '"') {
7
9
  const character = source[index];
8
10
  if (character !== "\\") {
9
11
  value += character;
@@ -13,12 +15,12 @@ function scanString(source, offset) {
13
15
  const escaped = source[index + 1];
14
16
  if (escaped === undefined)
15
17
  syntax("unterminated string", offset);
16
- if (escaped !== "\\" && escaped !== "\"")
17
- syntax("only \\\\ and \\\" escapes are supported", index);
18
+ if (escaped !== "\\" && escaped !== '"')
19
+ syntax('only \\\\ and \\" escapes are supported', index);
18
20
  value += escaped;
19
21
  index += 2;
20
22
  }
21
- if (source[index] !== "\"")
23
+ if (source[index] !== '"')
22
24
  syntax("unterminated string", offset);
23
25
  return { token: { kind: "string", value, offset }, next: index + 1 };
24
26
  }
@@ -59,7 +61,7 @@ function lex(source) {
59
61
  index += 1;
60
62
  continue;
61
63
  }
62
- if (character === "\"") {
64
+ if (character === '"') {
63
65
  const scanned = scanString(source, offset);
64
66
  tokens.push(scanned.token);
65
67
  index = scanned.next;
@@ -84,7 +86,11 @@ function canonicalTaskId(token, field) {
84
86
  return token.value;
85
87
  }
86
88
  function state(token) {
87
- if (token.value !== "open" && token.value !== "in_progress" && token.value !== "on_hold" && token.value !== "done" && token.value !== "drop") {
89
+ if (token.value !== "open" &&
90
+ token.value !== "in_progress" &&
91
+ token.value !== "on_hold" &&
92
+ token.value !== "done" &&
93
+ token.value !== "drop") {
88
94
  return syntax(`invalid state ${JSON.stringify(token.value)}`, token.offset);
89
95
  }
90
96
  return token.value;
@@ -155,9 +161,17 @@ class Parser {
155
161
  constructor(tokens) {
156
162
  this.tokens = tokens;
157
163
  }
158
- current() { return this.tokens[this.index]; }
159
- take() { const token = this.current(); this.index += 1; return token; }
160
- word(value) { return this.current().kind === "word" && this.current().value === value; }
164
+ current() {
165
+ return this.tokens[this.index];
166
+ }
167
+ take() {
168
+ const token = this.current();
169
+ this.index += 1;
170
+ return token;
171
+ }
172
+ word(value) {
173
+ return this.current().kind === "word" && this.current().value === value;
174
+ }
161
175
  parse() {
162
176
  const value = this.or();
163
177
  if (this.current().kind !== "end")
@@ -215,20 +229,30 @@ class Parser {
215
229
  }
216
230
  typedPredicate(field, operator, value) {
217
231
  switch (field.value) {
218
- case "state": return { field: "state", operator: equalityOperator(operator, "state"), value: state(value) };
219
- case "priority": return { field: "priority", operator: orderedOperator(operator, "priority"), value: priority(value) };
220
- case "title": return parseTextPredicate("title", operator, value);
221
- case "id": return parseTextPredicate("id", operator, value);
222
- case "parent": return {
223
- field: "parent",
224
- operator: equalityOperator(operator, "parent"),
225
- value: value.value === "none" ? null : canonicalTaskId(value, "parent"),
226
- };
227
- case "ready": return parseBooleanPredicate("ready", operator, value);
228
- case "blocked": return parseBooleanPredicate("blocked", operator, value);
229
- case "created": return parseTimestampPredicate("created", operator, value);
230
- case "updated": return parseTimestampPredicate("updated", operator, value);
231
- default: return parseRelationPredicate(field, operator, value);
232
+ case "state":
233
+ return { field: "state", operator: equalityOperator(operator, "state"), value: state(value) };
234
+ case "priority":
235
+ return { field: "priority", operator: orderedOperator(operator, "priority"), value: priority(value) };
236
+ case "title":
237
+ return parseTextPredicate("title", operator, value);
238
+ case "id":
239
+ return parseTextPredicate("id", operator, value);
240
+ case "parent":
241
+ return {
242
+ field: "parent",
243
+ operator: equalityOperator(operator, "parent"),
244
+ value: value.value === "none" ? null : canonicalTaskId(value, "parent"),
245
+ };
246
+ case "ready":
247
+ return parseBooleanPredicate("ready", operator, value);
248
+ case "blocked":
249
+ return parseBooleanPredicate("blocked", operator, value);
250
+ case "created":
251
+ return parseTimestampPredicate("created", operator, value);
252
+ case "updated":
253
+ return parseTimestampPredicate("updated", operator, value);
254
+ default:
255
+ return parseRelationPredicate(field, operator, value);
232
256
  }
233
257
  }
234
258
  }