Skip to content

feat(locate): resolve where every tool takes skills, with a Windows job (#1221) - #1252

Merged
jeff-r2026 merged 10 commits into
Tencent:mainfrom
SaulMoro:feat/1221-locate-skills
Oct 22, 2026
Merged

jeff-r2026 merged 10 commits into
Tencent:mainfrom
SaulMoro:feat/1221-locate-skills

Conversation

@SaulMoro

@SaulMoro SaulMoro commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

Review it one commit at a time: A2 is b9e03a93 and 61230293, E is 1ea413c9, 0cb7e559, 6929ed05 and b9bc6225, and the skills-directory and home rules are f1d85597, 2d34ca25, 88c8e8ba and 50fb7283. A1 merged in #1245.

Summary

This PR is steps A2 and E of #1221:

  • A2 adds one resolver, locate, which answers where each tool takes skills.
  • E adds a Windows job.
flowchart LR
    subgraph callers ["callers"]
        init["init, pull<br/>record moved homes"]:::added
        skills["skills: pull, push, uninstall, skill-use,<br/>doctor, dashboard, local agent"]:::added
        other["rules, blocks, agents, MCP, hooks"]:::todo
        matrix["matrix test<br/>darwin, linux, win32"]:::added
    end
    subgraph core ["src/tools.ts + src/locate.ts"]
        desc["TOOLS (#1245)<br/>home, moves, skill reads"]
        locate["locate(tool, 'skills', install, host)"]:::added
    end
    host{{"Host<br/>platform, env, cwd, recorded homes"}}:::added
    record[("~/.teamai/tool-homes.json")]:::added
    left["name old skill dirs<br/>copies stay"]:::added
    win["Windows job"]:::added
    page["docs/guide/tool-support.md"]:::todo
    old["skillsDirForTool"]:::removed
    init --> record
    skills & matrix --> locate --> desc
    locate --> host --> record
    skills --> left
    other -.-> locate
    desc -.-> page
    win --> matrix
    skills -.-> old
    classDef added fill:#2f8f4f,stroke:#1f6b39,color:#fff;
    classDef todo fill:#5c6670,stroke:#3d454c,color:#fff,stroke-dasharray:4 3;
    classDef removed fill:#a33a3a,stroke:#7a2a2a,color:#fff,stroke-dasharray:4 3;
Loading

Green: this PR. Gray: later steps of #1221 (B1, B2 and B3 are #1265, then B4, C and D). Red: removed.

Where skills go (A2).

  • Every skills writer and reader asks locate, including the skill-use check.
  • A variable that moves a tool's home moves its skills: XDG_CONFIG_HOME (OpenCode, Muse), OPENCODE_CONFIG_DIR, HERMES_HOME, PI_CODING_AGENT_DIR, COPILOT_HOME, DSH_HOME, OpenClaw's state dir and profile, and Hermes's Windows default.
  • init and the first pull that sees a move record it in ~/.teamai/tool-homes.json. The record wins over a shell without the variable; doctor reports a shell that disagrees.
  • Hermes, Copilot, DSH and OpenClaw hooks and rules follow the same home. OpenCode's, Muse's and Pi's other files move in step B, and doctor says so.

The rules this PR holds to.

Question Rule
Are two skills directories one? sameSkillDir: samePath after resolving links; a missing directory compares as written. The pull's fast path, the left-directory notice and doctor all ask it.
May pull delete teamai's copies in a skills directory a tool left? Never, in any scope. A reader may sit in the other scope, another project, another shell's environment or a tool teamai does not manage, and no pull can see them all. Pull records the new directory and names the old one once; the member deletes the copies.
How does a home variable resolve? A tool's own variable as the tool resolves it: ~ expanded, relative against the current directory (as on main). XDG_CONFIG_HOME and LOCALAPPDATA count only when absolute.

Windows (E). A windows-latest job runs the matrix, an allow-list of Windows-safe tests (a guard test enforces the list) and one real hook-dispatch session-start per hook shell. It is not required yet.

Evidence

Built CLI, isolated HOME, git provider, project-only install, only Hermes selected, HERMES_HOME=~/.claude, OpenCode installed at ~/.config/opencode, no project .opencode. Then Hermes moves to hermes-b and the project pulls:

88c8e8ba  ℹ [workspace] Removed 2 skill copy(ies) from home/.claude/skills: hermes takes skills from hermes-b/skills now.
          home/.claude/skills  deploy=no  stub=no
50fb7283  ℹ [workspace] hermes takes skills from hermes-b/skills now, so teamai no longer updates its copies in home/.claude/skills. Delete them once no tool reads that directory.
          hermes-b/skills      deploy=yes stub=yes
          home/.claude/skills  deploy=yes stub=yes
          next pull: no notice, copies still there
  • Before: pull-skill-dirs.test.ts "keeps teamai's copies there and names the directory once" failed in three of its four rows (project pull with a user-scope reader, user pull with a project's reader, no reader at all): the old copies were deleted.
    After: all four rows pass. A relative HERMES_HOME, COPILOT_HOME, DSH_HOME, OPENCODE_CONFIG_DIR, PI_CODING_AGENT_DIR or OPENCLAW_STATE_DIR resolves against the current directory, as on main. Table tests cover sameSkillDir, which directories a tool left, and every home variable in TOOLS.
  • tsc, lint, vitest run: 11945 passed, 21 skipped.
  • Full test:e2e at 50fb7283: 162 files passed, 4 skipped, 1 failed. workflow-signals (terminal Ctrl-C) fails the same way on main (fa6a361b) on this macOS machine, and passes in CI.
  • Earlier on this branch: moved XDG_CONFIG_HOME homes for OpenCode and Muse, an OpenClaw workspace flip that deletes nothing, an invalid tool-homes.json that stops the pull, and this PR's windows-latest job (632 unit tests, three hook shells).
  • Not run here: real Copilot, CodeBuddy, Muse, dsh and Pi hosts, a Windows desktop, and the gitlab and github providers.

Merge Danger

Door: two-way. Older releases ignore tool-homes.json, and a revert writes skills to the default paths on the next pull.

Blast Radius: where skills land.

  • A member whose shell moves a tool's home gets skills there. teamai's copies at the old path stay, no longer updated, and the first pull after the move names the path.
  • The first pull after the upgrade syncs in full once to record where skills went.
  • Not followed yet, for lack of a tool-side source: OMP_PROFILE, OPENCLAW_HOME, CODEBUDDY_CONFIG_DIR, HERMES_DATA_DIR_SUFFIX.

Part of #1221.

… a variable moves (Tencent#1221)

One resolver, locate(tool, 'skills', install, host), answers where each tool
takes skills for every tool, scope and platform. Every skills writer and
reader asks it, and skillsDirForTool is gone.

A home moved by XDG_CONFIG_HOME, OPENCODE_CONFIG_DIR, HERMES_HOME,
PI_CODING_AGENT_DIR, COPILOT_HOME, DSH_HOME, OpenClaw's state dir or profile,
or Hermes's Windows default is recorded once per machine in
~/.teamai/tool-homes.json, and the record wins over a shell without the
variable. When a tool's skills directory moves, pull releases teamai's
unchanged copies from the old one in one pass over every tool, after the
built-in stub; an edited or still-used copy is kept.
…ndows runner (Tencent#1221)

A windows-latest job runs an allow-list of tests that pass on Windows,
guarded by windows-test-list.test.ts, and one real hook-dispatch
session-start per hook shell. The hook-command tests pin the platform they
render for, so they assert the same exact strings on every OS.
…orrect (Tencent#1221)

The skill-use captures come from POSIX shells, so a Windows home goes into
them with forward slashes: a raw backslash broke the JSON and a bash command.
The retire fixtures are compared byte for byte, so they stay LF on checkout
like the hook golden fixtures.
…x on Windows (Tencent#1221)

session-start leaves a detached background dispatch running in the sandbox
home, and Windows refuses to remove a directory a process still holds
(EBUSY). rmSync's own retries wait for it.
…dirs (Tencent#1221)

A pull with no record of where skills went cannot take the fast path: a home
moved since the last delivery would never get skills. The push half still runs
against an install with no user-scope record.
…Tencent#1221)

The detached background pass of session-start runs in the payload's cwd, and
Windows cannot remove a directory that is a live process's cwd, however long
rmSync retries. The payload now names the temp dir, and the sandbox teardown
goes back to a plain remove.
@SaulMoro
SaulMoro marked this pull request as ready for review October 21, 2026 05:50
@github-actions

Copy link
Copy Markdown
  • [P1 blocking] Preserve directories still read by other tools — src/resources/skill-dirs.ts:102. The live set includes only write destinations, not locate().reads. For example, with HERMES_HOME=~/.claude and only Hermes selected, an installed OpenCode still reads ~/.claude/skills. Moving Hermes elsewhere makes pull delete those unchanged skills and the stub, although OpenCode still uses them and receives no replacement. Include read destinations in release protection.

  • [P2 non-blocking] Preserve relative tool-specific home overrides — src/tool-home.ts:55. Applying the XDG absolute-path restriction to every home variable regresses previously supported overrides. With HERMES_HOME=relative/path, Hermes previously resolved against the session directory; this diff explicitly switches teamai to the default home instead. The same regression affects Copilot and DSH. Resolve tool-specific relative overrides against the host cwd rather than silently ignoring them.

The description supplies sufficient built-CLI verification; the older evidence commit and explicitly deferred provider/host coverage are not blocking. No PR code was run, built, or installed.

… sameSkillDir (Tencent#1221)

The pull's fast path, the release of old skills directories and doctor
each compared directories their own way: by spelling in the host's
flavor, by realpath, or by samePath. They now all ask sameSkillDir:
the same path (samePath) once each side is resolved through its links,
a directory that does not exist yet compared as written.
…l still reads (Tencent#1221)

A pull released an old skills directory once no tool wrote there,
although a tool that is installed or selected could still read it:
with HERMES_HOME=~/.claude and only Hermes selected, moving Hermes
deleted the skills and the stub in ~/.claude/skills that an installed
OpenCode or Claude Code still loads. The release now also keeps every
directory such a tool reads or may take skills in.
…sion directory (Tencent#1221)

HERMES_HOME, COPILOT_HOME, DSH_HOME and the other variables a tool
reads for its own home resolve a relative value against the directory
the tool runs in, and so did teamai before this change. Only
XDG_CONFIG_HOME and LOCALAPPDATA stay absolute-only, as the XDG spec
has it.
@github-actions

Copy link
Copy Markdown
  • [P1 blocking] Protect user-scope readers during project pulls — src/resources/skill-dirs.ts:37. skillDirsInUse checks only the current install scope. In a project-only install with only Hermes selected, HERMES_HOME=~/.claude, and OpenCode installed at ~/.config/opencode but no project .opencode directory, moving Hermes causes the next project pull to delete the unchanged skills and stub from ~/.claude/skills. OpenCode still reads that global directory, but its user-scope reads never enter inUse. Include user-scope readers when protecting directories released by project pulls.

Both earlier findings are resolved in their reported cases: user-scope readers are protected, and relative tool-specific home overrides resolve against the session directory.

The description supplies sufficient built-CLI verification; deferred host/provider coverage is not blocking. No PR code was run, built, or installed. The shallow checkout prevented three-dot resolution; review used the common parent 858ef542 identified by both commit histories.

…d name it once (Tencent#1221)

Pull deleted teamai's unchanged copies from a skills directory a tool moved
off unless a tool of the pulling scope read it. A reader in another scope,
another project, another shell's environment or a tool teamai does not
manage was invisible to that check, so a project pull could empty
~/.claude/skills while OpenCode, installed for the user, still read it.

No pull can see every reader, so pull no longer deletes there. It records
the new directory and names the old one once; the member deletes the copies
when nothing reads them. formerSkillDirs and the in-use scan only served the
deletion and are gone.
@github-actions

Copy link
Copy Markdown

No new findings I’m confident are real in the current diff.

  • Resolved: Both reader-protection findings are fixed: pull now leaves copies in old skills directories, regardless of scope or remaining readers.
  • Resolved: Relative tool-specific home overrides resolve against the session directory.
  • Testing: The description supplies sufficient built-CLI verification at 50fb7283. Explicitly deferred host/provider coverage is not blocking.

The shallow checkout prevented three-dot resolution. Both commit histories confirm 858ef542 as the common parent, so I reviewed its diff to 50fb7283. No PR code was run, built, or installed.

@jeff-r2026
jeff-r2026 merged commit d9d0e0f into Tencent:main Oct 22, 2026
18 checks passed
Walternater pushed a commit to Walternater/teamai-cli that referenced this pull request Nov 2, 2026
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.

2 participants