@brucewaynedecoy/make-docs 2.0.5 → 2.0.7
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-2OT4A6LR.js → backup-M5RBOM6F.js} +4 -4
- package/dist/{chunk-VMKG3H4B.js → chunk-3ZFX5456.js} +2 -2
- package/dist/{chunk-46MGH32G.js → chunk-5WR4D6HH.js} +2 -2
- package/dist/{chunk-UNR4CYVX.js → chunk-65TAUWTC.js} +3 -3
- package/dist/{chunk-I4FADOUK.js → chunk-7AVGITZK.js} +2 -2
- package/dist/{chunk-CLSOY7NV.js → chunk-B6HJRHWL.js} +179 -103
- package/dist/chunk-B6HJRHWL.js.map +1 -0
- package/dist/{chunk-HXWD2EUD.js → chunk-C67WJWVP.js} +278 -74
- package/dist/chunk-C67WJWVP.js.map +1 -0
- package/dist/{chunk-CCYP5NU2.js → chunk-O27AYYF3.js} +3 -3
- package/dist/{chunk-XDSWX4Y4.js → chunk-OSS4NT6N.js} +88 -8
- package/dist/chunk-OSS4NT6N.js.map +1 -0
- package/dist/{chunk-CMNKQM7L.js → chunk-YJLVHT4J.js} +3 -3
- package/dist/{chunk-ISSMVKIA.js → chunk-Z4KZ4JTE.js} +2 -2
- package/dist/index.js +397 -36
- package/dist/index.js.map +1 -1
- package/dist/{registry-PC5GKAKM.js → registry-7L26WFZP.js} +7 -7
- package/dist/{self-WYVXO23B.js → self-4HOKEXBV.js} +7 -7
- package/dist/{server-BQOG6FTA.js → server-VXVGDWRY.js} +13 -9
- package/dist/server-VXVGDWRY.js.map +1 -0
- package/dist/{setup-system-KN7FTTLT.js → setup-system-CJESBAQ5.js} +7 -7
- package/dist/{skills-command-KEW7MOEW.js → skills-command-YXPOHXI2.js} +6 -6
- package/dist/{uninstall-45XF4CHD.js → uninstall-R2QK7XPK.js} +7 -7
- package/dist/{virtual_make-docs-first-party-skills-ECJESFL2.js → virtual_make-docs-first-party-skills-POWW3OI3.js} +2 -2
- package/dist/{virtual_make-docs-first-party-skills-ECJESFL2.js.map → virtual_make-docs-first-party-skills-POWW3OI3.js.map} +1 -1
- package/package.json +1 -1
- package/dist/chunk-CLSOY7NV.js.map +0 -1
- package/dist/chunk-HXWD2EUD.js.map +0 -1
- package/dist/chunk-XDSWX4Y4.js.map +0 -1
- package/dist/server-BQOG6FTA.js.map +0 -1
- /package/dist/{backup-2OT4A6LR.js.map → backup-M5RBOM6F.js.map} +0 -0
- /package/dist/{chunk-VMKG3H4B.js.map → chunk-3ZFX5456.js.map} +0 -0
- /package/dist/{chunk-46MGH32G.js.map → chunk-5WR4D6HH.js.map} +0 -0
- /package/dist/{chunk-UNR4CYVX.js.map → chunk-65TAUWTC.js.map} +0 -0
- /package/dist/{chunk-I4FADOUK.js.map → chunk-7AVGITZK.js.map} +0 -0
- /package/dist/{chunk-CCYP5NU2.js.map → chunk-O27AYYF3.js.map} +0 -0
- /package/dist/{chunk-CMNKQM7L.js.map → chunk-YJLVHT4J.js.map} +0 -0
- /package/dist/{chunk-ISSMVKIA.js.map → chunk-Z4KZ4JTE.js.map} +0 -0
- /package/dist/{registry-PC5GKAKM.js.map → registry-7L26WFZP.js.map} +0 -0
- /package/dist/{self-WYVXO23B.js.map → self-4HOKEXBV.js.map} +0 -0
- /package/dist/{setup-system-KN7FTTLT.js.map → setup-system-CJESBAQ5.js.map} +0 -0
- /package/dist/{skills-command-KEW7MOEW.js.map → skills-command-YXPOHXI2.js.map} +0 -0
- /package/dist/{uninstall-45XF4CHD.js.map → uninstall-R2QK7XPK.js.map} +0 -0
|
@@ -9587,13 +9587,13 @@ function validateAdoptionReceipt(value, label, ownershipClass) {
|
|
|
9587
9587
|
return null;
|
|
9588
9588
|
}
|
|
9589
9589
|
assertPlainObject(value, label);
|
|
9590
|
-
if (value.priorOwnershipClass !== "managed-snapshot") {
|
|
9591
|
-
throw new Error(`${label}.priorOwnershipClass must be managed-snapshot`);
|
|
9590
|
+
if (value.priorOwnershipClass !== "managed-snapshot" && value.priorOwnershipClass !== "unregistered") {
|
|
9591
|
+
throw new Error(`${label}.priorOwnershipClass must be managed-snapshot or unregistered`);
|
|
9592
9592
|
}
|
|
9593
9593
|
return {
|
|
9594
9594
|
receiptId: validateString(value.receiptId, `${label}.receiptId`),
|
|
9595
9595
|
adoptedAt: validateIsoTimestamp(value.adoptedAt, `${label}.adoptedAt`),
|
|
9596
|
-
priorOwnershipClass:
|
|
9596
|
+
priorOwnershipClass: value.priorOwnershipClass,
|
|
9597
9597
|
evidenceRefs: validateNonEmptyStringArray(value.evidenceRefs, `${label}.evidenceRefs`)
|
|
9598
9598
|
};
|
|
9599
9599
|
}
|
|
@@ -9727,7 +9727,7 @@ function validateRouterOwnershipManifestState(value, files, selections, packageM
|
|
|
9727
9727
|
ownershipClass: rawEntry.ownershipClass,
|
|
9728
9728
|
expectedMaterializationMode: "managed-block"
|
|
9729
9729
|
});
|
|
9730
|
-
if (proof.expectedSourceHash !== files[relativePath]?.hash || proof.installedHash !== files[relativePath]?.hash) {
|
|
9730
|
+
if (rawEntry.ownershipClass === "managed-snapshot" && proof.expectedSourceHash !== files[relativePath]?.hash || proof.installedHash !== files[relativePath]?.hash) {
|
|
9731
9731
|
throw new Error(
|
|
9732
9732
|
`manifest.routerOwnership.routers.${relativePath} hashes must match manifest.files`
|
|
9733
9733
|
);
|
|
@@ -11194,7 +11194,7 @@ function withReviewedStoreCompatibilityBridge(fn) {
|
|
|
11194
11194
|
function withInstallationDatabase(projectRoot, fn, options = {}) {
|
|
11195
11195
|
const root = canonicalInstallationPath(projectRoot);
|
|
11196
11196
|
const store = validateInstallationStoreRoot(root, options.storeRoot ?? active.get(root)?.storeRoot ?? held2.get(root)?.storeRoot ?? resolveStoreRoot());
|
|
11197
|
-
if (!options.readOnly && !held2.has(root))
|
|
11197
|
+
if (!options.readOnly && !options.skipPreparation && !held2.has(root))
|
|
11198
11198
|
prepareStore(root, store);
|
|
11199
11199
|
const databasePath = getStoreDatabasePath(store);
|
|
11200
11200
|
try {
|
|
@@ -11250,61 +11250,122 @@ function checkout(db, root) {
|
|
|
11250
11250
|
fail("ownership-unverified", "More than one checkout claims this platform path. No Store identity changed.");
|
|
11251
11251
|
return matches2[0] ?? null;
|
|
11252
11252
|
}
|
|
11253
|
-
function
|
|
11254
|
-
|
|
11255
|
-
|
|
11256
|
-
|
|
11257
|
-
|
|
11258
|
-
|
|
11259
|
-
|
|
11260
|
-
|
|
11261
|
-
if (
|
|
11262
|
-
|
|
11263
|
-
|
|
11264
|
-
|
|
11265
|
-
|
|
11266
|
-
|
|
11267
|
-
|
|
11268
|
-
|
|
11253
|
+
function checkoutOwnershipFacts(root, ledgerJson, projectId, requireFullProof) {
|
|
11254
|
+
if (!ledgerJson || ledgerJson === "null") return [];
|
|
11255
|
+
let manifest;
|
|
11256
|
+
try {
|
|
11257
|
+
manifest = validateAndMigrateManifest(JSON.parse(ledgerJson), "Make Docs Store checkout verification ledger");
|
|
11258
|
+
} catch {
|
|
11259
|
+
return fail("ownership-unverified", "The saved installation ledger is invalid. No checkout ownership changed.");
|
|
11260
|
+
}
|
|
11261
|
+
if (manifest.projectId !== projectId)
|
|
11262
|
+
return fail("ownership-unverified", "The saved installation ledger has a different project identity.");
|
|
11263
|
+
const facts = [];
|
|
11264
|
+
for (const [relative, entry] of Object.entries(manifest.files).sort(([a], [b]) => a.localeCompare(b))) {
|
|
11265
|
+
if (relative === ".make-docs/config.yaml" || entry.ownershipClass === "project-owned" || entry.ownershipClass === "runtime-state" || entry.ownershipClass === "project-override") continue;
|
|
11266
|
+
const ownershipClass = entry.ownershipClass ?? (manifest.schemaVersion === 1 ? "managed-snapshot" : null);
|
|
11267
|
+
if (!ownershipClass || !entry.sourceId || !/^[a-f0-9]{64}$/i.test(entry.hash)) {
|
|
11268
|
+
if (!requireFullProof) continue;
|
|
11269
|
+
return fail("ownership-unverified", `The saved ownership proof is incomplete for ${relative}. No checkout ownership changed.`);
|
|
11270
|
+
}
|
|
11271
|
+
const absolute = assertSafeFilePath(root, relative);
|
|
11269
11272
|
const stat = lstatSync6(absolute, { throwIfNoEntry: false });
|
|
11270
|
-
if (
|
|
11271
|
-
|
|
11272
|
-
|
|
11273
|
-
|
|
11274
|
-
|
|
11275
|
-
|
|
11276
|
-
|
|
11277
|
-
}
|
|
11278
|
-
|
|
11279
|
-
|
|
11280
|
-
|
|
11281
|
-
|
|
11282
|
-
|
|
11283
|
-
|
|
11284
|
-
|
|
11285
|
-
|
|
11286
|
-
|
|
11287
|
-
|
|
11288
|
-
|
|
11273
|
+
if (entry.skillExposure) {
|
|
11274
|
+
try {
|
|
11275
|
+
verifySkillExposure(root, relative, entry);
|
|
11276
|
+
} catch (error) {
|
|
11277
|
+
if (!requireFullProof && error instanceof InstallationStateError && error.code === "ownership-unverified") continue;
|
|
11278
|
+
throw error;
|
|
11279
|
+
}
|
|
11280
|
+
facts.push({ path: relative, ownershipClass, hash: entry.hash });
|
|
11281
|
+
continue;
|
|
11282
|
+
}
|
|
11283
|
+
if (!stat?.isFile() || stat.isSymbolicLink()) {
|
|
11284
|
+
if (requireFullProof) return fail("ownership-unverified", `The saved ${ownershipClass} path is not a regular file: ${relative}. No checkout ownership changed.`);
|
|
11285
|
+
continue;
|
|
11286
|
+
}
|
|
11287
|
+
const bytes = readFileSync5(absolute);
|
|
11288
|
+
let actualHash;
|
|
11289
|
+
if (ownershipClass === "managed-block") {
|
|
11290
|
+
const parsed = parseManagedBlock(bytes.toString("utf8"));
|
|
11291
|
+
if (parsed.state !== "valid" || parsed.body === null) {
|
|
11292
|
+
if (requireFullProof) return fail("ownership-unverified", `The managed block markers are invalid for ${relative}. No checkout ownership changed.`);
|
|
11293
|
+
continue;
|
|
11294
|
+
}
|
|
11295
|
+
actualHash = sha(parsed.body);
|
|
11296
|
+
} else {
|
|
11297
|
+
actualHash = sha(bytes);
|
|
11298
|
+
}
|
|
11299
|
+
if (actualHash !== entry.hash) {
|
|
11300
|
+
if (requireFullProof) return fail("ownership-unverified", `The saved ${ownershipClass} hash does not match ${relative}. No checkout ownership changed.`);
|
|
11301
|
+
continue;
|
|
11302
|
+
}
|
|
11303
|
+
facts.push({ path: relative, ownershipClass, hash: entry.hash });
|
|
11304
|
+
}
|
|
11305
|
+
return facts;
|
|
11306
|
+
}
|
|
11307
|
+
function verifySkillExposure(root, relative, entry) {
|
|
11308
|
+
const exposure = entry.skillExposure;
|
|
11309
|
+
if (entry.ownershipClass !== "selected-skill" || exposure.exposurePath !== relative || !exposure.mode)
|
|
11310
|
+
fail("ownership-unverified", `The saved skill exposure proof is incomplete for ${relative}.`);
|
|
11311
|
+
const absolute = assertSafeFilePath(root, relative);
|
|
11312
|
+
const stat = lstatSync6(absolute, { throwIfNoEntry: false });
|
|
11313
|
+
if (exposure.mode === "symlink") {
|
|
11314
|
+
if (!stat?.isSymbolicLink() || readlinkSync(absolute) !== exposure.symlinkTarget)
|
|
11315
|
+
fail("ownership-unverified", `The saved skill link does not match ${relative}.`);
|
|
11316
|
+
const linked = path9.resolve(path9.dirname(absolute), exposure.symlinkTarget);
|
|
11317
|
+
const canonical2 = assertSafeFilePath(root, exposure.canonicalPayloadPath);
|
|
11318
|
+
if (!platform.samePath(linked, canonical2))
|
|
11319
|
+
fail("ownership-unverified", `The saved skill link target is inconsistent for ${relative}.`);
|
|
11320
|
+
return;
|
|
11321
|
+
}
|
|
11322
|
+
if (!stat?.isDirectory() || stat.isSymbolicLink())
|
|
11323
|
+
fail("ownership-unverified", `The saved skill copy is not a directory: ${relative}.`);
|
|
11324
|
+
const canonical = assertSafeFilePath(root, exposure.canonicalPayloadPath);
|
|
11325
|
+
if (!lstatSync6(canonical, { throwIfNoEntry: false })?.isDirectory())
|
|
11326
|
+
fail("ownership-unverified", `The saved skill source is not a directory: ${relative}.`);
|
|
11327
|
+
const tree = (directory) => {
|
|
11328
|
+
const result = [];
|
|
11329
|
+
const visit3 = (current) => {
|
|
11330
|
+
for (const child of readdirSync4(current, { withFileTypes: true })) {
|
|
11331
|
+
const file = path9.join(current, child.name);
|
|
11332
|
+
if (child.isDirectory()) visit3(file);
|
|
11333
|
+
else if (child.isFile()) result.push([path9.relative(directory, file), sha(readFileSync5(file))]);
|
|
11334
|
+
else fail("ownership-unverified", `The saved skill copy contains an unsafe path: ${relative}.`);
|
|
11335
|
+
}
|
|
11336
|
+
};
|
|
11337
|
+
visit3(directory);
|
|
11338
|
+
return result.sort(([a], [b]) => a.localeCompare(b));
|
|
11339
|
+
};
|
|
11340
|
+
if (canonicalJson(tree(absolute)) !== canonicalJson(tree(canonical)))
|
|
11341
|
+
fail("ownership-unverified", `The saved skill copy differs from its source: ${relative}.`);
|
|
11342
|
+
}
|
|
11343
|
+
function checkoutVerificationEvidence(_db, root, projectId, _checkoutId, ledgerJson, requireFullProof = true) {
|
|
11344
|
+
const declaredId = readDeclarativeProjectId(root);
|
|
11345
|
+
if (declaredId && declaredId !== projectId)
|
|
11346
|
+
return fail("ownership-unverified", "The config project identity conflicts with the saved installation ledger.");
|
|
11289
11347
|
return {
|
|
11290
|
-
schemaVersion:
|
|
11348
|
+
schemaVersion: 2,
|
|
11291
11349
|
projectId,
|
|
11292
|
-
configDigest: configStat ? sha(readFileSync5(config)) : null,
|
|
11293
11350
|
ledgerDigest: ledgerJson && ledgerJson !== "null" ? sha(ledgerJson) : null,
|
|
11294
|
-
|
|
11351
|
+
ownershipFacts: checkoutOwnershipFacts(root, ledgerJson, projectId, requireFullProof)
|
|
11295
11352
|
};
|
|
11296
11353
|
}
|
|
11297
11354
|
function parseCheckoutVerification(row) {
|
|
11298
11355
|
if (!row.verification_json) return null;
|
|
11299
11356
|
try {
|
|
11300
11357
|
const value = JSON.parse(row.verification_json);
|
|
11358
|
+
if (value.schemaVersion === 2 && typeof value.projectId === "string" && (typeof value.ledgerDigest === "string" || value.ledgerDigest === null) && Array.isArray(value.ownershipFacts) && value.ownershipFacts.every((fact) => typeof fact?.path === "string" && typeof fact?.ownershipClass === "string" && typeof fact?.hash === "string"))
|
|
11359
|
+
return value;
|
|
11301
11360
|
return value.schemaVersion === 1 && typeof value.projectId === "string" && (typeof value.configDigest === "string" || value.configDigest === null) && (typeof value.ledgerDigest === "string" || value.ledgerDigest === null) && (typeof value.managedContentDigest === "string" || value.managedContentDigest === null) ? value : null;
|
|
11302
11361
|
} catch {
|
|
11303
11362
|
return null;
|
|
11304
11363
|
}
|
|
11305
11364
|
}
|
|
11306
11365
|
function sameCheckoutEvidence(left, right) {
|
|
11307
|
-
|
|
11366
|
+
if (left.projectId !== right.projectId || left.ledgerDigest !== right.ledgerDigest) return false;
|
|
11367
|
+
if (left.schemaVersion === 1) return left.ledgerDigest !== null;
|
|
11368
|
+
return canonicalJson(left.ownershipFacts) === canonicalJson(right.ownershipFacts);
|
|
11308
11369
|
}
|
|
11309
11370
|
function assertCheckoutIdentity(row, root) {
|
|
11310
11371
|
const id = readDeclarativeProjectId(root);
|
|
@@ -11326,32 +11387,169 @@ function bindCheckout(db, root, projectId) {
|
|
|
11326
11387
|
fail("ownership-unverified", "The requested project identity conflicts with the checkout config.");
|
|
11327
11388
|
const id = declarativeId ?? projectId ?? randomUUID5();
|
|
11328
11389
|
const sameProject = db.prepare("SELECT * FROM installation_checkouts WHERE project_id=?").all(id);
|
|
11329
|
-
|
|
11330
|
-
|
|
11331
|
-
if (absent.length !== 1)
|
|
11332
|
-
fail("ownership-unverified", "More than one absent checkout can claim this project path. No Store identity changed.");
|
|
11333
|
-
const row2 = absent[0];
|
|
11334
|
-
const busy = db.prepare("SELECT 1 FROM installation_operations WHERE checkout_id=? AND status='pending'").get(row2.checkout_id);
|
|
11335
|
-
if (busy || db.prepare("SELECT 1 FROM installation_locks WHERE root_path=?").get(row2.root_path))
|
|
11336
|
-
fail("recovery-required", "Resolve the old checkout operation before rebinding its path.");
|
|
11337
|
-
const ledger = db.prepare("SELECT manifest_json FROM installation_ledgers WHERE checkout_id=?").get(row2.checkout_id)?.manifest_json ?? null;
|
|
11338
|
-
const priorEvidence = parseCheckoutVerification(row2);
|
|
11339
|
-
const currentEvidence = checkoutVerificationEvidence(db, root, id, row2.checkout_id, ledger);
|
|
11340
|
-
if (!priorEvidence || !sameCheckoutEvidence(priorEvidence, currentEvidence))
|
|
11341
|
-
fail("ownership-unverified", "The moved checkout content does not match its last verified Store facts. No Store identity changed.");
|
|
11342
|
-
const key = platform.comparisonKey(root);
|
|
11343
|
-
const competing = db.prepare("SELECT * FROM installation_checkouts WHERE checkout_id<>?").all(row2.checkout_id).some((candidate) => candidate.root_path_key === key || platform.samePath(candidate.root_path, root));
|
|
11344
|
-
if (competing)
|
|
11345
|
-
fail("ownership-unverified", "Another checkout already claims this platform path. No Store identity changed.");
|
|
11346
|
-
const verifiedAt = now();
|
|
11347
|
-
const verificationJson = JSON.stringify(currentEvidence);
|
|
11348
|
-
db.prepare("UPDATE installation_checkouts SET root_path=?,root_path_key=?,verified_at=?,verification_json=? WHERE checkout_id=?").run(root, key, verifiedAt, verificationJson, row2.checkout_id);
|
|
11349
|
-
return { ...row2, root_path: root, root_path_key: key, verified_at: verifiedAt, verification_json: verificationJson };
|
|
11350
|
-
}
|
|
11390
|
+
if (sameProject.length && declarativeId)
|
|
11391
|
+
fail("ownership-unverified", "This project ID has a Store checkout at another path. Review checkout move or register a separate checkout before setup. No Store identity changed.");
|
|
11351
11392
|
const row = { checkout_id: randomUUID5(), project_id: id, root_path: root, root_path_key: platform.comparisonKey(root), verified_at: null, verification_json: null };
|
|
11352
11393
|
db.prepare("INSERT INTO installation_checkouts (checkout_id,project_id,root_path,created_at,root_path_key,verified_at,verification_json) VALUES (?,?,?,?,?,?,?)").run(row.checkout_id, id, root, now(), row.root_path_key, row.verified_at, row.verification_json);
|
|
11353
11394
|
return row;
|
|
11354
11395
|
}
|
|
11396
|
+
function previewInstallationCheckoutMove(projectRoot, sourceCheckoutId, storeRoot) {
|
|
11397
|
+
const root = canonicalInstallationPath(projectRoot);
|
|
11398
|
+
const id = readDeclarativeProjectId(root);
|
|
11399
|
+
const base = { schemaVersion: 1, projectId: id, targetRoot: root };
|
|
11400
|
+
if (!id) return { ...base, status: "none", candidates: [], nextAction: "A valid projectId in .make-docs/config.yaml is required before checkout move." };
|
|
11401
|
+
const store = validateInstallationStoreRoot(root, storeRoot ?? resolveStoreRoot());
|
|
11402
|
+
if (classifyStoreCheckpoint9State(store).state !== "supported-current")
|
|
11403
|
+
return { ...base, status: "blocked", candidates: [], nextAction: "The Store must use the current schema before checkout move." };
|
|
11404
|
+
return withInstallationDatabase(root, (db) => previewInstallationCheckoutMoveInDatabase(db, root, id, sourceCheckoutId), { storeRoot: store, readOnly: true });
|
|
11405
|
+
}
|
|
11406
|
+
function hasCompletedRemoval(db, checkoutId) {
|
|
11407
|
+
const latest = db.prepare("SELECT operation FROM installation_operations WHERE checkout_id=? AND status='completed' ORDER BY finished_at DESC, operation_id DESC LIMIT 1").get(checkoutId);
|
|
11408
|
+
return latest?.operation === "setup.remove";
|
|
11409
|
+
}
|
|
11410
|
+
function previewInstallationCheckoutMoveInDatabase(db, root, id, sourceCheckoutId) {
|
|
11411
|
+
const base = { schemaVersion: 1, projectId: id, targetRoot: root };
|
|
11412
|
+
const bound = checkout(db, root);
|
|
11413
|
+
if (bound && bound.project_id === id) {
|
|
11414
|
+
assertCheckoutIdentity(bound, root);
|
|
11415
|
+
const pending = db.prepare("SELECT operation_id FROM installation_operations WHERE checkout_id=? AND status='pending' LIMIT 1").get(bound.checkout_id);
|
|
11416
|
+
if (pending) return { ...base, status: "recovery-required", candidates: [], nextAction: `Run make-docs project state status --target-root ${JSON.stringify(root)} before recovery.` };
|
|
11417
|
+
const ledger = db.prepare("SELECT 1 FROM installation_ledgers WHERE checkout_id=?").get(bound.checkout_id);
|
|
11418
|
+
const removed = !ledger && hasCompletedRemoval(db, bound.checkout_id);
|
|
11419
|
+
return ledger ? { ...base, status: "bound", candidates: [], nextAction: "This checkout is already bound. Continue setup." } : removed ? { ...base, status: "bound", candidates: [], nextAction: "Review the completed removal before setup." } : { ...base, status: "portable-unregistered", candidates: [], nextAction: "Run make-docs setup --adopt to complete this checkout." };
|
|
11420
|
+
}
|
|
11421
|
+
const rows = db.prepare("SELECT * FROM installation_checkouts WHERE project_id=? ORDER BY checkout_id").all(id);
|
|
11422
|
+
const targetKey = platform.comparisonKey(root);
|
|
11423
|
+
const claimed = db.prepare("SELECT * FROM installation_checkouts").all().some((row) => row.root_path_key === targetKey || platform.samePath(row.root_path, root));
|
|
11424
|
+
const configDigest = sha(readFileSync5(path9.join(root, ".make-docs/config.yaml")));
|
|
11425
|
+
const separateReviewDigest = claimed || !rows.length ? null : sha(canonicalJson({
|
|
11426
|
+
schemaVersion: 1,
|
|
11427
|
+
action: "register-separate",
|
|
11428
|
+
projectId: id,
|
|
11429
|
+
targetRoot: root,
|
|
11430
|
+
targetKey,
|
|
11431
|
+
configDigest,
|
|
11432
|
+
otherCheckouts: rows.map((row) => [row.checkout_id, row.root_path, row.root_path_key])
|
|
11433
|
+
}));
|
|
11434
|
+
const candidates = rows.map((row) => {
|
|
11435
|
+
const blockers = [];
|
|
11436
|
+
if (sourceCheckoutId && row.checkout_id !== sourceCheckoutId) blockers.push("Another source checkout was selected.");
|
|
11437
|
+
if (lstatSync6(row.root_path, { throwIfNoEntry: false })) blockers.push("The source path still exists.");
|
|
11438
|
+
if (claimed) blockers.push("Another checkout claims the target path.");
|
|
11439
|
+
if (db.prepare("SELECT 1 FROM installation_operations WHERE checkout_id=? AND status='pending'").get(row.checkout_id)) blockers.push("The source has pending work.");
|
|
11440
|
+
for (const lockedRoot of [row.root_path, root]) {
|
|
11441
|
+
const lock = db.prepare("SELECT pid,hostname FROM installation_locks WHERE root_path=?").get(lockedRoot);
|
|
11442
|
+
if (lock) blockers.push(isDead(lock.pid, lock.hostname) ? "A dead writer lock needs recovery." : "A writer is active.");
|
|
11443
|
+
}
|
|
11444
|
+
if (db.prepare("SELECT 1 FROM tool_operations WHERE status='pending' LIMIT 1").get()) blockers.push("A tool operation is pending.");
|
|
11445
|
+
const ledger = db.prepare("SELECT manifest_json FROM installation_ledgers WHERE checkout_id=?").get(row.checkout_id)?.manifest_json ?? null;
|
|
11446
|
+
const saved = parseCheckoutVerification(row);
|
|
11447
|
+
let current = null;
|
|
11448
|
+
if (!ledger || !saved) blockers.push("The source lacks a saved ledger or ownership proof.");
|
|
11449
|
+
else {
|
|
11450
|
+
try {
|
|
11451
|
+
current = checkoutVerificationEvidence(db, root, id, row.checkout_id, ledger);
|
|
11452
|
+
} catch (error) {
|
|
11453
|
+
blockers.push(error instanceof Error ? error.message : String(error));
|
|
11454
|
+
}
|
|
11455
|
+
if (current && !sameCheckoutEvidence(saved, current)) blockers.push("Target ownership does not match the saved Store facts.");
|
|
11456
|
+
if (current && current.ownershipFacts.length === 0) blockers.push("The target has no independent managed ownership fact.");
|
|
11457
|
+
}
|
|
11458
|
+
const reviewDigest = blockers.length || !current || !saved || !ledger ? null : sha(canonicalJson({
|
|
11459
|
+
schemaVersion: 1,
|
|
11460
|
+
projectId: id,
|
|
11461
|
+
checkoutId: row.checkout_id,
|
|
11462
|
+
sourceRoot: canonicalInstallationPath(row.root_path),
|
|
11463
|
+
sourceKey: row.root_path_key,
|
|
11464
|
+
targetRoot: root,
|
|
11465
|
+
targetKey,
|
|
11466
|
+
configDigest,
|
|
11467
|
+
ledgerDigest: sha(ledger),
|
|
11468
|
+
targetFiles: current.ownershipFacts.map((fact) => {
|
|
11469
|
+
const absolute = path9.join(root, fact.path);
|
|
11470
|
+
const stat = lstatSync6(absolute, { throwIfNoEntry: false });
|
|
11471
|
+
return [fact.path, stat?.isSymbolicLink() ? `link:${readlinkSync(absolute)}` : stat?.isFile() ? `file:${sha(readFileSync5(absolute))}` : "missing"];
|
|
11472
|
+
}),
|
|
11473
|
+
savedEvidenceDigest: sha(row.verification_json),
|
|
11474
|
+
targetEvidence: current
|
|
11475
|
+
}));
|
|
11476
|
+
return { checkoutId: row.checkout_id, sourceRoot: row.root_path, targetRoot: root, available: blockers.length === 0, blockers, reviewDigest };
|
|
11477
|
+
});
|
|
11478
|
+
const selected = sourceCheckoutId ? candidates.find((candidate) => candidate.checkoutId === sourceCheckoutId) : candidates.length === 1 ? candidates[0] : null;
|
|
11479
|
+
return {
|
|
11480
|
+
...base,
|
|
11481
|
+
status: !candidates.length && !claimed ? "portable-unregistered" : selected?.available ? "ready" : "blocked",
|
|
11482
|
+
candidates,
|
|
11483
|
+
separateReviewDigest,
|
|
11484
|
+
nextAction: !candidates.length && !claimed ? "Run make-docs setup --adopt to register this checkout." : !candidates.length ? "Another project claims this path. Resolve that claim before setup." : candidates.length > 1 && !sourceCheckoutId ? "Select one source checkout ID before move. Register separately or cancel if the source is not the same checkout." : selected?.available ? "Review the exact source, target, and digest. Apply checkout move only with explicit approval." : "Resolve the listed blockers. Register a separate checkout or cancel."
|
|
11485
|
+
};
|
|
11486
|
+
}
|
|
11487
|
+
function registerSeparateInstallationCheckout(projectRoot, reviewDigest, storeRoot) {
|
|
11488
|
+
const root = canonicalInstallationPath(projectRoot);
|
|
11489
|
+
const store = validateInstallationStoreRoot(root, storeRoot ?? resolveStoreRoot());
|
|
11490
|
+
if (classifyStoreCheckpoint9State(store).state !== "supported-current")
|
|
11491
|
+
fail("store-unavailable", "Separate checkout registration requires a current Store.");
|
|
11492
|
+
return withInstallationDatabase(root, (db) => transaction(db, () => {
|
|
11493
|
+
const id = readDeclarativeProjectId(root);
|
|
11494
|
+
if (!id) fail("ownership-unverified", "A valid config projectId is required.");
|
|
11495
|
+
const preview = previewInstallationCheckoutMoveInDatabase(db, root, id);
|
|
11496
|
+
if (!preview.separateReviewDigest || preview.separateReviewDigest !== reviewDigest)
|
|
11497
|
+
fail("ownership-unverified", "Separate checkout review is stale or blocked. Preview again.");
|
|
11498
|
+
const checkoutId = randomUUID5();
|
|
11499
|
+
db.prepare("INSERT INTO installation_checkouts (checkout_id,project_id,root_path,created_at,root_path_key,verified_at,verification_json) VALUES (?,?,?,?,?,?,?)").run(checkoutId, id, root, now(), platform.comparisonKey(root), null, null);
|
|
11500
|
+
return {
|
|
11501
|
+
status: "registered",
|
|
11502
|
+
projectId: id,
|
|
11503
|
+
checkoutId,
|
|
11504
|
+
targetRoot: root,
|
|
11505
|
+
effect: "new-checkout-binding",
|
|
11506
|
+
projectFilesChanged: false,
|
|
11507
|
+
nextAction: "Run setup for this target to review its own installation state."
|
|
11508
|
+
};
|
|
11509
|
+
}), { storeRoot: store, skipPreparation: true });
|
|
11510
|
+
}
|
|
11511
|
+
function applyInstallationCheckoutMove(projectRoot, sourceCheckoutId, sourceRoot, reviewDigest, storeRoot) {
|
|
11512
|
+
const root = canonicalInstallationPath(projectRoot);
|
|
11513
|
+
const store = validateInstallationStoreRoot(root, storeRoot ?? resolveStoreRoot());
|
|
11514
|
+
if (classifyStoreCheckpoint9State(store).state !== "supported-current")
|
|
11515
|
+
fail("store-unavailable", "Checkout move requires a current Store. No Store state changed.");
|
|
11516
|
+
return withInstallationDatabase(root, (db) => transaction(db, () => {
|
|
11517
|
+
const alreadyBound = checkout(db, root);
|
|
11518
|
+
if (alreadyBound?.checkout_id === sourceCheckoutId && canonicalInstallationPath(sourceRoot) !== root) {
|
|
11519
|
+
const ledger2 = db.prepare("SELECT manifest_json FROM installation_ledgers WHERE checkout_id=?").get(sourceCheckoutId)?.manifest_json;
|
|
11520
|
+
const receipts = db.prepare("SELECT record_json FROM installation_migration_records WHERE checkout_id=? AND kind='receipt' AND record_id LIKE 'checkout-move:%'").all(sourceCheckoutId);
|
|
11521
|
+
const receipt2 = receipts.map((item) => JSON.parse(item.record_json)).find((item) => item.reviewDigest === reviewDigest && item.checkoutId === sourceCheckoutId && item.sourceRoot === canonicalInstallationPath(sourceRoot) && item.targetRoot === root && item.projectId === alreadyBound.project_id && item.ledgerDigest === (ledger2 ? sha(ledger2) : null) && item.evidenceDigest === (alreadyBound.verification_json ? sha(alreadyBound.verification_json) : null));
|
|
11522
|
+
if (receipt2) return {
|
|
11523
|
+
status: "already-completed",
|
|
11524
|
+
...receipt2,
|
|
11525
|
+
effect: "checkout-already-bound",
|
|
11526
|
+
projectFilesChanged: false,
|
|
11527
|
+
nextAction: "Continue setup for this target."
|
|
11528
|
+
};
|
|
11529
|
+
}
|
|
11530
|
+
const id = readDeclarativeProjectId(root);
|
|
11531
|
+
if (!id) fail("ownership-unverified", "A valid config projectId is required for checkout move.");
|
|
11532
|
+
const preview = previewInstallationCheckoutMoveInDatabase(db, root, id, sourceCheckoutId);
|
|
11533
|
+
const selected = preview.candidates.find((candidate) => candidate.checkoutId === sourceCheckoutId);
|
|
11534
|
+
if (preview.status !== "ready" || !selected?.reviewDigest || selected.reviewDigest !== reviewDigest || canonicalInstallationPath(selected.sourceRoot) !== canonicalInstallationPath(sourceRoot))
|
|
11535
|
+
fail("ownership-unverified", "Checkout move review is stale or blocked. Preview again. No Store identity changed.");
|
|
11536
|
+
const row = db.prepare("SELECT * FROM installation_checkouts WHERE checkout_id=?").get(sourceCheckoutId);
|
|
11537
|
+
const ledger = db.prepare("SELECT manifest_json FROM installation_ledgers WHERE checkout_id=?").get(sourceCheckoutId).manifest_json;
|
|
11538
|
+
const evidence = checkoutVerificationEvidence(db, root, row.project_id, sourceCheckoutId, ledger);
|
|
11539
|
+
const verifiedAt = now();
|
|
11540
|
+
const verificationJson = JSON.stringify(evidence);
|
|
11541
|
+
db.prepare("UPDATE installation_checkouts SET root_path=?,root_path_key=?,verified_at=?,verification_json=? WHERE checkout_id=?").run(root, platform.comparisonKey(root), verifiedAt, verificationJson, sourceCheckoutId);
|
|
11542
|
+
const receipt = { schemaVersion: 1, operation: "project.checkout-move.apply", projectId: row.project_id, checkoutId: sourceCheckoutId, sourceRoot: row.root_path, targetRoot: root, reviewDigest, ledgerDigest: sha(ledger), evidenceDigest: sha(verificationJson), appliedAt: verifiedAt };
|
|
11543
|
+
db.prepare("INSERT INTO installation_migration_records (checkout_id,kind,record_id,record_json) VALUES (?,'receipt',?,?)").run(sourceCheckoutId, `checkout-move:${randomUUID5()}`, JSON.stringify(receipt));
|
|
11544
|
+
return {
|
|
11545
|
+
status: "completed",
|
|
11546
|
+
...receipt,
|
|
11547
|
+
effect: "checkout-binding-moved",
|
|
11548
|
+
projectFilesChanged: false,
|
|
11549
|
+
nextAction: "Continue setup for this target."
|
|
11550
|
+
};
|
|
11551
|
+
}), { storeRoot: store, skipPreparation: true });
|
|
11552
|
+
}
|
|
11355
11553
|
function getInstallationCheckoutId(projectRoot, storeRoot) {
|
|
11356
11554
|
const root = canonicalInstallationPath(projectRoot);
|
|
11357
11555
|
return withInstallationDatabase(root, (db) => transaction(db, () => bindCheckout(db, root).checkout_id), { storeRoot });
|
|
@@ -11533,7 +11731,7 @@ function commitOperation(db, id, root, rollback = false) {
|
|
|
11533
11731
|
else
|
|
11534
11732
|
db.prepare("DELETE FROM installation_ledgers WHERE checkout_id=?").run(op.checkout_id);
|
|
11535
11733
|
const owner = db.prepare("SELECT project_id FROM installation_checkouts WHERE checkout_id=?").get(op.checkout_id);
|
|
11536
|
-
const evidence = checkoutVerificationEvidence(db, root, owner.project_id, op.checkout_id, ledger);
|
|
11734
|
+
const evidence = checkoutVerificationEvidence(db, root, owner.project_id, op.checkout_id, ledger, false);
|
|
11537
11735
|
db.prepare("UPDATE installation_checkouts SET root_path=?,root_path_key=?,verified_at=?,verification_json=? WHERE checkout_id=?").run(root, platform.comparisonKey(root), now(), JSON.stringify(evidence), op.checkout_id);
|
|
11538
11736
|
db.prepare("UPDATE installation_operations SET status=?,finished_at=? WHERE operation_id=?").run(rollback ? "rolled-back" : "completed", now(), id);
|
|
11539
11737
|
});
|
|
@@ -11893,15 +12091,18 @@ function readInstallationStatus(projectRoot, storeRoot) {
|
|
|
11893
12091
|
if (toolOperations.length)
|
|
11894
12092
|
return { ...base, projectId: id, storeAvailable: true, status: "recovery-required", toolOperations, nextAction: "A tool operation is pending. Review its package manager result before managed changes." };
|
|
11895
12093
|
const row = checkout(db, root);
|
|
11896
|
-
if (!row)
|
|
11897
|
-
|
|
12094
|
+
if (!row) {
|
|
12095
|
+
const prior = id ? db.prepare("SELECT 1 FROM installation_checkouts WHERE project_id=? LIMIT 1").get(id) : null;
|
|
12096
|
+
return { ...base, status: prior ? "ownership-unverified" : id ? "portable-unregistered" : "unregistered", projectId: id, storeAvailable: true, nextAction: prior ? "Review checkout move or separate checkout registration before setup." : id ? "Run make-docs setup --adopt to register this checkout." : "Run make-docs setup and review this checkout." };
|
|
12097
|
+
}
|
|
11898
12098
|
assertCheckoutIdentity(row, root);
|
|
11899
12099
|
const lock = db.prepare("SELECT pid,hostname FROM installation_locks WHERE root_path=?").get(root);
|
|
11900
12100
|
const pending = db.prepare("SELECT * FROM installation_operations WHERE checkout_id=? AND status='pending'").get(row.checkout_id);
|
|
11901
12101
|
const prepared = pending ? detachedSnapshot(db, pending) : null;
|
|
11902
12102
|
const manifest = db.prepare("SELECT manifest_json FROM installation_ledgers WHERE checkout_id=?").get(row.checkout_id)?.manifest_json;
|
|
11903
12103
|
const pendingAction = pending ? prepared ? detachedHooks.get(pending.operation).nextAction(root, pending.operation_id, prepared.mode) : pending.plan_complete ? `make-docs project state recover ${pending.operation_id} --resume --dry-run --target-root ${JSON.stringify(root)}` : `make-docs project state recover ${pending.operation_id} --rollback --dry-run --target-root ${JSON.stringify(root)}` : null;
|
|
11904
|
-
|
|
12104
|
+
const removed = !manifest && hasCompletedRemoval(db, row.checkout_id);
|
|
12105
|
+
return { ...base, projectId: row.project_id, checkoutId: row.checkout_id, storeAvailable: true, installationVersion: manifest ? JSON.parse(manifest).packageVersion : null, pendingOperation: pending ? { operation_id: pending.operation_id, operation: pending.operation, planComplete: Boolean(pending.plan_complete), ...prepared ? { mode: prepared.mode, reviewDigest: prepared.reviewDigest } : {} } : null, status: lock && !isDead(lock.pid, lock.hostname) ? "writer-active" : pending ? "recovery-required" : manifest ? "ready" : removed ? "unregistered" : "portable-unregistered", nextAction: pendingAction ?? (lock ? "Wait for the active writer." : manifest ? "No recovery is required." : removed ? "Review the completed removal before setup." : "Run make-docs setup --adopt to complete this checkout.") };
|
|
11905
12106
|
}, { storeRoot: store, readOnly: true });
|
|
11906
12107
|
} catch (e) {
|
|
11907
12108
|
return { ...base, status: e instanceof InstallationStateError ? e.code : "store-unavailable", storeAvailable: false, nextAction: e instanceof Error ? e.message : String(e) };
|
|
@@ -12980,7 +13181,7 @@ function validateEmbeddedSkillBundle(candidate) {
|
|
|
12980
13181
|
}
|
|
12981
13182
|
async function loadEmbeddedSkillBundle() {
|
|
12982
13183
|
try {
|
|
12983
|
-
const { bundle, sourceTestAdapter } = await import("./virtual_make-docs-first-party-skills-
|
|
13184
|
+
const { bundle, sourceTestAdapter } = await import("./virtual_make-docs-first-party-skills-POWW3OI3.js");
|
|
12984
13185
|
validateEmbeddedSkillBundle(bundle);
|
|
12985
13186
|
const [registryBytes, packageBytes] = await Promise.all([
|
|
12986
13187
|
readFile(path11.join(PACKAGE_ROOT, "skill-registry.json")),
|
|
@@ -13897,6 +14098,8 @@ export {
|
|
|
13897
14098
|
openStoreSqliteConnection,
|
|
13898
14099
|
STORE_LEASE_RECOVERY_FILE,
|
|
13899
14100
|
GLOBAL_ASSET_LOCK_FILE,
|
|
14101
|
+
parseManagedBlock,
|
|
14102
|
+
upsertManagedBlock,
|
|
13900
14103
|
getHarnessSkillDirectory,
|
|
13901
14104
|
InstallationStateError,
|
|
13902
14105
|
readInstallationPathClaims,
|
|
@@ -13908,6 +14111,9 @@ export {
|
|
|
13908
14111
|
withReviewedStoreCompatibilityBridge,
|
|
13909
14112
|
withInstallationDatabase,
|
|
13910
14113
|
readDeclarativeProjectId,
|
|
14114
|
+
previewInstallationCheckoutMove,
|
|
14115
|
+
registerSeparateInstallationCheckout,
|
|
14116
|
+
applyInstallationCheckoutMove,
|
|
13911
14117
|
getInstallationCheckoutId,
|
|
13912
14118
|
getExistingInstallationCheckoutId,
|
|
13913
14119
|
acquireInstallationLock,
|
|
@@ -13937,8 +14143,6 @@ export {
|
|
|
13937
14143
|
PROJECT_RESOURCE_TYPES,
|
|
13938
14144
|
HARNESS_TO_INSTRUCTION,
|
|
13939
14145
|
DEFAULT_SYSTEM_ASSET_MATERIALIZATION_MODE,
|
|
13940
|
-
parseManagedBlock,
|
|
13941
|
-
upsertManagedBlock,
|
|
13942
14146
|
PACKAGE_ROOT,
|
|
13943
14147
|
TEMPLATE_ROOT,
|
|
13944
14148
|
readPackageFile,
|
|
@@ -13997,4 +14201,4 @@ export {
|
|
|
13997
14201
|
getRecommendedSkillChoices,
|
|
13998
14202
|
applySkillRegistrySelectionMetadata
|
|
13999
14203
|
};
|
|
14000
|
-
//# sourceMappingURL=chunk-
|
|
14204
|
+
//# sourceMappingURL=chunk-C67WJWVP.js.map
|