@astrosheep/keiyaku 4.6.8 → 4.6.9
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 +40 -14
- package/build/plugins/claude/.claude-plugin/plugin.json +1 -1
- package/build/plugins/claude/skills/keiyaku/SKILL.md +5 -6
- package/build/plugins/claude/skills/keiyaku-akuma/SKILL.md +1 -1
- package/build/plugins/claude/skills/keiyaku-akuma/references/automation.md +8 -8
- package/build/plugins/claude/skills/keiyaku-babysit/SKILL.md +1 -1
- package/build/plugins/claude/skills/keiyaku-bind/SKILL.md +9 -9
- package/build/plugins/claude/skills/keiyaku-debt/SKILL.md +91 -0
- package/build/plugins/claude/skills/keiyaku-workflow/SKILL.md +2 -2
- package/build/plugins/codex/.codex-plugin/plugin.json +1 -1
- package/build/plugins/codex/skills/keiyaku/SKILL.md +5 -6
- package/build/plugins/codex/skills/keiyaku-akuma/SKILL.md +1 -1
- package/build/plugins/codex/skills/keiyaku-akuma/references/automation.md +8 -8
- package/build/plugins/codex/skills/keiyaku-babysit/SKILL.md +1 -1
- package/build/plugins/codex/skills/keiyaku-bind/SKILL.md +9 -9
- package/build/plugins/codex/skills/keiyaku-debt/SKILL.md +91 -0
- package/build/plugins/codex/skills/keiyaku-workflow/SKILL.md +2 -2
- package/build/plugins/opencode/index.js +1 -1
- package/build/plugins/opencode/skills/keiyaku/SKILL.md +5 -6
- package/build/plugins/opencode/skills/keiyaku-akuma/SKILL.md +1 -1
- package/build/plugins/opencode/skills/keiyaku-akuma/references/automation.md +8 -8
- package/build/plugins/opencode/skills/keiyaku-babysit/SKILL.md +1 -1
- package/build/plugins/opencode/skills/keiyaku-bind/SKILL.md +9 -9
- package/build/plugins/opencode/skills/keiyaku-debt/SKILL.md +91 -0
- package/build/plugins/opencode/skills/keiyaku-workflow/SKILL.md +2 -2
- package/build/skills/keiyaku/SKILL.md +5 -6
- package/build/skills/keiyaku-akuma/SKILL.md +1 -1
- package/build/skills/keiyaku-akuma/references/automation.md +8 -8
- package/build/skills/keiyaku-babysit/SKILL.md +1 -1
- package/build/skills/keiyaku-bind/SKILL.md +9 -9
- package/build/skills/keiyaku-debt/SKILL.md +91 -0
- package/build/skills/keiyaku-workflow/SKILL.md +2 -2
- package/build/src/akuma/akuma-instance.d.ts +2 -0
- package/build/src/akuma/akuma-instance.js +10 -0
- package/build/src/akuma/akuma-observe.d.ts +33 -8
- package/build/src/akuma/akuma-observe.js +88 -64
- package/build/src/akuma/akuma-owner.d.ts +11 -2
- package/build/src/akuma/akuma-owner.js +45 -35
- package/build/src/akuma/akuma-selection-execution.js +9 -1
- package/build/src/akuma/akuma-stream.d.ts +22 -0
- package/build/src/akuma/akuma-stream.js +116 -0
- package/build/src/akuma/akuma-wait.d.ts +1 -40
- package/build/src/akuma/akuma-wait.js +23 -84
- package/build/src/akuma/akuma.d.ts +17 -11
- package/build/src/akuma/akuma.js +2 -0
- package/build/src/akuma/allowed.d.ts +7 -12
- package/build/src/akuma/allowed.js +13 -4
- package/build/src/akuma/body-supervisor.d.ts +5 -5
- package/build/src/akuma/body-supervisor.js +22 -20
- package/build/src/akuma/body.js +28 -1
- package/build/src/akuma/call-request.d.ts +12 -22
- package/build/src/akuma/heart/activity-schema.d.ts +12 -0
- package/build/src/akuma/heart/activity-schema.js +6 -0
- package/build/src/akuma/heart/index.d.ts +59 -2
- package/build/src/akuma/heart/index.js +87 -8
- package/build/src/akuma/heart/rows.js +5 -3
- package/build/src/akuma/heart/soul.d.ts +9 -0
- package/build/src/akuma/heart/soul.js +29 -0
- package/build/src/akuma/heart/storage.d.ts +15 -0
- package/build/src/akuma/heart/storage.js +55 -0
- package/build/src/akuma/heart/timeline.d.ts +7 -0
- package/build/src/akuma/heart/timeline.js +10 -0
- package/build/src/akuma/index.d.ts +1 -0
- package/build/src/akuma/projection.d.ts +25 -0
- package/build/src/akuma/projection.js +24 -7
- package/build/src/akuma/provider-recipe.d.ts +11 -0
- package/build/src/akuma/provider-recipe.js +23 -0
- package/build/src/akuma/provider.d.ts +25 -0
- package/build/src/akuma/provider.js +99 -7
- package/build/src/akuma/providers/acp/events.js +25 -2
- package/build/src/akuma/providers/claude/events.js +76 -10
- package/build/src/akuma/providers/claude/index.js +2 -5
- package/build/src/akuma/providers/codex-app-server/events.js +17 -2
- package/build/src/akuma/providers/codex-app-server/index.js +15 -9
- package/build/src/akuma/providers/decode.d.ts +8 -0
- package/build/src/akuma/providers/decode.js +21 -0
- package/build/src/akuma/providers/grok-build/index.js +10 -26
- package/build/src/akuma/providers/opencode-sdk/event-stream.d.ts +3 -3
- package/build/src/akuma/providers/opencode-sdk/event-stream.js +2 -25
- package/build/src/akuma/providers/opencode-sdk/events.d.ts +7 -43
- package/build/src/akuma/providers/opencode-sdk/events.js +147 -284
- package/build/src/akuma/providers/opencode-sdk/index.js +267 -421
- package/build/src/akuma/providers/opencode-sdk/native-http.d.ts +9 -0
- package/build/src/akuma/providers/opencode-sdk/native-http.js +69 -0
- package/build/src/akuma/providers/opencode-sdk/session.d.ts +42 -36
- package/build/src/akuma/providers/opencode-sdk/session.js +75 -82
- package/build/src/akuma/providers/paseo/events.d.ts +8 -0
- package/build/src/akuma/providers/paseo/events.js +58 -11
- package/build/src/akuma/providers/paseo/index.js +11 -7
- package/build/src/akuma/providers/pi/events.d.ts +2 -0
- package/build/src/akuma/providers/pi/events.js +32 -24
- package/build/src/akuma/providers/pi/index.js +21 -35
- package/build/src/akuma/request-lifecycle.d.ts +1 -2
- package/build/src/akuma/request-lifecycle.js +2 -8
- package/build/src/akuma/request-rendezvous.js +38 -55
- package/build/src/akuma/request-serve.d.ts +1 -1
- package/build/src/akuma/request-serve.js +77 -113
- package/build/src/akuma/selection-observation.d.ts +57 -51
- package/build/src/akuma/selection-observation.js +3 -3
- package/build/src/akuma/turn-drive.d.ts +3 -0
- package/build/src/akuma/turn-drive.js +26 -5
- package/build/src/akuma-body.js +12 -22
- package/build/src/cli/akuma-caller.js +10 -0
- package/build/src/cli/commands/akuma-grammar.js +3 -4
- package/build/src/cli/commands/akuma.js +13 -51
- package/build/src/cli/commands/contract-grammar.d.ts +7 -6
- package/build/src/cli/commands/contract-grammar.js +27 -32
- package/build/src/cli/commands/contract-help.d.ts +16 -7
- package/build/src/cli/commands/contract-help.js +20 -11
- package/build/src/cli/commands/contract.js +11 -11
- package/build/src/cli/commands/debt-grammar.d.ts +19 -0
- package/build/src/cli/commands/debt-grammar.js +323 -0
- package/build/src/cli/commands/debt-query.d.ts +5 -0
- package/build/src/cli/commands/{task-query.js → debt-query.js} +9 -9
- package/build/src/cli/commands/{task.d.ts → debt.d.ts} +2 -2
- package/build/src/cli/commands/{task.js → debt.js} +83 -143
- package/build/src/cli/coordinates.d.ts +1 -1
- package/build/src/cli/coordinates.js +1 -1
- package/build/src/cli/parse.d.ts +4 -4
- package/build/src/cli/parse.js +17 -16
- package/build/src/cli/render/akuma-activity.d.ts +11 -83
- package/build/src/cli/render/akuma-activity.js +20 -382
- package/build/src/cli/render/catalog.d.ts +2 -2
- package/build/src/cli/render/catalog.js +5 -5
- package/build/src/cli/render/contract.js +2 -2
- package/build/src/cli/render/debt.d.ts +28 -0
- package/build/src/cli/render/{task.js → debt.js} +51 -112
- package/build/src/cli/render/kanshi.js +28 -28
- package/build/src/cli/render/marks.d.ts +5 -5
- package/build/src/cli/render/marks.js +4 -10
- package/build/src/cli/render/nuke.js +1 -1
- package/build/src/cli/runtime.js +3 -3
- package/build/src/cli/scan.d.ts +1 -1
- package/build/src/cli/usage.d.ts +1 -1
- package/build/src/cli/usage.js +4 -4
- package/build/src/contract-worktree.js +3 -3
- package/build/src/debt/board.d.ts +160 -0
- package/build/src/{task → debt}/board.js +89 -89
- package/build/src/debt/catalog.d.ts +11 -0
- package/build/src/debt/catalog.js +59 -0
- package/build/src/{task → debt}/context.d.ts +1 -1
- package/build/src/{task → debt}/context.js +1 -1
- package/build/src/{task → debt}/created-observation.d.ts +6 -10
- package/build/src/{task → debt}/created-observation.js +7 -7
- package/build/src/debt/document.d.ts +37 -0
- package/build/src/{task → debt}/document.js +37 -37
- package/build/src/debt/identity.d.ts +21 -0
- package/build/src/{task → debt}/identity.js +35 -35
- package/build/src/debt/index.d.ts +111 -0
- package/build/src/debt/index.js +203 -0
- package/build/src/{task → debt}/input.d.ts +8 -8
- package/build/src/{task → debt}/input.js +21 -21
- package/build/src/debt/lifecycle-operations.d.ts +6 -0
- package/build/src/{task → debt}/lifecycle-operations.js +27 -31
- package/build/src/debt/mutation-result.d.ts +981 -0
- package/build/src/debt/mutation-result.js +109 -0
- package/build/src/debt/mutation.d.ts +424 -0
- package/build/src/debt/mutation.js +223 -0
- package/build/src/debt/operation-types.d.ts +71 -0
- package/build/src/debt/operations.d.ts +28 -0
- package/build/src/{task → debt}/operations.js +59 -60
- package/build/src/debt/query.d.ts +76 -0
- package/build/src/{task → debt}/query.js +55 -55
- package/build/src/{task → debt}/store.d.ts +13 -13
- package/build/src/{task → debt}/store.js +58 -49
- package/build/src/debt/view.d.ts +4 -0
- package/build/src/debt/view.js +7 -0
- package/build/src/identity/coordinates.d.ts +1 -1
- package/build/src/index.d.ts +13 -13
- package/build/src/index.js +9 -9
- package/build/src/kanshi/index.d.ts +1 -1
- package/build/src/kanshi/read.js +33 -33
- package/build/src/kanshi/report.d.ts +7 -7
- package/build/src/kanshi/select.js +4 -4
- package/build/src/library/akumas.d.ts +2 -3
- package/build/src/library/bind.d.ts +3 -3
- package/build/src/library/bind.js +5 -5
- package/build/src/library/contract-creation.js +5 -5
- package/build/src/library/contract-execution.js +4 -4
- package/build/src/library/contract-types.d.ts +2 -2
- package/build/src/library/input.d.ts +2 -2
- package/build/src/library/input.js +5 -5
- package/build/src/library/invocation.js +2 -2
- package/build/src/library/nuke.js +3 -3
- package/build/src/library/outcome.d.ts +126 -126
- package/build/src/library/outcome.js +3 -3
- package/build/src/library/selection.d.ts +1 -4
- package/build/src/library/selection.js +11 -62
- package/build/src/plugin/public.d.ts +5 -0
- package/build/src/plugin/runtime.js +3 -1
- package/build/src/runtime/proc/windows-launch.exe +0 -0
- package/build/src/settlement/fence.d.ts +3 -3
- package/build/src/settlement/fence.js +4 -4
- package/build/src/settlement/holder.d.ts +16 -16
- package/build/src/settlement/holder.js +69 -63
- package/build/src/settlement/settle.d.ts +5 -5
- package/build/src/settlement/settle.js +53 -53
- package/package.json +12 -6
- package/plugins/paseo/plugin/index.server.ts +17 -0
- package/plugins/paseo/plugin/paseo-plugin.json +4 -0
- package/plugins/paseo/plugin/server/attach.ts +52 -0
- package/plugins/paseo/plugin/server/keiyaku.ts +44 -0
- package/plugins/paseo/plugin/server/message.ts +60 -0
- package/plugins/paseo/plugin/server/mirror.ts +193 -0
- package/plugins/paseo/plugin/server/model.ts +14 -0
- package/plugins/paseo/plugin/server/provider.ts +276 -0
- package/plugins/paseo/plugin/server/sdk-worker.ts +237 -0
- package/plugins/paseo/plugin/server/sdk.ts +289 -0
- package/plugins/paseo/plugin/server/stop.ts +26 -0
- package/plugins/paseo/plugin/server/transport.ts +35 -0
- package/plugins/paseo/plugin/shared/attach-rpc.ts +10 -0
- package/plugins/paseo/plugin/shared/refresh-rpc.ts +6 -0
- package/plugins/paseo/plugin/tsconfig.json +6 -0
- package/skills/keiyaku/SKILL.md +5 -6
- package/skills/keiyaku-akuma/SKILL.md +1 -1
- package/skills/keiyaku-akuma/references/automation.md +8 -8
- package/skills/keiyaku-babysit/SKILL.md +1 -1
- package/skills/keiyaku-bind/SKILL.md +9 -9
- package/skills/keiyaku-debt/SKILL.md +91 -0
- package/skills/keiyaku-workflow/SKILL.md +2 -2
- package/build/plugins/claude/skills/keiyaku-task/SKILL.md +0 -104
- package/build/plugins/codex/skills/keiyaku-task/SKILL.md +0 -104
- package/build/plugins/opencode/skills/keiyaku-task/SKILL.md +0 -104
- package/build/skills/keiyaku-task/SKILL.md +0 -104
- package/build/src/cli/commands/task-grammar.d.ts +0 -19
- package/build/src/cli/commands/task-grammar.js +0 -384
- package/build/src/cli/commands/task-query.d.ts +0 -5
- package/build/src/cli/render/task.d.ts +0 -39
- package/build/src/task/board.d.ts +0 -168
- package/build/src/task/catalog.d.ts +0 -11
- package/build/src/task/catalog.js +0 -59
- package/build/src/task/compose-language.d.ts +0 -57
- package/build/src/task/compose-language.js +0 -364
- package/build/src/task/compose-parser.d.ts +0 -32
- package/build/src/task/compose-parser.js +0 -180
- package/build/src/task/compose.d.ts +0 -16
- package/build/src/task/compose.js +0 -189
- package/build/src/task/document.d.ts +0 -39
- package/build/src/task/identity.d.ts +0 -21
- package/build/src/task/index.d.ts +0 -138
- package/build/src/task/index.js +0 -269
- package/build/src/task/lifecycle-operations.d.ts +0 -6
- package/build/src/task/mutation-result.d.ts +0 -1726
- package/build/src/task/mutation-result.js +0 -198
- package/build/src/task/mutation.d.ts +0 -590
- package/build/src/task/mutation.js +0 -262
- package/build/src/task/operation-types.d.ts +0 -71
- package/build/src/task/operations.d.ts +0 -28
- package/build/src/task/query.d.ts +0 -76
- package/build/src/task/view.d.ts +0 -4
- package/build/src/task/view.js +0 -7
- package/skills/keiyaku-task/SKILL.md +0 -104
- /package/build/src/{task → debt}/operation-types.js +0 -0
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
import { CliUsageError, DEBT_FAMILY_USAGE_GUIDE, unknownCommandGuide } from "../usage.js";
|
|
2
|
+
import { scanArgs } from "../scan.js";
|
|
3
|
+
import { parseDebtNamespaceSelector } from "../../debt/catalog.js";
|
|
4
|
+
import { parseDebtId } from "../../debt/identity.js";
|
|
5
|
+
import { parseDebtQueryExpression, validateDebtLimit, validateDebtParent, } from "./debt-query.js";
|
|
6
|
+
const COMMON = { json: "boolean" };
|
|
7
|
+
const DEBT_COMMAND_SPECS = {
|
|
8
|
+
add: {
|
|
9
|
+
arity: [0, 1],
|
|
10
|
+
stdin: "document",
|
|
11
|
+
flags: {
|
|
12
|
+
...COMMON,
|
|
13
|
+
namespace: "value",
|
|
14
|
+
state: "value",
|
|
15
|
+
priority: "value",
|
|
16
|
+
needs: "repeat",
|
|
17
|
+
parent: "value",
|
|
18
|
+
supersedes: "repeat",
|
|
19
|
+
relates: "repeat",
|
|
20
|
+
body: "value",
|
|
21
|
+
note: "value",
|
|
22
|
+
actor: "value",
|
|
23
|
+
},
|
|
24
|
+
usage: `debt add <TITLE> [--namespace <ns>] [--priority 0..3]
|
|
25
|
+
[--state open|done|drop]
|
|
26
|
+
[--note <text>] [--actor <actor>]
|
|
27
|
+
[--needs <DebtId>]... [--parent <DebtId>]
|
|
28
|
+
[--supersedes <DebtId>]... [--relates <DebtId>]...
|
|
29
|
+
[--body <text>]
|
|
30
|
+
debt add [--namespace <ns>] [--actor <actor>] -`,
|
|
31
|
+
purpose: "Create a Debt from flags or a Debt document on stdin.",
|
|
32
|
+
details: "The stdin document is YAML front matter (title, state, priority, needs, parent, supersedes, relates, note) followed by a Markdown body.",
|
|
33
|
+
},
|
|
34
|
+
show: {
|
|
35
|
+
arity: [1, Number.POSITIVE_INFINITY],
|
|
36
|
+
flags: COMMON,
|
|
37
|
+
usage: "debt show <DebtId>...",
|
|
38
|
+
purpose: "Read one or more Debts and their relationships.",
|
|
39
|
+
},
|
|
40
|
+
ls: {
|
|
41
|
+
arity: [0, 1],
|
|
42
|
+
flags: { ...COMMON, closed: "boolean", all: "boolean", world: "boolean", limit: "value" },
|
|
43
|
+
usage: "debt ls [<namespace-selector>] [--closed | --all] [--world] [--limit <n>]",
|
|
44
|
+
purpose: "List Debts in the selected namespace.",
|
|
45
|
+
details: [
|
|
46
|
+
"With no selector, lists the current directory Debt context.",
|
|
47
|
+
"debt/ selects the root namespace; --world lists every namespace in the current Debt world.",
|
|
48
|
+
].join("\n"),
|
|
49
|
+
},
|
|
50
|
+
ready: {
|
|
51
|
+
arity: [0, 0],
|
|
52
|
+
flags: { ...COMMON, world: "boolean", parent: "value", limit: "value" },
|
|
53
|
+
usage: "debt ready [--world] [--parent <DebtId>] [--limit <n>]",
|
|
54
|
+
purpose: "List open Debts whose every dependency is complete or dropped.",
|
|
55
|
+
details: "--world lists every namespace in the current Debt world.",
|
|
56
|
+
},
|
|
57
|
+
blocked: {
|
|
58
|
+
arity: [0, 0],
|
|
59
|
+
flags: { ...COMMON, world: "boolean", parent: "value", limit: "value" },
|
|
60
|
+
usage: "debt blocked [--world] [--parent <DebtId>] [--limit <n>]",
|
|
61
|
+
purpose: "List Debts with unmet dependencies.",
|
|
62
|
+
details: "--world lists every namespace in the current Debt world.",
|
|
63
|
+
},
|
|
64
|
+
query: {
|
|
65
|
+
arity: [0, 0],
|
|
66
|
+
flags: {
|
|
67
|
+
...COMMON,
|
|
68
|
+
where: "value",
|
|
69
|
+
world: "boolean",
|
|
70
|
+
closed: "boolean",
|
|
71
|
+
all: "boolean",
|
|
72
|
+
sort: "value",
|
|
73
|
+
limit: "value",
|
|
74
|
+
},
|
|
75
|
+
usage: `debt query [--where <expression>] [--closed | --all] [--world]
|
|
76
|
+
[--sort priority|created|updated|id] [--limit <n>]`,
|
|
77
|
+
purpose: "Filter and sort Debts with a boolean expression.",
|
|
78
|
+
details: [
|
|
79
|
+
"fields: state priority title id parent under needs blocks ready blocked created updated",
|
|
80
|
+
"operators: = != < > <= >= ~ and or not ( )",
|
|
81
|
+
"sort: priority and created ascend; updated descends; id is lexical. Default: priority.",
|
|
82
|
+
"--world lists every namespace in the current Debt world.",
|
|
83
|
+
"By default only active Debts match; --closed selects terminal Debts, --all includes both.",
|
|
84
|
+
"examples:",
|
|
85
|
+
" keiyaku debt query --where 'priority <= 1 and ready' --world",
|
|
86
|
+
" keiyaku debt query --where 'updated < 2026-08-06T00:00:00.000Z' --world",
|
|
87
|
+
].join("\n"),
|
|
88
|
+
},
|
|
89
|
+
tree: {
|
|
90
|
+
arity: [1, 1],
|
|
91
|
+
flags: COMMON,
|
|
92
|
+
usage: "debt tree <DebtId>",
|
|
93
|
+
purpose: "Show a Debt and its parent/child breakdown.",
|
|
94
|
+
},
|
|
95
|
+
doctor: {
|
|
96
|
+
arity: [0, 0],
|
|
97
|
+
flags: COMMON,
|
|
98
|
+
usage: "debt doctor",
|
|
99
|
+
purpose: "Check Debts for inconsistencies without changing them.",
|
|
100
|
+
},
|
|
101
|
+
update: {
|
|
102
|
+
arity: [1, 1],
|
|
103
|
+
flags: {
|
|
104
|
+
...COMMON,
|
|
105
|
+
title: "value",
|
|
106
|
+
body: "value",
|
|
107
|
+
append: "value",
|
|
108
|
+
note: "value",
|
|
109
|
+
priority: "value",
|
|
110
|
+
needs: "repeat",
|
|
111
|
+
"drop-needs": "repeat",
|
|
112
|
+
parent: "value",
|
|
113
|
+
"no-parent": "boolean",
|
|
114
|
+
supersedes: "repeat",
|
|
115
|
+
"drop-supersedes": "repeat",
|
|
116
|
+
relates: "repeat",
|
|
117
|
+
"drop-relates": "repeat",
|
|
118
|
+
},
|
|
119
|
+
usage: `debt update <DebtId> [--title <text>] [--body <text>|- | --append <text>]
|
|
120
|
+
[--note <text>]
|
|
121
|
+
[--priority 0..3] [--needs <DebtId>]... [--drop-needs <DebtId>]...
|
|
122
|
+
[--parent <DebtId> | --no-parent]
|
|
123
|
+
[--supersedes <DebtId>]... [--drop-supersedes <DebtId>]...
|
|
124
|
+
[--relates <DebtId>]... [--drop-relates <DebtId>]...`,
|
|
125
|
+
purpose: "Change a Debt's fields and relationships.",
|
|
126
|
+
details: [
|
|
127
|
+
"--body replaces the body; --append adds text after it, separated by a newline when needed.",
|
|
128
|
+
"--body - reads replacement body text from stdin.",
|
|
129
|
+
].join("\n"),
|
|
130
|
+
},
|
|
131
|
+
done: {
|
|
132
|
+
arity: [1, Number.POSITIVE_INFINITY],
|
|
133
|
+
flags: { ...COMMON, note: "value" },
|
|
134
|
+
usage: "debt done <DebtId>... [--note <text>]",
|
|
135
|
+
purpose: "Mark one or more Debts done.",
|
|
136
|
+
},
|
|
137
|
+
drop: {
|
|
138
|
+
arity: [1, Number.POSITIVE_INFINITY],
|
|
139
|
+
flags: { ...COMMON, note: "value" },
|
|
140
|
+
usage: "debt drop <DebtId>... [--note <text>]",
|
|
141
|
+
purpose: "Mark one or more Debts as no longer needed.",
|
|
142
|
+
},
|
|
143
|
+
context: {
|
|
144
|
+
arity: [0, 1],
|
|
145
|
+
flags: COMMON,
|
|
146
|
+
usage: "debt context [<namespace>]",
|
|
147
|
+
purpose: "Set or read the default Debt namespace for this directory.",
|
|
148
|
+
details: "Omit <namespace> to read the current context; use / to reset it to the root namespace.",
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
export function isDebtAction(value) {
|
|
152
|
+
return value !== undefined && Object.hasOwn(DEBT_COMMAND_SPECS, value);
|
|
153
|
+
}
|
|
154
|
+
export function renderDebtHelp(action) {
|
|
155
|
+
if (action !== undefined) {
|
|
156
|
+
const spec = DEBT_COMMAND_SPECS[action];
|
|
157
|
+
return `${spec.purpose}\n\n${renderDebtUsage(action)}${spec.details === undefined ? "" : `\n\n${spec.details}`}`;
|
|
158
|
+
}
|
|
159
|
+
const nameWidth = Math.max(...Object.keys(DEBT_COMMAND_SPECS).map((name) => name.length));
|
|
160
|
+
return [
|
|
161
|
+
"usage keiyaku debt <command> ...",
|
|
162
|
+
" keiyaku debt <command> --help shows that command's complete usage",
|
|
163
|
+
"",
|
|
164
|
+
...Object.entries(DEBT_COMMAND_SPECS).map(([name, spec]) => ` ${name.padEnd(nameWidth)} ${spec.purpose}`),
|
|
165
|
+
].join("\n");
|
|
166
|
+
}
|
|
167
|
+
function renderDebtUsage(action) {
|
|
168
|
+
return DEBT_COMMAND_SPECS[action].usage
|
|
169
|
+
.split("\n")
|
|
170
|
+
.map((line, index) => {
|
|
171
|
+
if (index === 0 || line.trimStart().startsWith("debt ")) {
|
|
172
|
+
const command = line.trimStart().startsWith("debt ") ? `keiyaku ${line.trim()}` : `keiyaku ${line}`;
|
|
173
|
+
return `${index === 0 ? "usage " : " "}${command}`;
|
|
174
|
+
}
|
|
175
|
+
return ` ${line.trim()}`;
|
|
176
|
+
})
|
|
177
|
+
.join("\n");
|
|
178
|
+
}
|
|
179
|
+
function debtUsage(action) {
|
|
180
|
+
const lines = DEBT_COMMAND_SPECS[action].usage.split("\n");
|
|
181
|
+
return lines
|
|
182
|
+
.map((line, index) => {
|
|
183
|
+
if (index === 0 || line.trimStart().startsWith("debt "))
|
|
184
|
+
return `keiyaku ${line.trim()}`;
|
|
185
|
+
return ` ${line.trim()}`;
|
|
186
|
+
})
|
|
187
|
+
.join("\n");
|
|
188
|
+
}
|
|
189
|
+
export function debtUsageGuide(action) {
|
|
190
|
+
return {
|
|
191
|
+
scope: `keiyaku debt ${action}`,
|
|
192
|
+
accepts: debtUsage(action),
|
|
193
|
+
help: `keiyaku debt ${action} --help`,
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
/** One scan spec per Debt action: `-` reads the document, or `--body -` replaces an update body. */
|
|
197
|
+
function scanSpec(action, spec) {
|
|
198
|
+
return {
|
|
199
|
+
subject: `debt ${action}`,
|
|
200
|
+
flags: spec.flags,
|
|
201
|
+
...(spec.stdin === undefined ? {} : { stdin: spec.stdin }),
|
|
202
|
+
stdinRefusal: "stdin marker '-' is not valid here",
|
|
203
|
+
...(action === "update" ? { stdinValue: "body" } : {}),
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
function validateUpdate(scanned, fail) {
|
|
207
|
+
const flags = scanned.flags;
|
|
208
|
+
if (flags.body !== undefined && flags.append !== undefined)
|
|
209
|
+
fail("--body and --append are mutually exclusive");
|
|
210
|
+
if (flags.parent !== undefined && flags["no-parent"] === true)
|
|
211
|
+
fail("--parent and --no-parent are mutually exclusive");
|
|
212
|
+
if (Object.keys(flags).every((name) => name === "json"))
|
|
213
|
+
fail("debt update requires at least one patch option");
|
|
214
|
+
}
|
|
215
|
+
function validateDebtReadFlags(action, flags, fail) {
|
|
216
|
+
if ((action === "ls" || action === "query") && flags.closed === true && flags.all === true)
|
|
217
|
+
fail("--closed and --all are mutually exclusive");
|
|
218
|
+
if (action === "ls" && flags.world === true) {
|
|
219
|
+
// An explicit selector is checked below, after positional shape is known.
|
|
220
|
+
}
|
|
221
|
+
if (typeof flags.limit === "string") {
|
|
222
|
+
try {
|
|
223
|
+
validateDebtLimit(flags.limit);
|
|
224
|
+
}
|
|
225
|
+
catch (error) {
|
|
226
|
+
fail(error instanceof Error ? error.message : String(error));
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
if (typeof flags.sort === "string" &&
|
|
230
|
+
flags.sort !== "priority" &&
|
|
231
|
+
flags.sort !== "created" &&
|
|
232
|
+
flags.sort !== "updated" &&
|
|
233
|
+
flags.sort !== "id") {
|
|
234
|
+
fail("--sort must be priority, created, updated, or id");
|
|
235
|
+
}
|
|
236
|
+
if ((action === "ready" || action === "blocked") && typeof flags.parent === "string") {
|
|
237
|
+
try {
|
|
238
|
+
validateDebtParent(flags.parent);
|
|
239
|
+
}
|
|
240
|
+
catch (error) {
|
|
241
|
+
fail(error instanceof Error ? error.message : String(error));
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
/** Actions whose positionals are all addressed DebtIds validated by the native owner. */
|
|
246
|
+
const DEBT_ID_ACTIONS = new Set(["show", "tree", "update", "done", "drop"]);
|
|
247
|
+
/** Validate every addressed DebtId positional through the native owner before any read or write. */
|
|
248
|
+
function validateDebtIdPositionals(positionals, fail) {
|
|
249
|
+
for (const debtId of positionals) {
|
|
250
|
+
try {
|
|
251
|
+
parseDebtId(debtId);
|
|
252
|
+
}
|
|
253
|
+
catch (error) {
|
|
254
|
+
fail(error instanceof Error ? error.message : String(error));
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
/** Validate an explicit `debt ls` namespace selector through the native owner. */
|
|
259
|
+
function validateListSelector(selector, fail) {
|
|
260
|
+
if (selector !== "debt/" && (!selector.startsWith("debt/") || !selector.endsWith("/")))
|
|
261
|
+
fail(`invalid Debt namespace selector: ${selector}`);
|
|
262
|
+
if (selector === "debt/")
|
|
263
|
+
return;
|
|
264
|
+
try {
|
|
265
|
+
parseDebtNamespaceSelector(selector);
|
|
266
|
+
}
|
|
267
|
+
catch (error) {
|
|
268
|
+
fail(error instanceof Error ? error.message : String(error));
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
function validateDebtScan(action, scanned, fail) {
|
|
272
|
+
const spec = DEBT_COMMAND_SPECS[action], { positionals, flags, stdin } = scanned;
|
|
273
|
+
if (positionals.length < spec.arity[0])
|
|
274
|
+
fail(spec.arity[1] === 1 ? `debt ${action} requires a DebtId` : `debt ${action} requires at least one DebtId`);
|
|
275
|
+
if (positionals.length > spec.arity[1])
|
|
276
|
+
fail(spec.arity[1] === 0
|
|
277
|
+
? `debt ${action} accepts no positional arguments`
|
|
278
|
+
: `debt ${action} accepts at most ${spec.arity[1]} positional argument${spec.arity[1] === 1 ? "" : "s"}`);
|
|
279
|
+
if (action === "add" && (stdin === "document") === (positionals.length === 1))
|
|
280
|
+
fail("debt add requires either TITLE or '-' input");
|
|
281
|
+
if (action === "add" &&
|
|
282
|
+
stdin === "document" &&
|
|
283
|
+
Object.keys(flags).some((name) => name !== "json" && name !== "namespace" && name !== "actor"))
|
|
284
|
+
fail("debt add document input owns its creation fields");
|
|
285
|
+
if (DEBT_ID_ACTIONS.has(action))
|
|
286
|
+
validateDebtIdPositionals(positionals, fail);
|
|
287
|
+
if (action === "ls" && positionals.length === 1) {
|
|
288
|
+
validateListSelector(positionals[0], fail);
|
|
289
|
+
if (flags.world === true)
|
|
290
|
+
fail("--world cannot be combined with an explicit Debt namespace selector");
|
|
291
|
+
}
|
|
292
|
+
validateDebtReadFlags(action, flags, fail);
|
|
293
|
+
if (action === "update")
|
|
294
|
+
validateUpdate(scanned, fail);
|
|
295
|
+
}
|
|
296
|
+
export function parseDebtCommand(argv) {
|
|
297
|
+
const candidate = argv[0];
|
|
298
|
+
if (!isDebtAction(candidate)) {
|
|
299
|
+
throw new CliUsageError(`unknown debt command: ${candidate ?? ""}`, unknownCommandGuide(DEBT_FAMILY_USAGE_GUIDE, candidate ?? ""));
|
|
300
|
+
}
|
|
301
|
+
const action = candidate;
|
|
302
|
+
const fail = (message) => {
|
|
303
|
+
throw new CliUsageError(message, debtUsageGuide(action));
|
|
304
|
+
};
|
|
305
|
+
const scanned = scanArgs(argv, scanSpec(action, DEBT_COMMAND_SPECS[action]), fail);
|
|
306
|
+
validateDebtScan(action, scanned, fail);
|
|
307
|
+
let where;
|
|
308
|
+
if (action === "query" && typeof scanned.flags.where === "string") {
|
|
309
|
+
try {
|
|
310
|
+
where = parseDebtQueryExpression(scanned.flags.where);
|
|
311
|
+
}
|
|
312
|
+
catch (error) {
|
|
313
|
+
fail(error instanceof Error ? error.message : String(error));
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
return {
|
|
317
|
+
command: "debt",
|
|
318
|
+
action,
|
|
319
|
+
output: scanned.flags.json === true ? "json" : "text",
|
|
320
|
+
...scanned,
|
|
321
|
+
...(where === undefined ? {} : { where }),
|
|
322
|
+
};
|
|
323
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type DebtQueryExpression } from "../../debt/query.js";
|
|
2
|
+
export type { DebtQueryExpression } from "../../debt/query.js";
|
|
3
|
+
export declare function parseDebtQueryExpression(source: string): DebtQueryExpression;
|
|
4
|
+
export declare function validateDebtLimit(source: string): void;
|
|
5
|
+
export declare function validateDebtParent(source: string): void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { normalizeDebtQueryPredicate, DebtQueryPredicateError, } from "../../debt/query.js";
|
|
2
2
|
function syntax(message, offset) {
|
|
3
3
|
throw new Error(`${message} at column ${offset + 1}`);
|
|
4
4
|
}
|
|
@@ -84,7 +84,7 @@ function parsedPredicate(field, operator, value) {
|
|
|
84
84
|
if (field.value === "title" && value.kind !== "string") {
|
|
85
85
|
syntax("title values must use double quotes", value.offset);
|
|
86
86
|
}
|
|
87
|
-
// Acquire textual literals only; the
|
|
87
|
+
// Acquire textual literals only; the Debt owner judges fields, operators and values.
|
|
88
88
|
const literal = field.value === "priority"
|
|
89
89
|
? Number(value.value)
|
|
90
90
|
: field.value === "parent" && value.value === "none"
|
|
@@ -93,10 +93,10 @@ function parsedPredicate(field, operator, value) {
|
|
|
93
93
|
? value.value === "true"
|
|
94
94
|
: value.value;
|
|
95
95
|
try {
|
|
96
|
-
return
|
|
96
|
+
return normalizeDebtQueryPredicate({ field: field.value, operator: operator.value, value: literal });
|
|
97
97
|
}
|
|
98
98
|
catch (error) {
|
|
99
|
-
if (error instanceof
|
|
99
|
+
if (error instanceof DebtQueryPredicateError) {
|
|
100
100
|
return syntax(error.message, { field, operator, value }[error.part].offset);
|
|
101
101
|
}
|
|
102
102
|
throw error;
|
|
@@ -175,20 +175,20 @@ class Parser {
|
|
|
175
175
|
return parsedPredicate(field, operator, value);
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
|
-
export function
|
|
178
|
+
export function parseDebtQueryExpression(source) {
|
|
179
179
|
if (source.trim().length === 0)
|
|
180
180
|
return syntax("query expression must be nonblank", 0);
|
|
181
181
|
return new Parser(lex(source)).parse();
|
|
182
182
|
}
|
|
183
|
-
export function
|
|
183
|
+
export function validateDebtLimit(source) {
|
|
184
184
|
if (!/^[1-9][0-9]*$/u.test(source) || !Number.isSafeInteger(Number(source)))
|
|
185
185
|
throw new Error("--limit requires a positive safe integer");
|
|
186
186
|
}
|
|
187
|
-
export function
|
|
187
|
+
export function validateDebtParent(source) {
|
|
188
188
|
try {
|
|
189
|
-
|
|
189
|
+
normalizeDebtQueryPredicate({ field: "under", operator: "=", value: source });
|
|
190
190
|
}
|
|
191
191
|
catch {
|
|
192
|
-
throw new Error("--parent requires a canonical
|
|
192
|
+
throw new Error("--parent requires a canonical DebtId");
|
|
193
193
|
}
|
|
194
194
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ParsedDebtCommand } from "./debt-grammar.js";
|
|
2
2
|
import type { CliRuntime } from "../runtime.js";
|
|
3
3
|
import type { CliCoordinates } from "../coordinates.js";
|
|
4
|
-
export declare function
|
|
4
|
+
export declare function runDebtCommand(command: ParsedDebtCommand, coordinates: CliCoordinates, runtime: CliRuntime): Promise<number>;
|