@threadbase-sh/scanner 0.24.7 → 0.25.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/dist/index.cjs CHANGED
@@ -756,203 +756,7 @@ function nameStoreSlotsFor(provider, filePath, sessionId) {
756
756
  }
757
757
  }
758
758
 
759
- // src/parser.ts
760
- var import_fs3 = require("fs");
761
- var import_path4 = require("path");
762
- var import_readline = require("readline");
763
-
764
- // src/persistent/metadata-reducer.ts
765
- var import_path3 = require("path");
766
-
767
- // src/providers/provider.ts
768
- var CLAUDE_CODE_PROVIDER = "claude-code";
769
- var CODEX_CLI_PROVIDER = "codex-cli";
770
- var CURSOR_PROVIDER = "cursor";
771
- var COPILOT_PROVIDER = "copilot";
772
- var LEGACY_CURSOR_PROVIDER = "cursor-cli";
773
- function canonicalizeProviderName(value) {
774
- if (value === LEGACY_CURSOR_PROVIDER) return CURSOR_PROVIDER;
775
- if (value === CLAUDE_CODE_PROVIDER || value === CODEX_CLI_PROVIDER || value === CURSOR_PROVIDER || value === COPILOT_PROVIDER) {
776
- return value;
777
- }
778
- return void 0;
779
- }
780
- function canonicalizeProviderList(providers) {
781
- const src = providers ?? [CLAUDE_CODE_PROVIDER];
782
- const out = [];
783
- for (const p of src) {
784
- const n = canonicalizeProviderName(p);
785
- if (n && !out.includes(n)) out.push(n);
786
- }
787
- return out;
788
- }
789
- function providerMatches(stored, wanted) {
790
- const a = canonicalizeProviderName(stored ?? CLAUDE_CODE_PROVIDER) ?? stored;
791
- const b = canonicalizeProviderName(wanted) ?? wanted;
792
- return a === b;
793
- }
794
-
795
- // src/persistent/claude-name-slots.ts
796
- function userPromptText(entry) {
797
- if (entry.isMeta || entry.isCompactSummary === true) return "";
798
- const content = entry.message?.content;
799
- if (typeof content === "string") return content;
800
- if (!Array.isArray(content)) return "";
801
- return content.map((b) => typeof b === "string" ? b : b?.type === "text" ? b.text : "").filter((t) => typeof t === "string" && t !== "").join(" ");
802
- }
803
- function applyClaudeNameEntry(slots, entry) {
804
- const apply = (slot, raw) => applyNameCandidate(slots, slot, typeof raw === "string" ? raw : void 0, "claude-code");
805
- if (entry.slug !== slots.slug) slots = apply("slug", entry.slug);
806
- switch (entry.type) {
807
- case "custom-title":
808
- return apply("userTitle", entry.customTitle);
809
- case "ai-title":
810
- return apply("toolTitle", entry.aiTitle);
811
- case "last-prompt":
812
- return apply("lastPrompt", entry.lastPrompt);
813
- case "user":
814
- return slots.firstUserMessage === void 0 ? apply("firstUserMessage", userPromptText(entry)) : slots;
815
- default:
816
- return slots;
817
- }
818
- }
819
-
820
- // src/persistent/metadata-reducer.ts
821
- function initialReducerState() {
822
- return {
823
- sessionId: "",
824
- nameSlots: {},
825
- latestTimestamp: "",
826
- cwd: "",
827
- teamName: "",
828
- model: null,
829
- messageCount: 0,
830
- lastMessageSender: "user",
831
- agentId: "",
832
- isSidechain: false,
833
- firstMessage: null,
834
- lastMessage: null,
835
- lastPrompt: "",
836
- pageMessageCount: 0,
837
- toolNames: [],
838
- previewParts: [],
839
- snippetParts: [],
840
- previewLength: 0,
841
- snippetLength: 0,
842
- badJsonLines: 0,
843
- turnDurations: []
844
- };
845
- }
846
- function reduceLine(state, rawEntry, tier) {
847
- const entry = asQueuedPromptUserEntry(rawEntry);
848
- if (entry.cwd && !state.cwd) state.cwd = entry.cwd;
849
- if (entry.sessionId && !state.sessionId) state.sessionId = entry.sessionId;
850
- state.nameSlots = applyClaudeNameEntry(state.nameSlots, entry);
851
- if (entry.teamName && !state.teamName) state.teamName = entry.teamName;
852
- if (entry.agentId && !state.agentId) state.agentId = entry.agentId;
853
- if (entry.isSidechain === true) state.isSidechain = true;
854
- if (entry.timestamp) {
855
- const ts = entry.timestamp;
856
- if (!state.latestTimestamp || ts > state.latestTimestamp) state.latestTimestamp = ts;
857
- }
858
- const turnDuration = turnDurationOf(entry);
859
- if (turnDuration) state.turnDurations?.push(turnDuration);
860
- const type = entry.type;
861
- if (type === "last-prompt") {
862
- if (entry.lastPrompt && !state.lastPrompt) state.lastPrompt = entry.lastPrompt;
863
- return;
864
- }
865
- if (type !== "user" && type !== "assistant") return;
866
- if (entry.isMeta) return;
867
- const msg = entry.message;
868
- if (entry.isCompactSummary === true) {
869
- if (extractTextContent(msg?.content)) state.pageMessageCount++;
870
- return;
871
- }
872
- if (state.model === null && msg?.model) state.model = msg.model;
873
- const content = extractTextContent(msg?.content);
874
- const hasToolUseResult = type === "user" && entry.toolUseResult != null;
875
- const isOnlyToolResult = hasToolUseResult && isOnlyToolResultContent(msg?.content);
876
- const toolSet = new Set(state.toolNames);
877
- collectToolNames(msg?.content, toolSet);
878
- state.toolNames = Array.from(toolSet);
879
- const toolUseBlocks = extractToolUseBlocks(msg?.content);
880
- const thinking = type === "assistant" ? extractThinking(msg?.content) : null;
881
- const hasThinking = !!(thinking?.content || thinking?.signature);
882
- if (content || isOnlyToolResult || toolUseBlocks.length > 0 || hasThinking) {
883
- state.pageMessageCount++;
884
- }
885
- if (content || isOnlyToolResult) {
886
- state.messageCount++;
887
- state.lastMessageSender = type;
888
- if (content) {
889
- const ts = entry.timestamp || "";
890
- if (!state.firstMessage) state.firstMessage = { text: content.slice(0, 200), timestamp: ts };
891
- state.lastMessage = { text: content.slice(0, 200), timestamp: ts };
892
- if (state.previewLength < tier.previewMax) {
893
- state.previewParts.push(content);
894
- state.previewLength += content.length;
895
- }
896
- if (state.snippetLength < tier.snippetMax) {
897
- const remaining = tier.snippetMax - state.snippetLength;
898
- const chunk = content.length > remaining ? content.slice(0, remaining) : content;
899
- state.snippetParts.push(chunk);
900
- state.snippetLength += chunk.length;
901
- }
902
- }
903
- }
904
- }
905
- function finalizeMeta(state, filePath, account, tier) {
906
- if (state.messageCount === 0) return null;
907
- const isSidechain = state.isSidechain && !!state.agentId;
908
- const isSubagentPath = SUBAGENT_PATH_RE.test(filePath);
909
- const isSubagent = isSidechain || isSubagentPath;
910
- let parentSessionId = null;
911
- if (isSubagentPath) {
912
- const uuidDir = (0, import_path3.dirname)((0, import_path3.dirname)(filePath));
913
- parentSessionId = (0, import_path3.join)((0, import_path3.dirname)(uuidDir), `${(0, import_path3.basename)(uuidDir)}.jsonl`);
914
- }
915
- const projectPath = state.cwd;
916
- return {
917
- id: filePath,
918
- filePath,
919
- provider: CLAUDE_CODE_PROVIDER,
920
- sessionId: state.sessionId || (0, import_path3.basename)(filePath, ".jsonl"),
921
- sessionName: resolveSessionName(state.nameSlots).name ?? "",
922
- nameSlots: state.nameSlots,
923
- projectPath,
924
- projectName: getShortProjectName(projectPath),
925
- account,
926
- timestamp: state.latestTimestamp || (/* @__PURE__ */ new Date()).toISOString(),
927
- messageCount: state.messageCount,
928
- lastMessageSender: state.lastMessageSender,
929
- preview: state.previewParts.join(" ").slice(0, tier.previewMax),
930
- contentSnippet: state.snippetParts.join(" "),
931
- gitBranch: null,
932
- model: state.model,
933
- isSubagent,
934
- parentSessionId,
935
- subagentId: isSidechain ? state.agentId : void 0,
936
- // A sidechain line's `sessionId` IS the parent's id — that is exactly the
937
- // conflation `subagentId` exists to undo, so it is the parent UUID here.
938
- parentSessionUuid: isSidechain && state.sessionId ? state.sessionId : void 0,
939
- // A teammate's records carry teamName; the lead's never do, yet the lead
940
- // receives <teammate-message> tags too, so the tag is not the discriminator.
941
- isTeammate: Boolean(state.teamName),
942
- teamName: state.teamName || null,
943
- toolNames: state.toolNames,
944
- firstMessage: state.firstMessage,
945
- lastMessage: state.lastMessage,
946
- lastPrompt: state.lastPrompt || void 0
947
- };
948
- }
949
- var SUBAGENT_PATH_RE = /[\\/]subagents[\\/]/;
950
- function getShortProjectName(fullPath) {
951
- const parts = fullPath.split("/").filter(Boolean);
952
- return parts.slice(-3).join("/");
953
- }
954
-
955
- // src/parser.ts
759
+ // src/parse-helpers.ts
956
760
  function asQueuedPromptUserEntry(entry) {
957
761
  if (entry.type !== "attachment") return entry;
958
762
  const att = entry.attachment;
@@ -965,109 +769,6 @@ function asQueuedPromptUserEntry(entry) {
965
769
  message: { role: "user", content: att.prompt }
966
770
  };
967
771
  }
968
- function turnDurationOf(entry) {
969
- if (entry.type !== "system" || entry.subtype !== "turn_duration" || typeof entry.durationMs !== "number") {
970
- return null;
971
- }
972
- return {
973
- durationMs: entry.durationMs,
974
- messageCount: entry.messageCount || 0,
975
- uuid: entry.uuid
976
- };
977
- }
978
- async function parseMeta(filePath, account, tier, onEntry) {
979
- const log = getLogger();
980
- log.trace({ filePath, account, tier: tier.name }, "parseMeta: start");
981
- const state = initialReducerState();
982
- const fileStream = (0, import_fs3.createReadStream)(filePath);
983
- const rl = (0, import_readline.createInterface)({ input: fileStream, crlfDelay: Infinity });
984
- try {
985
- for await (const line of rl) {
986
- if (!line.trim()) continue;
987
- let entry;
988
- try {
989
- entry = JSON.parse(line);
990
- } catch {
991
- state.badJsonLines++;
992
- continue;
993
- }
994
- reduceLine(state, entry, tier);
995
- onEntry?.(entry);
996
- }
997
- } catch (err) {
998
- log.warn({ filePath, err }, "parseMeta: read failed");
999
- return null;
1000
- }
1001
- if (state.badJsonLines > 0) {
1002
- log.warn(
1003
- { filePath, badJsonLines: state.badJsonLines },
1004
- "parseMeta: skipped malformed JSON lines"
1005
- );
1006
- }
1007
- const meta = finalizeMeta(state, filePath, account, tier);
1008
- if (!meta) log.trace({ filePath }, "parseMeta: no messages");
1009
- return meta;
1010
- }
1011
- async function parseConversation(filePath, account) {
1012
- const log = getLogger();
1013
- log.trace({ filePath, account }, "parseConversation: start");
1014
- const messages = [];
1015
- let badJsonLines = 0;
1016
- const textParts = [];
1017
- const turnDurations = [];
1018
- const state = initialConvState();
1019
- const fileStream = (0, import_fs3.createReadStream)(filePath);
1020
- const rl = (0, import_readline.createInterface)({ input: fileStream, crlfDelay: Infinity });
1021
- try {
1022
- for await (const line of rl) {
1023
- if (!line.trim()) continue;
1024
- let entry;
1025
- try {
1026
- entry = JSON.parse(line);
1027
- } catch {
1028
- badJsonLines++;
1029
- continue;
1030
- }
1031
- const turnDuration = turnDurationOf(entry);
1032
- if (turnDuration) {
1033
- turnDurations.push(turnDuration);
1034
- continue;
1035
- }
1036
- const message = reduceConvLine(state, entry);
1037
- if (message) {
1038
- messages.push(message);
1039
- if (message.text && !message.isCompactSummary) textParts.push(message.text);
1040
- }
1041
- }
1042
- } catch (err) {
1043
- log.warn({ filePath, err }, "parseConversation: read failed");
1044
- return null;
1045
- }
1046
- if (badJsonLines > 0) {
1047
- log.warn({ filePath, badJsonLines }, "parseConversation: skipped malformed JSON lines");
1048
- }
1049
- if (messages.length === 0) {
1050
- log.trace({ filePath }, "parseConversation: no messages");
1051
- return null;
1052
- }
1053
- log.debug({ filePath, messageCount: messages.length }, "parseConversation: complete");
1054
- applyTeamInfo(messages, state);
1055
- return {
1056
- id: filePath,
1057
- filePath,
1058
- projectPath: state.cwd,
1059
- projectName: getShortProjectName2(state.cwd),
1060
- sessionId: state.sessionId || (0, import_path4.basename)(filePath, ".jsonl"),
1061
- sessionName: resolveSessionName(state.nameSlots).name ?? "",
1062
- messages,
1063
- fullText: textParts.join(" "),
1064
- timestamp: state.latestTimestamp || (/* @__PURE__ */ new Date()).toISOString(),
1065
- messageCount: messages.length,
1066
- account,
1067
- turnDurations: turnDurations.length > 0 ? turnDurations : void 0,
1068
- lastPrompt: state.lastPrompt || void 0
1069
- };
1070
- }
1071
772
  function extractTextContent(content) {
1072
773
  if (!content) return "";
1073
774
  if (typeof content === "string") return cleanSystemTags(content);
@@ -1116,14 +817,6 @@ function extractToolResultBlocks(content, pendingToolUses) {
1116
817
  };
1117
818
  });
1118
819
  }
1119
- function collectToolNames(content, toolSet) {
1120
- if (!Array.isArray(content)) return;
1121
- for (const item of content) {
1122
- if (item?.type === "tool_use" && item?.name) {
1123
- toolSet.add(item.name);
1124
- }
1125
- }
1126
- }
1127
820
  function isOnlyToolResultContent(content) {
1128
821
  if (!Array.isArray(content)) return false;
1129
822
  return content.length > 0 && content.every((item) => item?.type === "tool_result");
@@ -1152,9 +845,30 @@ function parseTeammateMessageTag(content) {
1152
845
  const color = attrs.match(/color="([^"]*)"/)?.[1];
1153
846
  return { teammateId: id, summary, color };
1154
847
  }
1155
- function getShortProjectName2(fullPath) {
1156
- const parts = fullPath.split("/").filter(Boolean);
1157
- return parts.slice(-3).join("/");
848
+
849
+ // src/persistent/claude-name-slots.ts
850
+ function userPromptText(entry) {
851
+ if (entry.isMeta || entry.isCompactSummary === true) return "";
852
+ const content = entry.message?.content;
853
+ if (typeof content === "string") return content;
854
+ if (!Array.isArray(content)) return "";
855
+ return content.map((b) => typeof b === "string" ? b : b?.type === "text" ? b.text : "").filter((t) => typeof t === "string" && t !== "").join(" ");
856
+ }
857
+ function applyClaudeNameEntry(slots, entry) {
858
+ const apply = (slot, raw) => applyNameCandidate(slots, slot, typeof raw === "string" ? raw : void 0, "claude-code");
859
+ if (entry.slug !== slots.slug) slots = apply("slug", entry.slug);
860
+ switch (entry.type) {
861
+ case "custom-title":
862
+ return apply("userTitle", entry.customTitle);
863
+ case "ai-title":
864
+ return apply("toolTitle", entry.aiTitle);
865
+ case "last-prompt":
866
+ return apply("lastPrompt", entry.lastPrompt);
867
+ case "user":
868
+ return slots.firstUserMessage === void 0 ? apply("firstUserMessage", userPromptText(entry)) : slots;
869
+ default:
870
+ return slots;
871
+ }
1158
872
  }
1159
873
 
1160
874
  // src/persistent/conversation-reducer.ts
@@ -1281,7 +995,7 @@ function applyTeamInfo(messages, state) {
1281
995
  }
1282
996
 
1283
997
  // src/persistent/sidecar.ts
1284
- var import_fs4 = require("fs");
998
+ var import_fs3 = require("fs");
1285
999
  var SIDECAR_VERSION = 1;
1286
1000
  function sidecarPath(jsonlPath) {
1287
1001
  return `${jsonlPath}.idx.json`;
@@ -1307,14 +1021,14 @@ function buildSidecar(meta, cursor, updatedAt) {
1307
1021
  }
1308
1022
  function writeSidecar(jsonlPath, sidecar) {
1309
1023
  try {
1310
- (0, import_fs4.writeFileSync)(sidecarPath(jsonlPath), JSON.stringify(sidecar, null, 2));
1024
+ (0, import_fs3.writeFileSync)(sidecarPath(jsonlPath), JSON.stringify(sidecar, null, 2));
1311
1025
  } catch (err) {
1312
1026
  getLogger().warn({ jsonlPath, err }, "sidecar: write failed");
1313
1027
  }
1314
1028
  }
1315
1029
  function readSidecar(jsonlPath) {
1316
1030
  try {
1317
- return JSON.parse((0, import_fs4.readFileSync)(sidecarPath(jsonlPath), "utf-8"));
1031
+ return JSON.parse((0, import_fs3.readFileSync)(sidecarPath(jsonlPath), "utf-8"));
1318
1032
  } catch {
1319
1033
  return null;
1320
1034
  }
@@ -1323,19 +1037,19 @@ function readSidecar(jsonlPath) {
1323
1037
  // src/profiles.ts
1324
1038
  var import_promises = require("fs/promises");
1325
1039
  var import_os = require("os");
1326
- var import_path5 = require("path");
1040
+ var import_path3 = require("path");
1327
1041
  var PROFILES_FILE = "profiles.json";
1328
1042
  function resolveConfigDir(configDir) {
1329
1043
  return configDir.replace(/^~/, (0, import_os.homedir)());
1330
1044
  }
1331
1045
  function getProjectsDir(profile) {
1332
- return (0, import_path5.join)(resolveConfigDir(profile.configDir), "projects");
1046
+ return (0, import_path3.join)(resolveConfigDir(profile.configDir), "projects");
1333
1047
  }
1334
1048
  async function detectDefaultProfile() {
1335
1049
  return {
1336
1050
  id: "default",
1337
1051
  label: "Default",
1338
- configDir: (0, import_path5.join)((0, import_os.homedir)(), ".claude"),
1052
+ configDir: (0, import_path3.join)((0, import_os.homedir)(), ".claude"),
1339
1053
  enabled: true,
1340
1054
  emoji: "\u{1F916}"
1341
1055
  };
@@ -1344,7 +1058,7 @@ async function loadProfiles(configPath) {
1344
1058
  const log = getLogger();
1345
1059
  try {
1346
1060
  const resolved = resolveConfigDir(configPath);
1347
- const data = await (0, import_promises.readFile)((0, import_path5.join)(resolved, PROFILES_FILE), "utf-8");
1061
+ const data = await (0, import_promises.readFile)((0, import_path3.join)(resolved, PROFILES_FILE), "utf-8");
1348
1062
  const profiles = JSON.parse(data);
1349
1063
  log.debug({ configPath, count: profiles.length }, "profiles: loaded");
1350
1064
  return profiles;
@@ -1357,21 +1071,49 @@ async function loadProfiles(configPath) {
1357
1071
  async function saveProfiles(profiles, configPath) {
1358
1072
  const resolved = resolveConfigDir(configPath);
1359
1073
  await (0, import_promises.mkdir)(resolved, { recursive: true });
1360
- await (0, import_promises.writeFile)((0, import_path5.join)(resolved, PROFILES_FILE), JSON.stringify(profiles, null, 2));
1074
+ await (0, import_promises.writeFile)((0, import_path3.join)(resolved, PROFILES_FILE), JSON.stringify(profiles, null, 2));
1361
1075
  getLogger().debug({ configPath, count: profiles.length }, "profiles: saved");
1362
1076
  }
1363
1077
 
1364
1078
  // src/providers/codex-cli.ts
1365
1079
  var import_fast_glob = __toESM(require("fast-glob"), 1);
1366
- var import_fs5 = require("fs");
1080
+ var import_fs4 = require("fs");
1367
1081
  var import_promises2 = require("fs/promises");
1368
- var import_path7 = require("path");
1369
- var import_readline2 = require("readline");
1082
+ var import_path5 = require("path");
1083
+ var import_readline = require("readline");
1370
1084
 
1371
1085
  // src/canonical-path.ts
1372
- var import_path6 = require("path");
1086
+ var import_path4 = require("path");
1373
1087
  function canonicalPath(p) {
1374
- return import_path6.sep === "\\" ? p.replace(/\//g, "\\") : p;
1088
+ return import_path4.sep === "\\" ? p.replace(/\//g, "\\") : p;
1089
+ }
1090
+
1091
+ // src/providers/provider.ts
1092
+ var CLAUDE_CODE_PROVIDER = "claude-code";
1093
+ var CODEX_CLI_PROVIDER = "codex-cli";
1094
+ var CURSOR_PROVIDER = "cursor";
1095
+ var COPILOT_PROVIDER = "copilot";
1096
+ var LEGACY_CURSOR_PROVIDER = "cursor-cli";
1097
+ function canonicalizeProviderName(value) {
1098
+ if (value === LEGACY_CURSOR_PROVIDER) return CURSOR_PROVIDER;
1099
+ if (value === CLAUDE_CODE_PROVIDER || value === CODEX_CLI_PROVIDER || value === CURSOR_PROVIDER || value === COPILOT_PROVIDER) {
1100
+ return value;
1101
+ }
1102
+ return void 0;
1103
+ }
1104
+ function canonicalizeProviderList(providers) {
1105
+ const src = providers ?? [CLAUDE_CODE_PROVIDER];
1106
+ const out = [];
1107
+ for (const p of src) {
1108
+ const n = canonicalizeProviderName(p);
1109
+ if (n && !out.includes(n)) out.push(n);
1110
+ }
1111
+ return out;
1112
+ }
1113
+ function providerMatches(stored, wanted) {
1114
+ const a = canonicalizeProviderName(stored ?? CLAUDE_CODE_PROVIDER) ?? stored;
1115
+ const b = canonicalizeProviderName(wanted) ?? wanted;
1116
+ return a === b;
1375
1117
  }
1376
1118
 
1377
1119
  // src/providers/codex-cli.ts
@@ -1612,7 +1354,7 @@ function reduceCodexEntry(acc, entry, tier) {
1612
1354
  }
1613
1355
  function finalizeCodexMeta(acc, filePath, account, tier) {
1614
1356
  if (acc.messageCount === 0) return null;
1615
- const sessionId = acc.sessionId || (0, import_path7.basename)(filePath, ".jsonl");
1357
+ const sessionId = acc.sessionId || (0, import_path5.basename)(filePath, ".jsonl");
1616
1358
  const nameSlots = { ...acc.nameSlots, ...codexNameSlotsFor(filePath, acc.sessionId) };
1617
1359
  const projectPath = acc.cwd;
1618
1360
  const kind = acc.lastAssistant === null && acc.toolNames.length > 0 ? "task" : "conversation";
@@ -1626,7 +1368,7 @@ function finalizeCodexMeta(acc, filePath, account, tier) {
1626
1368
  sessionName: resolveSessionName(nameSlots).name ?? "",
1627
1369
  nameSlots,
1628
1370
  projectPath,
1629
- projectName: getShortProjectName3(projectPath),
1371
+ projectName: getShortProjectName(projectPath),
1630
1372
  account,
1631
1373
  timestamp: acc.latestTimestamp || (/* @__PURE__ */ new Date()).toISOString(),
1632
1374
  messageCount: acc.messageCount,
@@ -1647,7 +1389,7 @@ function finalizeCodexMeta(acc, filePath, account, tier) {
1647
1389
  lastPrompt: acc.lastUser?.text || void 0
1648
1390
  };
1649
1391
  }
1650
- function getShortProjectName3(fullPath) {
1392
+ function getShortProjectName(fullPath) {
1651
1393
  return fullPath.split("/").filter(Boolean).slice(-3).join("/");
1652
1394
  }
1653
1395
  function isSubagentSource(source) {
@@ -1670,7 +1412,7 @@ async function parseCodexConversation(filePath, account) {
1670
1412
  let latestTimestamp = "";
1671
1413
  let lastUserText = "";
1672
1414
  let nameSlots = {};
1673
- const rl = (0, import_readline2.createInterface)({ input: (0, import_fs5.createReadStream)(filePath), crlfDelay: Infinity });
1415
+ const rl = (0, import_readline.createInterface)({ input: (0, import_fs4.createReadStream)(filePath), crlfDelay: Infinity });
1674
1416
  try {
1675
1417
  for await (const line of rl) {
1676
1418
  if (!line.trim()) continue;
@@ -1713,8 +1455,8 @@ async function parseCodexConversation(filePath, account) {
1713
1455
  id: filePath,
1714
1456
  filePath,
1715
1457
  projectPath: cwd,
1716
- projectName: getShortProjectName3(cwd),
1717
- sessionId: sessionId || (0, import_path7.basename)(filePath, ".jsonl"),
1458
+ projectName: getShortProjectName(cwd),
1459
+ sessionId: sessionId || (0, import_path5.basename)(filePath, ".jsonl"),
1718
1460
  sessionName: resolveSessionName({ ...nameSlots, ...codexNameSlotsFor(filePath, sessionId) }).name ?? "",
1719
1461
  messages,
1720
1462
  fullText: textParts.join(" "),
@@ -1727,10 +1469,10 @@ async function parseCodexConversation(filePath, account) {
1727
1469
 
1728
1470
  // src/providers/copilot.ts
1729
1471
  var import_fast_glob2 = __toESM(require("fast-glob"), 1);
1730
- var import_fs6 = require("fs");
1472
+ var import_fs5 = require("fs");
1731
1473
  var import_promises3 = require("fs/promises");
1732
- var import_path8 = require("path");
1733
- var import_readline3 = require("readline");
1474
+ var import_path6 = require("path");
1475
+ var import_readline2 = require("readline");
1734
1476
  var SESSION_START = "session.start";
1735
1477
  var USER_MESSAGE = "user.message";
1736
1478
  var ASSISTANT_MESSAGE = "assistant.message";
@@ -1959,7 +1701,7 @@ function finalizeCopilotMeta(acc, filePath, account, tier) {
1959
1701
  sessionName: resolveSessionName(nameSlots).name ?? "",
1960
1702
  nameSlots,
1961
1703
  projectPath: acc.cwd,
1962
- projectName: getShortProjectName4(acc.cwd),
1704
+ projectName: getShortProjectName2(acc.cwd),
1963
1705
  account,
1964
1706
  timestamp: acc.latestTimestamp || fileMtimeIso(filePath),
1965
1707
  messageCount: acc.messageCount,
@@ -1979,14 +1721,14 @@ function finalizeCopilotMeta(acc, filePath, account, tier) {
1979
1721
  };
1980
1722
  }
1981
1723
  function sessionIdFromPath(filePath) {
1982
- return (0, import_path8.basename)((0, import_path8.dirname)(filePath));
1724
+ return (0, import_path6.basename)((0, import_path6.dirname)(filePath));
1983
1725
  }
1984
- function getShortProjectName4(fullPath) {
1726
+ function getShortProjectName2(fullPath) {
1985
1727
  return fullPath.split(/[/\\]/).filter(Boolean).slice(-3).join("/");
1986
1728
  }
1987
1729
  function fileMtimeIso(filePath) {
1988
1730
  try {
1989
- return new Date((0, import_fs6.statSync)(filePath).mtimeMs).toISOString();
1731
+ return new Date((0, import_fs5.statSync)(filePath).mtimeMs).toISOString();
1990
1732
  } catch {
1991
1733
  return (/* @__PURE__ */ new Date()).toISOString();
1992
1734
  }
@@ -2000,7 +1742,7 @@ async function parseCopilotConversation(filePath, account) {
2000
1742
  let latestTimestamp = "";
2001
1743
  let lastUserText = "";
2002
1744
  let nameSlots = {};
2003
- const rl = (0, import_readline3.createInterface)({ input: (0, import_fs6.createReadStream)(filePath), crlfDelay: Infinity });
1745
+ const rl = (0, import_readline2.createInterface)({ input: (0, import_fs5.createReadStream)(filePath), crlfDelay: Infinity });
2004
1746
  try {
2005
1747
  for await (const line of rl) {
2006
1748
  if (!line.trim()) continue;
@@ -2043,7 +1785,7 @@ async function parseCopilotConversation(filePath, account) {
2043
1785
  id: filePath,
2044
1786
  filePath,
2045
1787
  projectPath: cwd,
2046
- projectName: getShortProjectName4(cwd),
1788
+ projectName: getShortProjectName2(cwd),
2047
1789
  sessionId: sessionId || sessionIdFromPath(filePath),
2048
1790
  sessionName: resolveSessionName({ ...nameSlots, ...copilotNameSlotsFor(filePath) }).name ?? "",
2049
1791
  messages,
@@ -2058,13 +1800,13 @@ async function parseCopilotConversation(filePath, account) {
2058
1800
  // src/providers/cursor.ts
2059
1801
  var import_crypto = require("crypto");
2060
1802
  var import_fast_glob3 = __toESM(require("fast-glob"), 1);
2061
- var import_fs7 = require("fs");
2062
- var import_promises4 = require("fs/promises");
2063
- var import_path9 = require("path");
2064
- var import_readline4 = require("readline");
1803
+ var import_fs6 = require("fs");
1804
+ var import_promises4 = require("fs/promises");
1805
+ var import_path7 = require("path");
1806
+ var import_readline3 = require("readline");
2065
1807
  var TIMESTAMP_RE = /<timestamp>\s*([\s\S]*?)\s*<\/timestamp>/;
2066
1808
  var USER_QUERY_RE = /<user_query>\s*([\s\S]*?)\s*<\/user_query>/;
2067
- var SUBAGENT_PATH_RE2 = /[\\/]subagents[\\/]/;
1809
+ var SUBAGENT_PATH_RE = /[\\/]subagents[\\/]/;
2068
1810
  var CursorProvider = class {
2069
1811
  name = CURSOR_PROVIDER;
2070
1812
  async discover(roots) {
@@ -2358,9 +2100,9 @@ function reduceCursorEntry(acc, entry, tier) {
2358
2100
  }
2359
2101
  function finalizeCursorMeta(acc, filePath, account, tier) {
2360
2102
  if (acc.messageCount === 0) return null;
2361
- const sessionId = (0, import_path9.basename)(filePath, ".jsonl");
2103
+ const sessionId = (0, import_path7.basename)(filePath, ".jsonl");
2362
2104
  const nameSlots = { ...acc.nameSlots, ...cursorNameSlotsFor(filePath, sessionId) };
2363
- const isSubagent = SUBAGENT_PATH_RE2.test(filePath);
2105
+ const isSubagent = SUBAGENT_PATH_RE.test(filePath);
2364
2106
  const parent = isSubagent ? parentFromSubagentPath(filePath) : null;
2365
2107
  const { projectPath, projectName } = projectFromCursorPath(filePath);
2366
2108
  const timestamp = acc.latestTimestamp || fileMtimeIso2(filePath);
@@ -2399,34 +2141,34 @@ function finalizeCursorMeta(acc, filePath, account, tier) {
2399
2141
  };
2400
2142
  }
2401
2143
  function parentFromSubagentPath(filePath) {
2402
- const subagentsDir = (0, import_path9.dirname)(filePath);
2403
- const parentDir = (0, import_path9.dirname)(subagentsDir);
2404
- const parentSessionUuid = (0, import_path9.basename)(parentDir);
2144
+ const subagentsDir = (0, import_path7.dirname)(filePath);
2145
+ const parentDir = (0, import_path7.dirname)(subagentsDir);
2146
+ const parentSessionUuid = (0, import_path7.basename)(parentDir);
2405
2147
  if (!parentSessionUuid) return null;
2406
2148
  return {
2407
2149
  parentSessionUuid,
2408
- parentFilePath: canonicalPath((0, import_path9.join)(parentDir, `${parentSessionUuid}.jsonl`))
2150
+ parentFilePath: canonicalPath((0, import_path7.join)(parentDir, `${parentSessionUuid}.jsonl`))
2409
2151
  };
2410
2152
  }
2411
2153
  function projectFromCursorPath(filePath) {
2412
2154
  const parts = filePath.split(/[/\\]/);
2413
2155
  const idx = parts.lastIndexOf("agent-transcripts");
2414
- const cursorProjectDir = idx > 0 ? parts.slice(0, idx).join(import_path9.sep) : (0, import_path9.dirname)((0, import_path9.dirname)(filePath));
2415
- const slug = (0, import_path9.basename)(cursorProjectDir);
2156
+ const cursorProjectDir = idx > 0 ? parts.slice(0, idx).join(import_path7.sep) : (0, import_path7.dirname)((0, import_path7.dirname)(filePath));
2157
+ const slug = (0, import_path7.basename)(cursorProjectDir);
2416
2158
  const decoded = decodeCursorProjectSlug(slug);
2417
2159
  const projectPath = decoded ?? cursorProjectDir;
2418
- return { projectPath, projectName: getShortProjectName5(projectPath) || slug };
2160
+ return { projectPath, projectName: getShortProjectName3(projectPath) || slug };
2419
2161
  }
2420
2162
  function decodeCursorProjectSlug(slug) {
2421
2163
  if (!slug) return null;
2422
2164
  const segments = slug.split("-");
2423
2165
  if (segments.length === 0) return null;
2424
2166
  const rooted = slug.startsWith("Users-") || slug.startsWith("home-") || /^[A-Za-z]-/.test(slug);
2425
- let acc = rooted ? import_path9.sep : "";
2167
+ let acc = rooted ? import_path7.sep : "";
2426
2168
  let i = 0;
2427
2169
  if (rooted && segments[0] === "Users") {
2428
- const users = `${import_path9.sep}Users`;
2429
- if (!(0, import_fs7.existsSync)(users)) return null;
2170
+ const users = `${import_path7.sep}Users`;
2171
+ if (!(0, import_fs6.existsSync)(users)) return null;
2430
2172
  acc = users;
2431
2173
  i = 1;
2432
2174
  }
@@ -2434,9 +2176,9 @@ function decodeCursorProjectSlug(slug) {
2434
2176
  let found = null;
2435
2177
  let next = i + 1;
2436
2178
  for (let j = segments.length; j > i; j--) {
2437
- const candidate = (0, import_path9.join)(acc, segments.slice(i, j).join("-"));
2179
+ const candidate = (0, import_path7.join)(acc, segments.slice(i, j).join("-"));
2438
2180
  try {
2439
- if ((0, import_fs7.existsSync)(candidate) && (0, import_fs7.statSync)(candidate).isDirectory()) {
2181
+ if ((0, import_fs6.existsSync)(candidate) && (0, import_fs6.statSync)(candidate).isDirectory()) {
2440
2182
  found = candidate;
2441
2183
  next = j;
2442
2184
  break;
@@ -2450,12 +2192,12 @@ function decodeCursorProjectSlug(slug) {
2450
2192
  }
2451
2193
  return acc;
2452
2194
  }
2453
- function getShortProjectName5(fullPath) {
2195
+ function getShortProjectName3(fullPath) {
2454
2196
  return fullPath.split(/[/\\]/).filter(Boolean).slice(-3).join("/");
2455
2197
  }
2456
2198
  function fileMtimeIso2(filePath) {
2457
2199
  try {
2458
- return new Date((0, import_fs7.statSync)(filePath).mtimeMs).toISOString();
2200
+ return new Date((0, import_fs6.statSync)(filePath).mtimeMs).toISOString();
2459
2201
  } catch {
2460
2202
  return (/* @__PURE__ */ new Date()).toISOString();
2461
2203
  }
@@ -2475,7 +2217,7 @@ async function parseCursorConversation(filePath, account) {
2475
2217
  let latestTimestamp = "";
2476
2218
  let lastUserText = "";
2477
2219
  let nameSlots = {};
2478
- const rl = (0, import_readline4.createInterface)({ input: (0, import_fs7.createReadStream)(filePath), crlfDelay: Infinity });
2220
+ const rl = (0, import_readline3.createInterface)({ input: (0, import_fs6.createReadStream)(filePath), crlfDelay: Infinity });
2479
2221
  try {
2480
2222
  for await (const line of rl) {
2481
2223
  const message = parseCursorJsonlLine(line, messages.length);
@@ -2504,7 +2246,7 @@ async function parseCursorConversation(filePath, account) {
2504
2246
  }
2505
2247
  if (messages.length === 0) return null;
2506
2248
  const { projectPath, projectName } = projectFromCursorPath(filePath);
2507
- const sessionId = (0, import_path9.basename)(filePath, ".jsonl");
2249
+ const sessionId = (0, import_path7.basename)(filePath, ".jsonl");
2508
2250
  return {
2509
2251
  id: filePath,
2510
2252
  filePath,
@@ -2587,6 +2329,264 @@ async function discoverJsonlFiles(dirs, onProgress) {
2587
2329
  return results;
2588
2330
  }
2589
2331
 
2332
+ // src/persistent/metadata-reducer.ts
2333
+ var import_path9 = require("path");
2334
+
2335
+ // src/parser.ts
2336
+ var import_fs7 = require("fs");
2337
+ var import_path8 = require("path");
2338
+ var import_readline4 = require("readline");
2339
+ function turnDurationOf(entry) {
2340
+ if (entry.type !== "system" || entry.subtype !== "turn_duration" || typeof entry.durationMs !== "number") {
2341
+ return null;
2342
+ }
2343
+ return {
2344
+ durationMs: entry.durationMs,
2345
+ messageCount: entry.messageCount || 0,
2346
+ uuid: entry.uuid
2347
+ };
2348
+ }
2349
+ async function parseMeta(filePath, account, tier, onEntry) {
2350
+ const log = getLogger();
2351
+ log.trace({ filePath, account, tier: tier.name }, "parseMeta: start");
2352
+ const state = initialReducerState();
2353
+ const fileStream = (0, import_fs7.createReadStream)(filePath);
2354
+ const rl = (0, import_readline4.createInterface)({ input: fileStream, crlfDelay: Infinity });
2355
+ try {
2356
+ for await (const line of rl) {
2357
+ if (!line.trim()) continue;
2358
+ let entry;
2359
+ try {
2360
+ entry = JSON.parse(line);
2361
+ } catch {
2362
+ state.badJsonLines++;
2363
+ continue;
2364
+ }
2365
+ reduceLine(state, entry, tier);
2366
+ onEntry?.(entry);
2367
+ }
2368
+ } catch (err) {
2369
+ log.warn({ filePath, err }, "parseMeta: read failed");
2370
+ return null;
2371
+ }
2372
+ if (state.badJsonLines > 0) {
2373
+ log.warn(
2374
+ { filePath, badJsonLines: state.badJsonLines },
2375
+ "parseMeta: skipped malformed JSON lines"
2376
+ );
2377
+ }
2378
+ const meta = finalizeMeta(state, filePath, account, tier);
2379
+ if (!meta) log.trace({ filePath }, "parseMeta: no messages");
2380
+ return meta;
2381
+ }
2382
+ async function parseConversation(filePath, account) {
2383
+ const log = getLogger();
2384
+ log.trace({ filePath, account }, "parseConversation: start");
2385
+ const messages = [];
2386
+ let badJsonLines = 0;
2387
+ const textParts = [];
2388
+ const turnDurations = [];
2389
+ const state = initialConvState();
2390
+ const fileStream = (0, import_fs7.createReadStream)(filePath);
2391
+ const rl = (0, import_readline4.createInterface)({ input: fileStream, crlfDelay: Infinity });
2392
+ try {
2393
+ for await (const line of rl) {
2394
+ if (!line.trim()) continue;
2395
+ let entry;
2396
+ try {
2397
+ entry = JSON.parse(line);
2398
+ } catch {
2399
+ badJsonLines++;
2400
+ continue;
2401
+ }
2402
+ const turnDuration = turnDurationOf(entry);
2403
+ if (turnDuration) {
2404
+ turnDurations.push(turnDuration);
2405
+ continue;
2406
+ }
2407
+ const message = reduceConvLine(state, entry);
2408
+ if (message) {
2409
+ messages.push(message);
2410
+ if (message.text && !message.isCompactSummary) textParts.push(message.text);
2411
+ }
2412
+ }
2413
+ } catch (err) {
2414
+ log.warn({ filePath, err }, "parseConversation: read failed");
2415
+ return null;
2416
+ }
2417
+ if (badJsonLines > 0) {
2418
+ log.warn({ filePath, badJsonLines }, "parseConversation: skipped malformed JSON lines");
2419
+ }
2420
+ if (messages.length === 0) {
2421
+ log.trace({ filePath }, "parseConversation: no messages");
2422
+ return null;
2423
+ }
2424
+ log.debug({ filePath, messageCount: messages.length }, "parseConversation: complete");
2425
+ applyTeamInfo(messages, state);
2426
+ return {
2427
+ id: filePath,
2428
+ filePath,
2429
+ projectPath: state.cwd,
2430
+ projectName: getShortProjectName4(state.cwd),
2431
+ sessionId: state.sessionId || (0, import_path8.basename)(filePath, ".jsonl"),
2432
+ sessionName: resolveSessionName(state.nameSlots).name ?? "",
2433
+ messages,
2434
+ fullText: textParts.join(" "),
2435
+ timestamp: state.latestTimestamp || (/* @__PURE__ */ new Date()).toISOString(),
2436
+ messageCount: messages.length,
2437
+ account,
2438
+ turnDurations: turnDurations.length > 0 ? turnDurations : void 0,
2439
+ lastPrompt: state.lastPrompt || void 0
2440
+ };
2441
+ }
2442
+ function collectToolNames(content, toolSet) {
2443
+ if (!Array.isArray(content)) return;
2444
+ for (const item of content) {
2445
+ if (item?.type === "tool_use" && item?.name) {
2446
+ toolSet.add(item.name);
2447
+ }
2448
+ }
2449
+ }
2450
+ function getShortProjectName4(fullPath) {
2451
+ const parts = fullPath.split("/").filter(Boolean);
2452
+ return parts.slice(-3).join("/");
2453
+ }
2454
+
2455
+ // src/persistent/metadata-reducer.ts
2456
+ function initialReducerState() {
2457
+ return {
2458
+ sessionId: "",
2459
+ nameSlots: {},
2460
+ latestTimestamp: "",
2461
+ cwd: "",
2462
+ teamName: "",
2463
+ model: null,
2464
+ messageCount: 0,
2465
+ lastMessageSender: "user",
2466
+ agentId: "",
2467
+ isSidechain: false,
2468
+ firstMessage: null,
2469
+ lastMessage: null,
2470
+ lastPrompt: "",
2471
+ pageMessageCount: 0,
2472
+ toolNames: [],
2473
+ previewParts: [],
2474
+ snippetParts: [],
2475
+ previewLength: 0,
2476
+ snippetLength: 0,
2477
+ badJsonLines: 0,
2478
+ turnDurations: []
2479
+ };
2480
+ }
2481
+ function reduceLine(state, rawEntry, tier) {
2482
+ const entry = asQueuedPromptUserEntry(rawEntry);
2483
+ if (entry.cwd && !state.cwd) state.cwd = entry.cwd;
2484
+ if (entry.sessionId && !state.sessionId) state.sessionId = entry.sessionId;
2485
+ state.nameSlots = applyClaudeNameEntry(state.nameSlots, entry);
2486
+ if (entry.teamName && !state.teamName) state.teamName = entry.teamName;
2487
+ if (entry.agentId && !state.agentId) state.agentId = entry.agentId;
2488
+ if (entry.isSidechain === true) state.isSidechain = true;
2489
+ if (entry.timestamp) {
2490
+ const ts = entry.timestamp;
2491
+ if (!state.latestTimestamp || ts > state.latestTimestamp) state.latestTimestamp = ts;
2492
+ }
2493
+ const turnDuration = turnDurationOf(entry);
2494
+ if (turnDuration) state.turnDurations?.push(turnDuration);
2495
+ const type = entry.type;
2496
+ if (type === "last-prompt") {
2497
+ if (entry.lastPrompt && !state.lastPrompt) state.lastPrompt = entry.lastPrompt;
2498
+ return;
2499
+ }
2500
+ if (type !== "user" && type !== "assistant") return;
2501
+ if (entry.isMeta) return;
2502
+ const msg = entry.message;
2503
+ if (entry.isCompactSummary === true) {
2504
+ if (extractTextContent(msg?.content)) state.pageMessageCount++;
2505
+ return;
2506
+ }
2507
+ if (state.model === null && msg?.model) state.model = msg.model;
2508
+ const content = extractTextContent(msg?.content);
2509
+ const hasToolUseResult = type === "user" && entry.toolUseResult != null;
2510
+ const isOnlyToolResult = hasToolUseResult && isOnlyToolResultContent(msg?.content);
2511
+ const toolSet = new Set(state.toolNames);
2512
+ collectToolNames(msg?.content, toolSet);
2513
+ state.toolNames = Array.from(toolSet);
2514
+ const toolUseBlocks = extractToolUseBlocks(msg?.content);
2515
+ const thinking = type === "assistant" ? extractThinking(msg?.content) : null;
2516
+ const hasThinking = !!(thinking?.content || thinking?.signature);
2517
+ if (content || isOnlyToolResult || toolUseBlocks.length > 0 || hasThinking) {
2518
+ state.pageMessageCount++;
2519
+ }
2520
+ if (content || isOnlyToolResult) {
2521
+ state.messageCount++;
2522
+ state.lastMessageSender = type;
2523
+ if (content) {
2524
+ const ts = entry.timestamp || "";
2525
+ if (!state.firstMessage) state.firstMessage = { text: content.slice(0, 200), timestamp: ts };
2526
+ state.lastMessage = { text: content.slice(0, 200), timestamp: ts };
2527
+ if (state.previewLength < tier.previewMax) {
2528
+ state.previewParts.push(content);
2529
+ state.previewLength += content.length;
2530
+ }
2531
+ if (state.snippetLength < tier.snippetMax) {
2532
+ const remaining = tier.snippetMax - state.snippetLength;
2533
+ const chunk = content.length > remaining ? content.slice(0, remaining) : content;
2534
+ state.snippetParts.push(chunk);
2535
+ state.snippetLength += chunk.length;
2536
+ }
2537
+ }
2538
+ }
2539
+ }
2540
+ function finalizeMeta(state, filePath, account, tier) {
2541
+ if (state.messageCount === 0) return null;
2542
+ const isSidechain = state.isSidechain && !!state.agentId;
2543
+ const isSubagentPath = SUBAGENT_PATH_RE2.test(filePath);
2544
+ const isSubagent = isSidechain || isSubagentPath;
2545
+ let parentSessionId = null;
2546
+ if (isSubagentPath) {
2547
+ const uuidDir = (0, import_path9.dirname)((0, import_path9.dirname)(filePath));
2548
+ parentSessionId = (0, import_path9.join)((0, import_path9.dirname)(uuidDir), `${(0, import_path9.basename)(uuidDir)}.jsonl`);
2549
+ }
2550
+ const projectPath = state.cwd;
2551
+ return {
2552
+ id: filePath,
2553
+ filePath,
2554
+ provider: CLAUDE_CODE_PROVIDER,
2555
+ sessionId: state.sessionId || (0, import_path9.basename)(filePath, ".jsonl"),
2556
+ sessionName: resolveSessionName(state.nameSlots).name ?? "",
2557
+ nameSlots: state.nameSlots,
2558
+ projectPath,
2559
+ projectName: getShortProjectName5(projectPath),
2560
+ account,
2561
+ timestamp: state.latestTimestamp || (/* @__PURE__ */ new Date()).toISOString(),
2562
+ messageCount: state.messageCount,
2563
+ lastMessageSender: state.lastMessageSender,
2564
+ preview: state.previewParts.join(" ").slice(0, tier.previewMax),
2565
+ contentSnippet: state.snippetParts.join(" "),
2566
+ gitBranch: null,
2567
+ model: state.model,
2568
+ isSubagent,
2569
+ parentSessionId,
2570
+ subagentId: isSidechain ? state.agentId : void 0,
2571
+ // A sidechain line's `sessionId` IS the parent's id — that is exactly the
2572
+ // conflation `subagentId` exists to undo, so it is the parent UUID here.
2573
+ parentSessionUuid: isSidechain && state.sessionId ? state.sessionId : void 0,
2574
+ // A teammate's records carry teamName; the lead's never do, yet the lead
2575
+ // receives <teammate-message> tags too, so the tag is not the discriminator.
2576
+ isTeammate: Boolean(state.teamName),
2577
+ teamName: state.teamName || null,
2578
+ toolNames: state.toolNames,
2579
+ firstMessage: state.firstMessage,
2580
+ lastMessage: state.lastMessage,
2581
+ lastPrompt: state.lastPrompt || void 0
2582
+ };
2583
+ }
2584
+ var SUBAGENT_PATH_RE2 = /[\\/]subagents[\\/]/;
2585
+ function getShortProjectName5(fullPath) {
2586
+ const parts = fullPath.split("/").filter(Boolean);
2587
+ return parts.slice(-3).join("/");
2588
+ }
2589
+
2590
2590
  // src/providers/threadbase.ts
2591
2591
  var ThreadbaseProvider = class {
2592
2592
  name = CLAUDE_CODE_PROVIDER;
@@ -2861,7 +2861,7 @@ function assemble(filePath, account, messages, fullText, turnDurations, state) {
2861
2861
  id: filePath,
2862
2862
  filePath,
2863
2863
  projectPath: state.cwd,
2864
- projectName: getShortProjectName2(state.cwd),
2864
+ projectName: getShortProjectName4(state.cwd),
2865
2865
  sessionId: state.sessionId || (0, import_path10.basename)(filePath, ".jsonl"),
2866
2866
  sessionName: resolveSessionName(state.nameSlots).name ?? "",
2867
2867
  messages,