Prepares for adding Codex JSONL support — new indexers can be added
without touching the query layer.
- db.mjs: schema, openDb, truncation helpers, shared utilities
- indexer.mjs: file discovery, JSONL parsing, SQLite writes
- query.mjs: all query API functions (search, context, raw, etc.)
- runtime.mjs: thin CLI entry point + VM script executor
- Replace readFileSync+split with chunked line reader (readLines) to
avoid loading entire JSONL files into memory at once
- Wrap each file's indexing in its own transaction so one corrupt file
doesn't roll back the entire index
- Log warnings to stderr instead of silently swallowing errors in
indexSubagentMeta, indexWorkflows, and indexHistory
- Add try/catch around readdirSync calls in discoverJsonlFiles and
indexWorkflows to survive unreadable directories
- Push error-pattern filtering in failures() into SQL LIKE clauses
instead of scanning all tool_results in JS
- Don't truncate workflow result_json and script (low-volume, must
stay parseable)
- Replace blind string truncation on tool_calls.input_json with
structure-aware truncJson that shortens individual string values
while keeping the JSON skeleton valid
- Add raw(uuid, {offset, limit}) API for windowed access to the
original JSONL line, so truncated content can be recovered on demand
Previously the session metadata accumulator started from zero on every
reindex pass, so an incremental update would overwrite started_at and
message_count with values derived only from the new lines.
Now reads the existing session row first and merges new data on top.