Repository navigation
feat(config): make baseline the default path.mode - #738
linghengqian wants to merge 4 commits into
Conversation
`legacy` keeps every PATH entry in front of vfox's first directory in front of it, so a system directory that macOS path_helper or the Windows machine PATH put there keeps winning over the version `vfox use` selected (version-fox#337, version-fox#732). `baseline` fixes that by moving what was already in PATH when `vfox activate` ran behind vfox's directories, but everyone had to opt in with `vfox config path.mode baseline`. It is the default now; `vfox config path.mode legacy` brings back the behavior of 1.0.x. - config.DefaultPathMode names the default in one place. EmptyPath, both fallbacks of Path.EffectiveMode and the starting mode of pathPolicy() use it. - An empty or unknown mode is the default, as before, so a typo lands on baseline instead of failing `vfox env`, which runs at every prompt. EffectiveMode names `legacy` as a case of its own now, because it is no longer what the fallback returns. - A shell without a recorded baseline still behaves like legacy in every mode, so upgrading does not reorder the PATH of a running shell. - The path.shadowed hint for a directory that was already in PATH at activation can only come up in legacy mode now. It says so before it suggests `vfox config path.mode baseline`. Tests: the eleven that asserted the old default are updated. Tests that used `baseline` as the value that has to survive a merge, a save or a shared config would have passed for the wrong reason once it became the default, so they use `legacy`. New checks pin the default and its fallbacks, and that an unconfigured vfox leaves the PATH of a shell without a baseline alone. Part of version-fox#737
Quick Start and both READMEs no longer ask new installations to run `vfox config path.mode baseline`, and the configuration guide, the FAQ and AGENTS.md stop announcing that the default will change. Quick Start and the READMEs read as they did before version-fox#736 added that step. - Configuration guide (en, zh-hans): the section described what `legacy` does as the general behavior. It now says that `baseline` is the default, what `legacy` is, and how to keep the behavior of vfox 1.0.x: `vfox config path.mode legacy`, or `path.preserve` when only a few directories have to stay in front. - FAQ (en, zh-hans): a system JDK or a Homebrew node in front of vfox's directories no longer wins by default. It lists what still can (pnpm and anything added after `vfox activate`) and what to check when `vfox doctor` still names a system directory: a shell that was started before the upgrade, `legacy`, or `path.preserve`. - AGENTS.md: where the default is defined and what has to stay in step. Part of version-fox#737
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #738 +/- ##
=======================================
Coverage 55.58% 55.58%
=======================================
Files 112 112
Lines 8448 8448
=======================================
Hits 4696 4696
Misses 3293 3293
Partials 459 459 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
linghengqian
left a comment
There was a problem hiding this comment.
CC @aooohan . Could you please take a look and review this?
linghengqian
left a comment
There was a problem hiding this comment.
CC @version-fox/vfox-maintainers @version-fox/vfox-committers . Could you please take a look and review this?
AGENTS.md was the only file with a conflict: the `path.mode` bullets. Kept from this branch: the "Final PATH assembly" bullet that names `baseline` as the default, and the "`baseline` is the default" bullet that replaces "`legacy` stays the default". Kept from main: the extended "`vfox activate` records" bullet (`projectToolsKey`, `installsStamp`, `linksStamp`), which this branch does not touch. The merged tree builds, `go vet` is clean on Linux, Windows and macOS, and `go test` passes on every package except internal/shared/printer, which needs a TTY.
There was a problem hiding this comment.
🟡 Changes recommended
AGENTS.md overstates legacy compatibility by omitting that aggressive mode still demotes certain entries when __VFOX_ORIG_PATH is absent.
1 open issue
What changed in this PR
This pull request changes the default path.mode from legacy to baseline, putting vfox-managed SDK paths ahead of inherited PATH entries while preserving paths added after activation. It updates configuration behavior, diagnostics, tests, documentation, and migration guidance.
Changes:
- Centralizes
baselineas the default path mode while preserving explicitlegacybehavior. - Updates PATH-policy, activation, cache, diagnostic, CLI, and configuration tests.
- Revises English and Chinese documentation and repository guidance for the new default.
| File | Description |
|---|---|
README.md |
Removes the manual baseline configuration step. |
README_CN.md |
Removes the corresponding Chinese configuration step. |
internal/sdk/check.go |
Updates PATH shadow diagnostics for legacy mode. |
internal/sdk/check_test.go |
Tests diagnostics under default, baseline, and legacy modes. |
internal/env/pathpolicy.go |
Uses the centralized default PATH mode. |
internal/env/pathpolicy_test.go |
Updates PATH ordering and policy-cache coverage. |
internal/env/context.go |
Documents baseline as the default mode. |
internal/config/path.go |
Defines the baseline default and updates mode fallbacks. |
internal/config/path_test.go |
Verifies defaults, fallbacks, merging, and serialization. |
internal/config/new_file_test.go |
Tests new-file and shared-configuration behavior. |
docs/zh-hans/guides/quick-start.md |
Removes obsolete baseline setup instructions. |
docs/zh-hans/guides/faq.md |
Updates Chinese PATH-shadowing guidance. |
docs/zh-hans/guides/configuration.md |
Documents the new default and legacy compatibility option. |
docs/guides/quick-start.md |
Removes obsolete baseline setup instructions. |
docs/guides/faq.md |
Updates PATH-shadowing explanations and troubleshooting. |
docs/guides/configuration.md |
Documents baseline as the default and explains legacy migration. |
cmd/commands/path_cli_test.go |
Tests CLI PATH behavior for default, baseline, and legacy modes. |
cmd/commands/doctor_cli_test.go |
Updates shadow-diagnostic coverage. |
cmd/commands/config_cli_test.go |
Updates configuration and shared-setting tests. |
cmd/commands/alias_cli_test.go |
Verifies alias changes preserve non-default shared settings. |
AGENTS.md |
Updates guidance for the baseline default; one statement should be scoped to baseline mode because aggressive mode behaves differently without a recorded baseline. |
Review effort: Lite
AGENTS.md said that a shell without a recorded baseline behaves like `legacy` in every mode. Only `baseline` does: pathPolicy.keepInFront returns false for `aggressive` whether or not a baseline was recorded, and `legacy` never looks at one. Say that, instead of changing the policy: `aggressive` is an opt-in mode that this change does not touch. TestEnvWithoutABaselineBehavesLikeLegacyInEveryMode had the same overstatement in its name and only covered the default and `baseline`. It is now TestEnvWithoutABaselineOnlyBaselineModeFallsBackToLegacy and asserts the PATH of all four cases: the default, `baseline`, `legacy` and `aggressive`. Making `aggressive` follow `legacy`, or `baseline` stop doing so, fails it. Review feedback on version-fox#738.

Part of #737 (item 3, "Change the default of
path.modetobaseline").What changes
path.modedefaults tobaseline. The default waslegacy, which keeps everyPATHentry in front of vfox's first directory in front of it, so a system directory that macOSpath_helperor the Windows machinePATHput there kept winning over the versionvfox useselected (#337, #732).baselinemoves what was already inPATHwhenvfox activateran behind vfox's directories, and keeps what is added afterwards (a virtualenv, the$PNPM_HOMEofpnpm setup) in front. The way back is one line:vfox config path.mode legacy.Checked with real binaries, built from
mainand from this branch. The shell'sPATHis<system dir with alphatool>:<vfox sdks dir>:/usr/bin:/binwhenvfox activate bashruns, which is the shape behind #337 and #732:alphatoolrunsPATHstarts withmain(defaultlegacy)vfox config path.mode legacypath.preservelisting the system dirCode
config.DefaultPathModenames the default in one place.EmptyPath, both fallbacks ofPath.EffectiveModeand the starting mode ofpathPolicy()use it: the four places listed in Follow-ups of #736: plugin updates, the path.mode default and vfox config #737.vfox env, which runs at every prompt.EffectiveModehas to namelegacyas a case of its own now. Flipping only the fallbacks would turnmode: legacyintobaseline. I removed the case to see: 12 tests in all four packages fail.legacyinbaselinemode, the default, so upgrading does not reorder thePATHof a shell that is already running. It gets the new default when it is restarted.aggressivenever reads the baseline and demotes the same entries with or without one.TestEnvWithoutABaselineOnlyBaselineModeFallsBackToLegacycovers the unconfigured case and each of the modes.path.shadowedhint for a directory that was already inPATHat activation said to runvfox config path.mode baseline. That finding can only come up inlegacymode now (baselinemoves such a directory behind vfox's, and without a recorded baseline the source is "unknown"), so the hint says that first. The other two hints are still right and unchanged.Tests
The eleven tests that the flip breaks, as counted in #737, are updated: 4 in
cmd/commands, 4 ininternal/config, 2 ininternal/env, 1 ininternal/sdk.Five more kept passing for the wrong reason. They used
baselineas the value that has to survive a merge, a save, the first run with a sharedVFOX_HOMEor an alias change; once it is the default, losing it would not show. They uselegacynow:TestMergePath,TestPathRoundTripThroughYAML,TestSharedSettingsApplyOverANewUserConfigFile,TestAFreshUserFollowsTheSharedConfig,TestAliasChangesLeaveTheRestOfTheUserConfigAlone.New:
TestDefaultPathModeIsBaseline, and the unconfigured andlegacycases in the activate, env and use tests. Breaking the implementation four ways (nolegacycase,pathPolicy()starting fromlegacy, unknown values falling back tolegacy,EmptyPathstayinglegacy) fails tests each time.Docs
English and zh-hans. Quick Start and both READMEs lose the "set baseline" step and the announcement; they are identical to v1.0.13 again. The configuration guide described what
legacydoes as the general behavior; it now describes the default, and says how to keep the 1.0.x behavior (vfox config path.mode legacy, orpath.preservewhen a few directories have to stay in front). The FAQ says what can still win (pnpm, anything added aftervfox activate) and what to check whenvfox doctorstill names a system directory (a shell started before the upgrade,legacy,path.preserve).AGENTS.mdsays where the default lives.Not in this PR
vfox doctornotice. No release containspath.modeyet (v1.0.13 is the latest,mainis three commits ahead), so the first release that has the setting can ship withbaseline; there is no earlier release to warn in. If you would rather shippath.modewithlegacyfirst and flip one release later, this PR can wait for that release.vfox use java@Xdoesn't changejavawhen a JDK is in the system PATH and a global SDK is set #732 stay open until a release contains this.vfox config --unset path.modestill writes the default into the file instead of removing the key (Follow-ups of #736: plugin updates, the path.mode default and vfox config #737, item 4).Draft for the release notes
Verification
go teston all packages exceptinternal/shared/printer(it needs a TTY), run on the exported tree ofHEAD: pass.go veton Linux,GOOS=windowsandGOOS=darwin: clean. The docs site builds (VitePress, no dead links; the new callouts render in both languages).On Windows most tests that exercise the
PATHorder skip, as before (they use POSIX paths, and the CLI fixture skips there, #737 item 5). Theinternal/configtests, which pin the default and its fallbacks, run there.CI on my fork for the head commit (3703b90) is green:
VersionFox CI(ubuntu, macOS, Windows, the Windows regressions, Fish) andvfox E2E Test(Unix, macOS, Windows, MSIX packaging): CI, E2E.