modscode EN

modscode / 図鑑 / review-pane

review-pane

Side pane showing the files changed in this conversation as diffs; mark lines, comment, and send the comments back to Claude

確かめやすいコードターミナル+デスクトップペイントーストBoxButtonText

何をするか

  • 欄・トーストを描く
  • /changes を足す
  • ツールの呼び出しを見張る
  • prompt.submit・session.end・session.start・turn.complete ほか 3 個にフックする

良いところ

  • ネットワークに出ない
  • プロセスを起こさない
  • TypeScript で書かれている
  • デスクトップ専用の分岐がある

作り始めるためのコード

2 種類あります。上のデザインから modscode が書いた雛形と、その Mod 自身のコードのうち描いている部分です。

雛形(register.tsx)

register.tsx
import type { Register } from 'claude-code'

// Drawn like review-pane by Rudra Secure (pane, toast), as modscode read it from the mod's code:
// https://modscode.com/gallery/rudrasecure-review-pane/
// Written by modscode from that reading, not copied from the mod: use it as you like.
// Each value below stands for one the mod works out at run time; put in your own.
export const register: Register = on => {
  // the pane: open it with $.ui.open({ id: 'my-pane', title: "Changes" })
  on('ui.render', { component: 'Pane', requestId: 'my-pane' }, async ($, e) => {
    const { Box, Text, Button } = $.ui.resolve(e)
    const length = '…'
    const label = '…'
    const target = '…'
    const name = '…'
    return (
      <Box flexDirection="column">
        <Box flexDirection="column">
          <Text bold>
            {`${length} file changed`}
            {"  · Claude is working (comments will steer)"}
          </Text>
          <Button plain label={`…${label}`} />
          <Button plain label={`…${label}`} />
          <Button plain label={`…${label}`} />
        </Box>
        <Text dimColor>
          ────────
        </Text>
        <Box flexDirection="row" gap={1} flexWrap="wrap">
          <Button hotkey="s" variant="primary" label={`➤ Send ${length}`} />
          <Button hotkey="x" plain dimColor label="discard all" />
          <Button hotkey="c" plain label={`✎ Comment on ${target}`} />
          <Button hotkey="p" plain dimColor label="◂ file" />
          <Button hotkey="n" plain dimColor label="file ▸" />
          <Button hotkey="r" plain dimColor label="refresh" />
          <Button hotkey="t" plain dimColor label="plain" />
          <Button hotkey="k" plain dimColor label="↑" />
          <Button hotkey="j" plain dimColor label="↓" />
          <Button hotkey="v" plain dimColor label="unmark" />
          <Button hotkey="w" plain dimColor label={`word: ${name}`} />
          <Button hotkey="h" plain dimColor label="def" />
          <Button hotkey="g" plain dimColor label="go" />
          <Button hotkey="f" plain dimColor label="refs" />
        </Box>
        <Text dimColor wrap="truncate">
          click a name for its definition · drag to select · right-click for actions
        </Text>
        <Text dimColor>
          No textual changes (file identical to its original).
        </Text>
        <Text dimColor>
          {`… ${length} more diff rows not shown`}
        </Text>
        <Text dimColor>
          ────────
        </Text>
      </Box>
    )
  })

  on('session.start', async ($, e, next) => {
    const length = '…'
    await $.ui.toast(`review-pane: no comments to send`)
    await $.ui.toast(`Steered ${length} comment(s) into the running turn`)
    return next(e)
  })
}

Mod 自身のコード

Mod のライセンス(MIT)に従って載せています。全文は下にあります。写すときは著作権表示を残してください。

review-pane/hooks/register.tsx 670〜829 行 · ペイン
  on('ui.render', { component: 'Pane', requestId: PANE }, async ($, e) => {
    const elements = $.ui.resolve(e)
    const { Box, Text, Button } = elements
    const Input = 'Input' in elements ? elements.Input : undefined
    const Code = 'Code' in elements ? elements.Code : undefined
    const Markdown = 'Markdown' in elements ? elements.Markdown : undefined
    const Client = 'Client' in elements ? elements.Client : undefined
    const highlight = (await read($, isHighlighted)) && Code !== undefined
    const stored = await read($, lsp)
    // A card kept from an older version of the pane has another shape.
    const card = stored && typeof stored.symbol === 'object' ? stored : null
    const contextMenu = await read($, menu)
    const box = await read($, composer)
    const list = await read($, files)
    const drafts = await read($, comments)
    const root = await read($, cwd)
    const running = await read($, isTurnRunning)
    const width = Math.max(20, e.props.bodyColumns ?? e.viewport?.columns ?? 80)

    if (list.length === 0) {
      return (
        <Box flexDirection="column">
          <Text dimColor>No file changes in this conversation yet.</Text>
          <Text dimColor>Edits Claude makes with Edit/Write show up here.</Text>
        </Box>
      )
    }

    const c = clampCursor(await read($, cursor), list)
    const file = list[c.file]!
    const allRows = rowsOf(file)
    const rows = allRows.slice(0, MAX_ROWS)
    const [lo, hi] = selectedRange(c)
    const isRange = c.anchor !== null
    const fileDrafts = drafts.filter(d => d.path === file.path)
    const gutter = String(Math.max(1, ...rows.map(r => (r.kind === 'hunk' ? 0 : (r.newNo ?? r.oldNo ?? 0))))).length
    const target = describeLines(rows.slice(lo, hi + 1))
    const keySymbol = await cursorSymbol($)

    const fileList: FileListProps = {
      selected: c.file,
      isRunning: running,
      files: list.map((f): FileEntry => {
        const { added, removed } = countChanges(rowsOf(f))
        const shown = relative(f.path, root)
        const cut = shown.lastIndexOf('/') + 1
        return {
          status: f.before === null ? 'A' : f.after === null ? 'D' : 'M',
          dir: shown.slice(0, cut),
          name: shown.slice(cut),
          added,
          removed,
          comments: drafts.filter(d => d.path === f.path).length,
        }
      }),
    }

    const fileButtons = list.map((f, i) => {
      const { added, removed } = countChanges(rowsOf(f))
      const status = f.before === null ? 'A' : f.after === null ? 'D' : 'M'
      const count = drafts.filter(d => d.path === f.path).length
      const label = `${i === c.file ? '▸' : ' '} ${status} ${relative(f.path, root)}  +${added} -${removed}${count ? `  ✎${count}` : ''}`
      return (
        <Button
          key={`file-${i}`}
          plain
          dimColor={i !== c.file}
          label={label.length > width ? `…${label.slice(label.length - width + 1)}` : label}
          onPress={() => selectFile($, i)}
        />
      )
    })

    // ── What sits under a row: its comments, the comment box, a card, a menu.
    const inline = new Map<number, RenderElement[]>()
    const place = (row: number, element: RenderElement) => inline.set(row, [...(inline.get(row) ?? []), element])
    const unplaced: ReviewComment[] = []

    const sendLabel =
      drafts.length === 1 ? '➤ Send comment to Claude' : `➤ Send all ${drafts.length} comments to Claude`
    const editingId = await read($, editing)
    const draftCard = (d: ReviewComment): RenderElement =>
      editingId === d.id && Input ? (
        <Box key={`draft-${d.id}`} flexDirection="column" borderStyle="round" borderColor="blue" paddingX={1}>
          <Text color="blue" bold>{`✎ Editing the comment on ${d.lines}`}</Text>
          <Input
            key={`edit-${d.id}`}
            autoFocus
            submitLabel="save"
            value={editText}
            onInput={(text: string) => {
              editText = text
            }}
            onSubmit={(text: string) => saveEdit($, d.id, text)}
          />
          <Box flexDirection="row" gap={1}>
            <Button key={`save-${d.id}`} variant="primary" label="Save" onPress={() => saveEdit($, d.id, editText)} />
            <Button key={`cancel-${d.id}`} label="Cancel" onPress={() => stopEdit($, d.id)} />
          </Box>
        </Box>
      ) : (
        <Box key={`draft-${d.id}`} flexDirection="column" borderStyle="round" borderColor="yellow" paddingX={1}>
          <Text wrap="wrap">
            <Text color="yellow" bold>{`✎ ${d.lines}  `}</Text>
            {d.text}
          </Text>
          <Box flexDirection="row" gap={2}>
            {/* Sends every draft, on every file, as one message. */}
            <Button key={`send-${d.id}`} plain label={sendLabel} onPress={() => sendComments($)} />
            <Button key={`edit-btn-${d.id}`} plain dimColor label="Edit" onPress={() => startEdit($, d.id)} />
            <Button key={`drop-${d.id}`} plain dimColor label="Delete" onPress={() => deleteComment($, d.id)} />
          </Box>
        </Box>
      )
    for (const d of fileDrafts) {
      const at = commentRow(d, rows)
      if (at === undefined) unplaced.push(d)
      else place(at, draftCard(d))
    }

    if (box && Input && rows[box.hi]) {
      place(
        box.hi,
        <Box key="composer" flexDirection="column" borderStyle="round" borderColor="blue" paddingX={1}>
          <Text color="blue" bold>{`✎ Comment on ${describeLines(rows.slice(box.lo, box.hi + 1))}`}</Text>
          <Input
            key="comment"
            autoFocus
            placeholder="Write a comment for Claude, Enter to add"
            submitLabel="add"
            value={composerText}
            onInput={(text: string) => {
              composerText = text
            }}
            onSubmit={(text: string) => addComment($, text)}
          />
          <Box flexDirection="row" gap={1}>
            <Button key="composer-add" variant="primary" label="Add comment" onPress={() => addComment($, composerText)} />
            <Button
              key="composer-cancel"
              label="Cancel"
              onPress={() => closeComposer($, box.hi)}
            />
          </Box>
        </Box>,
      )
    }

    if (card && rows[card.symbol.row]) {
      place(
        card.symbol.row,
        <Box key="card" flexDirection="column" borderStyle="round" borderColor={card.isError ? 'red' : 'cyan'} paddingX={1}>
          <Box flexDirection="row">
            <Box flexGrow={1}>
              <Text bold color="cyan">{`${LSP_LABELS[card.operation]} · ${card.symbol.name}`}</Text>
            </Box>
            <Button key="lsp-close" plain dimColor label="✕" onPress={() => update($, lsp, () => null)} />
          </Box>
          {card.isBusy ? (
            <Text dimColor>Looking it up…</Text>
ライセンスの全文(MIT)
MIT License

Copyright (c) 2026 Rudra Secure

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

コードが呼ぶもの

ファイル読み取りClaude を動かすツール呼び出し

コードから読み取ったデザイン

読み取ったコミットのソースから描いたもので、動かした結果ではありません。一覧は 3 回描き、条件はデスクトップアプリで描く最初の分岐を取り、動かしたときにだけ決まる値は仮の例(点線の下線)にするか省きます。色と書体はこのサイトのものです。

コードから読めること

2026-10-06 に読んだコミット d408a11fd553 のソースから。最初のまとまりが載せる条件で、残りは自分で判断するための材料です。後のコミットは、次に読むまで見ていません。

載せる条件: 確かめやすいコード
入口を読んだhooks/hooks.json が名指すモジュールをすべて読んだ。review-pane/hooks/register.tsx
解析できるすべてのファイルが TypeScript か JavaScript として解析できる。5 ファイルを解析
コードが Mod の中で完結import は Mod 自身のファイルかエンジンのモジュールだけ。パッケージも require もない。コードはすべて Mod の中
読める圧縮した行・eval・new Function・計算した道の import()・符号化した塊がない。圧縮・eval・符号化した塊なし
呼び出しが見える通信とプログラム起動はその場で $.http.fetch・$.process.run と書き、他へ渡さない。外への呼び出しはすべてその場の $ で
入れる前に自分で判断する材料
描く場所コードから読んだ、描く先。ターミナル・デスクトップアプリ・両方・何も描かない(フックだけ: 見張りやプロンプトの書き換え)のどれか。出すだけで、外す理由にはしない。ターミナルとデスクトップアプリに同じように描く
入れる手順リポジトリ自身の .claude-plugin/marketplace.json にこの Mod が載っていて、ページに書いた手順でそのマーケットプレイスから入れられるか。リポジトリの .claude-plugin/marketplace.json に載っており、そこから入れられる
Windows のプログラム$.process で起動するプログラムが Windows にあるか(tail・date・open・osascript・/usr/… などは無い)。Windows にないプログラムを使わない
通信fetch の送り先(https のホスト)がコードに書いてあるか。通信なし
プログラム起動するプログラムの名前がコードに書いてあり、シェル・インタプリタ・通信用の道具でないか。プログラムを起動しない
読んで送るファイルや環境変数を読み、かつ通信するか。通信しない
ソースの鍵ソースに API キーや秘密鍵らしきものがあるか。ソースに鍵なし
ライセンスオープンなライセンス(MIT・Apache-2.0・BSD・ISC・Unlicense・0BSD・CC0)で全文があれば、modscode にコードを載せる。違えばリンクだけ。MIT

コードの文面を読んだだけで、安全の審査ではありません。動かしてはおらず、起動するプログラムの中で何が起きるかも見えません。入れる前の確認はあなたの役目です。 載せる条件

入れる

入れる前に、必ず自分で確かめてください。Mod はサンドボックスなしで、あなたの権限で動きます。modscode はこのコードの安全を保証しません。下のコードを読み(またはフォルダーで claude plugin validate .)、触るものを見て、読んだコミットを入れてください。

リポジトリがそのままマーケットプレイスです。このマーケットプレイスを足し(ターミナルでは次のコマンド、デスクトップアプリではプラグインの設定)、そこから Mod を入れます。

/plugin marketplace add rudrasecure/claude-mods
/plugin install review-pane@claude-mods

入るのはマーケットプレイスの最新のコミットで、ここで読んだもの(d408a11fd553)と違うことがあります。入れる前に見比べてください。

Claude に聞く

modscode のコネクタを入れると、Claude がこのデザイン・コードが触るもの・コードを読んで、それをもとに作れます。たとえば:

modscode のデザイン「rudrasecure-review-pane」をコードごと読んで、同じようなペインを作って

Claude から探す: MCP コネクタ

似たデザイン