Indexer Refactor Implementation Plan
For Claude: REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task.
Goal: Make the indexer easier to scan by extracting freshness checks and topics.yaml reconciliation from the page indexing transaction.
Architecture: Keep src/indexer/index.ts responsible for ensureFreshIndex, runIndexer, page scanning, and page-row writes. Move mtime freshness helpers into src/indexer/freshness.ts and topic DAG reconciliation into src/indexer/topics-yaml.ts. Do not change SQLite schema or page indexing behavior.
Tech Stack: TypeScript, fast-glob, better-sqlite3, Vitest.
Task 1: Extract Freshness Helpers#
Files:
- Create:
src/indexer/freshness.ts - Modify:
src/indexer/index.ts
Steps:
- Move
PAGES_GLOB,pagesNewerThan, andtopicsYamlNewerThanintofreshness.ts. - Keep
ensureFreshIndexinindex.tsso the public API stays stable. - Run
npm run lint.
Task 2: Extract Topics YAML Reconciliation#
Files:
- Create:
src/indexer/topics-yaml.ts - Modify:
src/indexer/index.ts
Steps:
- Move
TOPICS_YAML_FILENAMEandapplyTopicsYamlintotopics-yaml.ts. - Preserve malformed YAML warning behavior.
- Keep page transaction code in
index.ts. - Run focused indexer/search/topics/health tests.
Task 3: Verify Full Baseline#
Commands:
npm testnpm run lintnpm run build
Expected: All tests and build pass with no user-visible behavior change.