Remove Strategy interface abstraction and add commit_linking setting#531
Remove Strategy interface abstraction and add commit_linking setting#531
Conversation
PR SummaryMedium Risk Overview Adds Removes deprecated Written by Cursor Bugbot for commit 6096b8d. Configure here. |
There was a problem hiding this comment.
Pull request overview
This pull request simplifies the codebase architecture by removing an unnecessary abstraction layer and adds a new user-configurable setting for commit linking behavior.
Changes:
- Removed the Strategy interface abstraction since only ManualCommitStrategy ever existed, replacing all interface references with the concrete type
- Added a
commit_linkingsetting ("always"/"prompt") to control whether commits are automatically linked to agent sessions or prompt the user each time - Set new users to default to "always" (auto-link) while existing users retain "prompt" behavior for backward compatibility
- Removed deprecated strategy field warnings from status and doctor commands
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| cmd/entire/cli/strategy/strategy.go | Removed 146-line Strategy interface definition and all its method signatures |
| cmd/entire/cli/strategy/manual_commit.go | Changed NewManualCommitStrategy to return concrete type, removed Name/Description methods and interface check |
| cmd/entire/cli/strategy/manual_commit_hooks.go | Integrated commit_linking setting into PrepareCommitMsg to control auto-linking vs prompting behavior, added nolint comments |
| cmd/entire/cli/strategy/manual_commit_logs.go | Added nolint comment to suppress false positive unparam warning |
| cmd/entire/cli/strategy/session_test.go | Updated test name and implementation to reflect concrete type usage |
| cmd/entire/cli/strategy/manual_commit_test.go | Removed unnecessary type casting since NewManualCommitStrategy returns concrete type |
| cmd/entire/cli/settings/settings.go | Added CommitLinking field, constants, and GetCommitLinking() method; removed deprecated strategy warning functions |
| cmd/entire/cli/settings/settings_test.go | Added tests for commit_linking field loading, merging, and default behavior; removed deprecated strategy tests |
| cmd/entire/cli/config.go | Changed GetStrategy return type from interface to concrete type |
| cmd/entire/cli/setup.go | Set commit_linking to "always" for new installations in both interactive and non-interactive modes |
| cmd/entire/cli/status.go | Removed calls to WriteDeprecatedStrategyWarnings |
| cmd/entire/cli/status_test.go | Removed tests for deprecated strategy warnings |
| cmd/entire/cli/doctor.go | Removed deprecated strategy warning display from sessions fix command |
| cmd/entire/cli/doctor_test.go | Removed test for deprecated strategy warnings and cleaned up unused imports |
| cmd/entire/cli/rewind.go | Updated function signatures to accept concrete type instead of interface |
| cmd/entire/cli/reset.go | Updated function signature to accept concrete type instead of interface |
| cmd/entire/cli/hooks_git_cmd.go | Removed strategyName field from gitHookContext, use constant directly for logging |
| cmd/entire/cli/hook_registry.go | Use strategy.StrategyNameManualCommit constant directly instead of calling strategy.Name() |
| cmd/entire/cli/explain_test.go | Updated test name and implementation to reflect concrete type usage |
| cmd/entire/cli/checkpoint/temporary.go | Removed nolint:wrapcheck comment (minor/unrelated cleanup) |
Comments suppressed due to low confidence (1)
cmd/entire/cli/checkpoint/temporary.go:541
- This lint comment removal appears unrelated to the PR's purpose of removing the Strategy interface and adding commit_linking. The original comment "Propagating context cancellation" was actually correct - context errors should typically be propagated without wrapping to preserve their semantic meaning for context.Canceled and context.DeadlineExceeded checks.
This change should either be reverted or explained in the PR description if it's intentional cleanup.
return nil, branchErr
cmd/entire/cli/settings/settings.go
Outdated
| return fmt.Errorf("parsing commit_linking field: %w", err) | ||
| } | ||
| if cl != "" { | ||
| settings.CommitLinking = cl |
There was a problem hiding this comment.
The commit_linking field accepts any string value without validation. Invalid values like "never", "sometimes", or typos like "allways" will be silently accepted and treated as "prompt" by GetCommitLinking(), which could lead to unexpected behavior.
Consider adding validation to reject invalid values and provide clear error messages. For example, after unmarshaling the value, check if it's one of the allowed constants (CommitLinkingAlways or CommitLinkingPrompt) and return an error if not.
| settings.CommitLinking = cl | |
| switch cl { | |
| case "always", "prompt": | |
| settings.CommitLinking = cl | |
| default: | |
| return fmt.Errorf("invalid commit_linking value %q: must be \"always\" or \"prompt\"", cl) | |
| } |
|
bugbot run |
cc555bc to
d012bfd
Compare
|
Two thoughts on the
|
|
236eafe to
5f88e29
Compare
|
bugbot run |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Comment @cursor review or bugbot run to trigger another review on this PR
| } | ||
|
|
||
| // Helper to save settings to the appropriate file | ||
| // Save settings to the appropriate file. |
There was a problem hiding this comment.
New users never get "always" commit linking default
High Severity
The PR description states new users (via entire enable) should default to commit_linking: "always" (auto-link), while existing users without the setting default to "prompt". However, neither runEnableInteractive nor setupAgentHooksNonInteractive ever sets CommitLinking on the settings object. Since GetCommitLinking() returns CommitLinkingPrompt when the field is empty, all users — including new ones — get "prompt" behavior instead of the intended "always".
Additional Locations (1)
There was a problem hiding this comment.
this was based on outdataed PR description - resolved now
| return fmt.Errorf("saving local settings: %w", err) | ||
| } | ||
| return nil | ||
| } |
There was a problem hiding this comment.
Saving commit linking creates unintended enabled override
Medium Severity
saveCommitLinkingAlways calls settings.LoadFromFile on a potentially nonexistent settings.local.json, which returns a default struct with Enabled: true. It then saves the full struct, writing "enabled": true into local settings as a side effect. This pins an explicit enabled: true in the local file that wasn't user-intended, which could prevent a later project-level enabled: false from taking effect since local settings override project settings during merge.
|
cursor bugbot |
The CLI had a Strategy interface designed for multiple implementations,
but only ManualCommitStrategy ever existed. This removes the interface
and inlines the concrete type, reducing indirection. Also adds a
commit_linking setting ("always"/"prompt") so new users get auto-linked
commits by default while existing users keep the interactive prompt.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Entire-Checkpoint: 91746634036b
… behavior - Validate commit_linking values in loadFromFile() and mergeJSON() to reject typos/invalid values (Copilot feedback) - Only set commit_linking="always" for first-time installations, not when existing users re-run "entire enable" (Cursor feedback) - Applied fix to both setup paths (interactive and non-interactive) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Entire-Checkpoint: 6eed77bbdf5a
…oded string Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Entire-Checkpoint: 23022eee7a62
When existing users re-run "entire enable", clear the deprecated strategy field and explicitly write commit_linking: "prompt" so the settings file reflects the current spec. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Entire-Checkpoint: 7cb76929faa3
…gy field When "entire enable" routes saves to settings.local.json (because settings.json already exists), the project file was left with the stale "strategy" field. Now migrateProjectSettings() loads settings.json directly, clears the deprecated strategy field, writes commit_linking if missing, and saves it back. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Entire-Checkpoint: 64597ed00591
…rce of truth When "entire enable" routes to settings.local.json, the commit_linking field was being written there too. This meant editing settings.json to change commit_linking had no effect because the local file's value always won on merge. Now commit_linking is only written to settings.json (via migrateProjectSettings), and the local file omits it. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Entire-Checkpoint: 0a2fd94192c1
Replace complex setup-time commit_linking logic (isFirstSetup detection, migrateProjectSettings, struct-copy-and-strip) with a simpler UX: users discover commit_linking="always" through the commit prompt itself. When they pick "a", the preference is saved to settings.local.json. - Add ttyConfirmResult type with Yes/No/Always to askConfirmTTY - Add saveCommitLinkingAlways helper for persisting the preference - Update PrepareCommitMsg to handle three-way prompt result - Remove isFirstSetup checks, commit_linking init blocks, and migrateProjectSettings from setup.go - Remove unused CommitLinkingAlways/CommitLinkingPrompt aliases from config.go Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Entire-Checkpoint: 9da9b16fff31
…riptions Restructure askConfirmTTY to display a header, indented details, and self-documenting options ([Y]es / [n]o / [a]lways) so users understand what each choice does without guessing. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Entire-Checkpoint: 74991c8b8e1b
…settings Use raw JSON merge instead of LoadFromFile+SaveLocal to set only the commit_linking field. LoadFromFile returns Enabled:true by default, which would pin an explicit override in settings.local.json that prevents a later project-level enabled:false from taking effect. Also updated PR description to reflect that all users default to "prompt" behavior — users discover "always" through the [Y/n/a] commit prompt, not through setup-time logic. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Entire-Checkpoint: 4bffc26b6ff1
1e42f15 to
09c7882
Compare


Summary
Strategyinterface (~140 lines) that only had one implementation (ManualCommitStrategy), inlining the concrete type throughout the codebase[Y/n/a]to the commit linking prompt so users can opt into auto-linking at commit timea(always), the preference is saved tosettings.local.json— future commits auto-link without prompting"prompt"behavior (viaGetCommitLinking()returning"prompt"when unset). Users discover"always"through the prompt itself, eliminating setup-time complexityisFirstSetupdetection,migrateProjectSettings(), and duplicated save blocks fromsetup.goMigration behavior
[Y/n/a]on first commit with active session, can pickato auto-linkcommit_linkingset)aoptioncommit_linking: "always"aat promptsettings.local.jsongetscommit_linking: "always", future commits auto-linkTest plan
mise run fmtpassesmise run lintpasses (0 issues)mise run test:cipasses (all unit + integration tests)entire enable→ nocommit_linkingin settings (clean)git commit -m "test"with active session → prompt shows[Y/n/a]a→ commit links,settings.local.jsonnow hascommit_linking: "always"git commit -m "test"→ auto-links without prompt🤖 Generated with Claude Code