Skip to content

Conversation

@johnlindquist
Copy link
Owner

@johnlindquist johnlindquist commented Dec 9, 2025

Summary

This PR implements two user-requested config options:

  • Issue Trust confirmation #34 - Trust confirmation: Adds wt config set trust true to bypass setup command confirmations without needing to pass -t flag every time
  • Issue Worktree path #33 - Worktree path: Adds wt config set subfolder true to create worktrees in a my-app-worktrees/feature pattern instead of my-app-feature siblings

Changes

Trust Config (Issue #34)

  • Added trust boolean to ConfigSchema
  • Added getTrust() and setTrust() functions
  • Updated confirmCommands() in tui.ts to check config setting (OR with -t flag)
  • Added CLI commands: wt config set trust true/false, wt config get trust

Subfolder Config (Issue #33)

  • Added worktreeSubfolder boolean to ConfigSchema
  • Added getWorktreeSubfolder() and setWorktreeSubfolder() functions
  • Updated resolveWorktreePath() to support 4 cases:
    1. Custom path provided
    2. Global defaultWorktreePath configured
    3. NEW: Subfolder mode - my-app-worktrees/feature pattern
    4. Default sibling - my-app-feature pattern
  • Added CLI commands: wt config set subfolder true/false, wt config get subfolder

Usage

Trust mode - skip confirmation prompts for setup commands:

  • wt config set trust true
  • wt config get trust

Subfolder mode - organize worktrees in subdirectory:

  • wt config set subfolder true
  • wt config get subfolder
  • Creates: my-app-worktrees/feature instead of my-app-feature

Test plan

  • All 98 tests pass (8 new tests added)
  • Manual testing of wt config set/get trust true/false
  • Manual testing of wt config set/get subfolder true/false
  • Verified trust config skips confirmation in confirmCommands()
  • Verified subfolder config changes path resolution

Closes #33, closes #34

Summary by CodeRabbit

Release Notes

  • New Features

    • Added trust configuration option to bypass setup command confirmations.
    • Added subfolder configuration option to control worktree placement in subdirectories.
    • Introduced new CLI commands: config get/set trust and config get/set subfolder.
  • Tests

    • Added test coverage for trust and subfolder configuration features.

✏️ Tip: You can customize this high-level summary in your review settings.

- Add `wt config set trust true/false` to bypass setup command confirmations
  without needing to pass -t flag every time (issue #34)
- Add `wt config set subfolder true/false` to create worktrees in a
  my-app-worktrees/feature pattern instead of my-app-feature siblings (issue #33)
- Add getter/setter functions in config.ts for both options
- Update confirmCommands() to check config trust setting
- Update resolveWorktreePath() to support subfolder naming pattern
- Add 8 new tests for the config options (98 total tests pass)
@coderabbitai
Copy link

coderabbitai bot commented Dec 9, 2025

Walkthrough

This PR adds two new configuration options: trust (to bypass confirmation prompts during setup) and worktreeSubfolder (to organize worktrees in dedicated subdirectories). These are integrated into the CLI config commands, utility functions for path resolution and user confirmation, and include corresponding tests.

Changes

Cohort / File(s) Summary
Configuration Schema & APIs
src/config.ts
Added two new boolean config fields (trust, worktreeSubfolder) with default values and corresponding getter/setter methods: getTrust(), setTrust(), getWorktreeSubfolder(), setWorktreeSubfolder()
Config Command Handler
src/commands/config.ts
Extended config command handler to support "trust" and "subfolder" keys in both get and set operations; updated error messages and valid key listings
CLI Command Definitions
src/index.ts
Added four new config subcommands: config get trust, config get subfolder, config set trust <value>, config set subfolder <value>
Utility Integration
src/utils/paths.ts
Updated resolveWorktreePath logic to create worktrees under a *-worktrees subdirectory when subfolder mode is enabled
Confirmation Logic
src/utils/tui.ts
Modified confirmCommands to check trust config setting in addition to CLI flags for bypassing interactive confirmations
Test Coverage
test/config.test.ts
Added test suites for trust configuration and subfolder configuration, including default states, toggling, and truthy value handling

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • src/utils/paths.ts: New conditional branching in resolveWorktreePath requires verification of path construction logic across all cases (custom path, subfolder mode, standard fallback)
  • src/utils/tui.ts: Logic change in confirmation condition merits verification that trust mode correctly bypasses prompts without side effects
  • src/config.ts: Ensure schema defaults and getter/setter implementations are consistent across all new config properties
  • src/commands/config.ts: Review branching logic for both "trust" and "subfolder" keys to ensure symmetry with existing config operations

Poem

🐰 Two configs hop into the fold,
Trust whispers "skip the wait," brave and bold,
While worktrees nest in folders neat,
No scattered chaos on the street—
Organized repos, a rabbit's treat! 🌿

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main feature additions: two new config options (trust and subfolder) for configuring tool behavior.
Linked Issues check ✅ Passed The pull request successfully implements all coding requirements from Issues #33 and #34: trust config bypasses confirmations, subfolder config creates worktrees under repository-specific directories.
Out of Scope Changes check ✅ Passed All changes directly support the stated objectives: config schema extensions, CLI command additions, path resolution logic, and confirmation handling modifications align with issues #33 and #34.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/issues-33-34-config-options

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1301994 and 87413c8.

📒 Files selected for processing (6)
  • src/commands/config.ts (4 hunks)
  • src/config.ts (3 hunks)
  • src/index.ts (2 hunks)
  • src/utils/paths.ts (3 hunks)
  • src/utils/tui.ts (2 hunks)
  • test/config.test.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
src/commands/*.ts

📄 CodeRabbit inference engine (.cursor/rules/project.mdc)

src/commands/*.ts: Leverage Execa to execute Git commands and other external processes.
Provide clear, colored console feedback for success and error messages in CLI commands.

Files:

  • src/commands/config.ts
src/index.ts

📄 CodeRabbit inference engine (.cursor/rules/project.mdc)

src/index.ts: The main entry point for the CLI is src/index.ts, which sets up CLI commands and orchestrates command handlers.
Utilize Commander for parsing CLI commands and handling options.

Files:

  • src/index.ts
🧠 Learnings (5)
📓 Common learnings
Learnt from: CR
Repo: johnlindquist/worktree-cli PR: 0
File: .cursor/rules/project.mdc:0-0
Timestamp: 2025-08-04T13:02:29.847Z
Learning: Applies to src/commands/new.ts : Implement logic for creating new Git worktrees, including options for branch creation, dependency installation, and opening in an editor, in src/commands/new.ts.
Learnt from: CR
Repo: johnlindquist/worktree-cli PR: 0
File: .cursor/rules/project.mdc:0-0
Timestamp: 2025-08-04T13:02:29.847Z
Learning: Applies to src/commands/remove.ts : Handle removal of Git worktrees, including support for force deletion, in src/commands/remove.ts.
Learnt from: CR
Repo: johnlindquist/worktree-cli PR: 0
File: .cursor/rules/project.mdc:0-0
Timestamp: 2025-08-04T13:02:29.847Z
Learning: Applies to src/commands/list.ts : Provide functionality to list existing Git worktrees in src/commands/list.ts.
Learnt from: juristr
Repo: johnlindquist/worktree-cli PR: 20
File: src/commands/extract.ts:124-127
Timestamp: 2025-08-04T14:22:29.156Z
Learning: The worktree-cli project prioritizes consistency across commands. When implementing new commands like `extract`, developers follow existing patterns from similar commands like `new` to maintain API and implementation consistency.
📚 Learning: 2025-08-04T13:02:29.847Z
Learnt from: CR
Repo: johnlindquist/worktree-cli PR: 0
File: .cursor/rules/project.mdc:0-0
Timestamp: 2025-08-04T13:02:29.847Z
Learning: Applies to src/commands/new.ts : Implement logic for creating new Git worktrees, including options for branch creation, dependency installation, and opening in an editor, in src/commands/new.ts.

Applied to files:

  • src/commands/config.ts
  • src/utils/tui.ts
  • src/index.ts
  • src/config.ts
  • src/utils/paths.ts
📚 Learning: 2025-08-04T13:02:29.847Z
Learnt from: CR
Repo: johnlindquist/worktree-cli PR: 0
File: .cursor/rules/project.mdc:0-0
Timestamp: 2025-08-04T13:02:29.847Z
Learning: Applies to src/commands/remove.ts : Handle removal of Git worktrees, including support for force deletion, in src/commands/remove.ts.

Applied to files:

  • src/commands/config.ts
  • src/utils/tui.ts
  • src/index.ts
  • src/config.ts
  • src/utils/paths.ts
📚 Learning: 2025-08-04T13:02:29.847Z
Learnt from: CR
Repo: johnlindquist/worktree-cli PR: 0
File: .cursor/rules/project.mdc:0-0
Timestamp: 2025-08-04T13:02:29.847Z
Learning: Applies to src/commands/list.ts : Provide functionality to list existing Git worktrees in src/commands/list.ts.

Applied to files:

  • src/commands/config.ts
  • src/utils/tui.ts
  • src/index.ts
  • src/config.ts
  • src/utils/paths.ts
📚 Learning: 2025-08-04T14:22:29.156Z
Learnt from: juristr
Repo: johnlindquist/worktree-cli PR: 20
File: src/commands/extract.ts:124-127
Timestamp: 2025-08-04T14:22:29.156Z
Learning: The worktree-cli project prioritizes consistency across commands. When implementing new commands like `extract`, developers follow existing patterns from similar commands like `new` to maintain API and implementation consistency.

Applied to files:

  • src/utils/tui.ts
🧬 Code graph analysis (5)
src/commands/config.ts (1)
src/config.ts (4)
  • getTrust (111-113)
  • getWorktreeSubfolder (123-125)
  • setTrust (116-118)
  • setWorktreeSubfolder (128-130)
src/utils/tui.ts (1)
src/config.ts (1)
  • getTrust (111-113)
src/index.ts (2)
src/commands/config.ts (1)
  • configHandler (4-120)
build/commands/config.js (1)
  • configHandler (3-96)
src/config.ts (1)
build/config.js (1)
  • config (27-30)
src/utils/paths.ts (2)
src/config.ts (1)
  • getWorktreeSubfolder (123-125)
build/utils/paths.js (3)
  • parentDir (68-68)
  • currentDirName (69-69)
  • worktreeName (55-55)
🔇 Additional comments (6)
src/utils/paths.ts (1)

2-2: LGTM! Clean implementation of subfolder mode.

The subfolder path resolution logic is well-integrated and maintains backward compatibility. The documentation accurately describes all four cases, and the implementation correctly creates the my-app-worktrees/feature pattern when subfolder mode is enabled.

Also applies to: 51-56, 92-104

src/config.ts (1)

17-18: LGTM! Config options properly defined with sensible defaults.

The new trust and worktreeSubfolder configuration options follow the existing patterns in the codebase. The schema definitions include appropriate defaults (false), and the getter functions use nullish coalescing to ensure consistent behavior.

Also applies to: 37-45, 110-130

src/utils/tui.ts (1)

4-4: LGTM! Trust config properly integrated into confirmation flow.

The logic correctly checks both the explicit trust flag and the configured trust setting, allowing either to bypass confirmation prompts. This provides flexibility for both one-time and persistent trust modes.

Also applies to: 169-173

test/config.test.ts (1)

385-428: LGTM! Comprehensive test coverage for new config options.

Both test suites follow the established patterns and provide thorough coverage:

  • Default values are verified
  • Enable/disable functionality is tested
  • Alternative truthy values (e.g., "1") are handled
  • Config file persistence is validated

The tests align well with the PR objectives and ensure the features work as expected.

Also applies to: 430-475

src/commands/config.ts (1)

2-2: LGTM! Config handlers properly implemented with clear user feedback.

The get/set handlers for trust and subfolder follow the existing patterns and provide helpful context:

  • Get handlers show current state with explanatory notes
  • Set handlers accept boolean values ("true"/"false"/"1") and provide confirmation
  • Error messages guide users with available options
  • Consistent with the rest of the config command implementation

Also applies to: 21-90

src/index.ts (1)

202-219: LGTM! CLI commands properly defined with clear descriptions.

The new config set/get trust and config set/get subfolder commands follow the established patterns in the CLI:

  • Clear argument descriptions
  • Helpful command descriptions explaining the behavior
  • Proper integration with the configHandler
  • Consistent with existing config commands

Also applies to: 239-248


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

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +205 to +209
"<value>",
"Enable or disable trust mode (true/false)"
)
.description("Set trust mode to skip setup command confirmations.")
.action((value) => configHandler("set", "trust", value))

Choose a reason for hiding this comment

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

P1 Badge Rebuild missing for new config subcommands

The new config set trust/subfolder commands added here only exist in the TypeScript source, but the compiled entrypoint (build/index.js, which is what the wt bin points to and what test/config.test.ts executes via CLI_PATH) was not regenerated in this commit. The current build still registers only editor/provider/worktreepath, so on a fresh checkout or published package without manually re-running pnpm build, wt config set trust/subfolder will fail with an unknown-command error and the newly added tests will break. Please regenerate and commit the build outputs or run the tests against the source.

Useful? React with 👍 / 👎.

CaptainCodeAU added a commit to CaptainCodeAU/worktree-cli that referenced this pull request Dec 23, 2025
- Merged PR johnlindquist#35 (trust and subfolder config options)
- Implemented wt status command with comprehensive git status info
- Added 6 tests for status command (104 total tests passing)
- Created Claude Code slash command at .claude/commands/worktree.md
- Updated documentation with progress and new features
- Fixed test issues related to trust mode configuration
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.

Trust confirmation Worktree path

2 participants