test(ensemble-code-review): extract diff recipe to bin/pai-build-diff + bats + CI#15
Merged
Merged
Conversation
… + bats + CI
把 3 輪 self-dogfood 硬化的 diff 模式 inline recipe 抽成 version-pinned
shipped script,改成「單一真相源 + 自動化測試」取代人工 re-audit。
新增:
- bin/pai-build-diff — diff 模式建構器(5 模式 + 退出碼契約 0/3/1)。
封裝 ref/N 驗證、untracked symlink/FIFO/換行檔名安全、empty-tree base、
git/gh exit-code 檢查。SKILL.md 改成呼叫它(${CLAUDE_PLUGIN_ROOT}/bin/...)。
- test/pai-build-diff.bats — 25 個 regression(含 3 輪抓到的全部 bug)。
- test/run.sh + test/README.md — 本地一鍵 shellcheck + bats。
- .github/workflows/test.yml — CI 每次 push/PR 自動跑。
修正(extraction dogfood 抓到):
- 未知 mode 訊息 $MODE 緊貼全形( 被 set -u 誤判 unbound variable
→ 改 ${MODE}。已加 regression。
bump 2.13.2 → 2.14.0(plugin.json + marketplace.json)。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
摘要
把
ensemble-code-reviewdiff 模式那段「經過 3 輪 self-dogfood 硬化」的 inline bash recipe 抽成 version-pinned shipped script + 自動化測試,從「每次改都人工 re-audit」轉成「CI 自動守住」。對應使用者需求 task 1(轉自動化測試,複利 > 人工審)。改了什麼
bin/pai-build-diff--diff/--base/--since/--commits/--pr;退出碼契約 0=有 diff/3=無變更(良性)/1=錯誤。封裝全部硬化:ref/N 驗證(防 injection + dashed-ref)、untracked symlink no-follow / FIFO no-hang / 換行檔名 C-quote、--commits N≥TOT用 empty-tree base、git/gh exit-code 檢查。test/pai-build-diff.batstest/run.sh+test/README.md.github/workflows/test.ymlSKILL.md的 inline recipe(~38 行)→ 改成呼叫 script(~14 行)+ 一段「要改邏輯就改 script + 測試,別 inline 重寫」的註記。單一真相源。extraction 過程 dogfood 抓到的 bug
抽 script 時順手 dogfood,抓到一個真 bug:未知 mode 的錯誤訊息
未知 MODE: $MODE(限...——$MODE緊貼全形((UTF-8 三位元組),bash 把首位元組吞進變數名 →set -u誤報unbound variable。改${MODE}明確界定,並加 regression 測試(case 23)。設計取捨
(MODE, REF/N) → stdout,bats 直接run; assert_output捕捉。skill 仍擁有自己的DIFF_FILE(async reviewer agents 讀的那個 + Phase 4.5 cleanup 不受影響)—— 兩個不同檔、不同 lifecycle,所以 script 內用trap EXIT清理是安全的(同步、無 async reader)。-C <dir>flag:讓 bats 指向 fixture repo 而不需 cd;skill 不帶則用 cwd。驗證
新 recipe 也用 fixture 端到端模擬過:
--diff無 ARG→rc=0、--base帶 ARG→rc=0、壞 ref→rc=1 停、乾淨樹→rc=3 停。版本
2.13.2→2.14.0(plugin.json + marketplace.json 同步)。CHANGELOG 已補[2.14.0]。Scope note
這是使用者要求的兩件事中的 task 1。task 2(dogfood 另外三個 skill + 共用 harness)將另開 PR。