Skip to content

fix(installer): upgrade from the home folder leaves user-wide agent settings alone (#3234) - #3281

Open
b84330808 wants to merge 1 commit into
colbymchenry:mainfrom
b84330808:fix-refresh-from-home
Open

b84330808 wants to merge 1 commit into
colbymchenry:mainfrom
b84330808:fix-refresh-from-home

Conversation

@b84330808

Copy link
Copy Markdown

Fixes #3234

codegraph upgrade runs codegraph install --refresh in the current directory, and a new terminal starts in the home folder. The refresh sweeps both locations, and the local sweep reads each target's files under process.cwd(). In the home folder those are the user-wide files (./.cursor/mcp.json is ~/.cursor/mcp.json), so every global install looked like a local one and was rewritten as a project's:

  • Cursor's global entry had --path ${workspaceFolder} replaced with the home folder's absolute path, so every workspace served the home folder.
  • Codex, Gemini CLI and Qwen Code got ~/AGENTS.md, ~/GEMINI.md and ~/QWEN.md, which aren't their user-wide instructions files.

refreshTargets now skips every target in a local sweep when the current directory is one init refuses as a project root (home, a parent of it, a filesystem root), using the existing unsafeIndexRootReason. A local sweep inside a project is unchanged, and the global sweep still refreshes the user-wide installs.

Testing: added two tests to __tests__/installer-targets.test.ts. The first installs every target globally in a temporary home folder, runs a local sweep from there, and checks that no file in it changed and Cursor's entry still uses ${workspaceFolder}. Without the fix it fails with expected [ 'not-configured', 'unsupported' ] to include 'refreshed'. The second checks that a local sweep inside a project still refreshes a local install. npx vitest run __tests__/installer-targets.test.ts passes. I ran it on Windows 11 only; the change has no platform-specific code.

…ettings alone (colbymchenry#3234)

`codegraph upgrade` runs `codegraph install --refresh` in the terminal's
current directory, which in a new terminal is the home folder. The refresh
sweeps both locations, and the local one reads a target's files under
`process.cwd()`. In the home folder those are the user-wide files
(`./.cursor/mcp.json` is `~/.cursor/mcp.json`, `./.codex/config.toml` is
`~/.codex/config.toml`), so every global install looked like a local one
and was rewritten as a project's:

- Cursor's global entry had `--path ${workspaceFolder}` replaced by the
  home folder's absolute path, so every workspace served the home folder.
- Codex, Gemini CLI and Qwen Code got `~/AGENTS.md`, `~/GEMINI.md` and
  `~/QWEN.md`, which are not their user-wide instructions files.

The local sweep now skips a directory `init` refuses as a project root
(home, a parent of it, a filesystem root), through the existing
unsafeIndexRootReason. A local sweep inside a project is unchanged.
colbymchenry added a commit that referenced this pull request Nov 18, 2026
… user-wide setup

`codegraph upgrade` runs `codegraph install --refresh`, which sweeps the
global and the local location from whatever folder the terminal is in, and
a new terminal opens in the home folder. There an agent's project file and
its user-wide file are the same file: `./.cursor/mcp.json` is
`~/.cursor/mcp.json`, `./.codex/config.toml` is `~/.codex/config.toml`, and
likewise for Gemini CLI and Qwen Code. The local half of the sweep detected
each global install as a local one and re-installed it as a project's:

- Cursor's global entry had `--path ${workspaceFolder}` replaced with the
  home folder's absolute path, so every Cursor workspace was served the
  home folder (until a later refresh from some other folder put it back);
- Codex, Gemini CLI and Qwen Code got `~/AGENTS.md`, `~/GEMINI.md` and
  `~/QWEN.md`, which none of them reads as its user-wide instructions.

refreshTargets now finds nothing configured for a local sweep from a folder
that holds no project, the folders `init` already refuses (the home
folder, a folder above it, a filesystem root), using the same
unsafeIndexRootReason check. The global half is unchanged, and a local
sweep inside a project refreshes as before. Nothing is printed for the
skipped half, so an upgrade from the home folder stays as quiet as one
that has nothing local to refresh.

Validation:
- installer-targets.test.ts: a new test installs every agent globally into
  a temp home, runs the local sweep from it, and checks every file there
  is byte-identical, no AGENTS.md / GEMINI.md / QWEN.md appears, and
  Cursor keeps `${workspaceFolder}`. Red on main (Cursor reported
  refreshed), green here. A second test checks a local sweep inside a
  project still refreshes a stale block. The whole file passes
  (616 passed, 10 skipped), as do installer, installer-links-simulated,
  upgrade and cli-install-init (101 passed).
- Real CLI against a temp HOME (every agent installed globally, then
  `install --refresh` from HOME): v1.6.3 sources changed `.cursor/mcp.json`
  and created AGENTS.md, GEMINI.md and QWEN.md; this branch left all 31
  files byte-identical. From a project with a local Codex install, both
  refresh its AGENTS.md.

Left out: an explicit `codegraph install --location local` run from the home
folder still writes there; that's a direct request, not a sweep, and
refusing it is a separate call.

PR #3281 (@b84330808) and PR #3288 (@LuisAlbertoMK) proposed the same guard;
this follows #3281's quiet shape.

Fixes #3234

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
colbymchenry added a commit that referenced this pull request Nov 18, 2026
… user-wide setup (#3333)

`codegraph upgrade` runs `codegraph install --refresh`, which sweeps the
global and the local location from whatever folder the terminal is in, and
a new terminal opens in the home folder. There an agent's project file and
its user-wide file are the same file: `./.cursor/mcp.json` is
`~/.cursor/mcp.json`, `./.codex/config.toml` is `~/.codex/config.toml`, and
likewise for Gemini CLI and Qwen Code. The local half of the sweep detected
each global install as a local one and re-installed it as a project's:

- Cursor's global entry had `--path ${workspaceFolder}` replaced with the
  home folder's absolute path, so every Cursor workspace was served the
  home folder (until a later refresh from some other folder put it back);
- Codex, Gemini CLI and Qwen Code got `~/AGENTS.md`, `~/GEMINI.md` and
  `~/QWEN.md`, which none of them reads as its user-wide instructions.

refreshTargets now finds nothing configured for a local sweep from a folder
that holds no project, the folders `init` already refuses (the home
folder, a folder above it, a filesystem root), using the same
unsafeIndexRootReason check. The global half is unchanged, and a local
sweep inside a project refreshes as before. Nothing is printed for the
skipped half, so an upgrade from the home folder stays as quiet as one
that has nothing local to refresh.

Validation:
- installer-targets.test.ts: a new test installs every agent globally into
  a temp home, runs the local sweep from it, and checks every file there
  is byte-identical, no AGENTS.md / GEMINI.md / QWEN.md appears, and
  Cursor keeps `${workspaceFolder}`. Red on main (Cursor reported
  refreshed), green here. A second test checks a local sweep inside a
  project still refreshes a stale block. The whole file passes
  (616 passed, 10 skipped), as do installer, installer-links-simulated,
  upgrade and cli-install-init (101 passed).
- Real CLI against a temp HOME (every agent installed globally, then
  `install --refresh` from HOME): v1.6.3 sources changed `.cursor/mcp.json`
  and created AGENTS.md, GEMINI.md and QWEN.md; this branch left all 31
  files byte-identical. From a project with a local Codex install, both
  refresh its AGENTS.md.

Left out: an explicit `codegraph install --location local` run from the home
folder still writes there; that's a direct request, not a sweep, and
refusing it is a separate call.

PR #3281 (@b84330808) and PR #3288 (@LuisAlbertoMK) proposed the same guard;
this follows #3281's quiet shape.

Fixes #3234

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

install --refresh (via upgrade) writes the CodeGraph block into $HOME/AGENTS.md when cwd is $HOME

1 participant