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.
- package/CHANGELOG.md +69 -2
- package/CLI_COMMAND_MATRIX.md +73 -2
- package/README.md +39 -1
- package/dist/cli.js +178 -1
- package/dist/command-contract.json +506 -2
- package/dist/commands/graph.js +704 -0
- package/dist/commands/mcp.js +647 -0
- package/dist/commands/validate.js +16 -11
- package/dist/init/CLI_COMMAND_MATRIX.md +28 -0
- package/dist/init/README.md +26 -1
- package/dist/init/init-manifest.json +3 -3
- package/dist/util/argparse.js +4 -0
- package/package.json +4 -2
package/CHANGELOG.md
CHANGED
|
@@ -8,9 +8,76 @@ mdkg is pre-v1 public alpha software. Command, graph, cache, bundle, and DAL con
|
|
|
8
8
|
|
|
9
9
|
## Unreleased
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
## 0.3.6 - 2026-06-17
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- Added `mdkg mcp serve --stdio` as a local read-only MCP server for status,
|
|
16
|
+
workspace/subgraph discovery, search, show, bounded in-memory packs, goal
|
|
17
|
+
current/next, and validation.
|
|
18
|
+
- Added packed `smoke:mcp` coverage that installs mdkg from a tarball in a
|
|
19
|
+
temp prefix, launches the stdio server, exercises root and subgraph reads,
|
|
20
|
+
and proves mutation-shaped tool calls fail closed.
|
|
21
|
+
|
|
22
|
+
### Fixed
|
|
23
|
+
|
|
24
|
+
- Prepared `0.3.6` graph import hardening after the `0.3.5` publish:
|
|
25
|
+
`mdkg graph import-template --select-goal --apply` now activates the
|
|
26
|
+
rewritten imported start goal, pauses competing active root goals, validates,
|
|
27
|
+
and only then writes selected-goal state.
|
|
28
|
+
|
|
29
|
+
### Changed
|
|
30
|
+
|
|
31
|
+
- Extended graph import dry-run/apply receipts with activation and paused-goal
|
|
32
|
+
details, and made active template imports fail before writing when
|
|
33
|
+
`--select-goal` is omitted and multiple active root goals would result.
|
|
34
|
+
|
|
35
|
+
### Security
|
|
36
|
+
|
|
37
|
+
- The MCP server is stdio-only and exposes no task, goal activation, graph
|
|
38
|
+
import, queue, event, archive, format, SQL, shell, arbitrary file-read,
|
|
39
|
+
filesystem mutation, environment, or secret-access tools.
|
|
40
|
+
|
|
41
|
+
## 0.3.5 - 2026-06-17
|
|
42
|
+
|
|
43
|
+
### Added
|
|
44
|
+
|
|
45
|
+
- Added `mdkg graph clone <source> --target <path>` to create a complete
|
|
46
|
+
authored mdkg graph in a separate contained target directory while preserving
|
|
47
|
+
source IDs.
|
|
48
|
+
- Added `mdkg graph fork <source> --target <path> --start-goal <goal-id>` to
|
|
49
|
+
preserve IDs in a separate target graph and optionally select the demo or
|
|
50
|
+
bootstrap start goal in that target.
|
|
51
|
+
- Added `mdkg graph import-template <source> --dry-run|--apply` for same-repo
|
|
52
|
+
template graph imports with deterministic canonical ID rewrites, structured
|
|
53
|
+
reference rewrites, safe body ID/qid rewrites, and optional selected-goal
|
|
54
|
+
setup.
|
|
55
|
+
- Added packed `smoke:graph-clone` coverage that installs mdkg from a tarball
|
|
56
|
+
in a temp prefix and validates clone, fork, import-template dry-run/apply,
|
|
57
|
+
source non-mutation, help text, search, pack, and validation behavior.
|
|
58
|
+
|
|
59
|
+
### Changed
|
|
60
|
+
|
|
61
|
+
- Updated README, seeded init README, command matrix, help snapshots,
|
|
62
|
+
prepublish gates, and publish-readiness assertions to document the
|
|
63
|
+
distinction between authored graph creation through `mdkg graph ...` and
|
|
64
|
+
read-only orchestration context through `mdkg subgraph ...`.
|
|
65
|
+
- Added `smoke:graph-clone` to `prepublishOnly` before the existing subgraph
|
|
66
|
+
smoke so graph template import behavior is proven before release.
|
|
67
|
+
- Consolidated website-template-mdkg dogfood planning under the 0.3.5 graph
|
|
68
|
+
clone/import goal without mutating downstream repositories or starting
|
|
69
|
+
website implementation.
|
|
70
|
+
|
|
71
|
+
### Security
|
|
72
|
+
|
|
73
|
+
- Clone/fork targets must be empty or absent, root-contained, and not nested
|
|
74
|
+
inside live directory sources.
|
|
75
|
+
- Same-repo template imports default to dry-run, require `--apply` to write,
|
|
76
|
+
run under the mdkg mutation lock, rebuild generated indexes, and validate the
|
|
77
|
+
resulting graph before selecting a start goal.
|
|
78
|
+
- Semantic ID collisions during template import require an explicit
|
|
79
|
+
`--id-prefix`; numeric canonical IDs are rewritten to the next unused ID so
|
|
80
|
+
links remain deterministic.
|
|
14
81
|
|
|
15
82
|
## 0.3.4 - 2026-06-17
|
|
16
83
|
|
package/CLI_COMMAND_MATRIX.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# CLI Command Matrix
|
|
2
2
|
|
|
3
|
-
as_of: 2026-06-
|
|
4
|
-
package_version_in_source: 0.3.
|
|
3
|
+
as_of: 2026-06-17
|
|
4
|
+
package_version_in_source: 0.3.6
|
|
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`
|
|
@@ -35,6 +36,7 @@ Primary commands:
|
|
|
35
36
|
- `next`
|
|
36
37
|
- `validate`
|
|
37
38
|
- `status`
|
|
39
|
+
- `mcp`
|
|
38
40
|
- `fix`
|
|
39
41
|
|
|
40
42
|
Advanced / maintenance commands:
|
|
@@ -55,6 +57,7 @@ Capability cache discovery is read-only and accessed through `mdkg capability ..
|
|
|
55
57
|
Optional reusable SPEC capability records are accessed through `mdkg spec ...`.
|
|
56
58
|
Archive sidecars are accessed through `mdkg archive ...`.
|
|
57
59
|
Full graph snapshot bundles are accessed through `mdkg bundle ...`.
|
|
60
|
+
Whole-graph clone, fork, and same-repo template import workflows are accessed through `mdkg graph ...`.
|
|
58
61
|
Read-only child graph orchestration is accessed through `mdkg subgraph ...`.
|
|
59
62
|
Work contract/order/receipt semantic mirrors are accessed through `mdkg work ...`.
|
|
60
63
|
Recursive long-running objective contracts are accessed through `mdkg goal ...`.
|
|
@@ -62,6 +65,7 @@ Fresh init workspaces default to the SQLite access cache backend; existing migra
|
|
|
62
65
|
Project application database foundation commands are accessed through `mdkg db ...`; `mdkg index` remains the compatibility shortcut for graph index rebuilds.
|
|
63
66
|
Operator health summaries are accessed through read-only `mdkg status ...`; deeper diagnostics remain under `mdkg doctor ...`.
|
|
64
67
|
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.
|
|
68
|
+
Local MCP integration is accessed through `mdkg mcp serve --stdio`; it exposes read-only graph/status/workspace/search/show/pack/goal/validate tools only.
|
|
65
69
|
|
|
66
70
|
## Global usage
|
|
67
71
|
|
|
@@ -615,6 +619,45 @@ JSON receipts:
|
|
|
615
619
|
- `show`: `{ action: "show", bundle, manifest }`
|
|
616
620
|
- `list`: `{ action: "list", count, items }`
|
|
617
621
|
|
|
622
|
+
### `mdkg graph`
|
|
623
|
+
|
|
624
|
+
When to use:
|
|
625
|
+
- clone or fork a complete mdkg graph into a separate target directory while preserving IDs
|
|
626
|
+
- import a template graph into the current repo with deterministic ID/link rewrites
|
|
627
|
+
- prepare selected-goal demo handoffs from reusable graph templates
|
|
628
|
+
|
|
629
|
+
Usage:
|
|
630
|
+
- `mdkg graph clone <source-bundle-or-mdkg-dir> --target <path> [--json]`
|
|
631
|
+
- `mdkg graph fork <source-bundle-or-mdkg-dir> --target <path> [--start-goal <goal-id>] [--json]`
|
|
632
|
+
- `mdkg graph import-template <source-bundle-or-mdkg-dir> [--start-goal <goal-id>] [--select-goal] [--id-prefix <prefix>] [--dry-run] [--apply] [--json]`
|
|
633
|
+
|
|
634
|
+
Flags:
|
|
635
|
+
- `--target <path>`
|
|
636
|
+
- `--start-goal <goal-id>`
|
|
637
|
+
- `--select-goal`
|
|
638
|
+
- `--id-prefix <prefix>`
|
|
639
|
+
- `--dry-run`
|
|
640
|
+
- `--apply`
|
|
641
|
+
- `--json`
|
|
642
|
+
|
|
643
|
+
Notes:
|
|
644
|
+
- `graph clone` and `graph fork` preserve IDs because the target is a separate graph namespace
|
|
645
|
+
- clone/fork targets must be empty or absent and stay under the current mdkg root
|
|
646
|
+
- live directory sources are never mutated; clone/fork refuses targets nested inside a live source directory
|
|
647
|
+
- `graph fork --start-goal <goal-id>` writes selected-goal state in the target graph after validation
|
|
648
|
+
- `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
|
|
649
|
+
- `graph import-template` defaults to dry-run unless `--apply` is supplied
|
|
650
|
+
- 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
|
|
651
|
+
- colliding semantic template IDs require `--id-prefix`
|
|
652
|
+
- `--select-goal` requires `--start-goal`; on apply it activates the imported start goal, pauses competing active root goals, validates, then writes selected-goal state
|
|
653
|
+
- importing active template goals without `--select-goal` fails before writing when it would create multiple active root goals
|
|
654
|
+
- subgraphs remain read-only bundle projections for orchestration context; use `graph clone|fork|import-template` when authored graph state should be created
|
|
655
|
+
|
|
656
|
+
JSON receipts:
|
|
657
|
+
- `clone`: `{ action: "graph.clone", ok, mode, source, target, source_hash, preserved_ids, files_written, skipped_paths, index, validation, warnings }`
|
|
658
|
+
- `fork`: `{ action: "graph.fork", ok, mode, source, target, source_hash, preserved_ids, files_written, skipped_paths, start_goal?, selected_goal?, index, validation, warnings }`
|
|
659
|
+
- `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 }`
|
|
660
|
+
|
|
618
661
|
### `mdkg subgraph`
|
|
619
662
|
|
|
620
663
|
When to use:
|
|
@@ -1046,6 +1089,34 @@ JSON receipt shape:
|
|
|
1046
1089
|
- `generated` reports index, skills, capabilities, and subgraph cache existence/staleness
|
|
1047
1090
|
- `summary` includes machine-readable warning and error counts plus messages
|
|
1048
1091
|
|
|
1092
|
+
### `mdkg mcp`
|
|
1093
|
+
|
|
1094
|
+
Usage:
|
|
1095
|
+
- `mdkg mcp serve --stdio`
|
|
1096
|
+
|
|
1097
|
+
When to use:
|
|
1098
|
+
- expose one local mdkg root to an MCP-capable agent or orchestrator
|
|
1099
|
+
- let an external agent inspect mdkg status, workspace/subgraph aliases, search/show results, in-memory packs, goal current/next, and validation without shelling out to individual CLI commands
|
|
1100
|
+
|
|
1101
|
+
Flags:
|
|
1102
|
+
- `--stdio`
|
|
1103
|
+
- `--root`, `-r <path>`
|
|
1104
|
+
|
|
1105
|
+
Boundaries:
|
|
1106
|
+
- stdio is the only transport in this release; mdkg opens no HTTP listener
|
|
1107
|
+
- bind the server to one graph root with `--root <path>` when launching from outside the repo
|
|
1108
|
+
- tool calls are read-only and return MCP `structuredContent` plus text content
|
|
1109
|
+
- exposed tools: `mdkg_status`, `mdkg_workspace_list`, `mdkg_search`, `mdkg_show`, `mdkg_pack`, `mdkg_goal_current`, `mdkg_goal_next`, and `mdkg_validate`
|
|
1110
|
+
- `mdkg_pack` builds an in-memory bounded pack and does not write `.mdkg/pack`
|
|
1111
|
+
- no task, goal activation, graph import, queue, event, archive, format, SQL, shell, arbitrary file-read, filesystem mutation, environment, or secret-access tool is exposed
|
|
1112
|
+
- mutation allowlists and broader CLI parity are future design work, not part of this command surface
|
|
1113
|
+
- stdout is reserved for newline-delimited JSON-RPC MCP messages; diagnostics must stay off stdout
|
|
1114
|
+
|
|
1115
|
+
JSON-RPC receipt shapes:
|
|
1116
|
+
- initialize: `{ protocolVersion, capabilities: { tools }, serverInfo, instructions }`
|
|
1117
|
+
- `tools/list`: `{ tools: [{ name, title, description, inputSchema, annotations }] }`
|
|
1118
|
+
- `tools/call`: MCP tool result with `{ content, structuredContent, isError }`
|
|
1119
|
+
|
|
1049
1120
|
### `mdkg fix`
|
|
1050
1121
|
|
|
1051
1122
|
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.3.
|
|
17
|
+
Current package version in source: `0.3.6`
|
|
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,29 @@ 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. With
|
|
171
|
+
`--select-goal --apply`, import-template activates the rewritten imported start
|
|
172
|
+
goal, pauses competing active root goals, validates the graph, and then writes
|
|
173
|
+
selected-goal state. Subgraphs remain read-only planning views; use
|
|
174
|
+
`mdkg graph ...` when authored graph state should be created.
|
|
175
|
+
|
|
153
176
|
Register a child repo bundle as a read-only subgraph planning view:
|
|
154
177
|
|
|
155
178
|
```bash
|
|
@@ -185,6 +208,20 @@ Materialized trees are generated local state, ignored by graph indexing/search/v
|
|
|
185
208
|
|
|
186
209
|
Subgraph nodes are projected under the subgraph alias, for example `child_repo:task-1`. They are available to `list`, `search`, `show`, `pack`, capability discovery, and `capability resolve`, but remain read-only; mutate the child repo and sync its root-owned bundle snapshot to change subgraph content. Root-authored relationship and reference fields can point at configured subgraph qids such as `child_repo:work.example`; local ownership fields such as `epic`, `parent`, `prev`, and `next` stay local-only. Stale subgraphs warn during planning reads and fail `mdkg subgraph verify`. Public or internal subgraphs must be backed by public bundle profiles; private subgraphs stay private planning context.
|
|
187
210
|
|
|
211
|
+
Launch a local read-only MCP server when an MCP-capable agent should inspect a
|
|
212
|
+
specific mdkg graph without receiving mutation tools:
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
mdkg mcp serve --stdio --root /path/to/repo
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
The MCP surface is stdio-only in this release. It exposes read-only tools for
|
|
219
|
+
status, workspace/subgraph listing, search, show, in-memory pack generation,
|
|
220
|
+
goal current/next, and validation. It does not expose task updates, goal
|
|
221
|
+
activation, graph import, queue, event, archive, format, SQL, shell, arbitrary
|
|
222
|
+
file reads, filesystem mutation, environment variables, or secret access.
|
|
223
|
+
Future mutation allowlists remain design work.
|
|
224
|
+
|
|
188
225
|
Validate before handoff or commit:
|
|
189
226
|
|
|
190
227
|
```bash
|
|
@@ -309,6 +346,7 @@ These are the commands new users and agents should learn first:
|
|
|
309
346
|
- `mdkg task`
|
|
310
347
|
- `mdkg validate`
|
|
311
348
|
- `mdkg status`
|
|
349
|
+
- `mdkg mcp`
|
|
312
350
|
- `mdkg fix`
|
|
313
351
|
|
|
314
352
|
Advanced / maintenance commands still exist, but they are not the first-run story:
|
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"));
|
|
@@ -19,12 +20,14 @@ const validate_1 = require("./commands/validate");
|
|
|
19
20
|
const format_1 = require("./commands/format");
|
|
20
21
|
const doctor_1 = require("./commands/doctor");
|
|
21
22
|
const status_1 = require("./commands/status");
|
|
23
|
+
const mcp_1 = require("./commands/mcp");
|
|
22
24
|
const fix_1 = require("./commands/fix");
|
|
23
25
|
const db_1 = require("./commands/db");
|
|
24
26
|
const capability_1 = require("./commands/capability");
|
|
25
27
|
const spec_1 = require("./commands/spec");
|
|
26
28
|
const archive_1 = require("./commands/archive");
|
|
27
29
|
const bundle_1 = require("./commands/bundle");
|
|
30
|
+
const graph_1 = require("./commands/graph");
|
|
28
31
|
const subgraph_1 = require("./commands/subgraph");
|
|
29
32
|
const checkpoint_1 = require("./commands/checkpoint");
|
|
30
33
|
const init_1 = require("./commands/init");
|
|
@@ -69,6 +72,7 @@ function printUsage(log) {
|
|
|
69
72
|
log(" spec List, show, and validate optional SPEC.md capability records");
|
|
70
73
|
log(" archive Add, list, show, verify, and compress archive sidecars");
|
|
71
74
|
log(" bundle Create, list, show, and verify full graph snapshot bundles");
|
|
75
|
+
log(" graph Clone and fork whole mdkg graphs");
|
|
72
76
|
log(" subgraph Register, audit, plan, sync, materialize, and verify read-only child graph snapshots");
|
|
73
77
|
log(" work Create and update work contracts, orders, receipts, and artifacts");
|
|
74
78
|
log(" goal Inspect and advance recursive goal nodes");
|
|
@@ -76,6 +80,7 @@ function printUsage(log) {
|
|
|
76
80
|
log(" next Suggest the next work item");
|
|
77
81
|
log(" validate Validate frontmatter + graph");
|
|
78
82
|
log(" status Show read-only operator health summary");
|
|
83
|
+
log(" mcp Serve local read-only MCP tools over stdio");
|
|
79
84
|
log(" fix Plan read-only repairs with receipt-shaped JSON");
|
|
80
85
|
log("\nAdvanced / maintenance commands:");
|
|
81
86
|
log(" db Project database and index-cache commands");
|
|
@@ -554,6 +559,45 @@ function printBundleHelp(log, subcommand) {
|
|
|
554
559
|
}
|
|
555
560
|
printGlobalOptions(log);
|
|
556
561
|
}
|
|
562
|
+
function printGraphHelp(log, subcommand) {
|
|
563
|
+
switch ((subcommand ?? "").toLowerCase()) {
|
|
564
|
+
case "clone":
|
|
565
|
+
log("Usage:");
|
|
566
|
+
log(" mdkg graph clone <source-bundle-or-mdkg-dir> --target <path> [--json]");
|
|
567
|
+
log("\nNotes:");
|
|
568
|
+
log(" - clones a complete graph into an empty contained target directory");
|
|
569
|
+
log(" - preserves IDs because the target is a separate graph namespace");
|
|
570
|
+
log(" - source bundle or source directory is never mutated");
|
|
571
|
+
break;
|
|
572
|
+
case "fork":
|
|
573
|
+
log("Usage:");
|
|
574
|
+
log(" mdkg graph fork <source-bundle-or-mdkg-dir> --target <path> [--start-goal <goal-id>] [--json]");
|
|
575
|
+
log("\nNotes:");
|
|
576
|
+
log(" - forks a complete graph into an empty contained target directory");
|
|
577
|
+
log(" - preserves IDs and can select a start goal in the target graph");
|
|
578
|
+
log(" - source bundle or source directory is never mutated");
|
|
579
|
+
break;
|
|
580
|
+
case "import-template":
|
|
581
|
+
log("Usage:");
|
|
582
|
+
log(" mdkg graph import-template <source-bundle-or-mdkg-dir> [--start-goal <goal-id>] [--select-goal] [--id-prefix <prefix>] [--dry-run] [--apply] [--json]");
|
|
583
|
+
log("\nNotes:");
|
|
584
|
+
log(" - imports authored .mdkg/work template nodes into the current graph");
|
|
585
|
+
log(" - defaults to dry-run unless --apply is supplied");
|
|
586
|
+
log(" - rewrites canonical numeric IDs and structured graph links deterministically");
|
|
587
|
+
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");
|
|
588
|
+
break;
|
|
589
|
+
default:
|
|
590
|
+
log("Usage:");
|
|
591
|
+
log(" mdkg graph clone <source-bundle-or-mdkg-dir> --target <path> [--json]");
|
|
592
|
+
log(" mdkg graph fork <source-bundle-or-mdkg-dir> --target <path> [--start-goal <goal-id>] [--json]");
|
|
593
|
+
log(" mdkg graph import-template <source-bundle-or-mdkg-dir> [--start-goal <goal-id>] [--select-goal] [--id-prefix <prefix>] [--dry-run] [--apply] [--json]");
|
|
594
|
+
log("\nNotes:");
|
|
595
|
+
log(" - graph clone/fork create authored graph state in separate target directories and preserve IDs");
|
|
596
|
+
log(" - graph import-template imports template work nodes into the current graph with rewritten IDs");
|
|
597
|
+
log(" - subgraphs remain read-only bundle projections for orchestration context");
|
|
598
|
+
}
|
|
599
|
+
printGlobalOptions(log);
|
|
600
|
+
}
|
|
557
601
|
function printSubgraphHelp(log, subcommand) {
|
|
558
602
|
switch ((subcommand ?? "").toLowerCase()) {
|
|
559
603
|
case "add":
|
|
@@ -882,6 +926,29 @@ function printStatusHelp(log) {
|
|
|
882
926
|
log(" --json Emit machine-readable JSON output");
|
|
883
927
|
printGlobalOptions(log);
|
|
884
928
|
}
|
|
929
|
+
function printMcpHelp(log, subcommand) {
|
|
930
|
+
switch ((subcommand ?? "").toLowerCase()) {
|
|
931
|
+
case "serve":
|
|
932
|
+
log("Usage:");
|
|
933
|
+
log(" mdkg mcp serve --stdio");
|
|
934
|
+
log("\nBoundary:");
|
|
935
|
+
log(" - starts one local Model Context Protocol server bound to the selected --root");
|
|
936
|
+
log(" - stdio is the only transport in this release; no HTTP listener is opened");
|
|
937
|
+
log(" - exposes read-only tools for status, workspace list, search, show, pack, goal current/next, and validate");
|
|
938
|
+
log(" - exposes no task, goal, graph, queue, event, archive, format, SQL, shell, filesystem, or environment mutation tools");
|
|
939
|
+
log(" - stdout is reserved for newline-delimited JSON-RPC MCP messages");
|
|
940
|
+
printGlobalOptions(log);
|
|
941
|
+
return;
|
|
942
|
+
default:
|
|
943
|
+
log("Usage:");
|
|
944
|
+
log(" mdkg mcp serve --stdio");
|
|
945
|
+
log("\nBoundary:");
|
|
946
|
+
log(" - local read-only MCP server for mdkg graph inspection");
|
|
947
|
+
log(" - use --root <path> to select the mdkg graph explicitly");
|
|
948
|
+
log(" - phase one is stdio-only and does not expose mutation tools");
|
|
949
|
+
printGlobalOptions(log);
|
|
950
|
+
}
|
|
951
|
+
}
|
|
885
952
|
function printFixHelp(log, subcommand) {
|
|
886
953
|
switch ((subcommand ?? "").toLowerCase()) {
|
|
887
954
|
case "plan":
|
|
@@ -1020,6 +1087,9 @@ function printCommandHelp(log, command, subcommand) {
|
|
|
1020
1087
|
case "bundle":
|
|
1021
1088
|
printBundleHelp(log, subcommand);
|
|
1022
1089
|
return;
|
|
1090
|
+
case "graph":
|
|
1091
|
+
printGraphHelp(log, subcommand);
|
|
1092
|
+
return;
|
|
1023
1093
|
case "subgraph":
|
|
1024
1094
|
printSubgraphHelp(log, subcommand);
|
|
1025
1095
|
return;
|
|
@@ -1047,6 +1117,9 @@ function printCommandHelp(log, command, subcommand) {
|
|
|
1047
1117
|
case "status":
|
|
1048
1118
|
printStatusHelp(log);
|
|
1049
1119
|
return;
|
|
1120
|
+
case "mcp":
|
|
1121
|
+
printMcpHelp(log, subcommand);
|
|
1122
|
+
return;
|
|
1050
1123
|
case "fix":
|
|
1051
1124
|
printFixHelp(log, subcommand);
|
|
1052
1125
|
return;
|
|
@@ -1687,6 +1760,49 @@ function runBundleSubcommand(parsed, root) {
|
|
|
1687
1760
|
throw new errors_1.UsageError("bundle requires create/list/show/verify");
|
|
1688
1761
|
}
|
|
1689
1762
|
}
|
|
1763
|
+
function runGraphSubcommand(parsed, root) {
|
|
1764
|
+
const subcommand = (parsed.positionals[1] ?? "").toLowerCase();
|
|
1765
|
+
const source = parsed.positionals[2];
|
|
1766
|
+
const target = requireFlagValue("--target", parsed.flags["--target"]);
|
|
1767
|
+
const json = parseBooleanFlag("--json", parsed.flags["--json"]);
|
|
1768
|
+
switch (subcommand) {
|
|
1769
|
+
case "clone": {
|
|
1770
|
+
if (!source || parsed.positionals.length > 3) {
|
|
1771
|
+
throw new errors_1.UsageError("graph clone requires <source-bundle-or-mdkg-dir>");
|
|
1772
|
+
}
|
|
1773
|
+
if (!target) {
|
|
1774
|
+
throw new errors_1.UsageError("graph clone requires --target <path>");
|
|
1775
|
+
}
|
|
1776
|
+
(0, graph_1.runGraphCloneCommand)({ root, source, target, json });
|
|
1777
|
+
return 0;
|
|
1778
|
+
}
|
|
1779
|
+
case "fork": {
|
|
1780
|
+
if (!source || parsed.positionals.length > 3) {
|
|
1781
|
+
throw new errors_1.UsageError("graph fork requires <source-bundle-or-mdkg-dir>");
|
|
1782
|
+
}
|
|
1783
|
+
if (!target) {
|
|
1784
|
+
throw new errors_1.UsageError("graph fork requires --target <path>");
|
|
1785
|
+
}
|
|
1786
|
+
const startGoal = requireFlagValue("--start-goal", parsed.flags["--start-goal"]);
|
|
1787
|
+
(0, graph_1.runGraphForkCommand)({ root, source, target, startGoal, json });
|
|
1788
|
+
return 0;
|
|
1789
|
+
}
|
|
1790
|
+
case "import-template": {
|
|
1791
|
+
if (!source || parsed.positionals.length > 3) {
|
|
1792
|
+
throw new errors_1.UsageError("graph import-template requires <source-bundle-or-mdkg-dir>");
|
|
1793
|
+
}
|
|
1794
|
+
const startGoal = requireFlagValue("--start-goal", parsed.flags["--start-goal"]);
|
|
1795
|
+
const idPrefix = requireFlagValue("--id-prefix", parsed.flags["--id-prefix"]);
|
|
1796
|
+
const dryRun = parseBooleanFlag("--dry-run", parsed.flags["--dry-run"]);
|
|
1797
|
+
const apply = parseBooleanFlag("--apply", parsed.flags["--apply"]);
|
|
1798
|
+
const selectGoal = parseBooleanFlag("--select-goal", parsed.flags["--select-goal"]);
|
|
1799
|
+
(0, graph_1.runGraphImportTemplateCommand)({ root, source, startGoal, idPrefix, dryRun, apply, selectGoal, json });
|
|
1800
|
+
return 0;
|
|
1801
|
+
}
|
|
1802
|
+
default:
|
|
1803
|
+
throw new errors_1.UsageError("graph requires clone/fork/import-template");
|
|
1804
|
+
}
|
|
1805
|
+
}
|
|
1690
1806
|
function runSubgraphSubcommand(parsed, root) {
|
|
1691
1807
|
const subcommand = (parsed.positionals[1] ?? "").toLowerCase();
|
|
1692
1808
|
const json = parseBooleanFlag("--json", parsed.flags["--json"]);
|
|
@@ -2479,6 +2595,8 @@ function runCommand(parsed, root, runtime) {
|
|
|
2479
2595
|
return runArchiveSubcommand(parsed, root);
|
|
2480
2596
|
case "bundle":
|
|
2481
2597
|
return runBundleSubcommand(parsed, root);
|
|
2598
|
+
case "graph":
|
|
2599
|
+
return runGraphSubcommand(parsed, root);
|
|
2482
2600
|
case "subgraph":
|
|
2483
2601
|
return runSubgraphSubcommand(parsed, root);
|
|
2484
2602
|
case "work":
|
|
@@ -2699,6 +2817,8 @@ function runCommand(parsed, root, runtime) {
|
|
|
2699
2817
|
(0, status_1.runStatusCommand)({ root, json });
|
|
2700
2818
|
return 0;
|
|
2701
2819
|
}
|
|
2820
|
+
case "mcp":
|
|
2821
|
+
throw new errors_1.UsageError("mcp serve requires the async CLI entrypoint");
|
|
2702
2822
|
case "fix": {
|
|
2703
2823
|
const sub = (parsed.positionals[1] ?? "").toLowerCase();
|
|
2704
2824
|
if (!sub) {
|
|
@@ -2749,6 +2869,18 @@ function runCommand(parsed, root, runtime) {
|
|
|
2749
2869
|
return 1;
|
|
2750
2870
|
}
|
|
2751
2871
|
}
|
|
2872
|
+
async function runMcpSubcommand(parsed, root) {
|
|
2873
|
+
const sub = (parsed.positionals[1] ?? "").toLowerCase();
|
|
2874
|
+
if (sub !== "serve") {
|
|
2875
|
+
throw new errors_1.UsageError("mcp requires serve --stdio");
|
|
2876
|
+
}
|
|
2877
|
+
if (parsed.positionals.length > 2) {
|
|
2878
|
+
throw new errors_1.UsageError("mcp serve does not accept positional arguments");
|
|
2879
|
+
}
|
|
2880
|
+
const stdio = parseBooleanFlag("--stdio", parsed.flags["--stdio"]);
|
|
2881
|
+
await (0, mcp_1.runMcpServeCommand)({ root, stdio });
|
|
2882
|
+
return 0;
|
|
2883
|
+
}
|
|
2752
2884
|
function runCli(argv, runtime = {}) {
|
|
2753
2885
|
const io = resolveRuntime(runtime);
|
|
2754
2886
|
const parsed = (0, argparse_1.parseArgs)(argv);
|
|
@@ -2786,8 +2918,53 @@ function runCli(argv, runtime = {}) {
|
|
|
2786
2918
|
return handleCommandError(err, command, io);
|
|
2787
2919
|
}
|
|
2788
2920
|
}
|
|
2921
|
+
async function runCliAsync(argv, runtime = {}) {
|
|
2922
|
+
const io = resolveRuntime(runtime);
|
|
2923
|
+
const parsed = (0, argparse_1.parseArgs)(argv);
|
|
2924
|
+
if (parsed.error) {
|
|
2925
|
+
io.error(parsed.error);
|
|
2926
|
+
printUsage(io.log);
|
|
2927
|
+
return 1;
|
|
2928
|
+
}
|
|
2929
|
+
if (parsed.help) {
|
|
2930
|
+
printCommandHelp(io.log, parsed.positionals[0], parsed.positionals[1]);
|
|
2931
|
+
return 0;
|
|
2932
|
+
}
|
|
2933
|
+
if (parsed.version) {
|
|
2934
|
+
io.log(readPackageVersion());
|
|
2935
|
+
return 0;
|
|
2936
|
+
}
|
|
2937
|
+
const command = (parsed.positionals[0] ?? "").toLowerCase();
|
|
2938
|
+
if (!command) {
|
|
2939
|
+
printUsage(io.log);
|
|
2940
|
+
return 0;
|
|
2941
|
+
}
|
|
2942
|
+
if (command === "help") {
|
|
2943
|
+
printCommandHelp(io.log, parsed.positionals[1], parsed.positionals[2]);
|
|
2944
|
+
return 0;
|
|
2945
|
+
}
|
|
2946
|
+
const root = parsed.root ? path_1.default.resolve(parsed.root) : io.cwd();
|
|
2947
|
+
if (shouldRequireConfig(command, parsed.flags) && !hasConfig(root)) {
|
|
2948
|
+
printRootError(io.error, root);
|
|
2949
|
+
return 1;
|
|
2950
|
+
}
|
|
2951
|
+
try {
|
|
2952
|
+
if (command === "mcp") {
|
|
2953
|
+
return await runMcpSubcommand(parsed, root);
|
|
2954
|
+
}
|
|
2955
|
+
return runCommand(parsed, root, io);
|
|
2956
|
+
}
|
|
2957
|
+
catch (err) {
|
|
2958
|
+
return handleCommandError(err, command, io);
|
|
2959
|
+
}
|
|
2960
|
+
}
|
|
2789
2961
|
function main(argv = process.argv.slice(2)) {
|
|
2790
|
-
|
|
2962
|
+
runCliAsync(argv, { cwd: () => process.cwd() })
|
|
2963
|
+
.then((code) => process.exit(code))
|
|
2964
|
+
.catch((err) => {
|
|
2965
|
+
console.error(err instanceof Error ? err.message : String(err));
|
|
2966
|
+
process.exit(4);
|
|
2967
|
+
});
|
|
2791
2968
|
}
|
|
2792
2969
|
if (require.main === module) {
|
|
2793
2970
|
main();
|