mdkg 0.3.5 → 0.3.7
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 +97 -2
- package/CLI_COMMAND_MATRIX.md +90 -10
- package/README.md +54 -7
- package/dist/cli.js +222 -13
- package/dist/command-contract.json +587 -19
- package/dist/commands/bundle.js +2 -0
- package/dist/commands/checkpoint.js +139 -1
- package/dist/commands/db.js +8 -0
- package/dist/commands/format.js +116 -0
- package/dist/commands/goal.js +60 -0
- package/dist/commands/graph.js +280 -10
- package/dist/commands/handoff.js +295 -0
- package/dist/commands/mcp.js +656 -0
- package/dist/commands/pack.js +3 -1
- package/dist/commands/query_output.js +2 -0
- package/dist/commands/show.js +8 -0
- package/dist/commands/status.js +1 -0
- package/dist/commands/task.js +2 -0
- package/dist/commands/upgrade.js +61 -0
- package/dist/commands/validate.js +162 -3
- package/dist/commands/work.js +164 -0
- package/dist/core/project_db_queue_contract.js +101 -0
- package/dist/graph/edges.js +15 -0
- package/dist/graph/frontmatter.js +4 -1
- package/dist/graph/indexer.js +8 -0
- package/dist/graph/node.js +12 -1
- package/dist/graph/sqlite_index.js +2 -0
- package/dist/graph/subgraphs.js +2 -0
- package/dist/graph/validate_graph.js +5 -0
- package/dist/graph/visibility.js +6 -0
- package/dist/init/AGENT_START.md +4 -1
- package/dist/init/CLI_COMMAND_MATRIX.md +36 -4
- package/dist/init/README.md +26 -3
- package/dist/init/init-manifest.json +12 -12
- package/dist/init/templates/default/bug.md +2 -0
- package/dist/init/templates/default/chk.md +3 -0
- package/dist/init/templates/default/epic.md +2 -0
- package/dist/init/templates/default/feat.md +2 -0
- package/dist/init/templates/default/goal.md +3 -0
- package/dist/init/templates/default/spike.md +2 -0
- package/dist/init/templates/default/task.md +2 -0
- package/dist/init/templates/default/test.md +2 -0
- package/dist/pack/export_json.js +20 -8
- package/dist/pack/export_md.js +15 -4
- package/dist/pack/export_xml.js +9 -4
- package/dist/pack/metrics.js +12 -4
- package/dist/pack/pack.js +9 -1
- package/dist/util/argparse.js +1 -0
- package/package.json +7 -2
package/dist/cli.js
CHANGED
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
};
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.runCli = runCli;
|
|
8
|
+
exports.runCliAsync = runCliAsync;
|
|
8
9
|
exports.main = main;
|
|
9
10
|
const fs_1 = __importDefault(require("fs"));
|
|
10
11
|
const path_1 = __importDefault(require("path"));
|
|
@@ -14,11 +15,13 @@ const list_1 = require("./commands/list");
|
|
|
14
15
|
const search_1 = require("./commands/search");
|
|
15
16
|
const show_1 = require("./commands/show");
|
|
16
17
|
const pack_1 = require("./commands/pack");
|
|
18
|
+
const handoff_1 = require("./commands/handoff");
|
|
17
19
|
const next_1 = require("./commands/next");
|
|
18
20
|
const validate_1 = require("./commands/validate");
|
|
19
21
|
const format_1 = require("./commands/format");
|
|
20
22
|
const doctor_1 = require("./commands/doctor");
|
|
21
23
|
const status_1 = require("./commands/status");
|
|
24
|
+
const mcp_1 = require("./commands/mcp");
|
|
22
25
|
const fix_1 = require("./commands/fix");
|
|
23
26
|
const db_1 = require("./commands/db");
|
|
24
27
|
const capability_1 = require("./commands/capability");
|
|
@@ -65,12 +68,13 @@ function printUsage(log) {
|
|
|
65
68
|
log(" list List nodes with filters");
|
|
66
69
|
log(" search Search nodes by query");
|
|
67
70
|
log(" pack Generate a context pack");
|
|
71
|
+
log(" handoff Create sanitized agent handoff prompts from graph context");
|
|
68
72
|
log(" skill Create, list, show, search, and validate skills");
|
|
69
73
|
log(" capability List, search, show, and resolve cached capability surfaces");
|
|
70
74
|
log(" spec List, show, and validate optional SPEC.md capability records");
|
|
71
75
|
log(" archive Add, list, show, verify, and compress archive sidecars");
|
|
72
76
|
log(" bundle Create, list, show, and verify full graph snapshot bundles");
|
|
73
|
-
log(" graph Clone and
|
|
77
|
+
log(" graph Clone, fork, import, and inspect mdkg graph references");
|
|
74
78
|
log(" subgraph Register, audit, plan, sync, materialize, and verify read-only child graph snapshots");
|
|
75
79
|
log(" work Create and update work contracts, orders, receipts, and artifacts");
|
|
76
80
|
log(" goal Inspect and advance recursive goal nodes");
|
|
@@ -78,6 +82,7 @@ function printUsage(log) {
|
|
|
78
82
|
log(" next Suggest the next work item");
|
|
79
83
|
log(" validate Validate frontmatter + graph");
|
|
80
84
|
log(" status Show read-only operator health summary");
|
|
85
|
+
log(" mcp Serve local read-only MCP tools over stdio");
|
|
81
86
|
log(" fix Plan read-only repairs with receipt-shaped JSON");
|
|
82
87
|
log("\nAdvanced / maintenance commands:");
|
|
83
88
|
log(" db Project database and index-cache commands");
|
|
@@ -233,8 +238,10 @@ function printDbHelp(log, subcommand) {
|
|
|
233
238
|
log(" mdkg db queue stats [queue] [--json]");
|
|
234
239
|
log(" mdkg db queue list <queue> [--status ready|leased|acked|dead_letter|all] [--limit <n>] [--json]");
|
|
235
240
|
log(" mdkg db queue show <queue> <message-id> [--json]");
|
|
241
|
+
log(" mdkg db queue contract [--json]");
|
|
236
242
|
log("\nSemantics:");
|
|
237
243
|
log(" - queues are durable local delivery state, not canonical event history");
|
|
244
|
+
log(" - contract is read-only adapter metadata and does not require an initialized project DB");
|
|
238
245
|
log(" - paused queues reject enqueue and claim");
|
|
239
246
|
log(" - ack, fail, dead-letter, and release-expired are allowed while paused so leased work can settle");
|
|
240
247
|
log(" - no raw SQL or hosted queue dependency is exposed");
|
|
@@ -255,6 +262,7 @@ function printDbHelp(log, subcommand) {
|
|
|
255
262
|
log(" mdkg db queue ack|fail|dead-letter <queue> <message-id> --lease-owner <owner> [--json]");
|
|
256
263
|
log(" mdkg db queue pause|resume <queue> [--json]");
|
|
257
264
|
log(" mdkg db queue stats|list|show ... [--json]");
|
|
265
|
+
log(" mdkg db queue contract [--json]");
|
|
258
266
|
log(" mdkg db snapshot seal [--queue-policy drain|paused] [--json]");
|
|
259
267
|
log(" mdkg db snapshot verify [--json]");
|
|
260
268
|
log(" mdkg db snapshot status [--json]");
|
|
@@ -323,12 +331,14 @@ function printPackHelp(log) {
|
|
|
323
331
|
log(" --list-profiles List built-in pack profiles and exit");
|
|
324
332
|
log("\nAdvanced shaping / debug flags:");
|
|
325
333
|
log(" --depth --edges --strip-code --max-code-lines --max-chars --max-lines --max-tokens");
|
|
334
|
+
log(" --edges accepts parent, epic, relates, blocked_by, blocks, prev, next, context_refs, evidence_refs");
|
|
326
335
|
log(" --truncation-report --stats-out");
|
|
327
336
|
log("\nExamples:");
|
|
328
337
|
log(" mdkg pack --list-profiles");
|
|
329
338
|
log(" mdkg pack task-1");
|
|
330
339
|
log(" mdkg pack task-1 --profile concise --dry-run --stats");
|
|
331
340
|
log(" mdkg pack task-1 --visibility public --dry-run");
|
|
341
|
+
log(" mdkg pack task-1 --edges context_refs,evidence_refs --format json");
|
|
332
342
|
log(" mdkg pack task-1 --skills auto --skills-depth full");
|
|
333
343
|
log(" mdkg pack epic-2 --format json --profile headers");
|
|
334
344
|
printGlobalOptions(log);
|
|
@@ -344,6 +354,19 @@ function printPackProfiles(log) {
|
|
|
344
354
|
}
|
|
345
355
|
}
|
|
346
356
|
}
|
|
357
|
+
function printHandoffHelp(log) {
|
|
358
|
+
log("Usage:");
|
|
359
|
+
log(" mdkg handoff create <id-or-qid> [--ws <alias>] [--depth <n>] [--out <path>] [--json]");
|
|
360
|
+
log("\nPurpose:");
|
|
361
|
+
log(" - create a sanitized, copy-ready agent handoff from mdkg graph context");
|
|
362
|
+
log(" - summarize goal/work state, included pack nodes, latest checkpoint, boundaries, required checks, and next actions");
|
|
363
|
+
log(" - include raw secret, prompt, token, or payload marker warnings without copying raw node bodies into the handoff");
|
|
364
|
+
log(" - use pack traversal with context_refs and evidence_refs for background and proof nodes");
|
|
365
|
+
log("\nBoundaries:");
|
|
366
|
+
log(" - handoff create does not execute work, mutate graph nodes, or generate detailed node content");
|
|
367
|
+
log(" - --out must stay inside the repo root");
|
|
368
|
+
printGlobalOptions(log);
|
|
369
|
+
}
|
|
347
370
|
function printSkillHelp(log, subcommand) {
|
|
348
371
|
switch ((subcommand ?? "").toLowerCase()) {
|
|
349
372
|
case "new":
|
|
@@ -581,16 +604,26 @@ function printGraphHelp(log, subcommand) {
|
|
|
581
604
|
log(" - imports authored .mdkg/work template nodes into the current graph");
|
|
582
605
|
log(" - defaults to dry-run unless --apply is supplied");
|
|
583
606
|
log(" - rewrites canonical numeric IDs and structured graph links deterministically");
|
|
584
|
-
log(" - --select-goal requires --start-goal
|
|
607
|
+
log(" - --select-goal requires --start-goal; on apply it activates the imported start goal, pauses competing active root goals, validates, then writes selected-goal state");
|
|
608
|
+
break;
|
|
609
|
+
case "refs":
|
|
610
|
+
log("Usage:");
|
|
611
|
+
log(" mdkg graph refs <id-or-qid> [--ws <alias>] [--json]");
|
|
612
|
+
log("\nNotes:");
|
|
613
|
+
log(" - read-only summary of inbound and outbound graph references");
|
|
614
|
+
log(" - reports scope_refs, context_refs, evidence_refs, blockers, related refs, and structural links");
|
|
615
|
+
log(" - subgraph qids are inspectable but remain read-only");
|
|
585
616
|
break;
|
|
586
617
|
default:
|
|
587
618
|
log("Usage:");
|
|
588
619
|
log(" mdkg graph clone <source-bundle-or-mdkg-dir> --target <path> [--json]");
|
|
589
620
|
log(" mdkg graph fork <source-bundle-or-mdkg-dir> --target <path> [--start-goal <goal-id>] [--json]");
|
|
590
621
|
log(" mdkg graph import-template <source-bundle-or-mdkg-dir> [--start-goal <goal-id>] [--select-goal] [--id-prefix <prefix>] [--dry-run] [--apply] [--json]");
|
|
622
|
+
log(" mdkg graph refs <id-or-qid> [--ws <alias>] [--json]");
|
|
591
623
|
log("\nNotes:");
|
|
592
624
|
log(" - graph clone/fork create authored graph state in separate target directories and preserve IDs");
|
|
593
625
|
log(" - graph import-template imports template work nodes into the current graph with rewritten IDs");
|
|
626
|
+
log(" - graph refs is read-only and explains local plus subgraph graph relationships");
|
|
594
627
|
log(" - subgraphs remain read-only bundle projections for orchestration context");
|
|
595
628
|
}
|
|
596
629
|
printGlobalOptions(log);
|
|
@@ -712,6 +745,14 @@ function printWorkHelp(log, subcommand) {
|
|
|
712
745
|
log("Usage:");
|
|
713
746
|
log(" mdkg work artifact add <order-or-receipt-id-or-qid> <file> [--id <archive.id>] [--kind source|artifact] [--json]");
|
|
714
747
|
break;
|
|
748
|
+
case "validate":
|
|
749
|
+
log("Usage:");
|
|
750
|
+
log(" mdkg work validate [<id-or-qid>] [--type spec|work|work_order|receipt|feedback|dispute|proposal] [--json]");
|
|
751
|
+
log("\nNotes:");
|
|
752
|
+
log(" Read-only focused validation for agent workflow mirrors.");
|
|
753
|
+
log(" Reports typed diagnostics for SPEC.md, WORK.md, WORK_ORDER.md, RECEIPT.md, FEEDBACK.md, DISPUTE.md, and PROPOSAL.md files.");
|
|
754
|
+
log(" Obvious raw secret, prompt, token, or payload markers are warnings so humans and agents can review boundaries.");
|
|
755
|
+
break;
|
|
715
756
|
default:
|
|
716
757
|
log("Usage:");
|
|
717
758
|
log(" mdkg work contract new ...");
|
|
@@ -719,8 +760,10 @@ function printWorkHelp(log, subcommand) {
|
|
|
719
760
|
log(" mdkg work order new|status|update ...");
|
|
720
761
|
log(" mdkg work receipt new|verify|update ...");
|
|
721
762
|
log(" mdkg work artifact add ...");
|
|
763
|
+
log(" mdkg work validate [<id-or-qid>] [--type <workflow-type>] [--json]");
|
|
722
764
|
log("\nNotes:");
|
|
723
765
|
log(" - work commands mutate semantic mirror files only");
|
|
766
|
+
log(" - work validate is read-only and reports typed workflow diagnostics");
|
|
724
767
|
log(" - production order, receipt, feedback, dispute, payment, ledger, marketplace inventory, fulfillment, and execution state remains canonical outside mdkg");
|
|
725
768
|
log(" - do not store raw secrets, credentials, live payment state, ledger mutations, or canonical marketplace state in work mirrors");
|
|
726
769
|
log(" - artifact:// refs identify external/runtime-managed artifacts; archive:// refs identify committed mdkg archive sidecars");
|
|
@@ -751,7 +794,7 @@ function printTaskHelp(log, subcommand) {
|
|
|
751
794
|
case "done":
|
|
752
795
|
log("Usage:");
|
|
753
796
|
log(' mdkg task done <id-or-qid> [--ws <alias>] [--add-artifacts <a,...>] [--add-links <l,...>]');
|
|
754
|
-
log(' [--add-refs <id,...>] [--checkpoint "<title>"] [--run-id <id>] [--note "<text>"] [--json]');
|
|
797
|
+
log(' [--add-refs <id,...>] [--checkpoint "<title>"] [--checkpoint-kind implementation|test-proof|goal-closeout|audit|handoff] [--run-id <id>] [--note "<text>"] [--json]');
|
|
755
798
|
log("\nWhen to use:");
|
|
756
799
|
log(" Mark a task-like node done, optionally create a checkpoint, and emit a completion event when enabled.");
|
|
757
800
|
log(" Use `--checkpoint` for milestone compression, not every routine task completion.");
|
|
@@ -761,7 +804,7 @@ function printTaskHelp(log, subcommand) {
|
|
|
761
804
|
log("Usage:");
|
|
762
805
|
log(' mdkg task start <id-or-qid> [--ws <alias>] [--run-id <id>] [--note "<text>"] [--json]');
|
|
763
806
|
log(" mdkg task update <id-or-qid> [options] [--json]");
|
|
764
|
-
log(' mdkg task done <id-or-qid> [--checkpoint "<title>"] [options] [--json]');
|
|
807
|
+
log(' mdkg task done <id-or-qid> [--checkpoint "<title>"] [--checkpoint-kind implementation|test-proof|goal-closeout|audit|handoff] [options] [--json]');
|
|
765
808
|
log("\nNotes:");
|
|
766
809
|
log(" `mdkg task ...` only supports feat, task, bug, test, and spike nodes.");
|
|
767
810
|
log(" Spikes use this lifecycle; there is no separate `mdkg spike ...` command family.");
|
|
@@ -775,7 +818,7 @@ function printGoalHelp(log, subcommand) {
|
|
|
775
818
|
log("Usage:");
|
|
776
819
|
log(" mdkg goal show <goal-id-or-qid> [--ws <alias>] [--json]");
|
|
777
820
|
log("\nWhen to use:");
|
|
778
|
-
log(" Inspect a goal condition, current goal state, active node, required skills, and required checks.");
|
|
821
|
+
log(" Inspect a goal condition, current goal state, active node, last active node, required skills, and required checks.");
|
|
779
822
|
printGlobalOptions(log);
|
|
780
823
|
return;
|
|
781
824
|
case "next":
|
|
@@ -844,6 +887,9 @@ function printGoalHelp(log, subcommand) {
|
|
|
844
887
|
log(` mdkg goal ${subcommand} <goal-id-or-qid> [--ws <alias>] [--json]`);
|
|
845
888
|
log("\nWhen to use:");
|
|
846
889
|
log(" Update durable goal state after agent or human review.");
|
|
890
|
+
if (subcommand === "done") {
|
|
891
|
+
log(" Done goals preserve the final active_node as last_active_node and stop routing actionable work.");
|
|
892
|
+
}
|
|
847
893
|
printGlobalOptions(log);
|
|
848
894
|
return;
|
|
849
895
|
default:
|
|
@@ -860,6 +906,7 @@ function printGoalHelp(log, subcommand) {
|
|
|
860
906
|
log("\nNotes:");
|
|
861
907
|
log(" - goals orchestrate recursive progress; features, tasks, bugs, tests, and spikes are iterable work units");
|
|
862
908
|
log(" - `mdkg goal next` is read-only; use `mdkg goal claim` to update active_node");
|
|
909
|
+
log(" - `mdkg goal done` moves active_node to last_active_node so completed goals keep history without staying actionable");
|
|
863
910
|
log(" - `mdkg goal activate` enforces one active local root goal and pauses competing active goals");
|
|
864
911
|
log(" - goal evaluation is report-only and never executes required_checks");
|
|
865
912
|
log(" - subgraph goal qids are read-only; update the source workspace instead");
|
|
@@ -898,13 +945,18 @@ function printNextHelp(log) {
|
|
|
898
945
|
}
|
|
899
946
|
function printCheckpointHelp(log) {
|
|
900
947
|
log("Usage:");
|
|
901
|
-
log(" mdkg checkpoint new <title> [--ws <alias>] [--json]");
|
|
948
|
+
log(" mdkg checkpoint new <title> [--kind implementation|test-proof|goal-closeout|audit|handoff] [--ws <alias>] [--json]");
|
|
949
|
+
log(" Checkpoint bodies include command evidence, pass/fail status, warnings, changed surfaces, boundaries, and follow-up refs.");
|
|
902
950
|
log(' [--relates <id,id,...>] [--scope <id,id,...>] [--run-id <id>] [--note "<text>"]');
|
|
903
951
|
printGlobalOptions(log);
|
|
904
952
|
}
|
|
905
953
|
function printValidateHelp(log) {
|
|
906
954
|
log("Usage:");
|
|
907
|
-
log(" mdkg validate [--out <path>] [--quiet] [--json]");
|
|
955
|
+
log(" mdkg validate [--out <path>] [--quiet] [--changed-only] [--json]");
|
|
956
|
+
log("\nNotes:");
|
|
957
|
+
log(" Validates frontmatter schemas, graph references, visibility, skills, and events.");
|
|
958
|
+
log(" --changed-only filters warning presentation to changed .mdkg files while full graph errors still run.");
|
|
959
|
+
log(" JSON output includes warning_diagnostics with warning ids, categories, severity, paths, refs, and remediation text.");
|
|
908
960
|
printGlobalOptions(log);
|
|
909
961
|
}
|
|
910
962
|
function printStatusHelp(log) {
|
|
@@ -923,6 +975,29 @@ function printStatusHelp(log) {
|
|
|
923
975
|
log(" --json Emit machine-readable JSON output");
|
|
924
976
|
printGlobalOptions(log);
|
|
925
977
|
}
|
|
978
|
+
function printMcpHelp(log, subcommand) {
|
|
979
|
+
switch ((subcommand ?? "").toLowerCase()) {
|
|
980
|
+
case "serve":
|
|
981
|
+
log("Usage:");
|
|
982
|
+
log(" mdkg mcp serve --stdio");
|
|
983
|
+
log("\nBoundary:");
|
|
984
|
+
log(" - starts one local Model Context Protocol server bound to the selected --root");
|
|
985
|
+
log(" - stdio is the only transport in this release; no HTTP listener is opened");
|
|
986
|
+
log(" - exposes read-only tools for status, workspace list, search, show, pack, goal current/next, and validate");
|
|
987
|
+
log(" - exposes no task, goal, graph, queue, event, archive, format, SQL, shell, filesystem, or environment mutation tools");
|
|
988
|
+
log(" - stdout is reserved for newline-delimited JSON-RPC MCP messages");
|
|
989
|
+
printGlobalOptions(log);
|
|
990
|
+
return;
|
|
991
|
+
default:
|
|
992
|
+
log("Usage:");
|
|
993
|
+
log(" mdkg mcp serve --stdio");
|
|
994
|
+
log("\nBoundary:");
|
|
995
|
+
log(" - local read-only MCP server for mdkg graph inspection");
|
|
996
|
+
log(" - use --root <path> to select the mdkg graph explicitly");
|
|
997
|
+
log(" - phase one is stdio-only and does not expose mutation tools");
|
|
998
|
+
printGlobalOptions(log);
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
926
1001
|
function printFixHelp(log, subcommand) {
|
|
927
1002
|
switch ((subcommand ?? "").toLowerCase()) {
|
|
928
1003
|
case "plan":
|
|
@@ -985,6 +1060,10 @@ function printFixHelp(log, subcommand) {
|
|
|
985
1060
|
function printFormatHelp(log) {
|
|
986
1061
|
log("Usage:");
|
|
987
1062
|
log(" mdkg format");
|
|
1063
|
+
log(" mdkg format --headings [--dry-run|--apply] [--json]");
|
|
1064
|
+
log("\nNotes:");
|
|
1065
|
+
log(" Default format normalizes frontmatter in place.");
|
|
1066
|
+
log(" --headings adds missing recommended body headings; it defaults to dry-run and requires --apply to write files.");
|
|
988
1067
|
printGlobalOptions(log);
|
|
989
1068
|
}
|
|
990
1069
|
function printDoctorHelp(log) {
|
|
@@ -1046,6 +1125,9 @@ function printCommandHelp(log, command, subcommand) {
|
|
|
1046
1125
|
case "pack":
|
|
1047
1126
|
printPackHelp(log);
|
|
1048
1127
|
return;
|
|
1128
|
+
case "handoff":
|
|
1129
|
+
printHandoffHelp(log);
|
|
1130
|
+
return;
|
|
1049
1131
|
case "skill":
|
|
1050
1132
|
printSkillHelp(log, subcommand);
|
|
1051
1133
|
return;
|
|
@@ -1091,6 +1173,9 @@ function printCommandHelp(log, command, subcommand) {
|
|
|
1091
1173
|
case "status":
|
|
1092
1174
|
printStatusHelp(log);
|
|
1093
1175
|
return;
|
|
1176
|
+
case "mcp":
|
|
1177
|
+
printMcpHelp(log, subcommand);
|
|
1178
|
+
return;
|
|
1094
1179
|
case "fix":
|
|
1095
1180
|
printFixHelp(log, subcommand);
|
|
1096
1181
|
return;
|
|
@@ -1407,6 +1492,12 @@ function runDbSubcommand(parsed, root) {
|
|
|
1407
1492
|
}
|
|
1408
1493
|
(0, db_1.runDbQueueCreateCommand)(common);
|
|
1409
1494
|
return 0;
|
|
1495
|
+
case "contract":
|
|
1496
|
+
if (parsed.positionals.length > 3) {
|
|
1497
|
+
throw new errors_1.UsageError("mdkg db queue contract accepts no positional arguments");
|
|
1498
|
+
}
|
|
1499
|
+
(0, db_1.runDbQueueContractCommand)(common);
|
|
1500
|
+
return 0;
|
|
1410
1501
|
case "pause":
|
|
1411
1502
|
if (!queueName || parsed.positionals.length > 4) {
|
|
1412
1503
|
throw new errors_1.UsageError("mdkg db queue pause requires <queue>");
|
|
@@ -1474,7 +1565,7 @@ function runDbSubcommand(parsed, root) {
|
|
|
1474
1565
|
(0, db_1.runDbQueueShowCommand)(common);
|
|
1475
1566
|
return 0;
|
|
1476
1567
|
default:
|
|
1477
|
-
throw new errors_1.UsageError("mdkg db queue requires create/pause/resume/enqueue/claim/ack/fail/dead-letter/release-expired/stats/list/show");
|
|
1568
|
+
throw new errors_1.UsageError("mdkg db queue requires create/contract/pause/resume/enqueue/claim/ack/fail/dead-letter/release-expired/stats/list/show");
|
|
1478
1569
|
}
|
|
1479
1570
|
}
|
|
1480
1571
|
case "snapshot": {
|
|
@@ -1770,8 +1861,17 @@ function runGraphSubcommand(parsed, root) {
|
|
|
1770
1861
|
(0, graph_1.runGraphImportTemplateCommand)({ root, source, startGoal, idPrefix, dryRun, apply, selectGoal, json });
|
|
1771
1862
|
return 0;
|
|
1772
1863
|
}
|
|
1864
|
+
case "refs": {
|
|
1865
|
+
const id = parsed.positionals[2];
|
|
1866
|
+
if (!id || parsed.positionals.length > 3) {
|
|
1867
|
+
throw new errors_1.UsageError("graph refs requires <id-or-qid>");
|
|
1868
|
+
}
|
|
1869
|
+
const ws = requireFlagValue("--ws", parsed.flags["--ws"]);
|
|
1870
|
+
(0, graph_1.runGraphRefsCommand)({ root, id, ws, json });
|
|
1871
|
+
return 0;
|
|
1872
|
+
}
|
|
1773
1873
|
default:
|
|
1774
|
-
throw new errors_1.UsageError("graph requires clone/fork/import-template");
|
|
1874
|
+
throw new errors_1.UsageError("graph requires clone/fork/import-template/refs");
|
|
1775
1875
|
}
|
|
1776
1876
|
}
|
|
1777
1877
|
function runSubgraphSubcommand(parsed, root) {
|
|
@@ -1927,6 +2027,15 @@ function runWorkSubcommand(parsed, root) {
|
|
|
1927
2027
|
(0, work_1.runWorkTriggerCommand)({ root, ws, targetRef, id, title, requester, enqueue, json });
|
|
1928
2028
|
return 0;
|
|
1929
2029
|
}
|
|
2030
|
+
if (domain === "validate") {
|
|
2031
|
+
const id = parsed.positionals[2];
|
|
2032
|
+
if (parsed.positionals.length > 3) {
|
|
2033
|
+
throw new errors_1.UsageError("work validate accepts at most one workflow reference");
|
|
2034
|
+
}
|
|
2035
|
+
const type = requireFlagValue("--type", parsed.flags["--type"]);
|
|
2036
|
+
(0, work_1.runWorkValidateCommand)({ root, ws, id, type, json });
|
|
2037
|
+
return 0;
|
|
2038
|
+
}
|
|
1930
2039
|
if (domain === "contract" && action === "new") {
|
|
1931
2040
|
const title = parsed.positionals.slice(3).join(" ");
|
|
1932
2041
|
const id = requireFlagValue("--id", parsed.flags["--id"]);
|
|
@@ -2086,7 +2195,7 @@ function runWorkSubcommand(parsed, root) {
|
|
|
2086
2195
|
(0, work_1.runWorkArtifactAddCommand)({ root, ws, targetId, file, id, kind, json });
|
|
2087
2196
|
return 0;
|
|
2088
2197
|
}
|
|
2089
|
-
throw new errors_1.UsageError("work requires contract new, order new/update, receipt new/update,
|
|
2198
|
+
throw new errors_1.UsageError("work requires contract new, trigger, order new/update/status, receipt new/update/verify, artifact add, or validate");
|
|
2090
2199
|
}
|
|
2091
2200
|
function runSkillSubcommand(parsed, root) {
|
|
2092
2201
|
const subcommand = (parsed.positionals[1] ?? "").toLowerCase();
|
|
@@ -2371,6 +2480,7 @@ function runTaskSubcommand(parsed, root) {
|
|
|
2371
2480
|
const addLinks = requireFlagValue("--add-links", parsed.flags["--add-links"]);
|
|
2372
2481
|
const addRefs = requireFlagValue("--add-refs", parsed.flags["--add-refs"]);
|
|
2373
2482
|
const checkpoint = requireFlagValue("--checkpoint", parsed.flags["--checkpoint"]);
|
|
2483
|
+
const checkpointKind = requireFlagValue("--checkpoint-kind", parsed.flags["--checkpoint-kind"]);
|
|
2374
2484
|
const runId = requireFlagValue("--run-id", parsed.flags["--run-id"]);
|
|
2375
2485
|
const note = requireFlagValue("--note", parsed.flags["--note"]);
|
|
2376
2486
|
const json = parseBooleanFlag("--json", parsed.flags["--json"]);
|
|
@@ -2382,6 +2492,7 @@ function runTaskSubcommand(parsed, root) {
|
|
|
2382
2492
|
addLinks,
|
|
2383
2493
|
addRefs,
|
|
2384
2494
|
checkpoint,
|
|
2495
|
+
checkpointKind,
|
|
2385
2496
|
runId,
|
|
2386
2497
|
note,
|
|
2387
2498
|
json,
|
|
@@ -2720,6 +2831,32 @@ function runCommand(parsed, root, runtime) {
|
|
|
2720
2831
|
});
|
|
2721
2832
|
return 0;
|
|
2722
2833
|
}
|
|
2834
|
+
case "handoff": {
|
|
2835
|
+
const sub = (parsed.positionals[1] ?? "").toLowerCase();
|
|
2836
|
+
if (!sub) {
|
|
2837
|
+
throw new errors_1.UsageError("handoff requires a subcommand");
|
|
2838
|
+
}
|
|
2839
|
+
if (sub !== "create") {
|
|
2840
|
+
throw new errors_1.UsageError(`unknown handoff subcommand: ${sub}`);
|
|
2841
|
+
}
|
|
2842
|
+
const id = parsed.positionals[2];
|
|
2843
|
+
if (!id || parsed.positionals.length > 3) {
|
|
2844
|
+
throw new errors_1.UsageError("mdkg handoff create requires <id-or-qid>");
|
|
2845
|
+
}
|
|
2846
|
+
const ws = requireFlagValue("--ws", parsed.flags["--ws"]);
|
|
2847
|
+
const out = requireFlagValue("--out", parsed.flags["--out"]);
|
|
2848
|
+
const depth = parseNumberFlag("--depth", parsed.flags["--depth"]);
|
|
2849
|
+
const json = parseBooleanFlag("--json", parsed.flags["--json"]);
|
|
2850
|
+
(0, handoff_1.runHandoffCreateCommand)({
|
|
2851
|
+
root,
|
|
2852
|
+
id,
|
|
2853
|
+
ws,
|
|
2854
|
+
out,
|
|
2855
|
+
depth,
|
|
2856
|
+
json,
|
|
2857
|
+
});
|
|
2858
|
+
return 0;
|
|
2859
|
+
}
|
|
2723
2860
|
case "next": {
|
|
2724
2861
|
if (parsed.positionals.length > 2) {
|
|
2725
2862
|
throw new errors_1.UsageError("next accepts at most one id");
|
|
@@ -2749,6 +2886,7 @@ function runCommand(parsed, root, runtime) {
|
|
|
2749
2886
|
const ws = requireFlagValue("--ws", parsed.flags["--ws"]);
|
|
2750
2887
|
const relates = requireFlagValue("--relates", parsed.flags["--relates"]);
|
|
2751
2888
|
const scope = requireFlagValue("--scope", parsed.flags["--scope"]);
|
|
2889
|
+
const kind = requireFlagValue("--kind", parsed.flags["--kind"]);
|
|
2752
2890
|
const status = requireFlagValue("--status", parsed.flags["--status"]);
|
|
2753
2891
|
const priority = parseNumberFlag("--priority", parsed.flags["--priority"]);
|
|
2754
2892
|
const template = requireFlagValue("--template", parsed.flags["--template"]);
|
|
@@ -2761,6 +2899,7 @@ function runCommand(parsed, root, runtime) {
|
|
|
2761
2899
|
ws,
|
|
2762
2900
|
relates,
|
|
2763
2901
|
scope,
|
|
2902
|
+
kind,
|
|
2764
2903
|
status,
|
|
2765
2904
|
priority,
|
|
2766
2905
|
template,
|
|
@@ -2776,8 +2915,9 @@ function runCommand(parsed, root, runtime) {
|
|
|
2776
2915
|
}
|
|
2777
2916
|
const out = requireFlagValue("--out", parsed.flags["--out"]);
|
|
2778
2917
|
const quiet = parseBooleanFlag("--quiet", parsed.flags["--quiet"]);
|
|
2918
|
+
const changedOnly = parseBooleanFlag("--changed-only", parsed.flags["--changed-only"]);
|
|
2779
2919
|
const json = parseBooleanFlag("--json", parsed.flags["--json"]);
|
|
2780
|
-
(0, validate_1.runValidateCommand)({ root, out, quiet, json });
|
|
2920
|
+
(0, validate_1.runValidateCommand)({ root, out, quiet, json, changedOnly });
|
|
2781
2921
|
return 0;
|
|
2782
2922
|
}
|
|
2783
2923
|
case "status": {
|
|
@@ -2788,6 +2928,8 @@ function runCommand(parsed, root, runtime) {
|
|
|
2788
2928
|
(0, status_1.runStatusCommand)({ root, json });
|
|
2789
2929
|
return 0;
|
|
2790
2930
|
}
|
|
2931
|
+
case "mcp":
|
|
2932
|
+
throw new errors_1.UsageError("mcp serve requires the async CLI entrypoint");
|
|
2791
2933
|
case "fix": {
|
|
2792
2934
|
const sub = (parsed.positionals[1] ?? "").toLowerCase();
|
|
2793
2935
|
if (!sub) {
|
|
@@ -2819,7 +2961,17 @@ function runCommand(parsed, root, runtime) {
|
|
|
2819
2961
|
if (parsed.positionals.length > 1) {
|
|
2820
2962
|
throw new errors_1.UsageError("format does not accept positional arguments");
|
|
2821
2963
|
}
|
|
2822
|
-
(
|
|
2964
|
+
const headings = parseBooleanFlag("--headings", parsed.flags["--headings"]);
|
|
2965
|
+
const dryRun = parseBooleanFlag("--dry-run", parsed.flags["--dry-run"]);
|
|
2966
|
+
const apply = parseBooleanFlag("--apply", parsed.flags["--apply"]);
|
|
2967
|
+
const json = parseBooleanFlag("--json", parsed.flags["--json"]);
|
|
2968
|
+
if (!headings && (dryRun || apply || json)) {
|
|
2969
|
+
throw new errors_1.UsageError("format --dry-run, --apply, and --json require --headings");
|
|
2970
|
+
}
|
|
2971
|
+
if (dryRun && apply) {
|
|
2972
|
+
throw new errors_1.UsageError("format --headings cannot use --dry-run and --apply together");
|
|
2973
|
+
}
|
|
2974
|
+
(0, format_1.runFormatCommand)({ root, headings, dryRun, apply, json });
|
|
2823
2975
|
return 0;
|
|
2824
2976
|
case "doctor": {
|
|
2825
2977
|
if (parsed.positionals.length > 1) {
|
|
@@ -2838,6 +2990,18 @@ function runCommand(parsed, root, runtime) {
|
|
|
2838
2990
|
return 1;
|
|
2839
2991
|
}
|
|
2840
2992
|
}
|
|
2993
|
+
async function runMcpSubcommand(parsed, root) {
|
|
2994
|
+
const sub = (parsed.positionals[1] ?? "").toLowerCase();
|
|
2995
|
+
if (sub !== "serve") {
|
|
2996
|
+
throw new errors_1.UsageError("mcp requires serve --stdio");
|
|
2997
|
+
}
|
|
2998
|
+
if (parsed.positionals.length > 2) {
|
|
2999
|
+
throw new errors_1.UsageError("mcp serve does not accept positional arguments");
|
|
3000
|
+
}
|
|
3001
|
+
const stdio = parseBooleanFlag("--stdio", parsed.flags["--stdio"]);
|
|
3002
|
+
await (0, mcp_1.runMcpServeCommand)({ root, stdio });
|
|
3003
|
+
return 0;
|
|
3004
|
+
}
|
|
2841
3005
|
function runCli(argv, runtime = {}) {
|
|
2842
3006
|
const io = resolveRuntime(runtime);
|
|
2843
3007
|
const parsed = (0, argparse_1.parseArgs)(argv);
|
|
@@ -2875,8 +3039,53 @@ function runCli(argv, runtime = {}) {
|
|
|
2875
3039
|
return handleCommandError(err, command, io);
|
|
2876
3040
|
}
|
|
2877
3041
|
}
|
|
3042
|
+
async function runCliAsync(argv, runtime = {}) {
|
|
3043
|
+
const io = resolveRuntime(runtime);
|
|
3044
|
+
const parsed = (0, argparse_1.parseArgs)(argv);
|
|
3045
|
+
if (parsed.error) {
|
|
3046
|
+
io.error(parsed.error);
|
|
3047
|
+
printUsage(io.log);
|
|
3048
|
+
return 1;
|
|
3049
|
+
}
|
|
3050
|
+
if (parsed.help) {
|
|
3051
|
+
printCommandHelp(io.log, parsed.positionals[0], parsed.positionals[1]);
|
|
3052
|
+
return 0;
|
|
3053
|
+
}
|
|
3054
|
+
if (parsed.version) {
|
|
3055
|
+
io.log(readPackageVersion());
|
|
3056
|
+
return 0;
|
|
3057
|
+
}
|
|
3058
|
+
const command = (parsed.positionals[0] ?? "").toLowerCase();
|
|
3059
|
+
if (!command) {
|
|
3060
|
+
printUsage(io.log);
|
|
3061
|
+
return 0;
|
|
3062
|
+
}
|
|
3063
|
+
if (command === "help") {
|
|
3064
|
+
printCommandHelp(io.log, parsed.positionals[1], parsed.positionals[2]);
|
|
3065
|
+
return 0;
|
|
3066
|
+
}
|
|
3067
|
+
const root = parsed.root ? path_1.default.resolve(parsed.root) : io.cwd();
|
|
3068
|
+
if (shouldRequireConfig(command, parsed.flags) && !hasConfig(root)) {
|
|
3069
|
+
printRootError(io.error, root);
|
|
3070
|
+
return 1;
|
|
3071
|
+
}
|
|
3072
|
+
try {
|
|
3073
|
+
if (command === "mcp") {
|
|
3074
|
+
return await runMcpSubcommand(parsed, root);
|
|
3075
|
+
}
|
|
3076
|
+
return runCommand(parsed, root, io);
|
|
3077
|
+
}
|
|
3078
|
+
catch (err) {
|
|
3079
|
+
return handleCommandError(err, command, io);
|
|
3080
|
+
}
|
|
3081
|
+
}
|
|
2878
3082
|
function main(argv = process.argv.slice(2)) {
|
|
2879
|
-
|
|
3083
|
+
runCliAsync(argv, { cwd: () => process.cwd() })
|
|
3084
|
+
.then((code) => process.exit(code))
|
|
3085
|
+
.catch((err) => {
|
|
3086
|
+
console.error(err instanceof Error ? err.message : String(err));
|
|
3087
|
+
process.exit(4);
|
|
3088
|
+
});
|
|
2880
3089
|
}
|
|
2881
3090
|
if (require.main === module) {
|
|
2882
3091
|
main();
|