mdkg 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -133,6 +133,8 @@ mdkg show child_repo:work.example
133
133
  mdkg pack child_repo:work.example --dry-run --stats
134
134
  mdkg capability resolve "child capability" --json
135
135
  mdkg subgraph verify child_repo --json
136
+ mdkg subgraph audit child_repo --target .mdkg/subgraphs --json
137
+ mdkg subgraph upgrade-plan child_repo --json
136
138
  ```
137
139
 
138
140
  When the child repo is available under a configured root-relative `source_path`, refresh the root-owned bundle snapshot explicitly:
@@ -142,6 +144,8 @@ mdkg subgraph sync child_repo --dry-run --json
142
144
  mdkg subgraph sync child_repo --json
143
145
  ```
144
146
 
147
+ `audit` is read-only and reports source-path Git state, dirty tracked child files, bundle validity/freshness, root-owned bundle-path safety, optional materialized-target marker safety, and count-only capability summaries. `upgrade-plan` is also read-only, returns `apply_supported: false`, and proposes safe sync/verify/materialize next steps without writing bundles or child files.
148
+
145
149
  `sync` inspects the child Git repo, refuses dirty tracked changes by default, builds the configured private/public bundle into the root-owned source path, verifies it, and records `<branch>@<sha>` in `source_repo`. It never commits, pulls, pushes, checks out, resets, or mutates child mdkg Markdown. Use `--allow-dirty` only when the dirty state is intentional and must be recorded in the receipt.
146
150
 
147
151
  Generate a local read-only inspection tree when humans need to browse extracted child graph files:
@@ -277,6 +281,8 @@ These are the commands new users and agents should learn first:
277
281
  - `mdkg goal`
278
282
  - `mdkg task`
279
283
  - `mdkg validate`
284
+ - `mdkg status`
285
+ - `mdkg fix`
280
286
 
281
287
  Advanced / maintenance commands still exist, but they are not the first-run story:
282
288
  - `mdkg event`
@@ -284,9 +290,34 @@ Advanced / maintenance commands still exist, but they are not the first-run stor
284
290
  - `mdkg index`
285
291
  - `mdkg guide`
286
292
  - `mdkg format`
287
- - `mdkg doctor`
293
+ - `mdkg doctor --strict --json`
294
+ - `mdkg fix plan --json`
288
295
  - `mdkg workspace`
289
296
 
297
+ ## Operator health
298
+
299
+ Use `mdkg status --json` for a read-only operator summary before mutating a
300
+ repo. It reports package/release state, Git cleanliness, graph validity,
301
+ selected-goal state, project DB verification state, and generated cache
302
+ freshness without rebuilding indexes, running migrations, repairing files, or
303
+ changing selected-goal state.
304
+
305
+ Use `mdkg doctor --strict --json` when a CI job or agent needs actionable
306
+ typed checks. Strict doctor keeps the existing diagnostic command read-only and
307
+ adds stable check fields: `id`, `status`, `severity`, `message`,
308
+ `remediation`, and optional `refs`. Strict mode fails on invalid graph state,
309
+ stale generated graph/capability cache state, stale or achieved selected-goal
310
+ state, and enabled project DB verification failures. Warnings such as dirty
311
+ runtime DB files, archive size guidance, and bundle handoff guidance remain
312
+ warnings unless their underlying check fails.
313
+
314
+ Use `mdkg fix plan --json` when you want repair guidance without mutation. It
315
+ emits a receipt-shaped plan for generated index/cache repair, missing graph
316
+ references, and duplicate local ids. Planned changes include affected paths,
317
+ risk, reason codes, command hints, and `apply_supported: false`. `fix apply` is
318
+ not exposed; apply behavior is deferred until the dry-run plan contract has
319
+ enough evidence.
320
+
290
321
  ## Skills
291
322
 
292
323
  mdkg supports Agent Skills as procedural memory.
package/dist/cli.js CHANGED
@@ -18,6 +18,8 @@ const next_1 = require("./commands/next");
18
18
  const validate_1 = require("./commands/validate");
19
19
  const format_1 = require("./commands/format");
20
20
  const doctor_1 = require("./commands/doctor");
21
+ const status_1 = require("./commands/status");
22
+ const fix_1 = require("./commands/fix");
21
23
  const db_1 = require("./commands/db");
22
24
  const capability_1 = require("./commands/capability");
23
25
  const spec_1 = require("./commands/spec");
@@ -67,12 +69,14 @@ function printUsage(log) {
67
69
  log(" spec List, show, and validate optional SPEC.md capability records");
68
70
  log(" archive Add, list, show, verify, and compress archive sidecars");
69
71
  log(" bundle Create, list, show, and verify full graph snapshot bundles");
70
- log(" subgraph Register, sync, materialize, and verify read-only child graph snapshots");
72
+ log(" subgraph Register, audit, plan, sync, materialize, and verify read-only child graph snapshots");
71
73
  log(" work Create and update work contracts, orders, receipts, and artifacts");
72
74
  log(" goal Inspect and advance recursive goal nodes");
73
75
  log(" task Start, update, and complete task-like nodes");
74
76
  log(" next Suggest the next work item");
75
77
  log(" validate Validate frontmatter + graph");
78
+ log(" status Show read-only operator health summary");
79
+ log(" fix Plan read-only repairs with receipt-shaped JSON");
76
80
  log("\nAdvanced / maintenance commands:");
77
81
  log(" db Project database and index-cache commands");
78
82
  log(" event Enable or append episodic event logs");
@@ -514,7 +518,7 @@ function printBundleHelp(log, subcommand) {
514
518
  switch ((subcommand ?? "").toLowerCase()) {
515
519
  case "import":
516
520
  log("Usage:");
517
- log(" mdkg subgraph add/list/show/rm/enable/disable/verify/refresh/sync/materialize ...");
521
+ log(" mdkg subgraph add/list/show/rm/enable/disable/verify/refresh/audit/upgrade-plan/sync/materialize ...");
518
522
  log("\n`mdkg bundle import` has been replaced by `mdkg subgraph`.");
519
523
  break;
520
524
  case "create":
@@ -582,6 +586,20 @@ function printSubgraphHelp(log, subcommand) {
582
586
  log("Usage:");
583
587
  log(" mdkg subgraph refresh [alias|--all] [--json]");
584
588
  break;
589
+ case "audit":
590
+ log("Usage:");
591
+ log(" mdkg subgraph audit [alias|--all] [--target <path>] [--json]");
592
+ log("\nNotes:");
593
+ log(" - read-only audit for configured bundle health, source_path Git state, root-owned bundle paths, and optional materialize target safety");
594
+ log(" - exits nonzero only for error-level safety failures; warning-level drift stays in the receipt");
595
+ break;
596
+ case "upgrade-plan":
597
+ log("Usage:");
598
+ log(" mdkg subgraph upgrade-plan [alias|--all] [--json]");
599
+ log("\nNotes:");
600
+ log(" - read-only downstream upgrade planning receipt; apply_supported is false");
601
+ log(" - plans safe sync/verify/materialize next steps without mutating child repos or root bundles");
602
+ break;
585
603
  case "sync":
586
604
  log("Usage:");
587
605
  log(" mdkg subgraph sync [alias|--all] [--dry-run] [--allow-dirty] [--json]");
@@ -600,12 +618,15 @@ function printSubgraphHelp(log, subcommand) {
600
618
  log(" mdkg subgraph disable <alias> [--json]");
601
619
  log(" mdkg subgraph verify [alias|--all] [--json]");
602
620
  log(" mdkg subgraph refresh [alias|--all] [--json]");
621
+ log(" mdkg subgraph audit [alias|--all] [--target <path>] [--json]");
622
+ log(" mdkg subgraph upgrade-plan [alias|--all] [--json]");
603
623
  log(" mdkg subgraph sync [alias|--all] [--dry-run] [--allow-dirty] [--json]");
604
624
  log(" mdkg subgraph materialize [alias|--all] --target <path> [--clean] [--gitignore] [--json]");
605
625
  log("\nNotes:");
606
626
  log(" - subgraphs are read-only graph views backed by explicit bundle snapshots");
607
627
  log(" - default permissions are read-only and default freshness is 3600 seconds");
608
628
  log(" - refresh reloads configured bundle sources only; it does not build child bundles");
629
+ log(" - audit and upgrade-plan are read-only safety receipts for downstream orchestration");
609
630
  log(" - sync builds root-owned bundles from clean configured child source_path repos");
610
631
  log(" - materialize extracts bundle contents into generated inspection trees");
611
632
  }
@@ -824,6 +845,47 @@ function printValidateHelp(log) {
824
845
  log(" mdkg validate [--out <path>] [--quiet] [--json]");
825
846
  printGlobalOptions(log);
826
847
  }
848
+ function printStatusHelp(log) {
849
+ log("Usage:");
850
+ log(" mdkg status [--json]");
851
+ log("\nChecks:");
852
+ log(" - release/package and CHANGELOG summary");
853
+ log(" - git branch, dirty state, and upstream ahead/behind counts");
854
+ log(" - graph index load, validation errors, and generated cache freshness");
855
+ log(" - selected goal existence, achieved state, and active node");
856
+ log(" - project DB enabled/verify summary");
857
+ log("\nBoundaries:");
858
+ log(" - read-only operator summary; does not rebuild indexes or repair files");
859
+ log(" - use `mdkg doctor` for diagnostic detail and future strict check IDs");
860
+ log("\nOptions:");
861
+ log(" --json Emit machine-readable JSON output");
862
+ printGlobalOptions(log);
863
+ }
864
+ function printFixHelp(log, subcommand) {
865
+ switch ((subcommand ?? "").toLowerCase()) {
866
+ case "plan":
867
+ log("Usage:");
868
+ log(" mdkg fix plan [--family index|refs|ids|all] [--target <id-or-qid>] [--json]");
869
+ log("\nBoundaries:");
870
+ log(" - read-only repair planning; writes no files and does not rebuild indexes");
871
+ log(" - emits a deterministic receipt-shaped JSON plan with paths, risks, and reason codes");
872
+ log(" - initial families are index/cache, graph refs, and duplicate ids");
873
+ log(" - `fix apply` is intentionally not available in this release slice");
874
+ log("\nOptions:");
875
+ log(" --family <family> Select index, refs, ids, or all (default all)");
876
+ log(" --target <id-or-qid> Optional node target for family planners");
877
+ log(" --json Emit machine-readable JSON output");
878
+ printGlobalOptions(log);
879
+ return;
880
+ default:
881
+ log("Usage:");
882
+ log(" mdkg fix plan [--family index|refs|ids|all] [--target <id-or-qid>] [--json]");
883
+ log("\nNotes:");
884
+ log(" - fix planning is dry-run only and writes nothing");
885
+ log(" - apply behavior is deferred until the receipt contract is proven");
886
+ printGlobalOptions(log);
887
+ }
888
+ }
827
889
  function printFormatHelp(log) {
828
890
  log("Usage:");
829
891
  log(" mdkg format");
@@ -831,10 +893,12 @@ function printFormatHelp(log) {
831
893
  }
832
894
  function printDoctorHelp(log) {
833
895
  log("Usage:");
834
- log(" mdkg doctor [--json]");
896
+ log(" mdkg doctor [--strict] [--json]");
835
897
  log("\nChecks:");
836
898
  log(" - Node.js version compatibility");
837
899
  log(" - mdkg repo root + .mdkg/config.json");
900
+ log(" - Selected-goal stale or achieved state");
901
+ log(" - Project DB verification when enabled");
838
902
  log(" - Template schema availability");
839
903
  log(" - Archive sidecar storage hygiene");
840
904
  log(" - Bundle snapshot storage guidance");
@@ -843,6 +907,7 @@ function printDoctorHelp(log) {
843
907
  log(" - Capability cache load/rebuild health");
844
908
  log(" - SQLite cache health when enabled");
845
909
  log("\nOptions:");
910
+ log(" --strict Fail on stale selected-goal, DB, and generated cache health issues");
846
911
  log(" --json Emit machine-readable JSON output");
847
912
  printGlobalOptions(log);
848
913
  }
@@ -924,6 +989,12 @@ function printCommandHelp(log, command, subcommand) {
924
989
  case "validate":
925
990
  printValidateHelp(log);
926
991
  return;
992
+ case "status":
993
+ printStatusHelp(log);
994
+ return;
995
+ case "fix":
996
+ printFixHelp(log, subcommand);
997
+ return;
927
998
  case "format":
928
999
  printFormatHelp(log);
929
1000
  return;
@@ -1648,6 +1719,25 @@ function runSubgraphSubcommand(parsed, root) {
1648
1719
  (0, subgraph_1.runSubgraphRefreshCommand)({ root, alias, all, json });
1649
1720
  return 0;
1650
1721
  }
1722
+ case "audit": {
1723
+ if (parsed.positionals.length > 3) {
1724
+ throw new errors_1.UsageError("subgraph audit accepts at most one alias");
1725
+ }
1726
+ const alias = parsed.positionals[2];
1727
+ const all = parseBooleanFlag("--all", parsed.flags["--all"]);
1728
+ const target = requireFlagValue("--target", parsed.flags["--target"]);
1729
+ (0, subgraph_1.runSubgraphAuditCommand)({ root, alias, all, target, json });
1730
+ return 0;
1731
+ }
1732
+ case "upgrade-plan": {
1733
+ if (parsed.positionals.length > 3) {
1734
+ throw new errors_1.UsageError("subgraph upgrade-plan accepts at most one alias");
1735
+ }
1736
+ const alias = parsed.positionals[2];
1737
+ const all = parseBooleanFlag("--all", parsed.flags["--all"]);
1738
+ (0, subgraph_1.runSubgraphUpgradePlanCommand)({ root, alias, all, json });
1739
+ return 0;
1740
+ }
1651
1741
  case "sync": {
1652
1742
  if (parsed.positionals.length > 3) {
1653
1743
  throw new errors_1.UsageError("subgraph sync accepts at most one alias");
@@ -1675,7 +1765,7 @@ function runSubgraphSubcommand(parsed, root) {
1675
1765
  return 0;
1676
1766
  }
1677
1767
  default:
1678
- throw new errors_1.UsageError("subgraph requires add/list/show/rm/enable/disable/verify/refresh/sync/materialize");
1768
+ throw new errors_1.UsageError("subgraph requires add/list/show/rm/enable/disable/verify/refresh/audit/upgrade-plan/sync/materialize");
1679
1769
  }
1680
1770
  }
1681
1771
  function runWorkSubcommand(parsed, root) {
@@ -2530,6 +2620,31 @@ function runCommand(parsed, root, runtime) {
2530
2620
  (0, validate_1.runValidateCommand)({ root, out, quiet, json });
2531
2621
  return 0;
2532
2622
  }
2623
+ case "status": {
2624
+ if (parsed.positionals.length > 1) {
2625
+ throw new errors_1.UsageError("status does not accept positional arguments");
2626
+ }
2627
+ const json = parseBooleanFlag("--json", parsed.flags["--json"]);
2628
+ (0, status_1.runStatusCommand)({ root, json });
2629
+ return 0;
2630
+ }
2631
+ case "fix": {
2632
+ const sub = (parsed.positionals[1] ?? "").toLowerCase();
2633
+ if (!sub) {
2634
+ throw new errors_1.UsageError("fix requires a subcommand");
2635
+ }
2636
+ if (sub !== "plan") {
2637
+ throw new errors_1.UsageError(`unknown fix subcommand: ${sub}`);
2638
+ }
2639
+ if (parsed.positionals.length > 2) {
2640
+ throw new errors_1.UsageError("fix plan does not accept positional arguments");
2641
+ }
2642
+ const family = requireFlagValue("--family", parsed.flags["--family"]);
2643
+ const target = requireFlagValue("--target", parsed.flags["--target"]);
2644
+ const json = parseBooleanFlag("--json", parsed.flags["--json"]);
2645
+ (0, fix_1.runFixPlanCommand)({ root, family, target, json });
2646
+ return 0;
2647
+ }
2533
2648
  case "format":
2534
2649
  if (parsed.positionals.length > 1) {
2535
2650
  throw new errors_1.UsageError("format does not accept positional arguments");
@@ -2543,7 +2658,8 @@ function runCommand(parsed, root, runtime) {
2543
2658
  const noCache = parseBooleanFlag("--no-cache", parsed.flags["--no-cache"]);
2544
2659
  const noReindex = parseBooleanFlag("--no-reindex", parsed.flags["--no-reindex"]);
2545
2660
  const json = parseBooleanFlag("--json", parsed.flags["--json"]);
2546
- (0, doctor_1.runDoctorCommand)({ root, noCache, noReindex, json });
2661
+ const strict = parseBooleanFlag("--strict", parsed.flags["--strict"]);
2662
+ (0, doctor_1.runDoctorCommand)({ root, noCache, noReindex, json, strict });
2547
2663
  return 0;
2548
2664
  }
2549
2665
  default: