modscode EN

modscode / 図鑑 / vome-automation

vome-automation

A side pane for the Home Assistant automation Claude is working on: triggers, conditions and actions as HA's editor nests them, what a save changed, which steps the latest run took, and a car-stereo dot-matrix display that acts it out. Wor…

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

何をするか

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

良いところ

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

作り始めるためのコード

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

雛形(register.tsx)

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

// Drawn like vome-automation by Vortitron (pane, toast), as modscode read it from the mod's code:
// https://modscode.com/gallery/vortitron-vome-automation/
// 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: "Automation" })
  on('ui.render', { component: 'Pane', requestId: 'my-pane' }, async ($, e) => {
    const { Box, Text, Button, Link } = $.ui.resolve(e)
    const alias = '…'
    const filter = '…'
    const clock = '…'
    const added = '…'
    const changed = '…'
    const removed = '…'
    const clock2 = '…'
    const text = '…'
    const trigger = '…'
    const note = '…'
    const url = '…'
    const encodeURIComponent = '…'
    const length = '…'
    return (
      <Box flexDirection="column">
        <Box flexDirection="column">
          <Box flexDirection="column">
            <Text bold wrap="truncate-end">
              {alias}
            </Text>
            <Text dimColor wrap="truncate-end">
              {filter}
            </Text>
            <Text color="warning" wrap="truncate-end">
              {"Saved "}
              {clock}
              {` · ${added} added, ${changed} changed, ${removed} removed`}
            </Text>
            <Text wrap="truncate-end">
              <Text>
                {"Last run "}
                {clock2}
                {" · "}
                {text}
              </Text>
              <Text dimColor>
                {" · "}
                {trigger}
              </Text>
              <Text dimColor>
                {" (before the save, so not marked below)"}
              </Text>
            </Text>
          </Box>
          <Text dimColor wrap="truncate-end">
            {`Watching for a new run until ${clock}.`}
          </Text>
          <Text color="warning" wrap="truncate-end">
            {" "}
          </Text>
        </Box>
        <Box flexDirection="column" marginTop={1}>
          −
          {"                "}
          {" "}
          {`  ${note}`}
          −
          {"                "}
          {" "}
          {`  ${note}`}
          −
          {"                "}
          {" "}
          {`  ${note}`}
        </Box>
        <Box flexDirection="row" gap={2} marginTop={1}>
          <Button hotkey="r">
            Refresh
          </Button>
          <Button hotkey="w">
            Stop watching
          </Button>
          <Button hotkey="h" dimColor>
            What to allow
          </Button>
          <Button hotkey="o" dimColor>
            Other automation
          </Button>
          <Button hotkey="b" dimColor>
            Bulbs off
          </Button>
          <Link href={`${url}/config/automation/edit/${encodeURIComponent}`}>
            Open in Home Assistant
          </Link>
        </Box>
        <Text dimColor>
          ● ran ✗ false or error ○ not reached + added ~ changed − removed
        </Text>
        <Box flexDirection="column" marginTop={1}>
          <Text bold>
            Pick an automation (
            {length}
            )
          </Text>
          <Button dimColor>
            Close the list
          </Button>
        </Box>
        <Box flexDirection="row" gap={2} marginTop={1}>
          <Text dimColor wrap="wrap">
            {"Working on ESPHome too? The ESPHome pane shows the device and its builds: "}
            <Text color="suggestion">
              /plugin install vome-esphome --marketplace Vortitron/home-assistant-mcp
            </Text>
          </Text>
          <Button dimColor>
            Hide
          </Button>
        </Box>
      </Box>
    )
  })

  on('session.start', async ($, e, next) => {
    const alias = '…'
    const text = '…'
    await $.ui.toast(`${alias}: ${text}`)
    return next(e)
  })
}

Mod 自身のコード

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

claude-plugin/vome-automation/hooks/register.tsx 257〜416 行 · ペイン
  on('ui.render', { component: 'Pane', requestId: PANE }, async ($, e) => {
    const { Box, Text, Button, Link, Code, Markdown } = $.ui.resolve(e)
    const current = (await $.state.get(view)).value ?? null
    const latest = (await $.state.get(run)).value ?? null
    const watching = (await $.state.get(watch)).value ?? null
    const message = (await $.state.get(note)).value ?? null
    const urls = (await $.state.get(haUrls)).value ?? {}
    const lit = (await $.state.get(flash)).value ?? null
    const isFxEnabled = (await $.state.get(fxOn)).value ?? true
    const playing = (await $.state.get(fx)).value ?? null
    const isBuilding = (await $.state.get(building)).value ?? false
    const refusal = (await $.state.get(blocked)).value ?? null
    const picking = (await $.state.get(choices)).value ?? null
    const isSiblingHint = !hasSibling && ((await $.state.get(sibling)).value ?? false)
    const siblingHint = isSiblingHint ? (
      <Box flexDirection="row" gap={2} marginTop={1}>
        <Text dimColor wrap="wrap">
          Working on ESPHome too? The ESPHome pane shows the device and its builds: <Text color="suggestion">{ESPHOME_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

    // The home's automations to pick one from (/automation with nothing shown, or o). The phone app
    // has no Select, so there they are buttons, the first dozen.
    let pickerList = null
    if (picking) {
      const pick = (id: string) => $.state.set(pending, { automation: id, run: true, server: picking.server })
      if (e.surface === 'mobile') {
        pickerList = picking.automations.slice(0, 12).map(item => (
          <Button key={`pick-${item.id}`} plain onPress={() => pick(item.id)}>
            {item.alias}
          </Button>
        ))
      } else {
        const { Select } = $.ui.resolve(e)
        pickerList = (
          <Select
            key="pick"
            label="Automation"
            autoFocus
            options={picking.automations.map(item => ({ value: item.id, label: `${item.isOn ? '●' : '○'} ${item.alias}` }))}
            onSelect={value => pick(value)}
          />
        )
      }
    }
    const picker = picking ? (
      <Box flexDirection="column" marginTop={1}>
        <Text bold>Pick an automation ({picking.automations.length})</Text>
        {pickerList}
        <Button key="close-picker" dimColor onPress={() => $.state.set(choices, null)}>
          Close the list
        </Button>
      </Box>
    ) : null

    // A refused read takes the whole pane until dismissed: what to add and where, over everything,
    // rather than a HooksError in the note line that names neither.
    if (refusal && !refusal.isDismissed) {
      fxSite = null
      const rules = READ_TOOLS.map(tool => `"mcp__${refusal.server}__${tool}"`).join(',\n')
      return (
        <Box flexDirection="column" borderStyle="round" borderColor="warning" paddingX={1}>
          <Text bold color="warning">
            The automation pane needs permission to read
          </Text>
          <Text wrap="wrap">
            Auto mode refused its background read of {refusal.tool} on the {refusal.server} server. Claude Code refuses
            reads nobody asked for unless they are allowed by name.
          </Text>
          <Box marginTop={1}>
            <Text wrap="wrap">Add these lines to permissions.allow in</Text>
          </Box>
          <Markdown text={`[${settingsFile}](file://${settingsFile})`} />
          <Code source={rules} />
          <Text dimColor wrap="wrap">
            Or run /permissions and choose Allow for each. They only read: an automation and its recorded runs.
          </Text>
          <Box marginTop={1}>
            <Text dimColor wrap="wrap">
              Claude Code said: {compact(refusal.error, 300)}
            </Text>
          </Box>
          <Box flexDirection="row" gap={2} marginTop={1}>
            <Button
              key="copy-rules"
              hotkey="c"
              variant="primary"
              autoFocus
              onPress={press => $.ui.copy({ text: rules, surface: press.surface })}
            >
              Copy the lines
            </Button>
            <Button
              key="retry"
              hotkey="r"
              onPress={async () => {
                isBlocked = false
                await $.state.set(blocked, null)
                await $.state.set(note, null)
                await $.state.set(pending, { run: true })
              }}
            >
              Try again
            </Button>
            <Button key="dismiss" hotkey="d" role="dismiss" onPress={() => $.state.set(blocked, { ...refusal, isDismissed: true })}>
              Dismiss
            </Button>
          </Box>
          <Link href={README_URL}>Why the pane needs these</Link>
        </Box>
      )
    }
    // Dismissed: the pane as usual, its note line saying how to get the help back.
    const showHelp = refusal ? (
      <Button key="help" hotkey="h" dimColor onPress={() => $.state.set(blocked, { ...refusal, isDismissed: false })}>
        What to allow
      </Button>
    ) : null

    // While an interstitial plays it takes the header's first four lines; the swim (the intro, or
    // while an automation is worked on) takes all six. Same heights, so nothing below moves.
    // Both are Rasters, which only the terminal draws; elsewhere the pane goes without.
    const isSwimming = !current || isBuilding
    let sceneStrip = null
    let swimStrip = null
    if (e.surface === 'terminal' && isFxEnabled && (playing || isSwimming)) {
      const { Raster } = $.ui.resolve(e)
      const columns = Math.max(10, Math.min(512, e.props.bodyColumns))
      fxSite = { columns, isSwim: !playing }
      if (playing) {
        sceneStrip = <Raster key="bulbs" columns={columns} rows={FX_ROWS} cells={frame(Date.now() - playing.at, playing.scene, columns)} />
      } else {
        swimStrip = <Raster key="bulbs" columns={columns} rows={SWIM_ROWS} cells={swim(Date.now(), columns)} />
      }
    } else {
      fxSite = null
    }

    const connected = (await $.state.get(servers)).value ?? null
    if (!current && connected !== null && connected.length === 0) {
      return (
        <Box flexDirection="column">
          {swimStrip ?? sceneStrip}
          <Text bold>Connect Home Assistant first</Text>
          <Text wrap="wrap">
            This pane follows Claude's work through the Home Assistant MCP (@vortitron/home-assistant-mcp), and nothing
            connected in this session has its tools.
          </Text>
          <Box flexDirection="column" marginTop={1}>
claude-plugin/vome-automation/hooks/register.tsx 573〜593 行 · ペイン
function drawRow(T: ElementTable['Text'], row: Row, highlight: string | undefined) {
  if (row.isSection) {
    return (
      <T bold color="suggestion">
        {row.text.toUpperCase()}
      </T>
    )
  }
  const isStruck = row.change === '-' || row.tone === 'disabled'
  return (
    <T wrap="truncate-end" backgroundColor={highlight}>
      <T color={changeColour(row.change)}>{row.change === '-' ? '−' : row.change ?? ' '}</T>
      {'  '.repeat(row.depth)}
      <T color={toneColour(row.tone)}>{toneGlyph(row.tone)} </T>
      <T dimColor={row.tone === 'skipped' || row.tone === 'disabled'} strikethrough={isStruck}>
        {row.text}
      </T>
      {row.note ? <T dimColor>{`  ${row.note}`}</T> : null}
    </T>
  )
}
ライセンスの全文(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-automation/hooks/register.tsx
解析できるすべてのファイルが TypeScript か JavaScript として解析できる。3 ファイルを解析
コードが 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-automation@vome

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

Claude に聞く

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

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

Claude から探す: MCP コネクタ

似たデザイン