dsh-github-agents-proxy:讓 DSH Agent 以 GitHub App 身份提交與開 PR

前言

在 DeepSeek Harness(DSH)裏讓 Agent 改代碼、開 Pull Request 時,常見做法是用個人 PAT 或本機 gh 登錄態。提交會掛在你的賬號下,和「自動化助手」在 GitHub 上的身份也不一致。若你希望提交與 PR 明確歸屬於一個 GitHub App bot,同時仍保留人類協作者的 Co-authored-by,就需要把 Installation Token、作者信息與專用提交流程接進 Harness。

@dynastxu/dsh-github-agents-proxy(維護者 Dynastxu,歸類爲聯網工具)做這件事:配置一次 App 憑證後,gh、git 與 PR 相關操作走 App 的 Installation Token,必要時由 Agent 刷新令牌。下文按定位、能力、安裝配置與工具用法說明。

這是什麼

插件全稱 npm 包名 @dynastxu/dsh-github-agents-proxy,當前發佈版本爲 0.1.2,MIT 許可證,倉庫地址 https://github.com/Dynastxu/dsh-github-agents-proxy。簡介爲:GitHub App proxy for DeepSeek Harness agent changes。

一句話:讓 DSH 的 Agent 以已安裝到目標倉庫的 GitHub App 身份工作;令牌緩存與刷新由插件處理,設置頁展示狀態,無需在界面裏單獨填寫 bot 的 name/email。

社區目錄可在 SkillHub 插件頁 查看條目。DSH 生態強調「一切皆插件」;該目錄爲社區站點,與 DeepSeek、幻方無官方從屬關係。

核心功能

依據倉庫 README,已覈實能力如下。

  1. Agent 提交時以 App bot 作爲 author 與 committer,並自動追加你的 Co-authored-by。
  2. Agent 以 App bot 身份創建 PR;同一 head 分支若已有 open PR,則返回已有 PR,不重複創建。
  3. 在 設置 → GitHub App 令牌 填寫 App ID、Installation ID 與私鑰;頁頭可顯示從 GitHub 讀取的 App 名稱與頭像。
  4. 顯示令牌狀態與剩餘時間;過期或即將過期時由 Agent 按需調用刷新工具。
  5. 刷新成功後可爲普通 gh 命令配置令牌(configureGh 默認爲 true);可選在對話中注入 [github-app-token] 狀態(contextInjection 默認爲 true)。
  6. 可選開啓 blockRawGitCommit,拒絕 Agent 直接執行 git commit,引導使用 commit_changes。

身份格式由插件根據 App slug 與 bot 用戶查詢生成,形如:

<app-slug>[bot] <bot-user-id>+<app-slug>[bot]@users.noreply.github.com

身份只注入 Agent 子進程,不修改倉庫或全局 git 配置;外部終端提交不受影響。本地提交的 verified 爲 false,暫不支持簽名。

安裝與啓用

開始前需要:已在目標倉庫安裝的 GitHub App(至少 Contents、Pull requests 讀寫權限)、App ID、Installation ID、私鑰 PEM;運行環境需有 gh 命令。

推薦在 DSH 界面安裝:插件 → 添加插件 → 安裝第三方插件,包名填:

@dynastxu/dsh-github-agents-proxy

確認安裝後重啓 DSH。

也可用 CLI 安裝到當前 profile(將 <profile> 換成實際值,例如 web、desktop):

dsh plugin --profile <profile> add @dynastxu/dsh-github-agents-proxy

安裝後打開 設置 → GitHub App 令牌 填寫憑證,設置頁會自動保存。無 Web 設置頁時,可在 profile 的 cordis.patch.yml 中配置 github-agents-proxy 相關項。

配置要點

設置頁提供全部選項,並實時顯示緩存令牌狀態(已激活、即將過期、已過期等)。私鑰可通過文件路徑、privateKeyEnv(DSH 憑據引用)或在 Desktop 中選擇 PEM 文件;privateKeyPath 與 privateKeyEnv 二選一。

字段 默認值 含義
appId 配置憑證時必填 GitHub App ID
installationId 配置憑證時必填 安裝到目標倉庫後的 Installation ID
privateKeyPath — PEM 私鑰路徑
privateKeyEnv — DSH 憑據中保存私鑰時的引用名
tokenPath <profile 目錄>/github-app-token.json 令牌緩存文件
refreshThresholdSeconds 300 剩餘秒數低於該值時刷新
apiBaseUrl https://api.github.com GitHub API;Enterprise 可帶 api/v3
contextInjection true 是否在對話中注入令牌狀態
configureGh true 刷新後讓普通 gh 使用該令牌
blockRawGitCommit false 是否拒絕 Agent 直接 git commit

私鑰勿提交到倉庫;可放在 checkout 外、加入忽略列表,或存入 $DSH_HOME/.credentials.yaml 後在設置頁引用。私鑰不會出現在令牌文件、工具結果或對話上下文中。

Agent 工具與典型用法

插件向 Agent 暴露以下工具(參數以 README 爲準)。

commit_changes

提交當前改動,author/committer 爲 App bot,並追加 Co-authored-by: <你的名字> <你的郵箱>。必填 message;stage 可選 all(默認)、tracked、staged;另有 allow_empty、amend。默認不 push。

create_pull_request

以 App 身份創建 PR。必填 title;可選 body、base、head、draft、repo。默認使用工作目錄倉庫、當前分支與默認分支。head 須已推送到遠端;工具不提交、不推送。

refresh_ghapp_token

刷新 Installation Token。在 gh 返回 401、狀態爲 missing/expired/即將過期,或需立即換新令牌時使用。令牌仍有效時返回 token_still_valid;force: true 可強制刷新(例如令牌被撤銷)。

check_ghapp_token_status

只讀本地緩存,不訪問 GitHub。返回 valid、expiring、expired、missing、invalid、unconfigured 及有效期、剩餘時間、令牌文件路徑。

使用提示:gh 在刷新後會通過 gh auth login --with-token 使用該令牌;令牌默認寫在 profile 目錄的 github-app-token.json。插件不跑後臺任務,僅在 Agent 調用工具時訪問 GitHub。私鑰、JWT 和令牌不會返回給模型。

適用場景與注意

適合:已在組織或倉庫安裝 GitHub App、希望 Agent 產生的提交與 PR 明確歸屬 bot,同時保留人類 Co-authored-by 的 DSH 用戶;需要與 gh 共用同一 Installation Token 的自動化流程。

注意:

  • 插件以當前 DSH 進程權限運行;安裝第三方包前請自行查看源碼與 MIT 許可證,並評估私鑰與令牌存放方式。
  • blockRawGitCommit 僅檢查命令文本,不是安全邊界;Agent 仍可能通過 --author 或 GIT_AUTHOR_* 繞過身份注入。
  • 遠程 SSH 或容器中 git 是否繼承身份取決於該環境。
  • 包要求 Node ^22.19.0 || >=24.0.0,peer 依賴 @deepseek-ai/cordis ^4.0.1。

結尾

@dynastxu/dsh-github-agents-proxy 把 GitHub App Installation Token、提交作者與專用 commit_changes / create_pull_request 接到 DSH Agent 上,減少 Personal Token 混用帶來的歸屬模糊。憑證在設置頁一次性配置,令牌按需刷新即可配合 gh 與對話內狀態提示使用。

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

小夜