mdkg 0.0.8 → 0.1.0
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/CHANGELOG.md +71 -0
- package/CONTRIBUTING.md +124 -0
- package/README.md +49 -14
- package/dist/cli.js +113 -32
- package/dist/commands/checkpoint.js +19 -2
- package/dist/commands/event.js +12 -0
- package/dist/commands/init.js +4 -0
- package/dist/commands/init_manifest.js +131 -0
- package/dist/commands/new.js +57 -21
- package/dist/commands/pack.js +14 -0
- package/dist/commands/query_output.js +2 -0
- package/dist/commands/search.js +8 -0
- package/dist/commands/show.js +7 -0
- package/dist/commands/skill.js +80 -12
- package/dist/commands/task.js +42 -12
- package/dist/commands/upgrade.js +286 -0
- package/dist/commands/validate.js +31 -3
- package/dist/commands/workspace.js +105 -13
- package/dist/core/config.js +217 -22
- package/dist/core/migrate.js +39 -5
- package/dist/core/version.js +31 -0
- package/dist/core/workspace_path.js +41 -0
- package/dist/graph/agent_file_types.js +392 -0
- package/dist/graph/edges.js +13 -10
- package/dist/graph/frontmatter.js +33 -0
- package/dist/graph/indexer.js +1 -0
- package/dist/graph/node.js +43 -16
- package/dist/graph/skills_indexer.js +14 -1
- package/dist/graph/template_schema.js +13 -126
- package/dist/graph/validate_graph.js +302 -2
- package/dist/init/AGENT_START.md +14 -2
- package/dist/init/CLI_COMMAND_MATRIX.md +49 -1
- package/dist/init/README.md +14 -0
- package/dist/init/core/rule-6-templates-and-schemas.md +1 -3
- package/dist/init/init-manifest.json +197 -0
- package/dist/init/legacy/v0.0.9-init-manifest.json +197 -0
- package/dist/init/skills/default/verify-close-and-checkpoint/SKILL.md +12 -11
- package/dist/init/templates/default/dispute.md +31 -0
- package/dist/init/templates/default/feedback.md +27 -0
- package/dist/init/templates/default/proposal.md +35 -0
- package/dist/init/templates/default/receipt.md +31 -0
- package/dist/init/templates/default/spec.md +43 -0
- package/dist/init/templates/default/work.md +44 -0
- package/dist/init/templates/default/work_order.md +32 -0
- package/dist/pack/export_json.js +3 -0
- package/dist/pack/export_md.js +9 -0
- package/dist/pack/export_xml.js +9 -0
- package/dist/pack/order.js +7 -0
- package/dist/pack/pack.js +1 -0
- package/dist/templates/loader.js +2 -2
- package/dist/util/argparse.js +2 -0
- package/dist/util/id.js +19 -0
- package/package.json +10 -2
- package/scripts/postinstall.js +89 -0
package/dist/cli.js
CHANGED
|
@@ -22,6 +22,7 @@ const checkpoint_1 = require("./commands/checkpoint");
|
|
|
22
22
|
const init_1 = require("./commands/init");
|
|
23
23
|
const new_1 = require("./commands/new");
|
|
24
24
|
const guide_1 = require("./commands/guide");
|
|
25
|
+
const upgrade_1 = require("./commands/upgrade");
|
|
25
26
|
const event_1 = require("./commands/event");
|
|
26
27
|
const skill_1 = require("./commands/skill");
|
|
27
28
|
const task_1 = require("./commands/task");
|
|
@@ -47,6 +48,7 @@ function printUsage(log) {
|
|
|
47
48
|
log(" mdkg <command> [options]");
|
|
48
49
|
log("\nPrimary commands:");
|
|
49
50
|
log(" init Initialize .mdkg scaffolding");
|
|
51
|
+
log(" upgrade Conservatively upgrade mdkg scaffolding");
|
|
50
52
|
log(" new Create a node from templates");
|
|
51
53
|
log(" show Show a node by id or qid");
|
|
52
54
|
log(" list List nodes with filters");
|
|
@@ -63,9 +65,11 @@ function printUsage(log) {
|
|
|
63
65
|
log(" guide Show the mdkg guide");
|
|
64
66
|
log(" format Normalize frontmatter");
|
|
65
67
|
log(" doctor Run install and workspace diagnostics");
|
|
66
|
-
log(" workspace Manage workspaces (ls/add/rm)");
|
|
68
|
+
log(" workspace Manage workspaces (ls/add/rm/enable/disable)");
|
|
67
69
|
log("\nQuickstart:");
|
|
68
70
|
log(" mdkg init --llm");
|
|
71
|
+
log(" mdkg upgrade");
|
|
72
|
+
log(" mdkg upgrade --apply");
|
|
69
73
|
log(' mdkg new task "..." --status todo --priority 1');
|
|
70
74
|
log(' mdkg search "..."');
|
|
71
75
|
log(" mdkg show <id>");
|
|
@@ -95,12 +99,29 @@ function printInitHelp(log) {
|
|
|
95
99
|
log("\nCompatibility flags still supported but not shown in the primary onboarding story.");
|
|
96
100
|
printGlobalOptions(log);
|
|
97
101
|
}
|
|
102
|
+
function printUpgradeHelp(log) {
|
|
103
|
+
log("Usage:");
|
|
104
|
+
log(" mdkg upgrade [--dry-run] [--apply] [--json]");
|
|
105
|
+
log("\nOptions:");
|
|
106
|
+
log(" --dry-run Preview upgrade changes without writing files (default)");
|
|
107
|
+
log(" --apply Apply safe managed init asset upgrades");
|
|
108
|
+
log(" --json Emit machine-readable upgrade receipt");
|
|
109
|
+
log("\nNotes:");
|
|
110
|
+
log(" - preserves customized docs, templates, skills, and core files");
|
|
111
|
+
log(" - upgrades default mdkg skills only when they match managed seed fingerprints");
|
|
112
|
+
log(" - run without flags first, then rerun with --apply when the receipt looks right");
|
|
113
|
+
printGlobalOptions(log);
|
|
114
|
+
}
|
|
98
115
|
function printNewHelp(log) {
|
|
99
116
|
log("Usage:");
|
|
100
|
-
log(' mdkg new <type> "<title>" [options]');
|
|
117
|
+
log(' mdkg new <type> "<title>" [options] [--json]');
|
|
101
118
|
log("\nTypes:");
|
|
102
119
|
log(" rule prd edd dec prop epic feat task bug checkpoint test");
|
|
120
|
+
log("\nAgent workflow file types:");
|
|
121
|
+
log(" spec work work_order receipt feedback dispute proposal");
|
|
122
|
+
log(" Use --id <portable-id> with these types for semantic ids like agent.image-worker.");
|
|
103
123
|
log("\nOptions:");
|
|
124
|
+
log(" --id <portable-id> Explicit id for agent workflow file types");
|
|
104
125
|
log(" --ws <alias> Workspace alias (default root)");
|
|
105
126
|
log(" --status <status> Work item or decision status");
|
|
106
127
|
log(" --priority <0..9> Work item priority");
|
|
@@ -113,6 +134,8 @@ function printNewHelp(log) {
|
|
|
113
134
|
log(" --parent --prev --next --relates --blocked-by --blocks");
|
|
114
135
|
log(" --links --artifacts --refs --aliases --owners --cases --supersedes");
|
|
115
136
|
log(" --owners <owner,owner,...> Owners");
|
|
137
|
+
log("\nNotes:");
|
|
138
|
+
log(" spec/work scaffold as validation-clean docs; relational workflow docs need real refs.");
|
|
116
139
|
printGlobalOptions(log);
|
|
117
140
|
}
|
|
118
141
|
function printGuideHelp(log) {
|
|
@@ -122,9 +145,11 @@ function printGuideHelp(log) {
|
|
|
122
145
|
}
|
|
123
146
|
function printWorkspaceHelp(log) {
|
|
124
147
|
log("Usage:");
|
|
125
|
-
log(" mdkg workspace ls");
|
|
126
|
-
log(" mdkg workspace add <alias> <path> [--mdkg-dir <dir>]");
|
|
127
|
-
log(" mdkg workspace rm <alias>");
|
|
148
|
+
log(" mdkg workspace ls [--json]");
|
|
149
|
+
log(" mdkg workspace add <alias> <path> [--mdkg-dir <dir>] [--json]");
|
|
150
|
+
log(" mdkg workspace rm <alias> [--json]");
|
|
151
|
+
log(" mdkg workspace enable <alias> [--json]");
|
|
152
|
+
log(" mdkg workspace disable <alias> [--json]");
|
|
128
153
|
printGlobalOptions(log);
|
|
129
154
|
}
|
|
130
155
|
function printIndexHelp(log) {
|
|
@@ -199,7 +224,7 @@ function printSkillHelp(log, subcommand) {
|
|
|
199
224
|
switch ((subcommand ?? "").toLowerCase()) {
|
|
200
225
|
case "new":
|
|
201
226
|
log("Usage:");
|
|
202
|
-
log(' mdkg skill new <slug> "<name>" --description "<description>" [options]');
|
|
227
|
+
log(' mdkg skill new <slug> "<name>" --description "<description>" [options] [--json]');
|
|
203
228
|
log("\nOptions:");
|
|
204
229
|
log(" --tags <tag,tag,...> Optional skill tags");
|
|
205
230
|
log(" --authors <name,name,...> Optional authors list");
|
|
@@ -232,24 +257,24 @@ function printSkillHelp(log, subcommand) {
|
|
|
232
257
|
return;
|
|
233
258
|
case "validate":
|
|
234
259
|
log("Usage:");
|
|
235
|
-
log(" mdkg skill validate [<slug>]");
|
|
260
|
+
log(" mdkg skill validate [<slug>] [--json]");
|
|
236
261
|
printGlobalOptions(log);
|
|
237
262
|
return;
|
|
238
263
|
case "sync":
|
|
239
264
|
log("Usage:");
|
|
240
|
-
log(" mdkg skill sync [--force]");
|
|
265
|
+
log(" mdkg skill sync [--force] [--json]");
|
|
241
266
|
log("\nWhen to use:");
|
|
242
267
|
log(" Rebuild .agents/skills and .claude/skills from canonical .mdkg/skills.");
|
|
243
268
|
printGlobalOptions(log);
|
|
244
269
|
return;
|
|
245
270
|
default:
|
|
246
271
|
log("Usage:");
|
|
247
|
-
log(' mdkg skill new <slug> "<name>" --description "<description>" [options]');
|
|
272
|
+
log(' mdkg skill new <slug> "<name>" --description "<description>" [options] [--json]');
|
|
248
273
|
log(" mdkg skill list [--tags <tag,tag,...>] [--tags-mode any|all] [--json|--xml|--toon|--md]");
|
|
249
274
|
log(" mdkg skill show <slug> [--meta] [--json|--xml|--toon|--md]");
|
|
250
275
|
log(' mdkg skill search "<query>" [--tags <tag,tag,...>] [--tags-mode any|all] [--json|--xml|--toon|--md]');
|
|
251
|
-
log(" mdkg skill validate [<slug>]");
|
|
252
|
-
log(" mdkg skill sync [--force]");
|
|
276
|
+
log(" mdkg skill validate [<slug>] [--json]");
|
|
277
|
+
log(" mdkg skill sync [--force] [--json]");
|
|
253
278
|
log("\nNotes:");
|
|
254
279
|
log(" Skills are first-class under `mdkg skill ...`.");
|
|
255
280
|
log(" Use stage tags like `stage:plan`, `stage:execute`, and `stage:review` with --tags.");
|
|
@@ -260,7 +285,7 @@ function printTaskHelp(log, subcommand) {
|
|
|
260
285
|
switch ((subcommand ?? "").toLowerCase()) {
|
|
261
286
|
case "start":
|
|
262
287
|
log("Usage:");
|
|
263
|
-
log(' mdkg task start <id-or-qid> [--ws <alias>] [--run-id <id>] [--note "<text>"]');
|
|
288
|
+
log(' mdkg task start <id-or-qid> [--ws <alias>] [--run-id <id>] [--note "<text>"] [--json]');
|
|
264
289
|
log("\nWhen to use:");
|
|
265
290
|
log(" Move a task, bug, or test into progress as a structured state change.");
|
|
266
291
|
log(" If `events.jsonl` is missing, mdkg prints a short reminder about `mdkg event enable`.");
|
|
@@ -271,7 +296,7 @@ function printTaskHelp(log, subcommand) {
|
|
|
271
296
|
log(" mdkg task update <id-or-qid> [--ws <alias>] [--status <status>] [--priority <n>]");
|
|
272
297
|
log(" [--add-artifacts <a,...>] [--add-links <l,...>] [--add-refs <id,...>]");
|
|
273
298
|
log(" [--add-skills <slug,...>] [--add-tags <tag,...>] [--add-blocked-by <id,...>]");
|
|
274
|
-
log(' [--clear-blocked-by] [--run-id <id>] [--note "<text>"]');
|
|
299
|
+
log(' [--clear-blocked-by] [--run-id <id>] [--note "<text>"] [--json]');
|
|
275
300
|
log("\nWhen to use:");
|
|
276
301
|
log(" Update structured task metadata and evidence while keeping body and narrative edits in markdown.");
|
|
277
302
|
printGlobalOptions(log);
|
|
@@ -279,7 +304,7 @@ function printTaskHelp(log, subcommand) {
|
|
|
279
304
|
case "done":
|
|
280
305
|
log("Usage:");
|
|
281
306
|
log(' mdkg task done <id-or-qid> [--ws <alias>] [--add-artifacts <a,...>] [--add-links <l,...>]');
|
|
282
|
-
log(' [--add-refs <id,...>] [--checkpoint "<title>"] [--run-id <id>] [--note "<text>"]');
|
|
307
|
+
log(' [--add-refs <id,...>] [--checkpoint "<title>"] [--run-id <id>] [--note "<text>"] [--json]');
|
|
283
308
|
log("\nWhen to use:");
|
|
284
309
|
log(" Mark a task-like node done, optionally create a checkpoint, and emit a completion event when enabled.");
|
|
285
310
|
log(" Use `--checkpoint` for milestone compression, not every routine task completion.");
|
|
@@ -287,9 +312,9 @@ function printTaskHelp(log, subcommand) {
|
|
|
287
312
|
return;
|
|
288
313
|
default:
|
|
289
314
|
log("Usage:");
|
|
290
|
-
log(' mdkg task start <id-or-qid> [--ws <alias>] [--run-id <id>] [--note "<text>"]');
|
|
291
|
-
log(" mdkg task update <id-or-qid> [options]");
|
|
292
|
-
log(' mdkg task done <id-or-qid> [--checkpoint "<title>"] [options]');
|
|
315
|
+
log(' mdkg task start <id-or-qid> [--ws <alias>] [--run-id <id>] [--note "<text>"] [--json]');
|
|
316
|
+
log(" mdkg task update <id-or-qid> [options] [--json]");
|
|
317
|
+
log(' mdkg task done <id-or-qid> [--checkpoint "<title>"] [options] [--json]');
|
|
293
318
|
log("\nNotes:");
|
|
294
319
|
log(" `mdkg task ...` only supports task, bug, and test nodes in this wave.");
|
|
295
320
|
log(" Feat and epic closeout remain checkpoint-first guidance plus manual parent updates.");
|
|
@@ -300,7 +325,7 @@ function printEventHelp(log, subcommand) {
|
|
|
300
325
|
switch ((subcommand ?? "").toLowerCase()) {
|
|
301
326
|
case "enable":
|
|
302
327
|
log("Usage:");
|
|
303
|
-
log(" mdkg event enable [--ws <alias>]");
|
|
328
|
+
log(" mdkg event enable [--ws <alias>] [--json]");
|
|
304
329
|
log("\nWhen to use:");
|
|
305
330
|
log(" Create or ensure the append-only JSONL event log for a workspace.");
|
|
306
331
|
printGlobalOptions(log);
|
|
@@ -308,7 +333,7 @@ function printEventHelp(log, subcommand) {
|
|
|
308
333
|
case "append":
|
|
309
334
|
log("Usage:");
|
|
310
335
|
log(" mdkg event append --kind <kind> --status <ok|error|retry|skipped> --refs <id,...>");
|
|
311
|
-
log(' [--ws <alias>] [--artifacts <a,...>] [--notes "<text>"] [--run-id <id>]');
|
|
336
|
+
log(' [--ws <alias>] [--artifacts <a,...>] [--notes "<text>"] [--run-id <id>] [--json]');
|
|
312
337
|
log(" [--agent <name>] [--skill <slug>] [--tool <id>]");
|
|
313
338
|
log("\nWhen to use:");
|
|
314
339
|
log(" Append explicit provenance events from an orchestrator or manual workflow.");
|
|
@@ -316,8 +341,8 @@ function printEventHelp(log, subcommand) {
|
|
|
316
341
|
return;
|
|
317
342
|
default:
|
|
318
343
|
log("Usage:");
|
|
319
|
-
log(" mdkg event enable [--ws <alias>]");
|
|
320
|
-
log(" mdkg event append --kind <kind> --status <ok|error|retry|skipped> --refs <id,...> [options]");
|
|
344
|
+
log(" mdkg event enable [--ws <alias>] [--json]");
|
|
345
|
+
log(" mdkg event append --kind <kind> --status <ok|error|retry|skipped> --refs <id,...> [options] [--json]");
|
|
321
346
|
printGlobalOptions(log);
|
|
322
347
|
}
|
|
323
348
|
}
|
|
@@ -328,13 +353,13 @@ function printNextHelp(log) {
|
|
|
328
353
|
}
|
|
329
354
|
function printCheckpointHelp(log) {
|
|
330
355
|
log("Usage:");
|
|
331
|
-
log(" mdkg checkpoint new <title> [--ws <alias>]");
|
|
356
|
+
log(" mdkg checkpoint new <title> [--ws <alias>] [--json]");
|
|
332
357
|
log(' [--relates <id,id,...>] [--scope <id,id,...>] [--run-id <id>] [--note "<text>"]');
|
|
333
358
|
printGlobalOptions(log);
|
|
334
359
|
}
|
|
335
360
|
function printValidateHelp(log) {
|
|
336
361
|
log("Usage:");
|
|
337
|
-
log(" mdkg validate [--out <path>] [--quiet]");
|
|
362
|
+
log(" mdkg validate [--out <path>] [--quiet] [--json]");
|
|
338
363
|
printGlobalOptions(log);
|
|
339
364
|
}
|
|
340
365
|
function printFormatHelp(log) {
|
|
@@ -363,6 +388,9 @@ function printCommandHelp(log, command, subcommand) {
|
|
|
363
388
|
case "init":
|
|
364
389
|
printInitHelp(log);
|
|
365
390
|
return;
|
|
391
|
+
case "upgrade":
|
|
392
|
+
printUpgradeHelp(log);
|
|
393
|
+
return;
|
|
366
394
|
case "guide":
|
|
367
395
|
printGuideHelp(log);
|
|
368
396
|
return;
|
|
@@ -573,7 +601,8 @@ function runWorkspaceSubcommand(parsed, root) {
|
|
|
573
601
|
if (parsed.positionals.length > 2) {
|
|
574
602
|
throw new errors_1.UsageError("workspace ls takes no arguments");
|
|
575
603
|
}
|
|
576
|
-
(
|
|
604
|
+
const json = parseBooleanFlag("--json", parsed.flags["--json"]);
|
|
605
|
+
(0, workspace_1.runWorkspaceListCommand)({ root, json });
|
|
577
606
|
return 0;
|
|
578
607
|
}
|
|
579
608
|
case "add": {
|
|
@@ -583,7 +612,8 @@ function runWorkspaceSubcommand(parsed, root) {
|
|
|
583
612
|
throw new errors_1.UsageError("workspace add requires <alias> <path>");
|
|
584
613
|
}
|
|
585
614
|
const mdkgDir = requireFlagValue("--mdkg-dir", parsed.flags["--mdkg-dir"]);
|
|
586
|
-
|
|
615
|
+
const json = parseBooleanFlag("--json", parsed.flags["--json"]);
|
|
616
|
+
(0, workspace_1.runWorkspaceAddCommand)({ root, alias, workspacePath, mdkgDir, json });
|
|
587
617
|
return 0;
|
|
588
618
|
}
|
|
589
619
|
case "rm": {
|
|
@@ -591,11 +621,30 @@ function runWorkspaceSubcommand(parsed, root) {
|
|
|
591
621
|
if (!alias || parsed.positionals.length > 3) {
|
|
592
622
|
throw new errors_1.UsageError("workspace rm requires <alias>");
|
|
593
623
|
}
|
|
594
|
-
(
|
|
624
|
+
const json = parseBooleanFlag("--json", parsed.flags["--json"]);
|
|
625
|
+
(0, workspace_1.runWorkspaceRemoveCommand)({ root, alias, json });
|
|
626
|
+
return 0;
|
|
627
|
+
}
|
|
628
|
+
case "enable": {
|
|
629
|
+
const alias = parsed.positionals[2];
|
|
630
|
+
if (!alias || parsed.positionals.length > 3) {
|
|
631
|
+
throw new errors_1.UsageError("workspace enable requires <alias>");
|
|
632
|
+
}
|
|
633
|
+
const json = parseBooleanFlag("--json", parsed.flags["--json"]);
|
|
634
|
+
(0, workspace_1.runWorkspaceEnableCommand)({ root, alias, json });
|
|
635
|
+
return 0;
|
|
636
|
+
}
|
|
637
|
+
case "disable": {
|
|
638
|
+
const alias = parsed.positionals[2];
|
|
639
|
+
if (!alias || parsed.positionals.length > 3) {
|
|
640
|
+
throw new errors_1.UsageError("workspace disable requires <alias>");
|
|
641
|
+
}
|
|
642
|
+
const json = parseBooleanFlag("--json", parsed.flags["--json"]);
|
|
643
|
+
(0, workspace_1.runWorkspaceDisableCommand)({ root, alias, json });
|
|
595
644
|
return 0;
|
|
596
645
|
}
|
|
597
646
|
default:
|
|
598
|
-
throw new errors_1.UsageError("workspace requires ls/add/rm");
|
|
647
|
+
throw new errors_1.UsageError("workspace requires ls/add/rm/enable/disable");
|
|
599
648
|
}
|
|
600
649
|
}
|
|
601
650
|
function runSkillSubcommand(parsed, root) {
|
|
@@ -620,6 +669,7 @@ function runSkillSubcommand(parsed, root) {
|
|
|
620
669
|
const withScripts = parseBooleanFlag("--with-scripts", parsed.flags["--with-scripts"]);
|
|
621
670
|
const force = parseBooleanFlag("--force", parsed.flags["--force"]);
|
|
622
671
|
const runId = requireFlagValue("--run-id", parsed.flags["--run-id"]);
|
|
672
|
+
const json = parseBooleanFlag("--json", parsed.flags["--json"]);
|
|
623
673
|
(0, skill_1.runSkillNewCommand)({
|
|
624
674
|
root,
|
|
625
675
|
slug,
|
|
@@ -631,6 +681,7 @@ function runSkillSubcommand(parsed, root) {
|
|
|
631
681
|
withScripts,
|
|
632
682
|
force,
|
|
633
683
|
runId,
|
|
684
|
+
json,
|
|
634
685
|
});
|
|
635
686
|
return 0;
|
|
636
687
|
}
|
|
@@ -698,7 +749,8 @@ function runSkillSubcommand(parsed, root) {
|
|
|
698
749
|
throw new errors_1.UsageError("skill validate accepts at most one slug");
|
|
699
750
|
}
|
|
700
751
|
const slug = parsed.positionals[2];
|
|
701
|
-
(
|
|
752
|
+
const json = parseBooleanFlag("--json", parsed.flags["--json"]);
|
|
753
|
+
(0, skill_1.runSkillValidateCommand)({ root, slug, json });
|
|
702
754
|
return 0;
|
|
703
755
|
}
|
|
704
756
|
case "sync": {
|
|
@@ -706,7 +758,8 @@ function runSkillSubcommand(parsed, root) {
|
|
|
706
758
|
throw new errors_1.UsageError("skill sync does not accept positional arguments");
|
|
707
759
|
}
|
|
708
760
|
const force = parseBooleanFlag("--force", parsed.flags["--force"]);
|
|
709
|
-
(
|
|
761
|
+
const json = parseBooleanFlag("--json", parsed.flags["--json"]);
|
|
762
|
+
(0, skill_1.runSkillSyncCommand)({ root, force, json });
|
|
710
763
|
return 0;
|
|
711
764
|
}
|
|
712
765
|
default:
|
|
@@ -724,7 +777,8 @@ function runTaskSubcommand(parsed, root) {
|
|
|
724
777
|
const ws = requireFlagValue("--ws", parsed.flags["--ws"]);
|
|
725
778
|
const runId = requireFlagValue("--run-id", parsed.flags["--run-id"]);
|
|
726
779
|
const note = requireFlagValue("--note", parsed.flags["--note"]);
|
|
727
|
-
|
|
780
|
+
const json = parseBooleanFlag("--json", parsed.flags["--json"]);
|
|
781
|
+
(0, task_1.runTaskStartCommand)({ root, id, ws, runId, note, json });
|
|
728
782
|
return 0;
|
|
729
783
|
}
|
|
730
784
|
case "update": {
|
|
@@ -744,6 +798,7 @@ function runTaskSubcommand(parsed, root) {
|
|
|
744
798
|
const clearBlockedBy = parseBooleanFlag("--clear-blocked-by", parsed.flags["--clear-blocked-by"]);
|
|
745
799
|
const runId = requireFlagValue("--run-id", parsed.flags["--run-id"]);
|
|
746
800
|
const note = requireFlagValue("--note", parsed.flags["--note"]);
|
|
801
|
+
const json = parseBooleanFlag("--json", parsed.flags["--json"]);
|
|
747
802
|
(0, task_1.runTaskUpdateCommand)({
|
|
748
803
|
root,
|
|
749
804
|
id,
|
|
@@ -759,6 +814,7 @@ function runTaskSubcommand(parsed, root) {
|
|
|
759
814
|
clearBlockedBy,
|
|
760
815
|
runId,
|
|
761
816
|
note,
|
|
817
|
+
json,
|
|
762
818
|
});
|
|
763
819
|
return 0;
|
|
764
820
|
}
|
|
@@ -774,6 +830,7 @@ function runTaskSubcommand(parsed, root) {
|
|
|
774
830
|
const checkpoint = requireFlagValue("--checkpoint", parsed.flags["--checkpoint"]);
|
|
775
831
|
const runId = requireFlagValue("--run-id", parsed.flags["--run-id"]);
|
|
776
832
|
const note = requireFlagValue("--note", parsed.flags["--note"]);
|
|
833
|
+
const json = parseBooleanFlag("--json", parsed.flags["--json"]);
|
|
777
834
|
(0, task_1.runTaskDoneCommand)({
|
|
778
835
|
root,
|
|
779
836
|
id,
|
|
@@ -784,6 +841,7 @@ function runTaskSubcommand(parsed, root) {
|
|
|
784
841
|
checkpoint,
|
|
785
842
|
runId,
|
|
786
843
|
note,
|
|
844
|
+
json,
|
|
787
845
|
});
|
|
788
846
|
return 0;
|
|
789
847
|
}
|
|
@@ -799,7 +857,8 @@ function runEventSubcommand(parsed, root) {
|
|
|
799
857
|
throw new errors_1.UsageError("event enable does not accept positional arguments");
|
|
800
858
|
}
|
|
801
859
|
const ws = requireFlagValue("--ws", parsed.flags["--ws"]);
|
|
802
|
-
(
|
|
860
|
+
const json = parseBooleanFlag("--json", parsed.flags["--json"]);
|
|
861
|
+
(0, event_1.runEventEnableCommand)({ root, ws, json });
|
|
803
862
|
return 0;
|
|
804
863
|
}
|
|
805
864
|
case "append": {
|
|
@@ -819,6 +878,7 @@ function runEventSubcommand(parsed, root) {
|
|
|
819
878
|
const agent = requireFlagValue("--agent", parsed.flags["--agent"]);
|
|
820
879
|
const skill = requireFlagValue("--skill", parsed.flags["--skill"]);
|
|
821
880
|
const tool = requireFlagValue("--tool", parsed.flags["--tool"]);
|
|
881
|
+
const json = parseBooleanFlag("--json", parsed.flags["--json"]);
|
|
822
882
|
(0, event_1.runEventAppendCommand)({
|
|
823
883
|
root,
|
|
824
884
|
ws,
|
|
@@ -831,6 +891,7 @@ function runEventSubcommand(parsed, root) {
|
|
|
831
891
|
agent,
|
|
832
892
|
skill,
|
|
833
893
|
tool,
|
|
894
|
+
json,
|
|
834
895
|
});
|
|
835
896
|
return 0;
|
|
836
897
|
}
|
|
@@ -868,6 +929,19 @@ function runCommand(parsed, root, runtime) {
|
|
|
868
929
|
});
|
|
869
930
|
return 0;
|
|
870
931
|
}
|
|
932
|
+
case "upgrade": {
|
|
933
|
+
if (parsed.positionals.length > 1) {
|
|
934
|
+
throw new errors_1.UsageError("upgrade does not accept positional arguments");
|
|
935
|
+
}
|
|
936
|
+
const dryRun = parseBooleanFlag("--dry-run", parsed.flags["--dry-run"]);
|
|
937
|
+
const apply = parseBooleanFlag("--apply", parsed.flags["--apply"]);
|
|
938
|
+
if (dryRun && apply) {
|
|
939
|
+
throw new errors_1.UsageError("choose either --dry-run or --apply, not both");
|
|
940
|
+
}
|
|
941
|
+
const json = parseBooleanFlag("--json", parsed.flags["--json"]);
|
|
942
|
+
(0, upgrade_1.runUpgradeCommand)({ root, dryRun, apply, json });
|
|
943
|
+
return 0;
|
|
944
|
+
}
|
|
871
945
|
case "guide":
|
|
872
946
|
(0, guide_1.runGuideCommand)({ root });
|
|
873
947
|
return 0;
|
|
@@ -882,6 +956,7 @@ function runCommand(parsed, root, runtime) {
|
|
|
882
956
|
if (!type || !title) {
|
|
883
957
|
throw new errors_1.UsageError("new requires a type and title");
|
|
884
958
|
}
|
|
959
|
+
const id = requireFlagValue("--id", parsed.flags["--id"]);
|
|
885
960
|
const ws = requireFlagValue("--ws", parsed.flags["--ws"]);
|
|
886
961
|
const status = requireFlagValue("--status", parsed.flags["--status"]);
|
|
887
962
|
const priority = parseNumberFlag("--priority", parsed.flags["--priority"]);
|
|
@@ -905,10 +980,12 @@ function runCommand(parsed, root, runtime) {
|
|
|
905
980
|
const noCache = parseBooleanFlag("--no-cache", parsed.flags["--no-cache"]);
|
|
906
981
|
const noReindex = parseBooleanFlag("--no-reindex", parsed.flags["--no-reindex"]);
|
|
907
982
|
const runId = requireFlagValue("--run-id", parsed.flags["--run-id"]);
|
|
983
|
+
const json = parseBooleanFlag("--json", parsed.flags["--json"]);
|
|
908
984
|
(0, new_1.runNewCommand)({
|
|
909
985
|
root,
|
|
910
986
|
type,
|
|
911
987
|
title,
|
|
988
|
+
id,
|
|
912
989
|
ws,
|
|
913
990
|
status,
|
|
914
991
|
priority,
|
|
@@ -932,6 +1009,7 @@ function runCommand(parsed, root, runtime) {
|
|
|
932
1009
|
noCache,
|
|
933
1010
|
noReindex,
|
|
934
1011
|
runId,
|
|
1012
|
+
json,
|
|
935
1013
|
});
|
|
936
1014
|
return 0;
|
|
937
1015
|
}
|
|
@@ -1117,6 +1195,7 @@ function runCommand(parsed, root, runtime) {
|
|
|
1117
1195
|
const template = requireFlagValue("--template", parsed.flags["--template"]);
|
|
1118
1196
|
const runId = requireFlagValue("--run-id", parsed.flags["--run-id"]);
|
|
1119
1197
|
const note = requireFlagValue("--note", parsed.flags["--note"]);
|
|
1198
|
+
const json = parseBooleanFlag("--json", parsed.flags["--json"]);
|
|
1120
1199
|
(0, checkpoint_1.runCheckpointNewCommand)({
|
|
1121
1200
|
root,
|
|
1122
1201
|
title,
|
|
@@ -1128,6 +1207,7 @@ function runCommand(parsed, root, runtime) {
|
|
|
1128
1207
|
template,
|
|
1129
1208
|
runId,
|
|
1130
1209
|
note,
|
|
1210
|
+
json,
|
|
1131
1211
|
});
|
|
1132
1212
|
return 0;
|
|
1133
1213
|
}
|
|
@@ -1137,7 +1217,8 @@ function runCommand(parsed, root, runtime) {
|
|
|
1137
1217
|
}
|
|
1138
1218
|
const out = requireFlagValue("--out", parsed.flags["--out"]);
|
|
1139
1219
|
const quiet = parseBooleanFlag("--quiet", parsed.flags["--quiet"]);
|
|
1140
|
-
|
|
1220
|
+
const json = parseBooleanFlag("--json", parsed.flags["--json"]);
|
|
1221
|
+
(0, validate_1.runValidateCommand)({ root, out, quiet, json });
|
|
1141
1222
|
return 0;
|
|
1142
1223
|
}
|
|
1143
1224
|
case "format":
|
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createCheckpoint = createCheckpoint;
|
|
6
7
|
exports.runCheckpointNewCommand = runCheckpointNewCommand;
|
|
7
8
|
const fs_1 = __importDefault(require("fs"));
|
|
8
9
|
const path_1 = __importDefault(require("path"));
|
|
@@ -76,7 +77,7 @@ function normalizeWorkspace(value) {
|
|
|
76
77
|
}
|
|
77
78
|
return normalized;
|
|
78
79
|
}
|
|
79
|
-
function
|
|
80
|
+
function createCheckpoint(options) {
|
|
80
81
|
const title = options.title.trim();
|
|
81
82
|
if (!title) {
|
|
82
83
|
throw new errors_1.UsageError("checkpoint title cannot be empty");
|
|
@@ -140,5 +141,21 @@ function runCheckpointNewCommand(options) {
|
|
|
140
141
|
runId: options.runId,
|
|
141
142
|
now,
|
|
142
143
|
});
|
|
143
|
-
|
|
144
|
+
return {
|
|
145
|
+
workspace: ws,
|
|
146
|
+
id,
|
|
147
|
+
qid: `${ws}:${id}`,
|
|
148
|
+
path: path_1.default.relative(options.root, filePath),
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
function runCheckpointNewCommand(options) {
|
|
152
|
+
const checkpoint = createCheckpoint(options);
|
|
153
|
+
if (options.json) {
|
|
154
|
+
console.log(JSON.stringify({
|
|
155
|
+
action: "created",
|
|
156
|
+
checkpoint,
|
|
157
|
+
}, null, 2));
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
console.log(`checkpoint created: ${checkpoint.qid} (${checkpoint.path})`);
|
|
144
161
|
}
|
package/dist/commands/event.js
CHANGED
|
@@ -6,6 +6,14 @@ const event_support_1 = require("./event_support");
|
|
|
6
6
|
const errors_1 = require("../util/errors");
|
|
7
7
|
function runEventEnableCommand(options) {
|
|
8
8
|
const result = (0, event_support_1.ensureEventsEnabled)(options);
|
|
9
|
+
if (options.json) {
|
|
10
|
+
console.log(JSON.stringify({
|
|
11
|
+
action: "enabled",
|
|
12
|
+
workspace: result.ws,
|
|
13
|
+
created: result.created,
|
|
14
|
+
}, null, 2));
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
9
17
|
const createdLabel = result.created ? "created" : "already present";
|
|
10
18
|
console.log(`event logging enabled: ${result.ws} (${createdLabel})`);
|
|
11
19
|
}
|
|
@@ -41,5 +49,9 @@ function runEventAppendCommand(options) {
|
|
|
41
49
|
skill: options.skill,
|
|
42
50
|
tool: options.tool,
|
|
43
51
|
});
|
|
52
|
+
if (options.json) {
|
|
53
|
+
console.log(JSON.stringify({ action: "appended", event: record }, null, 2));
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
44
56
|
console.log(`event appended: ${record.workspace}:${record.kind} (${record.run_id})`);
|
|
45
57
|
}
|
package/dist/commands/init.js
CHANGED
|
@@ -9,6 +9,8 @@ const path_1 = __importDefault(require("path"));
|
|
|
9
9
|
const config_1 = require("../core/config");
|
|
10
10
|
const errors_1 = require("../util/errors");
|
|
11
11
|
const date_1 = require("../util/date");
|
|
12
|
+
const version_1 = require("../core/version");
|
|
13
|
+
const init_manifest_1 = require("./init_manifest");
|
|
12
14
|
const skill_support_1 = require("./skill_support");
|
|
13
15
|
const skill_mirror_1 = require("./skill_mirror");
|
|
14
16
|
const DEFAULT_SEED_SUBDIR = path_1.default.resolve(__dirname, "..", "init");
|
|
@@ -236,6 +238,7 @@ function runInitCommand(options) {
|
|
|
236
238
|
const seedCliMatrix = path_1.default.join(seedRoot, "CLI_COMMAND_MATRIX.md");
|
|
237
239
|
const seedReadme = path_1.default.join(seedRoot, "README.md");
|
|
238
240
|
const seedDefaultSkills = path_1.default.join(seedRoot, "skills", "default");
|
|
241
|
+
const seedManifest = (0, init_manifest_1.createInitManifest)(seedRoot, (0, version_1.readPackageVersion)());
|
|
239
242
|
if (!fs_1.default.existsSync(seedConfig) || !fs_1.default.existsSync(seedCore) || !fs_1.default.existsSync(seedTemplates)) {
|
|
240
243
|
throw new errors_1.NotFoundError(`init assets not found at ${seedRoot} (try reinstalling mdkg)`);
|
|
241
244
|
}
|
|
@@ -304,6 +307,7 @@ function runInitCommand(options) {
|
|
|
304
307
|
(0, skill_support_1.refreshSkillsRegistry)(root, config);
|
|
305
308
|
(0, skill_mirror_1.syncSkillMirrors)({ root, config, createRoots: true, force });
|
|
306
309
|
}
|
|
310
|
+
(0, init_manifest_1.writeInitManifest)(path_1.default.join(mdkgDir, init_manifest_1.INIT_MANIFEST_FILE), seedManifest);
|
|
307
311
|
const noUpdateIgnores = Boolean(options.noUpdateIgnores);
|
|
308
312
|
const shouldUpdateGitignore = Boolean(options.updateGitignore || !noUpdateIgnores);
|
|
309
313
|
const shouldUpdateNpmignore = Boolean(options.updateNpmignore || !noUpdateIgnores);
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.INIT_MANIFEST_SCHEMA_VERSION = exports.INIT_MANIFEST_FILE = void 0;
|
|
7
|
+
exports.sha256File = sha256File;
|
|
8
|
+
exports.seedSourcePath = seedSourcePath;
|
|
9
|
+
exports.createInitManifest = createInitManifest;
|
|
10
|
+
exports.writeInitManifest = writeInitManifest;
|
|
11
|
+
exports.readInitManifest = readInitManifest;
|
|
12
|
+
exports.loadLegacyInitManifests = loadLegacyInitManifests;
|
|
13
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
14
|
+
const fs_1 = __importDefault(require("fs"));
|
|
15
|
+
const path_1 = __importDefault(require("path"));
|
|
16
|
+
exports.INIT_MANIFEST_FILE = "init-manifest.json";
|
|
17
|
+
exports.INIT_MANIFEST_SCHEMA_VERSION = 1;
|
|
18
|
+
const STARTUP_DOCS = ["llms.txt", "AGENT_START.md", "CLI_COMMAND_MATRIX.md"];
|
|
19
|
+
const AGENT_DOCS = ["AGENTS.md", "CLAUDE.md"];
|
|
20
|
+
function toPosixPath(value) {
|
|
21
|
+
return value.split(path_1.default.sep).join("/");
|
|
22
|
+
}
|
|
23
|
+
function sha256Buffer(value) {
|
|
24
|
+
return crypto_1.default.createHash("sha256").update(value).digest("hex");
|
|
25
|
+
}
|
|
26
|
+
function sha256File(filePath) {
|
|
27
|
+
return sha256Buffer(fs_1.default.readFileSync(filePath));
|
|
28
|
+
}
|
|
29
|
+
function listFiles(dirPath) {
|
|
30
|
+
if (!fs_1.default.existsSync(dirPath)) {
|
|
31
|
+
return [];
|
|
32
|
+
}
|
|
33
|
+
const files = [];
|
|
34
|
+
const entries = fs_1.default.readdirSync(dirPath, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name));
|
|
35
|
+
for (const entry of entries) {
|
|
36
|
+
const fullPath = path_1.default.join(dirPath, entry.name);
|
|
37
|
+
if (entry.isDirectory()) {
|
|
38
|
+
files.push(...listFiles(fullPath));
|
|
39
|
+
}
|
|
40
|
+
else if (entry.isFile()) {
|
|
41
|
+
files.push(fullPath);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return files;
|
|
45
|
+
}
|
|
46
|
+
function addSeedFile(files, seedRoot, seedRelativePath, targetPath, category) {
|
|
47
|
+
const sourcePath = path_1.default.join(seedRoot, seedRelativePath);
|
|
48
|
+
if (!fs_1.default.existsSync(sourcePath) || !fs_1.default.statSync(sourcePath).isFile()) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
files.push({
|
|
52
|
+
path: toPosixPath(targetPath),
|
|
53
|
+
category,
|
|
54
|
+
sha256: sha256File(sourcePath),
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
function addSeedDir(files, seedRoot, seedRelativeDir, targetDir, category) {
|
|
58
|
+
const sourceDir = path_1.default.join(seedRoot, seedRelativeDir);
|
|
59
|
+
for (const sourcePath of listFiles(sourceDir)) {
|
|
60
|
+
const relPath = toPosixPath(path_1.default.relative(sourceDir, sourcePath));
|
|
61
|
+
files.push({
|
|
62
|
+
path: path_1.default.posix.join(targetDir, relPath),
|
|
63
|
+
category,
|
|
64
|
+
sha256: sha256File(sourcePath),
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function seedSourcePath(seedRoot, file) {
|
|
69
|
+
if (file.path === ".mdkg/config.json") {
|
|
70
|
+
return path_1.default.join(seedRoot, "config.json");
|
|
71
|
+
}
|
|
72
|
+
if (file.path === ".mdkg/README.md") {
|
|
73
|
+
return path_1.default.join(seedRoot, "README.md");
|
|
74
|
+
}
|
|
75
|
+
if (file.path.startsWith(".mdkg/core/")) {
|
|
76
|
+
return path_1.default.join(seedRoot, "core", file.path.slice(".mdkg/core/".length));
|
|
77
|
+
}
|
|
78
|
+
if (file.path.startsWith(".mdkg/templates/")) {
|
|
79
|
+
return path_1.default.join(seedRoot, "templates", file.path.slice(".mdkg/templates/".length));
|
|
80
|
+
}
|
|
81
|
+
if (file.path.startsWith(".mdkg/skills/")) {
|
|
82
|
+
return path_1.default.join(seedRoot, "skills", "default", file.path.slice(".mdkg/skills/".length));
|
|
83
|
+
}
|
|
84
|
+
return path_1.default.join(seedRoot, file.path);
|
|
85
|
+
}
|
|
86
|
+
function createInitManifest(seedRoot, mdkgVersion) {
|
|
87
|
+
const files = [];
|
|
88
|
+
addSeedFile(files, seedRoot, "config.json", ".mdkg/config.json", "config");
|
|
89
|
+
addSeedFile(files, seedRoot, "README.md", ".mdkg/README.md", "mdkg_doc");
|
|
90
|
+
addSeedDir(files, seedRoot, "core", ".mdkg/core", "core");
|
|
91
|
+
addSeedDir(files, seedRoot, "templates", ".mdkg/templates", "template");
|
|
92
|
+
for (const doc of AGENT_DOCS) {
|
|
93
|
+
addSeedFile(files, seedRoot, doc, doc, "agent_doc");
|
|
94
|
+
}
|
|
95
|
+
for (const doc of STARTUP_DOCS) {
|
|
96
|
+
addSeedFile(files, seedRoot, doc, doc, "startup_doc");
|
|
97
|
+
}
|
|
98
|
+
addSeedDir(files, seedRoot, path_1.default.join("skills", "default"), ".mdkg/skills", "default_skill");
|
|
99
|
+
return {
|
|
100
|
+
schema_version: exports.INIT_MANIFEST_SCHEMA_VERSION,
|
|
101
|
+
tool: "mdkg",
|
|
102
|
+
mdkg_version: mdkgVersion,
|
|
103
|
+
files: files.sort((a, b) => a.path.localeCompare(b.path)),
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
function writeInitManifest(filePath, manifest) {
|
|
107
|
+
fs_1.default.mkdirSync(path_1.default.dirname(filePath), { recursive: true });
|
|
108
|
+
fs_1.default.writeFileSync(filePath, `${JSON.stringify(manifest, null, 2)}\n`, "utf8");
|
|
109
|
+
}
|
|
110
|
+
function readInitManifest(filePath) {
|
|
111
|
+
if (!fs_1.default.existsSync(filePath)) {
|
|
112
|
+
return undefined;
|
|
113
|
+
}
|
|
114
|
+
const parsed = JSON.parse(fs_1.default.readFileSync(filePath, "utf8"));
|
|
115
|
+
if (parsed.schema_version !== exports.INIT_MANIFEST_SCHEMA_VERSION || parsed.tool !== "mdkg" || !Array.isArray(parsed.files)) {
|
|
116
|
+
throw new Error(`${filePath}: invalid mdkg init manifest`);
|
|
117
|
+
}
|
|
118
|
+
return parsed;
|
|
119
|
+
}
|
|
120
|
+
function loadLegacyInitManifests(seedRoot) {
|
|
121
|
+
const legacyDir = path_1.default.join(seedRoot, "legacy");
|
|
122
|
+
if (!fs_1.default.existsSync(legacyDir)) {
|
|
123
|
+
return [];
|
|
124
|
+
}
|
|
125
|
+
return fs_1.default
|
|
126
|
+
.readdirSync(legacyDir, { withFileTypes: true })
|
|
127
|
+
.filter((entry) => entry.isFile() && entry.name.endsWith(".json"))
|
|
128
|
+
.sort((a, b) => a.name.localeCompare(b.name))
|
|
129
|
+
.map((entry) => readInitManifest(path_1.default.join(legacyDir, entry.name)))
|
|
130
|
+
.filter((manifest) => manifest !== undefined);
|
|
131
|
+
}
|