@threadbase-sh/scanner 0.19.4 → 0.20.0
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 +14 -4
- package/dist/cli.js +381 -73
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +417 -103
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +395 -84
- package/dist/index.js.map +1 -1
- package/dist/persistent/index-engine.d.ts.map +1 -1
- package/dist/providers/copilot.d.ts +33 -0
- package/dist/providers/copilot.d.ts.map +1 -0
- package/dist/providers/provider.d.ts +2 -1
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/scanner.d.ts.map +1 -1
- package/dist/search-document.d.ts.map +1 -1
- package/dist/types.d.ts +2 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -5,7 +5,7 @@ import { Command } from "commander";
|
|
|
5
5
|
import pino2 from "pino";
|
|
6
6
|
|
|
7
7
|
// package.json
|
|
8
|
-
var version = "0.
|
|
8
|
+
var version = "0.20.0";
|
|
9
9
|
|
|
10
10
|
// src/logger.ts
|
|
11
11
|
import pino from "pino";
|
|
@@ -60,7 +60,7 @@ async function saveProfiles(profiles, configPath) {
|
|
|
60
60
|
|
|
61
61
|
// src/scanner.ts
|
|
62
62
|
import { EventEmitter } from "events";
|
|
63
|
-
import { closeSync as closeSync2, openSync as openSync2, readSync as readSync2, statSync as
|
|
63
|
+
import { closeSync as closeSync2, openSync as openSync2, readSync as readSync2, statSync as statSync5 } from "fs";
|
|
64
64
|
import { homedir as homedir2 } from "os";
|
|
65
65
|
import { join as join6 } from "path";
|
|
66
66
|
|
|
@@ -615,10 +615,11 @@ import { basename, dirname as dirname2, join as join3 } from "path";
|
|
|
615
615
|
var CLAUDE_CODE_PROVIDER = "claude-code";
|
|
616
616
|
var CODEX_CLI_PROVIDER = "codex-cli";
|
|
617
617
|
var CURSOR_PROVIDER = "cursor";
|
|
618
|
+
var COPILOT_PROVIDER = "copilot";
|
|
618
619
|
var LEGACY_CURSOR_PROVIDER = "cursor-cli";
|
|
619
620
|
function canonicalizeProviderName(value) {
|
|
620
621
|
if (value === LEGACY_CURSOR_PROVIDER) return CURSOR_PROVIDER;
|
|
621
|
-
if (value === CLAUDE_CODE_PROVIDER || value === CODEX_CLI_PROVIDER || value === CURSOR_PROVIDER) {
|
|
622
|
+
if (value === CLAUDE_CODE_PROVIDER || value === CODEX_CLI_PROVIDER || value === CURSOR_PROVIDER || value === COPILOT_PROVIDER) {
|
|
622
623
|
return value;
|
|
623
624
|
}
|
|
624
625
|
return void 0;
|
|
@@ -1223,37 +1224,37 @@ function fingerprint(filePath, size) {
|
|
|
1223
1224
|
return hash.digest("hex");
|
|
1224
1225
|
}
|
|
1225
1226
|
function classify(filePath, existing) {
|
|
1226
|
-
let
|
|
1227
|
+
let stat6;
|
|
1227
1228
|
try {
|
|
1228
1229
|
const s = statSync(filePath);
|
|
1229
|
-
|
|
1230
|
+
stat6 = { size: s.size, mtimeMs: s.mtimeMs };
|
|
1230
1231
|
} catch {
|
|
1231
1232
|
return { change: "vanished" };
|
|
1232
1233
|
}
|
|
1233
1234
|
if (!existing || existing.status !== "active" || existing.last_indexed_offset === 0) {
|
|
1234
|
-
return { change: "reindex", stat:
|
|
1235
|
+
return { change: "reindex", stat: stat6 };
|
|
1235
1236
|
}
|
|
1236
|
-
if (
|
|
1237
|
-
return { change: "reindex", stat:
|
|
1237
|
+
if (stat6.size < existing.last_indexed_offset) {
|
|
1238
|
+
return { change: "reindex", stat: stat6 };
|
|
1238
1239
|
}
|
|
1239
|
-
if (
|
|
1240
|
-
return { change: "unchanged", stat:
|
|
1240
|
+
if (stat6.size === existing.size_bytes && stat6.mtimeMs === existing.mtime_ms) {
|
|
1241
|
+
return { change: "unchanged", stat: stat6 };
|
|
1241
1242
|
}
|
|
1242
|
-
if (
|
|
1243
|
-
const fp = fingerprint(filePath,
|
|
1243
|
+
if (stat6.size === existing.last_indexed_offset) {
|
|
1244
|
+
const fp = fingerprint(filePath, stat6.size);
|
|
1244
1245
|
if (existing.content_fingerprint && fp !== existing.content_fingerprint) {
|
|
1245
|
-
return { change: "reindex", stat:
|
|
1246
|
+
return { change: "reindex", stat: stat6 };
|
|
1246
1247
|
}
|
|
1247
|
-
return { change: "unchanged", stat:
|
|
1248
|
+
return { change: "unchanged", stat: stat6 };
|
|
1248
1249
|
}
|
|
1249
1250
|
if (existing.content_fingerprint && existing.size_bytes === existing.last_indexed_offset && fingerprint(filePath, existing.last_indexed_offset) === existing.content_fingerprint) {
|
|
1250
|
-
return { change: "appended", stat:
|
|
1251
|
+
return { change: "appended", stat: stat6 };
|
|
1251
1252
|
}
|
|
1252
|
-
return { change: "reindex", stat:
|
|
1253
|
+
return { change: "reindex", stat: stat6 };
|
|
1253
1254
|
}
|
|
1254
1255
|
|
|
1255
1256
|
// src/persistent/index-engine.ts
|
|
1256
|
-
import { statSync as
|
|
1257
|
+
import { statSync as statSync4 } from "fs";
|
|
1257
1258
|
|
|
1258
1259
|
// src/providers/codex-cli.ts
|
|
1259
1260
|
import fg2 from "fast-glob";
|
|
@@ -1605,13 +1606,293 @@ async function parseCodexConversation(filePath, account) {
|
|
|
1605
1606
|
};
|
|
1606
1607
|
}
|
|
1607
1608
|
|
|
1608
|
-
// src/providers/
|
|
1609
|
-
import { createHash as createHash2 } from "crypto";
|
|
1609
|
+
// src/providers/copilot.ts
|
|
1610
1610
|
import fg3 from "fast-glob";
|
|
1611
|
-
import { createReadStream as createReadStream5,
|
|
1611
|
+
import { createReadStream as createReadStream5, statSync as statSync2 } from "fs";
|
|
1612
1612
|
import { stat as stat3 } from "fs/promises";
|
|
1613
|
-
import { basename as basename5, dirname as dirname3
|
|
1613
|
+
import { basename as basename5, dirname as dirname3 } from "path";
|
|
1614
1614
|
import { createInterface as createInterface3 } from "readline";
|
|
1615
|
+
var SESSION_START = "session.start";
|
|
1616
|
+
var USER_MESSAGE = "user.message";
|
|
1617
|
+
var ASSISTANT_MESSAGE = "assistant.message";
|
|
1618
|
+
var CopilotProvider = class {
|
|
1619
|
+
name = COPILOT_PROVIDER;
|
|
1620
|
+
async discover(roots) {
|
|
1621
|
+
const log = getLogger();
|
|
1622
|
+
const results = [];
|
|
1623
|
+
for (const root of roots) {
|
|
1624
|
+
let paths;
|
|
1625
|
+
try {
|
|
1626
|
+
paths = await fg3(["*/events.jsonl", "session-state/*/events.jsonl"], {
|
|
1627
|
+
cwd: root,
|
|
1628
|
+
absolute: true,
|
|
1629
|
+
dot: false,
|
|
1630
|
+
unique: true
|
|
1631
|
+
});
|
|
1632
|
+
} catch (err) {
|
|
1633
|
+
log.warn({ root, err }, "copilot discovery: glob failed");
|
|
1634
|
+
continue;
|
|
1635
|
+
}
|
|
1636
|
+
for (const filePath of paths) {
|
|
1637
|
+
try {
|
|
1638
|
+
const s = await stat3(filePath);
|
|
1639
|
+
if (s.size > 0) results.push({ filePath: canonicalPath(filePath), account: "copilot" });
|
|
1640
|
+
} catch (err) {
|
|
1641
|
+
log.warn({ filePath, err }, "copilot discovery: stat failed");
|
|
1642
|
+
}
|
|
1643
|
+
}
|
|
1644
|
+
}
|
|
1645
|
+
return results;
|
|
1646
|
+
}
|
|
1647
|
+
canParse(_filePath, sample) {
|
|
1648
|
+
for (const line of sample.split("\n")) {
|
|
1649
|
+
if (!line.trim()) continue;
|
|
1650
|
+
try {
|
|
1651
|
+
if (looksLikeCopilotEvent(JSON.parse(line))) return true;
|
|
1652
|
+
} catch {
|
|
1653
|
+
}
|
|
1654
|
+
}
|
|
1655
|
+
return false;
|
|
1656
|
+
}
|
|
1657
|
+
createEmptyAccumulator() {
|
|
1658
|
+
return {
|
|
1659
|
+
sessionId: "",
|
|
1660
|
+
cwd: "",
|
|
1661
|
+
gitBranch: null,
|
|
1662
|
+
model: null,
|
|
1663
|
+
latestTimestamp: "",
|
|
1664
|
+
messageCount: 0,
|
|
1665
|
+
lastMessageSender: "user",
|
|
1666
|
+
firstUser: null,
|
|
1667
|
+
lastUser: null,
|
|
1668
|
+
lastAssistant: null,
|
|
1669
|
+
toolNames: [],
|
|
1670
|
+
previewParts: [],
|
|
1671
|
+
previewLength: 0,
|
|
1672
|
+
snippetParts: [],
|
|
1673
|
+
snippetLength: 0
|
|
1674
|
+
};
|
|
1675
|
+
}
|
|
1676
|
+
reduceEntry(acc, entry, tier) {
|
|
1677
|
+
reduceCopilotEntry(acc, entry, tier);
|
|
1678
|
+
}
|
|
1679
|
+
finalize(acc, filePath, account, tier) {
|
|
1680
|
+
return finalizeCopilotMeta(acc, filePath, account, tier);
|
|
1681
|
+
}
|
|
1682
|
+
};
|
|
1683
|
+
function looksLikeCopilotEvent(entry) {
|
|
1684
|
+
return typeof entry.type === "string" && typeof entry.id === "string" && "parentId" in entry && asRecord(entry.data) !== null;
|
|
1685
|
+
}
|
|
1686
|
+
var asString2 = (v) => typeof v === "string" ? v : "";
|
|
1687
|
+
function asRecord(v) {
|
|
1688
|
+
return v && typeof v === "object" && !Array.isArray(v) ? v : null;
|
|
1689
|
+
}
|
|
1690
|
+
function copilotToolUseBlocks(data) {
|
|
1691
|
+
if (!Array.isArray(data.toolRequests)) return [];
|
|
1692
|
+
const blocks = [];
|
|
1693
|
+
for (const item of data.toolRequests) {
|
|
1694
|
+
const request = asRecord(item);
|
|
1695
|
+
const name = asString2(request?.name);
|
|
1696
|
+
if (!request || !name) continue;
|
|
1697
|
+
const input = asRecord(request.arguments) ?? { arguments: asString2(request.arguments) };
|
|
1698
|
+
blocks.push({ id: asString2(request.toolCallId), name, input });
|
|
1699
|
+
}
|
|
1700
|
+
return blocks;
|
|
1701
|
+
}
|
|
1702
|
+
function copilotEntryToMessage(entry) {
|
|
1703
|
+
if (!looksLikeCopilotEvent(entry)) return null;
|
|
1704
|
+
const data = entry.data;
|
|
1705
|
+
const timestamp = asString2(entry.timestamp);
|
|
1706
|
+
const uuid = asString2(data.messageId) || asString2(entry.id);
|
|
1707
|
+
if (entry.type === USER_MESSAGE) {
|
|
1708
|
+
const text = cleanSystemTags(asString2(data.content));
|
|
1709
|
+
return text ? { role: "user", text, timestamp, uuid } : null;
|
|
1710
|
+
}
|
|
1711
|
+
if (entry.type === ASSISTANT_MESSAGE) {
|
|
1712
|
+
const text = asString2(data.content).trim();
|
|
1713
|
+
const blocks = copilotToolUseBlocks(data);
|
|
1714
|
+
if (!text && blocks.length === 0) return null;
|
|
1715
|
+
const model = asString2(data.model);
|
|
1716
|
+
const metadata = {
|
|
1717
|
+
...model ? { model } : {},
|
|
1718
|
+
...blocks.length > 0 ? { toolUses: blocks.map((b) => b.name), toolUseBlocks: blocks } : {}
|
|
1719
|
+
};
|
|
1720
|
+
return {
|
|
1721
|
+
role: "assistant",
|
|
1722
|
+
text,
|
|
1723
|
+
timestamp,
|
|
1724
|
+
uuid,
|
|
1725
|
+
...Object.keys(metadata).length > 0 ? { metadata } : {}
|
|
1726
|
+
};
|
|
1727
|
+
}
|
|
1728
|
+
return null;
|
|
1729
|
+
}
|
|
1730
|
+
function parseCopilotJsonlLine(line) {
|
|
1731
|
+
const trimmed = line.trim();
|
|
1732
|
+
if (!trimmed) return null;
|
|
1733
|
+
try {
|
|
1734
|
+
return copilotEntryToMessage(JSON.parse(trimmed));
|
|
1735
|
+
} catch {
|
|
1736
|
+
return null;
|
|
1737
|
+
}
|
|
1738
|
+
}
|
|
1739
|
+
function readSessionStart(entry) {
|
|
1740
|
+
if (entry.type !== SESSION_START) return null;
|
|
1741
|
+
const data = asRecord(entry.data);
|
|
1742
|
+
if (!data) return null;
|
|
1743
|
+
const context = asRecord(data.context);
|
|
1744
|
+
return {
|
|
1745
|
+
sessionId: asString2(data.sessionId),
|
|
1746
|
+
cwd: asString2(context?.cwd),
|
|
1747
|
+
branch: asString2(context?.branch)
|
|
1748
|
+
};
|
|
1749
|
+
}
|
|
1750
|
+
function reduceCopilotEntry(acc, entry, tier) {
|
|
1751
|
+
const start = readSessionStart(entry);
|
|
1752
|
+
if (start) {
|
|
1753
|
+
if (!acc.sessionId) acc.sessionId = start.sessionId;
|
|
1754
|
+
if (!acc.cwd) acc.cwd = start.cwd;
|
|
1755
|
+
if (!acc.gitBranch && start.branch) acc.gitBranch = start.branch;
|
|
1756
|
+
return;
|
|
1757
|
+
}
|
|
1758
|
+
const message = copilotEntryToMessage(entry);
|
|
1759
|
+
if (!message) return;
|
|
1760
|
+
for (const name of message.metadata?.toolUses ?? []) {
|
|
1761
|
+
if (!acc.toolNames.includes(name)) acc.toolNames.push(name);
|
|
1762
|
+
}
|
|
1763
|
+
if (message.metadata?.model) acc.model = message.metadata.model;
|
|
1764
|
+
const { role, text, timestamp } = message;
|
|
1765
|
+
if (!text) return;
|
|
1766
|
+
if (timestamp && (!acc.latestTimestamp || timestamp > acc.latestTimestamp)) {
|
|
1767
|
+
acc.latestTimestamp = timestamp;
|
|
1768
|
+
}
|
|
1769
|
+
acc.messageCount++;
|
|
1770
|
+
acc.lastMessageSender = role;
|
|
1771
|
+
const snapshot = { text: text.slice(0, 200), timestamp };
|
|
1772
|
+
if (role === "user") {
|
|
1773
|
+
if (!acc.firstUser) acc.firstUser = snapshot;
|
|
1774
|
+
acc.lastUser = snapshot;
|
|
1775
|
+
} else {
|
|
1776
|
+
acc.lastAssistant = snapshot;
|
|
1777
|
+
}
|
|
1778
|
+
if (acc.previewLength < tier.previewMax) {
|
|
1779
|
+
acc.previewParts.push(text);
|
|
1780
|
+
acc.previewLength += text.length;
|
|
1781
|
+
}
|
|
1782
|
+
if (acc.snippetLength < tier.snippetMax) {
|
|
1783
|
+
const remaining = tier.snippetMax - acc.snippetLength;
|
|
1784
|
+
const chunk = text.length > remaining ? text.slice(0, remaining) : text;
|
|
1785
|
+
acc.snippetParts.push(chunk);
|
|
1786
|
+
acc.snippetLength += chunk.length;
|
|
1787
|
+
}
|
|
1788
|
+
}
|
|
1789
|
+
function finalizeCopilotMeta(acc, filePath, account, tier) {
|
|
1790
|
+
if (acc.messageCount === 0) return null;
|
|
1791
|
+
const sessionId = acc.sessionId || sessionIdFromPath(filePath);
|
|
1792
|
+
const kind = acc.lastAssistant === null && acc.toolNames.length > 0 ? "task" : "conversation";
|
|
1793
|
+
return {
|
|
1794
|
+
id: filePath,
|
|
1795
|
+
filePath,
|
|
1796
|
+
provider: COPILOT_PROVIDER,
|
|
1797
|
+
kind,
|
|
1798
|
+
externalSessionId: sessionId,
|
|
1799
|
+
sessionId,
|
|
1800
|
+
sessionName: deriveSessionNameFromFirstMessage(acc.firstUser),
|
|
1801
|
+
projectPath: acc.cwd,
|
|
1802
|
+
projectName: getShortProjectName4(acc.cwd),
|
|
1803
|
+
account,
|
|
1804
|
+
timestamp: acc.latestTimestamp || fileMtimeIso(filePath),
|
|
1805
|
+
messageCount: acc.messageCount,
|
|
1806
|
+
lastMessageSender: acc.lastMessageSender,
|
|
1807
|
+
preview: acc.previewParts.join(" ").slice(0, tier.previewMax),
|
|
1808
|
+
contentSnippet: acc.snippetParts.join(" "),
|
|
1809
|
+
gitBranch: acc.gitBranch,
|
|
1810
|
+
model: acc.model,
|
|
1811
|
+
isSubagent: false,
|
|
1812
|
+
parentSessionId: null,
|
|
1813
|
+
isTeammate: false,
|
|
1814
|
+
teamName: null,
|
|
1815
|
+
toolNames: acc.toolNames,
|
|
1816
|
+
firstMessage: acc.firstUser,
|
|
1817
|
+
lastMessage: acc.lastAssistant ?? acc.lastUser,
|
|
1818
|
+
lastPrompt: acc.lastUser?.text || void 0
|
|
1819
|
+
};
|
|
1820
|
+
}
|
|
1821
|
+
function sessionIdFromPath(filePath) {
|
|
1822
|
+
return basename5(dirname3(filePath));
|
|
1823
|
+
}
|
|
1824
|
+
function getShortProjectName4(fullPath) {
|
|
1825
|
+
return fullPath.split(/[/\\]/).filter(Boolean).slice(-3).join("/");
|
|
1826
|
+
}
|
|
1827
|
+
function fileMtimeIso(filePath) {
|
|
1828
|
+
try {
|
|
1829
|
+
return new Date(statSync2(filePath).mtimeMs).toISOString();
|
|
1830
|
+
} catch {
|
|
1831
|
+
return (/* @__PURE__ */ new Date()).toISOString();
|
|
1832
|
+
}
|
|
1833
|
+
}
|
|
1834
|
+
async function parseCopilotConversation(filePath, account) {
|
|
1835
|
+
const log = getLogger();
|
|
1836
|
+
const messages = [];
|
|
1837
|
+
const textParts = [];
|
|
1838
|
+
let sessionId = "";
|
|
1839
|
+
let cwd = "";
|
|
1840
|
+
let latestTimestamp = "";
|
|
1841
|
+
let lastUserText = "";
|
|
1842
|
+
const rl = createInterface3({ input: createReadStream5(filePath), crlfDelay: Infinity });
|
|
1843
|
+
try {
|
|
1844
|
+
for await (const line of rl) {
|
|
1845
|
+
if (!line.trim()) continue;
|
|
1846
|
+
let entry;
|
|
1847
|
+
try {
|
|
1848
|
+
entry = JSON.parse(line);
|
|
1849
|
+
} catch {
|
|
1850
|
+
continue;
|
|
1851
|
+
}
|
|
1852
|
+
const start = readSessionStart(entry);
|
|
1853
|
+
if (start) {
|
|
1854
|
+
if (!sessionId) sessionId = start.sessionId;
|
|
1855
|
+
if (!cwd) cwd = start.cwd;
|
|
1856
|
+
continue;
|
|
1857
|
+
}
|
|
1858
|
+
const message = copilotEntryToMessage(entry);
|
|
1859
|
+
if (!message) continue;
|
|
1860
|
+
if (message.timestamp && (!latestTimestamp || message.timestamp > latestTimestamp)) {
|
|
1861
|
+
latestTimestamp = message.timestamp;
|
|
1862
|
+
}
|
|
1863
|
+
messages.push(message);
|
|
1864
|
+
if (!message.text) continue;
|
|
1865
|
+
textParts.push(message.text);
|
|
1866
|
+
if (message.role === "user") lastUserText = message.text;
|
|
1867
|
+
}
|
|
1868
|
+
} catch (err) {
|
|
1869
|
+
log.warn({ filePath, err }, "parseCopilotConversation: read failed");
|
|
1870
|
+
return null;
|
|
1871
|
+
}
|
|
1872
|
+
if (messages.length === 0) return null;
|
|
1873
|
+
return {
|
|
1874
|
+
id: filePath,
|
|
1875
|
+
filePath,
|
|
1876
|
+
projectPath: cwd,
|
|
1877
|
+
projectName: getShortProjectName4(cwd),
|
|
1878
|
+
sessionId: sessionId || sessionIdFromPath(filePath),
|
|
1879
|
+
sessionName: "",
|
|
1880
|
+
messages,
|
|
1881
|
+
fullText: textParts.join(" "),
|
|
1882
|
+
timestamp: latestTimestamp || fileMtimeIso(filePath),
|
|
1883
|
+
messageCount: messages.length,
|
|
1884
|
+
account,
|
|
1885
|
+
lastPrompt: lastUserText || void 0
|
|
1886
|
+
};
|
|
1887
|
+
}
|
|
1888
|
+
|
|
1889
|
+
// src/providers/cursor.ts
|
|
1890
|
+
import { createHash as createHash2 } from "crypto";
|
|
1891
|
+
import fg4 from "fast-glob";
|
|
1892
|
+
import { createReadStream as createReadStream6, existsSync, statSync as statSync3 } from "fs";
|
|
1893
|
+
import { stat as stat4 } from "fs/promises";
|
|
1894
|
+
import { basename as basename6, dirname as dirname4, join as join4, sep as sep2 } from "path";
|
|
1895
|
+
import { createInterface as createInterface4 } from "readline";
|
|
1615
1896
|
var TIMESTAMP_RE = /<timestamp>\s*([\s\S]*?)\s*<\/timestamp>/;
|
|
1616
1897
|
var USER_QUERY_RE = /<user_query>\s*([\s\S]*?)\s*<\/user_query>/;
|
|
1617
1898
|
var SUBAGENT_PATH_RE2 = /[\\/]subagents[\\/]/;
|
|
@@ -1623,7 +1904,7 @@ var CursorProvider = class {
|
|
|
1623
1904
|
for (const root of roots) {
|
|
1624
1905
|
let paths;
|
|
1625
1906
|
try {
|
|
1626
|
-
paths = await
|
|
1907
|
+
paths = await fg4(["**/agent-transcripts/**/*.jsonl"], {
|
|
1627
1908
|
cwd: root,
|
|
1628
1909
|
absolute: true,
|
|
1629
1910
|
dot: false,
|
|
@@ -1635,7 +1916,7 @@ var CursorProvider = class {
|
|
|
1635
1916
|
}
|
|
1636
1917
|
for (const filePath of paths) {
|
|
1637
1918
|
try {
|
|
1638
|
-
const s = await
|
|
1919
|
+
const s = await stat4(filePath);
|
|
1639
1920
|
if (s.size > 0) results.push({ filePath: canonicalPath(filePath), account: "cursor" });
|
|
1640
1921
|
} catch (err) {
|
|
1641
1922
|
log.warn({ filePath, err }, "cursor discovery: stat failed");
|
|
@@ -1699,7 +1980,7 @@ function looksLikeImportedClaudeEntry(entry) {
|
|
|
1699
1980
|
function looksLikeImportedCodexEntry(entry) {
|
|
1700
1981
|
return entry.type === "session_meta" || entry.type === "response_item" || entry.type === "event_msg";
|
|
1701
1982
|
}
|
|
1702
|
-
function
|
|
1983
|
+
function asString3(value) {
|
|
1703
1984
|
return typeof value === "string" ? value : "";
|
|
1704
1985
|
}
|
|
1705
1986
|
function provenanceToken(value) {
|
|
@@ -1813,7 +2094,7 @@ function cursorEntryToMessage(entry) {
|
|
|
1813
2094
|
const role = message?.role === "assistant" || entry.type === "assistant" ? "assistant" : "user";
|
|
1814
2095
|
const content = message?.content ?? entry.content;
|
|
1815
2096
|
return withToolUses(
|
|
1816
|
-
{ role, text: extractCursorText(content), timestamp:
|
|
2097
|
+
{ role, text: extractCursorText(content), timestamp: asString3(entry.timestamp) },
|
|
1817
2098
|
content
|
|
1818
2099
|
);
|
|
1819
2100
|
}
|
|
@@ -1890,11 +2171,11 @@ function reduceCursorEntry(acc, entry, tier) {
|
|
|
1890
2171
|
}
|
|
1891
2172
|
function finalizeCursorMeta(acc, filePath, account, tier) {
|
|
1892
2173
|
if (acc.messageCount === 0) return null;
|
|
1893
|
-
const sessionId =
|
|
2174
|
+
const sessionId = basename6(filePath, ".jsonl");
|
|
1894
2175
|
const isSubagent = SUBAGENT_PATH_RE2.test(filePath);
|
|
1895
2176
|
const parent = isSubagent ? parentFromSubagentPath(filePath) : null;
|
|
1896
2177
|
const { projectPath, projectName } = projectFromCursorPath(filePath);
|
|
1897
|
-
const timestamp = acc.latestTimestamp ||
|
|
2178
|
+
const timestamp = acc.latestTimestamp || fileMtimeIso2(filePath);
|
|
1898
2179
|
const kind = acc.lastAssistant === null && acc.toolNames.length > 0 ? "task" : "conversation";
|
|
1899
2180
|
return {
|
|
1900
2181
|
id: filePath,
|
|
@@ -1929,9 +2210,9 @@ function finalizeCursorMeta(acc, filePath, account, tier) {
|
|
|
1929
2210
|
};
|
|
1930
2211
|
}
|
|
1931
2212
|
function parentFromSubagentPath(filePath) {
|
|
1932
|
-
const subagentsDir =
|
|
1933
|
-
const parentDir =
|
|
1934
|
-
const parentSessionUuid =
|
|
2213
|
+
const subagentsDir = dirname4(filePath);
|
|
2214
|
+
const parentDir = dirname4(subagentsDir);
|
|
2215
|
+
const parentSessionUuid = basename6(parentDir);
|
|
1935
2216
|
if (!parentSessionUuid) return null;
|
|
1936
2217
|
return {
|
|
1937
2218
|
parentSessionUuid,
|
|
@@ -1941,11 +2222,11 @@ function parentFromSubagentPath(filePath) {
|
|
|
1941
2222
|
function projectFromCursorPath(filePath) {
|
|
1942
2223
|
const parts = filePath.split(/[/\\]/);
|
|
1943
2224
|
const idx = parts.lastIndexOf("agent-transcripts");
|
|
1944
|
-
const cursorProjectDir = idx > 0 ? parts.slice(0, idx).join(sep2) :
|
|
1945
|
-
const slug =
|
|
2225
|
+
const cursorProjectDir = idx > 0 ? parts.slice(0, idx).join(sep2) : dirname4(dirname4(filePath));
|
|
2226
|
+
const slug = basename6(cursorProjectDir);
|
|
1946
2227
|
const decoded = decodeCursorProjectSlug(slug);
|
|
1947
2228
|
const projectPath = decoded ?? cursorProjectDir;
|
|
1948
|
-
return { projectPath, projectName:
|
|
2229
|
+
return { projectPath, projectName: getShortProjectName5(projectPath) || slug };
|
|
1949
2230
|
}
|
|
1950
2231
|
function decodeCursorProjectSlug(slug) {
|
|
1951
2232
|
if (!slug) return null;
|
|
@@ -1966,7 +2247,7 @@ function decodeCursorProjectSlug(slug) {
|
|
|
1966
2247
|
for (let j = segments.length; j > i; j--) {
|
|
1967
2248
|
const candidate = join4(acc, segments.slice(i, j).join("-"));
|
|
1968
2249
|
try {
|
|
1969
|
-
if (existsSync(candidate) &&
|
|
2250
|
+
if (existsSync(candidate) && statSync3(candidate).isDirectory()) {
|
|
1970
2251
|
found = candidate;
|
|
1971
2252
|
next = j;
|
|
1972
2253
|
break;
|
|
@@ -1980,12 +2261,12 @@ function decodeCursorProjectSlug(slug) {
|
|
|
1980
2261
|
}
|
|
1981
2262
|
return acc;
|
|
1982
2263
|
}
|
|
1983
|
-
function
|
|
2264
|
+
function getShortProjectName5(fullPath) {
|
|
1984
2265
|
return fullPath.split(/[/\\]/).filter(Boolean).slice(-3).join("/");
|
|
1985
2266
|
}
|
|
1986
|
-
function
|
|
2267
|
+
function fileMtimeIso2(filePath) {
|
|
1987
2268
|
try {
|
|
1988
|
-
return new Date(
|
|
2269
|
+
return new Date(statSync3(filePath).mtimeMs).toISOString();
|
|
1989
2270
|
} catch {
|
|
1990
2271
|
return (/* @__PURE__ */ new Date()).toISOString();
|
|
1991
2272
|
}
|
|
@@ -1996,7 +2277,7 @@ async function parseCursorConversation(filePath, account) {
|
|
|
1996
2277
|
const textParts = [];
|
|
1997
2278
|
let latestTimestamp = "";
|
|
1998
2279
|
let lastUserText = "";
|
|
1999
|
-
const rl =
|
|
2280
|
+
const rl = createInterface4({ input: createReadStream6(filePath), crlfDelay: Infinity });
|
|
2000
2281
|
try {
|
|
2001
2282
|
for await (const line of rl) {
|
|
2002
2283
|
const message = parseCursorJsonlLine(line, messages.length);
|
|
@@ -2015,7 +2296,7 @@ async function parseCursorConversation(filePath, account) {
|
|
|
2015
2296
|
}
|
|
2016
2297
|
if (messages.length === 0) return null;
|
|
2017
2298
|
const { projectPath, projectName } = projectFromCursorPath(filePath);
|
|
2018
|
-
const sessionId =
|
|
2299
|
+
const sessionId = basename6(filePath, ".jsonl");
|
|
2019
2300
|
return {
|
|
2020
2301
|
id: filePath,
|
|
2021
2302
|
filePath,
|
|
@@ -2025,7 +2306,7 @@ async function parseCursorConversation(filePath, account) {
|
|
|
2025
2306
|
sessionName: "",
|
|
2026
2307
|
messages,
|
|
2027
2308
|
fullText: textParts.join(" "),
|
|
2028
|
-
timestamp: latestTimestamp ||
|
|
2309
|
+
timestamp: latestTimestamp || fileMtimeIso2(filePath),
|
|
2029
2310
|
messageCount: messages.length,
|
|
2030
2311
|
account,
|
|
2031
2312
|
lastPrompt: lastUserText || void 0
|
|
@@ -2033,13 +2314,13 @@ async function parseCursorConversation(filePath, account) {
|
|
|
2033
2314
|
}
|
|
2034
2315
|
|
|
2035
2316
|
// src/providers/parse.ts
|
|
2036
|
-
import { createReadStream as
|
|
2037
|
-
import { createInterface as
|
|
2317
|
+
import { createReadStream as createReadStream7 } from "fs";
|
|
2318
|
+
import { createInterface as createInterface5 } from "readline";
|
|
2038
2319
|
async function parseMetaWithProvider(provider, filePath, account, tier, onEntry) {
|
|
2039
2320
|
const log = getLogger();
|
|
2040
2321
|
const acc = provider.createEmptyAccumulator();
|
|
2041
|
-
const rl =
|
|
2042
|
-
input:
|
|
2322
|
+
const rl = createInterface5({
|
|
2323
|
+
input: createReadStream7(filePath),
|
|
2043
2324
|
crlfDelay: Infinity
|
|
2044
2325
|
});
|
|
2045
2326
|
try {
|
|
@@ -2112,8 +2393,17 @@ function extractSearchDelta(entry) {
|
|
|
2112
2393
|
if (looksLikeCursorChatEntry(entry)) {
|
|
2113
2394
|
return extractCursorDelta(entry);
|
|
2114
2395
|
}
|
|
2396
|
+
if (looksLikeCopilotEvent(entry)) {
|
|
2397
|
+
return extractCopilotDelta(entry);
|
|
2398
|
+
}
|
|
2115
2399
|
return extractClaudeDelta(entry);
|
|
2116
2400
|
}
|
|
2401
|
+
function extractCopilotDelta(entry) {
|
|
2402
|
+
const message = parseCopilotJsonlLine(JSON.stringify(entry));
|
|
2403
|
+
if (!message) return emptySearchDocument();
|
|
2404
|
+
const tools = (message.metadata?.toolUseBlocks ?? []).map((block) => capToolPayload(block.input)).filter(Boolean).join(SEP);
|
|
2405
|
+
return { text: message.text, thinking: "", tools };
|
|
2406
|
+
}
|
|
2117
2407
|
function extractCursorDelta(entry) {
|
|
2118
2408
|
const msg = entry.message;
|
|
2119
2409
|
const content = msg?.content ?? entry.content;
|
|
@@ -2255,7 +2545,7 @@ function resolveTier(tierName, customTiers) {
|
|
|
2255
2545
|
// src/persistent/db.ts
|
|
2256
2546
|
import Database from "better-sqlite3";
|
|
2257
2547
|
import { mkdirSync } from "fs";
|
|
2258
|
-
import { dirname as
|
|
2548
|
+
import { dirname as dirname5 } from "path";
|
|
2259
2549
|
|
|
2260
2550
|
// src/persistent/schema.ts
|
|
2261
2551
|
var SCHEMA_VERSION = 10;
|
|
@@ -2580,7 +2870,7 @@ function hasColumn(db, table, column) {
|
|
|
2580
2870
|
// src/persistent/db.ts
|
|
2581
2871
|
function openDatabase(dbPath) {
|
|
2582
2872
|
if (dbPath !== ":memory:") {
|
|
2583
|
-
mkdirSync(
|
|
2873
|
+
mkdirSync(dirname5(dbPath), { recursive: true });
|
|
2584
2874
|
}
|
|
2585
2875
|
let db;
|
|
2586
2876
|
try {
|
|
@@ -2624,8 +2914,8 @@ function nativeBindingError(err, dbPath) {
|
|
|
2624
2914
|
}
|
|
2625
2915
|
|
|
2626
2916
|
// src/persistent/dir-watermark.ts
|
|
2627
|
-
import { readdir, stat as
|
|
2628
|
-
import { dirname as
|
|
2917
|
+
import { readdir, stat as stat5 } from "fs/promises";
|
|
2918
|
+
import { dirname as dirname6, join as join5 } from "path";
|
|
2629
2919
|
var FULL_RECONCILE_EVERY_N_SCANS = 20;
|
|
2630
2920
|
async function discoverJsonlFilesGated(dirs, files, scannedDirs, options = {}) {
|
|
2631
2921
|
const log = getLogger();
|
|
@@ -2641,7 +2931,7 @@ async function discoverJsonlFilesGated(dirs, files, scannedDirs, options = {}) {
|
|
|
2641
2931
|
for (const projectDir of resolved.entries) {
|
|
2642
2932
|
let dirStat;
|
|
2643
2933
|
try {
|
|
2644
|
-
dirStat = await
|
|
2934
|
+
dirStat = await stat5(projectDir);
|
|
2645
2935
|
} catch {
|
|
2646
2936
|
scannedDirs.remove(projectDir);
|
|
2647
2937
|
continue;
|
|
@@ -2679,7 +2969,7 @@ async function discoverJsonlFilesGated(dirs, files, scannedDirs, options = {}) {
|
|
|
2679
2969
|
async function resolveProjectDirs(projectsDir, scannedDirs) {
|
|
2680
2970
|
let rootStat;
|
|
2681
2971
|
try {
|
|
2682
|
-
rootStat = await
|
|
2972
|
+
rootStat = await stat5(projectsDir);
|
|
2683
2973
|
} catch {
|
|
2684
2974
|
return null;
|
|
2685
2975
|
}
|
|
@@ -2696,7 +2986,7 @@ async function resolveProjectDirs(projectsDir, scannedDirs) {
|
|
|
2696
2986
|
return { entries, commitRoot: { mtimeMs: rootStat.mtimeMs } };
|
|
2697
2987
|
}
|
|
2698
2988
|
function dirnameOf(filePath) {
|
|
2699
|
-
return
|
|
2989
|
+
return dirname6(filePath);
|
|
2700
2990
|
}
|
|
2701
2991
|
function joinPath(dir, name) {
|
|
2702
2992
|
return join5(dir, name);
|
|
@@ -2779,7 +3069,7 @@ function toCheckpoint(row) {
|
|
|
2779
3069
|
}
|
|
2780
3070
|
|
|
2781
3071
|
// src/persistent/repositories/conversation-files.repo.ts
|
|
2782
|
-
import { basename as
|
|
3072
|
+
import { basename as basename7, dirname as dirname7 } from "path";
|
|
2783
3073
|
var ConversationFilesRepo = class {
|
|
2784
3074
|
constructor(db) {
|
|
2785
3075
|
this.db = db;
|
|
@@ -2802,7 +3092,7 @@ var ConversationFilesRepo = class {
|
|
|
2802
3092
|
const info = this.db.prepare(
|
|
2803
3093
|
`INSERT INTO conversation_files (absolute_path, parent_dir, file_name, account)
|
|
2804
3094
|
VALUES (?, ?, ?, ?)`
|
|
2805
|
-
).run(canonical,
|
|
3095
|
+
).run(canonical, dirname7(canonical), basename7(canonical), account);
|
|
2806
3096
|
return Number(info.lastInsertRowid);
|
|
2807
3097
|
}
|
|
2808
3098
|
// Advance the cursor + persisted reducer state after a successful index pass.
|
|
@@ -3352,6 +3642,12 @@ var PersistentEngine = class {
|
|
|
3352
3642
|
discovered.push({ ...f, provider: cursor });
|
|
3353
3643
|
}
|
|
3354
3644
|
}
|
|
3645
|
+
const copilot = new CopilotProvider();
|
|
3646
|
+
if (enabled.includes(COPILOT_PROVIDER) && (options.copilotRoots?.length ?? 0) > 0) {
|
|
3647
|
+
for (const f of await copilot.discover(options.copilotRoots)) {
|
|
3648
|
+
discovered.push({ ...f, provider: copilot });
|
|
3649
|
+
}
|
|
3650
|
+
}
|
|
3355
3651
|
let scanned = 0;
|
|
3356
3652
|
const gitBranchMemo = /* @__PURE__ */ new Map();
|
|
3357
3653
|
const resolveGitBranch = (projectPath) => {
|
|
@@ -3393,6 +3689,9 @@ var PersistentEngine = class {
|
|
|
3393
3689
|
if (enabled.includes(CURSOR_PROVIDER) && (options.cursorRoots?.length ?? 0) > 0) {
|
|
3394
3690
|
coveredAccounts.add("cursor");
|
|
3395
3691
|
}
|
|
3692
|
+
if (enabled.includes(COPILOT_PROVIDER) && (options.copilotRoots?.length ?? 0) > 0) {
|
|
3693
|
+
coveredAccounts.add("copilot");
|
|
3694
|
+
}
|
|
3396
3695
|
const seen = new Set(discovered.map((d) => canonicalPath(d.filePath)));
|
|
3397
3696
|
for (const path of this.files.activePathsByAccounts([...coveredAccounts])) {
|
|
3398
3697
|
if (!seen.has(path)) this.markDeleted(path);
|
|
@@ -3412,8 +3711,8 @@ var PersistentEngine = class {
|
|
|
3412
3711
|
const tier = resolveTier(tierName, customTiers);
|
|
3413
3712
|
const filePath = canonicalPath(rawFilePath);
|
|
3414
3713
|
const existing = this.files.getByPath(filePath);
|
|
3415
|
-
const { change, stat:
|
|
3416
|
-
if (change === "vanished" || !
|
|
3714
|
+
const { change, stat: stat6 } = classify(filePath, existing);
|
|
3715
|
+
if (change === "vanished" || !stat6) {
|
|
3417
3716
|
this.markDeleted(filePath);
|
|
3418
3717
|
return { meta: null, change: "vanished" };
|
|
3419
3718
|
}
|
|
@@ -3426,7 +3725,7 @@ var PersistentEngine = class {
|
|
|
3426
3725
|
filePath,
|
|
3427
3726
|
account,
|
|
3428
3727
|
tier,
|
|
3429
|
-
|
|
3728
|
+
stat6,
|
|
3430
3729
|
resolveGitBranch
|
|
3431
3730
|
);
|
|
3432
3731
|
return { meta: meta2, change };
|
|
@@ -3452,7 +3751,7 @@ var PersistentEngine = class {
|
|
|
3452
3751
|
return { meta: null, change };
|
|
3453
3752
|
}
|
|
3454
3753
|
meta.gitBranch = resolveGitBranch(meta.projectPath);
|
|
3455
|
-
const fp =
|
|
3754
|
+
const fp = stat6.size > 0 ? fingerprint(filePath, stat6.size) : null;
|
|
3456
3755
|
const fileId = this.files.ensure(filePath, account);
|
|
3457
3756
|
const base = resume ? this.fts.readDocument(fileId) ?? emptySearchDocument() : emptySearchDocument();
|
|
3458
3757
|
const searchDoc = appendSearchDelta(base, searchDelta);
|
|
@@ -3463,8 +3762,8 @@ var PersistentEngine = class {
|
|
|
3463
3762
|
}
|
|
3464
3763
|
if (!resume) this.checkpoints.remove(filePath);
|
|
3465
3764
|
this.files.updateCursor(fileId, {
|
|
3466
|
-
sizeBytes:
|
|
3467
|
-
mtimeMs:
|
|
3765
|
+
sizeBytes: stat6.size,
|
|
3766
|
+
mtimeMs: stat6.mtimeMs,
|
|
3468
3767
|
// Advance only to the last fully-parsed line; a trailing partial line
|
|
3469
3768
|
// is left for the next pass.
|
|
3470
3769
|
offset: result.newOffset,
|
|
@@ -3481,8 +3780,8 @@ var PersistentEngine = class {
|
|
|
3481
3780
|
buildSidecar(
|
|
3482
3781
|
meta,
|
|
3483
3782
|
{
|
|
3484
|
-
sizeBytes:
|
|
3485
|
-
mtimeMs:
|
|
3783
|
+
sizeBytes: stat6.size,
|
|
3784
|
+
mtimeMs: stat6.mtimeMs,
|
|
3486
3785
|
offset: result.newOffset,
|
|
3487
3786
|
line: result.newLine
|
|
3488
3787
|
},
|
|
@@ -3501,7 +3800,7 @@ var PersistentEngine = class {
|
|
|
3501
3800
|
// the Threadbase path uses. The cursor records size/mtime (and offset = size)
|
|
3502
3801
|
// so the next pass classifies an unchanged file as "unchanged" and skips it;
|
|
3503
3802
|
// any change reparses from 0 again. No reducer_state is persisted.
|
|
3504
|
-
async indexFileWithProvider(provider, filePath, account, tier,
|
|
3803
|
+
async indexFileWithProvider(provider, filePath, account, tier, stat6, resolveGitBranch) {
|
|
3505
3804
|
const log = getLogger();
|
|
3506
3805
|
let searchDoc = emptySearchDocument();
|
|
3507
3806
|
const meta = await parseMetaWithProvider(provider, filePath, account, tier, (entry) => {
|
|
@@ -3514,7 +3813,7 @@ var PersistentEngine = class {
|
|
|
3514
3813
|
if (meta.gitBranch === null && meta.projectPath) {
|
|
3515
3814
|
meta.gitBranch = resolveGitBranch(meta.projectPath);
|
|
3516
3815
|
}
|
|
3517
|
-
const fp =
|
|
3816
|
+
const fp = stat6.size > 0 ? fingerprint(filePath, stat6.size) : null;
|
|
3518
3817
|
const fileId = this.files.ensure(filePath, account);
|
|
3519
3818
|
const upsert = this.db.transaction(() => {
|
|
3520
3819
|
this.conversations.upsert(fileId, meta, meta.messageCount);
|
|
@@ -3523,11 +3822,11 @@ var PersistentEngine = class {
|
|
|
3523
3822
|
}
|
|
3524
3823
|
this.checkpoints.remove(filePath);
|
|
3525
3824
|
this.files.updateCursor(fileId, {
|
|
3526
|
-
sizeBytes:
|
|
3527
|
-
mtimeMs:
|
|
3825
|
+
sizeBytes: stat6.size,
|
|
3826
|
+
mtimeMs: stat6.mtimeMs,
|
|
3528
3827
|
// offset = size marks the file fully consumed (non-zero so the next pass
|
|
3529
3828
|
// can classify it "unchanged"); no resumable reducer state is kept.
|
|
3530
|
-
offset:
|
|
3829
|
+
offset: stat6.size,
|
|
3531
3830
|
line: 0,
|
|
3532
3831
|
reducerState: null,
|
|
3533
3832
|
fingerprint: fp,
|
|
@@ -3593,8 +3892,8 @@ var PersistentEngine = class {
|
|
|
3593
3892
|
const meta = this.conversations.getByIdOrSession(id);
|
|
3594
3893
|
if (!meta) return null;
|
|
3595
3894
|
const filePath = meta.filePath;
|
|
3596
|
-
if (meta.provider === CODEX_CLI_PROVIDER || meta.provider === CURSOR_PROVIDER) {
|
|
3597
|
-
const conversation = meta.provider === CODEX_CLI_PROVIDER ? await parseCodexConversation(filePath, meta.account) : await parseCursorConversation(filePath, meta.account);
|
|
3895
|
+
if (meta.provider === CODEX_CLI_PROVIDER || meta.provider === CURSOR_PROVIDER || meta.provider === COPILOT_PROVIDER) {
|
|
3896
|
+
const conversation = meta.provider === CODEX_CLI_PROVIDER ? await parseCodexConversation(filePath, meta.account) : meta.provider === CURSOR_PROVIDER ? await parseCursorConversation(filePath, meta.account) : await parseCopilotConversation(filePath, meta.account);
|
|
3598
3897
|
if (!conversation) return null;
|
|
3599
3898
|
const { messages } = conversation;
|
|
3600
3899
|
const total2 = messages.length;
|
|
@@ -3609,7 +3908,7 @@ var PersistentEngine = class {
|
|
|
3609
3908
|
let floor = this.checkpoints.floor(filePath, fromIndex);
|
|
3610
3909
|
if (floor) {
|
|
3611
3910
|
try {
|
|
3612
|
-
if (floor.byteOffset >
|
|
3911
|
+
if (floor.byteOffset > statSync4(filePath).size) floor = null;
|
|
3613
3912
|
} catch {
|
|
3614
3913
|
}
|
|
3615
3914
|
}
|
|
@@ -3963,7 +4262,7 @@ var ConversationScanner = class {
|
|
|
3963
4262
|
const cached = statCache.get(filePath);
|
|
3964
4263
|
if (cached) {
|
|
3965
4264
|
try {
|
|
3966
|
-
const s =
|
|
4265
|
+
const s = statSync5(filePath);
|
|
3967
4266
|
if (s.mtimeMs === cached.stat.mtimeMs && s.size === cached.stat.size) {
|
|
3968
4267
|
return {
|
|
3969
4268
|
meta: cached.meta,
|
|
@@ -4121,12 +4420,12 @@ var ConversationScanner = class {
|
|
|
4121
4420
|
}
|
|
4122
4421
|
log.debug({ id, filePath: meta.filePath }, "getConversation: cache miss, parsing");
|
|
4123
4422
|
try {
|
|
4124
|
-
if (this.persistent && meta.provider !== CODEX_CLI_PROVIDER && meta.provider !== CURSOR_PROVIDER) {
|
|
4423
|
+
if (this.persistent && meta.provider !== CODEX_CLI_PROVIDER && meta.provider !== CURSOR_PROVIDER && meta.provider !== COPILOT_PROVIDER) {
|
|
4125
4424
|
const parsed = await parseConversationResumable(meta.filePath, meta.account);
|
|
4126
4425
|
if (parsed) this.conversationLRU.set(cid, parsed);
|
|
4127
4426
|
return parsed?.conversation ?? null;
|
|
4128
4427
|
}
|
|
4129
|
-
const conversation = meta.provider === CODEX_CLI_PROVIDER ? await parseCodexConversation(meta.filePath, meta.account) : meta.provider === CURSOR_PROVIDER ? await parseCursorConversation(meta.filePath, meta.account) : await parseConversation(meta.filePath, meta.account);
|
|
4428
|
+
const conversation = meta.provider === CODEX_CLI_PROVIDER ? await parseCodexConversation(meta.filePath, meta.account) : meta.provider === CURSOR_PROVIDER ? await parseCursorConversation(meta.filePath, meta.account) : meta.provider === COPILOT_PROVIDER ? await parseCopilotConversation(meta.filePath, meta.account) : await parseConversation(meta.filePath, meta.account);
|
|
4130
4429
|
if (conversation) {
|
|
4131
4430
|
this.conversationLRU.set(cid, { conversation });
|
|
4132
4431
|
}
|
|
@@ -4180,7 +4479,7 @@ var ConversationScanner = class {
|
|
|
4180
4479
|
// fallback, matching refreshFile.
|
|
4181
4480
|
async parseSingleFilePage(filePath, account, options) {
|
|
4182
4481
|
const provider = await this.resolveProviderForFile(filePath, null);
|
|
4183
|
-
const conversation = provider?.name === CODEX_CLI_PROVIDER ? await parseCodexConversation(filePath, account ?? "default") : provider?.name === CURSOR_PROVIDER ? await parseCursorConversation(filePath, account ?? "default") : await parseConversation(filePath, account ?? "default");
|
|
4482
|
+
const conversation = provider?.name === CODEX_CLI_PROVIDER ? await parseCodexConversation(filePath, account ?? "default") : provider?.name === CURSOR_PROVIDER ? await parseCursorConversation(filePath, account ?? "default") : provider?.name === COPILOT_PROVIDER ? await parseCopilotConversation(filePath, account ?? "default") : await parseConversation(filePath, account ?? "default");
|
|
4184
4483
|
if (!conversation) return null;
|
|
4185
4484
|
const { messages } = conversation;
|
|
4186
4485
|
const total = messages.length;
|
|
@@ -4490,6 +4789,12 @@ var ConversationScanner = class {
|
|
|
4490
4789
|
work.push({ ...f, provider });
|
|
4491
4790
|
}
|
|
4492
4791
|
}
|
|
4792
|
+
if (enabled.includes(COPILOT_PROVIDER) && (options.copilotRoots?.length ?? 0) > 0) {
|
|
4793
|
+
const provider = new CopilotProvider();
|
|
4794
|
+
for (const f of await provider.discover(options.copilotRoots)) {
|
|
4795
|
+
work.push({ ...f, provider });
|
|
4796
|
+
}
|
|
4797
|
+
}
|
|
4493
4798
|
return work;
|
|
4494
4799
|
}
|
|
4495
4800
|
// Resolve which provider should (re)parse a file. Stored metadata wins; for a
|
|
@@ -4501,6 +4806,7 @@ var ConversationScanner = class {
|
|
|
4501
4806
|
if (providerMatches(previous?.provider, CURSOR_PROVIDER)) {
|
|
4502
4807
|
return new CursorProvider();
|
|
4503
4808
|
}
|
|
4809
|
+
if (previous?.provider === COPILOT_PROVIDER) return new CopilotProvider();
|
|
4504
4810
|
if (previous?.provider) return void 0;
|
|
4505
4811
|
let sample = "";
|
|
4506
4812
|
try {
|
|
@@ -4519,6 +4825,8 @@ var ConversationScanner = class {
|
|
|
4519
4825
|
if (cursor.canParse(filePath, sample)) return cursor;
|
|
4520
4826
|
const codex = new CodexCliProvider();
|
|
4521
4827
|
if (codex.canParse(filePath, sample)) return codex;
|
|
4828
|
+
const copilot = new CopilotProvider();
|
|
4829
|
+
if (copilot.canParse(filePath, sample)) return copilot;
|
|
4522
4830
|
return void 0;
|
|
4523
4831
|
}
|
|
4524
4832
|
addToSessionIndex(meta) {
|