Implement the following plan: Plan: Deprecation warning for strategy field in settings…
- User
Implement the following plan:
Plan: Deprecation warning for
strategyfield in settingsContext
The
auto-commitstrategy was removed andmanual-commitis the only strategy. Users may still have"strategy": "auto-commit"in their settings files. BecauseDisallowUnknownFields()is used, this causes a hard error — breaking the CLI.Changes (~20 lines of production code)
1.
cmd/entire/cli/settings/settings.goAdd deprecated
Strategyfield to struct:go// Deprecated: no longer used. Exists to tolerate old settings files. Strategy string `json:"strategy,omitempty"`Add helper:
gofunc FilesWithDeprecatedStrategy() []string { var files []string for _, rel := range []string{EntireSettingsFile, EntireSettingsLocalFile} { abs, _ := paths.AbsPath(rel) s, err := LoadFromFile(abs) if err != nil || s.Strategy == "" { continue } files = append(files, rel) } return files }2.
cmd/entire/cli/status.goIn
runStatus()after status line, and inrunStatusDetailed()after effective status:gofor _, f := range settings.FilesWithDeprecatedStrategy() { fmt.Fprintf(w, "Warning: %s contains deprecated \"strategy\" field. Remove it to silence this warning.\n", f) }3.
cmd/entire/cli/doctor.goIn
runSessionsFix()at the start:gofor _, f := range settings.FilesWithDeprecatedStrategy() { fmt.Fprintf(cmd.OutOrStdout(), "Warning: %s contains deprecated \"strategy\" field. Remove it to silence this warning.\n", f) } Assistant
I'll start by reading the files I need to modify.
Assistant
Let me also check the test helper functions used in
status_test.go.Assistant
Now I have a clear picture. Let me implement all the changes.
Assistant
Now add the
FilesWithDeprecatedStrategyhelper function at the end of the file.Assistant
That lint warning is pre-existing (not from my change). Now update
status.goto add warnings in bothrunStatusandrunStatusDetailed.Assistant
Right,
settingsis the package, not the variable. Let me check the import and the variable name.Assistant
The variable
settingson line 80 shadows the package name. I need to use the package-level call. Let me check the variable name used.Assistant
The local variable
settingsshadows the package import. I need to use a qualified package reference. Let me fix both places to use the package name properly. Sincesettings(the variable) shadows the package, I'll need to reference the function through a different approach. Let me check if there's an import alias or if I should just move the call before the variable assignment.The simplest approach: call
settings.FilesWithDeprecatedStrategy()before the local variablesettingsis declared, or use the package function directly. Actually, inrunStatus, the variablesettingsis declared. But theFilesWithDeprecatedStrategyis a package-level function on thesettingspackage. I need to avoid shadowing. Let me just move the warning call to before the variable is used, or better yet, rename the call point. Actually the cleanest fix is to capture it before the shadowing variable:Assistant
Now I need to update the remaining references to
settingsinrunStatusto uses:Assistant
I see — there are still references to the old variable name
settingsthat need to bes. Let me re-read the current state.Assistant
I see — line 93 still uses
settings.Enabled(the old variable name). I need to change it tos.Enabled.Assistant
Now the
runStatusDetailedfunction already has the warning in the right place since the variable nameeffectiveSettingsdoesn't shadow the package. But line 109 usessettings.FilesWithDeprecatedStrategy()directly in the for loop — that will work sincesettingsis the package import at that scope. Let me verifyrunStatusDetaileddoesn't have any shadowing issues.Assistant
Good —
runStatusDetailedusessettings.LoadFromFileat line 117/126 andsettings.FilesWithDeprecatedStrategy()at line 109 — no shadowing issue there.Now update
doctor.goto add the warning at the start ofrunSessionsFix.Assistant
Now I need to add the
settingsimport todoctor.go.Assistant
Wait, the import may not be resolving. Let me check - the diagnostic just might be delayed. Let me verify the current state of the file.
Assistant
The import is there. The diagnostic was just stale. Now let me add the tests. First the settings test.
Assistant
Now I need to check whether these tests use
t.Chdir(which means they can't uset.Parallel()). The existing tests uset.Chdir, so my new tests will follow the same pattern. Let me also check for thepaths.ClearRepoRootCachefunction usage.Assistant
The existing settings tests don't call
ClearRepoRootCache. They uset.Chdirand manually create.gitdirectories. I'll follow the same pattern and add tests at the end of the file.Assistant
Now add the status test for the deprecation warning.
Assistant
Now let me also check if
doctor_test.goexists.Assistant
Now let me check where
setupGitRepoForPhaseTestis defined.Assistant
The doctor test for the deprecation warning needs to use the
runSessionsFixfunction which requires a*cobra.Command. Let me think about the simplest approach. The doctor tests usesetupGitRepoForPhaseTestwhich doest.TempDir()+ git init but doesn'tt.Chdirinto it. However,runSessionsFixcallsstrategy.ListSessionStates()andsettings.FilesWithDeprecatedStrategy()which both need to be in the right directory.Actually, looking more carefully at the plan, the doctor test isn't critical — the main value is in the settings and status tests. The doctor warning is a simple code path. But let me add a basic test. I need to look at how the cobra command is set up for testing.
Actually, looking at the doctor code,
runSessionsFixtakes a*cobra.Commandandbool. The simplest test would be to create a test that sets up the repo with a deprecated strategy field and calls the function, checking that the output contains the warning. Let me add a test.Assistant
The doctor test needs
runSessionsFixwhich needs acobra.Command. Let me check how other command tests create commands in this codebase.Assistant
I can create a simple
cobra.Commandand use its buffer. Let me add the doctor test.Assistant
Now add the test at the end of the file.
Assistant
Now let me also check that the
mergeJSONfunction in settings handles thestrategyfield properly. Since it usesDisallowUnknownFields()and then manually merges fields, I should check ifstrategyfrom local settings would work correctly during merge. Looking atmergeJSON, it does strict decoding into atemp EntireSettingsfirst (which now has theStrategyfield), so that's fine. But the manual merge below doesn't mergestrategy— that's actually okay because we only need to tolerate it, not actively merge it.Now let me run the format and lint checks.
Assistant
No lint issues. Now let me run the tests.
Assistant
The
TestFilesWithDeprecatedStrategytest failed becauseFilesWithDeprecatedStrategyrelies onpaths.AbsPath()which uses the repo root cache. The test creates.gitmanually but doesn't clear the cache. Let me check whatpaths.AbsPathdoes.Assistant
The issue is that
RepoRoot()usesgit rev-parse --show-toplevel, but the settings test only creates a.gitdirectory — it doesn't actually rungit init. Sogit rev-parsefails whent.Chdirmoves to the temp dir. The existing tests (likeTestLoad_AcceptsValidKeys) only callLoad()which callspaths.AbsPathinternally, and it falls back to relative paths. But myFilesWithDeprecatedStrategyfunction continues onerrfromAbsPath.Wait, let me look again at the test. The test does
t.Chdir(tmpDir)and creates.git/manually. Thegit rev-parse --show-toplevelcommand should work since.gitexists... actually no,git rev-parsedoesn't just check for the.gitdirectory — it needs a proper git repository. Since the test only creates the directory, not a full repo, it might fail.Assistant
Now run the tests again.
Assistant
All tests pass. Let me also verify lint is clean.
Assistant
Everything passes. Here's a summary of the changes:
Changes made
1.
cmd/entire/cli/settings/settings.go- Added deprecated
Strategy stringfield toEntireSettingsstruct withjson:"strategy,omitempty"tag — this allowsDisallowUnknownFields()to accept old settings files with"strategy": "auto-commit"instead of erroring - Added
FilesWithDeprecatedStrategy()helper that checks both settings files and returns paths of those containing the deprecated field
2.
cmd/entire/cli/status.go- In
runStatus(): prints a deprecation warning after the status line for each file with astrategyfield - In
runStatusDetailed(): prints the same warning after the effective status line - Renamed local variable
settingstosin to avoid shadowing the package import
- Added deprecated
- User
I do want a warning message more user friendly, and entire doctor should display the warning at the end of the prompt
Assistant
Now let me make both changes. First, I'll create a shared helper for the warning message to keep it consistent, then move the doctor warning to the end.
Assistant
I'll add a
WriteDeprecatedStrategyWarningshelper to the settings package that handles both the detection and the formatted output, making the warning message friendlier.Assistant
The diagnostic is premature — the
ioimport is used byWriteDeprecatedStrategyWarnings. Let me verify the file is correct.Assistant
Good, the
ioimport is used. Now updatestatus.goanddoctor.goto use the new helper.Assistant
Now move the doctor warning from the start to the end of
runSessionsFix.Assistant
Now add it at the end, just before the final
return nil.Assistant
I also need to handle the early returns. There are two:
len(states) == 0andlen(stuck) == 0. The warning should appear at the very end regardless. Let me restructure to use adefer.Assistant
Now update the tests to match the new message format. Let me update the test assertions.
Assistant
The status tests check for
"deprecated"and"strategy". The new message says"strategy" in .entire/settings.json is no longer needed. Let me update the assertions to match.Assistant
Now update the doctor test.
Assistant
Now run format, lint, and tests.
Assistant
All passing. Here's what changed:
Warning message — now reads:
codeNote: "strategy" in .entire/settings.json is no longer needed and can be removed.instead of the more technical
Warning: ... deprecated "strategy" field. Remove it to silence this warning.Doctor — warning now appears at the end (via
defer) so it shows after the stuck sessions output rather than before it.