Skip to content

feat(config): make baseline the default path.mode - #738

Open
linghengqian wants to merge 4 commits into
version-fox:mainfrom
linghengqian:feat/path-mode-baseline-default
Open

linghengqian wants to merge 4 commits into
version-fox:mainfrom
linghengqian:feat/path-mode-baseline-default

Conversation

@linghengqian

@linghengqian linghengqian commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

Part of #737 (item 3, "Change the default of path.mode to baseline").

What changes

path.mode defaults to baseline. The default was legacy, which 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 kept winning over the version vfox use selected (#337, #732). baseline moves what was already in PATH when vfox activate ran behind vfox's directories, and keeps what is added afterwards (a virtualenv, the $PNPM_HOME of pnpm setup) in front. The way back is one line: vfox config path.mode legacy.

Checked with real binaries, built from main and from this branch. The shell's PATH is <system dir with alphatool>:<vfox sdks dir>:/usr/bin:/bin when vfox activate bash runs, which is the shape behind #337 and #732:

alphatool runs PATH starts with
main (default legacy) the system's system dir, vfox dir
this branch, nothing configured vfox's vfox dir, system dir
this branch + vfox config path.mode legacy the system's system dir, vfox dir
this branch + path.preserve listing the system dir the system's system dir, vfox dir

Code

  • config.DefaultPathMode names the default in one place. EmptyPath, both fallbacks of Path.EffectiveMode and the starting mode of pathPolicy() use it: the four places listed in Follow-ups of #736: plugin updates, the path.mode default and vfox config #737.
  • The open question in Follow-ups of #736: plugin updates, the path.mode default and vfox config #737, whether a typo should land on the new default: yes. An empty or unknown value is the default, as it was before, so a typo does not fail vfox env, which runs at every prompt.
  • EffectiveMode has to name legacy as a case of its own now. Flipping only the fallbacks would turn mode: legacy into baseline. I removed the case to see: 12 tests in all four packages fail.
  • A shell without a recorded baseline still behaves like legacy in baseline mode, the default, so upgrading does not reorder the PATH of a shell that is already running. It gets the new default when it is restarted. aggressive never reads the baseline and demotes the same entries with or without one. TestEnvWithoutABaselineOnlyBaselineModeFallsBackToLegacy covers the unconfigured case and each of the modes.
  • The path.shadowed hint for a directory that was already in PATH at activation said to run vfox config path.mode baseline. That finding can only come up in legacy mode now (baseline moves 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 in internal/config, 2 in internal/env, 1 in internal/sdk.

Five more kept passing for the wrong reason. They used baseline as the value that has to survive a merge, a save, the first run with a shared VFOX_HOME or an alias change; once it is the default, losing it would not show. They use legacy now: TestMergePath, TestPathRoundTripThroughYAML, TestSharedSettingsApplyOverANewUserConfigFile, TestAFreshUserFollowsTheSharedConfig, TestAliasChangesLeaveTheRestOfTheUserConfigAlone.

New: TestDefaultPathModeIsBaseline, and the unconfigured and legacy cases in the activate, env and use tests. Breaking the implementation four ways (no legacy case, pathPolicy() starting from legacy, unknown values falling back to legacy, EmptyPath staying legacy) 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 legacy does as the general behavior; it now describes the default, and says how to keep the 1.0.x behavior (vfox config path.mode legacy, or path.preserve when a few directories have to stay in front). The FAQ says what can still win (pnpm, anything added after vfox activate) and what to check when vfox doctor still names a system directory (a shell started before the upgrade, legacy, path.preserve). AGENTS.md says where the default lives.

Not in this PR

Draft for the release notes

Changed default: path.mode is baseline. vfox now puts its directories in front of whatever was in PATH when vfox activate ran, so the system's node or java (macOS path_helper, the Windows machine PATH) no longer hides the version you selected. What is added to PATH after activation, such as a virtualenv, still stays in front. To get the behavior of 1.0.x back, run vfox config path.mode legacy; to keep a few directories in front, list them in path.preserve. A shell that was started before the upgrade keeps the old order until you open a new terminal.

Verification

go test on all packages except internal/shared/printer (it needs a TTY), run on the exported tree of HEAD: pass. go vet on Linux, GOOS=windows and GOOS=darwin: clean. The docs site builds (VitePress, no dead links; the new callouts render in both languages).

On Windows most tests that exercise the PATH order skip, as before (they use POSIX paths, and the CLI fixture skips there, #737 item 5). The internal/config tests, 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) and vfox E2E Test (Unix, macOS, Windows, MSIX packaging): CI, E2E.

`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
@linghengqian linghengqian added the enhancement New feature or request label Oct 23, 2026
@codecov

codecov Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 55.58%. Comparing base (37cff8f) to head (7394477).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@linghengqian linghengqian left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

CC @aooohan . Could you please take a look and review this?

@linghengqian linghengqian added this to the 1.0.14 milestone Nov 4, 2026

@linghengqian linghengqian left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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.
Copilot AI lite review requested due to automatic review settings November 6, 2026 02:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 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 baseline as the default path mode while preserving explicit legacy behavior.
  • 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

Comment thread AGENTS.md Resolved
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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants