modscode EN

modscode / 図鑑 / pulse-cc

pulse-cc

Stock and crypto quotes above the Claude Code prompt, with a /pulse panel to manage your watchlist.

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

何をするか

  • プロンプトの上の帯・欄を描く
  • /pulse を足す
  • session.attach・session.detach・session.end・session.startにフックする
  • ターンをまたいで自分の状態を持つ
  • ネットワークに出る

良いところ

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

作り始めるためのコード

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

雛形(register.tsx)

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

// Drawn like pulse-cc by fatwang2 (pane, band), as modscode read it from the mod's code:
// https://modscode.com/gallery/fatwang2-pulse-cc/
// 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 band above the prompt; what else goes there is drawn under it
  on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
    const { Box, Text } = $.ui.resolve(e)
    const state = '…'
    const symbol = '…'
    const formatBandPrice = '…'
    const symbol2 = '…'
    const formatBandPrice2 = '…'
    const symbol3 = '…'
    const formatBandPrice3 = '…'
    const length = '…'
    return (
      <Box flexDirection="column">
        <Box>
          <Text wrap="truncate">
            <Text dimColor>
              Pulse
            </Text>
            <Text color="warning">
              {` ${state}`}
            </Text>
            {"   "}
            <Text dimColor>
              Add a ticker with /pulse add AAPL
            </Text>
            <Text>
              <Text dimColor>
                {" · "}
              </Text>
              <Text bold>
                {symbol}
              </Text>
              {" "}
              <Text>
                <Text>
                  {formatBandPrice}
                </Text>
                {" "}
                <Text>
                  —
                </Text>
                <Text dimColor>
                  {" cached"}
                </Text>
              </Text>
            </Text>
            <Text>
              <Text dimColor>
                {" · "}
              </Text>
              <Text bold>
                {symbol2}
              </Text>
              {" "}
              <Text>
                <Text>
                  {formatBandPrice2}
                </Text>
                {" "}
                <Text>
                  —
                </Text>
                <Text dimColor>
                  {" cached"}
                </Text>
              </Text>
            </Text>
            <Text>
              <Text dimColor>
                {" · "}
              </Text>
              <Text bold>
                {symbol3}
              </Text>
              {" "}
              <Text>
                <Text>
                  {formatBandPrice3}
                </Text>
                {" "}
                <Text>
                  —
                </Text>
                <Text dimColor>
                  {" cached"}
                </Text>
              </Text>
            </Text>
            <Text dimColor>
              {`   +${length} more`}
            </Text>
          </Text>
        </Box>
        {await next(e)}
      </Box>
    )
  })

  // the pane: open it with $.ui.open({ id: 'my-pane', title: "Pulse" })
  on('ui.render', { component: 'Pane', requestId: 'my-pane' }, async ($, e) => {
    const { Box, Text, Button, Input, Link } = $.ui.resolve(e)
    const title = '…'
    const status = '…'
    const message = '…'
    const symbol = '…'
    const meta = '…'
    const formatPrice = '…'
    const formatPrice2 = '…'
    const meta2 = '…'
    const failed = '…'
    const symbol2 = '…'
    const meta3 = '…'
    const formatPrice3 = '…'
    const formatPrice4 = '…'
    const meta4 = '…'
    const failed2 = '…'
    const symbol3 = '…'
    const meta5 = '…'
    const formatPrice5 = '…'
    const formatPrice6 = '…'
    const meta6 = '…'
    const failed3 = '…'
    return (
      <Box flexDirection="column" paddingY={2}>
        <Box flexDirection="column">
          <Box justifyContent="space-between" alignItems="center" gap={2} flexWrap="wrap">
            <Text dimColor bold>
              {title}
            </Text>
            <Box gap={1}>
              <Button label="Refresh (r)" hotkey="r" dimColor />
              <Button label="Resume (p)" hotkey="p" dimColor />
            </Box>
          </Box>
          <Box>
            <Text>
              {status}
            </Text>
          </Box>
          <Box gap={1}>
            <Button label="Refresh" hotkey="r" />
            <Button label="Resume" hotkey="p" />
          </Box>
        </Box>
        <Box gap={1} alignItems="center">
          <Box flexGrow={1} flexShrink={1}>
            <Input placeholder="AAPL, BTC/USDT" value="" submitLabel="Add" autoFocus />
          </Box>
          <Button label="Add" />
        </Box>
        <Box>
          <Text color="error" wrap="wrap" />
        </Box>
        <Box marginTop={1}>
          <Text color="warning" wrap="wrap">
            {message}
          </Text>
        </Box>
        <Box flexDirection="column">
          <Text dimColor wrap="wrap">
            Your watchlist is empty. Add a ticker above.
          </Text>
          <Box flexDirection="column" width="100%" marginTop={0}>
            <Box gap={2} alignItems="center" width="100%">
              <Box flexDirection="column" flexGrow={1} flexShrink={1} minWidth={0}>
                <Text bold wrap="truncate">
                  {symbol}
                </Text>
                <Text dimColor wrap="truncate">
                  {meta}
                </Text>
              </Box>
              <Box flexDirection="column" alignItems="flex-end" flexShrink={0}>
                <Text wrap="truncate">
                  {formatPrice}
                </Text>
                <Text>
                  —
                </Text>
              </Box>
              <Button label="Remove" />
            </Box>
            <Box gap={2}>
              <Text wrap="truncate">
                {formatPrice2}
              </Text>
              <Text>
                —
              </Text>
            </Box>
            <Text dimColor wrap="truncate">
              {meta2}
            </Text>
            <Text color="warning" wrap="wrap">
              {"Cached quote · "}
              {failed}
            </Text>
          </Box>
          <Box flexDirection="column" width="100%" marginTop={0}>
            <Box gap={2} alignItems="center" width="100%">
              <Box flexDirection="column" flexGrow={1} flexShrink={1} minWidth={0}>
                <Text bold wrap="truncate">
                  {symbol2}
                </Text>
                <Text dimColor wrap="truncate">
                  {meta3}
                </Text>
              </Box>
              <Box flexDirection="column" alignItems="flex-end" flexShrink={0}>
                <Text wrap="truncate">
                  {formatPrice3}
                </Text>
                <Text>
                  —
                </Text>
              </Box>
              <Button label="Remove" />
            </Box>
            <Box gap={2}>
              <Text wrap="truncate">
                {formatPrice4}
              </Text>
              <Text>
                —
              </Text>
            </Box>
            <Text dimColor wrap="truncate">
              {meta4}
            </Text>
            <Text color="warning" wrap="wrap">
              {"Cached quote · "}
              {failed2}
            </Text>
          </Box>
          <Box flexDirection="column" width="100%" marginTop={0}>
            <Box gap={2} alignItems="center" width="100%">
              <Box flexDirection="column" flexGrow={1} flexShrink={1} minWidth={0}>
                <Text bold wrap="truncate">
                  {symbol3}
                </Text>
                <Text dimColor wrap="truncate">
                  {meta5}
                </Text>
              </Box>
              <Box flexDirection="column" alignItems="flex-end" flexShrink={0}>
                <Text wrap="truncate">
                  {formatPrice5}
                </Text>
                <Text>
                  —
                </Text>
              </Box>
              <Button label="Remove" />
            </Box>
            <Box gap={2}>
              <Text wrap="truncate">
                {formatPrice6}
              </Text>
              <Text>
                —
              </Text>
            </Box>
            <Text dimColor wrap="truncate">
              {meta6}
            </Text>
            <Text color="warning" wrap="wrap">
              {"Cached quote · "}
              {failed3}
            </Text>
          </Box>
        </Box>
        <Box flexDirection="column">
          <Text dimColor wrap="wrap">
            {"Yahoo Finance · Binance Spot · Stocks: regular session, exchange delays vary · Crypto: 24h change · Times are local · "}
            <Link href="https://www.pulseticker.app/">
              pulseticker.app
            </Link>
          </Text>
          <Text dimColor wrap="wrap">
            Tab: move between controls · Enter: activate · Esc: return to prompt
          </Text>
        </Box>
      </Box>
    )
  })
}

Mod 自身のコード

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

plugins/claude-code/hooks/register.tsx 90〜124 行 · バンド
  on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
    if (e.props.hasSurvey) return next(e)
    const { Box, Text } = $.ui.resolve(e)
    const width = Math.max(20, e.props.bodyColumns || e.viewport?.columns || 80)
    const state = watch.preferences.paused ? 'Paused' : ''
    const symbols = watch.preferences.symbols
    const label = (symbol: string) => {
      const quote = watch.quotes[symbol]
      const cached = watch.errors[symbol] && quote ? ' cached' : ''
      return quote ? `${symbol} ${formatBandPrice(quote)} ${formatChange(quote.changePercent)}${cached}` : `${symbol} unavailable`
    }
    const more = (list: string[]) => list.length < symbols.length ? `   +${symbols.length - list.length} more`.length : 0
    const fits = (list: string[]) => 8 + (state ? state.length + 3 : 0) + list.map(symbol => label(symbol).length).reduce((a, b) => a + b, 0)
      + Math.max(0, list.length - 1) * 3 + more(list) <= width
    let visible = symbols.slice(0, 5)
    while (visible.length > 1 && !fits(visible)) visible = visible.slice(0, -1)
    return <Box><Text wrap="truncate">
      <Text dimColor>Pulse</Text>
      {state && <Text color="warning">{` ${state}`}</Text>}{'   '}
      {!visible.length && <Text dimColor>Add a ticker with /pulse add AAPL</Text>}
      {visible.map((symbol, index) => {
        const quote = watch.quotes[symbol]
        const failed = !!watch.errors[symbol]
        return <Text key={symbol}>
          {index ? <Text dimColor>{' · '}</Text> : ''}<Text bold>{symbol}</Text>{' '}
          {quote ? <Text>
            <Text dimColor={failed}>{formatBandPrice(quote)}</Text>{' '}
            <Text color={changeColor(quote.changePercent)}>{formatChange(quote.changePercent)}</Text>
            {failed && <Text dimColor>{' cached'}</Text>}
          </Text> : <Text dimColor>{failed ? 'unavailable' : '…'}</Text>}
        </Text>
      })}
      {visible.length < symbols.length && <Text dimColor>{`   +${symbols.length - visible.length} more`}</Text>}
    </Text></Box>
  })
plugins/claude-code/hooks/register.tsx 126〜229 行 · ペイン
  on('ui.render', { component: 'Pane', requestId: PANE }, async ($, e, next) => {
    if (e.surface !== 'terminal' && e.surface !== 'desktop') return next(e)
    const { Box, Text, Button, Input, Link } = $.ui.resolve(e)
    // Desktop measures cells in its code font but draws proportional text, so
    // its rows fit side by side at fewer reported columns than the terminal's.
    const compact = e.props.bodyColumns < (e.surface === 'desktop' ? 44 : 64)
    // Desktop draws native controls (hotkey badges, the field's own submit
    // button, a close button); the terminal spells those out in text.
    const desktop = e.surface === 'desktop'
    const redraw = () => $.ui.invalidate('ui.render')
    const action = (task: () => Promise<unknown>) => { void act(task).finally(redraw) }
    const addTicker = () => action(async () => { await watch.add(input); input = ''; fieldRound++ })
    const paused = watch.preferences.paused
    const statusColor = paused ? 'warning' : watch.loading ? 'cyan' : 'success'
    const status = paused ? '● Auto-refresh paused' : watch.loading ? '● Refreshing quotes…' : `● Auto-refresh every ${intervalSeconds}s`
    const ccCount = watch.preferences.symbols.length
    const now = await $.clock.now()

    const section = (title: string) => <Text dimColor bold>{title.toUpperCase()}</Text>
    // Spacing is in cells. Desktop converts a cell to a code-font character, far
    // smaller than a terminal row, so it needs more of them for the same air. A
    // docked terminal pane has the full height; an inline one shares the prompt's.
    // Desktop draws a horizontal cell only a few pixels wide, so its horizontal
    // padding takes several.
    const space = desktop ? 3 : e.props.placement === 'dock' ? 2 : 1
    const gap = desktop ? 1 : 0
    const rowGap = desktop ? 2 : 1
    // Desktop text fields keep a fixed width (their submit button included), so
    // the insets stay small enough for the add field to fit a docked pane.
    const padX = desktop ? 4 : 1

    return <Box flexDirection="column" paddingX={padX} paddingY={desktop ? 2 : 0}>
      <Box key="status-section" flexDirection="column">
        <Box justifyContent="space-between" alignItems="center" gap={2} flexWrap="wrap">
          {section(`Watchlist · ${ccCount} ${ccCount === 1 ? 'ticker' : 'tickers'}`)}
          {!desktop && <Box key="watchlist-actions" gap={1}>
            <Button key="refresh" label="Refresh (r)" hotkey="r" dimColor onPress={() => action(() => watch.refresh())} />
            <Button key="pause" label={paused ? 'Resume (p)' : 'Pause (p)'} hotkey="p" dimColor
              onPress={() => action(() => watch.pause(!paused))} />
          </Box>}
        </Box>
        <Box marginTop={gap}><Text key="refresh-status" color={statusColor}>{status}</Text></Box>
        {desktop && <Box key="watchlist-actions" gap={1} marginTop={rowGap}>
          <Button key="refresh" label="Refresh" hotkey="r" onPress={() => action(() => watch.refresh())} />
          <Button key="pause" label={paused ? 'Resume' : 'Pause'} hotkey="p" onPress={() => action(() => watch.pause(!paused))} />
        </Box>}
      </Box>

      <Box key={`add-section-${fieldRound}`} gap={1} alignItems="center" marginTop={rowGap}>
        <Box flexGrow={1} flexShrink={1}>
          <Input key="add-ticker" placeholder={compact ? 'AAPL, BTC/USDT' : 'Add a ticker: AAPL, 0700.HK, BTC/USDT'} value={input}
            submitLabel={desktop ? 'Add' : 'add'} autoFocus onInput={value => { input = value }}
            onSubmit={value => { input = value; addTicker() }} />
        </Box>
        {!desktop && <Button key="add" label="Add" onPress={addTicker} />}
      </Box>
      {error && <Box marginTop={rowGap}><Text color="error" wrap="wrap">{error}</Text></Box>}
      {watch.message && <Box marginTop={1}>
        <Text color={watch.message.includes('rate limited') ? 'warning' : undefined} dimColor={!watch.message.includes('rate limited')} wrap="wrap">{watch.message}</Text>
      </Box>}

      <Box key="watchlist" flexDirection="column" marginTop={rowGap}>
        {!ccCount && <Text dimColor wrap="wrap">Your watchlist is empty. Add a ticker above.</Text>}
        {watch.preferences.symbols.map((symbol, index) => {
          const quote = watch.quotes[symbol]
          const failed = watch.errors[symbol]
          const price = <Text dimColor={!quote || !!failed} wrap="truncate">
            {quote ? formatPrice(quote) : failed ? 'Unavailable' : paused ? 'Not fetched' : 'Waiting…'}
          </Text>
          const change = <Text color={quote ? changeColor(quote.changePercent) : undefined} dimColor={!quote}>
            {quote ? formatChange(quote.changePercent) : '—'}
          </Text>
          const stale = quote ? formatStaleDate(quote.timestamp, now) : ''
          const meta = quote ? [quote.name, stale && `As of ${stale}`,
            !!quote.delaySeconds && `Delay ${Math.ceil(quote.delaySeconds / 60)}m`].filter(Boolean).join(' · ') : ''
          // minWidth 0 lets a long name truncate instead of pushing the row's
          // button out of a narrow Desktop pane (flex items default to content width).
          return <Box key={`ticker-${symbol}`} flexDirection="column" width="100%" marginTop={index ? rowGap : 0}>
            <Box gap={2} alignItems="center" width="100%">
              <Box flexDirection="column" flexGrow={1} flexShrink={1} minWidth={0}>
                <Text bold wrap="truncate">{symbol}</Text>
                {!compact && meta && <Text dimColor wrap="truncate">{meta}</Text>}
              </Box>
              {!compact && <Box flexDirection="column" alignItems="flex-end" flexShrink={0}>{price}{change}</Box>}
              <Button key={`remove-${symbol}`} label="Remove" dimColor={!desktop} onPress={() => action(() => watch.remove(symbol))} />
            </Box>
            {compact && <Box gap={2}>{price}{change}</Box>}
            {compact && meta && <Text dimColor wrap="truncate">{meta}</Text>}
            {failed && <Text color="warning" wrap="wrap">{quote ? 'Cached quote · ' : ''}{failed}</Text>}
          </Box>
        })}
      </Box>

      <Box key="footer" flexDirection="column" marginTop={space}>
        <Text dimColor wrap="wrap">
          {watch.preferences.symbols.some(isCryptoPair)
            ? 'Yahoo Finance · Binance Spot · Stocks: regular session, exchange delays vary · Crypto: 24h change · Times are local · '
            : 'Yahoo Finance · Regular-session quotes · Exchange delays vary · Times are local · '}
          <Link href="https://www.pulseticker.app/">pulseticker.app</Link>
        </Text>
        {!desktop && <Text dimColor wrap="wrap">Tab: move between controls · Enter: activate · Esc: return to prompt</Text>}
      </Box>
    </Box>
  })
ライセンスの全文(MIT)
MIT License

Copyright (c) 2026 fatwang2

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

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

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

入れる

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

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

/plugin marketplace add fatwang2/Pulse
/plugin install pulse-cc@pulse

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

Claude に聞く

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

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

Claude から探す: MCP コネクタ

似たデザイン