mdkg 0.0.3 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +181 -169
- package/dist/cli.js +1002 -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 +224 -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 +374 -0
- package/dist/commands/skill_mirror.js +290 -0
- package/dist/commands/skill_support.js +122 -0
- package/dist/commands/task.js +278 -0
- package/dist/commands/validate.js +106 -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/AGENTS.md +6 -41
- package/dist/init/AGENT_START.md +46 -0
- package/dist/init/CLAUDE.md +6 -35
- package/dist/init/CLI_COMMAND_MATRIX.md +29 -0
- package/dist/init/README.md +6 -4
- package/dist/init/core/HUMAN.md +36 -0
- package/dist/init/core/SOUL.md +257 -0
- package/dist/init/core/core.md +3 -1
- package/dist/init/core/rule-1-mdkg-conventions.md +9 -2
- package/dist/init/core/rule-3-cli-contract.md +81 -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/llms.txt +17 -0
- 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 +36 -5
- 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,402 @@ 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 --agent");
|
|
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, CLAUDE.md, llms.txt, and AGENT_START.md");
|
|
90
|
+
log(" --agent Add SOUL/HUMAN/skills/events scaffolding and skill mirrors");
|
|
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
|
+
case "sync":
|
|
238
|
+
log("Usage:");
|
|
239
|
+
log(" mdkg skill sync [--force]");
|
|
240
|
+
log("\nWhen to use:");
|
|
241
|
+
log(" Rebuild .agents/skills and .claude/skills from canonical .mdkg/skills.");
|
|
242
|
+
printGlobalOptions(log);
|
|
243
|
+
return;
|
|
244
|
+
default:
|
|
245
|
+
log("Usage:");
|
|
246
|
+
log(' mdkg skill new <slug> "<name>" --description "<description>" [options]');
|
|
247
|
+
log(" mdkg skill list [--tags <tag,tag,...>] [--tags-mode any|all] [--json]");
|
|
248
|
+
log(" mdkg skill show <slug> [--meta] [--json]");
|
|
249
|
+
log(' mdkg skill search "<query>" [--tags <tag,tag,...>] [--tags-mode any|all] [--json]');
|
|
250
|
+
log(" mdkg skill validate [<slug>]");
|
|
251
|
+
log(" mdkg skill sync [--force]");
|
|
252
|
+
log("\nNotes:");
|
|
253
|
+
log(" Skills are first-class under `mdkg skill ...`.");
|
|
254
|
+
log(" Use stage tags like `stage:plan`, `stage:execute`, and `stage:review` with --tags.");
|
|
255
|
+
printGlobalOptions(log);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
function printTaskHelp(log, subcommand) {
|
|
259
|
+
switch ((subcommand ?? "").toLowerCase()) {
|
|
260
|
+
case "start":
|
|
261
|
+
log("Usage:");
|
|
262
|
+
log(' mdkg task start <id-or-qid> [--ws <alias>] [--run-id <id>] [--note "<text>"]');
|
|
263
|
+
log("\nWhen to use:");
|
|
264
|
+
log(" Move a task, bug, or test into progress and emit a baseline event when logging is enabled.");
|
|
265
|
+
log(" If events are disabled, mdkg prints a short reminder about `mdkg event enable`.");
|
|
266
|
+
printGlobalOptions(log);
|
|
267
|
+
return;
|
|
268
|
+
case "update":
|
|
269
|
+
log("Usage:");
|
|
270
|
+
log(" mdkg task update <id-or-qid> [--ws <alias>] [--status <status>] [--priority <n>]");
|
|
271
|
+
log(" [--add-artifacts <a,...>] [--add-links <l,...>] [--add-refs <id,...>]");
|
|
272
|
+
log(" [--add-skills <slug,...>] [--add-tags <tag,...>] [--add-blocked-by <id,...>]");
|
|
273
|
+
log(' [--clear-blocked-by] [--run-id <id>] [--note "<text>"]');
|
|
274
|
+
log("\nWhen to use:");
|
|
275
|
+
log(" Update task metadata and evidence without editing markdown manually.");
|
|
276
|
+
printGlobalOptions(log);
|
|
277
|
+
return;
|
|
278
|
+
case "done":
|
|
279
|
+
log("Usage:");
|
|
280
|
+
log(' mdkg task done <id-or-qid> [--ws <alias>] [--add-artifacts <a,...>] [--add-links <l,...>]');
|
|
281
|
+
log(' [--add-refs <id,...>] [--checkpoint "<title>"] [--run-id <id>] [--note "<text>"]');
|
|
282
|
+
log("\nWhen to use:");
|
|
283
|
+
log(" Mark a task-like node done, optionally create a checkpoint, and emit a completion event when enabled.");
|
|
284
|
+
log(" Use `--checkpoint` for milestone compression, not every routine task completion.");
|
|
285
|
+
printGlobalOptions(log);
|
|
286
|
+
return;
|
|
287
|
+
default:
|
|
288
|
+
log("Usage:");
|
|
289
|
+
log(' mdkg task start <id-or-qid> [--ws <alias>] [--run-id <id>] [--note "<text>"]');
|
|
290
|
+
log(" mdkg task update <id-or-qid> [options]");
|
|
291
|
+
log(' mdkg task done <id-or-qid> [--checkpoint "<title>"] [options]');
|
|
292
|
+
log("\nNotes:");
|
|
293
|
+
log(" `mdkg task ...` only supports task, bug, and test nodes in this wave.");
|
|
294
|
+
log(" Feat and epic closeout remain checkpoint-first guidance plus manual parent updates.");
|
|
295
|
+
printGlobalOptions(log);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
function printEventHelp(log, subcommand) {
|
|
299
|
+
switch ((subcommand ?? "").toLowerCase()) {
|
|
300
|
+
case "enable":
|
|
301
|
+
log("Usage:");
|
|
302
|
+
log(" mdkg event enable [--ws <alias>] [--no-update-gitignore]");
|
|
303
|
+
log("\nWhen to use:");
|
|
304
|
+
log(" Create the append-only JSONL event log for a workspace.");
|
|
305
|
+
printGlobalOptions(log);
|
|
306
|
+
return;
|
|
307
|
+
case "append":
|
|
308
|
+
log("Usage:");
|
|
309
|
+
log(" mdkg event append --kind <kind> --status <ok|error|retry|skipped> --refs <id,...>");
|
|
310
|
+
log(' [--ws <alias>] [--artifacts <a,...>] [--notes "<text>"] [--run-id <id>]');
|
|
311
|
+
log(" [--agent <name>] [--skill <slug>] [--tool <id>]");
|
|
312
|
+
log("\nWhen to use:");
|
|
313
|
+
log(" Append explicit provenance events from an orchestrator or manual workflow.");
|
|
314
|
+
printGlobalOptions(log);
|
|
315
|
+
return;
|
|
316
|
+
default:
|
|
317
|
+
log("Usage:");
|
|
318
|
+
log(" mdkg event enable [--ws <alias>] [--no-update-gitignore]");
|
|
319
|
+
log(" mdkg event append --kind <kind> --status <ok|error|retry|skipped> --refs <id,...> [options]");
|
|
320
|
+
printGlobalOptions(log);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
function printNextHelp(log) {
|
|
324
|
+
log("Usage:");
|
|
325
|
+
log(" mdkg next [<id-or-qid>] [--ws <alias>]");
|
|
326
|
+
printGlobalOptions(log);
|
|
327
|
+
}
|
|
328
|
+
function printCheckpointHelp(log) {
|
|
329
|
+
log("Usage:");
|
|
330
|
+
log(" mdkg checkpoint new <title> [--ws <alias>]");
|
|
331
|
+
log(' [--relates <id,id,...>] [--scope <id,id,...>] [--run-id <id>] [--note "<text>"]');
|
|
332
|
+
printGlobalOptions(log);
|
|
333
|
+
}
|
|
334
|
+
function printValidateHelp(log) {
|
|
335
|
+
log("Usage:");
|
|
336
|
+
log(" mdkg validate [--out <path>] [--quiet]");
|
|
337
|
+
printGlobalOptions(log);
|
|
338
|
+
}
|
|
339
|
+
function printFormatHelp(log) {
|
|
340
|
+
log("Usage:");
|
|
341
|
+
log(" mdkg format");
|
|
342
|
+
printGlobalOptions(log);
|
|
343
|
+
}
|
|
344
|
+
function printDoctorHelp(log) {
|
|
345
|
+
log("Usage:");
|
|
346
|
+
log(" mdkg doctor [--json]");
|
|
347
|
+
log("\nChecks:");
|
|
348
|
+
log(" - Node.js version compatibility");
|
|
349
|
+
log(" - mdkg repo root + .mdkg/config.json");
|
|
350
|
+
log(" - Template schema availability");
|
|
351
|
+
log(" - Index load/rebuild health");
|
|
352
|
+
log("\nOptions:");
|
|
353
|
+
log(" --json Emit machine-readable JSON output");
|
|
354
|
+
printGlobalOptions(log);
|
|
355
|
+
}
|
|
356
|
+
function printCommandHelp(log, command, subcommand) {
|
|
213
357
|
switch ((command ?? "").toLowerCase()) {
|
|
214
358
|
case "":
|
|
215
359
|
case "help":
|
|
216
|
-
printUsage();
|
|
360
|
+
printUsage(log);
|
|
217
361
|
return;
|
|
218
362
|
case "init":
|
|
219
|
-
printInitHelp();
|
|
363
|
+
printInitHelp(log);
|
|
220
364
|
return;
|
|
221
365
|
case "guide":
|
|
222
|
-
printGuideHelp();
|
|
366
|
+
printGuideHelp(log);
|
|
223
367
|
return;
|
|
224
368
|
case "new":
|
|
225
|
-
printNewHelp();
|
|
369
|
+
printNewHelp(log);
|
|
226
370
|
return;
|
|
227
371
|
case "workspace":
|
|
228
|
-
printWorkspaceHelp();
|
|
372
|
+
printWorkspaceHelp(log);
|
|
229
373
|
return;
|
|
230
374
|
case "index":
|
|
231
|
-
printIndexHelp();
|
|
375
|
+
printIndexHelp(log);
|
|
232
376
|
return;
|
|
233
377
|
case "show":
|
|
234
|
-
printShowHelp();
|
|
378
|
+
printShowHelp(log);
|
|
235
379
|
return;
|
|
236
380
|
case "list":
|
|
237
|
-
printListHelp();
|
|
381
|
+
printListHelp(log);
|
|
238
382
|
return;
|
|
239
383
|
case "search":
|
|
240
|
-
printSearchHelp();
|
|
384
|
+
printSearchHelp(log);
|
|
241
385
|
return;
|
|
242
386
|
case "pack":
|
|
243
|
-
printPackHelp();
|
|
387
|
+
printPackHelp(log);
|
|
388
|
+
return;
|
|
389
|
+
case "skill":
|
|
390
|
+
printSkillHelp(log, subcommand);
|
|
391
|
+
return;
|
|
392
|
+
case "task":
|
|
393
|
+
printTaskHelp(log, subcommand);
|
|
394
|
+
return;
|
|
395
|
+
case "event":
|
|
396
|
+
printEventHelp(log, subcommand);
|
|
244
397
|
return;
|
|
245
398
|
case "next":
|
|
246
|
-
printNextHelp();
|
|
399
|
+
printNextHelp(log);
|
|
247
400
|
return;
|
|
248
401
|
case "checkpoint":
|
|
249
|
-
printCheckpointHelp();
|
|
402
|
+
printCheckpointHelp(log);
|
|
250
403
|
return;
|
|
251
404
|
case "validate":
|
|
252
|
-
printValidateHelp();
|
|
405
|
+
printValidateHelp(log);
|
|
253
406
|
return;
|
|
254
407
|
case "format":
|
|
255
|
-
printFormatHelp();
|
|
408
|
+
printFormatHelp(log);
|
|
256
409
|
return;
|
|
257
410
|
case "doctor":
|
|
258
|
-
printDoctorHelp();
|
|
411
|
+
printDoctorHelp(log);
|
|
259
412
|
return;
|
|
260
413
|
default:
|
|
261
|
-
printUsage();
|
|
414
|
+
printUsage(log);
|
|
262
415
|
}
|
|
263
416
|
}
|
|
264
|
-
function printRootError(root) {
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
417
|
+
function printRootError(error, root) {
|
|
418
|
+
error("mdkg must be run from a repo root with .mdkg/config.json");
|
|
419
|
+
error(`root checked: ${root}`);
|
|
420
|
+
error("hint: run from the repo root, pass --root <path>, or run `mdkg init`");
|
|
268
421
|
}
|
|
269
422
|
function readPackageVersion() {
|
|
270
423
|
const packagePath = path_1.default.resolve(__dirname, "..", "package.json");
|
|
@@ -349,462 +502,687 @@ function parseEdgesFlag(value) {
|
|
|
349
502
|
.filter(Boolean);
|
|
350
503
|
return raw.length > 0 ? raw : undefined;
|
|
351
504
|
}
|
|
352
|
-
function
|
|
353
|
-
|
|
354
|
-
if (!raw || raw.startsWith("-")) {
|
|
505
|
+
function parseCsvFlag(flag, value) {
|
|
506
|
+
if (value === undefined) {
|
|
355
507
|
return undefined;
|
|
356
508
|
}
|
|
357
|
-
|
|
509
|
+
if (value === true) {
|
|
510
|
+
throw new errors_1.UsageError(`${flag} requires a value`);
|
|
511
|
+
}
|
|
512
|
+
const items = String(value)
|
|
513
|
+
.split(",")
|
|
514
|
+
.map((item) => item.trim().toLowerCase())
|
|
515
|
+
.filter(Boolean);
|
|
516
|
+
return items.length > 0 ? items : undefined;
|
|
517
|
+
}
|
|
518
|
+
function parseTagsModeFlag(value) {
|
|
519
|
+
if (value === undefined) {
|
|
520
|
+
return undefined;
|
|
521
|
+
}
|
|
522
|
+
if (value === true) {
|
|
523
|
+
throw new errors_1.UsageError("--tags-mode requires a value");
|
|
524
|
+
}
|
|
525
|
+
const normalized = String(value).toLowerCase();
|
|
526
|
+
if (normalized === "any" || normalized === "all") {
|
|
527
|
+
return normalized;
|
|
528
|
+
}
|
|
529
|
+
throw new errors_1.UsageError("--tags-mode must be any or all");
|
|
358
530
|
}
|
|
359
|
-
function handleCommandError(err) {
|
|
531
|
+
function handleCommandError(err, command, runtime) {
|
|
360
532
|
const message = err instanceof Error ? err.message : String(err);
|
|
361
533
|
if (err instanceof errors_1.UsageError) {
|
|
362
|
-
|
|
363
|
-
printCommandHelp(
|
|
364
|
-
|
|
534
|
+
runtime.error(message);
|
|
535
|
+
printCommandHelp(runtime.log, command);
|
|
536
|
+
return 1;
|
|
365
537
|
}
|
|
366
538
|
if (err instanceof errors_1.ValidationError) {
|
|
367
|
-
|
|
368
|
-
|
|
539
|
+
runtime.error(message);
|
|
540
|
+
return 2;
|
|
369
541
|
}
|
|
370
542
|
if (err instanceof errors_1.NotFoundError) {
|
|
371
|
-
|
|
372
|
-
|
|
543
|
+
runtime.error(message);
|
|
544
|
+
return 3;
|
|
373
545
|
}
|
|
374
|
-
|
|
375
|
-
|
|
546
|
+
runtime.error(message);
|
|
547
|
+
return 4;
|
|
376
548
|
}
|
|
377
|
-
function
|
|
378
|
-
const
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
549
|
+
function runWorkspaceSubcommand(parsed, root) {
|
|
550
|
+
const subcommand = (parsed.positionals[1] ?? "").toLowerCase();
|
|
551
|
+
switch (subcommand) {
|
|
552
|
+
case "ls": {
|
|
553
|
+
if (parsed.positionals.length > 2) {
|
|
554
|
+
throw new errors_1.UsageError("workspace ls takes no arguments");
|
|
555
|
+
}
|
|
556
|
+
(0, workspace_1.runWorkspaceListCommand)({ root });
|
|
557
|
+
return 0;
|
|
558
|
+
}
|
|
559
|
+
case "add": {
|
|
560
|
+
const alias = parsed.positionals[2];
|
|
561
|
+
const workspacePath = parsed.positionals[3];
|
|
562
|
+
if (!alias || !workspacePath) {
|
|
563
|
+
throw new errors_1.UsageError("workspace add requires <alias> <path>");
|
|
564
|
+
}
|
|
565
|
+
const mdkgDir = requireFlagValue("--mdkg-dir", parsed.flags["--mdkg-dir"]);
|
|
566
|
+
(0, workspace_1.runWorkspaceAddCommand)({ root, alias, workspacePath, mdkgDir });
|
|
567
|
+
return 0;
|
|
568
|
+
}
|
|
569
|
+
case "rm": {
|
|
570
|
+
const alias = parsed.positionals[2];
|
|
571
|
+
if (!alias || parsed.positionals.length > 3) {
|
|
572
|
+
throw new errors_1.UsageError("workspace rm requires <alias>");
|
|
573
|
+
}
|
|
574
|
+
(0, workspace_1.runWorkspaceRemoveCommand)({ root, alias });
|
|
575
|
+
return 0;
|
|
576
|
+
}
|
|
577
|
+
default:
|
|
578
|
+
throw new errors_1.UsageError("workspace requires ls/add/rm");
|
|
391
579
|
}
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
580
|
+
}
|
|
581
|
+
function runSkillSubcommand(parsed, root) {
|
|
582
|
+
const subcommand = (parsed.positionals[1] ?? "").toLowerCase();
|
|
583
|
+
switch (subcommand) {
|
|
584
|
+
case "new": {
|
|
585
|
+
const slug = parsed.positionals[2];
|
|
586
|
+
const name = parsed.positionals[3];
|
|
587
|
+
if (!slug || !name) {
|
|
588
|
+
throw new errors_1.UsageError('skill new requires <slug> "<name>"');
|
|
589
|
+
}
|
|
590
|
+
if (parsed.positionals.length > 4) {
|
|
591
|
+
throw new errors_1.UsageError('skill new accepts exactly <slug> "<name>"');
|
|
592
|
+
}
|
|
593
|
+
const description = requireFlagValue("--description", parsed.flags["--description"]);
|
|
594
|
+
if (!description) {
|
|
595
|
+
throw new errors_1.UsageError("skill new requires --description");
|
|
596
|
+
}
|
|
597
|
+
const tags = requireFlagValue("--tags", parsed.flags["--tags"]);
|
|
598
|
+
const authors = requireFlagValue("--authors", parsed.flags["--authors"]);
|
|
599
|
+
const links = requireFlagValue("--links", parsed.flags["--links"]);
|
|
600
|
+
const withScripts = parseBooleanFlag("--with-scripts", parsed.flags["--with-scripts"]);
|
|
601
|
+
const force = parseBooleanFlag("--force", parsed.flags["--force"]);
|
|
602
|
+
const runId = requireFlagValue("--run-id", parsed.flags["--run-id"]);
|
|
603
|
+
(0, skill_1.runSkillNewCommand)({
|
|
604
|
+
root,
|
|
605
|
+
slug,
|
|
606
|
+
name,
|
|
607
|
+
description,
|
|
608
|
+
tags,
|
|
609
|
+
authors,
|
|
610
|
+
links,
|
|
611
|
+
withScripts,
|
|
612
|
+
force,
|
|
613
|
+
runId,
|
|
614
|
+
});
|
|
615
|
+
return 0;
|
|
616
|
+
}
|
|
617
|
+
case "list": {
|
|
618
|
+
if (parsed.positionals.length > 2) {
|
|
619
|
+
throw new errors_1.UsageError("skill list does not accept positional arguments");
|
|
620
|
+
}
|
|
621
|
+
const tags = parseCsvFlag("--tags", parsed.flags["--tags"]);
|
|
622
|
+
const tagsMode = parseTagsModeFlag(parsed.flags["--tags-mode"]);
|
|
623
|
+
const noCache = parseBooleanFlag("--no-cache", parsed.flags["--no-cache"]);
|
|
624
|
+
const noReindex = parseBooleanFlag("--no-reindex", parsed.flags["--no-reindex"]);
|
|
625
|
+
const json = parseBooleanFlag("--json", parsed.flags["--json"]);
|
|
626
|
+
(0, skill_1.runSkillListCommand)({
|
|
627
|
+
root,
|
|
628
|
+
tags,
|
|
629
|
+
tagsMode,
|
|
630
|
+
json,
|
|
631
|
+
noCache,
|
|
632
|
+
noReindex,
|
|
633
|
+
});
|
|
634
|
+
return 0;
|
|
635
|
+
}
|
|
636
|
+
case "show": {
|
|
637
|
+
const slug = parsed.positionals[2];
|
|
638
|
+
if (!slug || parsed.positionals.length > 3) {
|
|
639
|
+
throw new errors_1.UsageError("skill show requires <slug>");
|
|
640
|
+
}
|
|
641
|
+
const metaOnly = parseBooleanFlag("--meta", parsed.flags["--meta"]);
|
|
642
|
+
const json = parseBooleanFlag("--json", parsed.flags["--json"]);
|
|
643
|
+
const noCache = parseBooleanFlag("--no-cache", parsed.flags["--no-cache"]);
|
|
644
|
+
const noReindex = parseBooleanFlag("--no-reindex", parsed.flags["--no-reindex"]);
|
|
645
|
+
(0, skill_1.runSkillShowCommand)({
|
|
646
|
+
root,
|
|
647
|
+
slug,
|
|
648
|
+
metaOnly,
|
|
649
|
+
json,
|
|
650
|
+
noCache,
|
|
651
|
+
noReindex,
|
|
652
|
+
});
|
|
653
|
+
return 0;
|
|
654
|
+
}
|
|
655
|
+
case "search": {
|
|
656
|
+
if (parsed.positionals.length < 3) {
|
|
657
|
+
throw new errors_1.UsageError("skill search requires a query");
|
|
658
|
+
}
|
|
659
|
+
const query = parsed.positionals.slice(2).join(" ");
|
|
660
|
+
const tags = parseCsvFlag("--tags", parsed.flags["--tags"]);
|
|
661
|
+
const tagsMode = parseTagsModeFlag(parsed.flags["--tags-mode"]);
|
|
662
|
+
const json = parseBooleanFlag("--json", parsed.flags["--json"]);
|
|
663
|
+
const noCache = parseBooleanFlag("--no-cache", parsed.flags["--no-cache"]);
|
|
664
|
+
const noReindex = parseBooleanFlag("--no-reindex", parsed.flags["--no-reindex"]);
|
|
665
|
+
(0, skill_1.runSkillSearchCommand)({
|
|
666
|
+
root,
|
|
667
|
+
query,
|
|
668
|
+
tags,
|
|
669
|
+
tagsMode,
|
|
670
|
+
json,
|
|
671
|
+
noCache,
|
|
672
|
+
noReindex,
|
|
673
|
+
});
|
|
674
|
+
return 0;
|
|
675
|
+
}
|
|
676
|
+
case "validate": {
|
|
677
|
+
if (parsed.positionals.length > 3) {
|
|
678
|
+
throw new errors_1.UsageError("skill validate accepts at most one slug");
|
|
679
|
+
}
|
|
680
|
+
const slug = parsed.positionals[2];
|
|
681
|
+
(0, skill_1.runSkillValidateCommand)({ root, slug });
|
|
682
|
+
return 0;
|
|
683
|
+
}
|
|
684
|
+
case "sync": {
|
|
685
|
+
if (parsed.positionals.length > 2) {
|
|
686
|
+
throw new errors_1.UsageError("skill sync does not accept positional arguments");
|
|
687
|
+
}
|
|
688
|
+
const force = parseBooleanFlag("--force", parsed.flags["--force"]);
|
|
689
|
+
(0, skill_1.runSkillSyncCommand)({ root, force });
|
|
690
|
+
return 0;
|
|
691
|
+
}
|
|
692
|
+
default:
|
|
693
|
+
throw new errors_1.UsageError("skill requires new/list/show/search/validate/sync");
|
|
396
694
|
}
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
695
|
+
}
|
|
696
|
+
function runTaskSubcommand(parsed, root) {
|
|
697
|
+
const subcommand = (parsed.positionals[1] ?? "").toLowerCase();
|
|
698
|
+
switch (subcommand) {
|
|
699
|
+
case "start": {
|
|
700
|
+
const id = parsed.positionals[2];
|
|
701
|
+
if (!id || parsed.positionals.length > 3) {
|
|
702
|
+
throw new errors_1.UsageError("task start requires <id-or-qid>");
|
|
703
|
+
}
|
|
704
|
+
const ws = requireFlagValue("--ws", parsed.flags["--ws"]);
|
|
705
|
+
const runId = requireFlagValue("--run-id", parsed.flags["--run-id"]);
|
|
706
|
+
const note = requireFlagValue("--note", parsed.flags["--note"]);
|
|
707
|
+
(0, task_1.runTaskStartCommand)({ root, id, ws, runId, note });
|
|
708
|
+
return 0;
|
|
709
|
+
}
|
|
710
|
+
case "update": {
|
|
711
|
+
const id = parsed.positionals[2];
|
|
712
|
+
if (!id || parsed.positionals.length > 3) {
|
|
713
|
+
throw new errors_1.UsageError("task update requires <id-or-qid>");
|
|
714
|
+
}
|
|
715
|
+
const ws = requireFlagValue("--ws", parsed.flags["--ws"]);
|
|
716
|
+
const status = requireFlagValue("--status", parsed.flags["--status"]);
|
|
717
|
+
const priority = parseNumberFlag("--priority", parsed.flags["--priority"]);
|
|
718
|
+
const addArtifacts = requireFlagValue("--add-artifacts", parsed.flags["--add-artifacts"]);
|
|
719
|
+
const addLinks = requireFlagValue("--add-links", parsed.flags["--add-links"]);
|
|
720
|
+
const addRefs = requireFlagValue("--add-refs", parsed.flags["--add-refs"]);
|
|
721
|
+
const addSkills = requireFlagValue("--add-skills", parsed.flags["--add-skills"]);
|
|
722
|
+
const addTags = requireFlagValue("--add-tags", parsed.flags["--add-tags"]);
|
|
723
|
+
const addBlockedBy = requireFlagValue("--add-blocked-by", parsed.flags["--add-blocked-by"]);
|
|
724
|
+
const clearBlockedBy = parseBooleanFlag("--clear-blocked-by", parsed.flags["--clear-blocked-by"]);
|
|
725
|
+
const runId = requireFlagValue("--run-id", parsed.flags["--run-id"]);
|
|
726
|
+
const note = requireFlagValue("--note", parsed.flags["--note"]);
|
|
727
|
+
(0, task_1.runTaskUpdateCommand)({
|
|
728
|
+
root,
|
|
729
|
+
id,
|
|
730
|
+
ws,
|
|
731
|
+
status,
|
|
732
|
+
priority,
|
|
733
|
+
addArtifacts,
|
|
734
|
+
addLinks,
|
|
735
|
+
addRefs,
|
|
736
|
+
addSkills,
|
|
737
|
+
addTags,
|
|
738
|
+
addBlockedBy,
|
|
739
|
+
clearBlockedBy,
|
|
740
|
+
runId,
|
|
741
|
+
note,
|
|
742
|
+
});
|
|
743
|
+
return 0;
|
|
744
|
+
}
|
|
745
|
+
case "done": {
|
|
746
|
+
const id = parsed.positionals[2];
|
|
747
|
+
if (!id || parsed.positionals.length > 3) {
|
|
748
|
+
throw new errors_1.UsageError("task done requires <id-or-qid>");
|
|
749
|
+
}
|
|
750
|
+
const ws = requireFlagValue("--ws", parsed.flags["--ws"]);
|
|
751
|
+
const addArtifacts = requireFlagValue("--add-artifacts", parsed.flags["--add-artifacts"]);
|
|
752
|
+
const addLinks = requireFlagValue("--add-links", parsed.flags["--add-links"]);
|
|
753
|
+
const addRefs = requireFlagValue("--add-refs", parsed.flags["--add-refs"]);
|
|
754
|
+
const checkpoint = requireFlagValue("--checkpoint", parsed.flags["--checkpoint"]);
|
|
755
|
+
const runId = requireFlagValue("--run-id", parsed.flags["--run-id"]);
|
|
756
|
+
const note = requireFlagValue("--note", parsed.flags["--note"]);
|
|
757
|
+
(0, task_1.runTaskDoneCommand)({
|
|
758
|
+
root,
|
|
759
|
+
id,
|
|
760
|
+
ws,
|
|
761
|
+
addArtifacts,
|
|
762
|
+
addLinks,
|
|
763
|
+
addRefs,
|
|
764
|
+
checkpoint,
|
|
765
|
+
runId,
|
|
766
|
+
note,
|
|
767
|
+
});
|
|
768
|
+
return 0;
|
|
406
769
|
}
|
|
770
|
+
default:
|
|
771
|
+
throw new errors_1.UsageError("task requires start/update/done");
|
|
407
772
|
}
|
|
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);
|
|
773
|
+
}
|
|
774
|
+
function runEventSubcommand(parsed, root) {
|
|
775
|
+
const subcommand = (parsed.positionals[1] ?? "").toLowerCase();
|
|
776
|
+
switch (subcommand) {
|
|
777
|
+
case "enable": {
|
|
778
|
+
if (parsed.positionals.length > 2) {
|
|
779
|
+
throw new errors_1.UsageError("event enable does not accept positional arguments");
|
|
434
780
|
}
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
781
|
+
const ws = requireFlagValue("--ws", parsed.flags["--ws"]);
|
|
782
|
+
const noUpdateGitignore = parseBooleanFlag("--no-update-gitignore", parsed.flags["--no-update-gitignore"]);
|
|
783
|
+
(0, event_1.runEventEnableCommand)({ root, ws, updateGitignore: !noUpdateGitignore });
|
|
784
|
+
return 0;
|
|
785
|
+
}
|
|
786
|
+
case "append": {
|
|
787
|
+
if (parsed.positionals.length > 2) {
|
|
788
|
+
throw new errors_1.UsageError("event append does not accept positional arguments");
|
|
443
789
|
}
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
catch (err) {
|
|
450
|
-
handleCommandError(err);
|
|
451
|
-
}
|
|
452
|
-
process.exit(0);
|
|
790
|
+
const kind = requireFlagValue("--kind", parsed.flags["--kind"]);
|
|
791
|
+
const status = requireFlagValue("--status", parsed.flags["--status"]);
|
|
792
|
+
const refs = requireFlagValue("--refs", parsed.flags["--refs"]);
|
|
793
|
+
if (!kind || !status || !refs) {
|
|
794
|
+
throw new errors_1.UsageError("event append requires --kind, --status, and --refs");
|
|
453
795
|
}
|
|
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
|
-
parent,
|
|
491
|
-
prev,
|
|
492
|
-
next,
|
|
493
|
-
relates,
|
|
494
|
-
blockedBy,
|
|
495
|
-
blocks,
|
|
496
|
-
links,
|
|
497
|
-
artifacts,
|
|
498
|
-
refs,
|
|
499
|
-
aliases,
|
|
500
|
-
cases,
|
|
501
|
-
tags,
|
|
502
|
-
owners,
|
|
503
|
-
supersedes,
|
|
504
|
-
template,
|
|
505
|
-
noCache,
|
|
506
|
-
noReindex,
|
|
507
|
-
});
|
|
508
|
-
}
|
|
509
|
-
catch (err) {
|
|
510
|
-
handleCommandError(err);
|
|
511
|
-
}
|
|
512
|
-
process.exit(0);
|
|
796
|
+
const ws = requireFlagValue("--ws", parsed.flags["--ws"]);
|
|
797
|
+
const artifacts = requireFlagValue("--artifacts", parsed.flags["--artifacts"]);
|
|
798
|
+
const notes = requireFlagValue("--notes", parsed.flags["--notes"]);
|
|
799
|
+
const runId = requireFlagValue("--run-id", parsed.flags["--run-id"]);
|
|
800
|
+
const agent = requireFlagValue("--agent", parsed.flags["--agent"]);
|
|
801
|
+
const skill = requireFlagValue("--skill", parsed.flags["--skill"]);
|
|
802
|
+
const tool = requireFlagValue("--tool", parsed.flags["--tool"]);
|
|
803
|
+
(0, event_1.runEventAppendCommand)({
|
|
804
|
+
root,
|
|
805
|
+
ws,
|
|
806
|
+
kind,
|
|
807
|
+
status,
|
|
808
|
+
refs,
|
|
809
|
+
artifacts,
|
|
810
|
+
notes,
|
|
811
|
+
runId,
|
|
812
|
+
agent,
|
|
813
|
+
skill,
|
|
814
|
+
tool,
|
|
815
|
+
});
|
|
816
|
+
return 0;
|
|
817
|
+
}
|
|
818
|
+
default:
|
|
819
|
+
throw new errors_1.UsageError("event requires enable/append");
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
function runCommand(parsed, root, runtime) {
|
|
823
|
+
const command = (parsed.positionals[0] ?? "").toLowerCase();
|
|
824
|
+
switch (command) {
|
|
825
|
+
case "init": {
|
|
826
|
+
const force = parseBooleanFlag("--force", parsed.flags["--force"]);
|
|
827
|
+
const createAgents = parseBooleanFlag("--agents", parsed.flags["--agents"]);
|
|
828
|
+
const createClaude = parseBooleanFlag("--claude", parsed.flags["--claude"]);
|
|
829
|
+
const createLlm = parseBooleanFlag("--llm", parsed.flags["--llm"]);
|
|
830
|
+
if (parsed.flags["--omni"]) {
|
|
831
|
+
throw new errors_1.UsageError("`mdkg init --omni` was removed; use `mdkg init --agent`");
|
|
513
832
|
}
|
|
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
|
-
if (!alias || parsed.positionals.length > 3) {
|
|
547
|
-
handleCommandError(new errors_1.UsageError("workspace rm requires <alias>"));
|
|
548
|
-
}
|
|
549
|
-
try {
|
|
550
|
-
(0, workspace_1.runWorkspaceRemoveCommand)({ root, alias });
|
|
551
|
-
}
|
|
552
|
-
catch (err) {
|
|
553
|
-
handleCommandError(err);
|
|
554
|
-
}
|
|
555
|
-
process.exit(0);
|
|
556
|
-
}
|
|
557
|
-
default: {
|
|
558
|
-
handleCommandError(new errors_1.UsageError("workspace requires ls/add/rm"));
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
process.exit(0);
|
|
833
|
+
const agent = parseBooleanFlag("--agent", parsed.flags["--agent"]);
|
|
834
|
+
const noUpdateIgnores = parseBooleanFlag("--no-update-ignores", parsed.flags["--no-update-ignores"]);
|
|
835
|
+
const updateGitignore = parseBooleanFlag("--update-gitignore", parsed.flags["--update-gitignore"]);
|
|
836
|
+
const updateNpmignore = parseBooleanFlag("--update-npmignore", parsed.flags["--update-npmignore"]);
|
|
837
|
+
const updateDockerignore = parseBooleanFlag("--update-dockerignore", parsed.flags["--update-dockerignore"]);
|
|
838
|
+
(0, init_1.runInitCommand)({
|
|
839
|
+
root,
|
|
840
|
+
force,
|
|
841
|
+
updateGitignore,
|
|
842
|
+
updateNpmignore,
|
|
843
|
+
updateDockerignore,
|
|
844
|
+
noUpdateIgnores,
|
|
845
|
+
createAgents,
|
|
846
|
+
createClaude,
|
|
847
|
+
createLlm,
|
|
848
|
+
agent,
|
|
849
|
+
});
|
|
850
|
+
return 0;
|
|
851
|
+
}
|
|
852
|
+
case "guide":
|
|
853
|
+
(0, guide_1.runGuideCommand)({ root });
|
|
854
|
+
return 0;
|
|
855
|
+
case "index": {
|
|
856
|
+
const tolerant = Boolean(parsed.flags["--tolerant"]);
|
|
857
|
+
(0, index_1.runIndexCommand)({ root, tolerant });
|
|
858
|
+
return 0;
|
|
859
|
+
}
|
|
860
|
+
case "new": {
|
|
861
|
+
const type = parsed.positionals[1];
|
|
862
|
+
const title = parsed.positionals.slice(2).join(" ");
|
|
863
|
+
if (!type || !title) {
|
|
864
|
+
throw new errors_1.UsageError("new requires a type and title");
|
|
562
865
|
}
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
866
|
+
const ws = requireFlagValue("--ws", parsed.flags["--ws"]);
|
|
867
|
+
const status = requireFlagValue("--status", parsed.flags["--status"]);
|
|
868
|
+
const priority = parseNumberFlag("--priority", parsed.flags["--priority"]);
|
|
869
|
+
const epic = requireFlagValue("--epic", parsed.flags["--epic"]);
|
|
870
|
+
const parent = requireFlagValue("--parent", parsed.flags["--parent"]);
|
|
871
|
+
const prev = requireFlagValue("--prev", parsed.flags["--prev"]);
|
|
872
|
+
const next = requireFlagValue("--next", parsed.flags["--next"]);
|
|
873
|
+
const relates = requireFlagValue("--relates", parsed.flags["--relates"]);
|
|
874
|
+
const blockedBy = requireFlagValue("--blocked-by", parsed.flags["--blocked-by"]);
|
|
875
|
+
const blocks = requireFlagValue("--blocks", parsed.flags["--blocks"]);
|
|
876
|
+
const links = requireFlagValue("--links", parsed.flags["--links"]);
|
|
877
|
+
const artifacts = requireFlagValue("--artifacts", parsed.flags["--artifacts"]);
|
|
878
|
+
const refs = requireFlagValue("--refs", parsed.flags["--refs"]);
|
|
879
|
+
const aliases = requireFlagValue("--aliases", parsed.flags["--aliases"]);
|
|
880
|
+
const skills = requireFlagValue("--skills", parsed.flags["--skills"]);
|
|
881
|
+
const cases = requireFlagValue("--cases", parsed.flags["--cases"]);
|
|
882
|
+
const tags = requireFlagValue("--tags", parsed.flags["--tags"]);
|
|
883
|
+
const owners = requireFlagValue("--owners", parsed.flags["--owners"]);
|
|
884
|
+
const supersedes = requireFlagValue("--supersedes", parsed.flags["--supersedes"]);
|
|
885
|
+
const template = requireFlagValue("--template", parsed.flags["--template"]);
|
|
886
|
+
const noCache = parseBooleanFlag("--no-cache", parsed.flags["--no-cache"]);
|
|
887
|
+
const noReindex = parseBooleanFlag("--no-reindex", parsed.flags["--no-reindex"]);
|
|
888
|
+
const runId = requireFlagValue("--run-id", parsed.flags["--run-id"]);
|
|
889
|
+
(0, new_1.runNewCommand)({
|
|
890
|
+
root,
|
|
891
|
+
type,
|
|
892
|
+
title,
|
|
893
|
+
ws,
|
|
894
|
+
status,
|
|
895
|
+
priority,
|
|
896
|
+
epic,
|
|
897
|
+
parent,
|
|
898
|
+
prev,
|
|
899
|
+
next,
|
|
900
|
+
relates,
|
|
901
|
+
blockedBy,
|
|
902
|
+
blocks,
|
|
903
|
+
links,
|
|
904
|
+
artifacts,
|
|
905
|
+
refs,
|
|
906
|
+
aliases,
|
|
907
|
+
skills,
|
|
908
|
+
cases,
|
|
909
|
+
tags,
|
|
910
|
+
owners,
|
|
911
|
+
supersedes,
|
|
912
|
+
template,
|
|
913
|
+
noCache,
|
|
914
|
+
noReindex,
|
|
915
|
+
runId,
|
|
916
|
+
});
|
|
917
|
+
return 0;
|
|
918
|
+
}
|
|
919
|
+
case "workspace":
|
|
920
|
+
return runWorkspaceSubcommand(parsed, root);
|
|
921
|
+
case "skill":
|
|
922
|
+
return runSkillSubcommand(parsed, root);
|
|
923
|
+
case "task":
|
|
924
|
+
return runTaskSubcommand(parsed, root);
|
|
925
|
+
case "event":
|
|
926
|
+
return runEventSubcommand(parsed, root);
|
|
927
|
+
case "show": {
|
|
928
|
+
const id = parsed.positionals[1];
|
|
929
|
+
if (!id || parsed.positionals.length > 2) {
|
|
930
|
+
throw new errors_1.UsageError("show requires a single id");
|
|
931
|
+
}
|
|
932
|
+
const ws = requireFlagValue("--ws", parsed.flags["--ws"]);
|
|
933
|
+
const metaOnly = parseBooleanFlag("--meta", parsed.flags["--meta"]);
|
|
934
|
+
const json = parseBooleanFlag("--json", parsed.flags["--json"]);
|
|
935
|
+
const noCache = parseBooleanFlag("--no-cache", parsed.flags["--no-cache"]);
|
|
936
|
+
const noReindex = parseBooleanFlag("--no-reindex", parsed.flags["--no-reindex"]);
|
|
937
|
+
(0, show_1.runShowCommand)({
|
|
938
|
+
root,
|
|
939
|
+
id,
|
|
940
|
+
ws,
|
|
941
|
+
metaOnly,
|
|
942
|
+
json,
|
|
943
|
+
noCache,
|
|
944
|
+
noReindex,
|
|
945
|
+
});
|
|
946
|
+
return 0;
|
|
947
|
+
}
|
|
948
|
+
case "list": {
|
|
949
|
+
if (parsed.positionals.length > 1) {
|
|
950
|
+
throw new errors_1.UsageError("list does not accept positional arguments");
|
|
951
|
+
}
|
|
952
|
+
const ws = requireFlagValue("--ws", parsed.flags["--ws"]);
|
|
953
|
+
const type = requireFlagValue("--type", parsed.flags["--type"]);
|
|
954
|
+
const status = requireFlagValue("--status", parsed.flags["--status"]);
|
|
955
|
+
const epic = requireFlagValue("--epic", parsed.flags["--epic"]);
|
|
956
|
+
const priority = parseNumberFlag("--priority", parsed.flags["--priority"]);
|
|
957
|
+
const blocked = parseBooleanFlag("--blocked", parsed.flags["--blocked"]);
|
|
958
|
+
const tags = parseCsvFlag("--tags", parsed.flags["--tags"]);
|
|
959
|
+
const tagsMode = parseTagsModeFlag(parsed.flags["--tags-mode"]);
|
|
960
|
+
const json = parseBooleanFlag("--json", parsed.flags["--json"]);
|
|
961
|
+
const noCache = parseBooleanFlag("--no-cache", parsed.flags["--no-cache"]);
|
|
962
|
+
const noReindex = parseBooleanFlag("--no-reindex", parsed.flags["--no-reindex"]);
|
|
963
|
+
(0, list_1.runListCommand)({
|
|
964
|
+
root,
|
|
965
|
+
ws,
|
|
966
|
+
type,
|
|
967
|
+
status,
|
|
968
|
+
epic,
|
|
969
|
+
priority,
|
|
970
|
+
blocked,
|
|
971
|
+
tags,
|
|
972
|
+
tagsMode,
|
|
973
|
+
json,
|
|
974
|
+
noCache,
|
|
975
|
+
noReindex,
|
|
976
|
+
});
|
|
977
|
+
return 0;
|
|
978
|
+
}
|
|
979
|
+
case "search": {
|
|
980
|
+
if (parsed.positionals.length < 2) {
|
|
981
|
+
throw new errors_1.UsageError("search requires a query");
|
|
586
982
|
}
|
|
587
|
-
|
|
983
|
+
const query = parsed.positionals.slice(1).join(" ");
|
|
984
|
+
const ws = requireFlagValue("--ws", parsed.flags["--ws"]);
|
|
985
|
+
const type = requireFlagValue("--type", parsed.flags["--type"]);
|
|
986
|
+
const status = requireFlagValue("--status", parsed.flags["--status"]);
|
|
987
|
+
const tags = parseCsvFlag("--tags", parsed.flags["--tags"]);
|
|
988
|
+
const tagsMode = parseTagsModeFlag(parsed.flags["--tags-mode"]);
|
|
989
|
+
const json = parseBooleanFlag("--json", parsed.flags["--json"]);
|
|
990
|
+
const noCache = parseBooleanFlag("--no-cache", parsed.flags["--no-cache"]);
|
|
991
|
+
const noReindex = parseBooleanFlag("--no-reindex", parsed.flags["--no-reindex"]);
|
|
992
|
+
(0, search_1.runSearchCommand)({
|
|
993
|
+
root,
|
|
994
|
+
query,
|
|
995
|
+
ws,
|
|
996
|
+
type,
|
|
997
|
+
status,
|
|
998
|
+
tags,
|
|
999
|
+
tagsMode,
|
|
1000
|
+
json,
|
|
1001
|
+
noCache,
|
|
1002
|
+
noReindex,
|
|
1003
|
+
});
|
|
1004
|
+
return 0;
|
|
1005
|
+
}
|
|
1006
|
+
case "pack": {
|
|
1007
|
+
const listProfiles = parseBooleanFlag("--list-profiles", parsed.flags["--list-profiles"]);
|
|
1008
|
+
if (listProfiles) {
|
|
588
1009
|
if (parsed.positionals.length > 1) {
|
|
589
|
-
|
|
590
|
-
}
|
|
591
|
-
const ws = requireFlagValue("--ws", parsed.flags["--ws"]);
|
|
592
|
-
const type = requireFlagValue("--type", parsed.flags["--type"]);
|
|
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);
|
|
1010
|
+
throw new errors_1.UsageError("pack --list-profiles does not accept positional arguments");
|
|
614
1011
|
}
|
|
615
|
-
|
|
1012
|
+
printPackProfiles(runtime.log);
|
|
1013
|
+
return 0;
|
|
616
1014
|
}
|
|
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);
|
|
1015
|
+
const id = parsed.positionals[1];
|
|
1016
|
+
if (!id || parsed.positionals.length > 2) {
|
|
1017
|
+
throw new errors_1.UsageError("pack requires a single id");
|
|
642
1018
|
}
|
|
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);
|
|
1019
|
+
const ws = requireFlagValue("--ws", parsed.flags["--ws"]);
|
|
1020
|
+
const depth = parseNumberFlag("--depth", parsed.flags["--depth"]);
|
|
1021
|
+
const edges = parseEdgesFlag(parsed.flags["--edges"]);
|
|
1022
|
+
const verbose = parseBooleanFlag("--verbose", parsed.flags["--verbose"]);
|
|
1023
|
+
const concise = parseBooleanFlag("--concise", parsed.flags["--concise"]);
|
|
1024
|
+
const stripCode = parseBooleanFlag("--strip-code", parsed.flags["--strip-code"]);
|
|
1025
|
+
const format = requireFlagValue("--format", parsed.flags["--format"]);
|
|
1026
|
+
const packProfile = requireFlagValue("--pack-profile", parsed.flags["--pack-profile"]);
|
|
1027
|
+
const maxCodeLines = parseNumberFlag("--max-code-lines", parsed.flags["--max-code-lines"]);
|
|
1028
|
+
const maxChars = parseNumberFlag("--max-chars", parsed.flags["--max-chars"]);
|
|
1029
|
+
const maxLines = parseNumberFlag("--max-lines", parsed.flags["--max-lines"]);
|
|
1030
|
+
const maxTokens = parseNumberFlag("--max-tokens", parsed.flags["--max-tokens"]);
|
|
1031
|
+
const skills = requireFlagValue("--skills", parsed.flags["--skills"]);
|
|
1032
|
+
const skillsDepth = requireFlagValue("--skills-depth", parsed.flags["--skills-depth"]);
|
|
1033
|
+
const dryRun = parseBooleanFlag("--dry-run", parsed.flags["--dry-run"]);
|
|
1034
|
+
const stats = parseBooleanFlag("--stats", parsed.flags["--stats"]);
|
|
1035
|
+
const statsOut = requireFlagValue("--stats-out", parsed.flags["--stats-out"]);
|
|
1036
|
+
const truncationReport = requireFlagValue("--truncation-report", parsed.flags["--truncation-report"]);
|
|
1037
|
+
const out = requireFlagValue("--out", parsed.flags["--out"]);
|
|
1038
|
+
const noCache = parseBooleanFlag("--no-cache", parsed.flags["--no-cache"]);
|
|
1039
|
+
const noReindex = parseBooleanFlag("--no-reindex", parsed.flags["--no-reindex"]);
|
|
1040
|
+
(0, pack_1.runPackCommand)({
|
|
1041
|
+
root,
|
|
1042
|
+
id,
|
|
1043
|
+
ws,
|
|
1044
|
+
depth,
|
|
1045
|
+
edges,
|
|
1046
|
+
verbose,
|
|
1047
|
+
concise,
|
|
1048
|
+
stripCode,
|
|
1049
|
+
format,
|
|
1050
|
+
packProfile,
|
|
1051
|
+
maxCodeLines,
|
|
1052
|
+
maxChars,
|
|
1053
|
+
maxLines,
|
|
1054
|
+
maxTokens,
|
|
1055
|
+
skills,
|
|
1056
|
+
skillsDepth,
|
|
1057
|
+
dryRun,
|
|
1058
|
+
stats,
|
|
1059
|
+
statsOut,
|
|
1060
|
+
truncationReport,
|
|
1061
|
+
out,
|
|
1062
|
+
noCache,
|
|
1063
|
+
noReindex,
|
|
1064
|
+
});
|
|
1065
|
+
return 0;
|
|
1066
|
+
}
|
|
1067
|
+
case "next": {
|
|
1068
|
+
if (parsed.positionals.length > 2) {
|
|
1069
|
+
throw new errors_1.UsageError("next accepts at most one id");
|
|
704
1070
|
}
|
|
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);
|
|
1071
|
+
const id = parsed.positionals[1];
|
|
1072
|
+
const ws = requireFlagValue("--ws", parsed.flags["--ws"]);
|
|
1073
|
+
const noCache = parseBooleanFlag("--no-cache", parsed.flags["--no-cache"]);
|
|
1074
|
+
const noReindex = parseBooleanFlag("--no-reindex", parsed.flags["--no-reindex"]);
|
|
1075
|
+
(0, next_1.runNextCommand)({
|
|
1076
|
+
root,
|
|
1077
|
+
id,
|
|
1078
|
+
ws,
|
|
1079
|
+
noCache,
|
|
1080
|
+
noReindex,
|
|
1081
|
+
});
|
|
1082
|
+
return 0;
|
|
1083
|
+
}
|
|
1084
|
+
case "checkpoint": {
|
|
1085
|
+
const sub = (parsed.positionals[1] ?? "").toLowerCase();
|
|
1086
|
+
if (!sub) {
|
|
1087
|
+
throw new errors_1.UsageError("checkpoint requires a subcommand");
|
|
726
1088
|
}
|
|
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);
|
|
1089
|
+
if (sub !== "new") {
|
|
1090
|
+
throw new errors_1.UsageError(`unknown checkpoint subcommand: ${sub}`);
|
|
758
1091
|
}
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
1092
|
+
const title = parsed.positionals.slice(2).join(" ");
|
|
1093
|
+
const ws = requireFlagValue("--ws", parsed.flags["--ws"]);
|
|
1094
|
+
const relates = requireFlagValue("--relates", parsed.flags["--relates"]);
|
|
1095
|
+
const scope = requireFlagValue("--scope", parsed.flags["--scope"]);
|
|
1096
|
+
const status = requireFlagValue("--status", parsed.flags["--status"]);
|
|
1097
|
+
const priority = parseNumberFlag("--priority", parsed.flags["--priority"]);
|
|
1098
|
+
const template = requireFlagValue("--template", parsed.flags["--template"]);
|
|
1099
|
+
const runId = requireFlagValue("--run-id", parsed.flags["--run-id"]);
|
|
1100
|
+
const note = requireFlagValue("--note", parsed.flags["--note"]);
|
|
1101
|
+
(0, checkpoint_1.runCheckpointNewCommand)({
|
|
1102
|
+
root,
|
|
1103
|
+
title,
|
|
1104
|
+
ws,
|
|
1105
|
+
relates,
|
|
1106
|
+
scope,
|
|
1107
|
+
status,
|
|
1108
|
+
priority,
|
|
1109
|
+
template,
|
|
1110
|
+
runId,
|
|
1111
|
+
note,
|
|
1112
|
+
});
|
|
1113
|
+
return 0;
|
|
1114
|
+
}
|
|
1115
|
+
case "validate": {
|
|
1116
|
+
if (parsed.positionals.length > 1) {
|
|
1117
|
+
throw new errors_1.UsageError("validate does not accept positional arguments");
|
|
772
1118
|
}
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
handleCommandError(err);
|
|
782
|
-
}
|
|
783
|
-
process.exit(0);
|
|
1119
|
+
const out = requireFlagValue("--out", parsed.flags["--out"]);
|
|
1120
|
+
const quiet = parseBooleanFlag("--quiet", parsed.flags["--quiet"]);
|
|
1121
|
+
(0, validate_1.runValidateCommand)({ root, out, quiet });
|
|
1122
|
+
return 0;
|
|
1123
|
+
}
|
|
1124
|
+
case "format":
|
|
1125
|
+
if (parsed.positionals.length > 1) {
|
|
1126
|
+
throw new errors_1.UsageError("format does not accept positional arguments");
|
|
784
1127
|
}
|
|
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);
|
|
1128
|
+
(0, format_1.runFormatCommand)({ root });
|
|
1129
|
+
return 0;
|
|
1130
|
+
case "doctor": {
|
|
1131
|
+
if (parsed.positionals.length > 1) {
|
|
1132
|
+
throw new errors_1.UsageError("doctor does not accept positional arguments");
|
|
799
1133
|
}
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
1134
|
+
const noCache = parseBooleanFlag("--no-cache", parsed.flags["--no-cache"]);
|
|
1135
|
+
const noReindex = parseBooleanFlag("--no-reindex", parsed.flags["--no-reindex"]);
|
|
1136
|
+
const json = parseBooleanFlag("--json", parsed.flags["--json"]);
|
|
1137
|
+
(0, doctor_1.runDoctorCommand)({ root, noCache, noReindex, json });
|
|
1138
|
+
return 0;
|
|
804
1139
|
}
|
|
1140
|
+
default:
|
|
1141
|
+
runtime.error(`Unknown command: ${command}`);
|
|
1142
|
+
printUsage(runtime.log);
|
|
1143
|
+
return 1;
|
|
1144
|
+
}
|
|
1145
|
+
}
|
|
1146
|
+
function runCli(argv, runtime = {}) {
|
|
1147
|
+
const io = resolveRuntime(runtime);
|
|
1148
|
+
const parsed = (0, argparse_1.parseArgs)(argv);
|
|
1149
|
+
if (parsed.error) {
|
|
1150
|
+
io.error(parsed.error);
|
|
1151
|
+
printUsage(io.log);
|
|
1152
|
+
return 1;
|
|
1153
|
+
}
|
|
1154
|
+
if (parsed.help) {
|
|
1155
|
+
printCommandHelp(io.log, parsed.positionals[0], parsed.positionals[1]);
|
|
1156
|
+
return 0;
|
|
1157
|
+
}
|
|
1158
|
+
if (parsed.version) {
|
|
1159
|
+
io.log(readPackageVersion());
|
|
1160
|
+
return 0;
|
|
1161
|
+
}
|
|
1162
|
+
const command = (parsed.positionals[0] ?? "").toLowerCase();
|
|
1163
|
+
if (!command) {
|
|
1164
|
+
printUsage(io.log);
|
|
1165
|
+
return 0;
|
|
1166
|
+
}
|
|
1167
|
+
if (command === "help") {
|
|
1168
|
+
printCommandHelp(io.log, parsed.positionals[1], parsed.positionals[2]);
|
|
1169
|
+
return 0;
|
|
1170
|
+
}
|
|
1171
|
+
const root = parsed.root ? path_1.default.resolve(parsed.root) : io.cwd();
|
|
1172
|
+
if (shouldRequireConfig(command, parsed.flags) && !hasConfig(root)) {
|
|
1173
|
+
printRootError(io.error, root);
|
|
1174
|
+
return 1;
|
|
1175
|
+
}
|
|
1176
|
+
try {
|
|
1177
|
+
return runCommand(parsed, root, io);
|
|
805
1178
|
}
|
|
806
1179
|
catch (err) {
|
|
807
|
-
handleCommandError(err);
|
|
1180
|
+
return handleCommandError(err, command, io);
|
|
808
1181
|
}
|
|
809
1182
|
}
|
|
810
|
-
main()
|
|
1183
|
+
function main(argv = process.argv.slice(2)) {
|
|
1184
|
+
process.exit(runCli(argv, { cwd: () => process.cwd() }));
|
|
1185
|
+
}
|
|
1186
|
+
if (require.main === module) {
|
|
1187
|
+
main();
|
|
1188
|
+
}
|