Skip to content

feat: Dashboard 配置页极简化重构与双通道自动发布工作流 - #2

Merged
deepcoldy merged 4 commits into
mainfrom
feat/dashboard-minimal-dual-publish
Nov 28, 2026
Merged

deepcoldy merged 4 commits into
mainfrom
feat/dashboard-minimal-dual-publish

Conversation

@deepcoldy

Copy link
Copy Markdown
Contributor

概述

基于 origin/main 完成两项升级(保持后端 config.json 100% 向后兼容与密钥 write-only 安全边界不变):

  1. Dashboard #/plugins/github 配置页极简化重构:重构为「开箱即用、2 步配完、高级项全折叠」体验;
  2. 双通道自动发布工作流(.github/workflows/publish.yml):打 v* tag 自动并行触发 GitHub Release(.tgz + .tgz.sha512) 与 npm OIDC Trusted Publishing(含 npm@^11.5.1 升级修复),并同步更新 README.md。

一、Dashboard 配置页极简化重构

改造前后对比

模块 改造前 改造后
顶部总览 状态标签与独立限流卡片分散展示 顶部统一展示 4 项核心指标(运行状态:dormant 休眠等待首条规则 vs active 监控中、已启用规则数、最近一次同步时间、API 额度余量)与「立即同步一次」主按钮
鉴权配置 平铺展示 Auth Mode、API Base URL、PAT、gh Hostname、App ID、Installation ID、PEM 私钥等 7 个表单项 页面打开自动探测本机 gh auth token(不向前端暴露任何 token),已登录直接显示绿色状态卡「已自动识别本机 GitHub 账号 @<login>(来自 gh),免配置可直接使用」并默认选用 gh_cli;PAT / GitHub App / 自定义 GHES apiBaseUrl 收纳至默认折叠的「切换其他鉴权方式」,保留一键「测试连接」与已配置摘要
仓库监控规则 14+ 个表单字段平铺,且下拉/表格中直接暴露原始 cli_... 新增规则默认应用「PR 自动拉群评审」预设,主界面仅突出 2 项必填:① 仓库名(owner/repo,实时格式校验 + deepcoldy/botmux 占位提示);② Bot 角色选择(中文 Bot 名称,建群 Bot 自动预选首个可用 Bot,评审 Bot 多选并自动联动首个评审 Bot 为首审触发 Bot、可下拉改选)。全部低频项默认折叠至「高级过滤与模板设置」,编辑已自定义规则时自动展示「已自定义 N 项」徽标
全局高级设置 代理、Webhook、端口、轮询间隔全部与鉴权混排平铺,缺少每小时拉群上限配置 统一收纳至底部默认折叠的「高级设置(代理 / Webhook / 轮询与限流)」,含 maxGroupCreatesPerRepoPerHour;未展开时以单行摘要展示当前状态(如 轮询 60s · Webhook 未开启 · 无代理)
运行记录与诊断 手动补建、已拉群记录表、事件日志全部默认展开 收纳至底部默认折叠的 <details> 诊断区,保留全部功能与 PR 编号严格校验

安全与兼容性

  • 后端 config.json Schema、Control Server、Watcher 与 CLI 零破坏性变更;
  • PAT、GitHub App 私钥、代理密码、Webhook Secret 严格保持 write-only(仅服务端 0600 保存,前端永不回显且每次保存/刷新后清空输入框)。

二、双通道自动发布工作流(.github/workflows/publish.yml)

  • 保持 push: tags: ['v*'] 触发,两个 job 均独立校验 tag 在 origin/main 祖先链上且 vX.Y.Z 与 package.json 的 version 一致;
  • 拆分为两个 无 needs: 依赖、并行互不阻塞 的 job:
    • release-github(permissions: contents: write):运行 npm ci --no-audit --no-fund、npm test、npm pack(校验包内包含 package/package.json 与 package/dist/),用 Node crypto 生成单行标准 SRI 格式 <tarball>.sha512(sha512-<base64>),并通过 gh release create(自动生成 release notes)或已存在时 gh release upload --clobber 幂等上传 .tgz 与 .tgz.sha512;
    • publish-npm(permissions: contents: read, id-token: write):补上 npm install -g npm@^11.5.1 修复 Node 22 自带 npm 10.x 不支持 OIDC Trusted Publishing 的问题,运行 npm ci --no-audit --no-fund、npm test 与 npm publish --access public --provenance;npm 侧未完成首次绑定时也不阻塞 GitHub Release 产出,后续可单独重跑 publish-npm。
  • 同步更新 README.md(中英文):补充 GitHub Release 安装与 SRI 校验说明、简化后的 Dashboard 2 步配置指引。

验证结果

  • npm test(typecheck + build + validate + test:unit + test:integration)全绿:
    • 单元测试:30/30 通过(新增 test/unit/dashboard-helpers.test.ts 覆盖 Bot 友好名称排序与去重、2 步预设生成合法 RepoRule、自定义高级项计数与回填、鉴权与全局摘要计算);
    • 集成测试:40/40 通过(扩展 test/integration/dashboard-settings-cli.test.ts 覆盖极简渲染、默认 gh-cli 绿色状态卡、2 步建规落盘、编辑已有自定义规则回填、密钥 write-only 不回显;扩展 test/integration/packaging.test.ts 覆盖 publish.yml 双通道结构与 npm pack 产物含 package/package.json + package/dist/ + SRI sha512-<base64> 校验)。
  • 本地模拟执行 publish.yml 的打包与 SRI 生成脚本验证通过,产出的 botmux-ai-plugin-github-0.1.0.tgz(含完整 package/dist/)与 .tgz.sha512 与 npm pack 自身 integrity 哈希逐字节一致。
  • YAML 语法校验(yaml.safe_load)通过。

🤖 Generated with Claude Code

deepcoldy and others added 2 commits November 28, 2026 22:21
… workflow

- Refactor Dashboard #/plugins/github into an out-of-the-box, 2-step flow while
  keeping backend config.json 100% backward compatible and write-only secrets intact:
  - Auto-detect local gh auth token on load (never exposing tokens to frontend),
    displaying a green status card and defaulting to gh_cli, with PAT / GitHub App /
    GHES apiBaseUrl collapsed under "切换其他鉴权方式" and one-click "测试连接".
  - Apply "PR 自动拉群评审" preset to new repository rules with only 2 required
    fields (owner/repo slug with validation and friendly Chinese Bot role selection
    with auto-preselected creator bot & synced first-reviewer kickoff bot), collapsing
    all low-frequency options into "高级过滤与模板设置" with a customized-count badge.
  - Collapse global proxy, loopback webhook, port, poll interval, and hourly cap
    settings into a bottom panel with a single-line summary, and clarify the top
    overview (dormant vs active mode, enabled rules, latest sync, API quota, Sync Now).
- Upgrade .github/workflows/publish.yml into two independent parallel channels on
  v* tags (after origin/main ancestor & package.json version verification):
  - release-github: npm ci, npm test, npm pack (.tgz with package/dist/), Node crypto
    SRI .tgz.sha512, and idempotent gh release create/upload with generated notes.
  - publish-npm: upgrades npm@^11.5.1 for OIDC Trusted Publishing before running
    npm ci, npm test, and npm publish --access public --provenance.
- Update README.md and add unit & integration tests covering minimalist Dashboard
  rendering, gh-cli detection, 2-step rule creation, custom advanced backfill,
  write-only secrets, publish.yml structure, and tarball dist/ + SRI verification.

Co-Authored-By: Claude Code <[email protected]>
…ion tests

- Fix [P2 #8] webhook admission retry flake on slower CI runners by waiting
  deterministically for watcher queue drain (active=0, pending=0) and
  deliveryDedup.inFlightSize()=0 after unblock() instead of a fixed 80ms sleep.
- Replace similar short setTimeout waits in dashboard-settings-cli.test.ts and
  review-round3-regressions.test.ts with bounded waitFor() checks.

Co-Authored-By: Claude Code <[email protected]>
@deepcoldy

Copy link
Copy Markdown
Contributor Author

独立复审结论:暂不可合

复审对象:a87b033e02bef43e98be3f5c45b35e2398fc9077。

未发现密钥回显/日志泄漏,双通道发布工作流本体也符合约定;但仍有 1 个 P1、4 个 P2 需要处理。

P1 — SRI 校验失败不会阻止后续安装

README.md:59-61 与 README.md:228-230 都是:

test "${ACTUAL}" = "${EXPECTED}"
botmux plugin install "./botmux-ai-plugin-github-${VERSION}.tgz"

普通 bash/zsh 未启用 set -e 时,test 返回 1 后仍会继续执行安装。因此文档所称的“校验后再安装”实际上没有形成安全门。已在 bash 与 zsh 下复现。

建议将安装命令用 && 与校验连接,或在代码块开头明确启用 set -euo pipefail,并同步修正中英文示例。

P2 — 未展开高级区保存也会改变既有规则

  1. 建群 Bot 会被无条件从既有评审成员中删除。
    src/dashboard/helpers.ts:254-257 在 draftToRule() 中过滤 id !== creator,但服务端 schema 允许 creatorBotAppId 同时出现在 memberBotAppIds 中。实测一条 schema-valid 规则经 ruleToDraft() → draftToRule() 后,该成员直接从保存结果中消失。即使用户只编辑仓库名、完全未展开高级区,也会改写既有配置。交互式的 changeCreatorBot() 已处理角色冲突,纯保存路径不应再次无条件删除既有成员。

  2. 合法的含逗号分支/标签会被拆成多个值。
    src/dashboard/helpers.ts:223-230 用 join(', ') 转为文本,src/dashboard/helpers.ts:71-80,264-270 再按逗号/换行拆分。实测 baseBranches: ['release,2026'] 保存后变为 ['release', '2026'],labelAllowlist: ['priority,high'] 变为 ['priority', 'high']。这类字符串未被 schema 禁止,且 GitHub 标签/分支名可以包含逗号。该 CSV 表示沿用了旧实现,但与本 PR 的“既有配置无损保存”验收目标直接冲突;建议使用数组型 draft/带转义的编辑表示,至少补充 collapsed-save 的无损往返测试。

P2 — 分区保存会静默清空另一分区的未保存输入

src/dashboard/index.ts:452-487,636-655,667-752 将原来统一的鉴权/全局保存拆成两个 handler,但每次 persistPatch() 后都会 refresh() 并重新 hydrate 全部字段、清空所有密钥输入。

复现场景:填写新 PAT 但尚未保存,再修改服务端口并点击“保存高级设置”;服务端只保存全局 patch,随后 PAT 输入被清空且不会落盘。反向操作也会丢失尚未保存的代理、Webhook、端口、轮询和限流输入。建议按分区 hydrate,或显式保留/提示另一分区的 dirty draft。

P2 — 过期的自动鉴权探测会覆盖新保存的鉴权状态

src/dashboard/index.ts:489-539,667-706 没有请求 generation 或配置签名检查;静默探测期间“保存鉴权设置”仍可用。若旧 gh-cli 探测较慢,用户先完成 PAT/App 保存,旧响应随后仍会 setAuthTestResult()。src/dashboard/index.ts:990-997 会因此把旧 gh 错误显示到新 PAT/App 卡片上,或把旧身份显示在新鉴权方式旁。

建议保存鉴权时使未完成探测失效,并只接收 generation 与配置签名均匹配的响应。

已通过的检查

  • npm test:typecheck、build、validate 全过;unit 30/30、integration 40/40。
  • 实际执行打包与 SRI 生成:.tgz 含 package/package.json 和完整 package/dist/,.sha512 为单行 sha512-<base64>,格式检查通过。
  • publish.yml:两 job 无 needs: 依赖;tag 祖先链与版本一致性校验、Release --clobber、npm contents: read / id-token: write、npm@^11.5.1 和 npm publish --access public --provenance 均符合约定。
  • gh token、PAT、App 私钥、Webhook Secret、代理密码的回读路径均只返回 has* 状态;密钥输入保持空白,未发现原始密钥写入 Dashboard HTML/API 或日志的路径。
  • 变异验证:放宽仓库名校验会使单测变红;但删除 memberBotAppIds 的 creator 过滤、删除 Release --clobber 后,相关现有测试仍通过。

非阻断测试建议

test/integration/packaging.test.ts:154-198 目前主要是字符串存在性检查,建议至少补上 --clobber 的精确断言,并增加版本不匹配、tag 不在 main、SRI 文件内容/行数等失败路径;上述两个兼容性问题也应加入端到端 collapsed-save 回归测试。

deepcoldy and others added 2 commits November 29, 2026 02:29
…rd state safety)

- [P1] Fail-closed chain README.md EN & ZH GitHub Release download, non-empty
  SRI sha512 verification, and `botmux plugin install` using `&&` so a checksum
  mismatch always blocks installation even in interactive shells without `set -e`.
- [P2-1] Preserve `creatorBotAppId` inside `memberBotAppIds` during `draftToRule()`
  so editing/saving existing valid rules never drops a creator bot that also acts
  as a member, while keeping `kickoffBotAppId !== creatorBotAppId` safe in
  `toggleReviewerBot()` and `changeCreatorBot()`.
- [P2-2] Switch branch/author/label list fields in Dashboard rule drafts from
  comma-split to newline-delimited (`splitLines` + `<textarea>`) so valid names
  containing commas (e.g. `release,2026`, `priority,high`) round-trip losslessly
  both collapsed and expanded.
- [P2-3] Scope `hydrateFromEnvelope` / `refresh` by section (`auth` / `global` /
  `repos` / `status` / `all`) with per-section dirty tracking so saving one
  section never wipes unsaved drafts or secret inputs in another section, while
  still clearing write-only secret inputs for the saved section.
- [P2-4] Guard in-flight auth probes with a monotonic generation counter plus
  canonical auth config signature (`getAuthConfigSignature`) and bump generation
  on auth save so late `gh_cli` probe responses never overwrite newly saved auth.
- Add unit & integration regression tests for P2-1/P2-2 collapsed-save lossless
  round-trip, P2-3 cross-section draft preservation, P2-4 stale probe rejection,
  and strengthened `publish.yml` (`--clobber`, `--verify-tag`, `gh release view`,
  `fetch-depth: 0`, `permissions: {}`) and README SRI gating assertions.

Co-Authored-By: Claude Code <[email protected]>
Replace the fixed 150ms setTimeout in review-round2-regressions.test.ts [P1-1]
with an explicit commit hook triggered only after Step 2 asserts the fail-closed
safety settle window, preventing slow CI runners from firing the timer early.

Co-Authored-By: Claude Code <[email protected]>
@deepcoldy

Copy link
Copy Markdown
Contributor Author

增量复审结论:可合

复审范围严格限定为 a87b033e02..0a8c313d89 及受影响调用点;最终 head 为 0a8c313d89010ad4de52ae7fc550cdee94729810。上一轮 1 个 P1 与 4 个 P2 均已有效修复,本范围未发现新增 P1/P2。

  1. P1 README SRI 安装门:通过。 中英文示例均把下载、非空检查、SRI 相等检查与 botmux plugin install 串入同一 && 链,校验失败不会再执行安装。
  2. P2-1 creator 成员保留:通过。 draftToRule() 不再无条件删除 creator;同 creator 的 no-op 交互也保留成员。实际 schema-valid 往返中,['cli_shared', 'cli_reviewer'] 原样保留,角色切换路径仍会避免 creator/kickoff 冲突。
  3. P2-2 逗号名称无损:通过。 分支、作者、标签均改为逐行 textarea,splitLines() 只按换行分隔。实测 release,2026、priority,high、area: ui, ux 等值完整往返,相关自定义计数也使用同一逻辑。
  4. P2-3 跨分区草稿保留:通过。 auth/global 按分区 hydrate,并追踪 dirty 状态;repos/status 刷新也不会清空草稿。全局保存后未保存 PAT 仍在,鉴权保存后未保存代理 URL/密码仍在,本分区已成功保存的密钥输入仍按 write-only 约定清空。
  5. P2-4 过期探测防护:通过。 探测同时使用 generation 与配置签名;鉴权保存开始即使旧请求失效,响应前再次检查两者。延迟 gh 响应在 PAT 保存后到达的端到端场景已覆盖,旧身份不会覆盖新状态。

本地验证

  • 最终恢复后重新执行完整 npm test:typecheck、build、validate 全过;unit 31/31、integration 40/40。
  • 五组回退式变异均成功咬红:破坏 README && 安装门、恢复 creator 过滤、恢复逗号拆分、强制跨分区 hydrate、绕过 stale-response 检查;恢复源码后对应测试重新全绿,工作树无 diff。
  • 增量中的确定性测试调整只改变测试同步方式,未改变生产调用语义;发布工作流新增断言也已覆盖此前建议的 --clobber 等契约。

未执行 merge、打 tag、发版或修改线上插件。

@deepcoldy
deepcoldy merged commit 92dd002 into main Nov 28, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant