@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,523 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
createAuditReport,
|
|
4
|
+
getProjectBackupRoot
|
|
5
|
+
} from "./chunk-G5EF63GG.js";
|
|
6
|
+
import {
|
|
7
|
+
Ct,
|
|
8
|
+
Gt,
|
|
9
|
+
Rt,
|
|
10
|
+
Vt,
|
|
11
|
+
Wt
|
|
12
|
+
} from "./chunk-Z5K4FHYP.js";
|
|
13
|
+
import {
|
|
14
|
+
ensureParentDir,
|
|
15
|
+
loadManifest,
|
|
16
|
+
preparePlannedFileChange,
|
|
17
|
+
sealInstallationOperation,
|
|
18
|
+
withInstallationOperation
|
|
19
|
+
} from "./chunk-MXBHCHSM.js";
|
|
20
|
+
|
|
21
|
+
// src/backup.ts
|
|
22
|
+
import {
|
|
23
|
+
copyFileSync,
|
|
24
|
+
existsSync,
|
|
25
|
+
mkdirSync,
|
|
26
|
+
readdirSync,
|
|
27
|
+
readFileSync
|
|
28
|
+
} from "fs";
|
|
29
|
+
import os from "os";
|
|
30
|
+
import path from "path";
|
|
31
|
+
|
|
32
|
+
// src/lifecycle-ui.ts
|
|
33
|
+
import { stdin as input, stdout as output } from "process";
|
|
34
|
+
var lifecycleRenderer = createClackLifecycleRenderer();
|
|
35
|
+
function createClackLifecycleRenderer() {
|
|
36
|
+
return {
|
|
37
|
+
beginWorkflow(title) {
|
|
38
|
+
Wt(title);
|
|
39
|
+
},
|
|
40
|
+
renderBackupAuditSummary(options) {
|
|
41
|
+
renderAuditNote({
|
|
42
|
+
title: "make-docs setup backup",
|
|
43
|
+
lines: buildBackupAuditSummaryLines(options),
|
|
44
|
+
groups: [
|
|
45
|
+
formatEntryGroup(
|
|
46
|
+
"Files to copy",
|
|
47
|
+
options.copyableFiles,
|
|
48
|
+
(entry) => `${formatPath(entry)} (${entry.reason})`
|
|
49
|
+
),
|
|
50
|
+
formatEntryGroup(
|
|
51
|
+
"Directories to materialize",
|
|
52
|
+
options.materializableDirectories
|
|
53
|
+
),
|
|
54
|
+
formatEntryGroup(
|
|
55
|
+
"Retained paths",
|
|
56
|
+
options.auditReport.preservedPaths,
|
|
57
|
+
(entry) => `${formatPath(entry)} (${entry.reason})`
|
|
58
|
+
),
|
|
59
|
+
formatEntryGroup(
|
|
60
|
+
"Skipped paths",
|
|
61
|
+
options.auditReport.skippedPaths,
|
|
62
|
+
(entry) => `${formatPath(entry)} (${entry.reason})`
|
|
63
|
+
)
|
|
64
|
+
]
|
|
65
|
+
});
|
|
66
|
+
},
|
|
67
|
+
confirmBackupRun(permissions) {
|
|
68
|
+
return confirmLifecycleCheckpoint({
|
|
69
|
+
permissions,
|
|
70
|
+
message: "Create this backup?",
|
|
71
|
+
ttyError: "Backup confirmation requires a TTY. Re-run with `make-docs setup backup --yes`."
|
|
72
|
+
});
|
|
73
|
+
},
|
|
74
|
+
renderBackupNoopSummary() {
|
|
75
|
+
Gt(
|
|
76
|
+
"No make-docs-managed files required backup. No backup destination was created."
|
|
77
|
+
);
|
|
78
|
+
},
|
|
79
|
+
renderBackupCancelled() {
|
|
80
|
+
Gt("Backup cancelled.");
|
|
81
|
+
},
|
|
82
|
+
renderBackupCompletionSummary(result) {
|
|
83
|
+
if (result.status !== "completed" || !result.destinationDir) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
Vt(
|
|
87
|
+
[
|
|
88
|
+
`Destination: ${result.destinationDir}`,
|
|
89
|
+
`Copied files: ${result.copiedFiles.length}`,
|
|
90
|
+
`Materialized directories: ${result.materializedDirectories.length}`,
|
|
91
|
+
`Retained paths surfaced: ${result.auditReport.preservedPaths.length}`,
|
|
92
|
+
`Skipped paths surfaced: ${result.auditReport.skippedPaths.length}`
|
|
93
|
+
].join("\n"),
|
|
94
|
+
"Backup complete"
|
|
95
|
+
);
|
|
96
|
+
},
|
|
97
|
+
renderUninstallWarning(options) {
|
|
98
|
+
const lines = ["This command removes audited make-docs-managed paths", ""];
|
|
99
|
+
if (options.backupDestinationDir) {
|
|
100
|
+
lines.push("A backup will be created before removal begins.");
|
|
101
|
+
lines.push(`Backup destination: ${options.backupDestinationDir}`);
|
|
102
|
+
} else {
|
|
103
|
+
lines.push("Safer alternative: make-docs setup backup");
|
|
104
|
+
lines.push("Safer destructive flow: make-docs setup remove --backup");
|
|
105
|
+
}
|
|
106
|
+
Vt(lines.join("\n"), "WARNING");
|
|
107
|
+
},
|
|
108
|
+
confirmUninstallWarning(permissions) {
|
|
109
|
+
return confirmLifecycleCheckpoint({
|
|
110
|
+
permissions,
|
|
111
|
+
message: "Continue with uninstall review?",
|
|
112
|
+
ttyError: "Uninstall confirmation requires a TTY. Re-run with `make-docs setup remove --yes`."
|
|
113
|
+
});
|
|
114
|
+
},
|
|
115
|
+
renderUninstallAuditSummary(options) {
|
|
116
|
+
renderAuditNote({
|
|
117
|
+
title: "make-docs setup remove",
|
|
118
|
+
lines: buildUninstallAuditSummaryLines(options),
|
|
119
|
+
groups: [
|
|
120
|
+
formatEntryGroup(
|
|
121
|
+
"Files to remove",
|
|
122
|
+
options.auditReport.removableFiles,
|
|
123
|
+
(entry) => `${formatPath(entry)} (${entry.reason})`
|
|
124
|
+
),
|
|
125
|
+
formatEntryGroup(
|
|
126
|
+
"Directories to prune",
|
|
127
|
+
options.auditReport.prunableDirectories,
|
|
128
|
+
(entry) => `${formatPath(entry)} (${entry.reason})`
|
|
129
|
+
),
|
|
130
|
+
formatEntryGroup(
|
|
131
|
+
"Preserved paths",
|
|
132
|
+
options.auditReport.preservedPaths,
|
|
133
|
+
(entry) => `${formatPath(entry)} (${entry.reason})`
|
|
134
|
+
),
|
|
135
|
+
formatEntryGroup(
|
|
136
|
+
"Skipped paths",
|
|
137
|
+
options.auditReport.skippedPaths,
|
|
138
|
+
(entry) => `${formatPath(entry)} (${entry.reason})`
|
|
139
|
+
)
|
|
140
|
+
]
|
|
141
|
+
});
|
|
142
|
+
},
|
|
143
|
+
confirmUninstallRun(options) {
|
|
144
|
+
const message = options.backupRequested ? "Create the backup and then remove these audited paths? This action cannot be undone." : "Remove these audited paths? This action cannot be undone.";
|
|
145
|
+
return confirmLifecycleCheckpoint({
|
|
146
|
+
permissions: options.permissions,
|
|
147
|
+
message,
|
|
148
|
+
ttyError: "Uninstall confirmation requires a TTY. Re-run with `make-docs setup remove --yes`."
|
|
149
|
+
});
|
|
150
|
+
},
|
|
151
|
+
renderUninstallCancelled() {
|
|
152
|
+
Gt("Uninstall cancelled. No files were changed.");
|
|
153
|
+
},
|
|
154
|
+
renderUninstallCompletionSummary(options) {
|
|
155
|
+
Vt(
|
|
156
|
+
[
|
|
157
|
+
`Files removed: ${options.removedFiles.length}`,
|
|
158
|
+
`Directories pruned: ${options.prunedDirectories.length}`,
|
|
159
|
+
`Preserved paths: ${options.auditReport.preservedPaths.length}`,
|
|
160
|
+
`Skipped paths: ${options.auditReport.skippedPaths.length}`,
|
|
161
|
+
`Backup: ${formatBackupStatus(options.backupResult)}`
|
|
162
|
+
].join("\n"),
|
|
163
|
+
"Uninstall complete"
|
|
164
|
+
);
|
|
165
|
+
},
|
|
166
|
+
renderUninstallFailureSummary(options) {
|
|
167
|
+
Vt(
|
|
168
|
+
[
|
|
169
|
+
`Files removed before failure: ${options.removedFiles.length}`,
|
|
170
|
+
`Directories pruned before failure: ${options.prunedDirectories.length}`,
|
|
171
|
+
`Preserved paths: ${options.auditReport.preservedPaths.length}`,
|
|
172
|
+
`Skipped paths: ${options.auditReport.skippedPaths.length}`,
|
|
173
|
+
`Backup: ${formatBackupStatus(options.backupResult)}`,
|
|
174
|
+
`Error: ${options.errorMessage}`
|
|
175
|
+
].join("\n"),
|
|
176
|
+
"Uninstall partially completed"
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
function getLifecycleRenderer() {
|
|
182
|
+
return lifecycleRenderer;
|
|
183
|
+
}
|
|
184
|
+
function buildBackupAuditSummaryLines(options) {
|
|
185
|
+
const { auditReport, destinationDir } = options;
|
|
186
|
+
return [
|
|
187
|
+
`Target: ${auditReport.targetDir}`,
|
|
188
|
+
`Destination: ${destinationDir ?? "(no backup directory will be created)"}`,
|
|
189
|
+
...formatSkillSelectionReview(auditReport.skillSelectionReview),
|
|
190
|
+
...formatPluginSelectionReview(auditReport.pluginSelectionReview),
|
|
191
|
+
`Files to copy: ${options.copyableFiles.length}`,
|
|
192
|
+
`Directories to materialize: ${options.materializableDirectories.length}`,
|
|
193
|
+
`Retained: ${auditReport.preservedPaths.length}`,
|
|
194
|
+
`Skipped: ${auditReport.skippedPaths.length}`
|
|
195
|
+
];
|
|
196
|
+
}
|
|
197
|
+
function buildUninstallAuditSummaryLines(options) {
|
|
198
|
+
const { auditReport, backupDestinationDir } = options;
|
|
199
|
+
return [
|
|
200
|
+
`Target: ${auditReport.targetDir}`,
|
|
201
|
+
`Backup before removal: ${backupDestinationDir ?? "not requested"}`,
|
|
202
|
+
...formatSkillSelectionReview(auditReport.skillSelectionReview),
|
|
203
|
+
...formatPluginSelectionReview(auditReport.pluginSelectionReview),
|
|
204
|
+
`Files to remove: ${auditReport.removableFiles.length}`,
|
|
205
|
+
`Directories to prune: ${auditReport.prunableDirectories.length}`,
|
|
206
|
+
`Preserved: ${auditReport.preservedPaths.length}`,
|
|
207
|
+
`Skipped: ${auditReport.skippedPaths.length}`
|
|
208
|
+
];
|
|
209
|
+
}
|
|
210
|
+
function renderAuditNote(options) {
|
|
211
|
+
Vt(
|
|
212
|
+
[...options.lines, "", ...formatEntryGroups(options.groups)].join("\n"),
|
|
213
|
+
options.title
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
function formatEntryGroups(groups) {
|
|
217
|
+
return groups.flatMap(
|
|
218
|
+
(group, index) => index === 0 ? group : ["", ...group]
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
function formatEntryGroup(title, entries, formatter = formatPath) {
|
|
222
|
+
if (entries.length === 0) {
|
|
223
|
+
return [`${title}:`, "- none"];
|
|
224
|
+
}
|
|
225
|
+
return [`${title}:`, ...entries.map((entry) => `- ${formatter(entry)}`)];
|
|
226
|
+
}
|
|
227
|
+
function formatPath(entry) {
|
|
228
|
+
return entry.path;
|
|
229
|
+
}
|
|
230
|
+
function formatBackupStatus(result) {
|
|
231
|
+
if (!result) {
|
|
232
|
+
return "not requested";
|
|
233
|
+
}
|
|
234
|
+
if (result.status === "completed" && result.destinationDir) {
|
|
235
|
+
return `created at ${result.destinationDir}`;
|
|
236
|
+
}
|
|
237
|
+
if (result.status === "noop") {
|
|
238
|
+
return "requested, but no backup files or directories needed to be created";
|
|
239
|
+
}
|
|
240
|
+
return "requested";
|
|
241
|
+
}
|
|
242
|
+
function formatSkillSelectionReview(review) {
|
|
243
|
+
if (!review) {
|
|
244
|
+
return [];
|
|
245
|
+
}
|
|
246
|
+
if (!review.skillsEnabled) {
|
|
247
|
+
return ["Skills: disabled"];
|
|
248
|
+
}
|
|
249
|
+
const provenance = review.skillSelectionProvenance.length === 0 ? "(no saved provenance metadata)" : review.skillSelectionProvenance.map(
|
|
250
|
+
(entry) => `${entry.skillName}: ${entry.provenanceLabel} (${entry.provenanceKind})`
|
|
251
|
+
).join("; ");
|
|
252
|
+
return [
|
|
253
|
+
`Skills: enabled (${review.skillScope})`,
|
|
254
|
+
`Skills manifest: ${formatSkillManifestSource(review.skillManifest)}`,
|
|
255
|
+
`Selected skills: ${formatSelectedSkills(review.selectedSkills)}`,
|
|
256
|
+
`Skill provenance: ${provenance}`
|
|
257
|
+
];
|
|
258
|
+
}
|
|
259
|
+
function formatSkillManifestSource(source) {
|
|
260
|
+
if (!source) {
|
|
261
|
+
return "(legacy selections; no manifest provenance)";
|
|
262
|
+
}
|
|
263
|
+
if (source.source === "file") {
|
|
264
|
+
return `${source.displayName} (local file: ${source.path ?? "unknown path"})`;
|
|
265
|
+
}
|
|
266
|
+
if (source.source === "remote-pinned") {
|
|
267
|
+
return `${source.displayName} (remote pinned: ${source.digest ?? "missing digest"})`;
|
|
268
|
+
}
|
|
269
|
+
return `${source.displayName} (built-in)`;
|
|
270
|
+
}
|
|
271
|
+
function formatSelectedSkills(selectedSkills) {
|
|
272
|
+
return selectedSkills.length === 0 ? "(none)" : selectedSkills.join(", ");
|
|
273
|
+
}
|
|
274
|
+
function formatPluginSelectionReview(review) {
|
|
275
|
+
if (!review) {
|
|
276
|
+
return [];
|
|
277
|
+
}
|
|
278
|
+
if (!review.pluginsEnabled) {
|
|
279
|
+
return ["Plugins: disabled"];
|
|
280
|
+
}
|
|
281
|
+
const provenance = review.pluginSelectionProvenance.length === 0 ? "(no saved provenance metadata)" : review.pluginSelectionProvenance.map(
|
|
282
|
+
(entry) => `${entry.pluginId}: ${entry.provenanceLabel} (${entry.provenanceKind})`
|
|
283
|
+
).join("; ");
|
|
284
|
+
return [
|
|
285
|
+
`Plugins: enabled (${review.pluginScope})`,
|
|
286
|
+
`Plugin manifest: ${formatPluginManifestSource(review.pluginManifest)}`,
|
|
287
|
+
`Selected plugins: ${formatSelectedPlugins(review.selectedPlugins)}`,
|
|
288
|
+
`Plugin provenance: ${provenance}`
|
|
289
|
+
];
|
|
290
|
+
}
|
|
291
|
+
function formatPluginManifestSource(source) {
|
|
292
|
+
if (!source) {
|
|
293
|
+
return "(legacy selections; no manifest provenance)";
|
|
294
|
+
}
|
|
295
|
+
if (source.source === "file") {
|
|
296
|
+
return `${source.displayName} (local file: ${source.path ?? "unknown path"})`;
|
|
297
|
+
}
|
|
298
|
+
if (source.source === "remote-pinned") {
|
|
299
|
+
return `${source.displayName} (remote pinned: ${source.digest ?? "missing digest"})`;
|
|
300
|
+
}
|
|
301
|
+
return `${source.displayName} (built-in)`;
|
|
302
|
+
}
|
|
303
|
+
function formatSelectedPlugins(selectedPlugins) {
|
|
304
|
+
return selectedPlugins.length === 0 ? "(none)" : selectedPlugins.join(", ");
|
|
305
|
+
}
|
|
306
|
+
async function confirmLifecycleCheckpoint(options) {
|
|
307
|
+
if (options.permissions === "allow-all") {
|
|
308
|
+
return true;
|
|
309
|
+
}
|
|
310
|
+
if (!input.isTTY || !output.isTTY) {
|
|
311
|
+
throw new Error(options.ttyError);
|
|
312
|
+
}
|
|
313
|
+
const proceed = await Rt({
|
|
314
|
+
message: options.message,
|
|
315
|
+
initialValue: true,
|
|
316
|
+
active: "Yes",
|
|
317
|
+
inactive: "No",
|
|
318
|
+
withGuide: true
|
|
319
|
+
});
|
|
320
|
+
return !(Ct(proceed) || !proceed);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
// src/backup.ts
|
|
324
|
+
function compareBackupRelativePathDepth(left, right) {
|
|
325
|
+
const depth = (value) => value.split(/[\\/]+/u).filter(Boolean).length;
|
|
326
|
+
return depth(left) - depth(right);
|
|
327
|
+
}
|
|
328
|
+
async function runBackupCommand(options) {
|
|
329
|
+
const renderer = getLifecycleRenderer();
|
|
330
|
+
renderer.beginWorkflow("make-docs setup backup");
|
|
331
|
+
const preparedBackup = await prepareBackupExecution(options);
|
|
332
|
+
renderer.renderBackupAuditSummary({
|
|
333
|
+
auditReport: preparedBackup.auditReport,
|
|
334
|
+
destinationDir: preparedBackup.destinationPlan?.destinationDir ?? null,
|
|
335
|
+
copyableFiles: preparedBackup.copyableFiles,
|
|
336
|
+
materializableDirectories: preparedBackup.materializableDirectories
|
|
337
|
+
});
|
|
338
|
+
if (!hasBackupWork(preparedBackup)) {
|
|
339
|
+
renderer.renderBackupNoopSummary();
|
|
340
|
+
return createNoopBackupResult(preparedBackup);
|
|
341
|
+
}
|
|
342
|
+
const destinationPlan = preparedBackup.destinationPlan;
|
|
343
|
+
if (!destinationPlan) {
|
|
344
|
+
throw new Error(
|
|
345
|
+
"Backup destination plan is required when audited entries are copyable."
|
|
346
|
+
);
|
|
347
|
+
}
|
|
348
|
+
const shouldProceed = await renderer.confirmBackupRun(options.permissions);
|
|
349
|
+
if (!shouldProceed) {
|
|
350
|
+
renderer.renderBackupCancelled();
|
|
351
|
+
return {
|
|
352
|
+
status: "cancelled",
|
|
353
|
+
targetDir: preparedBackup.targetDir,
|
|
354
|
+
destinationDir: destinationPlan.destinationDir,
|
|
355
|
+
auditReport: preparedBackup.auditReport,
|
|
356
|
+
copiedFiles: [],
|
|
357
|
+
materializedDirectories: []
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
const result = executePreparedBackup(preparedBackup);
|
|
361
|
+
renderer.renderBackupCompletionSummary(result);
|
|
362
|
+
return result;
|
|
363
|
+
}
|
|
364
|
+
async function prepareBackupExecution(options) {
|
|
365
|
+
const targetDir = path.resolve(options.targetDir);
|
|
366
|
+
const homeDir = path.resolve(options.homeDir ?? os.homedir());
|
|
367
|
+
const auditReport = options.auditReport ?? await createAuditReport({
|
|
368
|
+
targetDir,
|
|
369
|
+
manifest: loadManifest(targetDir),
|
|
370
|
+
homeDir
|
|
371
|
+
});
|
|
372
|
+
const copyableFiles = auditReport.removableFiles.filter(hasBackupRelativePath);
|
|
373
|
+
const materializableDirectories = auditReport.prunableDirectories.filter(
|
|
374
|
+
hasBackupRelativePath
|
|
375
|
+
);
|
|
376
|
+
const materializableManagedDirectories = auditReport.removableFiles.filter((entry) => entry.kind === "directory").filter(hasBackupRelativePath).map((entry) => ({
|
|
377
|
+
...entry,
|
|
378
|
+
kind: "directory",
|
|
379
|
+
removableDescendantPaths: [],
|
|
380
|
+
preservedDescendantPaths: []
|
|
381
|
+
}));
|
|
382
|
+
const hasCopyableEntries = copyableFiles.length > 0 || materializableDirectories.length > 0 || materializableManagedDirectories.length > 0;
|
|
383
|
+
const hasProvidedDestinationPlan = Object.hasOwn(options, "destinationPlan");
|
|
384
|
+
const destinationPlan = hasCopyableEntries ? hasProvidedDestinationPlan ? options.destinationPlan ?? null : resolveBackupDestinationPlan(targetDir, options.now ?? /* @__PURE__ */ new Date()) : null;
|
|
385
|
+
if (hasCopyableEntries && !destinationPlan) {
|
|
386
|
+
throw new Error(
|
|
387
|
+
"Backup destination plan is required when audited entries are copyable."
|
|
388
|
+
);
|
|
389
|
+
}
|
|
390
|
+
return {
|
|
391
|
+
targetDir,
|
|
392
|
+
auditReport,
|
|
393
|
+
destinationPlan,
|
|
394
|
+
copyableFiles: copyableFiles.filter((entry) => entry.kind === "file"),
|
|
395
|
+
materializableDirectories: [
|
|
396
|
+
...materializableDirectories,
|
|
397
|
+
...materializableManagedDirectories
|
|
398
|
+
]
|
|
399
|
+
};
|
|
400
|
+
}
|
|
401
|
+
function executePreparedBackup(preparedBackup) {
|
|
402
|
+
if (!hasBackupWork(preparedBackup)) {
|
|
403
|
+
return createNoopBackupResult(preparedBackup);
|
|
404
|
+
}
|
|
405
|
+
if (!preparedBackup.destinationPlan) {
|
|
406
|
+
throw new Error(
|
|
407
|
+
"Backup destination plan is required before copying audited backup entries."
|
|
408
|
+
);
|
|
409
|
+
}
|
|
410
|
+
return withInstallationOperation(preparedBackup.targetDir, "setup.backup", () => {
|
|
411
|
+
const targetDir = preparedBackup.targetDir;
|
|
412
|
+
const destination = preparedBackup.destinationPlan.destinationDir;
|
|
413
|
+
if (preparedBackup.destinationPlan.promotion) throw new Error("Create a fresh backup plan. Existing backup paths must remain stable.");
|
|
414
|
+
if (existsSync(destination)) throw new Error(`Backup destination already exists: ${destination}. Re-run the command to resolve a fresh destination.`);
|
|
415
|
+
const changes = [preparePlannedFileChange(targetDir, path.relative(targetDir, destination), { kind: "directory" }, () => mkdirSync(destination, { recursive: true }))];
|
|
416
|
+
const copiedFiles = [];
|
|
417
|
+
const materializedDirectories = [];
|
|
418
|
+
for (const directory of [...preparedBackup.materializableDirectories].sort((a, b) => compareBackupRelativePathDepth(a.backupRelativePath, b.backupRelativePath))) {
|
|
419
|
+
const relative = directory.backupRelativePath;
|
|
420
|
+
if (!relative || relative === ".") continue;
|
|
421
|
+
const absolute = path.join(destination, relative);
|
|
422
|
+
changes.push(preparePlannedFileChange(targetDir, path.relative(targetDir, absolute), { kind: "directory" }, () => mkdirSync(absolute, { recursive: true })));
|
|
423
|
+
materializedDirectories.push(relative);
|
|
424
|
+
}
|
|
425
|
+
for (const file of preparedBackup.copyableFiles) {
|
|
426
|
+
const destinationPath = path.join(destination, file.backupRelativePath);
|
|
427
|
+
const content = readFileSync(file.absolutePath);
|
|
428
|
+
changes.push(preparePlannedFileChange(targetDir, path.relative(targetDir, destinationPath), { kind: "file", content }, () => {
|
|
429
|
+
ensureParentDir(destinationPath);
|
|
430
|
+
copyFileSync(file.absolutePath, destinationPath);
|
|
431
|
+
}));
|
|
432
|
+
copiedFiles.push(file.backupRelativePath);
|
|
433
|
+
}
|
|
434
|
+
sealInstallationOperation(targetDir);
|
|
435
|
+
for (const change of changes) change();
|
|
436
|
+
return {
|
|
437
|
+
status: "completed",
|
|
438
|
+
targetDir: preparedBackup.targetDir,
|
|
439
|
+
destinationDir: preparedBackup.destinationPlan.destinationDir,
|
|
440
|
+
auditReport: preparedBackup.auditReport,
|
|
441
|
+
copiedFiles,
|
|
442
|
+
materializedDirectories
|
|
443
|
+
};
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
function resolveBackupDestinationPlan(targetDir, now) {
|
|
447
|
+
const backupRoot = getProjectBackupRoot(targetDir);
|
|
448
|
+
const dateStamp = formatDateStamp(now);
|
|
449
|
+
const plainDirectory = path.join(backupRoot, dateStamp);
|
|
450
|
+
const existingOrdinals = collectExistingOrdinals(backupRoot, dateStamp);
|
|
451
|
+
const hasPlainDirectory = existsSync(plainDirectory);
|
|
452
|
+
if (!hasPlainDirectory && existingOrdinals.length === 0) {
|
|
453
|
+
return {
|
|
454
|
+
backupRoot,
|
|
455
|
+
dateStamp,
|
|
456
|
+
directoryName: dateStamp,
|
|
457
|
+
destinationDir: plainDirectory
|
|
458
|
+
};
|
|
459
|
+
}
|
|
460
|
+
const usedOrdinals = new Set(existingOrdinals);
|
|
461
|
+
let promotion;
|
|
462
|
+
if (hasPlainDirectory) usedOrdinals.add(0);
|
|
463
|
+
const nextOrdinal = Math.max(...usedOrdinals, 0) + 1;
|
|
464
|
+
const directoryName = `${dateStamp}-${formatOrdinal(nextOrdinal)}`;
|
|
465
|
+
return {
|
|
466
|
+
backupRoot,
|
|
467
|
+
dateStamp,
|
|
468
|
+
directoryName,
|
|
469
|
+
destinationDir: path.join(backupRoot, directoryName),
|
|
470
|
+
promotion
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
function collectExistingOrdinals(backupRoot, dateStamp) {
|
|
474
|
+
if (!existsSync(backupRoot)) {
|
|
475
|
+
return [];
|
|
476
|
+
}
|
|
477
|
+
const pattern = new RegExp(`^${escapeRegExp(dateStamp)}-(\\d+)$`);
|
|
478
|
+
return readdirSync(backupRoot).map((entryName) => {
|
|
479
|
+
const match = pattern.exec(entryName);
|
|
480
|
+
if (!match) {
|
|
481
|
+
return null;
|
|
482
|
+
}
|
|
483
|
+
return Number.parseInt(match[1] ?? "", 10);
|
|
484
|
+
}).filter((value) => Number.isInteger(value)).sort((left, right) => left - right);
|
|
485
|
+
}
|
|
486
|
+
function hasBackupRelativePath(entry) {
|
|
487
|
+
return typeof entry.backupRelativePath === "string";
|
|
488
|
+
}
|
|
489
|
+
function hasBackupWork(preparedBackup) {
|
|
490
|
+
return preparedBackup.copyableFiles.length > 0 || preparedBackup.materializableDirectories.length > 0;
|
|
491
|
+
}
|
|
492
|
+
function createNoopBackupResult(preparedBackup) {
|
|
493
|
+
return {
|
|
494
|
+
status: "noop",
|
|
495
|
+
targetDir: preparedBackup.targetDir,
|
|
496
|
+
destinationDir: null,
|
|
497
|
+
auditReport: preparedBackup.auditReport,
|
|
498
|
+
copiedFiles: [],
|
|
499
|
+
materializedDirectories: []
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
function formatDateStamp(now) {
|
|
503
|
+
const year = now.getFullYear();
|
|
504
|
+
const month = String(now.getMonth() + 1).padStart(2, "0");
|
|
505
|
+
const day = String(now.getDate()).padStart(2, "0");
|
|
506
|
+
return `${year}-${month}-${day}`;
|
|
507
|
+
}
|
|
508
|
+
function formatOrdinal(ordinal) {
|
|
509
|
+
return String(ordinal).padStart(2, "0");
|
|
510
|
+
}
|
|
511
|
+
function escapeRegExp(value) {
|
|
512
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
export {
|
|
516
|
+
getLifecycleRenderer,
|
|
517
|
+
compareBackupRelativePathDepth,
|
|
518
|
+
runBackupCommand,
|
|
519
|
+
prepareBackupExecution,
|
|
520
|
+
executePreparedBackup,
|
|
521
|
+
resolveBackupDestinationPlan
|
|
522
|
+
};
|
|
523
|
+
//# sourceMappingURL=chunk-GNP6HRVP.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/backup.ts","../src/lifecycle-ui.ts"],"sourcesContent":["import {\n copyFileSync,\n existsSync,\n mkdirSync,\n readdirSync,\n readFileSync,\n} from \"node:fs\";\nimport os from \"node:os\";\nimport path from \"node:path\";\nimport { preparePlannedFileChange, sealInstallationOperation, withInstallationOperation } from \"./store/installation-state\";\nimport { createAuditReport } from \"./audit\";\nimport { getProjectBackupRoot } from \"./backup-paths\";\nimport { getLifecycleRenderer } from \"./lifecycle-ui\";\nimport { loadManifest } from \"./manifest\";\nimport type {\n AuditReport,\n AuditPrunableDirectory,\n AuditRemovableFile,\n BackupCommandOptions,\n BackupDestinationPlan,\n BackupExecutionResult,\n} from \"./types\";\nimport { ensureParentDir } from \"./utils\";\n\ntype CopyableAuditRemovableFile = AuditRemovableFile & {\n backupRelativePath: string;\n};\n\ntype MaterializableAuditDirectory = AuditPrunableDirectory & {\n backupRelativePath: string;\n};\n\nexport type PrepareBackupExecutionOptions = {\n targetDir: string;\n homeDir?: string;\n now?: Date;\n auditReport?: AuditReport;\n destinationPlan?: BackupDestinationPlan | null;\n};\n\nexport type PreparedBackupExecution = {\n targetDir: string;\n auditReport: AuditReport;\n destinationPlan: BackupDestinationPlan | null;\n copyableFiles: CopyableAuditRemovableFile[];\n materializableDirectories: MaterializableAuditDirectory[];\n};\n\nexport function compareBackupRelativePathDepth(\n left: string,\n right: string,\n): number {\n const depth = (value: string) => value.split(/[\\\\/]+/u).filter(Boolean).length;\n return depth(left) - depth(right);\n}\n\nexport async function runBackupCommand(\n options: BackupCommandOptions,\n): Promise<BackupExecutionResult> {\n const renderer = getLifecycleRenderer();\n renderer.beginWorkflow(\"make-docs setup backup\");\n const preparedBackup = await prepareBackupExecution(options);\n\n renderer.renderBackupAuditSummary({\n auditReport: preparedBackup.auditReport,\n destinationDir: preparedBackup.destinationPlan?.destinationDir ?? null,\n copyableFiles: preparedBackup.copyableFiles,\n materializableDirectories: preparedBackup.materializableDirectories,\n });\n\n if (!hasBackupWork(preparedBackup)) {\n renderer.renderBackupNoopSummary();\n return createNoopBackupResult(preparedBackup);\n }\n\n const destinationPlan = preparedBackup.destinationPlan;\n if (!destinationPlan) {\n throw new Error(\n \"Backup destination plan is required when audited entries are copyable.\",\n );\n }\n\n const shouldProceed = await renderer.confirmBackupRun(options.permissions);\n if (!shouldProceed) {\n renderer.renderBackupCancelled();\n return {\n status: \"cancelled\",\n targetDir: preparedBackup.targetDir,\n destinationDir: destinationPlan.destinationDir,\n auditReport: preparedBackup.auditReport,\n copiedFiles: [],\n materializedDirectories: [],\n };\n }\n\n const result = executePreparedBackup(preparedBackup);\n renderer.renderBackupCompletionSummary(result);\n return result;\n}\n\nexport async function prepareBackupExecution(\n options: PrepareBackupExecutionOptions,\n): Promise<PreparedBackupExecution> {\n const targetDir = path.resolve(options.targetDir);\n const homeDir = path.resolve(options.homeDir ?? os.homedir());\n const auditReport =\n options.auditReport ??\n (await createAuditReport({\n targetDir,\n manifest: loadManifest(targetDir),\n homeDir,\n }));\n\n const copyableFiles = auditReport.removableFiles.filter(hasBackupRelativePath);\n const materializableDirectories = auditReport.prunableDirectories.filter(\n hasBackupRelativePath,\n );\n const materializableManagedDirectories = auditReport.removableFiles\n .filter((entry) => entry.kind === \"directory\")\n .filter(hasBackupRelativePath)\n .map((entry): MaterializableAuditDirectory => ({\n ...entry,\n kind: \"directory\",\n removableDescendantPaths: [],\n preservedDescendantPaths: [],\n }));\n const hasCopyableEntries =\n copyableFiles.length > 0 ||\n materializableDirectories.length > 0 ||\n materializableManagedDirectories.length > 0;\n const hasProvidedDestinationPlan = Object.hasOwn(options, \"destinationPlan\");\n const destinationPlan = hasCopyableEntries\n ? hasProvidedDestinationPlan\n ? options.destinationPlan ?? null\n : resolveBackupDestinationPlan(targetDir, options.now ?? new Date())\n : null;\n\n if (hasCopyableEntries && !destinationPlan) {\n throw new Error(\n \"Backup destination plan is required when audited entries are copyable.\",\n );\n }\n\n return {\n targetDir,\n auditReport,\n destinationPlan,\n copyableFiles: copyableFiles.filter((entry) => entry.kind === \"file\"),\n materializableDirectories: [\n ...materializableDirectories,\n ...materializableManagedDirectories,\n ],\n };\n}\n\nexport function executePreparedBackup(\n preparedBackup: PreparedBackupExecution,\n): BackupExecutionResult {\n if (!hasBackupWork(preparedBackup)) {\n return createNoopBackupResult(preparedBackup);\n }\n\n if (!preparedBackup.destinationPlan) {\n throw new Error(\n \"Backup destination plan is required before copying audited backup entries.\",\n );\n }\n\n return withInstallationOperation(preparedBackup.targetDir, \"setup.backup\", () => {\n const targetDir = preparedBackup.targetDir;\n const destination = preparedBackup.destinationPlan!.destinationDir;\n if (preparedBackup.destinationPlan!.promotion) throw new Error(\"Create a fresh backup plan. Existing backup paths must remain stable.\");\n if (existsSync(destination)) throw new Error(`Backup destination already exists: ${destination}. Re-run the command to resolve a fresh destination.`);\n const changes: Array<() => void> = [preparePlannedFileChange(targetDir, path.relative(targetDir, destination), { kind: \"directory\" }, () => mkdirSync(destination, { recursive: true }))];\n const copiedFiles: string[] = [];\n const materializedDirectories: string[] = [];\n for (const directory of [...preparedBackup.materializableDirectories].sort((a, b) =>\n compareBackupRelativePathDepth(a.backupRelativePath, b.backupRelativePath))) {\n const relative = directory.backupRelativePath;\n if (!relative || relative === \".\") continue;\n const absolute = path.join(destination, relative);\n changes.push(preparePlannedFileChange(targetDir, path.relative(targetDir, absolute), { kind: \"directory\" }, () => mkdirSync(absolute, { recursive: true })));\n materializedDirectories.push(relative);\n }\n for (const file of preparedBackup.copyableFiles) {\n const destinationPath = path.join(destination, file.backupRelativePath);\n const content = readFileSync(file.absolutePath);\n changes.push(preparePlannedFileChange(targetDir, path.relative(targetDir, destinationPath), { kind: \"file\", content }, () => {\n ensureParentDir(destinationPath);\n copyFileSync(file.absolutePath, destinationPath);\n }));\n copiedFiles.push(file.backupRelativePath);\n }\n sealInstallationOperation(targetDir);\n for (const change of changes) change();\n\n return {\n status: \"completed\",\n targetDir: preparedBackup.targetDir,\n destinationDir: preparedBackup.destinationPlan!.destinationDir,\n auditReport: preparedBackup.auditReport,\n copiedFiles,\n materializedDirectories,\n };\n });\n}\n\nexport function resolveBackupDestinationPlan(\n targetDir: string,\n now: Date,\n): BackupDestinationPlan {\n const backupRoot = getProjectBackupRoot(targetDir);\n const dateStamp = formatDateStamp(now);\n const plainDirectory = path.join(backupRoot, dateStamp);\n const existingOrdinals = collectExistingOrdinals(backupRoot, dateStamp);\n const hasPlainDirectory = existsSync(plainDirectory);\n\n if (!hasPlainDirectory && existingOrdinals.length === 0) {\n return {\n backupRoot,\n dateStamp,\n directoryName: dateStamp,\n destinationDir: plainDirectory,\n };\n }\n\n const usedOrdinals = new Set(existingOrdinals);\n let promotion: BackupDestinationPlan[\"promotion\"];\n\n // A completed backup path is a durable payload reference. Never rename it.\n if (hasPlainDirectory) usedOrdinals.add(0);\n\n const nextOrdinal = Math.max(...usedOrdinals, 0) + 1;\n const directoryName = `${dateStamp}-${formatOrdinal(nextOrdinal)}`;\n\n return {\n backupRoot,\n dateStamp,\n directoryName,\n destinationDir: path.join(backupRoot, directoryName),\n promotion,\n };\n}\n\nfunction collectExistingOrdinals(backupRoot: string, dateStamp: string): number[] {\n if (!existsSync(backupRoot)) {\n return [];\n }\n\n const pattern = new RegExp(`^${escapeRegExp(dateStamp)}-(\\\\d+)$`);\n return readdirSync(backupRoot)\n .map((entryName) => {\n const match = pattern.exec(entryName);\n if (!match) {\n return null;\n }\n\n return Number.parseInt(match[1] ?? \"\", 10);\n })\n .filter((value): value is number => Number.isInteger(value))\n .sort((left, right) => left - right);\n}\n\nfunction findLowestAvailableOrdinal(usedOrdinals: Set<number>): number {\n let ordinal = 1;\n while (usedOrdinals.has(ordinal)) {\n ordinal += 1;\n }\n return ordinal;\n}\n\nfunction hasBackupRelativePath<T extends { backupRelativePath: string | null }>(\n entry: T,\n): entry is T & { backupRelativePath: string } {\n return typeof entry.backupRelativePath === \"string\";\n}\n\nfunction hasBackupWork(preparedBackup: PreparedBackupExecution): boolean {\n return (\n preparedBackup.copyableFiles.length > 0 ||\n preparedBackup.materializableDirectories.length > 0\n );\n}\n\nfunction createNoopBackupResult(\n preparedBackup: PreparedBackupExecution,\n): BackupExecutionResult {\n return {\n status: \"noop\",\n targetDir: preparedBackup.targetDir,\n destinationDir: null,\n auditReport: preparedBackup.auditReport,\n copiedFiles: [],\n materializedDirectories: [],\n };\n}\n\nfunction formatDateStamp(now: Date): string {\n const year = now.getFullYear();\n const month = String(now.getMonth() + 1).padStart(2, \"0\");\n const day = String(now.getDate()).padStart(2, \"0\");\n return `${year}-${month}-${day}`;\n}\n\nfunction formatOrdinal(ordinal: number): string {\n return String(ordinal).padStart(2, \"0\");\n}\n\nfunction escapeRegExp(value: string): string {\n return value.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n","import { stdin as input, stdout as output } from \"node:process\";\nimport { confirm, intro, isCancel, note, outro } from \"@clack/prompts\";\nimport type {\n AuditPathMetadata,\n AuditPluginSelectionReview,\n AuditPreservedPath,\n AuditPrunableDirectory,\n AuditRemovableFile,\n AuditReport,\n AuditSkillSelectionReview,\n AuditSkippedPath,\n BackupExecutionResult,\n LifecyclePermissionsMode,\n PluginManifestSelectionSource,\n SkillManifestSelectionSource,\n} from \"./types\";\n\ntype LifecycleRenderableEntry =\n | AuditRemovableFile\n | AuditPrunableDirectory\n | AuditPreservedPath\n | AuditSkippedPath;\n\nexport type LifecycleAuditSummaryOptions = {\n auditReport: AuditReport;\n destinationDir: string | null;\n copyableFiles: AuditRemovableFile[];\n materializableDirectories: AuditPrunableDirectory[];\n};\n\nexport type LifecycleUninstallWarningOptions = {\n targetDir: string;\n backupDestinationDir: string | null;\n};\n\nexport type LifecycleUninstallAuditSummaryOptions = {\n auditReport: AuditReport;\n backupDestinationDir: string | null;\n};\n\nexport type LifecycleUninstallRunConfirmationOptions = {\n permissions: LifecyclePermissionsMode;\n backupRequested: boolean;\n};\n\nexport type LifecycleUninstallCompletionSummaryOptions = {\n auditReport: AuditReport;\n removedFiles: string[];\n prunedDirectories: string[];\n backupResult: BackupExecutionResult | null;\n};\n\nexport type LifecycleUninstallFailureSummaryOptions =\n LifecycleUninstallCompletionSummaryOptions & {\n errorMessage: string;\n };\n\nexport interface LifecycleRenderer {\n beginWorkflow(title: string): void;\n renderBackupAuditSummary(options: LifecycleAuditSummaryOptions): void;\n confirmBackupRun(permissions: LifecyclePermissionsMode): Promise<boolean>;\n renderBackupNoopSummary(): void;\n renderBackupCancelled(): void;\n renderBackupCompletionSummary(result: BackupExecutionResult): void;\n renderUninstallWarning(options: LifecycleUninstallWarningOptions): void;\n confirmUninstallWarning(\n permissions: LifecyclePermissionsMode,\n ): Promise<boolean>;\n renderUninstallAuditSummary(\n options: LifecycleUninstallAuditSummaryOptions,\n ): void;\n confirmUninstallRun(\n options: LifecycleUninstallRunConfirmationOptions,\n ): Promise<boolean>;\n renderUninstallCancelled(): void;\n renderUninstallCompletionSummary(\n options: LifecycleUninstallCompletionSummaryOptions,\n ): void;\n renderUninstallFailureSummary(\n options: LifecycleUninstallFailureSummaryOptions,\n ): void;\n}\n\nlet lifecycleRenderer: LifecycleRenderer = createClackLifecycleRenderer();\n\nexport function createClackLifecycleRenderer(): LifecycleRenderer {\n return {\n beginWorkflow(title) {\n intro(title);\n },\n renderBackupAuditSummary(options) {\n renderAuditNote({\n title: \"make-docs setup backup\",\n lines: buildBackupAuditSummaryLines(options),\n groups: [\n formatEntryGroup(\n \"Files to copy\",\n options.copyableFiles,\n (entry) => `${formatPath(entry)} (${entry.reason})`,\n ),\n formatEntryGroup(\n \"Directories to materialize\",\n options.materializableDirectories,\n ),\n formatEntryGroup(\n \"Retained paths\",\n options.auditReport.preservedPaths,\n (entry) => `${formatPath(entry)} (${entry.reason})`,\n ),\n formatEntryGroup(\n \"Skipped paths\",\n options.auditReport.skippedPaths,\n (entry) => `${formatPath(entry)} (${entry.reason})`,\n ),\n ],\n });\n },\n confirmBackupRun(permissions) {\n return confirmLifecycleCheckpoint({\n permissions,\n message: \"Create this backup?\",\n ttyError:\n \"Backup confirmation requires a TTY. Re-run with `make-docs setup backup --yes`.\",\n });\n },\n renderBackupNoopSummary() {\n outro(\n \"No make-docs-managed files required backup. No backup destination was created.\",\n );\n },\n renderBackupCancelled() {\n outro(\"Backup cancelled.\");\n },\n renderBackupCompletionSummary(result) {\n if (result.status !== \"completed\" || !result.destinationDir) {\n return;\n }\n\n note(\n [\n `Destination: ${result.destinationDir}`,\n `Copied files: ${result.copiedFiles.length}`,\n `Materialized directories: ${result.materializedDirectories.length}`,\n `Retained paths surfaced: ${result.auditReport.preservedPaths.length}`,\n `Skipped paths surfaced: ${result.auditReport.skippedPaths.length}`,\n ].join(\"\\n\"),\n \"Backup complete\",\n );\n },\n renderUninstallWarning(options) {\n const lines = [\"This command removes audited make-docs-managed paths\", \"\"];\n\n if (options.backupDestinationDir) {\n lines.push(\"A backup will be created before removal begins.\");\n lines.push(`Backup destination: ${options.backupDestinationDir}`);\n } else {\n lines.push(\"Safer alternative: make-docs setup backup\");\n lines.push(\"Safer destructive flow: make-docs setup remove --backup\");\n }\n\n note(lines.join(\"\\n\"), \"WARNING\");\n },\n confirmUninstallWarning(permissions) {\n return confirmLifecycleCheckpoint({\n permissions,\n message: \"Continue with uninstall review?\",\n ttyError:\n \"Uninstall confirmation requires a TTY. Re-run with `make-docs setup remove --yes`.\",\n });\n },\n renderUninstallAuditSummary(options) {\n renderAuditNote({\n title: \"make-docs setup remove\",\n lines: buildUninstallAuditSummaryLines(options),\n groups: [\n formatEntryGroup(\n \"Files to remove\",\n options.auditReport.removableFiles,\n (entry) => `${formatPath(entry)} (${entry.reason})`,\n ),\n formatEntryGroup(\n \"Directories to prune\",\n options.auditReport.prunableDirectories,\n (entry) => `${formatPath(entry)} (${entry.reason})`,\n ),\n formatEntryGroup(\n \"Preserved paths\",\n options.auditReport.preservedPaths,\n (entry) => `${formatPath(entry)} (${entry.reason})`,\n ),\n formatEntryGroup(\n \"Skipped paths\",\n options.auditReport.skippedPaths,\n (entry) => `${formatPath(entry)} (${entry.reason})`,\n ),\n ],\n });\n },\n confirmUninstallRun(options) {\n const message = options.backupRequested\n ? \"Create the backup and then remove these audited paths? This action cannot be undone.\"\n : \"Remove these audited paths? This action cannot be undone.\";\n\n return confirmLifecycleCheckpoint({\n permissions: options.permissions,\n message,\n ttyError:\n \"Uninstall confirmation requires a TTY. Re-run with `make-docs setup remove --yes`.\",\n });\n },\n renderUninstallCancelled() {\n outro(\"Uninstall cancelled. No files were changed.\");\n },\n renderUninstallCompletionSummary(options) {\n note(\n [\n `Files removed: ${options.removedFiles.length}`,\n `Directories pruned: ${options.prunedDirectories.length}`,\n `Preserved paths: ${options.auditReport.preservedPaths.length}`,\n `Skipped paths: ${options.auditReport.skippedPaths.length}`,\n `Backup: ${formatBackupStatus(options.backupResult)}`,\n ].join(\"\\n\"),\n \"Uninstall complete\",\n );\n },\n renderUninstallFailureSummary(options) {\n note(\n [\n `Files removed before failure: ${options.removedFiles.length}`,\n `Directories pruned before failure: ${options.prunedDirectories.length}`,\n `Preserved paths: ${options.auditReport.preservedPaths.length}`,\n `Skipped paths: ${options.auditReport.skippedPaths.length}`,\n `Backup: ${formatBackupStatus(options.backupResult)}`,\n `Error: ${options.errorMessage}`,\n ].join(\"\\n\"),\n \"Uninstall partially completed\",\n );\n },\n };\n}\n\nexport function getLifecycleRenderer(): LifecycleRenderer {\n return lifecycleRenderer;\n}\n\nexport function __setLifecycleRendererForTests(\n renderer: LifecycleRenderer | null,\n): void {\n lifecycleRenderer = renderer ?? createClackLifecycleRenderer();\n}\n\nexport function beginLifecycleWorkflow(title: string): void {\n getLifecycleRenderer().beginWorkflow(title);\n}\n\nexport function renderBackupAuditSummary(\n options: LifecycleAuditSummaryOptions,\n): void {\n getLifecycleRenderer().renderBackupAuditSummary(options);\n}\n\nexport async function confirmBackupRun(\n permissions: LifecyclePermissionsMode,\n): Promise<boolean> {\n return getLifecycleRenderer().confirmBackupRun(permissions);\n}\n\nexport function renderUninstallWarning(\n options: LifecycleUninstallWarningOptions,\n): void {\n getLifecycleRenderer().renderUninstallWarning(options);\n}\n\nexport async function confirmUninstallWarning(\n permissions: LifecyclePermissionsMode,\n): Promise<boolean> {\n return getLifecycleRenderer().confirmUninstallWarning(permissions);\n}\n\nexport function renderUninstallAuditSummary(\n options: LifecycleUninstallAuditSummaryOptions,\n): void {\n getLifecycleRenderer().renderUninstallAuditSummary(options);\n}\n\nexport async function confirmUninstallRun(\n options: LifecycleUninstallRunConfirmationOptions,\n): Promise<boolean> {\n return getLifecycleRenderer().confirmUninstallRun(options);\n}\n\nexport function renderUninstallCancelled(): void {\n getLifecycleRenderer().renderUninstallCancelled();\n}\n\nexport function renderUninstallCompletionSummary(\n options: LifecycleUninstallCompletionSummaryOptions,\n): void {\n getLifecycleRenderer().renderUninstallCompletionSummary(options);\n}\n\nexport function renderUninstallFailureSummary(\n options: LifecycleUninstallFailureSummaryOptions,\n): void {\n getLifecycleRenderer().renderUninstallFailureSummary(options);\n}\n\nexport function renderBackupNoopSummary(): void {\n getLifecycleRenderer().renderBackupNoopSummary();\n}\n\nexport function renderBackupCancelled(): void {\n getLifecycleRenderer().renderBackupCancelled();\n}\n\nexport function renderBackupCompletionSummary(\n result: BackupExecutionResult,\n): void {\n getLifecycleRenderer().renderBackupCompletionSummary(result);\n}\n\nfunction buildBackupAuditSummaryLines(options: LifecycleAuditSummaryOptions): string[] {\n const { auditReport, destinationDir } = options;\n return [\n `Target: ${auditReport.targetDir}`,\n `Destination: ${destinationDir ?? \"(no backup directory will be created)\"}`,\n ...formatSkillSelectionReview(auditReport.skillSelectionReview),\n ...formatPluginSelectionReview(auditReport.pluginSelectionReview),\n `Files to copy: ${options.copyableFiles.length}`,\n `Directories to materialize: ${options.materializableDirectories.length}`,\n `Retained: ${auditReport.preservedPaths.length}`,\n `Skipped: ${auditReport.skippedPaths.length}`,\n ];\n}\n\nfunction buildUninstallAuditSummaryLines(\n options: LifecycleUninstallAuditSummaryOptions,\n): string[] {\n const { auditReport, backupDestinationDir } = options;\n return [\n `Target: ${auditReport.targetDir}`,\n `Backup before removal: ${backupDestinationDir ?? \"not requested\"}`,\n ...formatSkillSelectionReview(auditReport.skillSelectionReview),\n ...formatPluginSelectionReview(auditReport.pluginSelectionReview),\n `Files to remove: ${auditReport.removableFiles.length}`,\n `Directories to prune: ${auditReport.prunableDirectories.length}`,\n `Preserved: ${auditReport.preservedPaths.length}`,\n `Skipped: ${auditReport.skippedPaths.length}`,\n ];\n}\n\nfunction renderAuditNote(options: {\n title: string;\n lines: string[];\n groups: string[][];\n}): void {\n note(\n [...options.lines, \"\", ...formatEntryGroups(options.groups)].join(\"\\n\"),\n options.title,\n );\n}\n\nfunction formatEntryGroups(groups: string[][]): string[] {\n return groups.flatMap((group, index) =>\n index === 0 ? group : [\"\", ...group],\n );\n}\n\nfunction formatEntryGroup(\n title: string,\n entries: LifecycleRenderableEntry[],\n formatter: (entry: LifecycleRenderableEntry) => string = formatPath,\n): string[] {\n if (entries.length === 0) {\n return [`${title}:`, \"- none\"];\n }\n\n return [`${title}:`, ...entries.map((entry) => `- ${formatter(entry)}`)];\n}\n\nfunction formatPath(entry: Pick<AuditPathMetadata, \"path\">): string {\n return entry.path;\n}\n\nfunction formatBackupStatus(result: BackupExecutionResult | null): string {\n if (!result) {\n return \"not requested\";\n }\n\n if (result.status === \"completed\" && result.destinationDir) {\n return `created at ${result.destinationDir}`;\n }\n\n if (result.status === \"noop\") {\n return \"requested, but no backup files or directories needed to be created\";\n }\n\n return \"requested\";\n}\n\nfunction formatSkillSelectionReview(\n review: AuditSkillSelectionReview | undefined,\n): string[] {\n if (!review) {\n return [];\n }\n\n if (!review.skillsEnabled) {\n return [\"Skills: disabled\"];\n }\n\n const provenance =\n review.skillSelectionProvenance.length === 0\n ? \"(no saved provenance metadata)\"\n : review.skillSelectionProvenance\n .map(\n (entry) =>\n `${entry.skillName}: ${entry.provenanceLabel} (${entry.provenanceKind})`,\n )\n .join(\"; \");\n\n return [\n `Skills: enabled (${review.skillScope})`,\n `Skills manifest: ${formatSkillManifestSource(review.skillManifest)}`,\n `Selected skills: ${formatSelectedSkills(review.selectedSkills)}`,\n `Skill provenance: ${provenance}`,\n ];\n}\n\nfunction formatSkillManifestSource(\n source: SkillManifestSelectionSource | undefined,\n): string {\n if (!source) {\n return \"(legacy selections; no manifest provenance)\";\n }\n\n if (source.source === \"file\") {\n return `${source.displayName} (local file: ${source.path ?? \"unknown path\"})`;\n }\n\n if (source.source === \"remote-pinned\") {\n return `${source.displayName} (remote pinned: ${source.digest ?? \"missing digest\"})`;\n }\n\n return `${source.displayName} (built-in)`;\n}\n\nfunction formatSelectedSkills(selectedSkills: string[]): string {\n return selectedSkills.length === 0 ? \"(none)\" : selectedSkills.join(\", \");\n}\n\nfunction formatPluginSelectionReview(\n review: AuditPluginSelectionReview | undefined,\n): string[] {\n if (!review) {\n return [];\n }\n\n if (!review.pluginsEnabled) {\n return [\"Plugins: disabled\"];\n }\n\n const provenance =\n review.pluginSelectionProvenance.length === 0\n ? \"(no saved provenance metadata)\"\n : review.pluginSelectionProvenance\n .map(\n (entry) =>\n `${entry.pluginId}: ${entry.provenanceLabel} (${entry.provenanceKind})`,\n )\n .join(\"; \");\n\n return [\n `Plugins: enabled (${review.pluginScope})`,\n `Plugin manifest: ${formatPluginManifestSource(review.pluginManifest)}`,\n `Selected plugins: ${formatSelectedPlugins(review.selectedPlugins)}`,\n `Plugin provenance: ${provenance}`,\n ];\n}\n\nfunction formatPluginManifestSource(\n source: PluginManifestSelectionSource | undefined,\n): string {\n if (!source) {\n return \"(legacy selections; no manifest provenance)\";\n }\n\n if (source.source === \"file\") {\n return `${source.displayName} (local file: ${source.path ?? \"unknown path\"})`;\n }\n\n if (source.source === \"remote-pinned\") {\n return `${source.displayName} (remote pinned: ${source.digest ?? \"missing digest\"})`;\n }\n\n return `${source.displayName} (built-in)`;\n}\n\nfunction formatSelectedPlugins(selectedPlugins: string[]): string {\n return selectedPlugins.length === 0 ? \"(none)\" : selectedPlugins.join(\", \");\n}\n\nasync function confirmLifecycleCheckpoint(options: {\n permissions: LifecyclePermissionsMode;\n message: string;\n ttyError: string;\n}): Promise<boolean> {\n if (options.permissions === \"allow-all\") {\n return true;\n }\n\n if (!input.isTTY || !output.isTTY) {\n throw new Error(options.ttyError);\n }\n\n const proceed = await confirm({\n message: options.message,\n initialValue: true,\n active: \"Yes\",\n inactive: \"No\",\n withGuide: true,\n });\n\n return !(isCancel(proceed) || !proceed);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,OAAO,QAAQ;AACf,OAAO,UAAU;;;ACRjB,SAAS,SAAS,OAAO,UAAU,cAAc;AAmFjD,IAAI,oBAAuC,6BAA6B;AAEjE,SAAS,+BAAkD;AAChE,SAAO;AAAA,IACL,cAAc,OAAO;AACnB,SAAM,KAAK;AAAA,IACb;AAAA,IACA,yBAAyB,SAAS;AAChC,sBAAgB;AAAA,QACd,OAAO;AAAA,QACP,OAAO,6BAA6B,OAAO;AAAA,QAC3C,QAAQ;AAAA,UACN;AAAA,YACE;AAAA,YACA,QAAQ;AAAA,YACR,CAAC,UAAU,GAAG,WAAW,KAAK,CAAC,KAAK,MAAM,MAAM;AAAA,UAClD;AAAA,UACA;AAAA,YACE;AAAA,YACA,QAAQ;AAAA,UACV;AAAA,UACA;AAAA,YACE;AAAA,YACA,QAAQ,YAAY;AAAA,YACpB,CAAC,UAAU,GAAG,WAAW,KAAK,CAAC,KAAK,MAAM,MAAM;AAAA,UAClD;AAAA,UACA;AAAA,YACE;AAAA,YACA,QAAQ,YAAY;AAAA,YACpB,CAAC,UAAU,GAAG,WAAW,KAAK,CAAC,KAAK,MAAM,MAAM;AAAA,UAClD;AAAA,QACF;AAAA,MACF,CAAC;AAAA,IACH;AAAA,IACA,iBAAiB,aAAa;AAC5B,aAAO,2BAA2B;AAAA,QAChC;AAAA,QACA,SAAS;AAAA,QACT,UACE;AAAA,MACJ,CAAC;AAAA,IACH;AAAA,IACA,0BAA0B;AACxB;AAAA,QACE;AAAA,MACF;AAAA,IACF;AAAA,IACA,wBAAwB;AACtB,SAAM,mBAAmB;AAAA,IAC3B;AAAA,IACA,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