mdkg 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/CHANGELOG.md +93 -0
  2. package/README.md +108 -15
  3. package/dist/cli.js +566 -15
  4. package/dist/commands/archive.js +474 -0
  5. package/dist/commands/bundle.js +743 -0
  6. package/dist/commands/bundle_import.js +243 -0
  7. package/dist/commands/capability.js +162 -0
  8. package/dist/commands/doctor.js +233 -2
  9. package/dist/commands/format.js +38 -9
  10. package/dist/commands/index.js +11 -0
  11. package/dist/commands/init.js +188 -63
  12. package/dist/commands/init_manifest.js +19 -6
  13. package/dist/commands/list.js +5 -2
  14. package/dist/commands/new.js +6 -0
  15. package/dist/commands/next.js +7 -0
  16. package/dist/commands/node_card.js +4 -1
  17. package/dist/commands/pack.js +62 -2
  18. package/dist/commands/query_output.js +1 -0
  19. package/dist/commands/search.js +5 -2
  20. package/dist/commands/show.js +7 -14
  21. package/dist/commands/skill_mirror.js +22 -0
  22. package/dist/commands/task.js +3 -0
  23. package/dist/commands/upgrade.js +151 -13
  24. package/dist/commands/validate.js +19 -2
  25. package/dist/commands/work.js +365 -0
  26. package/dist/commands/workspace.js +12 -2
  27. package/dist/core/config.js +100 -1
  28. package/dist/graph/agent_file_types.js +78 -5
  29. package/dist/graph/archive_file.js +125 -0
  30. package/dist/graph/archive_integrity.js +66 -0
  31. package/dist/graph/bundle_imports.js +418 -0
  32. package/dist/graph/capabilities_index_cache.js +103 -0
  33. package/dist/graph/capabilities_indexer.js +231 -0
  34. package/dist/graph/frontmatter.js +19 -0
  35. package/dist/graph/index_cache.js +21 -4
  36. package/dist/graph/indexer.js +4 -1
  37. package/dist/graph/node.js +23 -4
  38. package/dist/graph/node_body.js +37 -0
  39. package/dist/graph/skills_indexer.js +8 -3
  40. package/dist/graph/template_schema.js +33 -5
  41. package/dist/graph/validate_graph.js +83 -7
  42. package/dist/graph/visibility.js +214 -0
  43. package/dist/graph/workspace_files.js +22 -0
  44. package/dist/init/AGENT_START.md +21 -0
  45. package/dist/init/CLI_COMMAND_MATRIX.md +58 -3
  46. package/dist/init/README.md +60 -3
  47. package/dist/init/config.json +13 -1
  48. package/dist/init/core/guide.md +6 -2
  49. package/dist/init/core/rule-3-cli-contract.md +71 -4
  50. package/dist/init/core/rule-4-repo-safety-and-ignores.md +20 -0
  51. package/dist/init/core/rule-6-templates-and-schemas.md +10 -1
  52. package/dist/init/init-manifest.json +19 -14
  53. package/dist/init/skills/default/build-pack-and-execute-task/SKILL.md +2 -1
  54. package/dist/init/skills/default/verify-close-and-checkpoint/SKILL.md +26 -0
  55. package/dist/init/templates/default/archive.md +33 -0
  56. package/dist/init/templates/default/receipt.md +15 -1
  57. package/dist/init/templates/default/work.md +6 -1
  58. package/dist/init/templates/default/work_order.md +15 -1
  59. package/dist/pack/export_md.js +3 -0
  60. package/dist/pack/export_xml.js +3 -0
  61. package/dist/pack/order.js +1 -0
  62. package/dist/pack/pack.js +3 -13
  63. package/dist/templates/builtin.js +38 -0
  64. package/dist/templates/loader.js +9 -16
  65. package/dist/util/argparse.js +30 -0
  66. package/dist/util/refs.js +40 -0
  67. package/dist/util/zip.js +153 -0
  68. package/package.json +8 -2
@@ -10,7 +10,7 @@ relates: []
10
10
  refs: []
11
11
  aliases: []
12
12
  created: 2026-01-06
13
- updated: 2026-01-22
13
+ updated: 2026-05-14
14
14
  ---
15
15
 
16
16
  # Agent guide
@@ -19,8 +19,9 @@ This repo uses **mdkg** to manage documentation, decisions, and work tracking.
19
19
 
20
20
  ## Quickstart
21
21
 
22
- - `mdkg init --llm`
22
+ - `mdkg init --agent`
23
23
  - `mdkg index`
24
+ - `mdkg capability list --kind skill --json`
24
25
  - `mdkg new task "..." --status todo --priority 1`
25
26
  - `mdkg list --status todo`
26
27
  - `mdkg pack <id> --verbose`
@@ -32,6 +33,7 @@ This repo uses **mdkg** to manage documentation, decisions, and work tracking.
32
33
  - `mdkg guide` (print this guide)
33
34
  - `mdkg new <type> "<title>"`
34
35
  - `mdkg list` / `mdkg show` / `mdkg search`
36
+ - `mdkg capability list` / `mdkg capability search` / `mdkg capability show`
35
37
  - `mdkg pack`
36
38
  - `mdkg next`
37
39
  - `mdkg validate` / `mdkg format`
@@ -94,6 +96,8 @@ If formatting drift is common (especially with agent edits):
94
96
 
95
97
  Index is cached by default and auto-reindexed when stale.
96
98
 
99
+ `mdkg index` writes the node index, skills index, and capability cache. The capability cache is a derived access layer for skills, `SPEC.md`, `WORK.md`, core docs, and design docs; it is not source of truth and does not include normal task/epic/test/checkpoint nodes.
100
+
97
101
  If debugging index issues:
98
102
  - run `mdkg index`
99
103
  - inspect errors from strict frontmatter enforcement
@@ -10,7 +10,7 @@ relates: []
10
10
  refs: []
11
11
  aliases: []
12
12
  created: 2026-01-06
13
- updated: 2026-03-08
13
+ updated: 2026-05-17
14
14
  ---
15
15
 
16
16
  # mdkg CLI contract
@@ -69,6 +69,9 @@ Workspaces are registered in `.mdkg/config.json`.
69
69
 
70
70
  Qualified IDs may be used as input:
71
71
  - `<ws>:<id>` (example: `e2e:task-12`)
72
+ - Imported bundle nodes use the same qualified form with the import alias:
73
+ - `<import-alias>:<id>` (example: `agent_image:work.generate-image`)
74
+ - imported nodes are read-only planning context and MUST NOT be selected by local mutation commands
72
75
 
73
76
  If a user provides an unqualified ID and it is ambiguous globally:
74
77
  - mdkg MUST error and suggest qualified IDs.
@@ -102,9 +105,14 @@ If a user provides an unqualified ID and it is ambiguous globally:
102
105
  - updates `.gitignore` and `.npmignore` by default
103
106
  - `--no-update-ignores` disables default ignore writes
104
107
  - explicit flags (`--update-gitignore`, `--update-npmignore`, `--update-dockerignore`) force writes even with global opt-out
105
- - `--llm` is the canonical documented path for creating `AGENTS.md`, `CLAUDE.md`, `llms.txt`, and `AGENT_START.md`
106
- - `--agents` / `--claude` remain compatibility flags, but are not part of the primary onboarding story
107
- - `--agent` adds strict-node bootstrap docs and scaffolding:
108
+ - `--agent` is the canonical documented path for complete AI-agent bootstrap
109
+ - `--llm`, `--agents`, `--claude`, and `--omni` fail before mutation with guidance to use `mdkg init --agent`
110
+ - `--agent` adds startup docs, strict-node bootstrap docs, and scaffolding:
111
+ - `AGENT_START.md`
112
+ - `AGENTS.md`
113
+ - `CLAUDE.md`
114
+ - `llms.txt`
115
+ - `CLI_COMMAND_MATRIX.md`
108
116
  - `.mdkg/core/SOUL.md` (`id: rule-soul`)
109
117
  - `.mdkg/core/HUMAN.md` (`id: rule-human`)
110
118
  - seeded canonical skills:
@@ -116,6 +124,7 @@ If a user provides an unqualified ID and it is ambiguous globally:
116
124
  - `.agents/skills/`
117
125
  - `.claude/skills/`
118
126
  - deterministic `core.md` pin insertion (`rule-soul`, then `rule-human`)
127
+ - ignore policy for `.mdkg/index/`, `.mdkg/pack/`, and raw archive source copies under `.mdkg/archive/**/source/`
119
128
  - mirrored skills are append-focused outputs:
120
129
  - `.mdkg/skills/` remains canonical
121
130
  - unrelated existing folders under `.agents/skills/` and `.claude/skills/` are preserved
@@ -129,11 +138,14 @@ If a user provides an unqualified ID and it is ambiguous globally:
129
138
  - `mdkg workspace ls`
130
139
  - `mdkg workspace add <alias> <path>`
131
140
  - `mdkg workspace rm <alias>`
141
+ - workspace entries may include advisory `visibility: private|internal|public` metadata for capability-cache filtering
132
142
 
133
143
  ### Indexing
134
144
  - `mdkg index`
135
145
  - rebuild global cache `.mdkg/index/global.json`
136
146
  - rebuild skills cache `.mdkg/index/skills.json` from `.mdkg/skills/<slug>/SKILL.md`
147
+ - rebuild capability cache `.mdkg/index/capabilities.json` from skills, `SPEC.md`, `WORK.md`, core docs, and design docs
148
+ - rebuild bundle import projection cache `.mdkg/index/imports.json` when bundle imports are configured
137
149
  - tolerate `.mdkg/skills/<slug>/SKILLS.md` on read with warning
138
150
  - fail validation if both `SKILL.md` and `SKILLS.md` exist in one skill directory
139
151
  - strict by default (fails on invalid frontmatter)
@@ -170,12 +182,64 @@ Common flags:
170
182
  - `mdkg search "<query>" [--type <type>] [--status <status>] [--ws <alias>] [--tags <tag,tag,...>] [--tags-mode any|all] [--json|--xml|--toon|--md]`
171
183
  - search SHOULD match on IDs, titles, tags, path tokens, and searchable frontmatter lists (`links`, `artifacts`, `refs`, `aliases`)
172
184
  - `mdkg list [--type <type>] [--status <status>] [--ws <alias>] [--epic <id>] [--blocked] [--priority <n>] [--tags <tag,tag,...>] [--tags-mode any|all] [--json|--xml|--toon|--md]`
185
+ - enabled bundle imports are included in `show`, `search`, `list`, `pack`, and `capability` reads by default:
186
+ - imported nodes surface `source.imported: true` in JSON output
187
+ - human output labels imported nodes as read-only and stale when applicable
188
+ - stale imports warn during planning reads but remain usable
173
189
  - skills are first-class under `mdkg skill ...` only:
174
190
  - `mdkg skill list [--tags <tag,tag,...>] [--tags-mode any|all] [--json|--xml|--toon|--md]`
175
191
  - `mdkg skill show <slug> [--meta] [--json|--xml|--toon|--md]`
176
192
  - `mdkg skill search "<query>" [--tags <tag,tag,...>] [--tags-mode any|all] [--json|--xml|--toon|--md]`
177
193
  - `mdkg skill validate [<slug>]`
178
194
  - `mdkg skill sync [--force]`
195
+ - capabilities are cached Markdown projections under `mdkg capability ...`:
196
+ - `mdkg capability list [--kind <skill|spec|work|core|design>] [--visibility <private|internal|public>] [--json]`
197
+ - `mdkg capability search "<query>" [--kind <kind>] [--visibility <level>] [--json]`
198
+ - `mdkg capability show <id-or-qid-or-slug> [--json]`
199
+ - capability records are read-only derived cache entries, not source of truth
200
+ - normal task, epic, feat, bug, test, and checkpoint nodes are not capability records
201
+ - archives are first-class sidecar nodes under `mdkg archive ...`:
202
+ - `mdkg archive add <file> [--id <archive.id>] [--kind source|artifact] [--visibility private|internal|public] [--title <title>] [--refs <...>] [--relates <...>] [--json]`
203
+ - `mdkg archive list [--kind source|artifact] [--visibility private|internal|public] [--ws <alias>] [--json]`
204
+ - `mdkg archive show <id-or-archive-uri> [--ws <alias>] [--json]`
205
+ - `mdkg archive verify [id-or-archive-uri] [--ws <alias>] [--json]`
206
+ - `mdkg archive compress <id-or-archive-uri|--all> [--json]`
207
+ - `archive://<archive.id>` refs resolve against local archive sidecars
208
+ - archive visibility defaults to `private`
209
+ - in-repo source paths are recorded repo-relative; outside-repo source paths are redacted as `external:<basename>`
210
+ - `mdkg validate` and `mdkg archive verify` both check ZIP cache hash, ZIP readability, payload hash, and payload byte size
211
+ - raw copied sources live under `.mdkg/archive/**/source/`; sidecar `.md` and deterministic `.zip` caches remain commit-eligible
212
+ - full graph snapshot bundles live under `mdkg bundle ...`:
213
+ - `mdkg bundle create [--profile private|public] [--ws <alias|all>] [--output <path>] [--json]`
214
+ - `mdkg bundle verify [bundle-path] [--json]`
215
+ - `mdkg bundle show <bundle-path> [--json]`
216
+ - `mdkg bundle list [--json]`
217
+ - `mdkg bundle import add <alias> <bundle-path> [--visibility private|internal|public] [--profile private|public] [--source-path <path>] [--source-repo <ref>] [--max-stale-seconds <seconds>] [--json]`
218
+ - `mdkg bundle import list [--json]`
219
+ - `mdkg bundle import rm <alias> [--json]`
220
+ - `mdkg bundle import enable <alias> [--json]`
221
+ - `mdkg bundle import disable <alias> [--json]`
222
+ - `mdkg bundle import verify [alias|--all] [--json]`
223
+ - bundles are explicit transport artifacts and are not rewritten by `mdkg index`
224
+ - default output is `.mdkg/bundles/<profile>/<workspace-or-all>.mdkg.zip`
225
+ - public bundles must fail closed when public records reference private graph or archive records
226
+ - public bundles must fail closed when public records reference private/internal imported graph records
227
+ - bundle imports are read-only projected graph views; child repos remain owners of real mutations and commits
228
+ - `bundle import verify` exits nonzero for stale, missing, corrupt, profile-mismatched, or duplicate-id imports
229
+ - public bundle creation must not re-export imported child graph content and must fail if public local nodes reference private/internal imports
230
+ - public/internal imports require `expected_profile: public`; private bundle profiles cannot be promoted through import visibility
231
+ - `mdkg pack --visibility public|internal|private` records explicit pack visibility and filters public/internal packs through the same fail-closed policy
232
+ - work lifecycle helpers live under `mdkg work ...`:
233
+ - `mdkg work contract new "<title>" --id <work.id> --agent-id <agent.id> --kind <kind> --inputs <...> --outputs <...> [--required-capabilities <...>] [--pricing-model <...>] [--json]`
234
+ - `mdkg work order new "<title>" --id <order.id> --work-id <work.id> --requester <ref> [--request-ref <ref>] [--input-refs <...>] [--requested-outputs <...>] [--json]`
235
+ - `mdkg work order update <id-or-qid> [--status <status>] [--add-input-refs <...>] [--add-artifacts <...>] [--json]`
236
+ - `mdkg work receipt new "<title>" --id <receipt.id> --work-order-id <order.id> --outcome success|partial|failure [--receipt-status recorded|verified|rejected|superseded] [--json]`
237
+ - `mdkg work receipt update <id-or-qid> [--receipt-status <status>] [--add-artifacts <...>] [--add-proof-refs <...>] [--add-attestation-refs <...>] [--json]`
238
+ - `mdkg work artifact add <order-or-receipt-id-or-qid> <file> [--id <archive.id>] [--kind source|artifact] [--json]`
239
+ - these commands mutate mdkg semantic mirror files only; production order, receipt, feedback, dispute, payment, ledger, marketplace inventory, fulfillment, and execution state remains canonical outside mdkg
240
+ - work mirrors must not store raw secrets, credentials, live payment state, ledger mutations, or canonical marketplace state
241
+ - `artifact://...` refs identify external/runtime-managed artifacts; `archive://...` refs identify committed mdkg archive sidecars
242
+ - update and artifact commands accept local ids or local qids; imported bundle qids are read-only and must be changed in their source workspace
179
243
  - discovery/show output flags are mutually exclusive; text mode remains the default when none are supplied
180
244
 
181
245
  ### Task lifecycle mutation
@@ -186,6 +250,7 @@ Common flags:
186
250
  - supports additive list mutation for `artifacts`, `links`, `refs`, `skills`, `tags`, and `blocked_by`
187
251
  - supports scalar replacement for `status` and `priority`
188
252
  - `--clear-blocked-by` resets blockers before optional re-add
253
+ - imported bundle qids fail with an explicit read-only import error
189
254
  - `mdkg task done <id-or-qid> [--checkpoint "<title>"] [...]`
190
255
  - supports `task`, `bug`, and `test` nodes only
191
256
  - sets `status: done`
@@ -242,6 +307,8 @@ Common flags:
242
307
  - `mdkg validate`
243
308
  - strict frontmatter + graph integrity checks (exit code 2 on failure)
244
309
  - validates optional node->skill references
310
+ - validates configured bundle imports and fails on missing/corrupt enabled bundles, malformed import config, duplicate projected ids, and invalid import refs
311
+ - warns, but does not fail, on stale imports
245
312
  - validates optional `.mdkg/work/events/events.jsonl` record shape when file exists
246
313
  - warns when `.agents/skills/` or `.claude/skills/` drift from canonical `.mdkg/skills/`
247
314
  - `mdkg format`
@@ -22,6 +22,7 @@ mdkg content may contain sensitive notes and internal project planning. This rul
22
22
  - `.mdkg/` must not be shipped to production deployments.
23
23
  - `.mdkg/` must not be published to npm.
24
24
  - `.mdkg/index/` must never be committed.
25
+ - `.mdkg/bundles/` may be committed only when the repo intentionally tracks private or public snapshot bundles.
25
26
 
26
27
  ## Git ignore requirements
27
28
 
@@ -31,11 +32,13 @@ The repo MUST ignore at minimum:
31
32
  - `dist/`
32
33
  - `.mdkg/index/`
33
34
  - `.mdkg/pack/`
35
+ - `.mdkg/archive/**/source/`
34
36
 
35
37
  Recommended `.gitignore` entries:
36
38
  - `.mdkg/index/`
37
39
  - `.mdkg/index/**`
38
40
  - `.mdkg/pack/`
41
+ - `.mdkg/archive/**/source/`
39
42
 
40
43
  ## npm publish safety (required)
41
44
 
@@ -86,6 +89,23 @@ Explicit flags remain available and take precedence:
86
89
  - Index files MUST be ignored from git.
87
90
  - Index rebuild should be deterministic and safe to regenerate at any time.
88
91
 
92
+ ## Bundle safety
93
+
94
+ - `.mdkg/bundles/` stores explicit snapshot artifacts and is not ignored by default.
95
+ - Private bundles may include sensitive authored mdkg content and should stay in private repos.
96
+ - Public bundles must be created with `mdkg bundle create --profile public` so private graph, archive, and imported bundle refs fail closed.
97
+ - Public-safe packs must be created with `mdkg pack <id> --visibility public`; internal-safe packs use `--visibility internal`. These filters do not redact Markdown body text.
98
+ - Bundle ZIPs must exclude `.mdkg/pack/`, existing `.mdkg/index/`, nested `.mdkg/bundles/`, and raw `.mdkg/archive/**/source/` files.
99
+ - Repos that track archive caches or bundles should refresh in this order before commit: `mdkg archive compress --all`, `mdkg archive verify --json`, `mdkg bundle create --profile private`, then bundle verify.
100
+
101
+ ## Archive safety
102
+
103
+ - Archive sidecar `.md` files and deterministic `.zip` caches are the commit-eligible evidence record.
104
+ - Raw copied sources under `.mdkg/archive/**/source/` stay ignored by default.
105
+ - `mdkg validate` and `mdkg archive verify` must both check ZIP cache hash, ZIP readability, payload hash, and payload byte size.
106
+ - Outside-repo archive sources must be recorded as redacted labels such as `external:key_input_doc.pdf`, not absolute local paths.
107
+ - `mdkg doctor` warns when committed archive ZIP caches exceed `archive.large_cache_warning_bytes`; this is advisory and does not block validation.
108
+
89
109
  ## Workspace safety
90
110
 
91
111
  Workspace-local `.mdkg/` directories (near code) should follow the same rules:
@@ -108,6 +108,13 @@ Design docs (`prd/edd/prop`):
108
108
  Rules (`rule-*`):
109
109
  - no required status field
110
110
 
111
+ Archives (`archive`):
112
+ - required id starts with `archive.`
113
+ - required fields: `archive_kind`, `source_path`, `stored_path`, `compressed_path`, `mime_type`, `byte_size`, `sha256`, `compressed_sha256`, `visibility`, `provenance`, `ingest_status`
114
+ - `source_path` is repo-relative for in-repo sources or `external:<basename>` for outside-repo sources
115
+ - `stored_path` and `compressed_path` are relative to the sidecar directory
116
+ - `mdkg validate` and `mdkg archive verify` both check deterministic ZIP cache integrity and tolerate a missing raw source copy when the ZIP cache is valid
117
+
111
118
  ## Body headings (guidance only)
112
119
 
113
120
  Body headings are strongly recommended for agent usability but should not be hard requirements.
@@ -187,4 +194,6 @@ Body headings are strongly recommended for agent usability but should not be har
187
194
  - Node -> skill references in `skills: [...]` are validated against `.mdkg/skills/<slug>/SKILL.md`.
188
195
  - `.mdkg/work/events/events.jsonl` is optional; when present, records are schema-validated by `mdkg validate`.
189
196
  - If a template is missing:
190
- - `mdkg new` must fail with a helpful error (exit code 3).
197
+ - built-in mdkg node types may use the installed package's bundled default template as a read-only schema fallback.
198
+ - commands should warn when bundled fallback is used and recommend `mdkg upgrade --apply` to vendor missing templates.
199
+ - missing non-built-in templates or missing packaged fallback assets must fail with a helpful error.
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "schema_version": 1,
3
3
  "tool": "mdkg",
4
- "mdkg_version": "0.1.0",
4
+ "mdkg_version": "0.1.2",
5
5
  "files": [
6
6
  {
7
7
  "path": ".mdkg/config.json",
8
8
  "category": "config",
9
- "sha256": "eb76bf22ae9d04601c2fedac5fd22838797dd2cc829324638a6b69222d40aaa9"
9
+ "sha256": "8f0fd9ba020511e22d912f59c39bdd1c09706595564361694860ded3e9488e7e"
10
10
  },
11
11
  {
12
12
  "path": ".mdkg/core/core.md",
@@ -16,7 +16,7 @@
16
16
  {
17
17
  "path": ".mdkg/core/guide.md",
18
18
  "category": "core",
19
- "sha256": "0b0ba51fbc393b3d5e0a0df4dece6aa822b77ab0f4ee3814b2cdba77ef8b65d9"
19
+ "sha256": "ffee0b532801d934d32842a9a9b1332df6329ad78d6804b39607553899b5b9ae"
20
20
  },
21
21
  {
22
22
  "path": ".mdkg/core/HUMAN.md",
@@ -36,12 +36,12 @@
36
36
  {
37
37
  "path": ".mdkg/core/rule-3-cli-contract.md",
38
38
  "category": "core",
39
- "sha256": "b547a6edc20112013c607a033af4ac0c6bb3f9d66d445b0c545b2890a721b671"
39
+ "sha256": "ad151ac183dea1158884c4341154118d9623392871062b8faa6cecd4bde580ba"
40
40
  },
41
41
  {
42
42
  "path": ".mdkg/core/rule-4-repo-safety-and-ignores.md",
43
43
  "category": "core",
44
- "sha256": "d7fc4bfa3727ed7d5353eeb0089ad818b96a755578e217251106422559750291"
44
+ "sha256": "b4638d8b5aeae74768fb971a8844aa473177df8814b929fedff6faf865a034cc"
45
45
  },
46
46
  {
47
47
  "path": ".mdkg/core/rule-5-release-and-versioning.md",
@@ -51,7 +51,7 @@
51
51
  {
52
52
  "path": ".mdkg/core/rule-6-templates-and-schemas.md",
53
53
  "category": "core",
54
- "sha256": "0d6da477c12e3492f43c571a6e4daa373bf05005ef703ad5166b7c8786e553b0"
54
+ "sha256": "5181e2e8a025cb6b9d160c1232c425bfc426fd8fd1ae3f75ce5052981807fc5f"
55
55
  },
56
56
  {
57
57
  "path": ".mdkg/core/SOUL.md",
@@ -61,12 +61,12 @@
61
61
  {
62
62
  "path": ".mdkg/README.md",
63
63
  "category": "mdkg_doc",
64
- "sha256": "26e99be382b48682b7841f14404576f79bf6876b64a90aefa6c99c2440701d2a"
64
+ "sha256": "fc85d07197da2fce189d295b6e6047de2a49b711adc74c991029faec6be385de"
65
65
  },
66
66
  {
67
67
  "path": ".mdkg/skills/build-pack-and-execute-task/SKILL.md",
68
68
  "category": "default_skill",
69
- "sha256": "7f6104980e6b2ec0749881c6be2bd3d7982702259c4979763266d1c800aeb410"
69
+ "sha256": "3e240cb844b22e5e4c0046a4f839ac3c0d771a62d00a72719fc449477564b1ae"
70
70
  },
71
71
  {
72
72
  "path": ".mdkg/skills/select-work-and-ground-context/SKILL.md",
@@ -76,7 +76,12 @@
76
76
  {
77
77
  "path": ".mdkg/skills/verify-close-and-checkpoint/SKILL.md",
78
78
  "category": "default_skill",
79
- "sha256": "98a1b02927854201eeea73e3d7c9f5a104fab7a5c72e033ea261995341a8a7ce"
79
+ "sha256": "cf9d7f01eb78a3cf669b6303c2f22c7c08529fe0181e008a7b45c5e5b70ceb49"
80
+ },
81
+ {
82
+ "path": ".mdkg/templates/default/archive.md",
83
+ "category": "template",
84
+ "sha256": "d442523bbecd91a3c4a436043919117da00c145b368612311e98e628fe30d69b"
80
85
  },
81
86
  {
82
87
  "path": ".mdkg/templates/default/bug.md",
@@ -136,7 +141,7 @@
136
141
  {
137
142
  "path": ".mdkg/templates/default/receipt.md",
138
143
  "category": "template",
139
- "sha256": "aac6e6e27153a1ca85a515b03f0ac55db3eb0df3f9243c42f0b936f5e5a750b2"
144
+ "sha256": "f08753cc38e02d73a5df92df58c2d34b0d33749b298eeb31d81aa019c38d43dd"
140
145
  },
141
146
  {
142
147
  "path": ".mdkg/templates/default/rule.md",
@@ -161,17 +166,17 @@
161
166
  {
162
167
  "path": ".mdkg/templates/default/work_order.md",
163
168
  "category": "template",
164
- "sha256": "bdbdf6e34d59976a675dd1d25002dfc0ef49e725647c97a9e0b3552c93fb8600"
169
+ "sha256": "6ee6007674f30f88153ce79ed67d8c736b4f0998ceb0c8314a3f2cf9c48ac88c"
165
170
  },
166
171
  {
167
172
  "path": ".mdkg/templates/default/work.md",
168
173
  "category": "template",
169
- "sha256": "651b7339f6e23c8745264f3f6641a0c82fcd765247f0a70a9f407a118a49ec00"
174
+ "sha256": "9d8b971ded7a587105fb8b14bb79f68b612fa6e1962cf06859bab82e2aee57c7"
170
175
  },
171
176
  {
172
177
  "path": "AGENT_START.md",
173
178
  "category": "startup_doc",
174
- "sha256": "be0990bb81e194a2a396f9520cda66c34d0bbbd36daa5b48773246549aacab2e"
179
+ "sha256": "6ff5915ea72d7453b2f7666e138808b6b0854123c7030bcced313a15f86c2b3a"
175
180
  },
176
181
  {
177
182
  "path": "AGENTS.md",
@@ -186,7 +191,7 @@
186
191
  {
187
192
  "path": "CLI_COMMAND_MATRIX.md",
188
193
  "category": "startup_doc",
189
- "sha256": "eb441dd11b31270ddb31f0a77c75fc744671754cffac3aa8ac6f60e30a1f324f"
194
+ "sha256": "f852a4f0a99c87aeb123a839c2902798ffdf5bf8012b4f367cb9c85905473ae7"
190
195
  },
191
196
  {
192
197
  "path": "llms.txt",
@@ -33,7 +33,8 @@ Use `mdkg pack <id>` as the default execution context instead of ad-hoc file gat
33
33
  6. Discover skills by metadata first; load full skill bodies only for the selected execution procedures.
34
34
  7. Hand the pack, not a loose file list, to the next coding step or agent.
35
35
  8. Keep this stage patch-only: subagents and tools may produce patches, test output, and evidence, but not direct mdkg state writes or commits.
36
- 9. If execution reveals new artifacts or blockers, hand them to the orchestrator stage for `mdkg task update ...` as structured field updates; keep narrative summaries in markdown.
36
+ 9. If execution creates or changes archive sidecars, raw source files, or bundle-relevant graph state, hand that to the orchestrator stage so pre-commit `mdkg archive compress --all` and `mdkg bundle create --profile private` can run at the durable writer boundary.
37
+ 10. If execution reveals new artifacts or blockers, hand them to the orchestrator stage for `mdkg task update ...` as structured field updates; keep narrative summaries in markdown.
37
38
 
38
39
  ## Outputs
39
40
 
@@ -40,6 +40,32 @@ Finish work with evidence, validation, and minimal memory drift.
40
40
  12. If the latest checkpoint is relevant, use it as durable recall; treat raw events as provenance/debugging, not primary execution context.
41
41
  13. If `events.jsonl` is missing, recreate it with `mdkg event enable` before expecting automatic JSONL provenance.
42
42
 
43
+ ## Pre-Publish Release Gate
44
+
45
+ Use this local repo-only checklist before publishing mdkg:
46
+
47
+ 1. Confirm package intent and version in `package.json`, `package-lock.json`, `README.md`, `CLI_COMMAND_MATRIX.md`, and `CHANGELOG.md`.
48
+ 2. Use a clean npm cache: `export NPM_CONFIG_CACHE=/private/tmp/mdkg-npm-cache`.
49
+ 3. Run `npm ci`, `npm run build`, `node scripts/assert-publish-ready.js`, `npm run test`, `npm run cli:check`, `node dist/cli.js validate`, `npm run smoke:consumer`, `npm run smoke:matrix`, `npm run smoke:upgrade`, `npm run smoke:init`, `npm run smoke:capabilities`, `npm run smoke:archive-work`, `npm run smoke:bundle`, `npm run smoke:bundle-import`, and `npm run smoke:visibility`.
50
+ 4. Run `npm pack --dry-run --json` and confirm the tarball includes `dist/cli.js`, compiled folders, `dist/init/`, release docs, and `scripts/postinstall.js`.
51
+ 5. Confirm registry state with `npm view mdkg version --registry=https://registry.npmjs.org/`.
52
+ 6. Publish only after the registry still shows the previous version and npm auth is known to have write access.
53
+ 7. If publishing fails with 2FA or token policy errors, do not commit; fix npm auth or package policy, then rerun publish.
54
+ 8. After successful publish, verify `npm view mdkg version` and `npm view mdkg dist-tags`, then commit the release changes.
55
+
56
+ ## Bundle-Aware Commit Gate
57
+
58
+ When a repo tracks mdkg archive caches or snapshot bundles, refresh and verify them before the final commit. This is recommended after validation and before staging so the committed semantic graph, compressed archive caches, and snapshot bundle describe the same source state.
59
+
60
+ ```bash
61
+ mdkg archive compress --all
62
+ mdkg archive verify --json
63
+ mdkg bundle create --profile private
64
+ mdkg bundle verify .mdkg/bundles/private/all.mdkg.zip
65
+ ```
66
+
67
+ Skip `mdkg archive compress --all` only when the repo has no `.mdkg/archive` sidecars. Skip bundle refresh only when the repo intentionally does not track `.mdkg/bundles/`. Use `--profile public` or `mdkg pack --visibility public` only for explicit export-safe output after public workspace, archive, and import visibility has been reviewed.
68
+
43
69
  ## Outputs
44
70
 
45
71
  - Verified mdkg graph state
@@ -0,0 +1,33 @@
1
+ ---
2
+ id: {{id}}
3
+ type: archive
4
+ title: {{title}}
5
+ archive_kind: source
6
+ source_path: local
7
+ stored_path: source/example.txt
8
+ compressed_path: example.txt.zip
9
+ mime_type: text/plain
10
+ byte_size: 0
11
+ sha256: sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
12
+ compressed_sha256: sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
13
+ visibility: private
14
+ provenance: manual
15
+ ingest_status: pending
16
+ tags: []
17
+ owners: []
18
+ links: []
19
+ artifacts: []
20
+ relates: []
21
+ refs: []
22
+ aliases: []
23
+ created: {{created}}
24
+ updated: {{updated}}
25
+ ---
26
+
27
+ # Archive Entry
28
+
29
+ Describe the source or artifact represented by this sidecar.
30
+
31
+ # Provenance
32
+
33
+ Record non-secret provenance and ingest notes.
@@ -7,6 +7,10 @@ work_order_id: order.example
7
7
  receipt_status: recorded
8
8
  outcome: success
9
9
  cost_ref: cost.redacted
10
+ proof_refs: []
11
+ attestation_refs: []
12
+ input_hashes: []
13
+ output_hashes: []
10
14
  tags: []
11
15
  owners: []
12
16
  links: []
@@ -22,9 +26,19 @@ updated: {{updated}}
22
26
 
23
27
  Record the result and proof summary.
24
28
 
29
+ This file is a committed semantic mirror, not canonical payment, ledger,
30
+ marketplace, or execution state. Do not store raw secrets, credentials, live
31
+ payment state, ledger mutations, or bulky payloads here.
32
+
25
33
  # Artifacts
26
34
 
27
- List committed artifact references.
35
+ List committed artifact references. Use `artifact://...` for external or
36
+ runtime-managed artifact identities and `archive://...` for committed mdkg
37
+ archive sidecars.
38
+
39
+ # Proof
40
+
41
+ Record non-secret proof, attestation, and hash references.
28
42
 
29
43
  # Notes
30
44
 
@@ -31,6 +31,10 @@ updated: {{updated}}
31
31
 
32
32
  Describe the reusable capability contract.
33
33
 
34
+ This file is a semantic mirror for discovery and review. Do not store raw
35
+ secrets, credentials, live payment state, ledger mutations, marketplace
36
+ inventory, or canonical execution state here.
37
+
34
38
  # Inputs
35
39
 
36
40
  Document input descriptors and validation expectations.
@@ -41,4 +45,5 @@ Document output descriptors and artifact expectations.
41
45
 
42
46
  # Receipt
43
47
 
44
- Describe required receipt evidence.
48
+ Describe required receipt evidence. Production execution systems remain
49
+ canonical for real orders, receipts, payments, ledgers, and fulfillment state.
@@ -8,6 +8,10 @@ work_version: 0.1.0
8
8
  requester: user.example
9
9
  order_status: submitted
10
10
  request_ref: request.example
11
+ input_refs: []
12
+ requested_outputs: [result:text:required]
13
+ constraint_refs: []
14
+ artifact_policy: commit_sidecar_and_zip
11
15
  tags: []
12
16
  owners: []
13
17
  links: []
@@ -23,9 +27,19 @@ updated: {{updated}}
23
27
 
24
28
  Capture the concrete request against a WORK.md version.
25
29
 
30
+ This file is a committed semantic mirror, not the canonical execution database.
31
+ Do not store raw secrets, credentials, live payment state, ledger mutations,
32
+ marketplace inventory, or bulky payloads here.
33
+
26
34
  # Inputs
27
35
 
28
- Record committed input references without secrets.
36
+ Record committed input references without secrets. Use `archive://...` for mdkg
37
+ archive sidecars and `artifact://...` for external or runtime-managed artifact
38
+ identities.
39
+
40
+ # Requested Outputs
41
+
42
+ Document the output descriptors requested from the work contract.
29
43
 
30
44
  # Constraints
31
45
 
@@ -25,6 +25,9 @@ function renderHeader(meta, nodes) {
25
25
  if (meta.body_mode) {
26
26
  lines.push(`body_mode: ${meta.body_mode}`);
27
27
  }
28
+ if (meta.visibility) {
29
+ lines.push(`visibility: ${meta.visibility}`);
30
+ }
28
31
  if (meta.latest_checkpoint_qid) {
29
32
  lines.push(`latest_checkpoint_qid: ${meta.latest_checkpoint_qid}`);
30
33
  }
@@ -41,6 +41,9 @@ function exportXml(pack) {
41
41
  if (pack.meta.body_mode) {
42
42
  lines.push(` <body_mode>${escapeXml(pack.meta.body_mode)}</body_mode>`);
43
43
  }
44
+ if (pack.meta.visibility) {
45
+ lines.push(` <visibility>${escapeXml(pack.meta.visibility)}</visibility>`);
46
+ }
44
47
  if (pack.meta.latest_checkpoint_qid) {
45
48
  lines.push(` <latest_checkpoint_qid>${escapeXml(pack.meta.latest_checkpoint_qid)}</latest_checkpoint_qid>`);
46
49
  }
@@ -15,6 +15,7 @@ const FALLBACK_TYPES = [
15
15
  "feedback",
16
16
  "dispute",
17
17
  "proposal",
18
+ "archive",
18
19
  "epic",
19
20
  "feat",
20
21
  "task",
package/dist/pack/pack.js CHANGED
@@ -1,12 +1,7 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.buildPack = buildPack;
7
- const fs_1 = __importDefault(require("fs"));
8
- const path_1 = __importDefault(require("path"));
9
- const frontmatter_1 = require("../graph/frontmatter");
4
+ const node_body_1 = require("../graph/node_body");
10
5
  const qid_1 = require("../util/qid");
11
6
  const order_1 = require("./order");
12
7
  const verbose_core_1 = require("./verbose_core");
@@ -105,12 +100,6 @@ function buildPackNode(root, index, qid) {
105
100
  if (!node) {
106
101
  throw new Error(`node not found: ${qid}`);
107
102
  }
108
- const filePath = path_1.default.resolve(root, node.path);
109
- if (!fs_1.default.existsSync(filePath)) {
110
- throw new Error(`file not found for ${qid}: ${node.path}`);
111
- }
112
- const content = fs_1.default.readFileSync(filePath, "utf8");
113
- const body = (0, frontmatter_1.parseFrontmatter)(content, filePath).body.trimEnd();
114
103
  return {
115
104
  qid: node.qid,
116
105
  id: node.id,
@@ -125,7 +114,8 @@ function buildPackNode(root, index, qid) {
125
114
  refs: node.refs,
126
115
  aliases: node.aliases,
127
116
  attributes: node.attributes ?? {},
128
- body,
117
+ ...(node.source ? { source: node.source } : {}),
118
+ body: (0, node_body_1.readNodeBody)(root, node),
129
119
  };
130
120
  }
131
121
  function mergeWarnings(warnings, message) {
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.BUILTIN_TEMPLATE_SET = void 0;
7
+ exports.templateNameForType = templateNameForType;
8
+ exports.resolveLocalTemplatePath = resolveLocalTemplatePath;
9
+ exports.resolveBundledTemplateRoot = resolveBundledTemplateRoot;
10
+ exports.resolveBundledTemplatePath = resolveBundledTemplatePath;
11
+ exports.requireBundledTemplatePath = requireBundledTemplatePath;
12
+ const fs_1 = __importDefault(require("fs"));
13
+ const path_1 = __importDefault(require("path"));
14
+ exports.BUILTIN_TEMPLATE_SET = "default";
15
+ function templateNameForType(type) {
16
+ const normalized = type.toLowerCase();
17
+ if (normalized === "checkpoint") {
18
+ return "chk";
19
+ }
20
+ return normalized;
21
+ }
22
+ function resolveLocalTemplatePath(root, config, type, templateSet) {
23
+ const setName = (templateSet ?? config.templates.default_set).toLowerCase();
24
+ return path_1.default.resolve(root, config.templates.root_path, setName, `${templateNameForType(type)}.md`);
25
+ }
26
+ function resolveBundledTemplateRoot() {
27
+ return path_1.default.resolve(__dirname, "..", "init", "templates", exports.BUILTIN_TEMPLATE_SET);
28
+ }
29
+ function resolveBundledTemplatePath(type) {
30
+ return path_1.default.join(resolveBundledTemplateRoot(), `${templateNameForType(type)}.md`);
31
+ }
32
+ function requireBundledTemplatePath(type) {
33
+ const templatePath = resolveBundledTemplatePath(type);
34
+ if (!fs_1.default.existsSync(templatePath)) {
35
+ throw new Error(`bundled template fallback missing for type ${type}: ${templatePath} (try reinstalling mdkg)`);
36
+ }
37
+ return templatePath;
38
+ }