Skip to content

refactor: extract gitignore helpers out of scaffold.ts #882

Closed

Description

@amrmelsayed

Context

packages/codev/src/lib/scaffold.ts was originally extracted in Maintenance Run 0004 to deduplicate logic shared between codev init and codev adopt — its header still says "Scaffold utilities for codev init and adopt commands". Since then it has drifted:

"Scaffold" implies creating new project structure, but the file now also handles in-place repair of existing projects. The name no longer matches the contents.

Proposed change

Extract gitignore-related helpers into a new file:

packages/codev/src/lib/gitignore.ts

Moves:

  • CODEV_GITIGNORE_ENTRIES constant
  • FULL_GITIGNORE_CONTENT constant
  • createGitignore() (used by init)
  • updateGitignore() (used by adopt)
  • backfillGitignore() (used by update)
  • The internal parseEntryLines() helper
  • The BackfillGitignoreResult / BackfillGitignoreOptions / UpdateGitignoreResult types

scaffold.ts keeps only the genuine scaffolding helpers — createUserDirs, copyConsultTypes, copyResourceTemplates, copyRootFiles, copyRoles, copyProtocols, copySkills, createProjectsDir, copyDirRecursive.

Acceptance criteria

  • New file packages/codev/src/lib/gitignore.ts contains all gitignore-related exports listed above
  • scaffold.ts no longer references gitignore behavior
  • Import sites updated (init.ts, adopt.ts, update.ts, the test files)
  • Existing test coverage moved to a new gitignore.test.ts (or split out of scaffold.test.ts) — no test deleted or weakened, only relocated
  • tsc clean, full test suite green

Out of scope

  • No behavior change. This is a pure file move + import update.
  • No renaming of the functions themselves.
  • Not pruning scaffold.ts further (e.g. moving copyRoles to a roles.ts file). One refactor at a time.

Discovered while

Reviewing PR #881 (issue #880). The file's name vs. its current contents came up during post-merge discussion.

Activity

  1. self-assigned this
    on May 27, 2026
  2. added
    area/coreArea: shared core library / forge abstraction (packages/core, packages/codev/src/lib)
    on May 27, 2026
  3. amrmelsayed commented on May 27, 2026

    @amrmelsayed
    CollaboratorAuthor

    On it! Working on this with the PIR protocol (plan + dev-approval gates before PR).

  4. added 4 commits that reference this issue on May 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/coreArea: shared core library / forge abstraction (packages/core, packages/codev/src/lib)

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions