Skip to content

Let each provider plugin own its config folder - #6480

Closed
ymichael wants to merge 10 commits into
mainfrom
bb/swing-2b-provider-config-folders-thr_s3wyu7n866
Closed

ymichael wants to merge 10 commits into
mainfrom
bb/swing-2b-provider-config-folders-thr_s3wyu7n866

Conversation

@ymichael

@ymichael ymichael commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

Each provider's config folder (CLAUDE_CONFIG_DIR, CODEX_HOME, PI_CODING_AGENT_DIR) was worked out in several places that disagreed: Claude's alone four ways with three behaviours, resolveCodexHome three times. Core also computed provider folders itself (the daemon installed bb's skills into ~/.claude/skills regardless of CLAUDE_CONFIG_DIR; server move resolved CODEX_HOME). So a relocated profile listed the default folder's skills too (#3926), project-scoped settings were ignored when listing skills and commands (#3925), the usage check reported a signed-in account as expired (#3607), and a relative CLAUDE_CONFIG_DIR made fork look in the wrong place.

What changed

  • Each plugin owns its folder. The resolvers live in src/config-home.ts of the Claude Code, Codex and Pi plugins, resolved with the environment of the process being configured. Claude paths follow the Claude SDK's semantics (relative to the workspace cwd, no ~ expansion); Pi keeps its ~ expansion.
  • Core asks the plugin instead of computing paths. One internal host path-data contract (internal_DO_NOT_USE_providerPathsHostContract): both consumers enumerate registered providers advertising internal_DO_NOT_USE_resolvesProviderPaths, call each plugin once, and combine/deduplicate its paths. Today Claude contributes writable skill install roots and Codex contributes credential files; the other lists are empty, preserving current destinations. Core names no providers. Server move still only checks and warns; it does not copy credentials. Documented in docs/api_to_audit.md with its only callers.
  • Native roots use the project's environment; the cache includes the project. Host workers share process.env across overlapping calls (the first call's values win), so each host call now also receives its exact environment as context.experimental_env (SDK, documented in the Plugin Guide and docs/api_to_audit.md). The Claude, Codex, Pi and ACP resolvers and Codex helper inference read it, so overlapping projects can't read each other's profile.
  • Provider-path lookups degrade per plugin. A missing or failing plugin contributes no paths and is logged; global skill install/status and the server-move check carry on with the rest. Install wakes a suspended machine before asking. The lookup and the daemon command share one deadline. A CLAUDE_CONFIG_DIR/CODEX_HOME relative to each session's cwd contributes no machine-wide path. Absolute-path checks live in the wire schemas.
  • A provider whose resolver answers owns its user roots, so the default folder is no longer scanned beside a relocated one.
  • Claude health/usage read the active profile's credentials, account file and Keychain item.
  • Guard rule: the provider-contract purity test rejects reads of the three home variables and home-joined .claude / .codex / .pi/agent paths outside the owning plugin. Four allowlisted entries, each with a reason: ACP's single local Claude compatibility copy for Grok/omp (ACP is forkable and can't import another plugin; its omp Codex/Pi copies are excluded explicitly), Claude's legacy ~/.claude/local/claude executable, and Grok's fixed ~/.claude/plugins registry.
  • Wire: HOST_DAEMON_PROTOCOL_VERSION 257 → 259 (258 is taken by Share one question-form translator for ACP and Codex and support optional questions #6476). Plugin SDK 0.6.99.

Visible behaviour changes

  1. With a relocated profile, only the configured provider user roots are listed; .agents/skills roots remain.
  2. Skill/command listing uses the project's environment, so projects sharing a workspace can list differently.
  3. Claude config paths: literal, NFC-normalized, relative to the workspace cwd, no ~ expansion; empty means cwd, unset means ~/.claude.
  4. Claude health/usage never fall back to another profile's credentials.
  5. bb's global CLI skills install into the machine's CLAUDE_CONFIG_DIR; copies in an old profile are left alone.
  6. Daemons must update to protocol 259.
  7. If one provider plugin fails, global skill install still writes the other plugins' folders instead of failing the machine.

How you verified

  • Each fix has a regression that fails on main (relocated roots, project env on a real migrated database, custom-profile credentials, relative fork against the installed Claude SDK, global skill roots), and passes here.
  • The guard rejects six injected violations (three variables, three default paths) and lets unrelated PATH/homedir reads through.
  • Provider suites: Claude 414, Codex 543, Pi 327 (7 skipped), ACP 82. SDK 407, bridge protocol 312, daemon contract 76, server move 97, native-root integration goldens 22. Affected lint and typechecks pass; SDK version check passes.
  • Credential tests use controlled data and mock the SDK process boundary; no live account was exercised. The Claude plugin passes the standalone fork check (install, typecheck, tests, build). Windows fixtures use native absolute paths and file modes; purity allowlist keys normalize separators. The global-skill drift test now runs on Windows too.
  • Follow-up fixes: a daemon test runs two overlapping calls with different env and checks the second sees its own in experimental_env. Server tests cover install going through when one provider plugin fails, and a suspended machine waking (both fail on the previous head). There are contract tests rejecting relative provider paths, and plugin tests for relative profiles. Typecheck passes across all 86 affected packages. Tests pass for the contract, SDK, Claude/Codex/Pi/ACP plugins, the daemon plugin-host/global-skill/server-move suites, 21 affected server files (128 tests), and the purity guard.
  • Provider-literal ratchet passes; affected server aggregation suites: 110 passed. A custom plugin with two provider registrations is called once, and its paths are deduplicated.

The Codex app-server environment change (#4960) is in #6479, not here.

Fixes #3926
Fixes #3925
Fixes #3607

🤖 Generated with Claude Code

AGENT GENERATED

ymichael and others added 10 commits October 28, 2026 15:08
Claude Code, Codex and Pi each declared their default home's skills
directory (~/.claude/skills, ~/.codex/skills, ~/.pi/agent/skills) as a
static user root and also resolved the configured home's directory.
The listing scans both, so with CLAUDE_CONFIG_DIR, CODEX_HOME or
PI_CODING_AGENT_DIR set, the composer, Skills page and `bb skill list`
offered skills from a directory the agent no longer reads. The
resolvers now own those roots (Pi's resolver always answers its agent
dir) and the declarations keep only home-independent roots such as
~/.agents/skills. The native-roots goldens no longer expect the stale
default-home skills for moved homes.

Fixes #3926

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Listing a project's provider skills and commands asks the provider's
host entry to resolve its native roots, but the plugin host call always
resolved machine environment with projectId null. A project-scoped
CLAUDE_CONFIG_DIR, CODEX_HOME or PI_CODING_AGENT_DIR therefore reached
the project's turns and terminals but not the composer's / menu, the
Skills page, `bb project commands` or `bb skill list`. The project
command workspace now carries its project id, plugin host calls take an
explicit projectId (null for calls a plugin makes itself), and the
native-roots cache is keyed by project.

Fixes #3925

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The usage and health check read ~/.claude/.credentials.json, ~/.claude.json
and the "Claude Code-credentials" Keychain item no matter where
CLAUDE_CONFIG_DIR pointed, so a signed-in profile reported "expired"
whenever the default profile held a stale token. With CLAUDE_CONFIG_DIR
set, Claude Code stores its login under "Claude Code-credentials-<first 8
hex of sha256(CLAUDE_CONFIG_DIR)>", <dir>/.credentials.json and
<dir>/.claude.json; the check now reads exactly those.

The Claude config directory is resolved once, by the SDK's
experimental_resolveClaudeConfigDir (previously private to
experimental_resolveClaudePluginRoots). Session forks and skill
filtering used two other copies with different rules (no trim, no ~,
relative to cwd; skill filtering ignored the session's env); both are
deleted. The credential test's execFile mock now uses Node's callback
signature, so its Keychain cases exercise the Keychain path.

Fixes #3607

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…lugin

Host workers share process.env across overlapping calls, so a project-scoped
native-root resolve could read another project's CLAUDE_CONFIG_DIR or
CODEX_HOME. Host calls now carry their exact environment as
context.experimental_env, and the Claude, Codex, Pi and ACP resolvers plus
Codex helper inference read it.

Provider-path lookups no longer fail global skill install, status or the
server-move check when one plugin is missing or broken; that plugin's paths
are left out and logged. Install wakes a suspended machine before asking,
and each flow shares one deadline across the lookup and the daemon command.
A CLAUDE_CONFIG_DIR or CODEX_HOME relative to each session's cwd contributes
no machine-wide path. Absolute-path checks move into the wire schemas, Pi
reuses one stored-path resolver, and stale Claude bridge imports are removed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymichael
ymichael force-pushed the bb/swing-2b-provider-config-folders-thr_s3wyu7n866 branch from f8ec96e to 01792e6 Compare October 28, 2026 22:11
@ymichael

Copy link
Copy Markdown
Collaborator Author

Closing in favour of a smaller fix inside the Claude Code plugin only (no protocol bump, no SDK changes). The provider-paths plumbing and project-env listing (#3925) are out of scope.

AGENT GENERATED

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant