ID:WORK-144Status:done
Extract pure scanner functions into scanner-core module
Split scanner.ts so that pure functions (parseFileContent, scanPlanSources, and all supporting AST helpers) live in a new scanner-core.ts with zero Node.js imports. The existing scanner.ts re-imports from scanner-core.ts and adds filesystem-dependent functions.
Priority:highComplexity:moderateSource:SPEC-040
Acceptance Criteria
- New file
runes/plan/src/scanner-core.tsexists and contains all pure scanner functions scanner-core.tshas zero imports fromnode:fs,node:path,node:child_process, or@refrakt-md/contentparseFileContent(source, relPath)is exported fromscanner-core.tsscanPlanSources(sources)is exported fromscanner-core.ts- All supporting pure functions (
extractCriteria,extractResolution,extractRefs,extractScopedRefs,walkNodes,extractHeadingText,matchKnownSection,extractTitle) move toscanner-core.ts scanner.tsimports fromscanner-core.tsand re-exports the pure functions alongside its filesystem functions- All existing imports from
./scannerand the main entry point continue to work (no breaking changes) index.tsre-exportsparseFileContentandscanPlanSourcesunchanged- Existing tests pass without modification
Approach
- Create
scanner-core.tsand move all pure functions into it. Keep the Markdoc import (pure JS, no Node.js APIs) and any type imports from./types.ts. - In
scanner.ts, replace the moved function bodies withimport { parseFileContent, scanPlanSources, ... } from './scanner-core.js'andexport { parseFileContent, scanPlanSources } from './scanner-core.js'. - Filesystem-dependent functions (
parseFile,scanPlanFiles,collectMdFiles,readCache,writeCache) stay inscanner.ts. - Verify that
scanner.tsis the only file that importsnode:fs,node:path, and@refrakt-md/content. - Run existing tests to confirm no regressions.
Dependencies
None — this is the first extraction step.
References
- Edge Runtime Compatibility for Plan Package — Edge Runtime Compatibility for Plan Package
Resolution
Completed: 2026-04-14
Branch: claude/edge-runtime-refactor-HOg8v
What was done
- Created
runes/plan/src/scanner-core.tswith all pure scanner functions (parseFileContent, scanPlanSources, extractCriteria, extractResolution, extractRefs, extractScopedRefs, walkNodes, extractHeadingText, matchKnownSection, extractTitle, and supporting constants) - Rewrote
runes/plan/src/scanner.tsto import from scanner-core and re-export pure functions; kept only filesystem-dependent code (parseFile, scanPlanFiles, collectMdFiles, readCache, writeCache, getGitMtimes) - index.ts re-exports unchanged — no breaking changes to public API
Notes
- scanner-core.ts depends only on @markdoc/markdoc (pure JS) and @refrakt-md/runes (escapeFenceTags only)
- All 321 plan tests pass without modification
Relationships
Dependency of
History
- 888d791statusready→done
- ☑ New file `runes/plan/src/scanner-core.ts` exists and contains all pure scanner functions
- ☑ `scanner-core.ts` has zero imports from `node:fs`, `node:path`, `node:child_process`, or `@refrakt-md/content`
- ☑ `parseFileContent(source, relPath)` is exported from `scanner-core.ts`
- +6 more criteria
- 7340389Created (ready, high, moderate, SPEC-040, plan, architecture, edge-runtime)