modscode EN

modscode / 図鑑 / ruview-live

ruview-live

RuView live sensing in Claude Code: /ruview opens a pane beside the transcript with three views: an overview of your CSI nodes (ESP32, Realtek) and 60 GHz radar (rates, loss, RSSI, presence, device-reported vitals, alerts), a live CSI ampl…

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

何をするか

  • 欄を描く
  • session.end・session.start・ui.closeにフックする
  • プロセスを起こす

良いところ

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

作り始めるためのコード

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

雛形(register.tsx)

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

// Drawn like ruview-live by ruvnet (pane, status), as modscode read it from the mod's code:
// https://modscode.com/gallery/ruvnet-ruview-live/
// 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: "ruview-live" })
  on('ui.render', { component: 'Pane', requestId: 'my-pane' }, async ($, e) => {
    const { Box, Text } = $.ui.resolve(e)
    const text = '…'
    return (
      <Box flexDirection="column" gap={1} paddingX={1}>
        <Box flexDirection="column" />
        <Box flexDirection="row" gap={1} />
        <Text color="red" wrap="wrap">
          {`! ${text}`}
        </Text>
        <Text color="red" wrap="wrap">
          {`! ${text}`}
        </Text>
        <Text color="red" wrap="wrap">
          {`! ${text}`}
        </Text>
        <Box flexDirection="row" gap={1} />
      </Box>
    )
  })
}

Mod 自身のコード

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

harness/ruview/mod/hooks/register.mjs 209〜230 行 · ペイン
  on('ui.render', { component: 'Pane' }, async ($, e, next) => {
    if (e.requestId !== PANE_ID) return next(e);
    // A reload (hot reload, or a resumed session) re-runs register with fresh
    // variables while the engine keeps the pane open: drawing it means it is
    // open, so resume polling instead of waiting for the first capture forever.
    if (host && !stopTimer) startPolling();
    size = {
      columns: e.props?.bodyColumns ?? e.viewport?.columns ?? 100,
      rows: e.props?.scroll?.bodyRows ?? e.viewport?.rows ?? 30,
    };
    const ui = await $.ui.resolve(e);
    const now = await $.clock.now();
    return viewOf(ui, shownModel(), {
      ...drawOpts(now), refreshMs: settings.refreshMs, liveRefreshMs: settings.liveRefreshMs, busy, now,
      focused: e.props?.isFocused !== false,
      udpPort: settings.udpPort, radarConfigured: Boolean(settings.radarHost),
      onRefresh: () => { void refresh(); },
      onClose: () => { void close(); },
      onMode: (m) => setMode(m),
      onNextNode: () => { nodeIndex += 1; host?.invalidate(); },
    });
  });
harness/ruview/mod/hooks/views.mjs 63〜109 行 · ペイン
export function viewOf(ui, model, opts) {
  const { Box, Text, Button } = ui;
  const mode = opts.mode || 'overview';
  const live = mode !== 'overview';
  const interval = live ? (opts.liveRefreshMs ?? opts.refreshMs) : opts.refreshMs;
  const t = (children, props = {}) => Text({ wrap: 'truncate-end', ...props, children });
  const row = (children, props = {}) => Box({ flexDirection: 'row', gap: 1, ...props, children: children.filter(Boolean) });
  const pics = ui.Raster ? picturesOf(model, opts) : {};

  // Header: freshness badge and age, then the signal rule.
  const finiteAt = model && Number.isFinite(model.at);
  const age = finiteAt && Number.isFinite(opts.now) ? opts.now - model.at : NaN;
  const fresh = Number.isFinite(age) && age <= interval * 2 + 5000;
  const when = finiteAt ? new Date(model.at).toLocaleTimeString() : '—';
  const badge = !model ? t('○ STARTING', { dimColor: true, bold: true })
    : fresh ? t('● LIVE', { color: 'green', bold: true }) : t('○ STALE', { color: 'yellow', bold: true });
  const header = row([
    t('RuView', { color: 'cyan', bold: true }),
    badge,
    t(model ? `updated ${when}${ageOf(age) ? ` (${ageOf(age)})` : ''} · every ${Math.round(interval / 1000)}s` : `waiting for the first capture… · every ${Math.round(interval / 1000)}s`, { dimColor: true }),
    opts.busy ? t('⟳ refreshing', { color: 'cyan' }) : null,
  ]);
  const rule = pics.shimmer ? ui.Raster(pics.shimmer.grid.toRaster('shimmer')) : null;

  // Hotkeys reach a Pane only while it holds the keyboard; say how to give it.
  const tabs = opts.onMode ? row([
    ...TABS.map(([m, key, label]) => Button({
      key: `tab-${m}`, hotkey: key, label: `${m === mode ? '▸ ' : ''}${label} (${key})`, onPress: () => opts.onMode(m),
    })),
    opts.focused === false ? t('click the pane or press ctrl+x tab to use the keys', { dimColor: true, italic: true }) : null,
  ], { gap: 2 }) : null;

  const alerts = (model?.alerts || []).map((a) => Text({ color: a.level === 'bad' ? 'red' : 'yellow', wrap: 'wrap', children: `! ${a.text}` }));

  let body;
  if (mode === 'waterfall') body = waterfallView(ui, model, opts, pics, t, row);
  else if (mode === 'radar') body = radarView(ui, model, opts, pics, t, row);
  else body = overview(ui, model, opts, t, row);

  const footer = row([
    Button({ key: 'refresh', label: opts.busy ? 'Refreshing…' : 'Refresh (r)', hotkey: 'r', onPress: opts.onRefresh }),
    mode === 'waterfall' && opts.onNextNode && (model?.spectrum?.length ?? 0) > 1 ? Button({ key: 'next-node', label: 'Next node (n)', hotkey: 'n', onPress: opts.onNextNode }) : null,
    Button({ key: 'close', label: 'Close (c)', hotkey: 'c', onPress: opts.onClose }),
  ], { gap: 2 });

  return Box({ flexDirection: 'column', gap: 1, paddingX: 1, children: [Box({ flexDirection: 'column', children: [header, rule].filter(Boolean) }), tabs, ...alerts, body, footer].filter(Boolean) });
}
ライセンスの全文(MIT)
MIT License

Copyright (c) 2024 rUv

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.

このコードはコード参考書の実例にもあります: ステータスライン・設定項目(userConfig)

コードが呼ぶもの

プログラム起動

コードから読めること

2026-10-06 に読んだコミット 0b15c0ebc947 のソースから。最初のまとまりが載せる条件で、残りは自分で判断するための材料です。後のコミットは、次に読むまで見ていません。

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

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

入れる

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

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

/plugin marketplace add ruvnet/RuView
/plugin install ruview-live@ruview

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

Claude に聞く

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

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

Claude から探す: MCP コネクタ

似たデザイン