@brucewaynedecoy/make-docs 1.0.0-rc.1 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -201
- package/README.md +31 -67
- package/dist/backup-GCM64IPN.js +20 -0
- package/dist/backup-GCM64IPN.js.map +1 -0
- package/dist/chunk-2HNJCJJE.js +1291 -0
- package/dist/chunk-2HNJCJJE.js.map +1 -0
- package/dist/chunk-4LLSMDWJ.js +24674 -0
- package/dist/chunk-4LLSMDWJ.js.map +1 -0
- package/dist/chunk-57GN6ALR.js +204 -0
- package/dist/chunk-57GN6ALR.js.map +1 -0
- package/dist/chunk-C2IBRVUA.js +4136 -0
- package/dist/chunk-C2IBRVUA.js.map +1 -0
- package/dist/chunk-D4HDZEJT.js +37 -0
- package/dist/chunk-D4HDZEJT.js.map +1 -0
- package/dist/chunk-DFQJENNL.js +2340 -0
- package/dist/chunk-DFQJENNL.js.map +1 -0
- package/dist/chunk-DNDM7DUQ.js +39 -0
- package/dist/chunk-DNDM7DUQ.js.map +1 -0
- package/dist/chunk-GPVKIBFC.js +875 -0
- package/dist/chunk-GPVKIBFC.js.map +1 -0
- package/dist/chunk-IHMZ2OCS.js +1575 -0
- package/dist/chunk-IHMZ2OCS.js.map +1 -0
- package/dist/chunk-O2UZ35PV.js +523 -0
- package/dist/chunk-O2UZ35PV.js.map +1 -0
- package/dist/chunk-U25GFKNZ.js +13995 -0
- package/dist/chunk-U25GFKNZ.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-UHPM4A2U.js +653 -0
- package/dist/self-UHPM4A2U.js.map +1 -0
- package/dist/server-N7XAAV3X.js +512 -0
- package/dist/server-N7XAAV3X.js.map +1 -0
- package/dist/setup-system-JUHGDZJW.js +544 -0
- package/dist/setup-system-JUHGDZJW.js.map +1 -0
- package/dist/{skills-command-3ESCZ75U.js → skills-command-W3SE3OFP.js} +190 -32
- package/dist/skills-command-W3SE3OFP.js.map +1 -0
- package/dist/uninstall-BGMJ6KCI.js +223 -0
- package/dist/uninstall-BGMJ6KCI.js.map +1 -0
- package/dist/virtual_make-docs-first-party-skills-VXSUUHTL.js +11 -0
- package/dist/virtual_make-docs-first-party-skills-VXSUUHTL.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,204 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
normalizeRelativePath,
|
|
4
|
+
preparePlannedFileChange,
|
|
5
|
+
recordPlannedFileChange,
|
|
6
|
+
relativePathToTarget
|
|
7
|
+
} from "./chunk-U25GFKNZ.js";
|
|
8
|
+
|
|
9
|
+
// src/installation-files.ts
|
|
10
|
+
import { lstatSync, readdirSync, rmdirSync, unlinkSync } from "fs";
|
|
11
|
+
import path from "path";
|
|
12
|
+
function removeInstallationPath(projectRoot, relativePath) {
|
|
13
|
+
const absolute = path.isAbsolute(relativePath) ? relativePath : path.resolve(projectRoot, relativePath);
|
|
14
|
+
let stat;
|
|
15
|
+
try {
|
|
16
|
+
stat = lstatSync(absolute);
|
|
17
|
+
} catch (error) {
|
|
18
|
+
if (error.code === "ENOENT") return false;
|
|
19
|
+
throw error;
|
|
20
|
+
}
|
|
21
|
+
if (stat.isDirectory() && !stat.isSymbolicLink()) {
|
|
22
|
+
for (const name of readdirSync(absolute).sort()) removeInstallationPath(projectRoot, path.join(relativePath, name));
|
|
23
|
+
recordPlannedFileChange(projectRoot, relativePath, { kind: "missing" }, () => rmdirSync(absolute));
|
|
24
|
+
} else {
|
|
25
|
+
recordPlannedFileChange(projectRoot, relativePath, { kind: "missing" }, () => unlinkSync(absolute));
|
|
26
|
+
}
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
function pruneInstallationParents(projectRoot, start, boundary) {
|
|
30
|
+
let current = path.resolve(start);
|
|
31
|
+
const end = path.resolve(boundary);
|
|
32
|
+
while (current !== end && current.startsWith(end + path.sep)) {
|
|
33
|
+
let stat;
|
|
34
|
+
try {
|
|
35
|
+
stat = lstatSync(current);
|
|
36
|
+
} catch (error) {
|
|
37
|
+
if (error.code === "ENOENT") {
|
|
38
|
+
current = path.dirname(current);
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
throw error;
|
|
42
|
+
}
|
|
43
|
+
if (stat.isSymbolicLink() || !stat.isDirectory() || readdirSync(current).length) return;
|
|
44
|
+
const relative = current.startsWith(path.resolve(projectRoot) + path.sep) ? path.relative(projectRoot, current) : current;
|
|
45
|
+
recordPlannedFileChange(projectRoot, relative, { kind: "missing" }, () => rmdirSync(current));
|
|
46
|
+
current = path.dirname(current);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function prepareInstallationRemoval(projectRoot, relativePath) {
|
|
50
|
+
const absolute = path.isAbsolute(relativePath) ? relativePath : path.resolve(projectRoot, relativePath);
|
|
51
|
+
let stat;
|
|
52
|
+
try {
|
|
53
|
+
stat = lstatSync(absolute);
|
|
54
|
+
} catch (error) {
|
|
55
|
+
if (error.code === "ENOENT") return [];
|
|
56
|
+
throw error;
|
|
57
|
+
}
|
|
58
|
+
const changes = [];
|
|
59
|
+
if (stat.isDirectory() && !stat.isSymbolicLink()) {
|
|
60
|
+
for (const name of readdirSync(absolute).sort()) changes.push(...prepareInstallationRemoval(projectRoot, path.join(relativePath, name)));
|
|
61
|
+
changes.push(preparePlannedFileChange(projectRoot, relativePath, { kind: "missing" }, () => rmdirSync(absolute)));
|
|
62
|
+
} else changes.push(preparePlannedFileChange(projectRoot, relativePath, { kind: "missing" }, () => unlinkSync(absolute)));
|
|
63
|
+
return changes;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// src/lifecycle-plan.ts
|
|
67
|
+
import { createHash } from "crypto";
|
|
68
|
+
import { lstatSync as lstatSync2, readFileSync } from "fs";
|
|
69
|
+
function lifecycleDisposition(action) {
|
|
70
|
+
switch (action.type) {
|
|
71
|
+
case "create":
|
|
72
|
+
case "generate":
|
|
73
|
+
return "create";
|
|
74
|
+
case "update":
|
|
75
|
+
case "strip-managed-block":
|
|
76
|
+
return "update";
|
|
77
|
+
case "noop":
|
|
78
|
+
return "preserve";
|
|
79
|
+
case "skip":
|
|
80
|
+
return "skip";
|
|
81
|
+
case "remove-managed":
|
|
82
|
+
return "remove";
|
|
83
|
+
case "update-conflict":
|
|
84
|
+
case "skip-conflict":
|
|
85
|
+
return "conflict";
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function annotateLifecycleActions(actions) {
|
|
89
|
+
return actions.map((action) => ({
|
|
90
|
+
...action,
|
|
91
|
+
disposition: lifecycleDisposition(action)
|
|
92
|
+
}));
|
|
93
|
+
}
|
|
94
|
+
function createLifecyclePlanSnapshot(targetDir, actions, authorityPaths = []) {
|
|
95
|
+
const entries = Array.from(
|
|
96
|
+
/* @__PURE__ */ new Set([
|
|
97
|
+
...actions.map((action) => normalizeRelativePath(action.relativePath)),
|
|
98
|
+
...authorityPaths.map(normalizeRelativePath)
|
|
99
|
+
])
|
|
100
|
+
).sort(compareCodeUnits).map((relativePath) => inspectSnapshotEntry(targetDir, relativePath));
|
|
101
|
+
return {
|
|
102
|
+
id: `sha256:${digestJson(entries)}`,
|
|
103
|
+
entries
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
function assertLifecyclePlanSnapshotCurrent(targetDir, snapshot) {
|
|
107
|
+
const currentEntries = snapshot.entries.map(
|
|
108
|
+
(entry) => inspectSnapshotEntry(targetDir, entry.relativePath)
|
|
109
|
+
);
|
|
110
|
+
const currentId = `sha256:${digestJson(currentEntries)}`;
|
|
111
|
+
if (currentId !== snapshot.id) {
|
|
112
|
+
throw new Error(
|
|
113
|
+
"The reviewed lifecycle plan is stale because a planned path changed. Create and review a new plan before applying it."
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
function createLifecycleMutationReceipt(options) {
|
|
118
|
+
const committedAt = options.committedAt ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
119
|
+
const outcomes = emptyOutcomeCounts();
|
|
120
|
+
const conflicts = [];
|
|
121
|
+
for (const action of options.actions) {
|
|
122
|
+
const disposition = action.disposition ?? lifecycleDisposition(action);
|
|
123
|
+
outcomes[disposition] += 1;
|
|
124
|
+
if (disposition === "conflict") {
|
|
125
|
+
conflicts.push(action.relativePath);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
const receiptSubject = {
|
|
129
|
+
operation: options.operation,
|
|
130
|
+
projectId: options.projectId,
|
|
131
|
+
manifestSchemaVersion: options.manifestSchemaVersion,
|
|
132
|
+
profileId: options.profileId,
|
|
133
|
+
selectedResourceTypes: [...options.selectedResourceTypes].sort(compareCodeUnits),
|
|
134
|
+
outcomes,
|
|
135
|
+
conflicts: conflicts.sort(compareCodeUnits),
|
|
136
|
+
backupReferences: [...options.backupReferences ?? []].sort(compareCodeUnits),
|
|
137
|
+
committedAt
|
|
138
|
+
};
|
|
139
|
+
return {
|
|
140
|
+
schemaVersion: 1,
|
|
141
|
+
receiptId: `sha256:${digestJson(receiptSubject)}`,
|
|
142
|
+
...receiptSubject,
|
|
143
|
+
claims: {
|
|
144
|
+
validated: false,
|
|
145
|
+
accepted: false,
|
|
146
|
+
published: false,
|
|
147
|
+
released: false
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
function inspectSnapshotEntry(targetDir, relativePath) {
|
|
152
|
+
const absolutePath = relativePathToTarget(targetDir, relativePath);
|
|
153
|
+
let stats;
|
|
154
|
+
try {
|
|
155
|
+
stats = lstatSync2(absolutePath);
|
|
156
|
+
} catch (error) {
|
|
157
|
+
if (error.code === "ENOENT") {
|
|
158
|
+
return { relativePath, state: "missing" };
|
|
159
|
+
}
|
|
160
|
+
throw error;
|
|
161
|
+
}
|
|
162
|
+
if (stats.isSymbolicLink()) {
|
|
163
|
+
return { relativePath, state: "symlink" };
|
|
164
|
+
}
|
|
165
|
+
if (stats.isDirectory()) {
|
|
166
|
+
return { relativePath, state: "directory" };
|
|
167
|
+
}
|
|
168
|
+
if (stats.isFile()) {
|
|
169
|
+
return {
|
|
170
|
+
relativePath,
|
|
171
|
+
state: "file",
|
|
172
|
+
digest: createHash("sha256").update(readFileSync(absolutePath)).digest("hex")
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
return { relativePath, state: "other" };
|
|
176
|
+
}
|
|
177
|
+
function emptyOutcomeCounts() {
|
|
178
|
+
return {
|
|
179
|
+
create: 0,
|
|
180
|
+
update: 0,
|
|
181
|
+
preserve: 0,
|
|
182
|
+
conflict: 0,
|
|
183
|
+
skip: 0,
|
|
184
|
+
remove: 0,
|
|
185
|
+
stop: 0
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
function digestJson(value) {
|
|
189
|
+
return createHash("sha256").update(JSON.stringify(value)).digest("hex");
|
|
190
|
+
}
|
|
191
|
+
function compareCodeUnits(left, right) {
|
|
192
|
+
return left < right ? -1 : left > right ? 1 : 0;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export {
|
|
196
|
+
removeInstallationPath,
|
|
197
|
+
pruneInstallationParents,
|
|
198
|
+
prepareInstallationRemoval,
|
|
199
|
+
annotateLifecycleActions,
|
|
200
|
+
createLifecyclePlanSnapshot,
|
|
201
|
+
assertLifecyclePlanSnapshotCurrent,
|
|
202
|
+
createLifecycleMutationReceipt
|
|
203
|
+
};
|
|
204
|
+
//# sourceMappingURL=chunk-57GN6ALR.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/installation-files.ts","../src/lifecycle-plan.ts"],"sourcesContent":["import { lstatSync, readdirSync, rmdirSync, unlinkSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { preparePlannedFileChange, recordPlannedFileChange } from \"./store/installation-state\";\n\n/** Remove each reviewed file through the Store journal. Never follow links. */\nexport function removeInstallationPath(projectRoot: string, relativePath: string): boolean {\n const absolute = path.isAbsolute(relativePath) ? relativePath : path.resolve(projectRoot, relativePath);\n let stat;\n try { stat = lstatSync(absolute); }\n catch (error) { if ((error as NodeJS.ErrnoException).code === \"ENOENT\") return false; throw error; }\n if (stat.isDirectory() && !stat.isSymbolicLink()) {\n for (const name of readdirSync(absolute).sort()) removeInstallationPath(projectRoot, path.join(relativePath, name));\n recordPlannedFileChange(projectRoot, relativePath, { kind: \"missing\" }, () => rmdirSync(absolute));\n } else {\n recordPlannedFileChange(projectRoot, relativePath, { kind: \"missing\" }, () => unlinkSync(absolute));\n }\n return true;\n}\n\nexport function pruneInstallationParents(projectRoot: string, start: string, boundary: string): void {\n let current = path.resolve(start);\n const end = path.resolve(boundary);\n while (current !== end && current.startsWith(end + path.sep)) {\n let stat;\n try { stat = lstatSync(current); }\n catch (error) { if ((error as NodeJS.ErrnoException).code === \"ENOENT\") { current = path.dirname(current); continue; } throw error; }\n if (stat.isSymbolicLink() || !stat.isDirectory() || readdirSync(current).length) return;\n const relative = current.startsWith(path.resolve(projectRoot) + path.sep) ? path.relative(projectRoot, current) : current;\n recordPlannedFileChange(projectRoot, relative, { kind: \"missing\" }, () => rmdirSync(current));\n current = path.dirname(current);\n }\n}\n\n/** Declare a complete removal scope before any member is changed. */\nexport function prepareInstallationRemoval(projectRoot: string, relativePath: string): Array<() => void> {\n const absolute = path.isAbsolute(relativePath) ? relativePath : path.resolve(projectRoot, relativePath);\n let stat;\n try { stat = lstatSync(absolute); }\n catch (error) { if ((error as NodeJS.ErrnoException).code === \"ENOENT\") return []; throw error; }\n const changes: Array<() => void> = [];\n if (stat.isDirectory() && !stat.isSymbolicLink()) {\n for (const name of readdirSync(absolute).sort()) changes.push(...prepareInstallationRemoval(projectRoot, path.join(relativePath, name)));\n changes.push(preparePlannedFileChange(projectRoot, relativePath, { kind: \"missing\" }, () => rmdirSync(absolute)));\n } else changes.push(preparePlannedFileChange(projectRoot, relativePath, { kind: \"missing\" }, () => unlinkSync(absolute)));\n return changes;\n}\n","import { createHash } from \"node:crypto\";\nimport { lstatSync, readFileSync } from \"node:fs\";\nimport type {\n LifecycleMutationReceipt,\n LifecyclePlanDisposition,\n LifecyclePlanSnapshot,\n LifecyclePlanSnapshotEntry,\n PlannedAction,\n ProjectResourceType,\n} from \"./types\";\nimport { normalizeRelativePath, relativePathToTarget } from \"./utils\";\n\nexport function lifecycleDisposition(action: PlannedAction): LifecyclePlanDisposition {\n switch (action.type) {\n case \"create\":\n case \"generate\":\n return \"create\";\n case \"update\":\n case \"strip-managed-block\":\n return \"update\";\n case \"noop\":\n return \"preserve\";\n case \"skip\":\n return \"skip\";\n case \"remove-managed\":\n return \"remove\";\n case \"update-conflict\":\n case \"skip-conflict\":\n return \"conflict\";\n }\n}\n\nexport function annotateLifecycleActions(actions: PlannedAction[]): PlannedAction[] {\n return actions.map((action) => ({\n ...action,\n disposition: lifecycleDisposition(action),\n }));\n}\n\nexport function createLifecyclePlanSnapshot(\n targetDir: string,\n actions: readonly PlannedAction[],\n authorityPaths: readonly string[] = [],\n): LifecyclePlanSnapshot {\n const entries = Array.from(\n new Set([\n ...actions.map((action) => normalizeRelativePath(action.relativePath)),\n ...authorityPaths.map(normalizeRelativePath),\n ]),\n )\n .sort(compareCodeUnits)\n .map((relativePath) => inspectSnapshotEntry(targetDir, relativePath));\n return {\n id: `sha256:${digestJson(entries)}`,\n entries,\n };\n}\n\nexport function assertLifecyclePlanSnapshotCurrent(\n targetDir: string,\n snapshot: LifecyclePlanSnapshot,\n): void {\n const currentEntries = snapshot.entries.map((entry) =>\n inspectSnapshotEntry(targetDir, entry.relativePath),\n );\n const currentId = `sha256:${digestJson(currentEntries)}`;\n if (currentId !== snapshot.id) {\n throw new Error(\n \"The reviewed lifecycle plan is stale because a planned path changed. Create and review a new plan before applying it.\",\n );\n }\n}\n\nexport function createLifecycleMutationReceipt(options: {\n operation: string;\n projectId: string;\n manifestSchemaVersion: number;\n profileId: string;\n selectedResourceTypes: readonly ProjectResourceType[];\n actions: readonly PlannedAction[];\n backupReferences?: readonly string[];\n committedAt?: string;\n}): LifecycleMutationReceipt {\n const committedAt = options.committedAt ?? new Date().toISOString();\n const outcomes = emptyOutcomeCounts();\n const conflicts: string[] = [];\n for (const action of options.actions) {\n const disposition = action.disposition ?? lifecycleDisposition(action);\n outcomes[disposition] += 1;\n if (disposition === \"conflict\") {\n conflicts.push(action.relativePath);\n }\n }\n const receiptSubject = {\n operation: options.operation,\n projectId: options.projectId,\n manifestSchemaVersion: options.manifestSchemaVersion,\n profileId: options.profileId,\n selectedResourceTypes: [...options.selectedResourceTypes].sort(compareCodeUnits),\n outcomes,\n conflicts: conflicts.sort(compareCodeUnits),\n backupReferences: [...(options.backupReferences ?? [])].sort(compareCodeUnits),\n committedAt,\n };\n return {\n schemaVersion: 1,\n receiptId: `sha256:${digestJson(receiptSubject)}`,\n ...receiptSubject,\n claims: {\n validated: false,\n accepted: false,\n published: false,\n released: false,\n },\n };\n}\n\nfunction inspectSnapshotEntry(\n targetDir: string,\n relativePath: string,\n): LifecyclePlanSnapshotEntry {\n const absolutePath = relativePathToTarget(targetDir, relativePath);\n let stats;\n try {\n stats = lstatSync(absolutePath);\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === \"ENOENT\") {\n return { relativePath, state: \"missing\" };\n }\n throw error;\n }\n if (stats.isSymbolicLink()) {\n return { relativePath, state: \"symlink\" };\n }\n if (stats.isDirectory()) {\n return { relativePath, state: \"directory\" };\n }\n if (stats.isFile()) {\n return {\n relativePath,\n state: \"file\",\n digest: createHash(\"sha256\").update(readFileSync(absolutePath)).digest(\"hex\"),\n };\n }\n return { relativePath, state: \"other\" };\n}\n\nfunction emptyOutcomeCounts(): Record<LifecyclePlanDisposition, number> {\n return {\n create: 0,\n update: 0,\n preserve: 0,\n conflict: 0,\n skip: 0,\n remove: 0,\n stop: 0,\n };\n}\n\nfunction digestJson(value: unknown): string {\n return createHash(\"sha256\").update(JSON.stringify(value)).digest(\"hex\");\n}\n\nfunction compareCodeUnits(left: string, right: string): number {\n return left < right ? -1 : left > right ? 1 : 0;\n}\n"],"mappings":";;;;;;;;;AAAA,SAAS,WAAW,aAAa,WAAW,kBAAkB;AAC9D,OAAO,UAAU;AAIV,SAAS,uBAAuB,aAAqB,cAA+B;AACzF,QAAM,WAAW,KAAK,WAAW,YAAY,IAAI,eAAe,KAAK,QAAQ,aAAa,YAAY;AACtG,MAAI;AACJ,MAAI;AAAE,WAAO,UAAU,QAAQ;AAAA,EAAG,SAC3B,OAAO;AAAE,QAAK,MAAgC,SAAS,SAAU,QAAO;AAAO,UAAM;AAAA,EAAO;AACnG,MAAI,KAAK,YAAY,KAAK,CAAC,KAAK,eAAe,GAAG;AAChD,eAAW,QAAQ,YAAY,QAAQ,EAAE,KAAK,EAAG,wBAAuB,aAAa,KAAK,KAAK,cAAc,IAAI,CAAC;AAClH,4BAAwB,aAAa,cAAc,EAAE,MAAM,UAAU,GAAG,MAAM,UAAU,QAAQ,CAAC;AAAA,EACnG,OAAO;AACL,4BAAwB,aAAa,cAAc,EAAE,MAAM,UAAU,GAAG,MAAM,WAAW,QAAQ,CAAC;AAAA,EACpG;AACA,SAAO;AACT;AAEO,SAAS,yBAAyB,aAAqB,OAAe,UAAwB;AACnG,MAAI,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