@brucewaynedecoy/make-docs 2.0.6 → 2.0.8
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-P5NUPAJL.js → backup-BLN6XCAS.js} +4 -4
- package/dist/{chunk-LK6BLVZA.js → chunk-4OMXLXXY.js} +13 -9
- package/dist/chunk-4OMXLXXY.js.map +1 -0
- package/dist/{chunk-KFYUB4AX.js → chunk-ANZ4AJG7.js} +13 -2
- package/dist/chunk-ANZ4AJG7.js.map +1 -0
- package/dist/{chunk-XFFESINU.js → chunk-EZ7FEZTG.js} +2 -2
- package/dist/{chunk-DNPFQB24.js → chunk-G5BT3GGK.js} +3 -3
- package/dist/{chunk-SFKYGFUV.js → chunk-GMIVJ7MS.js} +24 -12
- package/dist/chunk-GMIVJ7MS.js.map +1 -0
- package/dist/{chunk-B7QF7XZT.js → chunk-I3BO4LEF.js} +230 -109
- package/dist/chunk-I3BO4LEF.js.map +1 -0
- package/dist/{chunk-TDB6UW4M.js → chunk-ILII44MP.js} +3 -3
- package/dist/{chunk-PI7W5QDB.js → chunk-L7UI56GS.js} +2 -2
- package/dist/{chunk-2WC74W66.js → chunk-MUQ2KL22.js} +2 -2
- package/dist/{chunk-EF47XIIR.js → chunk-XGTKLLI3.js} +8 -7
- package/dist/{chunk-EF47XIIR.js.map → chunk-XGTKLLI3.js.map} +1 -1
- package/dist/index.js +200 -37
- package/dist/index.js.map +1 -1
- package/dist/{registry-44WLX4F5.js → registry-7TE6OMSU.js} +7 -7
- package/dist/{self-WRWI5XNE.js → self-DIK2M5CA.js} +7 -7
- package/dist/{server-FYRDPOBR.js → server-IEI2UXRK.js} +9 -9
- package/dist/{setup-system-XX6NSVXZ.js → setup-system-SPZE6PYP.js} +7 -7
- package/dist/{skills-command-YAQP24JM.js → skills-command-ZPQG23OM.js} +6 -6
- package/dist/{uninstall-3YJKZ6UF.js → uninstall-BMDNLD6L.js} +7 -7
- package/dist/{virtual_make-docs-first-party-skills-5TYTCD5U.js → virtual_make-docs-first-party-skills-BGO3TGHN.js} +2 -2
- package/dist/{virtual_make-docs-first-party-skills-5TYTCD5U.js.map → virtual_make-docs-first-party-skills-BGO3TGHN.js.map} +1 -1
- package/package.json +1 -1
- package/dist/chunk-B7QF7XZT.js.map +0 -1
- package/dist/chunk-KFYUB4AX.js.map +0 -1
- package/dist/chunk-LK6BLVZA.js.map +0 -1
- package/dist/chunk-SFKYGFUV.js.map +0 -1
- /package/dist/{backup-P5NUPAJL.js.map → backup-BLN6XCAS.js.map} +0 -0
- /package/dist/{chunk-XFFESINU.js.map → chunk-EZ7FEZTG.js.map} +0 -0
- /package/dist/{chunk-DNPFQB24.js.map → chunk-G5BT3GGK.js.map} +0 -0
- /package/dist/{chunk-TDB6UW4M.js.map → chunk-ILII44MP.js.map} +0 -0
- /package/dist/{chunk-PI7W5QDB.js.map → chunk-L7UI56GS.js.map} +0 -0
- /package/dist/{chunk-2WC74W66.js.map → chunk-MUQ2KL22.js.map} +0 -0
- /package/dist/{registry-44WLX4F5.js.map → registry-7TE6OMSU.js.map} +0 -0
- /package/dist/{self-WRWI5XNE.js.map → self-DIK2M5CA.js.map} +0 -0
- /package/dist/{server-FYRDPOBR.js.map → server-IEI2UXRK.js.map} +0 -0
- /package/dist/{setup-system-XX6NSVXZ.js.map → setup-system-SPZE6PYP.js.map} +0 -0
- /package/dist/{skills-command-YAQP24JM.js.map → skills-command-ZPQG23OM.js.map} +0 -0
- /package/dist/{uninstall-3YJKZ6UF.js.map → uninstall-BMDNLD6L.js.map} +0 -0
|
@@ -7,18 +7,19 @@ import {
|
|
|
7
7
|
prepareInstallationRemoval,
|
|
8
8
|
pruneInstallationParents,
|
|
9
9
|
removeInstallationPath
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-EZ7FEZTG.js";
|
|
11
11
|
import {
|
|
12
12
|
NO_ACCESS,
|
|
13
13
|
getFirstPartyHarnessAdapter,
|
|
14
14
|
validateHarnessMethodSelection
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-MUQ2KL22.js";
|
|
16
16
|
import {
|
|
17
17
|
CONFLICTS_RELATIVE_DIR,
|
|
18
18
|
DEFAULT_SYSTEM_ASSET_MATERIALIZATION_MODE,
|
|
19
19
|
HARNESS_TO_INSTRUCTION,
|
|
20
20
|
INSTRUCTION_KINDS,
|
|
21
21
|
MANIFEST_RELATIVE_PATH,
|
|
22
|
+
PROJECT_RESOURCE_TYPES,
|
|
22
23
|
RETIRED_PLAYBOOK_CONTRACT_HASH,
|
|
23
24
|
RETIRED_PLAYBOOK_CONTRACT_PATH,
|
|
24
25
|
TEMPLATE_ROOT,
|
|
@@ -75,7 +76,7 @@ import {
|
|
|
75
76
|
withInstallationOperation,
|
|
76
77
|
writeContentFile,
|
|
77
78
|
writeManifest
|
|
78
|
-
} from "./chunk-
|
|
79
|
+
} from "./chunk-GMIVJ7MS.js";
|
|
79
80
|
|
|
80
81
|
// src/config.ts
|
|
81
82
|
import { existsSync, readFileSync } from "fs";
|
|
@@ -115,6 +116,7 @@ var TOP_LEVEL_KEYS = /* @__PURE__ */ new Set([
|
|
|
115
116
|
"generatedProse",
|
|
116
117
|
"harnessCapabilities",
|
|
117
118
|
"harnessIntegrations",
|
|
119
|
+
"resourceProjection",
|
|
118
120
|
"prd_authority"
|
|
119
121
|
]);
|
|
120
122
|
var LABEL_GROUP_KEYS = /* @__PURE__ */ new Set(["lifecycle", "documentKinds", "coordinates"]);
|
|
@@ -300,6 +302,13 @@ function loadMakeDocsConfig(targetDir) {
|
|
|
300
302
|
applyPersonas(parsed.personas, config, configPath, diagnostics);
|
|
301
303
|
applyHarnessCapabilities(parsed.harnessCapabilities, config, configPath, diagnostics);
|
|
302
304
|
applyHarnessIntegrations(parsed.harnessIntegrations, config, configPath, diagnostics);
|
|
305
|
+
if (parsed.resourceProjection !== void 0) {
|
|
306
|
+
if (!Array.isArray(parsed.resourceProjection) || parsed.resourceProjection.some((type) => !PROJECT_RESOURCE_TYPES.includes(type)) || new Set(parsed.resourceProjection).size !== parsed.resourceProjection.length) {
|
|
307
|
+
diagnostics.push({ code: "invalid-type", filePath: configPath, keyPath: "resourceProjection", message: "resourceProjection must be a list of distinct system resource types." });
|
|
308
|
+
} else {
|
|
309
|
+
config.resourceProjection = [...parsed.resourceProjection];
|
|
310
|
+
}
|
|
311
|
+
}
|
|
303
312
|
if (diagnostics.length > 0) {
|
|
304
313
|
return invalidConfigResult(configPath, diagnostics);
|
|
305
314
|
}
|
|
@@ -325,7 +334,8 @@ function planProjectHarnessIntegrationWrite(input) {
|
|
|
325
334
|
const beforeContent = existsSync(configPath) ? readFileSync(configPath, "utf8") : null;
|
|
326
335
|
const updated = updateProjectHarnessIntegrationsYaml(
|
|
327
336
|
beforeContent ?? input.contentWhenMissing,
|
|
328
|
-
input.reviewed
|
|
337
|
+
input.reviewed,
|
|
338
|
+
input.reviewedResourceProjection
|
|
329
339
|
);
|
|
330
340
|
return {
|
|
331
341
|
configPath,
|
|
@@ -335,10 +345,11 @@ function planProjectHarnessIntegrationWrite(input) {
|
|
|
335
345
|
reviewed: input.reviewed.map((record) => ({
|
|
336
346
|
...record,
|
|
337
347
|
...record.accessCeiling ? { accessCeiling: { ...record.accessCeiling } } : {}
|
|
338
|
-
}))
|
|
348
|
+
})),
|
|
349
|
+
...input.reviewedResourceProjection !== void 0 ? { reviewedResourceProjection: [...input.reviewedResourceProjection] } : {}
|
|
339
350
|
};
|
|
340
351
|
}
|
|
341
|
-
function updateProjectHarnessIntegrationsYaml(raw, reviewed) {
|
|
352
|
+
function updateProjectHarnessIntegrationsYaml(raw, reviewed, reviewedResourceProjection) {
|
|
342
353
|
const document = parseDocument(raw);
|
|
343
354
|
if (document.errors.length > 0) {
|
|
344
355
|
throw new Error(`Invalid make-docs config YAML: ${document.errors.map((error) => error.message).join("; ")}`);
|
|
@@ -396,6 +407,19 @@ function updateProjectHarnessIntegrationsYaml(raw, reviewed) {
|
|
|
396
407
|
setYamlScalar(access, "project", record.accessCeiling.project);
|
|
397
408
|
setYamlScalar(access, "hostConfig", record.accessCeiling.hostConfig);
|
|
398
409
|
}
|
|
410
|
+
if (reviewedResourceProjection !== void 0) {
|
|
411
|
+
if (reviewedResourceProjection.some((type) => !PROJECT_RESOURCE_TYPES.includes(type)) || new Set(reviewedResourceProjection).size !== reviewedResourceProjection.length) {
|
|
412
|
+
throw new Error("Reviewed resource projection has an invalid or duplicate type.");
|
|
413
|
+
}
|
|
414
|
+
const existing = getYamlMapValueNode(document.contents, "resourceProjection");
|
|
415
|
+
if (existing !== void 0 && existing !== null && !isSeq(existing)) {
|
|
416
|
+
throw new Error("resourceProjection must be a YAML sequence.");
|
|
417
|
+
}
|
|
418
|
+
const current = isSeq(existing) ? existing.items.map((item) => isScalar(item) ? item.value : null) : null;
|
|
419
|
+
if (!current || current.length !== reviewedResourceProjection.length || current.some((type, index) => type !== reviewedResourceProjection[index])) {
|
|
420
|
+
document.set("resourceProjection", document.createNode([...reviewedResourceProjection]));
|
|
421
|
+
}
|
|
422
|
+
}
|
|
399
423
|
const content = document.toString();
|
|
400
424
|
return { content, changed: content !== raw };
|
|
401
425
|
}
|
|
@@ -1011,7 +1035,7 @@ function cloneMcpToolMetadata(metadata) {
|
|
|
1011
1035
|
// src/install.ts
|
|
1012
1036
|
import { isDeepStrictEqual as isDeepStrictEqual2 } from "util";
|
|
1013
1037
|
import { existsSync as existsSync5, mkdirSync, readFileSync as readFileSync5, symlinkSync } from "fs";
|
|
1014
|
-
import
|
|
1038
|
+
import path7 from "path";
|
|
1015
1039
|
|
|
1016
1040
|
// src/retired-path-helper.ts
|
|
1017
1041
|
import { existsSync as existsSync2, lstatSync, readdirSync, readFileSync as readFileSync2 } from "fs";
|
|
@@ -1077,12 +1101,14 @@ function getRetiredResourceReplacement(relativePath) {
|
|
|
1077
1101
|
}
|
|
1078
1102
|
|
|
1079
1103
|
// src/planner.ts
|
|
1080
|
-
import { existsSync as existsSync4, lstatSync as
|
|
1081
|
-
import
|
|
1104
|
+
import { existsSync as existsSync4, lstatSync as lstatSync4, readFileSync as readFileSync4, readdirSync as readdirSync3, readlinkSync, statSync as statSync2 } from "fs";
|
|
1105
|
+
import path6 from "path";
|
|
1082
1106
|
import { homedir } from "os";
|
|
1083
1107
|
|
|
1084
1108
|
// src/project-projection.ts
|
|
1085
1109
|
import { Buffer as Buffer2 } from "buffer";
|
|
1110
|
+
import { lstatSync as lstatSync3 } from "fs";
|
|
1111
|
+
import path5 from "path";
|
|
1086
1112
|
|
|
1087
1113
|
// src/operations/resource/provider.ts
|
|
1088
1114
|
import { createHash } from "crypto";
|
|
@@ -1745,6 +1771,23 @@ var RESOURCE_PROJECTION_AUTHORITIES = Object.freeze({
|
|
|
1745
1771
|
function normalizeProjectResourceSelection(values) {
|
|
1746
1772
|
return Array.from(new Set(values)).sort(compareCodeUnits2);
|
|
1747
1773
|
}
|
|
1774
|
+
function inferLocalResourceProjection(targetDir) {
|
|
1775
|
+
const provider = unwrapProvider(loadInstalledSystemResourceProvider());
|
|
1776
|
+
const types = [];
|
|
1777
|
+
for (const type of PROJECT_RESOURCE_TYPES) {
|
|
1778
|
+
const resources = provider.resources.filter((resource) => resource.identity.type === type);
|
|
1779
|
+
if (resources.length === 0) continue;
|
|
1780
|
+
let present = 0;
|
|
1781
|
+
for (const resource of resources) {
|
|
1782
|
+
const relativePath = projectionPath(type, resource.identity.path);
|
|
1783
|
+
assertManagedPathHasNoSymlinks(targetDir, relativePath);
|
|
1784
|
+
if (lstatSync3(path5.join(targetDir, relativePath), { throwIfNoEntry: false })?.isFile()) present += 1;
|
|
1785
|
+
}
|
|
1786
|
+
if (present > 0 && present < resources.length) return { status: "partial", types };
|
|
1787
|
+
if (present === resources.length) types.push(type);
|
|
1788
|
+
}
|
|
1789
|
+
return { status: types.length ? "complete" : "none", types };
|
|
1790
|
+
}
|
|
1748
1791
|
function buildSelectedResourceProjection(options) {
|
|
1749
1792
|
const selectedTypes = normalizeProjectResourceSelection(
|
|
1750
1793
|
options.profile.selections.resourceProjection ?? []
|
|
@@ -1996,8 +2039,13 @@ async function createInstallPlan(options) {
|
|
|
1996
2039
|
targetDir,
|
|
1997
2040
|
profile,
|
|
1998
2041
|
existingManifest,
|
|
2042
|
+
adopt: options.adopt,
|
|
1999
2043
|
completedRemovalHandoff: options.completedRemovalHandoff
|
|
2000
2044
|
});
|
|
2045
|
+
const carriedOnDemandRouterPaths = new Set(
|
|
2046
|
+
carriedOnDemandRouterAssets.map((asset) => asset.relativePath)
|
|
2047
|
+
);
|
|
2048
|
+
const priorPortableAdoption = hasPriorPortableAdoptionProof(existingManifest);
|
|
2001
2049
|
const routerAssets = [...thinRouterAssets, ...carriedOnDemandRouterAssets];
|
|
2002
2050
|
const thinRouterPaths = new Set(
|
|
2003
2051
|
thinRouterAssets.map((asset) => asset.relativePath)
|
|
@@ -2143,6 +2191,34 @@ async function createInstallPlan(options) {
|
|
|
2143
2191
|
});
|
|
2144
2192
|
continue;
|
|
2145
2193
|
}
|
|
2194
|
+
const priorAdoptionGapRouter = priorPortableAdoption && carriedOnDemandRouterPaths.has(asset.relativePath) && !manifestEntry && !existingManifest?.routerOwnership?.routers[asset.relativePath];
|
|
2195
|
+
if (priorAdoptionGapRouter) {
|
|
2196
|
+
if (currentHash !== null && parseManagedBlock(currentContent).state === "valid") {
|
|
2197
|
+
desiredFiles[asset.relativePath] = {
|
|
2198
|
+
hash: currentHash,
|
|
2199
|
+
sourceId: asset.sourceId,
|
|
2200
|
+
ownershipClass: "project-owned"
|
|
2201
|
+
};
|
|
2202
|
+
forceManifestWrite = true;
|
|
2203
|
+
actions.push({
|
|
2204
|
+
type: "noop",
|
|
2205
|
+
relativePath: asset.relativePath,
|
|
2206
|
+
sourceId: asset.sourceId,
|
|
2207
|
+
reviewedConflictResolution: "skip",
|
|
2208
|
+
contentHash: currentHash,
|
|
2209
|
+
reason: "Keep the router omitted from the prior portable-adoption ledger."
|
|
2210
|
+
});
|
|
2211
|
+
} else {
|
|
2212
|
+
conflictsRunId ??= createRunId();
|
|
2213
|
+
actions.push({
|
|
2214
|
+
type: "skip-conflict",
|
|
2215
|
+
relativePath: asset.relativePath,
|
|
2216
|
+
sourceId: asset.sourceId,
|
|
2217
|
+
reason: "The router omitted from the prior adoption has no valid managed block."
|
|
2218
|
+
});
|
|
2219
|
+
}
|
|
2220
|
+
continue;
|
|
2221
|
+
}
|
|
2146
2222
|
if (currentHash === desiredHash) {
|
|
2147
2223
|
actions.push({
|
|
2148
2224
|
type: "noop",
|
|
@@ -2186,7 +2262,16 @@ async function createInstallPlan(options) {
|
|
|
2186
2262
|
});
|
|
2187
2263
|
continue;
|
|
2188
2264
|
}
|
|
2189
|
-
|
|
2265
|
+
const conflictClassification = classifyReviewableManagedFileConflictPath(
|
|
2266
|
+
asset.relativePath,
|
|
2267
|
+
{ isDesiredSkillAsset: desiredSkillFileSet.has(asset.relativePath) }
|
|
2268
|
+
);
|
|
2269
|
+
const conflictResolution = getManagedFileConflictResolution(
|
|
2270
|
+
asset.relativePath,
|
|
2271
|
+
conflictClassification,
|
|
2272
|
+
managedFileConflictResolutions
|
|
2273
|
+
);
|
|
2274
|
+
if (asset.sourceId.startsWith("resource:") && !hasVerifiedResourceOwnership(existingManifest, asset.relativePath, asset.sourceId) && !conflictResolution) {
|
|
2190
2275
|
conflictsRunId ??= createRunId();
|
|
2191
2276
|
actions.push({
|
|
2192
2277
|
type: "skip-conflict",
|
|
@@ -2210,13 +2295,25 @@ async function createInstallPlan(options) {
|
|
|
2210
2295
|
});
|
|
2211
2296
|
continue;
|
|
2212
2297
|
}
|
|
2298
|
+
if (isInstructionPath(asset.relativePath) && manifestEntry?.ownershipClass === "project-owned" && manifestEntry.sourceId === asset.sourceId && currentHash !== null && currentHash === manifestEntry.hash && parseManagedBlock(currentContent).state === "valid" && managedFileConflictResolutions?.[asset.relativePath] !== "overwrite") {
|
|
2299
|
+
desiredFiles[asset.relativePath] = manifestEntry;
|
|
2300
|
+
actions.push({
|
|
2301
|
+
type: "noop",
|
|
2302
|
+
relativePath: asset.relativePath,
|
|
2303
|
+
sourceId: asset.sourceId,
|
|
2304
|
+
reviewedConflictResolution: "skip",
|
|
2305
|
+
contentHash: currentHash,
|
|
2306
|
+
reason: "Preserve the verified project-owned router block."
|
|
2307
|
+
});
|
|
2308
|
+
continue;
|
|
2309
|
+
}
|
|
2213
2310
|
const migrationContent = getInstructionMigrationContent(
|
|
2214
2311
|
asset,
|
|
2215
2312
|
currentContent,
|
|
2216
2313
|
manifestEntry,
|
|
2217
2314
|
currentHash
|
|
2218
2315
|
);
|
|
2219
|
-
if (migrationContent) {
|
|
2316
|
+
if (migrationContent && !(options.adopt && conflictResolution === "skip")) {
|
|
2220
2317
|
actions.push({
|
|
2221
2318
|
type: "update",
|
|
2222
2319
|
relativePath: asset.relativePath,
|
|
@@ -2238,15 +2335,6 @@ async function createInstallPlan(options) {
|
|
|
2238
2335
|
});
|
|
2239
2336
|
continue;
|
|
2240
2337
|
}
|
|
2241
|
-
const conflictClassification = classifyReviewableManagedFileConflictPath(
|
|
2242
|
-
asset.relativePath,
|
|
2243
|
-
{ isDesiredSkillAsset: desiredSkillFileSet.has(asset.relativePath) }
|
|
2244
|
-
);
|
|
2245
|
-
const conflictResolution = getManagedFileConflictResolution(
|
|
2246
|
-
asset.relativePath,
|
|
2247
|
-
conflictClassification,
|
|
2248
|
-
managedFileConflictResolutions
|
|
2249
|
-
);
|
|
2250
2338
|
if (conflictClassification && conflictResolution === "overwrite") {
|
|
2251
2339
|
const content = getPlannedUpdateContent(asset, currentContent);
|
|
2252
2340
|
actions.push({
|
|
@@ -2263,18 +2351,20 @@ async function createInstallPlan(options) {
|
|
|
2263
2351
|
if (conflictClassification && conflictResolution === "skip") {
|
|
2264
2352
|
const resourceUri = asset.sourceId.startsWith("resource:") ? asset.sourceId.slice("resource:".length) : null;
|
|
2265
2353
|
const projectedResource = resourceUri ? selectedProjection.state.resources[resourceUri] : void 0;
|
|
2266
|
-
if (
|
|
2354
|
+
if (currentHash !== null && (options.adopt || manifestEntry && resourceUri && projectedResource?.managedDestination === asset.relativePath)) {
|
|
2267
2355
|
desiredFiles[asset.relativePath] = {
|
|
2268
2356
|
hash: currentHash,
|
|
2269
2357
|
sourceId: asset.sourceId,
|
|
2270
2358
|
ownershipClass: "project-owned"
|
|
2271
2359
|
};
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2360
|
+
if (resourceUri && projectedResource?.managedDestination === asset.relativePath) {
|
|
2361
|
+
selectedProjection.state.resources[resourceUri] = {
|
|
2362
|
+
...projectedResource,
|
|
2363
|
+
ownershipClass: "project-owned",
|
|
2364
|
+
installedDigest: currentHash,
|
|
2365
|
+
lastVerifiedAt: verifiedAt
|
|
2366
|
+
};
|
|
2367
|
+
}
|
|
2278
2368
|
forceManifestWrite = true;
|
|
2279
2369
|
actions.push({
|
|
2280
2370
|
type: "noop",
|
|
@@ -2290,6 +2380,7 @@ async function createInstallPlan(options) {
|
|
|
2290
2380
|
});
|
|
2291
2381
|
continue;
|
|
2292
2382
|
}
|
|
2383
|
+
if (options.adopt) delete desiredFiles[asset.relativePath];
|
|
2293
2384
|
actions.push({
|
|
2294
2385
|
type: "skip",
|
|
2295
2386
|
relativePath: asset.relativePath,
|
|
@@ -2338,7 +2429,7 @@ async function createInstallPlan(options) {
|
|
|
2338
2429
|
try {
|
|
2339
2430
|
assertManagedPathHasNoSymlinks(targetDir, relativePath);
|
|
2340
2431
|
const retiredPath = relativePathToTarget(targetDir, relativePath);
|
|
2341
|
-
clean = hasTrustedRetiredPlaybookContractOwnership(manifestEntry) && (!existsSync4(retiredPath) ||
|
|
2432
|
+
clean = hasTrustedRetiredPlaybookContractOwnership(manifestEntry) && (!existsSync4(retiredPath) || lstatSync4(retiredPath).isFile() && hashText(readTextFile(retiredPath)) === RETIRED_PLAYBOOK_CONTRACT_HASH);
|
|
2342
2433
|
} catch {
|
|
2343
2434
|
}
|
|
2344
2435
|
actions.push({
|
|
@@ -2355,7 +2446,7 @@ async function createInstallPlan(options) {
|
|
|
2355
2446
|
assertManagedPathHasNoSymlinks(targetDir, relativePath);
|
|
2356
2447
|
}
|
|
2357
2448
|
if (isPreservedLegacyPlaybook(relativePath) && existsSync4(absolutePath)) {
|
|
2358
|
-
if (!
|
|
2449
|
+
if (!lstatSync4(absolutePath).isFile()) {
|
|
2359
2450
|
conflictsRunId ??= createRunId();
|
|
2360
2451
|
actions.push({
|
|
2361
2452
|
type: "skip-conflict",
|
|
@@ -2403,7 +2494,7 @@ async function createInstallPlan(options) {
|
|
|
2403
2494
|
actions.push(action);
|
|
2404
2495
|
continue;
|
|
2405
2496
|
}
|
|
2406
|
-
if (!
|
|
2497
|
+
if (!lstatSync4(absolutePath).isFile()) {
|
|
2407
2498
|
conflictsRunId ??= createRunId();
|
|
2408
2499
|
actions.push({
|
|
2409
2500
|
type: "skip-conflict",
|
|
@@ -2525,6 +2616,28 @@ async function createInstallPlan(options) {
|
|
|
2525
2616
|
...resourceProjectionStops(annotatedActions),
|
|
2526
2617
|
...annotatedActions.filter((action) => action.reason?.includes("managed block is malformed")).map((action) => action.relativePath)
|
|
2527
2618
|
])).sort();
|
|
2619
|
+
const routerOwnership = createRouterOwnershipManifestState(profile, routerAssets, {
|
|
2620
|
+
packageMeta,
|
|
2621
|
+
verifiedAt,
|
|
2622
|
+
existingState: existingManifest?.routerOwnership
|
|
2623
|
+
});
|
|
2624
|
+
for (const [relativePath, router] of Object.entries(routerOwnership.routers)) {
|
|
2625
|
+
const file2 = desiredFiles[relativePath];
|
|
2626
|
+
if (options.adopt && !file2) {
|
|
2627
|
+
delete routerOwnership.routers[relativePath];
|
|
2628
|
+
continue;
|
|
2629
|
+
}
|
|
2630
|
+
if (file2?.ownershipClass === "project-owned") {
|
|
2631
|
+
router.ownershipClass = "project-owned";
|
|
2632
|
+
router.installedHash = file2.hash;
|
|
2633
|
+
router.adoptionReceipt = existingManifest?.routerOwnership?.routers[relativePath]?.adoptionReceipt ?? {
|
|
2634
|
+
receiptId: hashText(`portable-router:${relativePath}:${file2.hash}`),
|
|
2635
|
+
adoptedAt: verifiedAt,
|
|
2636
|
+
priorOwnershipClass: existingManifest?.routerOwnership?.routers[relativePath] ? "managed-snapshot" : "unregistered",
|
|
2637
|
+
evidenceRefs: [`project-file:${relativePath}`]
|
|
2638
|
+
};
|
|
2639
|
+
}
|
|
2640
|
+
}
|
|
2528
2641
|
return {
|
|
2529
2642
|
packageName: packageMeta.name,
|
|
2530
2643
|
packageVersion: packageMeta.version,
|
|
@@ -2535,11 +2648,7 @@ async function createInstallPlan(options) {
|
|
|
2535
2648
|
desiredSkillFiles: desiredSkillFiles.sort(),
|
|
2536
2649
|
conflictsRunId,
|
|
2537
2650
|
operation,
|
|
2538
|
-
routerOwnership
|
|
2539
|
-
packageMeta,
|
|
2540
|
-
verifiedAt,
|
|
2541
|
-
existingState: existingManifest?.routerOwnership
|
|
2542
|
-
}),
|
|
2651
|
+
routerOwnership,
|
|
2543
2652
|
resourceProjection: selectedProjection.state,
|
|
2544
2653
|
classificationSnapshot: createLifecyclePlanSnapshot(
|
|
2545
2654
|
targetDir,
|
|
@@ -2673,7 +2782,7 @@ function planDesiredSkillAsset(options) {
|
|
|
2673
2782
|
const { targetDir, asset, existingManifest, existingSkillFiles, previousSkillContent } = options;
|
|
2674
2783
|
const root = asset.relativePath.match(/^(.*(?:^|\/)(?:\.make-docs\/agentics|\.agents|\.claude|\.codex)\/skills\/[^/]+)(?:\/|$)/)?.[1];
|
|
2675
2784
|
const guardedRoots = [...new Set((isSkillExposureAsset(asset) ? [asset.relativePath, asset.skillExposure.canonicalPayloadPath] : [root]).filter((p) => !!p))];
|
|
2676
|
-
if (guardedRoots.some((root2) =>
|
|
2785
|
+
if (guardedRoots.some((root2) => lstatSync4(relativePathToTarget(targetDir, root2), { throwIfNoEntry: false }) && !Object.keys(existingManifest?.files ?? {}).some((p) => p === root2 || p.startsWith(root2 + "/")) && ![...existingSkillFiles].some((p) => p === root2 || p.startsWith(root2 + "/")))) {
|
|
2677
2786
|
return {
|
|
2678
2787
|
type: "skip-conflict",
|
|
2679
2788
|
relativePath: asset.relativePath,
|
|
@@ -2810,13 +2919,13 @@ function planDesiredSkillExposure(options) {
|
|
|
2810
2919
|
}
|
|
2811
2920
|
function isCleanOwnedSkillCopy(targetDir, asset, manifest) {
|
|
2812
2921
|
const absolute = relativePathToTarget(targetDir, asset.relativePath);
|
|
2813
|
-
if (!manifest || !
|
|
2922
|
+
if (!manifest || !lstatSync4(absolute).isDirectory()) return false;
|
|
2814
2923
|
const canonicalRoot = asset.skillExposure.canonicalPayloadPath;
|
|
2815
2924
|
const expected = Object.keys(manifest.files).filter((p) => p.startsWith(canonicalRoot + "/"));
|
|
2816
2925
|
const files = [];
|
|
2817
2926
|
const visit = (directory) => readdirSync3(directory, { withFileTypes: true }).every((entry) => {
|
|
2818
|
-
const target =
|
|
2819
|
-
const ownedPath = canonicalRoot + "/" +
|
|
2927
|
+
const target = path6.join(directory, entry.name);
|
|
2928
|
+
const ownedPath = canonicalRoot + "/" + path6.relative(absolute, target).split(path6.sep).join("/");
|
|
2820
2929
|
if (entry.isDirectory()) return expected.some((p) => p.startsWith(ownedPath + "/")) && visit(target);
|
|
2821
2930
|
if (!entry.isFile()) return false;
|
|
2822
2931
|
files.push(target);
|
|
@@ -2825,8 +2934,8 @@ function isCleanOwnedSkillCopy(targetDir, asset, manifest) {
|
|
|
2825
2934
|
if (!visit(absolute)) return false;
|
|
2826
2935
|
if (files.length !== expected.length) return false;
|
|
2827
2936
|
return files.every((p) => {
|
|
2828
|
-
if (!
|
|
2829
|
-
const canonicalPath = canonicalRoot + "/" +
|
|
2937
|
+
if (!lstatSync4(p).isFile()) return false;
|
|
2938
|
+
const canonicalPath = canonicalRoot + "/" + path6.relative(absolute, p).split(path6.sep).join("/");
|
|
2830
2939
|
const entry = manifest.files[canonicalPath];
|
|
2831
2940
|
return entry !== void 0 && hashText(readFileSync4(p)) === entry.hash;
|
|
2832
2941
|
});
|
|
@@ -2842,7 +2951,7 @@ function planStaleSkillFile(options) {
|
|
|
2842
2951
|
sourceId: manifestEntry?.sourceId ?? `skill:${relativePath}`
|
|
2843
2952
|
};
|
|
2844
2953
|
}
|
|
2845
|
-
const stats =
|
|
2954
|
+
const stats = lstatSync4(absolutePath);
|
|
2846
2955
|
if (!stats.isFile()) {
|
|
2847
2956
|
if ((manifestEntry?.skillExposure || isSkillExposurePath(relativePath)) && (manifestEntry?.skillExposure && isCleanOwnedSkillCopy(targetDir, { relativePath, skillExposure: manifestEntry.skillExposure }, existingManifest) || isManagedSkillExposurePath(
|
|
2848
2957
|
absolutePath,
|
|
@@ -2911,17 +3020,17 @@ async function getPreviousSkillContentByPath(existingManifest) {
|
|
|
2911
3020
|
}
|
|
2912
3021
|
function classifyExistingSkillExposure(targetDir, asset) {
|
|
2913
3022
|
const absolutePath = relativePathToTarget(targetDir, asset.relativePath);
|
|
2914
|
-
const stats =
|
|
3023
|
+
const stats = lstatSync4(absolutePath);
|
|
2915
3024
|
if (stats.isSymbolicLink()) {
|
|
2916
|
-
const currentTarget =
|
|
2917
|
-
|
|
3025
|
+
const currentTarget = path6.resolve(
|
|
3026
|
+
path6.dirname(absolutePath),
|
|
2918
3027
|
readlinkSync(absolutePath)
|
|
2919
3028
|
);
|
|
2920
3029
|
const expectedTarget = relativePathToTarget(
|
|
2921
3030
|
targetDir,
|
|
2922
3031
|
asset.skillExposure.canonicalPayloadPath
|
|
2923
3032
|
);
|
|
2924
|
-
return
|
|
3033
|
+
return path6.resolve(currentTarget) === path6.resolve(expectedTarget) ? "symlink" : "conflict";
|
|
2925
3034
|
}
|
|
2926
3035
|
if (!stats.isDirectory()) {
|
|
2927
3036
|
return "conflict";
|
|
@@ -2933,7 +3042,7 @@ function classifyExistingSkillExposure(targetDir, asset) {
|
|
|
2933
3042
|
}
|
|
2934
3043
|
function isCleanManifestOwnedLegacySkillExposureDirectory(targetDir, relativePath, existingManifest) {
|
|
2935
3044
|
const absolutePath = relativePathToTarget(targetDir, relativePath);
|
|
2936
|
-
if (!existingManifest || !existsSync4(absolutePath) || !
|
|
3045
|
+
if (!existingManifest || !existsSync4(absolutePath) || !lstatSync4(absolutePath).isDirectory()) {
|
|
2937
3046
|
return false;
|
|
2938
3047
|
}
|
|
2939
3048
|
const descendantPaths = listDescendantFilePaths(absolutePath).map(
|
|
@@ -2955,7 +3064,7 @@ function isLegacySkillSourceId(sourceId) {
|
|
|
2955
3064
|
}
|
|
2956
3065
|
function isCleanLegacySkillExposureDirectory(targetDir, relativePath, previousSkillContent) {
|
|
2957
3066
|
const absolutePath = relativePathToTarget(targetDir, relativePath);
|
|
2958
|
-
if (!existsSync4(absolutePath) || !
|
|
3067
|
+
if (!existsSync4(absolutePath) || !lstatSync4(absolutePath).isDirectory()) {
|
|
2959
3068
|
return false;
|
|
2960
3069
|
}
|
|
2961
3070
|
const descendantPaths = listDescendantFilePaths(absolutePath).map(
|
|
@@ -2971,7 +3080,7 @@ function isCleanLegacySkillExposureDirectory(targetDir, relativePath, previousSk
|
|
|
2971
3080
|
}
|
|
2972
3081
|
function copyMirrorMatches(copyMirrorAssets, targetDir, exposurePath) {
|
|
2973
3082
|
const absoluteExposurePath = relativePathToTarget(targetDir, exposurePath);
|
|
2974
|
-
if (!existsSync4(absoluteExposurePath) || !
|
|
3083
|
+
if (!existsSync4(absoluteExposurePath) || !lstatSync4(absoluteExposurePath).isDirectory()) {
|
|
2975
3084
|
return false;
|
|
2976
3085
|
}
|
|
2977
3086
|
const expectedContentByPath = new Map(
|
|
@@ -2991,7 +3100,7 @@ function copyMirrorMatches(copyMirrorAssets, targetDir, exposurePath) {
|
|
|
2991
3100
|
function listDescendantFilePaths(root) {
|
|
2992
3101
|
const entries = readdirSync3(root, { withFileTypes: true });
|
|
2993
3102
|
return entries.flatMap((entry) => {
|
|
2994
|
-
const entryPath =
|
|
3103
|
+
const entryPath = path6.join(root, entry.name);
|
|
2995
3104
|
if (entry.isDirectory()) {
|
|
2996
3105
|
return listDescendantFilePaths(entryPath);
|
|
2997
3106
|
}
|
|
@@ -3002,7 +3111,7 @@ function listDescendantFilePaths(root) {
|
|
|
3002
3111
|
});
|
|
3003
3112
|
}
|
|
3004
3113
|
function isManagedSkillExposurePath(absolutePath, targetDir, relativePath, previousSkillContent, manifestSkillExposure) {
|
|
3005
|
-
const stats =
|
|
3114
|
+
const stats = lstatSync4(absolutePath);
|
|
3006
3115
|
if (stats.isSymbolicLink()) {
|
|
3007
3116
|
if (manifestSkillExposure?.canonicalPayloadPath) {
|
|
3008
3117
|
return skillExposureSymlinkTargetMatches(
|
|
@@ -3016,9 +3125,9 @@ function isManagedSkillExposurePath(absolutePath, targetDir, relativePath, previ
|
|
|
3016
3125
|
return stats.isDirectory() && isCleanLegacySkillExposureDirectory(targetDir, relativePath, previousSkillContent);
|
|
3017
3126
|
}
|
|
3018
3127
|
function skillExposureSymlinkTargetMatches(absolutePath, targetDir, canonicalPayloadPath) {
|
|
3019
|
-
const currentTarget =
|
|
3128
|
+
const currentTarget = path6.resolve(path6.dirname(absolutePath), readlinkSync(absolutePath));
|
|
3020
3129
|
const expectedTarget = relativePathToTarget(targetDir, canonicalPayloadPath);
|
|
3021
|
-
return
|
|
3130
|
+
return path6.resolve(currentTarget) === path6.resolve(expectedTarget);
|
|
3022
3131
|
}
|
|
3023
3132
|
function skillExposureDescendantsMatch(targetDir, relativePath, previousSkillContent) {
|
|
3024
3133
|
const absolutePath = relativePathToTarget(targetDir, relativePath);
|
|
@@ -3034,7 +3143,7 @@ function skillExposureDescendantsMatch(targetDir, relativePath, previousSkillCon
|
|
|
3034
3143
|
});
|
|
3035
3144
|
}
|
|
3036
3145
|
function normalizeSkillDescendantPath(targetDir, skillRootPath, descendantPath) {
|
|
3037
|
-
return
|
|
3146
|
+
return path6.isAbsolute(skillRootPath) ? normalizePlanPath(descendantPath) : normalizePlanPath(path6.relative(targetDir, descendantPath));
|
|
3038
3147
|
}
|
|
3039
3148
|
function isSkillExposurePath(relativePath) {
|
|
3040
3149
|
const normalizedPath = normalizePlanPath(relativePath);
|
|
@@ -3133,7 +3242,7 @@ function classifyReviewableManagedFileConflictPath(relativePath, options = {}) {
|
|
|
3133
3242
|
};
|
|
3134
3243
|
}
|
|
3135
3244
|
function getInstructionKindForPath(relativePath) {
|
|
3136
|
-
const basename =
|
|
3245
|
+
const basename = path6.posix.basename(relativePath);
|
|
3137
3246
|
return INSTRUCTION_KINDS.includes(basename) ? basename : null;
|
|
3138
3247
|
}
|
|
3139
3248
|
function isSkillAssetPath(relativePath) {
|
|
@@ -3208,7 +3317,7 @@ function getSkillExposureHash(asset) {
|
|
|
3208
3317
|
JSON.stringify({
|
|
3209
3318
|
canonicalPayloadPath: normalizePlanPath(asset.skillExposure.canonicalPayloadPath),
|
|
3210
3319
|
copyMirrorHashes: asset.copyMirrorAssets.map((copyAsset) => [
|
|
3211
|
-
normalizePlanPath(
|
|
3320
|
+
normalizePlanPath(path6.relative(asset.relativePath, copyAsset.relativePath)),
|
|
3212
3321
|
hashText(copyAsset.content)
|
|
3213
3322
|
]),
|
|
3214
3323
|
exposurePath: normalizePlanPath(asset.skillExposure.exposurePath),
|
|
@@ -3254,6 +3363,9 @@ function getInstructionMigrationContent(asset, currentContent, manifestEntry, cu
|
|
|
3254
3363
|
if (!isInstructionPath(asset.relativePath)) {
|
|
3255
3364
|
return null;
|
|
3256
3365
|
}
|
|
3366
|
+
if (manifestEntry?.ownershipClass === "project-owned") {
|
|
3367
|
+
return null;
|
|
3368
|
+
}
|
|
3257
3369
|
const currentBlock = parseManagedBlock(currentContent);
|
|
3258
3370
|
if (currentBlock.state !== "absent") {
|
|
3259
3371
|
if (currentBlock.state === "valid" && currentHash !== null && manifestEntry?.hash === currentHash) {
|
|
@@ -3335,15 +3447,15 @@ function isLegacySamePathSource(sourceId, relativePath) {
|
|
|
3335
3447
|
return sourceId === `file:${relativePath}` || sourceId === `build:${relativePath}`;
|
|
3336
3448
|
}
|
|
3337
3449
|
function schemaOneSurfaceHasPreservedContent(options) {
|
|
3338
|
-
const surfaceRoot =
|
|
3450
|
+
const surfaceRoot = path6.join(options.targetDir, options.directory);
|
|
3339
3451
|
if (!existsSync4(surfaceRoot)) return false;
|
|
3340
|
-
const surfaceStat =
|
|
3452
|
+
const surfaceStat = lstatSync4(surfaceRoot);
|
|
3341
3453
|
if (!surfaceStat.isDirectory() || surfaceStat.isSymbolicLink()) return false;
|
|
3342
3454
|
const visit = (directory) => readdirSync3(directory, { withFileTypes: true }).some((entry) => {
|
|
3343
|
-
const absolutePath =
|
|
3455
|
+
const absolutePath = path6.join(directory, entry.name);
|
|
3344
3456
|
if (entry.isDirectory()) return visit(absolutePath);
|
|
3345
3457
|
const relativePath = normalizePlanPath(
|
|
3346
|
-
|
|
3458
|
+
path6.relative(options.targetDir, absolutePath)
|
|
3347
3459
|
);
|
|
3348
3460
|
const manifestEntry = options.manifest.files[relativePath];
|
|
3349
3461
|
if (!manifestEntry || manifestEntry.ownershipClass === "project-owned") {
|
|
@@ -3354,9 +3466,16 @@ function schemaOneSurfaceHasPreservedContent(options) {
|
|
|
3354
3466
|
});
|
|
3355
3467
|
return visit(surfaceRoot);
|
|
3356
3468
|
}
|
|
3469
|
+
function hasPriorPortableAdoptionProof(manifest) {
|
|
3470
|
+
if (manifest?.packageVersion !== "2.0.7") return false;
|
|
3471
|
+
return Object.entries(manifest.routerOwnership?.routers ?? {}).some(([relativePath, router]) => {
|
|
3472
|
+
const file2 = manifest.files[relativePath];
|
|
3473
|
+
return router.ownershipClass === "project-owned" && router.provenanceState === "verified" && router.lifecycleDisposition === "active" && router.adoptionReceipt?.priorOwnershipClass === "unregistered" && router.installedHash === file2?.hash && router.sourceId === file2?.sourceId && file2?.ownershipClass === "project-owned";
|
|
3474
|
+
});
|
|
3475
|
+
}
|
|
3357
3476
|
function getCarriedOnDemandRouterAssets(options) {
|
|
3358
3477
|
const manifest = options.existingManifest;
|
|
3359
|
-
if (!manifest || !manifest.routerOwnership && !options.completedRemovalHandoff && manifest.schemaVersion !== 1) {
|
|
3478
|
+
if (!manifest && !options.adopt || manifest && !manifest.routerOwnership && !options.completedRemovalHandoff && manifest.schemaVersion !== 1) {
|
|
3360
3479
|
return [];
|
|
3361
3480
|
}
|
|
3362
3481
|
const surfaceDirectories = {
|
|
@@ -3365,8 +3484,8 @@ function getCarriedOnDemandRouterAssets(options) {
|
|
|
3365
3484
|
};
|
|
3366
3485
|
const assets = [];
|
|
3367
3486
|
for (const [surface, directory] of Object.entries(surfaceDirectories)) {
|
|
3368
|
-
const surfaceExists = existsSync4(
|
|
3369
|
-
const schemaOneSurfaceNeedsRouters = manifest
|
|
3487
|
+
const surfaceExists = existsSync4(path6.join(options.targetDir, directory));
|
|
3488
|
+
const schemaOneSurfaceNeedsRouters = manifest?.schemaVersion === 1 && schemaOneSurfaceHasPreservedContent({
|
|
3370
3489
|
targetDir: options.targetDir,
|
|
3371
3490
|
directory,
|
|
3372
3491
|
manifest
|
|
@@ -3375,10 +3494,10 @@ function getCarriedOnDemandRouterAssets(options) {
|
|
|
3375
3494
|
options.profile,
|
|
3376
3495
|
surface
|
|
3377
3496
|
)) {
|
|
3378
|
-
const proof = manifest
|
|
3379
|
-
const file2 = manifest
|
|
3497
|
+
const proof = manifest?.routerOwnership?.routers[asset.relativePath];
|
|
3498
|
+
const file2 = manifest?.files[asset.relativePath];
|
|
3380
3499
|
const completedRemovalFileProof = options.completedRemovalHandoff === true && file2?.sourceId === asset.sourceId && (file2.ownershipClass === void 0 || file2.ownershipClass === "managed-block");
|
|
3381
|
-
if (completedRemovalFileProof || schemaOneSurfaceNeedsRouters || surfaceExists && (!proof || proof.routerClass === "bootstrap" || proof.routerClass === "on-demand-surface") && (!proof || proof.provenanceState === "verified" && proof.ownershipClass === "managed-snapshot" && proof.lifecycleDisposition === "active" && proof.sourceId === asset.sourceId && file2?.sourceId === asset.sourceId && file2.ownershipClass === "managed-block")) {
|
|
3500
|
+
if (options.adopt && surfaceExists || completedRemovalFileProof || schemaOneSurfaceNeedsRouters || surfaceExists && (!proof || proof.routerClass === "bootstrap" || proof.routerClass === "on-demand-surface") && (!proof || proof.provenanceState === "verified" && proof.ownershipClass === "managed-snapshot" && proof.lifecycleDisposition === "active" && proof.sourceId === asset.sourceId && file2?.sourceId === asset.sourceId && file2.ownershipClass === "managed-block" || proof.provenanceState === "verified" && proof.ownershipClass === "project-owned" && proof.lifecycleDisposition === "active" && proof.sourceId === asset.sourceId && proof.installedHash === file2?.hash && Boolean(proof.adoptionReceipt) && file2?.sourceId === asset.sourceId && file2.ownershipClass === "project-owned")) {
|
|
3382
3501
|
assets.push(asset);
|
|
3383
3502
|
}
|
|
3384
3503
|
}
|
|
@@ -3391,8 +3510,8 @@ function assertTextDocumentAsset(asset) {
|
|
|
3391
3510
|
function assertStandardSkillLayout(manifest, targetDir, selections) {
|
|
3392
3511
|
if (selections && (!selections.skills || selections.selectedSkills.length === 0)) return;
|
|
3393
3512
|
if (targetDir && selections) {
|
|
3394
|
-
const oldRoot =
|
|
3395
|
-
if (
|
|
3513
|
+
const oldRoot = path6.join(selections.skillScope === "global" ? homedir() : targetDir, ".make-docs/agentics");
|
|
3514
|
+
if (lstatSync4(oldRoot, { throwIfNoEntry: false })) throw new Error(`Existing legacy directory needs inspection and reviewed cutover before Skill changes: ${oldRoot}. Preserve its content. Review named owned Skills with setup skills --adopt-existing <selected names> --dry-run, then --review <digest>. Unowned or unknown legacy content needs an explicit resolution before normal setup.`);
|
|
3396
3515
|
}
|
|
3397
3516
|
if ((manifest?.skillFiles ?? []).some((p) => /(?:^|\/)\.make-docs\/agentics\/skills(?:\/|$)/.test(p.replace(/\\/g, "/"))) || Object.entries(manifest?.files ?? {}).some(([p, entry]) => /(?:^|\/)\.make-docs\/agentics\/skills(?:\/|$)/.test(p.replace(/\\/g, "/")) || /(?:^|\/)\.make-docs\/agentics\/skills(?:\/|$)/.test(entry.skillExposure?.canonicalPayloadPath ?? ""))) {
|
|
3398
3517
|
throw new Error("Legacy Skill layout needs reviewed cutover. Run setup skills --adopt-existing <selected names> --dry-run with the same target, scope, and tools; review the result, then repeat with --review <digest>. Existing content is preserved.");
|
|
@@ -3421,7 +3540,8 @@ async function planInstall(options) {
|
|
|
3421
3540
|
systemAssetMaterializationMode: options.systemAssetMaterializationMode,
|
|
3422
3541
|
skillRegistry: options.skillRegistry,
|
|
3423
3542
|
preserveExistingSkills: options.preserveExistingSkills,
|
|
3424
|
-
operation: options.operation
|
|
3543
|
+
operation: options.operation,
|
|
3544
|
+
adopt: options.adopt
|
|
3425
3545
|
});
|
|
3426
3546
|
}
|
|
3427
3547
|
async function planSkillsOnlyInstall(options) {
|
|
@@ -3653,8 +3773,8 @@ function prepareInstallAction(targetDir, plan, action, conflictFiles) {
|
|
|
3653
3773
|
}
|
|
3654
3774
|
if (action.type === "remove-managed") return prepareInstallationRemoval(targetDir, action.relativePath);
|
|
3655
3775
|
if (action.type === "skip-conflict" && action.content !== void 0 && plan.conflictsRunId) {
|
|
3656
|
-
const relative =
|
|
3657
|
-
const conflictPath =
|
|
3776
|
+
const relative = path7.join(CONFLICTS_RELATIVE_DIR, plan.conflictsRunId, toConflictRelativePath(action.relativePath));
|
|
3777
|
+
const conflictPath = path7.join(targetDir, relative);
|
|
3658
3778
|
return [preparePlannedFileChange(targetDir, relative, { kind: "file", content: action.content }, () => {
|
|
3659
3779
|
writeContentFile(conflictPath, action.content);
|
|
3660
3780
|
conflictFiles.push(conflictPath);
|
|
@@ -3729,13 +3849,13 @@ function applyAction(options) {
|
|
|
3729
3849
|
}
|
|
3730
3850
|
case "skip-conflict": {
|
|
3731
3851
|
if (action.content !== void 0 && plan.conflictsRunId) {
|
|
3732
|
-
const conflictPath =
|
|
3852
|
+
const conflictPath = path7.join(
|
|
3733
3853
|
targetDir,
|
|
3734
3854
|
CONFLICTS_RELATIVE_DIR,
|
|
3735
3855
|
plan.conflictsRunId,
|
|
3736
3856
|
toConflictRelativePath(action.relativePath)
|
|
3737
3857
|
);
|
|
3738
|
-
recordPlannedFileChange(targetDir,
|
|
3858
|
+
recordPlannedFileChange(targetDir, path7.relative(targetDir, conflictPath), { kind: "file", content: action.content }, () => writeContentFile(conflictPath, action.content));
|
|
3739
3859
|
conflictFiles.push(conflictPath);
|
|
3740
3860
|
}
|
|
3741
3861
|
return;
|
|
@@ -3809,10 +3929,10 @@ function writeCopyMirror(assets, targetDir) {
|
|
|
3809
3929
|
}
|
|
3810
3930
|
for (const asset of assets) {
|
|
3811
3931
|
const parents = [];
|
|
3812
|
-
let parent =
|
|
3813
|
-
while (!existsSync5(relativePathToTarget(targetDir, parent)) && parent !== "." && parent !==
|
|
3932
|
+
let parent = path7.dirname(asset.relativePath);
|
|
3933
|
+
while (!existsSync5(relativePathToTarget(targetDir, parent)) && parent !== "." && parent !== path7.dirname(parent)) {
|
|
3814
3934
|
parents.unshift(parent);
|
|
3815
|
-
parent =
|
|
3935
|
+
parent = path7.dirname(parent);
|
|
3816
3936
|
}
|
|
3817
3937
|
for (const directory of parents) recordPlannedFileChange(targetDir, directory, { kind: "directory" }, () => mkdirSync(relativePathToTarget(targetDir, directory)));
|
|
3818
3938
|
recordPlannedFileChange(targetDir, asset.relativePath, { kind: "file", content: asset.content }, () => writeContentFile(relativePathToTarget(targetDir, asset.relativePath), asset.content));
|
|
@@ -3823,25 +3943,25 @@ function pruneRemovedManagedPathParents(targetDir, relativePath, absolutePath) {
|
|
|
3823
3943
|
if (!boundary) {
|
|
3824
3944
|
return;
|
|
3825
3945
|
}
|
|
3826
|
-
pruneInstallationParents(targetDir,
|
|
3946
|
+
pruneInstallationParents(targetDir, path7.dirname(absolutePath), boundary);
|
|
3827
3947
|
}
|
|
3828
3948
|
function getRemoveManagedPruneBoundary(targetDir, relativePath, absolutePath) {
|
|
3829
|
-
if (relativePath === ".make-docs/scripts/check_path_hygiene.py") return
|
|
3830
|
-
if (!
|
|
3949
|
+
if (relativePath === ".make-docs/scripts/check_path_hygiene.py") return path7.join(targetDir, ".make-docs");
|
|
3950
|
+
if (!path7.isAbsolute(relativePath)) {
|
|
3831
3951
|
return targetDir;
|
|
3832
3952
|
}
|
|
3833
3953
|
return getGlobalSelectedAgenticsPruneBoundary(absolutePath);
|
|
3834
3954
|
}
|
|
3835
3955
|
function getGlobalSelectedAgenticsPruneBoundary(absolutePath) {
|
|
3836
|
-
const currentRoots = [
|
|
3837
|
-
const root = currentRoots.find((root2) => absolutePath.startsWith(root2 +
|
|
3838
|
-
if (root) return
|
|
3839
|
-
const segments =
|
|
3956
|
+
const currentRoots = [path7.join(homedir2(), ".agents/skills"), getHarnessSkillDirectory("codex", "global"), getHarnessSkillDirectory("claude-code", "global")];
|
|
3957
|
+
const root = currentRoots.find((root2) => absolutePath.startsWith(root2 + path7.sep));
|
|
3958
|
+
if (root) return path7.dirname(root);
|
|
3959
|
+
const segments = path7.resolve(absolutePath).split(path7.sep);
|
|
3840
3960
|
const agenticsIndex = segments.lastIndexOf("agentics");
|
|
3841
3961
|
if (agenticsIndex < 1 || segments[agenticsIndex - 1] !== ".make-docs") {
|
|
3842
3962
|
return null;
|
|
3843
3963
|
}
|
|
3844
|
-
return segments.slice(0, agenticsIndex).join(
|
|
3964
|
+
return segments.slice(0, agenticsIndex).join(path7.sep) || path7.sep;
|
|
3845
3965
|
}
|
|
3846
3966
|
function compareReviewableManagedFileConflicts(left, right) {
|
|
3847
3967
|
const leftGroup = MANAGED_FILE_CONFLICT_GROUP_ORDER[left.group];
|
|
@@ -3859,25 +3979,25 @@ var MANAGED_FILE_CONFLICT_GROUP_ORDER = {
|
|
|
3859
3979
|
function toConflictRelativePath(relativePath) {
|
|
3860
3980
|
const segments = relativePath.split(/[/\\]+/).filter(Boolean);
|
|
3861
3981
|
const safeSegments = segments.filter((segment) => segment !== "." && segment !== "..");
|
|
3862
|
-
if (
|
|
3982
|
+
if (path7.isAbsolute(relativePath)) {
|
|
3863
3983
|
const [first, ...rest] = safeSegments;
|
|
3864
3984
|
const drive = first?.replace(/:$/, "");
|
|
3865
|
-
return
|
|
3985
|
+
return path7.join("__absolute__", ...drive ? [drive, ...rest] : rest);
|
|
3866
3986
|
}
|
|
3867
|
-
return
|
|
3987
|
+
return path7.join(...safeSegments);
|
|
3868
3988
|
}
|
|
3869
3989
|
function toErrorMessage(error) {
|
|
3870
3990
|
return error instanceof Error ? error.message : String(error);
|
|
3871
3991
|
}
|
|
3872
3992
|
|
|
3873
3993
|
// src/skills-adoption.ts
|
|
3874
|
-
import { lstatSync as
|
|
3875
|
-
import
|
|
3994
|
+
import { lstatSync as lstatSync5, readFileSync as readFileSync6, readdirSync as readdirSync4, readlinkSync as readlinkSync2 } from "fs";
|
|
3995
|
+
import path8 from "path";
|
|
3876
3996
|
import os from "os";
|
|
3877
3997
|
import { isDeepStrictEqual as isDeepStrictEqual3 } from "util";
|
|
3878
3998
|
var OPERATION = "setup.skills.adopt";
|
|
3879
3999
|
var missing = () => ({ kind: "missing" });
|
|
3880
|
-
var normalized = (p) => p.split(
|
|
4000
|
+
var normalized = (p) => p.split(path8.sep).join("/");
|
|
3881
4001
|
var under = (p, root) => p === root || p.startsWith(root + "/");
|
|
3882
4002
|
var depth = (p) => p.split("/").length;
|
|
3883
4003
|
function canonical(value) {
|
|
@@ -3897,7 +4017,7 @@ function file(content, mode = 420) {
|
|
|
3897
4017
|
}
|
|
3898
4018
|
function inspect(root, p) {
|
|
3899
4019
|
const absolute = relativePathToTarget(root, p);
|
|
3900
|
-
const st =
|
|
4020
|
+
const st = lstatSync5(absolute, { throwIfNoEntry: false });
|
|
3901
4021
|
if (!st) return missing();
|
|
3902
4022
|
if (st.isSymbolicLink()) return { kind: "symlink", target: readlinkSync2(absolute) };
|
|
3903
4023
|
if (st.isDirectory()) return { kind: "directory", mode: st.mode & 511 };
|
|
@@ -3919,13 +4039,13 @@ function snapshot(root, roots, exact) {
|
|
|
3919
4039
|
function checkParents(root, roots) {
|
|
3920
4040
|
const issues = [];
|
|
3921
4041
|
for (const p of roots) {
|
|
3922
|
-
let parent =
|
|
3923
|
-
while (parent !==
|
|
3924
|
-
const st =
|
|
4042
|
+
let parent = path8.dirname(relativePathToTarget(root, p));
|
|
4043
|
+
while (parent !== path8.dirname(parent)) {
|
|
4044
|
+
const st = lstatSync5(parent, { throwIfNoEntry: false });
|
|
3925
4045
|
if (st?.isSymbolicLink()) issues.push(`Unsafe link parent: ${parent}.`);
|
|
3926
4046
|
if (st && !st.isDirectory()) issues.push(`Non-directory parent: ${parent}.`);
|
|
3927
4047
|
if (parent === root || parent === os.homedir()) break;
|
|
3928
|
-
parent =
|
|
4048
|
+
parent = path8.dirname(parent);
|
|
3929
4049
|
}
|
|
3930
4050
|
}
|
|
3931
4051
|
return [...new Set(issues)];
|
|
@@ -3933,13 +4053,13 @@ function checkParents(root, roots) {
|
|
|
3933
4053
|
function skillRoot(p) {
|
|
3934
4054
|
return p.match(/^(.*(?:^|\/)(?:\.make-docs\/agentics|\.agents|\.claude|\.codex)\/skills\/[^/]+)(?:\/|$)/)?.[1] ?? null;
|
|
3935
4055
|
}
|
|
3936
|
-
var legacySkillRoot = (p) => p.startsWith(".make-docs/agentics/skills/") ||
|
|
4056
|
+
var legacySkillRoot = (p) => p.startsWith(".make-docs/agentics/skills/") || path8.isAbsolute(p) && [os.homedir(), canonicalInstallationPath(os.homedir())].some((home) => p.startsWith(normalized(path8.join(home, ".make-docs/agentics/skills")) + "/"));
|
|
3937
4057
|
function addParents(map, before, p, boundary) {
|
|
3938
|
-
let parent = normalized(
|
|
4058
|
+
let parent = normalized(path8.dirname(p));
|
|
3939
4059
|
while (under(parent, boundary)) {
|
|
3940
4060
|
map[parent] ??= before[parent]?.kind === "directory" ? before[parent] : { kind: "directory", mode: 493 };
|
|
3941
4061
|
if (parent === boundary) break;
|
|
3942
|
-
parent = normalized(
|
|
4062
|
+
parent = normalized(path8.dirname(parent));
|
|
3943
4063
|
}
|
|
3944
4064
|
}
|
|
3945
4065
|
function setAsset(map, before, asset, boundary) {
|
|
@@ -3983,7 +4103,7 @@ async function buildSkillAdoptionReview(options) {
|
|
|
3983
4103
|
const exposures = assets.filter((a) => a.kind === "skill-exposure");
|
|
3984
4104
|
const payloads = assets.filter((a) => a.kind !== "skill-exposure");
|
|
3985
4105
|
const roots = [...new Set([...assets.map((a) => a.kind === "skill-exposure" ? a.relativePath : skillRoot(a.relativePath)), ...(beforeLedger?.skillFiles ?? []).map((p) => beforeLedger?.files[p]?.skillExposure ? p : skillRoot(p))].filter((p) => p !== null))].sort();
|
|
3986
|
-
const legacyContainers = [".make-docs/agentics", ...selections.skillScope === "global" || beforeLedger?.selections.skillScope === "global" ? [normalized(
|
|
4106
|
+
const legacyContainers = [".make-docs/agentics", ...selections.skillScope === "global" || beforeLedger?.selections.skillScope === "global" ? [normalized(path8.join(os.homedir(), ".make-docs/agentics"))] : []];
|
|
3987
4107
|
const unownedLegacy = [];
|
|
3988
4108
|
for (const container of legacyContainers) {
|
|
3989
4109
|
const parentIssues = checkParents(targetRoot, [container]);
|
|
@@ -4012,7 +4132,7 @@ async function buildSkillAdoptionReview(options) {
|
|
|
4012
4132
|
for (const claim of claims) if (canonicalInstallationPath(claim.rootPath) !== targetRoot || claim.kind === "pending") blockers.push(`Another ${claim.kind === "pending" ? "pending operation" : "checkout owner"} claims ${claim.path}: ${claim.rootPath}${claim.operationId ? ` (${claim.operationId})` : ""}.`);
|
|
4013
4133
|
const after = {};
|
|
4014
4134
|
const cleanupPaths = [];
|
|
4015
|
-
for (const oldRoot of roots.filter(legacySkillRoot)) if (!names.includes(
|
|
4135
|
+
for (const oldRoot of roots.filter(legacySkillRoot)) if (!names.includes(path8.basename(oldRoot))) blockers.push(`Legacy Skill ${path8.basename(oldRoot)} must be named in --adopt-existing for its reviewed layout cutover.`);
|
|
4016
4136
|
for (const oldName of beforeLedger?.selections.selectedSkills ?? []) if (!selections.selectedSkills.includes(oldName)) blockers.push(`Adoption cannot also deselect ${oldName}. Use normal setup skills to remove it, then create a new adoption review.`);
|
|
4017
4137
|
const alternatives = {};
|
|
4018
4138
|
const known = /* @__PURE__ */ new Set([...payloads.map((a) => a.relativePath), ...exposures.flatMap((a) => a.copyMirrorAssets.map((f) => f.relativePath)), ...Object.keys(beforeLedger?.files ?? {}).filter((p) => skillRoot(p))]);
|
|
@@ -4084,7 +4204,7 @@ async function buildSkillAdoptionReview(options) {
|
|
|
4084
4204
|
const prior = owned?.skillExposure;
|
|
4085
4205
|
const desired = exposures.find((exposure) => exposure.relativePath === action.relativePath);
|
|
4086
4206
|
const current = before[action.relativePath];
|
|
4087
|
-
const reviewedLegacyRetarget = prior && desired && current?.kind === "symlink" && prior.mode === "symlink" && current.target === prior.symlinkTarget && names.includes(prior.skillName) && beforeLedger?.skillFiles?.includes(action.relativePath) && owned.sourceId === desired.sourceId && prior.exposurePath === action.relativePath && prior.skillName === desired.skillExposure.skillName && prior.installName === desired.skillExposure.installName && prior.harness === desired.skillExposure.harness && prior.scope === desired.skillExposure.scope && legacySkillRoot(prior.canonicalPayloadPath) && roots.includes(prior.canonicalPayloadPath) &&
|
|
4207
|
+
const reviewedLegacyRetarget = prior && desired && current?.kind === "symlink" && prior.mode === "symlink" && current.target === prior.symlinkTarget && names.includes(prior.skillName) && beforeLedger?.skillFiles?.includes(action.relativePath) && owned.sourceId === desired.sourceId && prior.exposurePath === action.relativePath && prior.skillName === desired.skillExposure.skillName && prior.installName === desired.skillExposure.installName && prior.harness === desired.skillExposure.harness && prior.scope === desired.skillExposure.scope && legacySkillRoot(prior.canonicalPayloadPath) && roots.includes(prior.canonicalPayloadPath) && path8.resolve(path8.dirname(relativePathToTarget(targetRoot, action.relativePath)), prior.symlinkTarget) === path8.resolve(targetRoot, prior.canonicalPayloadPath);
|
|
4088
4208
|
if (!adoptedRoots.has(root) || owned && !reviewedLegacyRetarget) blockers.push(`Protected managed or unselected adoption conflict: ${action.relativePath}.`);
|
|
4089
4209
|
}
|
|
4090
4210
|
if (action.type === "remove-managed") delete desiredFiles[action.relativePath];
|
|
@@ -4097,7 +4217,7 @@ async function buildSkillAdoptionReview(options) {
|
|
|
4097
4217
|
const backupRoot = `.make-docs/backup/skill-adoption-${inventoryDigest.slice(0, 12)}`;
|
|
4098
4218
|
const backups = [];
|
|
4099
4219
|
for (const [p, old] of Object.entries(before)) if (old.kind === "file" && roots.some((root) => under(p, root)) && !same(old, after[p] ?? missing())) {
|
|
4100
|
-
const destination = backupRoot + "/" + (
|
|
4220
|
+
const destination = backupRoot + "/" + (path8.isAbsolute(p) ? "_global/" + p.replace(/^\/+/, "") : p);
|
|
4101
4221
|
backups.push({ source: p, destination, digest: old.digest });
|
|
4102
4222
|
after[destination] = old;
|
|
4103
4223
|
addParents(after, before, destination, backupRoot);
|
|
@@ -4108,20 +4228,20 @@ async function buildSkillAdoptionReview(options) {
|
|
|
4108
4228
|
before[backupRoot] = existingBackup;
|
|
4109
4229
|
}
|
|
4110
4230
|
for (const p of Object.keys(after)) {
|
|
4111
|
-
let parent = normalized(
|
|
4231
|
+
let parent = normalized(path8.dirname(p));
|
|
4112
4232
|
while (parent !== "." && parent !== "/" && !roots.some((r) => under(parent, r))) {
|
|
4113
|
-
if (
|
|
4114
|
-
if (
|
|
4115
|
-
if (
|
|
4233
|
+
if (path8.isAbsolute(parent) && !roots.some((r) => r.startsWith(parent + "/"))) break;
|
|
4234
|
+
if (path8.isAbsolute(parent) && parent === os.homedir()) break;
|
|
4235
|
+
if (path8.isAbsolute(parent) && parent === path8.join(os.homedir(), ".make-docs")) break;
|
|
4116
4236
|
const current = inspect(targetRoot, parent);
|
|
4117
4237
|
before[parent] ??= current;
|
|
4118
4238
|
if (current.kind === "missing") after[parent] ??= { kind: "directory", mode: 493 };
|
|
4119
4239
|
else if (current.kind === "directory") after[parent] ??= current;
|
|
4120
4240
|
else blockers.push(`Unsafe parent for planned output: ${parent}.`);
|
|
4121
|
-
parent = normalized(
|
|
4241
|
+
parent = normalized(path8.dirname(parent));
|
|
4122
4242
|
}
|
|
4123
4243
|
}
|
|
4124
|
-
const legacyParents = [...new Set(roots.filter(legacySkillRoot).flatMap((p) => [normalized(
|
|
4244
|
+
const legacyParents = [...new Set(roots.filter(legacySkillRoot).flatMap((p) => [normalized(path8.dirname(p)), normalized(path8.dirname(path8.dirname(p)))]))].sort((a, b) => depth(b) - depth(a));
|
|
4125
4245
|
for (const parent of legacyParents) {
|
|
4126
4246
|
const inventory = snapshot(targetRoot, [parent], []);
|
|
4127
4247
|
const unknown = Object.keys(inventory).filter((p) => p !== parent && !legacyParents.includes(p) && !roots.some((r) => under(p, r)));
|
|
@@ -4267,6 +4387,7 @@ export {
|
|
|
4267
4387
|
getSystemResourceMcpProfiles,
|
|
4268
4388
|
loadInstalledSystemResourceProvider,
|
|
4269
4389
|
matchesSystemResourceCatalogPath,
|
|
4390
|
+
inferLocalResourceProjection,
|
|
4270
4391
|
createRouterOwnershipManifestEntry,
|
|
4271
4392
|
createProjectSurfaceRouterAssets,
|
|
4272
4393
|
getThinRouterManagedBody,
|
|
@@ -4280,4 +4401,4 @@ export {
|
|
|
4280
4401
|
registerSkillAdoptionRecovery,
|
|
4281
4402
|
applySkillAdoptionReview
|
|
4282
4403
|
};
|
|
4283
|
-
//# sourceMappingURL=chunk-
|
|
4404
|
+
//# sourceMappingURL=chunk-I3BO4LEF.js.map
|