weektoken
Rate-limit pace for Claude Code's 5-hour and weekly windows: usage against elapsed time, plain-language forecast, per-model quotas and burn-up history. A band above the prompt and a full /weektoken pane, in English or Chinese.
何をするか
- プロンプトの上の帯・欄を描く
- /weektoken を足す
- config.set・session.measure・session.start・turn.complete ほか 3 個にフックする
- ターンをまたいで自分の状態を持つ
- プロセスを起こす
良いところ
- ネットワークに出ない
- TypeScript で書かれている
- デスクトップ専用の分岐がある
- エラーを扱う
作り始めるためのコード
2 種類あります。上のデザインから modscode が書いた雛形と、その Mod 自身のコードのうち描いている部分です。
雛形(register.tsx)
import type { Register } from 'claude-code'
// Drawn like weektoken by mj0111 (pane, band, toast), as modscode read it from the mod's code:
// https://modscode.com/gallery/3dnow-weektoken/
// 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 } = $.ui.resolve(e)
return (
<Box flexDirection="column">
{await next(e)}
</Box>
)
})
// the pane: open it with $.ui.open({ id: 'my-pane', title: "WeekToken" })
on('ui.render', { component: 'Pane', requestId: 'my-pane' }, async ($, e) => {
const { Box, Button, Text, Svg } = $.ui.resolve(e)
const full = '…'
const L = '…'
const burnRate = '…'
const displayLabel = '…'
const displayHeadline = '…'
const second = '…'
const trendText = '…'
const map = '…'
const windowNote = '…'
const __full = '…'
const nl = '…'
const source = '…'
const alt = '…'
return (
<Box flexDirection="column" gap={1} paddingX={1}>
<Box flexDirection="row" alignItems="center">
<Box flexShrink={0}>
<Button label="❮" plain />
</Box>
<Box flexShrink={0} justifyContent="center">
<Text bold wrap="truncate-end">
{full}
</Text>
</Box>
<Box flexShrink={0}>
<Button label="❮" plain />
</Box>
</Box>
<Box flexDirection="row" gap={1}>
<Button label={`${L}`} variant="primary" />
<Button label={`${L}`} variant="primary" />
</Box>
<Box flexDirection="column" gap={1}>
<Box flexDirection="row" gap={1}>
<Text bold>
{`${burnRate}×`}
</Text>
<Text dimColor>
{displayLabel}
</Text>
</Box>
<Text bold>
{displayHeadline}
</Text>
<Text dimColor wrap="wrap">
{second}
</Text>
<Text dimColor>
{trendText}
</Text>
<Text>
{map}
</Text>
<Text dimColor>
?
{windowNote}
</Text>
<Box flexDirection="row" gap={2}>
<Button label={`${__full}`} hotkey="h" />
<Button label={`${full} ›`} hotkey="l" />
</Box>
</Box>
<Box flexDirection="row" alignItems="center" gap={1}>
<Text dimColor wrap="truncate-end">
{nl}
</Text>
<Box flexGrow={1} />
<Button label={`${L}`} />
<Button label={`${L}`} />
</Box>
<Box flexGrow={1} />
<Box flexDirection="row" justifyContent="flex-end">
<Svg source={`${source}`} alt={`${alt}`} />
</Box>
</Box>
)
})
}
Mod 自身のコード
Mod のライセンス(MIT)に従って載せています。全文は下にあります。写すときは著作権表示を残してください。
weektoken/hooks/register.tsx 1083〜1093 行 · バンド
on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
if (disabled || e.props.hasSurvey) return next(e)
if (((await read($, bandA)) ?? 'open') === 'hidden') return next(e)
await useLang($)
const show = (await read($, confirmHideA)) ? 'confirm' : await read($, bandShowA)
if (!show) return next(e)
const ours = show === 'confirm' ? drawConfirmHide($, e) : drawBand($, e, show, !!(await read($, paneOpenA)))
const below = await next(e)
const { Box } = $.ui.resolve(e)
return <Box flexDirection="column">{ours}{isBlank(below) ? null : below}</Box>
})weektoken/hooks/register.tsx 1095〜1106 行 · ペイン
on('ui.render', { component: 'Pane', requestId: PANE }, async ($, e) => {
const samples = (await read($, samplesA)) ?? []
const view = (await read($, viewA)) ?? DEFAULT_VIEW
const note = await read($, noteA)
const band = (await read($, bandA)) ?? 'open'
await useLang($)
const now = await $.clock.now()
const activity = (await read($, activityA)) ?? { byModel: {} }
const bandKey = (await read($, bandKeyA)) ?? null
paneVersion = (await read($, versionA)) ?? ''
return drawPane($, e, samples, activity, view, note, band, buildModel(samples, view, now, bandKey), now)
})weektoken/hooks/register.tsx 883〜957 行 · ペイン
function drawPane($: any, e: any, samples: readonly Sample[], activity: Activity, view: PaneView, note: Note, band: BandMode, m: Model, now: number) {
const { Box, Text, Button } = $.ui.resolve(e)
// At least as tall as the pane body (row count from the host; Box sizes are in rows on every surface); the spacer before the credit pushes it to the bottom
const fill = e.props?.scroll?.bodyRows ? Math.max(1, e.props.scroll.bodyRows) : '100%'
paneActions.clear()
paneSurface = e.surface
paneFocusedAtRender = !!e.props?.isFocused
const term = e.surface === 'terminal'
const sel = m.selected
const row = sel ? m.rows[sel] : undefined
const nl = noteLine(row, samples, activity, now)
const busy = isBusy(note, now)
const footer = (
<Box flexDirection="row" alignItems="center" gap={1}>
{nl ? <Text dimColor wrap="truncate-end">{nl}</Text> : null}
<Box flexGrow={1} />
<Button key="band-toggle" label={band === 'hidden' ? L('⊕ 显示横条', '⊕ Show band') : L('⊖ 隐藏横条', '⊖ Hide band')} onPress={paneAct('band-toggle', () => toggleBandHidden($))} />
<Button key="refresh" label={busy ? L('↻ 刷新中…', '↻ Refreshing…') : L('↻ 刷新', '↻ Refresh')} {...(term ? { hotkey: 'r' } : {})} onPress={paneAct('refresh', () => refreshAll($, true))} />
</Box>
)
if (!row) {
return (
<Box flexDirection="column" gap={term ? 1 : 2} paddingX={1} minHeight={fill}>
{drawEmpty($, e)}
{footer}
<Box flexGrow={1} />
{credit($, e)}
</Box>
)
}
// Desktop: quota-switch arrows flank the title, as on the band; the name cell is sized to the longest quota name so arrows don't move on switch.
// (Arrows used to sit at both ends of the ring row; once readings moved into the image it grew 50% wider and squeezed the arrows against the ring)
// The terminal pace tab has its own named buttons (h / l), so no title arrows
const headArrows = !term && m.keys.length > 1
const headArrow = (offset: -1 | 1) => {
const name = offset < 0 ? 'prev' : 'next'
return (
<Box key={`sw-${name}`} flexShrink={0}>
<Button
key={name}
label={offset < 0 ? '❮' : '❯'}
plain
hover={{ color: identityText(P.neighbor(row.key, m.keys, offset) as string), bold: true }}
onPress={paneAct(name, () => stepKey($, m.keys, row.key, offset))}
/>
</Box>
)
}
const title = <Text color={identityText(row.key)} bold wrap="truncate-end">{row.full}</Text>
const header = headArrows ? (
<Box flexDirection="row" alignItems="center">
{headArrow(-1)}
<Box flexShrink={0} width={Math.max(...m.keys.map(k => cells(m.rows[k].full)))} justifyContent="center">{title}</Box>
{headArrow(1)}
</Box>
) : (
<Box flexDirection="row" alignItems="center" gap={1}>{title}</Box>
)
const tabs = (
<Box flexDirection="row" gap={1}>
<Button key="tab-pace" label={L('配速', 'Pace')} {...(term ? { hotkey: '1' } : {})} variant={view.tab === 'pace' ? 'primary' : 'secondary'} onPress={paneAct('tab-pace', () => setView($, v => ({ ...v, tab: 'pace', explore: false })))} />
<Button key="tab-burnup" label={L('用量轨迹', 'Burn-up')} {...(term ? { hotkey: '2' } : {})} variant={view.tab === 'burnup' ? 'primary' : 'secondary'} onPress={paneAct('tab-burnup', () => setView($, v => ({ ...v, tab: 'burnup', explore: false })))} />
</Box>
)
return (
<Box flexDirection="column" gap={term ? 1 : 2} paddingX={1} minHeight={fill}>
{header}
{tabs}
{view.tab === 'burnup' ? drawBurnUpTab($, e, samples, m, row, view, now) : drawPaceTab($, e, samples, m, row)}
{footer}
<Box flexGrow={1} />
{credit($, e)}
</Box>
)
}weektoken/hooks/register.tsx 693〜701 行 · ペイン
function drawEmpty($: any, e: any) {
const { Box, Text } = $.ui.resolve(e)
return (
<Box flexDirection="column" alignItems="center" paddingY={1}>
<Text bold>{L('还没有数据', 'No data yet')}</Text>
<Text dimColor wrap="wrap">{L('等这个会话收到第一条回复,或点「刷新」', "Waiting for this session's first reply, or press Refresh")}</Text>
</Box>
)
}weektoken/hooks/register.tsx 873〜881 行 · ペイン
function credit($: any, e: any) {
const { Box, Text } = $.ui.resolve(e)
const handle = `@${AUTHOR.x}${paneVersion ? ` · v${paneVersion}` : ''}`
return (
<Box flexDirection="row" justifyContent="flex-end">
{e.surface === 'terminal' ? <Text dimColor>{handle}</Text> : pic($, e, creditSvg(handle), handle)}
</Box>
)
}weektoken/hooks/register.tsx 491〜502 行 · ペイン
function pic($: any, e: any, source: string, alt: string, opts: { isInteractive?: boolean; fluid?: boolean; fillHeight?: number } = {}) {
const { Svg } = $.ui.resolve(e)
if (opts.fluid) return <Svg source={source} alt={alt} />
// Plain image with height only: the SVG declares no width (width="100%") and uses percentage geometry, so width follows the cell up to the image default 300px,
// stretching without distortion. No interactive frame: the host reloads it, flickering, whenever the same plugin redraws elsewhere (the pane) (confirmed on device)
if (opts.fillHeight) return <Svg source={source} alt={alt} height={opts.fillHeight} />
const m = /^<svg[^>]*?\swidth="([\d.]+)"\s+height="([\d.]+)"/.exec(source)
const size = m ? { width: Number(m[1]), height: Number(m[2]) } : {}
return opts.isInteractive
? <Svg source={source} alt={alt} {...size} isInteractive />
: <Svg source={source} alt={alt} {...size} />
}ライセンスの全文(MIT)
MIT License Copyright (c) 2026 mj0111 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 に読んだコミット e424db927c1f のソースから。最初のまとまりが載せる条件で、残りは自分で判断するための材料です。後のコミットは、次に読むまで見ていません。
| 載せる条件: 確かめやすいコード | |
|---|---|
| 入口を読んだ | hooks/hooks.json が名指すモジュールをすべて読んだ。weektoken/hooks/register.tsx |
| 解析できる | すべてのファイルが TypeScript か JavaScript として解析できる。6 ファイルを解析 |
| コードが 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/… などは無い)。weektoken/hooks/register.tsx:256 tail(Windows にない); weektoken/hooks/register.tsx:358 defaults(Windows にない) |
| 通信 | fetch の送り先(https のホスト)がコードに書いてあるか。通信なし |
| プログラム | 起動するプログラムの名前がコードに書いてあり、シェル・インタプリタ・通信用の道具でないか。weektoken/hooks/register.tsx:242 perl(シェル・インタプリタ) |
| 読んで送る | ファイルや環境変数を読み、かつ通信するか。通信しない |
| ソースの鍵 | ソースに API キーや秘密鍵らしきものがあるか。ソースに鍵なし |
| ライセンス | オープンなライセンス(MIT・Apache-2.0・BSD・ISC・Unlicense・0BSD・CC0)で全文があれば、modscode にコードを載せる。違えばリンクだけ。MIT |
コードの文面を読んだだけで、安全の審査ではありません。動かしてはおらず、起動するプログラムの中で何が起きるかも見えません。入れる前の確認はあなたの役目です。 載せる条件
入れる
入れる前に、必ず自分で確かめてください。Mod はサンドボックスなしで、あなたの権限で動きます。modscode はこのコードの安全を保証しません。下のコードを読み(またはフォルダーで claude plugin validate .)、触るものを見て、読んだコミットを入れてください。
リポジトリがそのままマーケットプレイスです。このマーケットプレイスを足し(ターミナルでは次のコマンド、デスクトップアプリではプラグインの設定)、そこから Mod を入れます。
/plugin marketplace add 3dnow/claude-mods/plugin install weektoken@mj0111-mods入るのはマーケットプレイスの最新のコミットで、ここで読んだもの(e424db927c1f)と違うことがあります。入れる前に見比べてください。
Claude に聞く
modscode のコネクタを入れると、Claude がこのデザイン・コードが触るもの・コードを読んで、それをもとに作れます。たとえば:
modscode のデザイン「3dnow-weektoken」をコードごと読んで、同じようなペインを作って似たデザイン
-
Claude に頼む…Fix loginRemoveCopy markdownacme/app · mainCopy linkCopy markdownbuild2h 10mbuild2h 10mbuild2h 10mHosted on uploads.sh, not committed to the repo.They will appear in a comment on the pull request once opened.
-
何をするか
- プロンプトの上の帯・欄を描く
- /progress を足す
- ツールの呼び出しを見張る(止めることがある)
- classic.SessionStart・prompt.compose・prompt.submit・session.start ほか 2 個にフックする
-
Claude に頼む…Skins0 Your promptadd rate limiting to the hub api0 Tool rows: finished, running, failedYour prompt Spinner0 Folded group of reads and searches●main · note 3 · note 3 · note 30 Edit diff cardDesktop only; the terminal keeps Claude Code's diff.0 Shell output cardDesktop only.0 Code block cardDesktop only; the terminal keeps Claude Code's markdown.0 TableAccentAccentAccentAccentAccentAccentAccentAccentAccentAccentAccentAccentCopyAccentAccentAccentAccentAccentAccentAccentAccentAccentAccentAccentAccentCopyAccentAccentAccentAccentAccentAccentAccentAccentAccentAccentAccentAccentCopy0 SpinnerAccent SpinnerSpinnerSpinner… 2h 10m0 Band above the prompt: normal, then nudging to compact█████░░░ 42% build█████░░░ 42% build█████░░░ 42% buildContext is 42% full0 Compact now0 Band above a questionTable BashBashBash0 Turn footer (terminal)3 build in 2h 10m · Grep · +3 −3
-
spending-effort-with-jev: no TypeSafe API key, so effort tips are off. Set it in /plugin.⚠ effort: long run, fuzzy spec → have Claude interview you, then go maxClaude に頼む…
-
✦ explain as pick how Claude answers×3 ● build3 ● build3 ● build▸ VideoClaude に頼む…
-
Claude に頼む…Clawd's shopLevel 3 · Fix loginTinkerer1 coin per 12.4 tokens Claude writes, 100 per level, 25 per badgeTake everything offContextbuildLevel 3buildLevel 3buildLevel 3ContextbuildLevel 3buildLevel 3buildLevel 3ContextbuildLevel 3buildLevel 3buildLevel 3