modscode EN

modscode / 図鑑 / touch-map

touch-map

See which files Claude has listed, read, partially read, edited, created or deleted, as a tree and an activity map in a pane.

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

何をするか

  • プロンプトの上の帯・欄・トーストを描く
  • /touch-map を足す
  • ツールの呼び出しを見張る
  • classic.InstructionsLoaded・classic.SessionStart・session.append・session.end ほか 3 個にフックする
  • ターンをまたいで自分の状態を持つ

良いところ

  • ネットワークに出ない
  • TypeScript で書かれている
  • エラーを扱う

作り始めるためのコード

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

雛形(register.tsx)

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

// Drawn like touch-map by y-hirakaw (pane, band, toast), as modscode read it from the mod's code:
// https://modscode.com/gallery/y-hirakaw-touch-map/
// 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 band above the prompt; what else goes there is drawn under it
  on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
    const { Box, Text, Button } = $.ui.resolve(e)
    const text = '…'
    const text2 = '…'
    const text3 = '…'
    const fmt = '…'
    return (
      <Box flexDirection="column">
        <Box flexDirection="row" gap={1}>
          <Text dimColor>
            Touch map
          </Text>
          <Text>
            <Text>
              {text}
            </Text>
            <Text>
              {text2}
            </Text>
            <Text>
              {text3}
            </Text>
          </Text>
          <Text>
            <Text bold>
              {fmt}
            </Text>
            <Text dimColor>
              {`/${fmt}`}
            </Text>
          </Text>
          <Button label="open" />
        </Box>
        {await next(e)}
      </Box>
    )
  })

  // the pane: open it with $.ui.open({ id: 'my-pane', title: "Touch map" })
  on('ui.render', { component: 'Pane', requestId: 'my-pane' }, async ($, e) => {
    const { Box, Text, Button } = $.ui.resolve(e)
    const label = '…'
    const elapsed = '…'
    const fmt = '…'
    const text = '…'
    const text2 = '…'
    const text3 = '…'
    const path = '…'
    const note = '…'
    const text4 = '…'
    const text5 = '…'
    const text6 = '…'
    const text7 = '…'
    const count = '…'
    const text8 = '…'
    const text9 = '…'
    const text10 = '…'
    const text11 = '…'
    const count2 = '…'
    const text12 = '…'
    const text13 = '…'
    const text14 = '…'
    const text15 = '…'
    const count3 = '…'
    const auto = '…'
    return (
      <Box flexDirection="column">
        <Box flexDirection="row" gap={1} paddingRight={2}>
          <Box flexGrow={1} flexShrink={1} minWidth={0}>
            <Text bold wrap="truncate-end">
              {label}
            </Text>
          </Box>
          <Text dimColor>
            {elapsed}
          </Text>
          <Button variant="primary" label="save" />
          <Button label="discard" />
        </Box>
        <Box flexDirection="row" flexWrap="wrap" columnGap={2}>
          <Text>
            <Text bold>
              {fmt}
            </Text>
            <Text dimColor>
              {`/${fmt}`}
            </Text>
          </Text>
          <Text>
            {text}
          </Text>
          <Text>
            {text2}
          </Text>
          <Text>
            {text3}
          </Text>
          <Text color="#f87171" />
        </Box>
        <Box flexDirection="row" gap={1}>
          <Text dimColor>
            now
          </Text>
          <Box flexShrink={1} minWidth={0}>
            <Text wrap="truncate-start">
              {path}
            </Text>
          </Box>
        </Box>
        <Text dimColor wrap="truncate-end">
          {note}
        </Text>
        <Text color="#3f4654">
          ────────
        </Text>
        <Text dimColor>
          nothing touched yet
        </Text>
        <Box flexDirection="column">
          <Box flexDirection="row" backgroundColor="#1d2029">
            <Box flexShrink={0} flexDirection="row">
              <Text>
                {"                "}
              </Text>
              <Text>
                {" "}
              </Text>
              <Text>
                {" "}
              </Text>
            </Box>
            <Box flexGrow={1} flexShrink={1} minWidth={0}>
              <Text wrap="truncate-end">
                {text4}
              </Text>
            </Box>
            <Box flexShrink={0} justifyContent="flex-end">
              <Text>
                <Text>
                  {text5}
                </Text>
                <Text>
                  {text6}
                </Text>
                <Text>
                  {text7}
                </Text>
              </Text>
            </Box>
            <Box width={10} flexShrink={0} justifyContent="flex-end">
              <Text dimColor>
                {count}
              </Text>
            </Box>
          </Box>
          <Box flexDirection="row" backgroundColor="#1d2029">
            <Box flexShrink={0} flexDirection="row">
              <Text>
                {"                "}
              </Text>
              <Text>
                {" "}
              </Text>
              <Text>
                {" "}
              </Text>
            </Box>
            <Box flexGrow={1} flexShrink={1} minWidth={0}>
              <Text wrap="truncate-end">
                {text8}
              </Text>
            </Box>
            <Box flexShrink={0} justifyContent="flex-end">
              <Text>
                <Text>
                  {text9}
                </Text>
                <Text>
                  {text10}
                </Text>
                <Text>
                  {text11}
                </Text>
              </Text>
            </Box>
            <Box width={10} flexShrink={0} justifyContent="flex-end">
              <Text dimColor>
                {count2}
              </Text>
            </Box>
          </Box>
          <Box flexDirection="row" backgroundColor="#1d2029">
            <Box flexShrink={0} flexDirection="row">
              <Text>
                {"                "}
              </Text>
              <Text>
                {" "}
              </Text>
              <Text>
                {" "}
              </Text>
            </Box>
            <Box flexGrow={1} flexShrink={1} minWidth={0}>
              <Text wrap="truncate-end">
                {text12}
              </Text>
            </Box>
            <Box flexShrink={0} justifyContent="flex-end">
              <Text>
                <Text>
                  {text13}
                </Text>
                <Text>
                  {text14}
                </Text>
                <Text>
                  {text15}
                </Text>
              </Text>
            </Box>
            <Box width={10} flexShrink={0} justifyContent="flex-end">
              <Text dimColor>
                {count3}
              </Text>
            </Box>
          </Box>
          <Text dimColor>
            {`  … ${fmt} more rows`}
          </Text>
        </Box>
        <Text color="#7dd3fc" wrap="truncate-end">
          {`◆ ${auto}`}
        </Text>
      </Box>
    )
  })

  on('session.start', async ($, e, next) => {
    await $.ui.toast(`Touch map: the terminal is too narrow to open the pane here. Run /touch-map to open it.`)
    await $.ui.toast(`Touch map: discarded`)
    return next(e)
  })
}

Mod 自身のコード

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

touch-map/hooks/register.tsx 1273〜1294 行 · バンド
  on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
    if (!(await read($, minimized))) return next(e)
    const { Box, Text, Button } = $.ui.resolve(e)
    const all: Record<string, Touch> = await read($, touches)
    const touched = Object.keys(all).length
    return (
      <Box flexDirection="row" gap={1}>
        <Text dimColor>Touch map</Text>
        <Text>
          {shareBar(counts(all), files.size, BAR).map(s => (
            <Text color={s.color}>{s.text}</Text>
          ))}
        </Text>
        <Text>
          <Text bold>{fmt(touched)}</Text>
          <Text dimColor>{`/${fmt(files.size)}`}</Text>
        </Text>
        {/* 開く処理は下の ui.press のフックで行う。ここで描いたときの $ で開くと、人の操作として扱われない */}
        <Button key="open" label="open" onPress={() => undefined} />
      </Box>
    )
  })
touch-map/hooks/register.tsx 1388〜1520 行 · ペイン
  on('ui.render', { component: 'Pane', requestId: PANE }, async ($, e) => {
    const started = await $.clock.now()
    const ui = $.ui.resolve(e)
    const { Box, Text, Button } = ui
    const Input = 'Input' in ui ? ui.Input : undefined
    const Raster = 'Raster' in ui ? ui.Raster : undefined
    const all: Record<string, Touch> = await read($, touches)
    const seg: Segment = await read($, segment)
    const showMap: boolean = await read($, mapAtom)
    const loaded: Loaded = await read($, loadedAtom)
    const now: Now | null = await read($, nowAtom)
    const rows = toRows(all, await read($, folds), now)
    const c = counts(all)
    const gone = goneCount(all)
    const auto = Object.keys(loaded)
    const cols = e.props.bodyColumns ?? e.viewport?.columns ?? 60
    // ペインの本体は高さを超えると Claude Code がスクロールさせるので、行は全部渡す(重くならないよう上限だけ置く)
    const shown = rows.slice(0, 400)
    const header = 3 + (now ? 1 : 0) + (seg.note !== '' ? 1 : 0) + (Object.keys(all).length === 0 ? 1 : 0)
    paneRows = Math.max(0, (e.props.scroll?.bodyRows ?? 0) - header)
    const legend = [
      ...DEEP_FIRST.filter(i => (c[i] ?? 0) > 0).map(i => ({ text: `■${LEVELS[i]} ${fmt(c[i] ?? 0)}`, color: COLORS[i] as string })),
      ...(gone > 0 ? [{ text: `✕deleted ${fmt(gone)}`, color: GONE }] : []),
      ...(auto.length > 0 ? [{ text: `◆auto ${auto.length}`, color: AUTO }] : []),
    ]
    const tree = (
      <Box flexDirection="column">
        {shown.map(row => {
          const nameColor =
            row.kind === 'dir' ? (row.stat ? undefined : TRACK)
              : row.kind === 'file' ? (row.touch?.d ? GONE : row.touch ? COLORS[row.touch.s] : TRACK)
                : TRACK
          const bar =
            row.kind === 'dir' ? shareBar(row.stat?.c ?? [], row.total, BAR)
              : row.kind === 'file' && row.touch ? fileBar(row.touch) : []
          const count =
            row.kind === 'dir' ? `${fmt(row.stat?.touched ?? 0)}/${fmt(row.total)}`
              : row.kind === 'file' && row.touch ? rangeOf(row.touch) : ''
          return (
            <Box key={`row:${row.kind}:${row.key}`} flexDirection="row" backgroundColor={row.kind === 'file' && row.now ? NOW_BG : undefined}>
              {/* 字下げと行頭の記号は、幅が足りなくても縮めない */}
              <Box flexShrink={0} flexDirection="row">
                <Text>{'  '.repeat(row.indent)}</Text>
                {row.kind === 'file' ? (
                  <Text> </Text>
                ) : (
                  <Button key={`go:${row.kind}:${row.key}`} plain dimColor label={glyphOf(row)} onPress={() => void toggle($, row.key, row.open)} />
                )}
                <Text> </Text>
              </Box>
              <Box flexGrow={1} flexShrink={1} minWidth={0}>
                <Text
                  wrap="truncate-end"
                  color={nameColor}
                  bold={row.kind === 'dir' && row.stat !== undefined || (row.kind === 'file' && row.now)}
                  strikethrough={row.kind === 'file' && row.touch?.d === true}
                >
                  {'text' in row ? row.text : row.name}
                </Text>
              </Box>
              {(row.kind === 'dir' || row.kind === 'file') && (
                <Box width={BAR + 1} flexShrink={0} justifyContent="flex-end">
                  <Text>
                    {bar.map(s => (
                      <Text color={s.color}>{s.text}</Text>
                    ))}
                  </Text>
                </Box>
              )}
              {(row.kind === 'dir' || row.kind === 'file') && (
                <Box width={10} flexShrink={0} justifyContent="flex-end">
                  <Text dimColor>{count}</Text>
                </Box>
              )}
            </Box>
          )
        })}
        {rows.length > shown.length && <Text dimColor>{`  … ${fmt(rows.length - shown.length)} more rows`}</Text>}
      </Box>
    )
    renderMs = (await $.clock.now()) - started

    return (
      <Box flexDirection="column">
        <Box flexDirection="row" gap={1} paddingRight={2}>
          <Box flexGrow={1} flexShrink={1} minWidth={0}>
            {Input ? (
              <Input key="label" placeholder="task name" value={seg.label} submitLabel="set" onSubmit={(value: string) => void setLabel($, value)} />
            ) : (
              <Text bold wrap="truncate-end">{seg.label}</Text>
            )}
          </Box>
          <Text dimColor>{elapsed(seg.startedAt, await $.clock.now())}</Text>
          <Button key="save" variant="primary" label="save" onPress={() => void save($, true)} />
          {/* 最小化はペイン右上の × でできるので、ボタンは置かない */}
          <Button key="discard" label="discard" onPress={() => void save($, false)} />
        </Box>
        {/* 狭いペインでは、項目の途中で切らずに項目の切れ目で折り返す */}
        <Box flexDirection="row" flexWrap="wrap" columnGap={2}>
          <Text>
            <Text bold>{fmt(Object.keys(all).length)}</Text>
            <Text dimColor>{`/${fmt(files.size)}`}</Text>
          </Text>
          {legend.map(l => (
            <Text color={l.color}>{l.text}</Text>
          ))}
          {fileNote.includes('cut') && <Text color={GONE}>{fileNote}</Text>}
        </Box>
        {now && (
          <Box flexDirection="row" gap={1}>
            <Text dimColor>now</Text>
            <Box flexShrink={1} minWidth={0}>
              <Text wrap="truncate-start" color={COLORS[now.level]}>{now.path}</Text>
            </Box>
          </Box>
        )}
        {seg.note !== '' && <Text dimColor wrap="truncate-end">{seg.note}</Text>}
        {Raster && showMap && files.size > 0 && (() => {
          // ペインの幅いっぱいまでマスを並べる(Raster の上限 512 桁まで)。ファイルが少なくて余るときは中央に寄せる
          const layout = layoutOf(Math.max(8, Math.min(256, Math.floor((cols + 1) / 2))))
          return (
            <Box flexDirection="row" justifyContent="center">
              <Raster key="map" columns={layout.width * 2 - 1} rows={MAP_ROWS} cells={mapCells(all, layout, started)} />
            </Box>
          )
        })()}
        <Text color={TRACK}>{'─'.repeat(Math.max(10, cols))}</Text>
        {Object.keys(all).length === 0 && <Text dimColor>nothing touched yet</Text>}
        {tree}
        {auto.length > 0 && <Text color={AUTO} wrap="truncate-end">{`◆ ${auto.join('  ')}`}</Text>}
      </Box>
    )
  })
ライセンスの全文(MIT)
MIT License

Copyright (c) 2026 y-hirakaw

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

載せる条件: 確かめやすいコード
入口を読んだhooks/hooks.json が名指すモジュールをすべて読んだ。touch-map/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(通信する), printenv
読んで送るファイルや環境変数を読み、かつ通信するか。読んだうえで通信する
ソースの鍵ソースに API キーや秘密鍵らしきものがあるか。ソースに鍵なし
ライセンスオープンなライセンス(MIT・Apache-2.0・BSD・ISC・Unlicense・0BSD・CC0)で全文があれば、modscode にコードを載せる。違えばリンクだけ。MIT

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

入れる

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

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

/plugin marketplace add y-hirakaw/claude-code-mods
/plugin install touch-map@y-hirakaw-mods

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

Claude に聞く

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

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

Claude から探す: MCP コネクタ

似たデザイン