@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.
Files changed (187) hide show
  1. package/LICENSE +21 -201
  2. package/README.md +36 -27
  3. package/dist/backup-73HQNKMC.js +20 -0
  4. package/dist/backup-73HQNKMC.js.map +1 -0
  5. package/dist/chunk-3BAJQXGH.js +1575 -0
  6. package/dist/chunk-3BAJQXGH.js.map +1 -0
  7. package/dist/chunk-64CTKJO7.js +4136 -0
  8. package/dist/chunk-64CTKJO7.js.map +1 -0
  9. package/dist/chunk-BENO4IH5.js +875 -0
  10. package/dist/chunk-BENO4IH5.js.map +1 -0
  11. package/dist/chunk-D4HDZEJT.js +37 -0
  12. package/dist/chunk-D4HDZEJT.js.map +1 -0
  13. package/dist/chunk-G5EF63GG.js +1291 -0
  14. package/dist/chunk-G5EF63GG.js.map +1 -0
  15. package/dist/chunk-GNP6HRVP.js +523 -0
  16. package/dist/chunk-GNP6HRVP.js.map +1 -0
  17. package/dist/chunk-HJYIQTMD.js +204 -0
  18. package/dist/chunk-HJYIQTMD.js.map +1 -0
  19. package/dist/chunk-LQ5NSWCJ.js +39 -0
  20. package/dist/chunk-LQ5NSWCJ.js.map +1 -0
  21. package/dist/chunk-LRVV7UDD.js +2340 -0
  22. package/dist/chunk-LRVV7UDD.js.map +1 -0
  23. package/dist/chunk-LVQSJF63.js +24674 -0
  24. package/dist/chunk-LVQSJF63.js.map +1 -0
  25. package/dist/chunk-MXBHCHSM.js +13995 -0
  26. package/dist/chunk-MXBHCHSM.js.map +1 -0
  27. package/dist/chunk-Z5K4FHYP.js +922 -0
  28. package/dist/chunk-Z5K4FHYP.js.map +1 -0
  29. package/dist/index.js +3798 -250
  30. package/dist/index.js.map +1 -1
  31. package/dist/self-YYXOLDKU.js +653 -0
  32. package/dist/self-YYXOLDKU.js.map +1 -0
  33. package/dist/server-O2ZELIMX.js +512 -0
  34. package/dist/server-O2ZELIMX.js.map +1 -0
  35. package/dist/setup-system-HZROFNMP.js +544 -0
  36. package/dist/setup-system-HZROFNMP.js.map +1 -0
  37. package/dist/{skills-command-3ESCZ75U.js → skills-command-MGGHY7HU.js} +190 -32
  38. package/dist/skills-command-MGGHY7HU.js.map +1 -0
  39. package/dist/uninstall-3UXXXNFO.js +223 -0
  40. package/dist/uninstall-3UXXXNFO.js.map +1 -0
  41. package/dist/virtual_make-docs-first-party-skills-ZII74YOB.js +11 -0
  42. package/dist/virtual_make-docs-first-party-skills-ZII74YOB.js.map +1 -0
  43. package/package.json +9 -6
  44. package/skill-registry.json +328 -125
  45. package/skill-registry.schema.json +221 -45
  46. package/template/.make-docs/AGENTS.md +18 -0
  47. package/template/.make-docs/CLAUDE.md +18 -0
  48. package/template/.make-docs/archive/AGENTS.md +11 -0
  49. package/template/.make-docs/archive/CLAUDE.md +11 -0
  50. package/template/.make-docs/system/AGENTS.md +12 -0
  51. package/template/.make-docs/system/CLAUDE.md +12 -0
  52. package/template/.make-docs/system/contracts/AGENTS.md +13 -0
  53. package/template/.make-docs/system/contracts/CLAUDE.md +13 -0
  54. package/template/{docs/assets/references → .make-docs/system/contracts}/commit-message-convention.md +4 -4
  55. package/template/.make-docs/system/contracts/coverage-pass-contract.md +198 -0
  56. package/template/.make-docs/system/contracts/deferred-obligation-contract.md +128 -0
  57. package/template/{docs/assets/references → .make-docs/system/contracts}/design-contract.md +7 -2
  58. package/template/{docs/assets/references → .make-docs/system/contracts}/guide-contract.md +21 -19
  59. package/template/{docs/assets/references → .make-docs/system/contracts}/history-record-contract.md +17 -11
  60. package/template/.make-docs/system/contracts/human-experience-contract.md +134 -0
  61. package/template/.make-docs/system/contracts/naive-uat-contract.md +231 -0
  62. package/template/.make-docs/system/contracts/output-contract.md +277 -0
  63. package/template/.make-docs/system/contracts/performance-evidence-governance.md +257 -0
  64. package/template/.make-docs/system/contracts/system-resource-contract.md +93 -0
  65. package/template/.make-docs/system/prompts/AGENTS.md +12 -0
  66. package/template/.make-docs/system/prompts/CLAUDE.md +12 -0
  67. package/template/.make-docs/system/prompts/coverage-pass-maintainer-guide.prompt.md +20 -0
  68. package/template/.make-docs/system/prompts/coverage-pass-prd-reconciliation.prompt.md +18 -0
  69. package/template/.make-docs/system/prompts/coverage-pass-testing-uat.prompt.md +46 -0
  70. package/template/.make-docs/system/prompts/coverage-pass-user-guide.prompt.md +20 -0
  71. package/template/.make-docs/system/prompts/designs-to-plan-change.prompt.md +18 -0
  72. package/template/.make-docs/system/prompts/designs-to-plan.prompt.md +14 -0
  73. package/template/.make-docs/system/prompts/docs-path-hygiene-cleanup.prompt.md +29 -0
  74. package/template/.make-docs/system/prompts/naive-uat-facilitator.prompt.md +28 -0
  75. package/template/.make-docs/system/prompts/naive-uat-tester.prompt.md +20 -0
  76. package/template/.make-docs/system/prompts/performance-coverage.prompt.md +63 -0
  77. package/template/.make-docs/system/prompts/plan-to-prd-change.prompt.md +12 -0
  78. package/template/.make-docs/system/prompts/plan-to-prd-green-field.prompt.md +10 -0
  79. package/template/.make-docs/system/prompts/prd-change-to-work.prompt.md +14 -0
  80. package/template/.make-docs/system/prompts/prd-to-work-full-prd.prompt.md +10 -0
  81. package/template/.make-docs/system/prompts/prd-to-work-prd-feature.prompt.md +10 -0
  82. package/template/.make-docs/system/prompts/request-to-design.prompt.md +20 -0
  83. package/template/.make-docs/system/prompts/session-to-history-record.prompt.md +23 -0
  84. package/template/{docs/assets → .make-docs/system}/prompts/work-to-commit-message.prompt.md +2 -2
  85. package/template/.make-docs/system/prompts/work-to-guides.prompt.md +22 -0
  86. package/template/.make-docs/system/references/AGENTS.md +14 -0
  87. package/template/.make-docs/system/references/CLAUDE.md +14 -0
  88. package/template/{docs/assets → .make-docs/system}/references/design-workflow.md +15 -2
  89. package/template/.make-docs/system/references/execution-workflow.md +189 -0
  90. package/template/.make-docs/system/references/human-experience.md +138 -0
  91. package/template/.make-docs/system/references/lifecycle.md +153 -0
  92. package/template/.make-docs/system/references/naive-uat-validation.md +65 -0
  93. package/template/.make-docs/system/references/naive-uat-workflow.md +64 -0
  94. package/template/.make-docs/system/references/path-and-link-hygiene.md +101 -0
  95. package/template/.make-docs/system/references/performance-evidence.md +114 -0
  96. package/template/.make-docs/system/references/planning-workflow.md +209 -0
  97. package/template/.make-docs/system/references/prd-change-management.md +165 -0
  98. package/template/{docs/assets → .make-docs/system}/references/wave-model.md +10 -8
  99. package/template/.make-docs/system/templates/AGENTS.md +12 -0
  100. package/template/.make-docs/system/templates/CLAUDE.md +12 -0
  101. package/template/.make-docs/system/templates/design.md +79 -0
  102. package/template/{docs/assets/templates/guide-developer.md → .make-docs/system/templates/guide-maintainer.md} +7 -3
  103. package/template/{docs/assets → .make-docs/system}/templates/guide-user.md +6 -2
  104. package/template/{docs/assets → .make-docs/system}/templates/history-record.md +6 -3
  105. package/template/.make-docs/system/templates/naive-uat-scenario.md +91 -0
  106. package/template/.make-docs/system/templates/performance-evidence-profile.md +252 -0
  107. package/template/.make-docs/system/templates/plan-overview.md +76 -0
  108. package/template/.make-docs/system/templates/plan-prd-change.md +155 -0
  109. package/template/{docs/assets → .make-docs/system}/templates/plan-prd-decompose.md +10 -0
  110. package/template/{docs/assets → .make-docs/system}/templates/plan-prd.md +28 -2
  111. package/template/{docs/assets → .make-docs/system}/templates/prd-architecture.md +13 -0
  112. package/template/.make-docs/system/templates/prd-glossary.md +28 -0
  113. package/template/.make-docs/system/templates/prd-index.md +70 -0
  114. package/template/{docs/assets → .make-docs/system}/templates/prd-overview.md +13 -0
  115. package/template/.make-docs/system/templates/prd-reference.md +30 -0
  116. package/template/{docs/assets → .make-docs/system}/templates/prd-risk-register.md +16 -1
  117. package/template/{docs/assets → .make-docs/system}/templates/prd-subsystem.md +15 -0
  118. package/template/.make-docs/system/templates/work-index.md +58 -0
  119. package/template/.make-docs/system/templates/work-phase.md +107 -0
  120. package/template/.make-docs/system-resources.catalog.json +91 -0
  121. package/template/.make-docs/system-resources.schema.json +204 -0
  122. package/template/AGENTS.md +8 -1
  123. package/template/CLAUDE.md +8 -1
  124. package/template/docs/AGENTS.codex-only.md +22 -0
  125. package/template/docs/AGENTS.md +21 -13
  126. package/template/docs/CLAUDE.claude-only.md +22 -0
  127. package/template/docs/CLAUDE.md +21 -13
  128. package/template/docs/assets/AGENTS.md +11 -7
  129. package/template/docs/assets/CLAUDE.md +11 -7
  130. package/template/docs/designs/AGENTS.md +8 -3
  131. package/template/docs/designs/CLAUDE.md +8 -3
  132. package/template/docs/plans/AGENTS.md +10 -3
  133. package/template/docs/plans/CLAUDE.md +10 -3
  134. package/template/docs/prd/AGENTS.md +14 -4
  135. package/template/docs/prd/CLAUDE.md +14 -4
  136. package/template/docs/work/AGENTS.md +10 -3
  137. package/template/docs/work/CLAUDE.md +10 -3
  138. package/dist/chunk-HP3HBG7F.js +0 -626
  139. package/dist/chunk-HP3HBG7F.js.map +0 -1
  140. package/dist/chunk-QRFH4J6H.js +0 -1194
  141. package/dist/chunk-QRFH4J6H.js.map +0 -1
  142. package/dist/chunk-WM3OXYTW.js +0 -2630
  143. package/dist/chunk-WM3OXYTW.js.map +0 -1
  144. package/dist/skills-command-3ESCZ75U.js.map +0 -1
  145. package/dist/uninstall-GQE4SJF2.js +0 -150
  146. package/dist/uninstall-GQE4SJF2.js.map +0 -1
  147. package/template/.make-docs/scripts/check_path_hygiene.py +0 -435
  148. package/template/docs/assets/archive/AGENTS.md +0 -20
  149. package/template/docs/assets/archive/CLAUDE.md +0 -20
  150. package/template/docs/assets/history/AGENTS.md +0 -12
  151. package/template/docs/assets/history/CLAUDE.md +0 -12
  152. package/template/docs/assets/prompts/AGENTS.md +0 -8
  153. package/template/docs/assets/prompts/CLAUDE.md +0 -8
  154. package/template/docs/assets/prompts/designs-to-plan-change.prompt.md +0 -14
  155. package/template/docs/assets/prompts/designs-to-plan.prompt.md +0 -10
  156. package/template/docs/assets/prompts/docs-path-hygiene-cleanup.prompt.md +0 -27
  157. package/template/docs/assets/prompts/plan-to-prd-change.prompt.md +0 -8
  158. package/template/docs/assets/prompts/plan-to-prd-green-field.prompt.md +0 -6
  159. package/template/docs/assets/prompts/prd-change-to-work.prompt.md +0 -10
  160. package/template/docs/assets/prompts/prd-to-work-full-prd.prompt.md +0 -6
  161. package/template/docs/assets/prompts/prd-to-work-prd-feature.prompt.md +0 -6
  162. package/template/docs/assets/prompts/request-to-design.prompt.md +0 -16
  163. package/template/docs/assets/prompts/session-to-history-record.prompt.md +0 -19
  164. package/template/docs/assets/prompts/work-to-guides.prompt.md +0 -18
  165. package/template/docs/assets/references/AGENTS.md +0 -9
  166. package/template/docs/assets/references/CLAUDE.md +0 -9
  167. package/template/docs/assets/references/execution-workflow.md +0 -157
  168. package/template/docs/assets/references/output-contract.md +0 -221
  169. package/template/docs/assets/references/path-and-link-hygiene.md +0 -49
  170. package/template/docs/assets/references/planning-workflow.md +0 -160
  171. package/template/docs/assets/references/prd-change-management.md +0 -129
  172. package/template/docs/assets/templates/AGENTS.md +0 -8
  173. package/template/docs/assets/templates/CLAUDE.md +0 -8
  174. package/template/docs/assets/templates/design.md +0 -30
  175. package/template/docs/assets/templates/plan-overview.md +0 -32
  176. package/template/docs/assets/templates/plan-prd-change.md +0 -99
  177. package/template/docs/assets/templates/prd-change-addition.md +0 -45
  178. package/template/docs/assets/templates/prd-change-revision.md +0 -45
  179. package/template/docs/assets/templates/prd-glossary.md +0 -15
  180. package/template/docs/assets/templates/prd-index.md +0 -45
  181. package/template/docs/assets/templates/prd-reference.md +0 -17
  182. package/template/docs/assets/templates/work-index.md +0 -21
  183. package/template/docs/assets/templates/work-phase.md +0 -34
  184. package/template/docs/guides/AGENTS.md +0 -15
  185. package/template/docs/guides/CLAUDE.md +0 -15
  186. /package/template/{docs/assets → .make-docs/system}/prompts/update-readme-green-field.prompt.md +0 -0
  187. /package/template/{docs/assets → .make-docs/system}/references/harness-capability-matrix.md +0 -0
@@ -0,0 +1,544 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ listHarnessCommandRules,
4
+ listOperationAccessFacts,
5
+ validateRegistryHarnessCommandRules
6
+ } from "./chunk-LVQSJF63.js";
7
+ import {
8
+ completeHarnessSystemOperation,
9
+ loadGlobalConfig,
10
+ prepareHarnessSystemOperation,
11
+ readCurrentHarnessIntegrationReceipt,
12
+ readPendingHarnessSystemOperation,
13
+ recordHarnessIntegrationReceipt,
14
+ writeGlobalConfig
15
+ } from "./chunk-3BAJQXGH.js";
16
+ import {
17
+ resolveEffectiveHarnessIntegration
18
+ } from "./chunk-64CTKJO7.js";
19
+ import "./chunk-HJYIQTMD.js";
20
+ import {
21
+ Ct,
22
+ Jt,
23
+ Rt
24
+ } from "./chunk-Z5K4FHYP.js";
25
+ import {
26
+ ExecutableVerificationError,
27
+ FIRST_PARTY_HARNESS_ADAPTERS,
28
+ listBoundedHarnessCommandRules,
29
+ requireFirstPartyHarnessAdapter,
30
+ resolveHarnessMethodSupport,
31
+ verifyMakeDocsExecutable
32
+ } from "./chunk-LRVV7UDD.js";
33
+ import {
34
+ getStoreDatabasePath,
35
+ platform,
36
+ readInstallationStatus,
37
+ resolveStoreRoot
38
+ } from "./chunk-MXBHCHSM.js";
39
+ import "./chunk-D4HDZEJT.js";
40
+
41
+ // src/setup-system.ts
42
+ import path from "path";
43
+ import { existsSync } from "fs";
44
+ var SYSTEM_COMMAND_RULE_AUTHORITY = Object.freeze({
45
+ list: listHarnessCommandRules,
46
+ validate: validateRegistryHarnessCommandRules
47
+ });
48
+ async function runSystemSetupCommand(options) {
49
+ const resumed = await resumePendingSystemSetupCommand(options);
50
+ if (resumed) return resumed;
51
+ const prepared = await prepareSystemSetupCommand(options);
52
+ options.onReview?.(prepared.review);
53
+ const blockedPlans = prepared.plans.filter((plan) => plan.status === "blocked" || plan.status === "unsupported");
54
+ const runnablePlans = prepared.plans.filter((plan) => plan.status !== "blocked" && plan.status !== "unsupported");
55
+ if (blockedPlans.length && runnablePlans.length === 0) {
56
+ const blocked = blockedPlans.map((plan) => ({ harness: plan.harness, reason: plan.detail, nextAction: plan.detail }));
57
+ return makeResult("blocked", prepared.selections, [], blocked, blocked[0]?.nextAction ?? null);
58
+ }
59
+ if (options.dryRun) {
60
+ const blocked = blockedPlans.map((plan) => ({ harness: plan.harness, reason: plan.detail, nextAction: plan.detail }));
61
+ return makeResult(
62
+ blocked.length || prepared.changed ? "partial" : prepared.plans.length ? "unchanged" : "skipped-none",
63
+ prepared.selections,
64
+ [],
65
+ blocked,
66
+ prepared.changed ? "Run `make-docs setup system --yes` to apply the reviewed machine changes." : blocked[0]?.nextAction ?? null
67
+ );
68
+ }
69
+ if (prepared.changed && !options.yes) {
70
+ const approved = await Rt({ message: "Apply the reviewed changes to this computer?", initialValue: false, active: "Yes", inactive: "No", withGuide: true });
71
+ if (Ct(approved) || !approved) return makeResult("blocked", prepared.selections, [], [], "Run `make-docs setup system` and approve the reviewed machine changes.");
72
+ }
73
+ return applyPreparedSystemSetup(prepared);
74
+ }
75
+ async function resumePendingSystemSetupCommand(options) {
76
+ return resumePendingSystemSetup(
77
+ options,
78
+ options.machineRoot ?? platform.userHome(),
79
+ options.targetRoot ?? process.cwd(),
80
+ options.storeRoot ?? resolveStoreRoot()
81
+ );
82
+ }
83
+ async function prepareSystemSetupCommand(options) {
84
+ const machineRoot = options.machineRoot ?? platform.userHome();
85
+ const targetRoot = options.targetRoot ?? process.cwd();
86
+ const storeRoot = options.storeRoot ?? resolveStoreRoot();
87
+ const executableAttempt = options.executable ? { executable: options.executable } : tryVerifyCurrentExecutable();
88
+ const selections = await selectMethods(options, machineRoot, storeRoot, executableAttempt);
89
+ validateProjectHarnessIntegrations(options.projectHarnessIntegrations, selections, options.harnesses);
90
+ const plans = buildAdapterPlans(options, selections, machineRoot, targetRoot, storeRoot, executableAttempt);
91
+ const intent = buildIntentProjection(storeRoot, selections, options.harnesses, options.persistIntent !== false);
92
+ const detection = inspectSystemHarnesses(machineRoot).filter((state) => options.harnesses[state.harness]);
93
+ const review = [
94
+ ...detection.map((state) => `${label(state.harness)} detection: ${state.state}${state.detail ? ` (${state.detail})` : ""}${state.nextAction ? ` Next: ${state.nextAction}` : ""}`),
95
+ "Detection is a hint. It does not prove support or limit your choice.",
96
+ "",
97
+ ...renderMethodSupport(machineRoot, options.harnesses, executableAttempt),
98
+ "Generic MCP client: available; Make Docs prints a standard configuration and does not edit client-owned files. Next: rerun setup with `--generic-mcp-client <label>`.",
99
+ "",
100
+ renderSystemPlans(plans),
101
+ "",
102
+ renderIntentChanges(storeRoot, intent.changes)
103
+ ].join("\n");
104
+ return {
105
+ options,
106
+ machineRoot,
107
+ targetRoot,
108
+ storeRoot,
109
+ selections,
110
+ plans,
111
+ intent,
112
+ review,
113
+ changed: plans.some((plan) => plan.changed) || intent.changes.length > 0
114
+ };
115
+ }
116
+ async function promptForSystemSetupMethods(options) {
117
+ const machineRoot = options.machineRoot ?? platform.userHome();
118
+ const storeRoot = options.storeRoot ?? resolveStoreRoot();
119
+ return selectMethods(
120
+ { ...options, promptForMethods: true, yes: false, dryRun: false },
121
+ machineRoot,
122
+ storeRoot,
123
+ options.executable ? { executable: options.executable } : tryVerifyCurrentExecutable()
124
+ );
125
+ }
126
+ async function applyPreparedSystemSetup(prepared) {
127
+ const { options, plans, selections, targetRoot, storeRoot } = prepared;
128
+ const blockedPlans = plans.filter((plan) => plan.status === "blocked" || plan.status === "unsupported");
129
+ const blocked = blockedPlans.map((plan) => ({
130
+ harness: plan.harness,
131
+ reason: plan.detail,
132
+ nextAction: plan.detail
133
+ }));
134
+ const runnable = plans.filter((plan) => plan.status !== "blocked" && plan.status !== "unsupported");
135
+ const changed = runnable.filter((plan) => plan.changed);
136
+ const configured = [];
137
+ let recoveryAction = null;
138
+ for (const plan of runnable) {
139
+ if (!plan.changed) {
140
+ if (options.persistIntent !== false) {
141
+ persistReviewedHarnessIntent(storeRoot, prepared.intent.config, plan.harness);
142
+ }
143
+ configured.push(plan.harness);
144
+ continue;
145
+ }
146
+ try {
147
+ await plan.apply();
148
+ if (!await plan.verify()) {
149
+ const recovery = recoveryActionForPlanFailure(
150
+ plan,
151
+ "The applied native entry did not verify.",
152
+ targetRoot,
153
+ storeRoot
154
+ );
155
+ blocked.push({ harness: plan.harness, reason: "The applied native entry did not verify.", nextAction: recovery });
156
+ recoveryAction ??= recovery;
157
+ if (plan.pendingOperation?.()) break;
158
+ continue;
159
+ }
160
+ if (options.persistIntent !== false) {
161
+ persistReviewedHarnessIntent(storeRoot, prepared.intent.config, plan.harness);
162
+ }
163
+ configured.push(plan.harness);
164
+ } catch (error) {
165
+ const reason = error instanceof Error ? error.message : String(error);
166
+ const recovery = recoveryActionForPlanFailure(
167
+ plan,
168
+ reason,
169
+ targetRoot,
170
+ storeRoot
171
+ );
172
+ blocked.push({ harness: plan.harness, reason, nextAction: recovery });
173
+ recoveryAction ??= recovery;
174
+ if (plan.pendingOperation?.()) break;
175
+ }
176
+ }
177
+ if (options.persistIntent !== false) {
178
+ persistReviewedDisabledIntents(storeRoot, prepared.intent.config, selections, options.harnesses);
179
+ }
180
+ if (blocked.length > 0) {
181
+ const status = recoveryAction ? configured.length > 0 ? "partial" : "recovery" : configured.length > 0 ? "partial" : "blocked";
182
+ return makeResult(status, selections, configured, blocked, recoveryAction ?? blocked[0]?.nextAction ?? null);
183
+ }
184
+ if (!changed.length) {
185
+ if (prepared.intent.changes.length > 0) {
186
+ if (Object.keys(options.harnesses).some((harness) => options.harnesses[harness] && selections[harness] !== "none")) {
187
+ return makeResult("configured", selections, [], [], null);
188
+ }
189
+ return makeResult("skipped-none", selections, [], [], null);
190
+ }
191
+ if (plans.length) {
192
+ return makeResult("unchanged", selections, plans.map((plan) => plan.harness), [], null);
193
+ }
194
+ return makeResult("skipped-none", selections, [], [], null);
195
+ }
196
+ return makeResult("configured", selections, configured, [], null);
197
+ }
198
+ function persistReviewedHarnessIntent(storeRoot, projected, harness) {
199
+ const intent = projected.settings.harnesses[harness];
200
+ if (!intent) return;
201
+ const current = loadGlobalConfig(storeRoot).config;
202
+ current.settings.harnesses[harness] = { ...intent, accessCeiling: { ...intent.accessCeiling } };
203
+ writeGlobalConfig(storeRoot, current);
204
+ }
205
+ function persistReviewedDisabledIntents(storeRoot, projected, selections, included) {
206
+ for (const harness of Object.keys(selections)) {
207
+ if (included[harness] && selections[harness] === "none") {
208
+ persistReviewedHarnessIntent(storeRoot, projected, harness);
209
+ }
210
+ }
211
+ }
212
+ function recoveryActionForPlanFailure(plan, reason, targetRoot, storeRoot) {
213
+ if (reason.includes("Run make-docs setup to review and apply the compatibility bridge")) {
214
+ return "Run `make-docs setup` to review and apply the Store compatibility bridge. Full setup will retry the approved machine work after that prerequisite verifies.";
215
+ }
216
+ if (reason.includes("Store operation is already pending")) {
217
+ try {
218
+ const currentProject = readInstallationStatus(targetRoot, storeRoot);
219
+ const pendingProject = "pendingOperation" in currentProject ? currentProject.pendingOperation : null;
220
+ if (currentProject.status === "recovery-required" && pendingProject) {
221
+ return "Run `make-docs setup` again. Setup will review the unfinished work for this project before it builds a new computer plan.";
222
+ }
223
+ if (currentProject.status === "recovery-required" && "toolOperations" in currentProject && currentProject.toolOperations.length > 0) {
224
+ return "A machine-wide Store operation is still pending. Finish or recover that recorded tool operation, then run `make-docs setup` again to build a current computer plan.";
225
+ }
226
+ if (currentProject.status === "writer-active") {
227
+ return "This project has an active writer. Wait for it to finish, then run `make-docs setup` again to build a current computer plan.";
228
+ }
229
+ return "This project has no pending operation to recover. Wait for the reported Store writer to finish, then run `make-docs setup` again. Setup will build a new computer plan from current Store state.";
230
+ } catch {
231
+ return "Run `make-docs setup` again. Setup will read the current project state before it builds a new computer plan.";
232
+ }
233
+ }
234
+ if (plan.pendingOperation?.()) {
235
+ return `Run \`make-docs setup system\` to resume the recorded ${label(plan.harness)} machine change.`;
236
+ }
237
+ return `Correct the reported ${label(plan.harness)} prerequisite, then run \`make-docs setup system\` to review a new machine plan.`;
238
+ }
239
+ async function selectMethods(options, root, storeRoot, executableAttempt) {
240
+ const chosen = { codex: "none", "claude-code": "none" };
241
+ const existing = loadGlobalConfig(storeRoot).config.settings.harnesses;
242
+ for (const adapter of FIRST_PARTY_HARNESS_ADAPTERS) {
243
+ const saved = existing[adapter.harnessId];
244
+ const savedMethod = saved?.selected && adapter.methods.some((method2) => method2.id === saved.maximumMethod) ? saved.maximumMethod : "none";
245
+ chosen[adapter.harnessId] = savedMethod;
246
+ if (!options.harnesses[adapter.harnessId]) continue;
247
+ const supplied = options.methods?.[adapter.harnessId];
248
+ if (supplied) {
249
+ chosen[adapter.harnessId] = supplied;
250
+ continue;
251
+ }
252
+ if (!options.promptForMethods || options.yes || options.dryRun) {
253
+ throw new Error(
254
+ `${adapter.displayName} is included but has no explicit method. Pass the matching method flag, including \`none\` to disable it.`
255
+ );
256
+ }
257
+ const answer = await Jt({ message: `${adapter.displayName} connection method`, options: [
258
+ { value: "none", label: "None", hint: "No native file changes. Resource reads still need no Store access." },
259
+ ...adapter.methods.map((method2) => {
260
+ const support = resolveHarnessMethodSupport(adapter, method2.id);
261
+ const available = support.selectable && executableAttempt.executable !== void 0;
262
+ const prerequisite = executableAttempt.error ? formatExecutableVerificationFailure(executableAttempt.error) : null;
263
+ return { value: method2.id, label: `${method2.id} (${available ? "available" : "unavailable"})`, hint: `${path.resolve(root, method2.nativeFile("machine"))}. ${prerequisite ?? `${support.reason} Next: ${support.nextAction}`}` };
264
+ })
265
+ ], initialValue: savedMethod });
266
+ if (Ct(answer) || typeof answer !== "string") continue;
267
+ const method = answer;
268
+ if (method === "none") {
269
+ chosen[adapter.harnessId] = "none";
270
+ continue;
271
+ }
272
+ chosen[adapter.harnessId] = method;
273
+ }
274
+ return chosen;
275
+ }
276
+ function buildAdapterPlans(options, selections, root, targetRoot, storeRoot, executableAttempt) {
277
+ const rules = listBoundedHarnessCommandRules(SYSTEM_COMMAND_RULE_AUTHORITY);
278
+ const plans = [];
279
+ for (const adapter of FIRST_PARTY_HARNESS_ADAPTERS) {
280
+ const method = selections[adapter.harnessId];
281
+ if (!options.harnesses[adapter.harnessId] || method === "none") continue;
282
+ const support = resolveHarnessMethodSupport(adapter, method);
283
+ const definition = adapter.methods.find((item) => item.id === method);
284
+ const nativeFile = path.resolve(root, definition.nativeFile("machine"));
285
+ const reviewFacts = methodReviewFacts(definition, rules);
286
+ const currentReceipt = existsSync(getStoreDatabasePath(storeRoot)) ? readCurrentHarnessIntegrationReceipt(targetRoot, storeRoot, "machine", adapter.harnessId, method) : null;
287
+ if (!support.selectable) {
288
+ plans.push(blockedPlan(adapter.harnessId, method, `${support.reason} Next: ${support.nextAction}`, nativeFile, reviewFacts));
289
+ continue;
290
+ }
291
+ if (!executableAttempt.executable) {
292
+ plans.push(blockedPlan(adapter.harnessId, method, formatExecutableVerificationFailure(executableAttempt.error), nativeFile, reviewFacts));
293
+ continue;
294
+ }
295
+ const executable = executableAttempt.executable;
296
+ const commandRules = definition.requiresCommandRules ? rules : void 0;
297
+ const adapterPlan = adapter.plan({ method, scope: "machine", root, executable, ...commandRules ? { commandRules, commandRuleAuthority: SYSTEM_COMMAND_RULE_AUTHORITY } : {}, ...currentReceipt ? { receipt: currentReceipt } : {} });
298
+ let receipt;
299
+ let pending;
300
+ plans.push({
301
+ harness: adapter.harnessId,
302
+ method,
303
+ status: adapterPlan.state === "current" ? "current" : adapterPlan.state === "missing" ? "incomplete" : adapterPlan.state,
304
+ ...reviewFacts,
305
+ machineFiles: adapterPlan.changes.map((change) => change.path),
306
+ changed: adapterPlan.changes.some((change) => change.action !== "none"),
307
+ detail: adapterPlan.nextAction,
308
+ async apply() {
309
+ pending = prepareHarnessSystemOperation({ targetRoot, storeRoot, adapterId: adapter.id, harnessId: adapter.harnessId, plan: adapterPlan, appliedVersion: options.appliedVersion ?? executable.packageVersion, verifiedAt: (/* @__PURE__ */ new Date()).toISOString() });
310
+ receipt = adapter.apply({ plan: adapterPlan, approved: true, operationId: pending.operationId, appliedVersion: pending.appliedVersion, verifiedAt: pending.verifiedAt }).receipt;
311
+ await options.afterNativeApplyForTests?.();
312
+ },
313
+ async verify() {
314
+ const exactReceipt = receipt ?? currentReceipt;
315
+ const verification = adapter.verify({ method, scope: "machine", root, executable, ...commandRules ? { commandRules, commandRuleAuthority: SYSTEM_COMMAND_RULE_AUTHORITY } : {}, ...exactReceipt ? { receipt: exactReceipt } : {} });
316
+ if (verification.state !== "current" || !exactReceipt) return false;
317
+ if (receipt) recordHarnessIntegrationReceipt(targetRoot, storeRoot, receipt);
318
+ if (pending) completeHarnessSystemOperation(targetRoot, storeRoot, pending, exactReceipt);
319
+ return true;
320
+ },
321
+ pendingOperation() {
322
+ return pending !== void 0;
323
+ }
324
+ });
325
+ }
326
+ return plans;
327
+ }
328
+ async function resumePendingSystemSetup(options, machineRoot, targetRoot, storeRoot) {
329
+ const pending = readPendingHarnessSystemOperation(targetRoot, storeRoot);
330
+ if (!pending) return null;
331
+ const selections = { codex: "none", "claude-code": "none" };
332
+ selections[pending.harnessId] = pending.connectionMethod;
333
+ const recoveryAction = `Run \`make-docs setup system --target ${JSON.stringify(targetRoot)}\` again to resume machine setup ${pending.operationId}.`;
334
+ if (options.dryRun) {
335
+ return makeResult("recovery", selections, [], [{ harness: pending.harnessId, reason: `Machine setup ${pending.operationId} is pending.`, nextAction: recoveryAction }], recoveryAction);
336
+ }
337
+ try {
338
+ const adapter = requireFirstPartyHarnessAdapter(pending.harnessId);
339
+ if (adapter.id !== pending.adapterId) throw new Error("The pending adapter identity does not match this build.");
340
+ if (!platform.samePath(pending.plan.root, machineRoot)) {
341
+ throw new Error(`The pending machine root ${pending.plan.root} does not match ${machineRoot}.`);
342
+ }
343
+ const executable = verifyMakeDocsExecutable({
344
+ executablePath: pending.plan.executable.path,
345
+ expectedSha256: pending.plan.executable.sha256
346
+ });
347
+ if (JSON.stringify(executable) !== JSON.stringify(pending.plan.executable)) {
348
+ throw new Error("The pending executable identity does not match this installed Make Docs binary.");
349
+ }
350
+ const definition = adapter.methods.find((method) => method.id === pending.connectionMethod);
351
+ if (!definition) throw new Error(`The pending ${pending.connectionMethod} method is not implemented by this adapter.`);
352
+ const commandRules = definition.requiresCommandRules ? listBoundedHarnessCommandRules(SYSTEM_COMMAND_RULE_AUTHORITY) : void 0;
353
+ const applied = adapter.apply({
354
+ plan: pending.plan,
355
+ approved: true,
356
+ operationId: pending.operationId,
357
+ appliedVersion: pending.appliedVersion,
358
+ verifiedAt: pending.verifiedAt
359
+ });
360
+ const verification = adapter.verify({
361
+ method: pending.connectionMethod,
362
+ scope: "machine",
363
+ root: machineRoot,
364
+ executable,
365
+ ...commandRules ? { commandRules, commandRuleAuthority: SYSTEM_COMMAND_RULE_AUTHORITY } : {},
366
+ receipt: applied.receipt
367
+ });
368
+ if (verification.state !== "current") {
369
+ throw new Error(`Pending machine setup did not verify: ${verification.reason ?? verification.state}`);
370
+ }
371
+ recordHarnessIntegrationReceipt(targetRoot, storeRoot, applied.receipt);
372
+ completeHarnessSystemOperation(targetRoot, storeRoot, pending, applied.receipt);
373
+ if (options.persistIntent !== false) {
374
+ persistRecoveredHarnessIntent(storeRoot, pending);
375
+ }
376
+ return makeResult("configured", selections, [pending.harnessId], [], null);
377
+ } catch (error) {
378
+ return makeResult("recovery", selections, [], [{ harness: pending.harnessId, reason: error instanceof Error ? error.message : String(error), nextAction: recoveryAction }], recoveryAction);
379
+ }
380
+ }
381
+ function persistRecoveredHarnessIntent(storeRoot, pending) {
382
+ const current = loadGlobalConfig(storeRoot).config;
383
+ current.settings.harnesses[pending.harnessId] = {
384
+ selected: true,
385
+ maximumMethod: pending.connectionMethod,
386
+ accessCeiling: deriveHarnessAccessCeiling(pending.connectionMethod)
387
+ };
388
+ writeGlobalConfig(storeRoot, current);
389
+ }
390
+ function buildIntentProjection(storeRoot, selections, included, enabled) {
391
+ const loaded = loadGlobalConfig(storeRoot);
392
+ const changes = [];
393
+ if (!enabled) return { config: loaded.config, changes };
394
+ for (const harness of Object.keys(selections)) {
395
+ if (!included[harness]) continue;
396
+ const method = selections[harness];
397
+ const previous = loaded.config.settings.harnesses[harness];
398
+ const sameMethod = previous?.selected === (method !== "none") && previous.maximumMethod === (method === "none" ? null : method);
399
+ const intent = {
400
+ selected: method !== "none",
401
+ maximumMethod: method === "none" ? null : method,
402
+ accessCeiling: sameMethod && previous ? previous.accessCeiling : deriveHarnessAccessCeiling(method)
403
+ };
404
+ resolveEffectiveHarnessIntegration(void 0, intent, harness);
405
+ const next = { ...previous ?? {}, ...intent };
406
+ if (JSON.stringify(previous ?? null) !== JSON.stringify(next)) {
407
+ changes.push({
408
+ harness,
409
+ before: previous?.selected && previous.maximumMethod ? previous.maximumMethod : "none",
410
+ after: method
411
+ });
412
+ }
413
+ loaded.config.settings.harnesses[harness] = next;
414
+ }
415
+ return { config: loaded.config, changes };
416
+ }
417
+ function renderIntentChanges(storeRoot, changes) {
418
+ const configPath = path.join(storeRoot, "config.json");
419
+ if (changes.length === 0) {
420
+ return `Global intent file: ${configPath}
421
+ - Effect: no global harness intent change.`;
422
+ }
423
+ return [
424
+ `Global intent file: ${configPath}`,
425
+ ...changes.map((change) => `- ${label(change.harness)} intent: ${change.before} -> ${change.after}`),
426
+ "- Effect: saves the reviewed machine access ceiling only after its native harness state verifies."
427
+ ].join("\n");
428
+ }
429
+ function validateProjectHarnessIntegrations(records, selections, included) {
430
+ for (const harness of Object.keys(selections)) {
431
+ if (!included[harness]) continue;
432
+ const method = selections[harness];
433
+ resolveEffectiveHarnessIntegration(
434
+ records?.find((record) => record.harness === harness),
435
+ {
436
+ selected: method !== "none",
437
+ maximumMethod: method === "none" ? null : method,
438
+ accessCeiling: deriveHarnessAccessCeiling(method)
439
+ },
440
+ harness
441
+ );
442
+ }
443
+ }
444
+ function methodReviewFacts(method, rules) {
445
+ const ruleOperations = new Set(rules.flatMap((rule) => [...rule.operationIds]));
446
+ const admitted = listOperationAccessFacts().filter(
447
+ (fact) => method.allowedStoreOperations === "active-operation-registry" ? fact.mcpReady : fact.status === "active" && ruleOperations.has(fact.operation)
448
+ );
449
+ return {
450
+ operations: admitted.map((fact) => fact.operation),
451
+ operationEffects: admitted.map((fact) => ({ operation: fact.operation, ...fact.access })),
452
+ allowedStoreOperations: method.allowedStoreOperations,
453
+ ownedEntries: [...method.ownedEntries]
454
+ };
455
+ }
456
+ function deriveHarnessAccessCeiling(method) {
457
+ if (method === "none") return { store: "none", project: "none", hostConfig: "none" };
458
+ const facts = listOperationAccessFacts().filter((fact) => fact.status === "active" && (method === "mcp" || fact.commandRuleCandidate));
459
+ const maximum = (values) => values.includes("write") ? "write" : values.includes("read") ? "read" : "none";
460
+ return {
461
+ store: maximum(facts.map((fact) => fact.access.store)),
462
+ project: maximum(facts.map((fact) => fact.access.project)),
463
+ hostConfig: "none"
464
+ };
465
+ }
466
+ function verifyCurrentExecutable() {
467
+ const executablePath = path.resolve(process.argv[1] ?? "");
468
+ return verifyMakeDocsExecutable({ executablePath });
469
+ }
470
+ function tryVerifyCurrentExecutable() {
471
+ try {
472
+ return { executable: verifyCurrentExecutable() };
473
+ } catch (error) {
474
+ return { error: error instanceof Error ? error : new Error(String(error)) };
475
+ }
476
+ }
477
+ function formatExecutableVerificationFailure(error) {
478
+ if (error instanceof ExecutableVerificationError) {
479
+ return [
480
+ `${error.code}: ${error.message}`,
481
+ `Launch path: ${error.launchPath}.`,
482
+ `Resolved path: ${error.resolvedPath ?? "unresolved"}.`,
483
+ `Failed rule: ${error.failedRule}.`,
484
+ `Next: ${error.nextAction}`
485
+ ].join(" ");
486
+ }
487
+ return `package-identity-unproved: ${error?.message ?? "The active packaged Make Docs executable could not be verified."} Next: Run setup from the installed package command and review the exact failure.`;
488
+ }
489
+ function blockedPlan(harness, method, detail, file, reviewFacts) {
490
+ return { harness, method, status: "blocked", ...reviewFacts, machineFiles: [file], changed: false, detail, async apply() {
491
+ }, async verify() {
492
+ return false;
493
+ } };
494
+ }
495
+ function makeResult(status, selections, configured, blocked, recoveryAction) {
496
+ const mutationState = status === "configured" ? "verified" : status === "partial" || status === "recovery" ? "partial" : "none";
497
+ return { schemaVersion: 2, status, scope: "machine", selections, configured, skipped: Object.keys(selections).filter((h) => selections[h] === "none"), blocked, attemptedWork: [...configured.map((harness) => `verified ${harness}`), ...blocked.map((item) => `checked ${item.harness}`)], mutationState, failedCondition: blocked[0]?.reason ?? null, nextAction: recoveryAction ?? blocked[0]?.nextAction ?? null, recoveryAction };
498
+ }
499
+ function label(harness) {
500
+ return harness === "claude-code" ? "Claude Code" : "Codex";
501
+ }
502
+ function renderSystemPlans(plans) {
503
+ if (!plans.length) return ["No native harness method is selected.", "Choosing none makes no native file changes.", "Resource reads need no Store access."].join("\n");
504
+ return plans.flatMap((plan) => {
505
+ const ceiling = deriveHarnessAccessCeiling(plan.method);
506
+ return [
507
+ `${label(plan.harness)} \u2014 ${plan.method}`,
508
+ `- State: ${plan.status}`,
509
+ `- Native files: ${plan.machineFiles.join(", ") || "none"}`,
510
+ `- Owned native entries: ${plan.ownedEntries.join(", ") || "none"}`,
511
+ `- Admitted operation IDs: ${plan.operations.join(", ") || "none"}`,
512
+ `- Store effects: ${plan.operationEffects.map((effect) => `${effect.operation} (Store ${effect.store})`).join(", ") || "none"}`,
513
+ `- Access ceiling: Store ${ceiling.store}; project ${ceiling.project}; host config ${ceiling.hostConfig}`,
514
+ `- Effect: ${plan.detail}`,
515
+ "- None effect: no native file changes; Store-backed agent operations stay unavailable; resource reads still need no Store access."
516
+ ];
517
+ }).join("\n");
518
+ }
519
+ function inspectSystemHarnesses(root = platform.userHome()) {
520
+ return FIRST_PARTY_HARNESS_ADAPTERS.map((adapter) => {
521
+ const detection = adapter.detect({ scope: "machine", root });
522
+ return { harness: adapter.harnessId, state: detection.state, detail: detection.reason ?? (detection.evidence.length ? detection.evidence.join(", ") : "No native entry found"), ...detection.state === "blocked" ? { nextAction: `Resolve access to the ${adapter.displayName} native files, then run \`make-docs setup system\` again.` } : {} };
523
+ });
524
+ }
525
+ function renderMethodSupport(root, selected, executableAttempt) {
526
+ return FIRST_PARTY_HARNESS_ADAPTERS.filter((adapter) => selected[adapter.harnessId]).flatMap((adapter) => adapter.methods.map((method) => {
527
+ const support = resolveHarnessMethodSupport(adapter, method.id);
528
+ const state = support.selectable && executableAttempt.executable ? support.state : "blocked";
529
+ const detail = support.selectable && executableAttempt.error ? formatExecutableVerificationFailure(executableAttempt.error) : `${support.reason} Next: ${support.nextAction}`;
530
+ return `${adapter.displayName} ${method.id}: ${state}; ${detail}; native file ${path.resolve(root, method.nativeFile("machine"))}; owned native entries ${method.ownedEntries.join(", ")}.`;
531
+ }));
532
+ }
533
+ export {
534
+ SYSTEM_COMMAND_RULE_AUTHORITY,
535
+ applyPreparedSystemSetup,
536
+ deriveHarnessAccessCeiling,
537
+ inspectSystemHarnesses,
538
+ prepareSystemSetupCommand,
539
+ promptForSystemSetupMethods,
540
+ renderSystemPlans,
541
+ resumePendingSystemSetupCommand,
542
+ runSystemSetupCommand
543
+ };
544
+ //# sourceMappingURL=setup-system-HZROFNMP.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/setup-system.ts"],"sourcesContent":["import { confirm, isCancel, select } from \"@clack/prompts\";\nimport path from \"node:path\";\nimport { existsSync } from \"node:fs\";\nimport { ExecutableVerificationError, FIRST_PARTY_HARNESS_ADAPTERS, listBoundedHarnessCommandRules, requireFirstPartyHarnessAdapter, resolveHarnessMethodSupport, verifyMakeDocsExecutable, type HarnessAccessReceipt, type HarnessCommandRule, type HarnessCommandRuleAuthority, type HarnessMethodDefinition, type HarnessMethodSelection, type VerifiedExecutableIdentity } from \"./harness-access/index.js\";\nimport { resolveEffectiveHarnessIntegration, type ProjectHarnessIntegrationRecord } from \"./config\";\nimport { listHarnessCommandRules, listOperationAccessFacts, validateRegistryHarnessCommandRules } from \"./operations/registry\";\nimport { getStoreDatabasePath, resolveStoreRoot } from \"./store/paths\";\nimport { loadGlobalConfig, writeGlobalConfig, type GlobalConfig } from \"./store/global-config\";\nimport { readCurrentHarnessIntegrationReceipt, recordHarnessIntegrationReceipt } from \"./store/harness-integration-receipts\";\nimport { completeHarnessSystemOperation, prepareHarnessSystemOperation, readPendingHarnessSystemOperation, type PendingHarnessSystemOperation } from \"./store/harness-system-operations\";\nimport { readInstallationStatus } from \"./store/installation-state\";\nimport type { SetupHarnessState } from \"./setup-state\";\nimport type { Harness } from \"./types\";\nimport { platform } from \"./platform\";\n\nexport const SYSTEM_COMMAND_RULE_AUTHORITY: HarnessCommandRuleAuthority = Object.freeze({\n list: listHarnessCommandRules,\n validate: validateRegistryHarnessCommandRules,\n});\n\nexport type SystemSetupStatus = \"configured\" | \"skipped-none\" | \"blocked\" | \"partial\" | \"failed\" | \"recovery\" | \"unchanged\";\nexport interface SystemSetupResult { schemaVersion: 2; status: SystemSetupStatus; scope: \"machine\"; selections: Record<Harness, HarnessMethodSelection>; configured: Harness[]; skipped: Harness[]; blocked: Array<{ harness: Harness; reason: string; nextAction: string }>; attemptedWork: string[]; mutationState: \"none\" | \"planned\" | \"partial\" | \"verified\"; failedCondition: string | null; nextAction: string | null; recoveryAction: string | null; }\nexport type SystemHarnessState = \"current\" | \"drifted\" | \"blocked\" | \"unsupported\" | \"incomplete\" | \"pending\";\nexport interface SystemHarnessOperationEffect { operation: string; store: \"none\" | \"read\" | \"write\"; project: \"none\" | \"read\" | \"write\"; hostConfig: \"none\" | \"read\" | \"write\"; }\nexport interface SystemHarnessPlan { harness: Harness; method: string; status: SystemHarnessState; operations: string[]; operationEffects: SystemHarnessOperationEffect[]; allowedStoreOperations: HarnessMethodDefinition[\"allowedStoreOperations\"]; ownedEntries: string[]; machineFiles: string[]; changed: boolean; detail: string; apply(): Promise<void>; verify(): Promise<boolean>; pendingOperation?(): boolean; }\nexport interface RunSystemSetupOptions { dryRun: boolean; yes: boolean; harnesses: Record<Harness, boolean>; methods?: Partial<Record<Harness, HarnessMethodSelection>>; promptForMethods?: boolean; projectHarnessIntegrations?: readonly ProjectHarnessIntegrationRecord[]; targetRoot?: string; storeRoot?: string; machineRoot?: string; executable?: VerifiedExecutableIdentity; appliedVersion?: string; persistIntent?: boolean; onReview?: (review: string) => void; afterNativeApplyForTests?: () => void | Promise<void>; }\n\ninterface SystemIntentChange {\n harness: Harness;\n before: HarnessMethodSelection;\n after: HarnessMethodSelection;\n}\n\nexport interface SystemIntentProjection {\n config: GlobalConfig;\n changes: SystemIntentChange[];\n}\n\nexport interface PreparedSystemSetup {\n options: RunSystemSetupOptions;\n machineRoot: string;\n targetRoot: string;\n storeRoot: string;\n selections: Record<Harness, HarnessMethodSelection>;\n plans: SystemHarnessPlan[];\n intent: SystemIntentProjection;\n review: string;\n changed: boolean;\n}\n\ninterface ExecutableVerificationAttempt {\n executable?: VerifiedExecutableIdentity;\n error?: Error;\n}\n\nexport async function runSystemSetupCommand(options: RunSystemSetupOptions): Promise<SystemSetupResult> {\n const resumed = await resumePendingSystemSetupCommand(options);\n if (resumed) return resumed;\n const prepared = await prepareSystemSetupCommand(options);\n options.onReview?.(prepared.review);\n const blockedPlans = prepared.plans.filter(plan => plan.status === \"blocked\" || plan.status === \"unsupported\");\n const runnablePlans = prepared.plans.filter(plan => plan.status !== \"blocked\" && plan.status !== \"unsupported\");\n if (blockedPlans.length && runnablePlans.length === 0) {\n const blocked = blockedPlans.map(plan => ({ harness: plan.harness, reason: plan.detail, nextAction: plan.detail }));\n return makeResult(\"blocked\", prepared.selections, [], blocked, blocked[0]?.nextAction ?? null);\n }\n if (options.dryRun) {\n const blocked = blockedPlans.map(plan => ({ harness: plan.harness, reason: plan.detail, nextAction: plan.detail }));\n return makeResult(\n blocked.length || prepared.changed ? \"partial\" : prepared.plans.length ? \"unchanged\" : \"skipped-none\",\n prepared.selections,\n [],\n blocked,\n prepared.changed ? \"Run `make-docs setup system --yes` to apply the reviewed machine changes.\" : blocked[0]?.nextAction ?? null,\n );\n }\n if (prepared.changed && !options.yes) {\n const approved = await confirm({ message: \"Apply the reviewed changes to this computer?\", initialValue: false, active: \"Yes\", inactive: \"No\", withGuide: true });\n if (isCancel(approved) || !approved) return makeResult(\"blocked\", prepared.selections, [], [], \"Run `make-docs setup system` and approve the reviewed machine changes.\");\n }\n return applyPreparedSystemSetup(prepared);\n}\n\nexport async function resumePendingSystemSetupCommand(\n options: RunSystemSetupOptions,\n): Promise<SystemSetupResult | null> {\n return resumePendingSystemSetup(\n options,\n options.machineRoot ?? platform.userHome(),\n options.targetRoot ?? process.cwd(),\n options.storeRoot ?? resolveStoreRoot(),\n );\n}\n\nexport async function prepareSystemSetupCommand(options: RunSystemSetupOptions): Promise<PreparedSystemSetup> {\n const machineRoot = options.machineRoot ?? platform.userHome();\n const targetRoot = options.targetRoot ?? process.cwd();\n const storeRoot = options.storeRoot ?? resolveStoreRoot();\n const executableAttempt: ExecutableVerificationAttempt = options.executable\n ? { executable: options.executable }\n : tryVerifyCurrentExecutable();\n const selections = await selectMethods(options, machineRoot, storeRoot, executableAttempt);\n validateProjectHarnessIntegrations(options.projectHarnessIntegrations, selections, options.harnesses);\n const plans = buildAdapterPlans(options, selections, machineRoot, targetRoot, storeRoot, executableAttempt);\n const intent = buildIntentProjection(storeRoot, selections, options.harnesses, options.persistIntent !== false);\n const detection = inspectSystemHarnesses(machineRoot).filter(state => options.harnesses[state.harness]);\n const review = [\n ...detection.map(state => `${label(state.harness)} detection: ${state.state}${state.detail ? ` (${state.detail})` : \"\"}${state.nextAction ? ` Next: ${state.nextAction}` : \"\"}`),\n \"Detection is a hint. It does not prove support or limit your choice.\",\n \"\",\n ...renderMethodSupport(machineRoot, options.harnesses, executableAttempt),\n \"Generic MCP client: available; Make Docs prints a standard configuration and does not edit client-owned files. Next: rerun setup with `--generic-mcp-client <label>`.\",\n \"\",\n renderSystemPlans(plans),\n \"\",\n renderIntentChanges(storeRoot, intent.changes),\n ].join(\"\\n\");\n return {\n options,\n machineRoot,\n targetRoot,\n storeRoot,\n selections,\n plans,\n intent,\n review,\n changed: plans.some(plan => plan.changed) || intent.changes.length > 0,\n };\n}\n\n/** Run only the method screens. Full project setup uses this between harness selection and shared Skills. */\nexport async function promptForSystemSetupMethods(\n options: RunSystemSetupOptions,\n): Promise<Record<Harness, HarnessMethodSelection>> {\n const machineRoot = options.machineRoot ?? platform.userHome();\n const storeRoot = options.storeRoot ?? resolveStoreRoot();\n return selectMethods(\n { ...options, promptForMethods: true, yes: false, dryRun: false },\n machineRoot,\n storeRoot,\n options.executable ? { executable: options.executable } : tryVerifyCurrentExecutable(),\n );\n}\n\nexport async function applyPreparedSystemSetup(prepared: PreparedSystemSetup): Promise<SystemSetupResult> {\n const { options, plans, selections, targetRoot, storeRoot } = prepared;\n const blockedPlans = plans.filter(plan => plan.status === \"blocked\" || plan.status === \"unsupported\");\n const blocked: SystemSetupResult[\"blocked\"] = blockedPlans.map(plan => ({\n harness: plan.harness,\n reason: plan.detail,\n nextAction: plan.detail,\n }));\n const runnable = plans.filter(plan => plan.status !== \"blocked\" && plan.status !== \"unsupported\");\n const changed = runnable.filter(plan => plan.changed);\n const configured: Harness[] = [];\n let recoveryAction: string | null = null;\n for (const plan of runnable) {\n if (!plan.changed) {\n if (options.persistIntent !== false) {\n persistReviewedHarnessIntent(storeRoot, prepared.intent.config, plan.harness);\n }\n configured.push(plan.harness);\n continue;\n }\n try {\n await plan.apply();\n if (!(await plan.verify())) {\n const recovery = recoveryActionForPlanFailure(\n plan,\n \"The applied native entry did not verify.\",\n targetRoot,\n storeRoot,\n );\n blocked.push({ harness: plan.harness, reason: \"The applied native entry did not verify.\", nextAction: recovery });\n recoveryAction ??= recovery;\n if (plan.pendingOperation?.()) break;\n continue;\n }\n if (options.persistIntent !== false) {\n persistReviewedHarnessIntent(storeRoot, prepared.intent.config, plan.harness);\n }\n configured.push(plan.harness);\n } catch (error) {\n const reason = error instanceof Error ? error.message : String(error);\n const recovery = recoveryActionForPlanFailure(\n plan,\n reason,\n targetRoot,\n storeRoot,\n );\n blocked.push({ harness: plan.harness, reason, nextAction: recovery });\n recoveryAction ??= recovery;\n if (plan.pendingOperation?.()) break;\n }\n }\n if (options.persistIntent !== false) {\n persistReviewedDisabledIntents(storeRoot, prepared.intent.config, selections, options.harnesses);\n }\n if (blocked.length > 0) {\n const status: SystemSetupStatus = recoveryAction\n ? configured.length > 0 ? \"partial\" : \"recovery\"\n : configured.length > 0 ? \"partial\" : \"blocked\";\n return makeResult(status, selections, configured, blocked, recoveryAction ?? blocked[0]?.nextAction ?? null);\n }\n if (!changed.length) {\n if (prepared.intent.changes.length > 0) {\n if ((Object.keys(options.harnesses) as Harness[]).some(harness => options.harnesses[harness] && selections[harness] !== \"none\")) {\n return makeResult(\"configured\", selections, [], [], null);\n }\n return makeResult(\"skipped-none\", selections, [], [], null);\n }\n if (plans.length) {\n return makeResult(\"unchanged\", selections, plans.map(plan => plan.harness), [], null);\n }\n return makeResult(\"skipped-none\", selections, [], [], null);\n }\n return makeResult(\"configured\", selections, configured, [], null);\n}\n\nfunction persistReviewedHarnessIntent(\n storeRoot: string,\n projected: GlobalConfig,\n harness: Harness,\n): void {\n const intent = projected.settings.harnesses[harness];\n if (!intent) return;\n const current = loadGlobalConfig(storeRoot).config;\n current.settings.harnesses[harness] = { ...intent, accessCeiling: { ...intent.accessCeiling } };\n writeGlobalConfig(storeRoot, current);\n}\n\nfunction persistReviewedDisabledIntents(\n storeRoot: string,\n projected: GlobalConfig,\n selections: Record<Harness, HarnessMethodSelection>,\n included: Record<Harness, boolean>,\n): void {\n for (const harness of Object.keys(selections) as Harness[]) {\n if (included[harness] && selections[harness] === \"none\") {\n persistReviewedHarnessIntent(storeRoot, projected, harness);\n }\n }\n}\n\nfunction recoveryActionForPlanFailure(\n plan: SystemHarnessPlan,\n reason: string,\n targetRoot: string,\n storeRoot: string,\n): string {\n if (reason.includes(\"Run make-docs setup to review and apply the compatibility bridge\")) {\n return \"Run `make-docs setup` to review and apply the Store compatibility bridge. Full setup will retry the approved machine work after that prerequisite verifies.\";\n }\n if (reason.includes(\"Store operation is already pending\")) {\n try {\n const currentProject = readInstallationStatus(targetRoot, storeRoot);\n const pendingProject = \"pendingOperation\" in currentProject\n ? currentProject.pendingOperation\n : null;\n if (currentProject.status === \"recovery-required\" && pendingProject) {\n return \"Run `make-docs setup` again. Setup will review the unfinished work for this project before it builds a new computer plan.\";\n }\n if (\n currentProject.status === \"recovery-required\" &&\n \"toolOperations\" in currentProject &&\n currentProject.toolOperations.length > 0\n ) {\n return \"A machine-wide Store operation is still pending. Finish or recover that recorded tool operation, then run `make-docs setup` again to build a current computer plan.\";\n }\n if (currentProject.status === \"writer-active\") {\n return \"This project has an active writer. Wait for it to finish, then run `make-docs setup` again to build a current computer plan.\";\n }\n return \"This project has no pending operation to recover. Wait for the reported Store writer to finish, then run `make-docs setup` again. Setup will build a new computer plan from current Store state.\";\n } catch {\n return \"Run `make-docs setup` again. Setup will read the current project state before it builds a new computer plan.\";\n }\n }\n if (plan.pendingOperation?.()) {\n return `Run \\`make-docs setup system\\` to resume the recorded ${label(plan.harness)} machine change.`;\n }\n return `Correct the reported ${label(plan.harness)} prerequisite, then run \\`make-docs setup system\\` to review a new machine plan.`;\n}\n\nasync function selectMethods(\n options: RunSystemSetupOptions,\n root: string,\n storeRoot: string,\n executableAttempt: ExecutableVerificationAttempt,\n): Promise<Record<Harness, HarnessMethodSelection>> {\n const chosen: Record<Harness, HarnessMethodSelection> = { codex: \"none\", \"claude-code\": \"none\" };\n const existing = loadGlobalConfig(storeRoot).config.settings.harnesses;\n for (const adapter of FIRST_PARTY_HARNESS_ADAPTERS) {\n const saved = existing[adapter.harnessId];\n const savedMethod = saved?.selected && adapter.methods.some(method => method.id === saved.maximumMethod)\n ? saved.maximumMethod as HarnessMethodSelection\n : \"none\";\n chosen[adapter.harnessId] = savedMethod;\n if (!options.harnesses[adapter.harnessId]) continue;\n const supplied = options.methods?.[adapter.harnessId];\n if (supplied) { chosen[adapter.harnessId] = supplied; continue; }\n if (!options.promptForMethods || options.yes || options.dryRun) {\n throw new Error(\n `${adapter.displayName} is included but has no explicit method. Pass the matching method flag, including \\`none\\` to disable it.`,\n );\n }\n const answer = await select<HarnessMethodSelection>({ message: `${adapter.displayName} connection method`, options: [\n { value: \"none\", label: \"None\", hint: \"No native file changes. Resource reads still need no Store access.\" },\n ...adapter.methods.map(method => { const support = resolveHarnessMethodSupport(adapter, method.id); const available = support.selectable && executableAttempt.executable !== undefined; const prerequisite = executableAttempt.error ? formatExecutableVerificationFailure(executableAttempt.error) : null; return { value: method.id, label: `${method.id} (${available ? \"available\" : \"unavailable\"})`, hint: `${path.resolve(root, method.nativeFile(\"machine\"))}. ${prerequisite ?? `${support.reason} Next: ${support.nextAction}`}` }; }),\n ], initialValue: savedMethod });\n if (isCancel(answer) || typeof answer !== \"string\") continue;\n const method = answer as HarnessMethodSelection;\n if (method === \"none\") { chosen[adapter.harnessId] = \"none\"; continue; }\n chosen[adapter.harnessId] = method;\n }\n return chosen;\n}\n\nfunction buildAdapterPlans(options: RunSystemSetupOptions, selections: Record<Harness, HarnessMethodSelection>, root: string, targetRoot: string, storeRoot: string, executableAttempt: ExecutableVerificationAttempt): SystemHarnessPlan[] {\n const rules = listBoundedHarnessCommandRules(SYSTEM_COMMAND_RULE_AUTHORITY);\n const plans: SystemHarnessPlan[] = [];\n for (const adapter of FIRST_PARTY_HARNESS_ADAPTERS) {\n const method = selections[adapter.harnessId];\n if (!options.harnesses[adapter.harnessId] || method === \"none\") continue;\n const support = resolveHarnessMethodSupport(adapter, method);\n const definition = adapter.methods.find(item => item.id === method)!;\n const nativeFile = path.resolve(root, definition.nativeFile(\"machine\"));\n const reviewFacts = methodReviewFacts(definition, rules);\n const currentReceipt: HarnessAccessReceipt | null = existsSync(getStoreDatabasePath(storeRoot))\n ? readCurrentHarnessIntegrationReceipt(targetRoot, storeRoot, \"machine\", adapter.harnessId, method)\n : null;\n if (!support.selectable) { plans.push(blockedPlan(adapter.harnessId, method, `${support.reason} Next: ${support.nextAction}`, nativeFile, reviewFacts)); continue; }\n if (!executableAttempt.executable) {\n plans.push(blockedPlan(adapter.harnessId, method, formatExecutableVerificationFailure(executableAttempt.error), nativeFile, reviewFacts));\n continue;\n }\n const executable = executableAttempt.executable;\n const commandRules = definition.requiresCommandRules ? rules : undefined;\n const adapterPlan = adapter.plan({ method, scope: \"machine\", root, executable, ...(commandRules ? { commandRules, commandRuleAuthority: SYSTEM_COMMAND_RULE_AUTHORITY } : {}), ...(currentReceipt ? { receipt: currentReceipt } : {}) });\n let receipt: HarnessAccessReceipt | undefined;\n let pending: PendingHarnessSystemOperation | undefined;\n plans.push({ harness: adapter.harnessId, method, status: adapterPlan.state === \"current\" ? \"current\" : adapterPlan.state === \"missing\" ? \"incomplete\" : adapterPlan.state, ...reviewFacts, machineFiles: adapterPlan.changes.map(change => change.path), changed: adapterPlan.changes.some(change => change.action !== \"none\"), detail: adapterPlan.nextAction,\n async apply() { pending = prepareHarnessSystemOperation({ targetRoot, storeRoot, adapterId: adapter.id, harnessId: adapter.harnessId, plan: adapterPlan, appliedVersion: options.appliedVersion ?? executable.packageVersion, verifiedAt: new Date().toISOString() }); receipt = adapter.apply({ plan: adapterPlan, approved: true, operationId: pending.operationId, appliedVersion: pending.appliedVersion, verifiedAt: pending.verifiedAt }).receipt; await options.afterNativeApplyForTests?.(); },\n async verify() { const exactReceipt = receipt ?? currentReceipt; const verification = adapter.verify({ method, scope: \"machine\", root, executable, ...(commandRules ? { commandRules, commandRuleAuthority: SYSTEM_COMMAND_RULE_AUTHORITY } : {}), ...(exactReceipt ? { receipt: exactReceipt } : {}) }); if (verification.state !== \"current\" || !exactReceipt) return false; if (receipt) recordHarnessIntegrationReceipt(targetRoot, storeRoot, receipt); if (pending) completeHarnessSystemOperation(targetRoot, storeRoot, pending, exactReceipt); return true; },\n pendingOperation() { return pending !== undefined; },\n });\n }\n return plans;\n}\n\nasync function resumePendingSystemSetup(\n options: RunSystemSetupOptions,\n machineRoot: string,\n targetRoot: string,\n storeRoot: string,\n): Promise<SystemSetupResult | null> {\n const pending = readPendingHarnessSystemOperation(targetRoot, storeRoot);\n if (!pending) return null;\n const selections: Record<Harness, HarnessMethodSelection> = { codex: \"none\", \"claude-code\": \"none\" };\n selections[pending.harnessId] = pending.connectionMethod;\n const recoveryAction = `Run \\`make-docs setup system --target ${JSON.stringify(targetRoot)}\\` again to resume machine setup ${pending.operationId}.`;\n if (options.dryRun) {\n return makeResult(\"recovery\", selections, [], [{ harness: pending.harnessId, reason: `Machine setup ${pending.operationId} is pending.`, nextAction: recoveryAction }], recoveryAction);\n }\n try {\n const adapter = requireFirstPartyHarnessAdapter(pending.harnessId);\n if (adapter.id !== pending.adapterId) throw new Error(\"The pending adapter identity does not match this build.\");\n if (!platform.samePath(pending.plan.root, machineRoot)) {\n throw new Error(`The pending machine root ${pending.plan.root} does not match ${machineRoot}.`);\n }\n const executable = verifyMakeDocsExecutable({\n executablePath: pending.plan.executable.path,\n expectedSha256: pending.plan.executable.sha256,\n });\n if (JSON.stringify(executable) !== JSON.stringify(pending.plan.executable)) {\n throw new Error(\"The pending executable identity does not match this installed Make Docs binary.\");\n }\n const definition = adapter.methods.find(method => method.id === pending.connectionMethod);\n if (!definition) throw new Error(`The pending ${pending.connectionMethod} method is not implemented by this adapter.`);\n const commandRules = definition.requiresCommandRules\n ? listBoundedHarnessCommandRules(SYSTEM_COMMAND_RULE_AUTHORITY)\n : undefined;\n const applied = adapter.apply({\n plan: pending.plan,\n approved: true,\n operationId: pending.operationId,\n appliedVersion: pending.appliedVersion,\n verifiedAt: pending.verifiedAt,\n });\n const verification = adapter.verify({\n method: pending.connectionMethod,\n scope: \"machine\",\n root: machineRoot,\n executable,\n ...(commandRules ? { commandRules, commandRuleAuthority: SYSTEM_COMMAND_RULE_AUTHORITY } : {}),\n receipt: applied.receipt,\n });\n if (verification.state !== \"current\") {\n throw new Error(`Pending machine setup did not verify: ${verification.reason ?? verification.state}`);\n }\n recordHarnessIntegrationReceipt(targetRoot, storeRoot, applied.receipt);\n completeHarnessSystemOperation(targetRoot, storeRoot, pending, applied.receipt);\n if (options.persistIntent !== false) {\n persistRecoveredHarnessIntent(storeRoot, pending);\n }\n return makeResult(\"configured\", selections, [pending.harnessId], [], null);\n } catch (error) {\n return makeResult(\"recovery\", selections, [], [{ harness: pending.harnessId, reason: error instanceof Error ? error.message : String(error), nextAction: recoveryAction }], recoveryAction);\n }\n}\n\nfunction persistRecoveredHarnessIntent(\n storeRoot: string,\n pending: PendingHarnessSystemOperation,\n): void {\n const current = loadGlobalConfig(storeRoot).config;\n current.settings.harnesses[pending.harnessId] = {\n selected: true,\n maximumMethod: pending.connectionMethod,\n accessCeiling: deriveHarnessAccessCeiling(pending.connectionMethod),\n };\n writeGlobalConfig(storeRoot, current);\n}\n\nfunction buildIntentProjection(\n storeRoot: string,\n selections: Record<Harness, HarnessMethodSelection>,\n included: Record<Harness, boolean>,\n enabled: boolean,\n): SystemIntentProjection {\n const loaded = loadGlobalConfig(storeRoot);\n const changes: SystemIntentChange[] = [];\n if (!enabled) return { config: loaded.config, changes };\n for (const harness of Object.keys(selections) as Harness[]) {\n if (!included[harness]) continue;\n const method = selections[harness];\n const previous = loaded.config.settings.harnesses[harness];\n const sameMethod = previous?.selected === (method !== \"none\") &&\n previous.maximumMethod === (method === \"none\" ? null : method);\n const intent = {\n selected: method !== \"none\",\n maximumMethod: method === \"none\" ? null : method,\n accessCeiling: sameMethod && previous\n ? previous.accessCeiling\n : deriveHarnessAccessCeiling(method),\n };\n resolveEffectiveHarnessIntegration(undefined, intent, harness);\n const next = { ...(previous ?? {}), ...intent };\n if (JSON.stringify(previous ?? null) !== JSON.stringify(next)) {\n changes.push({\n harness,\n before: previous?.selected && previous.maximumMethod\n ? previous.maximumMethod as HarnessMethodSelection\n : \"none\",\n after: method,\n });\n }\n loaded.config.settings.harnesses[harness] = next;\n }\n return { config: loaded.config, changes };\n}\n\nfunction renderIntentChanges(storeRoot: string, changes: readonly SystemIntentChange[]): string {\n const configPath = path.join(storeRoot, \"config.json\");\n if (changes.length === 0) {\n return `Global intent file: ${configPath}\\n- Effect: no global harness intent change.`;\n }\n return [\n `Global intent file: ${configPath}`,\n ...changes.map(change => `- ${label(change.harness)} intent: ${change.before} -> ${change.after}`),\n \"- Effect: saves the reviewed machine access ceiling only after its native harness state verifies.\",\n ].join(\"\\n\");\n}\n\nfunction validateProjectHarnessIntegrations(records: readonly ProjectHarnessIntegrationRecord[] | undefined, selections: Record<Harness, HarnessMethodSelection>, included: Record<Harness, boolean>): void {\n for (const harness of Object.keys(selections) as Harness[]) {\n if (!included[harness]) continue;\n const method = selections[harness];\n resolveEffectiveHarnessIntegration(\n records?.find(record => record.harness === harness),\n {\n selected: method !== \"none\",\n maximumMethod: method === \"none\" ? null : method,\n accessCeiling: deriveHarnessAccessCeiling(method),\n },\n harness,\n );\n }\n}\nfunction methodReviewFacts(\n method: HarnessMethodDefinition,\n rules: readonly HarnessCommandRule[],\n): Pick<SystemHarnessPlan, \"operations\" | \"operationEffects\" | \"allowedStoreOperations\" | \"ownedEntries\"> {\n const ruleOperations = new Set(rules.flatMap(rule => [...rule.operationIds]));\n const admitted = listOperationAccessFacts().filter(fact =>\n method.allowedStoreOperations === \"active-operation-registry\"\n ? fact.mcpReady\n : fact.status === \"active\" && ruleOperations.has(fact.operation),\n );\n return {\n operations: admitted.map(fact => fact.operation),\n operationEffects: admitted.map(fact => ({ operation: fact.operation, ...fact.access })),\n allowedStoreOperations: method.allowedStoreOperations,\n ownedEntries: [...method.ownedEntries],\n };\n}\n\nexport function deriveHarnessAccessCeiling(method: HarnessMethodSelection): { store: \"none\" | \"read\" | \"write\"; project: \"none\" | \"read\" | \"write\"; hostConfig: \"none\" } {\n if (method === \"none\") return { store: \"none\", project: \"none\", hostConfig: \"none\" };\n const facts = listOperationAccessFacts().filter(fact => fact.status === \"active\" && (method === \"mcp\" || fact.commandRuleCandidate));\n const maximum = (values: Array<\"none\" | \"read\" | \"write\">): \"none\" | \"read\" | \"write\" =>\n values.includes(\"write\") ? \"write\" : values.includes(\"read\") ? \"read\" : \"none\";\n return {\n store: maximum(facts.map(fact => fact.access.store)),\n project: maximum(facts.map(fact => fact.access.project)),\n hostConfig: \"none\",\n };\n}\nfunction verifyCurrentExecutable(): VerifiedExecutableIdentity {\n const executablePath = path.resolve(process.argv[1] ?? \"\");\n return verifyMakeDocsExecutable({ executablePath });\n}\nfunction tryVerifyCurrentExecutable(): ExecutableVerificationAttempt {\n try {\n return { executable: verifyCurrentExecutable() };\n } catch (error) {\n return { error: error instanceof Error ? error : new Error(String(error)) };\n }\n}\nfunction formatExecutableVerificationFailure(error?: Error): string {\n if (error instanceof ExecutableVerificationError) {\n return [\n `${error.code}: ${error.message}`,\n `Launch path: ${error.launchPath}.`,\n `Resolved path: ${error.resolvedPath ?? \"unresolved\"}.`,\n `Failed rule: ${error.failedRule}.`,\n `Next: ${error.nextAction}`,\n ].join(\" \");\n }\n return `package-identity-unproved: ${error?.message ?? \"The active packaged Make Docs executable could not be verified.\"} Next: Run setup from the installed package command and review the exact failure.`;\n}\nfunction blockedPlan(harness: Harness, method: string, detail: string, file: string, reviewFacts: Pick<SystemHarnessPlan, \"operations\" | \"operationEffects\" | \"allowedStoreOperations\" | \"ownedEntries\">): SystemHarnessPlan { return { harness, method, status: \"blocked\", ...reviewFacts, machineFiles: [file], changed: false, detail, async apply() {}, async verify() { return false; } }; }\nfunction makeResult(status: SystemSetupStatus, selections: Record<Harness, HarnessMethodSelection>, configured: Harness[], blocked: SystemSetupResult[\"blocked\"], recoveryAction: string | null): SystemSetupResult { const mutationState: SystemSetupResult[\"mutationState\"] = status === \"configured\" ? \"verified\" : status === \"partial\" || status === \"recovery\" ? \"partial\" : \"none\"; return { schemaVersion: 2, status, scope: \"machine\", selections, configured, skipped: (Object.keys(selections) as Harness[]).filter(h => selections[h] === \"none\"), blocked, attemptedWork: [...configured.map(harness => `verified ${harness}`), ...blocked.map(item => `checked ${item.harness}`)], mutationState, failedCondition: blocked[0]?.reason ?? null, nextAction: recoveryAction ?? blocked[0]?.nextAction ?? null, recoveryAction }; }\nfunction label(harness: Harness): string { return harness === \"claude-code\" ? \"Claude Code\" : \"Codex\"; }\n\nexport function renderSystemPlans(plans: SystemHarnessPlan[]): string {\n if (!plans.length) return [\"No native harness method is selected.\", \"Choosing none makes no native file changes.\", \"Resource reads need no Store access.\"].join(\"\\n\");\n return plans.flatMap(plan => {\n const ceiling = deriveHarnessAccessCeiling(plan.method as HarnessMethodSelection);\n return [\n `${label(plan.harness)} — ${plan.method}`,\n `- State: ${plan.status}`,\n `- Native files: ${plan.machineFiles.join(\", \") || \"none\"}`,\n `- Owned native entries: ${plan.ownedEntries.join(\", \") || \"none\"}`,\n `- Admitted operation IDs: ${plan.operations.join(\", \") || \"none\"}`,\n `- Store effects: ${plan.operationEffects.map(effect => `${effect.operation} (Store ${effect.store})`).join(\", \") || \"none\"}`,\n `- Access ceiling: Store ${ceiling.store}; project ${ceiling.project}; host config ${ceiling.hostConfig}`,\n `- Effect: ${plan.detail}`,\n \"- None effect: no native file changes; Store-backed agent operations stay unavailable; resource reads still need no Store access.\",\n ];\n }).join(\"\\n\");\n}\nexport function inspectSystemHarnesses(root = platform.userHome()): SetupHarnessState[] { return FIRST_PARTY_HARNESS_ADAPTERS.map(adapter => { const detection = adapter.detect({ scope: \"machine\", root }); return { harness: adapter.harnessId, state: detection.state, detail: detection.reason ?? (detection.evidence.length ? detection.evidence.join(\", \") : \"No native entry found\"), ...(detection.state === \"blocked\" ? { nextAction: `Resolve access to the ${adapter.displayName} native files, then run \\`make-docs setup system\\` again.` } : {}) }; }); }\nfunction renderMethodSupport(root: string, selected: Record<Harness, boolean>, executableAttempt: ExecutableVerificationAttempt): string[] { return FIRST_PARTY_HARNESS_ADAPTERS.filter(adapter => selected[adapter.harnessId]).flatMap(adapter => adapter.methods.map(method => { const support = resolveHarnessMethodSupport(adapter, method.id); const state = support.selectable && executableAttempt.executable ? support.state : \"blocked\"; const detail = support.selectable && executableAttempt.error ? formatExecutableVerificationFailure(executableAttempt.error) : `${support.reason} Next: ${support.nextAction}`; return `${adapter.displayName} ${method.id}: ${state}; ${detail}; native file ${path.resolve(root, method.nativeFile(\"machine\"))}; owned native entries ${method.ownedEntries.join(\", \")}.`; })); }\n"],"mappings":";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