Skip to content

fix(codegen): preserve hand-written directories during cleanStaleTargets#1256

Closed
pyramation wants to merge 2 commits into
mainfrom
fix/clean-stale-targets-preserve-handwritten
Closed

fix(codegen): preserve hand-written directories during cleanStaleTargets#1256
pyramation wants to merge 2 commits into
mainfrom
fix/clean-stale-targets-preserve-handwritten

Conversation

@pyramation
Copy link
Copy Markdown
Contributor

@pyramation pyramation commented Jun 1, 2026

Summary

removeStaleTargetDirs (added in cleanStaleTargets) deleted any subdirectory not matching a codegen target — including hand-written dirs like config/ and utils/ in sdk/constructive-cli/src/. This broke PR #1255.

Fix: generate() now writes a .generated sentinel file into each target output directory. removeStaleTargetDirs checks for this sentinel (fs.existsSync) before deleting — dirs without it are preserved. No file content scanning.

On the first run after this lands, existing dirs won't have sentinels yet so nothing gets cleaned (safe — codegen overwrites them anyway). Subsequent runs work correctly.

Link to Devin session: https://app.devin.ai/sessions/e3d4f66d70624516b67179748093d772
Requested by: @pyramation

removeStaleTargetDirs now checks for the @generated marker before
deleting a directory. Directories that contain only hand-written code
(e.g. config/, utils/ in constructive-cli) are preserved automatically.

This fixes the schema-propagation workflow deleting sdk/constructive-cli
support files (config/ and utils/) that cli-commands.ts depends on.
@devin-ai-integration
Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

Drop a .generated sentinel file in each target dir during codegen.
removeStaleTargetDirs checks for this sentinel (single fs.existsSync)
instead of scanning .ts file contents for @generated markers.
@pyramation pyramation closed this Jun 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant