@use-aistack/cli 0.16.9 → 0.16.10
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/cursor-worker.js +650 -235
- package/dist/cursor-worker.js.map +1 -1
- package/dist/index.js +736 -314
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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((
|
|
240
|
+
const residuePaths = [...new Set(cleanupErrors.flatMap((error) => error.details.residuePaths))].filter((path15) => !unverifiedResidueSet.has(path15)).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(
|
|
481
|
-
super(`Database is locked: ${
|
|
482
|
-
this.path =
|
|
480
|
+
constructor(path15) {
|
|
481
|
+
super(`Database is locked: ${path15}. Close Cursor or retry later.`);
|
|
482
|
+
this.path = path15;
|
|
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(
|
|
493
|
-
super(`Database not found: ${
|
|
494
|
-
this.path =
|
|
492
|
+
constructor(path15) {
|
|
493
|
+
super(`Database not found: ${path15}. Check dataPath configuration.`);
|
|
494
|
+
this.path = path15;
|
|
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(
|
|
547
|
-
super(`No workspace found for path: ${
|
|
548
|
-
this.path =
|
|
546
|
+
constructor(path15) {
|
|
547
|
+
super(`No workspace found for path: ${path15}. Please open the project in Cursor first.`);
|
|
548
|
+
this.path = path15;
|
|
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(
|
|
559
|
-
super(`Source and destination are the same: ${
|
|
560
|
-
this.path =
|
|
558
|
+
constructor(path15) {
|
|
559
|
+
super(`Source and destination are the same: ${path15}`);
|
|
560
|
+
this.path = path15;
|
|
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(
|
|
571
|
-
super(`No sessions found for workspace: ${
|
|
572
|
-
this.path =
|
|
570
|
+
constructor(path15) {
|
|
571
|
+
super(`No sessions found for workspace: ${path15}. Use 'cursor-history list --workspace "${path15}"' to verify.`);
|
|
572
|
+
this.path = path15;
|
|
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(
|
|
585
|
-
super(`Destination already has ${sessionCount} session(s): ${
|
|
586
|
-
this.path =
|
|
584
|
+
constructor(path15, sessionCount) {
|
|
585
|
+
super(`Destination already has ${sessionCount} session(s): ${path15}. Use --force to proceed (will add sessions alongside existing ones).`);
|
|
586
|
+
this.path = path15;
|
|
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(
|
|
622
|
-
super(`No Cursor data found at: ${
|
|
623
|
-
this.path =
|
|
621
|
+
constructor(path15) {
|
|
622
|
+
super(`No Cursor data found at: ${path15}. Verify Cursor is installed and has been used.`);
|
|
623
|
+
this.path = path15;
|
|
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(
|
|
634
|
-
super(`File already exists: ${
|
|
635
|
-
this.path =
|
|
633
|
+
constructor(path15) {
|
|
634
|
+
super(`File already exists: ${path15}. Use --force to overwrite.`);
|
|
635
|
+
this.path = path15;
|
|
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(
|
|
672
|
-
super(`Backup file not found: ${
|
|
673
|
-
this.path =
|
|
671
|
+
constructor(path15) {
|
|
672
|
+
super(`Backup file not found: ${path15}`);
|
|
673
|
+
this.path = path15;
|
|
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(
|
|
686
|
-
super(`Invalid backup file: ${
|
|
687
|
-
this.path =
|
|
685
|
+
constructor(path15, reason) {
|
|
686
|
+
super(`Invalid backup file: ${path15}. ${reason}`);
|
|
687
|
+
this.path = path15;
|
|
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(
|
|
699
|
-
super(`Target already has Cursor data: ${
|
|
700
|
-
this.path =
|
|
698
|
+
constructor(path15) {
|
|
699
|
+
super(`Target already has Cursor data: ${path15}. Use --force to overwrite.`);
|
|
700
|
+
this.path = path15;
|
|
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=3ee284d373d283bd4c4f5a74440096c9f1d6d5a4c9732d5d983ccdc6f10ff9f0/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
|
|
723
|
+
import { homedir as homedir9 } 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(
|
|
760
|
+
const defaultStoreRoot = join6(homedir9(), ".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(
|
|
770
|
+
return join6(process.env["APPDATA"] ?? join6(homedir9(), "AppData", "Roaming"), "Cursor", "User", "workspaceStorage");
|
|
771
771
|
case "macos":
|
|
772
|
-
return join6(
|
|
772
|
+
return join6(homedir9(), "Library", "Application Support", "Cursor", "User", "workspaceStorage");
|
|
773
773
|
case "linux":
|
|
774
|
-
return join6(
|
|
774
|
+
return join6(homedir9(), ".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(
|
|
791
|
-
if (
|
|
792
|
-
return join6(
|
|
790
|
+
function expandPath(path15) {
|
|
791
|
+
if (path15.startsWith("~")) {
|
|
792
|
+
return join6(homedir9(), path15.slice(1));
|
|
793
793
|
}
|
|
794
|
-
return
|
|
794
|
+
return path15;
|
|
795
795
|
}
|
|
796
|
-
function contractPath(
|
|
797
|
-
const home =
|
|
798
|
-
if (
|
|
799
|
-
return "~" +
|
|
796
|
+
function contractPath(path15) {
|
|
797
|
+
const home = homedir9();
|
|
798
|
+
if (path15.startsWith(home)) {
|
|
799
|
+
return "~" + path15.slice(home.length);
|
|
800
800
|
}
|
|
801
|
-
return
|
|
801
|
+
return path15;
|
|
802
802
|
}
|
|
803
803
|
function normalizePath(filePath) {
|
|
804
804
|
let normalized = filePath;
|
|
805
805
|
if (normalized.startsWith("~")) {
|
|
806
|
-
normalized = join6(
|
|
806
|
+
normalized = join6(homedir9(), 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(
|
|
911
|
+
return join6(homedir9(), ".cursor");
|
|
912
912
|
}
|
|
913
913
|
var cachedIsWsl, STORE_CHILDREN;
|
|
914
914
|
var init_platform = __esm({
|
|
@@ -1227,7 +1227,7 @@ function resolveSessionField(input, field, extrema) {
|
|
|
1227
1227
|
}, directTimes2[0].getTime());
|
|
1228
1228
|
return { value: new Date(selectedMs), source: "direct-message" };
|
|
1229
1229
|
}
|
|
1230
|
-
return { value: new Date(
|
|
1230
|
+
return { value: new Date(UNKNOWN_TIMESTAMP_EPOCH_MS2), source: "epoch-unknown" };
|
|
1231
1231
|
}
|
|
1232
1232
|
function resolveSessionTimestamps(input) {
|
|
1233
1233
|
const created = resolveSessionField(input, "createdAt", "earliest");
|
|
@@ -1242,7 +1242,7 @@ function resolveSessionTimestamps(input) {
|
|
|
1242
1242
|
function getPublicMessageTimestamp(message) {
|
|
1243
1243
|
if (!isValidTimestamp(message.timestamp)) {
|
|
1244
1244
|
return {
|
|
1245
|
-
timestamp: new Date(
|
|
1245
|
+
timestamp: new Date(UNKNOWN_TIMESTAMP_EPOCH_MS2),
|
|
1246
1246
|
timestampSource: "unknown"
|
|
1247
1247
|
};
|
|
1248
1248
|
}
|
|
@@ -1298,15 +1298,15 @@ function resolveMessageTimestamps(messages, sessionAnchor) {
|
|
|
1298
1298
|
message.timestampSource = "session-fallback";
|
|
1299
1299
|
continue;
|
|
1300
1300
|
}
|
|
1301
|
-
message.timestamp = new Date(
|
|
1301
|
+
message.timestamp = new Date(UNKNOWN_TIMESTAMP_EPOCH_MS2);
|
|
1302
1302
|
message.timestampSource = "unknown";
|
|
1303
1303
|
}
|
|
1304
1304
|
}
|
|
1305
|
-
var
|
|
1305
|
+
var UNKNOWN_TIMESTAMP_EPOCH_MS2, DIRECT_MESSAGE_TIMESTAMP_SOURCES;
|
|
1306
1306
|
var init_timestamps = __esm({
|
|
1307
1307
|
"../../node_modules/.pnpm/cursor-history@0.18.0_patch_hash=3ee284d373d283bd4c4f5a74440096c9f1d6d5a4c9732d5d983ccdc6f10ff9f0/node_modules/cursor-history/dist/core/timestamps.js"() {
|
|
1308
1308
|
"use strict";
|
|
1309
|
-
|
|
1309
|
+
UNKNOWN_TIMESTAMP_EPOCH_MS2 = 0;
|
|
1310
1310
|
DIRECT_MESSAGE_TIMESTAMP_SOURCES = /* @__PURE__ */ new Set([
|
|
1311
1311
|
"composer-created-at",
|
|
1312
1312
|
"composer-timing",
|
|
@@ -1439,8 +1439,8 @@ function normalizePublicWorkspacePath(value) {
|
|
|
1439
1439
|
return void 0;
|
|
1440
1440
|
}
|
|
1441
1441
|
}
|
|
1442
|
-
function exactComparisonKey(
|
|
1443
|
-
return
|
|
1442
|
+
function exactComparisonKey(path15) {
|
|
1443
|
+
return path15.caseInsensitive ? path15.path.toLowerCase() : path15.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(
|
|
2845
|
+
async openDatabase(path15, request2 = READ_SESSION_REQUEST) {
|
|
2846
2846
|
const driver = await this.ensureDriver(request2);
|
|
2847
|
-
return openObservedDatabase(request2.io, request2, () => driver.open(
|
|
2847
|
+
return openObservedDatabase(request2.io, request2, () => driver.open(path15, { readonly: true }));
|
|
2848
2848
|
}
|
|
2849
2849
|
/** Open a database in read-write mode. */
|
|
2850
|
-
async openDatabaseReadWrite(
|
|
2850
|
+
async openDatabaseReadWrite(path15, request2 = MIGRATION_REQUEST) {
|
|
2851
2851
|
const driver = await this.ensureDriver(request2);
|
|
2852
|
-
return openObservedDatabase(request2.io, request2, () => driver.open(
|
|
2852
|
+
return openObservedDatabase(request2.io, request2, () => driver.open(path15, { 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(
|
|
2860
|
+
openSync(path15, 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(
|
|
2864
|
+
return this.currentDriver.open(path15, 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(
|
|
3011
|
+
open(path15, 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(
|
|
3016
|
-
debugLog(`Opened database with better-sqlite3: ${
|
|
3015
|
+
const db = new BetterSqlite3(path15, { readonly: options.readonly });
|
|
3016
|
+
debugLog(`Opened database with better-sqlite3: ${path15} (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(
|
|
3207
|
+
open(path15, 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(
|
|
3212
|
-
debugLog(`Opened database with node:sqlite: ${
|
|
3211
|
+
const db = new nodeSqliteModule.DatabaseSync(path15, { readOnly: options.readonly });
|
|
3212
|
+
debugLog(`Opened database with node:sqlite: ${path15} (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=3ee284d373d283bd4c4f5a74440096c9f1d6d5a4c9732d5d983ccdc6f10ff9f0/node_modules/cursor-history/dist/core/database/index.js
|
|
3236
|
-
async function openDatabase(
|
|
3237
|
-
return registry.openDatabase(
|
|
3236
|
+
async function openDatabase(path15, request2) {
|
|
3237
|
+
return registry.openDatabase(path15, request2);
|
|
3238
3238
|
}
|
|
3239
|
-
async function openDatabaseReadWrite(
|
|
3240
|
-
return registry.openDatabaseReadWrite(
|
|
3239
|
+
async function openDatabaseReadWrite(path15, request2) {
|
|
3240
|
+
return registry.openDatabaseReadWrite(path15, 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(
|
|
3378
|
-
const descriptor = openSync(
|
|
3377
|
+
function createExclusivePrivateFile(path15, contents) {
|
|
3378
|
+
const descriptor = openSync(path15, exclusiveFlags(), 384);
|
|
3379
3379
|
try {
|
|
3380
3380
|
if (IS_PERMISSION_AWARE_POSIX)
|
|
3381
3381
|
fchmodSync(descriptor, 384);
|
|
@@ -3387,10 +3387,10 @@ function createExclusivePrivateFile(path14, contents) {
|
|
|
3387
3387
|
closeSync(descriptor);
|
|
3388
3388
|
}
|
|
3389
3389
|
}
|
|
3390
|
-
function attemptRemoveEntryNoFollow(
|
|
3390
|
+
function attemptRemoveEntryNoFollow(path15) {
|
|
3391
3391
|
let stats;
|
|
3392
3392
|
try {
|
|
3393
|
-
stats = lstatSync(
|
|
3393
|
+
stats = lstatSync(path15);
|
|
3394
3394
|
} catch (error) {
|
|
3395
3395
|
if (!isMissing(error)) {
|
|
3396
3396
|
}
|
|
@@ -3398,13 +3398,13 @@ function attemptRemoveEntryNoFollow(path14) {
|
|
|
3398
3398
|
}
|
|
3399
3399
|
if (stats.isDirectory() && !stats.isSymbolicLink()) {
|
|
3400
3400
|
try {
|
|
3401
|
-
rmdirSync(
|
|
3401
|
+
rmdirSync(path15);
|
|
3402
3402
|
} catch {
|
|
3403
3403
|
}
|
|
3404
3404
|
return;
|
|
3405
3405
|
}
|
|
3406
3406
|
try {
|
|
3407
|
-
unlinkSync(
|
|
3407
|
+
unlinkSync(path15);
|
|
3408
3408
|
} catch {
|
|
3409
3409
|
}
|
|
3410
3410
|
}
|
|
@@ -3432,9 +3432,9 @@ function attemptRemoveWorkspaceNoFollow(directoryPath) {
|
|
|
3432
3432
|
} catch {
|
|
3433
3433
|
}
|
|
3434
3434
|
}
|
|
3435
|
-
function mayStillExist(
|
|
3435
|
+
function mayStillExist(path15) {
|
|
3436
3436
|
try {
|
|
3437
|
-
lstatSync(
|
|
3437
|
+
lstatSync(path15);
|
|
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(
|
|
3735
|
-
this.path =
|
|
3734
|
+
constructor(path15, marker, markerPath, signal) {
|
|
3735
|
+
this.path = path15;
|
|
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(
|
|
3766
|
+
register(path15) {
|
|
3767
3767
|
this.assertOpen();
|
|
3768
|
-
const candidatePath = resolve(
|
|
3768
|
+
const candidatePath = resolve(path15);
|
|
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
|
|
3783
|
-
attemptRemoveEntryNoFollow(
|
|
3782
|
+
for (const path15 of tracked)
|
|
3783
|
+
attemptRemoveEntryNoFollow(path15);
|
|
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(
|
|
4807
|
-
return BoundedZipArchive.open(
|
|
4806
|
+
async function openBoundedZipArchive(path15, options) {
|
|
4807
|
+
return BoundedZipArchive.open(path15, 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(
|
|
4954
|
-
this.path =
|
|
4953
|
+
constructor(path15, entries, archiveSize, centralOffset, handle, limits, signal, io) {
|
|
4954
|
+
this.path = path15;
|
|
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(
|
|
4966
|
+
static async open(path15, 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(
|
|
4976
|
+
const handle = await open2(path15, "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(
|
|
4992
|
+
return new _BoundedZipArchive(path15, entries, archiveSize, central.offset, handle, limits, options.signal, options.io);
|
|
4993
4993
|
} catch (error) {
|
|
4994
4994
|
await handle.close();
|
|
4995
4995
|
throw error;
|
|
@@ -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: (
|
|
5576
|
+
openNoFollow: (path15) => openSync2(path15, 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: (
|
|
5579
|
+
statPathNoFollow: (path15) => projectStat(lstatSync2(path15, { bigint: true })),
|
|
5580
5580
|
close: (descriptor) => closeSync2(descriptor)
|
|
5581
5581
|
});
|
|
5582
5582
|
}
|
|
@@ -5590,9 +5590,9 @@ function errorCode(error) {
|
|
|
5590
5590
|
function hasIdentity2(stat8, expected) {
|
|
5591
5591
|
return stat8.isFile() && stat8.dev === expected.device && stat8.ino === expected.inode;
|
|
5592
5592
|
}
|
|
5593
|
-
function pathIdentityVerified(
|
|
5593
|
+
function pathIdentityVerified(path15, expected, operations) {
|
|
5594
5594
|
try {
|
|
5595
|
-
return hasIdentity2(operations.statPathNoFollow(
|
|
5595
|
+
return hasIdentity2(operations.statPathNoFollow(path15), 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: (
|
|
5647
|
-
statPathNoFollow: (
|
|
5646
|
+
unlink: (path15) => unlinkSync2(path15),
|
|
5647
|
+
statPathNoFollow: (path15) => lstatSync3(path15, { bigint: true })
|
|
5648
5648
|
});
|
|
5649
5649
|
}
|
|
5650
5650
|
});
|
|
@@ -5657,8 +5657,8 @@ function errorCode2(error) {
|
|
|
5657
5657
|
function hasIdentity3(stat8, expected) {
|
|
5658
5658
|
return stat8.isFile() && stat8.dev === expected.device && stat8.ino === expected.inode;
|
|
5659
5659
|
}
|
|
5660
|
-
function cleanupError(
|
|
5661
|
-
const error = new TemporaryArtifactCleanupError(identityVerified ? [
|
|
5660
|
+
function cleanupError(path15, cause, identityVerified = true) {
|
|
5661
|
+
const error = new TemporaryArtifactCleanupError(identityVerified ? [path15] : [], identityVerified ? [] : [path15]);
|
|
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: (
|
|
5710
|
-
statPathNoFollow: (
|
|
5709
|
+
unlink: (path15) => unlinkSync3(path15),
|
|
5710
|
+
statPathNoFollow: (path15) => lstatSync4(path15, { 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=3ee284d373d283bd4c4f5a74440096c9f1d6d5a4c9732d5d983ccdc6f10ff9f0/node_modules/cursor-history/dist/core/backup.js
|
|
5762
5762
|
import { createHash as createHash3, randomUUID } from "node:crypto";
|
|
5763
5763
|
import { chmodSync as chmodSync2, 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
|
|
5764
|
+
import { homedir as homedir10 } 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(
|
|
5804
|
+
return join8(homedir10(), "cursor-history-backups");
|
|
5805
5805
|
}
|
|
5806
5806
|
function computeChecksum(buffer) {
|
|
5807
5807
|
return `sha256:${createHash3("sha256").update(buffer).digest("hex")}`;
|
|
@@ -6075,12 +6075,12 @@ function checkDiskSpace(outputPath, requiredBytes) {
|
|
|
6075
6075
|
};
|
|
6076
6076
|
}
|
|
6077
6077
|
}
|
|
6078
|
-
function syncParentDirectory(
|
|
6078
|
+
function syncParentDirectory(path15) {
|
|
6079
6079
|
if (process.platform === "win32")
|
|
6080
6080
|
return;
|
|
6081
6081
|
let descriptor;
|
|
6082
6082
|
try {
|
|
6083
|
-
descriptor = openSync3(dirname4(
|
|
6083
|
+
descriptor = openSync3(dirname4(path15), constants3.O_RDONLY);
|
|
6084
6084
|
fsyncSync2(descriptor);
|
|
6085
6085
|
} catch {
|
|
6086
6086
|
} finally {
|
|
@@ -6092,13 +6092,13 @@ function syncParentDirectory(path14) {
|
|
|
6092
6092
|
}
|
|
6093
6093
|
}
|
|
6094
6094
|
}
|
|
6095
|
-
function removePrivateArchiveStage(
|
|
6095
|
+
function removePrivateArchiveStage(path15, operationError) {
|
|
6096
6096
|
try {
|
|
6097
|
-
unlinkSync4(
|
|
6097
|
+
unlinkSync4(path15);
|
|
6098
6098
|
} catch (error) {
|
|
6099
6099
|
if (errorCode3(error) === "ENOENT")
|
|
6100
6100
|
return;
|
|
6101
|
-
const cleanupError2 = new TemporaryArtifactCleanupError([
|
|
6101
|
+
const cleanupError2 = new TemporaryArtifactCleanupError([path15]);
|
|
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((
|
|
6365
|
+
].filter((path15) => !unverifiedResidueSet.has(path15));
|
|
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
|
|
6474
|
-
const expectedType = backupEntryTypeForCanonicalPath(
|
|
6473
|
+
const path15 = entry["path"];
|
|
6474
|
+
const expectedType = backupEntryTypeForCanonicalPath(path15);
|
|
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 =
|
|
6478
|
+
const destinationKey = path15.normalize("NFC").toLowerCase();
|
|
6479
6479
|
if (destinationKeys.has(destinationKey)) {
|
|
6480
|
-
throw new ZipArchiveFormatError(`Backup manifest contains a duplicate restore destination: ${
|
|
6480
|
+
throw new ZipArchiveFormatError(`Backup manifest contains a duplicate restore destination: ${path15}`);
|
|
6481
6481
|
}
|
|
6482
6482
|
destinationKeys.add(destinationKey);
|
|
6483
6483
|
return {
|
|
6484
|
-
path:
|
|
6484
|
+
path: path15,
|
|
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(
|
|
6502
|
-
if (
|
|
6501
|
+
function backupEntryTypeForCanonicalPath(path15) {
|
|
6502
|
+
if (path15 === "globalStorage/state.vscdb")
|
|
6503
6503
|
return "global-db";
|
|
6504
|
-
const match = /^workspaceStorage\/([^/]+)\/(state\.vscdb|workspace\.json)$/u.exec(
|
|
6504
|
+
const match = /^workspaceStorage\/([^/]+)\/(state\.vscdb|workspace\.json)$/u.exec(path15);
|
|
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:
|
|
6524
|
-
const containsGlobalDatabase = files.some(({ type, path:
|
|
6523
|
+
const expectedWorkspaceIds = files.filter(({ type }) => type === "workspace-db").map(({ path: path15 }) => /^workspaceStorage\/([^/]+)\/state\.vscdb$/u.exec(path15)?.[1]).filter((workspaceId) => workspaceId !== void 0).sort(compareCodePoints4);
|
|
6524
|
+
const containsGlobalDatabase = files.some(({ type, path: path15 }) => type === "global-db" && path15 === "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:
|
|
6680
|
+
const manifestEntry = manifestFiles.find(({ path: path15 }) => path15 === 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:
|
|
6735
|
+
const manifestEntry = validatedManifestFiles(manifest).find(({ path: path15 }) => path15 === 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(
|
|
6791
|
+
function lstatIfPresent(path15) {
|
|
6792
6792
|
try {
|
|
6793
|
-
return lstatSync5(
|
|
6793
|
+
return lstatSync5(path15);
|
|
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,
|
|
6800
|
+
function assertNoLinkedRestorePath(trustedRoot, path15, leafKind) {
|
|
6801
6801
|
const absoluteRoot = resolve2(trustedRoot);
|
|
6802
|
-
const absolutePath = resolve2(
|
|
6802
|
+
const absolutePath = resolve2(path15);
|
|
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}`);
|
|
@@ -7132,7 +7132,7 @@ async function listBackups(directory, options = {}) {
|
|
|
7132
7132
|
return backups;
|
|
7133
7133
|
}
|
|
7134
7134
|
function getDefaultCursorDataPath2() {
|
|
7135
|
-
const home =
|
|
7135
|
+
const home = homedir10();
|
|
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(
|
|
7764
|
+
async function parseStoreDb(path15, 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(
|
|
7768
|
+
if (!pathExists(path15, 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(path14, 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(
|
|
7780
|
+
await backupDatabase(path15, 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(path14, options = {}) {
|
|
|
7824
7824
|
operationError = error;
|
|
7825
7825
|
else {
|
|
7826
7826
|
options.onDiagnostic?.(error);
|
|
7827
|
-
debugLogStorage(`store.db defensive parse failed for ${
|
|
7827
|
+
debugLogStorage(`store.db defensive parse failed for ${path15}: ${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 ${
|
|
7832
|
+
debugLogStorage(`store.db source/schema parse failed for ${path15}: ${String(error)}`);
|
|
7833
7833
|
} else {
|
|
7834
7834
|
operationError = error;
|
|
7835
7835
|
}
|
|
@@ -7854,7 +7854,7 @@ async function parseStoreDb(path14, options = {}) {
|
|
|
7854
7854
|
throw operationError;
|
|
7855
7855
|
return result;
|
|
7856
7856
|
}
|
|
7857
|
-
function pathExists(
|
|
7857
|
+
function pathExists(path15, signal, io, logicalSessionId) {
|
|
7858
7858
|
throwIfAborted4(signal);
|
|
7859
7859
|
try {
|
|
7860
7860
|
if (io) {
|
|
@@ -7867,7 +7867,7 @@ function pathExists(path14, signal, io, logicalSessionId) {
|
|
|
7867
7867
|
...logicalSessionId ? { logicalSessionId } : {}
|
|
7868
7868
|
});
|
|
7869
7869
|
}
|
|
7870
|
-
statSync4(
|
|
7870
|
+
statSync4(path15);
|
|
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,
|
|
8839
|
-
return `${representation}\0${
|
|
8838
|
+
function occurrenceKey(representation, path15) {
|
|
8839
|
+
return `${representation}\0${path15}`;
|
|
8840
8840
|
}
|
|
8841
|
-
function occurrence(logicalSessionId, representation,
|
|
8841
|
+
function occurrence(logicalSessionId, representation, path15, workspacePath) {
|
|
8842
8842
|
return {
|
|
8843
|
-
instanceKey: occurrenceKey(representation,
|
|
8843
|
+
instanceKey: occurrenceKey(representation, path15),
|
|
8844
8844
|
logicalSessionId,
|
|
8845
8845
|
representation,
|
|
8846
|
-
path:
|
|
8846
|
+
path: path15,
|
|
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:
|
|
9194
|
+
if (!evidence.transcriptOccurrences.some(({ path: path15 }) => path15 === 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:
|
|
9211
|
+
if (!evidence.transcriptOccurrences.some(({ path: path15 }) => path15 === 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:
|
|
9285
|
+
let selectedDbCandidate = selectedDbTier[0] ?? dbCandidates.find(({ path: path15 }) => path15 === 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:
|
|
9499
|
+
if (!evidence.metadataOccurrences.some(({ path: path15 }) => path15 === sessionDir)) {
|
|
9500
9500
|
evidence.metadataOccurrences.push(metadataOccurrence);
|
|
9501
9501
|
}
|
|
9502
9502
|
if (dbInventoried) {
|
|
9503
9503
|
evidence.dbInventoried = true;
|
|
9504
|
-
if (!evidence.dbOccurrences.some(({ path:
|
|
9504
|
+
if (!evidence.dbOccurrences.some(({ path: path15 }) => path15 === 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(
|
|
9750
|
+
function readMeta(path15, 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(
|
|
9755
|
+
raw = readFileSync10(path15);
|
|
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(
|
|
9886
|
+
function pathExists2(path15, signal, io, resourceClass = "store-root-directory", logicalSessionId) {
|
|
9887
9887
|
throwIfAborted6(signal);
|
|
9888
9888
|
try {
|
|
9889
9889
|
observeStoreFs(io, "open", resourceClass, logicalSessionId);
|
|
9890
|
-
statSync5(
|
|
9890
|
+
statSync5(path15);
|
|
9891
9891
|
return true;
|
|
9892
9892
|
} catch (error) {
|
|
9893
9893
|
if (isAbsentOrWrongType(error))
|
|
@@ -11320,23 +11320,23 @@ function extractToolCalls(data) {
|
|
|
11320
11320
|
const params = parseToolParams2(toolData.params, toolData.rawArgs);
|
|
11321
11321
|
const status = getToolCallStatus(toolData);
|
|
11322
11322
|
const resultText = typeof toolData.result === "string" && toolData.result.trim().length > 0 ? toolData.result : void 0;
|
|
11323
|
-
const
|
|
11323
|
+
const toolCall2 = {
|
|
11324
11324
|
name,
|
|
11325
11325
|
status
|
|
11326
11326
|
};
|
|
11327
11327
|
if (params) {
|
|
11328
|
-
|
|
11328
|
+
toolCall2.params = params;
|
|
11329
11329
|
}
|
|
11330
11330
|
const files = extractToolFiles(params);
|
|
11331
11331
|
if (files) {
|
|
11332
|
-
|
|
11332
|
+
toolCall2.files = files;
|
|
11333
11333
|
}
|
|
11334
11334
|
if (status === "error" && resultText) {
|
|
11335
|
-
|
|
11335
|
+
toolCall2.error = extractToolError(resultText);
|
|
11336
11336
|
} else if (status === "completed" && resultText) {
|
|
11337
|
-
|
|
11337
|
+
toolCall2.result = resultText;
|
|
11338
11338
|
}
|
|
11339
|
-
return [
|
|
11339
|
+
return [toolCall2];
|
|
11340
11340
|
}
|
|
11341
11341
|
function mapBubbleToMessage(row) {
|
|
11342
11342
|
const corruptedMessage = () => ({
|
|
@@ -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:
|
|
11518
|
+
const containsGlobalDatabase = manifest.files.some(({ type, path: path15 }) => type === "global-db" && path15 === "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
|
|
12717
|
-
counts2.set(
|
|
12716
|
+
const path15 = normalizeWorkspacePath(candidate.workspace.path);
|
|
12717
|
+
counts2.set(path15, (counts2.get(path15) ?? 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:
|
|
13409
|
+
...composerWorkspaceInventory.map(({ path: path15 }) => path15),
|
|
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:
|
|
13675
|
+
const offScopeWorkspaces = composerWorkspaceInventory.filter(({ path: path15 }) => !workspaceFilterMatches(path15, 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
|
|
14968
|
+
const path15 = getParam(params, "path", "directory", "targetDirectory");
|
|
14969
14969
|
if (pattern)
|
|
14970
14970
|
lines2.push(`Pattern: ${pattern}`);
|
|
14971
|
-
if (
|
|
14972
|
-
lines2.push(`Path: ${
|
|
14971
|
+
if (path15)
|
|
14972
|
+
lines2.push(`Path: ${path15}`);
|
|
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");
|
|
@@ -15309,15 +15309,15 @@ function extractTimestamp(data) {
|
|
|
15309
15309
|
if (!timingInfo)
|
|
15310
15310
|
return null;
|
|
15311
15311
|
const rpc = timingInfo.clientRpcSendTime;
|
|
15312
|
-
if (typeof rpc === "number" && rpc >
|
|
15312
|
+
if (typeof rpc === "number" && rpc > MIN_VALID_UNIX_MS2) {
|
|
15313
15313
|
return new Date(rpc);
|
|
15314
15314
|
}
|
|
15315
15315
|
const settle = timingInfo.clientSettleTime;
|
|
15316
|
-
if (typeof settle === "number" && settle >
|
|
15316
|
+
if (typeof settle === "number" && settle > MIN_VALID_UNIX_MS2) {
|
|
15317
15317
|
return new Date(settle);
|
|
15318
15318
|
}
|
|
15319
15319
|
const end = timingInfo.clientEndTime;
|
|
15320
|
-
if (typeof end === "number" && end >
|
|
15320
|
+
if (typeof end === "number" && end > MIN_VALID_UNIX_MS2) {
|
|
15321
15321
|
return new Date(end);
|
|
15322
15322
|
}
|
|
15323
15323
|
return null;
|
|
@@ -15329,13 +15329,13 @@ function extractTimestampSource(data) {
|
|
|
15329
15329
|
if (!timingInfo)
|
|
15330
15330
|
return void 0;
|
|
15331
15331
|
const rpc = timingInfo.clientRpcSendTime;
|
|
15332
|
-
if (typeof rpc === "number" && rpc >
|
|
15332
|
+
if (typeof rpc === "number" && rpc > MIN_VALID_UNIX_MS2)
|
|
15333
15333
|
return "composer-timing";
|
|
15334
15334
|
const settle = timingInfo.clientSettleTime;
|
|
15335
|
-
if (typeof settle === "number" && settle >
|
|
15335
|
+
if (typeof settle === "number" && settle > MIN_VALID_UNIX_MS2)
|
|
15336
15336
|
return "composer-timing";
|
|
15337
15337
|
const end = timingInfo.clientEndTime;
|
|
15338
|
-
if (typeof end === "number" && end >
|
|
15338
|
+
if (typeof end === "number" && end > MIN_VALID_UNIX_MS2)
|
|
15339
15339
|
return "composer-timing";
|
|
15340
15340
|
return void 0;
|
|
15341
15341
|
}
|
|
@@ -15408,7 +15408,7 @@ function updateComposerData(db, composers, isNewFormat, originalRawData) {
|
|
|
15408
15408
|
const jsonValue = JSON.stringify(dataToWrite);
|
|
15409
15409
|
db.prepare("UPDATE ItemTable SET value = ? WHERE key = ?").run(jsonValue, "composer.composerData");
|
|
15410
15410
|
}
|
|
15411
|
-
var SESSION_READ_CAPABILITIES, MIGRATION_CAPABILITIES, OWNING_DATABASE_READ_FAILURES, CHAT_DATA_KEYS, PROMPTS_KEY, GENERATIONS_KEY, COMPOSER_GUID_RE2, BACKUP_COMPOSER_SESSION_IDS, BACKUP_GLOBAL_COUNTERPART_SESSION_IDS, BACKUP_LINKED_GLOBAL_SESSION_IDS, BACKUP_CONTAINS_GLOBAL_DATABASE, COUNTED_COMPOSER_SESSION_IDS, sessionReadContextPrivate, nextReadContextId, UNKNOWN_WORKSPACE_PATH, RESOLUTION_SOURCE_ROLE_ORDER, RESOLUTION_REASON_ORDER3,
|
|
15411
|
+
var SESSION_READ_CAPABILITIES, MIGRATION_CAPABILITIES, OWNING_DATABASE_READ_FAILURES, CHAT_DATA_KEYS, PROMPTS_KEY, GENERATIONS_KEY, COMPOSER_GUID_RE2, BACKUP_COMPOSER_SESSION_IDS, BACKUP_GLOBAL_COUNTERPART_SESSION_IDS, BACKUP_LINKED_GLOBAL_SESSION_IDS, BACKUP_CONTAINS_GLOBAL_DATABASE, COUNTED_COMPOSER_SESSION_IDS, sessionReadContextPrivate, nextReadContextId, UNKNOWN_WORKSPACE_PATH, RESOLUTION_SOURCE_ROLE_ORDER, RESOLUTION_REASON_ORDER3, MIN_VALID_UNIX_MS2;
|
|
15412
15412
|
var init_storage = __esm({
|
|
15413
15413
|
"../../node_modules/.pnpm/cursor-history@0.18.0_patch_hash=3ee284d373d283bd4c4f5a74440096c9f1d6d5a4c9732d5d983ccdc6f10ff9f0/node_modules/cursor-history/dist/core/storage.js"() {
|
|
15414
15414
|
"use strict";
|
|
@@ -15462,7 +15462,7 @@ var init_storage = __esm({
|
|
|
15462
15462
|
"store-db-expectation-unknown",
|
|
15463
15463
|
"store-conversation-unavailable"
|
|
15464
15464
|
];
|
|
15465
|
-
|
|
15465
|
+
MIN_VALID_UNIX_MS2 = 1e12;
|
|
15466
15466
|
}
|
|
15467
15467
|
});
|
|
15468
15468
|
|
|
@@ -15474,9 +15474,9 @@ import { pathToFileURL } from "node:url";
|
|
|
15474
15474
|
function generateSessionId() {
|
|
15475
15475
|
return randomUUID2();
|
|
15476
15476
|
}
|
|
15477
|
-
function transformPath(
|
|
15477
|
+
function transformPath(path15, sourcePrefix, destPrefix) {
|
|
15478
15478
|
const normalizedSource = sourcePrefix.replace(/\/+$/, "");
|
|
15479
|
-
const normalizedPath =
|
|
15479
|
+
const normalizedPath = path15;
|
|
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(
|
|
15596
|
-
const normalized = normalizePath(
|
|
15595
|
+
function toFileUri(path15) {
|
|
15596
|
+
const normalized = normalizePath(path15);
|
|
15597
15597
|
const windowsDrivePath = normalized.match(/^([A-Za-z]):[\\/](.*)$/);
|
|
15598
15598
|
if (windowsDrivePath) {
|
|
15599
15599
|
const drive = windowsDrivePath[1].toLowerCase();
|
|
@@ -15647,12 +15647,12 @@ function createMigrationReadGuard(limits, signal, sqliteDriver) {
|
|
|
15647
15647
|
sqliteDriver
|
|
15648
15648
|
};
|
|
15649
15649
|
}
|
|
15650
|
-
function physicalPathIdentity(label,
|
|
15651
|
-
const normalized = normalizedPathKey(
|
|
15652
|
-
if (!existsSync9(
|
|
15650
|
+
function physicalPathIdentity(label, path15) {
|
|
15651
|
+
const normalized = normalizedPathKey(path15);
|
|
15652
|
+
if (!existsSync9(path15))
|
|
15653
15653
|
return `${label}:${normalized}|missing`;
|
|
15654
15654
|
try {
|
|
15655
|
-
const stat8 = statSync6(
|
|
15655
|
+
const stat8 = statSync6(path15);
|
|
15656
15656
|
return `${label}:${normalized}|dev:${String(stat8.dev)}|ino:${String(stat8.ino)}`;
|
|
15657
15657
|
} catch {
|
|
15658
15658
|
return `${label}:${normalized}|unavailable`;
|
|
@@ -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
|
|
15805
|
-
if (!
|
|
15804
|
+
const path15 = readWorkspaceJson(workspaceDirectory);
|
|
15805
|
+
if (!path15 || !pathsEqual(path15, normalizedRequest))
|
|
15806
15806
|
continue;
|
|
15807
15807
|
return {
|
|
15808
15808
|
workspace: {
|
|
15809
15809
|
id: entry.name,
|
|
15810
|
-
path: normalizePath(
|
|
15810
|
+
path: normalizePath(path15),
|
|
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 = (
|
|
15828
|
+
const scanIds = (path15, 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, '${
|
|
15839
|
+
FROM ItemTable AS i, json_each(i.value, '${path15}') 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, '${
|
|
15858
|
+
FROM ItemTable AS i, json_each(i.value, '${path15}') 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.");
|
|
@@ -18906,13 +18906,13 @@ function apiEquivalentCost(modelKey, t, atMs) {
|
|
|
18906
18906
|
}
|
|
18907
18907
|
|
|
18908
18908
|
// src/version.ts
|
|
18909
|
-
var CLI_VERSION = true ? "0.16.
|
|
18909
|
+
var CLI_VERSION = true ? "0.16.10" : "0.0.0-dev";
|
|
18910
18910
|
|
|
18911
18911
|
// src/api.ts
|
|
18912
18912
|
var BASE_URL = process.env.AISTACK_URL || "https://aistack.to";
|
|
18913
18913
|
var STARTUP_READ_TIMEOUT_MS = 5e3;
|
|
18914
|
-
async function request(
|
|
18915
|
-
return fetch(`${BASE_URL}${
|
|
18914
|
+
async function request(path15, options = {}) {
|
|
18915
|
+
return fetch(`${BASE_URL}${path15}`, {
|
|
18916
18916
|
...options,
|
|
18917
18917
|
headers: {
|
|
18918
18918
|
"Content-Type": "application/json",
|
|
@@ -19343,9 +19343,9 @@ function canonicalizeRepoUrl(input) {
|
|
|
19343
19343
|
function repoNameFromCanonical(canonical) {
|
|
19344
19344
|
return parseRepo(canonical)?.repo ?? "";
|
|
19345
19345
|
}
|
|
19346
|
-
function normalizeUpstreamPath(
|
|
19347
|
-
if (!
|
|
19348
|
-
return
|
|
19346
|
+
function normalizeUpstreamPath(path15) {
|
|
19347
|
+
if (!path15) return "";
|
|
19348
|
+
return path15.split("/").filter(Boolean).join("/");
|
|
19349
19349
|
}
|
|
19350
19350
|
|
|
19351
19351
|
// src/git.ts
|
|
@@ -19391,16 +19391,16 @@ function buildRepoLinkResource(canonical) {
|
|
|
19391
19391
|
import { existsSync as existsSync2, readFileSync as readFileSync2 } from "node:fs";
|
|
19392
19392
|
import { homedir as homedir2 } from "node:os";
|
|
19393
19393
|
import { join as join2 } from "node:path";
|
|
19394
|
-
function readJson(
|
|
19394
|
+
function readJson(path15) {
|
|
19395
19395
|
try {
|
|
19396
|
-
if (!existsSync2(
|
|
19397
|
-
return JSON.parse(readFileSync2(
|
|
19396
|
+
if (!existsSync2(path15)) return null;
|
|
19397
|
+
return JSON.parse(readFileSync2(path15, "utf-8"));
|
|
19398
19398
|
} catch {
|
|
19399
19399
|
return null;
|
|
19400
19400
|
}
|
|
19401
19401
|
}
|
|
19402
|
-
function hooksFrom(
|
|
19403
|
-
const hooks = readJson(
|
|
19402
|
+
function hooksFrom(path15, source, out, seen) {
|
|
19403
|
+
const hooks = readJson(path15)?.hooks;
|
|
19404
19404
|
if (!hooks || typeof hooks !== "object") return;
|
|
19405
19405
|
for (const [event, config] of Object.entries(hooks)) {
|
|
19406
19406
|
const stableKey = `hooks:${source}:${event}`;
|
|
@@ -19549,16 +19549,16 @@ function buildMcpResource(name, group, pkg) {
|
|
|
19549
19549
|
pkg
|
|
19550
19550
|
};
|
|
19551
19551
|
}
|
|
19552
|
-
function readText(
|
|
19552
|
+
function readText(path15) {
|
|
19553
19553
|
try {
|
|
19554
|
-
if (!existsSync3(
|
|
19555
|
-
return readFileSync3(
|
|
19554
|
+
if (!existsSync3(path15)) return null;
|
|
19555
|
+
return readFileSync3(path15, "utf-8");
|
|
19556
19556
|
} catch {
|
|
19557
19557
|
return null;
|
|
19558
19558
|
}
|
|
19559
19559
|
}
|
|
19560
|
-
function readParsed(
|
|
19561
|
-
const raw = readText(
|
|
19560
|
+
function readParsed(path15, parse2) {
|
|
19561
|
+
const raw = readText(path15);
|
|
19562
19562
|
if (raw === null) return null;
|
|
19563
19563
|
try {
|
|
19564
19564
|
return parse2(raw);
|
|
@@ -19566,14 +19566,14 @@ function readParsed(path14, parse2) {
|
|
|
19566
19566
|
return null;
|
|
19567
19567
|
}
|
|
19568
19568
|
}
|
|
19569
|
-
function readJson2(
|
|
19570
|
-
return readParsed(
|
|
19569
|
+
function readJson2(path15) {
|
|
19570
|
+
return readParsed(path15, JSON.parse);
|
|
19571
19571
|
}
|
|
19572
|
-
function readYaml(
|
|
19573
|
-
return readParsed(
|
|
19572
|
+
function readYaml(path15) {
|
|
19573
|
+
return readParsed(path15, parseYaml);
|
|
19574
19574
|
}
|
|
19575
|
-
function readToml(
|
|
19576
|
-
return readParsed(
|
|
19575
|
+
function readToml(path15) {
|
|
19576
|
+
return readParsed(path15, parseToml);
|
|
19577
19577
|
}
|
|
19578
19578
|
function continueListToMap(file) {
|
|
19579
19579
|
if (!file?.mcpServers?.length) return void 0;
|
|
@@ -19712,8 +19712,8 @@ function resolveSource(entry, mpRepoUrl) {
|
|
|
19712
19712
|
const src = entry.source;
|
|
19713
19713
|
if (typeof src === "string") {
|
|
19714
19714
|
if (!mpRepoUrl) return null;
|
|
19715
|
-
const
|
|
19716
|
-
return { url: mpRepoUrl, path:
|
|
19715
|
+
const path15 = src.replace(/^\.\//, "").replace(/\/+$/, "");
|
|
19716
|
+
return { url: mpRepoUrl, path: path15 || void 0 };
|
|
19717
19717
|
}
|
|
19718
19718
|
if (src && typeof src === "object" && src.url) {
|
|
19719
19719
|
return { url: src.url, path: src.path, sha: src.sha };
|
|
@@ -19750,10 +19750,10 @@ function resolvePluginLinks(installed, marketplaces, manifests) {
|
|
|
19750
19750
|
}
|
|
19751
19751
|
return out;
|
|
19752
19752
|
}
|
|
19753
|
-
function readJson3(
|
|
19753
|
+
function readJson3(path15) {
|
|
19754
19754
|
try {
|
|
19755
|
-
if (!existsSync4(
|
|
19756
|
-
return JSON.parse(readFileSync4(
|
|
19755
|
+
if (!existsSync4(path15)) return null;
|
|
19756
|
+
return JSON.parse(readFileSync4(path15, "utf-8"));
|
|
19757
19757
|
} catch {
|
|
19758
19758
|
return null;
|
|
19759
19759
|
}
|
|
@@ -20387,7 +20387,7 @@ function diffResources(current, existing) {
|
|
|
20387
20387
|
// src/commands/connect.ts
|
|
20388
20388
|
import { spawnSync } from "node:child_process";
|
|
20389
20389
|
import { cpSync, existsSync as existsSync11 } from "node:fs";
|
|
20390
|
-
import { homedir as
|
|
20390
|
+
import { homedir as homedir17 } from "node:os";
|
|
20391
20391
|
import { dirname as dirname5, join as join13 } from "node:path";
|
|
20392
20392
|
import { fileURLToPath } from "node:url";
|
|
20393
20393
|
import * as p3 from "@clack/prompts";
|
|
@@ -24349,14 +24349,73 @@ var codexAdapter = {
|
|
|
24349
24349
|
};
|
|
24350
24350
|
|
|
24351
24351
|
// src/harness/cursor/cache.ts
|
|
24352
|
-
import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
|
|
24353
|
-
import { homedir as
|
|
24354
|
-
import
|
|
24352
|
+
import { mkdir as mkdir2, readFile as readFile2, rename as rename2, writeFile as writeFile2 } from "node:fs/promises";
|
|
24353
|
+
import { homedir as homedir12 } from "node:os";
|
|
24354
|
+
import path6 from "node:path";
|
|
24355
24355
|
|
|
24356
24356
|
// src/harness/cursor/account.ts
|
|
24357
24357
|
import { createHash as createHash6 } from "node:crypto";
|
|
24358
24358
|
|
|
24359
24359
|
// src/harness/cursor/evidence.ts
|
|
24360
|
+
var TOOL_PARAM_KEYS = ["command", "cmd", "skill", "subagent_type"];
|
|
24361
|
+
function slimSession(session) {
|
|
24362
|
+
const messages = session.messages.map((message) => {
|
|
24363
|
+
const slim = {
|
|
24364
|
+
role: message.role,
|
|
24365
|
+
contentLength: message.content?.length ?? 0,
|
|
24366
|
+
timestamp: message.timestamp
|
|
24367
|
+
};
|
|
24368
|
+
if (message.id !== void 0) slim.id = message.id;
|
|
24369
|
+
if (message.identityOrigin !== void 0)
|
|
24370
|
+
slim.identityOrigin = message.identityOrigin;
|
|
24371
|
+
if (message.parentMessageId !== void 0)
|
|
24372
|
+
slim.parentMessageId = message.parentMessageId;
|
|
24373
|
+
if (message.isSidechain !== void 0)
|
|
24374
|
+
slim.isSidechain = message.isSidechain;
|
|
24375
|
+
if (message.timestampSource !== void 0)
|
|
24376
|
+
slim.timestampSource = message.timestampSource;
|
|
24377
|
+
if (message.model !== void 0) slim.model = message.model;
|
|
24378
|
+
if (message.metadata?.corrupted !== void 0)
|
|
24379
|
+
slim.metadata = { corrupted: message.metadata.corrupted };
|
|
24380
|
+
if (message.toolCalls)
|
|
24381
|
+
slim.toolCalls = message.toolCalls.map((call) => {
|
|
24382
|
+
const out2 = { name: call.name };
|
|
24383
|
+
if (call.id !== void 0) out2.id = call.id;
|
|
24384
|
+
if (call.identityOrigin !== void 0)
|
|
24385
|
+
out2.identityOrigin = call.identityOrigin;
|
|
24386
|
+
if (call.params)
|
|
24387
|
+
for (const key2 of TOOL_PARAM_KEYS) {
|
|
24388
|
+
const value = call.params[key2];
|
|
24389
|
+
if (typeof value !== "string") continue;
|
|
24390
|
+
out2.params ??= {};
|
|
24391
|
+
out2.params[key2] = value;
|
|
24392
|
+
}
|
|
24393
|
+
return out2;
|
|
24394
|
+
});
|
|
24395
|
+
return slim;
|
|
24396
|
+
});
|
|
24397
|
+
const out = {
|
|
24398
|
+
id: session.id,
|
|
24399
|
+
timestamp: session.timestamp,
|
|
24400
|
+
messages
|
|
24401
|
+
};
|
|
24402
|
+
if (session.createdAtSource !== void 0)
|
|
24403
|
+
out.createdAtSource = session.createdAtSource;
|
|
24404
|
+
if (session.lastUpdatedAtSource !== void 0)
|
|
24405
|
+
out.lastUpdatedAtSource = session.lastUpdatedAtSource;
|
|
24406
|
+
if (session.resolutionState !== void 0)
|
|
24407
|
+
out.resolutionState = session.resolutionState;
|
|
24408
|
+
if (session.canonicalWorkspacePath !== void 0)
|
|
24409
|
+
out.canonicalWorkspacePath = session.canonicalWorkspacePath;
|
|
24410
|
+
if (session.metadata) {
|
|
24411
|
+
out.metadata = {};
|
|
24412
|
+
if (session.metadata.cursorVersion !== void 0)
|
|
24413
|
+
out.metadata.cursorVersion = session.metadata.cursorVersion;
|
|
24414
|
+
if (session.metadata.lastModified !== void 0)
|
|
24415
|
+
out.metadata.lastModified = session.metadata.lastModified;
|
|
24416
|
+
}
|
|
24417
|
+
return out;
|
|
24418
|
+
}
|
|
24360
24419
|
function timestamp(value) {
|
|
24361
24420
|
const n = typeof value === "number" ? value : typeof value === "string" ? /^\d+$/.test(value) ? Number(value) : Date.parse(value) : NaN;
|
|
24362
24421
|
return Number.isFinite(n) && n > 0 && n < 864e13 ? n : null;
|
|
@@ -24467,9 +24526,9 @@ function localContributions(local, api = []) {
|
|
|
24467
24526
|
const input = own.input !== void 0 ? own : user;
|
|
24468
24527
|
const buckets = {
|
|
24469
24528
|
...own,
|
|
24470
|
-
input: input.input ?? (pending ? Math.ceil(pending.
|
|
24529
|
+
input: input.input ?? (pending ? Math.ceil(pending.contentLength / 4) : void 0),
|
|
24471
24530
|
inputSource: input.inputSource ?? (pending ? "text" : void 0),
|
|
24472
|
-
output: own.output ?? Math.ceil(message.
|
|
24531
|
+
output: own.output ?? Math.ceil(message.contentLength / 4),
|
|
24473
24532
|
outputSource: own.outputSource ?? "text"
|
|
24474
24533
|
};
|
|
24475
24534
|
pending = void 0;
|
|
@@ -24500,16 +24559,290 @@ function reconcile(local, api) {
|
|
|
24500
24559
|
// src/harness/cursor/local.ts
|
|
24501
24560
|
import { existsSync as existsSync10 } from "node:fs";
|
|
24502
24561
|
import { stat as stat4 } from "node:fs/promises";
|
|
24503
|
-
import { homedir as
|
|
24504
|
-
import
|
|
24562
|
+
import { homedir as homedir11 } from "node:os";
|
|
24563
|
+
import path5 from "node:path";
|
|
24505
24564
|
import { Worker } from "node:worker_threads";
|
|
24506
|
-
|
|
24507
|
-
|
|
24508
|
-
|
|
24509
|
-
|
|
24565
|
+
|
|
24566
|
+
// src/harness/cursor/composer.ts
|
|
24567
|
+
var MIN_VALID_UNIX_MS = 1e12;
|
|
24568
|
+
var UNKNOWN_TIMESTAMP_EPOCH_MS = 0;
|
|
24569
|
+
var TOOL_PARAM_KEYS2 = ["command", "cmd", "skill", "subagent_type"];
|
|
24570
|
+
function storedDate(value) {
|
|
24571
|
+
if (typeof value !== "string" && typeof value !== "number") return null;
|
|
24572
|
+
const normalized = typeof value === "string" && /^\d+$/.test(value.trim()) ? Number(value.trim()) : value;
|
|
24573
|
+
const ms = new Date(normalized).getTime();
|
|
24574
|
+
return Number.isFinite(ms) ? ms : null;
|
|
24575
|
+
}
|
|
24576
|
+
function bubbleTime(data) {
|
|
24577
|
+
if (data.createdAt) {
|
|
24578
|
+
const ms = new Date(data.createdAt).getTime();
|
|
24579
|
+
return { ms, source: "composer-created-at" };
|
|
24580
|
+
}
|
|
24581
|
+
const timing = asObj(data.timingInfo);
|
|
24582
|
+
if (!timing) return null;
|
|
24583
|
+
for (const field of [
|
|
24584
|
+
"clientRpcSendTime",
|
|
24585
|
+
"clientSettleTime",
|
|
24586
|
+
"clientEndTime"
|
|
24587
|
+
]) {
|
|
24588
|
+
const value = timing[field];
|
|
24589
|
+
if (typeof value === "number" && value > MIN_VALID_UNIX_MS)
|
|
24590
|
+
return { ms: value, source: "composer-timing" };
|
|
24591
|
+
}
|
|
24592
|
+
return null;
|
|
24593
|
+
}
|
|
24594
|
+
function contentLength(data) {
|
|
24595
|
+
let length = 0;
|
|
24596
|
+
for (const key2 of ["text", "content", "finalText", "message", "markdown"]) {
|
|
24597
|
+
const value = data[key2];
|
|
24598
|
+
if (typeof value === "string" && value.trim().length > 0) {
|
|
24599
|
+
length = value.length;
|
|
24600
|
+
break;
|
|
24601
|
+
}
|
|
24602
|
+
}
|
|
24603
|
+
if (Array.isArray(data.codeBlocks))
|
|
24604
|
+
for (const block of data.codeBlocks) {
|
|
24605
|
+
const content = asObj(block)?.content;
|
|
24606
|
+
if (typeof content === "string") length += content.length;
|
|
24607
|
+
}
|
|
24608
|
+
return length;
|
|
24609
|
+
}
|
|
24610
|
+
function toolCall(data) {
|
|
24611
|
+
const tool = asObj(data.toolFormerData);
|
|
24612
|
+
const name = typeof tool?.name === "string" ? tool.name.trim() : "";
|
|
24613
|
+
if (!name) return void 0;
|
|
24614
|
+
const call = { name };
|
|
24615
|
+
const raw = tool?.params ?? tool?.rawArgs;
|
|
24616
|
+
if (typeof raw === "string" && raw.trim().length > 0) {
|
|
24617
|
+
let params;
|
|
24618
|
+
try {
|
|
24619
|
+
params = asObj(JSON.parse(raw)) ?? void 0;
|
|
24620
|
+
} catch {
|
|
24621
|
+
}
|
|
24622
|
+
if (params)
|
|
24623
|
+
for (const key2 of TOOL_PARAM_KEYS2) {
|
|
24624
|
+
const value = params[key2];
|
|
24625
|
+
if (typeof value !== "string") continue;
|
|
24626
|
+
call.params ??= {};
|
|
24627
|
+
call.params[key2] = value;
|
|
24628
|
+
}
|
|
24629
|
+
}
|
|
24630
|
+
return call;
|
|
24631
|
+
}
|
|
24632
|
+
var isValid = (ms) => typeof ms === "number" && Number.isFinite(ms);
|
|
24633
|
+
function resolveTimes(direct, sessionCreatedMs) {
|
|
24634
|
+
const out = direct.map(
|
|
24635
|
+
(d) => d && isValid(d.ms) && d.source ? { ms: d.ms, source: d.source } : void 0
|
|
24636
|
+
);
|
|
24637
|
+
let next;
|
|
24638
|
+
for (let i = out.length - 1; i >= 0; i--) {
|
|
24639
|
+
const d = out[i];
|
|
24640
|
+
if (d) {
|
|
24641
|
+
next = d.ms;
|
|
24642
|
+
continue;
|
|
24643
|
+
}
|
|
24644
|
+
if (next !== void 0) out[i] = { ms: next, source: "inferred-next" };
|
|
24645
|
+
}
|
|
24646
|
+
let previous;
|
|
24647
|
+
for (let i = 0; i < out.length; i++) {
|
|
24648
|
+
const d = out[i];
|
|
24649
|
+
if (d && d.source !== "inferred-next") {
|
|
24650
|
+
previous = d.ms;
|
|
24651
|
+
continue;
|
|
24652
|
+
}
|
|
24653
|
+
if (d) continue;
|
|
24654
|
+
if (previous !== void 0)
|
|
24655
|
+
out[i] = { ms: previous, source: "inferred-previous" };
|
|
24656
|
+
else if (sessionCreatedMs !== null)
|
|
24657
|
+
out[i] = { ms: sessionCreatedMs, source: "session-fallback" };
|
|
24658
|
+
else out[i] = { ms: UNKNOWN_TIMESTAMP_EPOCH_MS, source: "unknown" };
|
|
24659
|
+
}
|
|
24660
|
+
return out;
|
|
24661
|
+
}
|
|
24662
|
+
function readComposerSession(db, summary, signal) {
|
|
24663
|
+
const id = summary.id;
|
|
24664
|
+
const tokens = /* @__PURE__ */ new Map();
|
|
24665
|
+
const messages = [];
|
|
24666
|
+
const direct = [];
|
|
24667
|
+
for (const row of db.bubbles.iterate(`bubbleId:${id}:`, `bubbleId:${id};`)) {
|
|
24668
|
+
signal?.throwIfAborted();
|
|
24669
|
+
const key2 = String(row.key);
|
|
24670
|
+
const fallbackId = key2.slice(`bubbleId:${id}:`.length);
|
|
24671
|
+
let data = null;
|
|
24672
|
+
if (typeof row.value === "string") {
|
|
24673
|
+
try {
|
|
24674
|
+
data = asObj(JSON.parse(row.value));
|
|
24675
|
+
} catch {
|
|
24676
|
+
data = null;
|
|
24677
|
+
}
|
|
24678
|
+
}
|
|
24679
|
+
if (!data) {
|
|
24680
|
+
messages.push({
|
|
24681
|
+
id: fallbackId,
|
|
24682
|
+
identityOrigin: "composer-native",
|
|
24683
|
+
role: "assistant",
|
|
24684
|
+
contentLength: "[corrupted message]".length,
|
|
24685
|
+
timestamp: "",
|
|
24686
|
+
metadata: { corrupted: true }
|
|
24687
|
+
});
|
|
24688
|
+
direct.push(null);
|
|
24689
|
+
continue;
|
|
24690
|
+
}
|
|
24691
|
+
const bubbleId = asStr(data.bubbleId);
|
|
24692
|
+
const message = {
|
|
24693
|
+
id: bubbleId ?? fallbackId,
|
|
24694
|
+
identityOrigin: "composer-native",
|
|
24695
|
+
role: data.type === 2 ? "assistant" : "user",
|
|
24696
|
+
contentLength: contentLength(data),
|
|
24697
|
+
timestamp: ""
|
|
24698
|
+
};
|
|
24699
|
+
const model = asStr(asObj(data.modelInfo)?.modelName);
|
|
24700
|
+
if (model?.trim()) message.model = model;
|
|
24701
|
+
const call = toolCall(data);
|
|
24702
|
+
if (call) message.toolCalls = [call];
|
|
24703
|
+
messages.push(message);
|
|
24704
|
+
direct.push(bubbleTime(data));
|
|
24705
|
+
tokens.set(message.id, tokenEvidence(data));
|
|
24706
|
+
}
|
|
24707
|
+
if (messages.length === 0) return null;
|
|
24708
|
+
const stored = db.composer.get(`composerData:${id}`);
|
|
24709
|
+
const createdStored = storedDate(stored?.createdAt) ?? (summary.createdAtSource === "composer-metadata" ? storedDate(summary.timestamp) : null);
|
|
24710
|
+
const updatedStored = storedDate(stored?.lastUpdatedAt) ?? storedDate(stored?.updatedAt) ?? (summary.lastUpdatedAtSource === "composer-metadata" ? storedDate(summary.metadata?.lastModified) : null);
|
|
24711
|
+
const directMs = direct.flatMap((d) => d && isValid(d.ms) ? [d.ms] : []);
|
|
24712
|
+
const created = createdStored !== null ? { ms: createdStored, source: "composer-metadata" } : directMs.length ? { ms: Math.min(...directMs), source: "direct-message" } : { ms: UNKNOWN_TIMESTAMP_EPOCH_MS, source: "epoch-unknown" };
|
|
24713
|
+
const updated = updatedStored !== null ? { ms: updatedStored, source: "composer-metadata" } : directMs.length ? { ms: Math.max(...directMs), source: "direct-message" } : { ms: UNKNOWN_TIMESTAMP_EPOCH_MS, source: "epoch-unknown" };
|
|
24714
|
+
const times = resolveTimes(
|
|
24715
|
+
direct,
|
|
24716
|
+
created.source === "epoch-unknown" ? null : created.ms
|
|
24717
|
+
);
|
|
24718
|
+
for (const [i, message] of messages.entries()) {
|
|
24719
|
+
message.timestamp = new Date(times[i].ms).toISOString();
|
|
24720
|
+
message.timestampSource = times[i].source;
|
|
24721
|
+
}
|
|
24722
|
+
const header = db.header.get(`composerData:${id}`);
|
|
24723
|
+
if (typeof header?.conversation === "string") {
|
|
24724
|
+
try {
|
|
24725
|
+
const conversation = JSON.parse(header.conversation);
|
|
24726
|
+
if (Array.isArray(conversation))
|
|
24727
|
+
for (const [index, raw] of conversation.entries()) {
|
|
24728
|
+
const obj = asObj(raw);
|
|
24729
|
+
const bubble = asStr(obj?.bubbleId) ?? asStr(obj?.id) ?? `msg:${index}`;
|
|
24730
|
+
if (!tokens.has(bubble)) tokens.set(bubble, tokenEvidence(raw));
|
|
24731
|
+
}
|
|
24732
|
+
} catch {
|
|
24733
|
+
}
|
|
24734
|
+
}
|
|
24735
|
+
const session = {
|
|
24736
|
+
id,
|
|
24737
|
+
timestamp: new Date(created.ms).toISOString(),
|
|
24738
|
+
createdAtSource: created.source,
|
|
24739
|
+
lastUpdatedAtSource: updated.source,
|
|
24740
|
+
resolutionState: "complete",
|
|
24741
|
+
messages,
|
|
24742
|
+
metadata: { lastModified: new Date(updated.ms).toISOString() }
|
|
24743
|
+
};
|
|
24744
|
+
if (summary.canonicalWorkspacePath !== void 0)
|
|
24745
|
+
session.canonicalWorkspacePath = summary.canonicalWorkspacePath;
|
|
24746
|
+
if (summary.metadata?.cursorVersion !== void 0)
|
|
24747
|
+
session.metadata = {
|
|
24748
|
+
...session.metadata,
|
|
24749
|
+
cursorVersion: summary.metadata.cursorVersion
|
|
24750
|
+
};
|
|
24751
|
+
return { session, tokens };
|
|
24752
|
+
}
|
|
24753
|
+
function hasComposerHalf(summary) {
|
|
24754
|
+
if (summary.resolutionState === "ambiguous") return false;
|
|
24755
|
+
const sources = summary.sources;
|
|
24756
|
+
return Array.isArray(sources) ? sources.includes("composer") : true;
|
|
24757
|
+
}
|
|
24758
|
+
|
|
24759
|
+
// src/harness/cursor/sessionCache.ts
|
|
24760
|
+
import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
|
|
24761
|
+
import { homedir as homedir8 } from "node:os";
|
|
24762
|
+
import path4 from "node:path";
|
|
24763
|
+
import { gunzipSync, gzipSync } from "node:zlib";
|
|
24764
|
+
var SESSION_CACHE_FORMAT = 1;
|
|
24765
|
+
var defaultSessionCacheDir = () => path4.join(homedir8(), ".config", "aistack", "cursor");
|
|
24766
|
+
var sessionCacheFile = (dir, root, store) => path4.join(dir, `${digest(`${root}\0${store}`)}.sessions.json.gz`);
|
|
24767
|
+
function sessionStamp(summary, newest) {
|
|
24768
|
+
if (newest === null) return null;
|
|
24769
|
+
const count2 = summary.messageCount;
|
|
24770
|
+
const sources = summary.sources;
|
|
24771
|
+
return JSON.stringify([
|
|
24772
|
+
newest,
|
|
24773
|
+
typeof count2 === "number" ? count2 : null,
|
|
24774
|
+
Array.isArray(sources) ? sources : null,
|
|
24775
|
+
summary.resolutionState ?? null
|
|
24776
|
+
]);
|
|
24777
|
+
}
|
|
24778
|
+
function cacheable(local) {
|
|
24779
|
+
return local.session.resolutionState === "complete" && !local.session.messages.some((m) => m.metadata?.corrupted);
|
|
24780
|
+
}
|
|
24781
|
+
function toEntry(stamp, local) {
|
|
24782
|
+
return {
|
|
24783
|
+
stamp,
|
|
24784
|
+
session: local.session,
|
|
24785
|
+
tokens: Object.fromEntries(local.tokens)
|
|
24786
|
+
};
|
|
24787
|
+
}
|
|
24788
|
+
function fromEntry(entry) {
|
|
24789
|
+
return {
|
|
24790
|
+
session: entry.session,
|
|
24791
|
+
tokens: new Map(Object.entries(entry.tokens))
|
|
24792
|
+
};
|
|
24793
|
+
}
|
|
24794
|
+
function validEntry(value) {
|
|
24795
|
+
const entry = asObj(value);
|
|
24796
|
+
const session = asObj(entry?.session);
|
|
24797
|
+
return !!entry && typeof entry.stamp === "string" && !!session && typeof session.id === "string" && typeof session.timestamp === "string" && Array.isArray(session.messages) && session.messages.every((m) => {
|
|
24798
|
+
const message = asObj(m);
|
|
24799
|
+
return !!message && (message.role === "user" || message.role === "assistant") && typeof message.contentLength === "number" && typeof message.timestamp === "string";
|
|
24800
|
+
}) && !!asObj(entry.tokens);
|
|
24510
24801
|
}
|
|
24511
|
-
|
|
24512
|
-
|
|
24802
|
+
async function loadSessionCache(file) {
|
|
24803
|
+
const out = /* @__PURE__ */ new Map();
|
|
24804
|
+
let raw;
|
|
24805
|
+
try {
|
|
24806
|
+
raw = gunzipSync(await readFile(file)).toString("utf8");
|
|
24807
|
+
} catch (error) {
|
|
24808
|
+
if (error.code !== "ENOENT")
|
|
24809
|
+
traceError("cursor session cache read", error, "warn");
|
|
24810
|
+
return out;
|
|
24811
|
+
}
|
|
24812
|
+
try {
|
|
24813
|
+
const parsed = asObj(JSON.parse(raw));
|
|
24814
|
+
if (parsed?.format !== SESSION_CACHE_FORMAT) return out;
|
|
24815
|
+
const entries = asObj(parsed.sessions);
|
|
24816
|
+
if (!entries) return out;
|
|
24817
|
+
for (const [id, entry] of Object.entries(entries))
|
|
24818
|
+
if (validEntry(entry) && entry.session.id === id) out.set(id, entry);
|
|
24819
|
+
} catch (error) {
|
|
24820
|
+
traceError("cursor session cache read", error, "warn");
|
|
24821
|
+
out.clear();
|
|
24822
|
+
}
|
|
24823
|
+
return out;
|
|
24824
|
+
}
|
|
24825
|
+
async function saveSessionCache(file, cache) {
|
|
24826
|
+
await mkdir(path4.dirname(file), { recursive: true, mode: 448 });
|
|
24827
|
+
const body = gzipSync(
|
|
24828
|
+
JSON.stringify({
|
|
24829
|
+
format: SESSION_CACHE_FORMAT,
|
|
24830
|
+
sessions: Object.fromEntries(cache)
|
|
24831
|
+
})
|
|
24832
|
+
);
|
|
24833
|
+
const temporary = `${file}.${process.pid}.${Date.now()}.tmp`;
|
|
24834
|
+
await writeFile(temporary, body, { mode: 384 });
|
|
24835
|
+
await rename(temporary, file);
|
|
24836
|
+
}
|
|
24837
|
+
|
|
24838
|
+
// src/harness/cursor/local.ts
|
|
24839
|
+
function dataPath(env = process.env, home = homedir11(), platform4 = process.platform) {
|
|
24840
|
+
if (env.CURSOR_DATA_PATH) return path5.resolve(env.CURSOR_DATA_PATH);
|
|
24841
|
+
const base = platform4 === "darwin" ? path5.join(home, "Library", "Application Support") : platform4 === "win32" ? env.APPDATA || path5.join(home, "AppData", "Roaming") : env.XDG_CONFIG_HOME || path5.join(home, ".config");
|
|
24842
|
+
return path5.join(base, "Cursor", "User", "workspaceStorage");
|
|
24843
|
+
}
|
|
24844
|
+
var storeRoot = () => process.env.CURSOR_STORE_ROOT || path5.join(homedir11(), ".cursor");
|
|
24845
|
+
var globalDb = (root) => path5.join(path5.dirname(root), "globalStorage", "state.vscdb");
|
|
24513
24846
|
async function exists3(file) {
|
|
24514
24847
|
try {
|
|
24515
24848
|
await stat4(file);
|
|
@@ -24523,9 +24856,9 @@ async function hasLocalSource(root = dataPath()) {
|
|
|
24523
24856
|
[
|
|
24524
24857
|
root,
|
|
24525
24858
|
globalDb(root),
|
|
24526
|
-
|
|
24527
|
-
|
|
24528
|
-
|
|
24859
|
+
path5.join(storeRoot(), "projects"),
|
|
24860
|
+
path5.join(storeRoot(), "chats"),
|
|
24861
|
+
path5.join(storeRoot(), "acp-sessions")
|
|
24529
24862
|
].map(exists3)
|
|
24530
24863
|
)).some(Boolean);
|
|
24531
24864
|
}
|
|
@@ -24553,6 +24886,16 @@ async function openEvidenceDb(root) {
|
|
|
24553
24886
|
header: db.prepare(
|
|
24554
24887
|
"SELECT json_extract(value, '$.conversation') AS conversation FROM cursorDiskKV WHERE key = ?"
|
|
24555
24888
|
),
|
|
24889
|
+
// One session's bubbles are one key range; insertion order is the
|
|
24890
|
+
// conversation order, as cursor-history reads them.
|
|
24891
|
+
bubbles: db.prepare(
|
|
24892
|
+
"SELECT key, value FROM cursorDiskKV WHERE key >= ? AND key < ? ORDER BY rowid"
|
|
24893
|
+
),
|
|
24894
|
+
composer: db.prepare(`SELECT
|
|
24895
|
+
json_extract(value, '$.createdAt') AS createdAt,
|
|
24896
|
+
json_extract(value, '$.lastUpdatedAt') AS lastUpdatedAt,
|
|
24897
|
+
json_extract(value, '$.updatedAt') AS updatedAt
|
|
24898
|
+
FROM cursorDiskKV WHERE key = ?`),
|
|
24556
24899
|
close: () => db.close()
|
|
24557
24900
|
};
|
|
24558
24901
|
} catch (error) {
|
|
@@ -24604,6 +24947,15 @@ function setCursorReadWindow(sinceMs) {
|
|
|
24604
24947
|
function covers(held, wanted) {
|
|
24605
24948
|
return held === void 0 || wanted !== void 0 && held <= wanted;
|
|
24606
24949
|
}
|
|
24950
|
+
var sessionCacheDir;
|
|
24951
|
+
function sessionCachePath(root) {
|
|
24952
|
+
if (sessionCacheDir === null) return null;
|
|
24953
|
+
return sessionCacheFile(
|
|
24954
|
+
sessionCacheDir ?? defaultSessionCacheDir(),
|
|
24955
|
+
root,
|
|
24956
|
+
storeRoot()
|
|
24957
|
+
);
|
|
24958
|
+
}
|
|
24607
24959
|
async function readLocal(root = dataPath(), onProgress) {
|
|
24608
24960
|
const held = localReads.get(root);
|
|
24609
24961
|
if (held && covers(held.sinceMs, readWindowSinceMs)) {
|
|
@@ -24630,6 +24982,16 @@ async function readLocalOffThread(root, before, onProgress) {
|
|
|
24630
24982
|
if (!file) return readLocalOnce(root, before, onProgress);
|
|
24631
24983
|
return new Promise((resolve3) => {
|
|
24632
24984
|
const fallback = () => resolve3(readLocalOnce(root, before, onProgress));
|
|
24985
|
+
const outOfMemory = () => {
|
|
24986
|
+
trace(
|
|
24987
|
+
"cursor worker out of memory \xB7 Cursor history not read this sync",
|
|
24988
|
+
"warn"
|
|
24989
|
+
);
|
|
24990
|
+
const stats = emptyScanStats();
|
|
24991
|
+
stats.filesUnreadable++;
|
|
24992
|
+
stats.unreadableFiles.push({ path: "history", reason: "OUT_OF_MEMORY" });
|
|
24993
|
+
resolve3({ sessions: [], complete: false, stats });
|
|
24994
|
+
};
|
|
24633
24995
|
let settled = false;
|
|
24634
24996
|
const settle = (fn) => {
|
|
24635
24997
|
if (settled) return;
|
|
@@ -24641,6 +25003,7 @@ async function readLocalOffThread(root, before, onProgress) {
|
|
|
24641
25003
|
root,
|
|
24642
25004
|
before,
|
|
24643
25005
|
sinceMs: readWindowSinceMs,
|
|
25006
|
+
sessionCacheDir,
|
|
24644
25007
|
trace: traceEnabled(),
|
|
24645
25008
|
traceStartedAt: traceStartedAt(),
|
|
24646
25009
|
traceColor: traceRenderOptions().color,
|
|
@@ -24662,7 +25025,8 @@ async function readLocalOffThread(root, before, onProgress) {
|
|
|
24662
25025
|
"error",
|
|
24663
25026
|
(error) => settle(() => {
|
|
24664
25027
|
traceError("cursor worker", error);
|
|
24665
|
-
|
|
25028
|
+
if (traceErrorCode(error) === "ERR_WORKER_OUT_OF_MEMORY") outOfMemory();
|
|
25029
|
+
else fallback();
|
|
24666
25030
|
})
|
|
24667
25031
|
);
|
|
24668
25032
|
worker.on("exit", (code) => {
|
|
@@ -24696,8 +25060,9 @@ function olderThanWindow(summary, sinceMs) {
|
|
|
24696
25060
|
const newest = summaryNewestMs(summary);
|
|
24697
25061
|
return newest !== null && newest < sinceMs - READ_WINDOW_MARGIN_MS;
|
|
24698
25062
|
}
|
|
24699
|
-
async function readLocalOnce(root, before, onProgress, sourceReadLimits, stallMs = STALL_MS, sinceMs = readWindowSinceMs) {
|
|
25063
|
+
async function readLocalOnce(root, before, onProgress, sourceReadLimits, stallMs = STALL_MS, sinceMs = readWindowSinceMs, cacheDir = sessionCacheDir) {
|
|
24700
25064
|
before ??= await sourceStamp(root);
|
|
25065
|
+
sessionCacheDir = cacheDir;
|
|
24701
25066
|
const stats = emptyScanStats();
|
|
24702
25067
|
const out = { sessions: [], complete: true, stats };
|
|
24703
25068
|
if (!await hasLocalSource(root)) {
|
|
@@ -24715,6 +25080,13 @@ async function readLocalOnce(root, before, onProgress, sourceReadLimits, stallMs
|
|
|
24715
25080
|
let encodingInvalid = 0;
|
|
24716
25081
|
let total;
|
|
24717
25082
|
let stage = "reader setup";
|
|
25083
|
+
const cacheFile2 = sessionCachePath(root);
|
|
25084
|
+
const cache = cacheFile2 ? await loadSessionCache(cacheFile2) : /* @__PURE__ */ new Map();
|
|
25085
|
+
const listed = /* @__PURE__ */ new Set();
|
|
25086
|
+
let listingComplete = false;
|
|
25087
|
+
let fromCache = 0;
|
|
25088
|
+
let direct = 0;
|
|
25089
|
+
let viaLibrary = 0;
|
|
24718
25090
|
const stall = new AbortController();
|
|
24719
25091
|
const { signal } = stall;
|
|
24720
25092
|
let stallTimer;
|
|
@@ -24767,29 +25139,60 @@ async function readLocalOnce(root, before, onProgress, sourceReadLimits, stallMs
|
|
|
24767
25139
|
continue;
|
|
24768
25140
|
}
|
|
24769
25141
|
stats.filesFound++;
|
|
25142
|
+
listed.add(summary.id);
|
|
24770
25143
|
if (summary.resolutionState === "ambiguous") {
|
|
24771
25144
|
out.complete = false;
|
|
24772
25145
|
}
|
|
24773
25146
|
const position = `${stats.filesRead + stats.filesUnreadable + stats.filesSkippedByMtime + 1} of ${total}`;
|
|
24774
25147
|
const sessionStartedMs = Date.now();
|
|
25148
|
+
const stamp = sessionStamp(summary, summaryNewestMs(summary));
|
|
25149
|
+
const held = stamp === null ? void 0 : cache.get(summary.id);
|
|
25150
|
+
if (held && held.stamp === stamp) {
|
|
25151
|
+
out.sessions.push(fromEntry(held));
|
|
25152
|
+
stats.filesRead++;
|
|
25153
|
+
fromCache++;
|
|
25154
|
+
onProgress?.(stats.filesRead + stats.filesSkippedByMtime, total);
|
|
25155
|
+
progressed();
|
|
25156
|
+
continue;
|
|
25157
|
+
}
|
|
24775
25158
|
try {
|
|
24776
|
-
|
|
24777
|
-
|
|
24778
|
-
|
|
24779
|
-
if (
|
|
24780
|
-
if (
|
|
25159
|
+
let local = null;
|
|
25160
|
+
if (hasComposerHalf(summary)) {
|
|
25161
|
+
stage = "composer read";
|
|
25162
|
+
if (evidence === void 0) evidence = await openEvidenceDb(root);
|
|
25163
|
+
if (evidence)
|
|
25164
|
+
local = readComposerSession(evidence, summary, signal);
|
|
25165
|
+
}
|
|
25166
|
+
if (local) {
|
|
25167
|
+
direct++;
|
|
25168
|
+
if (local.session.messages.some((m) => m.metadata?.corrupted)) {
|
|
24781
25169
|
corrupted++;
|
|
24782
|
-
|
|
25170
|
+
out.complete = false;
|
|
25171
|
+
}
|
|
25172
|
+
} else {
|
|
25173
|
+
stage = "session read";
|
|
25174
|
+
const session = await reader.getSession(summary.id, config);
|
|
25175
|
+
if (session.resolutionState !== "complete" || session.messages.some((m) => m.metadata?.corrupted)) {
|
|
25176
|
+
if (session.resolutionState !== "complete") unresolved++;
|
|
25177
|
+
if (session.messages.some((m) => m.metadata?.corrupted))
|
|
25178
|
+
corrupted++;
|
|
25179
|
+
out.complete = false;
|
|
25180
|
+
}
|
|
25181
|
+
stage = "token evidence";
|
|
25182
|
+
if (evidence === void 0) evidence = await openEvidenceDb(root);
|
|
25183
|
+
const tokens = readTokenEvidence(session, evidence);
|
|
25184
|
+
local = { session: slimSession(session), tokens };
|
|
25185
|
+
viaLibrary++;
|
|
24783
25186
|
}
|
|
24784
|
-
|
|
24785
|
-
if (
|
|
24786
|
-
|
|
24787
|
-
|
|
25187
|
+
out.sessions.push(local);
|
|
25188
|
+
if (stamp !== null && cacheable(local))
|
|
25189
|
+
cache.set(summary.id, toEntry(stamp, local));
|
|
25190
|
+
else cache.delete(summary.id);
|
|
24788
25191
|
stats.filesRead++;
|
|
24789
25192
|
const elapsedMs = Date.now() - sessionStartedMs;
|
|
24790
25193
|
if (elapsedMs >= SLOW_SESSION_MS)
|
|
24791
25194
|
trace(
|
|
24792
|
-
`cursor slow session \xB7 ${position} \xB7 ${elapsedMs} ms \xB7 ${session.messages.length} messages, ${tokens.size} bubbles with token evidence`,
|
|
25195
|
+
`cursor slow session \xB7 ${position} \xB7 ${elapsedMs} ms \xB7 ${local.session.messages.length} messages, ${local.tokens.size} bubbles with token evidence`,
|
|
24793
25196
|
"warn"
|
|
24794
25197
|
);
|
|
24795
25198
|
onProgress?.(stats.filesRead + stats.filesSkippedByMtime, total);
|
|
@@ -24806,7 +25209,10 @@ async function readLocalOnce(root, before, onProgress, sourceReadLimits, stallMs
|
|
|
24806
25209
|
progressed();
|
|
24807
25210
|
}
|
|
24808
25211
|
}
|
|
24809
|
-
if (!page.pagination.hasMore)
|
|
25212
|
+
if (!page.pagination.hasMore) {
|
|
25213
|
+
listingComplete = true;
|
|
25214
|
+
break;
|
|
25215
|
+
}
|
|
24810
25216
|
if (page.data.length === 0 || offset >= 1e5) {
|
|
24811
25217
|
trace(
|
|
24812
25218
|
"cursor listing incomplete \xB7 empty page or pagination limit",
|
|
@@ -24841,6 +25247,21 @@ async function readLocalOnce(root, before, onProgress, sourceReadLimits, stallMs
|
|
|
24841
25247
|
stats.filesUnreadable++;
|
|
24842
25248
|
} finally {
|
|
24843
25249
|
clearTimeout(stallTimer);
|
|
25250
|
+
if (cacheFile2 && !retrySmallPage) {
|
|
25251
|
+
if (listingComplete) {
|
|
25252
|
+
for (const id of [...cache.keys()])
|
|
25253
|
+
if (!listed.has(id)) cache.delete(id);
|
|
25254
|
+
}
|
|
25255
|
+
try {
|
|
25256
|
+
await saveSessionCache(cacheFile2, cache);
|
|
25257
|
+
} catch (error) {
|
|
25258
|
+
traceError("cursor session cache save", error, "warn");
|
|
25259
|
+
}
|
|
25260
|
+
}
|
|
25261
|
+
if (fromCache || direct || viaLibrary)
|
|
25262
|
+
trace(
|
|
25263
|
+
`cursor \xB7 ${fromCache} sessions from cache, ${direct} read directly, ${viaLibrary} through cursor-history`
|
|
25264
|
+
);
|
|
24844
25265
|
try {
|
|
24845
25266
|
evidence?.close();
|
|
24846
25267
|
} catch (error) {
|
|
@@ -24864,7 +25285,8 @@ async function readLocalOnce(root, before, onProgress, sourceReadLimits, stallMs
|
|
|
24864
25285
|
onProgress,
|
|
24865
25286
|
{ ...sourceReadLimits, sqlitePageRows: 1 },
|
|
24866
25287
|
stallMs,
|
|
24867
|
-
sinceMs
|
|
25288
|
+
sinceMs,
|
|
25289
|
+
cacheDir
|
|
24868
25290
|
);
|
|
24869
25291
|
}
|
|
24870
25292
|
if (stats.filesSkippedByMtime)
|
|
@@ -25094,8 +25516,8 @@ var emptyCache = () => ({
|
|
|
25094
25516
|
local: [],
|
|
25095
25517
|
sessions: []
|
|
25096
25518
|
});
|
|
25097
|
-
var cacheFile = (root, store) =>
|
|
25098
|
-
|
|
25519
|
+
var cacheFile = (root, store) => path6.join(
|
|
25520
|
+
homedir12(),
|
|
25099
25521
|
".config",
|
|
25100
25522
|
"aistack",
|
|
25101
25523
|
"cursor",
|
|
@@ -25110,7 +25532,7 @@ function validContribution(value) {
|
|
|
25110
25532
|
}
|
|
25111
25533
|
async function loadCache(file) {
|
|
25112
25534
|
try {
|
|
25113
|
-
const raw = asObj(JSON.parse(await
|
|
25535
|
+
const raw = asObj(JSON.parse(await readFile2(file, "utf8")));
|
|
25114
25536
|
const windows = asObj(raw?.windows);
|
|
25115
25537
|
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)
|
|
25116
25538
|
throw Object.assign(new Error("Invalid cache"), {
|
|
@@ -25134,10 +25556,10 @@ async function loadCache(file) {
|
|
|
25134
25556
|
}
|
|
25135
25557
|
}
|
|
25136
25558
|
async function saveCache(file, value) {
|
|
25137
|
-
await
|
|
25559
|
+
await mkdir2(path6.dirname(file), { recursive: true, mode: 448 });
|
|
25138
25560
|
const temporary = `${file}.${process.pid}.${Date.now()}.tmp`;
|
|
25139
|
-
await
|
|
25140
|
-
await
|
|
25561
|
+
await writeFile2(temporary, JSON.stringify(value), { mode: 384 });
|
|
25562
|
+
await rename2(temporary, file);
|
|
25141
25563
|
}
|
|
25142
25564
|
var REFRESH_MS = 3e5;
|
|
25143
25565
|
var WINDOW_MS = 30 * 864e5;
|
|
@@ -25190,10 +25612,10 @@ function cachedEvents(cache, sessionIds) {
|
|
|
25190
25612
|
}
|
|
25191
25613
|
|
|
25192
25614
|
// src/harness/cursor/scan.ts
|
|
25193
|
-
import
|
|
25615
|
+
import path8 from "node:path";
|
|
25194
25616
|
|
|
25195
25617
|
// src/harness/cursor/workflow.ts
|
|
25196
|
-
import
|
|
25618
|
+
import path7 from "node:path";
|
|
25197
25619
|
var TOOLS = {
|
|
25198
25620
|
read_file: "Read",
|
|
25199
25621
|
read_file_v2: "Read",
|
|
@@ -25234,7 +25656,7 @@ function projectHistory(options) {
|
|
|
25234
25656
|
const scopes = /* @__PURE__ */ new Map();
|
|
25235
25657
|
const inWindow = (t) => t !== null && t >= sinceMs && t <= now;
|
|
25236
25658
|
for (const { session } of locals) {
|
|
25237
|
-
const projectWorkspace = session.canonicalWorkspacePath &&
|
|
25659
|
+
const projectWorkspace = session.canonicalWorkspacePath && path7.isAbsolute(session.canonicalWorkspacePath) ? session.canonicalWorkspacePath : void 0;
|
|
25238
25660
|
const times = messageTimes(session, api);
|
|
25239
25661
|
const scopeOf = (message) => {
|
|
25240
25662
|
const parent = message.parentMessageId && nativeOwners.get(message.parentMessageId);
|
|
@@ -25321,7 +25743,7 @@ function projectHistory(options) {
|
|
|
25321
25743
|
session: row.sidechain ? `${row.session}:sidechain` : row.session,
|
|
25322
25744
|
sidechain: row.sidechain
|
|
25323
25745
|
},
|
|
25324
|
-
...project &&
|
|
25746
|
+
...project && path7.isAbsolute(project) ? { projectWorkspace: project } : {},
|
|
25325
25747
|
type: "response",
|
|
25326
25748
|
tsMs: row.tsMs,
|
|
25327
25749
|
responseId: `${row.source}:${row.id ?? index}`,
|
|
@@ -25420,7 +25842,7 @@ async function scan3(options) {
|
|
|
25420
25842
|
aggregate.byModel.set(model, emptyUsage());
|
|
25421
25843
|
}
|
|
25422
25844
|
const project = session.canonicalWorkspacePath;
|
|
25423
|
-
if (project &&
|
|
25845
|
+
if (project && path8.isAbsolute(project)) aggregate.projectDirs.add(project);
|
|
25424
25846
|
if (session.metadata?.cursorVersion)
|
|
25425
25847
|
aggregate.ccVersions.add(session.metadata.cursorVersion);
|
|
25426
25848
|
const times = messageTimes(session, api).filter(
|
|
@@ -25475,7 +25897,7 @@ async function scan3(options) {
|
|
|
25475
25897
|
else aggregate.mainTokens += countsTotal(counts2);
|
|
25476
25898
|
noteSessionStart(aggregate, session, tsMs);
|
|
25477
25899
|
const project = sessions.get(session)?.session.canonicalWorkspacePath;
|
|
25478
|
-
if (project &&
|
|
25900
|
+
if (project && path8.isAbsolute(project))
|
|
25479
25901
|
noteProjectDay(aggregate, project, tsMs);
|
|
25480
25902
|
}
|
|
25481
25903
|
aggregate.files = local.stats.filesRead;
|
|
@@ -25760,17 +26182,17 @@ function ingestContribution(agg, row) {
|
|
|
25760
26182
|
|
|
25761
26183
|
// src/harness/grok/scan.ts
|
|
25762
26184
|
import { createReadStream as createReadStream2 } from "node:fs";
|
|
25763
|
-
import { readdir as readdir5, readFile as
|
|
25764
|
-
import { homedir as
|
|
25765
|
-
import
|
|
26185
|
+
import { readdir as readdir5, readFile as readFile4, stat as stat5 } from "node:fs/promises";
|
|
26186
|
+
import { homedir as homedir14 } from "node:os";
|
|
26187
|
+
import path10 from "node:path";
|
|
25766
26188
|
import readline2 from "node:readline";
|
|
25767
26189
|
import { parse as parseToml3 } from "smol-toml";
|
|
25768
26190
|
|
|
25769
26191
|
// src/harness/grok/context.ts
|
|
25770
26192
|
import { createHash as createHash7 } from "node:crypto";
|
|
25771
|
-
import { appendFile, mkdir as
|
|
25772
|
-
import { homedir as
|
|
25773
|
-
import
|
|
26193
|
+
import { appendFile, mkdir as mkdir3, readdir as readdir4, readFile as readFile3, unlink as unlink2 } from "node:fs/promises";
|
|
26194
|
+
import { homedir as homedir13 } from "node:os";
|
|
26195
|
+
import path9 from "node:path";
|
|
25774
26196
|
var DAY_MS = 864e5;
|
|
25775
26197
|
var hash = (value) => createHash7("sha256").update(value).digest("hex");
|
|
25776
26198
|
function contextCall(value) {
|
|
@@ -25793,17 +26215,17 @@ function contextCall(value) {
|
|
|
25793
26215
|
};
|
|
25794
26216
|
}
|
|
25795
26217
|
function contextCacheDirectory(root) {
|
|
25796
|
-
return
|
|
25797
|
-
|
|
26218
|
+
return path9.join(
|
|
26219
|
+
homedir13(),
|
|
25798
26220
|
".config",
|
|
25799
26221
|
"aistack",
|
|
25800
26222
|
"grok-context",
|
|
25801
|
-
hash(
|
|
26223
|
+
hash(path9.resolve(root))
|
|
25802
26224
|
);
|
|
25803
26225
|
}
|
|
25804
26226
|
async function optionalRead(file) {
|
|
25805
26227
|
try {
|
|
25806
|
-
return await
|
|
26228
|
+
return await readFile3(file, "utf8");
|
|
25807
26229
|
} catch (error) {
|
|
25808
26230
|
if (error.code === "ENOENT") return "";
|
|
25809
26231
|
throw error;
|
|
@@ -25821,14 +26243,14 @@ async function retainedContextCalls(root, sessions, cacheDir = contextCacheDirec
|
|
|
25821
26243
|
for (const file of files) {
|
|
25822
26244
|
if (!/^\d{4}-\d{2}-\d{2}\.jsonl$/.test(file)) continue;
|
|
25823
26245
|
if (Date.parse(file.slice(0, 10)) + DAY_MS < cutoff) {
|
|
25824
|
-
await unlink2(
|
|
26246
|
+
await unlink2(path9.join(cacheDir, file)).catch(
|
|
25825
26247
|
(error) => {
|
|
25826
26248
|
if (error.code !== "ENOENT") throw error;
|
|
25827
26249
|
}
|
|
25828
26250
|
);
|
|
25829
26251
|
continue;
|
|
25830
26252
|
}
|
|
25831
|
-
const raw2 = await optionalRead(
|
|
26253
|
+
const raw2 = await optionalRead(path9.join(cacheDir, file));
|
|
25832
26254
|
if (raw2 && !raw2.endsWith("\n"))
|
|
25833
26255
|
throw Object.assign(new Error("Incomplete Grok context cache"), {
|
|
25834
26256
|
code: "GROK_INCOMPLETE_CONTEXT_CACHE"
|
|
@@ -25849,7 +26271,7 @@ async function retainedContextCalls(root, sessions, cacheDir = contextCacheDirec
|
|
|
25849
26271
|
}
|
|
25850
26272
|
}
|
|
25851
26273
|
const raw = await optionalRead(
|
|
25852
|
-
|
|
26274
|
+
path9.join(root, "..", "logs", "unified.jsonl")
|
|
25853
26275
|
);
|
|
25854
26276
|
const additions = /* @__PURE__ */ new Map();
|
|
25855
26277
|
for (const line of raw.slice(0, raw.lastIndexOf("\n") + 1).split("\n")) {
|
|
@@ -25869,10 +26291,10 @@ async function retainedContextCalls(root, sessions, cacheDir = contextCacheDirec
|
|
|
25869
26291
|
additions.set(date, lines2);
|
|
25870
26292
|
}
|
|
25871
26293
|
if (additions.size) {
|
|
25872
|
-
await
|
|
26294
|
+
await mkdir3(cacheDir, { recursive: true, mode: 448 });
|
|
25873
26295
|
for (const [date, lines2] of additions) {
|
|
25874
26296
|
await appendFile(
|
|
25875
|
-
|
|
26297
|
+
path9.join(cacheDir, `${date}.jsonl`),
|
|
25876
26298
|
`${lines2.join("\n")}
|
|
25877
26299
|
`,
|
|
25878
26300
|
{ mode: 384 }
|
|
@@ -25885,8 +26307,8 @@ async function retainedContextCalls(root, sessions, cacheDir = contextCacheDirec
|
|
|
25885
26307
|
// src/harness/grok/scan.ts
|
|
25886
26308
|
function sessionRoots() {
|
|
25887
26309
|
return [
|
|
25888
|
-
|
|
25889
|
-
process.env.GROK_HOME ||
|
|
26310
|
+
path10.join(
|
|
26311
|
+
process.env.GROK_HOME || path10.join(homedir14(), ".grok"),
|
|
25890
26312
|
"sessions"
|
|
25891
26313
|
)
|
|
25892
26314
|
];
|
|
@@ -25920,7 +26342,7 @@ async function stableRead(file, jsonl) {
|
|
|
25920
26342
|
if (before.size === after.size && before.mtimeMs === after.mtimeMs)
|
|
25921
26343
|
return { lines: lines2, complete: true };
|
|
25922
26344
|
} else {
|
|
25923
|
-
const raw = await
|
|
26345
|
+
const raw = await readFile4(file, "utf8");
|
|
25924
26346
|
const after = await stat5(file);
|
|
25925
26347
|
if (before.size === after.size && before.mtimeMs === after.mtimeMs)
|
|
25926
26348
|
return { json: JSON.parse(raw), complete: true };
|
|
@@ -25938,12 +26360,12 @@ async function directories(root) {
|
|
|
25938
26360
|
const out = [];
|
|
25939
26361
|
for (const workspace of workspaces) {
|
|
25940
26362
|
if (!workspace.isDirectory() || workspace.isSymbolicLink()) continue;
|
|
25941
|
-
const workspacePath =
|
|
26363
|
+
const workspacePath = path10.join(root, workspace.name);
|
|
25942
26364
|
for (const session of await readdir5(workspacePath, {
|
|
25943
26365
|
withFileTypes: true
|
|
25944
26366
|
})) {
|
|
25945
26367
|
if (session.isDirectory() && !session.isSymbolicLink())
|
|
25946
|
-
out.push(
|
|
26368
|
+
out.push(path10.join(workspacePath, session.name));
|
|
25947
26369
|
}
|
|
25948
26370
|
}
|
|
25949
26371
|
return out.sort();
|
|
@@ -25957,7 +26379,7 @@ async function modelAliasesForRoot(root) {
|
|
|
25957
26379
|
if (process.env.GROK_MODELS_BASE_URL) return /* @__PURE__ */ new Map();
|
|
25958
26380
|
try {
|
|
25959
26381
|
const parsed = asObj(
|
|
25960
|
-
parseToml3(await
|
|
26382
|
+
parseToml3(await readFile4(path10.join(root, "..", "config.toml"), "utf8"))
|
|
25961
26383
|
);
|
|
25962
26384
|
if (!parsed || asObj(parsed.endpoints)?.models_base_url) return /* @__PURE__ */ new Map();
|
|
25963
26385
|
const models = asObj(parsed.model);
|
|
@@ -25998,10 +26420,10 @@ async function scan4(agg, opts = {}) {
|
|
|
25998
26420
|
const files = new Map(
|
|
25999
26421
|
entries.filter(
|
|
26000
26422
|
(e) => e.isFile() && (isGrokEvidenceFile(e.name) || e.name === "summary.json")
|
|
26001
|
-
).map((e) => [e.name,
|
|
26423
|
+
).map((e) => [e.name, path10.join(dir, e.name)])
|
|
26002
26424
|
);
|
|
26003
26425
|
let projectDir = dir;
|
|
26004
|
-
let sessionFallback =
|
|
26426
|
+
let sessionFallback = path10.basename(dir);
|
|
26005
26427
|
let child = false;
|
|
26006
26428
|
let parentSession;
|
|
26007
26429
|
const summary = files.get("summary.json");
|
|
@@ -26365,13 +26787,13 @@ function noteConfiguredMcpServers2(agg, state, serverNames) {
|
|
|
26365
26787
|
// src/harness/opencode/scan.ts
|
|
26366
26788
|
import { readFileSync as readFileSync12 } from "node:fs";
|
|
26367
26789
|
import { readdir as readdir6, stat as stat6 } from "node:fs/promises";
|
|
26368
|
-
import { homedir as
|
|
26369
|
-
import
|
|
26790
|
+
import { homedir as homedir15 } from "node:os";
|
|
26791
|
+
import path11 from "node:path";
|
|
26370
26792
|
var OPENCODE_MIGRATION_CEILING = 20260622202450;
|
|
26371
26793
|
function opencodeDataDirs() {
|
|
26372
26794
|
const xdg = process.env.XDG_DATA_HOME;
|
|
26373
|
-
const base = xdg ||
|
|
26374
|
-
return [
|
|
26795
|
+
const base = xdg || path11.join(homedir15(), ".local", "share");
|
|
26796
|
+
return [path11.join(base, "opencode")];
|
|
26375
26797
|
}
|
|
26376
26798
|
function isStoreFile(basename5) {
|
|
26377
26799
|
return basename5 === "opencode.db" || /^opencode-[^/]+\.db$/.test(basename5);
|
|
@@ -26381,7 +26803,7 @@ async function dbFilesIn(root) {
|
|
|
26381
26803
|
if (override) return [override];
|
|
26382
26804
|
try {
|
|
26383
26805
|
const entries = await readdir6(root, { withFileTypes: true });
|
|
26384
|
-
return entries.filter((e) => e.isFile() && isStoreFile(e.name)).map((e) =>
|
|
26806
|
+
return entries.filter((e) => e.isFile() && isStoreFile(e.name)).map((e) => path11.join(root, e.name)).sort();
|
|
26385
26807
|
} catch (error) {
|
|
26386
26808
|
if (error?.code !== "ENOENT")
|
|
26387
26809
|
traceError("opencode database discovery", error, "warn");
|
|
@@ -26423,7 +26845,7 @@ async function scan5(agg, opts = {}) {
|
|
|
26423
26845
|
traceError("opencode database read", e);
|
|
26424
26846
|
stats.filesUnreadable++;
|
|
26425
26847
|
stats.unreadableFiles.push({
|
|
26426
|
-
path:
|
|
26848
|
+
path: path11.basename(file),
|
|
26427
26849
|
reason: errorClass2(e)
|
|
26428
26850
|
});
|
|
26429
26851
|
}
|
|
@@ -26595,8 +27017,8 @@ function pickTs(jsonTs, columnTs) {
|
|
|
26595
27017
|
}
|
|
26596
27018
|
function opencodeConfigFile() {
|
|
26597
27019
|
const xdg = process.env.XDG_CONFIG_HOME;
|
|
26598
|
-
const base = xdg ||
|
|
26599
|
-
return
|
|
27020
|
+
const base = xdg || path11.join(homedir15(), ".config");
|
|
27021
|
+
return path11.join(base, "opencode", "opencode.json");
|
|
26600
27022
|
}
|
|
26601
27023
|
function readConfiguredMcpServers2(agg, state, configFile) {
|
|
26602
27024
|
const file = configFile ?? opencodeConfigFile();
|
|
@@ -26906,16 +27328,16 @@ function readCounts2(usageRaw) {
|
|
|
26906
27328
|
// src/harness/pi/scan.ts
|
|
26907
27329
|
import { createReadStream as createReadStream3 } from "node:fs";
|
|
26908
27330
|
import { readdir as readdir7, realpath as realpath3, stat as stat7 } from "node:fs/promises";
|
|
26909
|
-
import { homedir as
|
|
26910
|
-
import
|
|
27331
|
+
import { homedir as homedir16 } from "node:os";
|
|
27332
|
+
import path12 from "node:path";
|
|
26911
27333
|
import readline3 from "node:readline";
|
|
26912
27334
|
var MAX_SESSION_VERSION = 3;
|
|
26913
27335
|
function piAgentDir() {
|
|
26914
|
-
return process.env.PI_CODING_AGENT_DIR ||
|
|
27336
|
+
return process.env.PI_CODING_AGENT_DIR || path12.join(homedir16(), ".pi", "agent");
|
|
26915
27337
|
}
|
|
26916
27338
|
function sessionRoots2() {
|
|
26917
27339
|
const override = process.env.PI_CODING_AGENT_SESSION_DIR;
|
|
26918
|
-
return [override ||
|
|
27340
|
+
return [override || path12.join(piAgentDir(), "sessions")];
|
|
26919
27341
|
}
|
|
26920
27342
|
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$/;
|
|
26921
27343
|
function isSessionFile(basename5) {
|
|
@@ -26931,7 +27353,7 @@ async function* walkSessions(dir) {
|
|
|
26931
27353
|
return;
|
|
26932
27354
|
}
|
|
26933
27355
|
for (const e of entries) {
|
|
26934
|
-
const full =
|
|
27356
|
+
const full = path12.join(dir, e.name);
|
|
26935
27357
|
if (e.isDirectory()) yield* walkSessions(full);
|
|
26936
27358
|
else if (e.isFile() && isSessionFile(e.name)) yield full;
|
|
26937
27359
|
}
|
|
@@ -26983,7 +27405,7 @@ async function scan6(agg, opts = {}) {
|
|
|
26983
27405
|
stats.filesUnreadable++;
|
|
26984
27406
|
stats.filesRead--;
|
|
26985
27407
|
stats.unreadableFiles.push({
|
|
26986
|
-
path:
|
|
27408
|
+
path: path12.relative(root, file),
|
|
26987
27409
|
reason: "version-too-new"
|
|
26988
27410
|
});
|
|
26989
27411
|
}
|
|
@@ -26992,7 +27414,7 @@ async function scan6(agg, opts = {}) {
|
|
|
26992
27414
|
stats.filesUnreadable++;
|
|
26993
27415
|
stats.filesRead--;
|
|
26994
27416
|
stats.unreadableFiles.push({
|
|
26995
|
-
path:
|
|
27417
|
+
path: path12.relative(root, file),
|
|
26996
27418
|
reason: "read-error"
|
|
26997
27419
|
});
|
|
26998
27420
|
}
|
|
@@ -27137,7 +27559,7 @@ var MCP_ADD_ARGS = [
|
|
|
27137
27559
|
"mcp"
|
|
27138
27560
|
];
|
|
27139
27561
|
var MCP_REMOVE_ARGS = ["mcp", "remove", "--scope", "user", "aistack"];
|
|
27140
|
-
var SKILL_DEST = join13(
|
|
27562
|
+
var SKILL_DEST = join13(homedir17(), ".claude", "skills", "aistack-sync");
|
|
27141
27563
|
function runClaude(args) {
|
|
27142
27564
|
const r = spawnSync("claude", args, { encoding: "utf-8" });
|
|
27143
27565
|
const notFound = r.error !== void 0 && r.error.code === "ENOENT";
|
|
@@ -27461,11 +27883,11 @@ import * as p7 from "@clack/prompts";
|
|
|
27461
27883
|
// src/autosync/codexHook.ts
|
|
27462
27884
|
import { createHash as createHash8 } from "node:crypto";
|
|
27463
27885
|
import { existsSync as existsSync13, mkdirSync as mkdirSync4, readFileSync as readFileSync14, writeFileSync as writeFileSync4 } from "node:fs";
|
|
27464
|
-
import { homedir as
|
|
27886
|
+
import { homedir as homedir18 } from "node:os";
|
|
27465
27887
|
import { dirname as dirname7, join as join15 } from "node:path";
|
|
27466
27888
|
import { parse } from "smol-toml";
|
|
27467
27889
|
function codexHome2() {
|
|
27468
|
-
return process.env.CODEX_HOME || join15(
|
|
27890
|
+
return process.env.CODEX_HOME || join15(homedir18(), ".codex");
|
|
27469
27891
|
}
|
|
27470
27892
|
function codexHooksFile() {
|
|
27471
27893
|
return join15(codexHome2(), "hooks.json");
|
|
@@ -27606,14 +28028,14 @@ import * as p6 from "@clack/prompts";
|
|
|
27606
28028
|
|
|
27607
28029
|
// src/autosync/cursorHook.ts
|
|
27608
28030
|
import { existsSync as existsSync15, mkdirSync as mkdirSync6, readFileSync as readFileSync16, writeFileSync as writeFileSync6 } from "node:fs";
|
|
27609
|
-
import { homedir as
|
|
28031
|
+
import { homedir as homedir20, platform as platform2 } from "node:os";
|
|
27610
28032
|
import { dirname as dirname9, join as join17 } from "node:path";
|
|
27611
28033
|
|
|
27612
28034
|
// src/autosync/hook.ts
|
|
27613
28035
|
import { existsSync as existsSync14, mkdirSync as mkdirSync5, readFileSync as readFileSync15, writeFileSync as writeFileSync5 } from "node:fs";
|
|
27614
|
-
import { homedir as
|
|
28036
|
+
import { homedir as homedir19 } from "node:os";
|
|
27615
28037
|
import { dirname as dirname8, join as join16 } from "node:path";
|
|
27616
|
-
var CLAUDE_SETTINGS_FILE = join16(
|
|
28038
|
+
var CLAUDE_SETTINGS_FILE = join16(homedir19(), ".claude", "settings.json");
|
|
27617
28039
|
var AUTO_SYNC_HOOK_COMMAND = "npx -y @use-aistack/cli@latest sync --auto || npx -y --prefer-offline @use-aistack/cli sync --auto";
|
|
27618
28040
|
function isOurs2(entry) {
|
|
27619
28041
|
return typeof entry.command === "string" && entry.command.includes("@use-aistack/cli") && entry.command.includes("sync --auto");
|
|
@@ -27686,7 +28108,7 @@ function autoSyncHookInstalled(file = CLAUDE_SETTINGS_FILE) {
|
|
|
27686
28108
|
}
|
|
27687
28109
|
|
|
27688
28110
|
// src/autosync/cursorHook.ts
|
|
27689
|
-
var CURSOR_HOOK_FILE = join17(
|
|
28111
|
+
var CURSOR_HOOK_FILE = join17(homedir20(), ".cursor", "hooks.json");
|
|
27690
28112
|
function cursorHookCommand(os = platform2()) {
|
|
27691
28113
|
if (os === "win32") {
|
|
27692
28114
|
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"'`;
|
|
@@ -27766,10 +28188,10 @@ import {
|
|
|
27766
28188
|
unlinkSync as unlinkSync5,
|
|
27767
28189
|
writeFileSync as writeFileSync7
|
|
27768
28190
|
} from "node:fs";
|
|
27769
|
-
import { homedir as
|
|
28191
|
+
import { homedir as homedir21, platform as platform3 } from "node:os";
|
|
27770
28192
|
import { dirname as dirname10, join as join18 } from "node:path";
|
|
27771
28193
|
var GROK_HOOK_FILE = join18(
|
|
27772
|
-
process.env.GROK_HOME || join18(
|
|
28194
|
+
process.env.GROK_HOME || join18(homedir21(), ".grok"),
|
|
27773
28195
|
"hooks",
|
|
27774
28196
|
"aistack.json"
|
|
27775
28197
|
);
|
|
@@ -28127,7 +28549,7 @@ import {
|
|
|
28127
28549
|
unlinkSync as unlinkSync6,
|
|
28128
28550
|
writeFileSync as writeFileSync9
|
|
28129
28551
|
} from "node:fs";
|
|
28130
|
-
import { homedir as
|
|
28552
|
+
import { homedir as homedir23 } from "node:os";
|
|
28131
28553
|
import { dirname as dirname11, join as join19 } from "node:path";
|
|
28132
28554
|
|
|
28133
28555
|
// src/sync/stage.ts
|
|
@@ -28288,7 +28710,7 @@ function selectDaysToPublish(input) {
|
|
|
28288
28710
|
// src/workflow/git.ts
|
|
28289
28711
|
import { execFile, execFileSync as execFileSync2 } from "node:child_process";
|
|
28290
28712
|
import { existsSync as existsSync17 } from "node:fs";
|
|
28291
|
-
import
|
|
28713
|
+
import path13 from "node:path";
|
|
28292
28714
|
var TEST_FILE_RULE_VERSION = "test-files/v2";
|
|
28293
28715
|
var FILE_TYPE_RULE_VERSION = "file-types/v3";
|
|
28294
28716
|
var COMMIT_SET_RULE_VERSION = "commit-set/v1";
|
|
@@ -28721,7 +29143,7 @@ function reduceGitHistories(histories, options) {
|
|
|
28721
29143
|
current.changedLines += fileChangedLines;
|
|
28722
29144
|
if (isTestFile(file)) current.touchesTest = true;
|
|
28723
29145
|
if (fileChangedLines <= 0) continue;
|
|
28724
|
-
const extension =
|
|
29146
|
+
const extension = path13.extname(file).toLowerCase();
|
|
28725
29147
|
if (APPROVED_EXTENSIONS.has(extension)) {
|
|
28726
29148
|
current.extensionLines.set(
|
|
28727
29149
|
extension,
|
|
@@ -28827,10 +29249,10 @@ function buildWorkflowExtraction(harnessWorkflows, git, utcOffsetMinutes = machi
|
|
|
28827
29249
|
// src/sync/grokDateCache.ts
|
|
28828
29250
|
import { createHash as createHash9 } from "node:crypto";
|
|
28829
29251
|
import { existsSync as existsSync18, mkdirSync as mkdirSync8, readFileSync as readFileSync18, writeFileSync as writeFileSync8 } from "node:fs";
|
|
28830
|
-
import { homedir as
|
|
28831
|
-
import
|
|
28832
|
-
var defaultFile =
|
|
28833
|
-
|
|
29252
|
+
import { homedir as homedir22 } from "node:os";
|
|
29253
|
+
import path14 from "node:path";
|
|
29254
|
+
var defaultFile = path14.join(
|
|
29255
|
+
homedir22(),
|
|
28834
29256
|
".config",
|
|
28835
29257
|
"aistack",
|
|
28836
29258
|
"grok-session-dates.json"
|
|
@@ -28853,7 +29275,7 @@ function loadGrokDateHints(scope, file = defaultFile) {
|
|
|
28853
29275
|
function saveGrokDateHints(scope, hints, file = defaultFile) {
|
|
28854
29276
|
const cache = read2(file);
|
|
28855
29277
|
cache[scope] = hints;
|
|
28856
|
-
mkdirSync8(
|
|
29278
|
+
mkdirSync8(path14.dirname(file), { recursive: true });
|
|
28857
29279
|
writeFileSync8(file, JSON.stringify(cache, null, 2));
|
|
28858
29280
|
}
|
|
28859
29281
|
function mapToHints(value, floor) {
|
|
@@ -29637,7 +30059,7 @@ function describeScan(stats) {
|
|
|
29637
30059
|
}
|
|
29638
30060
|
|
|
29639
30061
|
// src/autosync/run.ts
|
|
29640
|
-
var SYNC_LOG_FILE = join19(
|
|
30062
|
+
var SYNC_LOG_FILE = join19(homedir23(), ".config", "aistack", "sync.log");
|
|
29641
30063
|
var SYNC_LOG_MAX_LINES = 200;
|
|
29642
30064
|
var FIX_COMMAND = "npx @use-aistack/cli sync";
|
|
29643
30065
|
var REVOKED_RESULT = "off - auto-sync is switched off for this stack";
|
|
@@ -29690,7 +30112,7 @@ async function runAutoSync(deps) {
|
|
|
29690
30112
|
const state = settings.autoSyncState ?? {};
|
|
29691
30113
|
const lastRunAt = state.lastRunAt ?? 0;
|
|
29692
30114
|
if (now - lastRunAt < windowMs) return;
|
|
29693
|
-
const reservationFile = deps.reservationFile ?? `${settingsFile ?? join19(
|
|
30115
|
+
const reservationFile = deps.reservationFile ?? `${settingsFile ?? join19(homedir23(), ".config", "aistack", "settings.json")}.auto-sync-attempt`;
|
|
29694
30116
|
if (!reserveAttempt(reservationFile, now, windowMs)) return;
|
|
29695
30117
|
saveSettings({ autoSyncState: { ...state, lastRunAt: now } }, settingsFile);
|
|
29696
30118
|
const stage = deps.stageImpl ?? stageSync;
|