Uh oh!
There was an error while loading. Please reload this page.
refactor: extract gitignore helpers out of scaffold.ts - #884
Conversation
amrmelsayed
commented
May 27, 2026
Architect ReviewLow-risk refactor. 589/352 across 11 files looks large but the breakdown is pure code-motion: 151 LOC moved into new CMAP unanimous (gemini=APPROVE, codex=APPROVE, claude=APPROVE — all HIGH confidence, zero key issues). Verified
Design observation worth keepingThe line-level append-only invariant from #880 transferred cleanly to the new home — VerdictApproved. Per PIR protocol, the Architect review |
Uh oh!
There was an error while loading. Please reload this page.
PIR Review: Extract gitignore helpers out of
scaffold.tsFixes#882
Summary
Moved the three gitignore management helpers (
createGitignore,updateGitignore,backfillGitignore), their constants (CODEV_GITIGNORE_ENTRIES,FULL_GITIGNORE_CONTENT), the privateparseEntryLineshelper, and the three gitignore-shaped types out ofpackages/codev/src/lib/scaffold.tsinto a new dedicatedpackages/codev/src/lib/gitignore.ts.scaffold.tsnow holds only genuine scaffolding helpers (directory creation, skeleton copying, root-file templating). Pure file move + import rewire — zero behavior change, no renames, no function-shape changes.Files Changed
packages/codev/src/lib/gitignore.ts(+151 / -0, new)packages/codev/src/lib/scaffold.ts(+8 / -116 net)packages/codev/src/commands/init.ts(+1 / -1)packages/codev/src/commands/adopt.ts(+1 / -1)packages/codev/src/commands/update.ts(+3 / -1)packages/codev/src/__tests__/gitignore.test.ts(+233 / -0, new)packages/codev/src/__tests__/scaffold.test.ts(+0 / -209)codev/plans/882-refactor-extract-gitignore-hel.md(+82 / -0, plan artifact)codev/state/pir-882_thread.md(+24 / -0, thread artifact)Commits
27f055d8[PIR refactor: extract gitignore helpers out of scaffold.ts #882] Plan draft63689fac[PIR refactor: extract gitignore helpers out of scaffold.ts #882] Extract gitignore helpers out of scaffold.ts15418d71[PIR refactor: extract gitignore helpers out of scaffold.ts #882] Thread: implementation complete(Plus six
chore(porch)commits porch wrote at phase / gate transitions — these document the protocol's state-machine moves but contain no code changes.)Test Results
pnpm build(root, builds@cluesmith/codev-corethen@cluesmith/codev): ✓ passpnpm test -- run(full vitest suite): ✓ pass — 151 files, 3187 tests, 0 failed, 13 pre-existing skipsdev-approvalchecksblock re-ranbuild(5.5s) andtests(20.2s) atporch done: both greencreateGitignore | updateGitignore | backfillGitignore | CODEV_GITIGNORE_ENTRIES | FULL_GITIGNORE_CONTENT | parseEntryLines | BackfillGitignoreResult | BackfillGitignoreOptions | UpdateGitignoreResult): zero hits inscaffold.ts/scaffold.test.ts; all consumers reach the new module via../lib/gitignore.jsdev-approvalgateArchitecture Updates
No arch.md changes needed — this PR reorganizes file boundaries within
packages/codev/src/lib/without changing module responsibilities, public CLI surface, or any cross-package contract. The newgitignore.tsis a peer ofscaffold.tsin the samelib/folder, consumed by the same three commands. No new layer, no new dependency direction, no new pattern. The arch doc's existing description of init / adopt / update remains accurate.Lessons Learned Updates
No lessons-learned.md changes needed — this was a mechanical extraction predicated on a clear smell (filename no longer matches contents) that the issue itself articulated. The decision to split was already made and validated by the post-merge discussion on PR #881; the execution carried no surprises worth capturing as durable wisdom. The general pattern ("watch for header drift; rename or split when a file's name stops matching its contents") is well-known and not specific to this codebase.
Things to Look At During PR Review
gitignore.test.tsvs the deleted blocks fromscaffold.test.ts): the fourdescribeblocks (createGitignore,updateGitignore,CODEV_GITIGNORE_ENTRIES,backfillGitignore (issue #880)) moved verbatim — sameit()bodies, same assertions. The new file ships its own minimalbeforeEach(justtempDir— the scaffold-only skeleton fixtures aren't needed here) instead of inheritingscaffold.test.ts's heavier setup. Worth diffing the moved blocks line-by-line if you want to confirm zero behavioral drift in the tests themselves.scaffold.test.ts(lines 274–) — it readsscaffold.tssource directly, so it correctly belongs with the scaffold tests. I considered adding a parallel regression that assertsscaffold.tssource no longer containsgitignore/CODEV_GITIGNORE_ENTRIES-style strings (mirroring the projectlist pattern), and flagged the option in the plan, but deferred the inclusion decision to dev-approval review and ultimately did not add it. Cheap to drop in if you want it.from '../lib/scaffold.js'block to two blocks — scaffold helpers fromscaffold.js, gitignore helpers fromgitignore.js. Symmetric with the existing pattern elsewhere in the codebase.parseEntryLinesstayed module-private, same as before. No tests reach it directly — only viabackfillGitignore.How to Test Locally
For reviewers pulling the branch:
pir-882→ View Diff (auto-detects the repo's default branch)afx dev pir-882works if you want to smoke-test the CLI from inside the worktreepnpm buildclean (catches any missed import)pnpm test -- run gitignore scaffold init adopt updategreen — the rewired commands exercise the moved imports end-to-end (init writes a fresh.gitignore, adopt merges into existing, update backfills missing entries)node packages/codev/dist/cli.js init /tmp/codev-smoke --yes && cat /tmp/codev-smoke/.gitignore— expect the Codev block including.architect-role.mdand the standardnode_modules//dist// OS-file entries