@use-aistack/cli 0.20.4 → 0.20.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.
package/dist/index.js CHANGED
@@ -237,7 +237,7 @@ var init_errors = __esm({
237
237
  ...new Set(cleanupErrors.flatMap((error) => error.details.unverifiedResiduePaths))
238
238
  ].sort(compareCodePoints);
239
239
  const unverifiedResidueSet = new Set(unverifiedResiduePaths);
240
- const residuePaths = [...new Set(cleanupErrors.flatMap((error) => error.details.residuePaths))].filter((path16) => !unverifiedResidueSet.has(path16)).sort(compareCodePoints);
240
+ const residuePaths = [...new Set(cleanupErrors.flatMap((error) => error.details.residuePaths))].filter((path17) => !unverifiedResidueSet.has(path17)).sort(compareCodePoints);
241
241
  const cleanupRemedy = residuePaths.length > 0 || unverifiedResiduePaths.length > 0 ? " Remove only verified private temporary paths after confirming no operation is active; do not delete unverified paths blindly." : "";
242
242
  super("RESTORE_ROLLBACK_INCOMPLETE", "Restore failed after one or more files were published; automatic rollback was not attempted.", {
243
243
  publishedFileCount,
@@ -477,9 +477,9 @@ var init_errors3 = __esm({
477
477
  name = "DatabaseLockedError";
478
478
  /** Path to locked database file */
479
479
  path;
480
- constructor(path16) {
481
- super(`Database is locked: ${path16}. Close Cursor or retry later.`);
482
- this.path = path16;
480
+ constructor(path17) {
481
+ super(`Database is locked: ${path17}. Close Cursor or retry later.`);
482
+ this.path = path17;
483
483
  if (Error.captureStackTrace) {
484
484
  Error.captureStackTrace(this, _DatabaseLockedError);
485
485
  }
@@ -489,9 +489,9 @@ var init_errors3 = __esm({
489
489
  name = "DatabaseNotFoundError";
490
490
  /** Path that was not found */
491
491
  path;
492
- constructor(path16) {
493
- super(`Database not found: ${path16}. Check dataPath configuration.`);
494
- this.path = path16;
492
+ constructor(path17) {
493
+ super(`Database not found: ${path17}. Check dataPath configuration.`);
494
+ this.path = path17;
495
495
  if (Error.captureStackTrace) {
496
496
  Error.captureStackTrace(this, _DatabaseNotFoundError);
497
497
  }
@@ -543,9 +543,9 @@ var init_errors3 = __esm({
543
543
  name = "WorkspaceNotFoundError";
544
544
  /** The workspace path that was not found */
545
545
  path;
546
- constructor(path16) {
547
- super(`No workspace found for path: ${path16}. Please open the project in Cursor first.`);
548
- this.path = path16;
546
+ constructor(path17) {
547
+ super(`No workspace found for path: ${path17}. Please open the project in Cursor first.`);
548
+ this.path = path17;
549
549
  if (Error.captureStackTrace) {
550
550
  Error.captureStackTrace(this, _WorkspaceNotFoundError);
551
551
  }
@@ -555,9 +555,9 @@ var init_errors3 = __esm({
555
555
  name = "SameWorkspaceError";
556
556
  /** The path that was specified for both source and destination */
557
557
  path;
558
- constructor(path16) {
559
- super(`Source and destination are the same: ${path16}`);
560
- this.path = path16;
558
+ constructor(path17) {
559
+ super(`Source and destination are the same: ${path17}`);
560
+ this.path = path17;
561
561
  if (Error.captureStackTrace) {
562
562
  Error.captureStackTrace(this, _SameWorkspaceError);
563
563
  }
@@ -567,9 +567,9 @@ var init_errors3 = __esm({
567
567
  name = "NoSessionsFoundError";
568
568
  /** The source workspace path */
569
569
  path;
570
- constructor(path16) {
571
- super(`No sessions found for workspace: ${path16}. Use 'cursor-history list --workspace "${path16}"' to verify.`);
572
- this.path = path16;
570
+ constructor(path17) {
571
+ super(`No sessions found for workspace: ${path17}. Use 'cursor-history list --workspace "${path17}"' to verify.`);
572
+ this.path = path17;
573
573
  if (Error.captureStackTrace) {
574
574
  Error.captureStackTrace(this, _NoSessionsFoundError);
575
575
  }
@@ -581,9 +581,9 @@ var init_errors3 = __esm({
581
581
  path;
582
582
  /** Number of existing sessions at destination */
583
583
  sessionCount;
584
- constructor(path16, sessionCount) {
585
- super(`Destination already has ${sessionCount} session(s): ${path16}. Use --force to proceed (will add sessions alongside existing ones).`);
586
- this.path = path16;
584
+ constructor(path17, sessionCount) {
585
+ super(`Destination already has ${sessionCount} session(s): ${path17}. Use --force to proceed (will add sessions alongside existing ones).`);
586
+ this.path = path17;
587
587
  this.sessionCount = sessionCount;
588
588
  if (Error.captureStackTrace) {
589
589
  Error.captureStackTrace(this, _DestinationHasSessionsError);
@@ -618,9 +618,9 @@ var init_errors3 = __esm({
618
618
  name = "NoDataError";
619
619
  /** Path that was checked for data */
620
620
  path;
621
- constructor(path16) {
622
- super(`No Cursor data found at: ${path16}. Verify Cursor is installed and has been used.`);
623
- this.path = path16;
621
+ constructor(path17) {
622
+ super(`No Cursor data found at: ${path17}. Verify Cursor is installed and has been used.`);
623
+ this.path = path17;
624
624
  if (Error.captureStackTrace) {
625
625
  Error.captureStackTrace(this, _NoDataError);
626
626
  }
@@ -630,9 +630,9 @@ var init_errors3 = __esm({
630
630
  name = "FileExistsError";
631
631
  /** Path to existing file */
632
632
  path;
633
- constructor(path16) {
634
- super(`File already exists: ${path16}. Use --force to overwrite.`);
635
- this.path = path16;
633
+ constructor(path17) {
634
+ super(`File already exists: ${path17}. Use --force to overwrite.`);
635
+ this.path = path17;
636
636
  if (Error.captureStackTrace) {
637
637
  Error.captureStackTrace(this, _FileExistsError);
638
638
  }
@@ -668,9 +668,9 @@ var init_errors3 = __esm({
668
668
  name = "BackupNotFoundError";
669
669
  /** Path to backup file that was not found */
670
670
  path;
671
- constructor(path16) {
672
- super(`Backup file not found: ${path16}`);
673
- this.path = path16;
671
+ constructor(path17) {
672
+ super(`Backup file not found: ${path17}`);
673
+ this.path = path17;
674
674
  if (Error.captureStackTrace) {
675
675
  Error.captureStackTrace(this, _BackupNotFoundError);
676
676
  }
@@ -682,9 +682,9 @@ var init_errors3 = __esm({
682
682
  path;
683
683
  /** Reason for invalidity */
684
684
  reason;
685
- constructor(path16, reason) {
686
- super(`Invalid backup file: ${path16}. ${reason}`);
687
- this.path = path16;
685
+ constructor(path17, reason) {
686
+ super(`Invalid backup file: ${path17}. ${reason}`);
687
+ this.path = path17;
688
688
  this.reason = reason;
689
689
  if (Error.captureStackTrace) {
690
690
  Error.captureStackTrace(this, _InvalidBackupError);
@@ -695,9 +695,9 @@ var init_errors3 = __esm({
695
695
  name = "TargetExistsError";
696
696
  /** Path to existing target */
697
697
  path;
698
- constructor(path16) {
699
- super(`Target already has Cursor data: ${path16}. Use --force to overwrite.`);
700
- this.path = path16;
698
+ constructor(path17) {
699
+ super(`Target already has Cursor data: ${path17}. Use --force to overwrite.`);
700
+ this.path = path17;
701
701
  if (Error.captureStackTrace) {
702
702
  Error.captureStackTrace(this, _TargetExistsError);
703
703
  }
@@ -720,7 +720,7 @@ var init_errors3 = __esm({
720
720
 
721
721
  // ../../node_modules/.pnpm/cursor-history@0.18.0_patch_hash=dbff0ea0e399ea9504168452170a23ee2b432a6dc6a69a20b49bf95ef139fa74/node_modules/cursor-history/dist/lib/platform.js
722
722
  import { existsSync as existsSync6, readFileSync as readFileSync7, readdirSync as readdirSync3 } from "node:fs";
723
- import { homedir as homedir9 } from "node:os";
723
+ import { homedir as homedir10 } from "node:os";
724
724
  import { basename as basename2, dirname as dirname3, join as join6 } from "node:path";
725
725
  function detectPlatform() {
726
726
  switch (process.platform) {
@@ -757,7 +757,7 @@ function detectPreferredStackSource(customDataPath) {
757
757
  return findStoreRoot(explicit) ? "store" : "composer";
758
758
  }
759
759
  const storeRootEnv = process.env["CURSOR_STORE_ROOT"];
760
- const defaultStoreRoot = join6(homedir9(), ".cursor");
760
+ const defaultStoreRoot = join6(homedir10(), ".cursor");
761
761
  if (storeRootEnv && !pathsEqual(storeRootEnv, defaultStoreRoot)) {
762
762
  return "store";
763
763
  }
@@ -767,11 +767,11 @@ function getDefaultCursorDataPath(platform4) {
767
767
  const p8 = platform4 ?? detectPlatform();
768
768
  switch (p8) {
769
769
  case "windows":
770
- return join6(process.env["APPDATA"] ?? join6(homedir9(), "AppData", "Roaming"), "Cursor", "User", "workspaceStorage");
770
+ return join6(process.env["APPDATA"] ?? join6(homedir10(), "AppData", "Roaming"), "Cursor", "User", "workspaceStorage");
771
771
  case "macos":
772
- return join6(homedir9(), "Library", "Application Support", "Cursor", "User", "workspaceStorage");
772
+ return join6(homedir10(), "Library", "Application Support", "Cursor", "User", "workspaceStorage");
773
773
  case "linux":
774
- return join6(homedir9(), ".config", "Cursor", "User", "workspaceStorage");
774
+ return join6(homedir10(), ".config", "Cursor", "User", "workspaceStorage");
775
775
  }
776
776
  }
777
777
  function getCursorDataPath(customPath) {
@@ -787,23 +787,23 @@ function getCursorDataPath(customPath) {
787
787
  function getGlobalStoragePath(customDataPath) {
788
788
  return join6(dirname3(getCursorDataPath(customDataPath)), "globalStorage");
789
789
  }
790
- function expandPath(path16) {
791
- if (path16.startsWith("~")) {
792
- return join6(homedir9(), path16.slice(1));
790
+ function expandPath(path17) {
791
+ if (path17.startsWith("~")) {
792
+ return join6(homedir10(), path17.slice(1));
793
793
  }
794
- return path16;
794
+ return path17;
795
795
  }
796
- function contractPath(path16) {
797
- const home = homedir9();
798
- if (path16.startsWith(home)) {
799
- return "~" + path16.slice(home.length);
796
+ function contractPath(path17) {
797
+ const home = homedir10();
798
+ if (path17.startsWith(home)) {
799
+ return "~" + path17.slice(home.length);
800
800
  }
801
- return path16;
801
+ return path17;
802
802
  }
803
803
  function normalizePath(filePath) {
804
804
  let normalized = filePath;
805
805
  if (normalized.startsWith("~")) {
806
- normalized = join6(homedir9(), normalized.slice(1));
806
+ normalized = join6(homedir10(), normalized.slice(1));
807
807
  }
808
808
  while (normalized.length > 1 && normalized.endsWith("/")) {
809
809
  normalized = normalized.slice(0, -1);
@@ -908,7 +908,7 @@ function resolveStoreRoot(customDataPath) {
908
908
  const storeEnv = process.env["CURSOR_STORE_ROOT"];
909
909
  if (storeEnv)
910
910
  return findStoreRoot(storeEnv) ?? storeEnv;
911
- return join6(homedir9(), ".cursor");
911
+ return join6(homedir10(), ".cursor");
912
912
  }
913
913
  var cachedIsWsl, STORE_CHILDREN;
914
914
  var init_platform = __esm({
@@ -1439,8 +1439,8 @@ function normalizePublicWorkspacePath(value) {
1439
1439
  return void 0;
1440
1440
  }
1441
1441
  }
1442
- function exactComparisonKey(path16) {
1443
- return path16.caseInsensitive ? path16.path.toLowerCase() : path16.path;
1442
+ function exactComparisonKey(path17) {
1443
+ return path17.caseInsensitive ? path17.path.toLowerCase() : path17.path;
1444
1444
  }
1445
1445
  function componentsEndWith(candidate, request2) {
1446
1446
  if (request2.drive && candidate.drive !== request2.drive)
@@ -2842,14 +2842,14 @@ var init_registry = __esm({
2842
2842
  return this.selectDatabaseDriver(request2);
2843
2843
  }
2844
2844
  /** Open a database in read-only mode. */
2845
- async openDatabase(path16, request2 = READ_SESSION_REQUEST) {
2845
+ async openDatabase(path17, request2 = READ_SESSION_REQUEST) {
2846
2846
  const driver = await this.ensureDriver(request2);
2847
- return openObservedDatabase(request2.io, request2, () => driver.open(path16, { readonly: true }));
2847
+ return openObservedDatabase(request2.io, request2, () => driver.open(path17, { readonly: true }));
2848
2848
  }
2849
2849
  /** Open a database in read-write mode. */
2850
- async openDatabaseReadWrite(path16, request2 = MIGRATION_REQUEST) {
2850
+ async openDatabaseReadWrite(path17, request2 = MIGRATION_REQUEST) {
2851
2851
  const driver = await this.ensureDriver(request2);
2852
- return openObservedDatabase(request2.io, request2, () => driver.open(path16, { readonly: false }));
2852
+ return openObservedDatabase(request2.io, request2, () => driver.open(path17, { readonly: false }));
2853
2853
  }
2854
2854
  /**
2855
2855
  * Synchronous database open (requires a completed capability-aware selection).
@@ -2857,11 +2857,11 @@ var init_registry = __esm({
2857
2857
  * This remains for backup parsing paths that perform synchronous reads after an awaited
2858
2858
  * selection or snapshot operation.
2859
2859
  */
2860
- openSync(path16, options) {
2860
+ openSync(path17, options) {
2861
2861
  if (!this.currentDriver) {
2862
2862
  throw new Error("No driver is currently active. Capability-aware selection must complete before using openSync().");
2863
2863
  }
2864
- return this.currentDriver.open(path16, options);
2864
+ return this.currentDriver.open(path17, options);
2865
2865
  }
2866
2866
  /** Create an online database snapshot with a provider satisfying the complete request. */
2867
2867
  async backupDatabase(sourcePath, destPath, request2 = BACKUP_REQUEST) {
@@ -3008,12 +3008,12 @@ var init_better_sqlite3 = __esm({
3008
3008
  getCapabilityProfile() {
3009
3009
  return loadBetterSqlite3Profile();
3010
3010
  },
3011
- open(path16, options) {
3011
+ open(path17, options) {
3012
3012
  if (!BetterSqlite3) {
3013
3013
  throw new Error("better-sqlite3 is not loaded. Call isAvailable() first.");
3014
3014
  }
3015
- const db = new BetterSqlite3(path16, { readonly: options.readonly });
3016
- debugLog(`Opened database with better-sqlite3: ${path16} (readonly: ${options.readonly})`);
3015
+ const db = new BetterSqlite3(path17, { readonly: options.readonly });
3016
+ debugLog(`Opened database with better-sqlite3: ${path17} (readonly: ${options.readonly})`);
3017
3017
  return new BetterSqlite3Database(db);
3018
3018
  },
3019
3019
  async backup(sourcePath, destPath) {
@@ -3204,12 +3204,12 @@ var init_node_sqlite = __esm({
3204
3204
  getCapabilityProfile() {
3205
3205
  return loadNodeSqliteProfile();
3206
3206
  },
3207
- open(path16, options) {
3207
+ open(path17, options) {
3208
3208
  if (!nodeSqliteModule) {
3209
3209
  throw new Error("node:sqlite is not loaded. Call isAvailable() first.");
3210
3210
  }
3211
- const db = new nodeSqliteModule.DatabaseSync(path16, { readOnly: options.readonly });
3212
- debugLog(`Opened database with node:sqlite: ${path16} (readonly: ${options.readonly})`);
3211
+ const db = new nodeSqliteModule.DatabaseSync(path17, { readOnly: options.readonly });
3212
+ debugLog(`Opened database with node:sqlite: ${path17} (readonly: ${options.readonly})`);
3213
3213
  return new NodeSqliteDatabaseWrapper(db, options.readonly);
3214
3214
  },
3215
3215
  async backup(sourcePath, destPath) {
@@ -3233,11 +3233,11 @@ var init_node_sqlite = __esm({
3233
3233
  });
3234
3234
 
3235
3235
  // ../../node_modules/.pnpm/cursor-history@0.18.0_patch_hash=dbff0ea0e399ea9504168452170a23ee2b432a6dc6a69a20b49bf95ef139fa74/node_modules/cursor-history/dist/core/database/index.js
3236
- async function openDatabase(path16, request2) {
3237
- return registry.openDatabase(path16, request2);
3236
+ async function openDatabase(path17, request2) {
3237
+ return registry.openDatabase(path17, request2);
3238
3238
  }
3239
- async function openDatabaseReadWrite(path16, request2) {
3240
- return registry.openDatabaseReadWrite(path16, request2);
3239
+ async function openDatabaseReadWrite(path17, request2) {
3240
+ return registry.openDatabaseReadWrite(path17, request2);
3241
3241
  }
3242
3242
  function getActiveDriver() {
3243
3243
  return registry.getActiveDriver();
@@ -3374,8 +3374,8 @@ function exclusiveFlags() {
3374
3374
  flags |= constants.O_NOFOLLOW;
3375
3375
  return flags;
3376
3376
  }
3377
- function createExclusivePrivateFile(path16, contents) {
3378
- const descriptor = openSync(path16, exclusiveFlags(), 384);
3377
+ function createExclusivePrivateFile(path17, contents) {
3378
+ const descriptor = openSync(path17, exclusiveFlags(), 384);
3379
3379
  try {
3380
3380
  if (IS_PERMISSION_AWARE_POSIX)
3381
3381
  fchmodSync(descriptor, 384);
@@ -3387,10 +3387,10 @@ function createExclusivePrivateFile(path16, contents) {
3387
3387
  closeSync(descriptor);
3388
3388
  }
3389
3389
  }
3390
- function attemptRemoveEntryNoFollow(path16) {
3390
+ function attemptRemoveEntryNoFollow(path17) {
3391
3391
  let stats;
3392
3392
  try {
3393
- stats = lstatSync(path16);
3393
+ stats = lstatSync(path17);
3394
3394
  } catch (error) {
3395
3395
  if (!isMissing(error)) {
3396
3396
  }
@@ -3398,13 +3398,13 @@ function attemptRemoveEntryNoFollow(path16) {
3398
3398
  }
3399
3399
  if (stats.isDirectory() && !stats.isSymbolicLink()) {
3400
3400
  try {
3401
- rmdirSync(path16);
3401
+ rmdirSync(path17);
3402
3402
  } catch {
3403
3403
  }
3404
3404
  return;
3405
3405
  }
3406
3406
  try {
3407
- unlinkSync(path16);
3407
+ unlinkSync(path17);
3408
3408
  } catch {
3409
3409
  }
3410
3410
  }
@@ -3432,9 +3432,9 @@ function attemptRemoveWorkspaceNoFollow(directoryPath) {
3432
3432
  } catch {
3433
3433
  }
3434
3434
  }
3435
- function mayStillExist(path16) {
3435
+ function mayStillExist(path17) {
3436
3436
  try {
3437
- lstatSync(path16);
3437
+ lstatSync(path17);
3438
3438
  return true;
3439
3439
  } catch (error) {
3440
3440
  return !isMissing(error);
@@ -3731,8 +3731,8 @@ var init_private_temp = __esm({
3731
3731
  stateValue = "open";
3732
3732
  abortSignal;
3733
3733
  abortHandler;
3734
- constructor(path16, marker, markerPath, signal) {
3735
- this.path = path16;
3734
+ constructor(path17, marker, markerPath, signal) {
3735
+ this.path = path17;
3736
3736
  this.marker = marker;
3737
3737
  this.trackedPaths.add(markerPath);
3738
3738
  this.abortSignal = signal;
@@ -3763,9 +3763,9 @@ var init_private_temp = __esm({
3763
3763
  createExclusivePrivateFile(filePath);
3764
3764
  return filePath;
3765
3765
  }
3766
- register(path16) {
3766
+ register(path17) {
3767
3767
  this.assertOpen();
3768
- const candidatePath = resolve(path16);
3768
+ const candidatePath = resolve(path17);
3769
3769
  if (!isDirectChildPath(this.path, candidatePath)) {
3770
3770
  throw new TypeError("Tracked temporary artifacts must be direct children of their private workspace.");
3771
3771
  }
@@ -3779,8 +3779,8 @@ var init_private_temp = __esm({
3779
3779
  this.abortSignal.removeEventListener("abort", this.abortHandler);
3780
3780
  }
3781
3781
  const tracked = [...this.trackedPaths].sort((left, right) => right.length - left.length);
3782
- for (const path16 of tracked)
3783
- attemptRemoveEntryNoFollow(path16);
3782
+ for (const path17 of tracked)
3783
+ attemptRemoveEntryNoFollow(path17);
3784
3784
  attemptRemoveWorkspaceNoFollow(this.path);
3785
3785
  const residuePaths = tracked.filter(mayStillExist);
3786
3786
  if (mayStillExist(this.path))
@@ -4803,8 +4803,8 @@ async function writeBoundedZipArchive(destinationPath, inputs, options = {}) {
4803
4803
  throw error;
4804
4804
  }
4805
4805
  }
4806
- async function openBoundedZipArchive(path16, options) {
4807
- return BoundedZipArchive.open(path16, options);
4806
+ async function openBoundedZipArchive(path17, options) {
4807
+ return BoundedZipArchive.open(path17, options);
4808
4808
  }
4809
4809
  var EOCD_SIGNATURE, ZIP64_EOCD_SIGNATURE, ZIP64_LOCATOR_SIGNATURE, CENTRAL_FILE_SIGNATURE, LOCAL_FILE_SIGNATURE, ZIP64_EXTRA_FIELD_ID, MAX_EOCD_SEARCH_BYTES, UTF8_FLAG, ENCRYPTED_FLAG, STRONG_ENCRYPTION_FLAG, DATA_DESCRIPTOR_FLAG, STORE_METHOD, DEFLATE_METHOD, MANIFEST_MEMORY_LIMIT, STREAM_CHUNK_BYTES, ZIP_LIMIT_FIELDS, ZipArchiveFormatError, CRC32_TABLE, CompressedVerifier, OutputIntegrityVerifier, BoundedZipArchive;
4810
4810
  var init_zip_stream = __esm({
@@ -4950,8 +4950,8 @@ var init_zip_stream = __esm({
4950
4950
  actualAggregateBytes = 0;
4951
4951
  byName;
4952
4952
  localEndBoundary;
4953
- constructor(path16, entries, archiveSize, centralOffset, handle, limits, signal, io) {
4954
- this.path = path16;
4953
+ constructor(path17, entries, archiveSize, centralOffset, handle, limits, signal, io) {
4954
+ this.path = path17;
4955
4955
  this.entries = entries;
4956
4956
  this.archiveSize = archiveSize;
4957
4957
  this.centralOffset = centralOffset;
@@ -4963,7 +4963,7 @@ var init_zip_stream = __esm({
4963
4963
  const offsets = entries.map((entry) => entry.localHeaderOffset).sort((a, b) => a - b);
4964
4964
  this.localEndBoundary = new Map(offsets.map((offset, index) => [offset, offsets[index + 1] ?? centralOffset]));
4965
4965
  }
4966
- static async open(path16, options = {}) {
4966
+ static async open(path17, options = {}) {
4967
4967
  const limits = resolveSourceReadLimits(options.sourceReadLimits);
4968
4968
  throwIfAborted(options.signal);
4969
4969
  if (options.io) {
@@ -4973,7 +4973,7 @@ var init_zip_stream = __esm({
4973
4973
  resourceClass: "backup-central-directory"
4974
4974
  });
4975
4975
  }
4976
- const handle = await open2(path16, "r");
4976
+ const handle = await open2(path17, "r");
4977
4977
  try {
4978
4978
  if (options.io) {
4979
4979
  observeAdapterIo(options.io, {
@@ -4989,7 +4989,7 @@ var init_zip_stream = __esm({
4989
4989
  const archiveSize = toSafeOffset(metadata.size, "ZIP archive size");
4990
4990
  const central = await locateCentralDirectory(handle, archiveSize, options.signal);
4991
4991
  const entries = await parseCentralDirectory(handle, archiveSize, central, limits, options.signal);
4992
- return new _BoundedZipArchive(path16, entries, archiveSize, central.offset, handle, limits, options.signal, options.io);
4992
+ return new _BoundedZipArchive(path17, entries, archiveSize, central.offset, handle, limits, options.signal, options.io);
4993
4993
  } catch (error) {
4994
4994
  await handle.close();
4995
4995
  throw error;
@@ -5495,16 +5495,16 @@ var init_composer_sqlite = __esm({
5495
5495
 
5496
5496
  // ../../node_modules/.pnpm/cursor-history@0.18.0_patch_hash=dbff0ea0e399ea9504168452170a23ee2b432a6dc6a69a20b49bf95ef139fa74/node_modules/cursor-history/dist/core/backup-publication.js
5497
5497
  import { closeSync as closeSync2, constants as constants2, fchmodSync as fchmodSync2, fstatSync as fstatSync2, lstatSync as lstatSync2, openSync as openSync2 } from "node:fs";
5498
- function projectStat(stat9) {
5498
+ function projectStat(stat10) {
5499
5499
  return {
5500
- device: BigInt(stat9.dev),
5501
- inode: BigInt(stat9.ino),
5502
- mode: Number(stat9.mode) & 511,
5503
- regularFile: stat9.isFile()
5500
+ device: BigInt(stat10.dev),
5501
+ inode: BigInt(stat10.ino),
5502
+ mode: Number(stat10.mode) & 511,
5503
+ regularFile: stat10.isFile()
5504
5504
  };
5505
5505
  }
5506
- function hasIdentity(stat9, expected) {
5507
- return stat9.device === expected.device && stat9.inode === expected.inode;
5506
+ function hasIdentity(stat10, expected) {
5507
+ return stat10.device === expected.device && stat10.inode === expected.inode;
5508
5508
  }
5509
5509
  function identityError(message) {
5510
5510
  const error = new Error(message);
@@ -5573,10 +5573,10 @@ var init_backup_publication = __esm({
5573
5573
  "use strict";
5574
5574
  init_errors();
5575
5575
  DEFAULT_MODE_OPERATIONS = Object.freeze({
5576
- openNoFollow: (path16) => openSync2(path16, constants2.O_RDONLY | (constants2.O_NOFOLLOW ?? 0)),
5576
+ openNoFollow: (path17) => openSync2(path17, constants2.O_RDONLY | (constants2.O_NOFOLLOW ?? 0)),
5577
5577
  statDescriptor: (descriptor) => projectStat(fstatSync2(descriptor, { bigint: true })),
5578
5578
  chmodDescriptor: (descriptor, mode) => fchmodSync2(descriptor, mode),
5579
- statPathNoFollow: (path16) => projectStat(lstatSync2(path16, { bigint: true })),
5579
+ statPathNoFollow: (path17) => projectStat(lstatSync2(path17, { bigint: true })),
5580
5580
  close: (descriptor) => closeSync2(descriptor)
5581
5581
  });
5582
5582
  }
@@ -5587,12 +5587,12 @@ import { linkSync, lstatSync as lstatSync3, renameSync, unlinkSync as unlinkSync
5587
5587
  function errorCode(error) {
5588
5588
  return error instanceof Error && "code" in error ? String(error.code) : void 0;
5589
5589
  }
5590
- function hasIdentity2(stat9, expected) {
5591
- return stat9.isFile() && stat9.dev === expected.device && stat9.ino === expected.inode;
5590
+ function hasIdentity2(stat10, expected) {
5591
+ return stat10.isFile() && stat10.dev === expected.device && stat10.ino === expected.inode;
5592
5592
  }
5593
- function pathIdentityVerified(path16, expected, operations) {
5593
+ function pathIdentityVerified(path17, expected, operations) {
5594
5594
  try {
5595
- return hasIdentity2(operations.statPathNoFollow(path16), expected);
5595
+ return hasIdentity2(operations.statPathNoFollow(path17), expected);
5596
5596
  } catch {
5597
5597
  return false;
5598
5598
  }
@@ -5643,8 +5643,8 @@ var init_backup_archive_publication = __esm({
5643
5643
  DEFAULT_OPERATIONS = Object.freeze({
5644
5644
  rename: (sourcePath, destinationPath) => renameSync(sourcePath, destinationPath),
5645
5645
  link: (sourcePath, destinationPath) => linkSync(sourcePath, destinationPath),
5646
- unlink: (path16) => unlinkSync2(path16),
5647
- statPathNoFollow: (path16) => lstatSync3(path16, { bigint: true })
5646
+ unlink: (path17) => unlinkSync2(path17),
5647
+ statPathNoFollow: (path17) => lstatSync3(path17, { bigint: true })
5648
5648
  });
5649
5649
  }
5650
5650
  });
@@ -5654,11 +5654,11 @@ import { linkSync as linkSync2, lstatSync as lstatSync4, renameSync as renameSyn
5654
5654
  function errorCode2(error) {
5655
5655
  return error instanceof Error && "code" in error ? String(error.code) : void 0;
5656
5656
  }
5657
- function hasIdentity3(stat9, expected) {
5658
- return stat9.isFile() && stat9.dev === expected.device && stat9.ino === expected.inode;
5657
+ function hasIdentity3(stat10, expected) {
5658
+ return stat10.isFile() && stat10.dev === expected.device && stat10.ino === expected.inode;
5659
5659
  }
5660
- function cleanupError(path16, cause, identityVerified = true) {
5661
- const error = new TemporaryArtifactCleanupError(identityVerified ? [path16] : [], identityVerified ? [] : [path16]);
5660
+ function cleanupError(path17, cause, identityVerified = true) {
5661
+ const error = new TemporaryArtifactCleanupError(identityVerified ? [path17] : [], identityVerified ? [] : [path17]);
5662
5662
  Object.defineProperty(error, "cause", { configurable: true, value: cause });
5663
5663
  return error;
5664
5664
  }
@@ -5706,8 +5706,8 @@ var init_restore_publication = __esm({
5706
5706
  DEFAULT_OPERATIONS2 = Object.freeze({
5707
5707
  rename: (sourcePath, destinationPath) => renameSync2(sourcePath, destinationPath),
5708
5708
  link: (sourcePath, destinationPath) => linkSync2(sourcePath, destinationPath),
5709
- unlink: (path16) => unlinkSync3(path16),
5710
- statPathNoFollow: (path16) => lstatSync4(path16, { bigint: true })
5709
+ unlink: (path17) => unlinkSync3(path17),
5710
+ statPathNoFollow: (path17) => lstatSync4(path17, { bigint: true })
5711
5711
  });
5712
5712
  }
5713
5713
  });
@@ -5761,7 +5761,7 @@ var init_session_id = __esm({
5761
5761
  // ../../node_modules/.pnpm/cursor-history@0.18.0_patch_hash=dbff0ea0e399ea9504168452170a23ee2b432a6dc6a69a20b49bf95ef139fa74/node_modules/cursor-history/dist/core/backup.js
5762
5762
  import { createHash as createHash4, randomUUID } from "node:crypto";
5763
5763
  import { chmodSync as chmodSync3, closeSync as closeSync3, constants as constants3, existsSync as existsSync7, copyFileSync, fchmodSync as fchmodSync3, fstatSync as fstatSync3, fsyncSync as fsyncSync2, lstatSync as lstatSync5, mkdirSync as mkdirSync2, openSync as openSync3, readFileSync as readFileSync9, readSync, readdirSync as readdirSync5, realpathSync as realpathSync2, statSync as statSync3, unlinkSync as unlinkSync4, writeSync } from "node:fs";
5764
- import { homedir as homedir10 } from "node:os";
5764
+ import { homedir as homedir11 } from "node:os";
5765
5765
  import { basename as basename4, dirname as dirname4, isAbsolute as isAbsolute2, join as join8, relative as relative3, resolve as resolve2, sep as sep2 } from "node:path";
5766
5766
  function backupDatabaseReadRequest(sqliteDriver, io, dbPath, logicalSessionId) {
5767
5767
  const global = dbPath === "globalStorage/state.vscdb";
@@ -5801,7 +5801,7 @@ function freezeSourceReadOptions(options = {}) {
5801
5801
  });
5802
5802
  }
5803
5803
  function getDefaultBackupDir() {
5804
- return join8(homedir10(), "cursor-history-backups");
5804
+ return join8(homedir11(), "cursor-history-backups");
5805
5805
  }
5806
5806
  function computeChecksum(buffer) {
5807
5807
  return `sha256:${createHash4("sha256").update(buffer).digest("hex")}`;
@@ -5821,11 +5821,11 @@ function scanDatabaseFiles(dataPath2) {
5821
5821
  const userDir = dirname4(dataPath2);
5822
5822
  const globalDbPath = join8(userDir, "globalStorage", "state.vscdb");
5823
5823
  if (existsSync7(globalDbPath)) {
5824
- const stat9 = statSync3(globalDbPath);
5824
+ const stat10 = statSync3(globalDbPath);
5825
5825
  files.push({
5826
5826
  absolutePath: globalDbPath,
5827
5827
  relativePath: "globalStorage/state.vscdb",
5828
- size: stat9.size,
5828
+ size: stat10.size,
5829
5829
  type: "global-db"
5830
5830
  });
5831
5831
  }
@@ -5838,22 +5838,22 @@ function scanDatabaseFiles(dataPath2) {
5838
5838
  const workspaceDir = join8(workspaceStorageDir, entry.name);
5839
5839
  const workspaceDbPath = join8(workspaceDir, "state.vscdb");
5840
5840
  if (existsSync7(workspaceDbPath)) {
5841
- const stat9 = statSync3(workspaceDbPath);
5841
+ const stat10 = statSync3(workspaceDbPath);
5842
5842
  files.push({
5843
5843
  absolutePath: workspaceDbPath,
5844
5844
  relativePath: `workspaceStorage/${entry.name}/state.vscdb`,
5845
- size: stat9.size,
5845
+ size: stat10.size,
5846
5846
  type: "workspace-db",
5847
5847
  workspaceId: entry.name
5848
5848
  });
5849
5849
  }
5850
5850
  const workspaceJsonPath = join8(workspaceDir, "workspace.json");
5851
5851
  if (existsSync7(workspaceJsonPath)) {
5852
- const stat9 = statSync3(workspaceJsonPath);
5852
+ const stat10 = statSync3(workspaceJsonPath);
5853
5853
  files.push({
5854
5854
  absolutePath: workspaceJsonPath,
5855
5855
  relativePath: `workspaceStorage/${entry.name}/workspace.json`,
5856
- size: stat9.size,
5856
+ size: stat10.size,
5857
5857
  type: "workspace-json",
5858
5858
  workspaceId: entry.name
5859
5859
  });
@@ -6075,12 +6075,12 @@ function checkDiskSpace(outputPath, requiredBytes) {
6075
6075
  };
6076
6076
  }
6077
6077
  }
6078
- function syncParentDirectory(path16) {
6078
+ function syncParentDirectory(path17) {
6079
6079
  if (process.platform === "win32")
6080
6080
  return;
6081
6081
  let descriptor;
6082
6082
  try {
6083
- descriptor = openSync3(dirname4(path16), constants3.O_RDONLY);
6083
+ descriptor = openSync3(dirname4(path17), constants3.O_RDONLY);
6084
6084
  fsyncSync2(descriptor);
6085
6085
  } catch {
6086
6086
  } finally {
@@ -6092,13 +6092,13 @@ function syncParentDirectory(path16) {
6092
6092
  }
6093
6093
  }
6094
6094
  }
6095
- function removePrivateArchiveStage(path16, operationError) {
6095
+ function removePrivateArchiveStage(path17, operationError) {
6096
6096
  try {
6097
- unlinkSync4(path16);
6097
+ unlinkSync4(path17);
6098
6098
  } catch (error) {
6099
6099
  if (errorCode3(error) === "ENOENT")
6100
6100
  return;
6101
- const cleanupError2 = new TemporaryArtifactCleanupError([path16]);
6101
+ const cleanupError2 = new TemporaryArtifactCleanupError([path17]);
6102
6102
  attachCleanupCause(cleanupError2, operationError ?? error);
6103
6103
  throw cleanupError2;
6104
6104
  }
@@ -6362,7 +6362,7 @@ function combineTemporaryCleanupErrors(first, second) {
6362
6362
  const unverifiedResidueSet = new Set(unverifiedResiduePaths);
6363
6363
  const residuePaths = [
6364
6364
  .../* @__PURE__ */ new Set([...first.details.residuePaths, ...second.details.residuePaths])
6365
- ].filter((path16) => !unverifiedResidueSet.has(path16));
6365
+ ].filter((path17) => !unverifiedResidueSet.has(path17));
6366
6366
  const combined = new TemporaryArtifactCleanupError(residuePaths, unverifiedResiduePaths);
6367
6367
  Object.defineProperty(combined, "cause", { configurable: true, value: first });
6368
6368
  return combined;
@@ -6470,18 +6470,18 @@ function validatedManifestFiles(manifest) {
6470
6470
  if (type !== "global-db" && type !== "workspace-db" && type !== "workspace-json" && type !== "manifest") {
6471
6471
  throw new ZipArchiveFormatError(`Backup manifest file ${index + 1} has an invalid type.`);
6472
6472
  }
6473
- const path16 = entry["path"];
6474
- const expectedType = backupEntryTypeForCanonicalPath(path16);
6473
+ const path17 = entry["path"];
6474
+ const expectedType = backupEntryTypeForCanonicalPath(path17);
6475
6475
  if (expectedType === void 0 || type !== expectedType) {
6476
6476
  throw new ZipArchiveFormatError(`Backup manifest file ${index + 1} has an unsupported path/type combination.`);
6477
6477
  }
6478
- const destinationKey = path16.normalize("NFC").toLowerCase();
6478
+ const destinationKey = path17.normalize("NFC").toLowerCase();
6479
6479
  if (destinationKeys.has(destinationKey)) {
6480
- throw new ZipArchiveFormatError(`Backup manifest contains a duplicate restore destination: ${path16}`);
6480
+ throw new ZipArchiveFormatError(`Backup manifest contains a duplicate restore destination: ${path17}`);
6481
6481
  }
6482
6482
  destinationKeys.add(destinationKey);
6483
6483
  return {
6484
- path: path16,
6484
+ path: path17,
6485
6485
  size: Number(entry["size"]),
6486
6486
  checksum: entry["checksum"].toLowerCase(),
6487
6487
  type
@@ -6498,10 +6498,10 @@ function isCanonicalBackupPathSegment(value) {
6498
6498
  }
6499
6499
  return true;
6500
6500
  }
6501
- function backupEntryTypeForCanonicalPath(path16) {
6502
- if (path16 === "globalStorage/state.vscdb")
6501
+ function backupEntryTypeForCanonicalPath(path17) {
6502
+ if (path17 === "globalStorage/state.vscdb")
6503
6503
  return "global-db";
6504
- const match = /^workspaceStorage\/([^/]+)\/(state\.vscdb|workspace\.json)$/u.exec(path16);
6504
+ const match = /^workspaceStorage\/([^/]+)\/(state\.vscdb|workspace\.json)$/u.exec(path17);
6505
6505
  if (!match || !isCanonicalBackupPathSegment(match[1]))
6506
6506
  return void 0;
6507
6507
  return match[2] === "state.vscdb" ? "workspace-db" : "workspace-json";
@@ -6520,8 +6520,8 @@ function validateComposerWorkspaceInventory(manifest, files) {
6520
6520
  if (!Array.isArray(inventory["workspaces"])) {
6521
6521
  throw new ZipArchiveFormatError("Backup manifest Composer workspace inventory workspaces must be an array.");
6522
6522
  }
6523
- const expectedWorkspaceIds = files.filter(({ type }) => type === "workspace-db").map(({ path: path16 }) => /^workspaceStorage\/([^/]+)\/state\.vscdb$/u.exec(path16)?.[1]).filter((workspaceId) => workspaceId !== void 0).sort(compareCodePoints4);
6524
- const containsGlobalDatabase = files.some(({ type, path: path16 }) => type === "global-db" && path16 === "globalStorage/state.vscdb");
6523
+ const expectedWorkspaceIds = files.filter(({ type }) => type === "workspace-db").map(({ path: path17 }) => /^workspaceStorage\/([^/]+)\/state\.vscdb$/u.exec(path17)?.[1]).filter((workspaceId) => workspaceId !== void 0).sort(compareCodePoints4);
6524
+ const containsGlobalDatabase = files.some(({ type, path: path17 }) => type === "global-db" && path17 === "globalStorage/state.vscdb");
6525
6525
  if (inventory["workspaces"].length !== expectedWorkspaceIds.length) {
6526
6526
  throw new ZipArchiveFormatError("Backup manifest Composer workspace inventory does not cover every workspace database.");
6527
6527
  }
@@ -6677,7 +6677,7 @@ async function openBackupDatabase(backupPath, dbPath, options = {}) {
6677
6677
  if (!entry || entry.isDirectory) {
6678
6678
  throw new BackupEntryNotFoundError(dbPath);
6679
6679
  }
6680
- const manifestEntry = manifestFiles.find(({ path: path16 }) => path16 === dbPath);
6680
+ const manifestEntry = manifestFiles.find(({ path: path17 }) => path17 === dbPath);
6681
6681
  if (!manifestEntry) {
6682
6682
  throw new ZipArchiveFormatError(`Backup database is not declared by the manifest: ${dbPath}`);
6683
6683
  }
@@ -6732,7 +6732,7 @@ async function readBackupEntryBuffer(backupPath, entryPath, options = {}, maxByt
6732
6732
  const manifest = await readManifestFromArchive(archive);
6733
6733
  if (!manifest)
6734
6734
  throw new ZipArchiveFormatError("Manifest file not found in backup.");
6735
- const manifestEntry = validatedManifestFiles(manifest).find(({ path: path16 }) => path16 === entryPath);
6735
+ const manifestEntry = validatedManifestFiles(manifest).find(({ path: path17 }) => path17 === entryPath);
6736
6736
  const entry = archive.getEntry(entryPath);
6737
6737
  if (!entry || entry.isDirectory) {
6738
6738
  if (manifestEntry) {
@@ -6788,18 +6788,18 @@ async function validateBackup(backupPath, options = {}) {
6788
6788
  };
6789
6789
  }
6790
6790
  }
6791
- function lstatIfPresent(path16) {
6791
+ function lstatIfPresent(path17) {
6792
6792
  try {
6793
- return lstatSync5(path16);
6793
+ return lstatSync5(path17);
6794
6794
  } catch (error) {
6795
6795
  if (errorCode3(error) === "ENOENT")
6796
6796
  return void 0;
6797
6797
  throw error;
6798
6798
  }
6799
6799
  }
6800
- function assertNoLinkedRestorePath(trustedRoot, path16, leafKind) {
6800
+ function assertNoLinkedRestorePath(trustedRoot, path17, leafKind) {
6801
6801
  const absoluteRoot = resolve2(trustedRoot);
6802
- const absolutePath = resolve2(path16);
6802
+ const absolutePath = resolve2(path17);
6803
6803
  const suffix = relative3(absoluteRoot, absolutePath);
6804
6804
  if (suffix === ".." || suffix.startsWith(`..${sep2}`) || isAbsolute2(suffix)) {
6805
6805
  throw new Error(`Restore destination escapes the Cursor data directory: ${absolutePath}`);
@@ -7103,12 +7103,12 @@ async function listBackups(directory, options = {}) {
7103
7103
  continue;
7104
7104
  }
7105
7105
  const filePath = join8(dir, entry.name);
7106
- const stat9 = statSync3(filePath);
7106
+ const stat10 = statSync3(filePath);
7107
7107
  const info = {
7108
7108
  filePath,
7109
7109
  filename: entry.name,
7110
- fileSize: stat9.size,
7111
- modifiedAt: stat9.mtime
7110
+ fileSize: stat10.size,
7111
+ modifiedAt: stat10.mtime
7112
7112
  };
7113
7113
  try {
7114
7114
  const manifest = await readBackupManifest(filePath, readOptions);
@@ -7132,7 +7132,7 @@ async function listBackups(directory, options = {}) {
7132
7132
  return backups;
7133
7133
  }
7134
7134
  function getDefaultCursorDataPath2() {
7135
- const home = homedir10();
7135
+ const home = homedir11();
7136
7136
  switch (process.platform) {
7137
7137
  case "win32":
7138
7138
  return join8(process.env["APPDATA"] ?? join8(home, "AppData", "Roaming"), "Cursor", "User", "workspaceStorage");
@@ -7761,11 +7761,11 @@ function attachErrorCause(error, cause) {
7761
7761
  });
7762
7762
  }
7763
7763
  }
7764
- async function parseStoreDb(path16, options = {}) {
7764
+ async function parseStoreDb(path17, options = {}) {
7765
7765
  const limits = options.limits ?? SOURCE_READ_LIMITS_V1_DEFAULTS;
7766
7766
  const failureOutcome = options.failureOutcome ?? "fatal";
7767
7767
  throwIfAborted4(options.signal);
7768
- if (!pathExists(path16, options.signal, options.io, options.logicalSessionId))
7768
+ if (!pathExists(path17, options.signal, options.io, options.logicalSessionId))
7769
7769
  return null;
7770
7770
  const budget = new SqliteSourceReadBudget(limits, failureOutcome);
7771
7771
  let workspace = null;
@@ -7777,7 +7777,7 @@ async function parseStoreDb(path16, options = {}) {
7777
7777
  workspace = createPrivateTempWorkspace({ prefix: "ch-store-", signal: options.signal });
7778
7778
  const tmpPath = workspace.createFile("store.db");
7779
7779
  throwIfAborted4(options.signal);
7780
- await backupDatabase(path16, tmpPath, databaseRequest("store-snapshot", STORE_SNAPSHOT_CAPABILITIES, options.sqliteDriver, options, "store-database"));
7780
+ await backupDatabase(path17, tmpPath, databaseRequest("store-snapshot", STORE_SNAPSHOT_CAPABILITIES, options.sqliteDriver, options, "store-database"));
7781
7781
  snapshotComplete = true;
7782
7782
  throwIfAborted4(options.signal);
7783
7783
  if (process.platform !== "win32")
@@ -7824,12 +7824,12 @@ async function parseStoreDb(path16, options = {}) {
7824
7824
  operationError = error;
7825
7825
  else {
7826
7826
  options.onDiagnostic?.(error);
7827
- debugLogStorage(`store.db defensive parse failed for ${path16}: ${error.code}`);
7827
+ debugLogStorage(`store.db defensive parse failed for ${path17}: ${error.code}`);
7828
7828
  }
7829
7829
  } else if (isSessionIntegrityError(error)) {
7830
7830
  operationError = error;
7831
7831
  } else if (error instanceof StoreSourceCorruptError || isSqliteSourceCorruptionError(error)) {
7832
- debugLogStorage(`store.db source/schema parse failed for ${path16}: ${String(error)}`);
7832
+ debugLogStorage(`store.db source/schema parse failed for ${path17}: ${String(error)}`);
7833
7833
  } else {
7834
7834
  operationError = error;
7835
7835
  }
@@ -7854,7 +7854,7 @@ async function parseStoreDb(path16, options = {}) {
7854
7854
  throw operationError;
7855
7855
  return result;
7856
7856
  }
7857
- function pathExists(path16, signal, io, logicalSessionId) {
7857
+ function pathExists(path17, signal, io, logicalSessionId) {
7858
7858
  throwIfAborted4(signal);
7859
7859
  try {
7860
7860
  if (io) {
@@ -7867,7 +7867,7 @@ function pathExists(path16, signal, io, logicalSessionId) {
7867
7867
  ...logicalSessionId ? { logicalSessionId } : {}
7868
7868
  });
7869
7869
  }
7870
- statSync4(path16);
7870
+ statSync4(path17);
7871
7871
  return true;
7872
7872
  } catch (error) {
7873
7873
  const code = error?.code;
@@ -8835,15 +8835,15 @@ function compareStringArrays2(left, right) {
8835
8835
  function getStorePhysicalOccurrences(session) {
8836
8836
  return physicalOccurrences.get(session) ?? [];
8837
8837
  }
8838
- function occurrenceKey(representation, path16) {
8839
- return `${representation}\0${path16}`;
8838
+ function occurrenceKey(representation, path17) {
8839
+ return `${representation}\0${path17}`;
8840
8840
  }
8841
- function occurrence(logicalSessionId, representation, path16, workspacePath) {
8841
+ function occurrence(logicalSessionId, representation, path17, workspacePath) {
8842
8842
  return {
8843
- instanceKey: occurrenceKey(representation, path16),
8843
+ instanceKey: occurrenceKey(representation, path17),
8844
8844
  logicalSessionId,
8845
8845
  representation,
8846
- path: path16,
8846
+ path: path17,
8847
8847
  ...workspacePath ? { workspacePath: normalizeWorkspacePath(workspacePath) } : {},
8848
8848
  sourceOrder: 0
8849
8849
  };
@@ -9191,7 +9191,7 @@ async function discoverStoreSessions(storeRoot2, options = {}) {
9191
9191
  const evidence = evidenceFor(uuid);
9192
9192
  evidence.transcriptInventoried = true;
9193
9193
  const transcriptOccurrence = occurrence(uuid, "store-transcript", nested, transcriptWorkspacePath(sanitized, metadataCandidates.get(logicalSessionIdKey(uuid)) ?? []));
9194
- if (!evidence.transcriptOccurrences.some(({ path: path16 }) => path16 === nested)) {
9194
+ if (!evidence.transcriptOccurrences.some(({ path: path17 }) => path17 === nested)) {
9195
9195
  evidence.transcriptOccurrences.push(transcriptOccurrence);
9196
9196
  }
9197
9197
  if (options.metadataOnly) {
@@ -9208,7 +9208,7 @@ async function discoverStoreSessions(storeRoot2, options = {}) {
9208
9208
  evidence.transcriptInventoried = true;
9209
9209
  const transcriptPath = join10(transcriptDir, entry.name);
9210
9210
  const transcriptOccurrence = occurrence(uuid, "store-transcript", transcriptPath, transcriptWorkspacePath(sanitized, metadataCandidates.get(logicalSessionIdKey(uuid)) ?? []));
9211
- if (!evidence.transcriptOccurrences.some(({ path: path16 }) => path16 === transcriptPath)) {
9211
+ if (!evidence.transcriptOccurrences.some(({ path: path17 }) => path17 === transcriptPath)) {
9212
9212
  evidence.transcriptOccurrences.push(transcriptOccurrence);
9213
9213
  }
9214
9214
  if (options.metadataOnly) {
@@ -9282,7 +9282,7 @@ async function discoverStoreSessions(storeRoot2, options = {}) {
9282
9282
  const usableDbCandidates = dbCandidates.filter((candidate) => Boolean(candidate.parsed && candidate.parsed.messages.length > 0));
9283
9283
  const selectedDbFidelity = usableDbCandidates.some(({ parsed }) => parsed.completeness === "complete") ? "complete" : "partial";
9284
9284
  const selectedDbTier = usableDbCandidates.filter(({ parsed }) => parsed.completeness === selectedDbFidelity);
9285
- let selectedDbCandidate = selectedDbTier[0] ?? dbCandidates.find(({ path: path16 }) => path16 === ss.storeDbPath) ?? dbCandidates[0];
9285
+ let selectedDbCandidate = selectedDbTier[0] ?? dbCandidates.find(({ path: path17 }) => path17 === ss.storeDbPath) ?? dbCandidates[0];
9286
9286
  let dbReplicaInstances = [];
9287
9287
  if (selectedDbTier.length > 1) {
9288
9288
  const physical = physicalStoreCandidates(ss.id, "store-db", selectedDbFidelity, selectedDbTier.map((candidate) => ({
@@ -9496,12 +9496,12 @@ function recordInventory(evidence, logicalSessionId, metaRead, sessionDir, dbPat
9496
9496
  if (metaRead.diagnostic)
9497
9497
  evidence.metadataFailures.push(metaRead.diagnostic);
9498
9498
  const metadataOccurrence = occurrence(logicalSessionId, "store-metadata", sessionDir, metaRead.meta?.cwd);
9499
- if (!evidence.metadataOccurrences.some(({ path: path16 }) => path16 === sessionDir)) {
9499
+ if (!evidence.metadataOccurrences.some(({ path: path17 }) => path17 === sessionDir)) {
9500
9500
  evidence.metadataOccurrences.push(metadataOccurrence);
9501
9501
  }
9502
9502
  if (dbInventoried) {
9503
9503
  evidence.dbInventoried = true;
9504
- if (!evidence.dbOccurrences.some(({ path: path16 }) => path16 === dbPath)) {
9504
+ if (!evidence.dbOccurrences.some(({ path: path17 }) => path17 === dbPath)) {
9505
9505
  evidence.dbOccurrences.push(occurrence(logicalSessionId, "store-db", dbPath, metaRead.meta?.cwd));
9506
9506
  }
9507
9507
  }
@@ -9747,12 +9747,12 @@ function listEntries(dir, signal, io) {
9747
9747
  throw error;
9748
9748
  }
9749
9749
  }
9750
- function readMeta(path16, signal, io, logicalSessionId, includeDisplayMetadata = true) {
9750
+ function readMeta(path17, signal, io, logicalSessionId, includeDisplayMetadata = true) {
9751
9751
  throwIfAborted6(signal);
9752
9752
  let raw;
9753
9753
  try {
9754
9754
  observeStoreFs(io, "read", "store-session-metadata", logicalSessionId, "store-db");
9755
- raw = readFileSync10(path16);
9755
+ raw = readFileSync10(path17);
9756
9756
  } catch (error) {
9757
9757
  if (isAbsentOrWrongType(error)) {
9758
9758
  return { present: false, unsupportedExpectationMetadata: false };
@@ -9883,11 +9883,11 @@ function decodeJsonObjectKey(raw, start, end) {
9883
9883
  function isJsonWhitespace(byte) {
9884
9884
  return byte === 32 || byte === 9 || byte === 10 || byte === 13;
9885
9885
  }
9886
- function pathExists2(path16, signal, io, resourceClass = "store-root-directory", logicalSessionId) {
9886
+ function pathExists2(path17, signal, io, resourceClass = "store-root-directory", logicalSessionId) {
9887
9887
  throwIfAborted6(signal);
9888
9888
  try {
9889
9889
  observeStoreFs(io, "open", resourceClass, logicalSessionId);
9890
- statSync5(path16);
9890
+ statSync5(path17);
9891
9891
  return true;
9892
9892
  } catch (error) {
9893
9893
  if (isAbsentOrWrongType(error))
@@ -11515,7 +11515,7 @@ async function resolveBackupWorkspaceInventory(manifest, backupPath, readOptions
11515
11515
  throw new ZipArchiveFormatError("No intact restorable files found in backup.");
11516
11516
  }
11517
11517
  const databases = backupWorkspaceDatabaseEntries(manifest);
11518
- const containsGlobalDatabase = manifest.files.some(({ type, path: path16 }) => type === "global-db" && path16 === "globalStorage/state.vscdb");
11518
+ const containsGlobalDatabase = manifest.files.some(({ type, path: path17 }) => type === "global-db" && path17 === "globalStorage/state.vscdb");
11519
11519
  const inventory = manifest.composerWorkspaceInventory;
11520
11520
  if (inventory) {
11521
11521
  const dbPathByWorkspaceId = new Map(databases.map(({ workspaceId, dbPath }) => [workspaceId, dbPath]));
@@ -12713,8 +12713,8 @@ function loadExactGlobalComposerSession(db, exactId, workspacePath, budget = cre
12713
12713
  function composerWorkspaceMemberships(candidates) {
12714
12714
  const counts2 = /* @__PURE__ */ new Map();
12715
12715
  for (const candidate of candidates) {
12716
- const path16 = normalizeWorkspacePath(candidate.workspace.path);
12717
- counts2.set(path16, (counts2.get(path16) ?? 0) + 1);
12716
+ const path17 = normalizeWorkspacePath(candidate.workspace.path);
12717
+ counts2.set(path17, (counts2.get(path17) ?? 0) + 1);
12718
12718
  }
12719
12719
  return [...counts2.entries()].sort(([left], [right]) => compareCodePoints8(left, right)).map(([workspacePath, contributingInstanceCount]) => ({
12720
12720
  workspacePath,
@@ -13406,7 +13406,7 @@ async function listSessions(options, customDataPath, backupPath, context) {
13406
13406
  composerWorkspaceInventory = await findComposerWorkspaceInventory(customDataPath, backupPath, context);
13407
13407
  const storeWorkspacePaths = storeCatalogSessions.flatMap(verifiedStoreWorkspacePaths);
13408
13408
  workspaceScopeResult = resolveWorkspaceScope(options.workspacePath, [
13409
- ...composerWorkspaceInventory.map(({ path: path16 }) => path16),
13409
+ ...composerWorkspaceInventory.map(({ path: path17 }) => path17),
13410
13410
  ...storeWorkspacePaths
13411
13411
  ]);
13412
13412
  if (workspaceScopeResult.kind === "not-found") {
@@ -13672,7 +13672,7 @@ async function listSessions(options, customDataPath, backupPath, context) {
13672
13672
  }
13673
13673
  }
13674
13674
  if (activeWorkspacePath) {
13675
- const offScopeWorkspaces = composerWorkspaceInventory.filter(({ path: path16 }) => !workspaceFilterMatches(path16, activeWorkspacePath));
13675
+ const offScopeWorkspaces = composerWorkspaceInventory.filter(({ path: path17 }) => !workspaceFilterMatches(path17, activeWorkspacePath));
13676
13676
  for (const workspace of offScopeWorkspaces) {
13677
13677
  if (backupPath) {
13678
13678
  for (const id of getBackupComposerSessionIds(workspace) ?? []) {
@@ -14965,11 +14965,11 @@ function formatToolCall(toolData, codeBlocks) {
14965
14965
  } else if (toolName === "grep" || toolName === "search" || toolName === "codebase_search") {
14966
14966
  lines2.push(`[Tool: ${toolName === "grep" ? "Grep" : "Search"}]`);
14967
14967
  const pattern = getParam(params, "pattern", "query", "searchQuery", "regex");
14968
- const path16 = getParam(params, "path", "directory", "targetDirectory");
14968
+ const path17 = getParam(params, "path", "directory", "targetDirectory");
14969
14969
  if (pattern)
14970
14970
  lines2.push(`Pattern: ${pattern}`);
14971
- if (path16)
14972
- lines2.push(`Path: ${path16}`);
14971
+ if (path17)
14972
+ lines2.push(`Path: ${path17}`);
14973
14973
  } else if (toolName === "run_terminal_command" || toolName === "run_terminal_cmd" || toolName === "execute_command") {
14974
14974
  lines2.push(`[Tool: Terminal Command]`);
14975
14975
  const cmd = getParam(params, "command", "cmd");
@@ -15474,9 +15474,9 @@ import { pathToFileURL } from "node:url";
15474
15474
  function generateSessionId() {
15475
15475
  return randomUUID2();
15476
15476
  }
15477
- function transformPath(path16, sourcePrefix, destPrefix) {
15477
+ function transformPath(path17, sourcePrefix, destPrefix) {
15478
15478
  const normalizedSource = sourcePrefix.replace(/\/+$/, "");
15479
- const normalizedPath = path16;
15479
+ const normalizedPath = path17;
15480
15480
  if (normalizedPath.startsWith(normalizedSource + "/") || normalizedPath === normalizedSource) {
15481
15481
  return destPrefix + normalizedPath.slice(normalizedSource.length);
15482
15482
  }
@@ -15592,8 +15592,8 @@ function isNestedPath(source, destination) {
15592
15592
  const normalizedDest = normalizePath(destination).replace(/\/+$/, "");
15593
15593
  return normalizedDest.startsWith(normalizedSource + "/");
15594
15594
  }
15595
- function toFileUri(path16) {
15596
- const normalized = normalizePath(path16);
15595
+ function toFileUri(path17) {
15596
+ const normalized = normalizePath(path17);
15597
15597
  const windowsDrivePath = normalized.match(/^([A-Za-z]):[\\/](.*)$/);
15598
15598
  if (windowsDrivePath) {
15599
15599
  const drive = windowsDrivePath[1].toLowerCase();
@@ -15647,13 +15647,13 @@ function createMigrationReadGuard(limits, signal, sqliteDriver) {
15647
15647
  sqliteDriver
15648
15648
  };
15649
15649
  }
15650
- function physicalPathIdentity(label, path16) {
15651
- const normalized = normalizedPathKey(path16);
15652
- if (!existsSync9(path16))
15650
+ function physicalPathIdentity(label, path17) {
15651
+ const normalized = normalizedPathKey(path17);
15652
+ if (!existsSync9(path17))
15653
15653
  return `${label}:${normalized}|missing`;
15654
15654
  try {
15655
- const stat9 = statSync6(path16);
15656
- return `${label}:${normalized}|dev:${String(stat9.dev)}|ino:${String(stat9.ino)}`;
15655
+ const stat10 = statSync6(path17);
15656
+ return `${label}:${normalized}|dev:${String(stat10.dev)}|ino:${String(stat10.ino)}`;
15657
15657
  } catch {
15658
15658
  return `${label}:${normalized}|unavailable`;
15659
15659
  }
@@ -15801,13 +15801,13 @@ async function findMigrationWorkspaceByPath(requested, dataPath2, guard) {
15801
15801
  const databasePath = join12(workspaceDirectory, "state.vscdb");
15802
15802
  if (!existsSync9(databasePath))
15803
15803
  continue;
15804
- const path16 = readWorkspaceJson(workspaceDirectory);
15805
- if (!path16 || !pathsEqual(path16, normalizedRequest))
15804
+ const path17 = readWorkspaceJson(workspaceDirectory);
15805
+ if (!path17 || !pathsEqual(path17, normalizedRequest))
15806
15806
  continue;
15807
15807
  return {
15808
15808
  workspace: {
15809
15809
  id: entry.name,
15810
- path: normalizePath(path16),
15810
+ path: normalizePath(path17),
15811
15811
  dbPath: databasePath,
15812
15812
  sessionCount: 0
15813
15813
  },
@@ -15825,7 +15825,7 @@ function loadWorkspaceComposerAddressInventory(db, budget, signal) {
15825
15825
  if (rootType !== "array" && rootType !== "object") {
15826
15826
  throw new TypeError("Composer workspace catalog is not a JSON array or object.");
15827
15827
  }
15828
- const scanIds = (path16, objectIds) => {
15828
+ const scanIds = (path17, objectIds) => {
15829
15829
  const scanBudget = new SqliteSourceReadBudget(budget.limits, budget.outcome);
15830
15830
  const results = [];
15831
15831
  const pageRows = scanBudget.limits.sqlitePageRows;
@@ -15836,7 +15836,7 @@ function loadWorkspaceComposerAddressInventory(db, budget, signal) {
15836
15836
  throwIfMigrationAborted(signal);
15837
15837
  const rows = db.prepare(`SELECT CAST(j.key AS INTEGER) AS itemIndex,
15838
15838
  length(CAST(${valueExpression} AS BLOB)) AS byteLength
15839
- FROM ItemTable AS i, json_each(i.value, '${path16}') AS j
15839
+ FROM ItemTable AS i, json_each(i.value, '${path17}') AS j
15840
15840
  WHERE i.rowid = ?
15841
15841
  AND ${typePredicate}
15842
15842
  AND CAST(j.key AS INTEGER) > ?
@@ -15855,7 +15855,7 @@ function loadWorkspaceComposerAddressInventory(db, budget, signal) {
15855
15855
  for (const item of metadata) {
15856
15856
  throwIfMigrationAborted(signal);
15857
15857
  const projected = db.prepare(`SELECT ${valueExpression} AS sessionId
15858
- FROM ItemTable AS i, json_each(i.value, '${path16}') AS j
15858
+ FROM ItemTable AS i, json_each(i.value, '${path17}') AS j
15859
15859
  WHERE i.rowid = ? AND CAST(j.key AS INTEGER) = ?`).get(source.rowId, item.itemIndex);
15860
15860
  if (typeof projected?.sessionId !== "string") {
15861
15861
  throw new Error("Composer ID projection changed after metadata admission.");
@@ -20341,13 +20341,13 @@ var KNOWN_ROW_IDS = /* @__PURE__ */ new Set([
20341
20341
  ]);
20342
20342
 
20343
20343
  // src/version.ts
20344
- var CLI_VERSION = true ? "0.20.4" : "0.0.0-dev";
20344
+ var CLI_VERSION = true ? "0.20.6" : "0.0.0-dev";
20345
20345
 
20346
20346
  // src/api.ts
20347
20347
  var BASE_URL = process.env.AISTACK_URL || "https://aistack.to";
20348
20348
  var STARTUP_READ_TIMEOUT_MS = 5e3;
20349
- async function request(path16, options = {}) {
20350
- return fetch(`${BASE_URL}${path16}`, {
20349
+ async function request(path17, options = {}) {
20350
+ return fetch(`${BASE_URL}${path17}`, {
20351
20351
  ...options,
20352
20352
  headers: {
20353
20353
  "Content-Type": "application/json",
@@ -20367,7 +20367,7 @@ function failure(what, res) {
20367
20367
  }
20368
20368
  if (res.status === 403) {
20369
20369
  return new Error(
20370
- `${what}: this machine is not allowed to do that. Run \`aistack login\` again to re-link it.`
20370
+ `${what}: this machine is not allowed to do that. Run \`npx @use-aistack/cli@latest login\` again to re-link it.`
20371
20371
  );
20372
20372
  }
20373
20373
  return new Error(`${what}: ${res.status}`);
@@ -20404,7 +20404,7 @@ async function stackCollect(token, data) {
20404
20404
  });
20405
20405
  if (res.status === 401)
20406
20406
  throw new Error(
20407
- "Authentication expired. Run `npx @use-aistack/cli login` again."
20407
+ "Authentication expired. Run `npx @use-aistack/cli@latest login` again."
20408
20408
  );
20409
20409
  if (!res.ok) {
20410
20410
  throw Object.assign(
@@ -20530,7 +20530,7 @@ async function postSync(token, bodyJson, retryTransport = false) {
20530
20530
  }
20531
20531
  } else if (res?.status === 401) {
20532
20532
  throw new Error(
20533
- "Authentication expired. Run `npx @use-aistack/cli login` again."
20533
+ "Authentication expired. Run `npx @use-aistack/cli@latest login` again."
20534
20534
  );
20535
20535
  } else if (res?.status === 403 || res?.status === 429) {
20536
20536
  throw failure("Sync failed", res);
@@ -20565,7 +20565,7 @@ async function fetchDayManifest(baseUrl, token) {
20565
20565
  if (res.status === 404) return null;
20566
20566
  if (res.status === 401)
20567
20567
  throw new Error(
20568
- "Authentication expired. Run `npx @use-aistack/cli login` again."
20568
+ "Authentication expired. Run `npx @use-aistack/cli@latest login` again."
20569
20569
  );
20570
20570
  if (res.status === 403 || res.status === 429)
20571
20571
  throw failure("Manifest fetch failed", res);
@@ -20609,7 +20609,7 @@ async function setAutoSync(token, flag) {
20609
20609
  });
20610
20610
  if (res.status === 401)
20611
20611
  throw new Error(
20612
- "Authentication expired. Run `npx @use-aistack/cli login` again."
20612
+ "Authentication expired. Run `npx @use-aistack/cli@latest login` again."
20613
20613
  );
20614
20614
  if (res.status === 403 || res.status === 429)
20615
20615
  throw failure("Auto-sync update failed", res);
@@ -20627,7 +20627,7 @@ async function stackGet(token) {
20627
20627
  });
20628
20628
  if (res.status === 401)
20629
20629
  throw new Error(
20630
- "Authentication expired. Run `npx @use-aistack/cli login` again."
20630
+ "Authentication expired. Run `npx @use-aistack/cli@latest login` again."
20631
20631
  );
20632
20632
  if (res.status === 404) return null;
20633
20633
  if (!res.ok) throw failure("Stack fetch failed", res);
@@ -20879,9 +20879,9 @@ function canonicalizeRepoUrl(input) {
20879
20879
  function repoNameFromCanonical(canonical) {
20880
20880
  return parseRepo(canonical)?.repo ?? "";
20881
20881
  }
20882
- function normalizeUpstreamPath(path16) {
20883
- if (!path16) return "";
20884
- return path16.split("/").filter(Boolean).join("/");
20882
+ function normalizeUpstreamPath(path17) {
20883
+ if (!path17) return "";
20884
+ return path17.split("/").filter(Boolean).join("/");
20885
20885
  }
20886
20886
 
20887
20887
  // src/git.ts
@@ -20927,16 +20927,16 @@ function buildRepoLinkResource(canonical) {
20927
20927
  import { existsSync as existsSync2, readFileSync as readFileSync2 } from "node:fs";
20928
20928
  import { homedir as homedir2 } from "node:os";
20929
20929
  import { join as join2 } from "node:path";
20930
- function readJson(path16) {
20930
+ function readJson(path17) {
20931
20931
  try {
20932
- if (!existsSync2(path16)) return null;
20933
- return JSON.parse(readFileSync2(path16, "utf-8"));
20932
+ if (!existsSync2(path17)) return null;
20933
+ return JSON.parse(readFileSync2(path17, "utf-8"));
20934
20934
  } catch {
20935
20935
  return null;
20936
20936
  }
20937
20937
  }
20938
- function hooksFrom(path16, source, out, seen) {
20939
- const hooks = readJson(path16)?.hooks;
20938
+ function hooksFrom(path17, source, out, seen) {
20939
+ const hooks = readJson(path17)?.hooks;
20940
20940
  if (!hooks || typeof hooks !== "object") return;
20941
20941
  for (const [event, config] of Object.entries(hooks)) {
20942
20942
  const stableKey = `hooks:${source}:${event}`;
@@ -21085,16 +21085,16 @@ function buildMcpResource(name, group, pkg) {
21085
21085
  pkg
21086
21086
  };
21087
21087
  }
21088
- function readText(path16) {
21088
+ function readText(path17) {
21089
21089
  try {
21090
- if (!existsSync3(path16)) return null;
21091
- return readFileSync3(path16, "utf-8");
21090
+ if (!existsSync3(path17)) return null;
21091
+ return readFileSync3(path17, "utf-8");
21092
21092
  } catch {
21093
21093
  return null;
21094
21094
  }
21095
21095
  }
21096
- function readParsed(path16, parse2) {
21097
- const raw = readText(path16);
21096
+ function readParsed(path17, parse2) {
21097
+ const raw = readText(path17);
21098
21098
  if (raw === null) return null;
21099
21099
  try {
21100
21100
  return parse2(raw);
@@ -21102,14 +21102,14 @@ function readParsed(path16, parse2) {
21102
21102
  return null;
21103
21103
  }
21104
21104
  }
21105
- function readJson2(path16) {
21106
- return readParsed(path16, JSON.parse);
21105
+ function readJson2(path17) {
21106
+ return readParsed(path17, JSON.parse);
21107
21107
  }
21108
- function readYaml(path16) {
21109
- return readParsed(path16, parseYaml);
21108
+ function readYaml(path17) {
21109
+ return readParsed(path17, parseYaml);
21110
21110
  }
21111
- function readToml(path16) {
21112
- return readParsed(path16, parseToml);
21111
+ function readToml(path17) {
21112
+ return readParsed(path17, parseToml);
21113
21113
  }
21114
21114
  function continueListToMap(file) {
21115
21115
  if (!file?.mcpServers?.length) return void 0;
@@ -21248,8 +21248,8 @@ function resolveSource(entry, mpRepoUrl) {
21248
21248
  const src = entry.source;
21249
21249
  if (typeof src === "string") {
21250
21250
  if (!mpRepoUrl) return null;
21251
- const path16 = src.replace(/^\.\//, "").replace(/\/+$/, "");
21252
- return { url: mpRepoUrl, path: path16 || void 0 };
21251
+ const path17 = src.replace(/^\.\//, "").replace(/\/+$/, "");
21252
+ return { url: mpRepoUrl, path: path17 || void 0 };
21253
21253
  }
21254
21254
  if (src && typeof src === "object" && src.url) {
21255
21255
  return { url: src.url, path: src.path, sha: src.sha };
@@ -21286,10 +21286,10 @@ function resolvePluginLinks(installed, marketplaces, manifests) {
21286
21286
  }
21287
21287
  return out;
21288
21288
  }
21289
- function readJson3(path16) {
21289
+ function readJson3(path17) {
21290
21290
  try {
21291
- if (!existsSync4(path16)) return null;
21292
- return JSON.parse(readFileSync4(path16, "utf-8"));
21291
+ if (!existsSync4(path17)) return null;
21292
+ return JSON.parse(readFileSync4(path17, "utf-8"));
21293
21293
  } catch {
21294
21294
  return null;
21295
21295
  }
@@ -21378,8 +21378,8 @@ function loadGitignore(cwd) {
21378
21378
  }
21379
21379
  function readFileSafe(filePath) {
21380
21380
  try {
21381
- const stat9 = statSync(filePath);
21382
- if (stat9.size > MAX_FILE_SIZE) return null;
21381
+ const stat10 = statSync(filePath);
21382
+ if (stat10.size > MAX_FILE_SIZE) return null;
21383
21383
  return readFileSync5(filePath, "utf-8");
21384
21384
  } catch {
21385
21385
  return null;
@@ -21634,7 +21634,7 @@ async function collectCommand(options) {
21634
21634
  const token = getToken();
21635
21635
  if (!token) {
21636
21636
  p2.log.error(
21637
- `Not authenticated. Run ${limeBold("npx @use-aistack/cli login")} first.`
21637
+ `Not authenticated. Run ${limeBold("npx @use-aistack/cli@latest login")} first.`
21638
21638
  );
21639
21639
  outroError("not authenticated");
21640
21640
  process.exit(1);
@@ -21923,7 +21923,7 @@ function diffResources(current, existing) {
21923
21923
  // src/commands/connect.ts
21924
21924
  import { spawnSync } from "node:child_process";
21925
21925
  import { cpSync, existsSync as existsSync11 } from "node:fs";
21926
- import { homedir as homedir17 } from "node:os";
21926
+ import { homedir as homedir18 } from "node:os";
21927
21927
  import { dirname as dirname5, join as join13 } from "node:path";
21928
21928
  import { fileURLToPath } from "node:url";
21929
21929
  import * as p3 from "@clack/prompts";
@@ -24796,17 +24796,127 @@ function noteConfiguredMcpServers(agg, serverNames) {
24796
24796
 
24797
24797
  // src/harness/codex/scan.ts
24798
24798
  import { readFileSync as readFileSync6 } from "node:fs";
24799
- import { open, readdir as readdir4, realpath as realpath3, stat as stat4 } from "node:fs/promises";
24800
- import { homedir as homedir7 } from "node:os";
24801
- import path4 from "node:path";
24799
+ import { open, readdir as readdir5, stat as stat5 } from "node:fs/promises";
24800
+ import { homedir as homedir8 } from "node:os";
24801
+ import path5 from "node:path";
24802
24802
  import { Readable } from "node:stream";
24803
24803
  import * as zlib from "node:zlib";
24804
24804
  import { parse as parseToml2 } from "smol-toml";
24805
- function codexHome() {
24806
- return process.env.CODEX_HOME || path4.join(homedir7(), ".codex");
24805
+
24806
+ // src/harness/shared/homes.ts
24807
+ import {
24808
+ mkdir,
24809
+ readdir as readdir4,
24810
+ readFile,
24811
+ realpath as realpath3,
24812
+ stat as stat4,
24813
+ writeFile
24814
+ } from "node:fs/promises";
24815
+ import { homedir as homedir7 } from "node:os";
24816
+ import path4 from "node:path";
24817
+ async function discoverHomes(options) {
24818
+ let complete = true;
24819
+ const resolve3 = async (dir) => {
24820
+ try {
24821
+ const real = await realpath3(dir);
24822
+ return (await stat4(real)).isDirectory() ? real : null;
24823
+ } catch (error) {
24824
+ if (!absent(error)) {
24825
+ complete = false;
24826
+ traceError("harness home resolution", error, "warn");
24827
+ }
24828
+ return null;
24829
+ }
24830
+ };
24831
+ const named = [...options.defaults];
24832
+ for (const { parent, prefix } of options.siblings ?? []) {
24833
+ try {
24834
+ named.push(
24835
+ ...(await readdir4(parent, { withFileTypes: true })).filter(
24836
+ (entry) => entry.name.startsWith(prefix) && (entry.isDirectory() || entry.isSymbolicLink())
24837
+ ).map((entry) => path4.join(parent, entry.name)).sort()
24838
+ );
24839
+ } catch (error) {
24840
+ if (!absent(error)) {
24841
+ complete = false;
24842
+ traceError("harness home discovery", error, "warn");
24843
+ }
24844
+ }
24845
+ }
24846
+ const homes = [];
24847
+ const add = (real) => {
24848
+ if (real && !homes.includes(real)) homes.push(real);
24849
+ };
24850
+ for (const dir of named) add(await resolve3(dir));
24851
+ const found = new Set(homes);
24852
+ const remembered = options.remember ? await readRemembered(options.remember) : [];
24853
+ const fresh = [];
24854
+ for (const dir of (options.configured ?? []).filter((dir2) => Boolean(dir2?.trim())).map(expandHome)) {
24855
+ const real = await resolve3(dir);
24856
+ add(real);
24857
+ if (real && !found.has(real) && !remembered.includes(real))
24858
+ fresh.push(real);
24859
+ }
24860
+ for (const dir of remembered) add(await resolve3(dir));
24861
+ if (options.remember && fresh.length)
24862
+ await writeRemembered(options.remember, [...remembered, ...fresh]);
24863
+ return { homes, complete };
24864
+ }
24865
+ var rememberedFile = () => path4.join(homedir7(), ".config", "aistack", "harness-homes.json");
24866
+ async function readRemembered(harness) {
24867
+ try {
24868
+ const parsed = JSON.parse(await readFile(rememberedFile(), "utf8"));
24869
+ const list = parsed?.[harness];
24870
+ return Array.isArray(list) ? list.filter((dir) => typeof dir === "string") : [];
24871
+ } catch (error) {
24872
+ if (!absent(error)) traceError("remembered harness homes", error, "warn");
24873
+ return [];
24874
+ }
24807
24875
  }
24808
- function rolloutRoots() {
24809
- return [path4.join(codexHome(), "sessions")];
24876
+ async function writeRemembered(harness, dirs) {
24877
+ const file = rememberedFile();
24878
+ try {
24879
+ let all = {};
24880
+ try {
24881
+ const parsed = JSON.parse(await readFile(file, "utf8"));
24882
+ if (parsed && typeof parsed === "object" && !Array.isArray(parsed))
24883
+ all = parsed;
24884
+ } catch (error) {
24885
+ if (!absent(error)) throw error;
24886
+ }
24887
+ all[harness] = dirs;
24888
+ await mkdir(path4.dirname(file), { recursive: true, mode: 448 });
24889
+ await writeFile(file, `${JSON.stringify(all, null, 2)}
24890
+ `, { mode: 384 });
24891
+ } catch (error) {
24892
+ traceError("remembered harness homes", error, "warn");
24893
+ }
24894
+ }
24895
+ function expandHome(dir) {
24896
+ const trimmed = dir.trim();
24897
+ return path4.resolve(
24898
+ trimmed.startsWith("~/") ? path4.join(homedir7(), trimmed.slice(2)) : trimmed
24899
+ );
24900
+ }
24901
+ function absent(error) {
24902
+ const code = error?.code;
24903
+ return code === "ENOENT" || code === "ENOTDIR";
24904
+ }
24905
+
24906
+ // src/harness/codex/scan.ts
24907
+ async function discoverCodexHomes() {
24908
+ const home = homedir8();
24909
+ return discoverHomes({
24910
+ defaults: [path5.join(home, ".codex")],
24911
+ configured: [process.env.CODEX_HOME],
24912
+ siblings: [{ parent: home, prefix: ".codex" }],
24913
+ remember: "codex"
24914
+ });
24915
+ }
24916
+ async function rolloutRoots() {
24917
+ return (await discoverCodexHomes()).homes.map(
24918
+ (home) => path5.join(home, "sessions")
24919
+ );
24810
24920
  }
24811
24921
  var ROLLOUT_RE = /^rollout-.*\.jsonl(\.zst)?$/;
24812
24922
  function isRolloutFile(basename5) {
@@ -24815,14 +24925,14 @@ function isRolloutFile(basename5) {
24815
24925
  async function* walkRollouts(dir) {
24816
24926
  let entries;
24817
24927
  try {
24818
- entries = await readdir4(dir, { withFileTypes: true });
24928
+ entries = await readdir5(dir, { withFileTypes: true });
24819
24929
  } catch (error) {
24820
24930
  if (error?.code !== "ENOENT")
24821
24931
  traceError("codex rollout discovery", error, "warn");
24822
24932
  return;
24823
24933
  }
24824
24934
  for (const e of entries) {
24825
- const full = path4.join(dir, e.name);
24935
+ const full = path5.join(dir, e.name);
24826
24936
  if (e.isDirectory()) yield* walkRollouts(full);
24827
24937
  else if (e.isFile() && isRolloutFile(e.name)) yield full;
24828
24938
  }
@@ -24840,76 +24950,76 @@ async function scanWindows(windows, opts = {}) {
24840
24950
  ...window,
24841
24951
  stats: emptyScanStats()
24842
24952
  }));
24843
- const visited = /* @__PURE__ */ new Set();
24844
- for (const root of opts.roots ?? rolloutRoots()) {
24953
+ const discovery = opts.roots ? { homes: [], complete: true } : await discoverCodexHomes();
24954
+ for (const { stats } of targets)
24955
+ stats.sourceDiscoveryComplete = discovery.complete;
24956
+ const roots = opts.roots ?? discovery.homes.map((home) => path5.join(home, "sessions"));
24957
+ const chosen = /* @__PURE__ */ new Map();
24958
+ for (const root of roots) {
24845
24959
  if (!await exists2(root)) continue;
24846
24960
  for await (const file of walkRollouts(root)) {
24847
24961
  for (const { stats } of targets) stats.filesFound++;
24848
- let resolved;
24962
+ let size = -1;
24963
+ let mtimeMs;
24849
24964
  try {
24850
- resolved = await realpath3(file);
24965
+ const st = await stat5(file);
24966
+ size = st.size;
24967
+ mtimeMs = st.mtimeMs;
24851
24968
  } catch (error) {
24852
24969
  if (error?.code !== "ENOENT")
24853
- traceError("codex rollout path resolution", error, "warn");
24854
- resolved = file;
24970
+ traceError("codex rollout stat", error, "warn");
24855
24971
  }
24856
- const dedupKey = resolved.endsWith(".zst") ? resolved.slice(0, -4) : resolved;
24857
- if (visited.has(dedupKey)) {
24972
+ const key2 = path5.basename(file).replace(/\.zst$/, "");
24973
+ const held = chosen.get(key2);
24974
+ if (held) {
24858
24975
  for (const { stats } of targets) stats.filesSkippedAsDuplicate++;
24859
- continue;
24976
+ if (size <= held.size) continue;
24860
24977
  }
24861
- visited.add(dedupKey);
24862
- let mtimeMs;
24863
- if (targets.some((target) => target.sinceMs !== void 0)) {
24864
- try {
24865
- mtimeMs = (await stat4(file)).mtimeMs;
24866
- } catch (error) {
24867
- if (error?.code !== "ENOENT")
24868
- traceError("codex rollout stat", error, "warn");
24869
- }
24870
- }
24871
- const eligible = targets.filter((target) => {
24872
- if (mtimeMs !== void 0 && target.sinceMs !== void 0 && mtimeMs < target.sinceMs) {
24873
- target.stats.filesSkippedByMtime++;
24874
- return false;
24875
- }
24876
- return true;
24877
- });
24878
- if (!eligible.length) continue;
24879
- for (const { aggregate, stats, onProgress } of eligible) {
24880
- aggregate.files++;
24881
- stats.filesRead++;
24882
- if (aggregate.files % 20 === 0) onProgress?.(aggregate.files);
24978
+ chosen.set(key2, { root, file, size, mtimeMs });
24979
+ }
24980
+ }
24981
+ for (const { root, file, mtimeMs } of chosen.values()) {
24982
+ const eligible = targets.filter((target) => {
24983
+ if (mtimeMs !== void 0 && target.sinceMs !== void 0 && mtimeMs < target.sinceMs) {
24984
+ target.stats.filesSkippedByMtime++;
24985
+ return false;
24883
24986
  }
24884
- const outcome = await ingestWithRetry(eligible, file, opts);
24885
- for (const { stats } of eligible) {
24886
- if (!outcome.ok) {
24887
- stats.filesUnreadable++;
24888
- stats.filesRead--;
24889
- if (outcome.reason === "zstd-unsupported")
24890
- stats.filesZstdUnsupported++;
24891
- stats.unreadableFiles.push({
24892
- path: path4.relative(root, file),
24893
- reason: outcome.reason
24894
- });
24895
- } else if (!outcome.genuine) {
24896
- stats.filesForeign++;
24897
- stats.filesRead--;
24898
- stats.foreignOriginators.set(
24899
- outcome.originator,
24900
- (stats.foreignOriginators.get(outcome.originator) ?? 0) + 1
24901
- );
24902
- }
24987
+ return true;
24988
+ });
24989
+ if (!eligible.length) continue;
24990
+ for (const { aggregate, stats, onProgress } of eligible) {
24991
+ aggregate.files++;
24992
+ stats.filesRead++;
24993
+ if (aggregate.files % 20 === 0) onProgress?.(aggregate.files);
24994
+ }
24995
+ const outcome = await ingestWithRetry(eligible, file, opts);
24996
+ for (const { stats } of eligible) {
24997
+ if (!outcome.ok) {
24998
+ stats.filesUnreadable++;
24999
+ stats.filesRead--;
25000
+ if (outcome.reason === "zstd-unsupported") stats.filesZstdUnsupported++;
25001
+ stats.unreadableFiles.push({
25002
+ path: path5.relative(root, file),
25003
+ reason: outcome.reason
25004
+ });
25005
+ } else if (!outcome.genuine) {
25006
+ stats.filesForeign++;
25007
+ stats.filesRead--;
25008
+ stats.foreignOriginators.set(
25009
+ outcome.originator,
25010
+ (stats.foreignOriginators.get(outcome.originator) ?? 0) + 1
25011
+ );
24903
25012
  }
24904
25013
  }
24905
25014
  }
25015
+ const configFiles = opts.configFile ? [opts.configFile] : discovery.homes.map((home) => path5.join(home, "config.toml"));
24906
25016
  for (const { aggregate } of targets)
24907
- readConfiguredMcpServers(aggregate, opts.configFile);
25017
+ for (const file of configFiles) readConfiguredMcpServers(aggregate, file);
24908
25018
  return targets.map((target) => target.stats);
24909
25019
  }
24910
25020
  async function exists2(p8) {
24911
25021
  try {
24912
- await stat4(p8);
25022
+ await stat5(p8);
24913
25023
  return true;
24914
25024
  } catch (error) {
24915
25025
  if (error?.code !== "ENOENT")
@@ -25080,8 +25190,7 @@ async function classifyRollout(records) {
25080
25190
  if (genuine) return { genuine: true };
25081
25191
  return { genuine: false, originator: originator ?? "(none)" };
25082
25192
  }
25083
- function readConfiguredMcpServers(agg, configFile) {
25084
- const file = configFile ?? path4.join(codexHome(), "config.toml");
25193
+ function readConfiguredMcpServers(agg, file) {
25085
25194
  let names = [];
25086
25195
  try {
25087
25196
  const parsed = parseToml2(readFileSync6(file, "utf8"));
@@ -25121,7 +25230,7 @@ var codexAdapter = {
25121
25230
  builtinTools: CODEX_BUILTIN_TOOLS,
25122
25231
  async detect(opts) {
25123
25232
  return hasRecentFile(
25124
- opts.roots ?? rolloutRoots(),
25233
+ opts.roots ?? await rolloutRoots(),
25125
25234
  isRolloutFile,
25126
25235
  opts.sinceMs
25127
25236
  );
@@ -25135,6 +25244,7 @@ var codexAdapter = {
25135
25244
  return {
25136
25245
  aggregate,
25137
25246
  stats,
25247
+ scanComplete: stats.sourceDiscoveryComplete !== false,
25138
25248
  workflow: aggregate.workflow.finish(),
25139
25249
  workflowLocal: aggregate.workflowLocal
25140
25250
  };
@@ -25149,6 +25259,7 @@ var codexAdapter = {
25149
25259
  return windows.map(({ aggregate }, index) => ({
25150
25260
  aggregate,
25151
25261
  stats: stats[index],
25262
+ scanComplete: stats[index].sourceDiscoveryComplete !== false,
25152
25263
  workflow: aggregate.workflow.finish(),
25153
25264
  workflowLocal: aggregate.workflowLocal
25154
25265
  }));
@@ -25156,9 +25267,9 @@ var codexAdapter = {
25156
25267
  };
25157
25268
 
25158
25269
  // src/harness/cursor/cache.ts
25159
- import { mkdir as mkdir2, readFile as readFile2, rename as rename2, writeFile as writeFile2 } from "node:fs/promises";
25160
- import { homedir as homedir12 } from "node:os";
25161
- import path7 from "node:path";
25270
+ import { mkdir as mkdir3, readFile as readFile3, rename as rename2, writeFile as writeFile3 } from "node:fs/promises";
25271
+ import { homedir as homedir13 } from "node:os";
25272
+ import path8 from "node:path";
25162
25273
 
25163
25274
  // src/harness/cursor/account.ts
25164
25275
  import { createHash as createHash7 } from "node:crypto";
@@ -25371,9 +25482,9 @@ function reconcile(local, api) {
25371
25482
 
25372
25483
  // src/harness/cursor/local.ts
25373
25484
  import { existsSync as existsSync10 } from "node:fs";
25374
- import { stat as stat5 } from "node:fs/promises";
25375
- import { homedir as homedir11 } from "node:os";
25376
- import path6 from "node:path";
25485
+ import { stat as stat6 } from "node:fs/promises";
25486
+ import { homedir as homedir12 } from "node:os";
25487
+ import path7 from "node:path";
25377
25488
  import { Worker } from "node:worker_threads";
25378
25489
 
25379
25490
  // src/harness/cursor/composer.ts
@@ -25576,13 +25687,13 @@ function hasComposerHalf(summary) {
25576
25687
  }
25577
25688
 
25578
25689
  // src/harness/cursor/sessionCache.ts
25579
- import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
25580
- import { homedir as homedir8 } from "node:os";
25581
- import path5 from "node:path";
25690
+ import { mkdir as mkdir2, readFile as readFile2, rename, writeFile as writeFile2 } from "node:fs/promises";
25691
+ import { homedir as homedir9 } from "node:os";
25692
+ import path6 from "node:path";
25582
25693
  import { gunzipSync, gzipSync } from "node:zlib";
25583
25694
  var SESSION_CACHE_FORMAT = 1;
25584
- var defaultSessionCacheDir = () => path5.join(homedir8(), ".config", "aistack", "cursor");
25585
- var sessionCacheFile = (dir, root, store) => path5.join(dir, `${digest(`${root}\0${store}`)}.sessions.json.gz`);
25695
+ var defaultSessionCacheDir = () => path6.join(homedir9(), ".config", "aistack", "cursor");
25696
+ var sessionCacheFile = (dir, root, store) => path6.join(dir, `${digest(`${root}\0${store}`)}.sessions.json.gz`);
25586
25697
  function sessionStamp(summary, newest) {
25587
25698
  if (newest === null) return null;
25588
25699
  const count2 = summary.messageCount;
@@ -25622,7 +25733,7 @@ async function loadSessionCache(file) {
25622
25733
  const out = /* @__PURE__ */ new Map();
25623
25734
  let raw;
25624
25735
  try {
25625
- raw = gunzipSync(await readFile(file)).toString("utf8");
25736
+ raw = gunzipSync(await readFile2(file)).toString("utf8");
25626
25737
  } catch (error) {
25627
25738
  if (error.code !== "ENOENT")
25628
25739
  traceError("cursor session cache read", error, "warn");
@@ -25642,7 +25753,7 @@ async function loadSessionCache(file) {
25642
25753
  return out;
25643
25754
  }
25644
25755
  async function saveSessionCache(file, cache) {
25645
- await mkdir(path5.dirname(file), { recursive: true, mode: 448 });
25756
+ await mkdir2(path6.dirname(file), { recursive: true, mode: 448 });
25646
25757
  const body = gzipSync(
25647
25758
  JSON.stringify({
25648
25759
  format: SESSION_CACHE_FORMAT,
@@ -25650,21 +25761,21 @@ async function saveSessionCache(file, cache) {
25650
25761
  })
25651
25762
  );
25652
25763
  const temporary = `${file}.${process.pid}.${Date.now()}.tmp`;
25653
- await writeFile(temporary, body, { mode: 384 });
25764
+ await writeFile2(temporary, body, { mode: 384 });
25654
25765
  await rename(temporary, file);
25655
25766
  }
25656
25767
 
25657
25768
  // src/harness/cursor/local.ts
25658
- function dataPath(env = process.env, home = homedir11(), platform4 = process.platform) {
25659
- if (env.CURSOR_DATA_PATH) return path6.resolve(env.CURSOR_DATA_PATH);
25660
- const base = platform4 === "darwin" ? path6.join(home, "Library", "Application Support") : platform4 === "win32" ? env.APPDATA || path6.join(home, "AppData", "Roaming") : env.XDG_CONFIG_HOME || path6.join(home, ".config");
25661
- return path6.join(base, "Cursor", "User", "workspaceStorage");
25769
+ function dataPath(env = process.env, home = homedir12(), platform4 = process.platform) {
25770
+ if (env.CURSOR_DATA_PATH) return path7.resolve(env.CURSOR_DATA_PATH);
25771
+ const base = platform4 === "darwin" ? path7.join(home, "Library", "Application Support") : platform4 === "win32" ? env.APPDATA || path7.join(home, "AppData", "Roaming") : env.XDG_CONFIG_HOME || path7.join(home, ".config");
25772
+ return path7.join(base, "Cursor", "User", "workspaceStorage");
25662
25773
  }
25663
- var storeRoot = () => process.env.CURSOR_STORE_ROOT || path6.join(homedir11(), ".cursor");
25664
- var globalDb = (root) => path6.join(path6.dirname(root), "globalStorage", "state.vscdb");
25774
+ var storeRoot = () => process.env.CURSOR_STORE_ROOT || path7.join(homedir12(), ".cursor");
25775
+ var globalDb = (root) => path7.join(path7.dirname(root), "globalStorage", "state.vscdb");
25665
25776
  async function exists3(file) {
25666
25777
  try {
25667
- await stat5(file);
25778
+ await stat6(file);
25668
25779
  return true;
25669
25780
  } catch (error) {
25670
25781
  return error.code !== "ENOENT";
@@ -25675,9 +25786,9 @@ async function hasLocalSource(root = dataPath()) {
25675
25786
  [
25676
25787
  root,
25677
25788
  globalDb(root),
25678
- path6.join(storeRoot(), "projects"),
25679
- path6.join(storeRoot(), "chats"),
25680
- path6.join(storeRoot(), "acp-sessions")
25789
+ path7.join(storeRoot(), "projects"),
25790
+ path7.join(storeRoot(), "chats"),
25791
+ path7.join(storeRoot(), "acp-sessions")
25681
25792
  ].map(exists3)
25682
25793
  )).some(Boolean);
25683
25794
  }
@@ -25749,7 +25860,7 @@ async function sourceStamp(root) {
25749
25860
  const values = await Promise.all(
25750
25861
  [globalDb(root), `${globalDb(root)}-wal`].map(async (file) => {
25751
25862
  try {
25752
- const info = await stat5(file);
25863
+ const info = await stat6(file);
25753
25864
  return `${info.size}:${info.mtimeMs}`;
25754
25865
  } catch {
25755
25866
  return "unavailable";
@@ -26138,7 +26249,7 @@ async function readLocalOnce(root, before, onProgress, sourceReadLimits, stallMs
26138
26249
  }
26139
26250
  async function globalDbSize(root) {
26140
26251
  try {
26141
- const info = await stat5(globalDb(root));
26252
+ const info = await stat6(globalDb(root));
26142
26253
  return `${(info.size / 1048576).toFixed(0)} MB`;
26143
26254
  } catch {
26144
26255
  return "absent";
@@ -26339,8 +26450,8 @@ var emptyCache = () => ({
26339
26450
  local: [],
26340
26451
  sessions: []
26341
26452
  });
26342
- var cacheFile = (root, store) => path7.join(
26343
- homedir12(),
26453
+ var cacheFile = (root, store) => path8.join(
26454
+ homedir13(),
26344
26455
  ".config",
26345
26456
  "aistack",
26346
26457
  "cursor",
@@ -26355,7 +26466,7 @@ function validContribution(value) {
26355
26466
  }
26356
26467
  async function loadCache(file) {
26357
26468
  try {
26358
- const raw = asObj(JSON.parse(await readFile2(file, "utf8")));
26469
+ const raw = asObj(JSON.parse(await readFile3(file, "utf8")));
26359
26470
  const windows = asObj(raw?.windows);
26360
26471
  if (raw?.version !== 1 || !(raw.account === null || typeof raw.account === "string") || !Array.isArray(raw.sessions) || !raw.sessions.every((id) => typeof id === "string") || !Array.isArray(raw.local) || !raw.local.every(validContribution) || !windows)
26361
26472
  throw Object.assign(new Error("Invalid cache"), {
@@ -26379,9 +26490,9 @@ async function loadCache(file) {
26379
26490
  }
26380
26491
  }
26381
26492
  async function saveCache(file, value) {
26382
- await mkdir2(path7.dirname(file), { recursive: true, mode: 448 });
26493
+ await mkdir3(path8.dirname(file), { recursive: true, mode: 448 });
26383
26494
  const temporary = `${file}.${process.pid}.${Date.now()}.tmp`;
26384
- await writeFile2(temporary, JSON.stringify(value), { mode: 384 });
26495
+ await writeFile3(temporary, JSON.stringify(value), { mode: 384 });
26385
26496
  await rename2(temporary, file);
26386
26497
  }
26387
26498
  var REFRESH_MS = 3e5;
@@ -26435,10 +26546,10 @@ function cachedEvents(cache, sessionIds) {
26435
26546
  }
26436
26547
 
26437
26548
  // src/harness/cursor/scan.ts
26438
- import path9 from "node:path";
26549
+ import path10 from "node:path";
26439
26550
 
26440
26551
  // src/harness/cursor/workflow.ts
26441
- import path8 from "node:path";
26552
+ import path9 from "node:path";
26442
26553
  var TOOLS = {
26443
26554
  read_file: "Read",
26444
26555
  read_file_v2: "Read",
@@ -26479,7 +26590,7 @@ function projectHistory(options) {
26479
26590
  const scopes = /* @__PURE__ */ new Map();
26480
26591
  const inWindow = (t) => t !== null && t >= sinceMs && t <= now;
26481
26592
  for (const { session } of locals) {
26482
- const projectWorkspace = session.canonicalWorkspacePath && path8.isAbsolute(session.canonicalWorkspacePath) ? session.canonicalWorkspacePath : void 0;
26593
+ const projectWorkspace = session.canonicalWorkspacePath && path9.isAbsolute(session.canonicalWorkspacePath) ? session.canonicalWorkspacePath : void 0;
26483
26594
  const times = messageTimes(session, api);
26484
26595
  const scopeOf = (message) => {
26485
26596
  const parent = message.parentMessageId && nativeOwners.get(message.parentMessageId);
@@ -26566,7 +26677,7 @@ function projectHistory(options) {
26566
26677
  session: row.sidechain ? `${row.session}:sidechain` : row.session,
26567
26678
  sidechain: row.sidechain
26568
26679
  },
26569
- ...project && path8.isAbsolute(project) ? { projectWorkspace: project } : {},
26680
+ ...project && path9.isAbsolute(project) ? { projectWorkspace: project } : {},
26570
26681
  type: "response",
26571
26682
  tsMs: row.tsMs,
26572
26683
  responseId: `${row.source}:${row.id ?? index}`,
@@ -26665,7 +26776,7 @@ async function scan3(options) {
26665
26776
  aggregate.byModel.set(model, emptyUsage());
26666
26777
  }
26667
26778
  const project = session.canonicalWorkspacePath;
26668
- if (project && path9.isAbsolute(project)) aggregate.projectDirs.add(project);
26779
+ if (project && path10.isAbsolute(project)) aggregate.projectDirs.add(project);
26669
26780
  if (session.metadata?.cursorVersion)
26670
26781
  aggregate.ccVersions.add(session.metadata.cursorVersion);
26671
26782
  let firstTime = null;
@@ -26722,7 +26833,7 @@ async function scan3(options) {
26722
26833
  else aggregate.mainTokens += countsTotal(counts2);
26723
26834
  noteSessionStart(aggregate, session, tsMs);
26724
26835
  const project = sessions.get(session)?.session.canonicalWorkspacePath;
26725
- if (project && path9.isAbsolute(project))
26836
+ if (project && path10.isAbsolute(project))
26726
26837
  noteProjectDay(aggregate, project, tsMs);
26727
26838
  }
26728
26839
  aggregate.files = local.stats.filesRead;
@@ -27009,17 +27120,17 @@ function ingestContribution(agg, row) {
27009
27120
 
27010
27121
  // src/harness/grok/scan.ts
27011
27122
  import { createReadStream as createReadStream2 } from "node:fs";
27012
- import { readdir as readdir6, readFile as readFile4, stat as stat6 } from "node:fs/promises";
27013
- import { homedir as homedir14 } from "node:os";
27014
- import path11 from "node:path";
27123
+ import { readdir as readdir7, readFile as readFile5, stat as stat7 } from "node:fs/promises";
27124
+ import { homedir as homedir15 } from "node:os";
27125
+ import path12 from "node:path";
27015
27126
  import readline2 from "node:readline";
27016
27127
  import { parse as parseToml3 } from "smol-toml";
27017
27128
 
27018
27129
  // src/harness/grok/context.ts
27019
27130
  import { createHash as createHash8 } from "node:crypto";
27020
- import { appendFile, mkdir as mkdir3, readdir as readdir5, readFile as readFile3, unlink as unlink2 } from "node:fs/promises";
27021
- import { homedir as homedir13 } from "node:os";
27022
- import path10 from "node:path";
27131
+ import { appendFile, mkdir as mkdir4, readdir as readdir6, readFile as readFile4, unlink as unlink2 } from "node:fs/promises";
27132
+ import { homedir as homedir14 } from "node:os";
27133
+ import path11 from "node:path";
27023
27134
  var DAY_MS = 864e5;
27024
27135
  var hash = (value) => createHash8("sha256").update(value).digest("hex");
27025
27136
  function contextCall(value) {
@@ -27042,17 +27153,17 @@ function contextCall(value) {
27042
27153
  };
27043
27154
  }
27044
27155
  function contextCacheDirectory(root) {
27045
- return path10.join(
27046
- homedir13(),
27156
+ return path11.join(
27157
+ homedir14(),
27047
27158
  ".config",
27048
27159
  "aistack",
27049
27160
  "grok-context",
27050
- hash(path10.resolve(root))
27161
+ hash(path11.resolve(root))
27051
27162
  );
27052
27163
  }
27053
27164
  async function optionalRead(file) {
27054
27165
  try {
27055
- return await readFile3(file, "utf8");
27166
+ return await readFile4(file, "utf8");
27056
27167
  } catch (error) {
27057
27168
  if (error.code === "ENOENT") return "";
27058
27169
  throw error;
@@ -27063,21 +27174,21 @@ async function retainedContextCalls(root, sessions, cacheDir = contextCacheDirec
27063
27174
  const calls = /* @__PURE__ */ new Map();
27064
27175
  let files = [];
27065
27176
  try {
27066
- files = await readdir5(cacheDir);
27177
+ files = await readdir6(cacheDir);
27067
27178
  } catch (error) {
27068
27179
  if (error.code !== "ENOENT") throw error;
27069
27180
  }
27070
27181
  for (const file of files) {
27071
27182
  if (!/^\d{4}-\d{2}-\d{2}\.jsonl$/.test(file)) continue;
27072
27183
  if (Date.parse(file.slice(0, 10)) + DAY_MS < cutoff) {
27073
- await unlink2(path10.join(cacheDir, file)).catch(
27184
+ await unlink2(path11.join(cacheDir, file)).catch(
27074
27185
  (error) => {
27075
27186
  if (error.code !== "ENOENT") throw error;
27076
27187
  }
27077
27188
  );
27078
27189
  continue;
27079
27190
  }
27080
- const raw2 = await optionalRead(path10.join(cacheDir, file));
27191
+ const raw2 = await optionalRead(path11.join(cacheDir, file));
27081
27192
  if (raw2 && !raw2.endsWith("\n"))
27082
27193
  throw Object.assign(new Error("Incomplete Grok context cache"), {
27083
27194
  code: "GROK_INCOMPLETE_CONTEXT_CACHE"
@@ -27098,7 +27209,7 @@ async function retainedContextCalls(root, sessions, cacheDir = contextCacheDirec
27098
27209
  }
27099
27210
  }
27100
27211
  const raw = await optionalRead(
27101
- path10.join(root, "..", "logs", "unified.jsonl")
27212
+ path11.join(root, "..", "logs", "unified.jsonl")
27102
27213
  );
27103
27214
  const additions = /* @__PURE__ */ new Map();
27104
27215
  for (const line of raw.slice(0, raw.lastIndexOf("\n") + 1).split("\n")) {
@@ -27118,10 +27229,10 @@ async function retainedContextCalls(root, sessions, cacheDir = contextCacheDirec
27118
27229
  additions.set(date, lines2);
27119
27230
  }
27120
27231
  if (additions.size) {
27121
- await mkdir3(cacheDir, { recursive: true, mode: 448 });
27232
+ await mkdir4(cacheDir, { recursive: true, mode: 448 });
27122
27233
  for (const [date, lines2] of additions) {
27123
27234
  await appendFile(
27124
- path10.join(cacheDir, `${date}.jsonl`),
27235
+ path11.join(cacheDir, `${date}.jsonl`),
27125
27236
  `${lines2.join("\n")}
27126
27237
  `,
27127
27238
  { mode: 384 }
@@ -27132,13 +27243,31 @@ async function retainedContextCalls(root, sessions, cacheDir = contextCacheDirec
27132
27243
  }
27133
27244
 
27134
27245
  // src/harness/grok/scan.ts
27135
- function sessionRoots() {
27136
- return [
27137
- path11.join(
27138
- process.env.GROK_HOME || path11.join(homedir14(), ".grok"),
27139
- "sessions"
27140
- )
27141
- ];
27246
+ async function discoverGrokHomes() {
27247
+ const home = homedir15();
27248
+ return discoverHomes({
27249
+ defaults: [path12.join(home, ".grok")],
27250
+ configured: [process.env.GROK_HOME],
27251
+ siblings: [{ parent: home, prefix: ".grok" }],
27252
+ remember: "grok-build"
27253
+ });
27254
+ }
27255
+ async function sessionRoots() {
27256
+ return (await discoverGrokHomes()).homes.map(
27257
+ (home) => path12.join(home, "sessions")
27258
+ );
27259
+ }
27260
+ async function evidenceBytes(dir) {
27261
+ let total = 0;
27262
+ for (const name of ["usage.json", "updates.jsonl", "events.jsonl"]) {
27263
+ try {
27264
+ total += (await stat7(path12.join(dir, name))).size;
27265
+ } catch (error) {
27266
+ if (error?.code !== "ENOENT")
27267
+ traceError("grok evidence stat", error, "warn");
27268
+ }
27269
+ }
27270
+ return total;
27142
27271
  }
27143
27272
  var isGrokEvidenceFile = (name) => name === "usage.json" || name === "updates.jsonl" || name === "events.jsonl";
27144
27273
  var delays = [0, 100, 300];
@@ -27147,7 +27276,7 @@ async function stableRead(file, jsonl) {
27147
27276
  for (const delay of delays) {
27148
27277
  if (delay) await pause(delay);
27149
27278
  try {
27150
- const before = await stat6(file);
27279
+ const before = await stat7(file);
27151
27280
  if (!before.isFile()) return { complete: false };
27152
27281
  if (jsonl) {
27153
27282
  const lines2 = [];
@@ -27165,12 +27294,12 @@ async function stableRead(file, jsonl) {
27165
27294
  lines2.push(null);
27166
27295
  }
27167
27296
  }
27168
- const after = await stat6(file);
27297
+ const after = await stat7(file);
27169
27298
  if (before.size === after.size && before.mtimeMs === after.mtimeMs)
27170
27299
  return { lines: lines2, complete: true };
27171
27300
  } else {
27172
- const raw = await readFile4(file, "utf8");
27173
- const after = await stat6(file);
27301
+ const raw = await readFile5(file, "utf8");
27302
+ const after = await stat7(file);
27174
27303
  if (before.size === after.size && before.mtimeMs === after.mtimeMs)
27175
27304
  return { json: JSON.parse(raw), complete: true };
27176
27305
  }
@@ -27183,16 +27312,16 @@ async function stableRead(file, jsonl) {
27183
27312
  }
27184
27313
  function absoluteCwd(value) {
27185
27314
  const cwd = asStr(value);
27186
- return cwd && path11.isAbsolute(cwd) && !cwd.includes("\0") ? cwd : void 0;
27315
+ return cwd && path12.isAbsolute(cwd) && !cwd.includes("\0") ? cwd : void 0;
27187
27316
  }
27188
27317
  async function workspaceCwd(workspacePath, entries) {
27189
27318
  try {
27190
- const cwd = absoluteCwd(decodeURIComponent(path11.basename(workspacePath)));
27319
+ const cwd = absoluteCwd(decodeURIComponent(path12.basename(workspacePath)));
27191
27320
  if (cwd !== void 0) return cwd;
27192
27321
  } catch {
27193
27322
  }
27194
27323
  if (entries.some((entry) => entry.name === ".cwd" && entry.isFile())) {
27195
- const raw = await readFile4(path11.join(workspacePath, ".cwd"), "utf8").catch(
27324
+ const raw = await readFile5(path12.join(workspacePath, ".cwd"), "utf8").catch(
27196
27325
  () => void 0
27197
27326
  );
27198
27327
  return absoluteCwd(raw);
@@ -27200,18 +27329,18 @@ async function workspaceCwd(workspacePath, entries) {
27200
27329
  }
27201
27330
  async function directories(root) {
27202
27331
  try {
27203
- const workspaces = await readdir6(root, { withFileTypes: true });
27332
+ const workspaces = await readdir7(root, { withFileTypes: true });
27204
27333
  const out = [];
27205
27334
  for (const workspace of workspaces) {
27206
27335
  if (!workspace.isDirectory() || workspace.isSymbolicLink()) continue;
27207
- const workspacePath = path11.join(root, workspace.name);
27208
- const entries = await readdir6(workspacePath, {
27336
+ const workspacePath = path12.join(root, workspace.name);
27337
+ const entries = await readdir7(workspacePath, {
27209
27338
  withFileTypes: true
27210
27339
  });
27211
27340
  const cwd = await workspaceCwd(workspacePath, entries);
27212
27341
  for (const session of entries) {
27213
27342
  if (session.isDirectory() && !session.isSymbolicLink())
27214
- out.push({ dir: path11.join(workspacePath, session.name), cwd });
27343
+ out.push({ dir: path12.join(workspacePath, session.name), cwd });
27215
27344
  }
27216
27345
  }
27217
27346
  return out.sort((a, b) => {
@@ -27228,7 +27357,7 @@ async function modelAliasesForRoot(root) {
27228
27357
  if (process.env.GROK_MODELS_BASE_URL) return /* @__PURE__ */ new Map();
27229
27358
  try {
27230
27359
  const parsed = asObj(
27231
- parseToml3(await readFile4(path11.join(root, "..", "config.toml"), "utf8"))
27360
+ parseToml3(await readFile5(path12.join(root, "..", "config.toml"), "utf8"))
27232
27361
  );
27233
27362
  if (!parsed || asObj(parsed.endpoints)?.models_base_url) return /* @__PURE__ */ new Map();
27234
27363
  const models = asObj(parsed.model);
@@ -27257,19 +27386,37 @@ async function scanWindows2(windows, opts = {}) {
27257
27386
  sessionDates: /* @__PURE__ */ new Map(),
27258
27387
  candidates: /* @__PURE__ */ new Map()
27259
27388
  }));
27260
- let complete = true;
27261
- for (const root of opts.roots ?? sessionRoots()) {
27389
+ const discovery = opts.roots ? { homes: [], complete: true } : await discoverGrokHomes();
27390
+ let complete = discovery.complete;
27391
+ const roots = opts.roots ?? discovery.homes.map((home) => path12.join(home, "sessions"));
27392
+ const listed = /* @__PURE__ */ new Map();
27393
+ const fullest = /* @__PURE__ */ new Map();
27394
+ for (const root of roots) {
27395
+ const dirs = await directories(root);
27396
+ listed.set(root, dirs);
27397
+ for (const { dir } of dirs ?? []) {
27398
+ const key2 = path12.relative(root, dir);
27399
+ const bytes = await evidenceBytes(dir);
27400
+ const held = fullest.get(key2);
27401
+ if (!held || bytes > held.bytes) fullest.set(key2, { dir, bytes });
27402
+ }
27403
+ }
27404
+ for (const root of roots) {
27262
27405
  const aliases = await modelAliasesForRoot(root);
27263
27406
  const contextSessions = /* @__PURE__ */ new Map();
27264
- const dirs = await directories(root);
27265
- if (dirs === null) {
27407
+ const dirs = listed.get(root);
27408
+ if (!dirs) {
27266
27409
  complete = false;
27267
27410
  continue;
27268
27411
  }
27269
27412
  for (const { dir, cwd } of dirs) {
27413
+ if (fullest.get(path12.relative(root, dir))?.dir !== dir) {
27414
+ stats.filesSkippedAsDuplicate++;
27415
+ continue;
27416
+ }
27270
27417
  let entries;
27271
27418
  try {
27272
- entries = await readdir6(dir, { withFileTypes: true });
27419
+ entries = await readdir7(dir, { withFileTypes: true });
27273
27420
  } catch (error) {
27274
27421
  traceError("grok session listing", error);
27275
27422
  complete = false;
@@ -27278,10 +27425,10 @@ async function scanWindows2(windows, opts = {}) {
27278
27425
  const files = new Map(
27279
27426
  entries.filter(
27280
27427
  (e) => e.isFile() && (isGrokEvidenceFile(e.name) || e.name === "summary.json")
27281
- ).map((e) => [e.name, path11.join(dir, e.name)])
27428
+ ).map((e) => [e.name, path12.join(dir, e.name)])
27282
27429
  );
27283
27430
  let projectDir = cwd;
27284
- let sessionFallback = path11.basename(dir);
27431
+ let sessionFallback = path12.basename(dir);
27285
27432
  let child = false;
27286
27433
  let parentSession;
27287
27434
  const summary = files.get("summary.json");
@@ -27453,8 +27600,8 @@ var GROK_BUILTIN_TOOLS = /* @__PURE__ */ new Set([
27453
27600
  var grokAdapter = {
27454
27601
  name: GROK_HARNESS_NAME,
27455
27602
  builtinTools: GROK_BUILTIN_TOOLS,
27456
- detect: (opts) => hasRecentFile(
27457
- opts.roots ?? sessionRoots(),
27603
+ detect: async (opts) => hasRecentFile(
27604
+ opts.roots ?? await sessionRoots(),
27458
27605
  isGrokEvidenceFile,
27459
27606
  opts.sinceMs
27460
27607
  ),
@@ -27682,30 +27829,60 @@ function ingestTypedSkill2(agg, row) {
27682
27829
 
27683
27830
  // src/harness/opencode/scan.ts
27684
27831
  import { readFileSync as readFileSync12 } from "node:fs";
27685
- import { readdir as readdir7, stat as stat7 } from "node:fs/promises";
27686
- import { homedir as homedir15 } from "node:os";
27687
- import path12 from "node:path";
27832
+ import { readdir as readdir8, realpath as realpath4, stat as stat8 } from "node:fs/promises";
27833
+ import { homedir as homedir16 } from "node:os";
27834
+ import path13 from "node:path";
27688
27835
  var OPENCODE_MIGRATION_CEILING = 20260622202450;
27689
- function opencodeDataDirs() {
27690
- const xdg = process.env.XDG_DATA_HOME;
27691
- const base = xdg || path12.join(homedir15(), ".local", "share");
27692
- return [path12.join(base, "opencode")];
27836
+ async function opencodeDataDirs() {
27837
+ const xdg = process.env.XDG_DATA_HOME?.trim();
27838
+ return discoverHomes({
27839
+ defaults: [path13.join(homedir16(), ".local", "share", "opencode")],
27840
+ configured: [xdg ? path13.join(xdg, "opencode") : void 0],
27841
+ remember: "opencode"
27842
+ });
27693
27843
  }
27694
27844
  function isStoreFile(basename5) {
27695
27845
  return basename5 === "opencode.db" || /^opencode-[^/]+\.db$/.test(basename5);
27696
27846
  }
27697
27847
  async function dbFilesIn(root) {
27698
- const override = process.env.OPENCODE_DB;
27699
- if (override) return [override];
27700
27848
  try {
27701
- const entries = await readdir7(root, { withFileTypes: true });
27702
- return entries.filter((e) => e.isFile() && isStoreFile(e.name)).map((e) => path12.join(root, e.name)).sort();
27849
+ const entries = await readdir8(root, { withFileTypes: true });
27850
+ return entries.filter((e) => e.isFile() && isStoreFile(e.name)).map((e) => path13.join(root, e.name)).sort();
27703
27851
  } catch (error) {
27704
27852
  if (error?.code !== "ENOENT")
27705
27853
  traceError("opencode database discovery", error, "warn");
27706
27854
  return [];
27707
27855
  }
27708
27856
  }
27857
+ async function storeFiles(roots) {
27858
+ const dirs = roots ?? (await opencodeDataDirs()).homes;
27859
+ const candidates = [];
27860
+ for (const root of dirs) candidates.push(...await dbFilesIn(root));
27861
+ const override = roots ? void 0 : process.env.OPENCODE_DB?.trim();
27862
+ if (override)
27863
+ candidates.push(
27864
+ path13.resolve(
27865
+ process.env.XDG_DATA_HOME?.trim() || path13.join(homedir16(), ".local", "share"),
27866
+ "opencode",
27867
+ override
27868
+ )
27869
+ );
27870
+ const files = [];
27871
+ const seen = /* @__PURE__ */ new Set();
27872
+ for (const file of candidates) {
27873
+ let key2 = file;
27874
+ try {
27875
+ key2 = await realpath4(file);
27876
+ } catch (error) {
27877
+ if (error?.code !== "ENOENT")
27878
+ traceError("opencode database path resolution", error, "warn");
27879
+ }
27880
+ if (seen.has(key2)) continue;
27881
+ seen.add(key2);
27882
+ files.push(file);
27883
+ }
27884
+ return files;
27885
+ }
27709
27886
  async function loadSqlite() {
27710
27887
  try {
27711
27888
  const mod = await import("node:sqlite");
@@ -27729,24 +27906,22 @@ async function scan5(agg, opts = {}) {
27729
27906
  const sinceMs = opts.sinceMs ?? 0;
27730
27907
  const state = createDbFoldState();
27731
27908
  readConfiguredMcpServers2(agg, state, opts.configFile);
27732
- for (const root of opts.roots ?? opencodeDataDirs()) {
27733
- for (const file of await dbFilesIn(root)) {
27734
- stats.filesFound++;
27735
- agg.files++;
27736
- try {
27737
- if (open4 === null) throw readError2("sqlite-unsupported");
27738
- readDb(agg, state, open4, file, sinceMs);
27739
- stats.filesRead++;
27740
- } catch (e) {
27741
- traceError("opencode database read", e);
27742
- stats.filesUnreadable++;
27743
- stats.unreadableFiles.push({
27744
- path: path12.basename(file),
27745
- reason: errorClass2(e)
27746
- });
27747
- }
27748
- if (opts.onProgress) opts.onProgress(stats.filesFound);
27909
+ for (const file of await storeFiles(opts.roots)) {
27910
+ stats.filesFound++;
27911
+ agg.files++;
27912
+ try {
27913
+ if (open4 === null) throw readError2("sqlite-unsupported");
27914
+ readDb(agg, state, open4, file, sinceMs);
27915
+ stats.filesRead++;
27916
+ } catch (e) {
27917
+ traceError("opencode database read", e);
27918
+ stats.filesUnreadable++;
27919
+ stats.unreadableFiles.push({
27920
+ path: path13.basename(file),
27921
+ reason: errorClass2(e)
27922
+ });
27749
27923
  }
27924
+ if (opts.onProgress) opts.onProgress(stats.filesFound);
27750
27925
  }
27751
27926
  return stats;
27752
27927
  }
@@ -27928,8 +28103,8 @@ function pickTs(jsonTs, columnTs) {
27928
28103
  }
27929
28104
  function opencodeConfigFile() {
27930
28105
  const xdg = process.env.XDG_CONFIG_HOME;
27931
- const base = xdg || path12.join(homedir15(), ".config");
27932
- return path12.join(base, "opencode", "opencode.json");
28106
+ const base = xdg || path13.join(homedir16(), ".config");
28107
+ return path13.join(base, "opencode", "opencode.json");
27933
28108
  }
27934
28109
  function readConfiguredMcpServers2(agg, state, configFile) {
27935
28110
  const file = configFile ?? opencodeConfigFile();
@@ -27981,26 +28156,24 @@ function stripJsonc(text) {
27981
28156
  async function detectOpencode(opts) {
27982
28157
  const open4 = await loadSqlite();
27983
28158
  if (open4 === null) return false;
27984
- for (const root of opts.roots ?? opencodeDataDirs()) {
27985
- for (const file of await dbFilesIn(root)) {
27986
- if (!await exists4(file)) continue;
27987
- let db = null;
28159
+ for (const file of await storeFiles(opts.roots)) {
28160
+ if (!await exists4(file)) continue;
28161
+ let db = null;
28162
+ try {
28163
+ db = open4(file);
28164
+ checkMigrationCeiling(db);
28165
+ const probe = (table) => db?.prepare(
28166
+ `select 1 as hit from ${table} where time_created >= ? limit 1`
28167
+ ).get(opts.sinceMs) !== void 0;
28168
+ if (probe("message") || probe("session_message")) return true;
28169
+ } catch (error) {
28170
+ traceError("opencode detection", error, "warn");
28171
+ } finally {
27988
28172
  try {
27989
- db = open4(file);
27990
- checkMigrationCeiling(db);
27991
- const probe = (table) => db?.prepare(
27992
- `select 1 as hit from ${table} where time_created >= ? limit 1`
27993
- ).get(opts.sinceMs) !== void 0;
27994
- if (probe("message") || probe("session_message")) return true;
28173
+ db?.close();
27995
28174
  } catch (error) {
27996
- traceError("opencode detection", error, "warn");
27997
- } finally {
27998
- try {
27999
- db?.close();
28000
- } catch (error) {
28001
- if (error?.code !== "ENOENT")
28002
- traceError("opencode source stat", error, "warn");
28003
- }
28175
+ if (error?.code !== "ENOENT")
28176
+ traceError("opencode source stat", error, "warn");
28004
28177
  }
28005
28178
  }
28006
28179
  }
@@ -28008,7 +28181,7 @@ async function detectOpencode(opts) {
28008
28181
  }
28009
28182
  async function exists4(p8) {
28010
28183
  try {
28011
- await stat7(p8);
28184
+ await stat8(p8);
28012
28185
  return true;
28013
28186
  } catch (error) {
28014
28187
  if (error?.code !== "ENOENT")
@@ -28238,17 +28411,24 @@ function readCounts2(usageRaw) {
28238
28411
 
28239
28412
  // src/harness/pi/scan.ts
28240
28413
  import { createReadStream as createReadStream3 } from "node:fs";
28241
- import { readdir as readdir8, realpath as realpath4, stat as stat8 } from "node:fs/promises";
28242
- import { homedir as homedir16 } from "node:os";
28243
- import path13 from "node:path";
28414
+ import { readdir as readdir9, realpath as realpath5, stat as stat9 } from "node:fs/promises";
28415
+ import { homedir as homedir17 } from "node:os";
28416
+ import path14 from "node:path";
28244
28417
  import readline3 from "node:readline";
28245
28418
  var MAX_SESSION_VERSION = 3;
28246
- function piAgentDir() {
28247
- return process.env.PI_CODING_AGENT_DIR || path13.join(homedir16(), ".pi", "agent");
28419
+ async function discoverSessionRoots() {
28420
+ const agentDir = process.env.PI_CODING_AGENT_DIR?.trim();
28421
+ return discoverHomes({
28422
+ defaults: [path14.join(homedir17(), ".pi", "agent", "sessions")],
28423
+ configured: [
28424
+ agentDir ? path14.join(agentDir, "sessions") : void 0,
28425
+ process.env.PI_CODING_AGENT_SESSION_DIR
28426
+ ],
28427
+ remember: "pi-mono"
28428
+ });
28248
28429
  }
28249
- function sessionRoots2() {
28250
- const override = process.env.PI_CODING_AGENT_SESSION_DIR;
28251
- return [override || path13.join(piAgentDir(), "sessions")];
28430
+ async function sessionRoots2() {
28431
+ return (await discoverSessionRoots()).homes;
28252
28432
  }
28253
28433
  var SESSION_FILE_RE = /^\d{4}-\d{2}-\d{2}T\d{2}-\d{2}-\d{2}-\d{3}Z_[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\.jsonl$/;
28254
28434
  function isSessionFile(basename5) {
@@ -28257,14 +28437,14 @@ function isSessionFile(basename5) {
28257
28437
  async function* walkSessions(dir) {
28258
28438
  let entries;
28259
28439
  try {
28260
- entries = await readdir8(dir, { withFileTypes: true });
28440
+ entries = await readdir9(dir, { withFileTypes: true });
28261
28441
  } catch (error) {
28262
28442
  if (error?.code !== "ENOENT")
28263
28443
  traceError("pi transcript discovery", error, "warn");
28264
28444
  return;
28265
28445
  }
28266
28446
  for (const e of entries) {
28267
- const full = path13.join(dir, e.name);
28447
+ const full = path14.join(dir, e.name);
28268
28448
  if (e.isDirectory()) yield* walkSessions(full);
28269
28449
  else if (e.isFile() && isSessionFile(e.name)) yield full;
28270
28450
  }
@@ -28273,13 +28453,15 @@ async function scan6(agg, opts = {}) {
28273
28453
  const stats = emptyScanStats();
28274
28454
  const visited = /* @__PURE__ */ new Set();
28275
28455
  const fold = createFoldState();
28276
- for (const root of opts.roots ?? sessionRoots2()) {
28456
+ const discovery = opts.roots ? { homes: opts.roots, complete: true } : await discoverSessionRoots();
28457
+ stats.sourceDiscoveryComplete = discovery.complete;
28458
+ for (const root of discovery.homes) {
28277
28459
  if (!await exists5(root)) continue;
28278
28460
  for await (const file of walkSessions(root)) {
28279
28461
  stats.filesFound++;
28280
28462
  let resolved;
28281
28463
  try {
28282
- resolved = await realpath4(file);
28464
+ resolved = await realpath5(file);
28283
28465
  } catch (error) {
28284
28466
  if (error?.code !== "ENOENT")
28285
28467
  traceError("pi transcript path resolution", error, "warn");
@@ -28292,7 +28474,7 @@ async function scan6(agg, opts = {}) {
28292
28474
  visited.add(resolved);
28293
28475
  if (opts.sinceMs !== void 0) {
28294
28476
  try {
28295
- const st = await stat8(file);
28477
+ const st = await stat9(file);
28296
28478
  if (st.mtimeMs < opts.sinceMs) {
28297
28479
  stats.filesSkippedByMtime++;
28298
28480
  continue;
@@ -28316,7 +28498,7 @@ async function scan6(agg, opts = {}) {
28316
28498
  stats.filesUnreadable++;
28317
28499
  stats.filesRead--;
28318
28500
  stats.unreadableFiles.push({
28319
- path: path13.relative(root, file),
28501
+ path: path14.relative(root, file),
28320
28502
  reason: "version-too-new"
28321
28503
  });
28322
28504
  }
@@ -28325,7 +28507,7 @@ async function scan6(agg, opts = {}) {
28325
28507
  stats.filesUnreadable++;
28326
28508
  stats.filesRead--;
28327
28509
  stats.unreadableFiles.push({
28328
- path: path13.relative(root, file),
28510
+ path: path14.relative(root, file),
28329
28511
  reason: "read-error"
28330
28512
  });
28331
28513
  }
@@ -28335,7 +28517,7 @@ async function scan6(agg, opts = {}) {
28335
28517
  }
28336
28518
  async function exists5(p8) {
28337
28519
  try {
28338
- await stat8(p8);
28520
+ await stat9(p8);
28339
28521
  return true;
28340
28522
  } catch (error) {
28341
28523
  if (error?.code !== "ENOENT")
@@ -28400,7 +28582,7 @@ var piAdapter = {
28400
28582
  builtinTools: PI_BUILTIN_TOOLS,
28401
28583
  async detect(opts) {
28402
28584
  return hasRecentFile(
28403
- opts.roots ?? sessionRoots2(),
28585
+ opts.roots ?? await sessionRoots2(),
28404
28586
  isSessionFile,
28405
28587
  opts.sinceMs
28406
28588
  );
@@ -28414,6 +28596,7 @@ var piAdapter = {
28414
28596
  return {
28415
28597
  aggregate,
28416
28598
  stats,
28599
+ scanComplete: stats.sourceDiscoveryComplete !== false,
28417
28600
  workflow: aggregate.workflow.finish(),
28418
28601
  workflowLocal: aggregate.workflowLocal
28419
28602
  };
@@ -28456,7 +28639,7 @@ async function detectedAdapters(sinceMs = detectionSinceMs()) {
28456
28639
  }
28457
28640
 
28458
28641
  // src/commands/connect.ts
28459
- var MANUAL_MCP_ADD = "claude mcp add --scope user aistack -- npx -y @use-aistack/cli mcp";
28642
+ var MANUAL_MCP_ADD = "claude mcp add --scope user aistack -- npx -y @use-aistack/cli@latest mcp";
28460
28643
  var MCP_ADD_ARGS = [
28461
28644
  "mcp",
28462
28645
  "add",
@@ -28466,11 +28649,11 @@ var MCP_ADD_ARGS = [
28466
28649
  "--",
28467
28650
  "npx",
28468
28651
  "-y",
28469
- "@use-aistack/cli",
28652
+ "@use-aistack/cli@latest",
28470
28653
  "mcp"
28471
28654
  ];
28472
28655
  var MCP_REMOVE_ARGS = ["mcp", "remove", "--scope", "user", "aistack"];
28473
- var SKILL_DEST = join13(homedir17(), ".claude", "skills", "aistack-sync");
28656
+ var SKILL_DEST = join13(homedir18(), ".claude", "skills", "aistack-sync");
28474
28657
  function runClaude(args) {
28475
28658
  const r = spawnSync("claude", args, { encoding: "utf-8" });
28476
28659
  const notFound = r.error !== void 0 && r.error.code === "ENOENT";
@@ -28593,7 +28776,7 @@ async function offerConnectUpsell(deps = {}) {
28593
28776
  return;
28594
28777
  }
28595
28778
  p3.log.message(
28596
- `If you change your mind: ${limeBold("npx @use-aistack/cli connect claude")}`
28779
+ `If you change your mind: ${limeBold("npx @use-aistack/cli@latest connect claude")}`
28597
28780
  );
28598
28781
  }
28599
28782
 
@@ -28606,7 +28789,7 @@ async function createCommand() {
28606
28789
  const token = getToken();
28607
28790
  if (!token) {
28608
28791
  p4.log.error(
28609
- `Not authenticated. Run ${limeBold("npx @use-aistack/cli login")} first.`
28792
+ `Not authenticated. Run ${limeBold("npx @use-aistack/cli@latest login")} first.`
28610
28793
  );
28611
28794
  outroError("not authenticated");
28612
28795
  process.exit(1);
@@ -28783,7 +28966,7 @@ async function loginCommand(options = {}) {
28783
28966
  process.exit(1);
28784
28967
  }
28785
28968
  p5.log.success(
28786
- `Token saved. Run ${limeBold("npx @use-aistack/cli sync")} to publish your usage.`
28969
+ `Token saved. Run ${limeBold("npx @use-aistack/cli@latest sync")} to publish your usage.`
28787
28970
  );
28788
28971
  outro2(lime("done"));
28789
28972
  }
@@ -28794,17 +28977,17 @@ import * as p7 from "@clack/prompts";
28794
28977
  // src/autosync/codexHook.ts
28795
28978
  import { createHash as createHash9 } from "node:crypto";
28796
28979
  import { existsSync as existsSync13, mkdirSync as mkdirSync4, readFileSync as readFileSync14, writeFileSync as writeFileSync4 } from "node:fs";
28797
- import { homedir as homedir18 } from "node:os";
28980
+ import { homedir as homedir19 } from "node:os";
28798
28981
  import { dirname as dirname7, join as join15 } from "node:path";
28799
28982
  import { parse } from "smol-toml";
28800
- function codexHome2() {
28801
- return process.env.CODEX_HOME || join15(homedir18(), ".codex");
28983
+ function codexHome() {
28984
+ return process.env.CODEX_HOME || join15(homedir19(), ".codex");
28802
28985
  }
28803
28986
  function codexHooksFile() {
28804
- return join15(codexHome2(), "hooks.json");
28987
+ return join15(codexHome(), "hooks.json");
28805
28988
  }
28806
28989
  function codexConfigFile() {
28807
- return join15(codexHome2(), "config.toml");
28990
+ return join15(codexHome(), "config.toml");
28808
28991
  }
28809
28992
  var CODEX_HOOK_COMMAND = `sh -c 'setsid nohup sh -c "npx -y @use-aistack/cli@latest sync --auto || npx -y --prefer-offline @use-aistack/cli sync --auto" >/dev/null 2>&1 &'`;
28810
28993
  function isOurs(entry) {
@@ -28939,14 +29122,14 @@ import * as p6 from "@clack/prompts";
28939
29122
 
28940
29123
  // src/autosync/cursorHook.ts
28941
29124
  import { existsSync as existsSync15, mkdirSync as mkdirSync6, readFileSync as readFileSync16, writeFileSync as writeFileSync6 } from "node:fs";
28942
- import { homedir as homedir20, platform as platform2 } from "node:os";
29125
+ import { homedir as homedir21, platform as platform2 } from "node:os";
28943
29126
  import { dirname as dirname9, join as join17 } from "node:path";
28944
29127
 
28945
29128
  // src/autosync/hook.ts
28946
29129
  import { existsSync as existsSync14, mkdirSync as mkdirSync5, readFileSync as readFileSync15, writeFileSync as writeFileSync5 } from "node:fs";
28947
- import { homedir as homedir19 } from "node:os";
29130
+ import { homedir as homedir20 } from "node:os";
28948
29131
  import { dirname as dirname8, join as join16 } from "node:path";
28949
- var CLAUDE_SETTINGS_FILE = join16(homedir19(), ".claude", "settings.json");
29132
+ var CLAUDE_SETTINGS_FILE = join16(homedir20(), ".claude", "settings.json");
28950
29133
  var AUTO_SYNC_HOOK_COMMAND = "npx -y @use-aistack/cli@latest sync --auto || npx -y --prefer-offline @use-aistack/cli sync --auto";
28951
29134
  function isOurs2(entry) {
28952
29135
  return typeof entry.command === "string" && entry.command.includes("@use-aistack/cli") && entry.command.includes("sync --auto");
@@ -29019,7 +29202,7 @@ function autoSyncHookInstalled(file = CLAUDE_SETTINGS_FILE) {
29019
29202
  }
29020
29203
 
29021
29204
  // src/autosync/cursorHook.ts
29022
- var CURSOR_HOOK_FILE = join17(homedir20(), ".cursor", "hooks.json");
29205
+ var CURSOR_HOOK_FILE = join17(homedir21(), ".cursor", "hooks.json");
29023
29206
  function cursorHookCommand(os = platform2()) {
29024
29207
  if (os === "win32") {
29025
29208
  const script = `Start-Process -WindowStyle Hidden -FilePath 'cmd.exe' -ArgumentList '/d /s /c "set AISTACK_HOOK_SOURCE=cursor&& (${AUTO_SYNC_HOOK_COMMAND}) <NUL >NUL 2>&1"'`;
@@ -29099,10 +29282,10 @@ import {
29099
29282
  unlinkSync as unlinkSync5,
29100
29283
  writeFileSync as writeFileSync7
29101
29284
  } from "node:fs";
29102
- import { homedir as homedir21, platform as platform3 } from "node:os";
29285
+ import { homedir as homedir22, platform as platform3 } from "node:os";
29103
29286
  import { dirname as dirname10, join as join18 } from "node:path";
29104
29287
  var GROK_HOOK_FILE = join18(
29105
- process.env.GROK_HOME || join18(homedir21(), ".grok"),
29288
+ process.env.GROK_HOME || join18(homedir22(), ".grok"),
29106
29289
  "hooks",
29107
29290
  "aistack.json"
29108
29291
  );
@@ -29204,7 +29387,7 @@ function grokAutoSyncHookInstalled(file = GROK_HOOK_FILE) {
29204
29387
  }
29205
29388
 
29206
29389
  // src/autosync/optin.ts
29207
- var NOT_LINKED = "This machine is not linked to an aistack account, and the auto-sync permission lives on your stack. Run `npx @use-aistack/cli sync` first.";
29390
+ var NOT_LINKED = "This machine is not linked to an aistack account, and the auto-sync permission lives on your stack. Run `npx @use-aistack/cli@latest sync` first.";
29208
29391
  var NOTHING_TO_TRIGGER = `No supported session on this machine in the last ${DEFAULT_WINDOW_DAYS} days, so nothing would trigger an auto-sync. Nothing was changed.`;
29209
29392
  async function enableAutoSync(frequencyHours = DEFAULT_FREQUENCY_HOURS, deps = {}) {
29210
29393
  frequencyHours = normalizeFrequencyHours(frequencyHours);
@@ -29256,7 +29439,7 @@ async function enableAutoSync(frequencyHours = DEFAULT_FREQUENCY_HOURS, deps = {
29256
29439
  return {
29257
29440
  ok: true,
29258
29441
  message: [
29259
- `Auto-sync is on. It runs about every ${frequencyHours}h when a ${harnessListLabel(detected)} ${names.has(CURSOR_HARNESS_NAME) ? "session is active" : "session starts"}. Turn it off any time: npx @use-aistack/cli sync --auto off`,
29442
+ `Auto-sync is on. It runs about every ${frequencyHours}h when a ${harnessListLabel(detected)} ${names.has(CURSOR_HARNESS_NAME) ? "session is active" : "session starts"}. Turn it off any time: npx @use-aistack/cli@latest sync --auto off`,
29260
29443
  ...trustLine ? [trustLine] : []
29261
29444
  ].join("\n")
29262
29445
  };
@@ -29443,7 +29626,7 @@ async function offerAutoSyncOptIn(deps = {}) {
29443
29626
  saveSettings({ autoSyncNeverAskAgain: true }, deps.settingsFile);
29444
29627
  }
29445
29628
  p6.log.message(
29446
- `If you change your mind: ${limeBold("npx @use-aistack/cli sync --auto on")} ${dim(
29629
+ `If you change your mind: ${limeBold("npx @use-aistack/cli@latest sync --auto on")} ${dim(
29447
29630
  "(and --auto off to revoke)"
29448
29631
  )}`
29449
29632
  );
@@ -29460,7 +29643,7 @@ import {
29460
29643
  unlinkSync as unlinkSync6,
29461
29644
  writeFileSync as writeFileSync9
29462
29645
  } from "node:fs";
29463
- import { homedir as homedir23 } from "node:os";
29646
+ import { homedir as homedir24 } from "node:os";
29464
29647
  import { dirname as dirname11, join as join19 } from "node:path";
29465
29648
 
29466
29649
  // src/sync/stage.ts
@@ -29622,7 +29805,7 @@ function selectDaysToPublish(input) {
29622
29805
  // src/workflow/git.ts
29623
29806
  import { execFile, execFileSync as execFileSync2 } from "node:child_process";
29624
29807
  import { existsSync as existsSync17 } from "node:fs";
29625
- import path14 from "node:path";
29808
+ import path15 from "node:path";
29626
29809
  var TEST_FILE_RULE_VERSION = "test-files/v2";
29627
29810
  var FILE_TYPE_RULE_VERSION = "file-types/v3";
29628
29811
  var COMMIT_SET_RULE_VERSION = "commit-set/v1";
@@ -30039,9 +30222,9 @@ function reduceGitHistories(histories, options) {
30039
30222
  if (included) seenCommits.add(hash2);
30040
30223
  continue;
30041
30224
  }
30042
- const stat9 = parseNumstat(field);
30043
- if (!stat9) continue;
30044
- let file = stat9.file;
30225
+ const stat10 = parseNumstat(field);
30226
+ if (!stat10) continue;
30227
+ let file = stat10.file;
30045
30228
  if (file.length === 0) {
30046
30229
  fieldIndex += 2;
30047
30230
  file = fields[fieldIndex] ?? fields[fieldIndex - 1] ?? "";
@@ -30049,13 +30232,13 @@ function reduceGitHistories(histories, options) {
30049
30232
  if (!current?.included) continue;
30050
30233
  if (isUnauthoredPath(file)) continue;
30051
30234
  current.authored = true;
30052
- const fileChangedLines = stat9.additions + stat9.removals;
30053
- current.additions += stat9.additions;
30054
- current.removals += stat9.removals;
30235
+ const fileChangedLines = stat10.additions + stat10.removals;
30236
+ current.additions += stat10.additions;
30237
+ current.removals += stat10.removals;
30055
30238
  current.changedLines += fileChangedLines;
30056
30239
  if (isTestFile(file)) current.touchesTest = true;
30057
30240
  if (fileChangedLines <= 0) continue;
30058
- const extension = path14.extname(file).toLowerCase();
30241
+ const extension = path15.extname(file).toLowerCase();
30059
30242
  if (APPROVED_EXTENSIONS.has(extension)) {
30060
30243
  current.extensionLines.set(
30061
30244
  extension,
@@ -30161,10 +30344,10 @@ function buildWorkflowExtraction(harnessWorkflows, git, utcOffsetMinutes = machi
30161
30344
  // src/sync/grokDateCache.ts
30162
30345
  import { createHash as createHash10 } from "node:crypto";
30163
30346
  import { existsSync as existsSync18, mkdirSync as mkdirSync8, readFileSync as readFileSync18, writeFileSync as writeFileSync8 } from "node:fs";
30164
- import { homedir as homedir22 } from "node:os";
30165
- import path15 from "node:path";
30166
- var defaultFile = path15.join(
30167
- homedir22(),
30347
+ import { homedir as homedir23 } from "node:os";
30348
+ import path16 from "node:path";
30349
+ var defaultFile = path16.join(
30350
+ homedir23(),
30168
30351
  ".config",
30169
30352
  "aistack",
30170
30353
  "grok-session-dates.json"
@@ -30187,7 +30370,7 @@ function loadGrokDateHints(scope, file = defaultFile) {
30187
30370
  function saveGrokDateHints(scope, hints, file = defaultFile) {
30188
30371
  const cache = read2(file);
30189
30372
  cache[scope] = hints;
30190
- mkdirSync8(path15.dirname(file), { recursive: true });
30373
+ mkdirSync8(path16.dirname(file), { recursive: true });
30191
30374
  writeFileSync8(file, JSON.stringify(cache, null, 2));
30192
30375
  }
30193
30376
  function mapToHints(value, floor) {
@@ -31046,9 +31229,9 @@ async function stageSync(deps) {
31046
31229
  if (historical.length === 0) {
31047
31230
  blockedReason = `No supported harness transcript from the last ${retentionDays} days to read.`;
31048
31231
  } else if (token === null) {
31049
- blockedReason = "This machine is not linked. Run `npx @use-aistack/cli login` first.";
31232
+ blockedReason = "This machine is not linked. Run `npx @use-aistack/cli@latest login` first.";
31050
31233
  } else if (config.stack === null) {
31051
- blockedReason = source === "bundled" ? "Could not fetch your settings from aistack, so the destination stack is unknown. Publish needs it. Check the network and preview again." : "This machine has no destination stack. Run `npx @use-aistack/cli sync` in an interactive terminal to choose one.";
31234
+ blockedReason = source === "bundled" ? "Could not fetch your settings from aistack, so the destination stack is unknown. Publish needs it. Check the network and preview again." : "This machine has no destination stack. Run `npx @use-aistack/cli@latest sync` in an interactive terminal to choose one.";
31052
31235
  }
31053
31236
  return {
31054
31237
  id: stageId(bodyJson),
@@ -31072,9 +31255,9 @@ function describeScan(stats) {
31072
31255
  }
31073
31256
 
31074
31257
  // src/autosync/run.ts
31075
- var SYNC_LOG_FILE = join19(homedir23(), ".config", "aistack", "sync.log");
31258
+ var SYNC_LOG_FILE = join19(homedir24(), ".config", "aistack", "sync.log");
31076
31259
  var SYNC_LOG_MAX_LINES = 200;
31077
- var FIX_COMMAND = "npx @use-aistack/cli sync";
31260
+ var FIX_COMMAND = "npx @use-aistack/cli@latest sync";
31078
31261
  var REVOKED_RESULT = "off - auto-sync is switched off for this stack";
31079
31262
  function appendLogLine(file, line) {
31080
31263
  mkdirSync9(dirname11(file), { recursive: true });
@@ -31125,7 +31308,7 @@ async function runAutoSync(deps) {
31125
31308
  const state = settings.autoSyncState ?? {};
31126
31309
  const lastRunAt = state.lastRunAt ?? 0;
31127
31310
  if (now - lastRunAt < windowMs) return;
31128
- const reservationFile = deps.reservationFile ?? `${settingsFile ?? join19(homedir23(), ".config", "aistack", "settings.json")}.auto-sync-attempt`;
31311
+ const reservationFile = deps.reservationFile ?? `${settingsFile ?? join19(homedir24(), ".config", "aistack", "settings.json")}.auto-sync-attempt`;
31129
31312
  if (!reserveAttempt(reservationFile, now, windowMs)) return;
31130
31313
  saveSettings({ autoSyncState: { ...state, lastRunAt: now } }, settingsFile);
31131
31314
  const stage = deps.stageImpl ?? stageSync;