@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.
- package/README.md +1 -1
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku/SKILL.md +3 -0
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-akuma/SKILL.md +3 -0
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-workflow/SKILL.md +3 -6
- package/build/src/akuma/akuma-errors.d.ts +6 -0
- package/build/src/akuma/akuma-errors.js +9 -0
- package/build/src/akuma/akuma-handle.d.ts +39 -0
- package/build/src/akuma/akuma-handle.js +263 -0
- package/build/src/akuma/akuma-observe.d.ts +19 -0
- package/build/src/akuma/akuma-observe.js +74 -0
- package/build/src/akuma/akuma-product-symbols.d.ts +1 -0
- package/build/src/akuma/akuma-product-symbols.js +1 -0
- package/build/src/akuma/akuma-product.d.ts +18 -0
- package/build/src/akuma/akuma-product.js +154 -0
- package/build/src/akuma/akuma.d.ts +37 -81
- package/build/src/akuma/akuma.js +39 -447
- package/build/src/akuma/allowed.d.ts +1 -0
- package/build/src/akuma/allowed.js +6 -0
- package/build/src/akuma/archetype.js +8 -5
- package/build/src/akuma/body-supervisor.d.ts +26 -0
- package/build/src/akuma/body-supervisor.js +89 -0
- package/build/src/akuma/body.d.ts +45 -4
- package/build/src/akuma/body.js +145 -35
- package/build/src/akuma/coordinate.js +17 -7
- package/build/src/akuma/heart/facts.js +1 -1
- package/build/src/akuma/heart/index.d.ts +1 -1
- package/build/src/akuma/heart/index.js +2 -4
- package/build/src/akuma/heart/request-authority.js +4 -4
- package/build/src/akuma/heart/request-rows.js +27 -16
- package/build/src/akuma/heart/rows.js +79 -41
- package/build/src/akuma/heart/soul.js +1 -1
- package/build/src/akuma/heart/storage.d.ts +1 -0
- package/build/src/akuma/heart/storage.js +76 -11
- package/build/src/akuma/heart/tells.js +35 -18
- package/build/src/akuma/heart/timeline.js +19 -11
- package/build/src/akuma/identity.d.ts +1 -0
- package/build/src/akuma/identity.js +1 -0
- package/build/src/akuma/index.d.ts +3 -3
- package/build/src/akuma/index.js +1 -1
- package/build/src/akuma/nuke.js +106 -14
- package/build/src/akuma/projection-read.d.ts +17 -0
- package/build/src/akuma/projection-read.js +135 -0
- package/build/src/akuma/projection.d.ts +1 -16
- package/build/src/akuma/projection.js +77 -154
- package/build/src/akuma/provider-recipe.js +11 -5
- package/build/src/akuma/provider.js +105 -62
- package/build/src/akuma/providers/acp/config.js +5 -6
- package/build/src/akuma/providers/acp/core.js +17 -10
- package/build/src/akuma/providers/acp/events.js +38 -29
- package/build/src/akuma/providers/acp/index.js +13 -9
- package/build/src/akuma/providers/claude/events.js +8 -12
- package/build/src/akuma/providers/claude/index.d.ts +1 -0
- package/build/src/akuma/providers/claude/index.js +55 -26
- package/build/src/akuma/providers/claude/input.js +6 -2
- package/build/src/akuma/providers/codex-app-server/events.js +61 -36
- package/build/src/akuma/providers/codex-app-server/index.js +25 -13
- package/build/src/akuma/providers/grok-build/index.js +22 -25
- package/build/src/akuma/providers/index.js +2 -18
- package/build/src/akuma/providers/opencode-sdk/events.js +32 -18
- package/build/src/akuma/providers/opencode-sdk/index.js +26 -17
- package/build/src/akuma/providers/opencode-sdk/session.js +21 -5
- package/build/src/akuma/providers/pi/events.js +26 -19
- package/build/src/akuma/providers/pi/index.js +58 -40
- package/build/src/akuma/publication.js +9 -9
- package/build/src/akuma/request-execution.d.ts +6 -0
- package/build/src/akuma/request-execution.js +86 -0
- package/build/src/akuma/request-serve.d.ts +12 -1
- package/build/src/akuma/request-serve.js +19 -122
- package/build/src/akuma/request-wire.d.ts +2 -2
- package/build/src/akuma/request-wire.js +75 -102
- package/build/src/akuma/requests.js +2 -2
- package/build/src/akuma/{body-turn.d.ts → turn-drive.d.ts} +2 -25
- package/build/src/akuma/{body-turn.js → turn-drive.js} +20 -103
- package/build/src/akuma-body.js +6 -5
- package/build/src/body/amend.d.ts +4 -1
- package/build/src/body/amend.js +14 -6
- package/build/src/body/decode.js +2 -4
- package/build/src/body/envelope.js +2 -4
- package/build/src/body/region.d.ts +1 -2
- package/build/src/body/region.js +2 -70
- package/build/src/body/render.js +17 -12
- package/build/src/body/shape.js +1 -7
- package/build/src/cli/accepted.d.ts +1 -1
- package/build/src/cli/accepted.js +8 -1
- package/build/src/cli/commands/akuma-invoke.js +18 -6
- package/build/src/cli/commands/akuma.d.ts +0 -6
- package/build/src/cli/commands/akuma.js +11 -24
- package/build/src/cli/commands/amend.d.ts +2 -2
- package/build/src/cli/commands/amend.js +2 -4
- package/build/src/cli/commands/bind.d.ts +4 -4
- package/build/src/cli/commands/bind.js +16 -6
- package/build/src/cli/commands/contract-invoke.d.ts +25 -0
- package/build/src/cli/commands/contract-invoke.js +193 -0
- package/build/src/cli/commands/contract.d.ts +109 -10
- package/build/src/cli/commands/contract.js +339 -16
- package/build/src/cli/commands/install.d.ts +1 -1
- package/build/src/cli/commands/install.js +23 -15
- package/build/src/cli/commands/task-invoke.js +187 -67
- package/build/src/cli/commands/task-query.js +48 -24
- package/build/src/cli/commands/task.js +150 -38
- package/build/src/cli/coordinates.js +2 -4
- package/build/src/cli/invoke.js +92 -208
- package/build/src/cli/main.js +4 -2
- package/build/src/cli/parse.d.ts +3 -90
- package/build/src/cli/parse.js +27 -233
- package/build/src/cli/render/akuma-activity.d.ts +38 -0
- package/build/src/cli/render/akuma-activity.js +362 -0
- package/build/src/cli/render/akuma-tool-command.js +6 -7
- package/build/src/cli/render/akuma-tool.js +10 -8
- package/build/src/cli/render/akuma.d.ts +1 -1
- package/build/src/cli/render/akuma.js +61 -353
- package/build/src/cli/render/audit.js +5 -15
- package/build/src/cli/render/board.d.ts +1 -0
- package/build/src/cli/render/board.js +17 -0
- package/build/src/cli/render/catalog.js +81 -8
- package/build/src/cli/render/contract-history.d.ts +2 -0
- package/build/src/cli/render/contract-history.js +83 -0
- package/build/src/cli/render/contract-observation.d.ts +10 -0
- package/build/src/cli/render/contract-observation.js +58 -0
- package/build/src/cli/render/contract.d.ts +1 -2
- package/build/src/cli/render/contract.js +41 -142
- package/build/src/cli/render/kanshi.js +239 -215
- package/build/src/cli/render/receipt.js +2 -9
- package/build/src/cli/render/refusal.js +10 -15
- package/build/src/cli/render/region.js +22 -6
- package/build/src/cli/render/settings.js +4 -4
- package/build/src/cli/render/task.js +34 -14
- package/build/src/cli/render/terminal.js +16 -5
- package/build/src/cli/result.d.ts +3 -3
- package/build/src/cli/runtime.d.ts +6 -1
- package/build/src/cli/runtime.js +84 -63
- package/build/src/cli/selectors.js +2 -4
- package/build/src/cli/usage.js +6 -5
- package/build/src/contract-worktree.d.ts +1 -23
- package/build/src/contract-worktree.js +79 -155
- package/build/src/coordination/durable-file.js +7 -3
- package/build/src/coordination/sqlite-transaction-lock.js +29 -12
- package/build/src/core/facts/codec.js +7 -3
- package/build/src/core/facts/types.d.ts +1 -1
- package/build/src/core/subject.js +16 -9
- package/build/src/core/verbs/abandon.d.ts +1 -1
- package/build/src/core/verbs/abandon.js +1 -1
- package/build/src/core/verbs/amend.d.ts +1 -1
- package/build/src/core/verbs/amend.js +7 -7
- package/build/src/core/verbs/attestation.js +4 -1
- package/build/src/core/verbs/bind.d.ts +1 -1
- package/build/src/core/verbs/bind.js +1 -1
- package/build/src/core/verbs/placement.d.ts +1 -1
- package/build/src/core/verbs/placement.js +10 -8
- package/build/src/dispatch/index.js +8 -6
- package/build/src/duration.js +5 -1
- package/build/src/git/admission.js +5 -3
- package/build/src/git/hooks.d.ts +8 -0
- package/build/src/git/hooks.js +63 -14
- package/build/src/git/identity.js +1 -4
- package/build/src/git/integration.d.ts +2 -3
- package/build/src/git/integration.js +32 -39
- package/build/src/git/nuke.d.ts +1 -1
- package/build/src/git/nuke.js +110 -57
- package/build/src/git/observe.d.ts +13 -1
- package/build/src/git/observe.js +51 -44
- package/build/src/git/process.js +4 -2
- package/build/src/git/read-observation.js +10 -8
- package/build/src/git/reconcile.d.ts +22 -2
- package/build/src/git/reconcile.js +38 -274
- package/build/src/git/repository.d.ts +2 -0
- package/build/src/git/repository.js +13 -22
- package/build/src/git/scratch.d.ts +8 -5
- package/build/src/git/scratch.js +29 -2
- package/build/src/git/target-placement.d.ts +9 -10
- package/build/src/git/target-placement.js +59 -62
- package/build/src/git/tender.js +13 -46
- package/build/src/git/terminal-reconcile.d.ts +21 -0
- package/build/src/git/terminal-reconcile.js +278 -0
- package/build/src/git/terminal-seal.js +15 -12
- package/build/src/git/tree.js +5 -2
- package/build/src/git/workspace.d.ts +24 -2
- package/build/src/git/workspace.js +120 -16
- package/build/src/identity/coordinates.js +3 -1
- package/build/src/identity/selector.js +6 -3
- package/build/src/kanshi/fleet.d.ts +6 -0
- package/build/src/kanshi/fleet.js +27 -0
- package/build/src/kanshi/index.d.ts +1 -1
- package/build/src/kanshi/read.js +60 -48
- package/build/src/kanshi/report.d.ts +11 -23
- package/build/src/kanshi/select.js +25 -24
- package/build/src/library/address.d.ts +2 -1
- package/build/src/library/address.js +7 -8
- package/build/src/library/akuma-creation.js +20 -12
- package/build/src/library/audit.d.ts +0 -1
- package/build/src/library/audit.js +1 -2
- package/build/src/library/bind.d.ts +53 -5
- package/build/src/library/bind.js +98 -22
- package/build/src/library/catalog.d.ts +1 -0
- package/build/src/library/catalog.js +6 -3
- package/build/src/library/configuration.js +3 -1
- package/build/src/library/continuation.d.ts +15 -4
- package/build/src/library/continuation.js +24 -16
- package/build/src/library/contract-bind.d.ts +26 -0
- package/build/src/library/contract-bind.js +106 -0
- package/build/src/library/contract-operations.d.ts +77 -0
- package/build/src/library/contract-operations.js +130 -0
- package/build/src/library/contract-types.d.ts +95 -0
- package/build/src/library/contract-types.js +1 -0
- package/build/src/library/contract.d.ts +19 -154
- package/build/src/library/contract.js +46 -261
- package/build/src/library/fleet.d.ts +1 -1
- package/build/src/library/fleet.js +19 -11
- package/build/src/library/input.d.ts +2 -0
- package/build/src/library/input.js +14 -0
- package/build/src/library/keiyaku.d.ts +8 -7
- package/build/src/library/keiyaku.js +3 -3
- package/build/src/library/nuke.js +14 -5
- package/build/src/library/reconcile.d.ts +9 -4
- package/build/src/library/reconcile.js +30 -24
- package/build/src/library/refusal.d.ts +13 -5
- package/build/src/library/refusal.js +7 -0
- package/build/src/library/region.d.ts +8 -7
- package/build/src/library/region.js +31 -11
- package/build/src/library/repo.js +2 -2
- package/build/src/markdown/lex.js +9 -2
- package/build/src/markdown/parse.js +11 -7
- package/build/src/markdown/query.js +4 -2
- package/build/src/protocol/amend.js +3 -1
- package/build/src/protocol/attempt.d.ts +7 -3
- package/build/src/protocol/attempt.js +9 -5
- package/build/src/protocol/audit.d.ts +1 -1
- package/build/src/protocol/audit.js +4 -14
- package/build/src/protocol/bind.d.ts +19 -6
- package/build/src/protocol/bind.js +28 -13
- package/build/src/protocol/completion.d.ts +0 -1
- package/build/src/protocol/completion.js +1 -3
- package/build/src/protocol/deliver.d.ts +1 -3
- package/build/src/protocol/deliver.js +15 -39
- package/build/src/protocol/intent.d.ts +1 -0
- package/build/src/protocol/intent.js +9 -7
- package/build/src/protocol/operations.d.ts +3 -7
- package/build/src/protocol/operations.js +5 -3
- package/build/src/protocol/placement.d.ts +0 -1
- package/build/src/protocol/placement.js +6 -6
- package/build/src/protocol/read/observation.d.ts +11 -0
- package/build/src/protocol/read/observation.js +37 -0
- package/build/src/protocol/read/status.d.ts +23 -12
- package/build/src/protocol/read/status.js +90 -72
- package/build/src/protocol/reconcile.d.ts +1 -0
- package/build/src/protocol/reconcile.js +2 -3
- package/build/src/protocol/reintegrate.js +1 -1
- package/build/src/protocol/review.d.ts +0 -1
- package/build/src/protocol/review.js +15 -22
- package/build/src/protocol/run.d.ts +1 -0
- package/build/src/protocol/run.js +4 -5
- package/build/src/runtime/proc/launch.d.ts +33 -0
- package/build/src/runtime/proc/launch.js +98 -0
- package/build/src/runtime/proc/line-rpc.js +9 -3
- package/build/src/runtime/proc/run.d.ts +12 -6
- package/build/src/runtime/proc/run.js +78 -21
- package/build/src/runtime/proc/stdio.js +7 -10
- package/build/src/settings.js +6 -2
- package/build/src/settlement/holder.js +13 -10
- package/build/src/settlement/settle.js +39 -6
- package/build/src/task/board.js +12 -6
- package/build/src/task/compose.js +85 -22
- package/build/src/task/context.js +21 -8
- package/build/src/task/document.js +46 -10
- package/build/src/task/identity.js +5 -2
- package/build/src/task/index.d.ts +0 -1
- package/build/src/task/index.js +119 -34
- package/build/src/task/input.js +29 -7
- package/build/src/task/mutation.js +61 -19
- package/build/src/task/operations.d.ts +6 -1
- package/build/src/task/operations.js +83 -29
- package/build/src/task/query.js +55 -26
- package/build/src/task/store.d.ts +3 -1
- package/build/src/task/store.js +81 -17
- package/build/src/verification/execution.js +14 -11
- package/build/src/workspace-place.js +19 -7
- package/build/src/world.js +16 -6
- package/package.json +8 -3
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Tasks,
|
|
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) {
|
|
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) {
|
|
38
|
-
|
|
39
|
-
|
|
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],
|
|
55
|
-
...(
|
|
56
|
-
...(
|
|
57
|
-
...(
|
|
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 }),
|
|
71
|
-
...(
|
|
72
|
-
...(
|
|
73
|
-
...(
|
|
74
|
-
...(
|
|
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 {
|
|
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 {
|
|
89
|
-
|
|
90
|
-
|
|
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 }),
|
|
94
|
-
...(
|
|
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 {
|
|
107
|
-
|
|
108
|
-
|
|
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 }),
|
|
111
|
-
...(
|
|
112
|
-
|
|
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 }),
|
|
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":
|
|
122
|
-
|
|
123
|
-
case "
|
|
124
|
-
|
|
125
|
-
case "
|
|
126
|
-
|
|
127
|
-
|
|
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":
|
|
143
|
-
|
|
144
|
-
case "task.
|
|
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":
|
|
148
|
-
|
|
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":
|
|
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":
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
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" ||
|
|
177
|
-
|
|
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":
|
|
214
|
-
|
|
215
|
-
case "
|
|
216
|
-
|
|
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":
|
|
232
|
-
|
|
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" ||
|
|
237
|
-
|
|
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" &&
|
|
241
|
-
|
|
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" ||
|
|
249
|
-
|
|
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) {
|
|
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(
|
|
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" &&
|
|
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() {
|
|
159
|
-
|
|
160
|
-
|
|
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":
|
|
219
|
-
|
|
220
|
-
case "
|
|
221
|
-
|
|
222
|
-
case "
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
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
|
}
|