mdkg 0.1.1 → 0.1.3

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.
Files changed (73) hide show
  1. package/CHANGELOG.md +104 -0
  2. package/README.md +124 -18
  3. package/dist/cli.js +567 -15
  4. package/dist/commands/archive.js +486 -0
  5. package/dist/commands/bundle.js +743 -0
  6. package/dist/commands/bundle_import.js +255 -0
  7. package/dist/commands/capability.js +162 -0
  8. package/dist/commands/checkpoint.js +31 -5
  9. package/dist/commands/doctor.js +269 -9
  10. package/dist/commands/format.js +38 -9
  11. package/dist/commands/index.js +12 -12
  12. package/dist/commands/init.js +194 -63
  13. package/dist/commands/init_manifest.js +19 -6
  14. package/dist/commands/list.js +5 -2
  15. package/dist/commands/new.js +36 -7
  16. package/dist/commands/next.js +7 -0
  17. package/dist/commands/node_card.js +4 -1
  18. package/dist/commands/pack.js +62 -2
  19. package/dist/commands/query_output.js +1 -0
  20. package/dist/commands/search.js +5 -2
  21. package/dist/commands/show.js +7 -14
  22. package/dist/commands/skill_mirror.js +22 -0
  23. package/dist/commands/task.js +23 -6
  24. package/dist/commands/upgrade.js +24 -1
  25. package/dist/commands/validate.js +20 -1
  26. package/dist/commands/work.js +397 -0
  27. package/dist/commands/workspace.js +12 -2
  28. package/dist/core/config.js +115 -1
  29. package/dist/graph/agent_file_types.js +78 -5
  30. package/dist/graph/archive_file.js +125 -0
  31. package/dist/graph/archive_integrity.js +66 -0
  32. package/dist/graph/bundle_imports.js +418 -0
  33. package/dist/graph/capabilities_index_cache.js +103 -0
  34. package/dist/graph/capabilities_indexer.js +231 -0
  35. package/dist/graph/frontmatter.js +19 -0
  36. package/dist/graph/index_cache.js +23 -6
  37. package/dist/graph/indexer.js +4 -1
  38. package/dist/graph/node.js +23 -4
  39. package/dist/graph/node_body.js +37 -0
  40. package/dist/graph/reindex.js +46 -0
  41. package/dist/graph/skills_index_cache.js +2 -2
  42. package/dist/graph/skills_indexer.js +8 -3
  43. package/dist/graph/sqlite_index.js +293 -0
  44. package/dist/graph/validate_graph.js +83 -7
  45. package/dist/graph/visibility.js +214 -0
  46. package/dist/graph/workspace_files.js +22 -0
  47. package/dist/init/AGENT_START.md +24 -0
  48. package/dist/init/CLI_COMMAND_MATRIX.md +61 -3
  49. package/dist/init/README.md +70 -4
  50. package/dist/init/config.json +18 -2
  51. package/dist/init/core/guide.md +6 -2
  52. package/dist/init/core/rule-1-mdkg-conventions.md +2 -1
  53. package/dist/init/core/rule-3-cli-contract.md +72 -4
  54. package/dist/init/core/rule-4-repo-safety-and-ignores.md +47 -11
  55. package/dist/init/core/rule-5-release-and-versioning.md +4 -3
  56. package/dist/init/core/rule-6-templates-and-schemas.md +7 -0
  57. package/dist/init/init-manifest.json +21 -16
  58. package/dist/init/skills/default/build-pack-and-execute-task/SKILL.md +2 -1
  59. package/dist/init/skills/default/verify-close-and-checkpoint/SKILL.md +26 -0
  60. package/dist/init/templates/default/archive.md +33 -0
  61. package/dist/init/templates/default/receipt.md +15 -1
  62. package/dist/init/templates/default/work.md +6 -1
  63. package/dist/init/templates/default/work_order.md +15 -1
  64. package/dist/pack/export_md.js +3 -0
  65. package/dist/pack/export_xml.js +3 -0
  66. package/dist/pack/order.js +1 -0
  67. package/dist/pack/pack.js +3 -13
  68. package/dist/util/argparse.js +30 -0
  69. package/dist/util/atomic.js +44 -0
  70. package/dist/util/lock.js +72 -0
  71. package/dist/util/refs.js +40 -0
  72. package/dist/util/zip.js +153 -0
  73. package/package.json +14 -5
package/CHANGELOG.md CHANGED
@@ -4,6 +4,110 @@ All notable changes to mdkg are documented here.
4
4
 
5
5
  This project follows a pragmatic changelog style inspired by Keep a Changelog. Versions use npm package versions.
6
6
 
7
+ ## 0.1.3 - Unreleased
8
+
9
+ ### Added
10
+
11
+ - Added first-class SQLite access cache support using Node's built-in `node:sqlite`; no third-party SQLite package is introduced.
12
+ - Added `.mdkg/index/mdkg.sqlite` as a rebuildable derived cache for nodes, edges, skills, capabilities, archives, bundle imports, source hashes, and schema metadata when `index.backend` is `sqlite`.
13
+ - Added fresh init defaults for `index.backend: sqlite`, `index.sqlite_path`, `index.sqlite_commit_warning_bytes`, and `index.lock_timeout_ms`.
14
+ - Added a shared mutation lock plus atomic writes for mdkg mutations and index writes.
15
+ - Added SQLite transactional id reservation for numeric node/checkpoint ids in SQLite mode.
16
+ - Added `npm run smoke:sqlite` and `npm run smoke:parallel` packed/temp-repo coverage.
17
+
18
+ ### Changed
19
+
20
+ - Raised the required Node runtime to `>=24.15.0`.
21
+ - Existing workspaces that are migrated from older configs remain on `index.backend: json` until they explicitly opt in to SQLite.
22
+ - Init ignore policy now keeps JSON indexes, temp files, lock directories, WAL, SHM, and journal files ignored while allowing `.mdkg/index/mdkg.sqlite` to be committed by intentional repo policy.
23
+ - `mdkg index` continues to write JSON compatibility indexes and also rebuilds SQLite when enabled.
24
+ - `mdkg doctor` and `mdkg validate` now report SQLite cache health when SQLite mode is enabled.
25
+ - README and seeded docs now state that mdkg is pre-v1 public alpha software and cache/DAL contracts may churn before v1.
26
+
27
+ ### Fixed
28
+
29
+ - Removed the accidental self-dependency on `mdkg` from package metadata.
30
+ - Hardened parallel `mdkg new`, checkpoint, task, work, archive, bundle import config, and index writes against naming conflicts and partial cache writes.
31
+
32
+ ## 0.1.2 - 2026-05-19
33
+
34
+ ### Added
35
+
36
+ - Added `.mdkg/index/capabilities.json` as a derived JSON cache for skills, `SPEC.md`, `WORK.md`, core docs, and design docs.
37
+ - Added read-only `mdkg capability list/search/show` commands with JSON output, kind filters, and advisory visibility filters.
38
+ - Added workspace `visibility` metadata for capability cache filtering, defaulting to `private`.
39
+ - Added capability cache health reporting to `mdkg doctor`.
40
+ - Added capability-cache smoke coverage for root plus child workspace aggregation and cache auto-rebuild.
41
+ - Added packed-package init smoke coverage for fresh base init, fresh `mdkg init --agent`, removed flag failures, repeated init idempotency, doctor/validate, upgrade dry-run parity, task creation, and pack generation.
42
+ - Added init preflight checks for seed config parseability and unmanaged skill mirror collisions.
43
+ - Added first-class archive sidecars under `.mdkg/archive` with `mdkg archive add/list/show/verify/compress`.
44
+ - Added deterministic single-file ZIP cache generation for archived source and artifact files.
45
+ - Added `type: archive` graph nodes and `archive://<archive.id>` reference validation.
46
+ - Added `mdkg work contract/order/receipt/artifact` lifecycle helpers for semantic mirror work contracts, work orders, receipts, and artifact registration.
47
+ - Added archive/work packed-package smoke coverage for fresh temp repositories.
48
+ - Added `mdkg bundle create/list/show/verify` for deterministic full `.mdkg` graph snapshot bundles.
49
+ - Added private and public bundle profiles with fail-closed public filtering for private graph and archive refs.
50
+ - Added bundle-local generated indexes (`global.json`, `skills.json`, `capabilities.json`) inside snapshot ZIPs.
51
+ - Added bundle unit and CLI coverage plus packed-package bundle smoke coverage.
52
+ - Added `mdkg bundle import add/list/rm/enable/disable/verify` for read-only child graph snapshot imports.
53
+ - Added `bundle_imports` config with explicit alias, bundle path, visibility, expected profile, source metadata, and optional staleness policy.
54
+ - Added `.mdkg/index/imports.json` as a derived import projection and health cache.
55
+ - Added packed-package bundle import smoke coverage.
56
+ - Added shared visibility policy enforcement for workspace nodes, archive sidecars, and imported bundle nodes.
57
+ - Added `mdkg pack --visibility public|internal|private` for explicit public-safe and internal-safe packs.
58
+ - Added `mdkg archive add --visibility private|internal|public` and `mdkg archive list --visibility ...`.
59
+ - Added packed-package visibility smoke coverage.
60
+ - Added `receipt_status: superseded` support for committed receipt mirrors.
61
+ - Added `mdkg work receipt new|update --receipt-status superseded` CLI parity with graph validation.
62
+ - Added runtime-style work/order/receipt fixture coverage with input refs, requested outputs, proof refs, artifacts, and hashes.
63
+ - Added local qid support for `mdkg work order update`, `mdkg work receipt update`, and `mdkg work artifact add`.
64
+ - Added `archive.large_cache_warning_bytes` config and `mdkg doctor` warnings for large committed archive ZIP caches.
65
+
66
+ ### Changed
67
+
68
+ - `mdkg index` now writes the node index, skill index, and capability cache together.
69
+ - Generated bootstrap config now includes the default capability cache path and root workspace visibility.
70
+ - Docs and command matrix now teach capability discovery as separate from normal graph node search.
71
+ - Made `mdkg init --agent` the single canonical AI-agent bootstrap path.
72
+ - `mdkg init --agent` now creates `AGENTS.md` and `CLAUDE.md` alongside `AGENT_START.md`, `llms.txt`, `CLI_COMMAND_MATRIX.md`, default skills, event log, registry, and skill mirrors.
73
+ - Init manifests are now mode-aware: base init only claims base assets, while agent init claims the full agent bootstrap.
74
+ - Updated generated `.mdkg/README.md` onboarding to guide already-initialized repos toward `upgrade`, `new`, `search`, `pack`, and `validate`.
75
+ - Added first-ingestion guidance to `AGENT_START.md` for imported docs bundles.
76
+ - Hardened `WORK_ORDER.md` and `RECEIPT.md` templates with input refs, requested outputs, constraint refs, proof refs, attestation refs, and input/output hashes.
77
+ - Init ignore updates now ignore raw archive source copies under `.mdkg/archive/**/source/` while leaving sidecar `.md` files and ZIP caches commit-eligible.
78
+ - `mdkg doctor` now reports archive storage hygiene warnings for stray uncompressed archive files.
79
+ - Added default bundle config under `.mdkg/bundles` without making `mdkg index` rewrite bundles.
80
+ - Updated docs, command matrix, and release skills with bundle creation and verification guidance.
81
+ - Updated seeded init/upgrade skills so managed workspaces receive pre-commit archive compression and private bundle refresh guidance.
82
+ - `list`, `search`, `show`, `pack`, and `capability` now include enabled read-only bundle imports by default.
83
+ - Imported nodes use import-alias qids such as `child_repo:task-1` and expose original bundle/source metadata in JSON output.
84
+ - Stale imports warn during planning reads while `mdkg bundle import verify` exits nonzero.
85
+ - Public bundle creation now fails when public local nodes reference private or internal imported graphs.
86
+ - Public/internal bundle imports now require public bundle profiles.
87
+ - `mdkg validate` and `mdkg doctor` now report public/internal references to less-visible mdkg records.
88
+ - Archive JSON receipts now include sidecar visibility.
89
+ - Archive sidecars created from outside-repo files now redact `source_path` to `external:<basename>` instead of storing absolute local paths.
90
+ - `mdkg validate` and `mdkg archive verify` now share strict ZIP cache integrity checks for ZIP hash, readability, payload SHA-256, and payload byte size.
91
+ - Work mirror docs and templates now state the canonical-system boundary for production order, receipt, feedback, dispute, payment, ledger, marketplace, fulfillment, and execution state.
92
+ - Work lifecycle packed-package smoke now proves local qid mutation, order status updates, final superseded receipts, archive verification, indexing, show, and pack.
93
+
94
+ ### Fixed
95
+
96
+ - Fixed fresh `mdkg init --agent` leaving missing managed wrapper docs that immediately required `mdkg upgrade --apply`.
97
+ - Fixed misleading init summaries by reporting manifest, ignore, registry, event log, core pin, and skill mirror actions.
98
+ - Fixed late init failure UX by printing a partial-init receipt with recovery guidance.
99
+ - Kept bundle output deterministic across repeated creates when only `.mdkg/bundles/` changes.
100
+ - Hardened publish readiness and init smoke checks to assert seeded release skills include archive compression and bundle refresh guidance.
101
+ - Mutating task and work update flows now reject imported qids with explicit read-only import errors.
102
+ - Work lifecycle mutation commands now reject imported order/receipt qids with explicit read-only bundle import guidance.
103
+ - Local graph indexing now allows edges to configured import aliases without treating them as missing local workspace nodes.
104
+ - Public bundle checks now reuse the same fail-closed policy as public/internal pack checks.
105
+ - `mdkg archive verify --json` now emits a verification receipt for corrupt archive ZIP caches instead of being blocked by strict index validation.
106
+
107
+ ### Removed
108
+
109
+ - Removed `mdkg init --llm`, `mdkg init --agents`, `mdkg init --claude`, and `mdkg init --omni`; each now fails before mutation with guidance to use `mdkg init --agent`.
110
+
7
111
  ## 0.1.1 - 2026-05-12
8
112
 
9
113
  ### Added
package/README.md CHANGED
@@ -9,11 +9,14 @@ It is built for:
9
9
 
10
10
  mdkg stays deliberately boring:
11
11
  - repo-native under `.mdkg/`
12
- - TypeScript + Node.js 18+
13
- - zero runtime dependencies
14
- - no sqlite, daemon, hosted index, or vector DB
12
+ - TypeScript + Node.js `>=24.15.0`
13
+ - zero third-party runtime dependencies
14
+ - first-class rebuildable SQLite cache through built-in `node:sqlite`
15
+ - no daemon, hosted index, or vector DB
15
16
 
16
- Current package version in source: `0.1.1`
17
+ Current package version in source: `0.1.3`
18
+
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.
17
20
 
18
21
  ## The product shape
19
22
 
@@ -43,19 +46,13 @@ bun add -g mdkg
43
46
 
44
47
  Initialize mdkg in a repo:
45
48
 
46
- ```bash
47
- mdkg init --llm
48
- ```
49
-
50
- This is the generic OSS bootstrap path. It creates `.mdkg/` and updates `.gitignore` / `.npmignore` by default. Use `--no-update-ignores` to opt out of those ignore-file updates.
51
-
52
- Optional agent-ready scaffold:
53
-
54
49
  ```bash
55
50
  mdkg init --agent
56
51
  ```
57
52
 
58
- This adds strict-node `SOUL.md` / `HUMAN.md`, seeds the three default mdkg usage skills, creates `events.jsonl`, updates the skill registry, adds core pin updates, and creates mirrored skill folders under `.agents/skills/` and `.claude/skills/`.
53
+ This is the canonical AI-agent bootstrap path. It creates `.mdkg/`, `AGENT_START.md`, `AGENTS.md`, `CLAUDE.md`, `llms.txt`, `CLI_COMMAND_MATRIX.md`, strict-node `SOUL.md` / `HUMAN.md`, the three default mdkg usage skills, `events.jsonl`, the skill registry, core pin updates, and mirrored skill folders under `.agents/skills/` and `.claude/skills/`. It also updates `.gitignore` / `.npmignore` by default. Use `--no-update-ignores` to opt out of those ignore-file updates.
54
+
55
+ For a non-agent markdown graph only, run `mdkg init`.
59
56
 
60
57
  Preview safe scaffold upgrades in an existing mdkg workspace:
61
58
 
@@ -100,14 +97,69 @@ Build deterministic context:
100
97
  ```bash
101
98
  mdkg pack task-1
102
99
  mdkg pack task-1 --profile concise --dry-run --stats
100
+ mdkg pack task-1 --visibility public --dry-run
101
+ ```
102
+
103
+ Create a full `.mdkg` graph snapshot bundle for root or child orchestration:
104
+
105
+ ```bash
106
+ mdkg archive compress --all
107
+ mdkg archive verify --json
108
+ mdkg bundle create --profile private
109
+ mdkg bundle verify .mdkg/bundles/private/all.mdkg.zip
110
+ mdkg bundle list --json
103
111
  ```
104
112
 
113
+ 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 imported bundle records.
114
+
115
+ Import a child repo bundle as a read-only planning view:
116
+
117
+ ```bash
118
+ mdkg bundle import add child_repo child-repo/.mdkg/bundles/private/all.mdkg.zip --source-path child-repo
119
+ mdkg bundle import list --json
120
+ mdkg search "child capability"
121
+ mdkg show child_repo:work.example
122
+ mdkg pack child_repo:work.example --dry-run --stats
123
+ mdkg bundle import verify child_repo --json
124
+ ```
125
+
126
+ Imported bundle nodes are projected under the import alias, for example `child_repo:task-1`. They are available to `list`, `search`, `show`, `pack`, and capability discovery, but remain read-only; mutate the child repo and refresh its bundle to change imported content. Stale imports warn during planning reads and fail `mdkg bundle import verify`. Public or internal imports must be backed by public bundle profiles; private imports stay private planning context.
127
+
105
128
  Validate before handoff or commit:
106
129
 
107
130
  ```bash
108
131
  mdkg validate
109
132
  ```
110
133
 
134
+ Discover cached capability surfaces:
135
+
136
+ ```bash
137
+ mdkg index
138
+ mdkg capability list --kind skill --json
139
+ mdkg capability search "image worker" --kind work --json
140
+ mdkg capability show <id-or-qid-or-slug> --json
141
+ ```
142
+
143
+ Register source and artifact files as committed archive sidecars:
144
+
145
+ ```bash
146
+ mdkg archive add ./inputs/key_input_doc.pdf --id archive.key-input-doc --kind source --visibility private
147
+ mdkg archive verify archive://archive.key-input-doc
148
+ mdkg archive list --json
149
+ ```
150
+
151
+ Create semantic mirror work contracts, orders, receipts, and artifacts:
152
+
153
+ ```bash
154
+ mdkg work contract new "generate image" --id work.generate-image --agent-id agent.image-worker --kind image_generation --inputs prompt:text:required --outputs image_url:url:required
155
+ mdkg work order new "generate image request" --id order.generate-image-1 --work-id work.generate-image --requester user://example --input-refs archive://archive.key-input-doc
156
+ mdkg work receipt new "generate image receipt" --id receipt.generate-image-1 --work-order-id order.generate-image-1 --outcome success --receipt-status recorded
157
+ mdkg work artifact add receipt.generate-image-1 ./outputs/image.png --id archive.generated-image --kind artifact
158
+ ```
159
+
160
+ Receipt statuses are `recorded`, `verified`, `rejected`, and `superseded`.
161
+ Update and artifact commands accept local ids or local qids; imported bundle qids are read-only and must be changed in their source workspace.
162
+
111
163
  Update structured task state and evidence while keeping body and narrative edits in markdown:
112
164
 
113
165
  ```bash
@@ -151,9 +203,13 @@ mdkg lives under a hidden root directory:
151
203
  - `.mdkg/work/` tasks, bugs, tests, epics, checkpoints
152
204
  - `.mdkg/templates/` templates used by `mdkg new`
153
205
  - `.mdkg/skills/` Agent Skills packages
206
+ - `.mdkg/archive/` sidecar metadata plus deterministic compressed source/artifact caches
207
+ - `.mdkg/bundles/` optional committed full graph snapshot bundles
208
+ - `.mdkg/index/mdkg.sqlite` optional committed, rebuildable SQLite access cache
209
+ - `.mdkg/index/imports.json` generated read-only bundle import cache
154
210
  - `.agents/skills/` Codex/OpenAI-facing mirrored skills
155
211
  - `.claude/skills/` Claude-facing mirrored skills
156
- - `.mdkg/index/` generated cache files
212
+ - `.mdkg/index/*.json` generated JSON compatibility cache files
157
213
 
158
214
  ## Primary commands
159
215
 
@@ -166,6 +222,9 @@ These are the commands new users and agents should learn first:
166
222
  - `mdkg next`
167
223
  - `mdkg pack`
168
224
  - `mdkg skill`
225
+ - `mdkg capability`
226
+ - `mdkg archive`
227
+ - `mdkg work`
169
228
  - `mdkg task`
170
229
  - `mdkg validate`
171
230
 
@@ -224,6 +283,27 @@ This repo now dogfoods three internal skills:
224
283
 
225
284
  Optional skill metadata with prefixes such as `ochatr_*` is treated as vendor extension data. Structured skill output exposes it under `extensions.ochatr` while keeping the top-level `ochatr` field as a compatibility alias introduced in 0.0.9. ochatr.ai is a pioneering adopter of this extension pattern, not the name of the base mdkg standard.
226
285
 
286
+ ## Capability cache
287
+
288
+ mdkg maintains `.mdkg/index/capabilities.json` as a derived access cache for deterministic capability surfaces:
289
+ - skills from `.mdkg/skills/**/SKILL.md`
290
+ - `SPEC.md`
291
+ - `WORK.md`
292
+ - core docs
293
+ - design docs
294
+
295
+ The capability cache is not the full graph and is not source of truth. Normal tasks, epics, bugs, tests, feats, and checkpoints remain in the standard graph index. Markdown remains authoritative; deleting the cache is recoverable with `mdkg index` or by running a capability command when auto-reindex is enabled.
296
+
297
+ Capability records aggregate enabled registered workspaces and include deterministic source metadata such as `workspace`, `visibility`, `kind`, `id`, `qid`, `path`, headings, refs, source hash, and `indexed_at`. Workspace `visibility` also feeds mdkg's export safety checks for public/internal packs and public bundles. This is a CLI safety layer, not secret scanning, body redaction, or a replacement for private git hosting.
298
+
299
+ ## Index backends and parallel safety
300
+
301
+ Fresh `mdkg init` workspaces default to `index.backend: sqlite`, which writes `.mdkg/index/mdkg.sqlite` as a rebuildable access cache using Node's built-in `node:sqlite`. Existing workspaces that are migrated from older configs default to `index.backend: json` until they opt in. Markdown files, archive sidecars, bundle manifests, and config remain source of truth in both modes.
302
+
303
+ `mdkg index` still writes JSON compatibility caches (`global.json`, `skills.json`, `capabilities.json`, and import projections when configured). In SQLite mode it also rebuilds the SQLite cache with nodes, edges, skills, capabilities, archive metadata, bundle imports, source hashes, and schema metadata. Deleting the SQLite file is recoverable with `mdkg index`.
304
+
305
+ 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.
306
+
227
307
  ## Agent workflow files
228
308
 
229
309
  mdkg recognizes a small set of canonical agent workflow documents:
@@ -237,13 +317,30 @@ Use `mdkg new spec|work|work_order|receipt|feedback|dispute|proposal "<title>"`
237
317
 
238
318
  Relational templates contain editable placeholder refs. `spec` and `work` scaffold as validation-clean standalone docs; `work_order`, `receipt`, `feedback`, `dispute`, and `proposal` need real refs before strict `mdkg validate` passes.
239
319
 
320
+ For executable or purchasable capability mirrors, prefer the lifecycle helpers under `mdkg work ...`. They create and update `WORK.md`, `WORK_ORDER.md`, and `RECEIPT.md` semantic mirror files only. Production order state, receipt state, feedback, disputes, payments, ledgers, marketplace inventory, fulfillment records, and execution state remain canonical outside mdkg, such as in Postgres or another application database. Do not store raw secrets, credentials, live payment state, ledger mutations, canonical marketplace state, or bulky raw payloads in these mirrors.
321
+
322
+ ## Archive sidecars
323
+
324
+ Archive entries live under `.mdkg/archive/<archive.id>/` and are normal graph nodes with `type: archive`. `mdkg archive add` copies the source into a managed local `source/` directory, writes a frontmatter sidecar `<file>.md`, and writes a deterministic single-file ZIP cache `<file>.zip`. The original source path is left untouched.
325
+
326
+ Archive sidecars support `archive://archive.example` refs from orders, receipts, artifacts, proof refs, and other workflow metadata. `artifact://...` refs remain external or runtime-managed artifact identities; `archive://...` refs name committed mdkg archive sidecars. `mdkg validate` and `mdkg archive verify` both require the sidecar contract, ZIP cache hash, readable ZIP payload, payload SHA-256, and payload byte size to match. A missing raw local source copy is non-fatal when the committed sidecar and ZIP cache are valid.
327
+
328
+ When the source passed to `mdkg archive add` is inside the repo, `source_path` is repo-relative. Outside-repo sources are redacted to `external:<basename>` so sidecars do not leak absolute local paths.
329
+
330
+ Archive sidecar visibility defaults to `private`. Use `mdkg archive add --visibility public` only when the sidecar metadata and ZIP cache are safe for public packs or public bundles.
331
+
332
+ By default, init/upgrade ignore generated raw archive source copies with `.mdkg/archive/**/source/`; sidecar `.md` files and compressed `.zip` caches remain commit-eligible. `mdkg doctor` warns when a committed archive ZIP cache exceeds `archive.large_cache_warning_bytes` in `.mdkg/config.json` (default `26214400`; set `0` to disable). Large-cache warnings do not block archive add or validation.
333
+
240
334
  ## Current direction
241
335
 
242
336
  This release includes:
243
337
  - `init --agent`
244
- - default ignore updates with `--no-update-ignores` for `.mdkg/index/` and `.mdkg/pack/`
338
+ - default ignore updates with `--no-update-ignores` for generated JSON index/temp/lock files, `.mdkg/pack/`, and raw archive source copies
245
339
  - root-only published init seed config
246
340
  - skills indexing and search/show/list support
341
+ - JSON capability cache for skills, `SPEC.md`, `WORK.md`, core docs, and design docs
342
+ - SQLite index backend for fresh workspaces using built-in `node:sqlite`
343
+ - mutation locking and atomic writes for parallel mdkg calls
247
344
  - optional `skills: [...]` on work items
248
345
  - pack-time skill inclusion
249
346
  - latest-checkpoint resolver + index hint
@@ -252,16 +349,22 @@ This release includes:
252
349
  - agent workflow file types and semantic `mdkg new --id` support
253
350
  - product-specific skill mirrors for Codex/OpenAI and Claude
254
351
  - shared `AGENT_START.md` startup guidance
352
+ - conservative `mdkg upgrade` with mode-aware init manifests
353
+ - archive sidecars with deterministic ZIP caches
354
+ - semantic mirror helpers under `mdkg work ...`
355
+ - explicit public/internal/private visibility enforcement for packs, bundles, archives, imports, validation, and doctor diagnostics
356
+ - strict archive ZIP payload integrity checks during validation
255
357
 
256
358
  Current direction:
257
- - keep the OSS story generic around `init --llm`
258
- - use `init --agent` for deeper AI-agent bootstrap
359
+ - keep the OSS story generic around `mdkg init --agent`
360
+ - use base `mdkg init` only for repos that do not want agent bootstrap assets
259
361
  - keep `pack <id>` at the center of the human/agent loop
260
362
  - use `mdkg task ...` for structured state changes and markdown edits for narrative/body content
261
363
  - make event logging guided instead of purely manual
262
364
  - dogfood real skills inside the repo
263
365
  - make skill authoring first-class through `mdkg skill`
264
366
  - make `CLI_COMMAND_MATRIX.md` the single source of truth for the live CLI surface
367
+ - keep production execution databases canonical while mdkg stores committed semantic mirrors
265
368
  - run manual behavior audits before enforcing stronger coverage thresholds
266
369
 
267
370
  Design and decision records live in the internal graph under `.mdkg/design/`.
@@ -271,8 +374,11 @@ Design and decision records live in the internal graph under `.mdkg/design/`.
271
374
  mdkg is not a secret store.
272
375
 
273
376
  Use these defaults:
274
- - keep `.mdkg/index/` gitignored
377
+ - keep generated `.mdkg/index/*.json`, temp, lock, WAL, SHM, and journal files gitignored
378
+ - commit `.mdkg/index/mdkg.sqlite` only when the repo intentionally tracks a reasonably sized rebuildable access cache
275
379
  - keep `.mdkg/pack/` gitignored
380
+ - keep `.mdkg/archive/**/source/` gitignored unless a repo intentionally commits raw local copies
381
+ - commit archive sidecar `.md` metadata and deterministic `.zip` caches when they are needed for reviewable evidence
276
382
  - event logs are committed by default; ignore or delete them manually if a repo wants local-only provenance
277
383
  - do not ship `.mdkg/` into production builds or published packages
278
384
  - if an external orchestrator is writing mdkg state, keep one durable writer per run and batch commits at end-of-run or checkpoint boundaries