mdkg 0.0.9 → 0.1.0

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 CHANGED
@@ -4,6 +4,21 @@ 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.0 - 2026-05-12
8
+
9
+ ### Added
10
+
11
+ - Added conservative `mdkg upgrade` for existing workspaces.
12
+ - Added `.mdkg/init-manifest.json` ownership tracking for managed init assets.
13
+ - Added v0.0.9 seed fingerprints so clean older workspaces can safely adopt current init docs, templates, and default skills.
14
+ - Added `npm run smoke:upgrade` for packed-package upgrade verification in temporary workspaces.
15
+
16
+ ### Changed
17
+
18
+ - `mdkg upgrade` defaults to dry-run; `mdkg upgrade --apply` is the only mutating upgrade path.
19
+ - Agent-enabled workspaces can receive safe managed default skill upgrades and mirror refreshes during upgrade.
20
+ - Publish readiness now checks packaged init manifests and runs upgrade smoke before publish.
21
+
7
22
  ## 0.0.9 - 2026-05-12
8
23
 
9
24
  ### Added
package/README.md CHANGED
@@ -13,7 +13,7 @@ mdkg stays deliberately boring:
13
13
  - zero runtime dependencies
14
14
  - no sqlite, daemon, hosted index, or vector DB
15
15
 
16
- Current package version in source: `0.0.9`
16
+ Current package version in source: `0.1.0`
17
17
 
18
18
  ## The product shape
19
19
 
@@ -57,6 +57,21 @@ mdkg init --agent
57
57
 
58
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/`.
59
59
 
60
+ Preview safe scaffold upgrades in an existing mdkg workspace:
61
+
62
+ ```bash
63
+ mdkg upgrade
64
+ mdkg upgrade --json
65
+ ```
66
+
67
+ Apply only after reviewing the receipt:
68
+
69
+ ```bash
70
+ mdkg upgrade --apply
71
+ ```
72
+
73
+ Upgrade is intentionally conservative. It creates missing managed startup docs and updates unchanged mdkg seed assets, but preserves customized docs, templates, skills, and core files as reported conflicts. Agent-enabled workspaces also get safe default skill upgrades and skill mirror refreshes; non-agent workspaces do not gain skills, events, or mirrors implicitly.
74
+
60
75
  Create a task:
61
76
 
62
77
  ```bash
@@ -142,6 +157,7 @@ mdkg lives under a hidden root directory:
142
157
 
143
158
  These are the commands new users and agents should learn first:
144
159
  - `mdkg init`
160
+ - `mdkg upgrade`
145
161
  - `mdkg new`
146
162
  - `mdkg search`
147
163
  - `mdkg show`
@@ -204,7 +220,7 @@ This repo now dogfoods three internal skills:
204
220
  - `build-pack-and-execute-task`
205
221
  - `verify-close-and-checkpoint`
206
222
 
207
- 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 0.0.9 compatibility alias. ochatr.ai is a pioneering adopter of this extension pattern, not the name of the base mdkg standard.
223
+ 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.
208
224
 
209
225
  ## Agent workflow files
210
226
 
package/dist/cli.js CHANGED
@@ -22,6 +22,7 @@ const checkpoint_1 = require("./commands/checkpoint");
22
22
  const init_1 = require("./commands/init");
23
23
  const new_1 = require("./commands/new");
24
24
  const guide_1 = require("./commands/guide");
25
+ const upgrade_1 = require("./commands/upgrade");
25
26
  const event_1 = require("./commands/event");
26
27
  const skill_1 = require("./commands/skill");
27
28
  const task_1 = require("./commands/task");
@@ -47,6 +48,7 @@ function printUsage(log) {
47
48
  log(" mdkg <command> [options]");
48
49
  log("\nPrimary commands:");
49
50
  log(" init Initialize .mdkg scaffolding");
51
+ log(" upgrade Conservatively upgrade mdkg scaffolding");
50
52
  log(" new Create a node from templates");
51
53
  log(" show Show a node by id or qid");
52
54
  log(" list List nodes with filters");
@@ -66,6 +68,8 @@ function printUsage(log) {
66
68
  log(" workspace Manage workspaces (ls/add/rm/enable/disable)");
67
69
  log("\nQuickstart:");
68
70
  log(" mdkg init --llm");
71
+ log(" mdkg upgrade");
72
+ log(" mdkg upgrade --apply");
69
73
  log(' mdkg new task "..." --status todo --priority 1');
70
74
  log(' mdkg search "..."');
71
75
  log(" mdkg show <id>");
@@ -95,6 +99,19 @@ function printInitHelp(log) {
95
99
  log("\nCompatibility flags still supported but not shown in the primary onboarding story.");
96
100
  printGlobalOptions(log);
97
101
  }
102
+ function printUpgradeHelp(log) {
103
+ log("Usage:");
104
+ log(" mdkg upgrade [--dry-run] [--apply] [--json]");
105
+ log("\nOptions:");
106
+ log(" --dry-run Preview upgrade changes without writing files (default)");
107
+ log(" --apply Apply safe managed init asset upgrades");
108
+ log(" --json Emit machine-readable upgrade receipt");
109
+ log("\nNotes:");
110
+ log(" - preserves customized docs, templates, skills, and core files");
111
+ log(" - upgrades default mdkg skills only when they match managed seed fingerprints");
112
+ log(" - run without flags first, then rerun with --apply when the receipt looks right");
113
+ printGlobalOptions(log);
114
+ }
98
115
  function printNewHelp(log) {
99
116
  log("Usage:");
100
117
  log(' mdkg new <type> "<title>" [options] [--json]');
@@ -371,6 +388,9 @@ function printCommandHelp(log, command, subcommand) {
371
388
  case "init":
372
389
  printInitHelp(log);
373
390
  return;
391
+ case "upgrade":
392
+ printUpgradeHelp(log);
393
+ return;
374
394
  case "guide":
375
395
  printGuideHelp(log);
376
396
  return;
@@ -909,6 +929,19 @@ function runCommand(parsed, root, runtime) {
909
929
  });
910
930
  return 0;
911
931
  }
932
+ case "upgrade": {
933
+ if (parsed.positionals.length > 1) {
934
+ throw new errors_1.UsageError("upgrade does not accept positional arguments");
935
+ }
936
+ const dryRun = parseBooleanFlag("--dry-run", parsed.flags["--dry-run"]);
937
+ const apply = parseBooleanFlag("--apply", parsed.flags["--apply"]);
938
+ if (dryRun && apply) {
939
+ throw new errors_1.UsageError("choose either --dry-run or --apply, not both");
940
+ }
941
+ const json = parseBooleanFlag("--json", parsed.flags["--json"]);
942
+ (0, upgrade_1.runUpgradeCommand)({ root, dryRun, apply, json });
943
+ return 0;
944
+ }
912
945
  case "guide":
913
946
  (0, guide_1.runGuideCommand)({ root });
914
947
  return 0;
@@ -9,6 +9,8 @@ const path_1 = __importDefault(require("path"));
9
9
  const config_1 = require("../core/config");
10
10
  const errors_1 = require("../util/errors");
11
11
  const date_1 = require("../util/date");
12
+ const version_1 = require("../core/version");
13
+ const init_manifest_1 = require("./init_manifest");
12
14
  const skill_support_1 = require("./skill_support");
13
15
  const skill_mirror_1 = require("./skill_mirror");
14
16
  const DEFAULT_SEED_SUBDIR = path_1.default.resolve(__dirname, "..", "init");
@@ -236,6 +238,7 @@ function runInitCommand(options) {
236
238
  const seedCliMatrix = path_1.default.join(seedRoot, "CLI_COMMAND_MATRIX.md");
237
239
  const seedReadme = path_1.default.join(seedRoot, "README.md");
238
240
  const seedDefaultSkills = path_1.default.join(seedRoot, "skills", "default");
241
+ const seedManifest = (0, init_manifest_1.createInitManifest)(seedRoot, (0, version_1.readPackageVersion)());
239
242
  if (!fs_1.default.existsSync(seedConfig) || !fs_1.default.existsSync(seedCore) || !fs_1.default.existsSync(seedTemplates)) {
240
243
  throw new errors_1.NotFoundError(`init assets not found at ${seedRoot} (try reinstalling mdkg)`);
241
244
  }
@@ -304,6 +307,7 @@ function runInitCommand(options) {
304
307
  (0, skill_support_1.refreshSkillsRegistry)(root, config);
305
308
  (0, skill_mirror_1.syncSkillMirrors)({ root, config, createRoots: true, force });
306
309
  }
310
+ (0, init_manifest_1.writeInitManifest)(path_1.default.join(mdkgDir, init_manifest_1.INIT_MANIFEST_FILE), seedManifest);
307
311
  const noUpdateIgnores = Boolean(options.noUpdateIgnores);
308
312
  const shouldUpdateGitignore = Boolean(options.updateGitignore || !noUpdateIgnores);
309
313
  const shouldUpdateNpmignore = Boolean(options.updateNpmignore || !noUpdateIgnores);
@@ -0,0 +1,131 @@
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.INIT_MANIFEST_SCHEMA_VERSION = exports.INIT_MANIFEST_FILE = void 0;
7
+ exports.sha256File = sha256File;
8
+ exports.seedSourcePath = seedSourcePath;
9
+ exports.createInitManifest = createInitManifest;
10
+ exports.writeInitManifest = writeInitManifest;
11
+ exports.readInitManifest = readInitManifest;
12
+ exports.loadLegacyInitManifests = loadLegacyInitManifests;
13
+ const crypto_1 = __importDefault(require("crypto"));
14
+ const fs_1 = __importDefault(require("fs"));
15
+ const path_1 = __importDefault(require("path"));
16
+ exports.INIT_MANIFEST_FILE = "init-manifest.json";
17
+ exports.INIT_MANIFEST_SCHEMA_VERSION = 1;
18
+ const STARTUP_DOCS = ["llms.txt", "AGENT_START.md", "CLI_COMMAND_MATRIX.md"];
19
+ const AGENT_DOCS = ["AGENTS.md", "CLAUDE.md"];
20
+ function toPosixPath(value) {
21
+ return value.split(path_1.default.sep).join("/");
22
+ }
23
+ function sha256Buffer(value) {
24
+ return crypto_1.default.createHash("sha256").update(value).digest("hex");
25
+ }
26
+ function sha256File(filePath) {
27
+ return sha256Buffer(fs_1.default.readFileSync(filePath));
28
+ }
29
+ function listFiles(dirPath) {
30
+ if (!fs_1.default.existsSync(dirPath)) {
31
+ return [];
32
+ }
33
+ const files = [];
34
+ const entries = fs_1.default.readdirSync(dirPath, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name));
35
+ for (const entry of entries) {
36
+ const fullPath = path_1.default.join(dirPath, entry.name);
37
+ if (entry.isDirectory()) {
38
+ files.push(...listFiles(fullPath));
39
+ }
40
+ else if (entry.isFile()) {
41
+ files.push(fullPath);
42
+ }
43
+ }
44
+ return files;
45
+ }
46
+ function addSeedFile(files, seedRoot, seedRelativePath, targetPath, category) {
47
+ const sourcePath = path_1.default.join(seedRoot, seedRelativePath);
48
+ if (!fs_1.default.existsSync(sourcePath) || !fs_1.default.statSync(sourcePath).isFile()) {
49
+ return;
50
+ }
51
+ files.push({
52
+ path: toPosixPath(targetPath),
53
+ category,
54
+ sha256: sha256File(sourcePath),
55
+ });
56
+ }
57
+ function addSeedDir(files, seedRoot, seedRelativeDir, targetDir, category) {
58
+ const sourceDir = path_1.default.join(seedRoot, seedRelativeDir);
59
+ for (const sourcePath of listFiles(sourceDir)) {
60
+ const relPath = toPosixPath(path_1.default.relative(sourceDir, sourcePath));
61
+ files.push({
62
+ path: path_1.default.posix.join(targetDir, relPath),
63
+ category,
64
+ sha256: sha256File(sourcePath),
65
+ });
66
+ }
67
+ }
68
+ function seedSourcePath(seedRoot, file) {
69
+ if (file.path === ".mdkg/config.json") {
70
+ return path_1.default.join(seedRoot, "config.json");
71
+ }
72
+ if (file.path === ".mdkg/README.md") {
73
+ return path_1.default.join(seedRoot, "README.md");
74
+ }
75
+ if (file.path.startsWith(".mdkg/core/")) {
76
+ return path_1.default.join(seedRoot, "core", file.path.slice(".mdkg/core/".length));
77
+ }
78
+ if (file.path.startsWith(".mdkg/templates/")) {
79
+ return path_1.default.join(seedRoot, "templates", file.path.slice(".mdkg/templates/".length));
80
+ }
81
+ if (file.path.startsWith(".mdkg/skills/")) {
82
+ return path_1.default.join(seedRoot, "skills", "default", file.path.slice(".mdkg/skills/".length));
83
+ }
84
+ return path_1.default.join(seedRoot, file.path);
85
+ }
86
+ function createInitManifest(seedRoot, mdkgVersion) {
87
+ const files = [];
88
+ addSeedFile(files, seedRoot, "config.json", ".mdkg/config.json", "config");
89
+ addSeedFile(files, seedRoot, "README.md", ".mdkg/README.md", "mdkg_doc");
90
+ addSeedDir(files, seedRoot, "core", ".mdkg/core", "core");
91
+ addSeedDir(files, seedRoot, "templates", ".mdkg/templates", "template");
92
+ for (const doc of AGENT_DOCS) {
93
+ addSeedFile(files, seedRoot, doc, doc, "agent_doc");
94
+ }
95
+ for (const doc of STARTUP_DOCS) {
96
+ addSeedFile(files, seedRoot, doc, doc, "startup_doc");
97
+ }
98
+ addSeedDir(files, seedRoot, path_1.default.join("skills", "default"), ".mdkg/skills", "default_skill");
99
+ return {
100
+ schema_version: exports.INIT_MANIFEST_SCHEMA_VERSION,
101
+ tool: "mdkg",
102
+ mdkg_version: mdkgVersion,
103
+ files: files.sort((a, b) => a.path.localeCompare(b.path)),
104
+ };
105
+ }
106
+ function writeInitManifest(filePath, manifest) {
107
+ fs_1.default.mkdirSync(path_1.default.dirname(filePath), { recursive: true });
108
+ fs_1.default.writeFileSync(filePath, `${JSON.stringify(manifest, null, 2)}\n`, "utf8");
109
+ }
110
+ function readInitManifest(filePath) {
111
+ if (!fs_1.default.existsSync(filePath)) {
112
+ return undefined;
113
+ }
114
+ const parsed = JSON.parse(fs_1.default.readFileSync(filePath, "utf8"));
115
+ if (parsed.schema_version !== exports.INIT_MANIFEST_SCHEMA_VERSION || parsed.tool !== "mdkg" || !Array.isArray(parsed.files)) {
116
+ throw new Error(`${filePath}: invalid mdkg init manifest`);
117
+ }
118
+ return parsed;
119
+ }
120
+ function loadLegacyInitManifests(seedRoot) {
121
+ const legacyDir = path_1.default.join(seedRoot, "legacy");
122
+ if (!fs_1.default.existsSync(legacyDir)) {
123
+ return [];
124
+ }
125
+ return fs_1.default
126
+ .readdirSync(legacyDir, { withFileTypes: true })
127
+ .filter((entry) => entry.isFile() && entry.name.endsWith(".json"))
128
+ .sort((a, b) => a.name.localeCompare(b.name))
129
+ .map((entry) => readInitManifest(path_1.default.join(legacyDir, entry.name)))
130
+ .filter((manifest) => manifest !== undefined);
131
+ }
@@ -0,0 +1,286 @@
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.runUpgradeCommand = runUpgradeCommand;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const migrate_1 = require("../core/migrate");
10
+ const config_1 = require("../core/config");
11
+ const paths_1 = require("../core/paths");
12
+ const version_1 = require("../core/version");
13
+ const errors_1 = require("../util/errors");
14
+ const init_manifest_1 = require("./init_manifest");
15
+ const skill_support_1 = require("./skill_support");
16
+ const skill_mirror_1 = require("./skill_mirror");
17
+ const DEFAULT_SEED_SUBDIR = path_1.default.resolve(__dirname, "..", "init");
18
+ const PROTECTED_CORE_DOCS = new Set([".mdkg/core/SOUL.md", ".mdkg/core/HUMAN.md"]);
19
+ const CREATE_ONLY_PRESERVED = new Set([".mdkg/core/core.md"]);
20
+ function seededInitEvent(nowIso) {
21
+ const event = {
22
+ ts: nowIso,
23
+ run_id: `upgrade-${nowIso.replace(/[^0-9]/g, "").slice(0, 14)}`,
24
+ workspace: "root",
25
+ agent: "mdkg",
26
+ kind: "RUN_STARTED",
27
+ status: "ok",
28
+ refs: ["edd-4"],
29
+ artifacts: [],
30
+ notes: "upgrade ensured agent event log",
31
+ redacted: true,
32
+ };
33
+ return `${JSON.stringify(event)}\n`;
34
+ }
35
+ function requireSeedAssets(seedRoot) {
36
+ for (const required of ["config.json", "README.md", "core", "templates"]) {
37
+ if (!fs_1.default.existsSync(path_1.default.join(seedRoot, required))) {
38
+ throw new errors_1.NotFoundError(`upgrade assets missing ${required} at ${seedRoot} (try reinstalling mdkg)`);
39
+ }
40
+ }
41
+ }
42
+ function isAgentWorkspace(root) {
43
+ return [
44
+ path_1.default.join(root, ".mdkg", "skills"),
45
+ path_1.default.join(root, ".agents", "skills"),
46
+ path_1.default.join(root, ".claude", "skills"),
47
+ path_1.default.join(root, ".mdkg", "work", "events", "events.jsonl"),
48
+ ].some((candidate) => fs_1.default.existsSync(candidate));
49
+ }
50
+ function copyFile(src, dest) {
51
+ fs_1.default.mkdirSync(path_1.default.dirname(dest), { recursive: true });
52
+ fs_1.default.copyFileSync(src, dest);
53
+ }
54
+ function writeFile(filePath, content) {
55
+ fs_1.default.mkdirSync(path_1.default.dirname(filePath), { recursive: true });
56
+ fs_1.default.writeFileSync(filePath, content, "utf8");
57
+ }
58
+ function createSummary() {
59
+ return {
60
+ created: 0,
61
+ updated: 0,
62
+ migrated: 0,
63
+ synced: 0,
64
+ skipped: 0,
65
+ conflicted: 0,
66
+ unchanged: 0,
67
+ };
68
+ }
69
+ function record(summary, changes, change) {
70
+ changes.push(change);
71
+ switch (change.action) {
72
+ case "create":
73
+ summary.created += 1;
74
+ break;
75
+ case "update":
76
+ summary.updated += 1;
77
+ break;
78
+ case "migrate":
79
+ summary.migrated += 1;
80
+ break;
81
+ case "sync":
82
+ summary.synced += 1;
83
+ break;
84
+ case "conflict":
85
+ summary.skipped += 1;
86
+ summary.conflicted += 1;
87
+ break;
88
+ }
89
+ }
90
+ function buildKnownHashes(manifests) {
91
+ const hashes = new Map();
92
+ for (const manifest of manifests) {
93
+ if (!manifest) {
94
+ continue;
95
+ }
96
+ for (const file of manifest.files) {
97
+ if (!hashes.has(file.path)) {
98
+ hashes.set(file.path, new Set());
99
+ }
100
+ hashes.get(file.path)?.add(file.sha256);
101
+ }
102
+ }
103
+ return hashes;
104
+ }
105
+ function shouldIncludeFile(file, agentWorkspace) {
106
+ if (file.category === "default_skill") {
107
+ return agentWorkspace;
108
+ }
109
+ return file.category !== "config";
110
+ }
111
+ function planSeedFile(options) {
112
+ const destPath = path_1.default.join(options.root, options.file.path);
113
+ const srcPath = (0, init_manifest_1.seedSourcePath)(options.seedRoot, options.file);
114
+ const currentHash = fs_1.default.existsSync(destPath) && fs_1.default.statSync(destPath).isFile() ? (0, init_manifest_1.sha256File)(destPath) : undefined;
115
+ const nextHash = options.file.sha256;
116
+ if (!currentHash) {
117
+ record(options.summary, options.changes, {
118
+ path: options.file.path,
119
+ category: options.file.category,
120
+ action: "create",
121
+ reason: "missing managed init asset",
122
+ });
123
+ if (!options.dryRun) {
124
+ copyFile(srcPath, destPath);
125
+ }
126
+ options.managedCurrentFiles.push(options.file);
127
+ return true;
128
+ }
129
+ if (currentHash === nextHash) {
130
+ options.summary.unchanged += 1;
131
+ options.managedCurrentFiles.push(options.file);
132
+ return false;
133
+ }
134
+ if (CREATE_ONLY_PRESERVED.has(options.file.path)) {
135
+ options.summary.unchanged += 1;
136
+ return false;
137
+ }
138
+ if (PROTECTED_CORE_DOCS.has(options.file.path)) {
139
+ record(options.summary, options.changes, {
140
+ path: options.file.path,
141
+ category: options.file.category,
142
+ action: "conflict",
143
+ reason: "protected core document exists; local content preserved",
144
+ });
145
+ return false;
146
+ }
147
+ const known = options.knownHashes.get(options.file.path);
148
+ if (known?.has(currentHash)) {
149
+ record(options.summary, options.changes, {
150
+ path: options.file.path,
151
+ category: options.file.category,
152
+ action: "update",
153
+ reason: "matches a managed seed hash",
154
+ });
155
+ if (!options.dryRun) {
156
+ copyFile(srcPath, destPath);
157
+ }
158
+ options.managedCurrentFiles.push(options.file);
159
+ return true;
160
+ }
161
+ record(options.summary, options.changes, {
162
+ path: options.file.path,
163
+ category: options.file.category,
164
+ action: "conflict",
165
+ reason: "local changes detected; content preserved",
166
+ });
167
+ return false;
168
+ }
169
+ function migrateConfigIfNeeded(root, dryRun, summary, changes) {
170
+ const cfgPath = (0, paths_1.configPath)(root);
171
+ const raw = JSON.parse(fs_1.default.readFileSync(cfgPath, "utf8"));
172
+ const migrated = (0, migrate_1.migrateConfig)(raw);
173
+ (0, config_1.validateConfigSchema)(migrated.config);
174
+ if (migrated.from === migrated.to) {
175
+ summary.unchanged += 1;
176
+ return;
177
+ }
178
+ record(summary, changes, {
179
+ path: ".mdkg/config.json",
180
+ category: "config",
181
+ action: "migrate",
182
+ reason: `config schema_version ${migrated.from} -> ${migrated.to}`,
183
+ });
184
+ if (!dryRun) {
185
+ writeFile(cfgPath, `${JSON.stringify(migrated.config, null, 2)}\n`);
186
+ }
187
+ }
188
+ function ensureAgentRuntimeFiles(root, dryRun, summary, changes) {
189
+ const eventsPath = path_1.default.join(root, ".mdkg", "work", "events", "events.jsonl");
190
+ if (!fs_1.default.existsSync(eventsPath)) {
191
+ record(summary, changes, {
192
+ path: ".mdkg/work/events/events.jsonl",
193
+ category: "event_log",
194
+ action: "create",
195
+ reason: "agent workspace is missing event log",
196
+ });
197
+ if (!dryRun) {
198
+ writeFile(eventsPath, seededInitEvent(new Date().toISOString()));
199
+ }
200
+ }
201
+ else {
202
+ summary.unchanged += 1;
203
+ }
204
+ }
205
+ function emitHumanReceipt(receipt) {
206
+ const mode = receipt.dry_run ? "dry-run" : "apply";
207
+ console.log(`mdkg upgrade ${mode}: ${receipt.summary.created} create, ${receipt.summary.updated} update, ${receipt.summary.migrated} migrate, ${receipt.summary.synced} sync, ${receipt.summary.conflicted} conflict`);
208
+ if (receipt.changes.length === 0) {
209
+ console.log("no upgrade changes pending");
210
+ }
211
+ else {
212
+ for (const change of receipt.changes) {
213
+ console.log(` ${change.action}: ${change.path} (${change.reason})`);
214
+ }
215
+ }
216
+ if (receipt.dry_run && receipt.changes.some((change) => change.action !== "conflict")) {
217
+ console.log("next: mdkg upgrade --apply");
218
+ }
219
+ }
220
+ function runUpgradeCommand(options) {
221
+ const root = path_1.default.resolve(options.root);
222
+ const seedRoot = options.seedRoot ? path_1.default.resolve(options.seedRoot) : DEFAULT_SEED_SUBDIR;
223
+ const dryRun = !options.apply;
224
+ const version = (0, version_1.readPackageVersion)();
225
+ requireSeedAssets(seedRoot);
226
+ const currentManifest = (0, init_manifest_1.createInitManifest)(seedRoot, version);
227
+ const existingManifest = (0, init_manifest_1.readInitManifest)(path_1.default.join(root, ".mdkg", init_manifest_1.INIT_MANIFEST_FILE));
228
+ const legacyManifests = (0, init_manifest_1.loadLegacyInitManifests)(seedRoot);
229
+ const knownHashes = buildKnownHashes([existingManifest, ...legacyManifests]);
230
+ const summary = createSummary();
231
+ const changes = [];
232
+ const agentWorkspace = isAgentWorkspace(root);
233
+ const managedCurrentFiles = [];
234
+ migrateConfigIfNeeded(root, dryRun, summary, changes);
235
+ for (const file of currentManifest.files) {
236
+ if (!shouldIncludeFile(file, agentWorkspace)) {
237
+ continue;
238
+ }
239
+ planSeedFile({
240
+ root,
241
+ seedRoot,
242
+ file,
243
+ knownHashes,
244
+ dryRun,
245
+ summary,
246
+ changes,
247
+ managedCurrentFiles,
248
+ });
249
+ }
250
+ if (agentWorkspace) {
251
+ ensureAgentRuntimeFiles(root, dryRun, summary, changes);
252
+ }
253
+ if (!dryRun) {
254
+ const appliedManifest = {
255
+ ...currentManifest,
256
+ files: managedCurrentFiles.sort((a, b) => a.path.localeCompare(b.path)),
257
+ };
258
+ (0, init_manifest_1.writeInitManifest)(path_1.default.join(root, ".mdkg", init_manifest_1.INIT_MANIFEST_FILE), appliedManifest);
259
+ if (agentWorkspace) {
260
+ const config = (0, config_1.validateConfigSchema)((0, migrate_1.migrateConfig)(JSON.parse(fs_1.default.readFileSync((0, paths_1.configPath)(root), "utf8"))).config);
261
+ (0, skill_support_1.refreshSkillsRegistry)(root, config);
262
+ (0, skill_mirror_1.scaffoldMirrorRoots)(root);
263
+ const result = (0, skill_mirror_1.syncSkillMirrors)({ root, config, createRoots: true });
264
+ record(summary, changes, {
265
+ path: ".agents/skills,.claude/skills",
266
+ category: "skill_mirror",
267
+ action: "sync",
268
+ reason: `${result.synced} mirrored skill(s), ${result.pruned} stale mirror(s) pruned`,
269
+ });
270
+ }
271
+ }
272
+ const receipt = {
273
+ action: "upgrade",
274
+ dry_run: dryRun,
275
+ version,
276
+ summary,
277
+ changes,
278
+ };
279
+ if (options.json) {
280
+ console.log(`${JSON.stringify(receipt, null, 2)}`);
281
+ }
282
+ else {
283
+ emitHumanReceipt(receipt);
284
+ }
285
+ return receipt;
286
+ }
@@ -0,0 +1,31 @@
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.readPackageVersion = readPackageVersion;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
9
+ function readPackageVersion(startDir = __dirname) {
10
+ let current = path_1.default.resolve(startDir);
11
+ for (let i = 0; i < 5; i += 1) {
12
+ const packagePath = path_1.default.join(current, "package.json");
13
+ if (fs_1.default.existsSync(packagePath)) {
14
+ try {
15
+ const raw = JSON.parse(fs_1.default.readFileSync(packagePath, "utf8"));
16
+ if (raw.name === "mdkg" && typeof raw.version === "string" && raw.version.trim().length > 0) {
17
+ return raw.version;
18
+ }
19
+ }
20
+ catch {
21
+ return "unknown";
22
+ }
23
+ }
24
+ const parent = path_1.default.dirname(current);
25
+ if (parent === current) {
26
+ break;
27
+ }
28
+ current = parent;
29
+ }
30
+ return "unknown";
31
+ }
@@ -23,6 +23,7 @@ Agent operating prompt:
23
23
  - Use `mdkg search "..."` and `mdkg next` to discover current work.
24
24
  - Use `mdkg skill list`, `mdkg skill search`, and `mdkg skill show <slug>` for skill discovery.
25
25
  - Use `mdkg task start/update/done` for structured task, bug, and test lifecycle fields.
26
+ - Use `mdkg upgrade` to preview scaffold updates; only run `mdkg upgrade --apply` after reviewing the receipt.
26
27
  - Keep nuanced summaries, body text, and manual parent closeout edits in markdown.
27
28
  - Use `mdkg event enable` only if `events.jsonl` is missing and provenance should be restored.
28
29
  - Use `CLI_COMMAND_MATRIX.md` for the canonical command and flag surface.
@@ -8,6 +8,7 @@ Verify live help with:
8
8
 
9
9
  Primary commands:
10
10
  - `mdkg init`
11
+ - `mdkg upgrade [--dry-run] [--apply] [--json]`
11
12
  - `mdkg new`
12
13
  - `mdkg show`
13
14
  - `mdkg list`
@@ -64,6 +65,11 @@ Agent bootstrap:
64
65
  - `mdkg init --llm --agent`
65
66
  - published bootstrap config is root-only by default
66
67
 
68
+ Upgrade:
69
+ - `mdkg upgrade` previews safe scaffold updates and writes nothing by default
70
+ - `mdkg upgrade --apply` updates only managed or unchanged init assets
71
+ - customized docs, templates, skills, and core files are preserved and reported
72
+
67
73
  Skill discovery:
68
74
  - `mdkg skill list --tags stage:plan --json`
69
75
  - `mdkg skill search "<query>" --json`
@@ -15,6 +15,7 @@ This repository is initialized for mdkg.
15
15
 
16
16
  ```bash
17
17
  mdkg init --llm --agent
18
+ mdkg upgrade
18
19
  mdkg search "..."
19
20
  mdkg show <id>
20
21
  mdkg pack <id>
@@ -50,3 +51,9 @@ Recommended:
50
51
  ```bash
51
52
  mdkg init --update-gitignore --update-npmignore
52
53
  ```
54
+
55
+ ## Upgrade
56
+
57
+ `mdkg upgrade` previews safe scaffold updates for existing workspaces and writes nothing by default.
58
+
59
+ Use `mdkg upgrade --apply` only after reviewing the receipt. Local customizations are preserved and reported instead of overwritten.
@@ -0,0 +1,197 @@
1
+ {
2
+ "schema_version": 1,
3
+ "tool": "mdkg",
4
+ "mdkg_version": "0.1.0",
5
+ "files": [
6
+ {
7
+ "path": ".mdkg/config.json",
8
+ "category": "config",
9
+ "sha256": "eb76bf22ae9d04601c2fedac5fd22838797dd2cc829324638a6b69222d40aaa9"
10
+ },
11
+ {
12
+ "path": ".mdkg/core/core.md",
13
+ "category": "core",
14
+ "sha256": "d87beecf4229535c0d0feea7deae28b97d0681105a1c282d9961e97918f0bbe8"
15
+ },
16
+ {
17
+ "path": ".mdkg/core/guide.md",
18
+ "category": "core",
19
+ "sha256": "0b0ba51fbc393b3d5e0a0df4dece6aa822b77ab0f4ee3814b2cdba77ef8b65d9"
20
+ },
21
+ {
22
+ "path": ".mdkg/core/HUMAN.md",
23
+ "category": "core",
24
+ "sha256": "75d2e015cd5ba61062cb84246017ee4f4221610d4a56e4a0b332271b90694965"
25
+ },
26
+ {
27
+ "path": ".mdkg/core/rule-1-mdkg-conventions.md",
28
+ "category": "core",
29
+ "sha256": "20073cd21c148f1b93a382550f835ccb2e896cc676903328557004319235c112"
30
+ },
31
+ {
32
+ "path": ".mdkg/core/rule-2-context-pack-rules.md",
33
+ "category": "core",
34
+ "sha256": "9dfd46b5ae791220c68304abc0784399509cf606821c937671cf63d6e9a8ce8f"
35
+ },
36
+ {
37
+ "path": ".mdkg/core/rule-3-cli-contract.md",
38
+ "category": "core",
39
+ "sha256": "b547a6edc20112013c607a033af4ac0c6bb3f9d66d445b0c545b2890a721b671"
40
+ },
41
+ {
42
+ "path": ".mdkg/core/rule-4-repo-safety-and-ignores.md",
43
+ "category": "core",
44
+ "sha256": "d7fc4bfa3727ed7d5353eeb0089ad818b96a755578e217251106422559750291"
45
+ },
46
+ {
47
+ "path": ".mdkg/core/rule-5-release-and-versioning.md",
48
+ "category": "core",
49
+ "sha256": "4fc6648052f80b90b2efc173e3bcab16cb0bc6680bb8b04f76c66fff06ad19cd"
50
+ },
51
+ {
52
+ "path": ".mdkg/core/rule-6-templates-and-schemas.md",
53
+ "category": "core",
54
+ "sha256": "0d6da477c12e3492f43c571a6e4daa373bf05005ef703ad5166b7c8786e553b0"
55
+ },
56
+ {
57
+ "path": ".mdkg/core/SOUL.md",
58
+ "category": "core",
59
+ "sha256": "2bfdd4d1a65dd18c14d3e8469d0d5c74c6cc7c067f0b56d227532b7ab620795a"
60
+ },
61
+ {
62
+ "path": ".mdkg/README.md",
63
+ "category": "mdkg_doc",
64
+ "sha256": "26e99be382b48682b7841f14404576f79bf6876b64a90aefa6c99c2440701d2a"
65
+ },
66
+ {
67
+ "path": ".mdkg/skills/build-pack-and-execute-task/SKILL.md",
68
+ "category": "default_skill",
69
+ "sha256": "7f6104980e6b2ec0749881c6be2bd3d7982702259c4979763266d1c800aeb410"
70
+ },
71
+ {
72
+ "path": ".mdkg/skills/select-work-and-ground-context/SKILL.md",
73
+ "category": "default_skill",
74
+ "sha256": "c8c04134532deda079f9ee290a66b2423892f9789fa946e44db4c89c05b8e1bf"
75
+ },
76
+ {
77
+ "path": ".mdkg/skills/verify-close-and-checkpoint/SKILL.md",
78
+ "category": "default_skill",
79
+ "sha256": "98a1b02927854201eeea73e3d7c9f5a104fab7a5c72e033ea261995341a8a7ce"
80
+ },
81
+ {
82
+ "path": ".mdkg/templates/default/bug.md",
83
+ "category": "template",
84
+ "sha256": "88e3f8d67aa3b2156be2006bd1c8139b7b16b46f2c05a4f4d840b3746a40f9c5"
85
+ },
86
+ {
87
+ "path": ".mdkg/templates/default/chk.md",
88
+ "category": "template",
89
+ "sha256": "15f793e422009c76f8bda72c3609157acd7f03762d9c9bdb096c4aa2e2c3fb89"
90
+ },
91
+ {
92
+ "path": ".mdkg/templates/default/dec.md",
93
+ "category": "template",
94
+ "sha256": "a2f7098fea538c153ac290f2e2edb2e755ca9dd07d17c2a127fb23959517ece9"
95
+ },
96
+ {
97
+ "path": ".mdkg/templates/default/dispute.md",
98
+ "category": "template",
99
+ "sha256": "b1c5330fd4a1e3f03dbb4ac8907bd728e55537e053dcf43ebcbdc835ff1d0579"
100
+ },
101
+ {
102
+ "path": ".mdkg/templates/default/edd.md",
103
+ "category": "template",
104
+ "sha256": "44828719927cfd31389b9d55b57fc4fa9bc640f3e2475baefe585e4043740f5e"
105
+ },
106
+ {
107
+ "path": ".mdkg/templates/default/epic.md",
108
+ "category": "template",
109
+ "sha256": "56697b69af027fe08c00866c0c0670f7d7e2a0857803bd4aabb99f4761311879"
110
+ },
111
+ {
112
+ "path": ".mdkg/templates/default/feat.md",
113
+ "category": "template",
114
+ "sha256": "99cfdd97b40b119cf899fd766d816c07b7daaafd8ec8e70e6c6de5c0d37f581c"
115
+ },
116
+ {
117
+ "path": ".mdkg/templates/default/feedback.md",
118
+ "category": "template",
119
+ "sha256": "61ad7b8b717d17736ba505f814fa6e4f9ec61f7fe4ae6622359304620a99d649"
120
+ },
121
+ {
122
+ "path": ".mdkg/templates/default/prd.md",
123
+ "category": "template",
124
+ "sha256": "afee167576a4f881ab191867e118864b7b5629e14b9c4a61359c8fbd7ececeee"
125
+ },
126
+ {
127
+ "path": ".mdkg/templates/default/prop.md",
128
+ "category": "template",
129
+ "sha256": "839b976a8ddc0d6abddfbe6114dfb87f64471958ae807c011538777b758aa1f0"
130
+ },
131
+ {
132
+ "path": ".mdkg/templates/default/proposal.md",
133
+ "category": "template",
134
+ "sha256": "16bfa81b6e665064e93e0d1b625dccc518b9885f87a32a15e5ba5441c2c27ea8"
135
+ },
136
+ {
137
+ "path": ".mdkg/templates/default/receipt.md",
138
+ "category": "template",
139
+ "sha256": "aac6e6e27153a1ca85a515b03f0ac55db3eb0df3f9243c42f0b936f5e5a750b2"
140
+ },
141
+ {
142
+ "path": ".mdkg/templates/default/rule.md",
143
+ "category": "template",
144
+ "sha256": "6321abf72af61a6513d7bfaa2d3122b2aa3bd2b95b662a52d569fb2bf819fda1"
145
+ },
146
+ {
147
+ "path": ".mdkg/templates/default/spec.md",
148
+ "category": "template",
149
+ "sha256": "e3e05d8d627c478d2757451f61b5a8fda8a75da9885a9261b2f8f5cb8a3a36dc"
150
+ },
151
+ {
152
+ "path": ".mdkg/templates/default/task.md",
153
+ "category": "template",
154
+ "sha256": "f6385dd4f56f1c8df164ac3e79d82c5a3fde3f952dc9cdc78c0b8077caa62277"
155
+ },
156
+ {
157
+ "path": ".mdkg/templates/default/test.md",
158
+ "category": "template",
159
+ "sha256": "bdae53e5cb4bd77712da155bbcfc24409ced8162c977e6bc478a9d1e695ddef7"
160
+ },
161
+ {
162
+ "path": ".mdkg/templates/default/work_order.md",
163
+ "category": "template",
164
+ "sha256": "bdbdf6e34d59976a675dd1d25002dfc0ef49e725647c97a9e0b3552c93fb8600"
165
+ },
166
+ {
167
+ "path": ".mdkg/templates/default/work.md",
168
+ "category": "template",
169
+ "sha256": "651b7339f6e23c8745264f3f6641a0c82fcd765247f0a70a9f407a118a49ec00"
170
+ },
171
+ {
172
+ "path": "AGENT_START.md",
173
+ "category": "startup_doc",
174
+ "sha256": "be0990bb81e194a2a396f9520cda66c34d0bbbd36daa5b48773246549aacab2e"
175
+ },
176
+ {
177
+ "path": "AGENTS.md",
178
+ "category": "agent_doc",
179
+ "sha256": "9e33a1c20320e317e1e37dbb09fd0303e355b9e7d49cf2128fe791aaa2ce2fb1"
180
+ },
181
+ {
182
+ "path": "CLAUDE.md",
183
+ "category": "agent_doc",
184
+ "sha256": "3ff3ec5560968f7f1bf6f7d34a3c4b6e636edc9f0d45f717cdebc4df3b76403a"
185
+ },
186
+ {
187
+ "path": "CLI_COMMAND_MATRIX.md",
188
+ "category": "startup_doc",
189
+ "sha256": "eb441dd11b31270ddb31f0a77c75fc744671754cffac3aa8ac6f60e30a1f324f"
190
+ },
191
+ {
192
+ "path": "llms.txt",
193
+ "category": "startup_doc",
194
+ "sha256": "8316bb8f634c6fb290ef1591e9c5b9786a2ddc06d25ab7d448fce8f4aebf65b8"
195
+ }
196
+ ]
197
+ }
@@ -0,0 +1,197 @@
1
+ {
2
+ "schema_version": 1,
3
+ "tool": "mdkg",
4
+ "mdkg_version": "0.0.9",
5
+ "files": [
6
+ {
7
+ "path": ".mdkg/config.json",
8
+ "category": "config",
9
+ "sha256": "eb76bf22ae9d04601c2fedac5fd22838797dd2cc829324638a6b69222d40aaa9"
10
+ },
11
+ {
12
+ "path": ".mdkg/core/HUMAN.md",
13
+ "category": "core",
14
+ "sha256": "75d2e015cd5ba61062cb84246017ee4f4221610d4a56e4a0b332271b90694965"
15
+ },
16
+ {
17
+ "path": ".mdkg/core/SOUL.md",
18
+ "category": "core",
19
+ "sha256": "2bfdd4d1a65dd18c14d3e8469d0d5c74c6cc7c067f0b56d227532b7ab620795a"
20
+ },
21
+ {
22
+ "path": ".mdkg/core/core.md",
23
+ "category": "core",
24
+ "sha256": "d87beecf4229535c0d0feea7deae28b97d0681105a1c282d9961e97918f0bbe8"
25
+ },
26
+ {
27
+ "path": ".mdkg/core/guide.md",
28
+ "category": "core",
29
+ "sha256": "0b0ba51fbc393b3d5e0a0df4dece6aa822b77ab0f4ee3814b2cdba77ef8b65d9"
30
+ },
31
+ {
32
+ "path": ".mdkg/core/rule-1-mdkg-conventions.md",
33
+ "category": "core",
34
+ "sha256": "20073cd21c148f1b93a382550f835ccb2e896cc676903328557004319235c112"
35
+ },
36
+ {
37
+ "path": ".mdkg/core/rule-2-context-pack-rules.md",
38
+ "category": "core",
39
+ "sha256": "9dfd46b5ae791220c68304abc0784399509cf63d6e9a8ce8f"
40
+ },
41
+ {
42
+ "path": ".mdkg/core/rule-3-cli-contract.md",
43
+ "category": "core",
44
+ "sha256": "b547a6edc20112013c607a033af4ac0c6bb3f9d66d445b0c545b2890a721b671"
45
+ },
46
+ {
47
+ "path": ".mdkg/core/rule-4-repo-safety-and-ignores.md",
48
+ "category": "core",
49
+ "sha256": "d7fc4bfa3727ed7d5353eeb0089ad818b96a755578e217251106422559750291"
50
+ },
51
+ {
52
+ "path": ".mdkg/core/rule-5-release-and-versioning.md",
53
+ "category": "core",
54
+ "sha256": "4fc6648052f80b90b2efc173e3bcab16cb0bc6680bb8b04f76c66fff06ad19cd"
55
+ },
56
+ {
57
+ "path": ".mdkg/core/rule-6-templates-and-schemas.md",
58
+ "category": "core",
59
+ "sha256": "0d6da477c12e3492f43c571a6e4daa373bf05005ef703ad5166b7c8786e553b0"
60
+ },
61
+ {
62
+ "path": ".mdkg/README.md",
63
+ "category": "mdkg_doc",
64
+ "sha256": "580ed58d4406783f79dd839902de3238647c99605e0849a87ca19a6bd9c738a2"
65
+ },
66
+ {
67
+ "path": ".mdkg/skills/build-pack-and-execute-task/SKILL.md",
68
+ "category": "default_skill",
69
+ "sha256": "7f6104980e6b2ec0749881c6be2bd3d7982702259c4979763266d1c800aeb410"
70
+ },
71
+ {
72
+ "path": ".mdkg/skills/select-work-and-ground-context/SKILL.md",
73
+ "category": "default_skill",
74
+ "sha256": "c8c04134532deda079f9ee290a66b2423892f9789fa946e44db4c89c05b8e1bf"
75
+ },
76
+ {
77
+ "path": ".mdkg/skills/verify-close-and-checkpoint/SKILL.md",
78
+ "category": "default_skill",
79
+ "sha256": "1d1bbb2cb09d13bc469706e60c38f883457d507144a33fd2675a7c1c48118132"
80
+ },
81
+ {
82
+ "path": ".mdkg/templates/default/bug.md",
83
+ "category": "template",
84
+ "sha256": "88e3f8d67aa3b2156be2006bd1c8139b7b16b46f2c05a4f4d840b3746a40f9c5"
85
+ },
86
+ {
87
+ "path": ".mdkg/templates/default/chk.md",
88
+ "category": "template",
89
+ "sha256": "15f793e422009c76f8bda72c3609157acd7f03762d9c9bdb096c4aa2e2c3fb89"
90
+ },
91
+ {
92
+ "path": ".mdkg/templates/default/dec.md",
93
+ "category": "template",
94
+ "sha256": "a2f7098fea538c153ac290f2e2edb2e755ca9dd07d17c2a127fb23959517ece9"
95
+ },
96
+ {
97
+ "path": ".mdkg/templates/default/dispute.md",
98
+ "category": "template",
99
+ "sha256": "b1c5330fd4a1e3f03dbb4ac8907bd728e55537e053dcf43ebcbdc835ff1d0579"
100
+ },
101
+ {
102
+ "path": ".mdkg/templates/default/edd.md",
103
+ "category": "template",
104
+ "sha256": "44828719927cfd31389b9d55b57fc4fa9bc640f3e2475baefe585e4043740f5e"
105
+ },
106
+ {
107
+ "path": ".mdkg/templates/default/epic.md",
108
+ "category": "template",
109
+ "sha256": "56697b69af027fe08c00866c0c0670f7d7e2a0857803bd4aabb99f4761311879"
110
+ },
111
+ {
112
+ "path": ".mdkg/templates/default/feat.md",
113
+ "category": "template",
114
+ "sha256": "99cfdd97b40b119cf899fd766d816c07b7daaafd8ec8e70e6c6de5c0d37f581c"
115
+ },
116
+ {
117
+ "path": ".mdkg/templates/default/feedback.md",
118
+ "category": "template",
119
+ "sha256": "61ad7b8b717d17736ba505f814fa6e4f9ec61f7fe4ae6622359304620a99d649"
120
+ },
121
+ {
122
+ "path": ".mdkg/templates/default/prd.md",
123
+ "category": "template",
124
+ "sha256": "afee167576a4f881ab191867e118864b7b5629e14b9c4a61359c8fbd7ececeee"
125
+ },
126
+ {
127
+ "path": ".mdkg/templates/default/prop.md",
128
+ "category": "template",
129
+ "sha256": "839b976a8ddc0d6abddfbe6114dfb87f64471958ae807c011538777b758aa1f0"
130
+ },
131
+ {
132
+ "path": ".mdkg/templates/default/proposal.md",
133
+ "category": "template",
134
+ "sha256": "16bfa81b6e665064e93e0d1b625dccc518b9885f87a32a15e5ba5441c2c27ea8"
135
+ },
136
+ {
137
+ "path": ".mdkg/templates/default/receipt.md",
138
+ "category": "template",
139
+ "sha256": "aac6e6e27153a1ca85a515b03f0ac55db3eb0df3f9243c42f0b936f5e5a750b2"
140
+ },
141
+ {
142
+ "path": ".mdkg/templates/default/rule.md",
143
+ "category": "template",
144
+ "sha256": "6321abf72af61a6513d7bfaa2d3122b2aa3bd2b95b662a52d569fb2bf819fda1"
145
+ },
146
+ {
147
+ "path": ".mdkg/templates/default/spec.md",
148
+ "category": "template",
149
+ "sha256": "e3e05d8d627c478d2757451f61b5a8fda8a75da9885a9261b2f8f5cb8a3a36dc"
150
+ },
151
+ {
152
+ "path": ".mdkg/templates/default/task.md",
153
+ "category": "template",
154
+ "sha256": "f6385dd4f56f1c8df164ac3e79d82c5a3fde3f952dc9cdc78c0b8077caa62277"
155
+ },
156
+ {
157
+ "path": ".mdkg/templates/default/test.md",
158
+ "category": "template",
159
+ "sha256": "bdae53e5cb4bd77712da155bbcfc24409ced8162c977e6bc478a9d1e695ddef7"
160
+ },
161
+ {
162
+ "path": ".mdkg/templates/default/work.md",
163
+ "category": "template",
164
+ "sha256": "651b7339f6e23c8745264f3f6641a0c82fcd765247f0a70a9f407a118a49ec00"
165
+ },
166
+ {
167
+ "path": ".mdkg/templates/default/work_order.md",
168
+ "category": "template",
169
+ "sha256": "bdbdf6e34d59976a675dd1d25002dfc0ef49e725647c97a9e0b3552c93fb8600"
170
+ },
171
+ {
172
+ "path": "AGENTS.md",
173
+ "category": "agent_doc",
174
+ "sha256": "9e33a1c20320e317e1e37dbb09fd0303e355b9e7d49cf2128fe791aaa2ce2fb1"
175
+ },
176
+ {
177
+ "path": "AGENT_START.md",
178
+ "category": "startup_doc",
179
+ "sha256": "ef8ec5feedbac948a1c63d14c5fff5bb41e3903d9de2c2b3e4db779278ff1b19"
180
+ },
181
+ {
182
+ "path": "CLAUDE.md",
183
+ "category": "agent_doc",
184
+ "sha256": "3ff3ec5560968f7f1bf6f7d34a3c4b6e636edc9f0d45f717cdebc4df3b76403a"
185
+ },
186
+ {
187
+ "path": "CLI_COMMAND_MATRIX.md",
188
+ "category": "startup_doc",
189
+ "sha256": "e39f45786eaf0cef07cc6fecd0c230474cfd7ee016a3736128566325cef73519"
190
+ },
191
+ {
192
+ "path": "llms.txt",
193
+ "category": "startup_doc",
194
+ "sha256": "8316bb8f634c6fb290ef1591e9c5b9786a2ddc06d25ab7d448fce8f4aebf65b8"
195
+ }
196
+ ]
197
+ }
@@ -28,16 +28,17 @@ Finish work with evidence, validation, and minimal memory drift.
28
28
 
29
29
  1. Run the relevant technical gates for the changed surface.
30
30
  2. Run `mdkg validate` before closing the task.
31
- 3. Use `mdkg task update <id> ...` for additive evidence and structured metadata changes; keep narrative/body edits in markdown.
32
- 4. Use `mdkg task done <id> --checkpoint "<title>"` when the task should close with milestone compression.
33
- 5. Batch durable mdkg writes at one boundary: task status, artifact refs, optional checkpoint, and commit.
34
- 6. Mark tasks done only after evidence exists.
35
- 7. Create a checkpoint only for milestone-level transitions, not every small step.
36
- 8. For feat or epic closeout, prefer a checkpoint body as the durable narrative summary of what changed and what is next.
37
- 9. Use feat closeout scope as direct children with `parent: <feat-id>` and epic closeout scope as descendant work with `epic: <epic-id>`.
38
- 10. Parent status edits remain manual; do not invent a hidden parent-closeout workflow.
39
- 11. If the latest checkpoint is relevant, use it as durable recall; treat raw events as provenance/debugging, not primary execution context.
40
- 12. If `events.jsonl` is missing, recreate it with `mdkg event enable` before expecting automatic JSONL provenance.
31
+ 3. For mdkg scaffold or release work, include `mdkg upgrade` dry-run/apply evidence and any package smoke that exercises upgrade behavior.
32
+ 4. Use `mdkg task update <id> ...` for additive evidence and structured metadata changes; keep narrative/body edits in markdown.
33
+ 5. Use `mdkg task done <id> --checkpoint "<title>"` when the task should close with milestone compression.
34
+ 6. Batch durable mdkg writes at one boundary: task status, artifact refs, optional checkpoint, and commit.
35
+ 7. Mark tasks done only after evidence exists.
36
+ 8. Create a checkpoint only for milestone-level transitions, not every small step.
37
+ 9. For feat or epic closeout, prefer a checkpoint body as the durable narrative summary of what changed and what is next.
38
+ 10. Use feat closeout scope as direct children with `parent: <feat-id>` and epic closeout scope as descendant work with `epic: <epic-id>`.
39
+ 11. Parent status edits remain manual; do not invent a hidden parent-closeout workflow.
40
+ 12. If the latest checkpoint is relevant, use it as durable recall; treat raw events as provenance/debugging, not primary execution context.
41
+ 13. If `events.jsonl` is missing, recreate it with `mdkg event enable` before expecting automatic JSONL provenance.
41
42
 
42
43
  ## Outputs
43
44
 
@@ -79,6 +79,7 @@ const BOOLEAN_FLAGS = new Set([
79
79
  "--concise",
80
80
  "--version",
81
81
  "--dry-run",
82
+ "--apply",
82
83
  "--json",
83
84
  "--xml",
84
85
  "--toon",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mdkg",
3
- "version": "0.0.9",
3
+ "version": "0.1.0",
4
4
  "description": "Markdown Knowledge Graph",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -13,10 +13,11 @@
13
13
  "test:coverage": "npm run build && npm run build:test && node --test --experimental-test-coverage dist/tests/**/*.test.js",
14
14
  "smoke:consumer": "npm run build && node scripts/smoke-consumer.js",
15
15
  "smoke:matrix": "npm run build && node scripts/smoke-command-matrix.js",
16
+ "smoke:upgrade": "npm run build && node scripts/smoke-upgrade.js",
16
17
  "cli:snapshot": "npm run build && node scripts/cli_help_snapshot.js",
17
18
  "cli:check": "npm run build && node scripts/cli_help_snapshot.js --check",
18
19
  "prepack": "npm run build && node scripts/assert-publish-ready.js",
19
- "prepublishOnly": "npm run test && npm run cli:check && node dist/cli.js validate && npm run smoke:consumer && npm run smoke:matrix && node scripts/assert-publish-ready.js",
20
+ "prepublishOnly": "npm run test && npm run cli:check && node dist/cli.js validate && npm run smoke:consumer && npm run smoke:matrix && npm run smoke:upgrade && node scripts/assert-publish-ready.js",
20
21
  "postinstall": "node scripts/postinstall.js"
21
22
  },
22
23
  "devDependencies": {