modscode EN

modscode / 図鑑 / agentpane

agentpane

A side pane for Claude Code that lists the subagents a session runs, what each is doing and what it costs in tokens, with each one's conversation a click away.

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

何をするか

  • 欄・トーストを描く
  • /agentpane を足す
  • ツールの呼び出しを見張る(止めることがある)
  • agent.spawn・session.start・turn.step・ui.closeにフックする

良いところ

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

作り始めるためのコード

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

雛形(register.tsx)

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

// Drawn like agentpane by Anji Xu (pane, band, status, toast), as modscode read it from the mod's code:
// https://modscode.com/gallery/xuanji86-agentpane/
// 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: "Agents" })
  on('ui.render', { component: 'Pane', requestId: 'my-pane' }, async ($, e) => {
    const { Box, Text, Button } = $.ui.resolve(e)
    const glyph = '…'
    const counts = '…'
    const loopsLine = '…'
    const axisTitle = '…'
    const mark = '…'
    const name = '…'
    const fmtDuration = '…'
    const name2 = '…'
    const name3 = '…'
    const text = '…'
    return (
      <Box flexDirection="row">
        <Box flexDirection="column" width={2} flexShrink={0}>
          <Text>
            {" "}
          </Text>
          <Button label={`${glyph}`} plain dimColor />
          <Button label={`${glyph}`} plain dimColor />
          <Button label={`${glyph}`} plain dimColor />
        </Box>
        <Box flexDirection="column">
          <Box flexDirection="column" justifyContent="space-between">
            <Box flexDirection="column" flexShrink={1} overflow="hidden">
              <Box justifyContent="space-between">
                <Text>
                  <Text color="claude">
                    {"✻ "}
                  </Text>
                  <Text bold>
                    Agents
                  </Text>
                </Text>
                <Text dimColor>
                  {counts}
                </Text>
              </Box>
              <Text dimColor>
                No agents yet. They show here while they run.
              </Text>
              <Box marginTop={1}>
                <Text dimColor wrap="truncate-end">
                  {loopsLine}
                </Text>
              </Box>
            </Box>
            <Box flexDirection="column" flexShrink={0}>
              <Box flexDirection="column" flexShrink={0} marginTop={1}>
                <Text dimColor wrap="truncate-end">
                  {`──${axisTitle}────────`}
                </Text>
                <Text wrap="truncate-end">
                  <Text>
                    {`${mark} `}
                  </Text>
                  <Text>
                    {name}
                  </Text>
                  <Text dimColor>
                    {" ········"}
                  </Text>
                  <Text>
                    ━━━━━━━━
                  </Text>
                  <Text dimColor>
                    {`········${fmtDuration}`}
                  </Text>
                </Text>
                <Text wrap="truncate-end">
                  <Text>
                    {`${mark} `}
                  </Text>
                  <Text>
                    {name2}
                  </Text>
                  <Text dimColor>
                    {" ········"}
                  </Text>
                  <Text>
                    ━━━━━━━━
                  </Text>
                  <Text dimColor>
                    {`········${fmtDuration}`}
                  </Text>
                </Text>
                <Text wrap="truncate-end">
                  <Text>
                    {`${mark} `}
                  </Text>
                  <Text>
                    {name3}
                  </Text>
                  <Text dimColor>
                    {" ········"}
                  </Text>
                  <Text>
                    ━━━━━━━━
                  </Text>
                  <Text dimColor>
                    {`········${fmtDuration}`}
                  </Text>
                </Text>
                <Text wrap="truncate-end">
                  <Text color="error">
                    {"✗ "}
                  </Text>
                  <Text dimColor>
                    {text}
                  </Text>
                </Text>
              </Box>
              <Text dimColor wrap="truncate-end">
                click an agent to open it · click "done" to hide finished ones
              </Text>
            </Box>
          </Box>
        </Box>
      </Box>
    )
  })

  on('session.start', async ($, e, next) => {
    const name = '…'
    const why = '…'
    await $.ui.toast(`Could not stop ${name}: ${why}`)
    return next(e)
  })
}

Mod 自身のコード

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

hooks/register.tsx 678〜837 行 · ペイン
  on('ui.render', { component: 'Pane', requestId: PANE }, async ($, e) => {
    const els = $.ui.resolve(e)
    const { Box, Button, Markdown, Text } = els
    // Live lines run on the surface's own frame clock where it has one (terminal, desktop); elsewhere they are
    // static. Every surface's table names Client, but on the others it draws nothing: ask by surface.
    const Client = (e.surface === 'terminal' || e.surface === 'desktop') && 'Client' in els ? els.Client : null
    lastPlacement = e.props.placement
    lastColumns = e.viewport?.columns ?? lastColumns
    isFullscreen = e.viewport?.isFullscreen ?? isFullscreen
    const inline = e.props.placement === 'inline' // above the prompt: a summary, no handle
    const W = Math.max(22, e.props.bodyColumns - (inline ? 0 : HANDLE_COLS) - RIGHT_MARGIN) // the content, right of the handle
    const viewed = e.props.view?.agentId ?? null // the agent the person has open in the main view
    const rows = Math.max(MIN_ROWS + 6, e.props.scroll.bodyRows)
    const now = await $.clock.now()
    const all = await read($, agents)
    const act = await read($, activity)
    const tok = await read($, tokens)
    const id = await read($, viewing)
    const agent = id ? all.find(a => a.id === id) : undefined
    viewingId = agent ? agent.id : null
    const runningCount = all.filter(a => a.status === 'running').length
    const doneCount = all.length - runningCount
    const hint = (text: string) => <Text dimColor wrap="truncate-end">{text}</Text>
    const alertOf = (a: Agent) => (tok[a.id]?.truncated ? `max_tokens ×${tok[a.id]!.truncated}` : '')
    // A running agent's spinner, shimmering "Running…" and clock, redrawn by the surface, not by this hook.
    const liveLine = (a: Agent, pad: string, detail: string) =>
      Client && a.seenRunning ? (
        <Client key={`live-${a.id}`} module="./live.tsx" props={{ since: a.firstSeen, now, pad, detail, alert: alertOf(a), motion: cfg.motion, clockOnly: false }} />
      ) : (
        <Text wrap="truncate-end">
          <Text color="claude">{`${pad}  ✻ Running…`}</Text>
          <Text dimColor>{` (${[elapsed(a, now), detail].filter(Boolean).join(' · ')}`}</Text>
          {alertOf(a) ? <Text color="error">{` · ${alertOf(a)}`}</Text> : null}
          <Text dimColor>)</Text>
        </Text>
      )
    const clock = (a: Agent) =>
      Client && a.status === 'running' && a.seenRunning ? (
        <Client key={`clock-${a.id}`} module="./live.tsx" props={{ since: a.firstSeen, now, pad: '', detail: '', alert: '', motion: false, clockOnly: true }} />
      ) : (
        <Text dimColor>{elapsed(a, now)}</Text>
      )
    // The first row, clear of the engine's close mark at its end.
    const header = (left: RenderChildren, right: RenderChildren) => (
      <Box width={W - CLOSE_MARK_COLS} justifyContent="space-between">
        {left}
        {typeof right === 'string' ? <Text dimColor>{right}</Text> : right}
      </Box>
    )
    // A handle on the pane's left edge, halfway down: ▸ hides the pane. Above the prompt there is no edge to hold.
    const withHandle = (body: RenderChildren) =>
      inline ? (
        <Box flexDirection="column" width={W}>
          {body}
        </Box>
      ) : (
      <Box flexDirection="row">
        <Box key="handle" flexDirection="column" width={HANDLE_COLS} flexShrink={0}>
          {Array.from({ length: Math.max(0, Math.floor((rows - HANDLE.length) / 2)) }, () => <Text> </Text>)}
          {HANDLE.map((glyph, i) => (
            <Button
              key={glyph.startsWith('▸') ? 'collapse' : `collapse-${i}`}
              label={glyph}
              plain
              dimColor
              hover={{ color: 'claude', bold: true }}
              onPress={() => foldAway($)}
            />
          ))}
        </Box>
        <Box flexDirection="column" width={W} height={rows}>
          {body}
        </Box>
      </Box>
      )

    // One agent's conversation, as Claude Code draws its own: > the brief, ⏺ replies and tool calls, ⎿ results.
    if (agent) {
      const key = `${agent.id}:${await read($, rev)}:${agent.status}`
      if (transcript.key !== key) {
        const msgs = await $.session.messages({ agentId: agent.id })
        transcript = { key, blocks: Array.isArray(msgs) ? transcriptBlocks(msgs, agent.status !== 'running') : [] }
      }
      const blocks = transcript.blocks
      const open = new Set(await read($, expanded))
      const armed = await read($, confirmStop)
      const savedTop = await read($, scrollTop)
      const top = savedTop === null ? null : Math.min(savedTop, Math.max(0, blocks.length - 1))
      const shown = pickBlocks(blocks, top)
      const newer = top === null ? 0 : blocks.length - top - 1 // blocks after the one at the top
      const used = tok[agent.id]
      const l = look(agent.status)
      const leave = async () => {
        await showList($)
        await openPane($, 'list') // back to the usual size
      }
      const toggle = (k: string) => update($, expanded, list => (list.includes(k) ? list.filter(x => x !== k) : [...list, k]))
      const result = (c: Call) =>
        c.state === 'running' ? [<Text color="claude">{'  ⎿  Running…'}</Text>]
        : c.state === 'stopped' ? [<Text dimColor>{'  ⎿  Interrupted'}</Text>]
        : [
            ...(c.result.length ? c.result : ['(No output)']).map((r, i) => (
              <Text color={c.state === 'error' ? 'error' : undefined} dimColor={c.state !== 'error'} wrap="truncate-end">
                {`${i ? '     ' : '  ⎿  '}${r}`}
              </Text>
            )),
            ...(c.more ? [<Text dimColor>{`     … +${c.more} line${c.more === 1 ? '' : 's'}`}</Text>] : []),
          ]
      const call = (c: Call) => (
        <Box flexDirection="column" flexShrink={0}>
          <Text wrap="truncate-end">
            <Text color={STATE_COLOR[c.state]}>⏺ </Text>
            <Text bold>{c.name}</Text>
            <Text>{c.arg ? `(${c.arg})` : ''}</Text>
          </Text>
          {result(c)}
        </Box>
      )
      const block = (b: Block): RenderElement => {
        if (b.kind === 'prompt') {
          const lines = wrap(b.text.slice(0, PROMPT_LINES * W * 2), W - 2)
          return (
            <Box flexDirection="column" flexShrink={0} marginTop={1}>
              {lines.slice(0, PROMPT_LINES).map((line, i) => (
                <Text dimColor wrap="truncate-end">{`${i ? '  ' : '> '}${line}`}</Text>
              ))}
              {lines.length > PROMPT_LINES ? <Text dimColor>{'  …'}</Text> : null}
            </Box>
          )
        }
        if (b.kind === 'reply') {
          const text = b.text.length > MAX_REPLY ? `${b.text.slice(0, MAX_REPLY)}\n\n… (${b.text.length - MAX_REPLY} more characters)` : b.text
          return (
            <Box flexDirection="row" flexShrink={0} marginTop={1}>
              <Text>⏺ </Text>
              <Box flexDirection="column" width={W - 2}>
                <Markdown text={text} />
              </Box>
            </Box>
          )
        }
        if (b.calls.length === 1) return <Box flexShrink={0} marginTop={1}>{call(b.calls[0]!)}</Box>
        const isOpen = open.has(b.key)
        const opened = lastCalls(b.calls)
        const live = b.calls.find(c => c.state === 'running')
        const failed = b.calls.find(c => c.state === 'error')
        return (
          <Box key={`grp-${b.key}`} flexDirection="column" flexShrink={0} marginTop={1}>
            <Box>
              <Text color={STATE_COLOR[groupState(b.calls)]}>⏺ </Text>
              <Button key={`group-${b.key}`} label={groupSummary(b.calls)} plain hover={{ color: 'claude' }} onPress={() => toggle(b.key)} />
              <Text dimColor>{isOpen ? ' (click to collapse)' : ' (click to expand)'}</Text>
            </Box>
            {isOpen ? (
              <Box flexDirection="column" paddingLeft={2}>
                {opened.hidden ? <Text dimColor>{`… +${opened.hidden} earlier call${opened.hidden === 1 ? '' : 's'}`}</Text> : null}
                {opened.shown.map(call)}
              </Box>
            ) : live ? (
              <Text color="claude" wrap="truncate-end">{`  ⎿  ${live.name}${live.arg ? `(${live.arg})` : ''} · Running…`}</Text>
ライセンスの全文(MIT)
MIT License

Copyright (c) 2026 Anji Xu

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 に読んだコミット 17be88979e57 のソースから。最初のまとまりが載せる条件で、残りは自分で判断するための材料です。後のコミットは、次に読むまで見ていません。

載せる条件: 確かめやすいコード
入口を読んだhooks/hooks.json が名指すモジュールをすべて読んだ。hooks/register.tsx
解析できるすべてのファイルが TypeScript か JavaScript として解析できる。4 ファイルを解析
コードが 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 xuanji86/claude-agentpane
/plugin install agentpane@claude-agentpane

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

Claude に聞く

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

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

Claude から探す: MCP コネクタ

似たデザイン