refactor: apply review findings from the ADR-007/008 PRs - #12
Merged
Conversation
Give the compacted-harness-injection group a single owner, UserMessage.IsCompactedHarnessInjection(), and make stats call it instead of repeating the flag list the renderer already enumerates. Cover ComputeStats turn counting with tests that fail when the increment is removed. Rename parseLineWithToolNames to parseLineWithToolCalls to match what it threads. Scan excerpt lines without splitting the whole text and strip ANSI only when an escape byte is present. Drop the unused FirstLine helper and a regexp that matched a plain literal; pin CommandMarker precedence in the turn policy and mixed teammate tag variants in one body. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TcvWErnKnuADJsomnZfwFr
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.
為什麼
對 PR #9、#10、#11 跑了五維度產品碼審查與測試品質審查,四項 Should Fix、五項 Nit 全部核對屬實,這個 PR 一次收掉。輸出行為不變:
cc-session read b11858cf改前改後 md5 相同(98e2173533a375206f0983d5b5618f8a)。改了什麼
Should Fix
UserMessage.IsCompactedHarnessInjection()成為「壓縮而非丟棄的 harness 注入」這組 12 個 flag 的單一定義,ComputeStats改呼叫它,不再與 renderer 各自列一份ComputeStats的 turn 計數補測試:teammate、task-notification、壓縮續接算 turn;interrupted、stop hook、skill 注入不算。Mutation 驗證:拿掉userTurnCount++後TestComputeStats_UserTurnCount轉紅parseLineWithToolNames改名parseLineWithToolCalls,對齊它現在攜帶的toolCallInfo與 skill 連結用途firstMeaningfulLine改逐行掃描不預先Split,StripANSI只在行內有\x1b時執行Nit
FirstLine與其測試hookErrorBoilerplate從 regexp 改strings.ContainsCommandMarker與IsTeammateMessage同時設定的優先序案例驗證
gofmt/go vet/go test ./...全綠;md5 前後一致;mutation 檢查紅後已還原。🤖 Generated with Claude Code
https://claude.ai/code/session_01TcvWErnKnuADJsomnZfwFr