ClaudeMods
☰
ZH-TW
● 0 人在線上 · 瀏覽 0 次
贊助提交作品
GitHub 儲存庫 · 發布者 tomasz-tomczyk

crit-tui

Claude Code 裡的早期 crit:在面板中評論對話、差異或檔案,把審查送給 Claude,並在線程中閱讀 Claude 的回覆。

tomasz-tomczyk@tomasz-tomczyk

tomasz-tomczyk/crit/tree/main/integrations/claude-code-tui

已翻譯

關於這個 mod

crit-tui

在 Claude Code 裡運作的審查迴圈,以 mod 形式提供。你可以在面板中評論對話內容、工作樹差異或檔案,一次把審查送給 Claude。Claude 會透過工具在線程中逐條回覆。

早期版本。

安裝

需要 Claude Code 2.1.287 以上版本(mods),而且 crit CLI 必須在 PATH 上。

/plugin marketplace add tomasz-tomczyk/crit
/plugin install crit-tui@crit

它和同一個市集中的主要 crit 外掛並列;兩個可以同時使用。想從 checkout 試用時,執行:

claude --plugin-dir integrations/claude-code-tui

使用方式

  • /crit-tui 開啟面板(沿用上次使用的來源,第一次開啟時顯示對話)
  • /crit-tui chat、/crit-tui diff、/crit-tui file <path> 選擇來源
  • /crit-tui send 送出審查,/crit-tui close 關閉面板

面板是一個 Client 區域:會接收原始按鍵與滑鼠事件。點一下就能把按鍵交給它(按 Esc 會把按鍵交還給提示列)。

| 輸入 | 功能 | | --- | --- | | 點一下某列 | 將游標移到該列 | | 拖曳 | 選取列 | | 點一下線程 | 為 r / x 選取線程 | | j k、↑ ↓、滾輪 | 移動 | | shift+↑ ↓,或按 v 後移動 | 選取列 | | 空白鍵 / pagedown,ctrl+u / pageup | 翻頁 | | g G、home end | 頂端、底端 | | n p、→ ← | 下一則、上一則訊息或檔案 | | l、tab | 下一個線程 | | c、enter | 在該列或選取範圍留言 | | r | 回覆選取的線程,或游標所在列的線程 | | x | 解決它 | | s | 將草稿與回覆送給 Claude | | a | 請 Claude 審查差異並留下評論 | | 1 2 3 | 對話、差異、檔案 | | h | 顯示或隱藏已解決的線程 | | f | 重新載入來源 |

輸入評論時:enter 儲存,shift+enter 加入換行,ctrl+u 清除。要取消時,在空白輸入框按 enter 或 backspace,或點一下 cancel。ctrl+c 和 Esc 不會傳到面板:Claude Code 會接手處理。

面板關閉時,提示列上方的橫列會顯示 Claude 的草稿與新回覆,並提供 send 和 open 按鈕。狀態列會顯示相同的數量。轉錄中,帶有評論的回覆下方會多一列,顯示評論數量。

Claude 會取得的內容

三個工具:

  • mcp__crit-tui__reply { id, body, resolve? }:回答評論
  • mcp__crit-tui__comment { file, line, end_line?, body }:在程式碼上留言
  • mcp__crit-tui__threads { include_resolved? }:列出未解決的線程

send 會用一則提示送出每個新評論(位置、引用列、內容、id)與每個新回覆,並要求 Claude 用 reply 回答每一項。

評論儲存位置

所有內容都會透過 CLI 寫入 crit,所以 crit 瀏覽器 UI 和 crit comments 看到的是同一份審查。

  • 差異和檔案評論 寫入儲存庫的審查檔,使用 crit comment --json。部分選取會帶有 quote 和 quote_offset,和網頁 UI 的文字選取一樣(舊版 crit 會忽略這兩個欄位)。
  • 聊天評論 寫入名為 claude-chat-<session id> 的 crit 計畫。第一次聊天評論時,mod 會用 crit plan --name <slug> --no-wait 儲存對話(每列一筆),再用 crit comment --plan <slug> 留言。每輪之後都會再次儲存;只有文字改變時,crit 才會新增版本。沒有聊天評論的工作階段不會建立任何內容。需要支援 crit plan --no-wait 的 crit;使用舊版 crit 時,聊天評論會留在工作階段裡。
  • Claude 的回覆 使用 --author Claude 寫入。
  • 沒有 crit CLI(設定 critBin)時,所有評論都留在工作階段裡。

面板如何組成

  • hooks/register.tsx 管理資料(文件、線程、crit 同步),並把面板畫成一個 <Client module="./client.tsx">。
  • hooks/client.tsx 管理游標、選取、捲動和評論框,透過 ui.message 把每個變更(comment、reply、resolve、send 等)送到 hooks 模組。
  • Client 的 props 上限約 100k 字元,所以會取得游標附近的一段列,靠近邊緣時再要求新的視窗。
  • Client 繪製時,引擎會忽略 setState,因此 Client 把狀態放在模組變數中,只在按鍵與滑鼠處理常式中呼叫 setState。

開發

claude plugin validate integrations/claude-code-tui
claude plugin test integrations/claude-code-tui

這個早期版本的限制

  • crit 路徑以儲存庫根目錄為相對基準。請從儲存庫根目錄啟動 Claude Code。
  • 被移除的(-)差異列會錨定在新側行號;crit 在 crit comment --json 中沒有舊側錨點。
  • crit comment --plan 會讓 anchor 留白(crit 的 bug),所以對話前面的內容變動時,聊天評論不會跟著文字移動。
  • 要重新開啟已解決的 crit 線程,必須使用 crit 瀏覽器 UI。
  • 差異內容是 git diff HEAD,再加上最多 20 個未追蹤檔案。

安裝

請先查看作者 README,確認 marketplace 與外掛名稱;指令可能隨儲存庫結構而變動。

claude plugin marketplace add tomasz-tomczyk/crit
claude plugin install crit-tui
原文 / README

crit-tui

A crit review loop inside Claude Code, as a mod. Comment on lines of the conversation, the working-tree diff, or a file in a pane. Send the review to Claude in one go. Claude answers each comment in its thread through a tool.

Early version.

Install

Needs Claude Code 2.1.287 or later (mods) and the crit CLI on your PATH.

/plugin marketplace add tomasz-tomczyk/crit
/plugin install crit-tui@crit

It sits next to the main crit plugin from the same marketplace; you can have both. To try it from a checkout instead:

claude --plugin-dir integrations/claude-code-tui

Use

  • /crit-tui opens the pane (last source used, the conversation at first)
  • /crit-tui chat, /crit-tui diff, /crit-tui file <path> pick the source
  • /crit-tui send sends the review, /crit-tui close closes the pane

The pane is one Client region: it gets raw keys and mouse events. Click it once to give it the keys (Esc gives them back to the prompt).

| input | does | | --- | --- | | click a line | move the cursor there | | drag | select rows | | click a thread | pick it for r / x | | j k, ↑ ↓, wheel | move | | shift+↑ ↓, or v then move | select rows | | space / pagedown, ctrl+u / pageup | page | | g G, home end | top, bottom | | n p, → ← | next, previous message or file | | l, tab | next thread | | c, enter | comment on the line or selection | | r | reply to the picked thread, or the one on this line | | x | resolve it | | s | send drafts and replies to Claude | | a | ask Claude to review the diff and leave comments | | 1 2 3 | conversation, diff, file | | h | show or hide resolved threads | | f | reload the source |

While typing a comment: enter saves, shift+enter adds a line, ctrl+u clears. To cancel: enter or backspace on an empty box, or click cancel. ctrl+c and Esc never reach the pane: Claude Code takes them.

While the pane is closed, a band above the prompt shows drafts and new replies from Claude, with send and open buttons. The status line shows the same counts. A reply in the transcript that has comments gets a line under it with the count.

What Claude gets

Three tools:

  • mcp__crit-tui__reply { id, body, resolve? }: answer a comment
  • mcp__crit-tui__comment { file, line, end_line?, body }: leave a comment on code
  • mcp__crit-tui__threads { include_resolved? }: list open threads

send submits one prompt with each new comment (where, quoted lines, body, id) and each new reply, and asks Claude to answer every item with reply.

Where comments live

Everything goes to crit through its CLI, so the crit browser UI and crit comments see the same review.

  • Diff and file comments go to the repo's review file with crit comment --json. A partial selection carries quote and quote_offset, as a web UI text selection does (an older crit ignores the two fields).
  • Chat comments go to a crit plan named claude-chat-<session id>. On the first chat comment the mod saves the conversation with crit plan --name <slug> --no-wait (one row per line), then comments with crit comment --plan <slug>. After each turn it saves again; crit adds a version only when the text changed. Sessions with no chat comments create nothing. Needs a crit with crit plan --no-wait; with an older crit, chat comments stay in the session.
  • Claude's replies are written with --author Claude.
  • Without the crit CLI (setting critBin), all comments stay in the session.

How the pane is built

  • hooks/register.tsx owns the data (documents, threads, crit sync) and draws the pane as one <Client module="./client.tsx">.
  • hooks/client.tsx owns the cursor, selection, scrolling and the comment box, and posts each change (comment, reply, resolve, send, ...) to the hooks module through ui.message.
  • A Client's props are capped near 100k characters, so it gets a window of rows around the cursor and asks for a new window near the edges.
  • The engine ignores a setState made while the Client draws, so the Client keeps its state in a module variable and calls setState only from its key and mouse handlers.

Developing

claude plugin validate integrations/claude-code-tui
claude plugin test integrations/claude-code-tui

Limits of this early version

  • crit paths are taken as repo-root relative. Start Claude Code at the repo root.
  • Removed (-) diff lines anchor to the new-side line they sit at; crit has no old-side anchor in crit comment --json.
  • crit comment --plan leaves anchor empty (crit bug), so a chat comment does not follow its text if earlier lines of the conversation change.
  • Reopening a resolved crit thread is left to the crit browser UI.
  • The diff is git diff HEAD plus up to 20 untracked files.

更多類似作品