@brucewaynedecoy/make-docs 2.0.4 → 2.0.5
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/dist/{backup-CM7RL2Q7.js → backup-2OT4A6LR.js} +4 -4
- package/dist/{chunk-GERMRLJ2.js → chunk-46MGH32G.js} +6 -4
- package/dist/chunk-46MGH32G.js.map +1 -0
- package/dist/{chunk-LV3CBXZB.js → chunk-CCYP5NU2.js} +3 -3
- package/dist/{chunk-OR5ZVGLG.js → chunk-CLSOY7NV.js} +151 -5
- package/dist/chunk-CLSOY7NV.js.map +1 -0
- package/dist/{chunk-ADVNSMA7.js → chunk-CMNKQM7L.js} +3 -3
- package/dist/{chunk-YVSASZMT.js → chunk-HXWD2EUD.js} +19 -14
- package/dist/chunk-HXWD2EUD.js.map +1 -0
- package/dist/{chunk-65QWMODG.js → chunk-I4FADOUK.js} +3 -3
- package/dist/{chunk-65QWMODG.js.map → chunk-I4FADOUK.js.map} +1 -1
- package/dist/{chunk-M7DMFIKU.js → chunk-ISSMVKIA.js} +224 -20
- package/dist/chunk-ISSMVKIA.js.map +1 -0
- package/dist/{chunk-J5QDGRZ7.js → chunk-UNR4CYVX.js} +116 -37
- package/dist/chunk-UNR4CYVX.js.map +1 -0
- package/dist/{chunk-7R2PPKTB.js → chunk-VMKG3H4B.js} +2 -2
- package/dist/{chunk-52FTNVXS.js → chunk-XDSWX4Y4.js} +8906 -2899
- package/dist/chunk-XDSWX4Y4.js.map +1 -0
- package/dist/index.js +210 -86
- package/dist/index.js.map +1 -1
- package/dist/registry-PC5GKAKM.js +50 -0
- package/dist/registry-PC5GKAKM.js.map +1 -0
- package/dist/{self-36ULRIJ6.js → self-WYVXO23B.js} +10 -10
- package/dist/server-BQOG6FTA.js +1113 -0
- package/dist/server-BQOG6FTA.js.map +1 -0
- package/dist/{setup-system-JI36YJ6D.js → setup-system-KN7FTTLT.js} +263 -40
- package/dist/setup-system-KN7FTTLT.js.map +1 -0
- package/dist/{skills-command-IGDVLNKY.js → skills-command-KEW7MOEW.js} +17 -7
- package/dist/skills-command-KEW7MOEW.js.map +1 -0
- package/dist/{uninstall-VBGMQQLA.js → uninstall-45XF4CHD.js} +9 -9
- package/dist/virtual_make-docs-first-party-skills-ECJESFL2.js +11 -0
- package/dist/virtual_make-docs-first-party-skills-ECJESFL2.js.map +1 -0
- package/package.json +5 -5
- package/skill-registry.json +24 -8
- package/skill-registry.schema.json +2 -1
- package/template/.make-docs/system/contracts/system-resource-contract.md +16 -0
- package/template/.make-docs/system-resources.catalog.json +415 -0
- package/template/.make-docs/system-resources.schema.json +25 -0
- package/dist/chunk-52FTNVXS.js.map +0 -1
- package/dist/chunk-GERMRLJ2.js.map +0 -1
- package/dist/chunk-J5QDGRZ7.js.map +0 -1
- package/dist/chunk-M7DMFIKU.js.map +0 -1
- package/dist/chunk-OR5ZVGLG.js.map +0 -1
- package/dist/chunk-YVSASZMT.js.map +0 -1
- package/dist/server-H754TA4Q.js +0 -512
- package/dist/server-H754TA4Q.js.map +0 -1
- package/dist/setup-system-JI36YJ6D.js.map +0 -1
- package/dist/skills-command-IGDVLNKY.js.map +0 -1
- package/dist/virtual_make-docs-first-party-skills-H3FC47C2.js +0 -11
- package/dist/virtual_make-docs-first-party-skills-H3FC47C2.js.map +0 -1
- /package/dist/{backup-CM7RL2Q7.js.map → backup-2OT4A6LR.js.map} +0 -0
- /package/dist/{chunk-LV3CBXZB.js.map → chunk-CCYP5NU2.js.map} +0 -0
- /package/dist/{chunk-ADVNSMA7.js.map → chunk-CMNKQM7L.js.map} +0 -0
- /package/dist/{chunk-7R2PPKTB.js.map → chunk-VMKG3H4B.js.map} +0 -0
- /package/dist/{self-36ULRIJ6.js.map → self-WYVXO23B.js.map} +0 -0
- /package/dist/{uninstall-VBGMQQLA.js.map → uninstall-45XF4CHD.js.map} +0 -0
|
@@ -3,44 +3,51 @@ import {
|
|
|
3
3
|
listHarnessCommandRules,
|
|
4
4
|
listOperationAccessFacts,
|
|
5
5
|
validateRegistryHarnessCommandRules
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-XDSWX4Y4.js";
|
|
7
|
+
import {
|
|
8
|
+
resolveEffectiveHarnessIntegration
|
|
9
|
+
} from "./chunk-CLSOY7NV.js";
|
|
10
|
+
import "./chunk-VMKG3H4B.js";
|
|
11
|
+
import {
|
|
12
|
+
confirm,
|
|
13
|
+
isCancel,
|
|
14
|
+
select
|
|
15
|
+
} from "./chunk-3EXHM5L2.js";
|
|
7
16
|
import {
|
|
8
17
|
completeHarnessSystemOperation,
|
|
18
|
+
failHarnessSystemOperation,
|
|
9
19
|
loadGlobalConfig,
|
|
10
20
|
prepareHarnessSystemOperation,
|
|
11
21
|
readCurrentHarnessIntegrationReceipt,
|
|
12
22
|
readPendingHarnessSystemOperation,
|
|
13
23
|
recordHarnessIntegrationReceipt,
|
|
14
24
|
writeGlobalConfig
|
|
15
|
-
} from "./chunk-
|
|
16
|
-
import {
|
|
17
|
-
resolveEffectiveHarnessIntegration
|
|
18
|
-
} from "./chunk-OR5ZVGLG.js";
|
|
19
|
-
import "./chunk-7R2PPKTB.js";
|
|
20
|
-
import {
|
|
21
|
-
confirm,
|
|
22
|
-
isCancel,
|
|
23
|
-
select
|
|
24
|
-
} from "./chunk-3EXHM5L2.js";
|
|
25
|
+
} from "./chunk-UNR4CYVX.js";
|
|
25
26
|
import {
|
|
26
27
|
ExecutableVerificationError,
|
|
27
28
|
FIRST_PARTY_HARNESS_ADAPTERS,
|
|
29
|
+
classifyPendingNativeMcpChange,
|
|
30
|
+
createMcpConnection,
|
|
31
|
+
hashMcpConnectionKey,
|
|
28
32
|
listBoundedHarnessCommandRules,
|
|
33
|
+
readNativeMcpConnection,
|
|
34
|
+
renderManualMcpEntry,
|
|
29
35
|
requireFirstPartyHarnessAdapter,
|
|
30
36
|
resolveHarnessMethodSupport,
|
|
31
|
-
verifyMakeDocsExecutable
|
|
32
|
-
|
|
37
|
+
verifyMakeDocsExecutable,
|
|
38
|
+
verifyManualMcpEntry
|
|
39
|
+
} from "./chunk-ISSMVKIA.js";
|
|
33
40
|
import {
|
|
34
41
|
getStoreDatabasePath,
|
|
35
42
|
platform,
|
|
36
43
|
readInstallationStatus,
|
|
37
44
|
resolveStoreRoot
|
|
38
|
-
} from "./chunk-
|
|
45
|
+
} from "./chunk-HXWD2EUD.js";
|
|
39
46
|
import "./chunk-D4HDZEJT.js";
|
|
40
47
|
|
|
41
48
|
// src/setup-system.ts
|
|
42
49
|
import path from "path";
|
|
43
|
-
import { existsSync } from "fs";
|
|
50
|
+
import { existsSync, lstatSync, readFileSync } from "fs";
|
|
44
51
|
var SYSTEM_COMMAND_RULE_AUTHORITY = Object.freeze({
|
|
45
52
|
list: listHarnessCommandRules,
|
|
46
53
|
validate: validateRegistryHarnessCommandRules
|
|
@@ -86,6 +93,9 @@ async function prepareSystemSetupCommand(options) {
|
|
|
86
93
|
const storeRoot = options.storeRoot ?? resolveStoreRoot();
|
|
87
94
|
const executableAttempt = options.executable ? { executable: options.executable } : tryVerifyCurrentExecutable();
|
|
88
95
|
const selections = await selectMethods(options, machineRoot, storeRoot, executableAttempt);
|
|
96
|
+
if (options.rotateMcp && !Object.keys(selections).some((harness) => options.harnesses[harness] && selections[harness] === "mcp")) {
|
|
97
|
+
throw new Error("MCP key rotation needs a selected MCP method.");
|
|
98
|
+
}
|
|
89
99
|
validateProjectHarnessIntegrations(options.projectHarnessIntegrations, selections, options.harnesses);
|
|
90
100
|
const plans = buildAdapterPlans(options, selections, machineRoot, targetRoot, storeRoot, executableAttempt);
|
|
91
101
|
const intent = buildIntentProjection(storeRoot, selections, options.harnesses, options.persistIntent !== false);
|
|
@@ -98,6 +108,7 @@ async function prepareSystemSetupCommand(options) {
|
|
|
98
108
|
"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
109
|
"",
|
|
100
110
|
renderSystemPlans(plans),
|
|
111
|
+
...plans.filter((plan) => plan.manualMcpOffer).map((plan) => `${label(plan.harness)} manual MCP path: after approval, issue one connection key for this project. The key appears once after project setup finishes. The native file stays client-owned.`),
|
|
101
112
|
"",
|
|
102
113
|
renderIntentChanges(storeRoot, intent.changes)
|
|
103
114
|
].join("\n");
|
|
@@ -110,7 +121,7 @@ async function prepareSystemSetupCommand(options) {
|
|
|
110
121
|
plans,
|
|
111
122
|
intent,
|
|
112
123
|
review,
|
|
113
|
-
changed: plans.some((plan) => plan.changed) || intent.changes.length > 0
|
|
124
|
+
changed: plans.some((plan) => plan.changed || plan.manualMcpOffer) || intent.changes.length > 0
|
|
114
125
|
};
|
|
115
126
|
}
|
|
116
127
|
async function promptForSystemSetupMethods(options) {
|
|
@@ -138,7 +149,7 @@ async function applyPreparedSystemSetup(prepared) {
|
|
|
138
149
|
for (const plan of runnable) {
|
|
139
150
|
if (!plan.changed) {
|
|
140
151
|
if (options.persistIntent !== false) {
|
|
141
|
-
persistReviewedHarnessIntent(storeRoot, prepared.intent.config, plan.harness);
|
|
152
|
+
persistReviewedHarnessIntent(storeRoot, prepared.intent.config, plan.harness, plan.method, prepared.machineRoot);
|
|
142
153
|
}
|
|
143
154
|
configured.push(plan.harness);
|
|
144
155
|
continue;
|
|
@@ -158,7 +169,7 @@ async function applyPreparedSystemSetup(prepared) {
|
|
|
158
169
|
continue;
|
|
159
170
|
}
|
|
160
171
|
if (options.persistIntent !== false) {
|
|
161
|
-
persistReviewedHarnessIntent(storeRoot, prepared.intent.config, plan.harness);
|
|
172
|
+
persistReviewedHarnessIntent(storeRoot, prepared.intent.config, plan.harness, plan.method, prepared.machineRoot);
|
|
162
173
|
}
|
|
163
174
|
configured.push(plan.harness);
|
|
164
175
|
} catch (error) {
|
|
@@ -178,8 +189,34 @@ async function applyPreparedSystemSetup(prepared) {
|
|
|
178
189
|
persistReviewedDisabledIntents(storeRoot, prepared.intent.config, selections, options.harnesses);
|
|
179
190
|
}
|
|
180
191
|
if (blocked.length > 0) {
|
|
181
|
-
const
|
|
182
|
-
|
|
192
|
+
const safePendingMcp = !recoveryAction && blockedPlans.length === blocked.length && blockedPlans.every((plan) => plan.status === "blocked" && plan.method === "mcp" && !plan.changed && !plan.pendingOperation?.());
|
|
193
|
+
const manualInstructions = [];
|
|
194
|
+
if (safePendingMcp && options.persistIntent !== false) {
|
|
195
|
+
for (const plan of blockedPlans) {
|
|
196
|
+
if (!plan.manualMcpOffer) {
|
|
197
|
+
if (plan.manualMcpEligible && options.manualMcpOutput === false) {
|
|
198
|
+
const blockedItem2 = blocked.find((item) => item.harness === plan.harness);
|
|
199
|
+
if (blockedItem2) blockedItem2.nextAction = "Review the blocked native entry. Run setup in a terminal for a one-time manual entry if it remains blocked.";
|
|
200
|
+
}
|
|
201
|
+
continue;
|
|
202
|
+
}
|
|
203
|
+
persistPendingManualMcpIntent(storeRoot, prepared.intent.config, plan, targetRoot);
|
|
204
|
+
manualInstructions.push({
|
|
205
|
+
harness: plan.harness,
|
|
206
|
+
path: plan.manualMcpOffer.path,
|
|
207
|
+
entryId: plan.manualMcpOffer.entryId,
|
|
208
|
+
text: plan.manualMcpOffer.text
|
|
209
|
+
});
|
|
210
|
+
const blockedItem = blocked.find((item) => item.harness === plan.harness);
|
|
211
|
+
if (blockedItem) blockedItem.nextAction = "Add the printed client-owned MCP entry, then run setup again to verify this platform.";
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
const status = recoveryAction ? configured.length > 0 ? "partial" : "recovery" : configured.length > 0 || safePendingMcp ? "partial" : "blocked";
|
|
215
|
+
return {
|
|
216
|
+
...makeResult(status, selections, configured, blocked, recoveryAction),
|
|
217
|
+
projectMayProceed: safePendingMcp,
|
|
218
|
+
manualInstructions
|
|
219
|
+
};
|
|
183
220
|
}
|
|
184
221
|
if (!changed.length) {
|
|
185
222
|
if (prepared.intent.changes.length > 0) {
|
|
@@ -195,11 +232,42 @@ async function applyPreparedSystemSetup(prepared) {
|
|
|
195
232
|
}
|
|
196
233
|
return makeResult("configured", selections, configured, [], null);
|
|
197
234
|
}
|
|
198
|
-
function
|
|
235
|
+
function persistPendingManualMcpIntent(storeRoot, projected, plan, targetRoot) {
|
|
236
|
+
const offer = plan.manualMcpOffer;
|
|
237
|
+
const intent = projected.settings.harnesses[plan.harness];
|
|
238
|
+
if (!offer || !intent) throw new Error("The reviewed manual MCP intent is missing.");
|
|
239
|
+
const current = loadGlobalConfig(storeRoot).config;
|
|
240
|
+
current.settings.harnesses[plan.harness] = {
|
|
241
|
+
...intent,
|
|
242
|
+
accessCeiling: { ...intent.accessCeiling },
|
|
243
|
+
mcpConnection: { ...offer.connection.record, active: false },
|
|
244
|
+
manualMcpPending: {
|
|
245
|
+
targetRoot: path.resolve(targetRoot),
|
|
246
|
+
id: offer.connection.id,
|
|
247
|
+
keySha256: offer.connection.record.keySha256
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
writeGlobalConfig(storeRoot, current);
|
|
251
|
+
}
|
|
252
|
+
function persistReviewedHarnessIntent(storeRoot, projected, harness, method, machineRoot) {
|
|
199
253
|
const intent = projected.settings.harnesses[harness];
|
|
200
254
|
if (!intent) return;
|
|
201
255
|
const current = loadGlobalConfig(storeRoot).config;
|
|
202
|
-
|
|
256
|
+
const next = { ...intent, accessCeiling: { ...intent.accessCeiling } };
|
|
257
|
+
if (method === "mcp" && machineRoot) {
|
|
258
|
+
const connection = readNativeMcpConnection(requireFirstPartyHarnessAdapter(harness), machineRoot);
|
|
259
|
+
if (!connection) throw new Error("The verified MCP host entry has no connection key.");
|
|
260
|
+
next.mcpConnection = {
|
|
261
|
+
id: connection.id,
|
|
262
|
+
keySha256: hashMcpConnectionKey(connection.key),
|
|
263
|
+
active: true,
|
|
264
|
+
method: "mcp",
|
|
265
|
+
owner: harness
|
|
266
|
+
};
|
|
267
|
+
} else if (next.mcpConnection) {
|
|
268
|
+
next.mcpConnection = { ...next.mcpConnection, active: false };
|
|
269
|
+
}
|
|
270
|
+
current.settings.harnesses[harness] = next;
|
|
203
271
|
writeGlobalConfig(storeRoot, current);
|
|
204
272
|
}
|
|
205
273
|
function persistReviewedDisabledIntents(storeRoot, projected, selections, included) {
|
|
@@ -237,7 +305,7 @@ function recoveryActionForPlanFailure(plan, reason, targetRoot, storeRoot) {
|
|
|
237
305
|
return `Correct the reported ${label(plan.harness)} prerequisite, then run \`make-docs setup system\` to review a new machine plan.`;
|
|
238
306
|
}
|
|
239
307
|
async function selectMethods(options, root, storeRoot, executableAttempt) {
|
|
240
|
-
const chosen = { codex: "none", "claude-code": "none" };
|
|
308
|
+
const chosen = { codex: "none", "claude-code": "none", "github-copilot": "none" };
|
|
241
309
|
const existing = loadGlobalConfig(storeRoot).config.settings.harnesses;
|
|
242
310
|
for (const adapter of FIRST_PARTY_HARNESS_ADAPTERS) {
|
|
243
311
|
const saved = existing[adapter.harnessId];
|
|
@@ -283,6 +351,13 @@ function buildAdapterPlans(options, selections, root, targetRoot, storeRoot, exe
|
|
|
283
351
|
const definition = adapter.methods.find((item) => item.id === method);
|
|
284
352
|
const nativeFile = path.resolve(root, definition.nativeFile("machine"));
|
|
285
353
|
const reviewFacts = methodReviewFacts(definition, rules);
|
|
354
|
+
if (adapter.harnessId === "github-copilot") {
|
|
355
|
+
const blocker = copilotConfigBlocker(root, targetRoot);
|
|
356
|
+
if (blocker) {
|
|
357
|
+
plans.push(blockedPlan(adapter.harnessId, method, blocker, nativeFile, reviewFacts));
|
|
358
|
+
continue;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
286
361
|
const currentReceipt = existsSync(getStoreDatabasePath(storeRoot)) ? readCurrentHarnessIntegrationReceipt(targetRoot, storeRoot, "machine", adapter.harnessId, method) : null;
|
|
287
362
|
if (!support.selectable) {
|
|
288
363
|
plans.push(blockedPlan(adapter.harnessId, method, `${support.reason} Next: ${support.nextAction}`, nativeFile, reviewFacts));
|
|
@@ -293,18 +368,72 @@ function buildAdapterPlans(options, selections, root, targetRoot, storeRoot, exe
|
|
|
293
368
|
continue;
|
|
294
369
|
}
|
|
295
370
|
const executable = executableAttempt.executable;
|
|
371
|
+
const pendingManual = loadGlobalConfig(storeRoot).config.settings.harnesses[adapter.harnessId]?.manualMcpPending;
|
|
372
|
+
if (method === "mcp" && pendingManual && typeof pendingManual === "object" && !Array.isArray(pendingManual)) {
|
|
373
|
+
const pending2 = pendingManual;
|
|
374
|
+
let connection = null;
|
|
375
|
+
try {
|
|
376
|
+
connection = readNativeMcpConnection(adapter, root);
|
|
377
|
+
} catch {
|
|
378
|
+
}
|
|
379
|
+
if (connection && pending2.id === connection.id && pending2.keySha256 === hashMcpConnectionKey(connection.key) && verifyManualMcpEntry(adapter, root, executable, connection)) {
|
|
380
|
+
plans.push({
|
|
381
|
+
harness: adapter.harnessId,
|
|
382
|
+
method,
|
|
383
|
+
status: "current",
|
|
384
|
+
...reviewFacts,
|
|
385
|
+
machineFiles: [nativeFile],
|
|
386
|
+
changed: false,
|
|
387
|
+
detail: "The client-owned manual MCP entry matches the reviewed command and connection key.",
|
|
388
|
+
async apply() {
|
|
389
|
+
},
|
|
390
|
+
async verify() {
|
|
391
|
+
return true;
|
|
392
|
+
}
|
|
393
|
+
});
|
|
394
|
+
continue;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
296
397
|
const commandRules = definition.requiresCommandRules ? rules : void 0;
|
|
297
|
-
const
|
|
398
|
+
const planInput = {
|
|
399
|
+
method,
|
|
400
|
+
scope: "machine",
|
|
401
|
+
root,
|
|
402
|
+
executable,
|
|
403
|
+
...commandRules ? { commandRules, commandRuleAuthority: SYSTEM_COMMAND_RULE_AUTHORITY } : {},
|
|
404
|
+
...currentReceipt ? { receipt: currentReceipt } : {}
|
|
405
|
+
};
|
|
406
|
+
let adapterPlan = adapter.plan(planInput);
|
|
407
|
+
let existingMcpConnection = null;
|
|
408
|
+
if (method === "mcp") {
|
|
409
|
+
try {
|
|
410
|
+
existingMcpConnection = readNativeMcpConnection(adapter, root);
|
|
411
|
+
} catch {
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
if (method === "mcp" && existingMcpConnection && (options.rotateMcp || adapterPlan.changes.some((change) => change.action !== "none"))) {
|
|
415
|
+
adapterPlan = adapter.plan({
|
|
416
|
+
...planInput,
|
|
417
|
+
mcpConnection: createMcpConnection(adapter.harnessId)
|
|
418
|
+
});
|
|
419
|
+
}
|
|
298
420
|
let receipt;
|
|
299
421
|
let pending;
|
|
422
|
+
const manualMcpEligible = method === "mcp" && adapterPlan.state === "blocked" && options.projectHarnessIntegrations !== void 0 && options.persistIntent !== false;
|
|
423
|
+
const manualMcpOffer = manualMcpEligible && options.manualMcpOutput === true ? (() => {
|
|
424
|
+
const connection = createMcpConnection(adapter.harnessId);
|
|
425
|
+
return { connection, ...renderManualMcpEntry(adapter, root, executable, connection) };
|
|
426
|
+
})() : void 0;
|
|
300
427
|
plans.push({
|
|
301
428
|
harness: adapter.harnessId,
|
|
302
429
|
method,
|
|
303
|
-
status: adapterPlan.state === "current" ? "current" : adapterPlan.state === "missing" ? "incomplete" : adapterPlan.state,
|
|
430
|
+
status: options.rotateMcp && existingMcpConnection && adapterPlan.state === "drifted" ? "pending" : adapterPlan.state === "current" ? "current" : adapterPlan.state === "missing" ? "incomplete" : adapterPlan.state,
|
|
304
431
|
...reviewFacts,
|
|
305
432
|
machineFiles: adapterPlan.changes.map((change) => change.path),
|
|
306
433
|
changed: adapterPlan.changes.some((change) => change.action !== "none"),
|
|
307
|
-
detail: adapterPlan.nextAction,
|
|
434
|
+
detail: existingMcpConnection && adapterPlan.changes.some((change) => change.action !== "none") && adapterPlan.state !== "blocked" ? "Review this key replacement. The old key stops working after the new native entry verifies. Restart the running MCP client to use the new key." : adapterPlan.nextAction,
|
|
435
|
+
...manualMcpEligible ? { manualMcpEligible } : {},
|
|
436
|
+
...manualMcpOffer ? { manualMcpOffer } : {},
|
|
308
437
|
async apply() {
|
|
309
438
|
pending = prepareHarnessSystemOperation({ targetRoot, storeRoot, adapterId: adapter.id, harnessId: adapter.harnessId, plan: adapterPlan, appliedVersion: options.appliedVersion ?? executable.packageVersion, verifiedAt: (/* @__PURE__ */ new Date()).toISOString() });
|
|
310
439
|
receipt = adapter.apply({ plan: adapterPlan, approved: true, operationId: pending.operationId, appliedVersion: pending.appliedVersion, verifiedAt: pending.verifiedAt }).receipt;
|
|
@@ -325,10 +454,31 @@ function buildAdapterPlans(options, selections, root, targetRoot, storeRoot, exe
|
|
|
325
454
|
}
|
|
326
455
|
return plans;
|
|
327
456
|
}
|
|
457
|
+
function copilotConfigBlocker(machineRoot, targetRoot) {
|
|
458
|
+
const expectedHome = path.resolve(machineRoot, ".copilot");
|
|
459
|
+
if (process.env.COPILOT_HOME && !platform.samePath(path.resolve(process.env.COPILOT_HOME), expectedHome)) {
|
|
460
|
+
return "COPILOT_HOME points to a different directory. Use the generic MCP setup path for this custom Copilot home, or use the default CLI home and review a new plan.";
|
|
461
|
+
}
|
|
462
|
+
for (const relative of [".mcp.json", ".github/mcp.json"]) {
|
|
463
|
+
const file = path.join(targetRoot, relative);
|
|
464
|
+
if (!existsSync(file)) continue;
|
|
465
|
+
try {
|
|
466
|
+
if (!lstatSync(file).isFile()) return `The project MCP file ${relative} is not a regular file. Review it before Copilot setup.`;
|
|
467
|
+
const parsed = JSON.parse(readFileSync(file, "utf8"));
|
|
468
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return `The project MCP file ${relative} is not a JSON object. Review it before Copilot setup.`;
|
|
469
|
+
const servers = parsed.mcpServers;
|
|
470
|
+
if (servers !== void 0 && (!servers || typeof servers !== "object" || Array.isArray(servers))) return `The project MCP file ${relative} has an invalid mcpServers value. Review it before Copilot setup.`;
|
|
471
|
+
if (servers && Object.hasOwn(servers, "make-docs")) return `The project MCP file ${relative} has a make-docs entry that can shadow the CLI user entry. Review the project entry before Copilot setup.`;
|
|
472
|
+
} catch {
|
|
473
|
+
return `The project MCP file ${relative} cannot be read as JSON. Review it before Copilot setup.`;
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
return null;
|
|
477
|
+
}
|
|
328
478
|
async function resumePendingSystemSetup(options, machineRoot, targetRoot, storeRoot) {
|
|
329
479
|
const pending = readPendingHarnessSystemOperation(targetRoot, storeRoot);
|
|
330
480
|
if (!pending) return null;
|
|
331
|
-
const selections = { codex: "none", "claude-code": "none" };
|
|
481
|
+
const selections = { codex: "none", "claude-code": "none", "github-copilot": "none" };
|
|
332
482
|
selections[pending.harnessId] = pending.connectionMethod;
|
|
333
483
|
const recoveryAction = `Run \`make-docs setup system --target ${JSON.stringify(targetRoot)}\` again to resume machine setup ${pending.operationId}.`;
|
|
334
484
|
if (options.dryRun) {
|
|
@@ -350,43 +500,107 @@ async function resumePendingSystemSetup(options, machineRoot, targetRoot, storeR
|
|
|
350
500
|
const definition = adapter.methods.find((method) => method.id === pending.connectionMethod);
|
|
351
501
|
if (!definition) throw new Error(`The pending ${pending.connectionMethod} method is not implemented by this adapter.`);
|
|
352
502
|
const commandRules = definition.requiresCommandRules ? listBoundedHarnessCommandRules(SYSTEM_COMMAND_RULE_AUTHORITY) : void 0;
|
|
353
|
-
|
|
503
|
+
if (pending.connectionMethod === "mcp") {
|
|
504
|
+
const hostState = classifyPendingNativeMcpChange(adapter, pending.plan);
|
|
505
|
+
if (hostState === "before") {
|
|
506
|
+
failHarnessSystemOperation(targetRoot, storeRoot, pending, {
|
|
507
|
+
reason: "The reviewed key was lost before the host file changed.",
|
|
508
|
+
changeOutcome: "none"
|
|
509
|
+
});
|
|
510
|
+
const nextAction = "Run `make-docs setup system` again to review a new MCP key.";
|
|
511
|
+
return makeResult("recovery", selections, [], [{
|
|
512
|
+
harness: pending.harnessId,
|
|
513
|
+
reason: "The prior MCP setup stopped before the host file changed.",
|
|
514
|
+
nextAction
|
|
515
|
+
}], nextAction);
|
|
516
|
+
}
|
|
517
|
+
if (hostState !== "after") {
|
|
518
|
+
throw new Error("The pending MCP host entry differs from the reviewed change. Preserve it for manual recovery.");
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
const appliedReceipt = pending.connectionMethod === "mcp" ? receiptFromPendingMcpPlan(pending) : adapter.apply({
|
|
354
522
|
plan: pending.plan,
|
|
355
523
|
approved: true,
|
|
356
524
|
operationId: pending.operationId,
|
|
357
525
|
appliedVersion: pending.appliedVersion,
|
|
358
526
|
verifiedAt: pending.verifiedAt
|
|
359
|
-
});
|
|
527
|
+
}).receipt;
|
|
360
528
|
const verification = adapter.verify({
|
|
361
529
|
method: pending.connectionMethod,
|
|
362
530
|
scope: "machine",
|
|
363
531
|
root: machineRoot,
|
|
364
532
|
executable,
|
|
365
533
|
...commandRules ? { commandRules, commandRuleAuthority: SYSTEM_COMMAND_RULE_AUTHORITY } : {},
|
|
366
|
-
receipt:
|
|
534
|
+
receipt: appliedReceipt
|
|
367
535
|
});
|
|
368
536
|
if (verification.state !== "current") {
|
|
369
537
|
throw new Error(`Pending machine setup did not verify: ${verification.reason ?? verification.state}`);
|
|
370
538
|
}
|
|
371
|
-
recordHarnessIntegrationReceipt(targetRoot, storeRoot,
|
|
372
|
-
completeHarnessSystemOperation(targetRoot, storeRoot, pending,
|
|
539
|
+
recordHarnessIntegrationReceipt(targetRoot, storeRoot, appliedReceipt);
|
|
540
|
+
completeHarnessSystemOperation(targetRoot, storeRoot, pending, appliedReceipt);
|
|
373
541
|
if (options.persistIntent !== false) {
|
|
374
|
-
persistRecoveredHarnessIntent(storeRoot, pending);
|
|
542
|
+
persistRecoveredHarnessIntent(storeRoot, pending, machineRoot);
|
|
375
543
|
}
|
|
376
544
|
return makeResult("configured", selections, [pending.harnessId], [], null);
|
|
377
545
|
} catch (error) {
|
|
378
546
|
return makeResult("recovery", selections, [], [{ harness: pending.harnessId, reason: error instanceof Error ? error.message : String(error), nextAction: recoveryAction }], recoveryAction);
|
|
379
547
|
}
|
|
380
548
|
}
|
|
381
|
-
function persistRecoveredHarnessIntent(storeRoot, pending) {
|
|
549
|
+
function persistRecoveredHarnessIntent(storeRoot, pending, machineRoot) {
|
|
382
550
|
const current = loadGlobalConfig(storeRoot).config;
|
|
551
|
+
const previous = current.settings.harnesses[pending.harnessId];
|
|
552
|
+
const connection = pending.connectionMethod === "mcp" ? readNativeMcpConnection(requireFirstPartyHarnessAdapter(pending.harnessId), machineRoot) : null;
|
|
553
|
+
if (pending.connectionMethod === "mcp" && !connection) {
|
|
554
|
+
throw new Error("The recovered MCP host entry has no connection key.");
|
|
555
|
+
}
|
|
383
556
|
current.settings.harnesses[pending.harnessId] = {
|
|
557
|
+
...previous ?? {},
|
|
384
558
|
selected: true,
|
|
385
559
|
maximumMethod: pending.connectionMethod,
|
|
386
|
-
accessCeiling:
|
|
560
|
+
accessCeiling: selectedHarnessAccessCeiling(previous, pending.connectionMethod),
|
|
561
|
+
...connection ? { mcpConnection: {
|
|
562
|
+
id: connection.id,
|
|
563
|
+
keySha256: hashMcpConnectionKey(connection.key),
|
|
564
|
+
active: true,
|
|
565
|
+
method: "mcp",
|
|
566
|
+
owner: pending.harnessId
|
|
567
|
+
} } : previous?.mcpConnection ? { mcpConnection: { ...previous.mcpConnection, active: false } } : {}
|
|
387
568
|
};
|
|
388
569
|
writeGlobalConfig(storeRoot, current);
|
|
389
570
|
}
|
|
571
|
+
function receiptFromPendingMcpPlan(pending) {
|
|
572
|
+
return {
|
|
573
|
+
schemaVersion: 2,
|
|
574
|
+
operationId: pending.operationId,
|
|
575
|
+
adapterId: pending.adapterId,
|
|
576
|
+
adapterVersion: pending.plan.adapterVersion,
|
|
577
|
+
harnessId: pending.harnessId,
|
|
578
|
+
connectionMethod: "mcp",
|
|
579
|
+
scope: "machine",
|
|
580
|
+
appliedVersion: pending.appliedVersion,
|
|
581
|
+
verifiedAt: pending.verifiedAt,
|
|
582
|
+
entries: pending.plan.changes.map((change) => {
|
|
583
|
+
if (!change.afterEntryFingerprint || !change.afterFileFingerprint || change.afterEntryValue === null) {
|
|
584
|
+
throw new Error("The pending MCP change has no verified target.");
|
|
585
|
+
}
|
|
586
|
+
return {
|
|
587
|
+
path: change.path,
|
|
588
|
+
entryId: change.entryId,
|
|
589
|
+
ownership: "make-docs",
|
|
590
|
+
beforeEntryFingerprint: change.beforeEntryFingerprint,
|
|
591
|
+
beforeFileFingerprint: change.beforeFileFingerprint,
|
|
592
|
+
beforeValue: change.beforeEntryValue,
|
|
593
|
+
entryFingerprint: change.afterEntryFingerprint,
|
|
594
|
+
fileFingerprint: change.afterFileFingerprint,
|
|
595
|
+
value: change.afterEntryValue
|
|
596
|
+
};
|
|
597
|
+
}),
|
|
598
|
+
result: "verified",
|
|
599
|
+
verificationResult: "passed",
|
|
600
|
+
driftState: "current",
|
|
601
|
+
recoveryStatus: "complete"
|
|
602
|
+
};
|
|
603
|
+
}
|
|
390
604
|
function buildIntentProjection(storeRoot, selections, included, enabled) {
|
|
391
605
|
const loaded = loadGlobalConfig(storeRoot);
|
|
392
606
|
const changes = [];
|
|
@@ -395,11 +609,10 @@ function buildIntentProjection(storeRoot, selections, included, enabled) {
|
|
|
395
609
|
if (!included[harness]) continue;
|
|
396
610
|
const method = selections[harness];
|
|
397
611
|
const previous = loaded.config.settings.harnesses[harness];
|
|
398
|
-
const sameMethod = previous?.selected === (method !== "none") && previous.maximumMethod === (method === "none" ? null : method);
|
|
399
612
|
const intent = {
|
|
400
613
|
selected: method !== "none",
|
|
401
614
|
maximumMethod: method === "none" ? null : method,
|
|
402
|
-
accessCeiling:
|
|
615
|
+
accessCeiling: selectedHarnessAccessCeiling(previous, method)
|
|
403
616
|
};
|
|
404
617
|
resolveEffectiveHarnessIntegration(void 0, intent, harness);
|
|
405
618
|
const next = { ...previous ?? {}, ...intent };
|
|
@@ -463,6 +676,12 @@ function deriveHarnessAccessCeiling(method) {
|
|
|
463
676
|
hostConfig: "none"
|
|
464
677
|
};
|
|
465
678
|
}
|
|
679
|
+
function selectedHarnessAccessCeiling(previous, method) {
|
|
680
|
+
if (previous && !(previous.maximumMethod === null && previous.accessCeiling.store === "none" && previous.accessCeiling.project === "none")) {
|
|
681
|
+
return previous.accessCeiling;
|
|
682
|
+
}
|
|
683
|
+
return deriveHarnessAccessCeiling(method);
|
|
684
|
+
}
|
|
466
685
|
function verifyCurrentExecutable() {
|
|
467
686
|
const executablePath = path.resolve(process.argv[1] ?? "");
|
|
468
687
|
return verifyMakeDocsExecutable({ executablePath });
|
|
@@ -494,10 +713,10 @@ function blockedPlan(harness, method, detail, file, reviewFacts) {
|
|
|
494
713
|
}
|
|
495
714
|
function makeResult(status, selections, configured, blocked, recoveryAction) {
|
|
496
715
|
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 };
|
|
716
|
+
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, projectMayProceed: blocked.length === 0 };
|
|
498
717
|
}
|
|
499
718
|
function label(harness) {
|
|
500
|
-
return harness === "claude-code" ? "Claude Code" : "Codex";
|
|
719
|
+
return harness === "claude-code" ? "Claude Code" : harness === "github-copilot" ? "GitHub Copilot CLI" : "Codex";
|
|
501
720
|
}
|
|
502
721
|
function renderSystemPlans(plans) {
|
|
503
722
|
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");
|
|
@@ -512,6 +731,10 @@ function renderSystemPlans(plans) {
|
|
|
512
731
|
`- Store effects: ${plan.operationEffects.map((effect) => `${effect.operation} (Store ${effect.store})`).join(", ") || "none"}`,
|
|
513
732
|
`- Access ceiling: Store ${ceiling.store}; project ${ceiling.project}; host config ${ceiling.hostConfig}`,
|
|
514
733
|
`- Effect: ${plan.detail}`,
|
|
734
|
+
...plan.harness === "github-copilot" ? [
|
|
735
|
+
`- GitHub Copilot CLI: ${plan.status}; this plan checks the CLI user entry.`,
|
|
736
|
+
"- GitHub Copilot app: blocked until a real app session proves which entry it uses. App-installed entries stay user-owned."
|
|
737
|
+
] : [],
|
|
515
738
|
"- None effect: no native file changes; Store-backed agent operations stay unavailable; resource reads still need no Store access."
|
|
516
739
|
];
|
|
517
740
|
}).join("\n");
|
|
@@ -541,4 +764,4 @@ export {
|
|
|
541
764
|
resumePendingSystemSetupCommand,
|
|
542
765
|
runSystemSetupCommand
|
|
543
766
|
};
|
|
544
|
-
//# sourceMappingURL=setup-system-
|
|
767
|
+
//# sourceMappingURL=setup-system-KN7FTTLT.js.map
|