modscode EN

modscode / 図鑑 / fleet

fleet

See every running Claude Code session and worktree at a glance: status, branch, uncommitted work, staleness

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

何をするか

  • プロンプトの上の帯・欄・トーストを描く
  • /exit・/fleet を足す
  • session.start・turn.complete・ui.close・ui.focusにフックする
  • ターンをまたいで自分の状態を持つ
  • プロセスを起こす

良いところ

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

作り始めるためのコード

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

雛形(register.tsx)

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

// Drawn like fleet by Adarsh Muralidharan (pane, band, status, toast), as modscode read it from the mod's code:
// https://modscode.com/gallery/dubbus-fleet/
// 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 why = '…'
    return (
      <Box flexDirection="column">
        <Text color="yellow" wrap="truncate-end">
          {"⧉ Before you go: this session "}
          {why}
          . A handoff keeps it for next time.
        </Text>
        <Box>
          <Button label="Hand off and exit" hotkey="h" variant="primary" />
          <Text>
            {" "}
          </Text>
          <Button label="Exit now" hotkey="e" />
          <Text>
            {" "}
          </Text>
          <Button label="Stay" hotkey="s" />
        </Box>
        {await next(e)}
      </Box>
    )
  })

  // the pane: open it with $.ui.open({ id: 'my-pane', title: "Fleet" })
  on('ui.render', { component: 'Pane', requestId: 'my-pane' }, async ($, e) => {
    const { Box, Text, Button } = $.ui.resolve(e)
    const warning = '…'
    const headline = '…'
    const details = '…'
    const glyph = '…'
    const label = '…'
    const status = '…'
    const basename = '…'
    const gitText = '…'
    const ctxText = '…'
    const status2 = '…'
    const basename2 = '…'
    const gitText2 = '…'
    const ctxText2 = '…'
    const status3 = '…'
    const basename3 = '…'
    const gitText3 = '…'
    const ctxText3 = '…'
    const length = '…'
    return (
      <Box flexDirection="column">
        <Text color="red" wrap="wrap">
          {"⚠ "}
          {warning}
        </Text>
        <Text bold wrap="truncate-end">
          {headline}
        </Text>
        <Text dimColor wrap="truncate-end">
          {details}
        </Text>
        <Text>
          {" "}
        </Text>
        <Box>
          <Button plain label="▸" autoFocus />
          <Text>
            {` ${glyph} `}
          </Text>
          <Text color="red" bold wrap="truncate-end">
            {`x to close: ${label}`}
            {" "}
          </Text>
          <Text>
            {" "}
          </Text>
          <Text>
            {status}
          </Text>
          <Text>
            {basename}
            {" "}
          </Text>
          <Text color="magenta">
            {gitText}
          </Text>
          <Text dimColor>
            {"    "}
            {" "}
          </Text>
          <Text color="red">
            {ctxText}
          </Text>
        </Box>
        <Box>
          <Button plain label="▸" autoFocus />
          <Text>
            {` ${glyph} `}
          </Text>
          <Text color="red" bold wrap="truncate-end">
            {`x to close: ${label}`}
            {" "}
          </Text>
          <Text>
            {" "}
          </Text>
          <Text>
            {status2}
          </Text>
          <Text>
            {basename2}
            {" "}
          </Text>
          <Text color="magenta">
            {gitText2}
          </Text>
          <Text dimColor>
            {"    "}
            {" "}
          </Text>
          <Text color="red">
            {ctxText2}
          </Text>
        </Box>
        <Box>
          <Button plain label="▸" autoFocus />
          <Text>
            {` ${glyph} `}
          </Text>
          <Text color="red" bold wrap="truncate-end">
            {`x to close: ${label}`}
            {" "}
          </Text>
          <Text>
            {" "}
          </Text>
          <Text>
            {status3}
          </Text>
          <Text>
            {basename3}
            {" "}
          </Text>
          <Text color="magenta">
            {gitText3}
          </Text>
          <Text dimColor>
            {"    "}
            {" "}
          </Text>
          <Text color="red">
            {ctxText3}
          </Text>
        </Box>
        <Text dimColor>
          {" +"}
          {length}
          {" more (/fleet list)"}
        </Text>
        <Text>
          {" "}
        </Text>
        <Box>
          <Button label="Handoff" hotkey="h" />
          <Text>
            {" "}
          </Text>
          <Button label="Save" hotkey="s" />
          <Text>
            {" "}
          </Text>
          <Button label="Close" hotkey="x" />
          <Text>
            {" "}
          </Text>
          <Button label="Copy resume" hotkey="c" />
          <Text>
            {" "}
          </Text>
          <Button label="Refresh" hotkey="r" />
        </Box>
        <Text dimColor wrap="truncate-end">
          ● in progress ◐ finished: hand off ○ light · ctx = tokens a resume re-caches · cold = cache expired
        </Text>
      </Box>
    )
  })

  on('session.start', async ($, e, next) => {
    const label = '…'
    const status = '…'
    await $.ui.toast(`⚠ ${label} needs you (${status})`)
    await $.ui.toast(`✓ ${label} finished`)
    return next(e)
  })
}

Mod 自身のコード

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

hooks/register.tsx 674〜690 行 · バンド
  on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
    const offer = await read($, band)
    if (!offer || e.props.hasSurvey) return next(e)
    return bandView($.ui.resolve(e), offer, {
      handOff: then => { void handOffSelf($, then) },
      startFresh: path => startFresh($, path),
      exitNow: () => {
        exitApproved = true
        runLater($, 'exit')
      },
      later: tokens => {
        snoozedAt = tokens
        void update($, band, () => null)
      },
      dismiss: () => { void update($, band, () => null) },
    })
  })
hooks/lib/views.tsx 112〜160 行 · バンド
export const bandView = (el: ElementTable, offer: Band, act: BandActions) => {
  const { Box, Button, Text } = el

  if (offer.kind === 'working') return <Text dimColor>⧉ {offer.text}</Text>

  if (offer.kind === 'handedOff') {
    return (
      <Box flexDirection="column">
        <Text color="green" wrap="truncate-end">⧉ Handoff written: {basename(offer.path)}</Text>
        <Box>
          <Button key="fresh" label="Start fresh from it" hotkey="f" variant="primary" onPress={() => act.startFresh(offer.path)} />
          <Text> </Text>
          <Button key="keep" label="Keep going here" hotkey="k" onPress={act.dismiss} />
        </Box>
      </Box>
    )
  }

  if (offer.kind === 'exit') {
    const why = offer.value === 'active' ? 'is still in progress' : `holds ${tokensText(offer.tokens)} tokens`
    return (
      <Box flexDirection="column">
        <Text color="yellow" wrap="truncate-end">⧉ Before you go: this session {why}. A handoff keeps it for next time.</Text>
        <Box>
          <Button key="handoff-exit" label="Hand off and exit" hotkey="h" variant="primary" onPress={() => act.handOff('exit')} />
          <Text> </Text>
          <Button key="exit-now" label="Exit now" hotkey="e" onPress={act.exitNow} />
          <Text> </Text>
          <Button key="stay" label="Stay" hotkey="s" onPress={act.dismiss} />
        </Box>
      </Box>
    )
  }

  return (
    <Box flexDirection="column">
      <Text color="yellow" wrap="truncate-end">
        ⧉ This session is carrying {tokensText(offer.tokens)} tokens. A handoff lets a fresh session continue from about 3k.
      </Text>
      <Box>
        <Button key="handoff-fresh" label="Hand off and start fresh" hotkey="h" variant="primary" onPress={() => act.handOff('fresh')} />
        <Text> </Text>
        <Button key="handoff-only" label="Just write it" hotkey="w" onPress={() => act.handOff(null)} />
        <Text> </Text>
        <Button key="later" label="Later" hotkey="l" onPress={() => act.later(offer.tokens)} />
      </Box>
    </Box>
  )
}
hooks/register.tsx 692〜706 行 · ペイン
  on('ui.render', { component: 'Pane', requestId: PANE }, async ($, e) => {
    const [snap, picked, closing] = await Promise.all([read($, snapshot), read($, selected), read($, pendingClose)])
    return paneView(
      $.ui.resolve(e),
      { snap, picked, closing, columns: e.props.bodyColumns, rows: e.viewport?.rows ?? 24 },
      {
        select: key => { void update($, selected, () => key) },
        handoff: () => { void handoffSelected($) },
        save: () => { void saveSelected($) },
        close: () => { void closeSelected($) },
        copy: press => { void copyResume($, press.surface) },
        refresh: () => { void scan($, true) },
      },
    )
  })
hooks/lib/views.tsx 30〜102 行 · ペイン
export const paneView = (el: ElementTable, view: PaneView, act: PaneActions) => {
  const { Box, Button, Text } = el
  const { snap, picked, closing } = view
  if (!snap) return <Text dimColor>Scanning…</Text>

  const now = snap.scannedAt
  const counts = windowCounts(snap.rows)
  const hasGit = snap.rows.some(r => r.git)
  const [headline, details] = summaryParts(snap)
  const ctxW = 10
  const projW = Math.max(8, Math.min(20, Math.floor(view.columns * 0.16)))
  const gitW = hasGit ? Math.max(6, Math.min(22, Math.floor(view.columns * 0.2))) : 0
  const nameW = Math.max(10, view.columns - 4 - 9 - projW - gitW - 5 - ctxW - 5)
  const room = Math.max(1, view.rows - 7)

  return (
    <Box flexDirection="column">
      {snap.warning ? <Text color="red" wrap="wrap">⚠ {snap.warning}</Text> : null}
      <Text bold wrap="truncate-end">{headline}</Text>
      {details ? <Text dimColor wrap="truncate-end">{details}</Text> : null}
      <Text> </Text>
      {snap.rows.slice(0, room).map((r, i) => {
        const isPicked = r.key === picked
        const stale = r.pid !== null && isStale(r, now)
        const color = r.status === 'busy' ? 'yellow' : needsYou(r.status) && r.pid !== null ? 'red' : undefined
        const cold = r.tokens !== null && isCold(r, now)
        return (
          <Box key={r.key}>
            <Button
              key={`row:${r.key}`}
              plain
              label={isPicked ? '▸' : r.isSelf ? '•' : ' '}
              autoFocus={i === 0 && picked === null ? true : undefined}
              onPress={() => act.select(r.key)}
            />
            <Text color={r.value ? VALUE_COLOR[r.value] : undefined} dimColor={r.value === 'light'}>{` ${glyph(r)} `}</Text>
            {r.key === closing ? (
              <Text color="red" bold wrap="truncate-end">{fit(`x to close: ${label(r)}`, nameW)} </Text>
            ) : (
              <Text bold={r.isSelf || isPicked} inverse={isPicked} color={r.isSelf ? 'cyan' : undefined} dimColor={stale && !isPicked} wrap="truncate-end">
                {fitLabel(r, counts, nameW)}
              </Text>
            )}
            <Text> </Text>
            <Text color={color} dimColor={!color}>{fit(r.status, 9)}</Text>
            <Text dimColor={stale}>{fit(basename(r.cwd), projW)} </Text>
            {hasGit ? (
              <Text color={r.git?.dirty ? 'magenta' : undefined} dimColor={!r.git || stale}>{fit(gitText(r.git), gitW)}</Text>
            ) : null}
            <Text dimColor>{(r.pid === null ? '' : ago(now - r.updatedAt)).padStart(4)} </Text>
            <Text color={cold && (r.tokens ?? 0) >= 500_000 ? 'red' : cold ? 'blue' : undefined} dimColor={!cold}>
              {ctxText(r, now).padStart(ctxW)}
            </Text>
          </Box>
        )
      })}
      {snap.rows.length > room ? <Text dimColor>  +{snap.rows.length - room} more (/fleet list)</Text> : null}
      <Text> </Text>
      <Box>
        <Button key="handoff" label="Handoff" hotkey="h" onPress={act.handoff} />
        <Text> </Text>
        <Button key="save" label="Save" hotkey="s" onPress={act.save} />
        <Text> </Text>
        <Button key="close" label="Close" hotkey="x" onPress={act.close} />
        <Text> </Text>
        <Button key="copy" label="Copy resume" hotkey="c" onPress={act.copy} />
        <Text> </Text>
        <Button key="refresh" label="Refresh" hotkey="r" onPress={act.refresh} />
      </Box>
      <Text dimColor wrap="truncate-end">● in progress  ◐ finished: hand off  ○ light · ctx = tokens a resume re-caches · cold = cache expired</Text>
    </Box>
  )
}
ライセンスの全文(MIT)
MIT License

Copyright (c) 2026 Adarsh Muralidharan

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

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

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

入れる

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

リポジトリの .claude-plugin/marketplace.json にこの Mod が載っていないため、入れる手順は出せません。コードとして読むか、作者の README に従ってください。

Claude に聞く

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

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

Claude から探す: MCP コネクタ

似たデザイン