modscode EN

modscode / 図鑑 / move-coach

move-coach

Camera pane with pose landmarks, spoken coaching and optional Muse EEG for the Built to Move mobility tests (macOS)

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

何をするか

  • 欄・トーストを描く
  • /move-coach を足す
  • ツールの呼び出しを見張る
  • session.startにフックする
  • ターンをまたいで自分の状態を持つ

良いところ

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

作り始めるためのコード

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

雛形(register.tsx)

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

// Drawn like move-coach by Nate Aune (pane, toast), as modscode read it from the mod's code:
// https://modscode.com/gallery/natea-move-coach/
// 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: "Move Coach" })
  on('ui.render', { component: 'Pane', requestId: 'my-pane' }, async ($, e) => {
    const { Box, Text, Select, Button } = $.ui.resolve(e)
    const who = '…'
    const points = '…'
    const max = '…'
    const done = '…'
    const length = '…'
    const short = '…'
    const bar = '…'
    const label = '…'
    const short2 = '…'
    const short3 = '…'
    const title = '…'
    const score_label = '…'
    const points2 = '…'
    const explanation = '…'
    const step = '…'
    const total = '…'
    const title2 = '…'
    const nextTitle = '…'
    const instruction = '…'
    const cue = '…'
    const metrics = '…'
    const device = '…'
    const status = '…'
    const c = '…'
    const sparkline = '…'
    const c2 = '…'
    const sparkline2 = '…'
    const c3 = '…'
    const sparkline3 = '…'
    const map = '…'
    const error = '…'
    const baselineLine = '…'
    const phase = '…'
    const elapsed = '…'
    const error2 = '…'
    const q = '…'
    const q2 = '…'
    const q3 = '…'
    const chosenCamera = '…'
    return (
      <Box flexDirection="column">
        <Box borderStyle="round" borderColor="green" paddingX={1} flexDirection="column">
          <Text bold color="green">
            MOVE SCORE
            {` · ${who}`}
            {" "}
            {points}
            {" / "}
            {max}
            {" ("}
            {done}
            {" of "}
            {length}
            {" tests)"}
          </Text>
          <Text>
            {short}
            {" "}
            {`${bar} ${points}/10  ${label}`}
          </Text>
          <Text>
            {short2}
            {" "}
            {`${bar} ${points}/10  ${label}`}
          </Text>
          <Text>
            {short3}
            {" "}
            {`${bar} ${points}/10  ${label}`}
          </Text>
        </Box>
        <Box borderStyle="double" borderColor="yellow" paddingX={1} flexDirection="column">
          <Text bold color="yellow">
            {"✓ "}
            {title}
            {": "}
            {score_label}
            {" → "}
            {points2}
            /10 points
          </Text>
          <Text>
            {"How it was scored: "}
            {explanation}
          </Text>
        </Box>
        <Text bold color="cyan">
          {"Test "}
          {step}
          {" of "}
          {total}
          {": "}
          {title2}
          {`  ·  next: ${nextTitle}`}
        </Text>
        <Text>
          {instruction}
        </Text>
        <Text color="green">
          {"🗣 "}
          {cue}
        </Text>
        <Box flexDirection="row" gap={2}>
          <Box flexDirection="column" />
        </Box>
        <Text dimColor>
          {metrics}
        </Text>
        <Box flexDirection="column">
          <Text bold color="magenta">
            🧠 Brain waves
            {` · ${device}`}
            {`  ·  ${status}`}
          </Text>
          <Box flexDirection="column">
            <Text>
              {c}
              {" "}
              {sparkline}
              {" "}
            </Text>
            <Text>
              {c2}
              {" "}
              {sparkline2}
              {" "}
            </Text>
            <Text>
              {c3}
              {" "}
              {sparkline3}
              {" "}
            </Text>
            <Text>
              {map}
            </Text>
          </Box>
          <Text color="red">
            {error}
          </Text>
          <Text color="green">
            {baselineLine}
          </Text>
        </Box>
        <Text dimColor>
          {`● ${phase} · ${elapsed}s`}
          {`  ·  ${status}`}
        </Text>
        <Text color="red">
          {error2}
        </Text>
        <Box flexDirection="column">
          <Text bold>
            Questions to confirm the score (answer in the chat):
          </Text>
          <Text>
            {"• "}
            {q}
          </Text>
          <Text>
            {"• "}
            {q2}
          </Text>
          <Text>
            {"• "}
            {q3}
          </Text>
        </Box>
        <Box flexDirection="row" gap={2}>
          <Select label="Camera" value={`${chosenCamera}`} />
          <Button label="Stop" />
          <Button label="EEG baseline" />
          <Button label="Stop EEG" />
          <Button label="Done with this side" />
        </Box>
      </Box>
    )
  })

  on('session.start', async ($, e, next) => {
    const mode = '…'
    const who = '…'
    await $.ui.toast(`Move Coach: type "/built-to-move-mobility-test ${mode} ${who}" to start.`)
    return next(e)
  })
}

Mod 自身のコード

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

plugins/move-coach/hooks/register.tsx 885〜1044 行 · ペイン
  on('ui.render', { component: 'Pane', requestId: PANE }, async ($, e) => {
    const els = $.ui.resolve(e) as any
    const { Box, Text, Button } = els
    const v = await read($, view)
    const camList = await read($, cameras)
    const meta = TESTS[v.test]
    const isTerminal = e.surface === 'terminal'

    const pictures = []
    for (const img of meta.images.slice(0, isTerminal ? 2 : 3)) {
      if (isTerminal && v.cells) {
        // inside tmux: the pre-rendered half-block version of the illustration
        let art = imageCache.get(`${img.file}.cells`)
        if (!art) {
          const path = await bookFile($, `${img.file}.cells.json`)
          if (!path) continue
          art = await $.fs.read(path)
          imageCache.set(`${img.file}.cells`, art)
        }
        const { cols, rows, cells } = JSON.parse(art) as { cols: number; rows: number; cells: string }
        pictures.push(
          <Box flexDirection="column" width={32}>
            <els.Raster key={`book-${img.file}`} columns={cols} rows={rows} cells={cells} />
            <Text dimColor>{img.caption}</Text>
          </Box>,
        )
      } else if (isTerminal) {
        const path = await bookFile($, `${img.file}.png`)
        if (!path) continue
        pictures.push(
          <Box flexDirection="column" width={32}>
            <els.Image source={{ file: path, format: 'png' }} columns={30} rows={14} alt={img.caption} />
            <Text dimColor>{img.caption}</Text>
          </Box>,
        )
      } else if (els.Svg) {
        let b64 = imageCache.get(img.file)
        if (!b64) {
          const path = await bookFile($, `${img.file}.jpg`)
          if (!path) continue
          const bytes = await $.fs.read(path, { as: 'bytes' })
          b64 = (bytes as { base64: string }).base64
          imageCache.set(img.file, b64)
        }
        pictures.push(
          <Box flexDirection="column" width={30}>
            <els.Svg source={bookSvg(b64)} alt={img.caption} width={200} height={200} />
            <Text dimColor>{img.caption}</Text>
          </Box>,
        )
      }
    }

    let camera
    if (isTerminal) {
      camera = v.cells ? (
        <els.Raster key="cam" columns={v.cols} rows={v.rows} cells={v.cells} />
      ) : v.png ? (
        <els.Image key="cam" source={{ file: v.png, format: 'png', generation: v.gen }} columns={64} rows={20} alt="camera with pose landmarks" />
      ) : (
        <Text dimColor>{v.isRunning ? 'waiting for the camera…' : 'camera off'}</Text>
      )
    } else if (els.Svg) {
      camera = <els.Svg source={cameraSvg(v)} alt="camera with pose landmarks" width={480} />
    } else {
      camera = <Text dimColor>This surface can't draw the camera.</Text>
    }

    const metrics = Object.entries(v.metrics)
      .map(([k, x]) => `${k}: ${typeof x === 'object' ? JSON.stringify(x) : String(x)}`)
      .join('  ·  ')

    const ev = await read($, eeg)
    const board = await read($, scores)
    const who = await read($, person)
    const total = totalOf(board)
    let last: { points?: number; score_label?: string; explanation?: string; stopped?: boolean } = {}
    try {
      last = v.result ? JSON.parse(v.result) : {}
    } catch {}

    return (
      <Box flexDirection="column">
        <Box borderStyle="round" borderColor="green" paddingX={1} flexDirection="column">
          <Text bold color="green">
            MOVE SCORE{who ? ` · ${who}` : ''}  {total.points} / {total.max}   ({total.done} of {SCORED.length} tests)
          </Text>
          {SCORED.map(t => (
            <Text dimColor={board[t.key] === undefined}>
              {t.short.padEnd(13)} {board[t.key] ? `${bar(board[t.key]!.points)} ${String(board[t.key]!.points).padStart(2)}/10  ${board[t.key]!.label}` : '▱▱▱▱▱▱▱▱▱▱  –  not tested'}
            </Text>
          ))}
        </Box>
        {!v.isRunning && typeof last.points === 'number' && (
          <Box borderStyle="double" borderColor="yellow" paddingX={1} flexDirection="column">
            <Text bold color="yellow">
              ✓ {meta.title}: {last.score_label} → {last.points}/10 points
            </Text>
            {last.explanation && <Text>How it was scored: {last.explanation}</Text>}
          </Box>
        )}
        {v.step && v.total ? (
          <Text bold color="cyan">
            Test {v.step} of {v.total}: {v.title}{v.nextTitle ? `  ·  next: ${v.nextTitle}` : '  ·  last test'}
          </Text>
        ) : (
          <Text bold>{v.title}</Text>
        )}
        {v.instruction && <Text>{v.instruction}</Text>}
        {v.isRunning && v.cue && <Text color="green">🗣 {v.cue}</Text>}
        <Box flexDirection="row" gap={2}>
          {camera}
          {pictures.length > 0 && <Box flexDirection="column">{pictures}</Box>}
        </Box>
        {metrics && <Text dimColor>{metrics}</Text>}
        {(ev.isRunning || ev.error || ev.raw.length > 0) && (
          <Box flexDirection="column">
            <Text bold color="magenta">
              🧠 Brain waves{ev.device ? ` · ${ev.device}` : ''}{ev.status ? `  ·  ${ev.status}` : ''}
            </Text>
            {ev.raw.length > 0 &&
              (!isTerminal && els.Svg ? (
                <els.Svg source={eegSvg(ev)} alt="EEG traces per channel and relative band power" width={480} />
              ) : (
                <Box flexDirection="column">
                  {ev.channels.map((c, i) => (
                    <Text>
                      {c.padEnd(5)} {sparkline(ev.raw[i] ?? [])} {ev.quality[i] ?? ''}
                    </Text>
                  ))}
                  <Text>{BAND_ORDER.map(b => `${b} ${Math.round((ev.bands[b] ?? 0) * 100)}%`).join('  ')}</Text>
                </Box>
              ))}
            {ev.error && <Text color="red">{ev.error}</Text>}
            {ev.baseline && <Text color={ev.baseline.phase === 'done' ? 'green' : ev.baseline.phase === 'cancelled' ? 'yellow' : 'cyan'}>{baselineLine(ev.baseline)}</Text>}
          </Box>
        )}
        <Text dimColor>
          {v.isRunning ? `● ${v.phase} · ${v.elapsed}s` : v.test === 'free' ? '○ camera off' : v.phase === 'done' ? (last.stopped ? '■ stopped. The camera is off; nothing was scored.' : '✓ done') : '○ idle'}
          {v.status ? `  ·  ${v.status}` : ''}
        </Text>
        {v.error && <Text color="red">{v.error}</Text>}
        {!v.isRunning && (last as { confirm?: string[] }).confirm?.length ? (
          <Box flexDirection="column">
            <Text bold>Questions to confirm the score (answer in the chat):</Text>
            {(last as { confirm?: string[] }).confirm!.map(q => (
              <Text>• {q}</Text>
            ))}
          </Box>
        ) : null}
        <Box flexDirection="row" gap={2}>
          {els.Select && camList.length > 0 && (
            <els.Select
              // keyed on the device list so a renumbered list remounts the picker instead of keeping stale labels
              key={`camera:${camList.map(c => c.name).join('|')}`}
              label="Camera"
              options={camList.map(c => ({ value: String(c.index), label: c.name }))}
              value={String(chosenCamera ?? 0)}
              onSelect={async (value: string) => pickCamera($, Number(value))}
            />
ライセンスの全文(MIT)
MIT License

Copyright (c) 2026 Nate Aune

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

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

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

入れる

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

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

/plugin marketplace add natea/move-coach
/plugin install move-coach@move-coach

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

Claude に聞く

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

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

Claude から探す: MCP コネクタ

似たデザイン