modscode EN

modscode / 図鑑 / bullswarm

bullswarm

Bullswarm as a Claude Mod: live subscription meters for every installed coding-agent CLI above the prompt, quota-aware routing of Claude's own subagents to whichever pool has surplus, a verdict note on every bullswarm command the model run…

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

何をするか

  • プロンプトの上の帯・トーストを描く
  • Agent・Bash の呼び出しを見張る
  • engine.create・prompt.context・session.start・ui.close ほか 1 個にフックする
  • ターンをまたいで自分の状態を持つ
  • プロセスを起こす

良いところ

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

作り始めるためのコード

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

雛形(register.tsx)

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

// Drawn like bullswarm by cowcow02 (pane, band, status, toast), as modscode read it from the mod's code:
// https://modscode.com/gallery/bulls-work-bullswarm/
// 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 summary = '…'
    const lastError = '…'
    const name = '…'
    const used = '…'
    const elapsed = '…'
    const running = '…'
    const name2 = '…'
    const used2 = '…'
    const elapsed2 = '…'
    const running2 = '…'
    const name3 = '…'
    const used3 = '…'
    const elapsed3 = '…'
    const running3 = '…'
    const i = '…'
    const shortId = '…'
    const done = '…'
    const runStatusText = '…'
    const goal = '…'
    const done2 = '…'
    const runStatusText2 = '…'
    const goal2 = '…'
    const done3 = '…'
    const runStatusText3 = '…'
    const goal3 = '…'
    const lane = '…'
    const nameOf = '…'
    const timingOf = '…'
    const source = '…'
    const lane2 = '…'
    const nameOf2 = '…'
    const lane3 = '…'
    const nameOf3 = '…'
    return (
      <Box flexDirection="column">
        <Box flexDirection="row" flexWrap="nowrap" gap={1} marginRight={4}>
          <Box flexShrink={1} overflow="hidden">
            <Text wrap="truncate-end">
              <Text bold color="magenta">
                bullswarm
              </Text>
              <Text dimColor>
                {" "}
                {summary}
                {" · used/elapsed · pace"}
              </Text>
            </Text>
          </Box>
          <Box flexShrink={0} flexDirection="row" gap={1}>
            <Button hotkey="w" label="[w] close" />
          </Box>
        </Box>
        <Text color="red" wrap="truncate-end">
          {lastError}
        </Text>
        <Box flexDirection="row">
          <Text wrap="truncate-end">
            <Text>
              {name}
            </Text>
            <Text backgroundColor="#3a3a3a">
              ········
            </Text>
            <Text>
              {" "}
              {used}
            </Text>
            <Text dimColor>
              {elapsed}
            </Text>
            <Text bold>
              {"  "}
              quarantined
            </Text>
            <Text color="cyan">
              {running}
            </Text>
          </Text>
        </Box>
        <Box flexDirection="row">
          <Text wrap="truncate-end">
            <Text>
              {name2}
            </Text>
            <Text backgroundColor="#3a3a3a">
              ········
            </Text>
            <Text>
              {" "}
              {used2}
            </Text>
            <Text dimColor>
              {elapsed2}
            </Text>
            <Text bold>
              {"  "}
              quarantined
            </Text>
            <Text color="cyan">
              {running2}
            </Text>
          </Text>
        </Box>
        <Box flexDirection="row">
          <Text wrap="truncate-end">
            <Text>
              {name3}
            </Text>
            <Text backgroundColor="#3a3a3a">
              ········
            </Text>
            <Text>
              {" "}
              {used3}
            </Text>
            <Text dimColor>
              {elapsed3}
            </Text>
            <Text bold>
              {"  "}
              quarantined
            </Text>
            <Text color="cyan">
              {running3}
            </Text>
          </Text>
        </Box>
        <Box flexDirection="row">
          <Button plain hotkey={`${i}`} label={`⧖ ${shortId}`} />
          <Text wrap="truncate-end">
            <Text color="magenta">
              {" ●"}
            </Text>
            <Text color="green">
              {"  "}
              {done}
            </Text>
            <Text color="yellow">
              {" "}
              {runStatusText}
            </Text>
            <Text color="cyan">
              {`  ${running}`}
            </Text>
            <Text dimColor>
              {" "}
              {goal}
            </Text>
          </Text>
        </Box>
        <Box flexDirection="row">
          <Button plain hotkey={`${i}`} label={`⧖ ${shortId}`} />
          <Text wrap="truncate-end">
            <Text color="magenta">
              {" ●"}
            </Text>
            <Text color="green">
              {"  "}
              {done2}
            </Text>
            <Text color="yellow">
              {" "}
              {runStatusText2}
            </Text>
            <Text color="cyan">
              {`  ${running}`}
            </Text>
            <Text dimColor>
              {" "}
              {goal2}
            </Text>
          </Text>
        </Box>
        <Box flexDirection="row">
          <Button plain hotkey={`${i}`} label={`⧖ ${shortId}`} />
          <Text wrap="truncate-end">
            <Text color="magenta">
              {" ●"}
            </Text>
            <Text color="green">
              {"  "}
              {done3}
            </Text>
            <Text color="yellow">
              {" "}
              {runStatusText3}
            </Text>
            <Text color="cyan">
              {`  ${running}`}
            </Text>
            <Text dimColor>
              {" "}
              {goal3}
            </Text>
          </Text>
        </Box>
        <Box flexDirection="row">
          <Text wrap="truncate-end">
            <Text color="cyan" bold>
              ▶ run
            </Text>
            <Text>
              {"  "}
              {lane}
              @
              {nameOf}
            </Text>
            <Text dimColor>
              {`  ${timingOf}`}
              {`  ${source}`}
            </Text>
          </Text>
        </Box>
        <Box flexDirection="row">
          <Text wrap="truncate-end">
            <Text color="cyan" bold>
              ▶ run
            </Text>
            <Text>
              {"  "}
              {lane2}
              @
              {nameOf2}
            </Text>
            <Text dimColor>
              {`  ${timingOf}`}
              {`  ${source}`}
            </Text>
          </Text>
        </Box>
        <Box flexDirection="row">
          <Text wrap="truncate-end">
            <Text color="cyan" bold>
              ▶ run
            </Text>
            <Text>
              {"  "}
              {lane3}
              @
              {nameOf3}
            </Text>
            <Text dimColor>
              {`  ${timingOf}`}
              {`  ${source}`}
            </Text>
          </Text>
        </Box>
        {await next(e)}
      </Box>
    )
  })

  on('session.start', async ($, e, next) => {
    const description = '…'
    const pool = '…'
    await $.ui.toast(`bullswarm routed "${description}" to ${pool}`)
    return next(e)
  })
}

Mod 自身のコード

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

mods/bullswarm/hooks/register.ts 841〜873 行 · バンド
  on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
    if (stripLevel === 'off' || e.surface === 'mobile' || e.props.hasSurvey || pools.length === 0)
      return next(e)

    const { Box, Text, Button } = await $.ui.resolve(e)
    const h = host

    return strip(
      { ui: { Box, Text, Button }, columns: e.props.bodyColumns, maxRows: e.props.maxRows },
      {
        pools,
        runs,
        assignments,
        autoRoute,
        routedCount: routed.length,
        lastError,
        paneOpen,
        selectedShortId,
        names,
        level: stripLevel,
      },
      {
        pane: () => {
          if (!h) return
          void (paneOpen ? closePane(h) : openPane(h, null))
        },
        open: shortId => {
          if (!h) return
          void (paneOpen && selectedShortId === shortId ? closePane(h) : openPane(h, shortId))
        },
      },
    )
  })
mods/bullswarm/hooks/strip.tsx 43〜148 行 · バンド
export function strip(
  kit: { ui: StripUi; columns: number; maxRows: number },
  model: StripModel,
  actions: StripActions,
): RenderElement {
  const { Box, Text, Button } = kit.ui
  const budget = Math.max(1, kit.maxRows - 1)
  const pools = model.level === 'full' ? model.pools.filter(p => p.enabled).slice(0, budget) : []
  const loose = looseOf(model.runs, model.assignments)
  const runRows = Math.max(0, budget - pools.length)
  const runs = model.runs.slice(0, runRows)
  const looseShown = loose.slice(0, Math.max(0, runRows - runs.length))
  const nameOf = (pool: string) => model.names.get(pool) ?? pool

  const summary = [
    model.runs.length ? `${model.runs.length} run${model.runs.length === 1 ? '' : 's'}` : 'no runs',
    model.assignments.length ? `${model.assignments.length} in flight` : '',
    model.routedCount ? `${model.routedCount} routed` : '',
    model.autoRoute ? '' : 'route off',
  ]
    .filter(Boolean)
    .join(' · ')

  return (
    <Box flexDirection="column">
      <Box flexDirection="row" flexWrap="nowrap" gap={1} marginRight={4}>
        <Box flexShrink={1} overflow="hidden">
          <Text wrap="truncate-end">
            <Text bold color="magenta">
              bullswarm
            </Text>
            <Text dimColor> {summary}{model.level === 'full' ? ' · used/elapsed · pace' : ''}</Text>
          </Text>
        </Box>
        <Box flexShrink={0} flexDirection="row" gap={1}>
          <Button
            key="pane"
            hotkey="w"
            label={model.paneOpen ? '[w] close' : '[w] runs'}
            onPress={actions.pane}
          />
        </Box>
      </Box>
      {model.lastError ? (
        <Text color="red" wrap="truncate-end">
          {model.lastError}
        </Text>
      ) : null}
      {poolRows({ Box, Text }, pools, model.assignments, model.names)}
      {runs.map((run, i) => {
        const steps = stepsOf(run, model.assignments)
        const done = `${run.actionsSucceeded}/${run.actionsTotal}`
        // One step in flight is named; the rest are counted, so the goal
        // that says which run this is always stays on the row.
        const named = steps
          .slice(0, 1)
          .map(a => `${a.actionId ?? '?'}@${nameOf(a.pool)}${timingOf(a) ? ` ${timingOf(a)}` : ''}`)
          .join(', ')
        const running = steps.length > 1 ? `${named}, and ${String(steps.length - 1)} more` : named
        const finished = run.status !== 'running'
        // A parked v3 run waits for the caller at a gate or loop.
        const waiting = (run.waitingFor ?? []).length > 0
        const selected = model.selectedShortId === run.shortId && model.paneOpen

        return (
          <Box key={run.runId} flexDirection="row">
            <Button
              key={`open-${run.shortId}`}
              plain
              hotkey={i < 9 ? String(i + 1) : undefined}
              label={`${waiting ? '⧖' : finished ? '◼' : '▶'} ${run.shortId}`}
              onPress={() => actions.open(run.shortId)}
            />
            <Text wrap="truncate-end">
              <Text color="magenta">{selected ? ' ●' : ''}</Text>
              <Text color="green">
                {'  '}
                {done}
              </Text>
              {finished ? <Text color="yellow">  {runStatusText(run)}</Text> : null}
              <Text color="cyan">{running ? `  ${running}` : ''}</Text>
              <Text dimColor>  {run.goal}</Text>
            </Text>
          </Box>
        )
      })}
      {looseShown.map((a, i) => (
        <Box key={`loose-${String(i)}`} flexDirection="row">
          <Text wrap="truncate-end">
            <Text color="cyan" bold>
              ▶ run
            </Text>
            <Text>
              {'  '}
              {a.lane}@{nameOf(a.pool)}
            </Text>
            <Text dimColor>
              {timingOf(a) ? `  ${timingOf(a)}` : ''}
              {a.source ? `  ${a.source}` : ''}
            </Text>
          </Text>
        </Box>
      ))}
    </Box>
  )
}
mods/bullswarm/hooks/pool-rows.tsx 84〜116 行 · バンド
export function poolRows(
  ui: RowsUi,
  pools: readonly BullswarmPool[],
  assignments: readonly BullswarmAssignment[],
  names: ReadonlyMap<string, string>,
): RenderElement[] {
  const { Box, Text } = ui
  return pools
    .filter(p => p.enabled)
    .map(p => {
      const state = stateOf(p)
      const name = (names.get(p.name) ?? p.name).padEnd(NAME_WIDTH).slice(0, NAME_WIDTH)
      const used = p.usedPct === null ? '  —' : `${String(Math.round(p.usedPct)).padStart(3)}%`
      const elapsed = p.elapsedPct === null ? '' : `/${String(Math.round(p.elapsedPct)).padStart(2)}%`
      const busy = assignments.filter(a => a.pool === p.name)
      const running = busy.length ? `  ${busy.map(a => a.actionId ?? a.lane).join(', ')}` : ''
      return (
        <Box key={p.name} flexDirection="row">
          <Text wrap="truncate-end">
            <Text>{name}</Text>
            {meterBar(Text, p.usedPct, p.elapsedPct, BAR_WIDTH)}
            <Text> {used}</Text>
            <Text dimColor>{elapsed}</Text>
            <Text color={state.color} bold>
              {'  '}
              {p.quarantine ? 'quarantined' : paceText(p)}
            </Text>
            {running ? <Text color="cyan">{running}</Text> : null}
          </Text>
        </Box>
      )
    })
}
mods/bullswarm/hooks/pool-rows.tsx 30〜72 行 · バンド
export function meterBar(
  Text: RowsUi['Text'],
  usedPct: number | null,
  elapsedPct: number | null,
  width: number,
  key?: string,
): RenderElement {
  if (usedPct === null) return <Text key={key} backgroundColor={TRACK}>{'·'.repeat(width)}</Text>
  const fill = severityColor(usedPct)
  const filled = Math.max(0, Math.min(width, Math.floor((usedPct / 100) * width)))
  let mark = -1
  let glyph = '▏'
  if (elapsedPct !== null) {
    mark = Math.floor((elapsedPct / 100) * width)
    if (mark >= width) {
      mark = width - 1
      glyph = '▕'
    }
  }
  const cells: RenderElement[] = []
  let i = 0
  while (i < width) {
    const bg = i < filled ? fill : TRACK
    if (i === mark) {
      cells.push(
        <Text key={`m${String(i)}`} color="white" backgroundColor={bg}>
          {glyph}
        </Text>,
      )
      i += 1
      continue
    }
    let j = i
    while (j < width && j !== mark && (j < filled) === (i < filled)) j += 1
    cells.push(
      <Text key={`c${String(i)}`} backgroundColor={bg}>
        {' '.repeat(j - i)}
      </Text>,
    )
    i = j
  }
  return <Text key={key}>{cells}</Text>
}
ライセンスの全文(MIT)
MIT License

Copyright (c) 2026 bullswarm contributors

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

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

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

入れる

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

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

/plugin marketplace add Bulls-Work/bullswarm
/plugin install bullswarm@bullswarm

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

Claude に聞く

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

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

Claude から探す: MCP コネクタ

似たデザイン