refactor: extract node:sqlite-free parsing.mjs so the core can be app-consumable (Phase 5d-1)

Move all pure parse/discover helpers (message extraction, project-path, codex
helpers, discovery) out of db.mjs/indexer.mjs into scripts/parsing.mjs, which
imports only node:fs/path/os. Providers now import from parsing.mjs, so the
provider import graph no longer transitively loads node:sqlite — a prerequisite
for the app (Electron/Node without node:sqlite) to consume the compiled core.
Verbatim move, no behavior change; indexer.mjs 840→209 lines. 119/119.
This commit is contained in:
tommy0103
2026-07-09 09:20:37 +08:00
parent 0598c29aad
commit 1bda4da170
5 changed files with 335 additions and 314 deletions
+2 -3
View File
@@ -12,9 +12,8 @@ const fs = require('node:fs');
import {
extractText, extractContentType, extractMessageIsMeta,
filePath, trunc, truncJson, readLines,
} from '../db.mjs';
import { discoverJsonlFiles } from '../indexer.mjs';
filePath, trunc, truncJson, readLines, discoverJsonlFiles,
} from '../parsing.mjs';
import type { Cursor, DiscoverContext, IndexRecord, IndexUnit, Provider } from './types.ts';
+2 -2
View File
@@ -12,14 +12,14 @@ import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
const fs = require('node:fs');
import { trunc, truncJson, readLines } from '../db.mjs';
import {
trunc, truncJson, readLines,
discoverCodexJsonlFiles, normalizeObservedCwd, projectSlugFromPath,
codexRawId, codexDbId, codexCallId, codexLineUuid, codexParentThreadId,
codexIsGuardianThread, codexAgentNickname, codexAgentRole, codexUsage,
codexEventText, codexMessagePayloadText, codexVisibleMessageKey,
codexToolInput, codexToolOutput,
} from '../indexer.mjs';
} from '../parsing.mjs';
import type { Cursor, DiscoverContext, IndexRecord, IndexUnit, MessageRecord, Provider } from './types.ts';