modscode EN

modscode / 図鑑 / avatars

avatars

Claude speaks a short version of each reply through ElevenLabs, as a narrator or a cast of characters with animated portraits above the prompt

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

何をするか

  • 欄・トーストを描く
  • /avatar を足す
  • mcp__avatars__search_voices・mcp__avatars__my_voices・mcp__avatars__audition・mcp__avatars__paths の呼び出しを見張る(止めることがある)
  • session.start・turn.completeにフックする
  • ネットワークに出る

良いところ

  • TypeScript で書かれている
  • デスクトップ専用の分岐がある
  • エラーを扱う

作り始めるためのコード

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

雛形(register.tsx)

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

// Drawn like avatars by Dead Money (pane, band, toast), as modscode read it from the mod's code:
// https://modscode.com/gallery/dead-money-avatars/
// 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: "Avatars" })
  on('ui.render', { component: 'Pane', requestId: 'my-pane' }, async ($, e) => {
    const { Box, Text, Select, Button } = $.ui.resolve(e)
    const description = '…'
    const voice = '…'
    const model = '…'
    const note = '…'
    return (
      <Box flexDirection="column" gap={1}>
        <Box flexDirection="column">
          <Text>
            {"Spoken replies: "}
            <Text bold>
              on
            </Text>
            {"   "}
            {"API key: "}
            <Text color="green">
              set
            </Text>
          </Text>
          <Text dimColor>
            Set it with /plugin (Avatars, configure), or export ELEVENLABS_API_KEY and restart.
          </Text>
        </Box>
        <Box flexDirection="column">
          <Select label="Mode  " autoFocus value="off" options={[{"label":"‹option›"},{"value":"off","label":"Off"}]} />
          <Text dimColor>
            {description}
          </Text>
        </Box>
        <Select label="Voice " value={`${voice}`} />
        <Button dimColor>
          Load my ElevenLabs voices
        </Button>
        <Select label="Model " value={`${model}`} />
        <Select label="Scenario " value="" options={[{"value":"","label":"Pick one to play"},{"label":"‹option›"}]} />
        <Box flexDirection="row" gap={1} flexWrap="wrap">
          <Button hotkey="t" variant="primary">
            Test
          </Button>
          <Button hotkey="r">
            Replay
          </Button>
          <Button hotkey="s">
            Stop
          </Button>
          <Button hotkey="o">
            Turn off
          </Button>
          <Button hotkey="d">
            Save as default
          </Button>
          <Button hotkey="c">
            Check setup
          </Button>
          <Button role="dismiss">
            Close
          </Button>
        </Box>
        <Text>
          {note}
        </Text>
        <Text dimColor>
          {"New modes: ask Claude to create one (the create-mode skill), or see "}
          .
        </Text>
      </Box>
    )
  })

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

Mod 自身のコード

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

plugins/avatars/hooks/register.tsx 889〜971 行 · ペイン
  on('ui.render', { component: 'Pane', requestId: MENU }, async ($, e) => {
    const { Box, Text, Button, Select } = $.ui.resolve(e)
    const mode = await modeOf($)
    const isOn = await isEnabled($)
    const model = await modelOf($)
    const voice = await voiceOf($, mode)
    const voices = await read($, libraryVoices)
    const note = await read($, menuNote)
    const hasKey = (await apiKey($)) !== undefined
    const scenarios = [...modes.values()].flatMap(m => Object.entries(m.scenarios ?? {}).map(([key, s]) => ({ key, title: `${m.title}: ${s.title}` })))
    const act = (work: () => Promise<string>) => () => {
      void work().then(text => update($, menuNote, () => text)).catch(err => update($, menuNote, () => String(err)))
    }

    const voiceOptions = [
      ...(mode?.voice ? [{ value: mode.voice, label: `${mode.title} default` }] : []),
      ...(voices ?? []).filter(v => v.id !== mode?.voice).map(v => ({ value: v.id, label: v.name })),
    ]
    if (voice && !voiceOptions.some(o => o.value === voice)) voiceOptions.unshift({ value: voice, label: voice })

    return (
      <Box flexDirection="column" gap={1}>
        <Box flexDirection="column">
          <Text>
            Spoken replies: <Text bold>{isOn ? 'on' : 'off'}</Text>
            {'   '}API key: {hasKey ? <Text color="green">set</Text> : <Text color="red">missing</Text>}
          </Text>
          {!hasKey && <Text dimColor>Set it with /plugin (Avatars, configure), or export ELEVENLABS_API_KEY and restart.</Text>}
        </Box>
        <Box flexDirection="column">
          <Select
            key="mode"
            label="Mode  "
            autoFocus
            value={mode?.name ?? 'off'}
            options={[...[...modes.values()].map(m => ({ value: m.name, label: m.title })), { value: 'off', label: 'Off' }]}
            onSelect={value => act(() => setMode($, value))()}
          />
          {mode && <Text dimColor>{mode.description}</Text>}
        </Box>
        {mode && !mode.call && voiceOptions.length > 0 && (
          <Select key="voice" label="Voice " value={voice} options={voiceOptions} onSelect={value => act(() => setVoice($, value))()} />
        )}
        {mode && !mode.call && voices === null && hasKey && (
          <Button key="load-voices" dimColor onPress={() => void refreshLibrary($)}>
            Load my ElevenLabs voices
          </Button>
        )}
        <Select
          key="model"
          label="Model "
          value={model}
          options={[...new Set([model, ...MODELS])].map(m => ({ value: m, label: `${m}${hasTags(m) ? ' (audio tags)' : ''}` }))}
          onSelect={value => act(() => setModel($, value))()}
        />
        {scenarios.length > 0 && (
          <Select
            key="scenario"
            label="Scenario "
            value=""
            options={[{ value: '', label: 'Pick one to play' }, ...scenarios.map(s => ({ value: s.key, label: s.title }))]}
            onSelect={value => value && act(() => playScenario($, value))()}
          />
        )}
        <Box flexDirection="row" gap={1} flexWrap="wrap">
          <Button key="test" hotkey="t" variant="primary" onPress={act(() => playDemo($, ''))}>Test</Button>
          <Button key="replay" hotkey="r" onPress={act(async () => {
            const last = await read($, lastSaid)
            if (!last) return 'Nothing spoken yet.'
            background($, say($, last))
            return 'Replaying.'
          })}>Replay</Button>
          <Button key="stop" hotkey="s" onPress={act(async () => (await stop(), 'Stopped.'))}>Stop</Button>
          <Button key="toggle" hotkey="o" onPress={act(() => setEnabled($, !isOn))}>{isOn ? 'Turn off' : 'Turn on'}</Button>
          <Button key="default" hotkey="d" onPress={act(() => saveDefaults($))}>Save as default</Button>
          <Button key="doctor" hotkey="c" onPress={act(() => doctor($))}>Check setup</Button>
          <Button key="close" role="dismiss" onPress={() => void $.ui.close({ id: MENU })}>Close</Button>
        </Box>
        {note !== '' && <Text>{note}</Text>}
        <Text dimColor>New modes: ask Claude to create one (the create-mode skill), or see {userModesDir}.</Text>
      </Box>
    )
  })
ライセンスの全文(MIT)
MIT License

Copyright (c) 2026 Dead Money

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

載せる条件: 確かめやすいコード
入口を読んだhooks/hooks.json が名指すモジュールをすべて読んだ。plugins/avatars/hooks/register.tsx
解析できるすべてのファイルが TypeScript か JavaScript として解析できる。6 ファイルを解析
コードが 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 のホスト)がコードに書いてあるか。plugins/avatars/hooks/register.tsx:508 fetch(`${API}/v1/voices/add/${owner}/${voice}`); plugins/avatars/hooks/register.tsx:703 fetch(`${API}${path}`); plugins/avatars/hooks/register.tsx:740 fetch(`${API}/v1/voices/${voice}`); plugins/avatars/hooks/register.tsx:1105 fetch(`${API}/v1/voices/${voice}`)
プログラム起動するプログラムの名前がコードに書いてあり、シェル・インタプリタ・通信用の道具でないか。plugins/avatars/hooks/register.tsx:458 実行時に決まるプログラム; plugins/avatars/hooks/register.tsx:726 実行時に決まるプログラム
読んで送るファイルや環境変数を読み、かつ通信するか。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 .)、触るものを見て、読んだコミットを入れてください。

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

/plugin marketplace add dead-money/claude-plugins
/plugin install avatars@dead-money

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

Claude に聞く

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

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

Claude から探す: MCP コネクタ

似たデザイン