@brucewaynedecoy/make-docs 1.0.0-rc.1 → 2.0.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.
- package/LICENSE +21 -201
- package/README.md +36 -27
- package/dist/backup-73HQNKMC.js +20 -0
- package/dist/backup-73HQNKMC.js.map +1 -0
- package/dist/chunk-3BAJQXGH.js +1575 -0
- package/dist/chunk-3BAJQXGH.js.map +1 -0
- package/dist/chunk-64CTKJO7.js +4136 -0
- package/dist/chunk-64CTKJO7.js.map +1 -0
- package/dist/chunk-BENO4IH5.js +875 -0
- package/dist/chunk-BENO4IH5.js.map +1 -0
- package/dist/chunk-D4HDZEJT.js +37 -0
- package/dist/chunk-D4HDZEJT.js.map +1 -0
- package/dist/chunk-G5EF63GG.js +1291 -0
- package/dist/chunk-G5EF63GG.js.map +1 -0
- package/dist/chunk-GNP6HRVP.js +523 -0
- package/dist/chunk-GNP6HRVP.js.map +1 -0
- package/dist/chunk-HJYIQTMD.js +204 -0
- package/dist/chunk-HJYIQTMD.js.map +1 -0
- package/dist/chunk-LQ5NSWCJ.js +39 -0
- package/dist/chunk-LQ5NSWCJ.js.map +1 -0
- package/dist/chunk-LRVV7UDD.js +2340 -0
- package/dist/chunk-LRVV7UDD.js.map +1 -0
- package/dist/chunk-LVQSJF63.js +24674 -0
- package/dist/chunk-LVQSJF63.js.map +1 -0
- package/dist/chunk-MXBHCHSM.js +13995 -0
- package/dist/chunk-MXBHCHSM.js.map +1 -0
- package/dist/chunk-Z5K4FHYP.js +922 -0
- package/dist/chunk-Z5K4FHYP.js.map +1 -0
- package/dist/index.js +3798 -250
- package/dist/index.js.map +1 -1
- package/dist/self-YYXOLDKU.js +653 -0
- package/dist/self-YYXOLDKU.js.map +1 -0
- package/dist/server-O2ZELIMX.js +512 -0
- package/dist/server-O2ZELIMX.js.map +1 -0
- package/dist/setup-system-HZROFNMP.js +544 -0
- package/dist/setup-system-HZROFNMP.js.map +1 -0
- package/dist/{skills-command-3ESCZ75U.js → skills-command-MGGHY7HU.js} +190 -32
- package/dist/skills-command-MGGHY7HU.js.map +1 -0
- package/dist/uninstall-3UXXXNFO.js +223 -0
- package/dist/uninstall-3UXXXNFO.js.map +1 -0
- package/dist/virtual_make-docs-first-party-skills-ZII74YOB.js +11 -0
- package/dist/virtual_make-docs-first-party-skills-ZII74YOB.js.map +1 -0
- package/package.json +9 -6
- package/skill-registry.json +328 -125
- package/skill-registry.schema.json +221 -45
- package/template/.make-docs/AGENTS.md +18 -0
- package/template/.make-docs/CLAUDE.md +18 -0
- package/template/.make-docs/archive/AGENTS.md +11 -0
- package/template/.make-docs/archive/CLAUDE.md +11 -0
- package/template/.make-docs/system/AGENTS.md +12 -0
- package/template/.make-docs/system/CLAUDE.md +12 -0
- package/template/.make-docs/system/contracts/AGENTS.md +13 -0
- package/template/.make-docs/system/contracts/CLAUDE.md +13 -0
- package/template/{docs/assets/references → .make-docs/system/contracts}/commit-message-convention.md +4 -4
- package/template/.make-docs/system/contracts/coverage-pass-contract.md +198 -0
- package/template/.make-docs/system/contracts/deferred-obligation-contract.md +128 -0
- package/template/{docs/assets/references → .make-docs/system/contracts}/design-contract.md +7 -2
- package/template/{docs/assets/references → .make-docs/system/contracts}/guide-contract.md +21 -19
- package/template/{docs/assets/references → .make-docs/system/contracts}/history-record-contract.md +17 -11
- package/template/.make-docs/system/contracts/human-experience-contract.md +134 -0
- package/template/.make-docs/system/contracts/naive-uat-contract.md +231 -0
- package/template/.make-docs/system/contracts/output-contract.md +277 -0
- package/template/.make-docs/system/contracts/performance-evidence-governance.md +257 -0
- package/template/.make-docs/system/contracts/system-resource-contract.md +93 -0
- package/template/.make-docs/system/prompts/AGENTS.md +12 -0
- package/template/.make-docs/system/prompts/CLAUDE.md +12 -0
- package/template/.make-docs/system/prompts/coverage-pass-maintainer-guide.prompt.md +20 -0
- package/template/.make-docs/system/prompts/coverage-pass-prd-reconciliation.prompt.md +18 -0
- package/template/.make-docs/system/prompts/coverage-pass-testing-uat.prompt.md +46 -0
- package/template/.make-docs/system/prompts/coverage-pass-user-guide.prompt.md +20 -0
- package/template/.make-docs/system/prompts/designs-to-plan-change.prompt.md +18 -0
- package/template/.make-docs/system/prompts/designs-to-plan.prompt.md +14 -0
- package/template/.make-docs/system/prompts/docs-path-hygiene-cleanup.prompt.md +29 -0
- package/template/.make-docs/system/prompts/naive-uat-facilitator.prompt.md +28 -0
- package/template/.make-docs/system/prompts/naive-uat-tester.prompt.md +20 -0
- package/template/.make-docs/system/prompts/performance-coverage.prompt.md +63 -0
- package/template/.make-docs/system/prompts/plan-to-prd-change.prompt.md +12 -0
- package/template/.make-docs/system/prompts/plan-to-prd-green-field.prompt.md +10 -0
- package/template/.make-docs/system/prompts/prd-change-to-work.prompt.md +14 -0
- package/template/.make-docs/system/prompts/prd-to-work-full-prd.prompt.md +10 -0
- package/template/.make-docs/system/prompts/prd-to-work-prd-feature.prompt.md +10 -0
- package/template/.make-docs/system/prompts/request-to-design.prompt.md +20 -0
- package/template/.make-docs/system/prompts/session-to-history-record.prompt.md +23 -0
- package/template/{docs/assets → .make-docs/system}/prompts/work-to-commit-message.prompt.md +2 -2
- package/template/.make-docs/system/prompts/work-to-guides.prompt.md +22 -0
- package/template/.make-docs/system/references/AGENTS.md +14 -0
- package/template/.make-docs/system/references/CLAUDE.md +14 -0
- package/template/{docs/assets → .make-docs/system}/references/design-workflow.md +15 -2
- package/template/.make-docs/system/references/execution-workflow.md +189 -0
- package/template/.make-docs/system/references/human-experience.md +138 -0
- package/template/.make-docs/system/references/lifecycle.md +153 -0
- package/template/.make-docs/system/references/naive-uat-validation.md +65 -0
- package/template/.make-docs/system/references/naive-uat-workflow.md +64 -0
- package/template/.make-docs/system/references/path-and-link-hygiene.md +101 -0
- package/template/.make-docs/system/references/performance-evidence.md +114 -0
- package/template/.make-docs/system/references/planning-workflow.md +209 -0
- package/template/.make-docs/system/references/prd-change-management.md +165 -0
- package/template/{docs/assets → .make-docs/system}/references/wave-model.md +10 -8
- package/template/.make-docs/system/templates/AGENTS.md +12 -0
- package/template/.make-docs/system/templates/CLAUDE.md +12 -0
- package/template/.make-docs/system/templates/design.md +79 -0
- package/template/{docs/assets/templates/guide-developer.md → .make-docs/system/templates/guide-maintainer.md} +7 -3
- package/template/{docs/assets → .make-docs/system}/templates/guide-user.md +6 -2
- package/template/{docs/assets → .make-docs/system}/templates/history-record.md +6 -3
- package/template/.make-docs/system/templates/naive-uat-scenario.md +91 -0
- package/template/.make-docs/system/templates/performance-evidence-profile.md +252 -0
- package/template/.make-docs/system/templates/plan-overview.md +76 -0
- package/template/.make-docs/system/templates/plan-prd-change.md +155 -0
- package/template/{docs/assets → .make-docs/system}/templates/plan-prd-decompose.md +10 -0
- package/template/{docs/assets → .make-docs/system}/templates/plan-prd.md +28 -2
- package/template/{docs/assets → .make-docs/system}/templates/prd-architecture.md +13 -0
- package/template/.make-docs/system/templates/prd-glossary.md +28 -0
- package/template/.make-docs/system/templates/prd-index.md +70 -0
- package/template/{docs/assets → .make-docs/system}/templates/prd-overview.md +13 -0
- package/template/.make-docs/system/templates/prd-reference.md +30 -0
- package/template/{docs/assets → .make-docs/system}/templates/prd-risk-register.md +16 -1
- package/template/{docs/assets → .make-docs/system}/templates/prd-subsystem.md +15 -0
- package/template/.make-docs/system/templates/work-index.md +58 -0
- package/template/.make-docs/system/templates/work-phase.md +107 -0
- package/template/.make-docs/system-resources.catalog.json +91 -0
- package/template/.make-docs/system-resources.schema.json +204 -0
- package/template/AGENTS.md +8 -1
- package/template/CLAUDE.md +8 -1
- package/template/docs/AGENTS.codex-only.md +22 -0
- package/template/docs/AGENTS.md +21 -13
- package/template/docs/CLAUDE.claude-only.md +22 -0
- package/template/docs/CLAUDE.md +21 -13
- package/template/docs/assets/AGENTS.md +11 -7
- package/template/docs/assets/CLAUDE.md +11 -7
- package/template/docs/designs/AGENTS.md +8 -3
- package/template/docs/designs/CLAUDE.md +8 -3
- package/template/docs/plans/AGENTS.md +10 -3
- package/template/docs/plans/CLAUDE.md +10 -3
- package/template/docs/prd/AGENTS.md +14 -4
- package/template/docs/prd/CLAUDE.md +14 -4
- package/template/docs/work/AGENTS.md +10 -3
- package/template/docs/work/CLAUDE.md +10 -3
- package/dist/chunk-HP3HBG7F.js +0 -626
- package/dist/chunk-HP3HBG7F.js.map +0 -1
- package/dist/chunk-QRFH4J6H.js +0 -1194
- package/dist/chunk-QRFH4J6H.js.map +0 -1
- package/dist/chunk-WM3OXYTW.js +0 -2630
- package/dist/chunk-WM3OXYTW.js.map +0 -1
- package/dist/skills-command-3ESCZ75U.js.map +0 -1
- package/dist/uninstall-GQE4SJF2.js +0 -150
- package/dist/uninstall-GQE4SJF2.js.map +0 -1
- package/template/.make-docs/scripts/check_path_hygiene.py +0 -435
- package/template/docs/assets/archive/AGENTS.md +0 -20
- package/template/docs/assets/archive/CLAUDE.md +0 -20
- package/template/docs/assets/history/AGENTS.md +0 -12
- package/template/docs/assets/history/CLAUDE.md +0 -12
- package/template/docs/assets/prompts/AGENTS.md +0 -8
- package/template/docs/assets/prompts/CLAUDE.md +0 -8
- package/template/docs/assets/prompts/designs-to-plan-change.prompt.md +0 -14
- package/template/docs/assets/prompts/designs-to-plan.prompt.md +0 -10
- package/template/docs/assets/prompts/docs-path-hygiene-cleanup.prompt.md +0 -27
- package/template/docs/assets/prompts/plan-to-prd-change.prompt.md +0 -8
- package/template/docs/assets/prompts/plan-to-prd-green-field.prompt.md +0 -6
- package/template/docs/assets/prompts/prd-change-to-work.prompt.md +0 -10
- package/template/docs/assets/prompts/prd-to-work-full-prd.prompt.md +0 -6
- package/template/docs/assets/prompts/prd-to-work-prd-feature.prompt.md +0 -6
- package/template/docs/assets/prompts/request-to-design.prompt.md +0 -16
- package/template/docs/assets/prompts/session-to-history-record.prompt.md +0 -19
- package/template/docs/assets/prompts/work-to-guides.prompt.md +0 -18
- package/template/docs/assets/references/AGENTS.md +0 -9
- package/template/docs/assets/references/CLAUDE.md +0 -9
- package/template/docs/assets/references/execution-workflow.md +0 -157
- package/template/docs/assets/references/output-contract.md +0 -221
- package/template/docs/assets/references/path-and-link-hygiene.md +0 -49
- package/template/docs/assets/references/planning-workflow.md +0 -160
- package/template/docs/assets/references/prd-change-management.md +0 -129
- package/template/docs/assets/templates/AGENTS.md +0 -8
- package/template/docs/assets/templates/CLAUDE.md +0 -8
- package/template/docs/assets/templates/design.md +0 -30
- package/template/docs/assets/templates/plan-overview.md +0 -32
- package/template/docs/assets/templates/plan-prd-change.md +0 -99
- package/template/docs/assets/templates/prd-change-addition.md +0 -45
- package/template/docs/assets/templates/prd-change-revision.md +0 -45
- package/template/docs/assets/templates/prd-glossary.md +0 -15
- package/template/docs/assets/templates/prd-index.md +0 -45
- package/template/docs/assets/templates/prd-reference.md +0 -17
- package/template/docs/assets/templates/work-index.md +0 -21
- package/template/docs/assets/templates/work-phase.md +0 -34
- package/template/docs/guides/AGENTS.md +0 -15
- package/template/docs/guides/CLAUDE.md +0 -15
- /package/template/{docs/assets → .make-docs/system}/prompts/update-readme-green-field.prompt.md +0 -0
- /package/template/{docs/assets → .make-docs/system}/references/harness-capability-matrix.md +0 -0
|
@@ -0,0 +1,875 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
createAuditReport
|
|
4
|
+
} from "./chunk-G5EF63GG.js";
|
|
5
|
+
import {
|
|
6
|
+
MANIFEST_RELATIVE_PATH,
|
|
7
|
+
acquireInstallationLock,
|
|
8
|
+
assertInstallationLockActive,
|
|
9
|
+
assertManagedPathHasNoSymlinks,
|
|
10
|
+
getManifestFileHash,
|
|
11
|
+
getManifestFileHashForSourceSchema,
|
|
12
|
+
getManifestPath,
|
|
13
|
+
importInstallationState,
|
|
14
|
+
listMigrationState,
|
|
15
|
+
parseManagedBlock,
|
|
16
|
+
platform,
|
|
17
|
+
readInstallationManifest,
|
|
18
|
+
readMigrationState,
|
|
19
|
+
readPackageFile,
|
|
20
|
+
relativePathToTarget,
|
|
21
|
+
releaseInstallationLock,
|
|
22
|
+
validateAndMigrateManifest
|
|
23
|
+
} from "./chunk-MXBHCHSM.js";
|
|
24
|
+
|
|
25
|
+
// src/store/legacy-installation.ts
|
|
26
|
+
import { createHash } from "crypto";
|
|
27
|
+
import { existsSync, lstatSync, readFileSync, readdirSync, rmdirSync, unlinkSync } from "fs";
|
|
28
|
+
import path from "path";
|
|
29
|
+
var STATE = ".make-docs/state";
|
|
30
|
+
var digest = (value) => createHash("sha256").update(value).digest("hex");
|
|
31
|
+
function stable(value) {
|
|
32
|
+
const sort = (v) => Array.isArray(v) ? v.map(sort) : v && typeof v === "object" ? Object.fromEntries(Object.entries(v).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([k, x]) => [k, sort(x)])) : v;
|
|
33
|
+
return JSON.stringify(sort(value));
|
|
34
|
+
}
|
|
35
|
+
function object(value) {
|
|
36
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error("Expected an object");
|
|
37
|
+
return value;
|
|
38
|
+
}
|
|
39
|
+
function exactKeys(value, allowed) {
|
|
40
|
+
if (Object.keys(value).some((key) => !allowed.includes(key))) throw new Error("Unsupported fields in legacy metadata");
|
|
41
|
+
}
|
|
42
|
+
function safeRelative(value) {
|
|
43
|
+
if (typeof value !== "string" || !value || value.includes("\\") || value.includes("\0") || path.posix.isAbsolute(value) || /^[a-z]:/i.test(value) || path.posix.normalize(value) !== value || value.split("/").some((x) => x === "." || x === ".." || !x)) throw new Error("Unsafe source path");
|
|
44
|
+
return value;
|
|
45
|
+
}
|
|
46
|
+
function safeFile(root, relativePath) {
|
|
47
|
+
safeRelative(relativePath);
|
|
48
|
+
assertManagedPathHasNoSymlinks(root, relativePath);
|
|
49
|
+
const absolute = path.join(root, relativePath);
|
|
50
|
+
if (!lstatSync(absolute).isFile()) throw new Error(`Not a regular file: ${relativePath}`);
|
|
51
|
+
return readFileSync(absolute);
|
|
52
|
+
}
|
|
53
|
+
function previewLegacyInstallationState(projectRoot) {
|
|
54
|
+
const result = {
|
|
55
|
+
manifest: null,
|
|
56
|
+
sources: [],
|
|
57
|
+
records: [],
|
|
58
|
+
preservedFiles: [],
|
|
59
|
+
blockers: [],
|
|
60
|
+
recoveryRequired: false,
|
|
61
|
+
minimumWriter: "Store installation contract 1 (W19 R3) or newer; obsolete CLI writers are unsupported after transfer."
|
|
62
|
+
};
|
|
63
|
+
if (!existsSync(projectRoot)) return result;
|
|
64
|
+
const root = platform.describePath(projectRoot).canonicalPath;
|
|
65
|
+
const read = (relativePath) => {
|
|
66
|
+
const bytes = safeFile(root, relativePath);
|
|
67
|
+
const value = object(JSON.parse(bytes.toString("utf8")));
|
|
68
|
+
result.sources.push({ relativePath, digest: digest(bytes) });
|
|
69
|
+
return value;
|
|
70
|
+
};
|
|
71
|
+
if (existsSync(path.join(root, MANIFEST_RELATIVE_PATH))) {
|
|
72
|
+
try {
|
|
73
|
+
result.manifest = validateAndMigrateManifest(read(MANIFEST_RELATIVE_PATH), path.join(root, MANIFEST_RELATIVE_PATH));
|
|
74
|
+
} catch (error) {
|
|
75
|
+
result.blockers.push(`Legacy manifest: ${String(error)}`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
const receipts = [];
|
|
79
|
+
const preserveFinderMetadata = (relativePath) => {
|
|
80
|
+
assertManagedPathHasNoSymlinks(root, relativePath);
|
|
81
|
+
if (!lstatSync(path.join(root, relativePath)).isFile()) throw new Error(`Not a regular Finder metadata file: ${relativePath}`);
|
|
82
|
+
result.preservedFiles.push(relativePath);
|
|
83
|
+
};
|
|
84
|
+
let barrier;
|
|
85
|
+
if (existsSync(path.join(root, STATE))) {
|
|
86
|
+
try {
|
|
87
|
+
assertManagedPathHasNoSymlinks(root, STATE);
|
|
88
|
+
for (const name of readdirSync(path.join(root, STATE)).sort()) {
|
|
89
|
+
const relative = `${STATE}/${name}`;
|
|
90
|
+
if (name === ".DS_Store") {
|
|
91
|
+
preserveFinderMetadata(relative);
|
|
92
|
+
} else if (name === "migration.lock.json" || name === "legacy-writers") {
|
|
93
|
+
if (name !== "legacy-writers" || !lstatSync(path.join(root, relative)).isDirectory() || readdirSync(path.join(root, relative)).length) {
|
|
94
|
+
result.blockers.push(`An obsolete writer needs review: ${relative}`);
|
|
95
|
+
}
|
|
96
|
+
} else if (name === "legacy-quiescence.json") {
|
|
97
|
+
barrier = read(relative);
|
|
98
|
+
exactKeys(barrier, ["schemaVersion", "status", "lockTokenDigest", "snapshotId", "activatedAt", "legacyOperations"]);
|
|
99
|
+
if (barrier.schemaVersion !== 1 || barrier.status !== "active" || typeof barrier.snapshotId !== "string" || !/^sha256:[a-f0-9]{64}$/.test(barrier.snapshotId) || !/^[a-f0-9]{64}$/.test(barrier.lockTokenDigest) || !Array.isArray(barrier.legacyOperations) || !barrier.legacyOperations.every((x) => typeof x === "string")) throw new Error("Invalid legacy quiescence record");
|
|
100
|
+
} else if (name === "migration-receipts") {
|
|
101
|
+
assertManagedPathHasNoSymlinks(root, relative);
|
|
102
|
+
for (const file of readdirSync(path.join(root, relative)).sort()) {
|
|
103
|
+
if (file === ".DS_Store") {
|
|
104
|
+
preserveFinderMetadata(`${relative}/${file}`);
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
if (!/^[a-f0-9]{64}\.json$/.test(file)) throw new Error(`Unknown receipt file: ${file}`);
|
|
108
|
+
const receipt = read(`${relative}/${file}`);
|
|
109
|
+
exactKeys(receipt, ["schemaVersion", "receiptId", "status", "checkpoint", "snapshotId", "lockTokenDigest", "createdAt", "code", "message", "rollback", "claims"]);
|
|
110
|
+
exactKeys(object(receipt.rollback), ["attempted", "completed", "restoredPaths", "unrestoredPaths"]);
|
|
111
|
+
exactKeys(object(receipt.claims), ["validated", "accepted", "downstreamAuthorized", "released"]);
|
|
112
|
+
const { schemaVersion, receiptId, claims, ...subject } = receipt;
|
|
113
|
+
if (schemaVersion !== 1 || receiptId !== `sha256:${file.slice(0, -5)}` || receiptId !== `sha256:${digest(stable(subject))}` || !/^sha256:[a-f0-9]{64}$/.test(receipt.snapshotId) || !/^[a-f0-9]{64}$/.test(receipt.lockTokenDigest) || !Number.isInteger(receipt.checkpoint) || receipt.checkpoint < 0 || receipt.checkpoint > 13 || !["completed", "paused", "blocked", "failed", "rollback-required"].includes(receipt.status) || !claims || Object.keys(claims).length !== 4 || Object.values(claims).some((x) => x !== false)) throw new Error(`Invalid receipt: ${file}`);
|
|
114
|
+
receipts.push(receipt);
|
|
115
|
+
}
|
|
116
|
+
} else result.blockers.push(`Unknown legacy state remains: ${relative}`);
|
|
117
|
+
}
|
|
118
|
+
} catch (error) {
|
|
119
|
+
result.blockers.push(String(error));
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
const snapshots = new Set(receipts.map((x) => x.snapshotId));
|
|
123
|
+
const backed = /* @__PURE__ */ new Set();
|
|
124
|
+
const backupRoot = path.join(root, ".make-docs/backup");
|
|
125
|
+
if (snapshots.size && existsSync(backupRoot)) {
|
|
126
|
+
try {
|
|
127
|
+
assertManagedPathHasNoSymlinks(root, ".make-docs/backup");
|
|
128
|
+
for (const name of readdirSync(backupRoot).sort()) {
|
|
129
|
+
const relative = `.make-docs/backup/${name}/backup-manifest.json`;
|
|
130
|
+
if (!existsSync(path.join(root, relative))) continue;
|
|
131
|
+
const bytes = safeFile(root, relative);
|
|
132
|
+
const backup = object(JSON.parse(bytes.toString("utf8")));
|
|
133
|
+
if (!snapshots.has(backup.snapshotId)) continue;
|
|
134
|
+
exactKeys(backup, ["schemaVersion", "backupId", "snapshotId", "projectRoot", "repository", "classification", "createdAt", "entries"]);
|
|
135
|
+
exactKeys(object(backup.repository), ["projectRootDigest", "projectId", "manifestSchemaVersion", "manifestDigest"]);
|
|
136
|
+
if (backup.schemaVersion !== 1 || backup.backupId !== name || backup.projectRoot !== root || !Array.isArray(backup.entries) || !backup.repository || backup.repository.projectRootDigest !== digest(root) || result.manifest?.projectId && backup.repository.projectId && backup.repository.projectId !== result.manifest.projectId) throw new Error(`Invalid linked backup: ${relative}`);
|
|
137
|
+
const seen = /* @__PURE__ */ new Set();
|
|
138
|
+
for (const raw of backup.entries) {
|
|
139
|
+
const entry = object(raw);
|
|
140
|
+
exactKeys(entry, ["relativePath", "backupPath", "original", "copied", "verified", "restoreOrder"]);
|
|
141
|
+
exactKeys(object(entry.original), ["relativePath", "ownership", "disposition", "reason", "entryType", "digest", "mode", "size", "linkTarget"]);
|
|
142
|
+
const rel = safeRelative(entry.relativePath);
|
|
143
|
+
if (seen.has(rel) || entry.original?.relativePath !== rel || typeof entry.verified !== "boolean" || !entry.verified) throw new Error(`Invalid backup entry: ${rel}`);
|
|
144
|
+
seen.add(rel);
|
|
145
|
+
if (entry.copied) {
|
|
146
|
+
if (entry.backupPath !== `files/${rel}` || !/^[a-f0-9]{64}$/.test(entry.original.digest)) throw new Error(`Invalid backup digest: ${rel}`);
|
|
147
|
+
if (digest(safeFile(root, `.make-docs/backup/${name}/${entry.backupPath}`)) !== entry.original.digest) throw new Error(`Backup content changed: ${rel}`);
|
|
148
|
+
} else if (entry.backupPath !== null) throw new Error(`Invalid backup reference: ${rel}`);
|
|
149
|
+
}
|
|
150
|
+
result.sources.push({ relativePath: relative, digest: digest(bytes) });
|
|
151
|
+
result.records.push({ kind: "backup", id: name, value: backup });
|
|
152
|
+
backed.add(backup.snapshotId);
|
|
153
|
+
}
|
|
154
|
+
} catch (error) {
|
|
155
|
+
result.blockers.push(String(error));
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
for (const receipt of receipts) {
|
|
159
|
+
if (!backed.has(receipt.snapshotId)) result.blockers.push(`Receipt has no verified backup link: ${receipt.receiptId}`);
|
|
160
|
+
result.records.push({ kind: "receipt", id: receipt.receiptId, value: receipt });
|
|
161
|
+
}
|
|
162
|
+
if (barrier) {
|
|
163
|
+
if (!receipts.some((r) => r.snapshotId === barrier.snapshotId && r.lockTokenDigest === barrier.lockTokenDigest)) result.blockers.push("Quiescence has no matching receipt");
|
|
164
|
+
result.records.push({ kind: "quiescence", id: "legacy", value: barrier });
|
|
165
|
+
}
|
|
166
|
+
for (const snapshot of snapshots) {
|
|
167
|
+
const group = receipts.filter((r) => r.snapshotId === snapshot);
|
|
168
|
+
if (!group.some((r) => r.checkpoint === 11 && r.status === "completed") || group.some((r) => r.status !== "completed")) result.recoveryRequired = true;
|
|
169
|
+
}
|
|
170
|
+
return result;
|
|
171
|
+
}
|
|
172
|
+
function importLegacyInstallationState(projectRoot, storeRoot) {
|
|
173
|
+
const previous = listMigrationState(projectRoot, "legacy-import", storeRoot);
|
|
174
|
+
const unfinished = previous.filter((p) => p.sources.some((source) => existsSync(path.join(projectRoot, source.relativePath))));
|
|
175
|
+
if (unfinished.length) {
|
|
176
|
+
const lease2 = acquireInstallationLock(projectRoot, storeRoot);
|
|
177
|
+
try {
|
|
178
|
+
for (const receipt of unfinished) cleanupSources(projectRoot, receipt.sources, lease2);
|
|
179
|
+
} finally {
|
|
180
|
+
releaseInstallationLock(lease2);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
const preview = previewLegacyInstallationState(projectRoot);
|
|
184
|
+
if (preview.blockers.length) throw new Error(`Legacy installation transfer blocked: ${preview.blockers.join("; ")}`);
|
|
185
|
+
if (!preview.sources.length) return preview;
|
|
186
|
+
const importId = `sha256:${digest(stable(preview.sources))}`;
|
|
187
|
+
const lease = acquireInstallationLock(projectRoot, storeRoot);
|
|
188
|
+
try {
|
|
189
|
+
importInstallationState(projectRoot, {
|
|
190
|
+
manifest: preview.manifest,
|
|
191
|
+
records: preview.records,
|
|
192
|
+
importId,
|
|
193
|
+
sources: preview.sources,
|
|
194
|
+
recoveryRequired: preview.recoveryRequired
|
|
195
|
+
}, storeRoot);
|
|
196
|
+
const receipt = readMigrationState(projectRoot, "legacy-import", importId, storeRoot);
|
|
197
|
+
if (!receipt || stable(receipt.sources) !== stable(preview.sources)) throw new Error("Legacy import read-back failed; all local inputs remain");
|
|
198
|
+
for (const record of preview.records) {
|
|
199
|
+
const imported = readMigrationState(projectRoot, record.kind, record.id, storeRoot);
|
|
200
|
+
if (!imported || stable(imported) !== stable(record.value)) throw new Error(`Legacy record read-back differs: ${record.kind}/${record.id}; local inputs remain`);
|
|
201
|
+
}
|
|
202
|
+
cleanupSources(projectRoot, preview.sources, lease);
|
|
203
|
+
} finally {
|
|
204
|
+
releaseInstallationLock(lease);
|
|
205
|
+
}
|
|
206
|
+
return preview;
|
|
207
|
+
}
|
|
208
|
+
function cleanupSources(projectRoot, sources, lease) {
|
|
209
|
+
assertInstallationLockActive(lease);
|
|
210
|
+
const allowed = new Set(sources.map((s) => s.relativePath));
|
|
211
|
+
const state = path.join(projectRoot, STATE);
|
|
212
|
+
if (existsSync(state)) {
|
|
213
|
+
assertManagedPathHasNoSymlinks(projectRoot, STATE);
|
|
214
|
+
for (const name of readdirSync(state)) {
|
|
215
|
+
const rel = `${STATE}/${name}`;
|
|
216
|
+
if (name === ".DS_Store") {
|
|
217
|
+
assertManagedPathHasNoSymlinks(projectRoot, rel);
|
|
218
|
+
if (!lstatSync(path.join(projectRoot, rel)).isFile()) throw new Error(`Not a regular Finder metadata file: ${rel}`);
|
|
219
|
+
} else if (name === "migration-receipts" || name === "legacy-writers") {
|
|
220
|
+
assertManagedPathHasNoSymlinks(projectRoot, rel);
|
|
221
|
+
for (const child of readdirSync(path.join(projectRoot, rel))) {
|
|
222
|
+
const childRelative = `${rel}/${child}`;
|
|
223
|
+
if (name === "migration-receipts" && child === ".DS_Store") {
|
|
224
|
+
assertManagedPathHasNoSymlinks(projectRoot, childRelative);
|
|
225
|
+
if (!lstatSync(path.join(projectRoot, childRelative)).isFile()) throw new Error(`Not a regular Finder metadata file: ${childRelative}`);
|
|
226
|
+
} else if (!allowed.has(childRelative)) throw new Error(`Unknown or active legacy state remains: ${childRelative}`);
|
|
227
|
+
}
|
|
228
|
+
} else if (!allowed.has(rel)) throw new Error(`Unknown or active legacy state remains: ${rel}`);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
const remaining = sources.filter((source) => existsSync(path.join(projectRoot, source.relativePath)));
|
|
232
|
+
for (const source of remaining) if (digest(safeFile(projectRoot, source.relativePath)) !== source.digest) throw new Error(`Legacy source changed: ${source.relativePath}`);
|
|
233
|
+
for (const source of remaining) {
|
|
234
|
+
if (digest(safeFile(projectRoot, source.relativePath)) !== source.digest) throw new Error(`Legacy source changed: ${source.relativePath}`);
|
|
235
|
+
assertInstallationLockActive(lease);
|
|
236
|
+
unlinkSync(path.join(projectRoot, source.relativePath));
|
|
237
|
+
}
|
|
238
|
+
for (const rel of [`${STATE}/migration-receipts`, `${STATE}/legacy-writers`, STATE]) {
|
|
239
|
+
const absolute = path.join(projectRoot, rel);
|
|
240
|
+
if (existsSync(absolute)) {
|
|
241
|
+
assertInstallationLockActive(lease);
|
|
242
|
+
assertManagedPathHasNoSymlinks(projectRoot, rel);
|
|
243
|
+
if (lstatSync(absolute).isDirectory() && readdirSync(absolute).length === 0) rmdirSync(absolute);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// src/compatibility.ts
|
|
249
|
+
import { existsSync as existsSync2, readFileSync as readFileSync2, statSync } from "fs";
|
|
250
|
+
import os from "os";
|
|
251
|
+
import path2 from "path";
|
|
252
|
+
var STATE_DISPOSITIONS = {
|
|
253
|
+
"clean-v1": "migrate",
|
|
254
|
+
"clean-v2-full-snapshot": "sync",
|
|
255
|
+
"clean-v2-provider-backed": "sync",
|
|
256
|
+
"clean-v2-hybrid-pinned-cache": "sync",
|
|
257
|
+
"modified-v1": "migrate-with-review",
|
|
258
|
+
"partial-install": "migrate-with-review",
|
|
259
|
+
"malformed-manifest": "backup-and-reinstall",
|
|
260
|
+
"missing-manifest-recognizable": "migrate-with-review",
|
|
261
|
+
"unknown-shape": "manual-review-required"
|
|
262
|
+
};
|
|
263
|
+
var LEGACY_RECOGNITION_FINGERPRINT_PATHS = [
|
|
264
|
+
"AGENTS.md",
|
|
265
|
+
"CLAUDE.md",
|
|
266
|
+
"docs/AGENTS.md",
|
|
267
|
+
"docs/CLAUDE.md",
|
|
268
|
+
"docs/assets/AGENTS.md",
|
|
269
|
+
"docs/assets/artifacts/AGENTS.md",
|
|
270
|
+
"docs/assets/archive/AGENTS.md",
|
|
271
|
+
"docs/assets/library/AGENTS.md",
|
|
272
|
+
".make-docs/system/references/lifecycle.md",
|
|
273
|
+
".make-docs/system/contracts/guide-contract.md",
|
|
274
|
+
".make-docs/system/templates/history-record.md"
|
|
275
|
+
];
|
|
276
|
+
var OPTIONAL_LOCAL_BOOTSTRAP_PATHS = /* @__PURE__ */ new Set([
|
|
277
|
+
".make-docs/config.yaml",
|
|
278
|
+
".make-docs/contracts/custom",
|
|
279
|
+
".make-docs/references/custom",
|
|
280
|
+
".make-docs/scripts/custom",
|
|
281
|
+
".make-docs/templates/custom"
|
|
282
|
+
]);
|
|
283
|
+
async function classifyCompatibilityState(options) {
|
|
284
|
+
const targetDir = path2.resolve(options.targetDir);
|
|
285
|
+
const homeDir = path2.resolve(options.homeDir ?? os.homedir());
|
|
286
|
+
const manifestPath = getManifestPath(targetDir);
|
|
287
|
+
const rawManifest = readRawManifest(targetDir);
|
|
288
|
+
if (!rawManifest.present) {
|
|
289
|
+
return classifyManifestMissing({ targetDir, homeDir, manifestPath });
|
|
290
|
+
}
|
|
291
|
+
if (!rawManifest.parseable || rawManifest.manifest === null) {
|
|
292
|
+
return classifyMalformedManifest({
|
|
293
|
+
targetDir,
|
|
294
|
+
homeDir,
|
|
295
|
+
manifestPath,
|
|
296
|
+
rawManifest
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
return classifyManifestPresent({
|
|
300
|
+
targetDir,
|
|
301
|
+
homeDir,
|
|
302
|
+
manifestPath,
|
|
303
|
+
rawManifest,
|
|
304
|
+
manifest: rawManifest.manifest
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
function scopeCompatibilityToInstallPlan(options) {
|
|
308
|
+
const { classification, plan, completedRemovalHandoff } = options;
|
|
309
|
+
if (!completedRemovalHandoff) {
|
|
310
|
+
return classification;
|
|
311
|
+
}
|
|
312
|
+
const plannedActions = new Map(
|
|
313
|
+
plan.actions.map((action) => [action.relativePath, action])
|
|
314
|
+
);
|
|
315
|
+
const isUnresolvedPlannedPath = (relativePath) => {
|
|
316
|
+
const action = plannedActions.get(relativePath);
|
|
317
|
+
return Boolean(
|
|
318
|
+
action && (action.type === "skip-conflict" || plan.stops?.includes(relativePath))
|
|
319
|
+
);
|
|
320
|
+
};
|
|
321
|
+
const filesystemTrust = classification.evidence.filesystemTrust;
|
|
322
|
+
const ambiguousFallbackPaths = filesystemTrust.ambiguousFallbackPaths.filter(
|
|
323
|
+
(relativePath) => isUnresolvedPlannedPath(relativePath)
|
|
324
|
+
);
|
|
325
|
+
const nonMakeDocsPathCollisions = filesystemTrust.nonMakeDocsPathCollisions.filter(
|
|
326
|
+
(relativePath) => isUnresolvedPlannedPath(relativePath)
|
|
327
|
+
);
|
|
328
|
+
const reasons = filesystemTrust.reasons.filter(
|
|
329
|
+
(reason) => !reason.startsWith("Ambiguous fallback paths:") && !reason.startsWith("Non-make-docs path collisions:") && !reason.startsWith("Completed reviewed removal:")
|
|
330
|
+
);
|
|
331
|
+
if (ambiguousFallbackPaths.length > 0) {
|
|
332
|
+
reasons.push(`Ambiguous planned fallback paths: ${ambiguousFallbackPaths.join(", ")}.`);
|
|
333
|
+
}
|
|
334
|
+
if (nonMakeDocsPathCollisions.length > 0) {
|
|
335
|
+
reasons.push(`Non-make-docs planned path collisions: ${nonMakeDocsPathCollisions.join(", ")}.`);
|
|
336
|
+
}
|
|
337
|
+
if (completedRemovalHandoff) {
|
|
338
|
+
reasons.push(
|
|
339
|
+
"Completed reviewed removal: the same verified checkout and backup provide the plain-setup reinstall handoff."
|
|
340
|
+
);
|
|
341
|
+
}
|
|
342
|
+
const disposition = (classification.state === "missing-manifest-recognizable" || classification.state === "unknown-shape") && ambiguousFallbackPaths.length === 0 && nonMakeDocsPathCollisions.length === 0 ? "migrate-with-review" : classification.disposition;
|
|
343
|
+
const evidence = {
|
|
344
|
+
...classification.evidence,
|
|
345
|
+
filesystemTrust: {
|
|
346
|
+
...filesystemTrust,
|
|
347
|
+
managedBlocksValid: classification.state === "missing-manifest-recognizable" || classification.state === "unknown-shape" ? ambiguousFallbackPaths.length === 0 : filesystemTrust.managedBlocksValid,
|
|
348
|
+
ambiguousFallbackPaths,
|
|
349
|
+
nonMakeDocsPathCollisions,
|
|
350
|
+
reasons
|
|
351
|
+
}
|
|
352
|
+
};
|
|
353
|
+
return {
|
|
354
|
+
...classification,
|
|
355
|
+
disposition,
|
|
356
|
+
evidence,
|
|
357
|
+
printableEvidence: [
|
|
358
|
+
`state=${classification.state}`,
|
|
359
|
+
`disposition=${disposition}`,
|
|
360
|
+
...formatAuditSkillSelectionEvidence(classification.auditReport),
|
|
361
|
+
...evidence.manifestTrust.reasons.map((reason) => `manifest: ${reason}`),
|
|
362
|
+
...evidence.filesystemTrust.reasons.map((reason) => `filesystem: ${reason}`),
|
|
363
|
+
...evidence.bootstrapTrust.reasons.map((reason) => `bootstrap: ${reason}`),
|
|
364
|
+
...evidence.skillTrust.reasons.map((reason) => `skills: ${reason}`),
|
|
365
|
+
...evidence.providerCacheTrust.reasons.map((reason) => `provider-cache: ${reason}`)
|
|
366
|
+
]
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
function formatCompatibilityClassification(classification) {
|
|
370
|
+
return classification.printableEvidence;
|
|
371
|
+
}
|
|
372
|
+
function classifyManifestPresent(options) {
|
|
373
|
+
return classifyManifestPresentAsync(options);
|
|
374
|
+
}
|
|
375
|
+
async function classifyManifestPresentAsync(options) {
|
|
376
|
+
const { targetDir, homeDir, manifestPath, rawManifest, manifest } = options;
|
|
377
|
+
const auditReport = await createAuditReport({
|
|
378
|
+
targetDir,
|
|
379
|
+
homeDir,
|
|
380
|
+
manifest
|
|
381
|
+
});
|
|
382
|
+
const filesystemTrust = evaluateFilesystemTrust(targetDir, manifest);
|
|
383
|
+
const bootstrapTrust = evaluateBootstrapTrust(targetDir, manifest);
|
|
384
|
+
const skillTrust = evaluateSkillTrust(targetDir, manifest, filesystemTrust);
|
|
385
|
+
const providerCacheTrust = evaluateProviderCacheTrust(manifest);
|
|
386
|
+
const manifestTrust = {
|
|
387
|
+
present: true,
|
|
388
|
+
parseable: true,
|
|
389
|
+
schemaVersion: rawManifest.schemaVersion,
|
|
390
|
+
packageIdentityTrusted: Boolean(manifest.packageName && manifest.packageVersion),
|
|
391
|
+
selectionsTrusted: manifest.selections !== null,
|
|
392
|
+
managedFileRecordsTrusted: Object.keys(manifest.files).length > 0,
|
|
393
|
+
skillRecordsTrusted: Array.isArray(manifest.skillFiles),
|
|
394
|
+
materializationProvenanceTrusted: providerCacheTrust.trusted,
|
|
395
|
+
reasons: []
|
|
396
|
+
};
|
|
397
|
+
pushReason(
|
|
398
|
+
manifestTrust.reasons,
|
|
399
|
+
manifestTrust.packageIdentityTrusted,
|
|
400
|
+
"Manifest package identity is present.",
|
|
401
|
+
"Manifest package identity is missing."
|
|
402
|
+
);
|
|
403
|
+
pushReason(
|
|
404
|
+
manifestTrust.reasons,
|
|
405
|
+
manifestTrust.managedFileRecordsTrusted,
|
|
406
|
+
"Manifest includes managed-file records.",
|
|
407
|
+
"Manifest has no managed-file records."
|
|
408
|
+
);
|
|
409
|
+
pushReason(
|
|
410
|
+
manifestTrust.reasons,
|
|
411
|
+
manifestTrust.materializationProvenanceTrusted,
|
|
412
|
+
"System asset provenance is trusted.",
|
|
413
|
+
"System asset provenance is incomplete or unavailable."
|
|
414
|
+
);
|
|
415
|
+
const trustedFilesystem = filesystemTrust.managedFilesMatch && filesystemTrust.managedBlocksValid && bootstrapTrust.requiredLocalBootstrapPresent && skillTrust.selectedSkillsTrusted;
|
|
416
|
+
const schemaVersion = rawManifest.schemaVersion;
|
|
417
|
+
const mode = manifest.systemAssetMaterialization?.mode ?? "full-snapshot";
|
|
418
|
+
let state;
|
|
419
|
+
if (!trustedFilesystem) {
|
|
420
|
+
state = schemaVersion === 1 ? "modified-v1" : "partial-install";
|
|
421
|
+
} else if (!providerCacheTrust.trusted) {
|
|
422
|
+
state = "partial-install";
|
|
423
|
+
} else if (schemaVersion === 1) {
|
|
424
|
+
state = "clean-v1";
|
|
425
|
+
} else if (mode === "provider-backed") {
|
|
426
|
+
state = "clean-v2-provider-backed";
|
|
427
|
+
} else if (mode === "hybrid-pinned-cache") {
|
|
428
|
+
state = "clean-v2-hybrid-pinned-cache";
|
|
429
|
+
} else {
|
|
430
|
+
state = "clean-v2-full-snapshot";
|
|
431
|
+
}
|
|
432
|
+
return createClassification({
|
|
433
|
+
state,
|
|
434
|
+
disposition: STATE_DISPOSITIONS[state],
|
|
435
|
+
targetDir,
|
|
436
|
+
manifestPath,
|
|
437
|
+
auditReport,
|
|
438
|
+
evidence: {
|
|
439
|
+
manifestTrust,
|
|
440
|
+
filesystemTrust,
|
|
441
|
+
bootstrapTrust,
|
|
442
|
+
skillTrust,
|
|
443
|
+
providerCacheTrust
|
|
444
|
+
}
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
async function classifyManifestMissing(options) {
|
|
448
|
+
const { targetDir, homeDir, manifestPath } = options;
|
|
449
|
+
const auditReport = await createAuditReport({
|
|
450
|
+
targetDir,
|
|
451
|
+
homeDir,
|
|
452
|
+
manifest: null
|
|
453
|
+
});
|
|
454
|
+
const fallback = evaluateFallbackRecognition(targetDir);
|
|
455
|
+
const state = fallback.recognizableManagedPaths.length > 0 ? "missing-manifest-recognizable" : "unknown-shape";
|
|
456
|
+
const disposition = state === "missing-manifest-recognizable" && fallback.ambiguousFallbackPaths.length > 0 ? "backup-and-reinstall" : STATE_DISPOSITIONS[state];
|
|
457
|
+
return createClassification({
|
|
458
|
+
state,
|
|
459
|
+
disposition,
|
|
460
|
+
targetDir,
|
|
461
|
+
manifestPath,
|
|
462
|
+
auditReport,
|
|
463
|
+
evidence: createFallbackEvidence({
|
|
464
|
+
present: false,
|
|
465
|
+
parseable: false,
|
|
466
|
+
schemaVersion: null,
|
|
467
|
+
fallback,
|
|
468
|
+
manifestReason: "Manifest is missing."
|
|
469
|
+
})
|
|
470
|
+
});
|
|
471
|
+
}
|
|
472
|
+
async function classifyMalformedManifest(options) {
|
|
473
|
+
const { targetDir, homeDir, manifestPath, rawManifest } = options;
|
|
474
|
+
const auditReport = await createAuditReport({
|
|
475
|
+
targetDir,
|
|
476
|
+
homeDir,
|
|
477
|
+
manifest: null
|
|
478
|
+
});
|
|
479
|
+
const fallback = evaluateFallbackRecognition(targetDir);
|
|
480
|
+
const disposition = fallback.recognizableManagedPaths.length > 0 ? "backup-and-reinstall" : "manual-review-required";
|
|
481
|
+
return createClassification({
|
|
482
|
+
state: "malformed-manifest",
|
|
483
|
+
disposition,
|
|
484
|
+
targetDir,
|
|
485
|
+
manifestPath,
|
|
486
|
+
auditReport,
|
|
487
|
+
evidence: createFallbackEvidence({
|
|
488
|
+
present: true,
|
|
489
|
+
parseable: false,
|
|
490
|
+
schemaVersion: rawManifest.schemaVersion,
|
|
491
|
+
fallback,
|
|
492
|
+
manifestReason: rawManifest.errorMessage ?? "Manifest exists but could not be trusted."
|
|
493
|
+
})
|
|
494
|
+
});
|
|
495
|
+
}
|
|
496
|
+
function evaluateFilesystemTrust(targetDir, manifest) {
|
|
497
|
+
const modifiedPaths = [];
|
|
498
|
+
const missingPaths = [];
|
|
499
|
+
const malformedManagedBlockPaths = [];
|
|
500
|
+
for (const [relativePath, entry] of Object.entries(manifest.files)) {
|
|
501
|
+
const absolutePath = relativePathToTarget(targetDir, relativePath);
|
|
502
|
+
if (!existsSync2(absolutePath)) {
|
|
503
|
+
missingPaths.push(relativePath);
|
|
504
|
+
continue;
|
|
505
|
+
}
|
|
506
|
+
if (entry.skillExposure) {
|
|
507
|
+
continue;
|
|
508
|
+
}
|
|
509
|
+
const content = readFileSync2(absolutePath, "utf8");
|
|
510
|
+
const currentHash = getManifestFileHashForSourceSchema(
|
|
511
|
+
relativePath,
|
|
512
|
+
content,
|
|
513
|
+
manifest.schemaVersion
|
|
514
|
+
);
|
|
515
|
+
if (currentHash === null) {
|
|
516
|
+
malformedManagedBlockPaths.push(relativePath);
|
|
517
|
+
continue;
|
|
518
|
+
}
|
|
519
|
+
if ((entry.sourceId.startsWith("router:") || entry.sourceId.startsWith("resource:")) && !hasTrustedLocalOwnershipProof(relativePath, entry, manifest)) {
|
|
520
|
+
modifiedPaths.push(relativePath);
|
|
521
|
+
continue;
|
|
522
|
+
}
|
|
523
|
+
if (!manifestEntryMatches(entry, currentHash) && !isTrustedCurrentPackageRefresh(relativePath, entry, currentHash, manifest)) {
|
|
524
|
+
modifiedPaths.push(relativePath);
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
const reasons = [];
|
|
528
|
+
pushReason(
|
|
529
|
+
reasons,
|
|
530
|
+
missingPaths.length === 0,
|
|
531
|
+
"All manifest-managed files are present.",
|
|
532
|
+
`Missing managed files: ${missingPaths.join(", ")}.`
|
|
533
|
+
);
|
|
534
|
+
pushReason(
|
|
535
|
+
reasons,
|
|
536
|
+
modifiedPaths.length === 0,
|
|
537
|
+
"Manifest-managed file hashes match.",
|
|
538
|
+
`Modified managed files: ${modifiedPaths.join(", ")}.`
|
|
539
|
+
);
|
|
540
|
+
pushReason(
|
|
541
|
+
reasons,
|
|
542
|
+
malformedManagedBlockPaths.length === 0,
|
|
543
|
+
"Managed instruction blocks are parseable.",
|
|
544
|
+
`Malformed managed blocks: ${malformedManagedBlockPaths.join(", ")}.`
|
|
545
|
+
);
|
|
546
|
+
return {
|
|
547
|
+
managedFilesMatch: modifiedPaths.length === 0 && missingPaths.length === 0,
|
|
548
|
+
managedBlocksValid: malformedManagedBlockPaths.length === 0,
|
|
549
|
+
recognizableManagedPaths: Object.keys(manifest.files).sort(),
|
|
550
|
+
modifiedPaths,
|
|
551
|
+
missingPaths,
|
|
552
|
+
ambiguousFallbackPaths: [],
|
|
553
|
+
nonMakeDocsPathCollisions: [],
|
|
554
|
+
reasons
|
|
555
|
+
};
|
|
556
|
+
}
|
|
557
|
+
function hasTrustedLocalOwnershipProof(relativePath, entry, manifest) {
|
|
558
|
+
if (entry.sourceId.startsWith("router:")) {
|
|
559
|
+
const router = manifest.routerOwnership?.routers[relativePath];
|
|
560
|
+
return Boolean(
|
|
561
|
+
router?.sourceId === entry.sourceId && router.ownershipClass === "managed-snapshot" && router.provenanceState === "verified" && router.lifecycleDisposition === "active" && router.adoptionReceipt === null && router.expectedSourceHash === entry.hash && router.installedHash === entry.hash
|
|
562
|
+
);
|
|
563
|
+
}
|
|
564
|
+
if (entry.sourceId.startsWith("resource:")) {
|
|
565
|
+
const uri = entry.sourceId.slice("resource:".length);
|
|
566
|
+
const resource = manifest.resourceProjection?.resources[uri];
|
|
567
|
+
return Boolean(
|
|
568
|
+
resource?.managedDestination === relativePath && resource.ownershipClass === "managed-snapshot" && resource.lifecycleDisposition === "active" && resource.installedDigest === entry.hash
|
|
569
|
+
);
|
|
570
|
+
}
|
|
571
|
+
return true;
|
|
572
|
+
}
|
|
573
|
+
function isTrustedCurrentPackageRefresh(relativePath, entry, currentHash, manifest) {
|
|
574
|
+
let ownershipTrusted = false;
|
|
575
|
+
if (entry.sourceId.startsWith("router:")) {
|
|
576
|
+
const router = manifest.routerOwnership?.routers[relativePath];
|
|
577
|
+
ownershipTrusted = router?.sourceId === entry.sourceId && router.ownershipClass === "managed-snapshot" && router.provenanceState === "verified" && router.lifecycleDisposition === "active" && router.installedHash === entry.hash && router.expectedSourceHash === entry.hash;
|
|
578
|
+
} else if (entry.sourceId.startsWith("resource:")) {
|
|
579
|
+
ownershipTrusted = Object.values(manifest.resourceProjection?.resources ?? {}).some(
|
|
580
|
+
(resource) => resource.managedDestination === relativePath && `resource:${resource.uri}` === entry.sourceId && resource.ownershipClass === "managed-snapshot" && resource.provenanceState === "verified" && resource.lifecycleDisposition === "active" && resource.installedDigest === entry.hash
|
|
581
|
+
);
|
|
582
|
+
} else if (entry.sourceId === `file:${relativePath}`) {
|
|
583
|
+
ownershipTrusted = entry.systemAsset?.logicalAssetId === relativePath && entry.systemAsset.localPath === relativePath && entry.systemAsset.expectedHashes.includes(entry.hash);
|
|
584
|
+
}
|
|
585
|
+
if (!ownershipTrusted) {
|
|
586
|
+
return false;
|
|
587
|
+
}
|
|
588
|
+
try {
|
|
589
|
+
const packageHash = getManifestFileHash(relativePath, readPackageFile(relativePath));
|
|
590
|
+
return packageHash !== null && currentHash === packageHash;
|
|
591
|
+
} catch {
|
|
592
|
+
return false;
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
function evaluateBootstrapTrust(targetDir, manifest) {
|
|
596
|
+
const localBootstrapPaths = manifest.systemAssetMaterialization?.localBootstrapPaths ?? [];
|
|
597
|
+
const missingBootstrapPaths = localBootstrapPaths.filter(
|
|
598
|
+
(relativePath) => !OPTIONAL_LOCAL_BOOTSTRAP_PATHS.has(relativePath) && !existsSync2(path2.join(targetDir, relativePath))
|
|
599
|
+
);
|
|
600
|
+
const reasons = [];
|
|
601
|
+
pushReason(
|
|
602
|
+
reasons,
|
|
603
|
+
missingBootstrapPaths.length === 0,
|
|
604
|
+
"Required local bootstrap files are present.",
|
|
605
|
+
`Missing local bootstrap files: ${missingBootstrapPaths.join(", ")}.`
|
|
606
|
+
);
|
|
607
|
+
return {
|
|
608
|
+
requiredLocalBootstrapPresent: missingBootstrapPaths.length === 0,
|
|
609
|
+
missingBootstrapPaths,
|
|
610
|
+
reasons
|
|
611
|
+
};
|
|
612
|
+
}
|
|
613
|
+
function evaluateSkillTrust(targetDir, manifest, filesystemTrust) {
|
|
614
|
+
const missingSkillOutputs = manifest.skillFiles.filter(
|
|
615
|
+
(relativePath) => !existsSync2(relativePathToTarget(targetDir, relativePath))
|
|
616
|
+
);
|
|
617
|
+
const skillFileSet = new Set(manifest.skillFiles);
|
|
618
|
+
const modifiedSkillOutputs = filesystemTrust.modifiedPaths.filter(
|
|
619
|
+
(relativePath) => skillFileSet.has(relativePath)
|
|
620
|
+
);
|
|
621
|
+
const reasons = [];
|
|
622
|
+
pushReason(
|
|
623
|
+
reasons,
|
|
624
|
+
missingSkillOutputs.length === 0,
|
|
625
|
+
"Selected skill outputs are present.",
|
|
626
|
+
`Missing selected skill outputs: ${missingSkillOutputs.join(", ")}.`
|
|
627
|
+
);
|
|
628
|
+
pushReason(
|
|
629
|
+
reasons,
|
|
630
|
+
modifiedSkillOutputs.length === 0,
|
|
631
|
+
"Selected skill outputs match manifest records.",
|
|
632
|
+
`Modified selected skill outputs: ${modifiedSkillOutputs.join(", ")}.`
|
|
633
|
+
);
|
|
634
|
+
return {
|
|
635
|
+
selectedSkillsTrusted: missingSkillOutputs.length === 0 && modifiedSkillOutputs.length === 0,
|
|
636
|
+
missingSkillOutputs,
|
|
637
|
+
modifiedSkillOutputs,
|
|
638
|
+
reasons
|
|
639
|
+
};
|
|
640
|
+
}
|
|
641
|
+
function evaluateProviderCacheTrust(manifest) {
|
|
642
|
+
const materialization = manifest.systemAssetMaterialization;
|
|
643
|
+
const mode = materialization?.mode ?? null;
|
|
644
|
+
const assets = Object.values(materialization?.assets ?? {});
|
|
645
|
+
const requiresRemoteEvidence = mode === "provider-backed" || mode === "hybrid-pinned-cache";
|
|
646
|
+
const providerAvailable = !requiresRemoteEvidence || assets.every((asset) => isProviderEvidenceAvailable(asset));
|
|
647
|
+
const staleHashes = assets.flatMap((asset) => asset.expectedHashes).filter((hash) => hash.includes("stale"));
|
|
648
|
+
const cacheUsable = mode !== "hybrid-pinned-cache" || staleHashes.length === 0;
|
|
649
|
+
const hasPinnedHashes = !requiresRemoteEvidence || assets.length > 0 && assets.every((asset) => asset.expectedHashes.length > 0);
|
|
650
|
+
const trusted = mode !== null && providerAvailable && cacheUsable && hasPinnedHashes;
|
|
651
|
+
const reasons = [];
|
|
652
|
+
pushReason(
|
|
653
|
+
reasons,
|
|
654
|
+
mode !== null,
|
|
655
|
+
`Materialization mode is ${mode}.`,
|
|
656
|
+
"Materialization mode is missing."
|
|
657
|
+
);
|
|
658
|
+
pushReason(
|
|
659
|
+
reasons,
|
|
660
|
+
providerAvailable,
|
|
661
|
+
"Provider evidence is available or not required.",
|
|
662
|
+
"Provider evidence is unavailable."
|
|
663
|
+
);
|
|
664
|
+
pushReason(
|
|
665
|
+
reasons,
|
|
666
|
+
cacheUsable,
|
|
667
|
+
"Pinned cache hashes are current or not required.",
|
|
668
|
+
`Stale pinned cache hashes: ${staleHashes.join(", ")}.`
|
|
669
|
+
);
|
|
670
|
+
pushReason(
|
|
671
|
+
reasons,
|
|
672
|
+
hasPinnedHashes,
|
|
673
|
+
"Remote materialization assets include pinned hashes.",
|
|
674
|
+
"Remote materialization assets are missing pinned hashes."
|
|
675
|
+
);
|
|
676
|
+
return {
|
|
677
|
+
mode,
|
|
678
|
+
trusted,
|
|
679
|
+
providerAvailable,
|
|
680
|
+
cacheUsable,
|
|
681
|
+
staleHashes,
|
|
682
|
+
reasons
|
|
683
|
+
};
|
|
684
|
+
}
|
|
685
|
+
function createFallbackEvidence(options) {
|
|
686
|
+
const { fallback } = options;
|
|
687
|
+
return {
|
|
688
|
+
manifestTrust: {
|
|
689
|
+
present: options.present,
|
|
690
|
+
parseable: options.parseable,
|
|
691
|
+
schemaVersion: options.schemaVersion,
|
|
692
|
+
packageIdentityTrusted: false,
|
|
693
|
+
selectionsTrusted: false,
|
|
694
|
+
managedFileRecordsTrusted: false,
|
|
695
|
+
skillRecordsTrusted: false,
|
|
696
|
+
materializationProvenanceTrusted: false,
|
|
697
|
+
reasons: [options.manifestReason]
|
|
698
|
+
},
|
|
699
|
+
filesystemTrust: {
|
|
700
|
+
managedFilesMatch: false,
|
|
701
|
+
managedBlocksValid: fallback.ambiguousFallbackPaths.length === 0,
|
|
702
|
+
recognizableManagedPaths: fallback.recognizableManagedPaths,
|
|
703
|
+
modifiedPaths: [],
|
|
704
|
+
missingPaths: [],
|
|
705
|
+
ambiguousFallbackPaths: fallback.ambiguousFallbackPaths,
|
|
706
|
+
nonMakeDocsPathCollisions: fallback.nonMakeDocsPathCollisions,
|
|
707
|
+
reasons: fallback.reasons
|
|
708
|
+
},
|
|
709
|
+
bootstrapTrust: {
|
|
710
|
+
requiredLocalBootstrapPresent: false,
|
|
711
|
+
missingBootstrapPaths: [],
|
|
712
|
+
reasons: ["Bootstrap trust requires a trusted manifest."]
|
|
713
|
+
},
|
|
714
|
+
skillTrust: {
|
|
715
|
+
selectedSkillsTrusted: false,
|
|
716
|
+
missingSkillOutputs: [],
|
|
717
|
+
modifiedSkillOutputs: [],
|
|
718
|
+
reasons: ["Skill trust requires a trusted manifest."]
|
|
719
|
+
},
|
|
720
|
+
providerCacheTrust: {
|
|
721
|
+
mode: null,
|
|
722
|
+
trusted: false,
|
|
723
|
+
providerAvailable: false,
|
|
724
|
+
cacheUsable: false,
|
|
725
|
+
staleHashes: [],
|
|
726
|
+
reasons: ["Provider/cache trust requires a trusted manifest."]
|
|
727
|
+
}
|
|
728
|
+
};
|
|
729
|
+
}
|
|
730
|
+
function evaluateFallbackRecognition(targetDir) {
|
|
731
|
+
const recognizableManagedPaths = [];
|
|
732
|
+
const ambiguousFallbackPaths = [];
|
|
733
|
+
const nonMakeDocsPathCollisions = [];
|
|
734
|
+
for (const relativePath of LEGACY_RECOGNITION_FINGERPRINT_PATHS) {
|
|
735
|
+
const absolutePath = path2.join(targetDir, relativePath);
|
|
736
|
+
if (!existsSync2(absolutePath) || !statSync(absolutePath).isFile()) {
|
|
737
|
+
continue;
|
|
738
|
+
}
|
|
739
|
+
const content = readFileSync2(absolutePath, "utf8");
|
|
740
|
+
if (looksCanonicalMakeDocsContent(relativePath, content)) {
|
|
741
|
+
recognizableManagedPaths.push(relativePath);
|
|
742
|
+
} else {
|
|
743
|
+
ambiguousFallbackPaths.push(relativePath);
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
const reasons = [];
|
|
747
|
+
pushReason(
|
|
748
|
+
reasons,
|
|
749
|
+
recognizableManagedPaths.length > 0,
|
|
750
|
+
`Recognized make-docs fallback paths: ${recognizableManagedPaths.join(", ")}.`,
|
|
751
|
+
"No canonical make-docs fallback paths were recognized."
|
|
752
|
+
);
|
|
753
|
+
if (ambiguousFallbackPaths.length > 0) {
|
|
754
|
+
reasons.push(`Ambiguous fallback paths: ${ambiguousFallbackPaths.join(", ")}.`);
|
|
755
|
+
}
|
|
756
|
+
if (nonMakeDocsPathCollisions.length > 0) {
|
|
757
|
+
reasons.push(
|
|
758
|
+
`Non-make-docs path collisions: ${nonMakeDocsPathCollisions.join(", ")}.`
|
|
759
|
+
);
|
|
760
|
+
}
|
|
761
|
+
return {
|
|
762
|
+
recognizableManagedPaths: recognizableManagedPaths.sort(),
|
|
763
|
+
ambiguousFallbackPaths: ambiguousFallbackPaths.sort(),
|
|
764
|
+
nonMakeDocsPathCollisions: nonMakeDocsPathCollisions.sort(),
|
|
765
|
+
reasons
|
|
766
|
+
};
|
|
767
|
+
}
|
|
768
|
+
function readRawManifest(targetDir) {
|
|
769
|
+
const installed = readInstallationManifest(targetDir);
|
|
770
|
+
if (installed) {
|
|
771
|
+
try {
|
|
772
|
+
const manifest = validateAndMigrateManifest(installed, "Make Docs Store installation ledger");
|
|
773
|
+
return { present: true, parseable: true, schemaVersion: manifest.schemaVersion, manifest };
|
|
774
|
+
} catch (error) {
|
|
775
|
+
return { present: true, parseable: false, schemaVersion: null, manifest: null, errorMessage: error instanceof Error ? error.message : String(error) };
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
assertManagedPathHasNoSymlinks(targetDir, MANIFEST_RELATIVE_PATH);
|
|
779
|
+
const manifestPath = getManifestPath(targetDir);
|
|
780
|
+
if (!existsSync2(manifestPath)) {
|
|
781
|
+
return {
|
|
782
|
+
present: false,
|
|
783
|
+
parseable: false,
|
|
784
|
+
schemaVersion: null,
|
|
785
|
+
manifest: null
|
|
786
|
+
};
|
|
787
|
+
}
|
|
788
|
+
try {
|
|
789
|
+
const raw = JSON.parse(readFileSync2(manifestPath, "utf8"));
|
|
790
|
+
return {
|
|
791
|
+
present: true,
|
|
792
|
+
parseable: true,
|
|
793
|
+
schemaVersion: typeof raw.schemaVersion === "number" ? raw.schemaVersion : null,
|
|
794
|
+
manifest: previewLegacyInstallationState(targetDir).manifest
|
|
795
|
+
};
|
|
796
|
+
} catch (error) {
|
|
797
|
+
return {
|
|
798
|
+
present: true,
|
|
799
|
+
parseable: false,
|
|
800
|
+
schemaVersion: null,
|
|
801
|
+
manifest: null,
|
|
802
|
+
errorMessage: error instanceof Error ? error.message : String(error)
|
|
803
|
+
};
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
function createClassification(options) {
|
|
807
|
+
const printableEvidence = [
|
|
808
|
+
`state=${options.state}`,
|
|
809
|
+
`disposition=${options.disposition}`,
|
|
810
|
+
...formatAuditSkillSelectionEvidence(options.auditReport),
|
|
811
|
+
...options.evidence.manifestTrust.reasons.map((reason) => `manifest: ${reason}`),
|
|
812
|
+
...options.evidence.filesystemTrust.reasons.map(
|
|
813
|
+
(reason) => `filesystem: ${reason}`
|
|
814
|
+
),
|
|
815
|
+
...options.evidence.bootstrapTrust.reasons.map(
|
|
816
|
+
(reason) => `bootstrap: ${reason}`
|
|
817
|
+
),
|
|
818
|
+
...options.evidence.skillTrust.reasons.map((reason) => `skills: ${reason}`),
|
|
819
|
+
...options.evidence.providerCacheTrust.reasons.map(
|
|
820
|
+
(reason) => `provider-cache: ${reason}`
|
|
821
|
+
)
|
|
822
|
+
];
|
|
823
|
+
return {
|
|
824
|
+
...options,
|
|
825
|
+
printableEvidence
|
|
826
|
+
};
|
|
827
|
+
}
|
|
828
|
+
function formatAuditSkillSelectionEvidence(auditReport) {
|
|
829
|
+
const review = auditReport?.skillSelectionReview;
|
|
830
|
+
if (!review) {
|
|
831
|
+
return [];
|
|
832
|
+
}
|
|
833
|
+
if (!review.skillsEnabled) {
|
|
834
|
+
return ["selection: skills disabled"];
|
|
835
|
+
}
|
|
836
|
+
const manifest = review.skillManifest ? `${review.skillManifest.displayName} (${review.skillManifest.sourcePolicyKind})` : "legacy selections without manifest provenance";
|
|
837
|
+
const selectedSkills = review.selectedSkills.length === 0 ? "(none)" : review.selectedSkills.join(", ");
|
|
838
|
+
const provenance = review.skillSelectionProvenance.length === 0 ? "no saved provenance metadata" : review.skillSelectionProvenance.map((entry) => `${entry.skillName}:${entry.provenanceKind}`).join(", ");
|
|
839
|
+
return [
|
|
840
|
+
`selection: skills ${review.skillScope}; manifest ${manifest}; selected ${selectedSkills}; provenance ${provenance}`
|
|
841
|
+
];
|
|
842
|
+
}
|
|
843
|
+
function manifestEntryMatches(entry, currentHash) {
|
|
844
|
+
return entry.hash === currentHash;
|
|
845
|
+
}
|
|
846
|
+
function isProviderEvidenceAvailable(asset) {
|
|
847
|
+
return Boolean(
|
|
848
|
+
asset.sourceProvider && !asset.sourceProvider.includes("unavailable") && asset.sourceVersion && asset.sourceImmutableRef && asset.expectedHashes.length > 0
|
|
849
|
+
);
|
|
850
|
+
}
|
|
851
|
+
function looksCanonicalMakeDocsContent(relativePath, content) {
|
|
852
|
+
const parsed = parseManagedBlock(content);
|
|
853
|
+
if (parsed.state === "valid" || content.includes("make-docs") || content.includes("Make Docs")) {
|
|
854
|
+
return true;
|
|
855
|
+
}
|
|
856
|
+
if (relativePath === ".make-docs/system/references/lifecycle.md") {
|
|
857
|
+
return content.includes("# Lifecycle Anchor") && content.includes("## Lifecycle Arc");
|
|
858
|
+
}
|
|
859
|
+
if (relativePath === ".make-docs/system/templates/history-record.md") {
|
|
860
|
+
return content.includes("ONE_LINE_SUMMARY") && content.includes("## Changes");
|
|
861
|
+
}
|
|
862
|
+
return false;
|
|
863
|
+
}
|
|
864
|
+
function pushReason(reasons, condition, success, failure) {
|
|
865
|
+
reasons.push(condition ? success : failure);
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
export {
|
|
869
|
+
previewLegacyInstallationState,
|
|
870
|
+
importLegacyInstallationState,
|
|
871
|
+
classifyCompatibilityState,
|
|
872
|
+
scopeCompatibilityToInstallPlan,
|
|
873
|
+
formatCompatibilityClassification
|
|
874
|
+
};
|
|
875
|
+
//# sourceMappingURL=chunk-BENO4IH5.js.map
|