modscode EN

modscode / 図鑑 / choitree

choitree

Live pane for Claude Code: file tree, git status, where Claude is working, tokens and usage limits, scoped to the current project

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

何をするか

  • 欄を描く
  • /choitree を足す
  • ツールの呼び出しを見張る
  • session.start・turn.complete・turn.start・turn.stepにフックする
  • ターンをまたいで自分の状態を持つ

良いところ

  • ネットワークに出ない
  • TypeScript で書かれている
  • 複数の言語で話す
  • ファイルを書かない

作り始めるためのコード

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

雛形(register.tsx)

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

// Drawn like choitree by choidevhi (pane), as modscode read it from the mod's code:
// https://modscode.com/gallery/choidevhi-choitree/
// 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: "choitree" })
  on('ui.render', { component: 'Pane', requestId: 'my-pane' }, async ($, e) => {
    const { Box, Text, Button } = $.ui.resolve(e)
    const row = '…'
    const row2 = '…'
    const row3 = '…'
    const SPIN = '…'
    const verbs = '…'
    const secs = '…'
    const usd = '…'
    const bar = '…'
    const pct = '…'
    const fmt = '…'
    const kinds = '…'
    const used = '…'
    const when = '…'
    const kinds2 = '…'
    const used2 = '…'
    const kinds3 = '…'
    const used3 = '…'
    const pop = '…'
    const branch = '…'
    const upstream = '…'
    const ahead = '…'
    const behind = '…'
    const changed = '…'
    const lastCommit = '…'
    const mark = '…'
    const iconOf = '…'
    const label = '…'
    const count = '…'
    const tool = '…'
    const mark2 = '…'
    const iconOf2 = '…'
    const count2 = '…'
    const tool2 = '…'
    const mark3 = '…'
    const iconOf3 = '…'
    const count3 = '…'
    const tool3 = '…'
    const more = '…'
    return (
      <Box flexDirection="column">
        <Box flexDirection="row">
          <Box flexDirection="column" marginRight={1}>
            <Text color="#D97757">
              {row}
            </Text>
            <Text color="#D97757">
              {row2}
            </Text>
            <Text color="#D97757">
              {row3}
            </Text>
          </Box>
          <Box flexDirection="column">
            <Text color="#D97757" bold>
              {SPIN}
              {" "}
              {verbs}
              {"… "}
              <Text dimColor>
                {secs}
                s
              </Text>
            </Text>
            <Text dimColor>
              {"🔧 "}
            </Text>
            <Text>
              <Text color="#D97757">
                {"🧠 "}
                ?
              </Text>
              <Text dimColor>
                {" ⏱ "}
                worked
                {" "}
                00
              </Text>
            </Text>
            <Text>
              <Text color="cyan">
                ↑
                000
              </Text>
              <Text color="magenta">
                {" ↓"}
                0
              </Text>
              <Text color="green">
                {" $"}
                {usd}
              </Text>
            </Text>
          </Box>
        </Box>
        <Text>
          <Text dimColor>
            Context
            {" "}
          </Text>
          <Text color="red">
            {bar}
          </Text>
          <Text dimColor>
            {" "}
            {pct}
            % (
            0
            /
            {fmt}
            )
          </Text>
        </Text>
        <Text>
          <Text dimColor>
            {kinds}
            {" "}
          </Text>
          <Text color="red">
            ████████░░░░░░░░
          </Text>
          <Text dimColor>
            {" "}
            {used}
            %
            {` · resets ${when}`}
          </Text>
        </Text>
        <Text>
          <Text dimColor>
            {kinds2}
            {" "}
          </Text>
          <Text color="red">
            ████████░░░░░░░░
          </Text>
          <Text dimColor>
            {" "}
            {used2}
            %
            {` · resets ${when}`}
          </Text>
        </Text>
        <Text>
          <Text dimColor>
            {kinds3}
            {" "}
          </Text>
          <Text color="red">
            ████████░░░░░░░░
          </Text>
          <Text dimColor>
            {" "}
            {used3}
            %
            {` · resets ${when}`}
          </Text>
        </Text>
        <Text bold color="cyan">
          {"📁 "}
          {pop}
        </Text>
        <Text>
          <Text color="magenta" bold>
            {" "}
            {branch}
          </Text>
          <Text>
            <Text dimColor>
              {" → "}
              {upstream}
            </Text>
            <Text color="green">
              {" ↑"}
              {ahead}
            </Text>
            <Text color="yellow">
              {" ↓"}
              {behind}
            </Text>
            <Text dimColor>
              {" ≡"}
            </Text>
          </Text>
          <Text dimColor>
            {" "}
            {`${changed}`}
          </Text>
        </Text>
        <Text dimColor>
          not a git repository
        </Text>
        <Text dimColor wrap="truncate-end">
          {"● "}
          {lastCommit}
        </Text>
        <Text color="green">
          {"▶ "}
          (no work yet)
        </Text>
        <Text dimColor>
          ────────────────
        </Text>
        <Box flexDirection="row">
          <Text color="yellow">
            {mark}
            {" "}
          </Text>
          <Text dimColor>
            {"                "}
          </Text>
          <Text>
            {iconOf}
            {" "}
          </Text>
          <Text color="green" bold>
            ▶
          </Text>
          <Button label={`${label}`} plain />
          <Text dimColor>
            {" ("}
            {count}
            )
          </Text>
          <Text color="blue">
            {" ← "}
            {tool}
          </Text>
        </Box>
        <Box flexDirection="row">
          <Text color="yellow">
            {mark2}
            {" "}
          </Text>
          <Text dimColor>
            {"                "}
          </Text>
          <Text>
            {iconOf2}
            {" "}
          </Text>
          <Text color="green" bold>
            ▶
          </Text>
          <Button label={`${label}`} plain />
          <Text dimColor>
            {" ("}
            {count2}
            )
          </Text>
          <Text color="blue">
            {" ← "}
            {tool2}
          </Text>
        </Box>
        <Box flexDirection="row">
          <Text color="yellow">
            {mark3}
            {" "}
          </Text>
          <Text dimColor>
            {"                "}
          </Text>
          <Text>
            {iconOf3}
            {" "}
          </Text>
          <Text color="green" bold>
            ▶
          </Text>
          <Button label={`${label}`} plain />
          <Text dimColor>
            {" ("}
            {count3}
            )
          </Text>
          <Text color="blue">
            {" ← "}
            {tool3}
          </Text>
        </Box>
        <Text dimColor>
          {`${more}`}
        </Text>
        <Text dimColor>
          ────────────────
        </Text>
        <Text dimColor>
          ⌨ ctrl+x tab focus pane · ↑↓ move · Enter open/fold
        </Text>
        <Text dimColor>
          {"  📂 click folder to fold · click file to insert @path"}
        </Text>
      </Box>
    )
  })
}

Mod 自身のコード

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

hooks/register.tsx 302〜452 行 · ペイン
  on('ui.render', { component: 'Pane', requestId: PANE }, async ($, e) => {
    const { Box, Text, Button } = $.ui.resolve(e)
    const ov = state.opened
    const s = state.snap
    const ts = state.touches
    if (!s) return <Text dimColor>{L.scanning}</Text>
    const act = state.activity
    const tk = state.tokens
    const us = await $.session.usage().catch(() => undefined)
    const body = act.busy ? BODY[Math.floor(act.frame / 2) % BODY.length]! : IDLE
    const secs = act.busy ? Math.floor((Date.now() - act.since) / 1000) : 0
    const model = await $.session.model().catch(() => '')
    const total = dur(state.workMs + (act.busy ? Date.now() - act.since : 0))
    const ctx = us?.context
    const pct = ctx?.percent ?? (ctx?.tokens ? (ctx.tokens / ctx.window) * 100 : 0)
    const bar = '█'.repeat(Math.round(pct / 10)) + '░'.repeat(10 - Math.round(pct / 10))
    const limits = us?.rateLimits ?? []
    const rows = Math.max(6, (e.viewport?.rows ?? 30) - 18 - limits.length)

    const lowRoot = s.root.toLowerCase() + '/'
    const rel = (p: string) => (p.toLowerCase().startsWith(lowRoot) ? p.slice(lowRoot.length) : p)
    const touched = new Map(ts.map(t => [rel(t.path), t]))
    const last = ts[ts.length - 1]
    const current = last ? rel(last.path) : ''
    const changed = Object.keys(s.status)
    const under = (dir: string, list: Iterable<string>) => [...list].some(c => c.startsWith(dir + '/'))
    const auto = (dir: string) => current.startsWith(dir + '/') || under(dir, changed) || under(dir, touched.keys())

    const hot = (dir: string) => ov[dir] ?? auto(dir)

    // 클릭으로 바꾼 폴더는 그대로, 나머지는 작업 중·변경·최근 접근 경로만 펼치고 나머지 폴더는 한 줄로 접는다.
    const lines: Line[] = []
    const walk = (prefix: string, depth: number) => {
      const dirs = new Map<string, number>()
      const files: string[] = []
      for (const f of s.files) {
        if (prefix && !f.startsWith(prefix + '/')) continue
        const rest = prefix ? f.slice(prefix.length + 1) : f
        const i = rest.indexOf('/')
        if (i > 0) dirs.set(rest.slice(0, i), (dirs.get(rest.slice(0, i)) ?? 0) + 1)
        else files.push(rest)
      }
      for (const [d, n] of [...dirs].sort()) {
        const full = prefix ? `${prefix}/${d}` : d
        lines.push({ depth, label: d + '/', path: full, isDir: true, count: n })
        if (hot(full)) walk(full, depth + 1)
      }
      for (const f of files.sort()) {
        lines.push({ depth, label: f, path: prefix ? `${prefix}/${f}` : f, isDir: false, count: 0 })
      }
    }
    walk('', 0)

    return (
      <Box flexDirection="column">
        <Box flexDirection="row">
          <Box flexDirection="column" marginRight={1}>
            {body.map(row => <Text color="#D97757">{row}</Text>)}
          </Box>
          <Box flexDirection="column">
            {act.busy ? (
              <Text color="#D97757" bold>{SPIN[act.frame % SPIN.length]} {L.verbs[Math.floor(act.since / 1000) % L.verbs.length]}… <Text dimColor>{secs}s</Text></Text>
            ) : (
              <Text dimColor>✳ {L.idle}</Text>
            )}
            <Text dimColor>{act.busy && act.tool ? `🔧 ${act.tool}` : L.steps(tk.steps)}</Text>
            <Text>
              <Text color="#D97757">🧠 {model || '?'}</Text>
              <Text dimColor>  ⏱ {L.work} {total}</Text>
            </Text>
            <Text>
              <Text color="cyan">↑{fmt(tk.input + tk.cacheRead + tk.cacheWrite)}</Text>
              <Text color="magenta"> ↓{fmt(tk.output)}</Text>
              {us?.cost && <Text color="green"> ${us.cost.usd.toFixed(2)}</Text>}
            </Text>
          </Box>
        </Box>
        {ctx && (
          <Text>
            <Text dimColor>{L.context} </Text>
            <Text color={pct > 80 ? 'red' : pct > 50 ? 'yellow' : 'green'}>{bar}</Text>
            <Text dimColor> {pct.toFixed(0)}% ({fmt(ctx.tokens ?? 0)}/{fmt(ctx.window)})</Text>
          </Text>
        )}
        {limits.map(r => {
          const used = Math.max(0, Math.min(100, r.percentUsed))
          const n = Math.round(used / 10)
          return (
            <Text key={r.kind}>
              <Text dimColor>{(L.kinds[r.kind as keyof typeof L.kinds] ?? r.kind).padEnd(6)} </Text>
              <Text color={used > 80 ? 'red' : used > 50 ? 'yellow' : 'green'}>{'█'.repeat(n) + '░'.repeat(10 - n)}</Text>
              <Text dimColor> {used.toFixed(0)}%{r.resetsAt ? ` · ${L.reset} ${when(r.resetsAt)}` : ''}</Text>
            </Text>
          )
        })}
        <Text bold color="cyan">📁 {s.root.split('/').pop()}</Text>
        {s.isRepo ? (
          <Text>
            <Text color="magenta" bold> {s.branch}</Text>
            {s.upstream ? (
              <Text>
                <Text dimColor> → {s.upstream}</Text>
                {s.ahead > 0 && <Text color="green"> ↑{s.ahead}</Text>}
                {s.behind > 0 && <Text color="yellow"> ↓{s.behind}</Text>}
                {s.ahead === 0 && s.behind === 0 && <Text dimColor> ≡</Text>}
              </Text>
            ) : (
              <Text dimColor> ({L.noUpstream})</Text>
            )}
            <Text dimColor>  {changed.length ? L.changed(changed.length) : L.clean}</Text>
          </Text>
        ) : null}
        {!s.isRepo && <Text dimColor>{L.notRepo}</Text>}
        {s.isRepo && s.lastCommit && <Text dimColor wrap="truncate-end">● {s.lastCommit}</Text>}
        <Text color="green">▶ {current || L.nothing}</Text>
        <Text dimColor>────────────────</Text>
        {lines.slice(0, rows).map(l => {
          const st = s.status[l.path]
          const [ic, col] = st ? (ICON[st] ?? ICON[st.charAt(0)] ?? ['●', 'yellow']) : [' ', 'white']
          const isCur = l.path === current
          const t = touched.get(l.path)
          const mark = l.isDir ? (under(l.path, changed) ? '•' : ' ') : ic
          return (
            <Box flexDirection="row" key={l.path}>
              <Text color={l.isDir ? 'yellow' : col}>{mark} </Text>
              <Text dimColor>{'  '.repeat(l.depth)}</Text>
              <Text>{iconOf(l.label.replace(/\/$/, ''), l.isDir, l.isDir && hot(l.path))} </Text>
              {isCur && <Text color="green" bold>▶</Text>}
              <Button
                key={l.path}
                label={l.label}
                plain
                dimColor={!isCur && !t && !l.isDir && !st}
                onPress={() =>
                  l.isDir
                    ? void ((state.opened = { ...state.opened, [l.path]: !hot(l.path) }), redraw($))
                    : void $.prompt.fill({ text: `@${l.path} `, mode: 'insert' })
                }
              />
              {l.isDir && !hot(l.path) && <Text dimColor> ({l.count})</Text>}
              {t && !isCur && <Text color="blue"> ← {t.tool}</Text>}
            </Box>
          )
        })}
        {lines.length > rows && <Text dimColor>{L.more(lines.length - rows)}</Text>}
        <Text dimColor>────────────────</Text>
        <Text dimColor>{L.keys1}</Text>
        <Text dimColor>{L.keys2}</Text>
      </Box>
    )
  })
ライセンスの全文(MIT)
MIT License

Copyright (c) 2026 choidevhi (https://choidev.com)

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.

コードが呼ぶもの

プログラム起動ファイル読み取りツール呼び出し保存

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

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

コードから読めること

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

載せる条件: 確かめやすいコード
入口を読んだhooks/hooks.json が名指すモジュールをすべて読んだ。hooks/register.tsx
解析できるすべてのファイルが TypeScript か JavaScript として解析できる。1 ファイルを解析
コードが 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 のホスト)がコードに書いてあるか。通信なし
プログラム起動するプログラムの名前がコードに書いてあり、シェル・インタプリタ・通信用の道具でないか。git(通信する)
読んで送るファイルや環境変数を読み、かつ通信するか。読んだうえで通信する
ソースの鍵ソースに API キーや秘密鍵らしきものがあるか。ソースに鍵なし
ライセンスオープンなライセンス(MIT・Apache-2.0・BSD・ISC・Unlicense・0BSD・CC0)で全文があれば、modscode にコードを載せる。違えばリンクだけ。MIT

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

入れる

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

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

/plugin marketplace add choidevhi/choitree
/plugin install choitree@choitree

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

Claude に聞く

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

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

Claude から探す: MCP コネクタ

似たデザイン