modscode EN

modscode / 図鑑 / painel-vivo

painel-vivo

Painel com o que está rodando: saída ao vivo, porcentagem, subagentes, contexto e cota, registro da sessão, explicação para leigo e glossário

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

何をするか

  • 欄を描く
  • /painel・/glossario を足す
  • ツールの呼び出しを見張る
  • agent.spawn・session.measure・session.start・turn.complete ほか 1 個にフックする
  • ターンをまたいで自分の状態を持つ

良いところ

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

作り始めるためのコード

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

雛形(register.tsx)

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

// Drawn like painel-vivo by Marcelo Diego (pane), as modscode read it from the mod's code:
// https://modscode.com/gallery/diegocamara89-painel-vivo/
// 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: "Em execução" })
  on('ui.render', { component: 'Pane', requestId: 'my-pane' }, async ($, e) => {
    const { Box, Text, Button, Markdown } = $.ui.resolve(e)
    const length = '…'
    const calados = '…'
    const modeloCurto = '…'
    const esforcoTxt = '…'
    const titulo = '…'
    const sinal = '…'
    const agoraTxt = '…'
    const barra = '…'
    const bolinhas = '…'
    const passos = '…'
    const tempo = '…'
    const cauda = '…'
    const sinal2 = '…'
    const agoraTxt2 = '…'
    const barra2 = '…'
    const bolinhas2 = '…'
    const tempo2 = '…'
    const cauda2 = '…'
    const sinal3 = '…'
    const agoraTxt3 = '…'
    const barra3 = '…'
    const bolinhas3 = '…'
    const tempo3 = '…'
    const cauda3 = '…'
    const desc = '…'
    const tool = '…'
    const cmd = '…'
    const l = '…'
    const explicacao = '…'
    const hora = '…'
    const split = '…'
    const hora2 = '…'
    const split2 = '…'
    const hora3 = '…'
    const split3 = '…'
    const n = '…'
    const agVivos = '…'
    const agTotal = '…'
    const barra4 = '…'
    const mil = '…'
    const cota5h = '…'
    const semana = '…'
    return (
      <Box flexDirection="column">
        <Box flexDirection="row" justifyContent="space-between">
          <Text>
            <Text bold>
              {length}
            </Text>
            {" trabalhando"}
            <Text color="yellow">
              {`  ·  ${calados} calado`}
            </Text>
            <Text color="red">
              {`  ·  ${length} erros para ver`}
            </Text>
            <Text dimColor>
              {`  ·  ${length} ações`}
            </Text>
          </Text>
          <Button plain label={`Glossário (${length})`} />
        </Box>
        <Text>
          <Text bold color="blue">
            {modeloCurto}
          </Text>
          <Text dimColor>
            {" · principal"}
          </Text>
          <Text dimColor>
            {"  ·  esforço "}
            <Text color="yellow">
              {esforcoTxt}
            </Text>
          </Text>
        </Text>
        <Text dimColor>
          <Text color="blue">
            ■
          </Text>
          {" subagente  "}
          <Text color="gray">
            ■
          </Text>
          {" comando  "}
          <Text color="magenta">
            ■
          </Text>
          {" agy  "}
          <Text color="cyan">
            ■
          </Text>
          {" Codex  "}
          <Text color="green">
            ■
          </Text>
          {" feito  "}
          <Text color="red">
            ■
          </Text>
          {" falhou"}
        </Text>
        <Text dimColor>
          Ninguém trabalhando agora.
        </Text>
        <Box flexDirection="row" flexWrap="wrap" columnGap={1}>
          <Box flexDirection="column" borderStyle="round" paddingX={1}>
            <Box flexDirection="row" justifyContent="space-between">
              <Button plain label={`${titulo}`} />
              <Text>
                {sinal}
              </Text>
            </Box>
            <Text dimColor>
              {`esforço ${esforcoTxt}`}
            </Text>
            <Text bold wrap="truncate-end">
              {agoraTxt}
            </Text>
            <Text color="cyan">
              {barra}
            </Text>
            <Text wrap="truncate-end">
              {bolinhas}
              <Text dimColor>
                {`  ${passos} passos · ${tempo}`}
              </Text>
            </Text>
            <Text dimColor>
              {tempo}
            </Text>
            <Text dimColor wrap="truncate-end">
              {cauda}
            </Text>
          </Box>
          <Box flexDirection="column" borderStyle="round" paddingX={1}>
            <Box flexDirection="row" justifyContent="space-between">
              <Button plain label={`${titulo}`} />
              <Text>
                {sinal2}
              </Text>
            </Box>
            <Text dimColor>
              {`esforço ${esforcoTxt}`}
            </Text>
            <Text bold wrap="truncate-end">
              {agoraTxt2}
            </Text>
            <Text color="cyan">
              {barra2}
            </Text>
            <Text wrap="truncate-end">
              {bolinhas2}
              <Text dimColor>
                {`  ${passos} passos · ${tempo}`}
              </Text>
            </Text>
            <Text dimColor>
              {tempo2}
            </Text>
            <Text dimColor wrap="truncate-end">
              {cauda2}
            </Text>
          </Box>
          <Box flexDirection="column" borderStyle="round" paddingX={1}>
            <Box flexDirection="row" justifyContent="space-between">
              <Button plain label={`${titulo}`} />
              <Text>
                {sinal3}
              </Text>
            </Box>
            <Text dimColor>
              {`esforço ${esforcoTxt}`}
            </Text>
            <Text bold wrap="truncate-end">
              {agoraTxt3}
            </Text>
            <Text color="cyan">
              {barra3}
            </Text>
            <Text wrap="truncate-end">
              {bolinhas3}
              <Text dimColor>
                {`  ${passos} passos · ${tempo}`}
              </Text>
            </Text>
            <Text dimColor>
              {tempo3}
            </Text>
            <Text dimColor wrap="truncate-end">
              {cauda3}
            </Text>
          </Box>
        </Box>
        <Box flexDirection="column" borderStyle="round" borderColor="blue" paddingX={1} marginTop={1}>
          <Box flexDirection="row" justifyContent="space-between">
            <Text bold wrap="truncate-end">
              {desc}
            </Text>
            <Button plain label="fechar" />
          </Box>
          <Text dimColor wrap="truncate-end">
            {`${tool}: ${cmd}`}
          </Text>
          <Text wrap="truncate-end">
            {`  ▶ ${desc} · ${tempo}`}
          </Text>
          <Text wrap="truncate-end">
            {`  ▶ ${desc} · ${tempo}`}
          </Text>
          <Text wrap="truncate-end">
            {`  ▶ ${desc} · ${tempo}`}
          </Text>
          <Text dimColor wrap="truncate-end">
            {`  ${l}`}
          </Text>
          <Text dimColor wrap="truncate-end">
            {`  ${l}`}
          </Text>
          <Text dimColor wrap="truncate-end">
            {`  ${l}`}
          </Text>
          <Text dimColor>
            explicando…
          </Text>
          <Markdown text={`${explicacao}`} />
        </Box>
        <Box flexDirection="row" columnGap={2}>
          <Text color="red">
            Para ver
          </Text>
          <Button plain label="dispensar todos" />
        </Box>
        <Box flexDirection="row" flexWrap="wrap" columnGap={2}>
          <Button plain label={`✕ ${titulo} · ${tempo}`} />
          <Button plain label={`✕ ${titulo} · ${tempo}`} />
          <Button plain label={`✕ ${titulo} · ${tempo}`} />
        </Box>
        <Box flexDirection="column" borderStyle="round" borderColor="gray" paddingX={1}>
          <Text dimColor>
            registro da sessão
          </Text>
          <Box flexDirection="row" columnGap={1}>
            <Text dimColor>
              {hora}
            </Text>
            <Text color="red" wrap="truncate-end">
              {split}
            </Text>
            <Button plain label={`${desc} · começou`} />
          </Box>
          <Box flexDirection="row" columnGap={1}>
            <Text dimColor>
              {hora2}
            </Text>
            <Text color="red" wrap="truncate-end">
              {split2}
            </Text>
            <Button plain label={`${desc} · começou`} />
          </Box>
          <Box flexDirection="row" columnGap={1}>
            <Text dimColor>
              {hora3}
            </Text>
            <Text color="red" wrap="truncate-end">
              {split3}
            </Text>
            <Button plain label={`${desc} · começou`} />
          </Box>
        </Box>
        <Button plain label={`▾ Histórico (${length})`} />
        <Text dimColor>
          {`  ✓ ${n} leituras, buscas e edições`}
        </Text>
        <Text dimColor>
          {`  ✓ ${n} leituras, buscas e edições`}
        </Text>
        <Text dimColor>
          {`  ✓ ${n} leituras, buscas e edições`}
        </Text>
        <Text>
          <Text dimColor>
            {"subagentes "}
          </Text>
          <Text color="blue">
            {`[${agVivos}/${agTotal}]`}
          </Text>
          <Text dimColor>
            {"   contexto "}
            <Text>
              {barra4}
            </Text>
            {`  ${mil} de ${mil}`}
          </Text>
          <Text dimColor>
            {"   cota 5h "}
            <Text>
              {`${cota5h}%`}
            </Text>
          </Text>
          <Text dimColor>
            {"   semana "}
            <Text>
              {`${semana}%`}
            </Text>
          </Text>
        </Text>
      </Box>
    )
  })
}

Mod 自身のコード

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

mods/painel-vivo/hooks/register.tsx 393〜552 行 · ペイン
  on('ui.render', { component: 'Pane', requestId: PANE }, async ($, e) => {
    const { Box, Text, Button, Markdown } = $.ui.resolve(e)
    const lista = await read($, chamadas)
    const sel = await read($, aberta)
    const vg = await read($, verGlossario)
    const glos = await read($, glossario)
    const ctx = await read($, contexto)
    const pri = await read($, principal)
    const agentesM = await read($, agentes)
    const vistosL = await read($, vistos)
    const histAberto = await read($, historicoAberto)
    const agora = await $.clock.now()

    if (vg) {
      return (
        <Box flexDirection="column">
          <Button plain label="← voltar" onPress={() => update($, verGlossario, () => false)} />
          <Text bold>Glossário ({glos.length} termos)</Text>
          {glos.length === 0 && <Text dimColor>Vazio. Abra uma tarefa e use "Explicar isto".</Text>}
          {glos.map(t => (
            <Text>
              <Text bold>{t.termo}</Text>: {t.definicao}
            </Text>
          ))}
        </Box>
      )
    }

    const ids = new Set(lista.map(c => c.id))
    const filhos = new Map<string, Chamada[]>()
    for (const c of lista) if (c.pai && ids.has(c.pai)) filhos.set(c.pai, [...(filhos.get(c.pai) ?? []), c])
    const topo = lista.filter(c => !c.pai || !ids.has(c.pai))
    const vistosS = new Set(vistosL)
    const vida = (c: Chamada) =>
      Math.max(c.ultimaSaida ?? 0, c.inicio, ...(filhos.get(c.id) ?? []).map(f => Math.max(f.fim ?? 0, f.ultimaSaida ?? 0, f.inicio)))

    const dura = (c: Chamada) => (c.fim ?? agora) - c.inicio
    const importante = (c: Chamada) =>
      c.tool === 'Agent' || c.rotulo === 'agy' || c.rotulo === 'Codex' || (c.tool === 'Bash' && dura(c) >= MESA_MS)
    const naMesa = (c: Chamada) => importante(c) && (c.fim === undefined || agora - c.fim < FICA_MS)
    const paraVer = topo.filter(c => c.erro && !vistosS.has(c.id))
    const mesas = topo.filter(c => naMesa(c) && !(c.erro && !vistosS.has(c.id)))
    const recentes = topo.filter(c => c.fim !== undefined && importante(c) && !naMesa(c) && !(c.erro && !vistosS.has(c.id))).slice(-5).reverse()
    const noRecente = new Set([...recentes, ...mesas, ...paraVer].map(c => c.id))
    const antigos = topo.filter(c => c.fim !== undefined && !noRecente.has(c.id)).reverse()

    const trabalhando = topo.filter(c => c.fim === undefined && importante(c))
    const calados = trabalhando.filter(c => agora - vida(c) >= 10_000).length

    const abrir = (c: Chamada) => async () => {
      if (c.erro) await update($, vistos, v => (v.includes(c.id) ? v : [...v, c.id].slice(-200)))
      await update($, aberta, v => (v === c.id ? '' : c.id))
    }

    const cartao = (c: Chamada, largura: string) => {
      const vivo = c.fim === undefined
      const calado = vivo ? agora - vida(c) : 0
      const sinal = !vivo ? (c.erro ? '✕ erro' : '✓ feito') : calado < 10_000 ? 'ativo' : `calado ${tempo(calado)}`
      const corSinal = !vivo ? (c.erro ? 'red' : 'green') : calado < 10_000 ? 'green' : calado < 60_000 ? 'yellow' : 'red'
      const borda = c.erro ? 'red' : !vivo ? 'green' : calado >= 10_000 ? corSinal : corDe(c)
      const ag = c.tool === 'Agent' ? Object.values(agentesM).find(a => a.pai === c.id) : undefined
      const fs = filhos.get(c.id) ?? []
      const g = (c.agys ?? []).slice(-1)[0]
      const passos = g ? g.passos : fs.filter(f => !INTERNAS.has(f.tool)).length
      const uteis = fs.filter(f => !INTERNAS.has(f.tool))
      const filhoVivo = uteis.filter(f => f.fim === undefined).slice(-1)[0] ?? (vivo ? uteis.slice(-1)[0] : undefined)
      const agoraTxt = g && !g.fim ? traduzir(g.agora)
        : filhoVivo ? fazendo(filhoVivo)
        : c.tool === 'Agent' && vivo ? 'pensando'
        : c.rotulo === 'Codex' ? (c.cauda ?? []).filter(l => l.startsWith('[codex]')).slice(-1)[0]?.replace('[codex] ', '') ?? c.desc
        : c.desc
      return (
        <Box flexDirection="column" width={largura} borderStyle="round" borderColor={borda} paddingX={1}>
          <Box flexDirection="row" justifyContent="space-between">
            <Button plain label={titulo(c, g)} onPress={abrir(c)} />
            <Text color={corSinal}>{sinal}</Text>
          </Box>
          {ag?.esforco && <Text dimColor>{`esforço ${esforcoTxt(ag.esforco)}`}</Text>}
          <Text bold wrap="truncate-end">{agoraTxt}</Text>
          {c.pct !== undefined && vivo && <Text color="cyan">{barra(c.pct)}</Text>}
          {passos > 0 && <Text wrap="truncate-end">{bolinhas(passos, vivo)}<Text dimColor>{`  ${passos} passos · ${tempo(dura(c))}`}</Text></Text>}
          {passos === 0 && <Text dimColor>{tempo(dura(c))}</Text>}
          {c.pct === undefined && vivo && (c.cauda ?? []).length > 0 && (
            <Text dimColor wrap="truncate-end">{(c.cauda ?? []).slice(-1)[0]}</Text>
          )}
        </Box>
      )
    }

    const etiqueta = (c: Chamada, _cor?: string) => (
      <Button plain label={`${c.erro ? '✕' : '✓'} ${titulo(c, (c.agys ?? []).slice(-1)[0])} · ${tempo(dura(c))}`} onPress={abrir(c)} />
    )

    const detalhe = (c: Chamada) => {
      const fs = filhos.get(c.id) ?? []
      return (
        <Box flexDirection="column" borderStyle="round" borderColor="blue" paddingX={1} marginTop={1}>
          <Box flexDirection="row" justifyContent="space-between">
            <Text bold wrap="truncate-end">{c.desc}</Text>
            <Button plain label="fechar" onPress={() => update($, aberta, () => '')} />
          </Box>
          <Text dimColor wrap="truncate-end">{`${c.tool}: ${c.cmd}`}</Text>
          {fs.slice(-8).map(f => (
            <Text dimColor={f.fim !== undefined} wrap="truncate-end">{`  ${f.fim === undefined ? '▶' : f.erro ? '✕' : '✓'} ${f.desc} · ${tempo(dura(f))}`}</Text>
          ))}
          {(c.cauda ?? []).slice(-12).map(l => <Text dimColor wrap="truncate-end">{`  ${l}`}</Text>)}
          {!c.explicacao && (c.explicando
            ? <Text dimColor>explicando…</Text>
            : <Button label="Explicar isto" onPress={() => void explicar($, c.id)} />)}
          {c.explicacao && <Markdown text={c.explicacao} />}
        </Box>
      )
    }

    // Registro: cada trabalho importante entra na hora em que começou ou terminou; os 6 mais novos.
    const registro = topo.filter(importante)
      .map(c => ({ c, t: c.fim ?? c.inicio }))
      .sort((a, b) => a.t - b.t)
      .slice(-6)
    const agentesTopo = topo.filter(c => c.tool === 'Agent')
    const agVivos = agentesTopo.filter(c => c.fim === undefined).length
    const agTotal = agentesTopo.length
    const tom = (p: number) => (p >= 85 ? 'red' : p >= 70 ? 'yellow' : 'green')

    const selC = sel ? lista.find(c => c.id === sel) : undefined
    const largura = (e.props as any)?.bodyColumns ?? e.viewport?.columns ?? 80
    const duas = largura >= 70

    return (
      <Box flexDirection="column">
        <Box flexDirection="row" justifyContent="space-between">
          <Text>
            <Text bold>{trabalhando.length}</Text> trabalhando
            {calados > 0 && <Text color="yellow">{`  ·  ${calados} calado`}</Text>}
            {paraVer.length > 0 && <Text color="red">{`  ·  ${paraVer.length} ${paraVer.length > 1 ? 'erros' : 'erro'} para ver`}</Text>}
            <Text dimColor>{`  ·  ${lista.length} ações`}</Text>
          </Text>
          <Button plain label={`Glossário (${glos.length})`} onPress={() => update($, verGlossario, () => true)} />
        </Box>
        {pri.modelo && (
          <Text>
            <Text bold color="blue">{modeloCurto(pri.modelo)}</Text>
            <Text dimColor>{' · principal'}</Text>
            {pri.esforco && <Text dimColor>{`  ·  esforço `}<Text color="yellow">{esforcoTxt(pri.esforco)}</Text></Text>}
          </Text>
        )}
        <Text dimColor>
          <Text color="blue">■</Text>{' subagente  '}<Text color="gray">■</Text>{' comando  '}<Text color="magenta">■</Text>{' agy  '}
          <Text color="cyan">■</Text>{' Codex  '}<Text color="green">■</Text>{' feito  '}<Text color="red">■</Text>{' falhou'}
        </Text>

        {mesas.length === 0 && <Text dimColor>Ninguém trabalhando agora.</Text>}
        <Box flexDirection="row" flexWrap="wrap" columnGap={1}>
          {mesas.slice(-6).map(c => cartao(c, duas ? '49%' : '100%'))}
        </Box>

        {selC && detalhe(selC)}

        {paraVer.length > 0 && (
          <Box flexDirection="row" columnGap={2}>
ライセンスの全文(MIT)
MIT License

Copyright (c) 2026 Marcelo Diego

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

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

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

入れる

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

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

/plugin marketplace add diegocamara89/claude-mods
/plugin install painel-vivo@claude-mods-diego

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

Claude に聞く

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

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

Claude から探す: MCP コネクタ

似たデザイン