mdkg 0.3.4 → 0.3.6

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.
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.collectValidateReceipt = collectValidateReceipt;
6
7
  exports.runValidateCommand = runValidateCommand;
7
8
  const fs_1 = __importDefault(require("fs"));
8
9
  const path_1 = __importDefault(require("path"));
@@ -244,7 +245,7 @@ function validateEventsJsonl(root, config, errors) {
244
245
  }
245
246
  }
246
247
  }
247
- function runValidateCommand(options) {
248
+ function collectValidateReceipt(options) {
248
249
  const config = (0, config_1.loadConfig)(options.root);
249
250
  const templateSchemaInfo = (0, template_schema_1.loadTemplateSchemasWithInfo)(options.root, config, node_1.ALLOWED_TYPES);
250
251
  const templateSchemas = templateSchemaInfo.schemas;
@@ -392,31 +393,35 @@ function runValidateCommand(options) {
392
393
  errors: uniqueErrors,
393
394
  ...(outPath ? { report_path: outPath } : {}),
394
395
  };
396
+ return receipt;
397
+ }
398
+ function runValidateCommand(options) {
399
+ const receipt = collectValidateReceipt(options);
395
400
  if (options.json) {
396
401
  console.log(JSON.stringify(receipt, null, 2));
397
- if (uniqueErrors.length > 0) {
398
- throw new errors_1.ValidationError(`validation failed with ${uniqueErrors.length} error(s)`);
402
+ if (receipt.error_count > 0) {
403
+ throw new errors_1.ValidationError(`validation failed with ${receipt.error_count} error(s)`);
399
404
  }
400
405
  return;
401
406
  }
402
407
  if (!options.quiet) {
403
- for (const warning of uniqueWarnings) {
408
+ for (const warning of receipt.warnings) {
404
409
  console.error(`warning: ${warning}`);
405
410
  }
406
411
  }
407
- if (uniqueErrors.length > 0) {
408
- if (outPath) {
409
- console.error(`validation failed: ${uniqueErrors.length} error(s). details written to ${outPath}`);
412
+ if (receipt.error_count > 0) {
413
+ if (receipt.report_path) {
414
+ console.error(`validation failed: ${receipt.error_count} error(s). details written to ${receipt.report_path}`);
410
415
  }
411
416
  else {
412
- for (const error of uniqueErrors) {
417
+ for (const error of receipt.errors) {
413
418
  console.error(error);
414
419
  }
415
420
  }
416
- throw new errors_1.ValidationError(`validation failed with ${uniqueErrors.length} error(s)`);
421
+ throw new errors_1.ValidationError(`validation failed with ${receipt.error_count} error(s)`);
417
422
  }
418
- if (outPath) {
419
- console.log(`validation report written: ${outPath}`);
423
+ if (receipt.report_path) {
424
+ console.log(`validation report written: ${receipt.report_path}`);
420
425
  }
421
426
  console.log("validation ok");
422
427
  }
@@ -22,11 +22,14 @@ Primary commands:
22
22
  - `mdkg spec`
23
23
  - `mdkg archive`
24
24
  - `mdkg bundle`
25
+ - `mdkg graph`
26
+ - `mdkg subgraph`
25
27
  - `mdkg work`
26
28
  - `mdkg goal`
27
29
  - `mdkg task`
28
30
  - `mdkg validate`
29
31
  - `mdkg status [--json]`
32
+ - `mdkg mcp serve --stdio`
30
33
  - `mdkg fix plan [--family index|refs|ids|all] [--target <id-or-qid>] [--base-ref <ref>] [--json]`
31
34
  - `mdkg fix apply [--family ids] [--target <id-or-qid>] [--base-ref <ref>] [--json]`
32
35
  - `mdkg fix ids [--target <id-or-qid>] [--base-ref <ref>] [--apply] [--json]`
@@ -42,6 +45,15 @@ Operator health:
42
45
  - graph-reference and index/cache findings remain review-only guidance
43
46
  - `fix plan --json` returns a receipt-shaped plan with selected families, risk counts, paths, reason codes, and per-change `apply_supported` metadata
44
47
 
48
+ Local MCP server:
49
+ - `mdkg mcp serve --stdio`
50
+ - starts one local Model Context Protocol server bound to the selected `--root`
51
+ - stdio is the only transport in this release; no HTTP listener is opened
52
+ - exposes read-only tools for status, workspace/subgraph list, search, show, in-memory pack, goal current/next, and validate
53
+ - exposes no task, goal activation, graph import, queue, event, archive, format, SQL, shell, arbitrary file-read, filesystem mutation, environment, or secret-access tools
54
+ - use `--root <path>` when launching from outside the repo
55
+ - stdout is reserved for newline-delimited JSON-RPC MCP messages
56
+
45
57
  Index backend:
46
58
  - fresh mdkg workspaces default to `index.backend: sqlite`
47
59
  - `.mdkg/index/mdkg.sqlite` is rebuildable and commit-eligible when intentionally tracked
@@ -204,6 +216,22 @@ Graph snapshot bundles:
204
216
  - public bundles include only public workspace content and public archive sidecars
205
217
  - public bundle creation fails when public records reference private graph, archive, or subgraph records
206
218
 
219
+ Graph clone, fork, and template import:
220
+ - `mdkg graph clone <source-bundle-or-mdkg-dir> --target <path> [--json]`
221
+ - `mdkg graph fork <source-bundle-or-mdkg-dir> --target <path> [--start-goal <goal-id>] [--json]`
222
+ - `mdkg graph import-template <source-bundle-or-mdkg-dir> [--start-goal <goal-id>] [--select-goal] [--id-prefix <prefix>] [--dry-run] [--apply] [--json]`
223
+ - `graph clone` and `graph fork` preserve IDs because the target is a separate graph namespace
224
+ - clone/fork targets must be empty or absent and stay under the current mdkg root
225
+ - live directory sources are never mutated; clone/fork refuses targets nested inside a live source directory
226
+ - `graph fork --start-goal <goal-id>` writes selected-goal state in the target graph after validation
227
+ - `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
228
+ - `graph import-template` defaults to dry-run unless `--apply` is supplied
229
+ - 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
230
+ - colliding semantic template IDs require `--id-prefix`
231
+ - `--select-goal` requires `--start-goal`; on apply it activates the imported start goal, pauses competing active root goals, validates, then writes selected-goal state
232
+ - importing active template goals without `--select-goal` fails before writing when it would create multiple active root goals
233
+ - subgraphs remain read-only bundle projections for orchestration context; use `graph clone|fork|import-template` when authored graph state should be created
234
+
207
235
  Subgraph orchestration:
208
236
  - `mdkg subgraph add <alias> <bundle-path> [--visibility private|internal|public] [--profile private|public] [--source-path <path>] [--json]`
209
237
  - `mdkg subgraph list [--json]`
@@ -29,13 +29,14 @@ mdkg capability search "..."
29
29
  mdkg spec list --json
30
30
  mdkg archive list
31
31
  mdkg bundle create --profile private
32
+ mdkg graph clone .mdkg/bundles/private/all.mdkg.zip --target demos/demo-1 --json
32
33
  mdkg subgraph list --json
33
34
  mdkg status --json
34
35
  mdkg fix plan --json
35
36
  mdkg validate
36
37
  ```
37
38
 
38
- This repo is already initialized. Use `mdkg upgrade` to preview safe scaffold updates, `mdkg index` to create or refresh generated graph/skill/capability/subgraph and SQLite caches after init, `mdkg new` to create work, `mdkg new goal "..."` plus `mdkg goal activate/current/next/claim/evaluate` for recursive long-running objectives, `mdkg search`/`mdkg show` to inspect graph state, `mdkg capability ...` to inspect cached skill/spec/work/core/design capabilities, `mdkg spec ...` for focused optional SPEC records, `mdkg capability resolve ...` to rank local and subgraph capabilities, `mdkg archive ...` to register source/artifact sidecars, `mdkg work ...` to create work contract/order/receipt semantic mirrors and deterministic trigger/verification records, `mdkg bundle ...` to create full graph snapshot bundles, `mdkg subgraph ...` to register read-only child graph planning views, `mdkg pack <id>` to build deterministic context, and `mdkg validate` before closeout.
39
+ This repo is already initialized. Use `mdkg upgrade` to preview safe scaffold updates, `mdkg index` to create or refresh generated graph/skill/capability/subgraph and SQLite caches after init, `mdkg new` to create work, `mdkg new goal "..."` plus `mdkg goal activate/current/next/claim/evaluate` for recursive long-running objectives, `mdkg search`/`mdkg show` to inspect graph state, `mdkg capability ...` to inspect cached skill/spec/work/core/design capabilities, `mdkg spec ...` for focused optional SPEC records, `mdkg capability resolve ...` to rank local and subgraph capabilities, `mdkg archive ...` to register source/artifact sidecars, `mdkg work ...` to create work contract/order/receipt semantic mirrors and deterministic trigger/verification records, `mdkg bundle ...` to create full graph snapshot bundles, `mdkg graph ...` to clone/fork/import authored graph templates, `mdkg subgraph ...` to register read-only child graph planning views, `mdkg pack <id>` to build deterministic context, and `mdkg validate` before closeout.
39
40
 
40
41
  Use `mdkg status --json` for a read-only operator summary of Git, graph,
41
42
  selected-goal, project DB, and generated-cache health before mutating work. Use
@@ -158,6 +159,22 @@ mdkg bundle verify .mdkg/bundles/private/all.mdkg.zip
158
159
 
159
160
  Use this as a pre-commit recommendation only when the repo tracks archive caches or `.mdkg/bundles/`. Private bundles are local graph transport artifacts and may be tracked in private repos when configured. Public bundles require selected workspaces with `visibility: public` and fail closed when public records reference private graph, archive, or subgraph records.
160
161
 
162
+ Clone or fork an authored graph into a separate repo/workspace while preserving IDs:
163
+
164
+ ```bash
165
+ mdkg graph clone .mdkg/bundles/private/all.mdkg.zip --target demos/demo-1 --json
166
+ mdkg graph fork templates/website-template-mdkg --target demos/live-build --start-goal goal-1 --json
167
+ ```
168
+
169
+ Import a template graph into the current repo with deterministic ID and link rewrites:
170
+
171
+ ```bash
172
+ mdkg graph import-template templates/website-template-mdkg --start-goal goal-1 --select-goal --dry-run --json
173
+ mdkg graph import-template templates/website-template-mdkg --start-goal goal-1 --select-goal --apply --json
174
+ ```
175
+
176
+ `graph clone` and `graph fork` preserve IDs because the target is a separate graph namespace. `graph import-template` rewrites canonical numeric IDs for same-repo imports and requires `--id-prefix` for colliding semantic IDs. With `--select-goal --apply`, import-template activates the rewritten imported start goal, pauses competing active root goals, validates the graph, and then writes selected-goal state. Subgraphs remain read-only planning views; use `mdkg graph ...` when authored graph state should be created.
177
+
161
178
  Register child bundle snapshots as read-only subgraphs with:
162
179
 
163
180
  ```bash
@@ -176,6 +193,14 @@ Use `mdkg subgraph materialize child_repo --target .mdkg/subgraphs --gitignore -
176
193
 
177
194
  Subgraph nodes use the subgraph alias as their qid prefix and can be inspected or packed, but mutations must happen in the owning child repo.
178
195
 
196
+ Launch a local read-only MCP server when an MCP-capable agent should inspect this graph without receiving mutation tools:
197
+
198
+ ```bash
199
+ mdkg mcp serve --stdio --root /path/to/repo
200
+ ```
201
+
202
+ The MCP server is stdio-only in this release. It exposes read-only tools for status, workspace/subgraph listing, search, show, in-memory pack generation, goal current/next, and validation. It does not expose task updates, goal activation, graph import, queue, event, archive, format, SQL, shell, arbitrary file reads, filesystem mutation, environment variables, or secret access. Future mutation allowlists remain design work.
203
+
179
204
  ## Archive and Work Mirrors
180
205
 
181
206
  Archive source/artifact files with:
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schema_version": 1,
3
3
  "tool": "mdkg",
4
- "mdkg_version": "0.3.4",
4
+ "mdkg_version": "0.3.6",
5
5
  "files": [
6
6
  {
7
7
  "path": ".mdkg/config.json",
@@ -61,7 +61,7 @@
61
61
  {
62
62
  "path": ".mdkg/README.md",
63
63
  "category": "mdkg_doc",
64
- "sha256": "5962993e8dffd53ccbceaaedd0b8f2a868421a3a1cc16d7002b661b39b7ebf79"
64
+ "sha256": "cecb50528b70c0c4e32f8a052a668b5d87d6ac542818229efa848a6b1ac42d62"
65
65
  },
66
66
  {
67
67
  "path": ".mdkg/skills/build-pack-and-execute-task/SKILL.md",
@@ -261,7 +261,7 @@
261
261
  {
262
262
  "path": "CLI_COMMAND_MATRIX.md",
263
263
  "category": "startup_doc",
264
- "sha256": "7322e6a2c47261f87dacd15ba0d93eba0d1e32eec0900a1e9f447ad13aaae860"
264
+ "sha256": "5321d82b594c1c0aa5574dcffbf21e5a1d3df89566b0f9acfc854fcaac3e13a7"
265
265
  },
266
266
  {
267
267
  "path": "llms.txt",
@@ -95,6 +95,8 @@ const VALUE_FLAGS = new Set([
95
95
  "--target",
96
96
  "--snapshot",
97
97
  "--family",
98
+ "--start-goal",
99
+ "--id-prefix",
98
100
  ]);
99
101
  const BOOLEAN_FLAGS = new Set([
100
102
  "--tolerant",
@@ -132,6 +134,8 @@ const BOOLEAN_FLAGS = new Set([
132
134
  "--allow-dirty",
133
135
  "--clean",
134
136
  "--gitignore",
137
+ "--select-goal",
138
+ "--stdio",
135
139
  ]);
136
140
  const FLAG_ALIASES = {
137
141
  "--o": "--out",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mdkg",
3
- "version": "0.3.4",
3
+ "version": "0.3.6",
4
4
  "description": "Markdown Knowledge Graph",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -33,6 +33,8 @@
33
33
  "smoke:spike": "npm run build && node scripts/smoke-spike.js",
34
34
  "smoke:goal-lifecycle": "npm run build && node scripts/smoke-goal-lifecycle.js",
35
35
  "smoke:bundle": "npm run build && node scripts/smoke-bundle.js",
36
+ "smoke:graph-clone": "npm run build && node scripts/smoke-graph-clone.js",
37
+ "smoke:mcp": "npm run build && node scripts/smoke-mcp.js",
36
38
  "smoke:bundle-import": "npm run smoke:subgraph",
37
39
  "smoke:visibility": "npm run build && node scripts/smoke-visibility.js",
38
40
  "smoke:sqlite": "npm run build && node scripts/smoke-sqlite.js",
@@ -42,7 +44,7 @@
42
44
  "cli:check": "npm run build && node scripts/cli_help_snapshot.js --check",
43
45
  "cli:contract": "npm run build && node scripts/generate-command-contract.js --check",
44
46
  "prepack": "npm run build && node scripts/assert-publish-ready.js",
45
- "prepublishOnly": "npm run test && npm run cli:check && npm run cli:contract && node dist/cli.js validate && npm run smoke:consumer && npm run smoke:matrix && npm run smoke:upgrade && npm run smoke:init && npm run smoke:capabilities && npm run smoke:db && npm run smoke:db-queue && npm run smoke:db-queue-cli && npm run smoke:db-events && npm run smoke:db-materializer && npm run smoke:db-snapshot && npm run smoke:archive-work && npm run smoke:work-invocation && npm run smoke:cli-ux-polish && npm run smoke:operator-health && npm run smoke:fix-plan && npm run smoke:branch-conflicts && npm run smoke:id-repair && npm run smoke:command-docs && npm run smoke:spike && npm run smoke:goal-lifecycle && npm run smoke:bundle && npm run smoke:subgraph && npm run smoke:visibility && npm run smoke:sqlite && npm run smoke:parallel && npm run smoke:goal && node scripts/assert-publish-ready.js",
47
+ "prepublishOnly": "npm run test && npm run cli:check && npm run cli:contract && node dist/cli.js validate && npm run smoke:consumer && npm run smoke:matrix && npm run smoke:upgrade && npm run smoke:init && npm run smoke:capabilities && npm run smoke:db && npm run smoke:db-queue && npm run smoke:db-queue-cli && npm run smoke:db-events && npm run smoke:db-materializer && npm run smoke:db-snapshot && npm run smoke:archive-work && npm run smoke:work-invocation && npm run smoke:cli-ux-polish && npm run smoke:operator-health && npm run smoke:fix-plan && npm run smoke:branch-conflicts && npm run smoke:id-repair && npm run smoke:command-docs && npm run smoke:spike && npm run smoke:goal-lifecycle && npm run smoke:bundle && npm run smoke:graph-clone && npm run smoke:mcp && npm run smoke:subgraph && npm run smoke:visibility && npm run smoke:sqlite && npm run smoke:parallel && npm run smoke:goal && node scripts/assert-publish-ready.js",
46
48
  "postinstall": "node scripts/postinstall.js",
47
49
  "smoke:subgraph": "npm run build && node scripts/smoke-subgraph.js"
48
50
  },