pace
Shows when a session gets heavy or its prompt cache is about to go cold, and parks a session so the next one can resume it
何をするか
- プロンプトの上の帯・欄・トーストを描く
- /pace-now・/pace-park・/pace-help・/pace-close を足す
- classic.SessionStart・engine.create・prompt.submit・session.end ほか 3 個にフックする
- プロセスを起こす
良いところ
- ネットワークに出ない
- TypeScript で書かれている
- エラーを扱う
- ファイルを書かない
作り始めるためのコード
2 種類あります。上のデザインから modscode が書いた雛形と、その Mod 自身のコードのうち描いている部分です。
雛形(register.tsx)
import type { Register } from 'claude-code'
// Drawn like pace by Asitha Weerasinghe (pane, band, status, toast), as modscode read it from the mod's code:
// https://modscode.com/gallery/asitha-w-pace/
// 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, Button } = $.ui.resolve(e)
const ICON = '…'
const text = '…'
const hint = '…'
const age = '…'
const title = '…'
const k = '…'
const length = '…'
const old = '…'
return (
<Box flexDirection="column">
<Box flexDirection="row" gap={1}>
<Text color="red" wrap="truncate">
{`${ICON} pace ${text} · ${hint}`}
</Text>
<Button label="1 park" hotkey="1" />
<Button label="2 dismiss" hotkey="2" />
</Box>
<Box flexDirection="row" gap={1}>
<Text dimColor wrap="truncate">
{`pace: resume point ${age} · ${title} · ${k}`}
</Text>
<Button label="3 resume" hotkey="3" />
<Button label="4 discard" hotkey="4" />
<Button label={`5 all ${length}`} hotkey="5" />
</Box>
<Box flexDirection="row" gap={1}>
<Text dimColor>
{`pace: ${old} resume point older than 7 days`}
</Text>
<Button label="6 clear" hotkey="6" />
</Box>
{await next(e)}
</Box>
)
})
// the pane: open it with $.ui.open({ id: 'my-pane', title: "pace · park" })
on('ui.render', { component: 'Pane', requestId: 'my-pane' }, async ($, e) => {
const { Box, Button, Text } = $.ui.resolve(e)
const label = '…'
const value = '…'
const label2 = '…'
const value2 = '…'
const label3 = '…'
const value3 = '…'
return (
<Box flexDirection="column">
<Button label="close" role="dismiss" />
<Box flexDirection="row">
<Text dimColor>
{label}
</Text>
<Text>
{value}
</Text>
</Box>
<Box flexDirection="row">
<Text dimColor>
{label2}
</Text>
<Text>
{value2}
</Text>
</Box>
<Box flexDirection="row">
<Text dimColor>
{label3}
</Text>
<Text>
{value3}
</Text>
</Box>
</Box>
)
})
on('session.start', async ($, e, next) => {
const location = '…'
await $.ui.toast(`pace: parking, writing the summary…`)
await $.ui.toast(`pace: parked → ${location}`)
return next(e)
})
}
Mod 自身のコード
Mod のライセンス(MIT)に従って載せています。全文は下にあります。写すときは著作権表示を残してください。
hooks/register.tsx 394〜451 行 · バンド
on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
if (e.props.hasSurvey || e.props.isWorking) return next(e)
const b = await read($, band)
const hidden = await read($, dismissed)
const points = await read($, resume)
const now = await $.clock.now()
const kind = BAND_ORDER.find(one => isBandKind(one) && b[one] !== undefined && !hidden.includes(one))
const fresh = points.filter(p => now - p.createdMs < OLD_MS)
const old = points.length - fresh.length
if (!kind && points.length === 0) return next(e)
const { Box, Button, Text } = $.ui.resolve(e)
const s = kind && isBandKind(kind) ? b[kind] : undefined
const beneath = await next(e)
return (
<Box flexDirection="column">
{s && kind && (
<Box key="signal" flexDirection="row" gap={1}>
<Text color={kind === 'cold' ? 'red' : 'yellow'} wrap="truncate">
{`${ICON[kind]} pace ${s.text}${s.hint ? ` · ${s.hint}` : ''}`}
</Text>
<Button key="park" label="1 park" hotkey="1" onPress={() => void openPark($, kind)} />
<Button key="dismiss" label="2 dismiss" hotkey="2" onPress={() => void update($, dismissed, l => [...l, kind])} />
</Box>
)}
{fresh[0] && (
<Box key="resume" flexDirection="row" gap={1}>
<Text dimColor wrap="truncate">
{`pace: resume point ${age(now - fresh[0].createdMs)} · ${fresh[0].title} · ${k(fresh[0].context)}`}
</Text>
<Button key="resume-go" label="3 resume" hotkey="3" onPress={() => void doResume($, fresh[0])} />
<Button key="resume-drop" label="4 discard" hotkey="4" onPress={() => void removePoints($, [fresh[0].path])} />
{points.length > 1 && (
<Button
key="resume-list"
label={`5 all ${points.length}`}
hotkey="5"
onPress={() => void $.ui.open({ id: RESUME_PANE, title: 'pace · resume points', focus: true, closeOnEscape: true })}
/>
)}
</Box>
)}
{old > 0 && (
<Box key="old" flexDirection="row" gap={1}>
<Text dimColor>{`pace: ${old} resume point${old === 1 ? '' : 's'} older than 7 days`}</Text>
<Button
key="old-clear"
label="6 clear"
hotkey="6"
onPress={() => void removePoints($, points.filter(p => now - p.createdMs >= OLD_MS).map(p => p.path))}
/>
</Box>
)}
{beneath}
</Box>
)
})hooks/register.tsx 453〜486 行 · ペイン
on('ui.render', { component: 'Pane', requestId: NOW_PANE }, async ($, e) => {
const { Box, Button, Text } = $.ui.resolve(e)
const n = await read($, nowState)
if (!n) return <Text dimColor>pace: no figures yet.</Text>
const left = n.cacheRemainingMs
const cache = left === undefined ? 'no request yet' : left > 0 ? `${Math.ceil(left / 60_000)}m left` : 'cold'
const rows: [string, string][] = [
['context', `${k(n.context)} of ${k(n.window)}${n.percent !== undefined ? ` (${Math.round(n.percent)}%)` : ''}`],
['turns', String(n.turns)],
['cache', cache],
['last request', `read ${k(n.lastRead)} · wrote ${k(n.lastWrite)}`],
['re-writes', String(n.rewrites)],
...n.rateLimits.map(
r => [r.kind, `${Math.round(r.percentUsed)}%${r.resetsAt ? ` · resets ${r.resetsAt}` : ''}`] as [string, string],
),
['cost', n.costUsd !== undefined ? `$${n.costUsd.toFixed(2)}` : '—'],
['signals', n.active.length > 0 ? n.active.join(', ') : 'none'],
...n.captures.map(
(c, i) =>
[i === 0 ? 'work' : '', `${i === 0 ? 'started' : i === n.captures.length - 1 ? 'now' : 'then'} at ${k(c.context)}: ${c.drifted ? '⇄ ' : ''}${c.text}${c.why ? ` (${c.why})` : ''}`] as [string, string],
),
]
return (
<Box flexDirection="column">
<Button key="close" label="close" role="dismiss" onPress={() => void $.ui.close({ id: NOW_PANE })} />
{rows.map(([label, value], i) => (
<Box key={`${label}${i}`} flexDirection="row">
<Text dimColor>{label.padEnd(14)}</Text>
<Text>{value}</Text>
</Box>
))}
</Box>
)
})ライセンスの全文(MIT)
MIT License Copyright (c) 2026 Asitha Weerasinghe 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 に読んだコミット e4457e5f8302 のソースから。最初のまとまりが載せる条件で、残りは自分で判断するための材料です。後のコミットは、次に読むまで見ていません。
| 載せる条件: 確かめやすいコード | |
|---|---|
| 入口を読んだ | hooks/hooks.json が名指すモジュールをすべて読んだ。hooks/register.tsx |
| 解析できる | すべてのファイルが TypeScript か JavaScript として解析できる。2 ファイルを解析 |
| コードが 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:118 rm(Windows にない) |
| 通信 | fetch の送り先(https のホスト)がコードに書いてあるか。通信なし |
| プログラム | 起動するプログラムの名前がコードに書いてあり、シェル・インタプリタ・通信用の道具でないか。rm |
| 読んで送る | ファイルや環境変数を読み、かつ通信するか。通信しない |
| ソースの鍵 | ソースに API キーや秘密鍵らしきものがあるか。ソースに鍵なし |
| ライセンス | オープンなライセンス(MIT・Apache-2.0・BSD・ISC・Unlicense・0BSD・CC0)で全文があれば、modscode にコードを載せる。違えばリンクだけ。MIT |
コードの文面を読んだだけで、安全の審査ではありません。動かしてはおらず、起動するプログラムの中で何が起きるかも見えません。入れる前の確認はあなたの役目です。 載せる条件
入れる
入れる前に、必ず自分で確かめてください。Mod はサンドボックスなしで、あなたの権限で動きます。modscode はこのコードの安全を保証しません。下のコードを読み(またはフォルダーで claude plugin validate .)、触るものを見て、読んだコミットを入れてください。
リポジトリがそのままマーケットプレイスです。このマーケットプレイスを足し(ターミナルでは次のコマンド、デスクトップアプリではプラグインの設定)、そこから Mod を入れます。
/plugin marketplace add asitha-w/pace/plugin install pace@asitha-w入るのはマーケットプレイスの最新のコミットで、ここで読んだもの(e4457e5f8302)と違うことがあります。入れる前に見比べてください。
Claude に聞く
modscode のコネクタを入れると、Claude がこのデザイン・コードが触るもの・コードを読んで、それをもとに作れます。たとえば:
modscode のデザイン「asitha-w-pace」をコードごと読んで、同じようなペインを作って似たデザイン
-
Claude に頼む…agent-discoverbuildbuildbuildRefreshMCP Browse/3Tab / shift+Tab move · Enter presses · ↑↓ scroll · Esc back to the promptBrowse...Audit asks:DeclineAcceptDeclineCancelAudit asks:DeclineAcceptDeclineCancelAudit asks:DeclineAcceptDeclineCancel
-
Claude に頼む…Prompt cacheexpired · LowTTL Cache breaks · last hit 0 · ctx 42%extending…This conversationavg hit – · req English · breaks Compact · extended Compact · peak ctx 12.4kPer request · token cost■ read ×0.1■ write□ miss▬▬▬ hit rate▬ break┊ idle near expiry▲ extendedCache breaksnone● Low Extend● Low Extend● Low ExtendBreak sensitivityEnglishHigher counts smaller drops as breaks; applies from the next requestExtensionsnone2h 10m · English · 32h 10m · English · 32h 10m · English · 3SettingsWhen about to expireLowAuto-extend per idle stretch2h 10mToast notificationsDetailsCache TTLautoPrompt cacheBand above the promptOffBreak sensitivityEnglishHigher counts smaller drops as breaks; applies from the next requestLanguageen
-
Claude に頼む…clawdifybuild 3build 3build 3Presets layer on top of what you have. Reset first for a clean slate.Empty = Claude Code default · lists are comma-separated · tokens {model} {cwd} {time} {date}buildbuildbuildYours bring back exactly the look you saved. /clawdify delete <name> removes one.buildbuildbuildSave current as my-look savecopy JSONreset allWhile thinking
-
Councilmodeaskdeepshow14:32?hideGeminiGeminiGeminiClaude に頼む…Review: deep, once · Request
-
Claude に頼む…QuestList 1 Kanban 2Fleet f This repo l Refs g Refresh r Normal size z Collapse cOpen FilterokAll reposDoneClosedClose itList* marks a task whose refs disagree about its status; origin/dev is drawn where it has one. Resolving it is that reposit…New task in acme/app CreateClosed tracker change in acme/app not committed yet. Until they land, this repository's other checkouts cannot see the ids in them and can mint the same… Ask Claude to land them⋯
-
何をするか
- 欄・プロンプトの上の帯・ステータス行を描く
- /pet を足す
- ツールの呼び出しを見張る(止めることがある)
- prompt.submit・session.end・session.start・turn.complete ほか 2 個にフックする