iteration-cli 0.10.0 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +181 -102
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -934,8 +934,8 @@ var require_src = __commonJS({
|
|
|
934
934
|
// src/cli.ts
|
|
935
935
|
import { spawnSync } from "node:child_process";
|
|
936
936
|
import os7 from "node:os";
|
|
937
|
-
import
|
|
938
|
-
import { promises as
|
|
937
|
+
import path18 from "node:path";
|
|
938
|
+
import { promises as fs14 } from "node:fs";
|
|
939
939
|
import { createInterface as createInterface3 } from "node:readline/promises";
|
|
940
940
|
import { parseArgs } from "node:util";
|
|
941
941
|
|
|
@@ -1175,10 +1175,10 @@ function mergeDefs(...defs) {
|
|
|
1175
1175
|
function cloneDef(schema) {
|
|
1176
1176
|
return mergeDefs(schema._zod.def);
|
|
1177
1177
|
}
|
|
1178
|
-
function getElementAtPath(obj,
|
|
1179
|
-
if (!
|
|
1178
|
+
function getElementAtPath(obj, path19) {
|
|
1179
|
+
if (!path19)
|
|
1180
1180
|
return obj;
|
|
1181
|
-
return
|
|
1181
|
+
return path19.reduce((acc, key) => acc?.[key], obj);
|
|
1182
1182
|
}
|
|
1183
1183
|
function promiseAllObject(promisesObj) {
|
|
1184
1184
|
const keys = Object.keys(promisesObj);
|
|
@@ -1518,11 +1518,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
1518
1518
|
}
|
|
1519
1519
|
return false;
|
|
1520
1520
|
}
|
|
1521
|
-
function prefixIssues(
|
|
1521
|
+
function prefixIssues(path19, issues) {
|
|
1522
1522
|
return issues.map((iss) => {
|
|
1523
1523
|
var _a3;
|
|
1524
1524
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
1525
|
-
iss.path.unshift(
|
|
1525
|
+
iss.path.unshift(path19);
|
|
1526
1526
|
return iss;
|
|
1527
1527
|
});
|
|
1528
1528
|
}
|
|
@@ -1968,16 +1968,16 @@ function flattenError(error2, mapper = (issue2) => issue2.message) {
|
|
|
1968
1968
|
}
|
|
1969
1969
|
function formatError(error2, mapper = (issue2) => issue2.message) {
|
|
1970
1970
|
const fieldErrors = { _errors: [] };
|
|
1971
|
-
const processError = (error3,
|
|
1971
|
+
const processError = (error3, path19 = []) => {
|
|
1972
1972
|
for (const issue2 of error3.issues) {
|
|
1973
1973
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
1974
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
1974
|
+
issue2.errors.map((issues) => processError({ issues }, [...path19, ...issue2.path]));
|
|
1975
1975
|
} else if (issue2.code === "invalid_key") {
|
|
1976
|
-
processError({ issues: issue2.issues }, [...
|
|
1976
|
+
processError({ issues: issue2.issues }, [...path19, ...issue2.path]);
|
|
1977
1977
|
} else if (issue2.code === "invalid_element") {
|
|
1978
|
-
processError({ issues: issue2.issues }, [...
|
|
1978
|
+
processError({ issues: issue2.issues }, [...path19, ...issue2.path]);
|
|
1979
1979
|
} else {
|
|
1980
|
-
const fullpath = [...
|
|
1980
|
+
const fullpath = [...path19, ...issue2.path];
|
|
1981
1981
|
if (fullpath.length === 0) {
|
|
1982
1982
|
fieldErrors._errors.push(mapper(issue2));
|
|
1983
1983
|
} else {
|
|
@@ -11148,11 +11148,11 @@ function requireLodash_sortby() {
|
|
|
11148
11148
|
function baseForOwn(object3, iteratee) {
|
|
11149
11149
|
return object3 && baseFor(object3, iteratee, keys);
|
|
11150
11150
|
}
|
|
11151
|
-
function baseGet(object3,
|
|
11152
|
-
|
|
11153
|
-
var index = 0, length =
|
|
11151
|
+
function baseGet(object3, path19) {
|
|
11152
|
+
path19 = isKey(path19, object3) ? [path19] : castPath(path19);
|
|
11153
|
+
var index = 0, length = path19.length;
|
|
11154
11154
|
while (object3 != null && index < length) {
|
|
11155
|
-
object3 = object3[toKey(
|
|
11155
|
+
object3 = object3[toKey(path19[index++])];
|
|
11156
11156
|
}
|
|
11157
11157
|
return index && index == length ? object3 : void 0;
|
|
11158
11158
|
}
|
|
@@ -11279,13 +11279,13 @@ function requireLodash_sortby() {
|
|
|
11279
11279
|
return object3 === source || baseIsMatch(object3, source, matchData);
|
|
11280
11280
|
};
|
|
11281
11281
|
}
|
|
11282
|
-
function baseMatchesProperty(
|
|
11283
|
-
if (isKey(
|
|
11284
|
-
return matchesStrictComparable(toKey(
|
|
11282
|
+
function baseMatchesProperty(path19, srcValue) {
|
|
11283
|
+
if (isKey(path19) && isStrictComparable(srcValue)) {
|
|
11284
|
+
return matchesStrictComparable(toKey(path19), srcValue);
|
|
11285
11285
|
}
|
|
11286
11286
|
return function(object3) {
|
|
11287
|
-
var objValue = get(object3,
|
|
11288
|
-
return objValue === void 0 && objValue === srcValue ? hasIn(object3,
|
|
11287
|
+
var objValue = get(object3, path19);
|
|
11288
|
+
return objValue === void 0 && objValue === srcValue ? hasIn(object3, path19) : baseIsEqual(srcValue, objValue, void 0, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG);
|
|
11289
11289
|
};
|
|
11290
11290
|
}
|
|
11291
11291
|
function baseOrderBy(collection, iteratees, orders) {
|
|
@@ -11301,9 +11301,9 @@ function requireLodash_sortby() {
|
|
|
11301
11301
|
return compareMultiple(object3, other, orders);
|
|
11302
11302
|
});
|
|
11303
11303
|
}
|
|
11304
|
-
function basePropertyDeep(
|
|
11304
|
+
function basePropertyDeep(path19) {
|
|
11305
11305
|
return function(object3) {
|
|
11306
|
-
return baseGet(object3,
|
|
11306
|
+
return baseGet(object3, path19);
|
|
11307
11307
|
};
|
|
11308
11308
|
}
|
|
11309
11309
|
function baseRest(func, start2) {
|
|
@@ -11558,11 +11558,11 @@ function requireLodash_sortby() {
|
|
|
11558
11558
|
return result;
|
|
11559
11559
|
};
|
|
11560
11560
|
}
|
|
11561
|
-
function hasPath(object3,
|
|
11562
|
-
|
|
11563
|
-
var result, index = -1, length =
|
|
11561
|
+
function hasPath(object3, path19, hasFunc) {
|
|
11562
|
+
path19 = isKey(path19, object3) ? [path19] : castPath(path19);
|
|
11563
|
+
var result, index = -1, length = path19.length;
|
|
11564
11564
|
while (++index < length) {
|
|
11565
|
-
var key = toKey(
|
|
11565
|
+
var key = toKey(path19[index]);
|
|
11566
11566
|
if (!(result = object3 != null && hasFunc(object3, key))) {
|
|
11567
11567
|
break;
|
|
11568
11568
|
}
|
|
@@ -11717,12 +11717,12 @@ function requireLodash_sortby() {
|
|
|
11717
11717
|
function toString(value) {
|
|
11718
11718
|
return value == null ? "" : baseToString(value);
|
|
11719
11719
|
}
|
|
11720
|
-
function get(object3,
|
|
11721
|
-
var result = object3 == null ? void 0 : baseGet(object3,
|
|
11720
|
+
function get(object3, path19, defaultValue) {
|
|
11721
|
+
var result = object3 == null ? void 0 : baseGet(object3, path19);
|
|
11722
11722
|
return result === void 0 ? defaultValue : result;
|
|
11723
11723
|
}
|
|
11724
|
-
function hasIn(object3,
|
|
11725
|
-
return object3 != null && hasPath(object3,
|
|
11724
|
+
function hasIn(object3, path19) {
|
|
11725
|
+
return object3 != null && hasPath(object3, path19, baseHasIn);
|
|
11726
11726
|
}
|
|
11727
11727
|
function keys(object3) {
|
|
11728
11728
|
return isArrayLike(object3) ? arrayLikeKeys(object3) : baseKeys(object3);
|
|
@@ -11730,8 +11730,8 @@ function requireLodash_sortby() {
|
|
|
11730
11730
|
function identity(value) {
|
|
11731
11731
|
return value;
|
|
11732
11732
|
}
|
|
11733
|
-
function property(
|
|
11734
|
-
return isKey(
|
|
11733
|
+
function property(path19) {
|
|
11734
|
+
return isKey(path19) ? baseProperty(toKey(path19)) : basePropertyDeep(path19);
|
|
11735
11735
|
}
|
|
11736
11736
|
module.exports = sortBy;
|
|
11737
11737
|
})(lodash_sortby, lodash_sortby.exports);
|
|
@@ -12162,16 +12162,16 @@ async function reportIfFoundPrivateKeyP12Format({ source, context, t }) {
|
|
|
12162
12162
|
return;
|
|
12163
12163
|
}
|
|
12164
12164
|
try {
|
|
12165
|
-
const
|
|
12166
|
-
const
|
|
12167
|
-
const pfxBytes = new Uint8Array(
|
|
12165
|
+
const fs15 = await import("node:fs");
|
|
12166
|
+
const path19 = await import("node:path");
|
|
12167
|
+
const pfxBytes = new Uint8Array(fs15.readFileSync(source.filePath));
|
|
12168
12168
|
const isGcpServiceAccountP12 = await verifyPkcs12Mac(pfxBytes, GCP_SERVICE_ACCOUNT_P12_PASSWORD);
|
|
12169
12169
|
if (!isGcpServiceAccountP12) {
|
|
12170
12170
|
return;
|
|
12171
12171
|
}
|
|
12172
12172
|
context.report({
|
|
12173
12173
|
message: t("PrivateKeyP12", {
|
|
12174
|
-
FILE_NAME:
|
|
12174
|
+
FILE_NAME: path19.basename(source.filePath)
|
|
12175
12175
|
}),
|
|
12176
12176
|
range: [0, source.content.length]
|
|
12177
12177
|
});
|
|
@@ -15689,20 +15689,93 @@ async function connectedConfig(source) {
|
|
|
15689
15689
|
}
|
|
15690
15690
|
|
|
15691
15691
|
// src/history-import.ts
|
|
15692
|
-
import
|
|
15692
|
+
import path17 from "node:path";
|
|
15693
15693
|
|
|
15694
15694
|
// src/service.ts
|
|
15695
|
-
import { promises as
|
|
15696
|
-
import
|
|
15695
|
+
import { promises as fs13 } from "node:fs";
|
|
15696
|
+
import path16 from "node:path";
|
|
15697
15697
|
import { setTimeout as delay3 } from "node:timers/promises";
|
|
15698
15698
|
|
|
15699
15699
|
// src/collector.ts
|
|
15700
|
-
import { promises as
|
|
15701
|
-
import
|
|
15700
|
+
import { promises as fs12 } from "node:fs";
|
|
15701
|
+
import path15 from "node:path";
|
|
15702
15702
|
|
|
15703
15703
|
// src/claude-transcript.ts
|
|
15704
15704
|
import { createHash as createHash4 } from "node:crypto";
|
|
15705
|
+
import path12 from "node:path";
|
|
15706
|
+
|
|
15707
|
+
// src/git-repository.ts
|
|
15708
|
+
import fs11 from "node:fs";
|
|
15705
15709
|
import path11 from "node:path";
|
|
15710
|
+
var repositoryUrls = /* @__PURE__ */ new Map();
|
|
15711
|
+
function missing(error2) {
|
|
15712
|
+
const code = error2.code;
|
|
15713
|
+
return code === "ENOENT" || code === "ENOTDIR";
|
|
15714
|
+
}
|
|
15715
|
+
function readText(file) {
|
|
15716
|
+
try {
|
|
15717
|
+
return fs11.readFileSync(file, "utf8");
|
|
15718
|
+
} catch (error2) {
|
|
15719
|
+
if (missing(error2)) return null;
|
|
15720
|
+
throw error2;
|
|
15721
|
+
}
|
|
15722
|
+
}
|
|
15723
|
+
function gitConfigFile(cwd) {
|
|
15724
|
+
try {
|
|
15725
|
+
if (!fs11.statSync(cwd).isDirectory()) return null;
|
|
15726
|
+
} catch (error2) {
|
|
15727
|
+
if (missing(error2)) return null;
|
|
15728
|
+
throw error2;
|
|
15729
|
+
}
|
|
15730
|
+
for (let directory = cwd; ; directory = path11.dirname(directory)) {
|
|
15731
|
+
const dotGit = path11.join(directory, ".git");
|
|
15732
|
+
let stats;
|
|
15733
|
+
try {
|
|
15734
|
+
stats = fs11.statSync(dotGit);
|
|
15735
|
+
} catch (error2) {
|
|
15736
|
+
if (!missing(error2)) throw error2;
|
|
15737
|
+
if (path11.dirname(directory) === directory) return null;
|
|
15738
|
+
continue;
|
|
15739
|
+
}
|
|
15740
|
+
if (stats.isDirectory()) return path11.join(dotGit, "config");
|
|
15741
|
+
const pointer = /^gitdir:\s*(.+?)\s*$/m.exec(readText(dotGit) ?? "");
|
|
15742
|
+
if (pointer === null) return null;
|
|
15743
|
+
const gitDirectory = path11.resolve(directory, pointer[1]);
|
|
15744
|
+
const common = readText(path11.join(gitDirectory, "commondir"))?.trim();
|
|
15745
|
+
return path11.join(
|
|
15746
|
+
common ? path11.resolve(gitDirectory, common) : gitDirectory,
|
|
15747
|
+
"config"
|
|
15748
|
+
);
|
|
15749
|
+
}
|
|
15750
|
+
}
|
|
15751
|
+
function originUrl(config2) {
|
|
15752
|
+
let inOrigin = false;
|
|
15753
|
+
for (const line of config2.split(/\r?\n/)) {
|
|
15754
|
+
const section = /^\s*\[\s*([^\]]+?)\s*\]/.exec(line);
|
|
15755
|
+
if (section !== null) {
|
|
15756
|
+
inOrigin = /^remote\s+"origin"$/i.test(section[1]);
|
|
15757
|
+
continue;
|
|
15758
|
+
}
|
|
15759
|
+
const url2 = inOrigin ? /^\s*url\s*=\s*(.+?)\s*$/i.exec(line) : null;
|
|
15760
|
+
if (url2 !== null) return url2[1].replace(/^"(.*)"$/, "$1");
|
|
15761
|
+
}
|
|
15762
|
+
return null;
|
|
15763
|
+
}
|
|
15764
|
+
function withoutCredentials(url2) {
|
|
15765
|
+
return url2.replace(/^([a-z][a-z0-9+.-]*:\/\/)[^/@]*@/i, "$1");
|
|
15766
|
+
}
|
|
15767
|
+
function gitRepositoryUrl(cwd) {
|
|
15768
|
+
const known = repositoryUrls.get(cwd);
|
|
15769
|
+
if (known !== void 0) return known;
|
|
15770
|
+
const configFile = gitConfigFile(cwd);
|
|
15771
|
+
const config2 = configFile === null ? null : readText(configFile);
|
|
15772
|
+
const origin = config2 === null ? null : originUrl(config2);
|
|
15773
|
+
const url2 = origin === null ? null : withoutCredentials(origin);
|
|
15774
|
+
repositoryUrls.set(cwd, url2);
|
|
15775
|
+
return url2;
|
|
15776
|
+
}
|
|
15777
|
+
|
|
15778
|
+
// src/claude-transcript.ts
|
|
15706
15779
|
var CONTEXT_RECORD_TYPES = /* @__PURE__ */ new Set([
|
|
15707
15780
|
"attachment",
|
|
15708
15781
|
"system",
|
|
@@ -15741,9 +15814,9 @@ function childThreadId(parentId, agentId) {
|
|
|
15741
15814
|
var SESSION_UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
15742
15815
|
function claudeSessionIdentity(filename) {
|
|
15743
15816
|
if (!filename.endsWith(".jsonl")) return null;
|
|
15744
|
-
const basename =
|
|
15745
|
-
if (
|
|
15746
|
-
const parent =
|
|
15817
|
+
const basename = path12.basename(filename, ".jsonl");
|
|
15818
|
+
if (path12.basename(path12.dirname(filename)) === "subagents") {
|
|
15819
|
+
const parent = path12.basename(path12.dirname(path12.dirname(filename)));
|
|
15747
15820
|
if (!basename.startsWith("agent-") || !SESSION_UUID.test(parent))
|
|
15748
15821
|
return null;
|
|
15749
15822
|
const agentId = basename.slice("agent-".length);
|
|
@@ -15798,7 +15871,7 @@ function contentText(value) {
|
|
|
15798
15871
|
});
|
|
15799
15872
|
return parts.length > 0 ? parts.join("\n") : null;
|
|
15800
15873
|
}
|
|
15801
|
-
function parseClaudeLine(line, filename, byteOffset) {
|
|
15874
|
+
function parseClaudeLine(line, filename, byteOffset, repositoryUrl = gitRepositoryUrl) {
|
|
15802
15875
|
const identity = claudeSessionIdentity(filename);
|
|
15803
15876
|
if (identity === null)
|
|
15804
15877
|
return { events: [], gaps: ["invalid_claude_session_path"] };
|
|
@@ -15821,33 +15894,39 @@ function parseClaudeLine(line, filename, byteOffset) {
|
|
|
15821
15894
|
if (record3.timestamp !== void 0 && timestamp(record3) === null)
|
|
15822
15895
|
gaps.push("invalid_source_timestamp");
|
|
15823
15896
|
const events = [];
|
|
15824
|
-
const
|
|
15825
|
-
|
|
15826
|
-
|
|
15827
|
-
cwd: string4(record3.cwd),
|
|
15828
|
-
git: { branch: string4(record3.gitBranch) },
|
|
15829
|
-
version: string4(record3.version),
|
|
15830
|
-
agentId: identity.agentId
|
|
15831
|
-
};
|
|
15832
|
-
events.push({
|
|
15833
|
-
...event(
|
|
15834
|
-
identity,
|
|
15835
|
-
record3,
|
|
15836
|
-
0,
|
|
15837
|
-
0,
|
|
15838
|
-
"session_meta",
|
|
15839
|
-
meta2,
|
|
15840
|
-
null,
|
|
15841
|
-
"session_meta"
|
|
15842
|
-
),
|
|
15843
|
-
run: {
|
|
15844
|
-
kind: "identity",
|
|
15897
|
+
const cwd = string4(record3.cwd);
|
|
15898
|
+
if (cwd !== null) {
|
|
15899
|
+
const meta2 = {
|
|
15845
15900
|
id: identity.runId,
|
|
15846
|
-
|
|
15847
|
-
|
|
15848
|
-
|
|
15849
|
-
|
|
15850
|
-
|
|
15901
|
+
parent_thread_id: identity.parentRunId,
|
|
15902
|
+
cwd,
|
|
15903
|
+
git: {
|
|
15904
|
+
branch: string4(record3.gitBranch),
|
|
15905
|
+
repository_url: repositoryUrl(cwd)
|
|
15906
|
+
},
|
|
15907
|
+
version: string4(record3.version),
|
|
15908
|
+
agentId: identity.agentId
|
|
15909
|
+
};
|
|
15910
|
+
events.push({
|
|
15911
|
+
...event(
|
|
15912
|
+
identity,
|
|
15913
|
+
record3,
|
|
15914
|
+
0,
|
|
15915
|
+
0,
|
|
15916
|
+
"session_meta",
|
|
15917
|
+
meta2,
|
|
15918
|
+
null,
|
|
15919
|
+
"session_meta"
|
|
15920
|
+
),
|
|
15921
|
+
run: {
|
|
15922
|
+
kind: "identity",
|
|
15923
|
+
id: identity.runId,
|
|
15924
|
+
parentId: identity.parentRunId,
|
|
15925
|
+
ownStart: true,
|
|
15926
|
+
startOrdinal: null
|
|
15927
|
+
}
|
|
15928
|
+
});
|
|
15929
|
+
}
|
|
15851
15930
|
if (recordType === "user") {
|
|
15852
15931
|
const message = object2(record3.message);
|
|
15853
15932
|
const content = message === null ? null : string4(message.content);
|
|
@@ -15970,7 +16049,7 @@ function parseClaudeLine(line, filename, byteOffset) {
|
|
|
15970
16049
|
|
|
15971
16050
|
// src/cursor-transcript.ts
|
|
15972
16051
|
import { createHash as createHash5 } from "node:crypto";
|
|
15973
|
-
import
|
|
16052
|
+
import path13 from "node:path";
|
|
15974
16053
|
var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
15975
16054
|
function record2(value) {
|
|
15976
16055
|
const parsed = record(string2(), json()).safeParse(value);
|
|
@@ -15998,8 +16077,8 @@ function event2(conversationId, filename, byteOffset, index, eventType, payload,
|
|
|
15998
16077
|
};
|
|
15999
16078
|
}
|
|
16000
16079
|
function parseCursorTranscriptLine(line, filename, byteOffset) {
|
|
16001
|
-
const conversationId =
|
|
16002
|
-
if (!UUID.test(conversationId) ||
|
|
16080
|
+
const conversationId = path13.basename(filename, ".jsonl");
|
|
16081
|
+
if (!UUID.test(conversationId) || path13.basename(path13.dirname(filename)) !== conversationId)
|
|
16003
16082
|
return { events: [], gaps: ["invalid_cursor_transcript_path"] };
|
|
16004
16083
|
let decoded;
|
|
16005
16084
|
try {
|
|
@@ -16318,7 +16397,7 @@ function validated(events, gaps) {
|
|
|
16318
16397
|
|
|
16319
16398
|
// src/rollout.ts
|
|
16320
16399
|
import { createHash as createHash6 } from "node:crypto";
|
|
16321
|
-
import
|
|
16400
|
+
import path14 from "node:path";
|
|
16322
16401
|
var recordSchema = record(string2(), unknown());
|
|
16323
16402
|
var CONTEXT_RECORDS = [
|
|
16324
16403
|
"session_meta",
|
|
@@ -16371,7 +16450,7 @@ function sourceOrdinal(value) {
|
|
|
16371
16450
|
return parsed.success ? parsed.data : null;
|
|
16372
16451
|
}
|
|
16373
16452
|
function sessionFromPath(filename) {
|
|
16374
|
-
const basename =
|
|
16453
|
+
const basename = path14.basename(filename, ".jsonl");
|
|
16375
16454
|
return basename.startsWith("rollout-") ? basename.slice("rollout-".length) : basename;
|
|
16376
16455
|
}
|
|
16377
16456
|
function callIdFrom(record3) {
|
|
@@ -16643,7 +16722,7 @@ function logGap(filename, offset, reason) {
|
|
|
16643
16722
|
function parseSourceRecord(source, line, filename, byteOffset) {
|
|
16644
16723
|
if (source === "claude") return parseClaudeLine(line, filename, byteOffset);
|
|
16645
16724
|
if (source === "cursor")
|
|
16646
|
-
return filename.includes(`${
|
|
16725
|
+
return filename.includes(`${path15.sep}cursor-hooks${path15.sep}`) ? parseCursorHookLine(line, filename) : parseCursorTranscriptLine(line, filename, byteOffset);
|
|
16647
16726
|
if (source === "codex") {
|
|
16648
16727
|
const parsed = parseRolloutLine(line, filename, byteOffset);
|
|
16649
16728
|
return parsed.kind === "event" ? { events: [parsed.event], gaps: [] } : parsed.kind === "gap" ? { events: [], gaps: [parsed.reason] } : { events: [], gaps: [] };
|
|
@@ -16654,7 +16733,7 @@ function parseSourceRecord(source, line, filename, byteOffset) {
|
|
|
16654
16733
|
async function scanSourceOnce(config2, paths, signal) {
|
|
16655
16734
|
signal?.throwIfAborted();
|
|
16656
16735
|
const source = collectorSource(config2);
|
|
16657
|
-
const sourceDirectory =
|
|
16736
|
+
const sourceDirectory = path15.resolve(collectorSourceDirectory(config2));
|
|
16658
16737
|
const state = await loadState(paths);
|
|
16659
16738
|
if (!state.initialized || state.sourceDirectory !== sourceDirectory) {
|
|
16660
16739
|
throw new Error(
|
|
@@ -16675,12 +16754,12 @@ async function scanSourceOnce(config2, paths, signal) {
|
|
|
16675
16754
|
let caughtUp = true;
|
|
16676
16755
|
for (const filename of files) {
|
|
16677
16756
|
signal?.throwIfAborted();
|
|
16678
|
-
const recordLimit = source === "cursor" && filename.includes(`${
|
|
16757
|
+
const recordLimit = source === "cursor" && filename.includes(`${path15.sep}cursor-hooks${path15.sep}`) ? 12 * 1024 * 1024 : MAX_RECORD_BYTES;
|
|
16679
16758
|
if (remainingBudget === 0) {
|
|
16680
16759
|
caughtUp = false;
|
|
16681
16760
|
break;
|
|
16682
16761
|
}
|
|
16683
|
-
const stats = await
|
|
16762
|
+
const stats = await fs12.stat(filename);
|
|
16684
16763
|
let offset = cursors[filename] ?? 0;
|
|
16685
16764
|
if (offset > stats.size) {
|
|
16686
16765
|
logGap(filename, offset, "rollout_file_shrank_resetting_cursor");
|
|
@@ -16696,7 +16775,7 @@ async function scanSourceOnce(config2, paths, signal) {
|
|
|
16696
16775
|
cursors[filename] = offset;
|
|
16697
16776
|
continue;
|
|
16698
16777
|
}
|
|
16699
|
-
const handle = await
|
|
16778
|
+
const handle = await fs12.open(filename, "r");
|
|
16700
16779
|
let buffer;
|
|
16701
16780
|
let readEnd = offset;
|
|
16702
16781
|
try {
|
|
@@ -16771,12 +16850,12 @@ async function scanSourceOnce(config2, paths, signal) {
|
|
|
16771
16850
|
lineStart = buffer.length;
|
|
16772
16851
|
}
|
|
16773
16852
|
cursors[filename] = offset + lineStart;
|
|
16774
|
-
if (source === "cursor" && filename.includes(`${
|
|
16853
|
+
if (source === "cursor" && filename.includes(`${path15.sep}cursor-hooks${path15.sep}`) && cursors[filename] === stats.size)
|
|
16775
16854
|
completedHooks.push(filename);
|
|
16776
16855
|
}
|
|
16777
16856
|
await appendEvents(events, paths);
|
|
16778
16857
|
for (const filename of completedHooks) {
|
|
16779
|
-
await
|
|
16858
|
+
await fs12.rm(filename);
|
|
16780
16859
|
delete cursors[filename];
|
|
16781
16860
|
}
|
|
16782
16861
|
await saveState(
|
|
@@ -16915,26 +16994,26 @@ async function persistHealth(health, paths) {
|
|
|
16915
16994
|
}
|
|
16916
16995
|
}
|
|
16917
16996
|
async function acquireCollectorLock(paths) {
|
|
16918
|
-
await ensurePrivateDirectory(
|
|
16997
|
+
await ensurePrivateDirectory(path16.dirname(paths.lock));
|
|
16919
16998
|
for (let attempt = 0; attempt < 2; attempt += 1) {
|
|
16920
16999
|
try {
|
|
16921
|
-
const handle = await
|
|
17000
|
+
const handle = await fs13.open(paths.lock, "wx", 384);
|
|
16922
17001
|
await handle.writeFile(`${process.pid}
|
|
16923
17002
|
`, "utf8");
|
|
16924
17003
|
await handle.sync();
|
|
16925
17004
|
await handle.close();
|
|
16926
17005
|
return async () => {
|
|
16927
|
-
const current = await
|
|
17006
|
+
const current = await fs13.readFile(paths.lock, "utf8").catch(() => "");
|
|
16928
17007
|
if (current.trim() === String(process.pid)) {
|
|
16929
|
-
await
|
|
17008
|
+
await fs13.rm(paths.lock, { force: true });
|
|
16930
17009
|
}
|
|
16931
17010
|
};
|
|
16932
17011
|
} catch (error2) {
|
|
16933
17012
|
if (errorCode2(error2) !== "EEXIST") throw error2;
|
|
16934
|
-
const lockContents = await
|
|
17013
|
+
const lockContents = await fs13.readFile(paths.lock, "utf8").catch(() => "");
|
|
16935
17014
|
const lockPid = Number(lockContents.trim());
|
|
16936
17015
|
if (!Number.isSafeInteger(lockPid) || lockPid < 2) {
|
|
16937
|
-
await
|
|
17016
|
+
await fs13.rm(paths.lock, { force: true });
|
|
16938
17017
|
continue;
|
|
16939
17018
|
}
|
|
16940
17019
|
try {
|
|
@@ -16942,7 +17021,7 @@ async function acquireCollectorLock(paths) {
|
|
|
16942
17021
|
throw new CollectorLockBusyError("Collector is already running.");
|
|
16943
17022
|
} catch (processError) {
|
|
16944
17023
|
if (errorCode2(processError) !== "ESRCH") throw processError;
|
|
16945
|
-
await
|
|
17024
|
+
await fs13.rm(paths.lock, { force: true });
|
|
16946
17025
|
}
|
|
16947
17026
|
}
|
|
16948
17027
|
}
|
|
@@ -17210,7 +17289,7 @@ async function importSourceHistory(config2, paths, confirmed, control = backgrou
|
|
|
17210
17289
|
const source = collectorSource(config2);
|
|
17211
17290
|
const directory = collectorSourceDirectory(config2);
|
|
17212
17291
|
const state = await loadState(paths);
|
|
17213
|
-
if (!state.initialized || state.sourceDirectory !==
|
|
17292
|
+
if (!state.initialized || state.sourceDirectory !== path17.resolve(directory)) {
|
|
17214
17293
|
throw new Error(
|
|
17215
17294
|
`Connect the ${source} source before importing its history.`
|
|
17216
17295
|
);
|
|
@@ -17639,7 +17718,7 @@ function usage(command) {
|
|
|
17639
17718
|
}
|
|
17640
17719
|
async function fileExists(filename) {
|
|
17641
17720
|
try {
|
|
17642
|
-
await
|
|
17721
|
+
await fs14.access(filename);
|
|
17643
17722
|
return true;
|
|
17644
17723
|
} catch (error2) {
|
|
17645
17724
|
if (error2 instanceof Error && "code" in error2 && error2.code === "ENOENT") {
|
|
@@ -17670,13 +17749,13 @@ async function defaultCommand() {
|
|
|
17670
17749
|
claude: sourceHome("claude"),
|
|
17671
17750
|
cursor: sourceHome("cursor")
|
|
17672
17751
|
});
|
|
17673
|
-
const
|
|
17752
|
+
const missing2 = discovered.filter(
|
|
17674
17753
|
(source) => snapshots.find((item) => item.source === source)?.snapshot.kind === "not_connected"
|
|
17675
17754
|
);
|
|
17676
|
-
if (
|
|
17755
|
+
if (missing2.length > 0) {
|
|
17677
17756
|
process.stdout.write(
|
|
17678
17757
|
`
|
|
17679
|
-
${
|
|
17758
|
+
${missing2.map(collectorSourceLabel).join(" and ")} found on this computer but not connected. Run iteration connect to include ${missing2.length === 1 ? "it" : "them"}.
|
|
17680
17759
|
`
|
|
17681
17760
|
);
|
|
17682
17761
|
}
|
|
@@ -17689,7 +17768,7 @@ ${missing.map(collectorSourceLabel).join(" and ")} found on this computer but no
|
|
|
17689
17768
|
await connectAll({});
|
|
17690
17769
|
}
|
|
17691
17770
|
function dataDirectory(source, values) {
|
|
17692
|
-
return
|
|
17771
|
+
return path18.resolve(
|
|
17693
17772
|
optionalString(values, "data-directory") ?? defaultCollectorDirectory(source)
|
|
17694
17773
|
);
|
|
17695
17774
|
}
|
|
@@ -17714,8 +17793,8 @@ async function initialize(source, values) {
|
|
|
17714
17793
|
const organizationId = optionalString(values, "organization-id");
|
|
17715
17794
|
const directory = dataDirectory(source, values);
|
|
17716
17795
|
const paths = collectorPaths(directory);
|
|
17717
|
-
const selectedHome =
|
|
17718
|
-
source === "codex" ? optionalString(values, "codex-home") ?? process.env.CODEX_HOME ??
|
|
17796
|
+
const selectedHome = path18.resolve(
|
|
17797
|
+
source === "codex" ? optionalString(values, "codex-home") ?? process.env.CODEX_HOME ?? path18.join(os7.homedir(), ".codex") : source === "claude" ? optionalString(values, "claude-home") ?? process.env.CLAUDE_CONFIG_DIR ?? path18.join(os7.homedir(), ".claude") : optionalString(values, "cursor-home") ?? path18.join(os7.homedir(), ".cursor")
|
|
17719
17798
|
);
|
|
17720
17799
|
await assertFreshCollectorDirectory(paths, source);
|
|
17721
17800
|
const preparedState = await prepareSourceInitialState(
|
|
@@ -17798,13 +17877,13 @@ async function connectAll(values) {
|
|
|
17798
17877
|
}
|
|
17799
17878
|
const configs = await Promise.all(COLLECTOR_SOURCES.map(connectedConfig));
|
|
17800
17879
|
const sourceHomes = {
|
|
17801
|
-
codex:
|
|
17880
|
+
codex: path18.resolve(
|
|
17802
17881
|
optionalString(values, "codex-home") ?? (configs[0] && "codexHome" in configs[0] ? configs[0].codexHome : sourceHome("codex"))
|
|
17803
17882
|
),
|
|
17804
|
-
claude:
|
|
17883
|
+
claude: path18.resolve(
|
|
17805
17884
|
optionalString(values, "claude-home") ?? (configs[1] && "claudeHome" in configs[1] ? configs[1].claudeHome : sourceHome("claude"))
|
|
17806
17885
|
),
|
|
17807
|
-
cursor:
|
|
17886
|
+
cursor: path18.resolve(
|
|
17808
17887
|
optionalString(values, "cursor-home") ?? (configs[2] && "cursorHome" in configs[2] ? configs[2].cursorHome : sourceHome("cursor"))
|
|
17809
17888
|
)
|
|
17810
17889
|
};
|