@brucewaynedecoy/make-docs 2.0.5 → 2.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/{backup-2OT4A6LR.js → backup-P5NUPAJL.js} +4 -4
  2. package/dist/{chunk-ISSMVKIA.js → chunk-2WC74W66.js} +2 -2
  3. package/dist/{chunk-CLSOY7NV.js → chunk-B7QF7XZT.js} +4 -4
  4. package/dist/{chunk-CCYP5NU2.js → chunk-DNPFQB24.js} +3 -3
  5. package/dist/{chunk-XDSWX4Y4.js → chunk-EF47XIIR.js} +87 -8
  6. package/dist/chunk-EF47XIIR.js.map +1 -0
  7. package/dist/{chunk-46MGH32G.js → chunk-KFYUB4AX.js} +2 -2
  8. package/dist/{chunk-CMNKQM7L.js → chunk-LK6BLVZA.js} +3 -3
  9. package/dist/{chunk-I4FADOUK.js → chunk-PI7W5QDB.js} +2 -2
  10. package/dist/{chunk-HXWD2EUD.js → chunk-SFKYGFUV.js} +260 -67
  11. package/dist/chunk-SFKYGFUV.js.map +1 -0
  12. package/dist/{chunk-UNR4CYVX.js → chunk-TDB6UW4M.js} +3 -3
  13. package/dist/{chunk-VMKG3H4B.js → chunk-XFFESINU.js} +2 -2
  14. package/dist/index.js +217 -19
  15. package/dist/index.js.map +1 -1
  16. package/dist/{registry-PC5GKAKM.js → registry-44WLX4F5.js} +7 -7
  17. package/dist/{self-WYVXO23B.js → self-WRWI5XNE.js} +7 -7
  18. package/dist/{server-BQOG6FTA.js → server-FYRDPOBR.js} +13 -9
  19. package/dist/server-FYRDPOBR.js.map +1 -0
  20. package/dist/{setup-system-KN7FTTLT.js → setup-system-XX6NSVXZ.js} +7 -7
  21. package/dist/{skills-command-KEW7MOEW.js → skills-command-YAQP24JM.js} +6 -6
  22. package/dist/{uninstall-45XF4CHD.js → uninstall-3YJKZ6UF.js} +7 -7
  23. package/dist/{virtual_make-docs-first-party-skills-ECJESFL2.js → virtual_make-docs-first-party-skills-5TYTCD5U.js} +2 -2
  24. package/dist/{virtual_make-docs-first-party-skills-ECJESFL2.js.map → virtual_make-docs-first-party-skills-5TYTCD5U.js.map} +1 -1
  25. package/package.json +1 -1
  26. package/dist/chunk-HXWD2EUD.js.map +0 -1
  27. package/dist/chunk-XDSWX4Y4.js.map +0 -1
  28. package/dist/server-BQOG6FTA.js.map +0 -1
  29. /package/dist/{backup-2OT4A6LR.js.map → backup-P5NUPAJL.js.map} +0 -0
  30. /package/dist/{chunk-ISSMVKIA.js.map → chunk-2WC74W66.js.map} +0 -0
  31. /package/dist/{chunk-CLSOY7NV.js.map → chunk-B7QF7XZT.js.map} +0 -0
  32. /package/dist/{chunk-CCYP5NU2.js.map → chunk-DNPFQB24.js.map} +0 -0
  33. /package/dist/{chunk-46MGH32G.js.map → chunk-KFYUB4AX.js.map} +0 -0
  34. /package/dist/{chunk-CMNKQM7L.js.map → chunk-LK6BLVZA.js.map} +0 -0
  35. /package/dist/{chunk-I4FADOUK.js.map → chunk-PI7W5QDB.js.map} +0 -0
  36. /package/dist/{chunk-UNR4CYVX.js.map → chunk-TDB6UW4M.js.map} +0 -0
  37. /package/dist/{chunk-VMKG3H4B.js.map → chunk-XFFESINU.js.map} +0 -0
  38. /package/dist/{registry-PC5GKAKM.js.map → registry-44WLX4F5.js.map} +0 -0
  39. /package/dist/{self-WYVXO23B.js.map → self-WRWI5XNE.js.map} +0 -0
  40. /package/dist/{setup-system-KN7FTTLT.js.map → setup-system-XX6NSVXZ.js.map} +0 -0
  41. /package/dist/{skills-command-KEW7MOEW.js.map → skills-command-YAQP24JM.js.map} +0 -0
  42. /package/dist/{uninstall-45XF4CHD.js.map → uninstall-3YJKZ6UF.js.map} +0 -0
@@ -27,7 +27,7 @@ import {
27
27
  readTextFile,
28
28
  relativePathToTarget,
29
29
  resolveInstallProfile
30
- } from "./chunk-HXWD2EUD.js";
30
+ } from "./chunk-SFKYGFUV.js";
31
31
 
32
32
  // src/backup-paths.ts
33
33
  import path from "path";
@@ -1290,4 +1290,4 @@ export {
1290
1290
  isWithinRoot,
1291
1291
  createAuditReport
1292
1292
  };
1293
- //# sourceMappingURL=chunk-46MGH32G.js.map
1293
+ //# sourceMappingURL=chunk-KFYUB4AX.js.map
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  createAuditReport
4
- } from "./chunk-46MGH32G.js";
4
+ } from "./chunk-KFYUB4AX.js";
5
5
  import {
6
6
  MANIFEST_RELATIVE_PATH,
7
7
  acquireInstallationLock,
@@ -20,7 +20,7 @@ import {
20
20
  relativePathToTarget,
21
21
  releaseInstallationLock,
22
22
  validateAndMigrateManifest
23
- } from "./chunk-HXWD2EUD.js";
23
+ } from "./chunk-SFKYGFUV.js";
24
24
 
25
25
  // src/store/legacy-installation.ts
26
26
  import { createHash } from "crypto";
@@ -872,4 +872,4 @@ export {
872
872
  scopeCompatibilityToInstallPlan,
873
873
  formatCompatibilityClassification
874
874
  };
875
- //# sourceMappingURL=chunk-CMNKQM7L.js.map
875
+ //# sourceMappingURL=chunk-LK6BLVZA.js.map
@@ -3,7 +3,7 @@ import {
3
3
  CAPABILITIES,
4
4
  HARNESSES,
5
5
  cloneSelections
6
- } from "./chunk-HXWD2EUD.js";
6
+ } from "./chunk-SFKYGFUV.js";
7
7
 
8
8
  // src/setup-state.ts
9
9
  var COMPLETE_PROJECT_CAPABILITIES = CAPABILITIES;
@@ -36,4 +36,4 @@ export {
36
36
  resolveUnifiedSetupState,
37
37
  describeHarnessSupport
38
38
  };
39
- //# sourceMappingURL=chunk-I4FADOUK.js.map
39
+ //# sourceMappingURL=chunk-PI7W5QDB.js.map
@@ -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 managedContentDigest(root, ledgerJson, operationPaths) {
11254
- const isCheckoutPath = (relative) => {
11255
- if (relative === ".") return false;
11256
- const absolute = path9.resolve(root, relative);
11257
- const relation = path9.relative(root, absolute);
11258
- return relation !== ".." && !relation.startsWith(`..${path9.sep}`) && !path9.isAbsolute(relation);
11259
- };
11260
- const paths = new Set(operationPaths.filter(isCheckoutPath));
11261
- if (ledgerJson && ledgerJson !== "null") {
11262
- const manifest = validateAndMigrateManifest(JSON.parse(ledgerJson), "Make Docs Store checkout verification ledger");
11263
- for (const relative of Object.keys(manifest.files)) if (isCheckoutPath(relative)) paths.add(relative);
11264
- }
11265
- if (paths.size === 0) return null;
11266
- const facts = [...paths].sort().map((relative) => {
11267
- const absolute = path9.resolve(root, relative);
11268
- const relation = path9.relative(root, absolute);
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 (!stat) return [relative, "missing"];
11271
- if (stat.isSymbolicLink()) return [relative, `link:${readlinkSync(absolute)}`];
11272
- if (stat.isFile()) return [relative, `file:${sha(readFileSync5(absolute))}`];
11273
- if (stat.isDirectory()) return [relative, "directory"];
11274
- return [relative, "unsupported"];
11275
- });
11276
- return sha(canonicalJson(facts));
11277
- }
11278
- function checkoutVerificationEvidence(db, root, projectId, checkoutId, ledgerJson) {
11279
- const config = path9.join(root, ".make-docs", "config.yaml");
11280
- const configStat = lstatSync6(config, { throwIfNoEntry: false });
11281
- if (configStat && (!configStat.isFile() || configStat.isSymbolicLink()))
11282
- fail("ownership-unverified", "The checkout identity file is not a safe regular file.");
11283
- const operationPaths = db.prepare(`
11284
- SELECT DISTINCT step.relative_path
11285
- FROM installation_steps step
11286
- JOIN installation_operations operation ON operation.operation_id=step.operation_id
11287
- WHERE operation.checkout_id=? AND step.applied=1
11288
- `).all(checkoutId).map((row) => row.relative_path);
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: 1,
11348
+ schemaVersion: 2,
11291
11349
  projectId,
11292
- configDigest: configStat ? sha(readFileSync5(config)) : null,
11293
11350
  ledgerDigest: ledgerJson && ledgerJson !== "null" ? sha(ledgerJson) : null,
11294
- managedContentDigest: managedContentDigest(root, ledgerJson, operationPaths)
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
- return left.projectId === right.projectId && left.configDigest === right.configDigest && left.ledgerDigest === right.ledgerDigest && left.managedContentDigest === right.managedContentDigest;
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,161 @@ 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
- const absent = sameProject.filter((row2) => !existsSync3(row2.root_path));
11330
- if (absent.length && declarativeId) {
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 previewInstallationCheckoutMoveInDatabase(db, root, id, sourceCheckoutId) {
11407
+ const base = { schemaVersion: 1, projectId: id, targetRoot: root };
11408
+ const bound = checkout(db, root);
11409
+ if (bound && bound.project_id === id) {
11410
+ assertCheckoutIdentity(bound, root);
11411
+ return { ...base, status: "bound", candidates: [], nextAction: "This checkout is already bound. Continue setup." };
11412
+ }
11413
+ const rows = db.prepare("SELECT * FROM installation_checkouts WHERE project_id=? ORDER BY checkout_id").all(id);
11414
+ const targetKey = platform.comparisonKey(root);
11415
+ const claimed = db.prepare("SELECT * FROM installation_checkouts").all().some((row) => row.root_path_key === targetKey || platform.samePath(row.root_path, root));
11416
+ const configDigest = sha(readFileSync5(path9.join(root, ".make-docs/config.yaml")));
11417
+ const separateReviewDigest = claimed || !rows.length ? null : sha(canonicalJson({
11418
+ schemaVersion: 1,
11419
+ action: "register-separate",
11420
+ projectId: id,
11421
+ targetRoot: root,
11422
+ targetKey,
11423
+ configDigest,
11424
+ otherCheckouts: rows.map((row) => [row.checkout_id, row.root_path, row.root_path_key])
11425
+ }));
11426
+ const candidates = rows.map((row) => {
11427
+ const blockers = [];
11428
+ if (sourceCheckoutId && row.checkout_id !== sourceCheckoutId) blockers.push("Another source checkout was selected.");
11429
+ if (lstatSync6(row.root_path, { throwIfNoEntry: false })) blockers.push("The source path still exists.");
11430
+ if (claimed) blockers.push("Another checkout claims the target path.");
11431
+ 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.");
11432
+ for (const lockedRoot of [row.root_path, root]) {
11433
+ const lock = db.prepare("SELECT pid,hostname FROM installation_locks WHERE root_path=?").get(lockedRoot);
11434
+ if (lock) blockers.push(isDead(lock.pid, lock.hostname) ? "A dead writer lock needs recovery." : "A writer is active.");
11435
+ }
11436
+ if (db.prepare("SELECT 1 FROM tool_operations WHERE status='pending' LIMIT 1").get()) blockers.push("A tool operation is pending.");
11437
+ const ledger = db.prepare("SELECT manifest_json FROM installation_ledgers WHERE checkout_id=?").get(row.checkout_id)?.manifest_json ?? null;
11438
+ const saved = parseCheckoutVerification(row);
11439
+ let current = null;
11440
+ if (!ledger || !saved) blockers.push("The source lacks a saved ledger or ownership proof.");
11441
+ else {
11442
+ try {
11443
+ current = checkoutVerificationEvidence(db, root, id, row.checkout_id, ledger);
11444
+ } catch (error) {
11445
+ blockers.push(error instanceof Error ? error.message : String(error));
11446
+ }
11447
+ if (current && !sameCheckoutEvidence(saved, current)) blockers.push("Target ownership does not match the saved Store facts.");
11448
+ if (current && current.ownershipFacts.length === 0) blockers.push("The target has no independent managed ownership fact.");
11449
+ }
11450
+ const reviewDigest = blockers.length || !current || !saved || !ledger ? null : sha(canonicalJson({
11451
+ schemaVersion: 1,
11452
+ projectId: id,
11453
+ checkoutId: row.checkout_id,
11454
+ sourceRoot: canonicalInstallationPath(row.root_path),
11455
+ sourceKey: row.root_path_key,
11456
+ targetRoot: root,
11457
+ targetKey,
11458
+ configDigest,
11459
+ ledgerDigest: sha(ledger),
11460
+ targetFiles: current.ownershipFacts.map((fact) => {
11461
+ const absolute = path9.join(root, fact.path);
11462
+ const stat = lstatSync6(absolute, { throwIfNoEntry: false });
11463
+ return [fact.path, stat?.isSymbolicLink() ? `link:${readlinkSync(absolute)}` : stat?.isFile() ? `file:${sha(readFileSync5(absolute))}` : "missing"];
11464
+ }),
11465
+ savedEvidenceDigest: sha(row.verification_json),
11466
+ targetEvidence: current
11467
+ }));
11468
+ return { checkoutId: row.checkout_id, sourceRoot: row.root_path, targetRoot: root, available: blockers.length === 0, blockers, reviewDigest };
11469
+ });
11470
+ const selected = sourceCheckoutId ? candidates.find((candidate) => candidate.checkoutId === sourceCheckoutId) : candidates.length === 1 ? candidates[0] : null;
11471
+ return {
11472
+ ...base,
11473
+ status: selected?.available ? "ready" : "blocked",
11474
+ candidates,
11475
+ separateReviewDigest,
11476
+ nextAction: !candidates.length ? "No saved checkout has this project ID. Review setup as a new registration." : 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."
11477
+ };
11478
+ }
11479
+ function registerSeparateInstallationCheckout(projectRoot, reviewDigest, storeRoot) {
11480
+ const root = canonicalInstallationPath(projectRoot);
11481
+ const store = validateInstallationStoreRoot(root, storeRoot ?? resolveStoreRoot());
11482
+ if (classifyStoreCheckpoint9State(store).state !== "supported-current")
11483
+ fail("store-unavailable", "Separate checkout registration requires a current Store.");
11484
+ return withInstallationDatabase(root, (db) => transaction(db, () => {
11485
+ const id = readDeclarativeProjectId(root);
11486
+ if (!id) fail("ownership-unverified", "A valid config projectId is required.");
11487
+ const preview = previewInstallationCheckoutMoveInDatabase(db, root, id);
11488
+ if (!preview.separateReviewDigest || preview.separateReviewDigest !== reviewDigest)
11489
+ fail("ownership-unverified", "Separate checkout review is stale or blocked. Preview again.");
11490
+ const checkoutId = randomUUID5();
11491
+ 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);
11492
+ return {
11493
+ status: "registered",
11494
+ projectId: id,
11495
+ checkoutId,
11496
+ targetRoot: root,
11497
+ effect: "new-checkout-binding",
11498
+ projectFilesChanged: false,
11499
+ nextAction: "Run setup for this target to review its own installation state."
11500
+ };
11501
+ }), { storeRoot: store, skipPreparation: true });
11502
+ }
11503
+ function applyInstallationCheckoutMove(projectRoot, sourceCheckoutId, sourceRoot, reviewDigest, storeRoot) {
11504
+ const root = canonicalInstallationPath(projectRoot);
11505
+ const store = validateInstallationStoreRoot(root, storeRoot ?? resolveStoreRoot());
11506
+ if (classifyStoreCheckpoint9State(store).state !== "supported-current")
11507
+ fail("store-unavailable", "Checkout move requires a current Store. No Store state changed.");
11508
+ return withInstallationDatabase(root, (db) => transaction(db, () => {
11509
+ const alreadyBound = checkout(db, root);
11510
+ if (alreadyBound?.checkout_id === sourceCheckoutId && canonicalInstallationPath(sourceRoot) !== root) {
11511
+ const ledger2 = db.prepare("SELECT manifest_json FROM installation_ledgers WHERE checkout_id=?").get(sourceCheckoutId)?.manifest_json;
11512
+ 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);
11513
+ 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));
11514
+ if (receipt2) return {
11515
+ status: "already-completed",
11516
+ ...receipt2,
11517
+ effect: "checkout-already-bound",
11518
+ projectFilesChanged: false,
11519
+ nextAction: "Continue setup for this target."
11520
+ };
11521
+ }
11522
+ const id = readDeclarativeProjectId(root);
11523
+ if (!id) fail("ownership-unverified", "A valid config projectId is required for checkout move.");
11524
+ const preview = previewInstallationCheckoutMoveInDatabase(db, root, id, sourceCheckoutId);
11525
+ const selected = preview.candidates.find((candidate) => candidate.checkoutId === sourceCheckoutId);
11526
+ if (preview.status !== "ready" || !selected?.reviewDigest || selected.reviewDigest !== reviewDigest || canonicalInstallationPath(selected.sourceRoot) !== canonicalInstallationPath(sourceRoot))
11527
+ fail("ownership-unverified", "Checkout move review is stale or blocked. Preview again. No Store identity changed.");
11528
+ const row = db.prepare("SELECT * FROM installation_checkouts WHERE checkout_id=?").get(sourceCheckoutId);
11529
+ const ledger = db.prepare("SELECT manifest_json FROM installation_ledgers WHERE checkout_id=?").get(sourceCheckoutId).manifest_json;
11530
+ const evidence = checkoutVerificationEvidence(db, root, row.project_id, sourceCheckoutId, ledger);
11531
+ const verifiedAt = now();
11532
+ const verificationJson = JSON.stringify(evidence);
11533
+ 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);
11534
+ 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 };
11535
+ db.prepare("INSERT INTO installation_migration_records (checkout_id,kind,record_id,record_json) VALUES (?,'receipt',?,?)").run(sourceCheckoutId, `checkout-move:${randomUUID5()}`, JSON.stringify(receipt));
11536
+ return {
11537
+ status: "completed",
11538
+ ...receipt,
11539
+ effect: "checkout-binding-moved",
11540
+ projectFilesChanged: false,
11541
+ nextAction: "Continue setup for this target."
11542
+ };
11543
+ }), { storeRoot: store, skipPreparation: true });
11544
+ }
11355
11545
  function getInstallationCheckoutId(projectRoot, storeRoot) {
11356
11546
  const root = canonicalInstallationPath(projectRoot);
11357
11547
  return withInstallationDatabase(root, (db) => transaction(db, () => bindCheckout(db, root).checkout_id), { storeRoot });
@@ -11533,7 +11723,7 @@ function commitOperation(db, id, root, rollback = false) {
11533
11723
  else
11534
11724
  db.prepare("DELETE FROM installation_ledgers WHERE checkout_id=?").run(op.checkout_id);
11535
11725
  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);
11726
+ const evidence = checkoutVerificationEvidence(db, root, owner.project_id, op.checkout_id, ledger, false);
11537
11727
  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
11728
  db.prepare("UPDATE installation_operations SET status=?,finished_at=? WHERE operation_id=?").run(rollback ? "rolled-back" : "completed", now(), id);
11539
11729
  });
@@ -12980,7 +13170,7 @@ function validateEmbeddedSkillBundle(candidate) {
12980
13170
  }
12981
13171
  async function loadEmbeddedSkillBundle() {
12982
13172
  try {
12983
- const { bundle, sourceTestAdapter } = await import("./virtual_make-docs-first-party-skills-ECJESFL2.js");
13173
+ const { bundle, sourceTestAdapter } = await import("./virtual_make-docs-first-party-skills-5TYTCD5U.js");
12984
13174
  validateEmbeddedSkillBundle(bundle);
12985
13175
  const [registryBytes, packageBytes] = await Promise.all([
12986
13176
  readFile(path11.join(PACKAGE_ROOT, "skill-registry.json")),
@@ -13897,6 +14087,8 @@ export {
13897
14087
  openStoreSqliteConnection,
13898
14088
  STORE_LEASE_RECOVERY_FILE,
13899
14089
  GLOBAL_ASSET_LOCK_FILE,
14090
+ parseManagedBlock,
14091
+ upsertManagedBlock,
13900
14092
  getHarnessSkillDirectory,
13901
14093
  InstallationStateError,
13902
14094
  readInstallationPathClaims,
@@ -13908,6 +14100,9 @@ export {
13908
14100
  withReviewedStoreCompatibilityBridge,
13909
14101
  withInstallationDatabase,
13910
14102
  readDeclarativeProjectId,
14103
+ previewInstallationCheckoutMove,
14104
+ registerSeparateInstallationCheckout,
14105
+ applyInstallationCheckoutMove,
13911
14106
  getInstallationCheckoutId,
13912
14107
  getExistingInstallationCheckoutId,
13913
14108
  acquireInstallationLock,
@@ -13937,8 +14132,6 @@ export {
13937
14132
  PROJECT_RESOURCE_TYPES,
13938
14133
  HARNESS_TO_INSTRUCTION,
13939
14134
  DEFAULT_SYSTEM_ASSET_MATERIALIZATION_MODE,
13940
- parseManagedBlock,
13941
- upsertManagedBlock,
13942
14135
  PACKAGE_ROOT,
13943
14136
  TEMPLATE_ROOT,
13944
14137
  readPackageFile,
@@ -13997,4 +14190,4 @@ export {
13997
14190
  getRecommendedSkillChoices,
13998
14191
  applySkillRegistrySelectionMetadata
13999
14192
  };
14000
- //# sourceMappingURL=chunk-HXWD2EUD.js.map
14193
+ //# sourceMappingURL=chunk-SFKYGFUV.js.map