Skip to content

feat: make generate command idempotent (write only changed files)#968

Merged
dyoshikawa merged 2 commits intomainfrom
feat/idempotent-generate
Feb 6, 2026
Merged

feat: make generate command idempotent (write only changed files)#968
dyoshikawa merged 2 commits intomainfrom
feat/idempotent-generate

Conversation

@dyoshikawa
Copy link
Owner

@dyoshikawa dyoshikawa commented Feb 6, 2026

Summary

  • Move diff detection logic into writeAiFiles() and writeAiDirs() so both normal and dry-run modes skip files with no actual changes
  • Change removeOrphanAiFiles() and removeOrphanAiDirs() to return orphan count (Promise<number>) instead of Promise<void>
  • Remove 4 redundant detect functions (detectFileDiff, detectOrphanFileDiff, detectDirDiff, detectOrphanDirDiff) from generate.ts, deriving hasDiff from write/orphan counts instead
  • Eliminate duplicate content computation in writeAiDirs (compute once in diff-check phase, reuse in write phase)
  • Add early exit in otherFiles diff-check loop when dirHasChanges is already true
  • Add unit tests for idempotent write behavior (writeAiFiles, writeAiDirs, return value assertions for removeOrphanAiFiles/removeOrphanAiDirs)

Test plan

  • pnpm cicheck passes (all 3690 tests, format, lint, typecheck, spell, secret checks)
  • Manual: run pnpm dev generate --targets "*" --features "*", then re-run with --dry-run — no "Would write" should appear
  • Manual: run pnpm dev generate --check --targets "*" --features "*" — exit code 0
  • Manual: edit a .rulesync/rules/*.md file, then --dry-run — only that file shows "Would write"

🤖 Generated with Claude Code

cm-dyoshikawa and others added 2 commits February 5, 2026 22:33
…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>
@dyoshikawa dyoshikawa merged commit 10734e1 into main Feb 6, 2026
10 checks passed
@dyoshikawa dyoshikawa deleted the feat/idempotent-generate branch February 6, 2026 08:57
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.

2 participants