village-builder

VB-373: Tools read source through one function

Status: done (2026-11-15) Priority: 3 Size: S Arch: yardstick Phase: implement Design ref: none (code structure). docs/typescript-plan.md (P1); the survey in backlog/VB-055.md. Goal: Eight tools and tests parse or scan the source of src/ as JavaScript text: tools/writes.js (acorn; also used by tests/dependencies.js, tools/stocks.js, tools/write-scopes.js), tests/lint.js and tests/lintrules.js (by line), tests/ownershiprules.js, tests/record.js, tests/commands.js, tests/registry.js and tools/wrap.js. After the move to .ts they would meet type annotations, which acorn rejects. Give them one function, readSource(file) in tools/lib/source.js, that returns the text as JavaScript: the file as it is for .js, and for .ts the text with its types blanked by node:module’s stripTypeScriptTypes (experimental in Node 22.23; it keeps every line and column, which was checked in a scratch directory on 12 November). No behaviour change today, since no file is .ts yet. Acceptance criteria:

Notes (implementation)