mdkg 0.0.3 → 0.0.4
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 +171 -169
- package/dist/cli.js +980 -624
- package/dist/commands/checkpoint.js +17 -6
- package/dist/commands/event.js +46 -0
- package/dist/commands/event_support.js +146 -0
- package/dist/commands/format.js +6 -7
- package/dist/commands/index.js +10 -4
- package/dist/commands/init.js +198 -16
- package/dist/commands/list.js +18 -1
- package/dist/commands/new.js +30 -5
- package/dist/commands/pack.js +194 -2
- package/dist/commands/query_output.js +84 -0
- package/dist/commands/search.js +22 -5
- package/dist/commands/show.js +26 -11
- package/dist/commands/skill.js +359 -0
- package/dist/commands/skill_support.js +121 -0
- package/dist/commands/task.js +270 -0
- package/dist/commands/validate.js +104 -7
- package/dist/graph/edges.js +2 -2
- package/dist/graph/frontmatter.js +1 -0
- package/dist/graph/indexer.js +21 -0
- package/dist/graph/node.js +20 -4
- package/dist/graph/skills_index_cache.js +94 -0
- package/dist/graph/skills_indexer.js +160 -0
- package/dist/init/core/rule-1-mdkg-conventions.md +9 -2
- package/dist/init/core/rule-3-cli-contract.md +73 -14
- package/dist/init/core/rule-4-repo-safety-and-ignores.md +9 -3
- package/dist/init/core/rule-6-templates-and-schemas.md +6 -2
- package/dist/init/skills/SKILL.md.example +41 -0
- package/dist/init/templates/default/bug.md +1 -0
- package/dist/init/templates/default/chk.md +1 -0
- package/dist/init/templates/default/epic.md +1 -0
- package/dist/init/templates/default/feat.md +1 -0
- package/dist/init/templates/default/task.md +1 -0
- package/dist/init/templates/default/test.md +1 -0
- package/dist/pack/export_md.js +6 -0
- package/dist/pack/export_xml.js +6 -0
- package/dist/pack/pack.js +35 -0
- package/dist/util/argparse.js +25 -0
- package/dist/util/filter.js +18 -0
- package/dist/util/id.js +23 -0
- package/package.json +5 -2
package/dist/cli.js
CHANGED
|
@@ -4,6 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
5
|
};
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.runCli = runCli;
|
|
8
|
+
exports.main = main;
|
|
7
9
|
const fs_1 = __importDefault(require("fs"));
|
|
8
10
|
const path_1 = __importDefault(require("path"));
|
|
9
11
|
const argparse_1 = require("./util/argparse");
|
|
@@ -20,251 +22,391 @@ const checkpoint_1 = require("./commands/checkpoint");
|
|
|
20
22
|
const init_1 = require("./commands/init");
|
|
21
23
|
const new_1 = require("./commands/new");
|
|
22
24
|
const guide_1 = require("./commands/guide");
|
|
25
|
+
const event_1 = require("./commands/event");
|
|
26
|
+
const skill_1 = require("./commands/skill");
|
|
27
|
+
const task_1 = require("./commands/task");
|
|
23
28
|
const workspace_1 = require("./commands/workspace");
|
|
24
29
|
const profile_1 = require("./pack/profile");
|
|
25
30
|
const errors_1 = require("./util/errors");
|
|
26
|
-
function
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
31
|
+
function resolveRuntime(runtime = {}) {
|
|
32
|
+
return {
|
|
33
|
+
log: runtime.log ?? console.log,
|
|
34
|
+
error: runtime.error ?? console.error,
|
|
35
|
+
cwd: runtime.cwd ?? (() => process.cwd()),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function printGlobalOptions(log) {
|
|
39
|
+
log("\nGlobal options:");
|
|
40
|
+
log(" --root, -r <path> Run against a specific repo root");
|
|
41
|
+
log(" --help, -h Show help");
|
|
42
|
+
log(" --version, -V Show version");
|
|
43
|
+
}
|
|
44
|
+
function printUsage(log) {
|
|
45
|
+
log("mdkg - Markdown Knowledge Graph");
|
|
46
|
+
log("\nUsage:");
|
|
47
|
+
log(" mdkg <command> [options]");
|
|
48
|
+
log("\nPrimary commands:");
|
|
49
|
+
log(" init Initialize .mdkg scaffolding");
|
|
50
|
+
log(" new Create a node from templates");
|
|
51
|
+
log(" show Show a node by id or qid");
|
|
52
|
+
log(" list List nodes with filters");
|
|
53
|
+
log(" search Search nodes by query");
|
|
54
|
+
log(" pack Generate a context pack");
|
|
55
|
+
log(" skill Create, list, show, search, and validate skills");
|
|
56
|
+
log(" task Start, update, and complete task-like nodes");
|
|
57
|
+
log(" next Suggest the next work item");
|
|
58
|
+
log(" validate Validate frontmatter + graph");
|
|
59
|
+
log("\nAdvanced / maintenance commands:");
|
|
60
|
+
log(" event Enable or append episodic event logs");
|
|
61
|
+
log(" checkpoint Create a checkpoint node");
|
|
62
|
+
log(" index Build the global index");
|
|
63
|
+
log(" guide Show the mdkg guide");
|
|
64
|
+
log(" format Normalize frontmatter");
|
|
65
|
+
log(" doctor Run install and workspace diagnostics");
|
|
66
|
+
log(" workspace Manage workspaces (ls/add/rm)");
|
|
67
|
+
log("\nQuickstart:");
|
|
68
|
+
log(" mdkg init --llm");
|
|
69
|
+
log(' mdkg new task "..." --status todo --priority 1');
|
|
70
|
+
log(' mdkg search "..."');
|
|
71
|
+
log(" mdkg show <id>");
|
|
72
|
+
log(" mdkg next");
|
|
73
|
+
log(" mdkg pack <id>");
|
|
74
|
+
log(" mdkg pack <id> --profile concise --dry-run --stats");
|
|
75
|
+
log(" mdkg task start <id>");
|
|
76
|
+
log(' mdkg skill new release-readiness "release readiness audit" --description "use when preparing a release"');
|
|
77
|
+
log(" mdkg skill list --tags stage:plan --json");
|
|
78
|
+
log(" mdkg validate");
|
|
79
|
+
log("\nOptional agent-ready bootstrap:");
|
|
80
|
+
log(" mdkg init --omni");
|
|
81
|
+
log("\nRun `mdkg help <command>` or `mdkg <command> --help` for details.");
|
|
82
|
+
printGlobalOptions(log);
|
|
83
|
+
}
|
|
84
|
+
function printInitHelp(log) {
|
|
85
|
+
log("Usage:");
|
|
86
|
+
log(" mdkg init [options]");
|
|
87
|
+
log("\nOptions:");
|
|
88
|
+
log(" --force Overwrite existing mdkg files");
|
|
89
|
+
log(" --llm Create AGENTS.md and CLAUDE.md");
|
|
90
|
+
log(" --omni Add SOUL/HUMAN/skills/events scaffolding");
|
|
91
|
+
log(" --no-update-ignores Skip default .gitignore/.npmignore updates");
|
|
92
|
+
log(" --update-gitignore Append mdkg ignore entries");
|
|
93
|
+
log(" --update-npmignore Append mdkg ignore entries");
|
|
94
|
+
log(" --update-dockerignore Append mdkg ignore entries");
|
|
95
|
+
log("\nCompatibility flags still supported but not shown in the primary onboarding story.");
|
|
96
|
+
printGlobalOptions(log);
|
|
97
|
+
}
|
|
98
|
+
function printNewHelp(log) {
|
|
99
|
+
log("Usage:");
|
|
100
|
+
log(' mdkg new <type> "<title>" [options]');
|
|
101
|
+
log("\nTypes:");
|
|
102
|
+
log(" rule prd edd dec prop epic feat task bug checkpoint test");
|
|
103
|
+
log("\nOptions:");
|
|
104
|
+
log(" --ws <alias> Workspace alias (default root)");
|
|
105
|
+
log(" --status <status> Work item or decision status");
|
|
106
|
+
log(" --priority <0..9> Work item priority");
|
|
107
|
+
log(" --epic <id> Epic id");
|
|
108
|
+
log(" --tags <tag,tag,...> Tags");
|
|
109
|
+
log(" --skills <slug,slug,...> Skill slugs for work items");
|
|
110
|
+
log(" --template <set> Template set");
|
|
111
|
+
log(" --run-id <id> Optional event run id when event logging is enabled");
|
|
112
|
+
log("\nAdvanced metadata flags:");
|
|
113
|
+
log(" --parent --prev --next --relates --blocked-by --blocks");
|
|
114
|
+
log(" --links --artifacts --refs --aliases --owners --cases --supersedes");
|
|
115
|
+
log(" --owners <owner,owner,...> Owners");
|
|
116
|
+
printGlobalOptions(log);
|
|
117
|
+
}
|
|
118
|
+
function printGuideHelp(log) {
|
|
119
|
+
log("Usage:");
|
|
120
|
+
log(" mdkg guide");
|
|
121
|
+
printGlobalOptions(log);
|
|
122
|
+
}
|
|
123
|
+
function printWorkspaceHelp(log) {
|
|
124
|
+
log("Usage:");
|
|
125
|
+
log(" mdkg workspace ls");
|
|
126
|
+
log(" mdkg workspace add <alias> <path> [--mdkg-dir <dir>]");
|
|
127
|
+
log(" mdkg workspace rm <alias>");
|
|
128
|
+
printGlobalOptions(log);
|
|
129
|
+
}
|
|
130
|
+
function printIndexHelp(log) {
|
|
131
|
+
log("Usage:");
|
|
132
|
+
log(" mdkg index [--tolerant]");
|
|
133
|
+
printGlobalOptions(log);
|
|
134
|
+
}
|
|
135
|
+
function printShowHelp(log) {
|
|
136
|
+
log("Usage:");
|
|
137
|
+
log(" mdkg show <id-or-qid> [--ws <alias>] [--meta] [--json]");
|
|
138
|
+
log("\nWhen to use:");
|
|
139
|
+
log(" Inspect one mdkg node exactly. Use `mdkg skill show <slug>` for skills.");
|
|
140
|
+
log("\nDefault behavior:");
|
|
141
|
+
log(" Shows full body content. Use --meta for card + metadata only.");
|
|
142
|
+
printGlobalOptions(log);
|
|
143
|
+
}
|
|
144
|
+
function printListHelp(log) {
|
|
145
|
+
log("Usage:");
|
|
146
|
+
log(" mdkg list [--type <type>] [--status <status>] [--ws <alias>] [--epic <id>]");
|
|
147
|
+
log(" [--priority <n>] [--blocked] [--tags <tag,tag,...>] [--tags-mode any|all] [--json]");
|
|
148
|
+
log("\nWhen to use:");
|
|
149
|
+
log(" List mdkg nodes. Use `mdkg skill list` for skills.");
|
|
150
|
+
printGlobalOptions(log);
|
|
151
|
+
}
|
|
152
|
+
function printSearchHelp(log) {
|
|
153
|
+
log("Usage:");
|
|
154
|
+
log(' mdkg search "<query>" [--type <type>] [--status <status>] [--ws <alias>]');
|
|
155
|
+
log(" [--tags <tag,tag,...>] [--tags-mode any|all] [--json]");
|
|
156
|
+
log("\nWhen to use:");
|
|
157
|
+
log(" Search mdkg nodes by metadata. Use `mdkg skill search` for skills.");
|
|
158
|
+
printGlobalOptions(log);
|
|
159
|
+
}
|
|
160
|
+
function printPackHelp(log) {
|
|
161
|
+
log("Usage:");
|
|
162
|
+
log(" mdkg pack <id-or-qid> [options]");
|
|
163
|
+
log(" mdkg pack --list-profiles");
|
|
164
|
+
log("\nOptions:");
|
|
165
|
+
log(" -w, --ws <alias> Workspace hint when resolving ambiguous ids");
|
|
166
|
+
log(" -v, --verbose Include pinned core docs from .mdkg/core/core.md");
|
|
167
|
+
log(" -f, --format <fmt> Output format: md|json|toon|xml (default md)");
|
|
168
|
+
log(" -o, --out <path> Output file path");
|
|
169
|
+
log(" --profile <name> Body profile: standard|concise|headers (default standard)");
|
|
170
|
+
log(" --skills <mode> Skill inclusion: none|auto|<slug,slug,...> (default auto)");
|
|
171
|
+
log(" --skills-depth <mode> Skill body mode: meta|full (default meta)");
|
|
172
|
+
log(" --dry-run Preview selection/order/stats without writing files");
|
|
173
|
+
log(" --stats Print per-node + total pack stats and write stats sidecar JSON");
|
|
174
|
+
log(" --list-profiles List built-in pack profiles and exit");
|
|
175
|
+
log("\nAdvanced shaping / debug flags:");
|
|
176
|
+
log(" --depth --edges --strip-code --max-code-lines --max-chars --max-lines --max-tokens");
|
|
177
|
+
log(" --truncation-report --stats-out");
|
|
178
|
+
log("\nExamples:");
|
|
179
|
+
log(" mdkg pack --list-profiles");
|
|
180
|
+
log(" mdkg pack task-1");
|
|
181
|
+
log(" mdkg pack task-1 --profile concise --dry-run --stats");
|
|
182
|
+
log(" mdkg pack task-1 --skills auto --skills-depth full");
|
|
183
|
+
log(" mdkg pack epic-2 --format json --profile headers");
|
|
184
|
+
printGlobalOptions(log);
|
|
185
|
+
}
|
|
186
|
+
function printPackProfiles(log) {
|
|
169
187
|
const profiles = (0, profile_1.listPackProfiles)();
|
|
170
|
-
|
|
188
|
+
log("Built-in pack profiles:");
|
|
171
189
|
for (const entry of profiles) {
|
|
172
|
-
|
|
173
|
-
|
|
190
|
+
log(`- ${entry.profile} (body=${entry.bodyMode})`);
|
|
191
|
+
log(` ${entry.description}`);
|
|
174
192
|
if (entry.defaults.length > 0) {
|
|
175
|
-
|
|
193
|
+
log(` defaults: ${entry.defaults.join(", ")}`);
|
|
176
194
|
}
|
|
177
195
|
}
|
|
178
196
|
}
|
|
179
|
-
function
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
197
|
+
function printSkillHelp(log, subcommand) {
|
|
198
|
+
switch ((subcommand ?? "").toLowerCase()) {
|
|
199
|
+
case "new":
|
|
200
|
+
log("Usage:");
|
|
201
|
+
log(' mdkg skill new <slug> "<name>" --description "<description>" [options]');
|
|
202
|
+
log("\nOptions:");
|
|
203
|
+
log(" --tags <tag,tag,...> Optional skill tags");
|
|
204
|
+
log(" --authors <name,name,...> Optional authors list");
|
|
205
|
+
log(" --links <url,url,...> Optional links list");
|
|
206
|
+
log(" --run-id <id> Optional event run id when event logging is enabled");
|
|
207
|
+
log(" --with-scripts Create scripts/ in the scaffold");
|
|
208
|
+
log(" --force Overwrite existing SKILL.md");
|
|
209
|
+
printGlobalOptions(log);
|
|
210
|
+
return;
|
|
211
|
+
case "list":
|
|
212
|
+
log("Usage:");
|
|
213
|
+
log(" mdkg skill list [--tags <tag,tag,...>] [--tags-mode any|all] [--json]");
|
|
214
|
+
log("\nWhen to use:");
|
|
215
|
+
log(" Discover skills directly, including stage-tagged orchestrator lookups.");
|
|
216
|
+
printGlobalOptions(log);
|
|
217
|
+
return;
|
|
218
|
+
case "show":
|
|
219
|
+
log("Usage:");
|
|
220
|
+
log(" mdkg skill show <slug> [--meta] [--json]");
|
|
221
|
+
log("\nWhen to use:");
|
|
222
|
+
log(" Inspect one skill body or metadata after discovery.");
|
|
223
|
+
printGlobalOptions(log);
|
|
224
|
+
return;
|
|
225
|
+
case "search":
|
|
226
|
+
log("Usage:");
|
|
227
|
+
log(' mdkg skill search "<query>" [--tags <tag,tag,...>] [--tags-mode any|all] [--json]');
|
|
228
|
+
log("\nWhen to use:");
|
|
229
|
+
log(" Search skills by trigger text, tags, and stage conventions like `stage:plan`.");
|
|
230
|
+
printGlobalOptions(log);
|
|
231
|
+
return;
|
|
232
|
+
case "validate":
|
|
233
|
+
log("Usage:");
|
|
234
|
+
log(" mdkg skill validate [<slug>]");
|
|
235
|
+
printGlobalOptions(log);
|
|
236
|
+
return;
|
|
237
|
+
default:
|
|
238
|
+
log("Usage:");
|
|
239
|
+
log(' mdkg skill new <slug> "<name>" --description "<description>" [options]');
|
|
240
|
+
log(" mdkg skill list [--tags <tag,tag,...>] [--tags-mode any|all] [--json]");
|
|
241
|
+
log(" mdkg skill show <slug> [--meta] [--json]");
|
|
242
|
+
log(' mdkg skill search "<query>" [--tags <tag,tag,...>] [--tags-mode any|all] [--json]');
|
|
243
|
+
log(" mdkg skill validate [<slug>]");
|
|
244
|
+
log("\nNotes:");
|
|
245
|
+
log(" Skills are first-class under `mdkg skill ...`.");
|
|
246
|
+
log(" Use stage tags like `stage:plan`, `stage:execute`, and `stage:review` with --tags.");
|
|
247
|
+
printGlobalOptions(log);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
function printTaskHelp(log, subcommand) {
|
|
251
|
+
switch ((subcommand ?? "").toLowerCase()) {
|
|
252
|
+
case "start":
|
|
253
|
+
log("Usage:");
|
|
254
|
+
log(' mdkg task start <id-or-qid> [--ws <alias>] [--run-id <id>] [--note "<text>"]');
|
|
255
|
+
log("\nWhen to use:");
|
|
256
|
+
log(" Move a task, bug, or test into progress and emit a baseline event when logging is enabled.");
|
|
257
|
+
printGlobalOptions(log);
|
|
258
|
+
return;
|
|
259
|
+
case "update":
|
|
260
|
+
log("Usage:");
|
|
261
|
+
log(" mdkg task update <id-or-qid> [--ws <alias>] [--status <status>] [--priority <n>]");
|
|
262
|
+
log(" [--add-artifacts <a,...>] [--add-links <l,...>] [--add-refs <id,...>]");
|
|
263
|
+
log(" [--add-skills <slug,...>] [--add-tags <tag,...>] [--add-blocked-by <id,...>]");
|
|
264
|
+
log(' [--clear-blocked-by] [--run-id <id>] [--note "<text>"]');
|
|
265
|
+
log("\nWhen to use:");
|
|
266
|
+
log(" Update task metadata and evidence without editing markdown manually.");
|
|
267
|
+
printGlobalOptions(log);
|
|
268
|
+
return;
|
|
269
|
+
case "done":
|
|
270
|
+
log("Usage:");
|
|
271
|
+
log(' mdkg task done <id-or-qid> [--ws <alias>] [--add-artifacts <a,...>] [--add-links <l,...>]');
|
|
272
|
+
log(' [--add-refs <id,...>] [--checkpoint "<title>"] [--run-id <id>] [--note "<text>"]');
|
|
273
|
+
log("\nWhen to use:");
|
|
274
|
+
log(" Mark a task-like node done, optionally create a checkpoint, and emit a completion event when enabled.");
|
|
275
|
+
printGlobalOptions(log);
|
|
276
|
+
return;
|
|
277
|
+
default:
|
|
278
|
+
log("Usage:");
|
|
279
|
+
log(' mdkg task start <id-or-qid> [--ws <alias>] [--run-id <id>] [--note "<text>"]');
|
|
280
|
+
log(" mdkg task update <id-or-qid> [options]");
|
|
281
|
+
log(' mdkg task done <id-or-qid> [--checkpoint "<title>"] [options]');
|
|
282
|
+
log("\nNotes:");
|
|
283
|
+
log(" `mdkg task ...` only supports task, bug, and test nodes in this wave.");
|
|
284
|
+
printGlobalOptions(log);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
function printEventHelp(log, subcommand) {
|
|
288
|
+
switch ((subcommand ?? "").toLowerCase()) {
|
|
289
|
+
case "enable":
|
|
290
|
+
log("Usage:");
|
|
291
|
+
log(" mdkg event enable [--ws <alias>] [--no-update-gitignore]");
|
|
292
|
+
log("\nWhen to use:");
|
|
293
|
+
log(" Create the append-only JSONL event log for a workspace.");
|
|
294
|
+
printGlobalOptions(log);
|
|
295
|
+
return;
|
|
296
|
+
case "append":
|
|
297
|
+
log("Usage:");
|
|
298
|
+
log(" mdkg event append --kind <kind> --status <ok|error|retry|skipped> --refs <id,...>");
|
|
299
|
+
log(' [--ws <alias>] [--artifacts <a,...>] [--notes "<text>"] [--run-id <id>]');
|
|
300
|
+
log(" [--agent <name>] [--skill <slug>] [--tool <id>]");
|
|
301
|
+
log("\nWhen to use:");
|
|
302
|
+
log(" Append explicit provenance events from an orchestrator or manual workflow.");
|
|
303
|
+
printGlobalOptions(log);
|
|
304
|
+
return;
|
|
305
|
+
default:
|
|
306
|
+
log("Usage:");
|
|
307
|
+
log(" mdkg event enable [--ws <alias>] [--no-update-gitignore]");
|
|
308
|
+
log(" mdkg event append --kind <kind> --status <ok|error|retry|skipped> --refs <id,...> [options]");
|
|
309
|
+
printGlobalOptions(log);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
function printNextHelp(log) {
|
|
313
|
+
log("Usage:");
|
|
314
|
+
log(" mdkg next [<id-or-qid>] [--ws <alias>]");
|
|
315
|
+
printGlobalOptions(log);
|
|
316
|
+
}
|
|
317
|
+
function printCheckpointHelp(log) {
|
|
318
|
+
log("Usage:");
|
|
319
|
+
log(" mdkg checkpoint new <title> [--ws <alias>]");
|
|
320
|
+
log(' [--relates <id,id,...>] [--scope <id,id,...>] [--run-id <id>] [--note "<text>"]');
|
|
321
|
+
printGlobalOptions(log);
|
|
322
|
+
}
|
|
323
|
+
function printValidateHelp(log) {
|
|
324
|
+
log("Usage:");
|
|
325
|
+
log(" mdkg validate [--out <path>] [--quiet]");
|
|
326
|
+
printGlobalOptions(log);
|
|
327
|
+
}
|
|
328
|
+
function printFormatHelp(log) {
|
|
329
|
+
log("Usage:");
|
|
330
|
+
log(" mdkg format");
|
|
331
|
+
printGlobalOptions(log);
|
|
332
|
+
}
|
|
333
|
+
function printDoctorHelp(log) {
|
|
334
|
+
log("Usage:");
|
|
335
|
+
log(" mdkg doctor [--json]");
|
|
336
|
+
log("\nChecks:");
|
|
337
|
+
log(" - Node.js version compatibility");
|
|
338
|
+
log(" - mdkg repo root + .mdkg/config.json");
|
|
339
|
+
log(" - Template schema availability");
|
|
340
|
+
log(" - Index load/rebuild health");
|
|
341
|
+
log("\nOptions:");
|
|
342
|
+
log(" --json Emit machine-readable JSON output");
|
|
343
|
+
printGlobalOptions(log);
|
|
344
|
+
}
|
|
345
|
+
function printCommandHelp(log, command, subcommand) {
|
|
213
346
|
switch ((command ?? "").toLowerCase()) {
|
|
214
347
|
case "":
|
|
215
348
|
case "help":
|
|
216
|
-
printUsage();
|
|
349
|
+
printUsage(log);
|
|
217
350
|
return;
|
|
218
351
|
case "init":
|
|
219
|
-
printInitHelp();
|
|
352
|
+
printInitHelp(log);
|
|
220
353
|
return;
|
|
221
354
|
case "guide":
|
|
222
|
-
printGuideHelp();
|
|
355
|
+
printGuideHelp(log);
|
|
223
356
|
return;
|
|
224
357
|
case "new":
|
|
225
|
-
printNewHelp();
|
|
358
|
+
printNewHelp(log);
|
|
226
359
|
return;
|
|
227
360
|
case "workspace":
|
|
228
|
-
printWorkspaceHelp();
|
|
361
|
+
printWorkspaceHelp(log);
|
|
229
362
|
return;
|
|
230
363
|
case "index":
|
|
231
|
-
printIndexHelp();
|
|
364
|
+
printIndexHelp(log);
|
|
232
365
|
return;
|
|
233
366
|
case "show":
|
|
234
|
-
printShowHelp();
|
|
367
|
+
printShowHelp(log);
|
|
235
368
|
return;
|
|
236
369
|
case "list":
|
|
237
|
-
printListHelp();
|
|
370
|
+
printListHelp(log);
|
|
238
371
|
return;
|
|
239
372
|
case "search":
|
|
240
|
-
printSearchHelp();
|
|
373
|
+
printSearchHelp(log);
|
|
241
374
|
return;
|
|
242
375
|
case "pack":
|
|
243
|
-
printPackHelp();
|
|
376
|
+
printPackHelp(log);
|
|
377
|
+
return;
|
|
378
|
+
case "skill":
|
|
379
|
+
printSkillHelp(log, subcommand);
|
|
380
|
+
return;
|
|
381
|
+
case "task":
|
|
382
|
+
printTaskHelp(log, subcommand);
|
|
383
|
+
return;
|
|
384
|
+
case "event":
|
|
385
|
+
printEventHelp(log, subcommand);
|
|
244
386
|
return;
|
|
245
387
|
case "next":
|
|
246
|
-
printNextHelp();
|
|
388
|
+
printNextHelp(log);
|
|
247
389
|
return;
|
|
248
390
|
case "checkpoint":
|
|
249
|
-
printCheckpointHelp();
|
|
391
|
+
printCheckpointHelp(log);
|
|
250
392
|
return;
|
|
251
393
|
case "validate":
|
|
252
|
-
printValidateHelp();
|
|
394
|
+
printValidateHelp(log);
|
|
253
395
|
return;
|
|
254
396
|
case "format":
|
|
255
|
-
printFormatHelp();
|
|
397
|
+
printFormatHelp(log);
|
|
256
398
|
return;
|
|
257
399
|
case "doctor":
|
|
258
|
-
printDoctorHelp();
|
|
400
|
+
printDoctorHelp(log);
|
|
259
401
|
return;
|
|
260
402
|
default:
|
|
261
|
-
printUsage();
|
|
403
|
+
printUsage(log);
|
|
262
404
|
}
|
|
263
405
|
}
|
|
264
|
-
function printRootError(root) {
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
406
|
+
function printRootError(error, root) {
|
|
407
|
+
error("mdkg must be run from a repo root with .mdkg/config.json");
|
|
408
|
+
error(`root checked: ${root}`);
|
|
409
|
+
error("hint: run from the repo root, pass --root <path>, or run `mdkg init`");
|
|
268
410
|
}
|
|
269
411
|
function readPackageVersion() {
|
|
270
412
|
const packagePath = path_1.default.resolve(__dirname, "..", "package.json");
|
|
@@ -349,462 +491,676 @@ function parseEdgesFlag(value) {
|
|
|
349
491
|
.filter(Boolean);
|
|
350
492
|
return raw.length > 0 ? raw : undefined;
|
|
351
493
|
}
|
|
352
|
-
function
|
|
353
|
-
|
|
354
|
-
if (!raw || raw.startsWith("-")) {
|
|
494
|
+
function parseCsvFlag(flag, value) {
|
|
495
|
+
if (value === undefined) {
|
|
355
496
|
return undefined;
|
|
356
497
|
}
|
|
357
|
-
|
|
498
|
+
if (value === true) {
|
|
499
|
+
throw new errors_1.UsageError(`${flag} requires a value`);
|
|
500
|
+
}
|
|
501
|
+
const items = String(value)
|
|
502
|
+
.split(",")
|
|
503
|
+
.map((item) => item.trim().toLowerCase())
|
|
504
|
+
.filter(Boolean);
|
|
505
|
+
return items.length > 0 ? items : undefined;
|
|
506
|
+
}
|
|
507
|
+
function parseTagsModeFlag(value) {
|
|
508
|
+
if (value === undefined) {
|
|
509
|
+
return undefined;
|
|
510
|
+
}
|
|
511
|
+
if (value === true) {
|
|
512
|
+
throw new errors_1.UsageError("--tags-mode requires a value");
|
|
513
|
+
}
|
|
514
|
+
const normalized = String(value).toLowerCase();
|
|
515
|
+
if (normalized === "any" || normalized === "all") {
|
|
516
|
+
return normalized;
|
|
517
|
+
}
|
|
518
|
+
throw new errors_1.UsageError("--tags-mode must be any or all");
|
|
358
519
|
}
|
|
359
|
-
function handleCommandError(err) {
|
|
520
|
+
function handleCommandError(err, command, runtime) {
|
|
360
521
|
const message = err instanceof Error ? err.message : String(err);
|
|
361
522
|
if (err instanceof errors_1.UsageError) {
|
|
362
|
-
|
|
363
|
-
printCommandHelp(
|
|
364
|
-
|
|
523
|
+
runtime.error(message);
|
|
524
|
+
printCommandHelp(runtime.log, command);
|
|
525
|
+
return 1;
|
|
365
526
|
}
|
|
366
527
|
if (err instanceof errors_1.ValidationError) {
|
|
367
|
-
|
|
368
|
-
|
|
528
|
+
runtime.error(message);
|
|
529
|
+
return 2;
|
|
369
530
|
}
|
|
370
531
|
if (err instanceof errors_1.NotFoundError) {
|
|
371
|
-
|
|
372
|
-
|
|
532
|
+
runtime.error(message);
|
|
533
|
+
return 3;
|
|
373
534
|
}
|
|
374
|
-
|
|
375
|
-
|
|
535
|
+
runtime.error(message);
|
|
536
|
+
return 4;
|
|
376
537
|
}
|
|
377
|
-
function
|
|
378
|
-
const
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
538
|
+
function runWorkspaceSubcommand(parsed, root) {
|
|
539
|
+
const subcommand = (parsed.positionals[1] ?? "").toLowerCase();
|
|
540
|
+
switch (subcommand) {
|
|
541
|
+
case "ls": {
|
|
542
|
+
if (parsed.positionals.length > 2) {
|
|
543
|
+
throw new errors_1.UsageError("workspace ls takes no arguments");
|
|
544
|
+
}
|
|
545
|
+
(0, workspace_1.runWorkspaceListCommand)({ root });
|
|
546
|
+
return 0;
|
|
547
|
+
}
|
|
548
|
+
case "add": {
|
|
549
|
+
const alias = parsed.positionals[2];
|
|
550
|
+
const workspacePath = parsed.positionals[3];
|
|
551
|
+
if (!alias || !workspacePath) {
|
|
552
|
+
throw new errors_1.UsageError("workspace add requires <alias> <path>");
|
|
553
|
+
}
|
|
554
|
+
const mdkgDir = requireFlagValue("--mdkg-dir", parsed.flags["--mdkg-dir"]);
|
|
555
|
+
(0, workspace_1.runWorkspaceAddCommand)({ root, alias, workspacePath, mdkgDir });
|
|
556
|
+
return 0;
|
|
557
|
+
}
|
|
558
|
+
case "rm": {
|
|
559
|
+
const alias = parsed.positionals[2];
|
|
560
|
+
if (!alias || parsed.positionals.length > 3) {
|
|
561
|
+
throw new errors_1.UsageError("workspace rm requires <alias>");
|
|
562
|
+
}
|
|
563
|
+
(0, workspace_1.runWorkspaceRemoveCommand)({ root, alias });
|
|
564
|
+
return 0;
|
|
565
|
+
}
|
|
566
|
+
default:
|
|
567
|
+
throw new errors_1.UsageError("workspace requires ls/add/rm");
|
|
391
568
|
}
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
569
|
+
}
|
|
570
|
+
function runSkillSubcommand(parsed, root) {
|
|
571
|
+
const subcommand = (parsed.positionals[1] ?? "").toLowerCase();
|
|
572
|
+
switch (subcommand) {
|
|
573
|
+
case "new": {
|
|
574
|
+
const slug = parsed.positionals[2];
|
|
575
|
+
const name = parsed.positionals[3];
|
|
576
|
+
if (!slug || !name) {
|
|
577
|
+
throw new errors_1.UsageError('skill new requires <slug> "<name>"');
|
|
578
|
+
}
|
|
579
|
+
if (parsed.positionals.length > 4) {
|
|
580
|
+
throw new errors_1.UsageError('skill new accepts exactly <slug> "<name>"');
|
|
581
|
+
}
|
|
582
|
+
const description = requireFlagValue("--description", parsed.flags["--description"]);
|
|
583
|
+
if (!description) {
|
|
584
|
+
throw new errors_1.UsageError("skill new requires --description");
|
|
585
|
+
}
|
|
586
|
+
const tags = requireFlagValue("--tags", parsed.flags["--tags"]);
|
|
587
|
+
const authors = requireFlagValue("--authors", parsed.flags["--authors"]);
|
|
588
|
+
const links = requireFlagValue("--links", parsed.flags["--links"]);
|
|
589
|
+
const withScripts = parseBooleanFlag("--with-scripts", parsed.flags["--with-scripts"]);
|
|
590
|
+
const force = parseBooleanFlag("--force", parsed.flags["--force"]);
|
|
591
|
+
const runId = requireFlagValue("--run-id", parsed.flags["--run-id"]);
|
|
592
|
+
(0, skill_1.runSkillNewCommand)({
|
|
593
|
+
root,
|
|
594
|
+
slug,
|
|
595
|
+
name,
|
|
596
|
+
description,
|
|
597
|
+
tags,
|
|
598
|
+
authors,
|
|
599
|
+
links,
|
|
600
|
+
withScripts,
|
|
601
|
+
force,
|
|
602
|
+
runId,
|
|
603
|
+
});
|
|
604
|
+
return 0;
|
|
605
|
+
}
|
|
606
|
+
case "list": {
|
|
607
|
+
if (parsed.positionals.length > 2) {
|
|
608
|
+
throw new errors_1.UsageError("skill list does not accept positional arguments");
|
|
609
|
+
}
|
|
610
|
+
const tags = parseCsvFlag("--tags", parsed.flags["--tags"]);
|
|
611
|
+
const tagsMode = parseTagsModeFlag(parsed.flags["--tags-mode"]);
|
|
612
|
+
const noCache = parseBooleanFlag("--no-cache", parsed.flags["--no-cache"]);
|
|
613
|
+
const noReindex = parseBooleanFlag("--no-reindex", parsed.flags["--no-reindex"]);
|
|
614
|
+
const json = parseBooleanFlag("--json", parsed.flags["--json"]);
|
|
615
|
+
(0, skill_1.runSkillListCommand)({
|
|
616
|
+
root,
|
|
617
|
+
tags,
|
|
618
|
+
tagsMode,
|
|
619
|
+
json,
|
|
620
|
+
noCache,
|
|
621
|
+
noReindex,
|
|
622
|
+
});
|
|
623
|
+
return 0;
|
|
624
|
+
}
|
|
625
|
+
case "show": {
|
|
626
|
+
const slug = parsed.positionals[2];
|
|
627
|
+
if (!slug || parsed.positionals.length > 3) {
|
|
628
|
+
throw new errors_1.UsageError("skill show requires <slug>");
|
|
629
|
+
}
|
|
630
|
+
const metaOnly = parseBooleanFlag("--meta", parsed.flags["--meta"]);
|
|
631
|
+
const json = parseBooleanFlag("--json", parsed.flags["--json"]);
|
|
632
|
+
const noCache = parseBooleanFlag("--no-cache", parsed.flags["--no-cache"]);
|
|
633
|
+
const noReindex = parseBooleanFlag("--no-reindex", parsed.flags["--no-reindex"]);
|
|
634
|
+
(0, skill_1.runSkillShowCommand)({
|
|
635
|
+
root,
|
|
636
|
+
slug,
|
|
637
|
+
metaOnly,
|
|
638
|
+
json,
|
|
639
|
+
noCache,
|
|
640
|
+
noReindex,
|
|
641
|
+
});
|
|
642
|
+
return 0;
|
|
643
|
+
}
|
|
644
|
+
case "search": {
|
|
645
|
+
if (parsed.positionals.length < 3) {
|
|
646
|
+
throw new errors_1.UsageError("skill search requires a query");
|
|
647
|
+
}
|
|
648
|
+
const query = parsed.positionals.slice(2).join(" ");
|
|
649
|
+
const tags = parseCsvFlag("--tags", parsed.flags["--tags"]);
|
|
650
|
+
const tagsMode = parseTagsModeFlag(parsed.flags["--tags-mode"]);
|
|
651
|
+
const json = parseBooleanFlag("--json", parsed.flags["--json"]);
|
|
652
|
+
const noCache = parseBooleanFlag("--no-cache", parsed.flags["--no-cache"]);
|
|
653
|
+
const noReindex = parseBooleanFlag("--no-reindex", parsed.flags["--no-reindex"]);
|
|
654
|
+
(0, skill_1.runSkillSearchCommand)({
|
|
655
|
+
root,
|
|
656
|
+
query,
|
|
657
|
+
tags,
|
|
658
|
+
tagsMode,
|
|
659
|
+
json,
|
|
660
|
+
noCache,
|
|
661
|
+
noReindex,
|
|
662
|
+
});
|
|
663
|
+
return 0;
|
|
664
|
+
}
|
|
665
|
+
case "validate": {
|
|
666
|
+
if (parsed.positionals.length > 3) {
|
|
667
|
+
throw new errors_1.UsageError("skill validate accepts at most one slug");
|
|
668
|
+
}
|
|
669
|
+
const slug = parsed.positionals[2];
|
|
670
|
+
(0, skill_1.runSkillValidateCommand)({ root, slug });
|
|
671
|
+
return 0;
|
|
672
|
+
}
|
|
673
|
+
default:
|
|
674
|
+
throw new errors_1.UsageError("skill requires new/list/show/search/validate");
|
|
396
675
|
}
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
676
|
+
}
|
|
677
|
+
function runTaskSubcommand(parsed, root) {
|
|
678
|
+
const subcommand = (parsed.positionals[1] ?? "").toLowerCase();
|
|
679
|
+
switch (subcommand) {
|
|
680
|
+
case "start": {
|
|
681
|
+
const id = parsed.positionals[2];
|
|
682
|
+
if (!id || parsed.positionals.length > 3) {
|
|
683
|
+
throw new errors_1.UsageError("task start requires <id-or-qid>");
|
|
684
|
+
}
|
|
685
|
+
const ws = requireFlagValue("--ws", parsed.flags["--ws"]);
|
|
686
|
+
const runId = requireFlagValue("--run-id", parsed.flags["--run-id"]);
|
|
687
|
+
const note = requireFlagValue("--note", parsed.flags["--note"]);
|
|
688
|
+
(0, task_1.runTaskStartCommand)({ root, id, ws, runId, note });
|
|
689
|
+
return 0;
|
|
690
|
+
}
|
|
691
|
+
case "update": {
|
|
692
|
+
const id = parsed.positionals[2];
|
|
693
|
+
if (!id || parsed.positionals.length > 3) {
|
|
694
|
+
throw new errors_1.UsageError("task update requires <id-or-qid>");
|
|
695
|
+
}
|
|
696
|
+
const ws = requireFlagValue("--ws", parsed.flags["--ws"]);
|
|
697
|
+
const status = requireFlagValue("--status", parsed.flags["--status"]);
|
|
698
|
+
const priority = parseNumberFlag("--priority", parsed.flags["--priority"]);
|
|
699
|
+
const addArtifacts = requireFlagValue("--add-artifacts", parsed.flags["--add-artifacts"]);
|
|
700
|
+
const addLinks = requireFlagValue("--add-links", parsed.flags["--add-links"]);
|
|
701
|
+
const addRefs = requireFlagValue("--add-refs", parsed.flags["--add-refs"]);
|
|
702
|
+
const addSkills = requireFlagValue("--add-skills", parsed.flags["--add-skills"]);
|
|
703
|
+
const addTags = requireFlagValue("--add-tags", parsed.flags["--add-tags"]);
|
|
704
|
+
const addBlockedBy = requireFlagValue("--add-blocked-by", parsed.flags["--add-blocked-by"]);
|
|
705
|
+
const clearBlockedBy = parseBooleanFlag("--clear-blocked-by", parsed.flags["--clear-blocked-by"]);
|
|
706
|
+
const runId = requireFlagValue("--run-id", parsed.flags["--run-id"]);
|
|
707
|
+
const note = requireFlagValue("--note", parsed.flags["--note"]);
|
|
708
|
+
(0, task_1.runTaskUpdateCommand)({
|
|
709
|
+
root,
|
|
710
|
+
id,
|
|
711
|
+
ws,
|
|
712
|
+
status,
|
|
713
|
+
priority,
|
|
714
|
+
addArtifacts,
|
|
715
|
+
addLinks,
|
|
716
|
+
addRefs,
|
|
717
|
+
addSkills,
|
|
718
|
+
addTags,
|
|
719
|
+
addBlockedBy,
|
|
720
|
+
clearBlockedBy,
|
|
721
|
+
runId,
|
|
722
|
+
note,
|
|
723
|
+
});
|
|
724
|
+
return 0;
|
|
406
725
|
}
|
|
726
|
+
case "done": {
|
|
727
|
+
const id = parsed.positionals[2];
|
|
728
|
+
if (!id || parsed.positionals.length > 3) {
|
|
729
|
+
throw new errors_1.UsageError("task done requires <id-or-qid>");
|
|
730
|
+
}
|
|
731
|
+
const ws = requireFlagValue("--ws", parsed.flags["--ws"]);
|
|
732
|
+
const addArtifacts = requireFlagValue("--add-artifacts", parsed.flags["--add-artifacts"]);
|
|
733
|
+
const addLinks = requireFlagValue("--add-links", parsed.flags["--add-links"]);
|
|
734
|
+
const addRefs = requireFlagValue("--add-refs", parsed.flags["--add-refs"]);
|
|
735
|
+
const checkpoint = requireFlagValue("--checkpoint", parsed.flags["--checkpoint"]);
|
|
736
|
+
const runId = requireFlagValue("--run-id", parsed.flags["--run-id"]);
|
|
737
|
+
const note = requireFlagValue("--note", parsed.flags["--note"]);
|
|
738
|
+
(0, task_1.runTaskDoneCommand)({
|
|
739
|
+
root,
|
|
740
|
+
id,
|
|
741
|
+
ws,
|
|
742
|
+
addArtifacts,
|
|
743
|
+
addLinks,
|
|
744
|
+
addRefs,
|
|
745
|
+
checkpoint,
|
|
746
|
+
runId,
|
|
747
|
+
note,
|
|
748
|
+
});
|
|
749
|
+
return 0;
|
|
750
|
+
}
|
|
751
|
+
default:
|
|
752
|
+
throw new errors_1.UsageError("task requires start/update/done");
|
|
407
753
|
}
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
const updateGitignore = parseBooleanFlag("--update-gitignore", parsed.flags["--update-gitignore"]);
|
|
416
|
-
const updateNpmignore = parseBooleanFlag("--update-npmignore", parsed.flags["--update-npmignore"]);
|
|
417
|
-
const updateDockerignore = parseBooleanFlag("--update-dockerignore", parsed.flags["--update-dockerignore"]);
|
|
418
|
-
try {
|
|
419
|
-
(0, init_1.runInitCommand)({
|
|
420
|
-
root,
|
|
421
|
-
force,
|
|
422
|
-
updateGitignore,
|
|
423
|
-
updateNpmignore,
|
|
424
|
-
updateDockerignore,
|
|
425
|
-
createAgents,
|
|
426
|
-
createClaude,
|
|
427
|
-
createLlm,
|
|
428
|
-
});
|
|
429
|
-
}
|
|
430
|
-
catch (err) {
|
|
431
|
-
handleCommandError(err);
|
|
432
|
-
}
|
|
433
|
-
process.exit(0);
|
|
754
|
+
}
|
|
755
|
+
function runEventSubcommand(parsed, root) {
|
|
756
|
+
const subcommand = (parsed.positionals[1] ?? "").toLowerCase();
|
|
757
|
+
switch (subcommand) {
|
|
758
|
+
case "enable": {
|
|
759
|
+
if (parsed.positionals.length > 2) {
|
|
760
|
+
throw new errors_1.UsageError("event enable does not accept positional arguments");
|
|
434
761
|
}
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
762
|
+
const ws = requireFlagValue("--ws", parsed.flags["--ws"]);
|
|
763
|
+
const noUpdateGitignore = parseBooleanFlag("--no-update-gitignore", parsed.flags["--no-update-gitignore"]);
|
|
764
|
+
(0, event_1.runEventEnableCommand)({ root, ws, updateGitignore: !noUpdateGitignore });
|
|
765
|
+
return 0;
|
|
766
|
+
}
|
|
767
|
+
case "append": {
|
|
768
|
+
if (parsed.positionals.length > 2) {
|
|
769
|
+
throw new errors_1.UsageError("event append does not accept positional arguments");
|
|
443
770
|
}
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
catch (err) {
|
|
450
|
-
handleCommandError(err);
|
|
451
|
-
}
|
|
452
|
-
process.exit(0);
|
|
771
|
+
const kind = requireFlagValue("--kind", parsed.flags["--kind"]);
|
|
772
|
+
const status = requireFlagValue("--status", parsed.flags["--status"]);
|
|
773
|
+
const refs = requireFlagValue("--refs", parsed.flags["--refs"]);
|
|
774
|
+
if (!kind || !status || !refs) {
|
|
775
|
+
throw new errors_1.UsageError("event append requires --kind, --status, and --refs");
|
|
453
776
|
}
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
777
|
+
const ws = requireFlagValue("--ws", parsed.flags["--ws"]);
|
|
778
|
+
const artifacts = requireFlagValue("--artifacts", parsed.flags["--artifacts"]);
|
|
779
|
+
const notes = requireFlagValue("--notes", parsed.flags["--notes"]);
|
|
780
|
+
const runId = requireFlagValue("--run-id", parsed.flags["--run-id"]);
|
|
781
|
+
const agent = requireFlagValue("--agent", parsed.flags["--agent"]);
|
|
782
|
+
const skill = requireFlagValue("--skill", parsed.flags["--skill"]);
|
|
783
|
+
const tool = requireFlagValue("--tool", parsed.flags["--tool"]);
|
|
784
|
+
(0, event_1.runEventAppendCommand)({
|
|
785
|
+
root,
|
|
786
|
+
ws,
|
|
787
|
+
kind,
|
|
788
|
+
status,
|
|
789
|
+
refs,
|
|
790
|
+
artifacts,
|
|
791
|
+
notes,
|
|
792
|
+
runId,
|
|
793
|
+
agent,
|
|
794
|
+
skill,
|
|
795
|
+
tool,
|
|
796
|
+
});
|
|
797
|
+
return 0;
|
|
798
|
+
}
|
|
799
|
+
default:
|
|
800
|
+
throw new errors_1.UsageError("event requires enable/append");
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
function runCommand(parsed, root, runtime) {
|
|
804
|
+
const command = (parsed.positionals[0] ?? "").toLowerCase();
|
|
805
|
+
switch (command) {
|
|
806
|
+
case "init": {
|
|
807
|
+
const force = parseBooleanFlag("--force", parsed.flags["--force"]);
|
|
808
|
+
const createAgents = parseBooleanFlag("--agents", parsed.flags["--agents"]);
|
|
809
|
+
const createClaude = parseBooleanFlag("--claude", parsed.flags["--claude"]);
|
|
810
|
+
const createLlm = parseBooleanFlag("--llm", parsed.flags["--llm"]);
|
|
811
|
+
const omni = parseBooleanFlag("--omni", parsed.flags["--omni"]);
|
|
812
|
+
const noUpdateIgnores = parseBooleanFlag("--no-update-ignores", parsed.flags["--no-update-ignores"]);
|
|
813
|
+
const updateGitignore = parseBooleanFlag("--update-gitignore", parsed.flags["--update-gitignore"]);
|
|
814
|
+
const updateNpmignore = parseBooleanFlag("--update-npmignore", parsed.flags["--update-npmignore"]);
|
|
815
|
+
const updateDockerignore = parseBooleanFlag("--update-dockerignore", parsed.flags["--update-dockerignore"]);
|
|
816
|
+
(0, init_1.runInitCommand)({
|
|
817
|
+
root,
|
|
818
|
+
force,
|
|
819
|
+
updateGitignore,
|
|
820
|
+
updateNpmignore,
|
|
821
|
+
updateDockerignore,
|
|
822
|
+
noUpdateIgnores,
|
|
823
|
+
createAgents,
|
|
824
|
+
createClaude,
|
|
825
|
+
createLlm,
|
|
826
|
+
omni,
|
|
827
|
+
});
|
|
828
|
+
return 0;
|
|
829
|
+
}
|
|
830
|
+
case "guide":
|
|
831
|
+
(0, guide_1.runGuideCommand)({ root });
|
|
832
|
+
return 0;
|
|
833
|
+
case "index": {
|
|
834
|
+
const tolerant = Boolean(parsed.flags["--tolerant"]);
|
|
835
|
+
(0, index_1.runIndexCommand)({ root, tolerant });
|
|
836
|
+
return 0;
|
|
837
|
+
}
|
|
838
|
+
case "new": {
|
|
839
|
+
const type = parsed.positionals[1];
|
|
840
|
+
const title = parsed.positionals.slice(2).join(" ");
|
|
841
|
+
if (!type || !title) {
|
|
842
|
+
throw new errors_1.UsageError("new requires a type and title");
|
|
513
843
|
}
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
844
|
+
const ws = requireFlagValue("--ws", parsed.flags["--ws"]);
|
|
845
|
+
const status = requireFlagValue("--status", parsed.flags["--status"]);
|
|
846
|
+
const priority = parseNumberFlag("--priority", parsed.flags["--priority"]);
|
|
847
|
+
const epic = requireFlagValue("--epic", parsed.flags["--epic"]);
|
|
848
|
+
const parent = requireFlagValue("--parent", parsed.flags["--parent"]);
|
|
849
|
+
const prev = requireFlagValue("--prev", parsed.flags["--prev"]);
|
|
850
|
+
const next = requireFlagValue("--next", parsed.flags["--next"]);
|
|
851
|
+
const relates = requireFlagValue("--relates", parsed.flags["--relates"]);
|
|
852
|
+
const blockedBy = requireFlagValue("--blocked-by", parsed.flags["--blocked-by"]);
|
|
853
|
+
const blocks = requireFlagValue("--blocks", parsed.flags["--blocks"]);
|
|
854
|
+
const links = requireFlagValue("--links", parsed.flags["--links"]);
|
|
855
|
+
const artifacts = requireFlagValue("--artifacts", parsed.flags["--artifacts"]);
|
|
856
|
+
const refs = requireFlagValue("--refs", parsed.flags["--refs"]);
|
|
857
|
+
const aliases = requireFlagValue("--aliases", parsed.flags["--aliases"]);
|
|
858
|
+
const skills = requireFlagValue("--skills", parsed.flags["--skills"]);
|
|
859
|
+
const cases = requireFlagValue("--cases", parsed.flags["--cases"]);
|
|
860
|
+
const tags = requireFlagValue("--tags", parsed.flags["--tags"]);
|
|
861
|
+
const owners = requireFlagValue("--owners", parsed.flags["--owners"]);
|
|
862
|
+
const supersedes = requireFlagValue("--supersedes", parsed.flags["--supersedes"]);
|
|
863
|
+
const template = requireFlagValue("--template", parsed.flags["--template"]);
|
|
864
|
+
const noCache = parseBooleanFlag("--no-cache", parsed.flags["--no-cache"]);
|
|
865
|
+
const noReindex = parseBooleanFlag("--no-reindex", parsed.flags["--no-reindex"]);
|
|
866
|
+
const runId = requireFlagValue("--run-id", parsed.flags["--run-id"]);
|
|
867
|
+
(0, new_1.runNewCommand)({
|
|
868
|
+
root,
|
|
869
|
+
type,
|
|
870
|
+
title,
|
|
871
|
+
ws,
|
|
872
|
+
status,
|
|
873
|
+
priority,
|
|
874
|
+
epic,
|
|
875
|
+
parent,
|
|
876
|
+
prev,
|
|
877
|
+
next,
|
|
878
|
+
relates,
|
|
879
|
+
blockedBy,
|
|
880
|
+
blocks,
|
|
881
|
+
links,
|
|
882
|
+
artifacts,
|
|
883
|
+
refs,
|
|
884
|
+
aliases,
|
|
885
|
+
skills,
|
|
886
|
+
cases,
|
|
887
|
+
tags,
|
|
888
|
+
owners,
|
|
889
|
+
supersedes,
|
|
890
|
+
template,
|
|
891
|
+
noCache,
|
|
892
|
+
noReindex,
|
|
893
|
+
runId,
|
|
894
|
+
});
|
|
895
|
+
return 0;
|
|
896
|
+
}
|
|
897
|
+
case "workspace":
|
|
898
|
+
return runWorkspaceSubcommand(parsed, root);
|
|
899
|
+
case "skill":
|
|
900
|
+
return runSkillSubcommand(parsed, root);
|
|
901
|
+
case "task":
|
|
902
|
+
return runTaskSubcommand(parsed, root);
|
|
903
|
+
case "event":
|
|
904
|
+
return runEventSubcommand(parsed, root);
|
|
905
|
+
case "show": {
|
|
906
|
+
const id = parsed.positionals[1];
|
|
907
|
+
if (!id || parsed.positionals.length > 2) {
|
|
908
|
+
throw new errors_1.UsageError("show requires a single id");
|
|
562
909
|
}
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
catch (err) {
|
|
583
|
-
handleCommandError(err);
|
|
584
|
-
}
|
|
585
|
-
process.exit(0);
|
|
910
|
+
const ws = requireFlagValue("--ws", parsed.flags["--ws"]);
|
|
911
|
+
const metaOnly = parseBooleanFlag("--meta", parsed.flags["--meta"]);
|
|
912
|
+
const json = parseBooleanFlag("--json", parsed.flags["--json"]);
|
|
913
|
+
const noCache = parseBooleanFlag("--no-cache", parsed.flags["--no-cache"]);
|
|
914
|
+
const noReindex = parseBooleanFlag("--no-reindex", parsed.flags["--no-reindex"]);
|
|
915
|
+
(0, show_1.runShowCommand)({
|
|
916
|
+
root,
|
|
917
|
+
id,
|
|
918
|
+
ws,
|
|
919
|
+
metaOnly,
|
|
920
|
+
json,
|
|
921
|
+
noCache,
|
|
922
|
+
noReindex,
|
|
923
|
+
});
|
|
924
|
+
return 0;
|
|
925
|
+
}
|
|
926
|
+
case "list": {
|
|
927
|
+
if (parsed.positionals.length > 1) {
|
|
928
|
+
throw new errors_1.UsageError("list does not accept positional arguments");
|
|
586
929
|
}
|
|
587
|
-
|
|
930
|
+
const ws = requireFlagValue("--ws", parsed.flags["--ws"]);
|
|
931
|
+
const type = requireFlagValue("--type", parsed.flags["--type"]);
|
|
932
|
+
const status = requireFlagValue("--status", parsed.flags["--status"]);
|
|
933
|
+
const epic = requireFlagValue("--epic", parsed.flags["--epic"]);
|
|
934
|
+
const priority = parseNumberFlag("--priority", parsed.flags["--priority"]);
|
|
935
|
+
const blocked = parseBooleanFlag("--blocked", parsed.flags["--blocked"]);
|
|
936
|
+
const tags = parseCsvFlag("--tags", parsed.flags["--tags"]);
|
|
937
|
+
const tagsMode = parseTagsModeFlag(parsed.flags["--tags-mode"]);
|
|
938
|
+
const json = parseBooleanFlag("--json", parsed.flags["--json"]);
|
|
939
|
+
const noCache = parseBooleanFlag("--no-cache", parsed.flags["--no-cache"]);
|
|
940
|
+
const noReindex = parseBooleanFlag("--no-reindex", parsed.flags["--no-reindex"]);
|
|
941
|
+
(0, list_1.runListCommand)({
|
|
942
|
+
root,
|
|
943
|
+
ws,
|
|
944
|
+
type,
|
|
945
|
+
status,
|
|
946
|
+
epic,
|
|
947
|
+
priority,
|
|
948
|
+
blocked,
|
|
949
|
+
tags,
|
|
950
|
+
tagsMode,
|
|
951
|
+
json,
|
|
952
|
+
noCache,
|
|
953
|
+
noReindex,
|
|
954
|
+
});
|
|
955
|
+
return 0;
|
|
956
|
+
}
|
|
957
|
+
case "search": {
|
|
958
|
+
if (parsed.positionals.length < 2) {
|
|
959
|
+
throw new errors_1.UsageError("search requires a query");
|
|
960
|
+
}
|
|
961
|
+
const query = parsed.positionals.slice(1).join(" ");
|
|
962
|
+
const ws = requireFlagValue("--ws", parsed.flags["--ws"]);
|
|
963
|
+
const type = requireFlagValue("--type", parsed.flags["--type"]);
|
|
964
|
+
const status = requireFlagValue("--status", parsed.flags["--status"]);
|
|
965
|
+
const tags = parseCsvFlag("--tags", parsed.flags["--tags"]);
|
|
966
|
+
const tagsMode = parseTagsModeFlag(parsed.flags["--tags-mode"]);
|
|
967
|
+
const json = parseBooleanFlag("--json", parsed.flags["--json"]);
|
|
968
|
+
const noCache = parseBooleanFlag("--no-cache", parsed.flags["--no-cache"]);
|
|
969
|
+
const noReindex = parseBooleanFlag("--no-reindex", parsed.flags["--no-reindex"]);
|
|
970
|
+
(0, search_1.runSearchCommand)({
|
|
971
|
+
root,
|
|
972
|
+
query,
|
|
973
|
+
ws,
|
|
974
|
+
type,
|
|
975
|
+
status,
|
|
976
|
+
tags,
|
|
977
|
+
tagsMode,
|
|
978
|
+
json,
|
|
979
|
+
noCache,
|
|
980
|
+
noReindex,
|
|
981
|
+
});
|
|
982
|
+
return 0;
|
|
983
|
+
}
|
|
984
|
+
case "pack": {
|
|
985
|
+
const listProfiles = parseBooleanFlag("--list-profiles", parsed.flags["--list-profiles"]);
|
|
986
|
+
if (listProfiles) {
|
|
588
987
|
if (parsed.positionals.length > 1) {
|
|
589
|
-
|
|
988
|
+
throw new errors_1.UsageError("pack --list-profiles does not accept positional arguments");
|
|
590
989
|
}
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
const status = requireFlagValue("--status", parsed.flags["--status"]);
|
|
594
|
-
const epic = requireFlagValue("--epic", parsed.flags["--epic"]);
|
|
595
|
-
const priority = parseNumberFlag("--priority", parsed.flags["--priority"]);
|
|
596
|
-
const blocked = parseBooleanFlag("--blocked", parsed.flags["--blocked"]);
|
|
597
|
-
const noCache = parseBooleanFlag("--no-cache", parsed.flags["--no-cache"]);
|
|
598
|
-
const noReindex = parseBooleanFlag("--no-reindex", parsed.flags["--no-reindex"]);
|
|
599
|
-
try {
|
|
600
|
-
(0, list_1.runListCommand)({
|
|
601
|
-
root,
|
|
602
|
-
ws,
|
|
603
|
-
type,
|
|
604
|
-
status,
|
|
605
|
-
epic,
|
|
606
|
-
priority,
|
|
607
|
-
blocked,
|
|
608
|
-
noCache,
|
|
609
|
-
noReindex,
|
|
610
|
-
});
|
|
611
|
-
}
|
|
612
|
-
catch (err) {
|
|
613
|
-
handleCommandError(err);
|
|
614
|
-
}
|
|
615
|
-
process.exit(0);
|
|
990
|
+
printPackProfiles(runtime.log);
|
|
991
|
+
return 0;
|
|
616
992
|
}
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
}
|
|
621
|
-
const query = parsed.positionals.slice(1).join(" ");
|
|
622
|
-
const ws = requireFlagValue("--ws", parsed.flags["--ws"]);
|
|
623
|
-
const type = requireFlagValue("--type", parsed.flags["--type"]);
|
|
624
|
-
const status = requireFlagValue("--status", parsed.flags["--status"]);
|
|
625
|
-
const noCache = parseBooleanFlag("--no-cache", parsed.flags["--no-cache"]);
|
|
626
|
-
const noReindex = parseBooleanFlag("--no-reindex", parsed.flags["--no-reindex"]);
|
|
627
|
-
try {
|
|
628
|
-
(0, search_1.runSearchCommand)({
|
|
629
|
-
root,
|
|
630
|
-
query,
|
|
631
|
-
ws,
|
|
632
|
-
type,
|
|
633
|
-
status,
|
|
634
|
-
noCache,
|
|
635
|
-
noReindex,
|
|
636
|
-
});
|
|
637
|
-
}
|
|
638
|
-
catch (err) {
|
|
639
|
-
handleCommandError(err);
|
|
640
|
-
}
|
|
641
|
-
process.exit(0);
|
|
993
|
+
const id = parsed.positionals[1];
|
|
994
|
+
if (!id || parsed.positionals.length > 2) {
|
|
995
|
+
throw new errors_1.UsageError("pack requires a single id");
|
|
642
996
|
}
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
truncationReport,
|
|
695
|
-
out,
|
|
696
|
-
noCache,
|
|
697
|
-
noReindex,
|
|
698
|
-
});
|
|
699
|
-
}
|
|
700
|
-
catch (err) {
|
|
701
|
-
handleCommandError(err);
|
|
702
|
-
}
|
|
703
|
-
process.exit(0);
|
|
997
|
+
const ws = requireFlagValue("--ws", parsed.flags["--ws"]);
|
|
998
|
+
const depth = parseNumberFlag("--depth", parsed.flags["--depth"]);
|
|
999
|
+
const edges = parseEdgesFlag(parsed.flags["--edges"]);
|
|
1000
|
+
const verbose = parseBooleanFlag("--verbose", parsed.flags["--verbose"]);
|
|
1001
|
+
const concise = parseBooleanFlag("--concise", parsed.flags["--concise"]);
|
|
1002
|
+
const stripCode = parseBooleanFlag("--strip-code", parsed.flags["--strip-code"]);
|
|
1003
|
+
const format = requireFlagValue("--format", parsed.flags["--format"]);
|
|
1004
|
+
const packProfile = requireFlagValue("--pack-profile", parsed.flags["--pack-profile"]);
|
|
1005
|
+
const maxCodeLines = parseNumberFlag("--max-code-lines", parsed.flags["--max-code-lines"]);
|
|
1006
|
+
const maxChars = parseNumberFlag("--max-chars", parsed.flags["--max-chars"]);
|
|
1007
|
+
const maxLines = parseNumberFlag("--max-lines", parsed.flags["--max-lines"]);
|
|
1008
|
+
const maxTokens = parseNumberFlag("--max-tokens", parsed.flags["--max-tokens"]);
|
|
1009
|
+
const skills = requireFlagValue("--skills", parsed.flags["--skills"]);
|
|
1010
|
+
const skillsDepth = requireFlagValue("--skills-depth", parsed.flags["--skills-depth"]);
|
|
1011
|
+
const dryRun = parseBooleanFlag("--dry-run", parsed.flags["--dry-run"]);
|
|
1012
|
+
const stats = parseBooleanFlag("--stats", parsed.flags["--stats"]);
|
|
1013
|
+
const statsOut = requireFlagValue("--stats-out", parsed.flags["--stats-out"]);
|
|
1014
|
+
const truncationReport = requireFlagValue("--truncation-report", parsed.flags["--truncation-report"]);
|
|
1015
|
+
const out = requireFlagValue("--out", parsed.flags["--out"]);
|
|
1016
|
+
const noCache = parseBooleanFlag("--no-cache", parsed.flags["--no-cache"]);
|
|
1017
|
+
const noReindex = parseBooleanFlag("--no-reindex", parsed.flags["--no-reindex"]);
|
|
1018
|
+
(0, pack_1.runPackCommand)({
|
|
1019
|
+
root,
|
|
1020
|
+
id,
|
|
1021
|
+
ws,
|
|
1022
|
+
depth,
|
|
1023
|
+
edges,
|
|
1024
|
+
verbose,
|
|
1025
|
+
concise,
|
|
1026
|
+
stripCode,
|
|
1027
|
+
format,
|
|
1028
|
+
packProfile,
|
|
1029
|
+
maxCodeLines,
|
|
1030
|
+
maxChars,
|
|
1031
|
+
maxLines,
|
|
1032
|
+
maxTokens,
|
|
1033
|
+
skills,
|
|
1034
|
+
skillsDepth,
|
|
1035
|
+
dryRun,
|
|
1036
|
+
stats,
|
|
1037
|
+
statsOut,
|
|
1038
|
+
truncationReport,
|
|
1039
|
+
out,
|
|
1040
|
+
noCache,
|
|
1041
|
+
noReindex,
|
|
1042
|
+
});
|
|
1043
|
+
return 0;
|
|
1044
|
+
}
|
|
1045
|
+
case "next": {
|
|
1046
|
+
if (parsed.positionals.length > 2) {
|
|
1047
|
+
throw new errors_1.UsageError("next accepts at most one id");
|
|
704
1048
|
}
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
catch (err) {
|
|
723
|
-
handleCommandError(err);
|
|
724
|
-
}
|
|
725
|
-
process.exit(0);
|
|
1049
|
+
const id = parsed.positionals[1];
|
|
1050
|
+
const ws = requireFlagValue("--ws", parsed.flags["--ws"]);
|
|
1051
|
+
const noCache = parseBooleanFlag("--no-cache", parsed.flags["--no-cache"]);
|
|
1052
|
+
const noReindex = parseBooleanFlag("--no-reindex", parsed.flags["--no-reindex"]);
|
|
1053
|
+
(0, next_1.runNextCommand)({
|
|
1054
|
+
root,
|
|
1055
|
+
id,
|
|
1056
|
+
ws,
|
|
1057
|
+
noCache,
|
|
1058
|
+
noReindex,
|
|
1059
|
+
});
|
|
1060
|
+
return 0;
|
|
1061
|
+
}
|
|
1062
|
+
case "checkpoint": {
|
|
1063
|
+
const sub = (parsed.positionals[1] ?? "").toLowerCase();
|
|
1064
|
+
if (!sub) {
|
|
1065
|
+
throw new errors_1.UsageError("checkpoint requires a subcommand");
|
|
726
1066
|
}
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
if (!sub) {
|
|
730
|
-
handleCommandError(new errors_1.UsageError("checkpoint requires a subcommand"));
|
|
731
|
-
}
|
|
732
|
-
if (sub !== "new") {
|
|
733
|
-
handleCommandError(new errors_1.UsageError(`unknown checkpoint subcommand: ${sub}`));
|
|
734
|
-
}
|
|
735
|
-
const title = parsed.positionals.slice(2).join(" ");
|
|
736
|
-
const ws = requireFlagValue("--ws", parsed.flags["--ws"]);
|
|
737
|
-
const relates = requireFlagValue("--relates", parsed.flags["--relates"]);
|
|
738
|
-
const scope = requireFlagValue("--scope", parsed.flags["--scope"]);
|
|
739
|
-
const status = requireFlagValue("--status", parsed.flags["--status"]);
|
|
740
|
-
const priority = parseNumberFlag("--priority", parsed.flags["--priority"]);
|
|
741
|
-
const template = requireFlagValue("--template", parsed.flags["--template"]);
|
|
742
|
-
try {
|
|
743
|
-
(0, checkpoint_1.runCheckpointNewCommand)({
|
|
744
|
-
root,
|
|
745
|
-
title,
|
|
746
|
-
ws,
|
|
747
|
-
relates,
|
|
748
|
-
scope,
|
|
749
|
-
status,
|
|
750
|
-
priority,
|
|
751
|
-
template,
|
|
752
|
-
});
|
|
753
|
-
}
|
|
754
|
-
catch (err) {
|
|
755
|
-
handleCommandError(err);
|
|
756
|
-
}
|
|
757
|
-
process.exit(0);
|
|
1067
|
+
if (sub !== "new") {
|
|
1068
|
+
throw new errors_1.UsageError(`unknown checkpoint subcommand: ${sub}`);
|
|
758
1069
|
}
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
1070
|
+
const title = parsed.positionals.slice(2).join(" ");
|
|
1071
|
+
const ws = requireFlagValue("--ws", parsed.flags["--ws"]);
|
|
1072
|
+
const relates = requireFlagValue("--relates", parsed.flags["--relates"]);
|
|
1073
|
+
const scope = requireFlagValue("--scope", parsed.flags["--scope"]);
|
|
1074
|
+
const status = requireFlagValue("--status", parsed.flags["--status"]);
|
|
1075
|
+
const priority = parseNumberFlag("--priority", parsed.flags["--priority"]);
|
|
1076
|
+
const template = requireFlagValue("--template", parsed.flags["--template"]);
|
|
1077
|
+
const runId = requireFlagValue("--run-id", parsed.flags["--run-id"]);
|
|
1078
|
+
const note = requireFlagValue("--note", parsed.flags["--note"]);
|
|
1079
|
+
(0, checkpoint_1.runCheckpointNewCommand)({
|
|
1080
|
+
root,
|
|
1081
|
+
title,
|
|
1082
|
+
ws,
|
|
1083
|
+
relates,
|
|
1084
|
+
scope,
|
|
1085
|
+
status,
|
|
1086
|
+
priority,
|
|
1087
|
+
template,
|
|
1088
|
+
runId,
|
|
1089
|
+
note,
|
|
1090
|
+
});
|
|
1091
|
+
return 0;
|
|
1092
|
+
}
|
|
1093
|
+
case "validate": {
|
|
1094
|
+
if (parsed.positionals.length > 1) {
|
|
1095
|
+
throw new errors_1.UsageError("validate does not accept positional arguments");
|
|
772
1096
|
}
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
handleCommandError(err);
|
|
782
|
-
}
|
|
783
|
-
process.exit(0);
|
|
1097
|
+
const out = requireFlagValue("--out", parsed.flags["--out"]);
|
|
1098
|
+
const quiet = parseBooleanFlag("--quiet", parsed.flags["--quiet"]);
|
|
1099
|
+
(0, validate_1.runValidateCommand)({ root, out, quiet });
|
|
1100
|
+
return 0;
|
|
1101
|
+
}
|
|
1102
|
+
case "format":
|
|
1103
|
+
if (parsed.positionals.length > 1) {
|
|
1104
|
+
throw new errors_1.UsageError("format does not accept positional arguments");
|
|
784
1105
|
}
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
const noReindex = parseBooleanFlag("--no-reindex", parsed.flags["--no-reindex"]);
|
|
791
|
-
const json = parseBooleanFlag("--json", parsed.flags["--json"]);
|
|
792
|
-
try {
|
|
793
|
-
(0, doctor_1.runDoctorCommand)({ root, noCache, noReindex, json });
|
|
794
|
-
}
|
|
795
|
-
catch (err) {
|
|
796
|
-
handleCommandError(err);
|
|
797
|
-
}
|
|
798
|
-
process.exit(0);
|
|
1106
|
+
(0, format_1.runFormatCommand)({ root });
|
|
1107
|
+
return 0;
|
|
1108
|
+
case "doctor": {
|
|
1109
|
+
if (parsed.positionals.length > 1) {
|
|
1110
|
+
throw new errors_1.UsageError("doctor does not accept positional arguments");
|
|
799
1111
|
}
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
1112
|
+
const noCache = parseBooleanFlag("--no-cache", parsed.flags["--no-cache"]);
|
|
1113
|
+
const noReindex = parseBooleanFlag("--no-reindex", parsed.flags["--no-reindex"]);
|
|
1114
|
+
const json = parseBooleanFlag("--json", parsed.flags["--json"]);
|
|
1115
|
+
(0, doctor_1.runDoctorCommand)({ root, noCache, noReindex, json });
|
|
1116
|
+
return 0;
|
|
804
1117
|
}
|
|
1118
|
+
default:
|
|
1119
|
+
runtime.error(`Unknown command: ${command}`);
|
|
1120
|
+
printUsage(runtime.log);
|
|
1121
|
+
return 1;
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
function runCli(argv, runtime = {}) {
|
|
1125
|
+
const io = resolveRuntime(runtime);
|
|
1126
|
+
const parsed = (0, argparse_1.parseArgs)(argv);
|
|
1127
|
+
if (parsed.error) {
|
|
1128
|
+
io.error(parsed.error);
|
|
1129
|
+
printUsage(io.log);
|
|
1130
|
+
return 1;
|
|
1131
|
+
}
|
|
1132
|
+
if (parsed.help) {
|
|
1133
|
+
printCommandHelp(io.log, parsed.positionals[0], parsed.positionals[1]);
|
|
1134
|
+
return 0;
|
|
1135
|
+
}
|
|
1136
|
+
if (parsed.version) {
|
|
1137
|
+
io.log(readPackageVersion());
|
|
1138
|
+
return 0;
|
|
1139
|
+
}
|
|
1140
|
+
const command = (parsed.positionals[0] ?? "").toLowerCase();
|
|
1141
|
+
if (!command) {
|
|
1142
|
+
printUsage(io.log);
|
|
1143
|
+
return 0;
|
|
1144
|
+
}
|
|
1145
|
+
if (command === "help") {
|
|
1146
|
+
printCommandHelp(io.log, parsed.positionals[1], parsed.positionals[2]);
|
|
1147
|
+
return 0;
|
|
1148
|
+
}
|
|
1149
|
+
const root = parsed.root ? path_1.default.resolve(parsed.root) : io.cwd();
|
|
1150
|
+
if (shouldRequireConfig(command, parsed.flags) && !hasConfig(root)) {
|
|
1151
|
+
printRootError(io.error, root);
|
|
1152
|
+
return 1;
|
|
1153
|
+
}
|
|
1154
|
+
try {
|
|
1155
|
+
return runCommand(parsed, root, io);
|
|
805
1156
|
}
|
|
806
1157
|
catch (err) {
|
|
807
|
-
handleCommandError(err);
|
|
1158
|
+
return handleCommandError(err, command, io);
|
|
808
1159
|
}
|
|
809
1160
|
}
|
|
810
|
-
main()
|
|
1161
|
+
function main(argv = process.argv.slice(2)) {
|
|
1162
|
+
process.exit(runCli(argv, { cwd: () => process.cwd() }));
|
|
1163
|
+
}
|
|
1164
|
+
if (require.main === module) {
|
|
1165
|
+
main();
|
|
1166
|
+
}
|