modscode / 図鑑 / clayfold-monitor
clayfold-monitor
Clayfold server and frontend statistics and the Claude Code instances the server runs, in a pane
何をするか
- 欄・トーストを描く
- ツールの呼び出しを見張る
- session.startにフックする
- ネットワークに出る
- プロセスを起こす
良いところ
- 小さい(348 行)
- TypeScript で書かれている
- デスクトップ専用の分岐がある
- エラーを扱う
作り始めるためのコード
2 種類あります。上のデザインから modscode が書いた雛形と、その Mod 自身のコードのうち描いている部分です。
雛形(register.tsx)
import type { Register } from 'claude-code'
// Drawn like clayfold-monitor by VinniZP (pane, status, toast), as modscode read it from the mod's code:
// https://modscode.com/gallery/vinnizp-clayfold-monitor/
// 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: "Clayfold" })
on('ui.render', { component: 'Pane', requestId: 'my-pane' }, async ($, e) => {
const { Box, Text, Link, Button } = $.ui.resolve(e)
const since = '…'
const appUrl = '…'
const pid = '…'
const bun = '…'
const port = '…'
const mb = '…'
const mb2 = '…'
const pct = '…'
const mb3 = '…'
const model = '…'
const criticModel = '…'
const usd = '…'
const vitePort = '…'
const streams = '…'
const length = '…'
const kind = '…'
const elapsed = '…'
const label = '…'
const label2 = '…'
const label3 = '…'
const instanceMeta = '…'
const key = '…'
const kind2 = '…'
const elapsed2 = '…'
const label4 = '…'
const label5 = '…'
const label6 = '…'
const instanceMeta2 = '…'
const kind3 = '…'
const elapsed3 = '…'
const label7 = '…'
const label8 = '…'
const label9 = '…'
const instanceMeta3 = '…'
const finishedText = '…'
const since2 = '…'
const finishedText2 = '…'
const since3 = '…'
const finishedText3 = '…'
const since4 = '…'
return (
<Box flexDirection="column">
<Text>
<Text bold>
Backend
</Text>
{" "}
<Text color="green">
up
</Text>
{" "}
{since}
{" "}
<Link href={`${appUrl}`} label="open app" />
</Text>
<Text wrap="truncate-end">
{"PID "}
{pid}
{" · Bun "}
{bun}
{" · :"}
{port}
</Text>
<Text wrap="truncate-end">
{mb}
{" (heap "}
{mb2}
{") · CPU "}
{pct}
{" · DB "}
{mb3}
</Text>
<Text dimColor wrap="truncate-end">
{model}
{", critic "}
{criticModel}
{" · "}
{usd}
{" per run"}
</Text>
<Text>
{" "}
</Text>
<Text bold>
Frontend
</Text>
<Text wrap="truncate-end">
{"web/dist "}
{`built ${since} ago`}
</Text>
<Text>
Vite :
{vitePort}
{" "}
<Text color="green">
up
</Text>
</Text>
<Text dimColor>
{streams}
{" open event stream"}
</Text>
<Text>
{" "}
</Text>
<Text bold>
{"Claude Code instances: "}
{length}
</Text>
<Text dimColor>
None running.
</Text>
<Box flexDirection="column" marginTop={1}>
<Text wrap="truncate-end">
<Text color="magenta">
{kind}
</Text>
{" "}
<Text bold>
—
</Text>
{" "}
<Text color="yellow">
{elapsed}
{" long run"}
</Text>
</Text>
<Text wrap="truncate-end">
{" "}
{label}
</Text>
<Text wrap="truncate-end">
{" "}
{label2}
</Text>
<Text wrap="truncate-end">
{" "}
{label3}
</Text>
<Text dimColor wrap="truncate-end">
{instanceMeta}
</Text>
<Box flexDirection="row" gap={2}>
<Button hotkey={`${key}`} dimColor>
stop
</Button>
<Link href={`${appUrl}`} label="open in browser" />
</Box>
</Box>
<Box flexDirection="column" marginTop={1}>
<Text wrap="truncate-end">
<Text color="magenta">
{kind2}
</Text>
{" "}
<Text bold>
—
</Text>
{" "}
<Text color="yellow">
{elapsed2}
{" long run"}
</Text>
</Text>
<Text wrap="truncate-end">
{" "}
{label4}
</Text>
<Text wrap="truncate-end">
{" "}
{label5}
</Text>
<Text wrap="truncate-end">
{" "}
{label6}
</Text>
<Text dimColor wrap="truncate-end">
{instanceMeta2}
</Text>
<Box flexDirection="row" gap={2}>
<Button hotkey={`${key}`} dimColor>
stop
</Button>
<Link href={`${appUrl}`} label="open in browser" />
</Box>
</Box>
<Box flexDirection="column" marginTop={1}>
<Text wrap="truncate-end">
<Text color="magenta">
{kind3}
</Text>
{" "}
<Text bold>
—
</Text>
{" "}
<Text color="yellow">
{elapsed3}
{" long run"}
</Text>
</Text>
<Text wrap="truncate-end">
{" "}
{label7}
</Text>
<Text wrap="truncate-end">
{" "}
{label8}
</Text>
<Text wrap="truncate-end">
{" "}
{label9}
</Text>
<Text dimColor wrap="truncate-end">
{instanceMeta3}
</Text>
<Box flexDirection="row" gap={2}>
<Button hotkey={`${key}`} dimColor>
stop
</Button>
<Link href={`${appUrl}`} label="open in browser" />
</Box>
</Box>
<Box flexDirection="column" marginTop={1}>
<Text bold>
Recently finished
</Text>
<Text wrap="truncate-end" color="red">
{finishedText}
{" · "}
{since2}
{" ago"}
</Text>
<Text wrap="truncate-end" color="red">
{finishedText2}
{" · "}
{since3}
{" ago"}
</Text>
<Text wrap="truncate-end" color="red">
{finishedText3}
{" · "}
{since4}
{" ago"}
</Text>
</Box>
</Box>
)
})
on('session.start', async ($, e, next) => {
const message = '…'
await $.ui.toast(`Clayfold: stopping the run…`)
await $.ui.toast(`Clayfold: stop failed: ${message}`)
return next(e)
})
}
Mod 自身のコード
読んだコミットにライセンスの全文が見つからなかったため、ソースの場所へのリンクだけにしています。
コードが呼ぶもの
通信プログラム起動ファイル読み取りツール呼び出し
コードから読み取ったデザイン
読み取ったコミットのソースから描いたもので、動かした結果ではありません。一覧は 3 回描き、条件はデスクトップアプリで描く最初の分岐を取り、動かしたときにだけ決まる値は仮の例(点線の下線)にするか省きます。色と書体はこのサイトのものです。
コードから読めること
2026-10-06 に読んだコミット a5f8ed84c832 のソースから。最初のまとまりが載せる条件で、残りは自分で判断するための材料です。後のコミットは、次に読むまで見ていません。
| 載せる条件: 確かめやすいコード | |
|---|---|
| 入口を読んだ | hooks/hooks.json が名指すモジュールをすべて読んだ。.claude/skills/clayfold-monitor/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/… などは無い)。Windows にないプログラムを使わない |
| 通信 | fetch の送り先(https のホスト)がコードに書いてあるか。.claude/skills/clayfold-monitor/hooks/register.tsx:92 fetch(`http://127.0.0.1:${port}/api/system`); .claude/skills/clayfold-monitor/hooks/register.tsx:108 fetch(`http://localhost:${config.vitePort}/`); .claude/skills/clayfold-monitor/hooks/register.tsx:133 fetch(`http://127.0.0.1:${port}/api/conversations/${enco) |
| プログラム | 起動するプログラムの名前がコードに書いてあり、シェル・インタプリタ・通信用の道具でないか。.claude/skills/clayfold-monitor/hooks/register.tsx:159 bun(シェル・インタプリタ) |
| 読んで送る | ファイルや環境変数を読み、かつ通信するか。読んだうえで通信する |
| ソースの鍵 | ソースに API キーや秘密鍵らしきものがあるか。ソースに鍵なし |
| ライセンス | オープンなライセンス(MIT・Apache-2.0・BSD・ISC・Unlicense・0BSD・CC0)で全文があれば、modscode にコードを載せる。違えばリンクだけ。AGPL-3.0(オープンなライセンスではない) |
コードの文面を読んだだけで、安全の審査ではありません。動かしてはおらず、起動するプログラムの中で何が起きるかも見えません。入れる前の確認はあなたの役目です。 載せる条件
入れる
入れる前に、必ず自分で確かめてください。Mod はサンドボックスなしで、あなたの権限で動きます。modscode はこのコードの安全を保証しません。下のコードを読み(またはフォルダーで claude plugin validate .)、触るものを見て、読んだコミットを入れてください。
リポジトリの .claude-plugin/marketplace.json にこの Mod が載っていないため、入れる手順は出せません。コードとして読むか、作者の README に従ってください。
Claude に聞く
modscode のコネクタを入れると、Claude がこのデザイン・コードが触るもの・コードを読んで、それをもとに作れます。たとえば:
modscode のデザイン「vinnizp-clayfold-monitor」をコードごと読んで、同じようなペインを作って似たデザイン
-
✦ explain as pick how Claude answers×3 ● build3 ● build3 ● build▸ VideoClaude に頼む…
-
Claude に頼む…Could not fetch PRs: PortuguesePR Inbox▍readbuildFix login━━━━━━━━Koreanq buildStill fetching · q goes back
-
Claude に頼む…CIcross Bash · Classicmain · a1b2c3d · failed at 14:32Open the run on GitHubFix it fClose x
(no log available)
-
Claude に頼む…GitHub inboxGitHubloading…Refresh rbuildbuildbuildClose xStealth IssuesNo open issues in this view.#3 Fix login · Pinned notice · 2h 10m · Top row commentsWork on itopen#3 Fix login · Pinned notice · 2h 10m · Top row commentsWork on itopen#3 Fix login · Pinned notice · 2h 10m · Top row commentsWork on itopenPull requestsNo open pull requests.#3 Fix login · main · draft · build · HiddenChecksReviewopen#3 Fix login · main · draft · build · HiddenChecksReviewopen#3 Fix login · main · draft · build · HiddenChecksReviewopenChecks for #3Plain
-
授权已失效,请在 Web 重新授权拆分已不能决定,已刷新Claude に頼む…
-
Claude に頼む…CI#3 Fix loginRefresh● build● build● buildRefreshRe-run failedRefresh