Skip to content

fix(locate): keep Codex's shared skills read when a root is recorded - #1890

Merged
SaulMoro merged 2 commits into
Tencent:mainfrom
Walternater:fix/codex-shared-skills-read
Nov 15, 2026
Merged

SaulMoro merged 2 commits into
Tencent:mainfrom
Walternater:fix/codex-shared-skills-read

Conversation

@Walternater

Copy link
Copy Markdown
Collaborator

Summary

A member who records CODEX_HOME at init had every pull (and doctor) fail codex reads the skills teamai writes for the shared ~/.agents/skills — with advice that cannot work, since the write judged unread is the shared directory, not the configured skills path.

rootsOf resolves a tool's declared reads through relocated(), which ran each read through applyToolRoots as if it were the tool's skills path. With toolRoots.codex recorded, the one-entry map made the read's own root (.agents) count as one of Codex's roots, so both reads became <recorded root>/skills and the shared directory vanished from the reads unreadWrites checks.

relocated() now moves a declared read only when it hangs off one of the tool's own roots — the set applyToolRoots moves (toolPathRoots of the tool's configured paths, plus its shipped default). A bare file name still moves, so Claude's .claude.json keeps following CLAUDE_CONFIG_DIR; Claude's and Cursor's declared reads hang off their own roots and are unchanged.

Fixes #1886.

Type of Change

Bug fix (no behavior change beyond the reported check).

Test Plan

  • New regression test in src/__tests__/locate.test.ts: with toolRoots: { codex: '/home/m/.codex-work' } in user scope, locate('codex', 'skills', …) reads ['/home/m/.codex-work/skills', '/home/m/.agents/skills'], shared is ~/.agents/skills, and unreadWrites is empty. Reverting only src/locate.ts fails it (duplicate <root>/skills reads) — the reported symptom.
  • Related suites: locate (82), tool-roots, doctor-delivery, skills (295 together), and lint + typecheck pass.
  • Real CLI pair, user scope, team repo with one skill, CODEX_HOME=$HOME/.codex-work recorded at init:
    • before (main 17238b7 build): pull ends ⚠ ✖ codex reads the skills teamai writes → codex does not read …/.agents/skills, and doctor shows the same failed check;
    • after: pull ends without a failed check and doctor shows ✔ codex reads the skills teamai writes, with the skill written to both ~/.codex-work/skills and ~/.agents/skills.

Notes

Not checked: a real-CLI run on Windows. The change is in path resolution shared by every tool, which the locate and tool-roots suites cover.

`rootsOf` re-roots a tool's declared reads through `relocated()`, which runs
the read through `applyToolRoots` as if it were the tool's skills path. With
`toolRoots.codex` recorded, the one-entry map made the read's own root count
as Codex's, so both reads became `<root>/skills`: the shared
`~/.agents/skills` teamai writes disappeared from what pull and doctor see
Codex reading, and every pull failed "codex reads the skills teamai writes"
with advice pointing at the configured path instead (Tencent#1886).

Move a declared read with a recorded root only when it hangs off one of the
tool's own roots, the set `applyToolRoots` moves (`toolPathRoots` of the
tool's configured paths plus its shipped default). A bare file name still
moves, so `.claude.json` keeps following `CLAUDE_CONFIG_DIR`.

Regression test in `locate.test.ts`: a recorded Codex root reads
`['<root>/skills', '~/.agents/skills']` and reports no unread writes.
@github-actions

Copy link
Copy Markdown

No findings. The current diff shows no concrete bug or review-rule violation I can confidently identify.

The PR description documents sufficient testing: a regression test, related suites, lint/typecheck, and a representative before/after real-CLI pull and doctor run. Windows verification is explicitly deferred.

Review was read-only; I did not run, build, or install PR code.

@SaulMoro SaulMoro left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This was generated by AI during triage.

Approving at be526b2.

What I checked

  • Red on main, green here. With main's src/locate.ts, the new case "reads the recorded skills directory and the shared one" fails. With this head, locate.test.ts and tool-roots.test.ts pass (129 tests), and typecheck passes.
  • Real CLI on POSIX, as a pair. Each verify world had a git team repo with one skill, user scope, Codex on PATH, and CODEX_HOME=$HOME/.codex-work recorded at init:
    • main (d1b2528): FAILED. teamai pull ends with ✖ codex reads the skills teamai writes → codex does not read …/home/.agents/skills. Point toolPaths.codex.skills …, and teamai doctor shows the same failed check.
    • this head (be526b2): VERIFIED. pull ends with no failed check, and doctor shows ✔ codex reads the skills teamai writes. The skill lands in ~/.codex-work/skills. A second pull is a clean no-op ("Already synced"), and the verify world's uninstall check reports nothing left behind.
  • Scope. Without a recorded root, relocated() now returns the read as it is, which is what scopedToolPaths already did when toolRoots was empty. A bare file name still moves, so Claude's .claude.json keeps following CLAUDE_CONFIG_DIR.

[P2 non-blocking]

  • The new helper copies an existing private one. rootsRecordedRootMoves (locate.ts:592-598) has the same body as relocationRootsOf in src/types.ts:3515, which is what applyToolRoots uses. There is one difference: applyToolRoots passes the toolRoots key (toolRootsKeyOf(tool)), and this passes the tool. For an instance recorded on the root of the tool it extends, the two can disagree about which roots move. Exporting relocationRootsOf and calling relocationRootsOf(toolRootsKeyOf(tool), install.toolPaths) would keep one definition, and would match applyToolRoots for instances too. Fine as a follow-up.

[P3 nit]

  • In my world nothing was written to ~/.agents/skills, on main or on this head. Only ~/.codex-work/skills got the skill. The body says the skill was written to both, so the difference may come from the Codex version or which other tools are present. It doesn't affect the fix: the shared directory is back among the reads, and that is what the check needs.
  • locate.ts:585 has a double blank line before the new doc comment.

CI review. No findings. We agree, apart from the P2 above.

Merge risk. Low. One closure in path resolution changes, and only when a tool root is recorded.

The Tencent#1886 fix moved a declared read only when it hangs off one of the tool's
roots, and built that set from the tool's own paths plus its shipped default.
An instance (`extends: codex`) has no shipped default of its own, so a read
that spells Codex's `.codex/skills` matched nothing, stayed un-relocated, and
`unreadWrites` then reported the instance's write under the recorded root as
not read — `tool-instances.test.ts` failed on it, and CI with it.

An instance reads through the tool it extends, so its shipped root is that
tool's default. Only the "no shipped default for an instance" half was wrong;
the guard against re-rooting a read that names no root keeps Tencent#1886 fixed.

Co-Authored-By: Claude Code <[email protected]>
@github-actions

Copy link
Copy Markdown

No findings. The current diff contains no concrete bug or Code Review Rules violation I can confidently identify. The earlier review reported no findings, so none require resolution.

The PR description documents sufficient testing: a failing-before-fix regression test, related suites, lint/typecheck, and a representative before/after real-CLI pull and doctor run. Windows verification is explicitly deferred.

Review was read-only and limited to the specified diff. I did not run, build, or install PR code.

@SaulMoro SaulMoro left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This was generated by AI during triage.

Approving again at 52a08bf.

What changed. The CI run at be526b2 failed on tool-instances.test.ts ("relocates an instance with no home to the recorded root of the tool it extends…"). An instance (extends: codex) got no shipped default, so a read under Codex's .codex/skills matched no root. Now the shipped roots come from the base tool for an instance too, and an instance's own default paths are still not assumed.

What I checked

  • With be526b2's locate.ts, that case fails (1 failed, 98 passed). With this head, tool-instances.test.ts and locate.test.ts pass (181 tests), and typecheck passes.
  • The earlier real-CLI pair still covers a plain Codex root. This commit changes only how an instance finds its base's roots.

CI review. No findings, and we agree. My earlier P2 and P3 still stand as non-blocking.

Merge risk. Low. An instance now relocates reads under its base tool's default roots, as the base tool already did.

@SaulMoro
SaulMoro merged commit eaaa697 into Tencent:main Nov 15, 2026
20 checks passed
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.

With CODEX_HOME recorded at init, every pull and doctor fail "codex reads the skills teamai writes" for ~/.agents/skills

3 participants