ID:WORK-145Status:done
Extract pure diffing functions into diff module
Extract the pure diffing and parsing functions from history.ts into a new diff.ts module with zero Node.js imports. The existing history.ts re-imports from diff.ts for its git-based history extraction.
Priority:highComplexity:simpleSource:SPEC-040
Acceptance Criteria
- New file
runes/plan/src/diff.tsexists and contains all pure diffing functions diff.tshas zero imports fromnode:fs,node:path, ornode:child_processdiffAttributes(prev, curr)is exported fromdiff.tswithAttributeChangetypediffCriteria(prev, curr)is exported fromdiff.tswithCriteriaChangetypeparseTagAttributes(line)is exported fromdiff.tsparseCheckboxes(content)is exported fromdiff.tswithParsedCheckboxtypehasResolutionSection(content)is exported fromdiff.tshistory.tsimports fromdiff.tsand re-exports the types for backwards compatibility- All existing imports from
./historycontinue to work (no breaking changes) - Existing history tests pass without modification
Approach
- Create
diff.tsand move the five pure functions plus their types (AttributeChange,CriteriaChange,ParsedCheckbox) and supporting regex constants (TAG_ATTR_RE,CHECKBOX_RE,RESOLUTION_RE). - In
history.ts, replace the moved code with imports:import { diffAttributes, diffCriteria, parseTagAttributes, parseCheckboxes, hasResolutionSection, type AttributeChange, type CriteriaChange, type ParsedCheckbox } from './diff.js'and re-export them. - Git transport functions (
getFileCommits,getFileAtCommit,extractEntityHistory,getBatchCommits,extractBatchHistory,isShallowClone) and cache functions stay inhistory.ts. - Run existing tests to confirm no regressions.
Dependencies
None — independent of the scanner-core extraction.
References
- Edge Runtime Compatibility for Plan Package — Edge Runtime Compatibility for Plan Package
- Git-Native Entity History — Git-Native Entity History
Resolution
Completed: 2026-04-14
Branch: claude/edge-runtime-refactor-HOg8v
What was done
- Created
runes/plan/src/diff.tswith all pure diffing functions (diffAttributes, diffCriteria, parseTagAttributes, parseCheckboxes, hasResolutionSection) and their types (AttributeChange, CriteriaChange, ParsedCheckbox) - Updated
runes/plan/src/history.tsto import from diff.ts and re-export all functions and types for backwards compatibility
Notes
- diff.ts has zero dependencies on Node.js APIs — only pure TypeScript
- All 31 history tests pass without modification
Relationships
Dependency of
History
- 888d791statusready→done
- ☑ New file `runes/plan/src/diff.ts` exists and contains all pure diffing functions
- ☑ `diff.ts` has zero imports from `node:fs`, `node:path`, or `node:child_process`
- ☑ `diffAttributes(prev, curr)` is exported from `diff.ts` with `AttributeChange` type
- +7 more criteria
- 7340389Created (ready, high, simple, SPEC-040, plan, architecture, edge-runtime)