modscode EN

modscode / 図鑑 / cozy-clawd

cozy-clawd

An unofficial fan mod: a cozy pixel-art band above the prompt where Clawd acts out what Claude is doing, beside a scene of session meters

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

何をするか

  • プロンプトの上の帯・欄を描く
  • ツールの呼び出しを見張る(止めることがある)
  • classic.Elicitation・classic.ElicitationResult・classic.PermissionRequest・classic.SessionStart ほか 7 個にフックする
  • ターンをまたいで自分の状態を持つ
  • プロセスを起こす

良いところ

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

作り始めるためのコード

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

雛形(register.tsx)

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

// Drawn like cozy-clawd by OrihuelaConde (pane, band, toast), as modscode read it from the mod's code:
// https://modscode.com/gallery/orihuelaconde-cozy-clawd/
// 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, Svg, Markdown, Text, Button } = $.ui.resolve(e)
    const svgFor = '…'
    const label = '…'
    const compactAsk = '…'
    const yes = '…'
    const no = '…'
    const svg = '…'
    const metersAlt = '…'
    return (
      <Box flexDirection="column">
        <Box flexDirection="row" alignItems="center" justifyContent="space-between" gap={2}>
          <Box flexDirection="row" alignItems="center" gap={1}>
            <Svg source={`${svgFor}`} alt={`Clawd: ${label}`} />
            <Markdown text={`### ${label}…`} dimColor />
          </Box>
          <Box flexDirection="row" alignItems="center" gap={1}>
            <Box flexDirection="row" alignItems="center" gap={1}>
              <Text dimColor>
                {compactAsk}
              </Text>
              <Button label={`${yes}`} variant="primary" />
              <Button label={`${no}`} />
            </Box>
            <Svg source={`${svg}`} alt={`${metersAlt}`} />
          </Box>
        </Box>
        {await next(e)}
      </Box>
    )
  })

  // the pane: open it with $.ui.open({ id: 'my-pane', title: "‹panelTitle›" })
  on('ui.render', { component: 'Pane', requestId: 'my-pane' }, async ($, e) => {
    const { Box, Text, Svg } = $.ui.resolve(e)
    const language = '…'
    const choiceName = '…'
    const choiceName2 = '…'
    const choiceName3 = '…'
    const pickScene = '…'
    const svg = '…'
    const label = '…'
    const metersAlt = '…'
    const inUse = '…'
    const label2 = '…'
    const inUse2 = '…'
    const label3 = '…'
    const inUse3 = '…'
    return (
      <Box flexDirection="column" gap={1} paddingY={1}>
        <Box flexDirection="row" flexWrap="wrap" alignItems="center" gap={1}>
          <Text dimColor>
            {language}
            :
          </Text>
          <Text bold>
            {choiceName}
          </Text>
          <Text bold>
            {choiceName2}
          </Text>
          <Text bold>
            {choiceName3}
          </Text>
        </Box>
        <Text dimColor>
          {pickScene}
        </Text>
        <Box flexDirection="column" alignItems="center" gap={1} padding={1} borderStyle="round" borderColor="#D97757">
          <Svg source={`${svg}`} alt={`${label}: ${metersAlt}`} />
          <Box flexDirection="row" alignItems="center" gap={1}>
            <Text bold>
              {label}
            </Text>
            <Text dimColor>
              {inUse}
            </Text>
          </Box>
        </Box>
        <Box flexDirection="column" alignItems="center" gap={1} padding={1} borderStyle="round" borderColor="#D97757">
          <Svg source={`${svg}`} alt={`${label}: ${metersAlt}`} />
          <Box flexDirection="row" alignItems="center" gap={1}>
            <Text bold>
              {label2}
            </Text>
            <Text dimColor>
              {inUse2}
            </Text>
          </Box>
        </Box>
        <Box flexDirection="column" alignItems="center" gap={1} padding={1} borderStyle="round" borderColor="#D97757">
          <Svg source={`${svg}`} alt={`${label}: ${metersAlt}`} />
          <Box flexDirection="row" alignItems="center" gap={1}>
            <Text bold>
              {label3}
            </Text>
            <Text dimColor>
              {inUse3}
            </Text>
          </Box>
        </Box>
      </Box>
    )
  })
}

Mod 自身のコード

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

hooks/register.tsx 1788〜1916 行 · バンド
  on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
    if (e.props.hasSurvey) {
      forgetPictures(e.requestId)
      return next(e)
    }

    const lang = langOn(e.surface, await langNow($))
    const t = TEXTS[lang]
    const drawnMode = await read($, mode)
    // A turn that ended without telling (an interruption) leaves no stale mode.
    const isIdle = !e.props.isWorking && drawnMode !== 'compacting' && drawnMode !== 'compacted'
    const now = await $.clock.now()
    const meters = metersOf(await statsNow($), now, drawnMode === 'compacting')
    // No Compact while a compaction runs.
    const isLow = drawnMode !== 'compacting' && meters.contextLeft !== null && meters.contextLeft <= COMPACT_AT
    await read($, redraws)
    const isAsking = await read($, isConfirming)
    const meterScene = meterSceneNamed(await read($, sceneName))
    const { scene, label, pick } = isIdle ? idleScene(meters, now) : sceneFor(drawnMode, await read($, tool), shownAt, now)
    const isOngoing = !isIdle && drawnMode !== 'compacted'

    // The terminal's band: Clawd and the meters as pictures of block
    // characters, Clawd's state beside it, in the size the person picked: the
    // small scenes (hooks/small.ts), or the large ones the desktop shows.
    // A scene of meters with no small drawing shows its large one. Where
    // both don't fit, Clawd with the meters in words; where Clawd doesn't
    // either, words alone.
    if (e.surface === 'terminal') {
      const { Box, Button, Raster, Text } = $.ui.resolve(e)
      const bg = await terminalBackground($)
      const said = `${label[lang]}${isOngoing ? '…' : ''}`
      const isSmall = (await read($, sizeName)) === 'small'
      const clawd = isSmall ? pictureOf(smallSvg(smallScene(pick)), 'quadrants') : pictureOf(svgFor(scene))
      const drawing = isSmall ? meterScene.small : undefined
      const metersPicture = pictureOf(drawing === undefined ? meterScene.svg(meters) : drawing.svg(meters))
      const numbers = drawing === undefined ? null : numbersPicture(meters, drawing.centers, metersPicture.columns)
      const controls = isAsking ? (
        <Box flexDirection="row" alignItems="center" gap={1}>
          <Text dimColor>{t.compactAsk}</Text>
          <Button key="compact-yes" label={t.yes} variant="primary" onPress={() => compactNow($, e.props.isWorking, lang)} />
          <Button key="compact-no" label={t.no} onPress={() => update($, isConfirming, () => false)} />
        </Box>
      ) : (
        // A Button alone keeps to the top of the band's row; in a Box it centers.
        isLow && (
          <Box>
            <Button key="compact" label={t.compact} onPress={() => update($, isConfirming, () => true)} />
          </Box>
        )
      )
      // A Button draws as `[ label ]` here.
      const controlsWidth = isAsking ? columnsOf(t.compactAsk) + columnsOf(t.yes) + columnsOf(t.no) + 10 : isLow ? columnsOf(t.compact) + 4 : 0
      const room = e.props.bodyColumns - MARK_COLUMNS
      const minLabel = MIN_LABEL_COLUMNS[lang]
      const labelRoom = room - clawd.columns - 1 - 2 - (controlsWidth > 0 ? controlsWidth + 1 : 0) - metersPicture.columns
      const fitsAll = labelRoom >= minLabel && e.props.maxRows >= metersPicture.rows + (numbers?.rows ?? 0)
      const fitsClawd = room - clawd.columns - 1 >= minLabel && e.props.maxRows >= clawd.rows
      forgetOtherSites(e.requestId)
      forgetPictures(e.requestId, fitsAll ? ['clawd', 'meters', ...(numbers === null ? [] : ['numbers'])] : fitsClawd ? ['clawd'] : [])

      if (fitsAll) {
        return (
          <Box flexDirection="row" alignItems="center" justifyContent="space-between" gap={2} paddingRight={MARK_COLUMNS}>
            <Box flexDirection="row" alignItems="center" gap={1}>
              <Raster key="clawd" columns={clawd.columns} rows={clawd.rows} cells={livePicture($, e.requestId, 'clawd', clawd, now, bg)} />
              <Box width={Math.min(columnsOf(said), labelRoom)}>
                <Text bold wrap="wrap">
                  {said}
                </Text>
              </Box>
            </Box>
            <Box flexDirection="row" alignItems="center" gap={1}>
              {controls}
              <Box flexDirection="column">
                <Raster key="meters" columns={metersPicture.columns} rows={metersPicture.rows} cells={livePicture($, e.requestId, 'meters', metersPicture, now, bg)} />
                {numbers && <Raster key="numbers" columns={numbers.columns} rows={numbers.rows} cells={livePicture($, e.requestId, 'numbers', numbers, now, bg)} />}
              </Box>
            </Box>
          </Box>
        )
      }
      const words = (
        <Box flexDirection="column" gap={1} width={fitsClawd ? room - clawd.columns - 1 : room}>
          <Text bold wrap="wrap">
            {fitsClawd ? said : `Clawd: ${said}`}
          </Text>
          <Text dimColor wrap="wrap">
            {metersAlt(meters, lang)}
          </Text>
          {controls}
        </Box>
      )
      return fitsClawd ? (
        <Box flexDirection="row" alignItems="center" gap={1} paddingRight={MARK_COLUMNS}>
          <Raster key="clawd" columns={clawd.columns} rows={clawd.rows} cells={livePicture($, e.requestId, 'clawd', clawd, now, bg)} />
          {words}
        </Box>
      ) : (
        <Box paddingRight={MARK_COLUMNS}>{words}</Box>
      )
    }

    const { Box, Button, Markdown, Svg, Text } = $.ui.resolve(e)
    return (
      <Box flexDirection="row" alignItems="center" justifyContent="space-between" gap={2}>
        <Box flexDirection="row" alignItems="center" gap={1}>
          <Svg source={svgFor(scene)} alt={`Clawd: ${label[lang]}`} width={VIEW_W * SCALE} height={VIEW_H * 2 * SCALE} />
          <Markdown text={`### ${label[lang]}${isOngoing ? '…' : ''}`} dimColor />
        </Box>
        <Box flexDirection="row" alignItems="center" gap={1}>
          {isAsking ? (
            <Box flexDirection="row" alignItems="center" gap={1}>
              <Text dimColor>{t.compactAsk}</Text>
              <Button key="compact-yes" label={t.yes} variant="primary" onPress={() => compactNow($, e.props.isWorking, lang)} />
              <Button key="compact-no" label={t.no} onPress={() => update($, isConfirming, () => false)} />
            </Box>
          ) : (
            isLow && <Button key="compact" label={t.compact} onPress={() => update($, isConfirming, () => true)} />
          )}
          <Svg
            source={meterScene.svg(meters)}
            alt={metersAlt(meters, lang)}
            width={meterScene.width * meterScene.scale}
            height={meterScene.height * meterScene.scale}
          />
        </Box>
      </Box>
    )
  })
hooks/register.tsx 1922〜2013 行 · ペイン
  on('ui.render', { component: 'Pane', requestId: PANEL }, async ($, e) => {
    isPanelFocused = e.props.isFocused
    await read($, redraws)
    const lang = langOn(e.surface, await langNow($))
    const t = TEXTS[lang]
    const choice = await read($, langChoice)
    const auto = langName(e.surface, await detectedLang($))
    const choiceName = (c: LangChoice) => (c === 'auto' ? t.auto(auto) : langName(e.surface, c))
    const shown = meterSceneNamed(await read($, sceneName)).name
    if (e.surface === 'terminal') {
      const { Box, Select, Text } = $.ui.resolve(e)
      const shownMode = await read($, mode)
      const now = await $.clock.now()
      const { label } =
        shownMode === 'idle' ? idleScene(metersOf(await statsNow($), now), now) : sceneFor(shownMode, await read($, tool), shownAt, now)
      const isOngoing = shownMode !== 'idle' && shownMode !== 'compacted'

      return (
        <Box flexDirection="column">
          <Text>{isOngoing ? `${label[lang]}…` : label[lang]}</Text>
          <Select
            key="scene"
            label={t.scene}
            options={METER_SCENES.map(s => ({ value: s.name, label: s.label[lang] }))}
            value={shown}
            onSelect={name => chooseMeterScene($, name)}
          />
          <Select
            key="language"
            label={t.language}
            options={LANG_CHOICES.map(c => ({ value: c, label: choiceName(c) }))}
            value={choice}
            onSelect={value => chooseLang($, LANG_CHOICES.find(c => c === value) ?? 'auto')}
          />
          <Select
            key="size"
            label={t.size}
            options={SIZES.map(s => ({ value: s, label: t.sizes[s] }))}
            value={await read($, sizeName)}
            onSelect={value => chooseSize($, SIZES.find(s => s === value) ?? 'small')}
          />
        </Box>
      )
    }

    const { Box, Button, Svg, Text } = $.ui.resolve(e)
    const meters = metersOf(await statsNow($), await $.clock.now())

    return (
      <Box flexDirection="column" gap={1} paddingY={1}>
        <Box flexDirection="row" flexWrap="wrap" alignItems="center" gap={1}>
          <Text dimColor>{t.language}:</Text>
          {LANG_CHOICES.map(c =>
            c === choice ? (
              <Text key={`language-${c}`} bold>
                {choiceName(c)}
              </Text>
            ) : (
              <Button key={`language-${c}`} label={choiceName(c)} onPress={() => chooseLang($, c)} />
            ),
          )}
        </Box>
        <Text dimColor>{t.pickScene}</Text>
        {METER_SCENES.map(s => {
          const isInUse = s.name === shown

          return (
            <Box
              key={`scene-${s.name}`}
              flexDirection="column"
              alignItems="center"
              gap={1}
              padding={1}
              borderStyle="round"
              borderColor={isInUse ? BODY : undefined}
              borderDimColor={!isInUse}
            >
              <Svg source={s.svg(meters)} alt={`${s.label[lang]}: ${metersAlt(meters, lang)}`} width={s.width * s.scale} height={s.height * s.scale} />
              <Box flexDirection="row" alignItems="center" gap={1}>
                <Text bold>{s.label[lang]}</Text>
                {isInUse ? (
                  <Text dimColor>{t.inUse}</Text>
                ) : (
                  <Button key={`use-${s.name}`} label={t.use} onPress={() => chooseMeterScene($, s.name)} />
                )}
              </Box>
            </Box>
          )
        })}
      </Box>
    )
  })
ライセンスの全文(MIT)
MIT License

Copyright (c) 2026 José Luis Orihuela Conde

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.

コードが呼ぶもの

プログラム起動環境変数ツール呼び出し保存

コードから読めること

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

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

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

入れる

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

リポジトリの .claude-plugin/marketplace.json にこの Mod が載っていないため、入れる手順は出せません。コードとして読むか、作者の README に従ってください。

Claude に聞く

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

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

Claude から探す: MCP コネクタ

似たデザイン