用 Claude Code(Claude Pro/Max)登录作为 DSH 的 anthropic 模型提供方,让 DSH 的 pi-ai 凭据记录与 Claude Code 钥匙串共用同一条轮换中的 OAuth 凭据链。
安装
# npm 包(预构建)
dsh plugin --profile web add @trmquang93/dsh-claude-code-account
# GitHub 源码(首次需按提示配置 allowBuilds 构建授权后重试)
dsh plugin --profile web add github:trmquang93/dsh-claude-code-account
装任何插件都等于在你的机器上跑第三方代码,权限和你本人一样大——能读你的文件、用你的凭据、访问网络,工具审批管不到它。GitHub 来源的插件还会在安装时执行构建脚本——pnpm 默认拦截,所以安装可能停在 ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED 或 ERR_PNPM_IGNORED_BUILDS;dsh 会打印出需要添加的确切键名,把它加进该 profile 的 pnpm-workspace.yaml 的 allowBuilds 下,重跑一次即可装上。放行构建本身就是一次信任判断:请只安装可信来源,并尽量锁定 commit(github:owner/repo#sha)。
README
该插件的 README 只有英文版本。
Use a Claude Code sign-in (Claude Pro/Max subscription) as a DSH model provider.
Claude Code keeps its OAuth grant in the login keychain, one item per
CLAUDE_CONFIG_DIR. DSH's pi-ai adapter keeps its own copy of that grant in the
credential record llm-pi-ai/<provider> and refreshes it when it expires. This
plugin keeps both sides on the same rotating chain, so
- the account keeps powering DSH model requests (through the
anthropicroute) with no second OAuth sign-in, and - the Claude Code CLI login keeps working after DSH refreshes the token, because the rotated grant is written back to the keychain.
It refreshes once when neither side holds a usable access token, and mirrors whichever side already holds the fresher valid grant (so a refresh DSH performed itself is repaired back into the keychain instead of being spent twice).
Install
dsh plugin --profile <name> add @trmquang93/dsh-claude-code-account
The package ships prebuilt JavaScript, so the install runs no build script and
needs no permission. It declares a bundle: dsh appends it to the profile's
dsh.profile.bundles and applies its patch on the next boot. Signing in to
Claude Code first is optional — the plugin reports a missing login instead of
failing the boot.
Prerequisite: the provider route
The route is configuration, not code. DSH's last patch layer — the profile's
own $DSH_HOME/profiles/<profile>/cordis.patch.yml — must list anthropic
under llm-pi-ai.providers. Keep the route key equal to the plugin's
provider:
- id: llm-pi-ai
name: '@deepseek-ai/dsh-llm-pi-ai'
config:
providers:
opencode-go:
apiKeyEnv: OPENCODE_GO_API_KEY
openrouter:
apiKeyEnv: OPENROUTER_API_KEY
anthropic:
displayName: Claude Code (personal)
The plugin ships its own Claude model list (models.json) and serves it on the
route, so new models appear without waiting for the app's bundled pi-ai. A
models list set on the route in the profile wins over it.
Set the route's displayName to the account it is wired to; the plugin writes
the credential and never the route.
Configuration
- id: claude-code-account
name: '@trmquang93/dsh-claude-code-account'
config:
account: default # default/work → ~/.claude, personal → ~/.claude-personal
provider: anthropic # pi-ai route whose record this plugin owns
accounts: # optional: extra name → config-dir map
personal: .claude-personal
work: .claude
configDir: /abs/dir # optional: an absolute CLAUDE_CONFIG_DIR instead
refreshLeadMs: 600000 # refresh when the access token is this close
intervalMs: 300000 # how often the timer re-checks
writeBack: true # write rotated tokens back into the keychain
claudeCommand: claude # used for `claude auth status --json` metadata
The account name selects the Claude Code config directory, and the directory selects the keychain item:
| account | config dir | keychain service |
|---|---|---|
default, work |
~/.claude |
Claude Code-credentials |
personal |
~/.claude-personal |
Claude Code-credentials-<sha256(absolute dir)[:8]> |
any configDir |
that directory | Claude Code-credentials, or the suffix above for a non-default directory |
That is exactly how Claude Code namespaces several logins in one keychain, so a
second login at ~/.claude-personal resolves to its own suffixed item
(sha256("<home>/.claude-personal")[:8]).
Use
- Sign in to Claude Code for the chosen account:
claude auth login, orCLAUDE_CONFIG_DIR=~/.claude-personal claude auth loginfor a second one. - Make sure the
anthropicroute is in the profile patch (above). DSH applies patch changes live with HMR. - Pick a Claude model in the model selector. The plugin has already mirrored
the account's grant into
llm-pi-ai/anthropic. - Ask
claude_code_account(tool) or read the startup log line for the account email, plan and access-token expiry.
The tool returns no secret values:
{
"account": "personal",
"configDir": "/Users/quangtran/.claude-personal",
"keychainService": "Claude Code-credentials-6195afbc",
"provider": "anthropic",
"providerRegistered": true,
"email": "trmquang@icloud.com",
"subscriptionType": "pro",
"accessExpiresAt": "2026-11-10T19:10:43.114Z",
"accessExpiresInMinutes": 469,
"source": "keychain",
"recordConfigured": true
}
action: "sync" forces a reconcile pass (refreshing when needed).
What can go wrong
- The plugin owns
llm-pi-ai/<provider>. Signing out or signing in to the same route from the Models page writes the same record; the next timer pass restores the Claude Code account's grant. Use another route key (and anotherproviderin this plugin's config) if the two must coexist. - A keychain write can be refused when the login keychain's access control
does not allow
securityto update the item; the sync then still updates DSH but the CLI keeps its old chain. The record reports the failure vialastError; re-enable the CLI by runningclaude auth loginfor the account. - An account that was never signed in fails with an actionable
run "claude auth login"message instead of silently leaving DSH keyless. - macOS only for the keychain read. Other platforms fall back to
<configDir>/.credentials.json, which is where Claude Code stores its grant on Linux. Nothing else is platform-specific. - Claude Code must keep working with the account. The plugin writes rotated
tokens back, but if the account's refresh token has expired, both sides need a
fresh
claude auth login.
Release
npm test
npm publish # publishConfig sets access:public and the public registry
Bump version first; files limits the tarball to the entry points, the patch,
the README and the LICENSE.
Tests
node --test test/ covers the decision logic (which side wins, when a network
refresh happens, write-back), the keychain-service naming, document merging, and
the record shape, all with injected fakes.
Verify a mounted account
claude_code_account(tool) or the startup log line reports the account email, plan and access-token expiry;action: "sync"forces a reconcile.- The composer model menu (or
/model) lists a Claude Code (personal) group once theanthropicroute is configured. - Send a short prompt with a Claude model selected — the answer comes from the subscription, not an API key.
CLAUDE_CONFIG_DIR=~/.claude-personal claude auth statusand a one-shotclaude -p "ok"must still work: that proves the write-back preserved the CLI login.
链接
同类插件
Ebony-Vinyl/dsh-our-free-model★ 77208
为 dsh 接入免费模型车道(含 DeepSeek V4.1 Flash、Kimi K3 等),无需登录、注册或填写 API Key,并提供本地 OpenAI 兼容网关、降级路由与用量看板。
dingminhua/dsh-connect-workbuddy★ 1681
将本机登录的 WorkBuddy 模型(国内版与国际版)接入 DSH,每次刷新按上游目录读取每个模型的积分倍率,支持逐模型图片输入开关、带自动换号的账号池、手动每日签到,以及卡片与输入框里的只读积分胶囊读数。
Alice-Marx/dsh-model-router★ 966
为 DeepSeek Harness 规划有依赖的工作包,将其分配给已配置的模型 API 或支持的厂商 CLI,并提供费用预览。
V1ki/dsh-plugin-subscriptions★ 618
把 ChatGPT(Codex)、Claude、Grok 订阅当作 DeepSeek Harness 的 LLM 提供方:设置页登录、模型目录、用量展示,以及 image_generate、video_generate 与 x_search 工具。
XDTrees/dsh-workbuddy-xdpool★ 541
把本机 WorkBuddy 桌面 App 登录过的所有账号自动并入 DSH 模型池:多账号轮换自动容错、实时积分,模型目录按模型标注积分倍率与限时免费 / 夜间折扣。
XDTrees/dsh-xdpool★ 541
把本机 WorkBuddy 桌面 App 登录过的所有账号自动并入 DSH 模型池:多账号轮换自动容错、429 冷却、实时积分,模型目录按模型标注积分倍率与限时免费 / 夜间折扣,扫码登录 13 家厂商,聚合免费额度渠道。账号重启不丢。
社区评论
评论公开保存在 GitHub Discussions。加载评论会连接 GitHub 和 Giscus;发表内容需要 GitHub 账号。