@threadbase-sh/scanner 0.14.7 → 0.15.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/cli.js +16 -9
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +27 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +26 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -50,6 +50,7 @@ __export(index_exports, {
|
|
|
50
50
|
getLogger: () => getLogger,
|
|
51
51
|
getProjectsDir: () => getProjectsDir,
|
|
52
52
|
loadProfiles: () => loadProfiles,
|
|
53
|
+
parseCodexJsonlLine: () => parseCodexJsonlLine,
|
|
53
54
|
parseJsonlLine: () => parseJsonlLine,
|
|
54
55
|
readGitBranch: () => readGitBranch,
|
|
55
56
|
readSidecar: () => readSidecar,
|
|
@@ -1057,6 +1058,26 @@ function extractCodexText(content) {
|
|
|
1057
1058
|
return "";
|
|
1058
1059
|
}).filter(Boolean).map(cleanSystemTags).join(" ");
|
|
1059
1060
|
}
|
|
1061
|
+
function parseCodexJsonlLine(line) {
|
|
1062
|
+
if (!line.trim()) return null;
|
|
1063
|
+
let entry;
|
|
1064
|
+
try {
|
|
1065
|
+
entry = JSON.parse(line);
|
|
1066
|
+
} catch {
|
|
1067
|
+
return null;
|
|
1068
|
+
}
|
|
1069
|
+
return codexEntryToMessage(entry);
|
|
1070
|
+
}
|
|
1071
|
+
function codexEntryToMessage(entry) {
|
|
1072
|
+
const payload = entry.payload;
|
|
1073
|
+
if (!payload || typeof payload !== "object") return null;
|
|
1074
|
+
if (entry.type !== "response_item" || payload.type !== "message") return null;
|
|
1075
|
+
const role = payload.role;
|
|
1076
|
+
if (role !== "user" && role !== "assistant") return null;
|
|
1077
|
+
const text = extractCodexText(payload.content);
|
|
1078
|
+
if (!text) return null;
|
|
1079
|
+
return { role, text, timestamp: asString(entry.timestamp) };
|
|
1080
|
+
}
|
|
1060
1081
|
function reduceCodexEntry(acc, entry, tier) {
|
|
1061
1082
|
const ts = asString(entry.timestamp);
|
|
1062
1083
|
if (ts && (!acc.latestTimestamp || ts > acc.latestTimestamp)) acc.latestTimestamp = ts;
|
|
@@ -1167,14 +1188,11 @@ async function parseCodexConversation(filePath, account) {
|
|
|
1167
1188
|
if (!cwd) cwd = asString(payload.cwd);
|
|
1168
1189
|
continue;
|
|
1169
1190
|
}
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
if (
|
|
1175
|
-
messages.push({ role, text, timestamp: ts });
|
|
1176
|
-
textParts.push(text);
|
|
1177
|
-
if (role === "user") lastUserText = text;
|
|
1191
|
+
const message = codexEntryToMessage(entry);
|
|
1192
|
+
if (!message) continue;
|
|
1193
|
+
messages.push(message);
|
|
1194
|
+
textParts.push(message.text);
|
|
1195
|
+
if (message.role === "user") lastUserText = message.text;
|
|
1178
1196
|
}
|
|
1179
1197
|
} catch (err) {
|
|
1180
1198
|
log.warn({ filePath, err }, "parseCodexConversation: read failed");
|
|
@@ -3978,6 +3996,7 @@ async function getConversation(id, options, scanner) {
|
|
|
3978
3996
|
getLogger,
|
|
3979
3997
|
getProjectsDir,
|
|
3980
3998
|
loadProfiles,
|
|
3999
|
+
parseCodexJsonlLine,
|
|
3981
4000
|
parseJsonlLine,
|
|
3982
4001
|
readGitBranch,
|
|
3983
4002
|
readSidecar,
|