@threadbase-sh/scanner 0.14.6 → 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 +25 -15
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +36 -14
- 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 +35 -14
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -320,6 +320,7 @@ declare class CodexCliProvider implements ScannerProvider<CodexAccumulator> {
|
|
|
320
320
|
reduceEntry(acc: CodexAccumulator, entry: Record<string, unknown>, tier: ContentTier): void;
|
|
321
321
|
finalize(acc: CodexAccumulator, filePath: string, account: string, tier: ContentTier): ConversationMeta | null;
|
|
322
322
|
}
|
|
323
|
+
declare function parseCodexJsonlLine(line: string): ConversationMessage | null;
|
|
323
324
|
|
|
324
325
|
interface ReducerState {
|
|
325
326
|
sessionId: string;
|
|
@@ -445,4 +446,4 @@ declare function scan(options?: ScanOptions, scanner?: ConversationScanner): Pro
|
|
|
445
446
|
declare function search(query: string, options?: SearchOptions, scanner?: ConversationScanner): Promise<SearchResult[]>;
|
|
446
447
|
declare function getConversation(id: string, options?: GetConversationOptions, scanner?: ConversationScanner): Promise<Conversation | null>;
|
|
447
448
|
|
|
448
|
-
export { type AttachmentSidecar, CodexCliProvider, type ContentTier, type Conversation, type ConversationMessage, type ConversationMeta, type ConversationPage, ConversationScanner, type ConversationScannerOptions, DEFAULT_TIERS, type DeferredToolsDeltaAttachment, type DiscoveredConversationFile, type FileStatEntry, type GetConversationOptions, type GetConversationPageOptions, type GroupedConversations, type Include, type ConvReducerState as JsonlParseState, type MessageMetadata, type MessageSender, type MessageSnapshot, type PersistentConfig, type Profile, type ProviderName, type ScanOptions, type ScanResult, type ScannerChangeEvent, type ScannerProvider, type ScannerProviderName, type SearchHighlight, SearchIndexer, type SearchMatch, type SearchOptions, type SearchResult, type Sidecar, type SingleFilePage, type SortOrder, type TeamInfo, ThreadbaseProvider, type ToolResultBlock, type ToolUseBlock, type TreeConversation, type TurnDuration, VALID_SORT_ORDERS, type View, type WatchOptions, applyAccountFilter, applyIncludeFilter, applyPagination, applyProjectFilter, applySinceFilter, applySort, cleanSystemTags, initialConvState as createJsonlParseState, createLogger, detectDefaultProfile, getConversation, getLogger, getProjectsDir, loadProfiles, parseJsonlLine, readGitBranch, readSidecar, resetDefaultScanner, resolveConfigDir, resolveTier, saveProfiles, scan, search, setLogger, sidecarPath };
|
|
449
|
+
export { type AttachmentSidecar, CodexCliProvider, type ContentTier, type Conversation, type ConversationMessage, type ConversationMeta, type ConversationPage, ConversationScanner, type ConversationScannerOptions, DEFAULT_TIERS, type DeferredToolsDeltaAttachment, type DiscoveredConversationFile, type FileStatEntry, type GetConversationOptions, type GetConversationPageOptions, type GroupedConversations, type Include, type ConvReducerState as JsonlParseState, type MessageMetadata, type MessageSender, type MessageSnapshot, type PersistentConfig, type Profile, type ProviderName, type ScanOptions, type ScanResult, type ScannerChangeEvent, type ScannerProvider, type ScannerProviderName, type SearchHighlight, SearchIndexer, type SearchMatch, type SearchOptions, type SearchResult, type Sidecar, type SingleFilePage, type SortOrder, type TeamInfo, ThreadbaseProvider, type ToolResultBlock, type ToolUseBlock, type TreeConversation, type TurnDuration, VALID_SORT_ORDERS, type View, type WatchOptions, applyAccountFilter, applyIncludeFilter, applyPagination, applyProjectFilter, applySinceFilter, applySort, cleanSystemTags, initialConvState as createJsonlParseState, createLogger, detectDefaultProfile, getConversation, getLogger, getProjectsDir, loadProfiles, parseCodexJsonlLine, parseJsonlLine, readGitBranch, readSidecar, resetDefaultScanner, resolveConfigDir, resolveTier, saveProfiles, scan, search, setLogger, sidecarPath };
|
package/dist/index.d.ts
CHANGED
|
@@ -320,6 +320,7 @@ declare class CodexCliProvider implements ScannerProvider<CodexAccumulator> {
|
|
|
320
320
|
reduceEntry(acc: CodexAccumulator, entry: Record<string, unknown>, tier: ContentTier): void;
|
|
321
321
|
finalize(acc: CodexAccumulator, filePath: string, account: string, tier: ContentTier): ConversationMeta | null;
|
|
322
322
|
}
|
|
323
|
+
declare function parseCodexJsonlLine(line: string): ConversationMessage | null;
|
|
323
324
|
|
|
324
325
|
interface ReducerState {
|
|
325
326
|
sessionId: string;
|
|
@@ -445,4 +446,4 @@ declare function scan(options?: ScanOptions, scanner?: ConversationScanner): Pro
|
|
|
445
446
|
declare function search(query: string, options?: SearchOptions, scanner?: ConversationScanner): Promise<SearchResult[]>;
|
|
446
447
|
declare function getConversation(id: string, options?: GetConversationOptions, scanner?: ConversationScanner): Promise<Conversation | null>;
|
|
447
448
|
|
|
448
|
-
export { type AttachmentSidecar, CodexCliProvider, type ContentTier, type Conversation, type ConversationMessage, type ConversationMeta, type ConversationPage, ConversationScanner, type ConversationScannerOptions, DEFAULT_TIERS, type DeferredToolsDeltaAttachment, type DiscoveredConversationFile, type FileStatEntry, type GetConversationOptions, type GetConversationPageOptions, type GroupedConversations, type Include, type ConvReducerState as JsonlParseState, type MessageMetadata, type MessageSender, type MessageSnapshot, type PersistentConfig, type Profile, type ProviderName, type ScanOptions, type ScanResult, type ScannerChangeEvent, type ScannerProvider, type ScannerProviderName, type SearchHighlight, SearchIndexer, type SearchMatch, type SearchOptions, type SearchResult, type Sidecar, type SingleFilePage, type SortOrder, type TeamInfo, ThreadbaseProvider, type ToolResultBlock, type ToolUseBlock, type TreeConversation, type TurnDuration, VALID_SORT_ORDERS, type View, type WatchOptions, applyAccountFilter, applyIncludeFilter, applyPagination, applyProjectFilter, applySinceFilter, applySort, cleanSystemTags, initialConvState as createJsonlParseState, createLogger, detectDefaultProfile, getConversation, getLogger, getProjectsDir, loadProfiles, parseJsonlLine, readGitBranch, readSidecar, resetDefaultScanner, resolveConfigDir, resolveTier, saveProfiles, scan, search, setLogger, sidecarPath };
|
|
449
|
+
export { type AttachmentSidecar, CodexCliProvider, type ContentTier, type Conversation, type ConversationMessage, type ConversationMeta, type ConversationPage, ConversationScanner, type ConversationScannerOptions, DEFAULT_TIERS, type DeferredToolsDeltaAttachment, type DiscoveredConversationFile, type FileStatEntry, type GetConversationOptions, type GetConversationPageOptions, type GroupedConversations, type Include, type ConvReducerState as JsonlParseState, type MessageMetadata, type MessageSender, type MessageSnapshot, type PersistentConfig, type Profile, type ProviderName, type ScanOptions, type ScanResult, type ScannerChangeEvent, type ScannerProvider, type ScannerProviderName, type SearchHighlight, SearchIndexer, type SearchMatch, type SearchOptions, type SearchResult, type Sidecar, type SingleFilePage, type SortOrder, type TeamInfo, ThreadbaseProvider, type ToolResultBlock, type ToolUseBlock, type TreeConversation, type TurnDuration, VALID_SORT_ORDERS, type View, type WatchOptions, applyAccountFilter, applyIncludeFilter, applyPagination, applyProjectFilter, applySinceFilter, applySort, cleanSystemTags, initialConvState as createJsonlParseState, createLogger, detectDefaultProfile, getConversation, getLogger, getProjectsDir, loadProfiles, parseCodexJsonlLine, parseJsonlLine, readGitBranch, readSidecar, resetDefaultScanner, resolveConfigDir, resolveTier, saveProfiles, scan, search, setLogger, sidecarPath };
|
package/dist/index.js
CHANGED
|
@@ -991,6 +991,26 @@ function extractCodexText(content) {
|
|
|
991
991
|
return "";
|
|
992
992
|
}).filter(Boolean).map(cleanSystemTags).join(" ");
|
|
993
993
|
}
|
|
994
|
+
function parseCodexJsonlLine(line) {
|
|
995
|
+
if (!line.trim()) return null;
|
|
996
|
+
let entry;
|
|
997
|
+
try {
|
|
998
|
+
entry = JSON.parse(line);
|
|
999
|
+
} catch {
|
|
1000
|
+
return null;
|
|
1001
|
+
}
|
|
1002
|
+
return codexEntryToMessage(entry);
|
|
1003
|
+
}
|
|
1004
|
+
function codexEntryToMessage(entry) {
|
|
1005
|
+
const payload = entry.payload;
|
|
1006
|
+
if (!payload || typeof payload !== "object") return null;
|
|
1007
|
+
if (entry.type !== "response_item" || payload.type !== "message") return null;
|
|
1008
|
+
const role = payload.role;
|
|
1009
|
+
if (role !== "user" && role !== "assistant") return null;
|
|
1010
|
+
const text = extractCodexText(payload.content);
|
|
1011
|
+
if (!text) return null;
|
|
1012
|
+
return { role, text, timestamp: asString(entry.timestamp) };
|
|
1013
|
+
}
|
|
994
1014
|
function reduceCodexEntry(acc, entry, tier) {
|
|
995
1015
|
const ts = asString(entry.timestamp);
|
|
996
1016
|
if (ts && (!acc.latestTimestamp || ts > acc.latestTimestamp)) acc.latestTimestamp = ts;
|
|
@@ -1101,14 +1121,11 @@ async function parseCodexConversation(filePath, account) {
|
|
|
1101
1121
|
if (!cwd) cwd = asString(payload.cwd);
|
|
1102
1122
|
continue;
|
|
1103
1123
|
}
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
if (
|
|
1109
|
-
messages.push({ role, text, timestamp: ts });
|
|
1110
|
-
textParts.push(text);
|
|
1111
|
-
if (role === "user") lastUserText = text;
|
|
1124
|
+
const message = codexEntryToMessage(entry);
|
|
1125
|
+
if (!message) continue;
|
|
1126
|
+
messages.push(message);
|
|
1127
|
+
textParts.push(message.text);
|
|
1128
|
+
if (message.role === "user") lastUserText = message.text;
|
|
1112
1129
|
}
|
|
1113
1130
|
} catch (err) {
|
|
1114
1131
|
log.warn({ filePath, err }, "parseCodexConversation: read failed");
|
|
@@ -3456,7 +3473,8 @@ var ConversationScanner = class {
|
|
|
3456
3473
|
// feeds the conversation's account field; "default" is the single-profile
|
|
3457
3474
|
// fallback, matching refreshFile.
|
|
3458
3475
|
async parseSingleFilePage(filePath, account, options) {
|
|
3459
|
-
const
|
|
3476
|
+
const provider = await this.resolveProviderForFile(filePath, null);
|
|
3477
|
+
const conversation = provider?.name === CODEX_CLI_PROVIDER ? await parseCodexConversation(filePath, account ?? "default") : await parseConversation(filePath, account ?? "default");
|
|
3460
3478
|
if (!conversation) return null;
|
|
3461
3479
|
const { messages } = conversation;
|
|
3462
3480
|
const total = messages.length;
|
|
@@ -3500,7 +3518,7 @@ var ConversationScanner = class {
|
|
|
3500
3518
|
const engine = this.engine();
|
|
3501
3519
|
const previous2 = engine.getByIdOrSession(filePath);
|
|
3502
3520
|
const resolvedAccount2 = account ?? previous2?.account ?? "default";
|
|
3503
|
-
const
|
|
3521
|
+
const provider2 = await this.resolveProviderForFile(filePath, previous2);
|
|
3504
3522
|
const { meta: meta2, change } = await engine.indexFile(
|
|
3505
3523
|
filePath,
|
|
3506
3524
|
resolvedAccount2,
|
|
@@ -3508,7 +3526,7 @@ var ConversationScanner = class {
|
|
|
3508
3526
|
void 0,
|
|
3509
3527
|
readGitBranch,
|
|
3510
3528
|
false,
|
|
3511
|
-
|
|
3529
|
+
provider2
|
|
3512
3530
|
);
|
|
3513
3531
|
const cacheKeys = /* @__PURE__ */ new Set();
|
|
3514
3532
|
for (const m of [previous2, meta2]) {
|
|
@@ -3529,10 +3547,12 @@ var ConversationScanner = class {
|
|
|
3529
3547
|
const resolvedAccount = account ?? previous?.account ?? "default";
|
|
3530
3548
|
let meta = null;
|
|
3531
3549
|
let searchDoc = emptySearchDocument();
|
|
3550
|
+
const onEntry = (entry) => {
|
|
3551
|
+
searchDoc = appendSearchDelta(searchDoc, extractSearchDelta(entry));
|
|
3552
|
+
};
|
|
3553
|
+
const provider = await this.resolveProviderForFile(filePath, previous ?? null);
|
|
3532
3554
|
try {
|
|
3533
|
-
meta = await
|
|
3534
|
-
searchDoc = appendSearchDelta(searchDoc, extractSearchDelta(entry));
|
|
3535
|
-
});
|
|
3555
|
+
meta = provider ? await parseMetaWithProvider(provider, filePath, resolvedAccount, this.lastTier, onEntry) : await parseMeta(filePath, resolvedAccount, this.lastTier, onEntry);
|
|
3536
3556
|
} catch (err) {
|
|
3537
3557
|
log.warn({ filePath, err }, "refreshFile: parseMeta threw");
|
|
3538
3558
|
meta = null;
|
|
@@ -3908,6 +3928,7 @@ export {
|
|
|
3908
3928
|
getLogger,
|
|
3909
3929
|
getProjectsDir,
|
|
3910
3930
|
loadProfiles,
|
|
3931
|
+
parseCodexJsonlLine,
|
|
3911
3932
|
parseJsonlLine,
|
|
3912
3933
|
readGitBranch,
|
|
3913
3934
|
readSidecar,
|