modscode EN

modscode / 図鑑 / vome-esphome

vome-esphome

A side pane for ESPHome in Claude Code: a map of the device from its YAML (board, network, buses, entities, pins, triggers) with what a save changed lit up, and the build Claude is running as it happens (phase, progress, the latest output,…

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

何をするか

  • デスクトップアプリに欄を描く
  • /esphome を足す
  • ツールの呼び出しを見張る(止めることがある)
  • plugin.register・session.startにフックする
  • ターンをまたいで自分の状態を持つ

良いところ

  • ネットワークに出ない
  • プロセスを起こさない
  • TypeScript で書かれている
  • デスクトップ専用の分岐がある

作り始めるためのコード

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

雛形(register.tsx)

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

// Drawn like vome-esphome by Vortitron (pane), as modscode read it from the mod's code:
// https://modscode.com/gallery/vortitron-vome-esphome/
// 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: "ESPHome" })
  on('ui.render', { component: 'Pane', requestId: 'my-pane' }, async ($, e) => {
    const { Box, Text, Markdown, Code, Button } = $.ui.resolve(e)
    const verb = '…'
    const configuration = '…'
    const status = '…'
    const uploadPercent = '…'
    const error = '…'
    const line = '…'
    const line2 = '…'
    const line3 = '…'
    const name = '…'
    const configuration2 = '…'
    const deployed = '…'
    const current = '…'
    const name2 = '…'
    const configuration3 = '…'
    const name3 = '…'
    const configuration4 = '…'
    const allowLines = '…'
    return (
      <Box flexDirection="column">
        <Text bold wrap="truncate-end">
          {verb}
          {" "}
          {configuration}
        </Text>
        <Text color="success" wrap="truncate-end">
          {status}
        </Text>
        <Text color="suggestion">
          ████████░░░░░░░░
          {" "}
          {uploadPercent}
          %
        </Text>
        <Text dimColor wrap="truncate-end">
          {" "}
        </Text>
        <Text color="error" wrap="wrap">
          {error}
        </Text>
        <Box flexDirection="column">
          <Text wrap="truncate-end">
            {line}
          </Text>
          <Text wrap="truncate-end">
            {line2}
          </Text>
          <Text wrap="truncate-end">
            {line3}
          </Text>
        </Box>
        <Box flexDirection="column" marginTop={1}>
          <Text bold>
            Devices
          </Text>
          <Text wrap="truncate-end">
            <Text color="warning">
              {"↑ "}
            </Text>
            {name}
            <Text dimColor>
              {"  "}
              {configuration2}
              {`  ${deployed}`}
              {` → ${current} available`}
            </Text>
          </Text>
          <Text wrap="truncate-end">
            <Text color="warning">
              {"↑ "}
            </Text>
            {name2}
            <Text dimColor>
              {"  "}
              {configuration3}
              {`  ${deployed}`}
              {` → ${current} available`}
            </Text>
          </Text>
          <Text wrap="truncate-end">
            <Text color="warning">
              {"↑ "}
            </Text>
            {name3}
            <Text dimColor>
              {"  "}
              {configuration4}
              {`  ${deployed}`}
              {` → ${current} available`}
            </Text>
          </Text>
        </Box>
        <Box flexDirection="column" borderStyle="round" borderColor="warning" paddingX={1} marginTop={1}>
          <Text color="warning" wrap="wrap">
            {"Auto mode refused the pane's read of the build's progress or the device's YAML. Add these to permissions.allow in "}
            ~/.claude/settings.json
            , then the next build shows live:
          </Text>
          <Markdown text="[~/.claude/settings.json](file://~/.claude/settings.json)" />
          <Code source={`${allowLines}`} />
          <Box flexDirection="row" gap={2}>
            <Button hotkey="c">
              Copy the lines
            </Button>
            <Button hotkey="r">
              Retry
            </Button>
          </Box>
        </Box>
        <Box flexDirection="row" gap={2} marginTop={1}>
          <Text dimColor wrap="wrap">
            {"Working on automations too? The automation pane shows them, and their runs: "}
            <Text color="suggestion">
              /plugin install vome-automation --marketplace Vortitron/home-assistant-mcp
            </Text>
          </Text>
          <Button dimColor>
            Hide
          </Button>
        </Box>
        <Box marginTop={1} gap={2}>
          <Button hotkey="l" dimColor>
            Map and latest lines
          </Button>
          <Button hotkey="b" dimColor>
            Animation off
          </Button>
        </Box>
      </Box>
    )
  })
}

Mod 自身のコード

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

claude-plugin/vome-esphome/hooks/register.tsx 185〜344 行 · ペイン
  on('ui.render', { component: 'Pane', requestId: PANE }, async ($, e) => {
    const { Box, Text, Button, Code, Markdown } = $.ui.resolve(e)
    const current = (await $.state.get(build)).value ?? null
    const known = (await $.state.get(devices)).value ?? null
    const refusal = (await $.state.get(blocked)).value ?? null
    const isFxEnabled = (await $.state.get(fxOn)).value ?? true
    const view = (await $.state.get(config)).value ?? null
    const isFullLog = (await $.state.get(showLog)).value ?? false
    const siblingHint =
      !hasSibling && ((await $.state.get(sibling)).value ?? false) ? (
        <Box flexDirection="row" gap={2} marginTop={1}>
          <Text dimColor wrap="wrap">
            Working on automations too? The automation pane shows them, and their runs: <Text color="suggestion">{AUTOMATION_INSTALL}</Text>
          </Text>
          <Button
            key="hide-sibling"
            dimColor
            onPress={async () => {
              await $.store.set('siblingHintOff', true).catch(() => undefined)
              await $.state.set(sibling, false)
            }}
          >
            Hide
          </Button>
        </Box>
      ) : null
    const width = Math.max(20, e.props.bodyColumns)
    const rows = Math.max(6, (e.viewport?.rows ?? 30) - 14)

    const deviceRows = known && known.length > 0 ? (
      <Box flexDirection="column" marginTop={1}>
        <Text bold>Devices</Text>
        {known.map(d => {
          const isBehind = d.deployed !== null && d.current !== null && d.deployed !== d.current
          return (
            <Text wrap="truncate-end">
              <Text color={isBehind ? 'warning' : undefined}>{isBehind ? '↑ ' : '  '}</Text>
              {d.name}
              <Text dimColor>
                {'  '}
                {d.configuration}
                {d.deployed ? `  ${d.deployed}` : ''}
                {isBehind ? ` → ${d.current} available` : ''}
              </Text>
            </Text>
          )
        })}
      </Box>
    ) : null

    // Auto mode refuses a background read nobody asked for unless it is allowed by name.
    const help = refusal ? (
      <Box flexDirection="column" borderStyle="round" borderColor="warning" paddingX={1} marginTop={1}>
        <Text color="warning" wrap="wrap">
          Auto mode refused the pane's read of the build's progress or the device's YAML. Add these to permissions.allow
          in {settingsFile}, then the next build shows live:
        </Text>
        <Markdown text={`[${settingsFile}](file://${settingsFile})`} />
        <Code source={allowLines(refusal.server)} />
        <Box flexDirection="row" gap={2}>
          <Button key="copy-rule" hotkey="c" onPress={press => $.ui.copy({ text: allowLines(refusal.server), surface: press.surface })}>
            Copy the lines
          </Button>
          <Button
            key="retry"
            hotkey="r"
            onPress={async () => {
              // Allowed since? Try the reads again now rather than at the next build.
              await $.state.set(blocked, null)
              isUnsupported = false
              configAsked = null
              const running = (await $.state.get(build)).value ?? null
              if (running && running.command !== 'logs') void loadConfig($, refusal.server, running.configuration)
              void poll($)
            }}
          >
            Retry
          </Button>
        </Box>
      </Box>
    ) : null

    const map = view ? deviceMap($.ui.resolve(e), view) : null
    const isStage = e.surface === 'terminal' && isFxEnabled
    const things = view ? thingsOf(view) : []
    const stage = (state: Omit<ChipState, 'things' | 'hasWifi'>) => {
      if (e.surface !== 'terminal') return null
      const { Raster } = $.ui.resolve(e)
      const columns = Math.min(512, width)
      strip = { columns, state: { ...state, things, hasWifi: !!view?.rows.some(row => row.section === 'Network' && row.label === 'wifi') } }
      return <Raster key="chip" columns={columns} rows={STRIP_ROWS} cells={chipFrame(Date.now(), strip.state, columns)} />
    }

    if (!current) {
      if (!isStage) strip = null
      return (
        <Box flexDirection="column">
          {isStage
            ? stage({
                outcome: 'idle',
                scene: 'idle',
                percent: null,
                words: view ? `${view.name} · ${things.length || 'no'} thing${things.length === 1 ? '' : 's'} attached` : 'dreaming of devices…',
                endedAt: null,
              })
            : null}
          {map ?? (
            <Text dimColor wrap="wrap">
              Nothing building. When Claude reads, edits or builds an ESPHome device, its map shows here, and a build's
              progress as it runs.
            </Text>
          )}
          {deviceRows}
          {help}
          {siblingHint}
        </Box>
      )
    }

    const parsed = progressOf(current.lines, current.command)
    const progress = { ...parsed, uploadPercent: uploadShown(parsed, current) }
    const took = elapsed((current.finishedAt ?? Date.now()) - current.startedAt)
    const verb = { validate: 'Checking', compile: 'Compiling', upload: 'Flashing', logs: 'Logs from' }[current.command] ?? current.command
    const done = { validate: 'Valid', compile: 'Compiled', upload: 'Flashed', logs: 'Read the logs' }[current.command] ?? 'Done'
    const status =
      current.outcome === 'running'
        ? `${phaseWords(progress, current.command)} · ${took}`
        : current.outcome === 'ok'
          ? `✓ ${done} in ${took}`
          : `✗ Failed after ${took}`
    const isUploading = current.outcome === 'running' && progress.uploadPercent !== null
    const isCompiling = current.outcome === 'running' && !isUploading && progress.compilePercent !== null
    const kept = current.lines.filter(line => current.command === 'logs' || kindOf(line) !== 'debug')
    // The latest couple of lines unless asked for all; a failure keeps a few more, where it explains itself.
    const tail = isFullLog || current.command === 'logs' ? kept.slice(-rows) : kept.slice(current.outcome === 'failed' ? -6 : -LOG_LINES)

    // The chip on the bench: a Raster, which only the terminal draws. Not for a logs read.
    let chip = null
    if (isStage) {
      // The scene follows the build, not the command: a flash compiles first, then uploads.
      const isUploadPhase = current.command === 'upload' && (progress.uploadPercent !== null || progress.phase === 'uploading')
      const scene: Scene =
        current.command === 'logs' ? 'logs' : current.command === 'validate' ? 'validate' : isUploadPhase ? 'upload' : 'compile'
      const words =
        current.outcome === 'running'
          ? `${scene === 'upload' ? 'flashing' : scene === 'validate' ? 'checking' : scene === 'logs' ? 'listening to' : 'compiling'} ${current.configuration}${(scene === 'upload' ? progress.uploadPercent : progress.compilePercent) !== null && scene !== 'logs' ? ` · ${scene === 'upload' ? progress.uploadPercent : progress.compilePercent}%` : ''}`
          : current.outcome === 'ok'
            ? `✓ ${current.configuration} ${done.toLowerCase()}`
            : `✗ ${current.configuration} failed`
      chip = stage({
        outcome: current.outcome,
        scene,
        percent: scene === 'upload' ? progress.uploadPercent : progress.compilePercent,
        words,
        endedAt: current.finishedAt,
      })
    } else {
      strip = null
    }
ライセンスの全文(MIT)
MIT License

Copyright (c) 2026 Andrew Lyeklint Hancock (Vortitron)

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

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

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

入れる

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

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

/plugin marketplace add Vortitron/home-assistant-mcp
/plugin install vome-esphome@vome

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

Claude に聞く

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

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

Claude から探す: MCP コネクタ

似たデザイン