mdkg 0.4.1 → 0.4.2

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
@@ -8,6 +8,38 @@ mdkg is pre-v1 public alpha software. Command, graph, cache, bundle, and DAL con
8
8
 
9
9
  ## Unreleased
10
10
 
11
+ ## 0.4.2 - 2026-07-05
12
+
13
+ ### Added
14
+
15
+ - Added the low-level `mdkg git` command family for Git-backed project
16
+ lifecycle primitives: `inspect`, `clone`, `fetch`, `closeout`,
17
+ `push-ready`, and approval-gated real `push` execution.
18
+ - Added Git source descriptors and accepted-revision evidence in command
19
+ receipts, including sanitized remote refs, branch, commit SHA, tree hash, and
20
+ the external-auth boundary.
21
+ - Added `mdkg git closeout` static JSON/Markdown receipts, plus sealed project
22
+ DB snapshot and deterministic dump evidence when SQLite project state
23
+ participated in the run.
24
+
25
+ ### Changed
26
+
27
+ - Made push readiness a high-bar preflight: explicit remote and branch,
28
+ credential-free remote config, clean worktree, passing mdkg validation, and a
29
+ valid DB snapshot when DB state participated.
30
+ - Documented Git auth as external to mdkg through system Git, credential
31
+ helpers, SSH, `gh`, CI/runtime env, or shell state; mdkg stores only refs,
32
+ hashes, policy names, and receipts.
33
+ - Deferred project-memory semantic query UX (`history`, `why`, and
34
+ `next-work`) to a separate CocoIndex-grounded design lane instead of shipping
35
+ it in the `0.4.2` Git lifecycle release.
36
+
37
+ ### Security
38
+
39
+ - Rejects embedded URL credentials for repository refs and push remotes, and
40
+ redacts any userinfo that appears in inspected remote URLs before writing
41
+ receipts or JSON output.
42
+
11
43
  ## 0.4.1 - 2026-07-04
12
44
 
13
45
  ### Added
@@ -1,7 +1,7 @@
1
1
  # CLI Command Matrix
2
2
 
3
- as_of: 2026-07-03
4
- package_version_in_source: 0.4.1
3
+ as_of: 2026-07-05
4
+ package_version_in_source: 0.4.2
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
 
@@ -42,6 +42,7 @@ Primary commands:
42
42
  - `archive`
43
43
  - `bundle`
44
44
  - `graph`
45
+ - `git`
45
46
  - `subgraph`
46
47
  - `work`
47
48
  - `goal`
@@ -72,6 +73,7 @@ Reusable manifest capability records are accessed through `mdkg manifest ...`;
72
73
  Archive sidecars are accessed through `mdkg archive ...`.
73
74
  Full graph snapshot bundles are accessed through `mdkg bundle ...`.
74
75
  Whole-graph clone, fork, and same-repo template import workflows are accessed through `mdkg graph ...`.
76
+ Low-level Git remote lifecycle primitives are accessed through `mdkg git ...`.
75
77
  Read-only child graph orchestration is accessed through `mdkg subgraph ...`.
76
78
  Work contract/order/receipt semantic mirrors are accessed through `mdkg work ...`.
77
79
  Recursive long-running objective contracts are accessed through `mdkg goal ...`.
@@ -746,6 +748,54 @@ JSON receipts:
746
748
  - `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?, activated_goal?, paused_goals, index?, validation?, warnings }`
747
749
  - `refs`: `{ action: "graph.refs", ok, target, outgoing, incoming, warnings }`
748
750
 
751
+ ### `mdkg git`
752
+
753
+ When to use:
754
+ - inspect the current Git-backed mdkg project and accepted revision evidence
755
+ - clone or fetch real Git remotes through the system Git CLI with external auth
756
+ - close out mdkg state to static receipts before an agent checkpoint commit
757
+ - prove push readiness before any approval-gated real remote push
758
+
759
+ Usage:
760
+ - `mdkg git inspect [--json]`
761
+ - `mdkg git clone <repository-ref> --target <path> [--branch <name>] [--json]`
762
+ - `mdkg git fetch [--remote <name>] [--branch <name>] [--json]`
763
+ - `mdkg git closeout [--queue-policy drain|paused] [--output <path>] [--json]`
764
+ - `mdkg git push-ready --remote <name> --branch <name> [--json]`
765
+ - `mdkg git push --remote <name> --branch <name> [--json]`
766
+ - `mdkg git push --remote <name> --branch <name> --stage-all --message <text> [--queue-policy drain|paused] [--json]`
767
+ - `mdkg git push --remote <name> --branch <name> [--stage-all --message <text>] [--json]`
768
+
769
+ Flags:
770
+ - `--target <path>`
771
+ - `--branch <name>`
772
+ - `--remote <name>`
773
+ - `--queue-policy drain|paused`
774
+ - `--output <path>`
775
+ - `--stage-all`
776
+ - `--message <text>`
777
+ - `--json`
778
+
779
+ Notes:
780
+ - `mdkg git` is a low-level lifecycle surface, not project-memory semantic search
781
+ - v1 uses the system Git CLI; authentication stays external through credential helpers, SSH, `gh`, CI/runtime env, or shell state
782
+ - mdkg rejects repository refs and push remotes with embedded URL credentials; inspected remotes with userinfo are redacted before receipts are printed
783
+ - `git inspect` is read-only and emits sanitized source descriptors plus accepted-revision hashes
784
+ - `git clone` writes only to an empty or absent contained `--target`; use `mdkg graph clone|fork` for bundle/template graph transport
785
+ - `git closeout` validates mdkg state and writes static JSON and Markdown receipts under `.mdkg/git/closeouts` by default
786
+ - when the project DB participated, `git closeout` also seals `.mdkg/db/state/project.sqlite` and writes a deterministic dump
787
+ - `git push-ready` is read-only and requires explicit remote and branch, clean worktree, passing mdkg validation, external-auth-safe remote config, and a valid DB snapshot when DB state participated
788
+ - `git push --stage-all` writes closeout evidence, stages all changes, commits with `--message`, reruns push-ready, then pushes `HEAD` to the explicit remote branch
789
+ - real `git push` should remain approval-gated by the calling runtime or human operator
790
+
791
+ JSON receipts:
792
+ - `inspect`: `{ action: "git.inspect", ok, root, inside_work_tree, branch, head_sha, tree_hash, remotes, status, source_descriptor, accepted_revision, warnings }`
793
+ - `clone`: `{ action: "git.clone", ok, repository_ref, target, branch, source_descriptor, accepted_revision, inspect, warnings }`
794
+ - `fetch`: `{ action: "git.fetch", ok, remote, branch, fetch_output, inspect, warnings }`
795
+ - `closeout`: `{ action: "git.closeout", ok, root, output_dir, generated_at, git, validation, db_participated, db_snapshot_status, db_snapshot_seal, db_snapshot_dump, static_receipts, warnings }`
796
+ - `push-ready`: `{ action: "git.push_ready", ok, root, remote, branch, remote_url, git, validation, db_snapshot_status, checks, warning_count, failure_count, warnings, errors }`
797
+ - `push`: `{ action: "git.push", ok, remote, branch, head_sha, pushed_ref, stage_all, closeout, commit, push_ready, push_output, warnings }`
798
+
749
799
  ### `mdkg subgraph`
750
800
 
751
801
  When to use:
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.4.1`
17
+ Current package version in source: `0.4.2`
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
 
@@ -242,6 +242,26 @@ Subgraph nodes are projected under the subgraph alias, for example `child_repo:t
242
242
 
243
243
  Use `mdkg graph refs <id-or-qid> --json` to inspect inbound and outbound scope, context, evidence, blocker, related, and structural links for local or read-only subgraph qids without mutating either graph.
244
244
 
245
+ Use low-level Git lifecycle receipts when an agent run needs to close out local
246
+ mdkg state and prove push readiness before an explicit remote update:
247
+
248
+ ```bash
249
+ mdkg git inspect --json
250
+ mdkg git clone git@github.com:org/repo.git --target worktrees/repo --branch main --json
251
+ mdkg git fetch --remote origin --branch main --json
252
+ mdkg git closeout --json
253
+ mdkg git push-ready --remote origin --branch main --json
254
+ mdkg git push --remote origin --branch main --stage-all --message "agent checkpoint" --json
255
+ ```
256
+
257
+ `mdkg git` uses the system Git CLI. Authentication stays external through SSH,
258
+ credential helpers, `gh`, CI/runtime environment, or shell state; mdkg rejects
259
+ embedded URL credentials and records only sanitized refs, hashes, policy names,
260
+ and receipts. `closeout` validates mdkg state before writing static JSON and
261
+ Markdown receipts, and when the project DB participated it also seals the
262
+ SQLite state and writes a deterministic dump. Treat real `mdkg git push` as an
263
+ approval-gated operation in agent runtimes.
264
+
245
265
  Launch a local read-only MCP server when an MCP-capable agent should inspect a
246
266
  specific mdkg graph without receiving mutation tools:
247
267
 
package/dist/cli.js CHANGED
@@ -29,6 +29,7 @@ const spec_1 = require("./commands/spec");
29
29
  const archive_1 = require("./commands/archive");
30
30
  const bundle_1 = require("./commands/bundle");
31
31
  const graph_1 = require("./commands/graph");
32
+ const git_1 = require("./commands/git");
32
33
  const subgraph_1 = require("./commands/subgraph");
33
34
  const checkpoint_1 = require("./commands/checkpoint");
34
35
  const init_1 = require("./commands/init");
@@ -76,6 +77,7 @@ function printUsage(log) {
76
77
  log(" archive Add, list, show, verify, and compress archive sidecars");
77
78
  log(" bundle Create, list, show, and verify full graph snapshot bundles");
78
79
  log(" graph Clone, fork, import, and inspect mdkg graph references");
80
+ log(" git Clone, fetch, inspect, close out, and push Git-backed mdkg projects");
79
81
  log(" subgraph Register, audit, plan, sync, materialize, and verify read-only child graph snapshots");
80
82
  log(" work Create and update work contracts, orders, receipts, and artifacts");
81
83
  log(" goal Inspect and advance recursive goal nodes");
@@ -653,6 +655,70 @@ function printGraphHelp(log, subcommand) {
653
655
  }
654
656
  printGlobalOptions(log);
655
657
  }
658
+ function printGitHelp(log, subcommand) {
659
+ switch ((subcommand ?? "").toLowerCase()) {
660
+ case "inspect":
661
+ log("Usage:");
662
+ log(" mdkg git inspect [--json]");
663
+ log("\nNotes:");
664
+ log(" - read-only Git worktree, remote, branch, status, descriptor, and accepted-revision receipt");
665
+ log(" - remote URLs are redacted when userinfo is present");
666
+ break;
667
+ case "clone":
668
+ log("Usage:");
669
+ log(" mdkg git clone <repository-ref> --target <path> [--branch <name>] [--json]");
670
+ log("\nNotes:");
671
+ log(" - uses the system Git CLI and external Git auth");
672
+ log(" - --target must be empty or absent and stay inside the current repo");
673
+ log(" - repository refs must not embed credentials");
674
+ break;
675
+ case "fetch":
676
+ log("Usage:");
677
+ log(" mdkg git fetch [--remote <name>] [--branch <name>] [--json]");
678
+ log("\nNotes:");
679
+ log(" - defaults to remote origin");
680
+ log(" - auth stays external through Git credential helpers, SSH, gh, CI env, or shell state");
681
+ break;
682
+ case "closeout":
683
+ log("Usage:");
684
+ log(" mdkg git closeout [--queue-policy drain|paused] [--output <path>] [--json]");
685
+ log("\nNotes:");
686
+ log(" - validates mdkg state before writing closeout receipts");
687
+ log(" - when the project DB participated, seals SQLite state and writes a deterministic dump");
688
+ log(" - writes static JSON and Markdown receipts under .mdkg/git/closeouts by default");
689
+ break;
690
+ case "push-ready":
691
+ log("Usage:");
692
+ log(" mdkg git push-ready --remote <name> --branch <name> [--json]");
693
+ log("\nNotes:");
694
+ log(" - read-only high-bar preflight for explicit Git remote/branch push");
695
+ log(" - requires clean worktree, valid mdkg graph, external auth boundary, and valid DB snapshot when DB state participated");
696
+ break;
697
+ case "push":
698
+ log("Usage:");
699
+ log(" mdkg git push --remote <name> --branch <name> [--json]");
700
+ log(" mdkg git push --remote <name> --branch <name> --stage-all --message <text> [--queue-policy drain|paused] [--json]");
701
+ log("\nNotes:");
702
+ log(" - real Git push via system Git; requires explicit remote and branch");
703
+ log(" - --stage-all writes closeout evidence, stages all changes, commits with --message, then runs push-ready before pushing");
704
+ log(" - no raw credentials, tokens, SSH keys, prompts, payloads, or provider auth are stored in receipts");
705
+ break;
706
+ default:
707
+ log("Usage:");
708
+ log(" mdkg git inspect [--json]");
709
+ log(" mdkg git clone <repository-ref> --target <path> [--branch <name>] [--json]");
710
+ log(" mdkg git fetch [--remote <name>] [--branch <name>] [--json]");
711
+ log(" mdkg git closeout [--queue-policy drain|paused] [--output <path>] [--json]");
712
+ log(" mdkg git push-ready --remote <name> --branch <name> [--json]");
713
+ log(" mdkg git push --remote <name> --branch <name> [--stage-all --message <text>] [--json]");
714
+ log("\nBoundaries:");
715
+ log(" - mdkg git is a low-level Git lifecycle surface, not project-memory semantic search");
716
+ log(" - system Git is the v1 execution backend");
717
+ log(" - authentication stays external; mdkg records only refs, hashes, policy names, and receipts");
718
+ log(" - real push operations require explicit remote and branch and should be approval-gated by the caller");
719
+ }
720
+ printGlobalOptions(log);
721
+ }
656
722
  function printSubgraphHelp(log, subcommand) {
657
723
  switch ((subcommand ?? "").toLowerCase()) {
658
724
  case "add":
@@ -1179,6 +1245,9 @@ function printCommandHelp(log, command, subcommand) {
1179
1245
  case "graph":
1180
1246
  printGraphHelp(log, subcommand);
1181
1247
  return;
1248
+ case "git":
1249
+ printGitHelp(log, subcommand);
1250
+ return;
1182
1251
  case "subgraph":
1183
1252
  printSubgraphHelp(log, subcommand);
1184
1253
  return;
@@ -1911,6 +1980,73 @@ function runGraphSubcommand(parsed, root) {
1911
1980
  throw new errors_1.UsageError("graph requires clone/fork/import-template/refs");
1912
1981
  }
1913
1982
  }
1983
+ function runGitSubcommand(parsed, root) {
1984
+ const subcommand = (parsed.positionals[1] ?? "").toLowerCase();
1985
+ const json = parseBooleanFlag("--json", parsed.flags["--json"]);
1986
+ switch (subcommand) {
1987
+ case "inspect": {
1988
+ if (parsed.positionals.length > 2) {
1989
+ throw new errors_1.UsageError("git inspect does not accept positional arguments");
1990
+ }
1991
+ (0, git_1.runGitInspectCommand)({ root, json });
1992
+ return 0;
1993
+ }
1994
+ case "clone": {
1995
+ const repository = parsed.positionals[2];
1996
+ if (!repository || parsed.positionals.length > 3) {
1997
+ throw new errors_1.UsageError("git clone requires <repository-ref>");
1998
+ }
1999
+ const target = requireFlagValue("--target", parsed.flags["--target"]);
2000
+ if (!target) {
2001
+ throw new errors_1.UsageError("git clone requires --target <path>");
2002
+ }
2003
+ const branch = requireFlagValue("--branch", parsed.flags["--branch"]);
2004
+ (0, git_1.runGitCloneCommand)({ root, repository, target, branch, json });
2005
+ return 0;
2006
+ }
2007
+ case "fetch": {
2008
+ if (parsed.positionals.length > 2) {
2009
+ throw new errors_1.UsageError("git fetch does not accept positional arguments");
2010
+ }
2011
+ const remote = requireFlagValue("--remote", parsed.flags["--remote"]);
2012
+ const branch = requireFlagValue("--branch", parsed.flags["--branch"]);
2013
+ (0, git_1.runGitFetchCommand)({ root, remote, branch, json });
2014
+ return 0;
2015
+ }
2016
+ case "closeout": {
2017
+ if (parsed.positionals.length > 2) {
2018
+ throw new errors_1.UsageError("git closeout does not accept positional arguments");
2019
+ }
2020
+ const queuePolicy = parseQueuePolicyFlag(parsed.flags["--queue-policy"]);
2021
+ const output = requireFlagValue("--output", parsed.flags["--out"]);
2022
+ (0, git_1.runGitCloseoutCommand)({ root, queuePolicy, output, json });
2023
+ return 0;
2024
+ }
2025
+ case "push-ready": {
2026
+ if (parsed.positionals.length > 2) {
2027
+ throw new errors_1.UsageError("git push-ready does not accept positional arguments");
2028
+ }
2029
+ const remote = requireFlagValue("--remote", parsed.flags["--remote"]);
2030
+ const branch = requireFlagValue("--branch", parsed.flags["--branch"]);
2031
+ (0, git_1.runGitPushReadyCommand)({ root, remote, branch, json });
2032
+ return 0;
2033
+ }
2034
+ case "push": {
2035
+ if (parsed.positionals.length > 2) {
2036
+ throw new errors_1.UsageError("git push does not accept positional arguments");
2037
+ }
2038
+ const remote = requireFlagValue("--remote", parsed.flags["--remote"]);
2039
+ const branch = requireFlagValue("--branch", parsed.flags["--branch"]);
2040
+ const message = requireFlagValue("--message", parsed.flags["--message"]);
2041
+ const stageAll = parseBooleanFlag("--stage-all", parsed.flags["--stage-all"]);
2042
+ const queuePolicy = parseQueuePolicyFlag(parsed.flags["--queue-policy"]);
2043
+ (0, git_1.runGitPushCommand)({ root, remote, branch, message, stageAll, queuePolicy, json });
2044
+ return 0;
2045
+ }
2046
+ default:
2047
+ throw new errors_1.UsageError("git requires inspect/clone/fetch/closeout/push-ready/push");
2048
+ }
2049
+ }
1914
2050
  function runSubgraphSubcommand(parsed, root) {
1915
2051
  const subcommand = (parsed.positionals[1] ?? "").toLowerCase();
1916
2052
  const json = parseBooleanFlag("--json", parsed.flags["--json"]);
@@ -2747,6 +2883,8 @@ function runCommand(parsed, root, runtime) {
2747
2883
  return runBundleSubcommand(parsed, root);
2748
2884
  case "graph":
2749
2885
  return runGraphSubcommand(parsed, root);
2886
+ case "git":
2887
+ return runGitSubcommand(parsed, root);
2750
2888
  case "subgraph":
2751
2889
  return runSubgraphSubcommand(parsed, root);
2752
2890
  case "work":