feat: make generate command idempotent (write only changed files)#968
Merged
dyoshikawa merged 2 commits intomainfrom Feb 6, 2026
Merged
feat: make generate command idempotent (write only changed files)#968dyoshikawa merged 2 commits intomainfrom
dyoshikawa merged 2 commits intomainfrom
Conversation
…ual diffs Move diff detection into writeAiFiles/writeAiDirs so both normal and dry-run modes skip unchanged files. Remove the now-redundant detectFileDiff, detectOrphanFileDiff, detectDirDiff, and detectOrphanDirDiff functions from generate.ts, deriving hasDiff from write/orphan counts instead. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…dempotent write tests Reuse pre-computed content in writeAiDirs write phase instead of recomputing, add early exit in otherFiles diff-check loop, and add unit tests for idempotent write behavior in both FeatureProcessor and DirFeatureProcessor. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
writeAiFiles()andwriteAiDirs()so both normal and dry-run modes skip files with no actual changesremoveOrphanAiFiles()andremoveOrphanAiDirs()to return orphan count (Promise<number>) instead ofPromise<void>detectFileDiff,detectOrphanFileDiff,detectDirDiff,detectOrphanDirDiff) fromgenerate.ts, derivinghasDifffrom write/orphan counts insteadwriteAiDirs(compute once in diff-check phase, reuse in write phase)otherFilesdiff-check loop whendirHasChangesis already truewriteAiFiles,writeAiDirs, return value assertions forremoveOrphanAiFiles/removeOrphanAiDirs)Test plan
pnpm cicheckpasses (all 3690 tests, format, lint, typecheck, spell, secret checks)pnpm dev generate --targets "*" --features "*", then re-run with--dry-run— no "Would write" should appearpnpm dev generate --check --targets "*" --features "*"— exit code 0.rulesync/rules/*.mdfile, then--dry-run— only that file shows "Would write"🤖 Generated with Claude Code