@ascenda-one/history-import 0.1.39 → 0.1.41
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/README.md +56 -6
- package/dist/activeTimeFigures.js +4 -0
- package/dist/activeTimeFigures.js.map +1 -1
- package/dist/cli.js +1380 -507
- package/dist/cli.js.map +1 -1
- package/dist/extractors/copilotCli.js +719 -0
- package/dist/extractors/copilotCli.js.map +1 -0
- package/dist/extractors/vscode.js +152 -17
- package/dist/extractors/vscode.js.map +1 -1
- package/dist/handoffActiveTime.js +6 -0
- package/dist/handoffActiveTime.js.map +1 -1
- package/dist/localHandoff.js +60 -1
- package/dist/localHandoff.js.map +1 -1
- package/dist/participate.js +82 -14
- package/dist/participate.js.map +1 -1
- package/dist/scan.js +50 -0
- package/dist/scan.js.map +1 -1
- package/dist/schedule.js +11 -5
- package/dist/schedule.js.map +1 -1
- package/dist/staging.js +38 -0
- package/dist/staging.js.map +1 -1
- package/dist/stores.js +1 -0
- package/dist/stores.js.map +1 -1
- package/dist/types.js +6 -2
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -309,8 +309,8 @@ var require_modelClassifier = __commonJS({
|
|
|
309
309
|
"../packages/tool-kit/out/modelClassifier.js"(exports) {
|
|
310
310
|
"use strict";
|
|
311
311
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
312
|
-
exports.classifyModelClass =
|
|
313
|
-
function
|
|
312
|
+
exports.classifyModelClass = classifyModelClass3;
|
|
313
|
+
function classifyModelClass3(raw) {
|
|
314
314
|
const candidate = raw;
|
|
315
315
|
if (candidate === void 0 || candidate === null)
|
|
316
316
|
return void 0;
|
|
@@ -379,7 +379,7 @@ var require_buckets = __commonJS({
|
|
|
379
379
|
"use strict";
|
|
380
380
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
381
381
|
exports.bucketLinesChanged = bucketLinesChanged3;
|
|
382
|
-
exports.bucketDurationMs =
|
|
382
|
+
exports.bucketDurationMs = bucketDurationMs6;
|
|
383
383
|
function bucketLinesChanged3(count) {
|
|
384
384
|
if (count <= 0)
|
|
385
385
|
return "0";
|
|
@@ -391,7 +391,7 @@ var require_buckets = __commonJS({
|
|
|
391
391
|
return "50-200";
|
|
392
392
|
return "200+";
|
|
393
393
|
}
|
|
394
|
-
function
|
|
394
|
+
function bucketDurationMs6(durationMs) {
|
|
395
395
|
if (typeof durationMs !== "number" || !Number.isFinite(durationMs) || durationMs < 0)
|
|
396
396
|
return void 0;
|
|
397
397
|
const minutes = durationMs / 6e4;
|
|
@@ -416,7 +416,7 @@ var require_afterHours = __commonJS({
|
|
|
416
416
|
"use strict";
|
|
417
417
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
418
418
|
exports.BUSINESS_DAY = void 0;
|
|
419
|
-
exports.isOutsideBusinessHours =
|
|
419
|
+
exports.isOutsideBusinessHours = isOutsideBusinessHours4;
|
|
420
420
|
exports.isAfterHours = isAfterHours3;
|
|
421
421
|
exports.utcOffsetMinutesAt = utcOffsetMinutesAt2;
|
|
422
422
|
exports.localHourAt = localHourAt;
|
|
@@ -426,7 +426,7 @@ var require_afterHours = __commonJS({
|
|
|
426
426
|
start: "09:00",
|
|
427
427
|
end: "17:00"
|
|
428
428
|
};
|
|
429
|
-
function
|
|
429
|
+
function isOutsideBusinessHours4(at = /* @__PURE__ */ new Date(), opts = {}) {
|
|
430
430
|
const days = opts.days ?? exports.BUSINESS_DAY.days;
|
|
431
431
|
if (!days.includes(at.getDay()))
|
|
432
432
|
return true;
|
|
@@ -604,7 +604,7 @@ var require_metricKeys = __commonJS({
|
|
|
604
604
|
family: "context",
|
|
605
605
|
readBy: ["handoff"],
|
|
606
606
|
unit: "tokens",
|
|
607
|
-
note: "Codex
|
|
607
|
+
note: "Codex: the model_context_window the rollout itself recorded \u2014 the real denominator its contextWindowPeakPct was computed against. VS Code: the largest modelConfiguration.contextSize a Copilot request recorded. Claude Code records no window and its ratio assumes 200k; absent here means the store never said."
|
|
608
608
|
},
|
|
609
609
|
date: { family: "clock", readBy: ["handoff"] },
|
|
610
610
|
errorCount: { family: "outcome", readBy: ["handoff"] },
|
|
@@ -720,6 +720,17 @@ var require_metricKeys = __commonJS({
|
|
|
720
720
|
unit: "lines",
|
|
721
721
|
note: "Claude Code only: user lines written by the Agent SDK or a headless run (entrypoint sdk-*). Nobody typed them, so promptCount leaves them out. Counted once per line across the store."
|
|
722
722
|
},
|
|
723
|
+
copilotCredits: {
|
|
724
|
+
family: "context",
|
|
725
|
+
readBy: ["diagnostic"],
|
|
726
|
+
unit: "Copilot credits",
|
|
727
|
+
note: "VS Code only: the sum of each Copilot request's copilotCredits, rounded to five decimal places. Absent where no request recorded the figure, which Copilot builds before Jun 2026 don't."
|
|
728
|
+
},
|
|
729
|
+
reasoningEffort: {
|
|
730
|
+
family: "model",
|
|
731
|
+
readBy: ["diagnostic"],
|
|
732
|
+
note: "VS Code only: the modelConfiguration.reasoningEffort most of a Copilot session's requests ran with. Absent where no request recorded a model configuration."
|
|
733
|
+
},
|
|
723
734
|
tokensNotCollected: {
|
|
724
735
|
family: "context",
|
|
725
736
|
readBy: ["diagnostic"],
|
|
@@ -733,7 +744,28 @@ var require_metricKeys = __commonJS({
|
|
|
733
744
|
duplicateChatSessions: {
|
|
734
745
|
family: "reading",
|
|
735
746
|
readBy: ["diagnostic"],
|
|
736
|
-
note: "VS Code only: chat sessions seen in more than one place (a transferred session also in a workspace). Counted once."
|
|
747
|
+
note: "VS Code only: chat sessions seen in more than one place (a transferred session also in a workspace). Counted once. Copilot CLI uses it for a session written both as a directory and as an older flat file."
|
|
748
|
+
},
|
|
749
|
+
clientName: {
|
|
750
|
+
family: "session",
|
|
751
|
+
readBy: ["diagnostic"],
|
|
752
|
+
note: "Copilot CLI only: workspace.yaml's client_name, one constant word naming what started the CLI (vscode, vscode-agent-host). Absent on sessions written before the field existed, which were the standalone CLI."
|
|
753
|
+
},
|
|
754
|
+
totalApiDurationMs: {
|
|
755
|
+
family: "session",
|
|
756
|
+
readBy: ["diagnostic"],
|
|
757
|
+
unit: "milliseconds",
|
|
758
|
+
note: "Copilot CLI only: session.shutdown.totalApiDurationMs, the time the session spent waiting on model calls. Absent where the session has no shutdown event."
|
|
759
|
+
},
|
|
760
|
+
selectedModel: {
|
|
761
|
+
family: "model",
|
|
762
|
+
readBy: ["diagnostic"],
|
|
763
|
+
note: "Copilot CLI only: the model the person chose at session start (session.start.selectedModel), which is auto when they let the router pick. primaryModel is the model that served the session, so the two differ exactly when the router chose."
|
|
764
|
+
},
|
|
765
|
+
selectedModelClass: {
|
|
766
|
+
family: "model",
|
|
767
|
+
readBy: ["diagnostic"],
|
|
768
|
+
note: "Copilot CLI only: classifyModelClass of selectedModel, so a session whose person picked auto reads router:auto beside the served model's class."
|
|
737
769
|
},
|
|
738
770
|
sessionsStartedFromBubble: {
|
|
739
771
|
family: "reading",
|
|
@@ -1120,9 +1152,9 @@ var require_payload = __commonJS({
|
|
|
1120
1152
|
}
|
|
1121
1153
|
return void 0;
|
|
1122
1154
|
}
|
|
1123
|
-
function getNested(input,
|
|
1155
|
+
function getNested(input, path16) {
|
|
1124
1156
|
let current = input;
|
|
1125
|
-
for (const segment of
|
|
1157
|
+
for (const segment of path16) {
|
|
1126
1158
|
if (!current || typeof current !== "object")
|
|
1127
1159
|
return void 0;
|
|
1128
1160
|
current = current[segment];
|
|
@@ -1130,16 +1162,16 @@ var require_payload = __commonJS({
|
|
|
1130
1162
|
return current;
|
|
1131
1163
|
}
|
|
1132
1164
|
function getNestedString(input, paths) {
|
|
1133
|
-
for (const
|
|
1134
|
-
const value = getNested(input,
|
|
1165
|
+
for (const path16 of paths) {
|
|
1166
|
+
const value = getNested(input, path16);
|
|
1135
1167
|
if (typeof value === "string" && value.trim())
|
|
1136
1168
|
return value;
|
|
1137
1169
|
}
|
|
1138
1170
|
return void 0;
|
|
1139
1171
|
}
|
|
1140
1172
|
function getNestedNumber(input, paths) {
|
|
1141
|
-
for (const
|
|
1142
|
-
const value = getNested(input,
|
|
1173
|
+
for (const path16 of paths) {
|
|
1174
|
+
const value = getNested(input, path16);
|
|
1143
1175
|
if (typeof value === "number" && Number.isFinite(value))
|
|
1144
1176
|
return value;
|
|
1145
1177
|
}
|
|
@@ -1255,7 +1287,7 @@ var require_collectorVersion = __commonJS({
|
|
|
1255
1287
|
exports.COLLECTOR_VERSION = exports.UNRELEASED_COLLECTOR_VERSION = void 0;
|
|
1256
1288
|
exports.describeCollectorVersion = describeCollectorVersion;
|
|
1257
1289
|
exports.UNRELEASED_COLLECTOR_VERSION = "unreleased";
|
|
1258
|
-
exports.COLLECTOR_VERSION = "0.1.
|
|
1290
|
+
exports.COLLECTOR_VERSION = "0.1.41" ? "0.1.41" : exports.UNRELEASED_COLLECTOR_VERSION;
|
|
1259
1291
|
function describeCollectorVersion(version = exports.COLLECTOR_VERSION) {
|
|
1260
1292
|
return version === exports.UNRELEASED_COLLECTOR_VERSION ? `${version} (built from a checkout, not a release)` : version;
|
|
1261
1293
|
}
|
|
@@ -1313,33 +1345,33 @@ var require_tokenStore = __commonJS({
|
|
|
1313
1345
|
exports.listPersistedToolInstallationIds = listPersistedToolInstallationIds2;
|
|
1314
1346
|
exports.readTokenFile = readTokenFile3;
|
|
1315
1347
|
exports.sanitizeFilePart = sanitizeFilePart;
|
|
1316
|
-
var
|
|
1348
|
+
var fs16 = __importStar(__require("fs"));
|
|
1317
1349
|
var os6 = __importStar(__require("os"));
|
|
1318
|
-
var
|
|
1350
|
+
var path16 = __importStar(__require("path"));
|
|
1319
1351
|
function ascendaHome6(home = os6.homedir()) {
|
|
1320
|
-
return process.env.ASCENDA_HOME ??
|
|
1352
|
+
return process.env.ASCENDA_HOME ?? path16.join(home, ".ascenda");
|
|
1321
1353
|
}
|
|
1322
1354
|
function defaultTokenFilePath3(toolInstallationId) {
|
|
1323
|
-
return
|
|
1355
|
+
return path16.join(ascendaHome6(), "tokens", sanitizeFilePart(toolInstallationId));
|
|
1324
1356
|
}
|
|
1325
1357
|
function tokenExpiryFilePath(tokenFilePath) {
|
|
1326
|
-
return
|
|
1358
|
+
return path16.join(path16.dirname(tokenFilePath), "expiry", path16.basename(tokenFilePath));
|
|
1327
1359
|
}
|
|
1328
1360
|
function persistEventWriteToken2(tokenFilePath, token, expiresAt) {
|
|
1329
|
-
const dir =
|
|
1330
|
-
|
|
1331
|
-
|
|
1361
|
+
const dir = path16.dirname(tokenFilePath);
|
|
1362
|
+
fs16.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
1363
|
+
fs16.writeFileSync(tokenFilePath, token, { encoding: "utf8", mode: 384 });
|
|
1332
1364
|
if (process.platform !== "win32") {
|
|
1333
|
-
|
|
1334
|
-
|
|
1365
|
+
fs16.chmodSync(dir, 448);
|
|
1366
|
+
fs16.chmodSync(tokenFilePath, 384);
|
|
1335
1367
|
}
|
|
1336
1368
|
const expiryFile = tokenExpiryFilePath(tokenFilePath);
|
|
1337
1369
|
try {
|
|
1338
1370
|
if (expiresAt && Number.isFinite(Date.parse(expiresAt))) {
|
|
1339
|
-
|
|
1340
|
-
|
|
1371
|
+
fs16.mkdirSync(path16.dirname(expiryFile), { recursive: true, mode: 448 });
|
|
1372
|
+
fs16.writeFileSync(expiryFile, expiresAt, { encoding: "utf8", mode: 384 });
|
|
1341
1373
|
} else {
|
|
1342
|
-
|
|
1374
|
+
fs16.rmSync(expiryFile, { force: true });
|
|
1343
1375
|
}
|
|
1344
1376
|
} catch {
|
|
1345
1377
|
}
|
|
@@ -1347,23 +1379,23 @@ var require_tokenStore = __commonJS({
|
|
|
1347
1379
|
exports.EVENT_TOKEN_TTL_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
1348
1380
|
function readTokenExpiry2(tokenFilePath) {
|
|
1349
1381
|
try {
|
|
1350
|
-
const recorded = Date.parse(
|
|
1382
|
+
const recorded = Date.parse(fs16.readFileSync(tokenExpiryFilePath(tokenFilePath), "utf8").trim());
|
|
1351
1383
|
if (Number.isFinite(recorded))
|
|
1352
1384
|
return recorded;
|
|
1353
1385
|
} catch {
|
|
1354
1386
|
}
|
|
1355
1387
|
try {
|
|
1356
|
-
return
|
|
1388
|
+
return fs16.statSync(tokenFilePath).mtimeMs + exports.EVENT_TOKEN_TTL_MS;
|
|
1357
1389
|
} catch {
|
|
1358
1390
|
return void 0;
|
|
1359
1391
|
}
|
|
1360
1392
|
}
|
|
1361
1393
|
function listPersistedToolInstallationIds2(toolType) {
|
|
1362
1394
|
const prefix = `${sanitizeFilePart(toolType)}_`;
|
|
1363
|
-
const dir =
|
|
1395
|
+
const dir = path16.join(ascendaHome6(), "tokens");
|
|
1364
1396
|
let names;
|
|
1365
1397
|
try {
|
|
1366
|
-
names =
|
|
1398
|
+
names = fs16.readdirSync(dir);
|
|
1367
1399
|
} catch {
|
|
1368
1400
|
return [];
|
|
1369
1401
|
}
|
|
@@ -1371,9 +1403,9 @@ var require_tokenStore = __commonJS({
|
|
|
1371
1403
|
for (const name of names.sort()) {
|
|
1372
1404
|
if (!name.startsWith(prefix) || name.length === prefix.length)
|
|
1373
1405
|
continue;
|
|
1374
|
-
const file =
|
|
1406
|
+
const file = path16.join(dir, name);
|
|
1375
1407
|
try {
|
|
1376
|
-
if (!
|
|
1408
|
+
if (!fs16.statSync(file).isFile())
|
|
1377
1409
|
continue;
|
|
1378
1410
|
} catch {
|
|
1379
1411
|
continue;
|
|
@@ -1386,9 +1418,9 @@ var require_tokenStore = __commonJS({
|
|
|
1386
1418
|
}
|
|
1387
1419
|
function readTokenFile3(tokenFilePath) {
|
|
1388
1420
|
try {
|
|
1389
|
-
if (!
|
|
1421
|
+
if (!fs16.existsSync(tokenFilePath))
|
|
1390
1422
|
return void 0;
|
|
1391
|
-
const value =
|
|
1423
|
+
const value = fs16.readFileSync(tokenFilePath, "utf8").trim();
|
|
1392
1424
|
return value || void 0;
|
|
1393
1425
|
} catch {
|
|
1394
1426
|
return void 0;
|
|
@@ -1450,13 +1482,13 @@ var require_stateStore = __commonJS({
|
|
|
1450
1482
|
exports.recordOutboxDiscard = recordOutboxDiscard;
|
|
1451
1483
|
exports.shouldAnnounceFailure = shouldAnnounceFailure;
|
|
1452
1484
|
exports.markFailureNotified = markFailureNotified;
|
|
1453
|
-
var
|
|
1454
|
-
var
|
|
1485
|
+
var fs16 = __importStar(__require("fs"));
|
|
1486
|
+
var path16 = __importStar(__require("path"));
|
|
1455
1487
|
var tokenStore_1 = require_tokenStore();
|
|
1456
1488
|
function defaultStateFilePath(toolInstallationId) {
|
|
1457
1489
|
const dir = process.env.ASCENDA_STATE_DIR?.trim();
|
|
1458
|
-
const base = dir ? dir :
|
|
1459
|
-
return
|
|
1490
|
+
const base = dir ? dir : path16.join((0, tokenStore_1.ascendaHome)(), "state");
|
|
1491
|
+
return path16.join(base, `${(0, tokenStore_1.sanitizeFilePart)(toolInstallationId)}.json`);
|
|
1460
1492
|
}
|
|
1461
1493
|
function unresolvedToolInstallationId(toolType) {
|
|
1462
1494
|
return `${toolType}:unresolved`;
|
|
@@ -1466,9 +1498,9 @@ var require_stateStore = __commonJS({
|
|
|
1466
1498
|
}
|
|
1467
1499
|
function readCollectorState(stateFilePath) {
|
|
1468
1500
|
try {
|
|
1469
|
-
if (!
|
|
1501
|
+
if (!fs16.existsSync(stateFilePath))
|
|
1470
1502
|
return void 0;
|
|
1471
|
-
const raw =
|
|
1503
|
+
const raw = fs16.readFileSync(stateFilePath, "utf8").trim();
|
|
1472
1504
|
if (!raw)
|
|
1473
1505
|
return void 0;
|
|
1474
1506
|
const parsed = JSON.parse(raw);
|
|
@@ -1535,17 +1567,17 @@ var require_stateStore = __commonJS({
|
|
|
1535
1567
|
function writeStateFile(stateFilePath, state) {
|
|
1536
1568
|
const temporaryPath = `${stateFilePath}.${process.pid}.tmp`;
|
|
1537
1569
|
try {
|
|
1538
|
-
const dir =
|
|
1539
|
-
|
|
1540
|
-
|
|
1570
|
+
const dir = path16.dirname(stateFilePath);
|
|
1571
|
+
fs16.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
1572
|
+
fs16.writeFileSync(temporaryPath, `${JSON.stringify(state, null, 2)}
|
|
1541
1573
|
`, { encoding: "utf8", mode: 384 });
|
|
1542
|
-
|
|
1574
|
+
fs16.renameSync(temporaryPath, stateFilePath);
|
|
1543
1575
|
if (process.platform !== "win32")
|
|
1544
|
-
|
|
1576
|
+
fs16.chmodSync(stateFilePath, 384);
|
|
1545
1577
|
} catch {
|
|
1546
1578
|
try {
|
|
1547
|
-
if (
|
|
1548
|
-
|
|
1579
|
+
if (fs16.existsSync(temporaryPath))
|
|
1580
|
+
fs16.unlinkSync(temporaryPath);
|
|
1549
1581
|
} catch {
|
|
1550
1582
|
}
|
|
1551
1583
|
}
|
|
@@ -1606,8 +1638,8 @@ var require_outbox = __commonJS({
|
|
|
1606
1638
|
exports.readOutboxSummary = readOutboxSummary;
|
|
1607
1639
|
exports.claimOutbox = claimOutbox;
|
|
1608
1640
|
exports.enforceOutboxBounds = enforceOutboxBounds;
|
|
1609
|
-
var
|
|
1610
|
-
var
|
|
1641
|
+
var fs16 = __importStar(__require("fs"));
|
|
1642
|
+
var path16 = __importStar(__require("path"));
|
|
1611
1643
|
var stateStore_1 = require_stateStore();
|
|
1612
1644
|
var tokenStore_1 = require_tokenStore();
|
|
1613
1645
|
exports.OUTBOX_DRAIN_ENV_VAR = "ASCENDA_OUTBOX_DRAIN";
|
|
@@ -1623,25 +1655,25 @@ var require_outbox = __commonJS({
|
|
|
1623
1655
|
return !(value === "0" || value === "false" || value === "no" || value === "off");
|
|
1624
1656
|
}
|
|
1625
1657
|
function defaultOutboxFilePath(toolInstallationId) {
|
|
1626
|
-
const dir =
|
|
1627
|
-
return
|
|
1658
|
+
const dir = path16.dirname((0, stateStore_1.defaultStateFilePath)(toolInstallationId));
|
|
1659
|
+
return path16.join(dir, `${(0, tokenStore_1.sanitizeFilePart)(toolInstallationId)}.outbox.jsonl`);
|
|
1628
1660
|
}
|
|
1629
1661
|
function appendToOutbox(outboxFilePath, payload, now = /* @__PURE__ */ new Date()) {
|
|
1630
1662
|
try {
|
|
1631
|
-
const dir =
|
|
1632
|
-
|
|
1663
|
+
const dir = path16.dirname(outboxFilePath);
|
|
1664
|
+
fs16.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
1633
1665
|
const entry = { queuedAt: now.toISOString(), payload };
|
|
1634
|
-
|
|
1666
|
+
fs16.appendFileSync(outboxFilePath, `${JSON.stringify(entry)}
|
|
1635
1667
|
`, { encoding: "utf8", mode: 384 });
|
|
1636
1668
|
if (process.platform !== "win32")
|
|
1637
|
-
|
|
1669
|
+
fs16.chmodSync(outboxFilePath, 384);
|
|
1638
1670
|
return true;
|
|
1639
1671
|
} catch {
|
|
1640
1672
|
return false;
|
|
1641
1673
|
}
|
|
1642
1674
|
}
|
|
1643
1675
|
function readOutboxSummary(outboxFilePath) {
|
|
1644
|
-
const files = [outboxFilePath, ...listClaimFiles(outboxFilePath)].filter((file) =>
|
|
1676
|
+
const files = [outboxFilePath, ...listClaimFiles(outboxFilePath)].filter((file) => fs16.existsSync(file));
|
|
1645
1677
|
if (files.length === 0)
|
|
1646
1678
|
return void 0;
|
|
1647
1679
|
let depth = 0;
|
|
@@ -1662,7 +1694,7 @@ var require_outbox = __commonJS({
|
|
|
1662
1694
|
const claimPath = `${outboxFilePath}.${process.pid}${CLAIM_SUFFIX}`;
|
|
1663
1695
|
const claimed = [];
|
|
1664
1696
|
try {
|
|
1665
|
-
|
|
1697
|
+
fs16.renameSync(outboxFilePath, claimPath);
|
|
1666
1698
|
claimed.push(claimPath);
|
|
1667
1699
|
} catch {
|
|
1668
1700
|
}
|
|
@@ -1671,10 +1703,10 @@ var require_outbox = __commonJS({
|
|
|
1671
1703
|
if (claimed.includes(orphan))
|
|
1672
1704
|
continue;
|
|
1673
1705
|
try {
|
|
1674
|
-
if (now -
|
|
1706
|
+
if (now - fs16.statSync(orphan).mtimeMs < ORPHANED_CLAIM_AGE_MS)
|
|
1675
1707
|
continue;
|
|
1676
1708
|
const mine = `${claimPath}.${orphanIndex++}`;
|
|
1677
|
-
|
|
1709
|
+
fs16.renameSync(orphan, mine);
|
|
1678
1710
|
claimed.push(mine);
|
|
1679
1711
|
} catch {
|
|
1680
1712
|
}
|
|
@@ -1699,18 +1731,18 @@ var require_outbox = __commonJS({
|
|
|
1699
1731
|
released = true;
|
|
1700
1732
|
if (remainder.length > 0) {
|
|
1701
1733
|
try {
|
|
1702
|
-
|
|
1703
|
-
|
|
1734
|
+
fs16.mkdirSync(path16.dirname(outboxFilePath), { recursive: true, mode: 448 });
|
|
1735
|
+
fs16.appendFileSync(outboxFilePath, remainder.map((entry) => `${JSON.stringify(entry)}
|
|
1704
1736
|
`).join(""), { encoding: "utf8", mode: 384 });
|
|
1705
1737
|
if (process.platform !== "win32")
|
|
1706
|
-
|
|
1738
|
+
fs16.chmodSync(outboxFilePath, 384);
|
|
1707
1739
|
} catch {
|
|
1708
1740
|
return;
|
|
1709
1741
|
}
|
|
1710
1742
|
}
|
|
1711
1743
|
for (const file of claimed) {
|
|
1712
1744
|
try {
|
|
1713
|
-
|
|
1745
|
+
fs16.unlinkSync(file);
|
|
1714
1746
|
} catch {
|
|
1715
1747
|
}
|
|
1716
1748
|
}
|
|
@@ -1743,10 +1775,10 @@ var require_outbox = __commonJS({
|
|
|
1743
1775
|
return { kept, discarded: { count, reasons, ...oldestQueuedAt !== void 0 ? { oldestQueuedAt } : {} } };
|
|
1744
1776
|
}
|
|
1745
1777
|
function listClaimFiles(outboxFilePath) {
|
|
1746
|
-
const dir =
|
|
1747
|
-
const prefix = `${
|
|
1778
|
+
const dir = path16.dirname(outboxFilePath);
|
|
1779
|
+
const prefix = `${path16.basename(outboxFilePath)}.`;
|
|
1748
1780
|
try {
|
|
1749
|
-
return
|
|
1781
|
+
return fs16.readdirSync(dir).filter((name) => name.startsWith(prefix) && name.includes(CLAIM_SUFFIX)).map((name) => path16.join(dir, name)).sort();
|
|
1750
1782
|
} catch {
|
|
1751
1783
|
return [];
|
|
1752
1784
|
}
|
|
@@ -1754,7 +1786,7 @@ var require_outbox = __commonJS({
|
|
|
1754
1786
|
function readEntries(file) {
|
|
1755
1787
|
let raw;
|
|
1756
1788
|
try {
|
|
1757
|
-
raw =
|
|
1789
|
+
raw = fs16.readFileSync(file, "utf8");
|
|
1758
1790
|
} catch {
|
|
1759
1791
|
return { entries: [], unreadable: 0 };
|
|
1760
1792
|
}
|
|
@@ -1826,7 +1858,7 @@ var require_backgroundDelivery = __commonJS({
|
|
|
1826
1858
|
exports.flushLockPath = flushLockPath;
|
|
1827
1859
|
exports.startBackgroundFlush = startBackgroundFlush;
|
|
1828
1860
|
exports.runOutboxFlush = runOutboxFlush;
|
|
1829
|
-
var
|
|
1861
|
+
var fs16 = __importStar(__require("fs"));
|
|
1830
1862
|
var child_process_1 = __require("child_process");
|
|
1831
1863
|
var outbox_1 = require_outbox();
|
|
1832
1864
|
exports.HOOK_DELIVERY_ENV_VAR = "ASCENDA_HOOK_DELIVERY";
|
|
@@ -1842,27 +1874,27 @@ var require_backgroundDelivery = __commonJS({
|
|
|
1842
1874
|
}
|
|
1843
1875
|
function lockIsFresh(lockPath, now) {
|
|
1844
1876
|
try {
|
|
1845
|
-
return now -
|
|
1877
|
+
return now - fs16.statSync(lockPath).mtimeMs < exports.FLUSH_LOCK_FRESH_MS;
|
|
1846
1878
|
} catch {
|
|
1847
1879
|
return false;
|
|
1848
1880
|
}
|
|
1849
1881
|
}
|
|
1850
1882
|
function touchLock(lockPath) {
|
|
1851
1883
|
try {
|
|
1852
|
-
|
|
1884
|
+
fs16.writeFileSync(lockPath, `${process.pid}
|
|
1853
1885
|
`, { encoding: "utf8", mode: 384 });
|
|
1854
1886
|
} catch {
|
|
1855
1887
|
}
|
|
1856
1888
|
}
|
|
1857
1889
|
function removeLock(lockPath) {
|
|
1858
1890
|
try {
|
|
1859
|
-
|
|
1891
|
+
fs16.unlinkSync(lockPath);
|
|
1860
1892
|
} catch {
|
|
1861
1893
|
}
|
|
1862
1894
|
}
|
|
1863
1895
|
function outboxHasEntries(outboxFilePath) {
|
|
1864
1896
|
try {
|
|
1865
|
-
return
|
|
1897
|
+
return fs16.statSync(outboxFilePath).size > 0;
|
|
1866
1898
|
} catch {
|
|
1867
1899
|
return false;
|
|
1868
1900
|
}
|
|
@@ -2134,15 +2166,15 @@ var require_credentials = __commonJS({
|
|
|
2134
2166
|
exports.readHostCredentials = readHostCredentials2;
|
|
2135
2167
|
exports.writeHostCredentials = writeHostCredentials;
|
|
2136
2168
|
exports.removeHostCredentials = removeHostCredentials;
|
|
2137
|
-
var
|
|
2138
|
-
var
|
|
2169
|
+
var fs16 = __importStar(__require("fs"));
|
|
2170
|
+
var path16 = __importStar(__require("path"));
|
|
2139
2171
|
var tokenStore_1 = require_tokenStore();
|
|
2140
2172
|
function credentialsFilePath() {
|
|
2141
|
-
return
|
|
2173
|
+
return path16.join((0, tokenStore_1.ascendaHome)(), "credentials.json");
|
|
2142
2174
|
}
|
|
2143
2175
|
function readMachineCredentials3() {
|
|
2144
2176
|
try {
|
|
2145
|
-
const raw =
|
|
2177
|
+
const raw = fs16.readFileSync(credentialsFilePath(), "utf8").trim();
|
|
2146
2178
|
if (!raw)
|
|
2147
2179
|
return void 0;
|
|
2148
2180
|
const parsed = JSON.parse(raw);
|
|
@@ -2155,12 +2187,12 @@ var require_credentials = __commonJS({
|
|
|
2155
2187
|
}
|
|
2156
2188
|
function writeMachineCredentials(credentials) {
|
|
2157
2189
|
const file = credentialsFilePath();
|
|
2158
|
-
|
|
2159
|
-
|
|
2190
|
+
fs16.mkdirSync(path16.dirname(file), { recursive: true, mode: 448 });
|
|
2191
|
+
fs16.writeFileSync(file, `${JSON.stringify(credentials, null, 2)}
|
|
2160
2192
|
`, { encoding: "utf8", mode: 384 });
|
|
2161
2193
|
if (process.platform !== "win32") {
|
|
2162
|
-
|
|
2163
|
-
|
|
2194
|
+
fs16.chmodSync(path16.dirname(file), 448);
|
|
2195
|
+
fs16.chmodSync(file, 384);
|
|
2164
2196
|
}
|
|
2165
2197
|
}
|
|
2166
2198
|
function writeTopLevelCredentials(credentials) {
|
|
@@ -2267,9 +2299,9 @@ var require_eventLog = __commonJS({
|
|
|
2267
2299
|
exports.describeEventLog = describeEventLog;
|
|
2268
2300
|
exports.parseEventLogFlag = parseEventLogFlag;
|
|
2269
2301
|
exports.appendEventLog = appendEventLog;
|
|
2270
|
-
var
|
|
2302
|
+
var fs16 = __importStar(__require("fs"));
|
|
2271
2303
|
var os6 = __importStar(__require("os"));
|
|
2272
|
-
var
|
|
2304
|
+
var path16 = __importStar(__require("path"));
|
|
2273
2305
|
var agentEvent_1 = require_agentEvent();
|
|
2274
2306
|
var credentials_1 = require_credentials();
|
|
2275
2307
|
var tokenStore_1 = require_tokenStore();
|
|
@@ -2283,11 +2315,11 @@ var require_eventLog = __commonJS({
|
|
|
2283
2315
|
if (value === "~")
|
|
2284
2316
|
return os6.homedir();
|
|
2285
2317
|
if (value.startsWith("~/"))
|
|
2286
|
-
return
|
|
2287
|
-
return
|
|
2318
|
+
return path16.join(os6.homedir(), value.slice(2));
|
|
2319
|
+
return path16.resolve(value);
|
|
2288
2320
|
}
|
|
2289
2321
|
function defaultEventLogPath() {
|
|
2290
|
-
return
|
|
2322
|
+
return path16.join((0, tokenStore_1.ascendaHome)(), "events.jsonl");
|
|
2291
2323
|
}
|
|
2292
2324
|
function resolveEventLog(options = {}) {
|
|
2293
2325
|
for (const [source, raw] of [
|
|
@@ -2331,21 +2363,21 @@ var require_eventLog = __commonJS({
|
|
|
2331
2363
|
function appendEventLog(logFilePath, entry) {
|
|
2332
2364
|
try {
|
|
2333
2365
|
rotateIfLarge(logFilePath);
|
|
2334
|
-
const dir =
|
|
2335
|
-
|
|
2366
|
+
const dir = path16.dirname(logFilePath);
|
|
2367
|
+
fs16.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
2336
2368
|
const line = { ...entry, event: entry.event ?? (0, agentEvent_1.toAgentEvent)(entry.payload) };
|
|
2337
|
-
|
|
2369
|
+
fs16.appendFileSync(logFilePath, `${JSON.stringify(line)}
|
|
2338
2370
|
`, { encoding: "utf8", mode: 384 });
|
|
2339
2371
|
if (process.platform !== "win32")
|
|
2340
|
-
|
|
2372
|
+
fs16.chmodSync(logFilePath, 384);
|
|
2341
2373
|
} catch {
|
|
2342
2374
|
}
|
|
2343
2375
|
}
|
|
2344
2376
|
function rotateIfLarge(logFilePath) {
|
|
2345
2377
|
try {
|
|
2346
|
-
if (
|
|
2378
|
+
if (fs16.statSync(logFilePath).size < MAX_BYTES)
|
|
2347
2379
|
return;
|
|
2348
|
-
|
|
2380
|
+
fs16.renameSync(logFilePath, `${logFilePath}.1`);
|
|
2349
2381
|
} catch {
|
|
2350
2382
|
}
|
|
2351
2383
|
}
|
|
@@ -2361,7 +2393,7 @@ var require_http = __commonJS({
|
|
|
2361
2393
|
exports.createPairingSession = createPairingSession;
|
|
2362
2394
|
exports.getPairingStatus = getPairingStatus;
|
|
2363
2395
|
exports.startStudyJoin = startStudyJoin;
|
|
2364
|
-
exports.getStudyJoinStatus =
|
|
2396
|
+
exports.getStudyJoinStatus = getStudyJoinStatus2;
|
|
2365
2397
|
exports.readInitiatives = readInitiatives;
|
|
2366
2398
|
exports.readStudyNotices = readStudyNotices;
|
|
2367
2399
|
exports.setStudyObjection = setStudyObjection;
|
|
@@ -2412,7 +2444,7 @@ var require_http = __commonJS({
|
|
|
2412
2444
|
throw await apiError(response);
|
|
2413
2445
|
return await response.json();
|
|
2414
2446
|
}
|
|
2415
|
-
async function
|
|
2447
|
+
async function getStudyJoinStatus2(apiBaseUrl, eventWriteToken, joinSessionId) {
|
|
2416
2448
|
const response = await fetch(`${apiBaseUrl}/v1/org-study-join-sessions/${encodeURIComponent(joinSessionId)}/status`, {
|
|
2417
2449
|
method: "GET",
|
|
2418
2450
|
headers: { Accept: "application/json", Authorization: `Bearer ${eventWriteToken}` }
|
|
@@ -3134,16 +3166,16 @@ var require_contextRegistry = __commonJS({
|
|
|
3134
3166
|
exports.readWorkContextRegistry = readWorkContextRegistry;
|
|
3135
3167
|
exports.recordWorkContext = recordWorkContext2;
|
|
3136
3168
|
exports.recordWorkContextAlias = recordWorkContextAlias2;
|
|
3137
|
-
var
|
|
3169
|
+
var fs16 = __importStar(__require("fs"));
|
|
3138
3170
|
var os6 = __importStar(__require("os"));
|
|
3139
|
-
var
|
|
3171
|
+
var path16 = __importStar(__require("path"));
|
|
3140
3172
|
var MAX_PATHS_PER_ENTRY = 8;
|
|
3141
3173
|
function workContextRegistryFilePath() {
|
|
3142
|
-
return
|
|
3174
|
+
return path16.join(os6.homedir(), ".ascenda", "work-contexts.json");
|
|
3143
3175
|
}
|
|
3144
3176
|
function readWorkContextRegistry(registryFilePath = workContextRegistryFilePath()) {
|
|
3145
3177
|
try {
|
|
3146
|
-
const parsed = JSON.parse(
|
|
3178
|
+
const parsed = JSON.parse(fs16.readFileSync(registryFilePath, "utf8"));
|
|
3147
3179
|
if (parsed && parsed.version === 1 && parsed.contexts && typeof parsed.contexts === "object") {
|
|
3148
3180
|
return parsed;
|
|
3149
3181
|
}
|
|
@@ -3219,14 +3251,14 @@ var require_contextRegistry = __commonJS({
|
|
|
3219
3251
|
return iso.slice(0, 10);
|
|
3220
3252
|
}
|
|
3221
3253
|
function writeRegistry(registryFilePath, registry) {
|
|
3222
|
-
const dir =
|
|
3223
|
-
|
|
3254
|
+
const dir = path16.dirname(registryFilePath);
|
|
3255
|
+
fs16.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
3224
3256
|
const tmp = `${registryFilePath}.${process.pid}.tmp`;
|
|
3225
|
-
|
|
3257
|
+
fs16.writeFileSync(tmp, `${JSON.stringify(registry, null, 2)}
|
|
3226
3258
|
`, { encoding: "utf8", mode: 384 });
|
|
3227
|
-
|
|
3259
|
+
fs16.renameSync(tmp, registryFilePath);
|
|
3228
3260
|
if (process.platform !== "win32") {
|
|
3229
|
-
|
|
3261
|
+
fs16.chmodSync(registryFilePath, 384);
|
|
3230
3262
|
}
|
|
3231
3263
|
}
|
|
3232
3264
|
}
|
|
@@ -3281,8 +3313,8 @@ var require_forgeProject = __commonJS({
|
|
|
3281
3313
|
exports.readForgeFullName = readForgeFullName2;
|
|
3282
3314
|
exports.forgeFullNameFromConfig = forgeFullNameFromConfig;
|
|
3283
3315
|
exports.recordForgeProjectAlias = recordForgeProjectAlias;
|
|
3284
|
-
var
|
|
3285
|
-
var
|
|
3316
|
+
var fs16 = __importStar(__require("fs"));
|
|
3317
|
+
var path16 = __importStar(__require("path"));
|
|
3286
3318
|
var contextRegistry_1 = require_contextRegistry();
|
|
3287
3319
|
function forgeProjectHash(value) {
|
|
3288
3320
|
let h = 2166136261;
|
|
@@ -3341,7 +3373,7 @@ ${branch}`;
|
|
|
3341
3373
|
return null;
|
|
3342
3374
|
let config;
|
|
3343
3375
|
try {
|
|
3344
|
-
config =
|
|
3376
|
+
config = fs16.readFileSync(path16.join(repositoryRoot, ".git", "config"), "utf8");
|
|
3345
3377
|
} catch {
|
|
3346
3378
|
return null;
|
|
3347
3379
|
}
|
|
@@ -3448,31 +3480,31 @@ var require_salt = __commonJS({
|
|
|
3448
3480
|
exports.readOrCreateMachineSalt = readOrCreateMachineSalt;
|
|
3449
3481
|
exports.hashWithMachineSalt = hashWithMachineSalt2;
|
|
3450
3482
|
var crypto = __importStar(__require("crypto"));
|
|
3451
|
-
var
|
|
3452
|
-
var
|
|
3483
|
+
var fs16 = __importStar(__require("fs"));
|
|
3484
|
+
var path16 = __importStar(__require("path"));
|
|
3453
3485
|
var tokenStore_1 = require_tokenStore();
|
|
3454
3486
|
function machineSaltFilePath() {
|
|
3455
|
-
return
|
|
3487
|
+
return path16.join((0, tokenStore_1.ascendaHome)(), "salt");
|
|
3456
3488
|
}
|
|
3457
3489
|
var cache = /* @__PURE__ */ new Map();
|
|
3458
3490
|
function readOrCreateMachineSalt(saltFilePath = machineSaltFilePath()) {
|
|
3459
3491
|
const hit = cache.get(saltFilePath);
|
|
3460
3492
|
if (hit)
|
|
3461
3493
|
return hit;
|
|
3462
|
-
const dir =
|
|
3463
|
-
|
|
3494
|
+
const dir = path16.dirname(saltFilePath);
|
|
3495
|
+
fs16.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
3464
3496
|
let salt;
|
|
3465
3497
|
try {
|
|
3466
3498
|
salt = crypto.randomBytes(32).toString("hex");
|
|
3467
|
-
|
|
3499
|
+
fs16.writeFileSync(saltFilePath, salt, { encoding: "utf8", mode: 384, flag: "wx" });
|
|
3468
3500
|
} catch (error) {
|
|
3469
3501
|
if (error.code !== "EEXIST")
|
|
3470
3502
|
throw error;
|
|
3471
|
-
salt =
|
|
3503
|
+
salt = fs16.readFileSync(saltFilePath, "utf8").trim();
|
|
3472
3504
|
}
|
|
3473
3505
|
if (process.platform !== "win32") {
|
|
3474
|
-
|
|
3475
|
-
|
|
3506
|
+
fs16.chmodSync(dir, 448);
|
|
3507
|
+
fs16.chmodSync(saltFilePath, 384);
|
|
3476
3508
|
}
|
|
3477
3509
|
cache.set(saltFilePath, salt);
|
|
3478
3510
|
return salt;
|
|
@@ -3532,8 +3564,8 @@ var require_workContext = __commonJS({
|
|
|
3532
3564
|
exports.deriveBranchHash = deriveBranchHash3;
|
|
3533
3565
|
exports.readBranchName = readBranchName;
|
|
3534
3566
|
exports.deriveBranchHashForCwd = deriveBranchHashForCwd;
|
|
3535
|
-
var
|
|
3536
|
-
var
|
|
3567
|
+
var fs16 = __importStar(__require("fs"));
|
|
3568
|
+
var path16 = __importStar(__require("path"));
|
|
3537
3569
|
var salt_1 = require_salt();
|
|
3538
3570
|
var MAX_WALK_DEPTH = 64;
|
|
3539
3571
|
function deriveWorkContext4(cwd, saltFilePath) {
|
|
@@ -3564,25 +3596,25 @@ var require_workContext = __commonJS({
|
|
|
3564
3596
|
};
|
|
3565
3597
|
}
|
|
3566
3598
|
function resolveRepositoryRoots(startDir) {
|
|
3567
|
-
if (!
|
|
3599
|
+
if (!fs16.existsSync(startDir))
|
|
3568
3600
|
return null;
|
|
3569
3601
|
let dir = startDir;
|
|
3570
3602
|
for (let depth = 0; depth < MAX_WALK_DEPTH; depth++) {
|
|
3571
|
-
const dotGit =
|
|
3572
|
-
let
|
|
3603
|
+
const dotGit = path16.join(dir, ".git");
|
|
3604
|
+
let stat7 = null;
|
|
3573
3605
|
try {
|
|
3574
|
-
|
|
3606
|
+
stat7 = fs16.statSync(dotGit);
|
|
3575
3607
|
} catch {
|
|
3576
|
-
|
|
3608
|
+
stat7 = null;
|
|
3577
3609
|
}
|
|
3578
|
-
if (
|
|
3610
|
+
if (stat7?.isDirectory())
|
|
3579
3611
|
return { checkoutRoot: dir, canonicalRoot: dir, gitDir: dotGit };
|
|
3580
|
-
if (
|
|
3612
|
+
if (stat7?.isFile()) {
|
|
3581
3613
|
const gitDir = readGitdirPointer(dotGit, dir);
|
|
3582
3614
|
const canonicalRoot = (gitDir ? worktreeParentRoot(gitDir) : null) ?? dir;
|
|
3583
3615
|
return { checkoutRoot: dir, canonicalRoot, gitDir };
|
|
3584
3616
|
}
|
|
3585
|
-
const parent =
|
|
3617
|
+
const parent = path16.dirname(dir);
|
|
3586
3618
|
if (parent === dir)
|
|
3587
3619
|
return null;
|
|
3588
3620
|
dir = parent;
|
|
@@ -3591,16 +3623,16 @@ var require_workContext = __commonJS({
|
|
|
3591
3623
|
}
|
|
3592
3624
|
function readGitdirPointer(dotGitFile, containingDir) {
|
|
3593
3625
|
try {
|
|
3594
|
-
const match = /^gitdir:\s*(.+)\s*$/m.exec(
|
|
3626
|
+
const match = /^gitdir:\s*(.+)\s*$/m.exec(fs16.readFileSync(dotGitFile, "utf8"));
|
|
3595
3627
|
if (!match)
|
|
3596
3628
|
return null;
|
|
3597
|
-
return
|
|
3629
|
+
return path16.resolve(containingDir, match[1].trim());
|
|
3598
3630
|
} catch {
|
|
3599
3631
|
return null;
|
|
3600
3632
|
}
|
|
3601
3633
|
}
|
|
3602
3634
|
function worktreeParentRoot(resolvedGitDir) {
|
|
3603
|
-
const marker = `${
|
|
3635
|
+
const marker = `${path16.sep}.git${path16.sep}worktrees${path16.sep}`;
|
|
3604
3636
|
const idx = resolvedGitDir.indexOf(marker);
|
|
3605
3637
|
if (idx === -1)
|
|
3606
3638
|
return null;
|
|
@@ -3610,12 +3642,12 @@ var require_workContext = __commonJS({
|
|
|
3610
3642
|
const sep2 = startPath.includes("\\") && !startPath.includes("/") ? "\\" : "/";
|
|
3611
3643
|
const leading = /^[\\/]/.test(startPath) ? sep2 : "";
|
|
3612
3644
|
const segments = startPath.split(/[\\/]/).filter(Boolean);
|
|
3613
|
-
const
|
|
3645
|
+
const join15 = (count) => leading + segments.slice(0, count).join(sep2);
|
|
3614
3646
|
for (let i = 0; i + 2 < segments.length; i++) {
|
|
3615
3647
|
if (segments[i] === ".claude" && segments[i + 1] === "worktrees") {
|
|
3616
3648
|
if (i === 0)
|
|
3617
3649
|
return null;
|
|
3618
|
-
return { checkoutRoot:
|
|
3650
|
+
return { checkoutRoot: join15(i + 3), canonicalRoot: join15(i), gitDir: null };
|
|
3619
3651
|
}
|
|
3620
3652
|
}
|
|
3621
3653
|
for (let i = 0; i + 1 < segments.length; i++) {
|
|
@@ -3625,7 +3657,7 @@ var require_workContext = __commonJS({
|
|
|
3625
3657
|
continue;
|
|
3626
3658
|
const repoName = folder.slice(0, -suffix.length);
|
|
3627
3659
|
const canonicalRoot = leading + [...segments.slice(0, i), repoName].join(sep2);
|
|
3628
|
-
return { checkoutRoot:
|
|
3660
|
+
return { checkoutRoot: join15(i + 2), canonicalRoot, gitDir: null };
|
|
3629
3661
|
}
|
|
3630
3662
|
return null;
|
|
3631
3663
|
}
|
|
@@ -3673,7 +3705,7 @@ var require_workContext = __commonJS({
|
|
|
3673
3705
|
return null;
|
|
3674
3706
|
let head;
|
|
3675
3707
|
try {
|
|
3676
|
-
head =
|
|
3708
|
+
head = fs16.readFileSync(path16.join(gitDir, "HEAD"), "utf8").trim();
|
|
3677
3709
|
} catch {
|
|
3678
3710
|
return null;
|
|
3679
3711
|
}
|
|
@@ -3736,8 +3768,8 @@ var require_forgeKeys = __commonJS({
|
|
|
3736
3768
|
exports.REPO_KEYS_ENV_VAR = void 0;
|
|
3737
3769
|
exports.repoKeysEnabled = repoKeysEnabled2;
|
|
3738
3770
|
exports.deriveForgeKeysForCwd = deriveForgeKeysForCwd;
|
|
3739
|
-
var
|
|
3740
|
-
var
|
|
3771
|
+
var fs16 = __importStar(__require("fs"));
|
|
3772
|
+
var path16 = __importStar(__require("path"));
|
|
3741
3773
|
var credentials_1 = require_credentials();
|
|
3742
3774
|
var forgeProject_1 = require_forgeProject();
|
|
3743
3775
|
var workContext_1 = require_workContext();
|
|
@@ -3752,7 +3784,7 @@ var require_forgeKeys = __commonJS({
|
|
|
3752
3784
|
}
|
|
3753
3785
|
function readDefaultBranch(repositoryRoot) {
|
|
3754
3786
|
try {
|
|
3755
|
-
const head =
|
|
3787
|
+
const head = fs16.readFileSync(path16.join(repositoryRoot, ".git", "refs", "remotes", "origin", "HEAD"), "utf8").trim();
|
|
3756
3788
|
const match = /^ref:\s*refs\/remotes\/origin\/(.+)$/.exec(head);
|
|
3757
3789
|
return match ? (0, workContext_1.normalizeBranchName)(match[1]) : null;
|
|
3758
3790
|
} catch {
|
|
@@ -3920,6 +3952,8 @@ var require_hookAdapter = __commonJS({
|
|
|
3920
3952
|
if (!logFile)
|
|
3921
3953
|
throw error;
|
|
3922
3954
|
logUnsent(logFile, events, options);
|
|
3955
|
+
if (!(error instanceof MissingInstallationIdError))
|
|
3956
|
+
throw error;
|
|
3923
3957
|
return;
|
|
3924
3958
|
}
|
|
3925
3959
|
const sender = new eventSender_1.AscendaEventSender({
|
|
@@ -4088,6 +4122,7 @@ var require_studyJoin = __commonJS({
|
|
|
4088
4122
|
};
|
|
4089
4123
|
}();
|
|
4090
4124
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4125
|
+
exports.gitOfferLine = gitOfferLine;
|
|
4091
4126
|
exports.runStudyJoin = runStudyJoin2;
|
|
4092
4127
|
exports.formatWindow = formatWindow2;
|
|
4093
4128
|
exports.describeStudyGrant = describeStudyGrant2;
|
|
@@ -4096,6 +4131,11 @@ var require_studyJoin = __commonJS({
|
|
|
4096
4131
|
var readline2 = __importStar(__require("node:readline"));
|
|
4097
4132
|
var confirmLinks_1 = require_confirmLinks();
|
|
4098
4133
|
var http_1 = require_http();
|
|
4134
|
+
function gitOfferLine(optionalImportStores) {
|
|
4135
|
+
if (!optionalImportStores?.includes("git"))
|
|
4136
|
+
return void 0;
|
|
4137
|
+
return "The page also has an unticked box for git history: commit times, size buckets, files changed and whether each is a merge. No messages, paths, names or emails.";
|
|
4138
|
+
}
|
|
4099
4139
|
var STUDY_JOIN_MODE = "report";
|
|
4100
4140
|
var POLL_INTERVAL_MS = 3e3;
|
|
4101
4141
|
var POLL_TIMEOUT_MS = 11 * 60 * 1e3;
|
|
@@ -4132,6 +4172,9 @@ var require_studyJoin = __commonJS({
|
|
|
4132
4172
|
print("Report (30 days) grants:");
|
|
4133
4173
|
for (const grant of start.grants)
|
|
4134
4174
|
print(` ${describeStudyGrant2(grant)}`);
|
|
4175
|
+
const gitOffer = gitOfferLine(start.optionalImportStores);
|
|
4176
|
+
if (gitOffer)
|
|
4177
|
+
print(gitOffer);
|
|
4135
4178
|
print("");
|
|
4136
4179
|
print("Study mode needs the Ascenda app. Open the app to join that way instead.");
|
|
4137
4180
|
print("");
|
|
@@ -4186,7 +4229,7 @@ var require_studyJoin = __commonJS({
|
|
|
4186
4229
|
print("");
|
|
4187
4230
|
print("Each of these can be turned off separately, in the app's consent settings.");
|
|
4188
4231
|
print("The organisation sees group counts, never who joined.");
|
|
4189
|
-
report({ status: "joined", start, granted });
|
|
4232
|
+
report({ status: "joined", start, granted, importStores: poll.importStores ?? null });
|
|
4190
4233
|
return 0;
|
|
4191
4234
|
}
|
|
4192
4235
|
if (poll.status === "expired") {
|
|
@@ -4208,7 +4251,7 @@ var require_studyJoin = __commonJS({
|
|
|
4208
4251
|
print("Each of these can be turned off separately, in the app's consent settings.");
|
|
4209
4252
|
}
|
|
4210
4253
|
print("Run join again, or check with your organisation.");
|
|
4211
|
-
report({ status: "refused", start, granted, refusedReason: poll.refusedReason, message: describeRefusal(poll.refusedReason) });
|
|
4254
|
+
report({ status: "refused", start, granted, refusedReason: poll.refusedReason, message: describeRefusal(poll.refusedReason), importStores: poll.importStores ?? null });
|
|
4212
4255
|
return 1;
|
|
4213
4256
|
}
|
|
4214
4257
|
print("");
|
|
@@ -4357,7 +4400,7 @@ var require_pairingStudyJoin = __commonJS({
|
|
|
4357
4400
|
exports.settleStudyJoin = settleStudyJoin;
|
|
4358
4401
|
exports.writePairingJoinOutcome = writePairingJoinOutcome;
|
|
4359
4402
|
exports.pairingJoinOutcome = pairingJoinOutcome;
|
|
4360
|
-
var
|
|
4403
|
+
var fs16 = __importStar(__require("node:fs"));
|
|
4361
4404
|
var confirmLinks_1 = require_confirmLinks();
|
|
4362
4405
|
var studyJoin_1 = require_studyJoin();
|
|
4363
4406
|
var http_1 = require_http();
|
|
@@ -4386,11 +4429,13 @@ var require_pairingStudyJoin = __commonJS({
|
|
|
4386
4429
|
}
|
|
4387
4430
|
function pairingAttemptLines(attempt) {
|
|
4388
4431
|
const { session } = attempt;
|
|
4389
|
-
const
|
|
4390
|
-
if (!
|
|
4432
|
+
const join15 = attempt.carriesJoin ? session.studyJoin : void 0;
|
|
4433
|
+
if (!join15)
|
|
4391
4434
|
return (0, confirmLinks_1.pairingConfirmLines)(session.qrUrl, session.code);
|
|
4435
|
+
const gitOffer = (0, studyJoin_1.gitOfferLine)(join15.optionalImportStores);
|
|
4392
4436
|
return [
|
|
4393
|
-
`This also joins ${
|
|
4437
|
+
`This also joins ${join15.organisationName} (${(0, studyJoin_1.formatWindow)(join15.windowStartUtc, join15.windowEndUtc)}). The page shows what you'd share before you confirm.`,
|
|
4438
|
+
...gitOffer ? [gitOffer] : [],
|
|
4394
4439
|
`Open this link to confirm: ${session.qrUrl}`
|
|
4395
4440
|
];
|
|
4396
4441
|
}
|
|
@@ -4414,7 +4459,7 @@ var require_pairingStudyJoin = __commonJS({
|
|
|
4414
4459
|
if (!file)
|
|
4415
4460
|
return;
|
|
4416
4461
|
try {
|
|
4417
|
-
|
|
4462
|
+
fs16.writeFileSync(file, `${JSON.stringify(outcome)}
|
|
4418
4463
|
`, { mode: 384 });
|
|
4419
4464
|
} catch {
|
|
4420
4465
|
}
|
|
@@ -4715,12 +4760,12 @@ var require_hookRunner = __commonJS({
|
|
|
4715
4760
|
exports.resolveHookNode = resolveHookNode;
|
|
4716
4761
|
exports.tidyHomePath = tidyHomePath2;
|
|
4717
4762
|
var child_process_1 = __require("child_process");
|
|
4718
|
-
var
|
|
4719
|
-
var
|
|
4763
|
+
var fs16 = __importStar(__require("fs"));
|
|
4764
|
+
var path16 = __importStar(__require("path"));
|
|
4720
4765
|
var collectorVersion_1 = require_collectorVersion();
|
|
4721
4766
|
var tokenStore_1 = require_tokenStore();
|
|
4722
4767
|
function hookRunnerPaths(binaryName) {
|
|
4723
|
-
const launcher =
|
|
4768
|
+
const launcher = path16.join((0, tokenStore_1.ascendaHome)(), "bin", binaryName);
|
|
4724
4769
|
return { launcher, bundle: `${launcher}.mjs`, record: `${launcher}.node`, noNode: `${launcher}.no-node`, version: `${launcher}.version` };
|
|
4725
4770
|
}
|
|
4726
4771
|
var LAUNCHER_MANAGEMENT_COMMANDS = ["setup", "install", "status", "uninstall", "doctor", "pair", "join", "object", "-h", "--help"];
|
|
@@ -4832,7 +4877,7 @@ var require_hookRunner = __commonJS({
|
|
|
4832
4877
|
}
|
|
4833
4878
|
function readInstalledVersion(file) {
|
|
4834
4879
|
try {
|
|
4835
|
-
return
|
|
4880
|
+
return fs16.readFileSync(file, "utf8").trim() || void 0;
|
|
4836
4881
|
} catch {
|
|
4837
4882
|
return void 0;
|
|
4838
4883
|
}
|
|
@@ -4841,41 +4886,41 @@ var require_hookRunner = __commonJS({
|
|
|
4841
4886
|
const paths = hookRunnerPaths(options.binaryName);
|
|
4842
4887
|
if (options.dryRun)
|
|
4843
4888
|
return paths.launcher;
|
|
4844
|
-
const source =
|
|
4889
|
+
const source = path16.resolve(options.source ?? process.argv[1]);
|
|
4845
4890
|
const incoming = options.version ?? collectorVersion_1.COLLECTOR_VERSION;
|
|
4846
4891
|
const installed = readInstalledVersion(paths.version);
|
|
4847
4892
|
const installedFile = process.platform === "win32" ? paths.launcher : paths.bundle;
|
|
4848
|
-
if (installed &&
|
|
4893
|
+
if (installed && fs16.existsSync(installedFile) && isDowngrade(installed, incoming)) {
|
|
4849
4894
|
options.onKeptNewer?.(installed, incoming);
|
|
4850
|
-
if (process.platform !== "win32" && !
|
|
4895
|
+
if (process.platform !== "win32" && !fs16.existsSync(paths.launcher))
|
|
4851
4896
|
writeAtomically2(paths.launcher, hookLauncherScript(options), 493);
|
|
4852
4897
|
return paths.launcher;
|
|
4853
4898
|
}
|
|
4854
|
-
|
|
4899
|
+
fs16.mkdirSync(path16.dirname(paths.launcher), { recursive: true });
|
|
4855
4900
|
if (process.platform === "win32") {
|
|
4856
|
-
if (source !==
|
|
4857
|
-
|
|
4901
|
+
if (source !== path16.resolve(paths.launcher))
|
|
4902
|
+
fs16.copyFileSync(source, paths.launcher);
|
|
4858
4903
|
writeAtomically2(paths.version, `${incoming}
|
|
4859
4904
|
`, 420);
|
|
4860
4905
|
return paths.launcher;
|
|
4861
4906
|
}
|
|
4862
|
-
if (source !==
|
|
4863
|
-
writeAtomically2(paths.bundle,
|
|
4907
|
+
if (source !== path16.resolve(paths.bundle))
|
|
4908
|
+
writeAtomically2(paths.bundle, fs16.readFileSync(source), 493);
|
|
4864
4909
|
writeAtomically2(paths.launcher, hookLauncherScript(options), 493);
|
|
4865
4910
|
writeAtomically2(paths.record, `${process.execPath}
|
|
4866
4911
|
`, 420);
|
|
4867
|
-
if (source !==
|
|
4912
|
+
if (source !== path16.resolve(paths.bundle))
|
|
4868
4913
|
writeAtomically2(paths.version, `${incoming}
|
|
4869
4914
|
`, 420);
|
|
4870
|
-
|
|
4915
|
+
fs16.rmSync(paths.noNode, { force: true });
|
|
4871
4916
|
return paths.launcher;
|
|
4872
4917
|
}
|
|
4873
4918
|
function removeHookRunner(binaryName) {
|
|
4874
4919
|
const removed = [];
|
|
4875
4920
|
for (const file of Object.values(hookRunnerPaths(binaryName))) {
|
|
4876
|
-
if (!
|
|
4921
|
+
if (!fs16.existsSync(file))
|
|
4877
4922
|
continue;
|
|
4878
|
-
|
|
4923
|
+
fs16.rmSync(file, { force: true });
|
|
4879
4924
|
removed.push(file);
|
|
4880
4925
|
}
|
|
4881
4926
|
return removed;
|
|
@@ -4885,28 +4930,28 @@ var require_hookRunner = __commonJS({
|
|
|
4885
4930
|
}
|
|
4886
4931
|
function writeAtomically2(target, contents, mode) {
|
|
4887
4932
|
const tmp = `${target}.${process.pid}.tmp`;
|
|
4888
|
-
|
|
4889
|
-
|
|
4890
|
-
|
|
4933
|
+
fs16.writeFileSync(tmp, contents, { mode });
|
|
4934
|
+
fs16.chmodSync(tmp, mode);
|
|
4935
|
+
fs16.renameSync(tmp, target);
|
|
4891
4936
|
}
|
|
4892
|
-
var stateDir = () => process.env.ASCENDA_STATE_DIR ??
|
|
4937
|
+
var stateDir = () => process.env.ASCENDA_STATE_DIR ?? path16.join((0, tokenStore_1.ascendaHome)(), "state");
|
|
4893
4938
|
function lastHookPath(tool) {
|
|
4894
|
-
return
|
|
4939
|
+
return path16.join(stateDir(), `${tool}-last-hook.json`);
|
|
4895
4940
|
}
|
|
4896
4941
|
function stampLastHook(tool, event, now = /* @__PURE__ */ new Date()) {
|
|
4897
4942
|
try {
|
|
4898
|
-
|
|
4943
|
+
fs16.mkdirSync(stateDir(), { recursive: true });
|
|
4899
4944
|
const file = lastHookPath(tool);
|
|
4900
4945
|
const tmp = `${file}.${process.pid}.tmp`;
|
|
4901
|
-
|
|
4946
|
+
fs16.writeFileSync(tmp, `${JSON.stringify({ event, at: now.toISOString() })}
|
|
4902
4947
|
`, { mode: 384 });
|
|
4903
|
-
|
|
4948
|
+
fs16.renameSync(tmp, file);
|
|
4904
4949
|
} catch {
|
|
4905
4950
|
}
|
|
4906
4951
|
}
|
|
4907
4952
|
function readLastHook(tool) {
|
|
4908
4953
|
try {
|
|
4909
|
-
const parsed = JSON.parse(
|
|
4954
|
+
const parsed = JSON.parse(fs16.readFileSync(lastHookPath(tool), "utf8"));
|
|
4910
4955
|
if (typeof parsed.event !== "string" || typeof parsed.at !== "string")
|
|
4911
4956
|
return void 0;
|
|
4912
4957
|
return { event: parsed.event, at: parsed.at };
|
|
@@ -4929,7 +4974,7 @@ var require_hookRunner = __commonJS({
|
|
|
4929
4974
|
return `${Math.round(hours / 24)} days ago`;
|
|
4930
4975
|
}
|
|
4931
4976
|
function resolveHookNode(launcher) {
|
|
4932
|
-
if (!
|
|
4977
|
+
if (!fs16.existsSync(launcher))
|
|
4933
4978
|
return { problem: "the hook launcher is not installed" };
|
|
4934
4979
|
const probe = (0, child_process_1.spawnSync)("/bin/sh", [launcher], {
|
|
4935
4980
|
encoding: "utf8",
|
|
@@ -4994,19 +5039,19 @@ var require_settingsFile = __commonJS({
|
|
|
4994
5039
|
}();
|
|
4995
5040
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4996
5041
|
exports.replaceSettingsFile = replaceSettingsFile;
|
|
4997
|
-
var
|
|
4998
|
-
var
|
|
5042
|
+
var fs16 = __importStar(__require("fs"));
|
|
5043
|
+
var path16 = __importStar(__require("path"));
|
|
4999
5044
|
var hookRunner_1 = require_hookRunner();
|
|
5000
5045
|
function replaceSettingsFile(settingsFile, contents) {
|
|
5001
|
-
const exists =
|
|
5002
|
-
const target = exists ?
|
|
5046
|
+
const exists = fs16.existsSync(settingsFile);
|
|
5047
|
+
const target = exists ? fs16.realpathSync(settingsFile) : settingsFile;
|
|
5003
5048
|
if (exists) {
|
|
5004
5049
|
const backup = `${settingsFile}.ascenda-backup`;
|
|
5005
|
-
if (!
|
|
5006
|
-
|
|
5050
|
+
if (!fs16.existsSync(backup))
|
|
5051
|
+
fs16.copyFileSync(target, backup);
|
|
5007
5052
|
}
|
|
5008
|
-
|
|
5009
|
-
const mode = exists ?
|
|
5053
|
+
fs16.mkdirSync(path16.dirname(target), { recursive: true });
|
|
5054
|
+
const mode = exists ? fs16.statSync(target).mode & 511 : 420;
|
|
5010
5055
|
(0, hookRunner_1.writeAtomically)(target, contents, mode);
|
|
5011
5056
|
}
|
|
5012
5057
|
}
|
|
@@ -5111,22 +5156,22 @@ var require_saverHandoff = __commonJS({
|
|
|
5111
5156
|
exports.heldForSaver = heldForSaver;
|
|
5112
5157
|
exports.readSaverStatuses = readSaverStatuses;
|
|
5113
5158
|
exports.probeSocket = probeSocket;
|
|
5114
|
-
var
|
|
5159
|
+
var fs16 = __importStar(__require("fs"));
|
|
5115
5160
|
var net = __importStar(__require("net"));
|
|
5116
5161
|
var os6 = __importStar(__require("os"));
|
|
5117
|
-
var
|
|
5162
|
+
var path16 = __importStar(__require("path"));
|
|
5118
5163
|
var SAVER_HOST_BUNDLE_ID = "com.apple.ScreenSaver.Engine.legacyScreenSaver";
|
|
5119
5164
|
function saverContainerDir() {
|
|
5120
|
-
return process.env.ASCENDA_SAVER_CONTAINER ??
|
|
5165
|
+
return process.env.ASCENDA_SAVER_CONTAINER ?? path16.join(os6.homedir(), "Library", "Containers", SAVER_HOST_BUNDLE_ID, "Data");
|
|
5121
5166
|
}
|
|
5122
5167
|
function saverSupportDir() {
|
|
5123
|
-
return
|
|
5168
|
+
return path16.join(saverContainerDir(), "Library", "Application Support", "AscendaWaterlineSaver");
|
|
5124
5169
|
}
|
|
5125
5170
|
function saverReplayPath() {
|
|
5126
|
-
return
|
|
5171
|
+
return path16.join(saverContainerDir(), "l.replay.json");
|
|
5127
5172
|
}
|
|
5128
5173
|
function saverStatusDir() {
|
|
5129
|
-
return
|
|
5174
|
+
return path16.join(saverSupportDir(), "status");
|
|
5130
5175
|
}
|
|
5131
5176
|
exports.SAVER_REPLAY_WINDOW_MS = 30 * 60 * 1e3;
|
|
5132
5177
|
var SAVER_REPLAY_MAX = 32;
|
|
@@ -5135,7 +5180,7 @@ var require_saverHandoff = __commonJS({
|
|
|
5135
5180
|
try {
|
|
5136
5181
|
if (process.env.ASCENDA_LIVE_BUS_SOCKET && !process.env.ASCENDA_SAVER_CONTAINER)
|
|
5137
5182
|
return;
|
|
5138
|
-
if (!
|
|
5183
|
+
if (!fs16.existsSync(saverSupportDir()))
|
|
5139
5184
|
return;
|
|
5140
5185
|
const wire = signal;
|
|
5141
5186
|
const tool = wire.tool;
|
|
@@ -5149,15 +5194,15 @@ var require_saverHandoff = __commonJS({
|
|
|
5149
5194
|
kept.sort((a, b) => a.at - b.at);
|
|
5150
5195
|
const body = JSON.stringify({ schema: exports.SAVER_REPLAY_SCHEMA, signals: kept.slice(-SAVER_REPLAY_MAX) });
|
|
5151
5196
|
const tmp = `${file}.${process.pid}.tmp`;
|
|
5152
|
-
|
|
5197
|
+
fs16.writeFileSync(tmp, `${body}
|
|
5153
5198
|
`, { mode: 384 });
|
|
5154
|
-
|
|
5199
|
+
fs16.renameSync(tmp, file);
|
|
5155
5200
|
} catch {
|
|
5156
5201
|
}
|
|
5157
5202
|
}
|
|
5158
5203
|
function readHeld(file) {
|
|
5159
5204
|
try {
|
|
5160
|
-
const parsed = JSON.parse(
|
|
5205
|
+
const parsed = JSON.parse(fs16.readFileSync(file, "utf8"));
|
|
5161
5206
|
if (parsed.schema !== exports.SAVER_REPLAY_SCHEMA || !Array.isArray(parsed.signals))
|
|
5162
5207
|
return [];
|
|
5163
5208
|
return parsed.signals.filter((held) => typeof held === "object" && held !== null && typeof held.tool === "string" && typeof held.session === "string" && typeof held.event === "string" && typeof held.at === "number");
|
|
@@ -5174,14 +5219,14 @@ var require_saverHandoff = __commonJS({
|
|
|
5174
5219
|
function readSaverStatuses(now = Date.now()) {
|
|
5175
5220
|
let names;
|
|
5176
5221
|
try {
|
|
5177
|
-
names =
|
|
5222
|
+
names = fs16.readdirSync(saverStatusDir()).filter((name) => name.endsWith(".json"));
|
|
5178
5223
|
} catch {
|
|
5179
5224
|
return [];
|
|
5180
5225
|
}
|
|
5181
5226
|
const readings = [];
|
|
5182
5227
|
for (const name of names) {
|
|
5183
5228
|
try {
|
|
5184
|
-
const status = JSON.parse(
|
|
5229
|
+
const status = JSON.parse(fs16.readFileSync(path16.join(saverStatusDir(), name), "utf8"));
|
|
5185
5230
|
if (typeof status.pid !== "number" || typeof status.updatedAt !== "string")
|
|
5186
5231
|
continue;
|
|
5187
5232
|
readings.push({ ...status, alive: processAlive(status.pid), ageMs: now - Date.parse(status.updatedAt) });
|
|
@@ -5201,7 +5246,7 @@ var require_saverHandoff = __commonJS({
|
|
|
5201
5246
|
function probeSocket(socketPath, timeoutMs = 300) {
|
|
5202
5247
|
return new Promise((resolve3) => {
|
|
5203
5248
|
try {
|
|
5204
|
-
if (!
|
|
5249
|
+
if (!fs16.statSync(socketPath).isSocket()) {
|
|
5205
5250
|
resolve3("absent");
|
|
5206
5251
|
return;
|
|
5207
5252
|
}
|
|
@@ -5276,10 +5321,10 @@ var require_liveBus = __commonJS({
|
|
|
5276
5321
|
exports.bucketPromptSize = bucketPromptSize;
|
|
5277
5322
|
exports.emitLiveSignal = emitLiveSignal;
|
|
5278
5323
|
exports.deliverLine = deliverLine;
|
|
5279
|
-
var
|
|
5324
|
+
var fs16 = __importStar(__require("fs"));
|
|
5280
5325
|
var net = __importStar(__require("net"));
|
|
5281
5326
|
var os6 = __importStar(__require("os"));
|
|
5282
|
-
var
|
|
5327
|
+
var path16 = __importStar(__require("path"));
|
|
5283
5328
|
var hookSet_1 = require_hookSet();
|
|
5284
5329
|
var saverHandoff_1 = require_saverHandoff();
|
|
5285
5330
|
var WRITE_TIMEOUT_MS = 50;
|
|
@@ -5292,9 +5337,9 @@ var require_liveBus = __commonJS({
|
|
|
5292
5337
|
return [override];
|
|
5293
5338
|
const home = os6.homedir();
|
|
5294
5339
|
return [
|
|
5295
|
-
|
|
5296
|
-
|
|
5297
|
-
|
|
5340
|
+
path16.join(home, ".ascenda", "live.sock"),
|
|
5341
|
+
path16.join(home, "Library", "Containers", APP_BUNDLE_ID2, "Data", ".ascenda", "live.sock"),
|
|
5342
|
+
path16.join(home, "Library", "Containers", exports.SAVER_HOST_BUNDLE_ID, "Data", "l.sock")
|
|
5298
5343
|
];
|
|
5299
5344
|
}
|
|
5300
5345
|
function existingSocketCandidates() {
|
|
@@ -5303,7 +5348,7 @@ var require_liveBus = __commonJS({
|
|
|
5303
5348
|
return candidates;
|
|
5304
5349
|
return candidates.filter((candidate) => {
|
|
5305
5350
|
try {
|
|
5306
|
-
return
|
|
5351
|
+
return fs16.statSync(candidate).isSocket();
|
|
5307
5352
|
} catch {
|
|
5308
5353
|
return false;
|
|
5309
5354
|
}
|
|
@@ -5830,9 +5875,9 @@ var require_cliAgentSetup = __commonJS({
|
|
|
5830
5875
|
exports.findStaleHookCommands = findStaleHookCommands;
|
|
5831
5876
|
exports.cliAgentRegistrations = cliAgentRegistrations;
|
|
5832
5877
|
var crypto = __importStar(__require("crypto"));
|
|
5833
|
-
var
|
|
5878
|
+
var fs16 = __importStar(__require("fs"));
|
|
5834
5879
|
var os6 = __importStar(__require("os"));
|
|
5835
|
-
var
|
|
5880
|
+
var path16 = __importStar(__require("path"));
|
|
5836
5881
|
var collectorVersion_1 = require_collectorVersion();
|
|
5837
5882
|
var credentials_1 = require_credentials();
|
|
5838
5883
|
var eventLog_1 = require_eventLog();
|
|
@@ -5960,7 +6005,7 @@ ${(0, setupDisclosure_1.renderSetupDisclosure)({ sends: spec.sends, displayName:
|
|
|
5960
6005
|
if (options.dryRun) {
|
|
5961
6006
|
row("info", "moved", `would remove the copy in ${(0, hookRunner_1.tidyHomePath)(otherFile, os6.homedir())}, so each event runs once`);
|
|
5962
6007
|
} else if (removeOurHookEntries(otherFile, spec)) {
|
|
5963
|
-
row("ok", "moved", `removed the copy in ${(0, hookRunner_1.tidyHomePath)(otherFile, os6.homedir())}, so each event runs once ${ui.dim("(backup beside it)")}`);
|
|
6008
|
+
row("ok", "moved", `removed the copy in ${(0, hookRunner_1.tidyHomePath)(otherFile, os6.homedir())}, so each event runs once${spec.settings.owned ? "" : ` ${ui.dim("(backup beside it)")}`}`);
|
|
5964
6009
|
} else {
|
|
5965
6010
|
row("warn", "note", `${(0, hookRunner_1.tidyHomePath)(otherFile, os6.homedir())} registers these hooks too, so each event runs twice.`);
|
|
5966
6011
|
detail("", `Remove the ${spec.binaryName} entries from one of the two files.`);
|
|
@@ -6013,7 +6058,7 @@ ${(0, setupDisclosure_1.renderSetupDisclosure)({ sends: spec.sends, displayName:
|
|
|
6013
6058
|
return 0;
|
|
6014
6059
|
}
|
|
6015
6060
|
function isHomeProject(options) {
|
|
6016
|
-
return options.scope === "project" &&
|
|
6061
|
+
return options.scope === "project" && path16.resolve(options.projectDir) === path16.resolve(os6.homedir());
|
|
6017
6062
|
}
|
|
6018
6063
|
function parseArgs2(argv, spec) {
|
|
6019
6064
|
const options = {
|
|
@@ -6068,7 +6113,7 @@ ${(0, setupDisclosure_1.renderSetupDisclosure)({ sends: spec.sends, displayName:
|
|
|
6068
6113
|
break;
|
|
6069
6114
|
}
|
|
6070
6115
|
case "--project-dir":
|
|
6071
|
-
options.projectDir =
|
|
6116
|
+
options.projectDir = path16.resolve(next());
|
|
6072
6117
|
break;
|
|
6073
6118
|
case "--dry-run":
|
|
6074
6119
|
options.dryRun = true;
|
|
@@ -6165,7 +6210,7 @@ ${usage(spec)}`);
|
|
|
6165
6210
|
const toolInstallationId = existingId ?? `${spec.toolType}:${crypto.randomUUID()}`;
|
|
6166
6211
|
let attempt;
|
|
6167
6212
|
try {
|
|
6168
|
-
attempt = await (0, pairingStudyJoin_1.createPairingAttempt)(apiBaseUrl, toolInstallationId, spec.toolType,
|
|
6213
|
+
attempt = await (0, pairingStudyJoin_1.createPairingAttempt)(apiBaseUrl, toolInstallationId, spec.toolType, spec.displayName);
|
|
6169
6214
|
} catch (error) {
|
|
6170
6215
|
console.error(`
|
|
6171
6216
|
Could not reach ${apiBaseUrl} to pair: ${error instanceof Error ? error.message : String(error)}`);
|
|
@@ -6231,9 +6276,9 @@ Pairing ${status.status}. Run setup again.`);
|
|
|
6231
6276
|
}
|
|
6232
6277
|
function writeHookSettings(settingsFile, binary, spec, dryRun) {
|
|
6233
6278
|
let settings = { ...spec.settings.scaffold ?? {} };
|
|
6234
|
-
const exists =
|
|
6235
|
-
if (exists) {
|
|
6236
|
-
const raw =
|
|
6279
|
+
const exists = fs16.existsSync(settingsFile);
|
|
6280
|
+
if (exists && !spec.settings.owned) {
|
|
6281
|
+
const raw = fs16.readFileSync(settingsFile, "utf8").trim();
|
|
6237
6282
|
if (raw) {
|
|
6238
6283
|
try {
|
|
6239
6284
|
settings = JSON.parse(raw);
|
|
@@ -6245,14 +6290,14 @@ ${settingsFile} is not valid JSON. Fix or move it, then run setup again.`);
|
|
|
6245
6290
|
}
|
|
6246
6291
|
}
|
|
6247
6292
|
const command = hookCommand(binary, spec);
|
|
6248
|
-
const hooks = { ...settings.hooks ?? {} };
|
|
6293
|
+
const hooks = spec.settings.owned ? {} : { ...settings.hooks ?? {} };
|
|
6249
6294
|
for (const event of spec.hookEvents) {
|
|
6250
6295
|
hooks[event] = placeOurEntry(hooks[event] ?? [], spec.settings.entry(command, event), spec);
|
|
6251
6296
|
}
|
|
6252
6297
|
const updated = { ...settings, hooks };
|
|
6253
6298
|
const serialised = `${JSON.stringify(updated, null, 2)}
|
|
6254
6299
|
`;
|
|
6255
|
-
if (exists &&
|
|
6300
|
+
if (exists && fs16.readFileSync(settingsFile, "utf8") === serialised)
|
|
6256
6301
|
return false;
|
|
6257
6302
|
if (dryRun) {
|
|
6258
6303
|
console.log(`
|
|
@@ -6260,6 +6305,11 @@ ${settingsFile} is not valid JSON. Fix or move it, then run setup again.`);
|
|
|
6260
6305
|
${serialised}`);
|
|
6261
6306
|
return true;
|
|
6262
6307
|
}
|
|
6308
|
+
if (spec.settings.owned) {
|
|
6309
|
+
fs16.mkdirSync(path16.dirname(settingsFile), { recursive: true });
|
|
6310
|
+
(0, hookRunner_1.writeAtomically)(settingsFile, serialised, 420);
|
|
6311
|
+
return true;
|
|
6312
|
+
}
|
|
6263
6313
|
(0, settingsFile_1.replaceSettingsFile)(settingsFile, serialised);
|
|
6264
6314
|
return true;
|
|
6265
6315
|
}
|
|
@@ -6400,7 +6450,7 @@ ${serialised}`);
|
|
|
6400
6450
|
}
|
|
6401
6451
|
function readSettings(settingsFile) {
|
|
6402
6452
|
try {
|
|
6403
|
-
return JSON.parse(
|
|
6453
|
+
return JSON.parse(fs16.readFileSync(settingsFile, "utf8"));
|
|
6404
6454
|
} catch {
|
|
6405
6455
|
return {};
|
|
6406
6456
|
}
|
|
@@ -6419,7 +6469,7 @@ ${serialised}`);
|
|
|
6419
6469
|
console.log(`pairing ${credentials?.toolInstallationId ?? "\u2014 not paired"}${localOnly ? " (installed, not paired \u2014 local features active, telemetry inactive)" : ""}`);
|
|
6420
6470
|
console.log(`token ${localOnly ? "\u2014 none needed until this install is paired" : tokenFile && (0, tokenStore_1.readTokenFile)(tokenFile) ? "present" : "\u2014 missing"}`);
|
|
6421
6471
|
console.log(`event log ${(0, eventLog_1.describeEventLog)((0, eventLog_1.resolveEventLog)({ localOnly }), `npx ${spec.packageName} setup`)}`);
|
|
6422
|
-
console.log(`hook binary ${
|
|
6472
|
+
console.log(`hook binary ${fs16.existsSync(binary) ? binary : "\u2014 not installed"}`);
|
|
6423
6473
|
const node = process.platform === "win32" ? void 0 : (0, hookRunner_1.resolveHookNode)(binary);
|
|
6424
6474
|
if (node) {
|
|
6425
6475
|
console.log(node.problem ? `node \u2014 ${node.problem}. Install Node 20 or newer, then run setup again` : `node ${node.node} (${node.version}, ${node.how === "recorded" ? "recorded at setup" : "found by the launcher"})`);
|
|
@@ -6466,7 +6516,7 @@ ${serialised}`);
|
|
|
6466
6516
|
await notices.markShown();
|
|
6467
6517
|
const paired = localOnly || credentials?.toolInstallationId !== void 0;
|
|
6468
6518
|
const wired = registered === spec.hookEvents.length || options.scope === "project" && elsewhere === spec.hookEvents.length;
|
|
6469
|
-
const healthy = paired && wired &&
|
|
6519
|
+
const healthy = paired && wired && fs16.existsSync(binary) && !stale.length && !node?.problem && trustLines.length === 0;
|
|
6470
6520
|
return healthy ? 0 : 1;
|
|
6471
6521
|
}
|
|
6472
6522
|
function countRegistered(settings, spec) {
|
|
@@ -6487,7 +6537,7 @@ ${serialised}`);
|
|
|
6487
6537
|
file: (0, hookRunner_1.tidyHomePath)(file, home),
|
|
6488
6538
|
registered,
|
|
6489
6539
|
scope,
|
|
6490
|
-
homeProject: scope === "project" &&
|
|
6540
|
+
homeProject: scope === "project" && path16.resolve(projectDir) === path16.resolve(home)
|
|
6491
6541
|
});
|
|
6492
6542
|
}
|
|
6493
6543
|
return found;
|
|
@@ -6514,6 +6564,15 @@ ${serialised}`);
|
|
|
6514
6564
|
if (found.length)
|
|
6515
6565
|
lines.push("", ...found);
|
|
6516
6566
|
}
|
|
6567
|
+
if (spec.doctorExtras) {
|
|
6568
|
+
try {
|
|
6569
|
+
const extra = spec.doctorExtras(ui);
|
|
6570
|
+
if (extra.length)
|
|
6571
|
+
lines.push("", ...extra);
|
|
6572
|
+
} catch (error) {
|
|
6573
|
+
lines.push("", ` ${spec.displayName} checks could not run: ${error instanceof Error ? error.message : String(error)}`);
|
|
6574
|
+
}
|
|
6575
|
+
}
|
|
6517
6576
|
lines.push("", ...accountLines(ui, spec));
|
|
6518
6577
|
const localOnly = (0, credentials_1.isLocalOnlyHostInstall)(spec.host, (id) => (0, tokenStore_1.readTokenFile)((0, tokenStore_1.defaultTokenFilePath)(id)) !== void 0);
|
|
6519
6578
|
lines.push("", ` ${ui.bold("Local events")} ${(0, eventLog_1.describeEventLog)((0, eventLog_1.resolveEventLog)({ localOnly }), `npx ${spec.packageName} setup`)}`);
|
|
@@ -6567,10 +6626,14 @@ ${serialised}`);
|
|
|
6567
6626
|
];
|
|
6568
6627
|
}
|
|
6569
6628
|
function removeOurHookEntries(settingsFile, spec) {
|
|
6570
|
-
if (!
|
|
6629
|
+
if (!fs16.existsSync(settingsFile))
|
|
6571
6630
|
return true;
|
|
6631
|
+
if (spec.settings.owned) {
|
|
6632
|
+
fs16.rmSync(settingsFile, { force: true });
|
|
6633
|
+
return true;
|
|
6634
|
+
}
|
|
6572
6635
|
try {
|
|
6573
|
-
const settings = JSON.parse(
|
|
6636
|
+
const settings = JSON.parse(fs16.readFileSync(settingsFile, "utf8"));
|
|
6574
6637
|
const hooks = { ...settings.hooks ?? {} };
|
|
6575
6638
|
for (const event of Object.keys(hooks)) {
|
|
6576
6639
|
const kept = withoutOurEntries(hooks[event], spec);
|
|
@@ -6591,12 +6654,12 @@ ${serialised}`);
|
|
|
6591
6654
|
}
|
|
6592
6655
|
function uninstall(options, spec) {
|
|
6593
6656
|
const settingsFile = spec.settings.settingsPath(options.scope, options.projectDir);
|
|
6594
|
-
if (
|
|
6657
|
+
if (fs16.existsSync(settingsFile)) {
|
|
6595
6658
|
if (!removeOurHookEntries(settingsFile, spec)) {
|
|
6596
6659
|
console.error(`could not parse ${settingsFile} \u2014 remove the ascenda hook entries by hand`);
|
|
6597
6660
|
return 1;
|
|
6598
6661
|
}
|
|
6599
|
-
console.log(`hooks removed from ${settingsFile}`);
|
|
6662
|
+
console.log(spec.settings.owned ? `removed ${settingsFile}` : `hooks removed from ${settingsFile}`);
|
|
6600
6663
|
}
|
|
6601
6664
|
for (const file of (0, hookRunner_1.removeHookRunner)(spec.binaryName)) {
|
|
6602
6665
|
if (!file.endsWith(".node") && !file.endsWith(".no-node"))
|
|
@@ -6606,7 +6669,7 @@ ${serialised}`);
|
|
|
6606
6669
|
(0, credentials_1.removeHostCredentials)(spec.host);
|
|
6607
6670
|
console.log(`removed tools.${spec.host} from ${(0, credentials_1.credentialsFilePath)()}`);
|
|
6608
6671
|
}
|
|
6609
|
-
console.log(`tokens left in ${
|
|
6672
|
+
console.log(`tokens left in ${path16.join((0, tokenStore_1.ascendaHome)(), "tokens")} \u2014 revoke in the Ascenda app to invalidate them`);
|
|
6610
6673
|
return 0;
|
|
6611
6674
|
}
|
|
6612
6675
|
}
|
|
@@ -6658,12 +6721,12 @@ var require_turnState = __commonJS({
|
|
|
6658
6721
|
exports.readTurnPromptId = readTurnPromptId;
|
|
6659
6722
|
exports.consumeTurnDurationMs = consumeTurnDurationMs;
|
|
6660
6723
|
var crypto_1 = __require("crypto");
|
|
6661
|
-
var
|
|
6662
|
-
var
|
|
6724
|
+
var fs16 = __importStar(__require("fs"));
|
|
6725
|
+
var path16 = __importStar(__require("path"));
|
|
6663
6726
|
var tokenStore_1 = require_tokenStore();
|
|
6664
|
-
var stateDir = () => process.env.ASCENDA_STATE_DIR ??
|
|
6727
|
+
var stateDir = () => process.env.ASCENDA_STATE_DIR ?? path16.join((0, tokenStore_1.ascendaHome)(), "state");
|
|
6665
6728
|
function turnFile(agent, sessionId) {
|
|
6666
|
-
return
|
|
6729
|
+
return path16.join(stateDir(), `${sanitize(agent)}-turn-${sanitize(sessionId)}`);
|
|
6667
6730
|
}
|
|
6668
6731
|
function sanitize(value) {
|
|
6669
6732
|
return value.replace(/[^a-zA-Z0-9._-]/g, "_");
|
|
@@ -6673,8 +6736,8 @@ var require_turnState = __commonJS({
|
|
|
6673
6736
|
return void 0;
|
|
6674
6737
|
try {
|
|
6675
6738
|
const promptId = (0, crypto_1.randomUUID)();
|
|
6676
|
-
|
|
6677
|
-
|
|
6739
|
+
fs16.mkdirSync(stateDir(), { recursive: true });
|
|
6740
|
+
fs16.writeFileSync(turnFile(agent, sessionId), `${now} ${promptId}`, { encoding: "utf8", mode: 384 });
|
|
6678
6741
|
return promptId;
|
|
6679
6742
|
} catch {
|
|
6680
6743
|
return void 0;
|
|
@@ -6684,7 +6747,7 @@ var require_turnState = __commonJS({
|
|
|
6684
6747
|
if (!sessionId)
|
|
6685
6748
|
return void 0;
|
|
6686
6749
|
try {
|
|
6687
|
-
const id =
|
|
6750
|
+
const id = fs16.readFileSync(turnFile(agent, sessionId), "utf8").trim().split(/\s+/)[1];
|
|
6688
6751
|
return id && /^[A-Za-z0-9_-]{1,128}$/.test(id) ? id : void 0;
|
|
6689
6752
|
} catch {
|
|
6690
6753
|
return void 0;
|
|
@@ -6695,8 +6758,8 @@ var require_turnState = __commonJS({
|
|
|
6695
6758
|
return void 0;
|
|
6696
6759
|
const file = turnFile(agent, sessionId);
|
|
6697
6760
|
try {
|
|
6698
|
-
const started = Number(
|
|
6699
|
-
|
|
6761
|
+
const started = Number(fs16.readFileSync(file, "utf8").trim().split(/\s+/)[0]);
|
|
6762
|
+
fs16.rmSync(file, { force: true });
|
|
6700
6763
|
if (!Number.isFinite(started) || started <= 0 || started > now)
|
|
6701
6764
|
return void 0;
|
|
6702
6765
|
return now - started;
|
|
@@ -6752,30 +6815,30 @@ var require_pluginBundle = __commonJS({
|
|
|
6752
6815
|
exports.pluginBundlePaths = pluginBundlePaths;
|
|
6753
6816
|
exports.installPluginBundle = installPluginBundle;
|
|
6754
6817
|
exports.describePluginBundleOutcome = describePluginBundleOutcome;
|
|
6755
|
-
var
|
|
6756
|
-
var
|
|
6818
|
+
var fs16 = __importStar(__require("fs"));
|
|
6819
|
+
var path16 = __importStar(__require("path"));
|
|
6757
6820
|
var collectorVersion_1 = require_collectorVersion();
|
|
6758
6821
|
var hookRunner_1 = require_hookRunner();
|
|
6759
6822
|
var tokenStore_1 = require_tokenStore();
|
|
6760
6823
|
function pluginBundlePaths(name) {
|
|
6761
|
-
const base =
|
|
6824
|
+
const base = path16.join((0, tokenStore_1.ascendaHome)(), "plugin", name);
|
|
6762
6825
|
return { bundle: `${base}.mjs`, version: `${base}.version`, checked: `${base}.checked` };
|
|
6763
6826
|
}
|
|
6764
6827
|
function installPluginBundle(options) {
|
|
6765
6828
|
const paths = pluginBundlePaths(options.name);
|
|
6766
|
-
const source =
|
|
6829
|
+
const source = path16.resolve(options.source ?? process.argv[1]);
|
|
6767
6830
|
const incoming = options.version ?? collectorVersion_1.COLLECTOR_VERSION;
|
|
6768
6831
|
const installed = readVersion(paths.version);
|
|
6769
|
-
const present =
|
|
6770
|
-
if (source ===
|
|
6832
|
+
const present = fs16.existsSync(paths.bundle);
|
|
6833
|
+
if (source === path16.resolve(paths.bundle))
|
|
6771
6834
|
return { kind: "current", version: installed ?? incoming };
|
|
6772
6835
|
if (present && installed && (0, hookRunner_1.isDowngrade)(installed, incoming))
|
|
6773
6836
|
return { kind: "kept-newer", installed, incoming };
|
|
6774
|
-
const contents =
|
|
6775
|
-
if (present && installed === incoming && contents.equals(
|
|
6837
|
+
const contents = fs16.readFileSync(source);
|
|
6838
|
+
if (present && installed === incoming && contents.equals(fs16.readFileSync(paths.bundle))) {
|
|
6776
6839
|
return { kind: "current", version: incoming };
|
|
6777
6840
|
}
|
|
6778
|
-
|
|
6841
|
+
fs16.mkdirSync(path16.dirname(paths.bundle), { recursive: true });
|
|
6779
6842
|
(0, hookRunner_1.writeAtomically)(paths.bundle, contents, 420);
|
|
6780
6843
|
(0, hookRunner_1.writeAtomically)(paths.version, `${incoming}
|
|
6781
6844
|
`, 420);
|
|
@@ -6793,7 +6856,7 @@ var require_pluginBundle = __commonJS({
|
|
|
6793
6856
|
}
|
|
6794
6857
|
function readVersion(file) {
|
|
6795
6858
|
try {
|
|
6796
|
-
return
|
|
6859
|
+
return fs16.readFileSync(file, "utf8").trim() || void 0;
|
|
6797
6860
|
} catch {
|
|
6798
6861
|
return void 0;
|
|
6799
6862
|
}
|
|
@@ -6849,14 +6912,14 @@ var require_agentProcess = __commonJS({
|
|
|
6849
6912
|
exports.findAgentPid = findAgentPid;
|
|
6850
6913
|
exports.livePidFields = livePidFields;
|
|
6851
6914
|
var child_process_1 = __require("child_process");
|
|
6852
|
-
var
|
|
6915
|
+
var path16 = __importStar(__require("path"));
|
|
6853
6916
|
exports.AGENT_PROCESS = {
|
|
6854
6917
|
claude_code: {
|
|
6855
|
-
executable: (command) =>
|
|
6918
|
+
executable: (command) => path16.basename(command) === "claude" || /\/claude\/versions\/[^/]+$/.test(command) || /\/@anthropic-ai\/claude-code\/bin\/claude\.exe$/.test(command),
|
|
6856
6919
|
scriptMarkers: ["@anthropic-ai/claude-code"]
|
|
6857
6920
|
},
|
|
6858
6921
|
codex: {
|
|
6859
|
-
executable: (command) => /^codex(-(aarch64|x86_64)-apple-darwin)?$/.test(
|
|
6922
|
+
executable: (command) => /^codex(-(aarch64|x86_64)-apple-darwin)?$/.test(path16.basename(command)),
|
|
6860
6923
|
args: (args) => !/\s(app-server|mcp-server)(\s|$)/.test(args)
|
|
6861
6924
|
},
|
|
6862
6925
|
gemini_cli: {
|
|
@@ -6910,7 +6973,7 @@ var require_agentProcess = __commonJS({
|
|
|
6910
6973
|
if (rule.executable(info.command)) {
|
|
6911
6974
|
return accepts(rule, rule.args ? argsLookup(pid) : "") ? { pid, match: "executable" } : void 0;
|
|
6912
6975
|
}
|
|
6913
|
-
if (markers.length > 0 && SCRIPT_RUNTIME.test(
|
|
6976
|
+
if (markers.length > 0 && SCRIPT_RUNTIME.test(path16.basename(info.command))) {
|
|
6914
6977
|
const args = argsLookup(pid);
|
|
6915
6978
|
const marker = args === void 0 ? void 0 : scriptMarkerIn(args, markers);
|
|
6916
6979
|
if (marker !== void 0) {
|
|
@@ -6949,7 +7012,7 @@ var require_out3 = __commonJS({
|
|
|
6949
7012
|
exports.shouldAnnounceFailure = exports.recordSendOutcome = exports.readCollectorState = exports.defaultStateFilePath = exports.tokenExpiryFilePath = exports.readTokenFile = exports.readTokenExpiry = exports.persistEventWriteToken = exports.listPersistedToolInstallationIds = exports.defaultTokenFilePath = exports.ascendaHome = exports.EVENT_TOKEN_TTL_MS = exports.recordTurnStart = exports.readTurnPromptId = exports.consumeTurnDurationMs = exports.writeTopLevelCredentials = exports.writeMachineCredentials = exports.writeRepoKeysSetting = exports.writeEventLogSetting = exports.writeHostCredentials = exports.removeHostCredentials = exports.readMachineCredentials = exports.readHostCredentials = exports.isLocalOnlyHostInstall = exports.credentialsFilePath = exports.renderSetupDisclosure = exports.REFUSALS = exports.FREE_TEXT_KEYS = exports.FAMILY_SENTENCES = exports.ALWAYS_SENT = exports.writeHookSettings = exports.trustProblemLines = exports.runCliAgentSetup = exports.registeredHookSets = exports.ourHookPositions = exports.isCliAgentManagementCommand = exports.findStaleHookCommands = exports.cliAgentHookBinPath = exports.resolveContextHashes = exports.resolveCliAgentInstallationId = exports.withPromptId = exports.withForgeKeys = exports.loadCliAgentConfig = exports.flushHookOutbox = exports.deliverHookEvents = exports.MissingInstallationIdError = exports.DEFAULT_API_BASE_URL = exports.resolveEventLogPath = exports.resolveEventLog = exports.parseEventLogFlag = void 0;
|
|
6950
7013
|
exports.saverReplayPath = exports.saverContainerDir = exports.readSaverStatuses = exports.probeSocket = exports.heldForSaver = exports.holdForSaver = exports.LIVE_BUS_BACKGROUND_TRUST_MS = exports.liveBusSocketCandidates = exports.liveBusSocketPath = exports.bucketPromptSize = exports.deliverLine = exports.emitLiveSignal = exports.repoKeysEnabled = exports.deriveForgeKeysForCwd = exports.REPO_KEYS_ENV_VAR = exports.recordForgeProjectAlias = exports.forgeFullNameFromConfig = exports.readForgeFullName = exports.parseForgeFullName = exports.forgeBranchKey = exports.forgeRepoKey = exports.forgeProjectHash = exports.workContextRegistryFilePath = exports.readWorkContextRegistry = exports.recordWorkContextAlias = exports.recordWorkContext = exports.readBranchName = exports.normalizeBranchName = exports.deriveBranchHashForCwd = exports.deriveBranchHash = exports.deriveWorkContext = exports.hashWithMachineSalt = exports.readOrCreateMachineSalt = exports.machineSaltFilePath = exports.fixedTimeProvider = exports.systemTimeProvider = exports.enforceOutboxBounds = exports.claimOutbox = exports.readOutboxSummary = exports.appendToOutbox = exports.defaultOutboxFilePath = exports.outboxDrainEnabled = exports.DEFAULT_OUTBOX_DRAIN_BATCH_SIZE = exports.DEFAULT_OUTBOX_MAX_AGE_MS = exports.DEFAULT_OUTBOX_MAX_ENTRIES = exports.OUTBOX_DRAIN_ENV_VAR = exports.recordOutboxDiscard = exports.unresolvedToolInstallationId = exports.unresolvedStateFilePath = exports.markFailureNotified = void 0;
|
|
6951
7014
|
exports.isRetryableStatus = exports.parseIngestResponse = exports.postToolEventsBatch = exports.postToolEvent = exports.renewToolToken = exports.getStudyJoinStatus = exports.getPairingStatus = exports.createPairingSession = exports.AscendaApiError = exports.scriptMarkerIn = exports.psLookup = exports.psArgsLookup = exports.livePidFields = exports.findAgentProcess = exports.findAgentPid = exports.AGENT_PROCESS = exports.readViaPlugin = exports.readHookSet = exports.isHookSet = exports.hookSetOfCommand = exports.hookSetChanges = exports.hookSetArgument = exports.describeHookSetChanges = exports.UNVERSIONED_HOOK_SET = exports.HOOK_SET_FLAG = exports.liveSignalDoctorLines = exports.doctorRow = exports.DOCTOR_VALUE_COLUMN = exports.pluginBundlePaths = exports.installPluginBundle = exports.describePluginBundleOutcome = exports.replaceSettingsFile = exports.writeAtomically = exports.tidyHomePath = exports.stampLastHook = exports.resolveHookNode = exports.removeHookRunner = exports.readLastHook = exports.lastHookPath = exports.isDowngrade = exports.installHookRunner = exports.hookRunnerPaths = exports.hookRunnerCommand = exports.hookLauncherScript = exports.describeAge = exports.terminalStyle = exports.colourEnabled = exports.SAVER_REPLAY_WINDOW_MS = exports.saverSupportDir = exports.saverStatusDir = void 0;
|
|
6952
|
-
exports.writePairingJoinOutcome = exports.settleStudyJoin = exports.pairingJoinOutcome = exports.pairingAttemptLines = exports.createPairingAttempt = exports.PAIR_ORG_JOIN_CODE_ENV = exports.PAIR_JOIN_OUTCOME_FILE_ENV = exports.studyJoinConfirmUrl = exports.pairingConfirmUrl = exports.pairingConfirmLines = exports.runStudyJoin = exports.formatWindow = exports.describeStudyGrant = exports.describeStudyKind = exports.describeStudyJoinRefusal = exports.studyNoticeStatus = exports.runStudyObjection = exports.renderStudyNotices = exports.NOTICED_PURPOSES = exports.renderInitiatives = exports.initiativesStatusLines = exports.INITIATIVE_COPY = exports.startStudyJoin = exports.setStudyObjection = exports.markStudyNoticeShown = exports.readStudyNotices = exports.readInitiatives = void 0;
|
|
7015
|
+
exports.writePairingJoinOutcome = exports.settleStudyJoin = exports.pairingJoinOutcome = exports.pairingAttemptLines = exports.createPairingAttempt = exports.PAIR_ORG_JOIN_CODE_ENV = exports.PAIR_JOIN_OUTCOME_FILE_ENV = exports.studyJoinConfirmUrl = exports.pairingConfirmUrl = exports.pairingConfirmLines = exports.runStudyJoin = exports.gitOfferLine = exports.formatWindow = exports.describeStudyGrant = exports.describeStudyKind = exports.describeStudyJoinRefusal = exports.studyNoticeStatus = exports.runStudyObjection = exports.renderStudyNotices = exports.NOTICED_PURPOSES = exports.renderInitiatives = exports.initiativesStatusLines = exports.INITIATIVE_COPY = exports.startStudyJoin = exports.setStudyObjection = exports.markStudyNoticeShown = exports.readStudyNotices = exports.readInitiatives = void 0;
|
|
6953
7016
|
var commandClassifier_1 = require_commandClassifier();
|
|
6954
7017
|
Object.defineProperty(exports, "classifyCommand", { enumerable: true, get: function() {
|
|
6955
7018
|
return commandClassifier_1.classifyCommand;
|
|
@@ -7640,6 +7703,9 @@ var require_out3 = __commonJS({
|
|
|
7640
7703
|
Object.defineProperty(exports, "formatWindow", { enumerable: true, get: function() {
|
|
7641
7704
|
return studyJoin_1.formatWindow;
|
|
7642
7705
|
} });
|
|
7706
|
+
Object.defineProperty(exports, "gitOfferLine", { enumerable: true, get: function() {
|
|
7707
|
+
return studyJoin_1.gitOfferLine;
|
|
7708
|
+
} });
|
|
7643
7709
|
Object.defineProperty(exports, "runStudyJoin", { enumerable: true, get: function() {
|
|
7644
7710
|
return studyJoin_1.runStudyJoin;
|
|
7645
7711
|
} });
|
|
@@ -7679,8 +7745,8 @@ var require_out3 = __commonJS({
|
|
|
7679
7745
|
});
|
|
7680
7746
|
|
|
7681
7747
|
// src/cli.ts
|
|
7682
|
-
import * as
|
|
7683
|
-
import * as
|
|
7748
|
+
import * as fs15 from "node:fs/promises";
|
|
7749
|
+
import * as path15 from "node:path";
|
|
7684
7750
|
|
|
7685
7751
|
// src/stores.ts
|
|
7686
7752
|
import * as os from "node:os";
|
|
@@ -7726,6 +7792,7 @@ function resolveStorePaths(home = os.homedir(), env = process.env) {
|
|
|
7726
7792
|
codexRoot,
|
|
7727
7793
|
codexSessions: path.join(codexRoot, "sessions"),
|
|
7728
7794
|
codexArchivedSessions: path.join(codexRoot, "archived_sessions"),
|
|
7795
|
+
copilotSessionState: path.join(home, ".copilot", "session-state"),
|
|
7729
7796
|
cursorStateDb: path.join(appSupport, "Cursor", "User", "globalStorage", "state.vscdb"),
|
|
7730
7797
|
cursorSearchDb: path.join(
|
|
7731
7798
|
appSupport,
|
|
@@ -7869,6 +7936,43 @@ async function scanCodex(paths) {
|
|
|
7869
7936
|
inv.notes.push("no rolling purge observed on rollouts; archived sessions are counted alongside live ones");
|
|
7870
7937
|
return inv;
|
|
7871
7938
|
}
|
|
7939
|
+
async function scanCopilotCli(paths) {
|
|
7940
|
+
const inv = {
|
|
7941
|
+
store: "copilot_cli",
|
|
7942
|
+
rootPath: paths.copilotSessionState,
|
|
7943
|
+
present: false,
|
|
7944
|
+
counts: {},
|
|
7945
|
+
notes: []
|
|
7946
|
+
};
|
|
7947
|
+
let entries;
|
|
7948
|
+
try {
|
|
7949
|
+
entries = await fs.readdir(paths.copilotSessionState, { withFileTypes: true });
|
|
7950
|
+
} catch {
|
|
7951
|
+
return inv;
|
|
7952
|
+
}
|
|
7953
|
+
const window = new Window();
|
|
7954
|
+
let sessionLogs = 0;
|
|
7955
|
+
let flatLogs = 0;
|
|
7956
|
+
let bytes = 0;
|
|
7957
|
+
for (const entry of entries) {
|
|
7958
|
+
const full = path2.join(paths.copilotSessionState, entry.name);
|
|
7959
|
+
const log = entry.isDirectory() && !entry.name.startsWith(".") ? path2.join(full, "events.jsonl") : null;
|
|
7960
|
+
const target = log ?? (entry.isFile() && entry.name.endsWith(".jsonl") ? full : null);
|
|
7961
|
+
if (!target) continue;
|
|
7962
|
+
const st = await statOrNull(target);
|
|
7963
|
+
if (!st) continue;
|
|
7964
|
+
if (log) sessionLogs += 1;
|
|
7965
|
+
else flatLogs += 1;
|
|
7966
|
+
bytes += st.size;
|
|
7967
|
+
window.see(st.mtime);
|
|
7968
|
+
}
|
|
7969
|
+
inv.present = true;
|
|
7970
|
+
inv.counts = { sessionLogs, flatLogs, bytes };
|
|
7971
|
+
inv.oldest = window.oldest?.toISOString();
|
|
7972
|
+
inv.newest = window.newest?.toISOString();
|
|
7973
|
+
inv.notes.push("no purge observed on session logs; a session in both shapes is read once");
|
|
7974
|
+
return inv;
|
|
7975
|
+
}
|
|
7872
7976
|
async function scanCursor(paths) {
|
|
7873
7977
|
const inv = {
|
|
7874
7978
|
store: "cursor",
|
|
@@ -7997,6 +8101,7 @@ async function scanAll(paths) {
|
|
|
7997
8101
|
return [
|
|
7998
8102
|
await scanClaudeCode(paths),
|
|
7999
8103
|
await scanCodex(paths),
|
|
8104
|
+
await scanCopilotCli(paths),
|
|
8000
8105
|
await scanCursor(paths),
|
|
8001
8106
|
await scanVsCode(paths),
|
|
8002
8107
|
await scanGit(paths)
|
|
@@ -8114,6 +8219,31 @@ async function snapshotVsCodeWorkspaceStorage(area, sourceRoot, label) {
|
|
|
8114
8219
|
}
|
|
8115
8220
|
return dest;
|
|
8116
8221
|
}
|
|
8222
|
+
async function snapshotCopilotSessionState(area, sourceRoot, label) {
|
|
8223
|
+
const dest = path3.join(area.root, label);
|
|
8224
|
+
await fs3.mkdir(dest, { recursive: true });
|
|
8225
|
+
let entries = [];
|
|
8226
|
+
try {
|
|
8227
|
+
entries = await fs3.readdir(sourceRoot, { withFileTypes: true });
|
|
8228
|
+
} catch {
|
|
8229
|
+
return dest;
|
|
8230
|
+
}
|
|
8231
|
+
for (const entry of entries) {
|
|
8232
|
+
if (entry.isFile() && entry.name.endsWith(".jsonl")) {
|
|
8233
|
+
await fs3.copyFile(path3.join(sourceRoot, entry.name), path3.join(dest, entry.name), CLONE);
|
|
8234
|
+
continue;
|
|
8235
|
+
}
|
|
8236
|
+
if (!entry.isDirectory() || entry.name.startsWith(".")) continue;
|
|
8237
|
+
for (const file of ["events.jsonl", "workspace.yaml"]) {
|
|
8238
|
+
try {
|
|
8239
|
+
await fs3.mkdir(path3.join(dest, entry.name), { recursive: true });
|
|
8240
|
+
await fs3.copyFile(path3.join(sourceRoot, entry.name, file), path3.join(dest, entry.name, file), CLONE);
|
|
8241
|
+
} catch {
|
|
8242
|
+
}
|
|
8243
|
+
}
|
|
8244
|
+
}
|
|
8245
|
+
return dest;
|
|
8246
|
+
}
|
|
8117
8247
|
var STAGING_KEEP = ["events.jsonl"];
|
|
8118
8248
|
async function entrySizeBytes(target) {
|
|
8119
8249
|
let st;
|
|
@@ -8229,12 +8359,16 @@ var STORE_SOURCE = {
|
|
|
8229
8359
|
// with `metadata.host: "codex"` (see STORE_HOST), and the import follows
|
|
8230
8360
|
// them so a historical Codex row and a live one are the same population.
|
|
8231
8361
|
codex: "cli_agent",
|
|
8362
|
+
// Same rule, and the host the live Copilot CLI hooks will send. Not
|
|
8363
|
+
// `copilot_otel`: that source is held for an OpenTelemetry route.
|
|
8364
|
+
copilot_cli: "cli_agent",
|
|
8232
8365
|
cursor: "cursor_mcp",
|
|
8233
8366
|
vscode: "vscode_extension",
|
|
8234
8367
|
git: "code_forge"
|
|
8235
8368
|
};
|
|
8236
8369
|
var STORE_HOST = {
|
|
8237
|
-
codex: "codex"
|
|
8370
|
+
codex: "codex",
|
|
8371
|
+
copilot_cli: "copilot_cli"
|
|
8238
8372
|
};
|
|
8239
8373
|
var HISTORICAL_PROVENANCE = {
|
|
8240
8374
|
direct: "historical_direct",
|
|
@@ -10355,10 +10489,539 @@ async function* extractCodex(snapshotDir, extractionId, options = {}) {
|
|
|
10355
10489
|
}
|
|
10356
10490
|
}
|
|
10357
10491
|
|
|
10358
|
-
// src/extractors/
|
|
10492
|
+
// src/extractors/copilotCli.ts
|
|
10359
10493
|
var import_tool_kit5 = __toESM(require_out3(), 1);
|
|
10360
10494
|
import * as fs6 from "node:fs/promises";
|
|
10361
10495
|
import * as path7 from "node:path";
|
|
10496
|
+
var KNOWN_COPILOT_LOG_VERSIONS = /* @__PURE__ */ new Set([1]);
|
|
10497
|
+
var KNOWN_COPILOT_EVENT_TYPES = /* @__PURE__ */ new Set([
|
|
10498
|
+
"session.start",
|
|
10499
|
+
"session.model_change",
|
|
10500
|
+
"session.auto_mode_resolved",
|
|
10501
|
+
"user.message",
|
|
10502
|
+
"assistant.message",
|
|
10503
|
+
"tool.execution_start",
|
|
10504
|
+
"tool.execution_complete",
|
|
10505
|
+
"permission.requested",
|
|
10506
|
+
"session.compaction_complete",
|
|
10507
|
+
"session.shutdown"
|
|
10508
|
+
]);
|
|
10509
|
+
var META_COPILOT_EVENT_TYPES = /* @__PURE__ */ new Set([
|
|
10510
|
+
"assistant.turn_start",
|
|
10511
|
+
"assistant.turn_end",
|
|
10512
|
+
"session.resume",
|
|
10513
|
+
"session.plan_changed",
|
|
10514
|
+
"session.compaction_start",
|
|
10515
|
+
"session.truncation",
|
|
10516
|
+
"session.usage_checkpoint",
|
|
10517
|
+
"system.message",
|
|
10518
|
+
"permission.completed",
|
|
10519
|
+
"subagent.started",
|
|
10520
|
+
"subagent.completed",
|
|
10521
|
+
"subagent.failed",
|
|
10522
|
+
"abort"
|
|
10523
|
+
]);
|
|
10524
|
+
var SKIPPED_COPILOT_EVENT_TYPES = /* @__PURE__ */ new Set(["hook.start", "hook.end"]);
|
|
10525
|
+
function asRecord2(value) {
|
|
10526
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : null;
|
|
10527
|
+
}
|
|
10528
|
+
function asNumber3(value) {
|
|
10529
|
+
return typeof value === "number" && Number.isFinite(value) ? value : 0;
|
|
10530
|
+
}
|
|
10531
|
+
function nonEmptyString2(value) {
|
|
10532
|
+
return typeof value === "string" && value.trim() !== "" ? value : null;
|
|
10533
|
+
}
|
|
10534
|
+
function sniffCopilotLine(line) {
|
|
10535
|
+
const trimmed = line.trim();
|
|
10536
|
+
if (trimmed === "") return { kind: "unparsed" };
|
|
10537
|
+
let parsed;
|
|
10538
|
+
try {
|
|
10539
|
+
parsed = JSON.parse(trimmed);
|
|
10540
|
+
} catch {
|
|
10541
|
+
return { kind: "unparsed" };
|
|
10542
|
+
}
|
|
10543
|
+
const record = asRecord2(parsed);
|
|
10544
|
+
if (!record || typeof record.type !== "string") return { kind: "unparsed" };
|
|
10545
|
+
const type = record.type;
|
|
10546
|
+
if (SKIPPED_COPILOT_EVENT_TYPES.has(type)) return { kind: "skipped", type };
|
|
10547
|
+
const occurredAt = typeof record.timestamp === "string" ? record.timestamp : null;
|
|
10548
|
+
if (META_COPILOT_EVENT_TYPES.has(type)) return { kind: "meta", type, occurredAt };
|
|
10549
|
+
if (!KNOWN_COPILOT_EVENT_TYPES.has(type)) return { kind: "unknown", type, occurredAt };
|
|
10550
|
+
return { kind: "event", type, occurredAt, data: asRecord2(record.data) ?? {} };
|
|
10551
|
+
}
|
|
10552
|
+
var WORKSPACE_KEYS = {
|
|
10553
|
+
cwd: "cwd",
|
|
10554
|
+
git_root: "gitRoot",
|
|
10555
|
+
branch: "branch",
|
|
10556
|
+
client_name: "clientName"
|
|
10557
|
+
};
|
|
10558
|
+
function readCopilotWorkspace(text) {
|
|
10559
|
+
const out = { cwd: null, gitRoot: null, branch: null, clientName: null };
|
|
10560
|
+
for (const line of text.split(/\r?\n/)) {
|
|
10561
|
+
const match = /^([a-z_]+):[ \t]*(.*?)[ \t]*$/.exec(line);
|
|
10562
|
+
if (!match) continue;
|
|
10563
|
+
const field = WORKSPACE_KEYS[match[1]];
|
|
10564
|
+
if (!field) continue;
|
|
10565
|
+
let value = match[2];
|
|
10566
|
+
if (value === "" || value === "~" || value === "null" || /^[|>]/.test(value)) continue;
|
|
10567
|
+
const quoted = /^(["'])(.*)\1$/.exec(value);
|
|
10568
|
+
if (quoted) value = quoted[2];
|
|
10569
|
+
if (value !== "") out[field] = value;
|
|
10570
|
+
}
|
|
10571
|
+
return out;
|
|
10572
|
+
}
|
|
10573
|
+
function copilotAutonomyModeOf(agentMode, permissionMode) {
|
|
10574
|
+
const agent = nonEmptyString2(agentMode);
|
|
10575
|
+
const permission = nonEmptyString2(permissionMode);
|
|
10576
|
+
if (!agent && !permission) return null;
|
|
10577
|
+
if (agent === "plan") return "plan";
|
|
10578
|
+
if (permission === "manual" && (agent === null || agent === "interactive")) return "default";
|
|
10579
|
+
return `copilot:${agent ?? "?"}/${permission ?? "?"}`;
|
|
10580
|
+
}
|
|
10581
|
+
function tokenCountOf(details, key) {
|
|
10582
|
+
return asNumber3(asRecord2(details[key])?.tokenCount);
|
|
10583
|
+
}
|
|
10584
|
+
function shutdownFiguresOf(data) {
|
|
10585
|
+
const out = {
|
|
10586
|
+
inputTokens: 0,
|
|
10587
|
+
outputTokens: 0,
|
|
10588
|
+
cacheReadTokens: 0,
|
|
10589
|
+
cacheCreationTokens: 0,
|
|
10590
|
+
tokensSeen: false,
|
|
10591
|
+
linesAdded: null,
|
|
10592
|
+
linesRemoved: null,
|
|
10593
|
+
filesChangedCount: null,
|
|
10594
|
+
totalApiDurationMs: null
|
|
10595
|
+
};
|
|
10596
|
+
const details = asRecord2(data.tokenDetails);
|
|
10597
|
+
if (details) {
|
|
10598
|
+
out.inputTokens = tokenCountOf(details, "input");
|
|
10599
|
+
out.outputTokens = tokenCountOf(details, "output");
|
|
10600
|
+
out.cacheReadTokens = tokenCountOf(details, "cache_read");
|
|
10601
|
+
out.cacheCreationTokens = tokenCountOf(details, "cache_write");
|
|
10602
|
+
out.tokensSeen = true;
|
|
10603
|
+
} else {
|
|
10604
|
+
const metrics = asRecord2(data.modelMetrics);
|
|
10605
|
+
for (const value of Object.values(metrics ?? {})) {
|
|
10606
|
+
const usage = asRecord2(asRecord2(value)?.usage);
|
|
10607
|
+
if (!usage) continue;
|
|
10608
|
+
const cacheRead = asNumber3(usage.cacheReadTokens);
|
|
10609
|
+
const cacheWrite = asNumber3(usage.cacheWriteTokens);
|
|
10610
|
+
out.inputTokens += Math.max(0, asNumber3(usage.inputTokens) - cacheRead - cacheWrite);
|
|
10611
|
+
out.outputTokens += asNumber3(usage.outputTokens);
|
|
10612
|
+
out.cacheReadTokens += cacheRead;
|
|
10613
|
+
out.cacheCreationTokens += cacheWrite;
|
|
10614
|
+
out.tokensSeen = true;
|
|
10615
|
+
}
|
|
10616
|
+
}
|
|
10617
|
+
const changes = asRecord2(data.codeChanges);
|
|
10618
|
+
if (changes) {
|
|
10619
|
+
if (typeof changes.linesAdded === "number") out.linesAdded = changes.linesAdded;
|
|
10620
|
+
if (typeof changes.linesRemoved === "number") out.linesRemoved = changes.linesRemoved;
|
|
10621
|
+
if (Array.isArray(changes.filesModified)) out.filesChangedCount = changes.filesModified.length;
|
|
10622
|
+
}
|
|
10623
|
+
if (typeof data.totalApiDurationMs === "number") out.totalApiDurationMs = data.totalApiDurationMs;
|
|
10624
|
+
return out;
|
|
10625
|
+
}
|
|
10626
|
+
function newFold3(sessionId) {
|
|
10627
|
+
return {
|
|
10628
|
+
sessionId,
|
|
10629
|
+
sourceVersion: null,
|
|
10630
|
+
selectedModel: null,
|
|
10631
|
+
contextCwd: null,
|
|
10632
|
+
contextGitRoot: null,
|
|
10633
|
+
contextBranch: null,
|
|
10634
|
+
firstTs: null,
|
|
10635
|
+
lastTs: null,
|
|
10636
|
+
humanPrompts: 0,
|
|
10637
|
+
afterHoursPrompts: 0,
|
|
10638
|
+
humanPromptTimestamps: [],
|
|
10639
|
+
subagentPrompts: 0,
|
|
10640
|
+
assistantTurns: 0,
|
|
10641
|
+
toolCallIds: /* @__PURE__ */ new Set(),
|
|
10642
|
+
toolCallCount: 0,
|
|
10643
|
+
subagentToolCallCount: 0,
|
|
10644
|
+
toolCalls: [],
|
|
10645
|
+
toolResults: 0,
|
|
10646
|
+
toolResultErrorCount: 0,
|
|
10647
|
+
compactionCount: 0,
|
|
10648
|
+
models: /* @__PURE__ */ new Map(),
|
|
10649
|
+
lastServedModel: null,
|
|
10650
|
+
modelSwitchCount: 0,
|
|
10651
|
+
shutdown: null,
|
|
10652
|
+
unknownLines: 0,
|
|
10653
|
+
metaLines: 0,
|
|
10654
|
+
unparsedLines: 0,
|
|
10655
|
+
timelinePoints: [],
|
|
10656
|
+
undatedTimelineLines: 0
|
|
10657
|
+
};
|
|
10658
|
+
}
|
|
10659
|
+
function sessionStartOf(lines) {
|
|
10660
|
+
for (const line of lines) {
|
|
10661
|
+
const sniffed = sniffCopilotLine(line);
|
|
10662
|
+
if (sniffed.kind === "event" && sniffed.type === "session.start") return sniffed.data;
|
|
10663
|
+
}
|
|
10664
|
+
return null;
|
|
10665
|
+
}
|
|
10666
|
+
function isReadableCopilotLog(start) {
|
|
10667
|
+
return start !== null && typeof start.version === "number" && KNOWN_COPILOT_LOG_VERSIONS.has(start.version);
|
|
10668
|
+
}
|
|
10669
|
+
function isSubagentTask(data) {
|
|
10670
|
+
return typeof data.source === "string" && data.source.startsWith("agent-");
|
|
10671
|
+
}
|
|
10672
|
+
function voteModel(fold, model) {
|
|
10673
|
+
if (!model) return;
|
|
10674
|
+
fold.models.set(model, (fold.models.get(model) ?? 0) + 1);
|
|
10675
|
+
}
|
|
10676
|
+
function foldLines(fold, lines) {
|
|
10677
|
+
let inForce = null;
|
|
10678
|
+
let posture = null;
|
|
10679
|
+
let startSeen = false;
|
|
10680
|
+
for (const line of lines) {
|
|
10681
|
+
const sniffed = sniffCopilotLine(line);
|
|
10682
|
+
if (sniffed.kind === "unparsed") {
|
|
10683
|
+
if (line.trim() !== "") fold.unparsedLines += 1;
|
|
10684
|
+
continue;
|
|
10685
|
+
}
|
|
10686
|
+
if (sniffed.kind === "skipped") continue;
|
|
10687
|
+
if (sniffed.kind === "meta") fold.metaLines += 1;
|
|
10688
|
+
if (sniffed.kind === "unknown") fold.unknownLines += 1;
|
|
10689
|
+
const occurredAt = sniffed.occurredAt;
|
|
10690
|
+
if (occurredAt) {
|
|
10691
|
+
if (!fold.firstTs || occurredAt < fold.firstTs) fold.firstTs = occurredAt;
|
|
10692
|
+
if (!fold.lastTs || occurredAt > fold.lastTs) fold.lastTs = occurredAt;
|
|
10693
|
+
}
|
|
10694
|
+
let humanHere = false;
|
|
10695
|
+
if (sniffed.kind === "event") {
|
|
10696
|
+
const data = sniffed.data;
|
|
10697
|
+
switch (sniffed.type) {
|
|
10698
|
+
case "session.start": {
|
|
10699
|
+
if (startSeen) break;
|
|
10700
|
+
startSeen = true;
|
|
10701
|
+
const version = nonEmptyString2(data.copilotVersion);
|
|
10702
|
+
fold.sourceVersion = version && version !== "unknown" ? version : null;
|
|
10703
|
+
fold.selectedModel = nonEmptyString2(data.selectedModel);
|
|
10704
|
+
inForce = fold.selectedModel === "auto" ? null : fold.selectedModel;
|
|
10705
|
+
const context = asRecord2(data.context);
|
|
10706
|
+
fold.contextCwd = nonEmptyString2(context?.cwd);
|
|
10707
|
+
fold.contextGitRoot = nonEmptyString2(context?.gitRoot);
|
|
10708
|
+
fold.contextBranch = nonEmptyString2(context?.branch);
|
|
10709
|
+
break;
|
|
10710
|
+
}
|
|
10711
|
+
case "session.model_change": {
|
|
10712
|
+
const next = nonEmptyString2(data.newModel);
|
|
10713
|
+
if (next) inForce = next === "auto" ? null : next;
|
|
10714
|
+
break;
|
|
10715
|
+
}
|
|
10716
|
+
case "session.auto_mode_resolved": {
|
|
10717
|
+
const chosen = nonEmptyString2(data.chosenModel);
|
|
10718
|
+
if (chosen) inForce = chosen;
|
|
10719
|
+
break;
|
|
10720
|
+
}
|
|
10721
|
+
case "user.message": {
|
|
10722
|
+
if (isSubagentTask(data)) {
|
|
10723
|
+
fold.subagentPrompts += 1;
|
|
10724
|
+
break;
|
|
10725
|
+
}
|
|
10726
|
+
fold.humanPrompts += 1;
|
|
10727
|
+
if (occurredAt && (0, import_tool_kit5.isOutsideBusinessHours)(new Date(occurredAt))) fold.afterHoursPrompts += 1;
|
|
10728
|
+
fold.humanPromptTimestamps.push(occurredAt);
|
|
10729
|
+
humanHere = true;
|
|
10730
|
+
break;
|
|
10731
|
+
}
|
|
10732
|
+
case "assistant.message": {
|
|
10733
|
+
fold.assistantTurns += 1;
|
|
10734
|
+
const model = nonEmptyString2(data.model) ?? inForce;
|
|
10735
|
+
voteModel(fold, model);
|
|
10736
|
+
if (model) {
|
|
10737
|
+
if (fold.lastServedModel && fold.lastServedModel !== model) fold.modelSwitchCount += 1;
|
|
10738
|
+
fold.lastServedModel = model;
|
|
10739
|
+
}
|
|
10740
|
+
break;
|
|
10741
|
+
}
|
|
10742
|
+
case "tool.execution_start": {
|
|
10743
|
+
const id = nonEmptyString2(data.toolCallId);
|
|
10744
|
+
if (id) {
|
|
10745
|
+
if (fold.toolCallIds.has(id)) break;
|
|
10746
|
+
fold.toolCallIds.add(id);
|
|
10747
|
+
}
|
|
10748
|
+
fold.toolCallCount += 1;
|
|
10749
|
+
if (nonEmptyString2(data.parentToolCallId)) fold.subagentToolCallCount += 1;
|
|
10750
|
+
voteModel(fold, nonEmptyString2(data.model) ?? inForce);
|
|
10751
|
+
if (occurredAt) {
|
|
10752
|
+
fold.toolCalls.push({
|
|
10753
|
+
at: occurredAt,
|
|
10754
|
+
name: sanitizeToolName(typeof data.toolName === "string" ? data.toolName : null)
|
|
10755
|
+
});
|
|
10756
|
+
}
|
|
10757
|
+
break;
|
|
10758
|
+
}
|
|
10759
|
+
case "tool.execution_complete": {
|
|
10760
|
+
fold.toolResults += 1;
|
|
10761
|
+
if (data.success === false) fold.toolResultErrorCount += 1;
|
|
10762
|
+
break;
|
|
10763
|
+
}
|
|
10764
|
+
case "permission.requested": {
|
|
10765
|
+
const mode = copilotAutonomyModeOf(data.agentMode, data.permissionMode);
|
|
10766
|
+
if (mode) posture = mode;
|
|
10767
|
+
break;
|
|
10768
|
+
}
|
|
10769
|
+
case "session.compaction_complete": {
|
|
10770
|
+
if (data.success !== false) fold.compactionCount += 1;
|
|
10771
|
+
break;
|
|
10772
|
+
}
|
|
10773
|
+
case "session.shutdown": {
|
|
10774
|
+
fold.shutdown = shutdownFiguresOf(data);
|
|
10775
|
+
break;
|
|
10776
|
+
}
|
|
10777
|
+
default:
|
|
10778
|
+
break;
|
|
10779
|
+
}
|
|
10780
|
+
}
|
|
10781
|
+
if (occurredAt) {
|
|
10782
|
+
const ms = Date.parse(occurredAt);
|
|
10783
|
+
if (Number.isFinite(ms)) {
|
|
10784
|
+
fold.timelinePoints.push({ at: ms, human: humanHere, agentOutput: !humanHere, autonomyMode: posture });
|
|
10785
|
+
} else {
|
|
10786
|
+
fold.undatedTimelineLines += 1;
|
|
10787
|
+
}
|
|
10788
|
+
}
|
|
10789
|
+
}
|
|
10790
|
+
}
|
|
10791
|
+
function topModel3(models) {
|
|
10792
|
+
let best = null;
|
|
10793
|
+
let bestCount = 0;
|
|
10794
|
+
for (const [model, count] of models) {
|
|
10795
|
+
if (count > bestCount) {
|
|
10796
|
+
best = model;
|
|
10797
|
+
bestCount = count;
|
|
10798
|
+
}
|
|
10799
|
+
}
|
|
10800
|
+
return best;
|
|
10801
|
+
}
|
|
10802
|
+
var ACTIVE_GAP_MS3 = DEFAULT_ACTIVE_GAP_MS;
|
|
10803
|
+
var RAPID_REPROMPT_MS3 = 2 * 6e4;
|
|
10804
|
+
function rapidRepromptCountOf3(fold) {
|
|
10805
|
+
const timestamps = fold.humanPromptTimestamps.filter((t) => t !== null);
|
|
10806
|
+
let count = 0;
|
|
10807
|
+
for (let i = 1; i < timestamps.length; i++) {
|
|
10808
|
+
const gap = Date.parse(timestamps[i]) - Date.parse(timestamps[i - 1]);
|
|
10809
|
+
if (Number.isFinite(gap) && gap >= 0 && gap < RAPID_REPROMPT_MS3) count += 1;
|
|
10810
|
+
}
|
|
10811
|
+
return count;
|
|
10812
|
+
}
|
|
10813
|
+
function sessionDurationMs3(fold) {
|
|
10814
|
+
if (!fold.firstTs || !fold.lastTs) return null;
|
|
10815
|
+
const ms = Date.parse(fold.lastTs) - Date.parse(fold.firstTs);
|
|
10816
|
+
return Number.isFinite(ms) && ms >= 0 ? ms : null;
|
|
10817
|
+
}
|
|
10818
|
+
async function listCopilotSessions(snapshotDir) {
|
|
10819
|
+
let entries;
|
|
10820
|
+
try {
|
|
10821
|
+
entries = await fs6.readdir(snapshotDir, { withFileTypes: true });
|
|
10822
|
+
} catch {
|
|
10823
|
+
return { sessions: [], duplicates: 0 };
|
|
10824
|
+
}
|
|
10825
|
+
const dirs = /* @__PURE__ */ new Set();
|
|
10826
|
+
const flat = /* @__PURE__ */ new Set();
|
|
10827
|
+
for (const entry of entries) {
|
|
10828
|
+
if (entry.isDirectory() && !entry.name.startsWith(".")) dirs.add(entry.name);
|
|
10829
|
+
else if (entry.isFile() && entry.name.endsWith(".jsonl")) flat.add(entry.name.slice(0, -".jsonl".length));
|
|
10830
|
+
}
|
|
10831
|
+
const exists = async (p) => {
|
|
10832
|
+
try {
|
|
10833
|
+
return (await fs6.stat(p)).isFile();
|
|
10834
|
+
} catch {
|
|
10835
|
+
return false;
|
|
10836
|
+
}
|
|
10837
|
+
};
|
|
10838
|
+
const sessions = [];
|
|
10839
|
+
let duplicates = 0;
|
|
10840
|
+
for (const id of [.../* @__PURE__ */ new Set([...dirs, ...flat])].sort()) {
|
|
10841
|
+
const dirLog = path7.join(snapshotDir, id, "events.jsonl");
|
|
10842
|
+
const workspace = path7.join(snapshotDir, id, "workspace.yaml");
|
|
10843
|
+
const workspacePath = dirs.has(id) && await exists(workspace) ? workspace : null;
|
|
10844
|
+
if (dirs.has(id) && await exists(dirLog)) {
|
|
10845
|
+
if (flat.has(id)) duplicates += 1;
|
|
10846
|
+
sessions.push({ sessionId: id, logPath: dirLog, workspacePath });
|
|
10847
|
+
} else if (flat.has(id)) {
|
|
10848
|
+
sessions.push({ sessionId: id, logPath: path7.join(snapshotDir, `${id}.jsonl`), workspacePath });
|
|
10849
|
+
}
|
|
10850
|
+
}
|
|
10851
|
+
return { sessions, duplicates };
|
|
10852
|
+
}
|
|
10853
|
+
async function* extractCopilotCli(snapshotDir, extractionId) {
|
|
10854
|
+
const { sessions, duplicates } = await listCopilotSessions(snapshotDir);
|
|
10855
|
+
if (sessions.length === 0) return;
|
|
10856
|
+
let windowOldest = null;
|
|
10857
|
+
let windowNewest = null;
|
|
10858
|
+
let sessionCount = 0;
|
|
10859
|
+
let unparsedSessions = 0;
|
|
10860
|
+
let unreadableSessions = 0;
|
|
10861
|
+
let malformedLines = 0;
|
|
10862
|
+
for (const files of sessions) {
|
|
10863
|
+
let text;
|
|
10864
|
+
try {
|
|
10865
|
+
text = await fs6.readFile(files.logPath, "utf8");
|
|
10866
|
+
} catch {
|
|
10867
|
+
unreadableSessions += 1;
|
|
10868
|
+
continue;
|
|
10869
|
+
}
|
|
10870
|
+
const lines = text.split("\n");
|
|
10871
|
+
const start = sessionStartOf(lines);
|
|
10872
|
+
if (!isReadableCopilotLog(start)) {
|
|
10873
|
+
unparsedSessions += 1;
|
|
10874
|
+
continue;
|
|
10875
|
+
}
|
|
10876
|
+
let workspace = { cwd: null, gitRoot: null, branch: null, clientName: null };
|
|
10877
|
+
if (files.workspacePath) {
|
|
10878
|
+
try {
|
|
10879
|
+
workspace = readCopilotWorkspace(await fs6.readFile(files.workspacePath, "utf8"));
|
|
10880
|
+
} catch {
|
|
10881
|
+
}
|
|
10882
|
+
}
|
|
10883
|
+
const fold = newFold3(nonEmptyString2(start?.sessionId) ?? files.sessionId);
|
|
10884
|
+
foldLines(fold, lines);
|
|
10885
|
+
malformedLines += fold.unparsedLines;
|
|
10886
|
+
if (!fold.firstTs || !fold.lastTs) continue;
|
|
10887
|
+
sessionCount += 1;
|
|
10888
|
+
if (!windowOldest || fold.firstTs < windowOldest) windowOldest = fold.firstTs;
|
|
10889
|
+
if (!windowNewest || fold.lastTs > windowNewest) windowNewest = fold.lastTs;
|
|
10890
|
+
const repoRef = workspace.gitRoot ?? fold.contextGitRoot ?? workspace.cwd ?? fold.contextCwd;
|
|
10891
|
+
const gitBranch = workspace.branch ?? fold.contextBranch;
|
|
10892
|
+
const base = {
|
|
10893
|
+
store: "copilot_cli",
|
|
10894
|
+
sourceVersion: fold.sourceVersion,
|
|
10895
|
+
sessionRef: fold.sessionId,
|
|
10896
|
+
repoRef,
|
|
10897
|
+
extractionId
|
|
10898
|
+
};
|
|
10899
|
+
for (const ts of fold.humanPromptTimestamps) {
|
|
10900
|
+
if (!ts) continue;
|
|
10901
|
+
yield { ...base, occurredAt: ts, eventKind: "ai_prompt_submitted", metrics: {}, provenance: HISTORICAL_PROVENANCE.direct };
|
|
10902
|
+
}
|
|
10903
|
+
for (const call of fold.toolCalls) {
|
|
10904
|
+
yield {
|
|
10905
|
+
...base,
|
|
10906
|
+
occurredAt: call.at,
|
|
10907
|
+
eventKind: "ai_tool_call_started",
|
|
10908
|
+
metrics: { toolName: call.name },
|
|
10909
|
+
provenance: HISTORICAL_PROVENANCE.direct
|
|
10910
|
+
};
|
|
10911
|
+
}
|
|
10912
|
+
const durationMs = sessionDurationMs3(fold);
|
|
10913
|
+
const split = splitActiveTime(fold.timelinePoints, { activeGapMs: ACTIVE_GAP_MS3 });
|
|
10914
|
+
const metrics = {
|
|
10915
|
+
promptCount: fold.humanPrompts,
|
|
10916
|
+
subagentPrompts: fold.subagentPrompts,
|
|
10917
|
+
assistantTurns: fold.assistantTurns,
|
|
10918
|
+
toolCallCount: fold.toolCallCount,
|
|
10919
|
+
subagentToolCallCount: fold.subagentToolCallCount,
|
|
10920
|
+
toolResultCount: fold.toolResults,
|
|
10921
|
+
durationBucket: durationMs === null ? "unknown" : (0, import_tool_kit5.bucketDurationMs)(durationMs) ?? "unknown",
|
|
10922
|
+
afterHoursPrompts: fold.afterHoursPrompts,
|
|
10923
|
+
unknownLines: fold.unknownLines,
|
|
10924
|
+
metaLines: fold.metaLines,
|
|
10925
|
+
unparsedLines: fold.unparsedLines,
|
|
10926
|
+
modelCount: fold.models.size,
|
|
10927
|
+
modelSwitchCount: fold.modelSwitchCount,
|
|
10928
|
+
compactionCount: fold.compactionCount,
|
|
10929
|
+
toolResultErrorCount: fold.toolResultErrorCount,
|
|
10930
|
+
toolFailureCount: fold.toolResultErrorCount,
|
|
10931
|
+
rapidRepromptCount: rapidRepromptCountOf3(fold),
|
|
10932
|
+
activeMinutes: minutesOf(split.handsOnMs + split.agentSupervisingMs),
|
|
10933
|
+
handsOnMinutes: minutesOf(split.handsOnMs),
|
|
10934
|
+
agentSupervisingMinutes: minutesOf(split.agentSupervisingMs),
|
|
10935
|
+
activeSplitInstants: split.instants,
|
|
10936
|
+
activeSplitUndatedLines: fold.undatedTimelineLines,
|
|
10937
|
+
activeSplitUnposturedInstants: split.unposturedInstants,
|
|
10938
|
+
sessionStartedAt: fold.firstTs
|
|
10939
|
+
};
|
|
10940
|
+
if (durationMs !== null) metrics.sessionMinutes = Math.round(durationMs / 6e4);
|
|
10941
|
+
const primaryModel = topModel3(fold.models);
|
|
10942
|
+
if (primaryModel) metrics.primaryModel = primaryModel;
|
|
10943
|
+
if (fold.selectedModel) {
|
|
10944
|
+
metrics.selectedModel = fold.selectedModel;
|
|
10945
|
+
const selectedClass = (0, import_tool_kit5.classifyModelClass)(fold.selectedModel);
|
|
10946
|
+
if (selectedClass) metrics.selectedModelClass = selectedClass;
|
|
10947
|
+
}
|
|
10948
|
+
if (gitBranch) metrics.gitBranch = gitBranch;
|
|
10949
|
+
if (workspace.clientName) metrics.clientName = workspace.clientName;
|
|
10950
|
+
const shutdown = fold.shutdown;
|
|
10951
|
+
if (shutdown?.tokensSeen) {
|
|
10952
|
+
metrics.inputTokens = shutdown.inputTokens;
|
|
10953
|
+
metrics.outputTokens = shutdown.outputTokens;
|
|
10954
|
+
metrics.cacheReadTokens = shutdown.cacheReadTokens;
|
|
10955
|
+
metrics.cacheCreationTokens = shutdown.cacheCreationTokens;
|
|
10956
|
+
} else {
|
|
10957
|
+
metrics.tokensNotCollected = true;
|
|
10958
|
+
}
|
|
10959
|
+
if (shutdown?.linesAdded != null) metrics.linesAdded = shutdown.linesAdded;
|
|
10960
|
+
if (shutdown?.linesRemoved != null) metrics.linesRemoved = shutdown.linesRemoved;
|
|
10961
|
+
if (shutdown?.filesChangedCount != null) metrics.filesChangedCount = shutdown.filesChangedCount;
|
|
10962
|
+
if (shutdown?.totalApiDurationMs != null) metrics.totalApiDurationMs = shutdown.totalApiDurationMs;
|
|
10963
|
+
yield {
|
|
10964
|
+
...base,
|
|
10965
|
+
occurredAt: fold.lastTs,
|
|
10966
|
+
eventKind: "create_focus_session",
|
|
10967
|
+
metrics,
|
|
10968
|
+
dayBreakdown: sliceSessionByLocalDay(fold.humanPromptTimestamps, {
|
|
10969
|
+
activeGapMs: ACTIVE_GAP_MS3,
|
|
10970
|
+
activeInstants: fold.timelinePoints
|
|
10971
|
+
}),
|
|
10972
|
+
activeSpans: activeSpans(fold.timelinePoints, { activeGapMs: ACTIVE_GAP_MS3 }).spans,
|
|
10973
|
+
autonomySplit: Object.fromEntries(
|
|
10974
|
+
Object.entries(split.supervisingMsByBand).map(([band, ms]) => [band, minutesOf(ms)])
|
|
10975
|
+
),
|
|
10976
|
+
provenance: HISTORICAL_PROVENANCE.derived
|
|
10977
|
+
};
|
|
10978
|
+
if (fold.afterHoursPrompts > 0) {
|
|
10979
|
+
yield {
|
|
10980
|
+
...base,
|
|
10981
|
+
occurredAt: fold.lastTs,
|
|
10982
|
+
eventKind: "after_hours_ai_session",
|
|
10983
|
+
metrics: { afterHoursPrompts: fold.afterHoursPrompts },
|
|
10984
|
+
provenance: HISTORICAL_PROVENANCE.derived
|
|
10985
|
+
};
|
|
10986
|
+
}
|
|
10987
|
+
if (fold.toolResultErrorCount > 0) {
|
|
10988
|
+
yield {
|
|
10989
|
+
...base,
|
|
10990
|
+
occurredAt: fold.lastTs,
|
|
10991
|
+
eventKind: "tool_failure",
|
|
10992
|
+
metrics: { toolFailureCount: fold.toolResultErrorCount, toolResultErrorCount: fold.toolResultErrorCount },
|
|
10993
|
+
provenance: HISTORICAL_PROVENANCE.derived
|
|
10994
|
+
};
|
|
10995
|
+
}
|
|
10996
|
+
}
|
|
10997
|
+
const unread = unparsedSessions + unreadableSessions;
|
|
10998
|
+
if (windowOldest && windowNewest || unread > 0) {
|
|
10999
|
+
const window = windowOldest && windowNewest ? { windowOldest, windowNewest } : {};
|
|
11000
|
+
yield {
|
|
11001
|
+
occurredAt: windowNewest ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
11002
|
+
store: "copilot_cli",
|
|
11003
|
+
sourceVersion: null,
|
|
11004
|
+
sessionRef: null,
|
|
11005
|
+
repoRef: null,
|
|
11006
|
+
eventKind: "extraction_epoch",
|
|
11007
|
+
metrics: {
|
|
11008
|
+
...window,
|
|
11009
|
+
sessionCount,
|
|
11010
|
+
unparsedChatSessionFiles: unparsedSessions,
|
|
11011
|
+
unreadableChatSessionFiles: unreadableSessions,
|
|
11012
|
+
malformedChatSessionLines: malformedLines,
|
|
11013
|
+
duplicateChatSessions: duplicates
|
|
11014
|
+
},
|
|
11015
|
+
provenance: HISTORICAL_PROVENANCE.derived,
|
|
11016
|
+
extractionId
|
|
11017
|
+
};
|
|
11018
|
+
}
|
|
11019
|
+
}
|
|
11020
|
+
|
|
11021
|
+
// src/extractors/cursor.ts
|
|
11022
|
+
var import_tool_kit6 = __toESM(require_out3(), 1);
|
|
11023
|
+
import * as fs7 from "node:fs/promises";
|
|
11024
|
+
import * as path8 from "node:path";
|
|
10362
11025
|
import { execFile as execFile3 } from "node:child_process";
|
|
10363
11026
|
import { promisify as promisify3 } from "node:util";
|
|
10364
11027
|
var execFileAsync3 = promisify3(execFile3);
|
|
@@ -10366,7 +11029,7 @@ var KNOWN_CURSOR_BUBBLE_VERSIONS = /* @__PURE__ */ new Set([3]);
|
|
|
10366
11029
|
var KNOWN_CURSOR_HEADER_TYPES = /* @__PURE__ */ new Set(["head"]);
|
|
10367
11030
|
var BUBBLE_TYPE_USER = 1;
|
|
10368
11031
|
var BUBBLE_TYPE_ASSISTANT = 2;
|
|
10369
|
-
function
|
|
11032
|
+
function asNumber4(value) {
|
|
10370
11033
|
return typeof value === "number" && Number.isFinite(value) ? value : 0;
|
|
10371
11034
|
}
|
|
10372
11035
|
function pickTop(counts) {
|
|
@@ -10452,9 +11115,9 @@ function sniffCursorHeaderRow(row) {
|
|
|
10452
11115
|
const { repoRef, gitBranch } = repoInfoOf(row);
|
|
10453
11116
|
return {
|
|
10454
11117
|
kind: "head",
|
|
10455
|
-
linesAdded:
|
|
10456
|
-
linesRemoved:
|
|
10457
|
-
filesChangedCount:
|
|
11118
|
+
linesAdded: asNumber4(row.linesAdded),
|
|
11119
|
+
linesRemoved: asNumber4(row.linesRemoved),
|
|
11120
|
+
filesChangedCount: asNumber4(row.filesChangedCount),
|
|
10458
11121
|
contextUsagePercent: typeof row.contextUsagePercent === "number" ? row.contextUsagePercent : null,
|
|
10459
11122
|
mode: row.mode,
|
|
10460
11123
|
repoRef,
|
|
@@ -10476,10 +11139,10 @@ function sniffCursorBubbleRow(row) {
|
|
|
10476
11139
|
kind: row.btype === BUBBLE_TYPE_USER ? "user" : "assistant",
|
|
10477
11140
|
composerId,
|
|
10478
11141
|
createdAt: row.createdAt,
|
|
10479
|
-
inputTokens:
|
|
10480
|
-
outputTokens:
|
|
10481
|
-
humanChangesCount:
|
|
10482
|
-
lintErrorsCount:
|
|
11142
|
+
inputTokens: asNumber4(row.inputTokens),
|
|
11143
|
+
outputTokens: asNumber4(row.outputTokens),
|
|
11144
|
+
humanChangesCount: asNumber4(row.humanChangesCount),
|
|
11145
|
+
lintErrorsCount: asNumber4(row.lintErrorsCount),
|
|
10483
11146
|
modelName: row.modelName,
|
|
10484
11147
|
sourceVersion: String(row.v),
|
|
10485
11148
|
toolCallId: row.toolCallId,
|
|
@@ -10497,7 +11160,7 @@ function foldToolCall(fold, sniffed) {
|
|
|
10497
11160
|
fold.toolCallNames.set(id, sanitizeToolName(sniffed.toolName));
|
|
10498
11161
|
}
|
|
10499
11162
|
}
|
|
10500
|
-
function
|
|
11163
|
+
function newFold4(row, sniffed) {
|
|
10501
11164
|
return {
|
|
10502
11165
|
composerId: row.composerId,
|
|
10503
11166
|
createdAtMs: Number.isFinite(row.createdAt) ? row.createdAt : null,
|
|
@@ -10567,21 +11230,21 @@ function resolveTimeline(fold) {
|
|
|
10567
11230
|
source: end.source
|
|
10568
11231
|
};
|
|
10569
11232
|
}
|
|
10570
|
-
function
|
|
11233
|
+
function sessionDurationMs4(fold) {
|
|
10571
11234
|
const timeline = resolveTimeline(fold);
|
|
10572
11235
|
if (timeline === null) return null;
|
|
10573
11236
|
const ms = timeline.endedAtMs - timeline.startedAtMs;
|
|
10574
11237
|
return Number.isFinite(ms) && ms >= 0 ? ms : null;
|
|
10575
11238
|
}
|
|
10576
11239
|
function durationBucketOf3(fold) {
|
|
10577
|
-
const ms =
|
|
11240
|
+
const ms = sessionDurationMs4(fold);
|
|
10578
11241
|
if (ms === null) return "unknown";
|
|
10579
|
-
return (0,
|
|
11242
|
+
return (0, import_tool_kit6.bucketDurationMs)(ms) ?? "unknown";
|
|
10580
11243
|
}
|
|
10581
11244
|
async function* extractCursor(snapshotDir, extractionId) {
|
|
10582
|
-
const dbPath =
|
|
11245
|
+
const dbPath = path8.join(snapshotDir, "state.vscdb");
|
|
10583
11246
|
try {
|
|
10584
|
-
await
|
|
11247
|
+
await fs7.stat(dbPath);
|
|
10585
11248
|
} catch {
|
|
10586
11249
|
return;
|
|
10587
11250
|
}
|
|
@@ -10623,7 +11286,7 @@ async function* extractCursor(snapshotDir, extractionId) {
|
|
|
10623
11286
|
if (sniffed.parentComposerId) subagentParentOf.set(row.composerId, sniffed.parentComposerId);
|
|
10624
11287
|
continue;
|
|
10625
11288
|
}
|
|
10626
|
-
folds.set(row.composerId,
|
|
11289
|
+
folds.set(row.composerId, newFold4(row, sniffed));
|
|
10627
11290
|
}
|
|
10628
11291
|
let bubbleRows = [];
|
|
10629
11292
|
try {
|
|
@@ -10676,7 +11339,7 @@ async function* extractCursor(snapshotDir, extractionId) {
|
|
|
10676
11339
|
foldToolCall(ownFold, sniffed);
|
|
10677
11340
|
if (sniffed.kind === "user") {
|
|
10678
11341
|
ownFold.humanPrompts += 1;
|
|
10679
|
-
if (sniffed.createdAt && (0,
|
|
11342
|
+
if (sniffed.createdAt && (0, import_tool_kit6.isAfterHours)(new Date(sniffed.createdAt))) {
|
|
10680
11343
|
ownFold.afterHoursPrompts += 1;
|
|
10681
11344
|
}
|
|
10682
11345
|
ownFold.humanPromptTimestamps.push(sniffed.createdAt);
|
|
@@ -10768,7 +11431,7 @@ async function* extractCursor(snapshotDir, extractionId) {
|
|
|
10768
11431
|
extractionId
|
|
10769
11432
|
};
|
|
10770
11433
|
}
|
|
10771
|
-
const durationMs =
|
|
11434
|
+
const durationMs = sessionDurationMs4(fold);
|
|
10772
11435
|
const sessionMetrics = {
|
|
10773
11436
|
toolCallCount: fold.toolCallFirstSeen.size,
|
|
10774
11437
|
// The gap between the count and the events above, stated rather than
|
|
@@ -10865,9 +11528,9 @@ async function* extractCursor(snapshotDir, extractionId) {
|
|
|
10865
11528
|
}
|
|
10866
11529
|
|
|
10867
11530
|
// src/extractors/vscode.ts
|
|
10868
|
-
var
|
|
10869
|
-
import * as
|
|
10870
|
-
import * as
|
|
11531
|
+
var import_tool_kit7 = __toESM(require_out3(), 1);
|
|
11532
|
+
import * as fs8 from "node:fs/promises";
|
|
11533
|
+
import * as path9 from "node:path";
|
|
10871
11534
|
import { fileURLToPath } from "node:url";
|
|
10872
11535
|
var KNOWN_HISTORY_VERSION = 1;
|
|
10873
11536
|
var KNOWN_CHAT_SESSION_VERSION = 3;
|
|
@@ -10887,7 +11550,7 @@ function uriToPath(uri) {
|
|
|
10887
11550
|
async function buildWorkspaceFolderIndex(workspaceStorageDir) {
|
|
10888
11551
|
let hashDirs = [];
|
|
10889
11552
|
try {
|
|
10890
|
-
hashDirs = (await
|
|
11553
|
+
hashDirs = (await fs8.readdir(workspaceStorageDir, { withFileTypes: true })).filter((e) => e.isDirectory()).map((e) => e.name);
|
|
10891
11554
|
} catch {
|
|
10892
11555
|
return [];
|
|
10893
11556
|
}
|
|
@@ -10895,7 +11558,7 @@ async function buildWorkspaceFolderIndex(workspaceStorageDir) {
|
|
|
10895
11558
|
for (const hash of hashDirs) {
|
|
10896
11559
|
let raw;
|
|
10897
11560
|
try {
|
|
10898
|
-
raw = await
|
|
11561
|
+
raw = await fs8.readFile(path9.join(workspaceStorageDir, hash, "workspace.json"), "utf8");
|
|
10899
11562
|
} catch {
|
|
10900
11563
|
continue;
|
|
10901
11564
|
}
|
|
@@ -10918,7 +11581,7 @@ function workspaceRootOf(filePath, index) {
|
|
|
10918
11581
|
return folder.folderPath;
|
|
10919
11582
|
}
|
|
10920
11583
|
}
|
|
10921
|
-
return
|
|
11584
|
+
return path9.dirname(filePath);
|
|
10922
11585
|
}
|
|
10923
11586
|
function sniffHistoryFile(raw) {
|
|
10924
11587
|
let parsed;
|
|
@@ -10944,14 +11607,14 @@ async function foldEditDays(historyDir, index) {
|
|
|
10944
11607
|
};
|
|
10945
11608
|
let hashDirs = [];
|
|
10946
11609
|
try {
|
|
10947
|
-
hashDirs = (await
|
|
11610
|
+
hashDirs = (await fs8.readdir(historyDir, { withFileTypes: true })).filter((e) => e.isDirectory()).map((e) => e.name);
|
|
10948
11611
|
} catch {
|
|
10949
11612
|
return result;
|
|
10950
11613
|
}
|
|
10951
11614
|
for (const hash of hashDirs.sort()) {
|
|
10952
11615
|
let raw;
|
|
10953
11616
|
try {
|
|
10954
|
-
raw = await
|
|
11617
|
+
raw = await fs8.readFile(path9.join(historyDir, hash, "entries.json"), "utf8");
|
|
10955
11618
|
} catch (error) {
|
|
10956
11619
|
if (!isAbsence(error)) result.unreadableFiles += 1;
|
|
10957
11620
|
continue;
|
|
@@ -11008,12 +11671,42 @@ function toolInvocationsOf(request) {
|
|
|
11008
11671
|
}
|
|
11009
11672
|
return calls;
|
|
11010
11673
|
}
|
|
11674
|
+
var ROUND_CALL_ID_SUFFIX = /__vscode-\d+$/;
|
|
11675
|
+
function toolCallRoundTimesOf(request) {
|
|
11676
|
+
const times = /* @__PURE__ */ new Map();
|
|
11677
|
+
const result = request.result;
|
|
11678
|
+
if (typeof result !== "object" || result === null) return times;
|
|
11679
|
+
const metadata = result.metadata;
|
|
11680
|
+
if (typeof metadata !== "object" || metadata === null) return times;
|
|
11681
|
+
const rounds = metadata.toolCallRounds;
|
|
11682
|
+
if (!Array.isArray(rounds)) return times;
|
|
11683
|
+
for (const round of rounds) {
|
|
11684
|
+
if (typeof round !== "object" || round === null) continue;
|
|
11685
|
+
const entry = round;
|
|
11686
|
+
if (typeof entry.timestamp !== "number" || !Number.isFinite(entry.timestamp)) continue;
|
|
11687
|
+
if (!Array.isArray(entry.toolCalls)) continue;
|
|
11688
|
+
for (const call of entry.toolCalls) {
|
|
11689
|
+
if (typeof call !== "object" || call === null) continue;
|
|
11690
|
+
const id = call.id;
|
|
11691
|
+
if (typeof id !== "string") continue;
|
|
11692
|
+
const toolCallId = id.replace(ROUND_CALL_ID_SUFFIX, "");
|
|
11693
|
+
if (toolCallId.length > 0 && !times.has(toolCallId)) times.set(toolCallId, entry.timestamp);
|
|
11694
|
+
}
|
|
11695
|
+
}
|
|
11696
|
+
return times;
|
|
11697
|
+
}
|
|
11698
|
+
function finiteNumber(value) {
|
|
11699
|
+
return typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : null;
|
|
11700
|
+
}
|
|
11701
|
+
function countInto(map, key) {
|
|
11702
|
+
if (typeof key === "string" && key.length > 0) map.set(key, (map.get(key) ?? 0) + 1);
|
|
11703
|
+
}
|
|
11011
11704
|
var JSONL_KIND_HEADER = 0;
|
|
11012
11705
|
var JSONL_KIND_SET = 1;
|
|
11013
11706
|
var JSONL_KIND_SPLICE = 2;
|
|
11014
|
-
function resolvePath(root,
|
|
11707
|
+
function resolvePath(root, path16) {
|
|
11015
11708
|
let cur = root;
|
|
11016
|
-
for (const seg of
|
|
11709
|
+
for (const seg of path16) {
|
|
11017
11710
|
if (typeof seg === "number") {
|
|
11018
11711
|
if (!Array.isArray(cur) || seg >= cur.length) return null;
|
|
11019
11712
|
cur = cur[seg];
|
|
@@ -11024,10 +11717,10 @@ function resolvePath(root, path15) {
|
|
|
11024
11717
|
}
|
|
11025
11718
|
return cur ?? null;
|
|
11026
11719
|
}
|
|
11027
|
-
function applySet(root,
|
|
11028
|
-
if (
|
|
11029
|
-
const parent = resolvePath(root,
|
|
11030
|
-
const last =
|
|
11720
|
+
function applySet(root, path16, value) {
|
|
11721
|
+
if (path16.length === 0) return;
|
|
11722
|
+
const parent = resolvePath(root, path16.slice(0, -1));
|
|
11723
|
+
const last = path16[path16.length - 1];
|
|
11031
11724
|
if (typeof last === "number") {
|
|
11032
11725
|
if (!Array.isArray(parent)) return;
|
|
11033
11726
|
while (parent.length <= last) parent.push(null);
|
|
@@ -11037,8 +11730,8 @@ function applySet(root, path15, value) {
|
|
|
11037
11730
|
parent[last] = value;
|
|
11038
11731
|
}
|
|
11039
11732
|
}
|
|
11040
|
-
function applySplice(root,
|
|
11041
|
-
const target = resolvePath(root,
|
|
11733
|
+
function applySplice(root, path16, values, index) {
|
|
11734
|
+
const target = resolvePath(root, path16);
|
|
11042
11735
|
if (!Array.isArray(target)) return;
|
|
11043
11736
|
if (index !== null && index >= 0 && index <= target.length) target.splice(index, 0, ...values);
|
|
11044
11737
|
else target.push(...values);
|
|
@@ -11080,12 +11773,12 @@ function parseJsonlChatSession(raw) {
|
|
|
11080
11773
|
}
|
|
11081
11774
|
return { record, malformedLines };
|
|
11082
11775
|
}
|
|
11083
|
-
function
|
|
11776
|
+
function topOf(counts) {
|
|
11084
11777
|
let best = null;
|
|
11085
11778
|
let bestCount = 0;
|
|
11086
|
-
for (const [
|
|
11779
|
+
for (const [key, count] of counts) {
|
|
11087
11780
|
if (count > bestCount) {
|
|
11088
|
-
best =
|
|
11781
|
+
best = key;
|
|
11089
11782
|
bestCount = count;
|
|
11090
11783
|
}
|
|
11091
11784
|
}
|
|
@@ -11094,7 +11787,7 @@ function topModel3(models) {
|
|
|
11094
11787
|
async function readChatSessionFile(filePath, file, workspaceRoot, result, seenSessionIds, loose) {
|
|
11095
11788
|
let raw;
|
|
11096
11789
|
try {
|
|
11097
|
-
raw = await
|
|
11790
|
+
raw = await fs8.readFile(filePath, "utf8");
|
|
11098
11791
|
} catch {
|
|
11099
11792
|
result.unreadableFiles += 1;
|
|
11100
11793
|
return;
|
|
@@ -11128,7 +11821,7 @@ async function readChatSessionFile(filePath, file, workspaceRoot, result, seenSe
|
|
|
11128
11821
|
return;
|
|
11129
11822
|
}
|
|
11130
11823
|
const fold = {
|
|
11131
|
-
sessionId: typeof record.sessionId === "string" ? record.sessionId :
|
|
11824
|
+
sessionId: typeof record.sessionId === "string" ? record.sessionId : path9.basename(file, path9.extname(file)),
|
|
11132
11825
|
workspaceRoot,
|
|
11133
11826
|
firstTs: null,
|
|
11134
11827
|
lastTs: null,
|
|
@@ -11138,7 +11831,15 @@ async function readChatSessionFile(filePath, file, workspaceRoot, result, seenSe
|
|
|
11138
11831
|
errorCount: 0,
|
|
11139
11832
|
models: /* @__PURE__ */ new Map(),
|
|
11140
11833
|
requestTimestamps: [],
|
|
11141
|
-
toolCalls: /* @__PURE__ */ new Map()
|
|
11834
|
+
toolCalls: /* @__PURE__ */ new Map(),
|
|
11835
|
+
outputTokens: 0,
|
|
11836
|
+
outputTokensSeen: false,
|
|
11837
|
+
promptTokensPeak: 0,
|
|
11838
|
+
copilotCredits: 0,
|
|
11839
|
+
copilotCreditsSeen: false,
|
|
11840
|
+
contextWindowTokens: 0,
|
|
11841
|
+
reasoningEfforts: /* @__PURE__ */ new Map(),
|
|
11842
|
+
modes: /* @__PURE__ */ new Map()
|
|
11142
11843
|
};
|
|
11143
11844
|
for (const r of requests) {
|
|
11144
11845
|
if (typeof r !== "object" || r === null) return;
|
|
@@ -11150,15 +11851,41 @@ async function readChatSessionFile(filePath, file, workspaceRoot, result, seenSe
|
|
|
11150
11851
|
fold.requestTimestamps.push(iso);
|
|
11151
11852
|
if (!fold.firstTs || iso < fold.firstTs) fold.firstTs = iso;
|
|
11152
11853
|
if (!fold.lastTs || iso > fold.lastTs) fold.lastTs = iso;
|
|
11153
|
-
if ((0,
|
|
11854
|
+
if ((0, import_tool_kit7.isAfterHours)(new Date(iso))) fold.afterHoursRequests += 1;
|
|
11154
11855
|
if (req.isCanceled === true) fold.canceledCount += 1;
|
|
11155
11856
|
const requestResult = req.result;
|
|
11156
11857
|
if (requestResult && requestResult.errorDetails) fold.errorCount += 1;
|
|
11157
11858
|
if (typeof req.modelId === "string") {
|
|
11158
11859
|
fold.models.set(req.modelId, (fold.models.get(req.modelId) ?? 0) + 1);
|
|
11159
11860
|
}
|
|
11861
|
+
const completionTokens = finiteNumber(req.completionTokens);
|
|
11862
|
+
if (completionTokens !== null) {
|
|
11863
|
+
fold.outputTokens += completionTokens;
|
|
11864
|
+
fold.outputTokensSeen = true;
|
|
11865
|
+
}
|
|
11866
|
+
const promptTokens = finiteNumber(req.promptTokens);
|
|
11867
|
+
if (promptTokens !== null && promptTokens > fold.promptTokensPeak) fold.promptTokensPeak = promptTokens;
|
|
11868
|
+
const credits = finiteNumber(req.copilotCredits);
|
|
11869
|
+
if (credits !== null) {
|
|
11870
|
+
fold.copilotCredits += credits;
|
|
11871
|
+
fold.copilotCreditsSeen = true;
|
|
11872
|
+
}
|
|
11873
|
+
const modelConfiguration = req.modelConfiguration;
|
|
11874
|
+
if (typeof modelConfiguration === "object" && modelConfiguration !== null) {
|
|
11875
|
+
const contextSize = finiteNumber(modelConfiguration.contextSize);
|
|
11876
|
+
if (contextSize !== null && contextSize > fold.contextWindowTokens) fold.contextWindowTokens = contextSize;
|
|
11877
|
+
countInto(fold.reasoningEfforts, modelConfiguration.reasoningEffort);
|
|
11878
|
+
}
|
|
11879
|
+
const modeInfo = req.modeInfo;
|
|
11880
|
+
if (typeof modeInfo === "object" && modeInfo !== null) countInto(fold.modes, modeInfo.kind);
|
|
11881
|
+
const roundTimes = toolCallRoundTimesOf(req);
|
|
11160
11882
|
for (const call of toolInvocationsOf(req)) {
|
|
11161
|
-
if (
|
|
11883
|
+
if (fold.toolCalls.has(call.id)) continue;
|
|
11884
|
+
const roundTs = roundTimes.get(call.id);
|
|
11885
|
+
fold.toolCalls.set(
|
|
11886
|
+
call.id,
|
|
11887
|
+
roundTs === void 0 ? { at: iso, name: call.name, timed: false } : { at: new Date(roundTs).toISOString(), name: call.name, timed: true }
|
|
11888
|
+
);
|
|
11162
11889
|
}
|
|
11163
11890
|
}
|
|
11164
11891
|
if (fold.requestCount > 0) {
|
|
@@ -11184,22 +11911,22 @@ async function foldChatSessions(roots) {
|
|
|
11184
11911
|
for (const root of roots) {
|
|
11185
11912
|
let wsHashes = [];
|
|
11186
11913
|
try {
|
|
11187
|
-
wsHashes = (await
|
|
11914
|
+
wsHashes = (await fs8.readdir(root.workspaceStorageDir, { withFileTypes: true })).filter((e) => e.isDirectory()).map((e) => e.name);
|
|
11188
11915
|
} catch {
|
|
11189
11916
|
wsHashes = [];
|
|
11190
11917
|
}
|
|
11191
11918
|
for (const hash of wsHashes.sort()) {
|
|
11192
|
-
const wsDir =
|
|
11919
|
+
const wsDir = path9.join(root.workspaceStorageDir, hash);
|
|
11193
11920
|
let workspaceRoot = null;
|
|
11194
11921
|
try {
|
|
11195
|
-
const raw = await
|
|
11922
|
+
const raw = await fs8.readFile(path9.join(wsDir, "workspace.json"), "utf8");
|
|
11196
11923
|
const parsed = JSON.parse(raw);
|
|
11197
11924
|
workspaceRoot = uriToPath(parsed.folder);
|
|
11198
11925
|
} catch {
|
|
11199
11926
|
}
|
|
11200
11927
|
let files = [];
|
|
11201
11928
|
try {
|
|
11202
|
-
const entries = await
|
|
11929
|
+
const entries = await fs8.readdir(path9.join(wsDir, "chatSessions"));
|
|
11203
11930
|
files = entries.filter((f) => f.endsWith(".json") || f.endsWith(".jsonl"));
|
|
11204
11931
|
result.unrecognisedFiles += entries.length - files.length;
|
|
11205
11932
|
} catch {
|
|
@@ -11207,7 +11934,7 @@ async function foldChatSessions(roots) {
|
|
|
11207
11934
|
}
|
|
11208
11935
|
for (const file of files.sort()) {
|
|
11209
11936
|
await readChatSessionFile(
|
|
11210
|
-
|
|
11937
|
+
path9.join(wsDir, "chatSessions", file),
|
|
11211
11938
|
file,
|
|
11212
11939
|
workspaceRoot,
|
|
11213
11940
|
result,
|
|
@@ -11221,14 +11948,14 @@ async function foldChatSessions(roots) {
|
|
|
11221
11948
|
for (const dir of root.looseChatDirs ?? []) {
|
|
11222
11949
|
let entries;
|
|
11223
11950
|
try {
|
|
11224
|
-
entries = await
|
|
11951
|
+
entries = await fs8.readdir(dir);
|
|
11225
11952
|
} catch {
|
|
11226
11953
|
continue;
|
|
11227
11954
|
}
|
|
11228
11955
|
const files = entries.filter((f) => f.endsWith(".json") || f.endsWith(".jsonl"));
|
|
11229
11956
|
result.unrecognisedFiles += entries.length - files.length;
|
|
11230
11957
|
for (const file of files.sort()) {
|
|
11231
|
-
await readChatSessionFile(
|
|
11958
|
+
await readChatSessionFile(path9.join(dir, file), file, null, result, seenSessionIds, true);
|
|
11232
11959
|
}
|
|
11233
11960
|
}
|
|
11234
11961
|
}
|
|
@@ -11238,11 +11965,11 @@ function rootsOf(source) {
|
|
|
11238
11965
|
if (typeof source === "string") {
|
|
11239
11966
|
return [
|
|
11240
11967
|
{
|
|
11241
|
-
historyDir:
|
|
11242
|
-
workspaceStorageDir:
|
|
11968
|
+
historyDir: path9.join(source, "history"),
|
|
11969
|
+
workspaceStorageDir: path9.join(source, "workspaceStorage"),
|
|
11243
11970
|
looseChatDirs: [
|
|
11244
|
-
|
|
11245
|
-
|
|
11971
|
+
path9.join(source, "emptyWindowChatSessions"),
|
|
11972
|
+
path9.join(source, "transferredChatSessions")
|
|
11246
11973
|
]
|
|
11247
11974
|
}
|
|
11248
11975
|
];
|
|
@@ -11331,7 +12058,7 @@ async function* extractVsCode(source, extractionId) {
|
|
|
11331
12058
|
repoRef: fold.workspaceRoot,
|
|
11332
12059
|
eventKind: "ai_tool_call_started",
|
|
11333
12060
|
metrics: { toolName: call.name },
|
|
11334
|
-
provenance: HISTORICAL_PROVENANCE.derived,
|
|
12061
|
+
provenance: call.timed ? HISTORICAL_PROVENANCE.direct : HISTORICAL_PROVENANCE.derived,
|
|
11335
12062
|
extractionId
|
|
11336
12063
|
};
|
|
11337
12064
|
}
|
|
@@ -11345,11 +12072,25 @@ async function* extractVsCode(source, extractionId) {
|
|
|
11345
12072
|
modelCount: fold.models.size,
|
|
11346
12073
|
sessionStartedAt: fold.firstTs
|
|
11347
12074
|
};
|
|
11348
|
-
const primaryModel =
|
|
12075
|
+
const primaryModel = topOf(fold.models);
|
|
11349
12076
|
if (primaryModel) sessionMetrics.primaryModel = primaryModel;
|
|
12077
|
+
if (fold.outputTokensSeen) sessionMetrics.outputTokens = fold.outputTokens;
|
|
12078
|
+
if (fold.promptTokensPeak > 0) sessionMetrics.contextWindowPeakTokens = fold.promptTokensPeak;
|
|
12079
|
+
if (!fold.outputTokensSeen && fold.promptTokensPeak === 0) sessionMetrics.tokensNotCollected = true;
|
|
12080
|
+
if (fold.contextWindowTokens > 0) {
|
|
12081
|
+
sessionMetrics.contextWindowTokens = fold.contextWindowTokens;
|
|
12082
|
+
if (fold.promptTokensPeak > 0) {
|
|
12083
|
+
sessionMetrics.contextWindowPeakPct = Math.round(fold.promptTokensPeak / fold.contextWindowTokens * 1e3) / 1e3;
|
|
12084
|
+
}
|
|
12085
|
+
}
|
|
12086
|
+
if (fold.copilotCreditsSeen) sessionMetrics.copilotCredits = Math.round(fold.copilotCredits * 1e5) / 1e5;
|
|
12087
|
+
const reasoningEffort = topOf(fold.reasoningEfforts);
|
|
12088
|
+
if (reasoningEffort) sessionMetrics.reasoningEffort = reasoningEffort;
|
|
12089
|
+
const mode = topOf(fold.modes);
|
|
12090
|
+
if (mode) sessionMetrics.mode = mode;
|
|
11350
12091
|
if (Number.isFinite(durationMs) && durationMs >= 0) {
|
|
11351
12092
|
sessionMetrics.sessionMinutes = Math.round(durationMs / 6e4);
|
|
11352
|
-
const bucket = (0,
|
|
12093
|
+
const bucket = (0, import_tool_kit7.bucketDurationMs)(durationMs);
|
|
11353
12094
|
if (bucket) sessionMetrics.durationBucket = bucket;
|
|
11354
12095
|
}
|
|
11355
12096
|
yield {
|
|
@@ -11424,10 +12165,10 @@ async function* extractVsCode(source, extractionId) {
|
|
|
11424
12165
|
}
|
|
11425
12166
|
|
|
11426
12167
|
// src/extractors/git.ts
|
|
11427
|
-
var
|
|
12168
|
+
var import_tool_kit8 = __toESM(require_out3(), 1);
|
|
11428
12169
|
import { execFile as execFile4 } from "node:child_process";
|
|
11429
12170
|
import { createHash as createHash2 } from "node:crypto";
|
|
11430
|
-
import * as
|
|
12171
|
+
import * as fs9 from "node:fs/promises";
|
|
11431
12172
|
import { promisify as promisify4 } from "node:util";
|
|
11432
12173
|
var execFileAsync4 = promisify4(execFile4);
|
|
11433
12174
|
var DEFAULT_GIT_SINCE_DAYS = 365;
|
|
@@ -11440,7 +12181,7 @@ async function git(repo, args) {
|
|
|
11440
12181
|
}
|
|
11441
12182
|
async function repoRootOf(ref) {
|
|
11442
12183
|
try {
|
|
11443
|
-
await
|
|
12184
|
+
await fs9.access(ref);
|
|
11444
12185
|
const root = (await git(ref, ["rev-parse", "--show-toplevel"])).trim();
|
|
11445
12186
|
return root || null;
|
|
11446
12187
|
} catch {
|
|
@@ -11470,7 +12211,7 @@ function parseGitLog(output) {
|
|
|
11470
12211
|
const commits = [];
|
|
11471
12212
|
for (const block of output.split(COMMIT_MARK)) {
|
|
11472
12213
|
if (!block.trim()) continue;
|
|
11473
|
-
const [header, ...
|
|
12214
|
+
const [header, ...stat7] = block.split("\n");
|
|
11474
12215
|
const [sha, parentField, epoch, email, source] = header.split("");
|
|
11475
12216
|
if (!sha || !epoch) continue;
|
|
11476
12217
|
const seconds = Number(epoch);
|
|
@@ -11478,7 +12219,7 @@ function parseGitLog(output) {
|
|
|
11478
12219
|
let files = 0;
|
|
11479
12220
|
let added = 0;
|
|
11480
12221
|
let removed = 0;
|
|
11481
|
-
for (const line of
|
|
12222
|
+
for (const line of stat7) {
|
|
11482
12223
|
const m = /^(\d+|-)\t(\d+|-)\t/.exec(line);
|
|
11483
12224
|
if (!m) continue;
|
|
11484
12225
|
files += 1;
|
|
@@ -11510,7 +12251,7 @@ async function* extractGit(repoRefs, extractionId, options = {}) {
|
|
|
11510
12251
|
skipped += 1;
|
|
11511
12252
|
continue;
|
|
11512
12253
|
}
|
|
11513
|
-
const canonical = (0,
|
|
12254
|
+
const canonical = (0, import_tool_kit8.deriveWorkContext)(root)?.projectPath ?? root;
|
|
11514
12255
|
if (!roots.has(canonical)) roots.set(canonical, root);
|
|
11515
12256
|
}
|
|
11516
12257
|
let read = 0;
|
|
@@ -11550,8 +12291,8 @@ async function* extractGit(repoRefs, extractionId, options = {}) {
|
|
|
11550
12291
|
continue;
|
|
11551
12292
|
}
|
|
11552
12293
|
read += 1;
|
|
11553
|
-
const fullName = (0,
|
|
11554
|
-
const context = (0,
|
|
12294
|
+
const fullName = (0, import_tool_kit8.repoKeysEnabled)() ? (0, import_tool_kit8.readForgeFullName)(canonical) : null;
|
|
12295
|
+
const context = (0, import_tool_kit8.deriveWorkContext)(canonical);
|
|
11555
12296
|
const seen = /* @__PURE__ */ new Set();
|
|
11556
12297
|
for (const commit of parseGitLog(output)) {
|
|
11557
12298
|
if (seen.has(commit.sha)) continue;
|
|
@@ -11564,17 +12305,17 @@ async function* extractGit(repoRefs, extractionId, options = {}) {
|
|
|
11564
12305
|
isMergeCommit: isMerge,
|
|
11565
12306
|
authoredByMe: true,
|
|
11566
12307
|
filesChangedCount: commit.files,
|
|
11567
|
-
linesAddedBucket: (0,
|
|
11568
|
-
linesRemovedBucket: (0,
|
|
11569
|
-
linesChangedBucket: (0,
|
|
12308
|
+
linesAddedBucket: (0, import_tool_kit8.bucketLinesChanged)(commit.added),
|
|
12309
|
+
linesRemovedBucket: (0, import_tool_kit8.bucketLinesChanged)(commit.removed),
|
|
12310
|
+
linesChangedBucket: (0, import_tool_kit8.bucketLinesChanged)(commit.added + commit.removed)
|
|
11570
12311
|
};
|
|
11571
12312
|
const onDefault = commit.branch !== null && commit.branch === defaultBranch;
|
|
11572
12313
|
if (commit.branch && !onDefault) {
|
|
11573
|
-
if ((0,
|
|
12314
|
+
if ((0, import_tool_kit8.deriveBranchHash)(commit.branch)) metrics.gitBranch = commit.branch;
|
|
11574
12315
|
}
|
|
11575
12316
|
if (fullName) {
|
|
11576
|
-
metrics.repoKey = (0,
|
|
11577
|
-
if (commit.branch && !onDefault) metrics.branchKey = (0,
|
|
12317
|
+
metrics.repoKey = (0, import_tool_kit8.forgeRepoKey)(fullName);
|
|
12318
|
+
if (commit.branch && !onDefault) metrics.branchKey = (0, import_tool_kit8.forgeBranchKey)(fullName, commit.branch);
|
|
11578
12319
|
}
|
|
11579
12320
|
if (!windowOldest || commit.at < windowOldest) windowOldest = commit.at;
|
|
11580
12321
|
if (!windowNewest || commit.at > windowNewest) windowNewest = commit.at;
|
|
@@ -11615,15 +12356,15 @@ async function* extractGit(repoRefs, extractionId, options = {}) {
|
|
|
11615
12356
|
}
|
|
11616
12357
|
|
|
11617
12358
|
// src/archive.ts
|
|
11618
|
-
var
|
|
12359
|
+
var import_tool_kit9 = __toESM(require_out3(), 1);
|
|
11619
12360
|
import { createHash as createHash3 } from "node:crypto";
|
|
11620
12361
|
import { createReadStream as createReadStream2, existsSync } from "node:fs";
|
|
11621
|
-
import * as
|
|
11622
|
-
import * as
|
|
12362
|
+
import * as fs10 from "node:fs/promises";
|
|
12363
|
+
import * as path10 from "node:path";
|
|
11623
12364
|
import { pipeline } from "node:stream/promises";
|
|
11624
12365
|
var ARCHIVE_SCHEMA = 1;
|
|
11625
12366
|
function defaultArchiveRoot(home) {
|
|
11626
|
-
return
|
|
12367
|
+
return path10.join((0, import_tool_kit9.ascendaHome)(home), "history-import", "archive");
|
|
11627
12368
|
}
|
|
11628
12369
|
function defaultArchiveSources(paths, includeVsCodeSessions = false) {
|
|
11629
12370
|
const sources = [
|
|
@@ -11663,10 +12404,10 @@ function defaultArchiveSources(paths, includeVsCodeSessions = false) {
|
|
|
11663
12404
|
return sources;
|
|
11664
12405
|
}
|
|
11665
12406
|
function blobPath(archiveRoot, sha256) {
|
|
11666
|
-
return
|
|
12407
|
+
return path10.join(archiveRoot, "objects", sha256.slice(0, 2), sha256);
|
|
11667
12408
|
}
|
|
11668
12409
|
function manifestDir(archiveRoot) {
|
|
11669
|
-
return
|
|
12410
|
+
return path10.join(archiveRoot, "manifests");
|
|
11670
12411
|
}
|
|
11671
12412
|
async function hashFile(file) {
|
|
11672
12413
|
const hash = createHash3("sha256");
|
|
@@ -11676,21 +12417,21 @@ async function hashFile(file) {
|
|
|
11676
12417
|
async function walkFiles(root) {
|
|
11677
12418
|
let st;
|
|
11678
12419
|
try {
|
|
11679
|
-
st = await
|
|
12420
|
+
st = await fs10.stat(root);
|
|
11680
12421
|
} catch {
|
|
11681
12422
|
return [];
|
|
11682
12423
|
}
|
|
11683
|
-
if (!st.isDirectory()) return [{ absolute: root, relative:
|
|
12424
|
+
if (!st.isDirectory()) return [{ absolute: root, relative: path10.basename(root) }];
|
|
11684
12425
|
const found = [];
|
|
11685
12426
|
async function walk(dir, prefix) {
|
|
11686
12427
|
let entries;
|
|
11687
12428
|
try {
|
|
11688
|
-
entries = await
|
|
12429
|
+
entries = await fs10.readdir(dir, { withFileTypes: true });
|
|
11689
12430
|
} catch {
|
|
11690
12431
|
return;
|
|
11691
12432
|
}
|
|
11692
12433
|
for (const entry of entries) {
|
|
11693
|
-
const absolute =
|
|
12434
|
+
const absolute = path10.join(dir, entry.name);
|
|
11694
12435
|
const relative = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
11695
12436
|
if (entry.isDirectory()) await walk(absolute, relative);
|
|
11696
12437
|
else if (entry.isFile()) found.push({ absolute, relative });
|
|
@@ -11701,14 +12442,14 @@ async function walkFiles(root) {
|
|
|
11701
12442
|
}
|
|
11702
12443
|
async function listManifests(archiveRoot) {
|
|
11703
12444
|
try {
|
|
11704
|
-
return (await
|
|
12445
|
+
return (await fs10.readdir(manifestDir(archiveRoot))).filter((f) => f.endsWith(".json")).map((f) => f.slice(0, -".json".length)).sort();
|
|
11705
12446
|
} catch {
|
|
11706
12447
|
return [];
|
|
11707
12448
|
}
|
|
11708
12449
|
}
|
|
11709
12450
|
async function readManifest(archiveRoot, generation) {
|
|
11710
12451
|
try {
|
|
11711
|
-
const raw = await
|
|
12452
|
+
const raw = await fs10.readFile(path10.join(manifestDir(archiveRoot), `${generation}.json`), "utf8");
|
|
11712
12453
|
const parsed = JSON.parse(raw);
|
|
11713
12454
|
if (parsed.schema !== ARCHIVE_SCHEMA) return null;
|
|
11714
12455
|
return parsed;
|
|
@@ -11725,7 +12466,7 @@ async function archiveStores(options) {
|
|
|
11725
12466
|
const { archiveRoot, sources, generation, now } = options;
|
|
11726
12467
|
const result = {
|
|
11727
12468
|
generation,
|
|
11728
|
-
manifestPath:
|
|
12469
|
+
manifestPath: path10.join(manifestDir(archiveRoot), `${generation}.json`),
|
|
11729
12470
|
filesArchived: 0,
|
|
11730
12471
|
filesDeduplicated: 0,
|
|
11731
12472
|
newBytes: 0,
|
|
@@ -11733,8 +12474,8 @@ async function archiveStores(options) {
|
|
|
11733
12474
|
perStore: {},
|
|
11734
12475
|
unreadable: 0
|
|
11735
12476
|
};
|
|
11736
|
-
await
|
|
11737
|
-
await
|
|
12477
|
+
await fs10.mkdir(path10.join(archiveRoot, "objects"), { recursive: true });
|
|
12478
|
+
await fs10.mkdir(manifestDir(archiveRoot), { recursive: true });
|
|
11738
12479
|
const previous = await readLatestManifest(archiveRoot);
|
|
11739
12480
|
const previousByKey = /* @__PURE__ */ new Map();
|
|
11740
12481
|
for (const file of previous?.files ?? []) {
|
|
@@ -11748,8 +12489,8 @@ async function archiveStores(options) {
|
|
|
11748
12489
|
for (const suffix of source.siblings ?? []) {
|
|
11749
12490
|
const absolute = source.root + suffix;
|
|
11750
12491
|
try {
|
|
11751
|
-
await
|
|
11752
|
-
targets.push({ absolute, relative:
|
|
12492
|
+
await fs10.stat(absolute);
|
|
12493
|
+
targets.push({ absolute, relative: path10.basename(absolute) });
|
|
11753
12494
|
} catch {
|
|
11754
12495
|
}
|
|
11755
12496
|
}
|
|
@@ -11761,7 +12502,7 @@ async function archiveStores(options) {
|
|
|
11761
12502
|
const relativePath = `${source.label}/${target.relative}`;
|
|
11762
12503
|
let st;
|
|
11763
12504
|
try {
|
|
11764
|
-
st = await
|
|
12505
|
+
st = await fs10.stat(target.absolute);
|
|
11765
12506
|
} catch {
|
|
11766
12507
|
result.unreadable += 1;
|
|
11767
12508
|
continue;
|
|
@@ -11770,7 +12511,7 @@ async function archiveStores(options) {
|
|
|
11770
12511
|
let sha256 = null;
|
|
11771
12512
|
if (prior && prior.size === st.size && prior.mtimeMs === st.mtimeMs) {
|
|
11772
12513
|
try {
|
|
11773
|
-
await
|
|
12514
|
+
await fs10.stat(blobPath(archiveRoot, prior.sha256));
|
|
11774
12515
|
sha256 = prior.sha256;
|
|
11775
12516
|
} catch {
|
|
11776
12517
|
sha256 = null;
|
|
@@ -11787,22 +12528,22 @@ async function archiveStores(options) {
|
|
|
11787
12528
|
const destination = blobPath(archiveRoot, sha256);
|
|
11788
12529
|
let alreadyHeld = true;
|
|
11789
12530
|
try {
|
|
11790
|
-
await
|
|
12531
|
+
await fs10.stat(destination);
|
|
11791
12532
|
} catch {
|
|
11792
12533
|
alreadyHeld = false;
|
|
11793
12534
|
}
|
|
11794
12535
|
if (alreadyHeld) {
|
|
11795
12536
|
result.filesDeduplicated += 1;
|
|
11796
12537
|
} else {
|
|
11797
|
-
await
|
|
12538
|
+
await fs10.mkdir(path10.dirname(destination), { recursive: true });
|
|
11798
12539
|
const temporary2 = `${destination}.tmp-${generation}`;
|
|
11799
12540
|
try {
|
|
11800
|
-
await
|
|
11801
|
-
await
|
|
12541
|
+
await fs10.copyFile(target.absolute, temporary2);
|
|
12542
|
+
await fs10.rename(temporary2, destination);
|
|
11802
12543
|
result.newBytes += st.size;
|
|
11803
12544
|
storeStats.newBytes += st.size;
|
|
11804
12545
|
} catch {
|
|
11805
|
-
await
|
|
12546
|
+
await fs10.rm(temporary2, { force: true });
|
|
11806
12547
|
result.unreadable += 1;
|
|
11807
12548
|
continue;
|
|
11808
12549
|
}
|
|
@@ -11827,8 +12568,8 @@ async function archiveStores(options) {
|
|
|
11827
12568
|
files
|
|
11828
12569
|
};
|
|
11829
12570
|
const temporary = `${result.manifestPath}.tmp`;
|
|
11830
|
-
await
|
|
11831
|
-
await
|
|
12571
|
+
await fs10.writeFile(temporary, JSON.stringify(manifest, null, 2) + "\n", "utf8");
|
|
12572
|
+
await fs10.rename(temporary, result.manifestPath);
|
|
11832
12573
|
return result;
|
|
11833
12574
|
}
|
|
11834
12575
|
async function verifyArchive(archiveRoot, manifest, deep = true) {
|
|
@@ -11838,7 +12579,7 @@ async function verifyArchive(archiveRoot, manifest, deep = true) {
|
|
|
11838
12579
|
const blob = blobPath(archiveRoot, file.sha256);
|
|
11839
12580
|
result.checked += 1;
|
|
11840
12581
|
try {
|
|
11841
|
-
await
|
|
12582
|
+
await fs10.stat(blob);
|
|
11842
12583
|
} catch {
|
|
11843
12584
|
result.missing.push(file.relativePath);
|
|
11844
12585
|
continue;
|
|
@@ -11860,10 +12601,10 @@ async function restoreArchive(archiveRoot, manifest, destination) {
|
|
|
11860
12601
|
const result = { restored: 0, skipped: 0, destination };
|
|
11861
12602
|
for (const file of manifest.files) {
|
|
11862
12603
|
const blob = blobPath(archiveRoot, file.sha256);
|
|
11863
|
-
const target =
|
|
12604
|
+
const target = path10.join(destination, file.store, file.relativePath);
|
|
11864
12605
|
try {
|
|
11865
|
-
await
|
|
11866
|
-
await
|
|
12606
|
+
await fs10.mkdir(path10.dirname(target), { recursive: true });
|
|
12607
|
+
await fs10.copyFile(blob, target);
|
|
11867
12608
|
result.restored += 1;
|
|
11868
12609
|
} catch {
|
|
11869
12610
|
result.skipped += 1;
|
|
@@ -11877,7 +12618,7 @@ async function pruneArchive(archiveRoot, keep) {
|
|
|
11877
12618
|
const doomed = keep >= generations.length ? [] : generations.slice(0, generations.length - keep);
|
|
11878
12619
|
for (const generation of doomed) {
|
|
11879
12620
|
try {
|
|
11880
|
-
await
|
|
12621
|
+
await fs10.rm(path10.join(manifestDir(archiveRoot), `${generation}.json`), { force: true });
|
|
11881
12622
|
result.generationsRemoved.push(generation);
|
|
11882
12623
|
} catch {
|
|
11883
12624
|
}
|
|
@@ -11887,31 +12628,31 @@ async function pruneArchive(archiveRoot, keep) {
|
|
|
11887
12628
|
const manifest = await readManifest(archiveRoot, generation);
|
|
11888
12629
|
for (const file of manifest?.files ?? []) live.add(file.sha256);
|
|
11889
12630
|
}
|
|
11890
|
-
const objectsRoot =
|
|
12631
|
+
const objectsRoot = path10.join(archiveRoot, "objects");
|
|
11891
12632
|
let shards = [];
|
|
11892
12633
|
try {
|
|
11893
|
-
shards = (await
|
|
12634
|
+
shards = (await fs10.readdir(objectsRoot, { withFileTypes: true })).filter((e) => e.isDirectory()).map((e) => e.name);
|
|
11894
12635
|
} catch {
|
|
11895
12636
|
return result;
|
|
11896
12637
|
}
|
|
11897
12638
|
for (const shard of shards) {
|
|
11898
12639
|
let blobs = [];
|
|
11899
12640
|
try {
|
|
11900
|
-
blobs = await
|
|
12641
|
+
blobs = await fs10.readdir(path10.join(objectsRoot, shard));
|
|
11901
12642
|
} catch {
|
|
11902
12643
|
continue;
|
|
11903
12644
|
}
|
|
11904
12645
|
for (const blob of blobs) {
|
|
11905
12646
|
if (live.has(blob)) continue;
|
|
11906
|
-
const target =
|
|
12647
|
+
const target = path10.join(objectsRoot, shard, blob);
|
|
11907
12648
|
let size = 0;
|
|
11908
12649
|
try {
|
|
11909
|
-
size = (await
|
|
12650
|
+
size = (await fs10.stat(target)).size;
|
|
11910
12651
|
} catch {
|
|
11911
12652
|
continue;
|
|
11912
12653
|
}
|
|
11913
12654
|
try {
|
|
11914
|
-
await
|
|
12655
|
+
await fs10.rm(target, { force: true });
|
|
11915
12656
|
result.blobsRemoved += 1;
|
|
11916
12657
|
result.freedBytes += size;
|
|
11917
12658
|
} catch {
|
|
@@ -11921,24 +12662,24 @@ async function pruneArchive(archiveRoot, keep) {
|
|
|
11921
12662
|
return result;
|
|
11922
12663
|
}
|
|
11923
12664
|
async function archiveSizeBytes(archiveRoot) {
|
|
11924
|
-
const objectsRoot =
|
|
12665
|
+
const objectsRoot = path10.join(archiveRoot, "objects");
|
|
11925
12666
|
let total = 0;
|
|
11926
12667
|
let shards = [];
|
|
11927
12668
|
try {
|
|
11928
|
-
shards = (await
|
|
12669
|
+
shards = (await fs10.readdir(objectsRoot, { withFileTypes: true })).filter((e) => e.isDirectory()).map((e) => e.name);
|
|
11929
12670
|
} catch {
|
|
11930
12671
|
return 0;
|
|
11931
12672
|
}
|
|
11932
12673
|
for (const shard of shards) {
|
|
11933
12674
|
let blobs = [];
|
|
11934
12675
|
try {
|
|
11935
|
-
blobs = await
|
|
12676
|
+
blobs = await fs10.readdir(path10.join(objectsRoot, shard));
|
|
11936
12677
|
} catch {
|
|
11937
12678
|
continue;
|
|
11938
12679
|
}
|
|
11939
12680
|
for (const blob of blobs) {
|
|
11940
12681
|
try {
|
|
11941
|
-
total += (await
|
|
12682
|
+
total += (await fs10.stat(path10.join(objectsRoot, shard, blob))).size;
|
|
11942
12683
|
} catch {
|
|
11943
12684
|
}
|
|
11944
12685
|
}
|
|
@@ -11947,11 +12688,11 @@ async function archiveSizeBytes(archiveRoot) {
|
|
|
11947
12688
|
}
|
|
11948
12689
|
|
|
11949
12690
|
// src/ship.ts
|
|
11950
|
-
var
|
|
12691
|
+
var import_tool_kit11 = __toESM(require_out3(), 1);
|
|
11951
12692
|
import { createHash as createHash4 } from "node:crypto";
|
|
11952
12693
|
|
|
11953
12694
|
// src/credentials.ts
|
|
11954
|
-
var
|
|
12695
|
+
var import_tool_kit10 = __toESM(require_out3(), 1);
|
|
11955
12696
|
var DEFAULT_API_BASE_URL = "https://api.ascenda.one";
|
|
11956
12697
|
var ShipConfigError = class extends Error {
|
|
11957
12698
|
constructor(message) {
|
|
@@ -11972,21 +12713,21 @@ function resolveInstallationId(flags) {
|
|
|
11972
12713
|
if (flags.installationId?.trim()) return { id: normalizeId(flags.installationId), source: "flag" };
|
|
11973
12714
|
const fromEnv = process.env.ASCENDA_TOOL_INSTALLATION_ID?.trim();
|
|
11974
12715
|
if (fromEnv) return { id: normalizeId(fromEnv), source: "env" };
|
|
11975
|
-
const credentials = (0,
|
|
12716
|
+
const credentials = (0, import_tool_kit10.readMachineCredentials)();
|
|
11976
12717
|
const top = credentials?.toolInstallationId?.trim();
|
|
11977
12718
|
if (top && !credentials?.localOnly) return { id: normalizeId(top), source: "credentials" };
|
|
11978
|
-
const hostIds = Object.keys(credentials?.tools ?? {}).map((host) => (0,
|
|
12719
|
+
const hostIds = Object.keys(credentials?.tools ?? {}).map((host) => (0, import_tool_kit10.readHostCredentials)(host)?.toolInstallationId?.trim()).filter((id) => Boolean(id) && Boolean((0, import_tool_kit10.readTokenFile)((0, import_tool_kit10.defaultTokenFilePath)(id))));
|
|
11979
12720
|
if (hostIds.length === 1) return { id: normalizeId(hostIds[0]), source: "credentials" };
|
|
11980
12721
|
if (hostIds.length > 1) {
|
|
11981
12722
|
throw new ShipConfigError(
|
|
11982
12723
|
`${hostIds.length} paired tools in ~/.ascenda/credentials.json (${hostIds.join(", ")}) and no way to choose. Pass --installation-id <id> or set ASCENDA_TOOL_INSTALLATION_ID.`
|
|
11983
12724
|
);
|
|
11984
12725
|
}
|
|
11985
|
-
const onDisk = (0,
|
|
12726
|
+
const onDisk = (0, import_tool_kit10.listPersistedToolInstallationIds)("claude_code");
|
|
11986
12727
|
if (onDisk.length === 1) return { id: onDisk[0], source: "disk" };
|
|
11987
12728
|
if (onDisk.length > 1) {
|
|
11988
12729
|
throw new ShipConfigError(
|
|
11989
|
-
`${onDisk.length} claude_code tokens in ${(0,
|
|
12730
|
+
`${onDisk.length} claude_code tokens in ${(0, import_tool_kit10.ascendaHome)()}/tokens (${onDisk.join(", ")}). Pass --installation-id <id> to choose one.`
|
|
11990
12731
|
);
|
|
11991
12732
|
}
|
|
11992
12733
|
if (credentials?.localOnly) {
|
|
@@ -11995,15 +12736,15 @@ function resolveInstallationId(flags) {
|
|
|
11995
12736
|
);
|
|
11996
12737
|
}
|
|
11997
12738
|
throw new ShipConfigError(
|
|
11998
|
-
`No paired tool found: no --installation-id, no ASCENDA_TOOL_INSTALLATION_ID, nothing in ${(0,
|
|
12739
|
+
`No paired tool found: no --installation-id, no ASCENDA_TOOL_INSTALLATION_ID, nothing in ${(0, import_tool_kit10.ascendaHome)()}/credentials.json and no token in ${(0, import_tool_kit10.ascendaHome)()}/tokens. ${SETUP_HINT}`
|
|
11999
12740
|
);
|
|
12000
12741
|
}
|
|
12001
12742
|
function loadShipConfig(flags = {}) {
|
|
12002
12743
|
const { id: toolInstallationId } = resolveInstallationId(flags);
|
|
12003
|
-
const credentials = (0,
|
|
12744
|
+
const credentials = (0, import_tool_kit10.readMachineCredentials)();
|
|
12004
12745
|
const apiBaseUrl = (flags.apiBaseUrl ?? process.env.ASCENDA_API_BASE_URL ?? credentials?.apiBaseUrl ?? DEFAULT_API_BASE_URL).replace(/\/$/, "");
|
|
12005
|
-
const tokenFilePath = flags.tokenFile ?? process.env.ASCENDA_EVENT_WRITE_TOKEN_FILE ?? (0,
|
|
12006
|
-
const eventWriteToken = (0,
|
|
12746
|
+
const tokenFilePath = flags.tokenFile ?? process.env.ASCENDA_EVENT_WRITE_TOKEN_FILE ?? (0, import_tool_kit10.defaultTokenFilePath)(toolInstallationId);
|
|
12747
|
+
const eventWriteToken = (0, import_tool_kit10.readTokenFile)(tokenFilePath) ?? process.env.ASCENDA_EVENT_WRITE_TOKEN?.trim();
|
|
12007
12748
|
if (!eventWriteToken) {
|
|
12008
12749
|
throw new ShipConfigError(
|
|
12009
12750
|
`No event write token for ${toolInstallationId}: nothing at ${tokenFilePath} and ASCENDA_EVENT_WRITE_TOKEN is unset. Pair it: ${pairCommand(toolInstallationId)}`
|
|
@@ -12013,14 +12754,14 @@ function loadShipConfig(flags = {}) {
|
|
|
12013
12754
|
apiBaseUrl,
|
|
12014
12755
|
toolInstallationId,
|
|
12015
12756
|
eventWriteToken,
|
|
12016
|
-
...(0,
|
|
12757
|
+
...(0, import_tool_kit10.readTokenFile)(tokenFilePath) ? { tokenFilePath } : {}
|
|
12017
12758
|
};
|
|
12018
12759
|
}
|
|
12019
12760
|
async function prepareToken(config, options = {}) {
|
|
12020
12761
|
const now = options.now ?? Date.now;
|
|
12021
|
-
const lead = options.leadMs ??
|
|
12762
|
+
const lead = options.leadMs ?? import_tool_kit10.TOKEN_RENEW_LEAD_MS;
|
|
12022
12763
|
if (!config.tokenFilePath) return { config, note: null };
|
|
12023
|
-
const expiresAt = (0,
|
|
12764
|
+
const expiresAt = (0, import_tool_kit10.readTokenExpiry)(config.tokenFilePath);
|
|
12024
12765
|
if (expiresAt === void 0) return { config, note: null };
|
|
12025
12766
|
if (now() >= expiresAt) {
|
|
12026
12767
|
throw new ShipConfigError(
|
|
@@ -12028,11 +12769,11 @@ async function prepareToken(config, options = {}) {
|
|
|
12028
12769
|
);
|
|
12029
12770
|
}
|
|
12030
12771
|
if (now() < expiresAt - lead) return { config, note: null };
|
|
12031
|
-
const renew = options.renew ??
|
|
12772
|
+
const renew = options.renew ?? import_tool_kit10.renewToolToken;
|
|
12032
12773
|
try {
|
|
12033
12774
|
const renewed = await renew(config.apiBaseUrl, config.eventWriteToken, AbortSignal.timeout(15e3));
|
|
12034
12775
|
if (!renewed) {
|
|
12035
|
-
const onDisk = (0,
|
|
12776
|
+
const onDisk = (0, import_tool_kit10.readTokenFile)(config.tokenFilePath);
|
|
12036
12777
|
if (onDisk && onDisk !== config.eventWriteToken) {
|
|
12037
12778
|
return { config: { ...config, eventWriteToken: onDisk }, note: "token already renewed by another process" };
|
|
12038
12779
|
}
|
|
@@ -12040,7 +12781,7 @@ async function prepareToken(config, options = {}) {
|
|
|
12040
12781
|
`The server rejected the event token for ${config.toolInstallationId} when renewing it. Pair again: ${pairCommand(config.toolInstallationId)}`
|
|
12041
12782
|
);
|
|
12042
12783
|
}
|
|
12043
|
-
(0,
|
|
12784
|
+
(0, import_tool_kit10.persistEventWriteToken)(config.tokenFilePath, renewed.eventWriteToken, renewed.expiresAt);
|
|
12044
12785
|
return {
|
|
12045
12786
|
config: { ...config, eventWriteToken: renewed.eventWriteToken },
|
|
12046
12787
|
note: `renewed the event token (now valid until ${renewed.expiresAt.slice(0, 10)})`
|
|
@@ -12075,12 +12816,12 @@ function workContextOf(repoRef) {
|
|
|
12075
12816
|
if (!repoRef) return null;
|
|
12076
12817
|
const hit = workContextMemo.get(repoRef);
|
|
12077
12818
|
if (hit !== void 0) return hit;
|
|
12078
|
-
const context = (0,
|
|
12819
|
+
const context = (0, import_tool_kit11.deriveWorkContext)(repoRef);
|
|
12079
12820
|
if (context) {
|
|
12080
|
-
(0,
|
|
12081
|
-
const legacyHash = (0,
|
|
12821
|
+
(0, import_tool_kit11.recordWorkContext)(context);
|
|
12822
|
+
const legacyHash = (0, import_tool_kit11.hashWithMachineSalt)(repoRef);
|
|
12082
12823
|
if (legacyHash && legacyHash !== context.workspaceHash && legacyHash !== context.projectHash) {
|
|
12083
|
-
(0,
|
|
12824
|
+
(0, import_tool_kit11.recordWorkContextAlias)(legacyHash, context.workspaceLabel ?? repoRef, context.workspacePath);
|
|
12084
12825
|
}
|
|
12085
12826
|
}
|
|
12086
12827
|
workContextMemo.set(repoRef, context);
|
|
@@ -12090,8 +12831,8 @@ var legacyBranchDigestsSeen = /* @__PURE__ */ new Set();
|
|
|
12090
12831
|
function registerLegacyBranchDigest(rawBranch, branchHash) {
|
|
12091
12832
|
if (legacyBranchDigestsSeen.has(rawBranch)) return;
|
|
12092
12833
|
legacyBranchDigestsSeen.add(rawBranch);
|
|
12093
|
-
const legacyHash = (0,
|
|
12094
|
-
if (legacyHash && legacyHash !== branchHash) (0,
|
|
12834
|
+
const legacyHash = (0, import_tool_kit11.hashWithMachineSalt)(rawBranch);
|
|
12835
|
+
if (legacyHash && legacyHash !== branchHash) (0, import_tool_kit11.recordWorkContextAlias)(legacyHash, rawBranch);
|
|
12095
12836
|
}
|
|
12096
12837
|
function toWirePayload(event, ordinal, toolInstallationId) {
|
|
12097
12838
|
const metadata = {
|
|
@@ -12101,7 +12842,7 @@ function toWirePayload(event, ordinal, toolInstallationId) {
|
|
|
12101
12842
|
// The importer build that shipped this row. Extractors gain metrics from
|
|
12102
12843
|
// release to release, so a metric missing from an older import is a fact
|
|
12103
12844
|
// about the build that read the store, and this is how a reader knows.
|
|
12104
|
-
collectorVersion:
|
|
12845
|
+
collectorVersion: import_tool_kit11.COLLECTOR_VERSION
|
|
12105
12846
|
};
|
|
12106
12847
|
if (event.sourceVersion) metadata.sourceVersion = event.sourceVersion;
|
|
12107
12848
|
const host = STORE_HOST[event.store];
|
|
@@ -12112,13 +12853,13 @@ function toWirePayload(event, ordinal, toolInstallationId) {
|
|
|
12112
12853
|
if (typeof metadata.gitBranch === "string") {
|
|
12113
12854
|
const rawBranch = metadata.gitBranch;
|
|
12114
12855
|
delete metadata.gitBranch;
|
|
12115
|
-
const branchHash = (0,
|
|
12856
|
+
const branchHash = (0, import_tool_kit11.deriveBranchHash)(rawBranch);
|
|
12116
12857
|
if (branchHash) {
|
|
12117
12858
|
metadata.branchHash = branchHash;
|
|
12118
12859
|
registerLegacyBranchDigest(rawBranch, branchHash);
|
|
12119
12860
|
}
|
|
12120
12861
|
}
|
|
12121
|
-
const modelClass = (0,
|
|
12862
|
+
const modelClass = (0, import_tool_kit11.classifyModelClass)(metadata.primaryModel);
|
|
12122
12863
|
if (modelClass !== void 0) metadata.modelClass = modelClass;
|
|
12123
12864
|
const context = workContextOf(event.repoRef);
|
|
12124
12865
|
return {
|
|
@@ -12133,7 +12874,7 @@ function toWirePayload(event, ordinal, toolInstallationId) {
|
|
|
12133
12874
|
// The offset in force WHEN THE EVENT HAPPENED, not when the import ran.
|
|
12134
12875
|
// A nine-month backfill crosses DST boundaries; stamping today's
|
|
12135
12876
|
// offset on all of it would shift a whole season by an hour.
|
|
12136
|
-
utcOffsetMinutes: (0,
|
|
12877
|
+
utcOffsetMinutes: (0, import_tool_kit11.utcOffsetMinutesAt)(new Date(event.occurredAt)),
|
|
12137
12878
|
severity: "low",
|
|
12138
12879
|
sessionId: event.sessionRef,
|
|
12139
12880
|
workspaceHash: context?.workspaceHash ?? null,
|
|
@@ -12264,9 +13005,9 @@ async function shipEvents(events, config, onProgress) {
|
|
|
12264
13005
|
}
|
|
12265
13006
|
|
|
12266
13007
|
// src/schedule.ts
|
|
12267
|
-
import * as
|
|
13008
|
+
import * as fs11 from "node:fs/promises";
|
|
12268
13009
|
import * as os2 from "node:os";
|
|
12269
|
-
import * as
|
|
13010
|
+
import * as path11 from "node:path";
|
|
12270
13011
|
import { spawn } from "node:child_process";
|
|
12271
13012
|
var DEFAULT_INTERVAL_DAYS = 14;
|
|
12272
13013
|
var MAX_INTERVAL_DAYS = 90;
|
|
@@ -12293,15 +13034,16 @@ function checkRetention(plan, everyDays) {
|
|
|
12293
13034
|
reason: `Claude Code deletes transcripts after ${label} (cleanupPeriodDays), too soon for a run every ${everyDays} days. Run \`ascenda-history-import fix-retention --apply\` first, or pass --override-retention.`
|
|
12294
13035
|
};
|
|
12295
13036
|
}
|
|
12296
|
-
function scheduledCommand(entry = process.argv[1] ?? "", node = process.execPath, env = process.env) {
|
|
13037
|
+
function scheduledCommand(entry = process.argv[1] ?? "", node = process.execPath, env = process.env, options = {}) {
|
|
13038
|
+
const importArgs = ["import", "--ship", ...options.git ? ["--git"] : []];
|
|
12297
13039
|
const pinned = {};
|
|
12298
13040
|
if (env.ASCENDA_HOME) pinned.ASCENDA_HOME = env.ASCENDA_HOME;
|
|
12299
13041
|
if (env.ASCENDA_API_BASE_URL) pinned.ASCENDA_API_BASE_URL = env.ASCENDA_API_BASE_URL;
|
|
12300
|
-
const inNpxCache = entry.split(
|
|
13042
|
+
const inNpxCache = entry.split(path11.sep).includes("_npx");
|
|
12301
13043
|
if (inNpxCache || !entry) {
|
|
12302
|
-
return { argv: [
|
|
13044
|
+
return { argv: [path11.join(path11.dirname(node), "npx"), "-y", "@ascenda-one/history-import", ...importArgs], env: pinned };
|
|
12303
13045
|
}
|
|
12304
|
-
return { argv: [node, entry,
|
|
13046
|
+
return { argv: [node, entry, ...importArgs], env: pinned };
|
|
12305
13047
|
}
|
|
12306
13048
|
var xml = (value) => value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
12307
13049
|
function launchdPlist(input) {
|
|
@@ -12382,12 +13124,12 @@ function defaultScheduleEnv() {
|
|
|
12382
13124
|
};
|
|
12383
13125
|
}
|
|
12384
13126
|
function scheduleFiles(env) {
|
|
12385
|
-
const log =
|
|
13127
|
+
const log = path11.join(env.home, ".ascenda", "logs", "history-import.log");
|
|
12386
13128
|
if (env.platform === "darwin") {
|
|
12387
|
-
return { files: [
|
|
13129
|
+
return { files: [path11.join(env.home, "Library", "LaunchAgents", `${LAUNCHD_LABEL}.plist`)], log };
|
|
12388
13130
|
}
|
|
12389
|
-
const dir =
|
|
12390
|
-
return { files: [
|
|
13131
|
+
const dir = path11.join(env.home, ".config", "systemd", "user");
|
|
13132
|
+
return { files: [path11.join(dir, `${SYSTEMD_UNIT}.service`), path11.join(dir, `${SYSTEMD_UNIT}.timer`)], log };
|
|
12391
13133
|
}
|
|
12392
13134
|
async function installSchedule(env, options) {
|
|
12393
13135
|
if (env.platform === "win32") {
|
|
@@ -12395,10 +13137,10 @@ async function installSchedule(env, options) {
|
|
|
12395
13137
|
}
|
|
12396
13138
|
if (env.platform === "other") throw new Error("Scheduling is supported on macOS, Linux and (as a printed command) Windows.");
|
|
12397
13139
|
const { files, log } = scheduleFiles(env);
|
|
12398
|
-
await
|
|
12399
|
-
for (const file of files) await
|
|
13140
|
+
await fs11.mkdir(path11.dirname(log), { recursive: true });
|
|
13141
|
+
for (const file of files) await fs11.mkdir(path11.dirname(file), { recursive: true });
|
|
12400
13142
|
if (env.platform === "darwin") {
|
|
12401
|
-
await
|
|
13143
|
+
await fs11.writeFile(
|
|
12402
13144
|
files[0],
|
|
12403
13145
|
launchdPlist({ command: options.command, everyDays: options.everyDays, logFile: log, pathEnv: options.pathEnv ?? "/usr/local/bin:/usr/bin:/bin" })
|
|
12404
13146
|
);
|
|
@@ -12407,8 +13149,8 @@ async function installSchedule(env, options) {
|
|
|
12407
13149
|
const loaded = await env.run(["launchctl", "bootstrap", domain, files[0]]);
|
|
12408
13150
|
return { written: files, activated: loaded.code === 0 };
|
|
12409
13151
|
}
|
|
12410
|
-
await
|
|
12411
|
-
await
|
|
13152
|
+
await fs11.writeFile(files[0], systemdService({ command: options.command, logFile: log }));
|
|
13153
|
+
await fs11.writeFile(files[1], systemdTimer({ everyDays: options.everyDays }));
|
|
12412
13154
|
await env.run(["systemctl", "--user", "daemon-reload"]);
|
|
12413
13155
|
const enabled = await env.run(["systemctl", "--user", "enable", "--now", `${SYSTEMD_UNIT}.timer`]);
|
|
12414
13156
|
return { written: files, activated: enabled.code === 0 };
|
|
@@ -12424,7 +13166,7 @@ async function removeSchedule(env) {
|
|
|
12424
13166
|
const removed = [];
|
|
12425
13167
|
for (const file of files) {
|
|
12426
13168
|
try {
|
|
12427
|
-
await
|
|
13169
|
+
await fs11.rm(file);
|
|
12428
13170
|
removed.push(file);
|
|
12429
13171
|
} catch {
|
|
12430
13172
|
}
|
|
@@ -12437,28 +13179,30 @@ async function scheduleStatus(env) {
|
|
|
12437
13179
|
const present = [];
|
|
12438
13180
|
for (const file of files) {
|
|
12439
13181
|
try {
|
|
12440
|
-
await
|
|
13182
|
+
await fs11.access(file);
|
|
12441
13183
|
present.push(file);
|
|
12442
13184
|
} catch {
|
|
12443
13185
|
}
|
|
12444
13186
|
}
|
|
12445
|
-
if (present.length === 0) return { installed: false, files: [], everyDays: null, active: null, log };
|
|
13187
|
+
if (present.length === 0) return { installed: false, files: [], everyDays: null, git: false, active: null, log };
|
|
12446
13188
|
let everyDays = null;
|
|
12447
|
-
const text = await
|
|
13189
|
+
const text = await fs11.readFile(present.find((f) => f.endsWith(".plist") || f.endsWith(".timer")) ?? present[0], "utf8");
|
|
13190
|
+
const commandFile = present.find((f) => f.endsWith(".plist") || f.endsWith(".service"));
|
|
13191
|
+
const git2 = commandFile ? /(<string>|\s)--git(<\/string>|\s|$)/m.test(await fs11.readFile(commandFile, "utf8")) : false;
|
|
12448
13192
|
const seconds = /<key>StartInterval<\/key>\s*<integer>(\d+)<\/integer>/.exec(text);
|
|
12449
13193
|
const timer = /OnUnitActiveSec=(\d+)d/.exec(text);
|
|
12450
13194
|
if (seconds) everyDays = Number(seconds[1]) / 86400;
|
|
12451
13195
|
else if (timer) everyDays = Number(timer[1]);
|
|
12452
13196
|
const probe = env.platform === "darwin" ? await env.run(["launchctl", "print", `gui/${env.uid}/${LAUNCHD_LABEL}`]) : await env.run(["systemctl", "--user", "is-active", `${SYSTEMD_UNIT}.timer`]);
|
|
12453
|
-
return { installed: true, files: present, everyDays, active: probe.code === 0, log };
|
|
13197
|
+
return { installed: true, files: present, everyDays, git: git2, active: probe.code === 0, log };
|
|
12454
13198
|
}
|
|
12455
13199
|
|
|
12456
13200
|
// src/participate.ts
|
|
12457
|
-
var
|
|
13201
|
+
var import_tool_kit12 = __toESM(require_out3(), 1);
|
|
12458
13202
|
import { spawn as spawn2 } from "node:child_process";
|
|
12459
|
-
import * as
|
|
13203
|
+
import * as fs12 from "node:fs";
|
|
12460
13204
|
import * as os3 from "node:os";
|
|
12461
|
-
import * as
|
|
13205
|
+
import * as path12 from "node:path";
|
|
12462
13206
|
import * as readline from "node:readline";
|
|
12463
13207
|
var HISTORICAL_IMPORT_GRANT = 507;
|
|
12464
13208
|
var PARTICIPATE_AGENTS = [
|
|
@@ -12487,7 +13231,7 @@ var PARTICIPATE_AGENTS = [
|
|
|
12487
13231
|
packageName: "@ascenda-one/cursor-hooks",
|
|
12488
13232
|
workspaceDir: "ascenda-cursor-hooks",
|
|
12489
13233
|
credentialsKey: "cursor",
|
|
12490
|
-
configDirs: (home) => [
|
|
13234
|
+
configDirs: (home) => [path12.join(home, ".cursor")],
|
|
12491
13235
|
binaries: ["cursor", "cursor-agent"]
|
|
12492
13236
|
},
|
|
12493
13237
|
{
|
|
@@ -12496,7 +13240,7 @@ var PARTICIPATE_AGENTS = [
|
|
|
12496
13240
|
packageName: "@ascenda-one/windsurf-hooks",
|
|
12497
13241
|
workspaceDir: "ascenda-windsurf-hooks",
|
|
12498
13242
|
credentialsKey: "windsurf",
|
|
12499
|
-
configDirs: (home) => [
|
|
13243
|
+
configDirs: (home) => [path12.join(home, ".codeium", "windsurf")],
|
|
12500
13244
|
binaries: ["windsurf"]
|
|
12501
13245
|
},
|
|
12502
13246
|
{
|
|
@@ -12505,7 +13249,7 @@ var PARTICIPATE_AGENTS = [
|
|
|
12505
13249
|
packageName: "@ascenda-one/gemini-hooks",
|
|
12506
13250
|
workspaceDir: "ascenda-gemini-hooks",
|
|
12507
13251
|
credentialsKey: "gemini_cli",
|
|
12508
|
-
configDirs: (home) => [
|
|
13252
|
+
configDirs: (home) => [path12.join(home, ".gemini")],
|
|
12509
13253
|
binaries: ["gemini"]
|
|
12510
13254
|
}
|
|
12511
13255
|
];
|
|
@@ -12519,7 +13263,7 @@ Claude Code's transcripts longer, and sends the history already here.
|
|
|
12519
13263
|
Safe to run again: anything already done is kept.
|
|
12520
13264
|
|
|
12521
13265
|
Options
|
|
12522
|
-
--api-base-url <url> Ascenda host (default ${
|
|
13266
|
+
--api-base-url <url> Ascenda host (default ${import_tool_kit12.DEFAULT_API_BASE_URL})
|
|
12523
13267
|
--local [port] the local dev server (default port 4477)
|
|
12524
13268
|
--agents <ids> only these, comma-separated: ${PARTICIPATE_AGENTS.map((agent) => agent.id).join(", ")}
|
|
12525
13269
|
--fix-retention keep Claude Code transcripts longer without asking
|
|
@@ -12587,13 +13331,13 @@ ${USAGE}`);
|
|
|
12587
13331
|
}
|
|
12588
13332
|
function onPath(binary, env) {
|
|
12589
13333
|
const extensions = process.platform === "win32" ? (env.PATHEXT ?? ".EXE;.CMD;.BAT").split(";") : [""];
|
|
12590
|
-
for (const dir of (env.PATH ?? "").split(
|
|
13334
|
+
for (const dir of (env.PATH ?? "").split(path12.delimiter)) {
|
|
12591
13335
|
if (!dir) continue;
|
|
12592
13336
|
for (const extension of extensions) {
|
|
12593
|
-
const candidate =
|
|
13337
|
+
const candidate = path12.join(dir, binary + extension.toLowerCase());
|
|
12594
13338
|
try {
|
|
12595
|
-
const
|
|
12596
|
-
if (
|
|
13339
|
+
const stat7 = fs12.statSync(candidate);
|
|
13340
|
+
if (stat7.isFile()) return true;
|
|
12597
13341
|
} catch {
|
|
12598
13342
|
}
|
|
12599
13343
|
}
|
|
@@ -12601,48 +13345,48 @@ function onPath(binary, env) {
|
|
|
12601
13345
|
return false;
|
|
12602
13346
|
}
|
|
12603
13347
|
function detectAgent(agent, home, env) {
|
|
12604
|
-
const dir = agent.configDirs(home, env).find((candidate) =>
|
|
12605
|
-
if (dir) return (0,
|
|
13348
|
+
const dir = agent.configDirs(home, env).find((candidate) => fs12.existsSync(candidate));
|
|
13349
|
+
if (dir) return (0, import_tool_kit12.tidyHomePath)(dir, home);
|
|
12606
13350
|
const binary = agent.binaries.find((name) => onPath(name, env));
|
|
12607
13351
|
return binary ? `${binary} on PATH` : void 0;
|
|
12608
13352
|
}
|
|
12609
13353
|
function credentialsOf(agent) {
|
|
12610
|
-
const machine = (0,
|
|
13354
|
+
const machine = (0, import_tool_kit12.readMachineCredentials)();
|
|
12611
13355
|
return agent.credentialsKey === null ? machine : machine?.tools?.[agent.credentialsKey];
|
|
12612
13356
|
}
|
|
12613
13357
|
function pairingOf(agent) {
|
|
12614
13358
|
const credentials = credentialsOf(agent);
|
|
12615
13359
|
const id = credentials?.toolInstallationId;
|
|
12616
13360
|
if (!id || credentials.localOnly) return void 0;
|
|
12617
|
-
const tokenFile = (0,
|
|
12618
|
-
if (!(0,
|
|
12619
|
-
return { toolInstallationId: id, apiBaseUrl: (credentials.apiBaseUrl ??
|
|
13361
|
+
const tokenFile = (0, import_tool_kit12.defaultTokenFilePath)(id);
|
|
13362
|
+
if (!(0, import_tool_kit12.readTokenFile)(tokenFile)) return void 0;
|
|
13363
|
+
return { toolInstallationId: id, apiBaseUrl: (credentials.apiBaseUrl ?? import_tool_kit12.DEFAULT_API_BASE_URL).replace(/\/$/, ""), tokenFile };
|
|
12620
13364
|
}
|
|
12621
13365
|
function participationFilePath() {
|
|
12622
|
-
return
|
|
13366
|
+
return path12.join((0, import_tool_kit12.ascendaHome)(), "participation.json");
|
|
12623
13367
|
}
|
|
12624
13368
|
function readParticipation() {
|
|
12625
13369
|
try {
|
|
12626
|
-
const parsed = JSON.parse(
|
|
13370
|
+
const parsed = JSON.parse(fs12.readFileSync(participationFilePath(), "utf8"));
|
|
12627
13371
|
return parsed && typeof parsed.joinCode === "string" ? parsed : void 0;
|
|
12628
13372
|
} catch {
|
|
12629
13373
|
return void 0;
|
|
12630
13374
|
}
|
|
12631
13375
|
}
|
|
12632
13376
|
function writeParticipation(record) {
|
|
12633
|
-
|
|
12634
|
-
(0,
|
|
13377
|
+
fs12.mkdirSync(path12.dirname(participationFilePath()), { recursive: true, mode: 448 });
|
|
13378
|
+
(0, import_tool_kit12.writeAtomically)(participationFilePath(), `${JSON.stringify(record, null, 2)}
|
|
12635
13379
|
`, 384);
|
|
12636
13380
|
}
|
|
12637
13381
|
function npxCommand(packageName, args) {
|
|
12638
|
-
const spec =
|
|
13382
|
+
const spec = import_tool_kit12.COLLECTOR_VERSION === import_tool_kit12.UNRELEASED_COLLECTOR_VERSION ? packageName : `${packageName}@${import_tool_kit12.COLLECTOR_VERSION}`;
|
|
12639
13383
|
const win = process.platform === "win32";
|
|
12640
13384
|
return { command: win ? "npx.cmd" : "npx", args: ["-y", spec, ...args], shell: win };
|
|
12641
13385
|
}
|
|
12642
13386
|
function defaultAdapterCommand(env) {
|
|
12643
13387
|
const root = env.ASCENDA_PARTICIPATE_BUNDLE_ROOT?.trim();
|
|
12644
13388
|
if (root) {
|
|
12645
|
-
return (agent, args) => ({ command: process.execPath, args: [
|
|
13389
|
+
return (agent, args) => ({ command: process.execPath, args: [path12.join(root, agent.workspaceDir, "dist", "cli.js"), ...args] });
|
|
12646
13390
|
}
|
|
12647
13391
|
return (agent, args) => npxCommand(agent.packageName, args);
|
|
12648
13392
|
}
|
|
@@ -12726,7 +13470,7 @@ async function runParticipate(ctx) {
|
|
|
12726
13470
|
`);
|
|
12727
13471
|
return 1;
|
|
12728
13472
|
}
|
|
12729
|
-
const ui = (0,
|
|
13473
|
+
const ui = (0, import_tool_kit12.terminalStyle)((0, import_tool_kit12.colourEnabled)(stdout, env));
|
|
12730
13474
|
const home = os3.homedir();
|
|
12731
13475
|
const adapterCommand = ctx.adapterCommand ?? defaultAdapterCommand(env);
|
|
12732
13476
|
const importerCommand = ctx.importerCommand ?? defaultImporterCommand;
|
|
@@ -12763,21 +13507,21 @@ ${ui.bold(`${n}/4 ${title}`)}`);
|
|
|
12763
13507
|
print(` ${ui.bold(agent.displayName)} ${ui.dim(`(found ${foundAt})`)}`);
|
|
12764
13508
|
if (needsConfirm) print(` ${ui.cyan(`Confirm ${++confirmIndex} of ${confirms}:`)} ${confirmWhat(agent)} using the link below.`);
|
|
12765
13509
|
const args = ["setup", "--scope", "user", ...options.apiBaseUrl ? ["--api-base-url", options.apiBaseUrl] : []];
|
|
12766
|
-
const outcomeDir = agent === carrier ?
|
|
12767
|
-
const outcomeFile = outcomeDir ?
|
|
13510
|
+
const outcomeDir = agent === carrier ? fs12.mkdtempSync(path12.join(os3.tmpdir(), "ascenda-participate-join-")) : void 0;
|
|
13511
|
+
const outcomeFile = outcomeDir ? path12.join(outcomeDir, "pairing-join.json") : void 0;
|
|
12768
13512
|
const childEnv = { ...env };
|
|
12769
|
-
delete childEnv[
|
|
12770
|
-
delete childEnv[
|
|
13513
|
+
delete childEnv[import_tool_kit12.PAIR_ORG_JOIN_CODE_ENV];
|
|
13514
|
+
delete childEnv[import_tool_kit12.PAIR_JOIN_OUTCOME_FILE_ENV];
|
|
12771
13515
|
if (outcomeFile) {
|
|
12772
|
-
childEnv[
|
|
12773
|
-
childEnv[
|
|
13516
|
+
childEnv[import_tool_kit12.PAIR_ORG_JOIN_CODE_ENV] = options.joinCode;
|
|
13517
|
+
childEnv[import_tool_kit12.PAIR_JOIN_OUTCOME_FILE_ENV] = outcomeFile;
|
|
12774
13518
|
}
|
|
12775
13519
|
let exit;
|
|
12776
13520
|
try {
|
|
12777
13521
|
exit = await runChild(adapterCommand(agent, args), childEnv, stdout);
|
|
12778
13522
|
if (outcomeFile) carried = readPairingJoinOutcome(outcomeFile);
|
|
12779
13523
|
} finally {
|
|
12780
|
-
if (outcomeDir)
|
|
13524
|
+
if (outcomeDir) fs12.rmSync(outcomeDir, { recursive: true, force: true });
|
|
12781
13525
|
}
|
|
12782
13526
|
const pairing = pairingOf(agent);
|
|
12783
13527
|
if (exit !== 0) agents.push({ agent, foundAt, state: "failed", detail: `setup exited ${exit}`, pairing });
|
|
@@ -12790,7 +13534,7 @@ ${ui.bold(`${n}/4 ${title}`)}`);
|
|
|
12790
13534
|
let study;
|
|
12791
13535
|
if (joinRemembered && record) {
|
|
12792
13536
|
study = { state: "already", record };
|
|
12793
|
-
print(` Already joined ${record.organisationName} with this code ${ui.dim(`(${(0,
|
|
13537
|
+
print(` Already joined ${record.organisationName} with this code ${ui.dim(`(${(0, import_tool_kit12.formatWindow)(record.windowStartUtc, record.windowEndUtc)})`)}. Not asking again.`);
|
|
12794
13538
|
print(ui.dim(" To join again anyway, add --rejoin."));
|
|
12795
13539
|
} else if (carried && settledByPairing(carried)) {
|
|
12796
13540
|
study = studyFromPairing(carried, options, agents.find((result) => result.agent === carrier)?.pairing?.apiBaseUrl ?? lead?.pairing?.apiBaseUrl ?? "");
|
|
@@ -12806,9 +13550,9 @@ ${ui.bold(`${n}/4 ${title}`)}`);
|
|
|
12806
13550
|
if (carried?.join === "not_carried") print(ui.dim(" This server didn't take the code on the pairing, so the study is joined separately."));
|
|
12807
13551
|
print(` ${ui.cyan(`Confirm ${++confirmIndex} of ${Math.max(confirms, confirmIndex)}:`)} join the study, after you answer the question below.`);
|
|
12808
13552
|
let outcome;
|
|
12809
|
-
await (0,
|
|
13553
|
+
await (0, import_tool_kit12.runStudyJoin)({
|
|
12810
13554
|
apiBaseUrl: lead.pairing.apiBaseUrl,
|
|
12811
|
-
eventWriteToken: (0,
|
|
13555
|
+
eventWriteToken: (0, import_tool_kit12.readTokenFile)(lead.pairing.tokenFile) ?? "",
|
|
12812
13556
|
displayName: lead.agent.displayName,
|
|
12813
13557
|
joinCode: options.joinCode,
|
|
12814
13558
|
stdin,
|
|
@@ -12828,12 +13572,14 @@ ${ui.bold(`${n}/4 ${title}`)}`);
|
|
|
12828
13572
|
windowStartUtc: outcome.start.windowStartUtc,
|
|
12829
13573
|
windowEndUtc: outcome.start.windowEndUtc,
|
|
12830
13574
|
granted: outcome.granted,
|
|
12831
|
-
joinedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
13575
|
+
joinedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
13576
|
+
joinSessionId: outcome.start.joinSessionId,
|
|
13577
|
+
importStores: outcome.importStores ?? null
|
|
12832
13578
|
};
|
|
12833
13579
|
writeParticipation(joined);
|
|
12834
13580
|
study = { state: "joined", record: joined };
|
|
12835
13581
|
} else {
|
|
12836
|
-
study = { state: "not_joined", reason: describeJoinMiss(outcome), granted: outcome?.granted ?? [] };
|
|
13582
|
+
study = { state: "not_joined", reason: describeJoinMiss(outcome), granted: outcome?.granted ?? [], importStores: outcome?.importStores };
|
|
12837
13583
|
}
|
|
12838
13584
|
}
|
|
12839
13585
|
step(3, "Retention");
|
|
@@ -12851,7 +13597,10 @@ ${ui.bold(`${n}/4 ${title}`)}`);
|
|
|
12851
13597
|
backfill = { state: "skipped", reason: "the study didn't grant importing your history, so it would be refused" };
|
|
12852
13598
|
print(" Skipped: importing your history wasn't granted, so the backend would refuse it.");
|
|
12853
13599
|
} else {
|
|
12854
|
-
|
|
13600
|
+
const stores = await importStoresFor(study, (0, import_tool_kit12.readTokenFile)(lead.pairing.tokenFile) ?? "");
|
|
13601
|
+
const git2 = gitDecision(stores);
|
|
13602
|
+
print(` Git history: ${git2.included ? "" : "not "}included. ${capitalise(git2.reason)}.`);
|
|
13603
|
+
backfill = await runBackfill(lead, importerCommand, env, stdout, git2);
|
|
12855
13604
|
}
|
|
12856
13605
|
printSummary({ agents, study, retention, backfill, print, ui, home });
|
|
12857
13606
|
const ok = agents.every((result) => result.state === "collecting") && study.state !== "not_joined" && retention.state !== "failed" && (backfill.state === "ran" ? backfill.summary.exitCode === 0 : backfill.state !== "failed");
|
|
@@ -12859,7 +13608,7 @@ ${ui.bold(`${n}/4 ${title}`)}`);
|
|
|
12859
13608
|
}
|
|
12860
13609
|
function readPairingJoinOutcome(file) {
|
|
12861
13610
|
try {
|
|
12862
|
-
const parsed = JSON.parse(
|
|
13611
|
+
const parsed = JSON.parse(fs12.readFileSync(file, "utf8"));
|
|
12863
13612
|
return parsed && typeof parsed.join === "string" ? parsed : void 0;
|
|
12864
13613
|
} catch {
|
|
12865
13614
|
return void 0;
|
|
@@ -12870,30 +13619,32 @@ function settledByPairing(outcome) {
|
|
|
12870
13619
|
}
|
|
12871
13620
|
function studyFromPairing(outcome, options, apiBaseUrl) {
|
|
12872
13621
|
if (outcome.join === "refused") return { state: "not_joined", reason: outcome.message ?? "the code was refused", granted: [] };
|
|
12873
|
-
const
|
|
12874
|
-
if (!
|
|
13622
|
+
const join15 = outcome.studyJoin;
|
|
13623
|
+
if (!join15) {
|
|
12875
13624
|
const reason = outcome.pairing === "paired" ? "the join didn't finish" : "the pairing wasn't confirmed, so neither was the join";
|
|
12876
13625
|
return { state: "not_joined", reason, granted: [] };
|
|
12877
13626
|
}
|
|
12878
|
-
const granted =
|
|
12879
|
-
if (
|
|
13627
|
+
const granted = join15.granted ?? [];
|
|
13628
|
+
if (join15.status === "confirmed" && granted.length > 0) {
|
|
12880
13629
|
return {
|
|
12881
13630
|
state: "joined",
|
|
12882
13631
|
record: {
|
|
12883
13632
|
joinCode: options.joinCode,
|
|
12884
13633
|
apiBaseUrl,
|
|
12885
|
-
organisationName:
|
|
12886
|
-
studyKind:
|
|
12887
|
-
windowStartUtc:
|
|
12888
|
-
windowEndUtc:
|
|
13634
|
+
organisationName: join15.organisationName,
|
|
13635
|
+
studyKind: join15.studyKind,
|
|
13636
|
+
windowStartUtc: join15.windowStartUtc,
|
|
13637
|
+
windowEndUtc: join15.windowEndUtc,
|
|
12889
13638
|
granted,
|
|
12890
|
-
joinedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
13639
|
+
joinedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
13640
|
+
joinSessionId: join15.joinSessionId,
|
|
13641
|
+
importStores: join15.importStores ?? null
|
|
12891
13642
|
}
|
|
12892
13643
|
};
|
|
12893
13644
|
}
|
|
12894
|
-
if (
|
|
12895
|
-
if (
|
|
12896
|
-
if (
|
|
13645
|
+
if (join15.status === "confirmed") return { state: "not_joined", reason: "nothing was granted", granted: [] };
|
|
13646
|
+
if (join15.status === "refused") return { state: "not_joined", reason: (0, import_tool_kit12.describeStudyJoinRefusal)(join15.refusedReason), granted, importStores: join15.importStores };
|
|
13647
|
+
if (join15.status === "expired") return { state: "not_joined", reason: "the link expired before it was confirmed", granted: [] };
|
|
12897
13648
|
return { state: "not_joined", reason: "the link wasn't confirmed in time", granted: [] };
|
|
12898
13649
|
}
|
|
12899
13650
|
function rememberedJoin(record, options) {
|
|
@@ -12919,12 +13670,12 @@ function describeJoinMiss(outcome) {
|
|
|
12919
13670
|
}
|
|
12920
13671
|
async function runRetention(options, home, env, stdin, stdout, print) {
|
|
12921
13672
|
const paths = resolveStorePaths(home, env);
|
|
12922
|
-
if (!
|
|
13673
|
+
if (!fs12.existsSync(paths.claudeRoot)) {
|
|
12923
13674
|
print(" Nothing to change: Claude Code isn't on this machine.");
|
|
12924
13675
|
return { state: "absent" };
|
|
12925
13676
|
}
|
|
12926
13677
|
const plan = await planClaudeRetentionFix(paths);
|
|
12927
|
-
const where = (0,
|
|
13678
|
+
const where = (0, import_tool_kit12.tidyHomePath)(plan.settingsPath, home);
|
|
12928
13679
|
if (!plan.changeNeeded) {
|
|
12929
13680
|
print(` Claude Code keeps transcripts for ${plan.currentCleanupPeriodDays} days already. Nothing to change.`);
|
|
12930
13681
|
return { state: "current", plan };
|
|
@@ -12954,13 +13705,46 @@ async function runRetention(options, home, env, stdin, stdout, print) {
|
|
|
12954
13705
|
return { state: "failed", plan, reason };
|
|
12955
13706
|
}
|
|
12956
13707
|
}
|
|
12957
|
-
async function
|
|
13708
|
+
async function readImportStores(record, token) {
|
|
13709
|
+
if (record?.joinSessionId) {
|
|
13710
|
+
try {
|
|
13711
|
+
const status = await (0, import_tool_kit12.getStudyJoinStatus)(record.apiBaseUrl, token, record.joinSessionId);
|
|
13712
|
+
const stores = status.importStores ?? null;
|
|
13713
|
+
if (!sameStores(stores, record.importStores)) writeParticipation({ ...record, importStores: stores });
|
|
13714
|
+
return { from: "status", stores };
|
|
13715
|
+
} catch {
|
|
13716
|
+
}
|
|
13717
|
+
}
|
|
13718
|
+
if (record && Array.isArray(record.importStores)) return { from: "record", stores: record.importStores };
|
|
13719
|
+
return { from: "unknown", stores: null };
|
|
13720
|
+
}
|
|
13721
|
+
function sameStores(a, b) {
|
|
13722
|
+
return JSON.stringify([...a ?? []].sort()) === JSON.stringify([...b ?? []].sort()) && a == null === (b == null);
|
|
13723
|
+
}
|
|
13724
|
+
async function importStoresFor(study, token) {
|
|
13725
|
+
if (study.state === "joined") return { from: "join", stores: study.record.importStores ?? null };
|
|
13726
|
+
if (study.state === "already") return readImportStores(study.record, token);
|
|
13727
|
+
if (study.state !== "not_joined" || study.importStores === void 0) return { from: "unknown", stores: null };
|
|
13728
|
+
return { from: "join", stores: study.importStores };
|
|
13729
|
+
}
|
|
13730
|
+
var GIT_NOT_GRANTED = "your history-import grant doesn't cover git. To add it, run this again with --rejoin and tick the git box on the page";
|
|
13731
|
+
function gitDecision(read) {
|
|
13732
|
+
if (read.stores?.includes("git")) return { included: true, reason: "your history-import grant covers git" };
|
|
13733
|
+
if (read.from === "unknown") return { included: false, reason: "couldn't read which stores your grant covers, so git was left out" };
|
|
13734
|
+
return { included: false, reason: GIT_NOT_GRANTED };
|
|
13735
|
+
}
|
|
13736
|
+
function capitalise(text) {
|
|
13737
|
+
return text.charAt(0).toUpperCase() + text.slice(1);
|
|
13738
|
+
}
|
|
13739
|
+
async function runBackfill(lead, importerCommand, env, stdout, git2) {
|
|
12958
13740
|
const pairing = lead.pairing;
|
|
12959
|
-
const summaryDir =
|
|
12960
|
-
const summaryFile =
|
|
12961
|
-
|
|
13741
|
+
const summaryDir = fs12.mkdtempSync(path12.join(os3.tmpdir(), "ascenda-participate-"));
|
|
13742
|
+
const summaryFile = path12.join(summaryDir, "import-summary.json");
|
|
13743
|
+
stdout.write(` Sending as ${lead.agent.displayName}'s pairing ${pairing.toolInstallationId}.
|
|
13744
|
+
`);
|
|
12962
13745
|
try {
|
|
12963
|
-
const
|
|
13746
|
+
const args = ["import", "--ship", ...git2.included ? ["--git"] : [], "--summary-json", summaryFile];
|
|
13747
|
+
const exit = await runChild(importerCommand(args), {
|
|
12964
13748
|
...env,
|
|
12965
13749
|
ASCENDA_API_BASE_URL: pairing.apiBaseUrl,
|
|
12966
13750
|
ASCENDA_TOOL_INSTALLATION_ID: pairing.toolInstallationId,
|
|
@@ -12968,14 +13752,14 @@ async function runBackfill(lead, importerCommand, env, stdout, print) {
|
|
|
12968
13752
|
}, stdout);
|
|
12969
13753
|
let summary;
|
|
12970
13754
|
try {
|
|
12971
|
-
summary = JSON.parse(
|
|
13755
|
+
summary = JSON.parse(fs12.readFileSync(summaryFile, "utf8"));
|
|
12972
13756
|
} catch {
|
|
12973
|
-
return { state: "failed", reason: `the import exited ${exit} without a summary
|
|
13757
|
+
return { state: "failed", reason: `the import exited ${exit} without a summary`, git: git2 };
|
|
12974
13758
|
}
|
|
12975
|
-
if (summary.nothingToImport) return { state: "nothing" };
|
|
12976
|
-
return { state: "ran", summary, shippedAs: pairing.toolInstallationId };
|
|
13759
|
+
if (summary.nothingToImport) return { state: "nothing", git: git2 };
|
|
13760
|
+
return { state: "ran", summary, shippedAs: pairing.toolInstallationId, git: git2 };
|
|
12977
13761
|
} finally {
|
|
12978
|
-
|
|
13762
|
+
fs12.rmSync(summaryDir, { recursive: true, force: true });
|
|
12979
13763
|
}
|
|
12980
13764
|
}
|
|
12981
13765
|
var REJECTION_SENTENCES = {
|
|
@@ -13001,12 +13785,12 @@ function printSummary(input) {
|
|
|
13001
13785
|
});
|
|
13002
13786
|
if (study.state === "not_joined") {
|
|
13003
13787
|
print(`${label("Study")}${ui.mark("bad")} not joined: ${study.reason}`);
|
|
13004
|
-
if (study.granted.length) print(`${pad} granted before it stopped: ${study.granted.map(
|
|
13788
|
+
if (study.granted.length) print(`${pad} granted before it stopped: ${study.granted.map(import_tool_kit12.describeStudyGrant).join("; ")}`);
|
|
13005
13789
|
} else {
|
|
13006
13790
|
const { record } = study;
|
|
13007
|
-
print(`${label("Study")}${ui.mark("ok")} ${record.organisationName}, ${(0,
|
|
13008
|
-
print(`${pad} window ${(0,
|
|
13009
|
-
for (const grant of record.granted) print(`${pad} granted: ${(0,
|
|
13791
|
+
print(`${label("Study")}${ui.mark("ok")} ${record.organisationName}, ${(0, import_tool_kit12.describeStudyKind)(record.studyKind)}${study.state === "already" ? ui.dim(" (joined earlier)") : ""}`);
|
|
13792
|
+
print(`${pad} window ${(0, import_tool_kit12.formatWindow)(record.windowStartUtc, record.windowEndUtc)}`);
|
|
13793
|
+
for (const grant of record.granted) print(`${pad} granted: ${(0, import_tool_kit12.describeStudyGrant)(grant)}`);
|
|
13010
13794
|
}
|
|
13011
13795
|
const days = (plan) => plan.currentCleanupPeriodDays === null ? "30 days (default)" : `${plan.currentCleanupPeriodDays} days`;
|
|
13012
13796
|
if (retention.state === "absent") print(`${label("Retention")}${ui.mark("info")} Claude Code isn't on this machine`);
|
|
@@ -13033,12 +13817,16 @@ function printSummary(input) {
|
|
|
13033
13817
|
print(`${pad} ${n(count)} rejected: ${REJECTION_SENTENCES[reason] ?? reason}`);
|
|
13034
13818
|
}
|
|
13035
13819
|
if (ship.consentBlocked) print(`${pad} stopped early: the account has no consent for a history import, so nothing more was sent`);
|
|
13820
|
+
if (ship.storesNotGranted?.length) print(`${pad} not granted, so skipped: ${ship.storesNotGranted.join(", ")}`);
|
|
13036
13821
|
if (ship.httpFailures) print(`${pad} ${n(ship.httpFailures)} batch(es) failed to send. Run this again to fill the gaps`);
|
|
13037
13822
|
}
|
|
13038
13823
|
for (const outcome of summary.outcomes.filter((entry) => entry.status === "failed")) {
|
|
13039
13824
|
print(`${pad} ${outcome.store} couldn't be read: ${outcome.error}`);
|
|
13040
13825
|
}
|
|
13041
13826
|
}
|
|
13827
|
+
if (backfill.state !== "skipped") {
|
|
13828
|
+
print(`${label("Git")}${ui.mark(backfill.git.included ? "ok" : "info")} ${backfill.git.included ? "included" : "not included"}: ${backfill.git.reason}`);
|
|
13829
|
+
}
|
|
13042
13830
|
print("");
|
|
13043
13831
|
const unpaired = agents.filter((result) => result.state !== "collecting");
|
|
13044
13832
|
if (unpaired.length || study.state === "not_joined" || backfill.state === "failed") {
|
|
@@ -13049,7 +13837,7 @@ function printSummary(input) {
|
|
|
13049
13837
|
}
|
|
13050
13838
|
|
|
13051
13839
|
// src/localHandoff.ts
|
|
13052
|
-
var
|
|
13840
|
+
var import_tool_kit13 = __toESM(require_out3(), 1);
|
|
13053
13841
|
|
|
13054
13842
|
// src/handoffActiveTime.ts
|
|
13055
13843
|
var SESSION_SPLIT_QUANTITIES = {
|
|
@@ -13097,6 +13885,10 @@ var CODEX_ACTIVE_TIME_QUANTITIES = {
|
|
|
13097
13885
|
...SESSION_SPLIT_QUANTITIES,
|
|
13098
13886
|
...PROJECT_DIGEST_QUANTITIES
|
|
13099
13887
|
};
|
|
13888
|
+
var COPILOT_CLI_ACTIVE_TIME_QUANTITIES = {
|
|
13889
|
+
...SESSION_SPLIT_QUANTITIES,
|
|
13890
|
+
...PROJECT_DIGEST_QUANTITIES
|
|
13891
|
+
};
|
|
13100
13892
|
var CROSS_STORE_ACTIVE_TIME_QUANTITIES = {
|
|
13101
13893
|
...PROJECT_ELAPSED_QUANTITIES
|
|
13102
13894
|
};
|
|
@@ -13257,23 +14049,23 @@ function clipByLocalDay(interval) {
|
|
|
13257
14049
|
}
|
|
13258
14050
|
|
|
13259
14051
|
// src/localHandoff.ts
|
|
13260
|
-
import * as
|
|
14052
|
+
import * as fs13 from "node:fs/promises";
|
|
13261
14053
|
import * as os4 from "node:os";
|
|
13262
|
-
import * as
|
|
14054
|
+
import * as path13 from "node:path";
|
|
13263
14055
|
var APP_BUNDLE_ID = "one.ascenda.ascendaMissionControl";
|
|
13264
14056
|
var HANDOFF_SCHEMA = 6;
|
|
13265
14057
|
function handoffDir(home = os4.homedir()) {
|
|
13266
|
-
return
|
|
14058
|
+
return path13.join((0, import_tool_kit13.ascendaHome)(home), "history-import");
|
|
13267
14059
|
}
|
|
13268
14060
|
function handoffFilePath(home = os4.homedir(), store = "claude_code") {
|
|
13269
|
-
return
|
|
14061
|
+
return path13.join(handoffDir(home), `${store}.json`);
|
|
13270
14062
|
}
|
|
13271
14063
|
var projectLabelMemo = /* @__PURE__ */ new Map();
|
|
13272
14064
|
function projectLabelOf(repoRef) {
|
|
13273
14065
|
if (!repoRef) return null;
|
|
13274
14066
|
const hit = projectLabelMemo.get(repoRef);
|
|
13275
14067
|
if (hit !== void 0) return hit;
|
|
13276
|
-
const label = (0,
|
|
14068
|
+
const label = (0, import_tool_kit13.deriveWorkContext)(repoRef)?.projectLabel ?? null;
|
|
13277
14069
|
projectLabelMemo.set(repoRef, label);
|
|
13278
14070
|
return label;
|
|
13279
14071
|
}
|
|
@@ -13282,7 +14074,7 @@ function projectHashOf(repoRef) {
|
|
|
13282
14074
|
if (!repoRef) return null;
|
|
13283
14075
|
const hit = projectHashMemo.get(repoRef);
|
|
13284
14076
|
if (hit !== void 0) return hit;
|
|
13285
|
-
const hash = (0,
|
|
14077
|
+
const hash = (0, import_tool_kit13.deriveWorkContext)(repoRef)?.projectHash ?? null;
|
|
13286
14078
|
projectHashMemo.set(repoRef, hash);
|
|
13287
14079
|
return hash;
|
|
13288
14080
|
}
|
|
@@ -13525,6 +14317,60 @@ function buildCodexHandoff(events, extractionId, generatedAt) {
|
|
|
13525
14317
|
projects: buildProjectDigests(sessions, projectSpans)
|
|
13526
14318
|
};
|
|
13527
14319
|
}
|
|
14320
|
+
function buildCopilotCliHandoff(events, extractionId, generatedAt) {
|
|
14321
|
+
const sessions = [];
|
|
14322
|
+
const projectSpans = collectProjectSpans(events);
|
|
14323
|
+
let windowOldest = null;
|
|
14324
|
+
let windowNewest = null;
|
|
14325
|
+
for (const event of events) {
|
|
14326
|
+
if (event.eventKind === "extraction_epoch") {
|
|
14327
|
+
const oldest = event.metrics.windowOldest;
|
|
14328
|
+
const newest = event.metrics.windowNewest;
|
|
14329
|
+
if (typeof oldest === "string") windowOldest = oldest;
|
|
14330
|
+
if (typeof newest === "string") windowNewest = newest;
|
|
14331
|
+
continue;
|
|
14332
|
+
}
|
|
14333
|
+
if (event.eventKind !== "create_focus_session") continue;
|
|
14334
|
+
sessions.push({
|
|
14335
|
+
at: event.occurredAt,
|
|
14336
|
+
startedAt: typeof event.metrics.sessionStartedAt === "string" ? event.metrics.sessionStartedAt : null,
|
|
14337
|
+
sessionRef: event.sessionRef,
|
|
14338
|
+
projectLabel: projectLabelOf(event.repoRef),
|
|
14339
|
+
projectHash: projectHashOf(event.repoRef),
|
|
14340
|
+
promptCount: Number(event.metrics.promptCount ?? 0),
|
|
14341
|
+
durationBucket: String(event.metrics.durationBucket ?? "unknown"),
|
|
14342
|
+
afterHoursPrompts: Number(event.metrics.afterHoursPrompts ?? 0),
|
|
14343
|
+
primaryModel: typeof event.metrics.primaryModel === "string" ? event.metrics.primaryModel : null,
|
|
14344
|
+
activeMinutes: Number(event.metrics.activeMinutes ?? 0),
|
|
14345
|
+
handsOnMinutes: Number(event.metrics.handsOnMinutes ?? 0),
|
|
14346
|
+
agentSupervisingMinutes: Number(event.metrics.agentSupervisingMinutes ?? 0),
|
|
14347
|
+
autonomySplit: event.autonomySplit ?? {},
|
|
14348
|
+
compactionCount: Number(event.metrics.compactionCount ?? 0),
|
|
14349
|
+
toolFailureCount: Number(event.metrics.toolFailureCount ?? 0),
|
|
14350
|
+
toolCallCount: Number(event.metrics.toolCallCount ?? 0),
|
|
14351
|
+
linesAdded: typeof event.metrics.linesAdded === "number" ? event.metrics.linesAdded : null,
|
|
14352
|
+
linesRemoved: typeof event.metrics.linesRemoved === "number" ? event.metrics.linesRemoved : null,
|
|
14353
|
+
days: event.dayBreakdown ?? [],
|
|
14354
|
+
provenance: event.provenance
|
|
14355
|
+
});
|
|
14356
|
+
}
|
|
14357
|
+
sessions.sort((a, b) => a.at.localeCompare(b.at));
|
|
14358
|
+
return {
|
|
14359
|
+
schema: HANDOFF_SCHEMA,
|
|
14360
|
+
extractionId,
|
|
14361
|
+
generatedAt,
|
|
14362
|
+
timezone: LOCAL_TIMEZONE,
|
|
14363
|
+
activeGapMinutes: DEFAULT_ACTIVE_GAP_MS / 6e4,
|
|
14364
|
+
// Not classified past the prompt line yet, as with Codex.
|
|
14365
|
+
handsOnBoundary: "nearest_line",
|
|
14366
|
+
activeTimeQuantities: COPILOT_CLI_ACTIVE_TIME_QUANTITIES,
|
|
14367
|
+
store: "copilot_cli",
|
|
14368
|
+
windowOldest,
|
|
14369
|
+
windowNewest,
|
|
14370
|
+
sessions,
|
|
14371
|
+
projects: buildProjectDigests(sessions, projectSpans)
|
|
14372
|
+
};
|
|
14373
|
+
}
|
|
13528
14374
|
function buildCursorHandoff(events, extractionId, generatedAt) {
|
|
13529
14375
|
const sessions = [];
|
|
13530
14376
|
let windowOldest = null;
|
|
@@ -13629,14 +14475,14 @@ function buildVsCodeHandoff(events, extractionId, generatedAt) {
|
|
|
13629
14475
|
async function writeHandoff(handoff, home = os4.homedir()) {
|
|
13630
14476
|
if (!await appIsInstalled(home)) return null;
|
|
13631
14477
|
const dir = handoffDir(home);
|
|
13632
|
-
await
|
|
14478
|
+
await fs13.mkdir(dir, { recursive: true });
|
|
13633
14479
|
const target = handoffFilePath(home, handoff.store);
|
|
13634
14480
|
await writeJsonAtomically(target, handoff);
|
|
13635
14481
|
return target;
|
|
13636
14482
|
}
|
|
13637
14483
|
async function appIsInstalled(home) {
|
|
13638
14484
|
try {
|
|
13639
|
-
await
|
|
14485
|
+
await fs13.stat(path13.join(home, "Library", "Application Support", APP_BUNDLE_ID));
|
|
13640
14486
|
return true;
|
|
13641
14487
|
} catch {
|
|
13642
14488
|
return false;
|
|
@@ -13644,18 +14490,18 @@ async function appIsInstalled(home) {
|
|
|
13644
14490
|
}
|
|
13645
14491
|
async function writeJsonAtomically(target, payload) {
|
|
13646
14492
|
const temp = `${target}.tmp`;
|
|
13647
|
-
await
|
|
13648
|
-
await
|
|
14493
|
+
await fs13.writeFile(temp, JSON.stringify(payload, null, 2) + "\n", "utf8");
|
|
14494
|
+
await fs13.rename(temp, target);
|
|
13649
14495
|
}
|
|
13650
14496
|
|
|
13651
14497
|
// src/crossStoreElapsed.ts
|
|
13652
|
-
import * as
|
|
14498
|
+
import * as fs14 from "node:fs/promises";
|
|
13653
14499
|
import * as os5 from "node:os";
|
|
13654
|
-
import * as
|
|
14500
|
+
import * as path14 from "node:path";
|
|
13655
14501
|
var CROSS_STORE_ELAPSED_DIR_NAME = "elapsed";
|
|
13656
14502
|
var CROSS_STORE_ELAPSED_FILE_NAME = "cross-store.json";
|
|
13657
14503
|
function crossStoreElapsedPath(home = os5.homedir()) {
|
|
13658
|
-
return
|
|
14504
|
+
return path14.join(handoffDir(home), CROSS_STORE_ELAPSED_DIR_NAME, CROSS_STORE_ELAPSED_FILE_NAME);
|
|
13659
14505
|
}
|
|
13660
14506
|
var CrossStoreElapsedPool = class {
|
|
13661
14507
|
byKey = /* @__PURE__ */ new Map();
|
|
@@ -13716,7 +14562,7 @@ var CrossStoreElapsedPool = class {
|
|
|
13716
14562
|
};
|
|
13717
14563
|
async function removeCrossStoreElapsed(home = os5.homedir()) {
|
|
13718
14564
|
try {
|
|
13719
|
-
await
|
|
14565
|
+
await fs14.unlink(crossStoreElapsedPath(home));
|
|
13720
14566
|
return true;
|
|
13721
14567
|
} catch {
|
|
13722
14568
|
return false;
|
|
@@ -13725,7 +14571,7 @@ async function removeCrossStoreElapsed(home = os5.homedir()) {
|
|
|
13725
14571
|
async function writeCrossStoreElapsed(file, home = os5.homedir()) {
|
|
13726
14572
|
if (!await appIsInstalled(home)) return null;
|
|
13727
14573
|
const target = crossStoreElapsedPath(home);
|
|
13728
|
-
await
|
|
14574
|
+
await fs14.mkdir(path14.dirname(target), { recursive: true });
|
|
13729
14575
|
await writeJsonAtomically(target, file);
|
|
13730
14576
|
return target;
|
|
13731
14577
|
}
|
|
@@ -13748,7 +14594,7 @@ function formatInventory(inv) {
|
|
|
13748
14594
|
}
|
|
13749
14595
|
async function pathExists(target) {
|
|
13750
14596
|
try {
|
|
13751
|
-
await
|
|
14597
|
+
await fs15.access(target);
|
|
13752
14598
|
return true;
|
|
13753
14599
|
} catch {
|
|
13754
14600
|
return false;
|
|
@@ -13927,10 +14773,16 @@ shipped: sent=${shipResult.sent} accepted=${shipResult.accepted} duplicate=${shi
|
|
|
13927
14773
|
"\n stopped early: this account has no consent for a retrospective import, so the\n backend refused the whole batch and every remaining event would be refused too.\n Nothing was stored. Turn on historical import for this account: in the Flow app\n under Connections > Bring in daily tools, or on the web where you joined your\n study. Then run this again; the import is idempotent, so nothing here is wasted.\n"
|
|
13928
14774
|
);
|
|
13929
14775
|
}
|
|
13930
|
-
|
|
14776
|
+
const notGranted = (shipResult.storesNotGranted ?? []).filter((store) => store !== "git");
|
|
14777
|
+
if (shipResult.storesNotGranted?.includes("git")) {
|
|
14778
|
+
out.write(
|
|
14779
|
+
"\n git wasn't granted, so no commits were sent. The other stores carried on.\n To grant it, join your study again and tick the git box on the page:\n npx -y @ascenda-one/history-import participate <code> --rejoin\n"
|
|
14780
|
+
);
|
|
14781
|
+
}
|
|
14782
|
+
if (notGranted.length) {
|
|
13931
14783
|
out.write(
|
|
13932
14784
|
`
|
|
13933
|
-
not granted: ${
|
|
14785
|
+
not granted: ${notGranted.join(", ")}. Historical import is on for this account but
|
|
13934
14786
|
doesn't include those stores, so their events were skipped. Add them to the grant
|
|
13935
14787
|
(Flow app, or the web where you joined your study) and run this again.
|
|
13936
14788
|
`
|
|
@@ -13948,8 +14800,8 @@ shipped: sent=${shipResult.sent} accepted=${shipResult.accepted} duplicate=${shi
|
|
|
13948
14800
|
}
|
|
13949
14801
|
async function writeSummaryJson(file, summary) {
|
|
13950
14802
|
if (!file) return;
|
|
13951
|
-
await
|
|
13952
|
-
await
|
|
14803
|
+
await fs15.mkdir(path15.dirname(file), { recursive: true });
|
|
14804
|
+
await fs15.writeFile(file, JSON.stringify(summary, null, 2) + "\n", "utf8");
|
|
13953
14805
|
}
|
|
13954
14806
|
function exitCodeFor(outcomes, ship, shipResult, shipError) {
|
|
13955
14807
|
if (outcomes.some((o) => o.status === "failed")) return 1;
|
|
@@ -14019,17 +14871,19 @@ async function main() {
|
|
|
14019
14871
|
() => scanClaudeCode(paths)
|
|
14020
14872
|
);
|
|
14021
14873
|
const codexScan = await safeScan("codex", paths.codexSessions, () => scanCodex(paths));
|
|
14874
|
+
const copilotScan = await safeScan("copilot_cli", paths.copilotSessionState, () => scanCopilotCli(paths));
|
|
14022
14875
|
const cursorScan = await safeScan("cursor", paths.cursorStateDb, () => scanCursor(paths));
|
|
14023
14876
|
const vsCodeScan = await safeScan("vscode", paths.vscodeHistory, () => scanVsCode(paths));
|
|
14024
14877
|
const claudeInventory = claudeScan.inventory;
|
|
14025
14878
|
const codexInventory = codexScan.inventory;
|
|
14879
|
+
const copilotInventory = copilotScan.inventory;
|
|
14026
14880
|
const cursorInventory = cursorScan.inventory;
|
|
14027
14881
|
const vsCodeInventory = vsCodeScan.inventory;
|
|
14028
|
-
const scans = [claudeScan, codexScan, cursorScan, vsCodeScan];
|
|
14882
|
+
const scans = [claudeScan, codexScan, copilotScan, cursorScan, vsCodeScan];
|
|
14029
14883
|
const anyScanFailed = scans.some((r) => r.scanError !== null);
|
|
14030
14884
|
if (scans.every((r) => !r.inventory.present) && !anyScanFailed) {
|
|
14031
14885
|
process.stderr.write(
|
|
14032
|
-
`no Claude Code store at ${claudeInventory.rootPath}, no Codex store at ${codexInventory.rootPath}, no Cursor store at ${cursorInventory.rootPath}, and no VS Code store at ${vsCodeInventory.rootPath} \u2014 nothing to import
|
|
14886
|
+
`no Claude Code store at ${claudeInventory.rootPath}, no Codex store at ${codexInventory.rootPath}, no Copilot CLI store at ${copilotInventory.rootPath}, no Cursor store at ${cursorInventory.rootPath}, and no VS Code store at ${vsCodeInventory.rootPath} \u2014 nothing to import
|
|
14033
14887
|
`
|
|
14034
14888
|
);
|
|
14035
14889
|
await writeSummaryJson(summaryJson, { exitCode: 2, nothingToImport: true, outcomes: [], totalExtracted: 0, shipResult: null, shipError: null });
|
|
@@ -14047,6 +14901,7 @@ async function main() {
|
|
|
14047
14901
|
if (claudeInventory.present) willCopy.push(...paths.claudeProjectsDirs);
|
|
14048
14902
|
if (vsCodeInventory.present) willCopy.push(...paths.vscodeVariants.map((v) => v.history));
|
|
14049
14903
|
if (codexInventory.present) willCopy.push(paths.codexSessions, paths.codexArchivedSessions);
|
|
14904
|
+
if (copilotInventory.present) willCopy.push(paths.copilotSessionState);
|
|
14050
14905
|
if (snapshotSessions && vsCodeInventory.present) {
|
|
14051
14906
|
willCopy.push(...paths.vscodeVariants.map((v) => v.workspaceStorage));
|
|
14052
14907
|
}
|
|
@@ -14068,52 +14923,60 @@ refusing to start rather than failing halfway through the copy
|
|
|
14068
14923
|
const crossStore = new CrossStoreElapsedPool();
|
|
14069
14924
|
try {
|
|
14070
14925
|
await runSource(outcomes, "claude_code", claudeInventory, allEvents, async (collect) => {
|
|
14071
|
-
const snapshotRoot =
|
|
14926
|
+
const snapshotRoot = path15.join(area.root, "claude_code");
|
|
14072
14927
|
for (const projectsDir of paths.claudeProjectsDirs) {
|
|
14073
14928
|
try {
|
|
14074
|
-
await
|
|
14929
|
+
await fs15.access(projectsDir);
|
|
14075
14930
|
} catch {
|
|
14076
14931
|
continue;
|
|
14077
14932
|
}
|
|
14078
|
-
await snapshotPath(area, projectsDir,
|
|
14933
|
+
await snapshotPath(area, projectsDir, path15.join("claude_code", "projects"));
|
|
14079
14934
|
}
|
|
14080
14935
|
for await (const event of extractClaudeCode(snapshotRoot, area.extractionId)) collect(event);
|
|
14081
14936
|
}, (events) => buildHandoff(events, area.extractionId, (/* @__PURE__ */ new Date()).toISOString()), claudeScan.scanError, crossStore);
|
|
14082
14937
|
await runSource(outcomes, "codex", codexInventory, allEvents, async (collect) => {
|
|
14083
|
-
const codexSnapshotRoot =
|
|
14938
|
+
const codexSnapshotRoot = path15.join(area.root, "codex");
|
|
14084
14939
|
const roots = {
|
|
14085
14940
|
sessions: paths.codexSessions,
|
|
14086
14941
|
archived_sessions: paths.codexArchivedSessions
|
|
14087
14942
|
};
|
|
14088
14943
|
for (const dir of CODEX_SNAPSHOT_DIRS) {
|
|
14089
14944
|
try {
|
|
14090
|
-
await
|
|
14945
|
+
await fs15.access(roots[dir]);
|
|
14091
14946
|
} catch {
|
|
14092
14947
|
continue;
|
|
14093
14948
|
}
|
|
14094
|
-
await snapshotPath(area, roots[dir],
|
|
14949
|
+
await snapshotPath(area, roots[dir], path15.join("codex", dir));
|
|
14095
14950
|
}
|
|
14096
14951
|
for await (const event of extractCodex(codexSnapshotRoot, area.extractionId)) collect(event);
|
|
14097
14952
|
}, (events) => buildCodexHandoff(events, area.extractionId, (/* @__PURE__ */ new Date()).toISOString()), codexScan.scanError, crossStore);
|
|
14953
|
+
await runSource(outcomes, "copilot_cli", copilotInventory, allEvents, async (collect) => {
|
|
14954
|
+
const copilotSnapshotRoot = await snapshotCopilotSessionState(
|
|
14955
|
+
area,
|
|
14956
|
+
paths.copilotSessionState,
|
|
14957
|
+
path15.join("copilot_cli", "session-state")
|
|
14958
|
+
);
|
|
14959
|
+
for await (const event of extractCopilotCli(copilotSnapshotRoot, area.extractionId)) collect(event);
|
|
14960
|
+
}, (events) => buildCopilotCliHandoff(events, area.extractionId, (/* @__PURE__ */ new Date()).toISOString()), copilotScan.scanError, crossStore);
|
|
14098
14961
|
await runSource(outcomes, "cursor", cursorInventory, allEvents, async (collect) => {
|
|
14099
|
-
const cursorSnapshotRoot =
|
|
14100
|
-
await snapshotPath(area, paths.cursorStateDb,
|
|
14962
|
+
const cursorSnapshotRoot = path15.join(area.root, "cursor");
|
|
14963
|
+
await snapshotPath(area, paths.cursorStateDb, path15.join("cursor", "state.vscdb"));
|
|
14101
14964
|
for await (const event of extractCursor(cursorSnapshotRoot, area.extractionId)) collect(event);
|
|
14102
14965
|
}, (events) => buildCursorHandoff(events, area.extractionId, (/* @__PURE__ */ new Date()).toISOString()), cursorScan.scanError, crossStore);
|
|
14103
14966
|
await runSource(outcomes, "vscode", vsCodeInventory, allEvents, async (collect) => {
|
|
14104
14967
|
const roots = [];
|
|
14105
14968
|
for (const variant of paths.vscodeVariants) {
|
|
14106
14969
|
const suffix = variant.name === "Code" ? "" : `-${variant.name.toLowerCase().replace(/[^a-z0-9]+/g, "-")}`;
|
|
14107
|
-
const stagedHistory =
|
|
14970
|
+
const stagedHistory = path15.join(area.root, "vscode", `history${suffix}`);
|
|
14108
14971
|
if (await pathExists(variant.history)) {
|
|
14109
|
-
await snapshotPath(area, variant.history,
|
|
14972
|
+
await snapshotPath(area, variant.history, path15.join("vscode", `history${suffix}`));
|
|
14110
14973
|
}
|
|
14111
14974
|
let workspaceStorageDir = variant.workspaceStorage;
|
|
14112
14975
|
if (snapshotSessions && await pathExists(variant.workspaceStorage)) {
|
|
14113
14976
|
workspaceStorageDir = await snapshotVsCodeWorkspaceStorage(
|
|
14114
14977
|
area,
|
|
14115
14978
|
variant.workspaceStorage,
|
|
14116
|
-
|
|
14979
|
+
path15.join("vscode", `workspaceStorage${suffix}`)
|
|
14117
14980
|
);
|
|
14118
14981
|
}
|
|
14119
14982
|
roots.push({
|
|
@@ -14129,7 +14992,7 @@ refusing to start rather than failing halfway through the copy
|
|
|
14129
14992
|
if (withGit) {
|
|
14130
14993
|
const repoRefs = /* @__PURE__ */ new Set();
|
|
14131
14994
|
for (const event of allEvents) {
|
|
14132
|
-
if (event.store !== "git" && event.repoRef &&
|
|
14995
|
+
if (event.store !== "git" && event.repoRef && path15.isAbsolute(event.repoRef)) {
|
|
14133
14996
|
repoRefs.add(event.repoRef);
|
|
14134
14997
|
}
|
|
14135
14998
|
}
|
|
@@ -14166,8 +15029,8 @@ refusing to start rather than failing halfway through the copy
|
|
|
14166
15029
|
`
|
|
14167
15030
|
);
|
|
14168
15031
|
}
|
|
14169
|
-
const eventsFile =
|
|
14170
|
-
await
|
|
15032
|
+
const eventsFile = path15.join(area.root, "events.jsonl");
|
|
15033
|
+
await fs15.writeFile(eventsFile, allEvents.map((e) => JSON.stringify(e)).join("\n") + "\n", "utf8");
|
|
14171
15034
|
let shipResult = null;
|
|
14172
15035
|
let shipError = null;
|
|
14173
15036
|
if (ship) {
|
|
@@ -14394,14 +15257,21 @@ generation ${result.generation}
|
|
|
14394
15257
|
`);
|
|
14395
15258
|
return 2;
|
|
14396
15259
|
}
|
|
15260
|
+
let shipConfig;
|
|
14397
15261
|
try {
|
|
14398
|
-
loadShipConfig();
|
|
15262
|
+
shipConfig = loadShipConfig();
|
|
14399
15263
|
} catch (error) {
|
|
14400
15264
|
process.stderr.write(`${error instanceof Error ? error.message : String(error)}
|
|
14401
15265
|
`);
|
|
14402
15266
|
return 2;
|
|
14403
15267
|
}
|
|
14404
|
-
const
|
|
15268
|
+
const record = readParticipation();
|
|
15269
|
+
const stores = await readImportStores(
|
|
15270
|
+
record && record.apiBaseUrl.replace(/\/$/, "") === shipConfig.apiBaseUrl.replace(/\/$/, "") ? record : void 0,
|
|
15271
|
+
shipConfig.eventWriteToken
|
|
15272
|
+
);
|
|
15273
|
+
const git2 = stores.stores?.includes("git") ?? false;
|
|
15274
|
+
const result = await installSchedule(env, { everyDays, command: scheduledCommand(void 0, void 0, void 0, { git: git2 }), pathEnv: process.env.PATH });
|
|
14405
15275
|
if (result.printed) {
|
|
14406
15276
|
process.stdout.write(`Windows: nothing written. Run this to schedule it:
|
|
14407
15277
|
|
|
@@ -14412,10 +15282,13 @@ generation ${result.generation}
|
|
|
14412
15282
|
for (const file of result.written) process.stdout.write(`wrote ${file}
|
|
14413
15283
|
`);
|
|
14414
15284
|
process.stdout.write(
|
|
14415
|
-
result.activated ? `scheduled: import --ship every ${everyDays} days
|
|
15285
|
+
result.activated ? `scheduled: import --ship${git2 ? " --git" : ""} every ${everyDays} days
|
|
14416
15286
|
` : `files written, but the scheduler didn't load them \u2014 log out and in, or load them by hand
|
|
14417
15287
|
`
|
|
14418
15288
|
);
|
|
15289
|
+
process.stdout.write(
|
|
15290
|
+
git2 ? "git history: included, your grant covers it. If you take git off the grant, run schedule install again.\n" : stores.from === "unknown" ? "git history: not included. No study join on this machine says git is granted. Run schedule install again after you grant it.\n" : "git history: not included, your grant doesn't cover it. If you grant it later, run schedule install again.\n"
|
|
15291
|
+
);
|
|
14419
15292
|
return result.activated ? 0 : 1;
|
|
14420
15293
|
}
|
|
14421
15294
|
if (action === "remove") {
|
|
@@ -14431,7 +15304,7 @@ generation ${result.generation}
|
|
|
14431
15304
|
return 0;
|
|
14432
15305
|
}
|
|
14433
15306
|
process.stdout.write(
|
|
14434
|
-
`installed: every ${status.everyDays ?? "?"} days, ${status.active ? "loaded" : "not loaded"}
|
|
15307
|
+
`installed: every ${status.everyDays ?? "?"} days, ${status.active ? "loaded" : "not loaded"}, ${status.git ? "with" : "without"} git history
|
|
14435
15308
|
` + status.files.map((f) => ` ${f}
|
|
14436
15309
|
`).join("") + ` log: ${status.log}
|
|
14437
15310
|
`
|