Repository navigation
feat(doctor): fail until each tool trusts the project or approves its team MCP servers - #1660
Conversation
Codex project trust was evaluated inline by the agents check and by a Codex-only MCP check. Both now ask read-gates.ts for the verdict of each gate locate declares, so a new trust or approval gate is one case there. Proof: the Codex trust tests in doctor-mcp-delivery and doctor-agent-places pass unchanged; typecheck and lint pass.
Pi 1.4.0 loads a project's .pi/skills and .pi/mcp.json only in a trusted project, and pi -p treats an undecided one as untrusted. doctor now reads Pi's trust.json (nearest entry walking up, then defaultProjectTrust) and names the line that trusts the project. Proof: doctor-read-gates tests (verdicts recorded from Pi 1.4.0 runs in an isolated HOME); mutating each branch fails its case; locate matrix rows declare the gate.
…f hooks Muse Code 1.4.14 loads a project's .agents/skills, .mcp.json and .muse/hooks.json only in a trusted workspace, keyed by the real path of the checkout's own git root, and muse exec runs an undecided one untrusted. doctor now reads Muse's trust.json and names the entry to add. Hook files gain read gates in the descriptor, as agents and MCP have. Proof: doctor-read-gates tests (verdicts recorded from Muse 1.4.14 runs in an isolated HOME: untrusted, trusted, parent key, linked worktree, XDG_CONFIG_HOME); locate matrix rows declare the gate.
Copilot CLI 1.0.105 loads workspace MCP servers and repo hooks only in a trusted folder, and copilot -p skips them. doctor now reads trustedFolders (or the older trusted_folders) from Copilot's config.json, which opens with // comment lines: an entry covers the folders under it, and a linked worktree takes its main checkout's. Proof: doctor-read-gates tests (verdicts recorded from Copilot CLI 1.0.105 runs in an isolated HOME: parent folder, sibling prefix, worktree, COPILOT_HOME, legacy key, workspace and self-mode hooks); locate matrix rows declare the gate.
An interactive Qoder CLI 1.1.81 session ignores a project's .qoder/settings.json (MCP servers, self-mode hooks) until the user settings' permissions.trustDirectories covers the folder, and starts a project server only once it is approved by name in mcp.enabledProjectMcpServers. A name in mcp.disabledProjectMcpServers stays off in qodercli -p too. doctor now reads both verdicts. Proof: doctor-read-gates tests (verdicts recorded from Qoder CLI 1.1.81 runs in an isolated HOME: ancestor, folderTrust off, project settings cannot self-trust, QODER_CONFIG_DIR, rejection in project settings); locate matrix rows declare the gates. Qoder CN shares the project file but its trust store was not run, so it has no gate.
An interactive Claude Code 2.1.316 session starts a .mcp.json server only once it is approved, and never one in disabledMcpjsonServers. Approvals live in settings files: ~/.claude/settings.json counts always, the project's settings.json and the main checkout's settings.local.json only once ~/.claude.json trusts the main checkout. doctor now merges them as Claude Code does and names the dialog or the key that approves. A local scope in ~/.claude.json waits on no approval and gets no check. Proof: doctor-read-gates tests (rules recorded from Claude Code 2.1.316 runs in an isolated HOME: untrusted, trusted, user settings, rejection, linked worktree, local scope); locate matrix rows declare the gate.
…ervers CodeBuddy Code 2.179.1 reads the approval of a project's .mcp.json servers from <cwd>/.codebuddy/settings.local.json only (CODEBUDDY_PROJECT_CONFIG_DIR moves it), and holds a pending server back in codebuddy -p too. doctor now reads that file. A local scope in .codebuddy.json waits on no approval and gets no check. Proof: doctor-read-gates tests (rules recorded from CodeBuddy Code 2.179.1 runs in an isolated HOME: by name, enable all, rejection, user settings ignored, CODEBUDDY_PROJECT_CONFIG_DIR, local scope); locate matrix row declares the gate.
… servers Cursor CLI 2026.10.21 keeps a project's approvals in ~/.cursor/projects/<slug of the real git root>/: mcp-disabled.json names servers it never loads or asks about again, mcp-approvals.json holds <name>-<hash>, the hash taken over the server with the env of the shell Cursor runs in. doctor cannot redo that hash, so it reports a declined server, and a server with no approval once the CLI approved others here, naming cursor-agent mcp enable. With no CLI state (a Cursor IDE member), the check passes. Proof: mcp disable/enable recorded with Cursor CLI 2026.10.21 in an isolated HOME on 2026-11-02 (mcp-disabled.json is an array of names); doctor-read-gates tests; locate matrix row declares the gate.
The diagnostics guide (English and Chinese) gets the doctor output of a new checkout, the prompts that clear it, a rejected server, a headless machine, and where each tool keeps its answer. The troubleshooting reference tells the agent to have the member accept the prompt rather than edit a trust file unasked. The example output is from a real teamai pull and doctor run in an isolated HOME, paths renamed.
OpenCode V2 applies configured `instructions` entries (packages/core/src/config/plugin/instruction.ts at v2.0.30, v2.1.2 and v2.2.5: "configured `instructions` entries are explicit requests"). teamai leaves them out on V2 because its plugin adds the same files, and V2 would load them twice. Pull and doctor told members the opposite. The behaviour stays; the pull message, two doctor fixes and the comments now give the real reason. The Hermes comment in source.ts also said Hermes never reads <root>/.hermes/skills; it does for a root listed in skills.trusted_project_dirs (agent/skill_utils.py).
Pi reads AGENTS.override.md before AGENTS.md only from 0.84.0: the resource loader of @earendil-works/pi-coding-agent 0.83.0 has no override candidate and 0.84.0 has it, and no @mariozechner release does. With an override present, user-scope pull writes the team instructions there, so an older Pi saw none of them while doctor passed. Doctor now runs `pi --version` when Pi's target is the override and fails below 0.84.0, naming the upgrade or the move back to AGENTS.md. Without a pi on PATH or a parseable version the check is not added.
Pi added project trust in 0.79.0 (its changelog: "Pi now asks before loading project-local settings, resources, instructions, and packages"; 0.78.1 ships no trust.json handling). On an older Pi doctor failed the trust check and named a prompt that does not exist. getAgentVersion now detects `pi`, and the gate counts as met below 0.79.0. Also from review: unreadable() and approvalVerdict() take named arguments, since their string parameters were easy to swap, and the three settings-list approvals share listedApproval().
Every Pi before 0.74.0 is @mariozechner/pi-coding-agent, whose `pi` command makes `npm install -g @earendil-works/pi-coding-agent` stop with EEXIST (reproduced in an isolated npm prefix over 0.73.1). The fix text now uninstalls it first. The check reads Pi's version through getAgentVersion and semver, and its name spells Pi like the trust checks. Docs: the Pi row of the trust table says 0.79.0, and the headless trust.json example says it is for a runner with no trust.json yet, as it replaces the file.
A project MCP file can be read by several tools: Claude writes .mcp.json and Muse Code reads it too. The MCP read-gate checks went through every tool in toolPaths, so with Muse absent doctor still failed "Muse Code trusts this project". They now skip a tool whose `installed` gate is unmet, as the other doctor checks do; hook gates already did, through writable().
The Cursor CLI 2026.10.21 approves `<name>-<16 hex>`, the first 16 hex
of sha256(JSON.stringify({ path: <project root>, server: <its
.cursor/mcp.json entry> })), and an approval of an earlier definition no
longer loads the server. doctor took any approval of the name, so a pull
that changed a server's command kept passing while the CLI held it back.
It now computes the key; an entry reading ${...} is hashed resolved with
the shell's env, so for those any approval of the name still counts.
With no mcp-approvals.json the CLI approves nothing. doctor now holds the
servers back once the CLI has run on this machine (its cli-config.json),
and keeps passing for a member on the Cursor IDE alone. The gate places
both files the way the CLI does: CURSOR_DATA_DIR for projects/,
CURSOR_CONFIG_DIR else XDG_CONFIG_HOME/cursor for cli-config.json.
Checked with the real cursor-agent 2026.10.21 in an isolated HOME: doctor
passes before the CLI runs, fails after `cursor-agent mcp list` shows
"needs approval", passes after `mcp enable`, and fails again after the
team bumps the server and pull rewrites it, when `mcp list` again shows
"needs approval".
The Cursor CLI hashes a server after resolving its ${env:NAME}, ${NAME}
and ${NAME:-default} with its shell's env, leaving an unset name as
written. doctor took any approval of the name for such an entry, so an
approval of an earlier definition still passed. It now resolves them the
same way (the CLI's own pattern) with doctor's env and compares the full
key; a mismatch counts as waiting, and the fix says which env doctor used.
Checked against cursor-agent 2026.10.21: an entry mixing ${env:...},
${NAME:-default} and unset names, approved with ISSUES_TOKEN=abc, gets
issues-aee3481da24f25bf from both the CLI and this resolver.
|
No confident, actionable findings in the specified PR diff. The PR description satisfies the testing requirement: it records built, real-CLI verification at Review was read-only; I did not run, build, or install anything from the PR. |
Claude Code keeps no per-hook approval, but `disableAllHooks` in the settings file that decides stops every hook, teamai's included: the checkout's .claude/settings.local.json, then its .claude/settings.json, then the user settings.json. Checked with `claude -p` 2.1.316 and a SessionStart hook: true in settings.local.json skips it, false runs it, and local false over project true runs it. Claude's hook channels declare a claude-hooks-enabled gate. A team-repo project keeps its team hooks in the user settings (Tencent#264), whose gates locate placed through the user view and so dropped; it now places a project's gates on them, which only Claude declares. Managed policy, which can also turn hooks off, is not read.
|
No confident, actionable findings in the specified PR diff. The PR description satisfies the testing requirement: it records built, real-CLI verification on November 2, 2026, including failing and passing trust/approval states, plus the Claude hooks run at The earlier pass raised no findings, so none require resolution. Review was read-only; I did not run, build, or install anything from the PR. |
SaulMoro
left a comment
There was a problem hiding this comment.
This was generated by AI during triage.
Approving at f525a4b.
Built-CLI run at b91797a on an isolated HOME: one team skill and one MCP server, then init and pull with Claude and Pi in project scope.
teamai doctor |
Base build | This PR |
|---|---|---|
| No trust or approval yet | exit 0, no gate lines | exit 1: ✖ Pi skills, ✖ Pi MCP, ✖ Claude MCP approval |
After writing the entries by hand into ~/.pi/agent/trust.json, ~/.claude.json and .claude/settings.local.json |
exit 0 | exit 0, all three ✔ |
-
Fails closed: a malformed
trust.jsonor~/.claude.jsonfails the check instead of passing it. The trust and approval files are byte-identical afterdoctor. -
Worktrees and paths: a linked worktree fails the Pi gate until it has its own entry. A Claude approval in the main checkout's
settings.local.jsoncounts for its worktrees. A symlinked project path passes when the entries use the real path. -
Agrees with Pi: real Pi 1.4.0
pi mcp listignores the untrusted project and loads the trusted one, matchingdoctor. -
Pi override version: the 0.84.0 minimum for
AGENTS.override.mdmatches the npm tarballs: 0.83.0 has no override support and 0.84.0 does. -
Last commit:
disableAllHooks(f525a4b) I read rather than ran. It follows the local → project → user order and treats an unparseable file as unreadable, not as a pass. -
[P3 nit]
src/read-gates.ts:127-128treats Pi 0.79.0 withdefaultProjectTrust: "always"as trusted. That setting first shipped in 0.79.1 (Pi CHANGELOG and the 0.79.0 tarball), so the floor for that branch should be 0.79.1.
CI review: no findings at b91797a or f525a4b, and I agree.
Not checked:
- Muse, Copilot, Qoder, CodeBuddy and Cursor with the real tools; the description's record covers each.
- Whether Claude's trust walk-up reaches folders above the repo root.
- Windows and the
gitlab/githubproviders, left to CI.
The plugins.enabled gate from #1221's doctor section is not covered here and stays open there.
…#1660) `teamai doctor` now fails until each tool trusts the project or approves its team MCP servers, so delivered skills, MCP servers and hooks are actually loaded. It reads each tool's own answer and never writes it: Pi, Muse Code, Copilot CLI, Qoder CLI, Claude Code (MCP approval and `disableAllHooks`), CodeBuddy Code, Cursor CLI and Codex. It also fails on a Pi older than 0.84.0 when the team instructions sit in `AGENTS.override.md`, and corrects the OpenCode V2 `instructions` and Hermes wording. Related to Tencent#1221
Summary
pullwrites team skills, MCP servers and hooks into a project, but several tools load them only after the member trusts the project or approves its servers. Until then the files sit there unused, whileteamai doctorsaid everything was fine. Doctor now reads each tool's own answer and fails, naming the prompt or the line that gives it, until the tool will actually load what teamai delivered. Pull still writes either way..pi/skills,.pi/mcp.json~/.pi/agent/trust.json,defaultProjectTrust.agents/skills,.mcp.json,.muse/hooks.json~/.config/muse/trust.json.github/mcp.json,.github/hookstrustedFoldersin~/.copilot/config.json.qoder/settings.jsonpermissions.trustDirectories,mcp.*ProjectMcpServers.mcp.jsonserversenabled/disabledMcpjsonServers, trust in~/.claude.jsondisableAllHooksin.claude/settings.local.json, then.claude/settings.json, then~/.claude/settings.json.mcp.jsonservers.codebuddy/settings.local.json.cursor/mcp.jsonservers~/.cursor/projects/<project>/mcp-approvals.json,mcp-disabled.json.codex/config.toml[projects]in~/.codex/config.tomlAlso from #1221:
AGENTS.override.mdonly from 0.84.0 (absent from the@earendil-works/pi-coding-agent0.83.0 loader, present in 0.84.0; no@mariozechnerrelease has it). When the override holds the team instructions, doctor now fails on an older Pi.instructions(packages/core/src/config/plugin/instruction.ts, v2.0.30 to v2.2.5). teamai leaves its entries out on V2 because its plugin adds the same files, and V2 would load them twice. The pull message, two doctor fixes and the comments said V2 ignores them. The behaviour stays; the wording changed.<root>/.hermes/skillsfor a root inskills.trusted_project_dirs; comment fixed.Docs:
docs/guide/diagnostics.md(+ zh-CN) gains "A tool has not trusted the project yet", with real doctor output and the prompt that clears each one.skill-datatroubleshooting gains the matching entry.Type of Change
Test Plan
npx tsc --noEmitpassesnpm run lintpasses (includesnode scripts/check-docs.mjs)npx vitest runpasses: 648 files, 20093 tests at b91797a; after f525a4b, the doctor, locate and hook suites (49 files, 5672 tests)doctor-read-gates.test.ts(62, throughbuildChecks),doctor-pi-override-version.test.ts(4), and the locate matrix rows for every gate (locate-mcp,locate-hooks,locate-matrix)Real CLI, built at b91797a on 2026-11-02 (the Claude hooks run at f525a4b). Each run used an isolated HOME, a local bare team remote and a fresh git checkout, then real
teamai init+pull+doctor. Long fix lines are cut.Claude, Pi, Muse, Copilot and Qoder, before and after granting each answer in the tool's own file. The real tools confirm both states:
CodeBuddy (its own project, since Claude shares
.mcp.json):✖ CodeBuddy Code approves this project's team MCP servers, then✔afterenabledMcpjsonServersin.codebuddy/settings.local.json, thendoctor exit: 0.Cursor CLI, with the real
cursor-agent2026.10.21 giving every answer:Claude Code hooks. teamai keeps a team-repo project's hooks in
~/.claude/settings.json(#264), and the project's own settings can still turn them off.claude -p2.1.316 with a SessionStart hook behaves the same way: it skips the hook withtrueinsettings.local.json, runs it withfalse, and the local file'sfalsewins over the project'strue.Pi
AGENTS.override.md, user scope, with the real@mariozechner/pi-coding-agent0.73.1 and@earendil-works/pi-coding-agent1.4.0:The uninstall step is needed. Installing
@earendil-works/pi-coding-agentover 0.73.1 stops withnpm error File exists: .../bin/pi.Related Issues
Part of #1221: "doctor does not check workspace trust (Claude, Muse), project trust (Codex agents, Pi), folder trust (Copilot) or MCP approval", "doctor reports the conditions and gates from
locate", the stale comments, and the PiAGENTS.override.mdminimum version (0.84.0, not 1.4.0 as the issue says).Notes for Reviewers
~/.claude.jsontrusts the main checkout.sha256({ path, server })over the entry after${env:...}resolution, so an approval of an earlier definition does not count.cli-config.json) is taken to be on the IDE, whose approvals doctor cannot read, and passes.disableAllHooksorallowManagedHooksOnlyset by an admin).opencode-hooks.ts:278) still says V2 ignoresinstructions. Doctor compares that plugin byte for byte, so editing it would mark every installed plugin out of date.gitlabandgithubproviders, left to CI.