Skip to content

feat: add --force option to regenerate content even if unchanged#9

Merged
twangodev merged 3 commits intomainfrom
feat/force-gen
Mar 10, 2026
Merged

feat: add --force option to regenerate content even if unchanged#9
twangodev merged 3 commits intomainfrom
feat/force-gen

Conversation

@twangodev
Copy link
Owner

@twangodev twangodev commented Mar 10, 2026

Summary by CodeRabbit

  • New Features
    • Added a new --force flag to the generate command (defaults to false).
    • CLI and configuration now recognize and propagate the force option so the generate flow respects the flag across invocations.

Copilot AI review requested due to automatic review settings March 10, 2026 08:25
@coderabbitai
Copy link

coderabbitai bot commented Mar 10, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d5629424-4896-446d-a82d-06688d112fbb

📥 Commits

Reviewing files that changed from the base of the PR and between 2272e0b and 6858139.

📒 Files selected for processing (1)
  • src/commands/generate.ts

📝 Walkthrough

Walkthrough

Adds a new --force CLI flag (default false) that, when set, bypasses the "content unchanged" skip during audio generation; the flag is wired through CLI types and resolved configuration and used to conditionally disable the existing-data skip check.

Changes

Cohort / File(s) Summary
CLI & Types
src/cli.ts, src/types/index.ts
Added optional force option to CLI options and GenerateOptions type (defaults to false).
Config Resolution
src/core/config.ts
Added force: boolean to ResolvedConfig and defaulted it to false when resolving config from options.
Generate Command
src/commands/generate.ts
Skip logic for existing audio data is now gated by config.force — when force is true, existing audio data is ignored and generation proceeds; otherwise existing-data check behaves as before.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant CLI
  participant Config
  participant Generator
  participant Filesystem

  User->>CLI: run `generate --force` or without
  CLI->>Config: parse options (include force)
  Config-->>CLI: resolved config (force: true|false)
  CLI->>Generator: invoke generate with config
  Generator->>Filesystem: read file content
  alt config.force is false
    Generator->>Generator: extractExistingAudioData(content)
    Generator-->>Generator: if hash/voice match -> skip generation
  else config.force is true
    Generator-->>Generator: skip extraction (force override)
    Generator->>Filesystem: proceed to generate/update audio
  end
  Generator->>Filesystem: write/update file (when generating)
  Generator-->>CLI: result/status
  CLI-->>User: print outcome
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 I hopped in with a tiny course,
A little flag named --force,
When content's same and silence reigns,
I nudge the maker, break the chains.
Regenerate — a joyful bounce! 🥕✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title accurately describes the main change: adding a --force option to enable content regeneration even when unchanged. It directly corresponds to the file modifications across cli.ts, generate.ts, config.ts, and types/index.ts.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/force-gen

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a --force option to the generate command so users can regenerate TTS audio and reinject the MDX component even when the content hash and voice IDs indicate nothing has changed.

Changes:

  • Introduces force in GenerateOptions and ResolvedConfig.
  • Wires --force through the CLI and config resolution.
  • Updates generate skip logic to respect --force.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/types/index.ts Adds force?: boolean to GenerateOptions typing.
src/core/config.ts Adds force to resolved config and sets a default.
src/commands/generate.ts Bypasses “content unchanged” skipping when --force is set.
src/cli.ts Exposes --force CLI flag for the generate command.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +101 to +105
// Check if file already has audio component with hash
const existingData = await extractExistingAudioData(content, config.componentName);

// If component exists with matching hash and voice IDs, skip
if (existingData) {
// If component exists with matching hash and voice IDs, skip (unless --force)
if (existingData && !config.force) {
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When --force is enabled, we still call extractExistingAudioData(...), which parses the MDX AST and can be relatively expensive. Consider short-circuiting this (e.g., only extracting existing data when !config.force) to avoid unnecessary work on large docs sets.

Copilot uses AI. Check for mistakes.
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot open a new pull request to apply changes based on this feedback

Copy link
Contributor

Copilot AI commented Mar 10, 2026

@twangodev I've opened a new pull request, #10, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI and others added 2 commits March 10, 2026 03:36
Co-authored-by: twangodev <48845764+twangodev@users.noreply.github.com>
Co-authored-by: twangodev <48845764+twangodev@users.noreply.github.com>
@twangodev twangodev merged commit 16d8955 into main Mar 10, 2026
4 of 5 checks passed
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.

3 participants