Repository navigation
feat(locate): rules, blocks, agents, and MCP go through locate (#1221) - #1265
Conversation
Tencent#1221) locate now answers with a channel ('files', 'run-time', 'none', 'unknown') and places that say what kind they are: a directory, a blocks file, or a map inside a shared config file. A locator per resource sits in LOCATORS, so a resource without one fails tsc, and each resource keeps its own result type. Skills is still the only resource. The helpers serve every place kind: writable (was writableDir) and ownOf replace the 12 writableDir calls and 4 reads of .own; writesOf, cleanupOf and unreadWrites also handle files, map entries and a read hidden by an earlier file of a first-existing lookup ('shadowed'). No behavior change: A2's skills matrix and locate tests pass with only the accessor adapted to places.
…into Install (Tencent#1221) installOf now also reads sharing.gitExclude, whether the business repo is the team repo, and whether the workspace has child checkouts, once, so the rules, blocks and MCP locators get them from Install instead of each caller. Host gains realpath and readText, the two reads the key Claude Code files a checkout under needs (Tencent#915). Nothing reads the new fields yet.
… module (Tencent#1221) codex-project-trust.ts now holds Codex's verdict on a project and the fix doctor prints, taking the ReadGate locate declares, so the agents and MCP checks can share one reading. Doctor's MCP trust check builds the same gate and prints the same lines.
…cent#1221) The flag now says what still goes to the default home when OpenCode, Pi or Muse moves its home: teamai's hooks and models switch settings, until B4 moves them.
…s, not skillDirs (Tencent#1221) skill-dirs.ts becomes places.ts: lastPullByWorkspace[key].places holds, per resource, the places each tool took it from at the last full pull. Skills is the only resource recorded; rules, blocks and agents join once their writers go through locate. The fast path compares every recorded resource (placesUnmoved). A record from an earlier release reads its skillDirs as places.skills, and pull never writes skillDirs again.
…s in the descriptor (Tencent#1221) Each built-in tool now names, per scope, how it takes rules, instruction blocks, agents and MCP servers: the adapter with the paths it reads, a run-time channel with the probe that says it is installed, 'none', or 'unknown'. Leaving a resource or a scope out fails tsc (tools.type-test.ts). The rows hold the Tencent#1221 design, including WorkBuddy's MCP lookup (D-e), ZCode's mcp.servers (D-c) and no MCP channel for the internal builds (D-f); no writer reads them yet. The per-tool tables that decided the same facts are now views of the descriptor: the rule formats' tool keys, the session-hook and extension rule tools, detectMcpFormat's sets and the agent tool list. A test pins them to the tables they replaced. The internal builds keep their MCP format until the MCP writers move to locate.
…Tencent#1221) Every configured or declared tool path now becomes absolute in rootsOf, and every resource takes one write gate per tool (gatesOf), so the blocks file, OpenCode's activation and the MCP file resolve once and move with a home. No caller uses the new locators yet; their tables run through one shared matrix runner, which the skills matrix now uses too.
…OLS, not ALL_SUPPORTED_TOOLS (Tencent#1221) ALL_SUPPORTED_TOOLS was a copy of AGENT_TOOLS read through casts. Its readers narrow with isAgentToolId instead, and the copy is gone.
…ncent#1221) One row per tool and scope, plus the moved homes: OpenCode under XDG_CONFIG_HOME, OPENCODE_CONFIG_DIR and a recorded home, Muse under XDG_CONFIG_HOME, Copilot under COPILOT_HOME, and Claude's toolRoots.
…ent#1221) Every tool in both scopes, each row citing its source. The dsh workspace cells follow Tencent#1223: dsh loads teamai's hook config, so its SessionStart hook carries the workspace rules and blocks.
…encent#1221) resolveMcpTargets now takes every target from locate(tool, 'mcp'): WorkBuddy's user servers go to the first existing of its lookup order, its project servers to CodeBuddy's local scope under sharing.gitExclude, and OpenCode, Muse and Pi follow a moved home (XDG_CONFIG_HOME, OPENCODE_CONFIG_DIR, PI_CODING_AGENT_DIR). The local-scope tools, the file readers of claude's .mcp.json and OpenCode's plugin file come from the descriptor instead of tables here. Copilot's MCP file still says it is installed (Tencent#628).
…ds them (Tencent#1221) install_mcp and uninstall_mcp take the tool's MCP file from locate(tool, 'mcp'), as a pull does: WorkBuddy's user servers go to the first of its files that exists, and OpenCode, Muse and Pi follow a moved home. USER_MCP_LOOKUP and userMcpFile go; doctor's read-file check names the target's own lookup files.
…d home (Tencent#1221) Every rules directory pull, push, the pre-push sync, the built-in rules, recall disable, the Cursor user-rules hook, doctor and the local agent's report read now comes from locate(tool, 'rules'). OpenCode under XDG_CONFIG_HOME or OPENCODE_CONFIG_DIR gets its rules and their `instructions` glob in the config dir it reads, and the glob goes to the activation file locate names instead of the MCP field. Muse under XDG_CONFIG_HOME and Pi under PI_CODING_AGENT_DIR get the team-rules block in the AGENTS.md they read. The rules locator keeps honoring a team toolPaths entry written before a tool's rules moved (Tencent#938, Tencent#946): it names a rules directory the tool never reads, so locate returns that directory with no reads, pull still writes there and doctor still fails it. The inline team-rules block comes from the blocks location, so such an entry keeps its block too.
…encent#1221) agentToolDirs, which the pull writer, doctor and the model holds read, asks locate. OpenCode and Muse agents now follow a home that XDG_CONFIG_HOME, OPENCODE_CONFIG_DIR or the tool-homes record moves, as their skills already did.
…Tencent#1221) deployBuiltinAgents and recall off ask locate, so the recall agent follows a moved OpenCode or Muse home too. deployBuiltinAgents now takes the local config: every caller passes one, and the test that called it without one passes the member's config instead.
…ai renders none for (Tencent#1221) An earlier release copied team .md agents into any configured agents directory, so teamai remove, the tombstone pass and uninstall still clear its copies there.
…encent#1221) The push scan and teamai remove ask locate for each tool's agents directory, so they see the copies in a moved OpenCode or Muse home. A custom tool, for which teamai renders no agents, is no longer scanned or cleaned.
… it (Tencent#1221) runLocalDriver's toolPaths are now the team's as teamai.yaml states them, and loadAgent asks locate, so a user-scope agent in a moved OpenCode home loads.
A custom tool gets no agents directory: teamai renders no agents for it.
…y it left (Tencent#1221) places.agents joins the record the fast path compares, so a home that moves at one team revision syncs agents in full, and the first pull after it names the old directory once. A tool that did not take every agent (a member's own file, a held model, a failed write or built-in) keeps its old directory on record until it does. The record of an earlier release names no agents places, so its first pull syncs in full: the skillDirs upgrade test now expects that, and the fast-path fixtures record agents places as this CLI does.
…sts the project that holds them (Tencent#1221) Doctor names a tool whose agents moved since the last pull, notes a tool whose agents follow a moved home while its other files stay in the default one, and checks Codex trust for a team that ships agents and no MCP servers.
…Tencent#1221) The agents rows of locate-agents.test.ts state each of these paths with its source: OMP's user agents, Qoder CN's user agents, WorkBuddy's default, and Copilot's project directory. The whole default toolPaths literals and the toolRoots helper outputs stay, since they pin every other key too.
) Every MCP writer now records the file it wrote a server to: pull, which `mcp inject` and `mcp remove` run, and the local agent. A record whose file the tool no longer reads splits three ways: - in one of teamai's own relocations (a lookup file, the mapped or alternate file, an earlier release's default): moved out, as before; - still holding the server elsewhere, after a home move or a remap: kept, and named once, as skills are; - anywhere else: taken as the current file's. A record an older teamai wrote notes no file. It reads as the mapped file for a lookup target, the default home for OpenCode, Muse and Pi, and the target's file otherwise; one whose entry an earlier release's default holds unchanged is moved out of that file. locate marks the built-in path of a remapped tool 'builtin', apart from an earlier release's 'default': a remap leaves the old file as it is.
… installed (Tencent#1221) instructionHookChannel answered ready for every tool it did not know, so a ZCode, DeepSeek Harness or Muse Code channel with no teamai hook counted as delivering. channelReadiness takes the probe the tool's run-time channel names and checks it: the SessionStart hook in the hooks file for Codex and Muse Code, that hook plus hooks.enabled for ZCode, the cordis.patch.yml row and the bridge config for DeepSeek Harness. A new probe fails the type check until it has a check.
…1221) Uninstall takes the servers of a partition that is no project out of each local scope where locate places it, so WorkBuddy's in .codebuddy.json go too, and CODEBUDDY_CONFIG_DIR is read through the host. The files whose git exclusions it removes are every place cleanupOf names for a tool: its file, OpenCode's plugin file, the other files of a lookup and the retired ones.
…cks at session start (Tencent#1221) In a project these three read no file teamai could write the culture, claudemd and recall blocks to, and their session-start hook added only the rules, so they got none of the blocks. Whether a tool takes a scope's blocks from a hook now comes from its run-time blocks channel in the descriptor: the hook adds the blocks before the rules, the HTTP agent's prompts ride the same hook and are written to no file, and the hook's limit comes from the descriptor. project-hook-rules.test.ts pinned "rules only, no instruction blocks" for the three: that was Tencent#945's requirement, and Tencent#1221 replaces it, so the test asserts the blocks now. A run-time channel is probed in the member's home, where the hook or extension lives; the instruction-targets shape test creates ~/.pi for Pi as it already did ~/.omp.
…1221) readJsonDoc and writeJsonDoc take the keys from a file's top to its server map, keeping every other key on the way, and a target carries the key locate names when it is not the format's own. No target has one yet; ZCode's `mcp.servers` is next. The local agent writes under the key of the place it writes.
Testing: The description documents build/check results and representative real-CLI verification, including a run on Earlier findings: The missing-history issue and all previously reported code scenarios are resolved in the current diff. Review was read-only; no PR code was run, built, or installed. |
…le, and keep what a kept record says of resolved values (Tencent#1221)
Testing: The description documents build/check results and representative real-CLI verification on Earlier findings: The missing-history issue and all previously reported code scenarios are resolved in the current diff. Review was read-only; no PR code was run, built, or installed. |
… it may sit in cannot be read (Tencent#1221)
…'s servers does not parse (Tencent#1221)
Testing: The description supplies build/check results and representative real-CLI verification on Earlier findings: The missing-history issue and all previously reported code scenarios are resolved. Review was read-only; no PR code was run, built, or installed. |
…vers sit in a config that does not parse (Tencent#1221)
|
No new findings I’m confident are real in the current diff.
Reviewed only |
Resolve the doctor-delivery.ts import conflict with Tencent#1274 and update its dropped-keys fixture to the zcode default this branch sets (mcp in .zcode/cli/config.json, mcpProject in .zcode/config.json).
|
No new findings I’m confident are real in the current diff.
Reviewed only |
# Conflicts: # src/teamai-only-files.ts
|
No new findings I’m confident are real in the current diff.
Reviewed only |
jeff-r2026
left a comment
There was a problem hiding this comment.
Reviewed at f2faef2 merged with current main (no conflicts): tsc, lint, build pass; full unit suite passes except 2 cases in submodule-checkout.test.ts that fail identically on plain main; e2e mcp-uninstall / codebuddy-mcp-local-915 / teamai-only-files-915 / doctor-delivery-cli 48/48. Real-CLI smoke with OpenCode home moved via XDG_CONFIG_HOME: pull now delivers rules/agents/MCP/instructions there (main skips them), doctor green, uninstall --force cleans everything.
Non-blocking, please call out in release notes: (1) a team mapping claudemd for JoyCode/Kiro/Qoder/Trae is now treated as retired, so pull strips the teamai block there; (2) CODEBUDDY_CONFIG_DIR now moves the whole CodeBuddy home while hooks follow only in B4.
…nt#1221) (Tencent#1265) * refactor(locate): return Location<R> through LOCATORS with place kinds (Tencent#1221) locate now answers with a channel ('files', 'run-time', 'none', 'unknown') and places that say what kind they are: a directory, a blocks file, or a map inside a shared config file. A locator per resource sits in LOCATORS, so a resource without one fails tsc, and each resource keeps its own result type. Skills is still the only resource. The helpers serve every place kind: writable (was writableDir) and ownOf replace the 12 writableDir calls and 4 reads of .own; writesOf, cleanupOf and unreadWrites also handle files, map entries and a read hidden by an earlier file of a first-existing lookup ('shadowed'). No behavior change: A2's skills matrix and locate tests pass with only the accessor adapted to places. * refactor(locate): parse gitExclude, self mode and workspace children into Install (Tencent#1221) installOf now also reads sharing.gitExclude, whether the business repo is the team repo, and whether the workspace has child checkouts, once, so the rules, blocks and MCP locators get them from Install instead of each caller. Host gains realpath and readText, the two reads the key Claude Code files a checkout under needs (Tencent#915). Nothing reads the new fields yet. * refactor(locate): move Codex project trust out of doctor into its own module (Tencent#1221) codex-project-trust.ts now holds Codex's verdict on a project and the fix doctor prints, taking the ReadGate locate declares, so the agents and MCP checks can share one reading. Doctor's MCP trust check builds the same gate and prints the same lines. * refactor(locate): rename Home.moves.partial to settingsAtDefault (Tencent#1221) The flag now says what still goes to the default home when OpenCode, Pi or Muse moves its home: teamai's hooks and models switch settings, until B4 moves them. * refactor(locate): record where each tool takes a resource under places, not skillDirs (Tencent#1221) skill-dirs.ts becomes places.ts: lastPullByWorkspace[key].places holds, per resource, the places each tool took it from at the last full pull. Skills is the only resource recorded; rules, blocks and agents join once their writers go through locate. The fast path compares every recorded resource (placesUnmoved). A record from an earlier release reads its skillDirs as places.skills, and pull never writes skillDirs again. * feat(tools): state every tool's rules, blocks, agents and MCP channels in the descriptor (Tencent#1221) Each built-in tool now names, per scope, how it takes rules, instruction blocks, agents and MCP servers: the adapter with the paths it reads, a run-time channel with the probe that says it is installed, 'none', or 'unknown'. Leaving a resource or a scope out fails tsc (tools.type-test.ts). The rows hold the Tencent#1221 design, including WorkBuddy's MCP lookup (D-e), ZCode's mcp.servers (D-c) and no MCP channel for the internal builds (D-f); no writer reads them yet. The per-tool tables that decided the same facts are now views of the descriptor: the rule formats' tool keys, the session-hook and extension rule tools, detectMcpFormat's sets and the agent tool list. A test pins them to the tables they replaced. The internal builds keep their MCP format until the MCP writers move to locate. * feat(tools): locate rules, blocks, agents and MCP from the descriptor (Tencent#1221) Every configured or declared tool path now becomes absolute in rootsOf, and every resource takes one write gate per tool (gatesOf), so the blocks file, OpenCode's activation and the MCP file resolve once and move with a home. No caller uses the new locators yet; their tables run through one shared matrix runner, which the skills matrix now uses too. * refactor(agents): read the agent tools from the descriptor's AGENT_TOOLS, not ALL_SUPPORTED_TOOLS (Tencent#1221) ALL_SUPPORTED_TOOLS was a copy of AGENT_TOOLS read through casts. Its readers narrow with isAgentToolId instead, and the copy is gone. * test(locate): state where every tool takes agents, in both scopes (Tencent#1221) One row per tool and scope, plus the moved homes: OpenCode under XDG_CONFIG_HOME, OPENCODE_CONFIG_DIR and a recorded home, Muse under XDG_CONFIG_HOME, Copilot under COPILOT_HOME, and Claude's toolRoots. * test(locate): state every tool's rules and blocks in the matrix (Tencent#1221) Every tool in both scopes, each row citing its source. The dsh workspace cells follow Tencent#1223: dsh loads teamai's hook config, so its SessionStart hook carries the workspace rules and blocks. * feat(mcp): write each tool's servers where locate says it reads them (Tencent#1221) resolveMcpTargets now takes every target from locate(tool, 'mcp'): WorkBuddy's user servers go to the first existing of its lookup order, its project servers to CodeBuddy's local scope under sharing.gitExclude, and OpenCode, Muse and Pi follow a moved home (XDG_CONFIG_HOME, OPENCODE_CONFIG_DIR, PI_CODING_AGENT_DIR). The local-scope tools, the file readers of claude's .mcp.json and OpenCode's plugin file come from the descriptor instead of tables here. Copilot's MCP file still says it is installed (Tencent#628). * feat(local-agent): install MCP servers where locate says the tool reads them (Tencent#1221) install_mcp and uninstall_mcp take the tool's MCP file from locate(tool, 'mcp'), as a pull does: WorkBuddy's user servers go to the first of its files that exists, and OpenCode, Muse and Pi follow a moved home. USER_MCP_LOOKUP and userMcpFile go; doctor's read-file check names the target's own lookup files. * fix(rules): write rules where locate puts them, so they follow a moved home (Tencent#1221) Every rules directory pull, push, the pre-push sync, the built-in rules, recall disable, the Cursor user-rules hook, doctor and the local agent's report read now comes from locate(tool, 'rules'). OpenCode under XDG_CONFIG_HOME or OPENCODE_CONFIG_DIR gets its rules and their `instructions` glob in the config dir it reads, and the glob goes to the activation file locate names instead of the MCP field. Muse under XDG_CONFIG_HOME and Pi under PI_CODING_AGENT_DIR get the team-rules block in the AGENTS.md they read. The rules locator keeps honoring a team toolPaths entry written before a tool's rules moved (Tencent#938, Tencent#946): it names a rules directory the tool never reads, so locate returns that directory with no reads, pull still writes there and doctor still fails it. The inline team-rules block comes from the blocks location, so such an entry keeps its block too. * feat(agents): deliver agents where locate says each tool takes them (Tencent#1221) agentToolDirs, which the pull writer, doctor and the model holds read, asks locate. OpenCode and Muse agents now follow a home that XDG_CONFIG_HOME, OPENCODE_CONFIG_DIR or the tool-homes record moves, as their skills already did. * feat(agents): deploy and remove the built-in agents where locate says (Tencent#1221) deployBuiltinAgents and recall off ask locate, so the recall agent follows a moved OpenCode or Muse home too. deployBuiltinAgents now takes the local config: every caller passes one, and the test that called it without one passes the member's config instead. * feat(locate): retire the agents directory a team maps for a tool teamai renders none for (Tencent#1221) An earlier release copied team .md agents into any configured agents directory, so teamai remove, the tombstone pass and uninstall still clear its copies there. * feat(agents): push and remove read the agents directory locate names (Tencent#1221) The push scan and teamai remove ask locate for each tool's agents directory, so they see the copies in a moved OpenCode or Muse home. A custom tool, for which teamai renders no agents, is no longer scanned or cleaned. * feat(agents): pull's tombstone pass and target set ask locate for agents (Tencent#1221) * feat(workflow): load a step's agent from where locate says pull wrote it (Tencent#1221) runLocalDriver's toolPaths are now the team's as teamai.yaml states them, and loadAgent asks locate, so a user-scope agent in a moved OpenCode home loads. * feat(uninstall): find agents in every directory locate names for them (Tencent#1221) * feat(init): seed the agents directory locate names (Tencent#1221) A custom tool gets no agents directory: teamai renders no agents for it. * feat(agents): record where each tool took agents, and name a directory it left (Tencent#1221) places.agents joins the record the fast path compares, so a home that moves at one team revision syncs agents in full, and the first pull after it names the old directory once. A tool that did not take every agent (a member's own file, a held model, a failed write or built-in) keeps its old directory on record until it does. The record of an earlier release names no agents places, so its first pull syncs in full: the skillDirs upgrade test now expects that, and the fast-path fixtures record agents places as this CLI does. * feat(doctor): say where each tool takes agents, and whether Codex trusts the project that holds them (Tencent#1221) Doctor names a tool whose agents moved since the last pull, notes a tool whose agents follow a moved home while its other files stay in the default one, and checks Codex trust for a team that ships agents and no MCP servers. * test(agents): drop the agents path assertions the locate table states (Tencent#1221) The agents rows of locate-agents.test.ts state each of these paths with its source: OMP's user agents, Qoder CN's user agents, WorkBuddy's default, and Copilot's project directory. The whole default toolPaths literals and the toolRoots helper outputs stay, since they pin every other key too. * docs(reference): agents follow OpenCode's and Muse's moved homes (Tencent#1221) * feat(mcp): note each server's file in its ownership record (Tencent#1221) Every MCP writer now records the file it wrote a server to: pull, which `mcp inject` and `mcp remove` run, and the local agent. A record whose file the tool no longer reads splits three ways: - in one of teamai's own relocations (a lookup file, the mapped or alternate file, an earlier release's default): moved out, as before; - still holding the server elsewhere, after a home move or a remap: kept, and named once, as skills are; - anywhere else: taken as the current file's. A record an older teamai wrote notes no file. It reads as the mapped file for a lookup target, the default home for OpenCode, Muse and Pi, and the target's file otherwise; one whose entry an earlier release's default holds unchanged is moved out of that file. locate marks the built-in path of a remapped tool 'builtin', apart from an earlier release's 'default': a remap leaves the old file as it is. * fix(hooks): count a session-start channel ready only once its hook is installed (Tencent#1221) instructionHookChannel answered ready for every tool it did not know, so a ZCode, DeepSeek Harness or Muse Code channel with no teamai hook counted as delivering. channelReadiness takes the probe the tool's run-time channel names and checks it: the SessionStart hook in the hooks file for Codex and Muse Code, that hook plus hooks.enabled for ZCode, the cordis.patch.yml row and the bridge config for DeepSeek Harness. A new probe fails the type check until it has a check. * feat(uninstall): find each tool's MCP places through locate (Tencent#1221) Uninstall takes the servers of a partition that is no project out of each local scope where locate places it, so WorkBuddy's in .codebuddy.json go too, and CODEBUDDY_CONFIG_DIR is read through the host. The files whose git exclusions it removes are every place cleanupOf names for a tool: its file, OpenCode's plugin file, the other files of a lookup and the retired ones. * fix(rules): give Muse Code, dsh and ZCode a project's instruction blocks at session start (Tencent#1221) In a project these three read no file teamai could write the culture, claudemd and recall blocks to, and their session-start hook added only the rules, so they got none of the blocks. Whether a tool takes a scope's blocks from a hook now comes from its run-time blocks channel in the descriptor: the hook adds the blocks before the rules, the HTTP agent's prompts ride the same hook and are written to no file, and the hook's limit comes from the descriptor. project-hook-rules.test.ts pinned "rules only, no instruction blocks" for the three: that was Tencent#945's requirement, and Tencent#1221 replaces it, so the test asserts the blocks now. A run-time channel is probed in the member's home, where the hook or extension lives; the instruction-targets shape test creates ~/.pi for Pi as it already did ~/.omp. * refactor(mcp): read and write a server map under a key path (Tencent#1221) readJsonDoc and writeJsonDoc take the keys from a file's top to its server map, keeping every other key on the way, and a target carries the key locate names when it is not the format's own. No target has one yet; ZCode's `mcp.servers` is next. The local agent writes under the key of the place it writes. * fix(mcp): deliver ZCode servers through its native config (Tencent#1221) ZCode 3.16.2 reads mcp.servers in its user and project config. Move owned entries out of the former shared file, keep unrelated keys, and judge nested server maps for git exclusion. The outside-home path assertion changes because MCP now lives in the ZCode home. * fix(rules): write instruction blocks where locate puts them (Tencent#1221) Pull, the retire pass, uninstall, doctor, the OpenCode registration and the local agent now take each tool's blocks file from locate(tool, 'blocks'). USER_TARGETS, PROJECT_TARGETS, GIT_EXCLUDED_PROJECT_TARGETS, entryFor, instructionTargetFile, instructionTargetPath, instructionTargetAt, retiredInstructionFiles, userRulesFile, readsTeamRulesFromFile and isInstructionToolInstalled are gone; block text and planning stay in instruction-targets.ts. Behavior that moves with it: - Muse, OpenCode and Pi get their user blocks in the home they read (XDG_CONFIG_HOME, OPENCODE_CONFIG_DIR, PI_CODING_AGENT_DIR), and OpenCode's own AGENTS.md is looked for there before the Claude fallback is used. - OpenCode's `instructions` entry goes to the file locate names as the blocks activation, not the one the MCP field names. - A tool has the teamai-recall subagent only where locate gives it an agents directory, so a custom tool with an `agents` path gets the direct recall block. - blocksFileOf takes a fixed `dir` for CodeBuddy's and WorkBuddy's project file: CodeBuddy's engine reads .codebuddy/rules whatever the team maps, so both keep sharing one copy there. - One install gate per tool: WorkBuddy is installed where .workbuddy is. The Tencent#945 shape test counted an entry with only a bare `claudemd` as installed; it now creates .workbuddy, since that requirement is gone. * fix(mcp): use WorkBuddy project lookup and retire the old file (Tencent#1221) WorkBuddy uses the same project lookup as CodeBuddy. Update the old default-path assertion to the observed .mcp.json requirement, and clean the previous .workbuddy/mcp.json entries by ownership hash in both tree and local scope. * feat(doctor): report MCP read locations and unknown channels (Tencent#1221) * fix(local-agent): preserve MCP homes and migrate retired config keys (Tencent#1221) * test(mcp): cover tool locations in the shared matrix (Tencent#1221) * docs(mcp): explain native configs and moved homes (Tencent#1221) * fix(mcp): retain recorded config addresses during cleanup (Tencent#1221) * fix(local-agent): name old MCP configs for TOML installs (Tencent#1221) * fix(doctor): mark ZCode fallback loss as a warning (Tencent#1221) * feat(rules): record where each tool took rules and blocks, and name a place it left (Tencent#1221) A moved home has to redeliver rules and instruction blocks on an unchanged revision, and a copy the member kept has to leave the old place on record. The ledger's rules set is what makes that incomplete. Co-authored-by: Cursor <[email protected]> * feat(doctor): say where each tool takes rules and instruction blocks (Tencent#1221) A moved home and a directory the tool does not read were visible for skills only. Rules and blocks get the same lines. Co-authored-by: Cursor <[email protected]> * refactor(rules): take rules and CLAUDE.md paths from locate (Tencent#1221) Uninstall scanned a rules directory it built with path.join, and the legacy rules-section strip did the same for CLAUDE.md. Both now ask locate. A retired claudemd stays in the strip. A rules directory stays in the uninstall scan. The guard is the skills twin, and it balances parentheses. The skills regex stops at the first nested call, so it missed path.join(resolveToolBaseDir(tool, localConfig), toolPaths[tool]?.rules ?? ''). Red, before the move, from npx vitest run src/__tests__/locate.test.ts -t "rules directory or claudemd": AssertionError: expected [ …(3) ] to deeply equal [] + [ + "resources/rules.ts: path.join(baseDir, toolPath.claudemd)", + "uninstall.ts: path.join(baseDir, toolPath.rules)", + "uninstall.ts: path.join(resolveToolBaseDir(tool, localConfig), toolPaths[tool]?.rules ?? '')", + ] The allow-list is empty. Co-authored-by: Cursor <[email protected]> * refactor(rules): take OpenCode's retired project config from the rules location (Tencent#1221) Co-authored-by: Cursor <[email protected]> * fix(rules): remove tombstoned copies from a rules directory teamai no longer writes (Tencent#1221) Co-authored-by: Cursor <[email protected]> * docs(reference): state where rules and instruction blocks follow a moved home (Tencent#1221) Co-authored-by: Cursor <[email protected]> * test(pull): give fast-path fixtures the rules and instruction blocks a pull records (Tencent#1221) Co-authored-by: Cursor <[email protected]> * test(pull): expect the instruction-block notice when an OpenCode agent home moves (Tencent#1221) A moved OpenCode home also leaves teamai-context.md behind. The agent place tests still required that line to stay silent. Co-authored-by: Cursor <[email protected]> * fix(ci): keep the Codex team-hook command on bare bash (Tencent#1221) Merging main failed Windows CI because the team-hook dispatcher still substituted a Git Bash path into command, while main pins bare bash on every platform and carries the Windows form in commandWindows. The same merge left the doctor fixture without OpenCode's rendered mcp entry, and the WorkBuddy teamai-only case expecting the retired project file. Co-authored-by: Cursor <[email protected]> * fix(local-agent): resolve a local-scope MCP record without a file in that scope (Tencent#1221) A record an earlier release wrote for Claude's or CodeBuddy's local scope notes no file. It resolved against the project's file instead, so with sharing.gitExclude on, install_mcp refused to update the server as not managed by teamai. Pull never adds the file in HTTP mode, so the record did not heal. * fix(rules): retire a mapped claudemd for a tool with no blocks channel (Tencent#1221) An earlier release wrote the instruction blocks into a claudemd the team mapped for JoyCode, Kiro, Qoder or Trae. Pull no longer writes there, so it now strips teamai's blocks from that file and uninstall finds them, as the rules and agents locators already do for a configured directory. team-culture.md named that claudemd as the workspace channel for ZCode, DeepSeek Harness, JoyCode and Muse Code; the first three now get the blocks from the session-start hook, and JoyCode gets none. * fix(rules): list OpenCode's user instruction file whatever the team maps MCP to (Tencent#1221) registerOpencodeContext took the config from the MCP mapping, so a team mapping no opencode mcp got no instructions entry, and one mapping it elsewhere got the entry in a file pull, doctor and uninstall do not read. It writes the opencode.json beside the file again, as they read it. * fix(uninstall): remove teamai's MCP servers from a file the tool left (Tencent#1221) After a home move, uninstall dropped the records of servers an earlier release wrote to the old file and left the servers there. It now takes the unchanged ones out, as the local agent's uninstall_mcp does; a copy the member changed stays. * feat(locate): follow CodeBuddy's home when CODEBUDDY_CONFIG_DIR moves it (Tencent#1221) CodeBuddy 2.168.0 reads its whole home from CODEBUDDY_CONFIG_DIR, not ~/.codebuddy, and keeps .codebuddy.json there too. teamai assumed the variable moved only .codebuddy.json, so skills, rules, CODEBUDDY.md, agents and the user MCP files went to a home CodeBuddy did not read. The variable is now a home move, recorded as the others are, so every shell writes the same place. Hooks stay in ~/.codebuddy/settings.json until B4, and doctor notes it. * fix(uninstall): remove local-scope MCP servers from a file the tool left (Tencent#1221) With sharing.gitExclude off, uninstall took teamai's servers out of the local scope's current file only. After CodeBuddy's home moved, it dropped the records of servers in the old .codebuddy.json and left the servers. It now removes the unchanged ones there, as it does for a target. * fix(mcp): take servers from the file their record names after CodeBuddy's home moves (Tencent#1221) Once CODEBUDDY_CONFIG_DIR moves CodeBuddy's home, a record names a file the tool left. Three paths still used the current file: - A record an earlier release wrote with no file was taken to own the moved mapped file, so a pull could overwrite a member's server there. It now resolves to the mapped file under the default home. - The local agent's uninstall_mcp removed nothing from the recorded .codebuddy.json and dropped the record. - Uninstall and pull took other checkouts' servers out of the current .codebuddy.json only, and dropped their records. They now go by the file each record names, as the orphan cleanup already did. Test setup clears CODEBUDDY_CONFIG_DIR with the other home variables. * test: clear every variable that moves a tool home, as TOOLS declares it (Tencent#1221) The test setup listed the home variables by hand and missed CODEBUDDY_CONFIG_DIR, so a test that stubs only HOME wrote fixtures into a developer's real CodeBuddy home. It now takes them from the tool descriptors, as init does: homeVariables moves to tools.ts beside the descriptors so both read one list. * fix(uninstall): take teamai's servers out of a Codex config.toml a moved root left (Tencent#1221) Uninstall cleaned the file a tool left after its root moved with the JSON writer only. A Codex config.toml there did not parse, so its servers stayed. Every edit of an MCP file now goes through one writer that picks the file's format, and a Codex block the member changed stays, as a JSON entry does. * fix(locate): follow the user config's tool roots from a project that records none (Tencent#1221) A project config without toolRoots took the tool's default home for everything locate reads from the tool's user config: the Codex hook gate of rules and blocks, Codex's trust config for agents and MCP, and Claude's local MCP scope. With Codex placed elsewhere by the user config and ~/.codex absent, a project pull skipped instruction delivery. The user view now takes the user config's roots in that case, as resolveMemberToolRoots and the earlier resolver did. * fix(uninstall): clean each MCP record in the file it names, OpenCode's moved project file too (Tencent#1221) Uninstall handed every OpenCode record outside the current file to the alternate file, so after toolPaths.opencode.mcpProject moved, teamai's servers stayed in the original opencode.json and their records were dropped. Records now go to the file they name. A record whose file no longer parses is kept for the retry instead of being read as gone. * fix(uninstall): clean recorded MCP files when the current one cannot be read (Tencent#1221) Uninstall now cleans each record in the file it names whatever state the current target is in, and a Codex config.toml that cannot be read keeps its records, as an unparsable JSON file does. * fix(uninstall): clean recorded MCP files whatever state the current one is in, in the scope a project's servers left too (Tencent#1221) * fix(mcp): tell a retired MCP key apart from the current one in one file, and keep what a kept record says of resolved values (Tencent#1221) * fix(mcp): keep an earlier release's MCP record while the retired file it may sit in cannot be read (Tencent#1221) * fix(uninstall): keep the data home while an MCP config holding teamai's servers does not parse (Tencent#1221) * fix(uninstall): keep the data home while a removed worktree's MCP servers sit in a config that does not parse (Tencent#1221) --------- Co-authored-by: Cursor <[email protected]> Co-authored-by: teamai-ci <teamai-ci@noreply>
Summary
This PR is steps B1, B2 and B3 of #1221.
flowchart LR subgraph callers ["callers"] rules["rules, blocks:<br/>pull, uninstall, doctor"]:::added agents["agents:<br/>pull, doctor, local agent"]:::added mcp["MCP:<br/>resolveMcpTargets, doctor"]:::added skills["skills (#1252)"] later["hooks, self scope,<br/>models switch settings"]:::todo end subgraph core ["src/locate.ts"] locate["locate(tool,<br/>rules | blocks | agents | mcp)"]:::added places["places records<br/>skills, rules, blocks, agents"]:::added end host{{"Host"}} own["MCP file stays on<br/>the ownership record"] left["name a place the tool left<br/>copies stay"]:::added page["runtime rows and<br/>docs/guide/tool-support.md"]:::todo old["path joins,<br/>instructionTargetPath"]:::removed skills --> locate rules & agents & mcp --> locate locate --> places locate --> host mcp --> own rules & agents --> left later -.-> locate places -.-> page rules & agents & mcp -.-> 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;Green: this PR. Gray: later steps of #1221 (B4, then C and D). Red: removed.
Rules, instruction blocks, agents, and MCP servers are written where
locatesays each tool reads them, including a moved home. A place a tool left is named once. MCP does not join that record; uninstall still removes teamai's unchanged servers from a file the tool left.Two rules hold across every path:
config.tomlis edited as TOML, and a copy the member changed stays, as a JSON entry does.applyMcpFileinmcp-reconcile.tstoolRootsfollows the user config's, asresolveMemberToolRootsdoes. That covers everythinglocatereads from the tool's user config in project scope: the Codex hook gate of rules and blocks, Codex's trust config for agents and MCP, and Claude's local MCP scope. Project skills read no user-scope path.userViewOfinlocate.tsMCP ownership records that name a file other than the current one are cleaned in the file they name, for every tool, format and scope. One function,
applyMcpFileThenOthersinmcp-reconcile.ts, reconciles the current file and then those files. The reconcile loop calls it, and so does the cleanup of the place Claude's and CodeBuddy's project servers left (.mcp.jsonor the tool's local scope, assharing.gitExcludepicks):On uninstall, the current file's state (written, unchanged, missing, unparsable, unreadable) changes no row. A pull that cannot read the current file moves nothing and keeps every record. A file a pull moves servers out of on purpose (OpenCode's other project file, a lookup or retired file) keeps them, and their records, while it does not parse or cannot be read. A record from an earlier release that notes no file follows the current file when the file it guesses lacks the entry, and stays tied to a retired place that cannot be read, so the next run retries there. A record kept for a file the run could not read keeps what it said of resolved values. While a kept record's file cannot be read, uninstall keeps the data home that holds the record, names the file and exits 1, as it does for other files it could not clean. That covers every record a retry reaches: the checkout's own, and the local scope of every checkout of the project for each tool it syncs, a removed worktree's included. Those other checkouts' records also count as owned, so uninstall from a checkout that holds none of teamai's servers still cleans them.
A place is a file, a key in it, and a project under that key. A team config from before this PR can map ZCode's
mcpto~/.agents/mcp.json, where an earlier release wrote undermcpServerswhile ZCode now readsmcp.servers: those are two places in one file, and the retired one follows the table above. Every comparison of MCP places (locate, the record split, the other-file cleanup, the local agent, doctor) uses that identity.A
claudemdthe team maps for a tool with no blocks channel (JoyCode, Kiro, Qoder, Trae) is retired: pull strips teamai's blocks from it and uninstall finds them. ZCode, DeepSeek Harness and Muse Code get a project's blocks from the session-start hook.CODEBUDDY_CONFIG_DIRmoves CodeBuddy's whole home, not only.codebuddy.json. teamai now treats it as a home move and records it like the other ones, so every shell writes to the same place. Hooks stay in~/.codebuddy/settings.jsonuntil B4, and doctor says so.The README support table does not change. Every tick still matches the tool's channels here: this PR fixes where existing deliveries land, and no tool gains or loses a resource.
builtin-hooks.tskeeps the Codex team-hook command on barebash. That is a CI fix after mergingmain, not part of #1221.Evidence
toolPaths.rules,toolPaths.claudemd, and MCP paths themselves. A moved OpenCode or Muse home left rules and blocks at the old home.After: on
7222f4be(main merged in),npx tsc --noEmitandnpm run lintexited 0, andnpx vitest runpassed 503 files (1 skipped) and 14637 tests (21 skipped). Oncfc243a0,npm run buildexited 0. The MCP record table inmcp-locate-targets.test.tsruns 132 rows (mode x current-file state x recorded-file state, for OpenCode, Claude and Codex in both scopes), plus 16 for the place Claude's and CodeBuddy's project servers left, plus 8 for ZCode'smcpServers(uninstall and pull; same file or ZCode's own; the retired file unparsable or unreadable, then repaired). The 4 retired-file rows failed onee998ef8.e2e/mcp-uninstall.test.tsadds 2 rows (Claude's~/.claude.json, ZCode's retired~/.agents/mcp.json, each unparsable, then repaired); both failed onee998ef8.e2e/codebuddy-mcp-local-915.test.tsadds 2 rows: uninstall from a checkout holding no servers, while a removed worktree's servers sit in a.codebuddy.jsonthat parses, or does not parse until it is repaired; both failed on924ec0ba. Locally, the e2e suite passed 168 files and 1415 tests; the only failures were the two Ctrl-C cases ofworkflow-signals.test.ts, which fail only on this machine and touch no code here.cfc243a0, project scope, CodeBuddy,sharing.gitExcludeon:initandpullin the main checkout and in a linked worktree, then the team drops its servers and the main checkout pulls (its local scope is empty), the worktree is removed, and~/.codebuddy.json(still holdingplain-apifor the worktree) is made invalid JSON.uninstall --forceexits 1 withUninstall incomplete: kept <home>/.teamai/projects/<app> ... Repair permissions or JSON in <home>/.codebuddy.json (projects["<wt>"]), andmanaged-local-mcp.jsonkeeps the worktree's key. After the repair,uninstall --forceprintsRemoved 1 teamai-managed MCP server(s), exits 0, and the worktree's servers and the records are gone. On924ec0bathe first uninstall exited 0 and deleted the records, leavingplain-apiunowned.teamai init --agent codebuddy --scope projectwithsharing.gitExcludeon,teamai pull(~/.codebuddy.jsonholdsapifor the project; the member addsmine), thensharing.gitExcludeoff in the team config andCODEBUDDY_CONFIG_DIR=<dir>whose.codebuddy.jsonholds invalid JSON, with no pull, thenteamai uninstall --force:f86645eb:Could not parse <dir>/.codebuddy.json.~/.codebuddy.jsonstill holdsapi,mine.a488a3d4: the same warning, thenRemoved 1 teamai-managed MCP server(s).~/.codebuddy.jsonholdsmine, and<dir>/.codebuddy.jsonis untouched.3787ad14, user scope, OpenCode with no teammcpmapping,initthenpull:opencode.jsonliststeamai-context.mdininstructions, andteamai doctorpasses every OpenCode check. CodeBuddy 2.168.0 withCODEBUDDY_CONFIG_DIR=<dir>: skills, rules and.mcp.jsonland in<dir>, andcodebuddy mcp listshowsteamapi.Merge Danger
Door: two-way
A checkout whose places record has skills but not rules, blocks, or agents takes one full sync. The next pull can take the fast path again.
Blast Radius: pull, uninstall, local agent MCP
Doctor, uninstall, and the local agent read the same places. MCP cleanup still follows the ownership record. A local-scope MCP record an earlier release wrote without a file resolves in that scope, so the local agent can update it.
Uninstall now keeps a Codex MCP block the member changed since teamai wrote it, as it already did for JSON configs. Uninstall now exits 1 and keeps
~/.teamaiwhile an MCP config holding teamai's recorded servers does not parse or cannot be read; it used to delete the records and leave those servers unowned. That includes a removed worktree's local scope.A member with
CODEBUDDY_CONFIG_DIRset gets CodeBuddy's skills, rules, blocks, agents and MCP files in that directory from the next pull. The copies under~/.codebuddystay, and pull names that place once. Uninstall removes teamai's unchanged MCP servers from the old file.