mdkg 0.1.6 → 0.1.7
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 +30 -0
- package/README.md +54 -3
- package/dist/cli.js +208 -3
- package/dist/commands/bundle.js +6 -0
- package/dist/commands/checkpoint.js +1 -1
- package/dist/commands/db.js +560 -0
- package/dist/commands/doctor.js +18 -0
- package/dist/commands/format.js +10 -5
- package/dist/commands/index.js +16 -11
- package/dist/commands/init.js +3 -0
- package/dist/commands/new.js +17 -2
- package/dist/commands/subgraph.js +416 -0
- package/dist/commands/upgrade.js +43 -7
- package/dist/commands/work.js +21 -19
- package/dist/core/config.js +103 -0
- package/dist/core/project_db.js +108 -0
- package/dist/core/project_db_migrations.js +600 -0
- package/dist/core/project_db_snapshot.js +510 -0
- package/dist/graph/agent_file_types.js +14 -9
- package/dist/graph/node.js +2 -2
- package/dist/graph/skills_index_cache.js +1 -0
- package/dist/graph/sqlite_index.js +25 -0
- package/dist/graph/validate_graph.js +75 -63
- package/dist/init/AGENT_START.md +13 -1
- package/dist/init/CLI_COMMAND_MATRIX.md +37 -0
- package/dist/init/README.md +25 -0
- package/dist/init/config.json +11 -0
- package/dist/init/core/rule-3-cli-contract.md +7 -0
- package/dist/init/core/rule-4-repo-safety-and-ignores.md +35 -2
- package/dist/init/init-manifest.json +7 -7
- package/dist/util/argparse.js +5 -0
- package/dist/util/refs.js +2 -2
- package/package.json +4 -2
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,36 @@ This project follows a pragmatic changelog style inspired by Keep a Changelog. V
|
|
|
6
6
|
|
|
7
7
|
mdkg is pre-v1 public alpha software. Command, graph, cache, bundle, and DAL contracts may change quickly while the project converges on a stable v1 surface.
|
|
8
8
|
|
|
9
|
+
## 0.1.7 - 2026-06-04
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- Added `mdkg db` as the project database command namespace for the pre-v1 DB foundation.
|
|
14
|
+
- Added `mdkg db index rebuild/status/verify` while keeping `mdkg index` as the compatibility shortcut for graph index rebuilds.
|
|
15
|
+
- Added generic project DB config and `.mdkg/db/{schema,runtime,state,receipts}` layout support, separate from the rebuildable `.mdkg/index` graph cache.
|
|
16
|
+
- Added `mdkg db init` to create the generic project DB scaffold, write `.mdkg/db/project-db.json`, and enable `db.enabled` without creating an active runtime SQLite database.
|
|
17
|
+
- Added `mdkg db migrate` using Node's built-in `node:sqlite` for mdkg-owned generic foundation migrations with migration keys, order, checksums, and applied timestamps.
|
|
18
|
+
- Added `mdkg db verify` and `mdkg db stats` for non-mutating project DB health checks and deterministic summaries.
|
|
19
|
+
- Added `mdkg db snapshot seal/verify/status/dump/diff` for opt-in sealed SQLite checkpoints, manifests, canonical dumps, and deterministic review diffs.
|
|
20
|
+
- Added prefix-based cross-subgraph graph references so root-authored nodes can point at configured child graph qids such as `child_repo:work.example`.
|
|
21
|
+
- Added `mdkg subgraph sync [alias|--all] [--dry-run] [--allow-dirty] [--json]` to rebuild root-owned child bundle snapshots from configured clean child Git repo `source_path` entries.
|
|
22
|
+
- Added `mdkg subgraph materialize [alias|--all] --target <path> [--clean] [--gitignore] [--json]` for generated read-only inspection trees extracted from configured subgraph bundles.
|
|
23
|
+
- Added unit and packed-package smoke coverage for subgraph sync dry-runs, child Git cleanliness checks, root-owned bundle refresh, materialization marker safety, and cross-subgraph refs.
|
|
24
|
+
- Added unit, packed-package init, dedicated `smoke:db`, and `smoke:db-snapshot` coverage for project DB runtime and sealed snapshot workflows.
|
|
25
|
+
|
|
26
|
+
### Changed
|
|
27
|
+
|
|
28
|
+
- Init, upgrade, README, command matrix, and agent-start docs now distinguish `.mdkg/index` as rebuildable graph cache state from `.mdkg/db` as project application database state.
|
|
29
|
+
- Project DB runtime SQLite files, WAL/SHM/journal files, locks, and temp files remain ignored by default; schema files, manifests, receipts, and opt-in sealed snapshots remain policy-driven.
|
|
30
|
+
- `mdkg subgraph refresh` remains reload-only; `mdkg subgraph sync` is now the explicit command that builds child bundles.
|
|
31
|
+
- Init and upgrade ignore guidance now treats `.mdkg/subgraphs/` as local generated inspection state.
|
|
32
|
+
- Bundle creation, local graph indexing, search, validate, pack, and SQLite hydration keep ignoring materialized subgraph trees so extracted child files never become root-owned graph nodes.
|
|
33
|
+
|
|
34
|
+
### Fixed
|
|
35
|
+
|
|
36
|
+
- Relationship and reference fields now preserve `alias:id` qids while still treating `scheme://...` values as external URI refs.
|
|
37
|
+
- Local ownership fields such as `epic`, `parent`, `prev`, and `next` reject subgraph qids, preserving child graph ownership boundaries.
|
|
38
|
+
|
|
9
39
|
## 0.1.6 - 2026-06-01
|
|
10
40
|
|
|
11
41
|
### Fixed
|
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.1.
|
|
17
|
+
Current package version in source: `0.1.7`
|
|
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
|
|
|
@@ -126,7 +126,7 @@ Bundles are explicit graph transport artifacts, separate from task context packs
|
|
|
126
126
|
Register a child repo bundle as a read-only subgraph planning view:
|
|
127
127
|
|
|
128
128
|
```bash
|
|
129
|
-
mdkg subgraph add child_repo
|
|
129
|
+
mdkg subgraph add child_repo .mdkg/bundles/private/subgraphs/child_repo.mdkg.zip --source-path projects/child_repo
|
|
130
130
|
mdkg subgraph list --json
|
|
131
131
|
mdkg search "child capability"
|
|
132
132
|
mdkg show child_repo:work.example
|
|
@@ -135,7 +135,24 @@ mdkg capability resolve "child capability" --json
|
|
|
135
135
|
mdkg subgraph verify child_repo --json
|
|
136
136
|
```
|
|
137
137
|
|
|
138
|
-
|
|
138
|
+
When the child repo is available under a configured root-relative `source_path`, refresh the root-owned bundle snapshot explicitly:
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
mdkg subgraph sync child_repo --dry-run --json
|
|
142
|
+
mdkg subgraph sync child_repo --json
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
`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
|
+
|
|
147
|
+
Generate a local read-only inspection tree when humans need to browse extracted child graph files:
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
mdkg subgraph materialize child_repo --target .mdkg/subgraphs --clean --gitignore --json
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Materialized trees are generated local state, ignored by graph indexing/search/validation/packing/bundles/SQLite hydration, and protected by a `.mdkg-materialized.json` marker before clean replacement.
|
|
154
|
+
|
|
155
|
+
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.
|
|
139
156
|
|
|
140
157
|
Validate before handoff or commit:
|
|
141
158
|
|
|
@@ -219,6 +236,8 @@ mdkg lives under a hidden root directory:
|
|
|
219
236
|
- `.mdkg/bundles/` optional committed full graph snapshot bundles
|
|
220
237
|
- `.mdkg/index/mdkg.sqlite` optional committed, rebuildable SQLite access cache
|
|
221
238
|
- `.mdkg/index/subgraphs.json` generated read-only subgraph projection cache
|
|
239
|
+
- `.mdkg/db/` future project application database layout and receipts
|
|
240
|
+
- `.mdkg/subgraphs/` generated materialized subgraph inspection trees
|
|
222
241
|
- `.agents/skills/` Codex/OpenAI-facing mirrored skills
|
|
223
242
|
- `.claude/skills/` Claude-facing mirrored skills
|
|
224
243
|
- `.mdkg/index/*.json` generated JSON compatibility cache files
|
|
@@ -317,6 +336,36 @@ Fresh `mdkg init` workspaces default to `index.backend: sqlite`, which writes `.
|
|
|
317
336
|
|
|
318
337
|
Mutating commands use a workspace mutation lock plus atomic writes. SQLite mode additionally reserves numeric ids in a SQLite transaction before writing Markdown so parallel `mdkg new` and checkpoint calls avoid naming conflicts. Skipped ids after failed writes are acceptable because Markdown remains canonical.
|
|
319
338
|
|
|
339
|
+
## Project DB Layout
|
|
340
|
+
|
|
341
|
+
`.mdkg/db` is reserved for project application database state, separate from
|
|
342
|
+
the rebuildable `.mdkg/index` graph cache. Run `mdkg db init` to create the
|
|
343
|
+
generic scaffold and explicitly enable `db.enabled` in config. The generic
|
|
344
|
+
layout is `.mdkg/db/schema`, `.mdkg/db/runtime`, `.mdkg/db/state`, and
|
|
345
|
+
`.mdkg/db/receipts`; `mdkg db init` also writes a deterministic
|
|
346
|
+
`.mdkg/db/project-db.json` manifest.
|
|
347
|
+
|
|
348
|
+
Runtime DB files, WAL, SHM, journal, lock, and temp files are ignored by
|
|
349
|
+
default. `mdkg db init` does not create an active runtime SQLite database.
|
|
350
|
+
Run `mdkg db migrate` after init to create or update the active runtime
|
|
351
|
+
SQLite database at the configured `db.runtime_path`; the first migration writes
|
|
352
|
+
only mdkg-owned generic foundation tables and records migration order,
|
|
353
|
+
checksums, and applied timestamps.
|
|
354
|
+
Use `mdkg db verify` for non-mutating health checks over config, layout,
|
|
355
|
+
runtime SQLite integrity, migration metadata, and transient runtime files. Use
|
|
356
|
+
`mdkg db stats` for deterministic table counts, DB size, migration state,
|
|
357
|
+
receipt-file count, and state snapshot presence.
|
|
358
|
+
Use `mdkg db snapshot seal` to create an explicit sealed checkpoint at
|
|
359
|
+
`.mdkg/db/state/project.sqlite` with `.mdkg/db/state/project.manifest.json`.
|
|
360
|
+
Use `mdkg db snapshot verify` and `mdkg db snapshot status` for checkpoint
|
|
361
|
+
health, and use `mdkg db snapshot dump` / `mdkg db snapshot diff` as
|
|
362
|
+
deterministic review aids for SQLite snapshots instead of comparing raw binary
|
|
363
|
+
bytes.
|
|
364
|
+
Schema files, manifests, receipt artifacts, and opt-in sealed snapshots remain
|
|
365
|
+
commit-eligible by explicit repo policy. `mdkg doctor` warns when active runtime
|
|
366
|
+
or transient project DB files are present so they are not accidentally committed
|
|
367
|
+
as sealed state.
|
|
368
|
+
|
|
320
369
|
## Goal nodes
|
|
321
370
|
|
|
322
371
|
Goal nodes are durable recursive objective contracts. Use `mdkg new goal "<objective>"` when a human or agent needs to keep working across multiple concrete nodes until a measurable end condition is achieved.
|
|
@@ -400,6 +449,8 @@ mdkg is not a secret store.
|
|
|
400
449
|
Use these defaults:
|
|
401
450
|
- keep generated `.mdkg/index/*.json`, temp, lock, WAL, SHM, and journal files gitignored
|
|
402
451
|
- commit `.mdkg/index/mdkg.sqlite` only when the repo intentionally tracks a reasonably sized rebuildable access cache
|
|
452
|
+
- keep `.mdkg/db/runtime/` and `.mdkg/db` WAL/SHM/journal/lock/temp files gitignored
|
|
453
|
+
- commit `.mdkg/db/schema`, manifests, receipts, and sealed state snapshots only by explicit repo policy
|
|
403
454
|
- keep `.mdkg/pack/` gitignored
|
|
404
455
|
- keep `.mdkg/archive/**/source/` gitignored unless a repo intentionally commits raw local copies
|
|
405
456
|
- commit archive sidecar `.md` metadata and deterministic `.zip` caches when they are needed for reviewable evidence
|
package/dist/cli.js
CHANGED
|
@@ -18,6 +18,7 @@ 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 db_1 = require("./commands/db");
|
|
21
22
|
const capability_1 = require("./commands/capability");
|
|
22
23
|
const archive_1 = require("./commands/archive");
|
|
23
24
|
const bundle_1 = require("./commands/bundle");
|
|
@@ -64,13 +65,14 @@ function printUsage(log) {
|
|
|
64
65
|
log(" capability List, search, show, and resolve cached capability surfaces");
|
|
65
66
|
log(" archive Add, list, show, verify, and compress archive sidecars");
|
|
66
67
|
log(" bundle Create, list, show, and verify full graph snapshot bundles");
|
|
67
|
-
log(" subgraph Register and verify read-only child graph snapshots");
|
|
68
|
+
log(" subgraph Register, sync, materialize, and verify read-only child graph snapshots");
|
|
68
69
|
log(" work Create and update work contracts, orders, receipts, and artifacts");
|
|
69
70
|
log(" goal Inspect and advance recursive goal nodes");
|
|
70
71
|
log(" task Start, update, and complete task-like nodes");
|
|
71
72
|
log(" next Suggest the next work item");
|
|
72
73
|
log(" validate Validate frontmatter + graph");
|
|
73
74
|
log("\nAdvanced / maintenance commands:");
|
|
75
|
+
log(" db Project database and index-cache commands");
|
|
74
76
|
log(" event Enable or append episodic event logs");
|
|
75
77
|
log(" checkpoint Create a checkpoint node");
|
|
76
78
|
log(" index Build the global index");
|
|
@@ -178,6 +180,61 @@ function printIndexHelp(log) {
|
|
|
178
180
|
log(" - .mdkg/index/mdkg.sqlite when index.backend is sqlite");
|
|
179
181
|
printGlobalOptions(log);
|
|
180
182
|
}
|
|
183
|
+
function printDbHelp(log, subcommand) {
|
|
184
|
+
switch ((subcommand ?? "").toLowerCase()) {
|
|
185
|
+
case "index":
|
|
186
|
+
log("Usage:");
|
|
187
|
+
log(" mdkg db index rebuild [--tolerant] [--json]");
|
|
188
|
+
log(" mdkg db index status [--json]");
|
|
189
|
+
log(" mdkg db index verify [--json]");
|
|
190
|
+
log("\nNotes:");
|
|
191
|
+
log(" - `mdkg index` remains the compatibility shortcut for index rebuilds");
|
|
192
|
+
log(" - `.mdkg/index` is the rebuildable graph cache, not project application state");
|
|
193
|
+
printGlobalOptions(log);
|
|
194
|
+
return;
|
|
195
|
+
case "snapshot":
|
|
196
|
+
log("Usage:");
|
|
197
|
+
log(" mdkg db snapshot seal [--json]");
|
|
198
|
+
log(" mdkg db snapshot verify [--json]");
|
|
199
|
+
log(" mdkg db snapshot status [--json]");
|
|
200
|
+
log(" mdkg db snapshot dump [--snapshot <path>] [--output <path>] [--json]");
|
|
201
|
+
log(" mdkg db snapshot diff <left-snapshot> <right-snapshot> [--json]");
|
|
202
|
+
log("\nBoundaries:");
|
|
203
|
+
log(" - snapshot seal writes a clean opt-in sealed project DB checkpoint");
|
|
204
|
+
log(" - snapshot verify/status read `.mdkg/db/state/project.sqlite` and its manifest");
|
|
205
|
+
log(" - snapshot dump/diff are deterministic review aids, not source of truth");
|
|
206
|
+
log(" - active runtime/WAL files remain ignored by default");
|
|
207
|
+
printGlobalOptions(log);
|
|
208
|
+
return;
|
|
209
|
+
default:
|
|
210
|
+
log("Usage:");
|
|
211
|
+
log(" mdkg db index rebuild [--tolerant] [--json]");
|
|
212
|
+
log(" mdkg db index status [--json]");
|
|
213
|
+
log(" mdkg db index verify [--json]");
|
|
214
|
+
log(" mdkg db init [--json]");
|
|
215
|
+
log(" mdkg db migrate [--json]");
|
|
216
|
+
log(" mdkg db verify [--json]");
|
|
217
|
+
log(" mdkg db stats [--json]");
|
|
218
|
+
log(" mdkg db snapshot seal [--json]");
|
|
219
|
+
log(" mdkg db snapshot verify [--json]");
|
|
220
|
+
log(" mdkg db snapshot status [--json]");
|
|
221
|
+
log(" mdkg db snapshot dump [--snapshot <path>] [--output <path>] [--json]");
|
|
222
|
+
log(" mdkg db snapshot diff <left-snapshot> <right-snapshot> [--json]");
|
|
223
|
+
log("\nBoundaries:");
|
|
224
|
+
log(" - `.mdkg/index` is the rebuildable graph cache");
|
|
225
|
+
log(" - `.mdkg/db` is future project application state");
|
|
226
|
+
log(" - `mdkg db init` creates the generic layout and enables db config");
|
|
227
|
+
log(" - `mdkg db init` does not create an active runtime SQLite database");
|
|
228
|
+
log(" - `mdkg db migrate` creates/updates the active runtime SQLite database");
|
|
229
|
+
log(" - `mdkg db migrate` applies mdkg-owned generic foundation migrations only");
|
|
230
|
+
log(" - `mdkg db verify` checks config, layout, SQLite integrity, migrations, and transient files");
|
|
231
|
+
log(" - `mdkg db stats` reports table counts, migration state, DB size, and receipt counts");
|
|
232
|
+
log(" - `mdkg db snapshot ...` manages opt-in sealed checkpoints and review dumps");
|
|
233
|
+
log(" - active `.mdkg/db/runtime` and transient DB files are ignored by default");
|
|
234
|
+
log(" - no raw SQL, hosted queue, profile, or publish behavior is exposed here");
|
|
235
|
+
printGlobalOptions(log);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
181
238
|
function printShowHelp(log) {
|
|
182
239
|
log("Usage:");
|
|
183
240
|
log(" mdkg show <id-or-qid> [--ws <alias>] [--meta] [--json|--xml|--toon|--md]");
|
|
@@ -387,7 +444,7 @@ function printBundleHelp(log, subcommand) {
|
|
|
387
444
|
switch ((subcommand ?? "").toLowerCase()) {
|
|
388
445
|
case "import":
|
|
389
446
|
log("Usage:");
|
|
390
|
-
log(" mdkg subgraph add/list/show/rm/enable/disable/verify/refresh ...");
|
|
447
|
+
log(" mdkg subgraph add/list/show/rm/enable/disable/verify/refresh/sync/materialize ...");
|
|
391
448
|
log("\n`mdkg bundle import` has been replaced by `mdkg subgraph`.");
|
|
392
449
|
break;
|
|
393
450
|
case "create":
|
|
@@ -455,6 +512,14 @@ function printSubgraphHelp(log, subcommand) {
|
|
|
455
512
|
log("Usage:");
|
|
456
513
|
log(" mdkg subgraph refresh [alias|--all] [--json]");
|
|
457
514
|
break;
|
|
515
|
+
case "sync":
|
|
516
|
+
log("Usage:");
|
|
517
|
+
log(" mdkg subgraph sync [alias|--all] [--dry-run] [--allow-dirty] [--json]");
|
|
518
|
+
break;
|
|
519
|
+
case "materialize":
|
|
520
|
+
log("Usage:");
|
|
521
|
+
log(" mdkg subgraph materialize [alias|--all] --target <path> [--clean] [--gitignore] [--json]");
|
|
522
|
+
break;
|
|
458
523
|
default:
|
|
459
524
|
log("Usage:");
|
|
460
525
|
log(" mdkg subgraph add <alias> <bundle-path> [--visibility private|internal|public] [--profile private|public] [--source-path <path>] [--source-repo <ref>] [--max-stale-seconds <seconds>] [--json]");
|
|
@@ -465,10 +530,14 @@ function printSubgraphHelp(log, subcommand) {
|
|
|
465
530
|
log(" mdkg subgraph disable <alias> [--json]");
|
|
466
531
|
log(" mdkg subgraph verify [alias|--all] [--json]");
|
|
467
532
|
log(" mdkg subgraph refresh [alias|--all] [--json]");
|
|
533
|
+
log(" mdkg subgraph sync [alias|--all] [--dry-run] [--allow-dirty] [--json]");
|
|
534
|
+
log(" mdkg subgraph materialize [alias|--all] --target <path> [--clean] [--gitignore] [--json]");
|
|
468
535
|
log("\nNotes:");
|
|
469
536
|
log(" - subgraphs are read-only graph views backed by explicit bundle snapshots");
|
|
470
537
|
log(" - default permissions are read-only and default freshness is 3600 seconds");
|
|
471
538
|
log(" - refresh reloads configured bundle sources only; it does not build child bundles");
|
|
539
|
+
log(" - sync builds root-owned bundles from clean configured child source_path repos");
|
|
540
|
+
log(" - materialize extracts bundle contents into generated inspection trees");
|
|
472
541
|
}
|
|
473
542
|
printGlobalOptions(log);
|
|
474
543
|
}
|
|
@@ -714,6 +783,9 @@ function printCommandHelp(log, command, subcommand) {
|
|
|
714
783
|
case "index":
|
|
715
784
|
printIndexHelp(log);
|
|
716
785
|
return;
|
|
786
|
+
case "db":
|
|
787
|
+
printDbHelp(log, subcommand);
|
|
788
|
+
return;
|
|
717
789
|
case "show":
|
|
718
790
|
printShowHelp(log);
|
|
719
791
|
return;
|
|
@@ -977,6 +1049,111 @@ function runWorkspaceSubcommand(parsed, root) {
|
|
|
977
1049
|
throw new errors_1.UsageError("workspace requires ls/add/rm/enable/disable");
|
|
978
1050
|
}
|
|
979
1051
|
}
|
|
1052
|
+
function runDbSubcommand(parsed, root) {
|
|
1053
|
+
const subcommand = (parsed.positionals[1] ?? "").toLowerCase();
|
|
1054
|
+
switch (subcommand) {
|
|
1055
|
+
case "index": {
|
|
1056
|
+
const action = (parsed.positionals[2] ?? "").toLowerCase();
|
|
1057
|
+
const json = parseBooleanFlag("--json", parsed.flags["--json"]);
|
|
1058
|
+
const tolerant = parseBooleanFlag("--tolerant", parsed.flags["--tolerant"]);
|
|
1059
|
+
switch (action) {
|
|
1060
|
+
case "rebuild":
|
|
1061
|
+
if (parsed.positionals.length > 3) {
|
|
1062
|
+
throw new errors_1.UsageError(`mdkg db index ${action} does not accept positional arguments`);
|
|
1063
|
+
}
|
|
1064
|
+
(0, db_1.runDbIndexRebuildCommand)({ root, tolerant, json });
|
|
1065
|
+
return 0;
|
|
1066
|
+
case "status":
|
|
1067
|
+
if (parsed.positionals.length > 3) {
|
|
1068
|
+
throw new errors_1.UsageError(`mdkg db index ${action} does not accept positional arguments`);
|
|
1069
|
+
}
|
|
1070
|
+
(0, db_1.runDbIndexStatusCommand)({ root, tolerant, json });
|
|
1071
|
+
return 0;
|
|
1072
|
+
case "verify":
|
|
1073
|
+
if (parsed.positionals.length > 3) {
|
|
1074
|
+
throw new errors_1.UsageError(`mdkg db index ${action} does not accept positional arguments`);
|
|
1075
|
+
}
|
|
1076
|
+
(0, db_1.runDbIndexVerifyCommand)({ root, tolerant, json });
|
|
1077
|
+
return 0;
|
|
1078
|
+
default:
|
|
1079
|
+
throw new errors_1.UsageError("mdkg db index requires rebuild/status/verify");
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
case "init": {
|
|
1083
|
+
if (parsed.positionals.length > 2) {
|
|
1084
|
+
throw new errors_1.UsageError("mdkg db init does not accept positional arguments");
|
|
1085
|
+
}
|
|
1086
|
+
const json = parseBooleanFlag("--json", parsed.flags["--json"]);
|
|
1087
|
+
(0, db_1.runDbInitCommand)({ root, json });
|
|
1088
|
+
return 0;
|
|
1089
|
+
}
|
|
1090
|
+
case "migrate":
|
|
1091
|
+
if (parsed.positionals.length > 2) {
|
|
1092
|
+
throw new errors_1.UsageError("mdkg db migrate does not accept positional arguments");
|
|
1093
|
+
}
|
|
1094
|
+
(0, db_1.runDbMigrateCommand)({ root, json: parseBooleanFlag("--json", parsed.flags["--json"]) });
|
|
1095
|
+
return 0;
|
|
1096
|
+
case "verify":
|
|
1097
|
+
if (parsed.positionals.length > 2) {
|
|
1098
|
+
throw new errors_1.UsageError("mdkg db verify does not accept positional arguments");
|
|
1099
|
+
}
|
|
1100
|
+
(0, db_1.runDbVerifyCommand)({ root, json: parseBooleanFlag("--json", parsed.flags["--json"]) });
|
|
1101
|
+
return 0;
|
|
1102
|
+
case "stats": {
|
|
1103
|
+
if (parsed.positionals.length > 2) {
|
|
1104
|
+
throw new errors_1.UsageError("mdkg db stats does not accept positional arguments");
|
|
1105
|
+
}
|
|
1106
|
+
(0, db_1.runDbStatsCommand)({ root, json: parseBooleanFlag("--json", parsed.flags["--json"]) });
|
|
1107
|
+
return 0;
|
|
1108
|
+
}
|
|
1109
|
+
case "snapshot": {
|
|
1110
|
+
const action = (parsed.positionals[2] ?? "").toLowerCase();
|
|
1111
|
+
const json = parseBooleanFlag("--json", parsed.flags["--json"]);
|
|
1112
|
+
switch (action) {
|
|
1113
|
+
case "seal":
|
|
1114
|
+
if (parsed.positionals.length > 3) {
|
|
1115
|
+
throw new errors_1.UsageError("mdkg db snapshot seal does not accept positional arguments");
|
|
1116
|
+
}
|
|
1117
|
+
(0, db_1.runDbSnapshotSealCommand)({ root, json });
|
|
1118
|
+
return 0;
|
|
1119
|
+
case "verify":
|
|
1120
|
+
if (parsed.positionals.length > 3) {
|
|
1121
|
+
throw new errors_1.UsageError("mdkg db snapshot verify does not accept positional arguments");
|
|
1122
|
+
}
|
|
1123
|
+
(0, db_1.runDbSnapshotVerifyCommand)({ root, json });
|
|
1124
|
+
return 0;
|
|
1125
|
+
case "status":
|
|
1126
|
+
if (parsed.positionals.length > 3) {
|
|
1127
|
+
throw new errors_1.UsageError("mdkg db snapshot status does not accept positional arguments");
|
|
1128
|
+
}
|
|
1129
|
+
(0, db_1.runDbSnapshotStatusCommand)({ root, json });
|
|
1130
|
+
return 0;
|
|
1131
|
+
case "dump": {
|
|
1132
|
+
if (parsed.positionals.length > 3) {
|
|
1133
|
+
throw new errors_1.UsageError("mdkg db snapshot dump does not accept positional arguments");
|
|
1134
|
+
}
|
|
1135
|
+
const snapshot = requireFlagValue("--snapshot", parsed.flags["--snapshot"]);
|
|
1136
|
+
const output = requireFlagValue("--output", parsed.flags["--out"]);
|
|
1137
|
+
(0, db_1.runDbSnapshotDumpCommand)({ root, snapshot, output, json });
|
|
1138
|
+
return 0;
|
|
1139
|
+
}
|
|
1140
|
+
case "diff": {
|
|
1141
|
+
const left = parsed.positionals[3];
|
|
1142
|
+
const right = parsed.positionals[4];
|
|
1143
|
+
if (!left || !right || parsed.positionals.length > 5) {
|
|
1144
|
+
throw new errors_1.UsageError("mdkg db snapshot diff requires <left-snapshot> <right-snapshot>");
|
|
1145
|
+
}
|
|
1146
|
+
(0, db_1.runDbSnapshotDiffCommand)({ root, left, right, json });
|
|
1147
|
+
return 0;
|
|
1148
|
+
}
|
|
1149
|
+
default:
|
|
1150
|
+
throw new errors_1.UsageError("mdkg db snapshot requires seal/verify/status/dump/diff");
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
default:
|
|
1154
|
+
throw new errors_1.UsageError("mdkg db requires index/init/migrate/verify/stats/snapshot");
|
|
1155
|
+
}
|
|
1156
|
+
}
|
|
980
1157
|
function runCapabilitySubcommand(parsed, root) {
|
|
981
1158
|
const subcommand = (parsed.positionals[1] ?? "").toLowerCase();
|
|
982
1159
|
switch (subcommand) {
|
|
@@ -1231,8 +1408,34 @@ function runSubgraphSubcommand(parsed, root) {
|
|
|
1231
1408
|
(0, subgraph_1.runSubgraphRefreshCommand)({ root, alias, all, json });
|
|
1232
1409
|
return 0;
|
|
1233
1410
|
}
|
|
1411
|
+
case "sync": {
|
|
1412
|
+
if (parsed.positionals.length > 3) {
|
|
1413
|
+
throw new errors_1.UsageError("subgraph sync accepts at most one alias");
|
|
1414
|
+
}
|
|
1415
|
+
const alias = parsed.positionals[2];
|
|
1416
|
+
const all = parseBooleanFlag("--all", parsed.flags["--all"]);
|
|
1417
|
+
const dryRun = parseBooleanFlag("--dry-run", parsed.flags["--dry-run"]);
|
|
1418
|
+
const allowDirty = parseBooleanFlag("--allow-dirty", parsed.flags["--allow-dirty"]);
|
|
1419
|
+
(0, subgraph_1.runSubgraphSyncCommand)({ root, alias, all, dryRun, allowDirty, json });
|
|
1420
|
+
return 0;
|
|
1421
|
+
}
|
|
1422
|
+
case "materialize": {
|
|
1423
|
+
if (parsed.positionals.length > 3) {
|
|
1424
|
+
throw new errors_1.UsageError("subgraph materialize accepts at most one alias");
|
|
1425
|
+
}
|
|
1426
|
+
const alias = parsed.positionals[2];
|
|
1427
|
+
const all = parseBooleanFlag("--all", parsed.flags["--all"]);
|
|
1428
|
+
const target = requireFlagValue("--target", parsed.flags["--target"]);
|
|
1429
|
+
if (!target) {
|
|
1430
|
+
throw new errors_1.UsageError("subgraph materialize requires --target <path>");
|
|
1431
|
+
}
|
|
1432
|
+
const clean = parseBooleanFlag("--clean", parsed.flags["--clean"]);
|
|
1433
|
+
const gitignore = parseBooleanFlag("--gitignore", parsed.flags["--gitignore"]);
|
|
1434
|
+
(0, subgraph_1.runSubgraphMaterializeCommand)({ root, alias, all, target, clean, gitignore, json });
|
|
1435
|
+
return 0;
|
|
1436
|
+
}
|
|
1234
1437
|
default:
|
|
1235
|
-
throw new errors_1.UsageError("subgraph requires add/list/show/rm/enable/disable/verify/refresh");
|
|
1438
|
+
throw new errors_1.UsageError("subgraph requires add/list/show/rm/enable/disable/verify/refresh/sync/materialize");
|
|
1236
1439
|
}
|
|
1237
1440
|
}
|
|
1238
1441
|
function runWorkSubcommand(parsed, root) {
|
|
@@ -1822,6 +2025,8 @@ function runCommand(parsed, root, runtime) {
|
|
|
1822
2025
|
}
|
|
1823
2026
|
case "workspace":
|
|
1824
2027
|
return runWorkspaceSubcommand(parsed, root);
|
|
2028
|
+
case "db":
|
|
2029
|
+
return runDbSubcommand(parsed, root);
|
|
1825
2030
|
case "skill":
|
|
1826
2031
|
return runSkillSubcommand(parsed, root);
|
|
1827
2032
|
case "capability":
|
package/dist/commands/bundle.js
CHANGED
|
@@ -3,6 +3,10 @@ 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.sha256Buffer = sha256Buffer;
|
|
7
|
+
exports.buildBundle = buildBundle;
|
|
8
|
+
exports.parseBundle = parseBundle;
|
|
9
|
+
exports.verifyBundle = verifyBundle;
|
|
6
10
|
exports.runBundleCreateCommand = runBundleCreateCommand;
|
|
7
11
|
exports.runBundleVerifyCommand = runBundleVerifyCommand;
|
|
8
12
|
exports.runBundleShowCommand = runBundleShowCommand;
|
|
@@ -119,6 +123,8 @@ function isExcludedRelativePath(relative) {
|
|
|
119
123
|
normalized.startsWith(".mdkg/pack/") ||
|
|
120
124
|
normalized.includes("/.mdkg/bundles/") ||
|
|
121
125
|
normalized.startsWith(".mdkg/bundles/") ||
|
|
126
|
+
normalized.includes("/.mdkg/subgraphs/") ||
|
|
127
|
+
normalized.startsWith(".mdkg/subgraphs/") ||
|
|
122
128
|
normalized.includes("/.mdkg/index/") ||
|
|
123
129
|
normalized.startsWith(".mdkg/index/") ||
|
|
124
130
|
((normalized.includes("/.mdkg/archive/") || normalized.startsWith(".mdkg/archive/")) &&
|
|
@@ -35,7 +35,7 @@ function normalizeId(value, key) {
|
|
|
35
35
|
}
|
|
36
36
|
function normalizeIdRef(value, key) {
|
|
37
37
|
const normalized = value.toLowerCase();
|
|
38
|
-
if (!(0, id_1.
|
|
38
|
+
if (!(0, id_1.isPortableIdRef)(normalized)) {
|
|
39
39
|
throw new errors_1.UsageError(`${key} entries must match <id> or <ws>:<id>: ${value}`);
|
|
40
40
|
}
|
|
41
41
|
return normalized;
|