mdkg 0.3.3 → 0.3.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/CHANGELOG.md CHANGED
@@ -12,6 +12,86 @@ mdkg is pre-v1 public alpha software. Command, graph, cache, bundle, and DAL con
12
12
 
13
13
  - No changes yet.
14
14
 
15
+ ## 0.3.5 - 2026-06-17
16
+
17
+ ### Added
18
+
19
+ - Added `mdkg graph clone <source> --target <path>` to create a complete
20
+ authored mdkg graph in a separate contained target directory while preserving
21
+ source IDs.
22
+ - Added `mdkg graph fork <source> --target <path> --start-goal <goal-id>` to
23
+ preserve IDs in a separate target graph and optionally select the demo or
24
+ bootstrap start goal in that target.
25
+ - Added `mdkg graph import-template <source> --dry-run|--apply` for same-repo
26
+ template graph imports with deterministic canonical ID rewrites, structured
27
+ reference rewrites, safe body ID/qid rewrites, and optional selected-goal
28
+ setup.
29
+ - Added packed `smoke:graph-clone` coverage that installs mdkg from a tarball
30
+ in a temp prefix and validates clone, fork, import-template dry-run/apply,
31
+ source non-mutation, help text, search, pack, and validation behavior.
32
+
33
+ ### Changed
34
+
35
+ - Updated README, seeded init README, command matrix, help snapshots,
36
+ prepublish gates, and publish-readiness assertions to document the
37
+ distinction between authored graph creation through `mdkg graph ...` and
38
+ read-only orchestration context through `mdkg subgraph ...`.
39
+ - Added `smoke:graph-clone` to `prepublishOnly` before the existing subgraph
40
+ smoke so graph template import behavior is proven before release.
41
+ - Consolidated website-template-mdkg dogfood planning under the 0.3.5 graph
42
+ clone/import goal without mutating downstream repositories or starting
43
+ website implementation.
44
+
45
+ ### Security
46
+
47
+ - Clone/fork targets must be empty or absent, root-contained, and not nested
48
+ inside live directory sources.
49
+ - Same-repo template imports default to dry-run, require `--apply` to write,
50
+ run under the mdkg mutation lock, rebuild generated indexes, and validate the
51
+ resulting graph before selecting a start goal.
52
+ - Semantic ID collisions during template import require an explicit
53
+ `--id-prefix`; numeric canonical IDs are rewritten to the next unused ID so
54
+ links remain deterministic.
55
+
56
+ ## 0.3.4 - 2026-06-17
57
+
58
+ ### Added
59
+
60
+ - Added IDs-family repair apply support with `mdkg fix apply --family ids`
61
+ and the focused `mdkg fix ids [--apply]` convenience command.
62
+ - Added `--base-ref` support for duplicate-ID repair planning so mainline IDs
63
+ can be preserved while incoming duplicate nodes receive the next unused
64
+ canonical numeric ID.
65
+ - Added unresolved Git add/add conflict-stage repair for mdkg Markdown files:
66
+ stage 2 remains at the conflicted path, stage 3 is rewritten to a new
67
+ canonical ID/path, and the Git index conflict stages are resolved with a
68
+ receipt.
69
+ - Added packed `smoke:id-repair` coverage that installs mdkg from a tarball in
70
+ a temp prefix, validates clean duplicate repair, base-ref link preservation,
71
+ unresolved Git conflict-stage repair, and final graph validation.
72
+
73
+ ### Changed
74
+
75
+ - Updated `mdkg fix plan` receipts so duplicate-ID findings advertise
76
+ `apply_supported: true` with an explicit `apply_kind`, while index/cache and
77
+ graph-reference findings remain review-only.
78
+ - Updated command help, README, init assets, command matrix, generated command
79
+ contract metadata, and publish-readiness assertions to document the new
80
+ IDs-only apply boundary.
81
+ - Updated branch-conflict and fix-plan smokes to distinguish non-mutating plan
82
+ behavior from the newly apply-capable duplicate-ID repair family.
83
+
84
+ ### Security
85
+
86
+ - `fix apply` refuses unsupported families, blocked plans, and non-IDs repair
87
+ findings instead of silently applying partial graph/reference/index repairs.
88
+ - Duplicate-ID apply writes Markdown atomically under the mdkg mutation lock,
89
+ rebuilds derived indexes, and emits receipt evidence with touched paths,
90
+ source plan hash, and ambiguous reference notes.
91
+ - Base-ref link rewriting is conservative: references in files absent from the
92
+ base ref can be rewritten to the repaired incoming ID, while base-existing
93
+ references remain on the mainline ID and ambiguous references are reported.
94
+
15
95
  ## 0.3.3 - 2026-06-16
16
96
 
17
97
  ### Added
@@ -1,7 +1,7 @@
1
1
  # CLI Command Matrix
2
2
 
3
- as_of: 2026-06-06
4
- package_version_in_source: 0.3.1
3
+ as_of: 2026-06-17
4
+ package_version_in_source: 0.3.5
5
5
  source: live help from `src/cli.ts`, runtime command handlers, and `dec-15`..`dec-18`
6
6
  status: canonical single-source command and flag reference for mdkg
7
7
 
@@ -28,6 +28,7 @@ Primary commands:
28
28
  - `spec`
29
29
  - `archive`
30
30
  - `bundle`
31
+ - `graph`
31
32
  - `subgraph`
32
33
  - `work`
33
34
  - `goal`
@@ -55,13 +56,14 @@ Capability cache discovery is read-only and accessed through `mdkg capability ..
55
56
  Optional reusable SPEC capability records are accessed through `mdkg spec ...`.
56
57
  Archive sidecars are accessed through `mdkg archive ...`.
57
58
  Full graph snapshot bundles are accessed through `mdkg bundle ...`.
59
+ Whole-graph clone, fork, and same-repo template import workflows are accessed through `mdkg graph ...`.
58
60
  Read-only child graph orchestration is accessed through `mdkg subgraph ...`.
59
61
  Work contract/order/receipt semantic mirrors are accessed through `mdkg work ...`.
60
62
  Recursive long-running objective contracts are accessed through `mdkg goal ...`.
61
63
  Fresh init workspaces default to the SQLite access cache backend; existing migrated configs stay on JSON until opted in.
62
64
  Project application database foundation commands are accessed through `mdkg db ...`; `mdkg index` remains the compatibility shortcut for graph index rebuilds.
63
65
  Operator health summaries are accessed through read-only `mdkg status ...`; deeper diagnostics remain under `mdkg doctor ...`.
64
- Repair planning is accessed through read-only `mdkg fix plan ...`; apply behavior is intentionally deferred.
66
+ Repair planning is accessed through read-only `mdkg fix plan ...`; duplicate-ID graph repairs can be applied through `mdkg fix apply --family ids ...` or the convenience `mdkg fix ids --apply ...`. Index/cache and graph-reference findings remain plan/manual-review only.
65
67
 
66
68
  ## Global usage
67
69
 
@@ -615,6 +617,44 @@ JSON receipts:
615
617
  - `show`: `{ action: "show", bundle, manifest }`
616
618
  - `list`: `{ action: "list", count, items }`
617
619
 
620
+ ### `mdkg graph`
621
+
622
+ When to use:
623
+ - clone or fork a complete mdkg graph into a separate target directory while preserving IDs
624
+ - import a template graph into the current repo with deterministic ID/link rewrites
625
+ - prepare selected-goal demo handoffs from reusable graph templates
626
+
627
+ Usage:
628
+ - `mdkg graph clone <source-bundle-or-mdkg-dir> --target <path> [--json]`
629
+ - `mdkg graph fork <source-bundle-or-mdkg-dir> --target <path> [--start-goal <goal-id>] [--json]`
630
+ - `mdkg graph import-template <source-bundle-or-mdkg-dir> [--start-goal <goal-id>] [--select-goal] [--id-prefix <prefix>] [--dry-run] [--apply] [--json]`
631
+
632
+ Flags:
633
+ - `--target <path>`
634
+ - `--start-goal <goal-id>`
635
+ - `--select-goal`
636
+ - `--id-prefix <prefix>`
637
+ - `--dry-run`
638
+ - `--apply`
639
+ - `--json`
640
+
641
+ Notes:
642
+ - `graph clone` and `graph fork` preserve IDs because the target is a separate graph namespace
643
+ - clone/fork targets must be empty or absent and stay under the current mdkg root
644
+ - live directory sources are never mutated; clone/fork refuses targets nested inside a live source directory
645
+ - `graph fork --start-goal <goal-id>` writes selected-goal state in the target graph after validation
646
+ - `graph import-template` imports authored `.mdkg/work/*.md` template nodes into the current repo and skips config, generated indexes, archive payloads, bundles, and materialized subgraph views
647
+ - `graph import-template` defaults to dry-run unless `--apply` is supplied
648
+ - same-repo template import rewrites canonical numeric IDs to the next unused ID by type prefix and rewrites structured refs plus safe body-local id/qid mentions
649
+ - colliding semantic template IDs require `--id-prefix`
650
+ - `--select-goal` requires `--start-goal` and writes selected-goal state only after apply validation
651
+ - subgraphs remain read-only bundle projections for orchestration context; use `graph clone|fork|import-template` when authored graph state should be created
652
+
653
+ JSON receipts:
654
+ - `clone`: `{ action: "graph.clone", ok, mode, source, target, source_hash, preserved_ids, files_written, skipped_paths, index, validation, warnings }`
655
+ - `fork`: `{ action: "graph.fork", ok, mode, source, target, source_hash, preserved_ids, files_written, skipped_paths, start_goal?, selected_goal?, index, validation, warnings }`
656
+ - `import-template`: `{ action: "graph.import_template", ok, mode, source, source_hash, preserved_ids: false, rewritten_ids, rewritten_refs, planned_paths, files_written, skipped_paths, start_goal?, selected_goal?, index?, validation?, warnings }`
657
+
618
658
  ### `mdkg subgraph`
619
659
 
620
660
  When to use:
@@ -1049,27 +1089,38 @@ JSON receipt shape:
1049
1089
  ### `mdkg fix`
1050
1090
 
1051
1091
  When to use:
1052
- - plan reviewable graph/index repairs before any apply command exists
1092
+ - plan reviewable graph/index repairs before applying supported duplicate-ID rewrites
1053
1093
  - get a receipt-shaped JSON plan for automation and agent review
1094
+ - repair branch-merge duplicate IDs while preserving main/base IDs where possible
1054
1095
 
1055
1096
  Usage:
1056
- - `mdkg fix plan [--family index|refs|ids|all] [--target <id-or-qid>] [--json]`
1097
+ - `mdkg fix plan [--family index|refs|ids|all] [--target <id-or-qid>] [--base-ref <ref>] [--json]`
1098
+ - `mdkg fix apply [--family ids] [--target <id-or-qid>] [--base-ref <ref>] [--json]`
1099
+ - `mdkg fix ids [--target <id-or-qid>] [--base-ref <ref>] [--apply] [--json]`
1057
1100
 
1058
1101
  Flags:
1059
1102
  - `--family <family>`
1060
1103
  - `--target <id-or-qid>`
1104
+ - `--base-ref <ref>`
1105
+ - `--apply`
1061
1106
  - `--json`
1062
1107
 
1063
1108
  Boundaries:
1064
- - dry-run only and writes nothing
1065
- - does not rebuild indexes, edit graph files, rename ids, or update references
1066
- - `fix apply` is intentionally not available in the first repair-planning slice
1109
+ - `fix plan` is dry-run only and writes nothing
1110
+ - `fix apply` currently supports only IDs-family duplicate-ID graph rewrites
1111
+ - `fix ids` without `--apply` is equivalent to `fix plan --family ids`
1112
+ - `fix ids --apply` is equivalent to `fix apply --family ids`
1113
+ - apply rewrites graph Markdown atomically, rebuilds derived indexes, and emits a receipt
1114
+ - unresolved Git add/add conflict stages are handled by keeping stage 2 at the conflicted path and writing stage 3 to a new canonical ID/path
1115
+ - graph-reference and index/cache findings remain review-only guidance
1067
1116
  - initial families are index/cache, graph refs, and duplicate ids
1068
1117
 
1069
1118
  JSON receipt:
1070
1119
  - `{ action: "fix.plan", ok, schema_version, plan_id, plan_hash, generated_at, root, family, target, dirty, families, risk_counts, proposed_changes, blocked_changes, summary }`
1071
- - each proposed change includes family, risk, status, reason, paths, refs, optional before/after values, command hint, and `apply_supported: false`
1072
- - `summary.apply_deferred` remains true until a future apply design is approved
1120
+ - each proposed change includes family, risk, status, reason, paths, refs, optional before/after values, command hint, and `apply_supported`
1121
+ - duplicate-ID changes include candidate ID/path details and `apply_kind`
1122
+ - `{ action: "fix.apply", ok, schema_version, receipt_hash, root, family, target, base_ref, plan_id, plan_hash, applied_changes, touched_paths, ambiguous_reference_rewrites, index, summary }`
1123
+ - `summary.apply_deferred` remains true when the selected plan includes index/cache, graph-ref, blocked, or otherwise unsupported findings
1073
1124
 
1074
1125
  ### `mdkg doctor`
1075
1126
 
package/README.md CHANGED
@@ -14,7 +14,7 @@ mdkg stays deliberately boring:
14
14
  - first-class rebuildable SQLite cache through built-in `node:sqlite`
15
15
  - no daemon, hosted index, or vector DB
16
16
 
17
- Current package version in source: `0.3.1`
17
+ Current package version in source: `0.3.5`
18
18
 
19
19
  mdkg is still pre-v1 public alpha software. The public package is usable, but graph, cache, bundle, and DAL contracts may continue to change quickly while the project converges on a stable v1 surface.
20
20
 
@@ -150,6 +150,27 @@ mdkg bundle list --json
150
150
 
151
151
  Bundles are explicit graph transport artifacts, separate from task context packs. Before a commit in repos that track archives or bundles, refresh compressed archive caches first, then create the private bundle so the committed graph state is self-consistent. Private bundles are the default and may be committed in private repos when configured. Public bundles require at least one selected workspace with `visibility: public` and include only public workspace content and public archive sidecars; bundle creation fails if public content points at private graph, archive, or subgraph records.
152
152
 
153
+ Clone or fork a reusable graph template into a separate target when the target
154
+ should preserve IDs as its own graph namespace:
155
+
156
+ ```bash
157
+ mdkg graph clone .mdkg/bundles/private/all.mdkg.zip --target demos/demo-1 --json
158
+ mdkg graph fork templates/website-template-mdkg --target demos/live-build --start-goal goal-1 --json
159
+ ```
160
+
161
+ Import a template graph into the current repo only through the rewritten-ID
162
+ path. Review the dry-run receipt first, then apply explicitly:
163
+
164
+ ```bash
165
+ mdkg graph import-template templates/website-template-mdkg --start-goal goal-1 --select-goal --dry-run --json
166
+ mdkg graph import-template templates/website-template-mdkg --start-goal goal-1 --select-goal --apply --json
167
+ ```
168
+
169
+ `graph clone` and `graph fork` preserve IDs; `graph import-template` rewrites
170
+ canonical numeric IDs and internal links to avoid same-repo collisions. Subgraphs
171
+ remain read-only planning views; use `mdkg graph ...` when authored graph state
172
+ should be created.
173
+
153
174
  Register a child repo bundle as a read-only subgraph planning view:
154
175
 
155
176
  ```bash
@@ -341,9 +362,13 @@ warnings unless their underlying check fails.
341
362
  Use `mdkg fix plan --json` when you want repair guidance without mutation. It
342
363
  emits a receipt-shaped plan for generated index/cache repair, missing graph
343
364
  references, and duplicate local ids. Planned changes include affected paths,
344
- risk, reason codes, command hints, and `apply_supported: false`. `fix apply` is
345
- not exposed; apply behavior is deferred until the dry-run plan contract has
346
- enough evidence.
365
+ risk, reason codes, command hints, and per-change `apply_supported` metadata.
366
+ Duplicate-ID graph repairs can be applied with
367
+ `mdkg fix apply --family ids --json` or `mdkg fix ids --apply --json`; use
368
+ `--base-ref main` when mainline IDs should win. Index/cache and graph-reference
369
+ findings remain review-only. For unresolved Git add/add conflicts, `fix ids`
370
+ keeps stage 2 at the conflicted path, rewrites stage 3 to the next unused
371
+ canonical ID/path, and records a receipt.
347
372
 
348
373
  ## Skills
349
374
 
package/dist/cli.js CHANGED
@@ -25,6 +25,7 @@ const capability_1 = require("./commands/capability");
25
25
  const spec_1 = require("./commands/spec");
26
26
  const archive_1 = require("./commands/archive");
27
27
  const bundle_1 = require("./commands/bundle");
28
+ const graph_1 = require("./commands/graph");
28
29
  const subgraph_1 = require("./commands/subgraph");
29
30
  const checkpoint_1 = require("./commands/checkpoint");
30
31
  const init_1 = require("./commands/init");
@@ -69,6 +70,7 @@ function printUsage(log) {
69
70
  log(" spec List, show, and validate optional SPEC.md capability records");
70
71
  log(" archive Add, list, show, verify, and compress archive sidecars");
71
72
  log(" bundle Create, list, show, and verify full graph snapshot bundles");
73
+ log(" graph Clone and fork whole mdkg graphs");
72
74
  log(" subgraph Register, audit, plan, sync, materialize, and verify read-only child graph snapshots");
73
75
  log(" work Create and update work contracts, orders, receipts, and artifacts");
74
76
  log(" goal Inspect and advance recursive goal nodes");
@@ -554,6 +556,45 @@ function printBundleHelp(log, subcommand) {
554
556
  }
555
557
  printGlobalOptions(log);
556
558
  }
559
+ function printGraphHelp(log, subcommand) {
560
+ switch ((subcommand ?? "").toLowerCase()) {
561
+ case "clone":
562
+ log("Usage:");
563
+ log(" mdkg graph clone <source-bundle-or-mdkg-dir> --target <path> [--json]");
564
+ log("\nNotes:");
565
+ log(" - clones a complete graph into an empty contained target directory");
566
+ log(" - preserves IDs because the target is a separate graph namespace");
567
+ log(" - source bundle or source directory is never mutated");
568
+ break;
569
+ case "fork":
570
+ log("Usage:");
571
+ log(" mdkg graph fork <source-bundle-or-mdkg-dir> --target <path> [--start-goal <goal-id>] [--json]");
572
+ log("\nNotes:");
573
+ log(" - forks a complete graph into an empty contained target directory");
574
+ log(" - preserves IDs and can select a start goal in the target graph");
575
+ log(" - source bundle or source directory is never mutated");
576
+ break;
577
+ case "import-template":
578
+ log("Usage:");
579
+ log(" mdkg graph import-template <source-bundle-or-mdkg-dir> [--start-goal <goal-id>] [--select-goal] [--id-prefix <prefix>] [--dry-run] [--apply] [--json]");
580
+ log("\nNotes:");
581
+ log(" - imports authored .mdkg/work template nodes into the current graph");
582
+ log(" - defaults to dry-run unless --apply is supplied");
583
+ log(" - rewrites canonical numeric IDs and structured graph links deterministically");
584
+ log(" - --select-goal requires --start-goal and writes selected-goal state only after apply validation");
585
+ break;
586
+ default:
587
+ log("Usage:");
588
+ log(" mdkg graph clone <source-bundle-or-mdkg-dir> --target <path> [--json]");
589
+ log(" mdkg graph fork <source-bundle-or-mdkg-dir> --target <path> [--start-goal <goal-id>] [--json]");
590
+ log(" mdkg graph import-template <source-bundle-or-mdkg-dir> [--start-goal <goal-id>] [--select-goal] [--id-prefix <prefix>] [--dry-run] [--apply] [--json]");
591
+ log("\nNotes:");
592
+ log(" - graph clone/fork create authored graph state in separate target directories and preserve IDs");
593
+ log(" - graph import-template imports template work nodes into the current graph with rewritten IDs");
594
+ log(" - subgraphs remain read-only bundle projections for orchestration context");
595
+ }
596
+ printGlobalOptions(log);
597
+ }
557
598
  function printSubgraphHelp(log, subcommand) {
558
599
  switch ((subcommand ?? "").toLowerCase()) {
559
600
  case "add":
@@ -886,24 +927,58 @@ function printFixHelp(log, subcommand) {
886
927
  switch ((subcommand ?? "").toLowerCase()) {
887
928
  case "plan":
888
929
  log("Usage:");
889
- log(" mdkg fix plan [--family index|refs|ids|all] [--target <id-or-qid>] [--json]");
930
+ log(" mdkg fix plan [--family index|refs|ids|all] [--target <id-or-qid>] [--base-ref <ref>] [--json]");
890
931
  log("\nBoundaries:");
891
932
  log(" - read-only repair planning; writes no files and does not rebuild indexes");
892
933
  log(" - emits a deterministic receipt-shaped JSON plan with paths, risks, and reason codes");
893
934
  log(" - initial families are index/cache, graph refs, and duplicate ids");
894
- log(" - `fix apply` is intentionally not available in this release slice");
935
+ log(" - ids-family duplicate-id repairs can be applied with `mdkg fix apply --family ids`");
936
+ log(" - index/cache and graph-ref findings remain review-only guidance");
895
937
  log("\nOptions:");
896
938
  log(" --family <family> Select index, refs, ids, or all (default all)");
897
939
  log(" --target <id-or-qid> Optional node target for family planners");
940
+ log(" --base-ref <ref> Prefer IDs that already exist at a Git base ref");
941
+ log(" --json Emit machine-readable JSON output");
942
+ printGlobalOptions(log);
943
+ return;
944
+ case "apply":
945
+ log("Usage:");
946
+ log(" mdkg fix apply [--family ids] [--target <id-or-qid>] [--base-ref <ref>] [--json]");
947
+ log("\nBoundaries:");
948
+ log(" - applies only supported ids-family duplicate-ID rewrites");
949
+ log(" - refuses index/cache, graph-ref, all-family, blocked, and unsupported repairs");
950
+ log(" - writes graph Markdown atomically and rebuilds derived indexes");
951
+ log(" - emits a receipt with plan hash, touched paths, and manual-review reference notes");
952
+ log("\nOptions:");
953
+ log(" --family ids Explicit apply family; ids is the only supported apply family");
954
+ log(" --target <id-or-qid> Optional duplicate ID target");
955
+ log(" --base-ref <ref> Prefer IDs that already exist at a Git base ref");
956
+ log(" --json Emit machine-readable JSON output");
957
+ printGlobalOptions(log);
958
+ return;
959
+ case "ids":
960
+ log("Usage:");
961
+ log(" mdkg fix ids [--target <id-or-qid>] [--base-ref <ref>] [--apply] [--json]");
962
+ log("\nBoundaries:");
963
+ log(" - convenience command for duplicate-ID planning and application");
964
+ log(" - without --apply it is equivalent to `mdkg fix plan --family ids`");
965
+ log(" - with --apply it is equivalent to `mdkg fix apply --family ids`");
966
+ log("\nOptions:");
967
+ log(" --target <id-or-qid> Optional duplicate ID target");
968
+ log(" --base-ref <ref> Prefer IDs that already exist at a Git base ref");
969
+ log(" --apply Apply supported duplicate-ID rewrites");
898
970
  log(" --json Emit machine-readable JSON output");
899
971
  printGlobalOptions(log);
900
972
  return;
901
973
  default:
902
974
  log("Usage:");
903
- log(" mdkg fix plan [--family index|refs|ids|all] [--target <id-or-qid>] [--json]");
975
+ log(" mdkg fix plan [--family index|refs|ids|all] [--target <id-or-qid>] [--base-ref <ref>] [--json]");
976
+ log(" mdkg fix apply [--family ids] [--target <id-or-qid>] [--base-ref <ref>] [--json]");
977
+ log(" mdkg fix ids [--target <id-or-qid>] [--base-ref <ref>] [--apply] [--json]");
904
978
  log("\nNotes:");
905
- log(" - fix planning is dry-run only and writes nothing");
906
- log(" - apply behavior is deferred until the receipt contract is proven");
979
+ log(" - fix plan is dry-run only and writes nothing");
980
+ log(" - fix apply is limited to duplicate-ID graph repairs with receipt evidence");
981
+ log(" - index/cache and graph-ref repairs remain plan/manual-review only");
907
982
  printGlobalOptions(log);
908
983
  }
909
984
  }
@@ -986,6 +1061,9 @@ function printCommandHelp(log, command, subcommand) {
986
1061
  case "bundle":
987
1062
  printBundleHelp(log, subcommand);
988
1063
  return;
1064
+ case "graph":
1065
+ printGraphHelp(log, subcommand);
1066
+ return;
989
1067
  case "subgraph":
990
1068
  printSubgraphHelp(log, subcommand);
991
1069
  return;
@@ -1653,6 +1731,49 @@ function runBundleSubcommand(parsed, root) {
1653
1731
  throw new errors_1.UsageError("bundle requires create/list/show/verify");
1654
1732
  }
1655
1733
  }
1734
+ function runGraphSubcommand(parsed, root) {
1735
+ const subcommand = (parsed.positionals[1] ?? "").toLowerCase();
1736
+ const source = parsed.positionals[2];
1737
+ const target = requireFlagValue("--target", parsed.flags["--target"]);
1738
+ const json = parseBooleanFlag("--json", parsed.flags["--json"]);
1739
+ switch (subcommand) {
1740
+ case "clone": {
1741
+ if (!source || parsed.positionals.length > 3) {
1742
+ throw new errors_1.UsageError("graph clone requires <source-bundle-or-mdkg-dir>");
1743
+ }
1744
+ if (!target) {
1745
+ throw new errors_1.UsageError("graph clone requires --target <path>");
1746
+ }
1747
+ (0, graph_1.runGraphCloneCommand)({ root, source, target, json });
1748
+ return 0;
1749
+ }
1750
+ case "fork": {
1751
+ if (!source || parsed.positionals.length > 3) {
1752
+ throw new errors_1.UsageError("graph fork requires <source-bundle-or-mdkg-dir>");
1753
+ }
1754
+ if (!target) {
1755
+ throw new errors_1.UsageError("graph fork requires --target <path>");
1756
+ }
1757
+ const startGoal = requireFlagValue("--start-goal", parsed.flags["--start-goal"]);
1758
+ (0, graph_1.runGraphForkCommand)({ root, source, target, startGoal, json });
1759
+ return 0;
1760
+ }
1761
+ case "import-template": {
1762
+ if (!source || parsed.positionals.length > 3) {
1763
+ throw new errors_1.UsageError("graph import-template requires <source-bundle-or-mdkg-dir>");
1764
+ }
1765
+ const startGoal = requireFlagValue("--start-goal", parsed.flags["--start-goal"]);
1766
+ const idPrefix = requireFlagValue("--id-prefix", parsed.flags["--id-prefix"]);
1767
+ const dryRun = parseBooleanFlag("--dry-run", parsed.flags["--dry-run"]);
1768
+ const apply = parseBooleanFlag("--apply", parsed.flags["--apply"]);
1769
+ const selectGoal = parseBooleanFlag("--select-goal", parsed.flags["--select-goal"]);
1770
+ (0, graph_1.runGraphImportTemplateCommand)({ root, source, startGoal, idPrefix, dryRun, apply, selectGoal, json });
1771
+ return 0;
1772
+ }
1773
+ default:
1774
+ throw new errors_1.UsageError("graph requires clone/fork/import-template");
1775
+ }
1776
+ }
1656
1777
  function runSubgraphSubcommand(parsed, root) {
1657
1778
  const subcommand = (parsed.positionals[1] ?? "").toLowerCase();
1658
1779
  const json = parseBooleanFlag("--json", parsed.flags["--json"]);
@@ -2445,6 +2566,8 @@ function runCommand(parsed, root, runtime) {
2445
2566
  return runArchiveSubcommand(parsed, root);
2446
2567
  case "bundle":
2447
2568
  return runBundleSubcommand(parsed, root);
2569
+ case "graph":
2570
+ return runGraphSubcommand(parsed, root);
2448
2571
  case "subgraph":
2449
2572
  return runSubgraphSubcommand(parsed, root);
2450
2573
  case "work":
@@ -2670,16 +2793,26 @@ function runCommand(parsed, root, runtime) {
2670
2793
  if (!sub) {
2671
2794
  throw new errors_1.UsageError("fix requires a subcommand");
2672
2795
  }
2673
- if (sub !== "plan") {
2796
+ if (!["plan", "apply", "ids"].includes(sub)) {
2674
2797
  throw new errors_1.UsageError(`unknown fix subcommand: ${sub}`);
2675
2798
  }
2676
2799
  if (parsed.positionals.length > 2) {
2677
- throw new errors_1.UsageError("fix plan does not accept positional arguments");
2800
+ throw new errors_1.UsageError(`fix ${sub} does not accept positional arguments`);
2678
2801
  }
2679
2802
  const family = requireFlagValue("--family", parsed.flags["--family"]);
2680
2803
  const target = requireFlagValue("--target", parsed.flags["--target"]);
2804
+ const baseRef = requireFlagValue("--base-ref", parsed.flags["--base-ref"]);
2681
2805
  const json = parseBooleanFlag("--json", parsed.flags["--json"]);
2682
- (0, fix_1.runFixPlanCommand)({ root, family, target, json });
2806
+ if (sub === "plan") {
2807
+ (0, fix_1.runFixPlanCommand)({ root, family, target, baseRef, json });
2808
+ return 0;
2809
+ }
2810
+ if (sub === "apply") {
2811
+ (0, fix_1.runFixApplyCommand)({ root, family, target, baseRef, json });
2812
+ return 0;
2813
+ }
2814
+ const apply = parseBooleanFlag("--apply", parsed.flags["--apply"]);
2815
+ (0, fix_1.runFixIdsCommand)({ root, target, baseRef, json, apply });
2683
2816
  return 0;
2684
2817
  }
2685
2818
  case "format":