modscode / 図鑑 / statusline-band
statusline-band
A panel above the prompt with rate limits and their pace, context, cost and tokens, git status and switches, actions, and a Spotify card, with Clawd and Beatbot
何をするか
- 欄・プロンプトの上の帯・トーストを描く
- ツールの呼び出しを見張る(止めることがある)
- attribution.text・classic.PostToolUse・classic.PreToolUse・classic.UserPromptSubmit ほか 4 個にフックする
- ターンをまたいで自分の状態を持つ
- ネットワークに出る
良いところ
- TypeScript で書かれている
- デスクトップ専用の分岐がある
- エラーを扱う
- ファイルを書かない
作り始めるためのコード
2 種類あります。上のデザインから modscode が書いた雛形と、その Mod 自身のコードのうち描いている部分です。
雛形(register.tsx)
import type { Register } from 'claude-code'
// Drawn like statusline-band by Asyraf Hussin (pane, band, toast), as modscode read it from the mod's code:
// https://modscode.com/gallery/asyrafhussin-statusline-band/
// 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: "Usage, last ‹span› days" })
on('ui.render', { component: 'Pane', requestId: 'my-pane' }, async ($, e) => {
const { Box, Text, Button } = $.ui.resolve(e)
const count = '…'
const message = '…'
const query = '…'
const fitText = '…'
const formatClock = '…'
const sub = '…'
return (
<Box flexDirection="column" paddingTop={1} paddingLeft={2} paddingRight={3}>
<Box justifyContent="space-between">
<Text color="#1db954" bold>
● Spotify
</Text>
<Text dimColor>
{count}
</Text>
</Box>
<Box marginTop={1} borderStyle="round" borderColor="#1db954" paddingX={1}>
<Text dimColor>
This surface has no text box.
</Text>
</Box>
<Box marginTop={1} flexDirection="column">
<Text dimColor>
Type and press Enter; pick a track to play it.
</Text>
<Text color="#f87171">
{message}
</Text>
<Text dimColor>
{`Nothing found for “${query}”.`}
</Text>
<Box flexDirection="column">
<Box justifyContent="space-between">
<Box flexShrink={1}>
<Text color="#1db954">
{"♪ "}
</Text>
<Button plain label={`${fitText}`} />
</Box>
<Text dimColor>
{` ${formatClock}`}
</Text>
</Box>
<Text dimColor wrap="truncate">
{` ${sub}`}
</Text>
</Box>
<Box flexDirection="column">
<Box justifyContent="space-between">
<Box flexShrink={1}>
<Text color="#1db954">
{"♪ "}
</Text>
<Button plain label={`${fitText}`} />
</Box>
<Text dimColor>
{` ${formatClock}`}
</Text>
</Box>
<Text dimColor wrap="truncate">
{` ${sub}`}
</Text>
</Box>
<Box flexDirection="column">
<Box justifyContent="space-between">
<Box flexShrink={1}>
<Text color="#1db954">
{"♪ "}
</Text>
<Button plain label={`${fitText}`} />
</Box>
<Text dimColor>
{` ${formatClock}`}
</Text>
</Box>
<Text dimColor wrap="truncate">
{` ${sub}`}
</Text>
</Box>
</Box>
<Box flexDirection="column" marginTop={1}>
<Text dimColor wrap="truncate">
────────────────────────
</Text>
<Text dimColor wrap="truncate">
<Text color="#1db954">
{"▶ "}
</Text>
↑↓ or Tab · Enter plays · Esc closes
</Text>
</Box>
</Box>
)
})
// 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 arms = '…'
const shirtText = '…'
const arms2 = '…'
const legs = '…'
const text = '…'
const text2 = '…'
const text3 = '…'
const historyLabel = '…'
const text4 = '…'
const text5 = '…'
const text6 = '…'
const text7 = '…'
const text8 = '…'
const text9 = '…'
const text10 = '…'
const text11 = '…'
const text12 = '…'
const text13 = '…'
const text14 = '…'
const text15 = '…'
const text16 = '…'
const text17 = '…'
const text18 = '…'
const text19 = '…'
const text20 = '…'
const text21 = '…'
const text22 = '…'
const text23 = '…'
const text24 = '…'
const text25 = '…'
const text26 = '…'
const text27 = '…'
const text28 = '…'
const text29 = '…'
const text30 = '…'
const text31 = '…'
const text32 = '…'
const text33 = '…'
const text34 = '…'
const text35 = '…'
const text36 = '…'
const text37 = '…'
const text38 = '…'
const text39 = '…'
const text40 = '…'
const text41 = '…'
const text42 = '…'
const minimizeLabel = '…'
const text43 = '…'
const text44 = '…'
const text45 = '…'
const label = '…'
const step = '…'
const text46 = '…'
const text47 = '…'
const text48 = '…'
const text49 = '…'
const text50 = '…'
const text51 = '…'
const controlGap = '…'
const controlGap2 = '…'
const pausePad = '…'
const searchGap = '…'
const time = '…'
const volume = '…'
const text52 = '…'
const text53 = '…'
const text54 = '…'
const text55 = '…'
const text56 = '…'
const text57 = '…'
const text58 = '…'
const text59 = '…'
const text60 = '…'
const text61 = '…'
const text62 = '…'
const text63 = '…'
const text64 = '…'
const text65 = '…'
const text66 = '…'
const text67 = '…'
const text68 = '…'
const text69 = '…'
const text70 = '…'
const text71 = '…'
const text72 = '…'
const text73 = '…'
const text74 = '…'
const text75 = '…'
const musicMinimize = '…'
const text76 = '…'
const text77 = '…'
const text78 = '…'
return (
<Box paddingX={1} paddingY={1} flexDirection="column">
<Box alignItems="center">
<Box flexDirection="column" width={11} flexShrink={0}>
<Text>
<Text>
{" "}
</Text>
<Text color="#d97757">
{" ▐█████▌ "}
</Text>
</Text>
<Text>
<Text>
{" "}
</Text>
<Text color="#d97757">
{arms}
</Text>
<Text color="#2563eb">
▜
</Text>
<Text backgroundColor="#2563eb" color="#ffffff" bold>
{shirtText}
</Text>
<Text color="#2563eb">
▛
</Text>
<Text color="#d97757">
{arms2}
</Text>
</Text>
<Text>
<Text>
{" "}
</Text>
<Text color="#d97757">
{legs}
</Text>
</Text>
</Box>
<Box flexDirection="column" paddingX={1}>
<Box>
<Text wrap="truncate">
<Text>
{text}
</Text>
<Text>
{text2}
</Text>
<Text>
{text3}
</Text>
</Text>
<Button plain dimColor label={`${historyLabel}`} />
<Text wrap="truncate">
<Text>
{text4}
</Text>
<Text>
{text5}
</Text>
<Text>
{text6}
</Text>
</Text>
</Box>
<Box>
<Box flexDirection="column">
<Text wrap="truncate">
<Text>
{text7}
</Text>
<Text>
{text8}
</Text>
<Text>
{text9}
</Text>
</Text>
</Box>
<Box flexGrow={1} paddingX={2} justifyContent="space-between">
<Box>
<Text wrap="truncate">
<Text>
{text10}
</Text>
<Text>
{text11}
</Text>
<Text>
{text12}
</Text>
</Text>
<Box>
<Text wrap="truncate">
<Text>
{text13}
</Text>
<Text>
{text14}
</Text>
<Text>
{text15}
</Text>
</Text>
<Box position="absolute" top={1} left={0} display="none">
<Text wrap="truncate">
<Text>
{text16}
</Text>
<Text>
{text17}
</Text>
<Text>
{text18}
</Text>
</Text>
</Box>
</Box>
<Text wrap="truncate">
<Text>
{text19}
</Text>
<Text>
{text20}
</Text>
<Text>
{text21}
</Text>
</Text>
<Box>
<Text wrap="truncate">
<Text>
{text22}
</Text>
<Text>
{text23}
</Text>
<Text>
{text24}
</Text>
</Text>
<Box position="absolute" top={1} left={0} display="none">
<Text wrap="truncate">
<Text>
{text25}
</Text>
<Text>
{text26}
</Text>
<Text>
{text27}
</Text>
</Text>
</Box>
</Box>
<Text wrap="truncate">
<Text>
{text28}
</Text>
<Text>
{text29}
</Text>
<Text>
{text30}
</Text>
</Text>
<Box>
<Text wrap="truncate">
<Text>
{text31}
</Text>
<Text>
{text32}
</Text>
<Text>
{text33}
</Text>
</Text>
<Box position="absolute" top={1} left={0} display="none">
<Text wrap="truncate">
<Text>
{text34}
</Text>
<Text>
{text35}
</Text>
<Text>
{text36}
</Text>
</Text>
</Box>
</Box>
</Box>
<Button label="compacting…" hotkey="c" variant="primary" />
</Box>
<Box flexDirection="column">
<Text wrap="truncate">
<Text>
{text37}
</Text>
<Text>
{text38}
</Text>
<Text>
{text39}
</Text>
</Text>
</Box>
</Box>
<Box>
<Text wrap="truncate">
<Text>
{text40}
</Text>
<Text>
{text41}
</Text>
<Text>
{text42}
</Text>
</Text>
<Button plain dimColor label={`${minimizeLabel}`} />
<Text>
<Text>
{text43}
</Text>
<Text>
{text44}
</Text>
<Text>
{text45}
</Text>
</Text>
</Box>
</Box>
</Box>
<Box marginLeft={0} justifyContent="space-between" flexWrap="wrap">
<Box flexWrap="wrap" flexShrink={1}>
<Box flexShrink={0}>
<Text dimColor>
{" · "}
</Text>
<Button plain dimColor label={`${label}`} />
</Box>
<Box flexShrink={0}>
<Text dimColor>
{" · "}
</Text>
<Button plain dimColor label={`${label}`} />
</Box>
<Box flexShrink={0}>
<Text dimColor>
{" · "}
</Text>
<Button plain dimColor label={`${label}`} />
</Box>
</Box>
<Box flexShrink={0}>
<Button plain dimColor label="spotify" />
<Text color="#4ade80">
{" on"}
</Text>
<Text dimColor>
{" · "}
</Text>
<Button plain dimColor label="lyrics" />
<Text color="#4ade80">
{" on"}
</Text>
<Text dimColor>
{" · "}
</Text>
<Button plain dimColor label={`${step}`} />
<Text color="#4ade80">
{" auto"}
</Text>
<Text dimColor>
{" · "}
</Text>
<Button plain dimColor label={`${step}`} />
<Text color="#4ade80">
{" auto"}
</Text>
<Text dimColor>
{" · "}
</Text>
<Button plain dimColor label={`${step}`} />
<Text color="#4ade80">
{" auto"}
</Text>
</Box>
</Box>
<Box marginTop={0}>
<Box>
<Box width={11} flexShrink={0} paddingLeft={1}>
</Box>
<Box flexDirection="column" paddingX={1}>
<Text wrap="truncate">
<Text>
{text46}
</Text>
<Text>
{text47}
</Text>
<Text>
{text48}
</Text>
</Text>
<Box>
<Text wrap="truncate">
<Text>
{text49}
</Text>
<Text>
{text50}
</Text>
<Text>
{text51}
</Text>
</Text>
<Box flexGrow={1} paddingX={2} justifyContent="space-between">
<Box flexShrink={0}>
<Button plain label="◀◀" />
<Text>
{controlGap}
</Text>
<Button plain label="❚❚" />
<Text>
{controlGap2}
</Text>
<Button plain label="▶▶" />
<Text>
{`${pausePad}${searchGap}`}
</Text>
<Button plain dimColor label="search" />
<Text>
{" "}
</Text>
<Text wrap="truncate">
<Text color="#1db954">
━━━━━━━━
</Text>
<Text dimColor>
━━━━━━━━
</Text>
<Text dimColor>
{` ${time}`}
</Text>
</Text>
</Box>
<Box flexShrink={0} display="flex">
<Button plain label="shuffle" />
<Text dimColor>
{" · "}
</Text>
<Button plain label="repeat" />
<Text dimColor>
{" · vol "}
</Text>
<Button plain dimColor label="−" />
<Text>
{` ${volume}% `}
</Text>
<Button plain dimColor label="+" />
</Box>
</Box>
<Text wrap="truncate">
<Text>
{text52}
</Text>
<Text>
{text53}
</Text>
<Text>
{text54}
</Text>
</Text>
</Box>
<Box>
<Text wrap="truncate">
<Text>
{text55}
</Text>
<Text>
{text56}
</Text>
<Text>
{text57}
</Text>
</Text>
<Box flexGrow={1} paddingX={2}>
<Text wrap="truncate">
{" "}
</Text>
</Box>
<Text wrap="truncate">
<Text>
{text58}
</Text>
<Text>
{text59}
</Text>
<Text>
{text60}
</Text>
</Text>
</Box>
<Box>
<Text wrap="truncate">
<Text>
{text61}
</Text>
<Text>
{text62}
</Text>
<Text>
{text63}
</Text>
</Text>
<Box flexGrow={1} paddingX={2}>
<Text wrap="truncate">
{" "}
</Text>
</Box>
<Text wrap="truncate">
<Text>
{text64}
</Text>
<Text>
{text65}
</Text>
<Text>
{text66}
</Text>
</Text>
</Box>
<Box>
<Text wrap="truncate">
<Text>
{text67}
</Text>
<Text>
{text68}
</Text>
<Text>
{text69}
</Text>
</Text>
<Box flexGrow={1} paddingX={2}>
<Text wrap="truncate">
{" "}
</Text>
</Box>
<Text wrap="truncate">
<Text>
{text70}
</Text>
<Text>
{text71}
</Text>
<Text>
{text72}
</Text>
</Text>
</Box>
<Box>
<Text wrap="truncate">
<Text>
{text73}
</Text>
<Text>
{text74}
</Text>
<Text>
{text75}
</Text>
</Text>
<Button plain dimColor label={`${musicMinimize}`} />
<Text>
<Text>
{text76}
</Text>
<Text>
{text77}
</Text>
<Text>
{text78}
</Text>
</Text>
</Box>
</Box>
</Box>
</Box>
{await next(e)}
</Box>
)
})
on('session.start', async ($, e, next) => {
const name = '…'
const percent = '…'
const formatReset = '…'
await $.ui.toast(`🔥 ${name} limit at ${percent}%`)
await $.ui.toast(`▲ ${name} limit runs out in ~${formatReset} at this pace, ${formatReset} before it resets`)
return next(e)
})
}
Mod 自身のコード
Mod のライセンス(MIT)に従って載せています。全文は下にあります。写すときは著作権表示を残してください。
mod/statusline-band/hooks/register.tsx 1038〜1046 行 · ペイン
on('ui.render', { component: 'Pane', requestId: SEARCH_PANE }, async ($, e) => {
const state = await read($, search)
return drawSearchPane($.ui.resolve(e), {
...state,
playingUri: (await read($, music))?.trackId ?? null,
onSearch: query => void searchSpotify($, query),
onPlay: track => void playFound($, track),
})
})mod/statusline-band/hooks/pane.tsx 80〜140 行 · ペイン
export function drawSearchPane({ Box, Button, Text, Input }: Kit, view: SearchView) {
const found = view.status === 'found' && view.tracks.length > 0
const count = found ? `${view.tracks.length} tracks` : view.status === 'searching' ? 'searching…' : ''
return (
<Box flexDirection="column" paddingTop={1} paddingLeft={2} paddingRight={3}>
<Box justifyContent="space-between">
<Text color={SPOTIFY_GREEN} bold>{'● Spotify'}</Text>
<Text dimColor>{count}</Text>
</Box>
<Box marginTop={1} borderStyle="round" borderColor={SPOTIFY_GREEN} paddingX={1}>
{Input ? (
<Input
key="spotify-query"
placeholder="a track, an artist, an album"
value={view.query}
submitLabel="search"
autoFocus
onSubmit={value => view.onSearch(value)}
/>
) : (
<Text dimColor>{'This surface has no text box.'}</Text>
)}
</Box>
<Box marginTop={1} flexDirection="column">
{view.status === 'idle' ? <Text dimColor>{'Type and press Enter; pick a track to play it.'}</Text> : null}
{view.status === 'failed' ? <Text color="#f87171">{view.message}</Text> : null}
{view.status === 'found' && view.tracks.length === 0 ? <Text dimColor>{`Nothing found for “${view.query}”.`}</Text> : null}
{view.tracks.map(track => {
const isPlaying = track.uri === view.playingUri
const sub = [track.artist, track.album].filter(Boolean).join(' · ')
return (
<Box key={`found-${track.uri}`} flexDirection="column">
<Box justifyContent="space-between">
<Box flexShrink={1}>
<Text color={SPOTIFY_GREEN}>{isPlaying ? '♪ ' : ' '}</Text>
<Button
key={`play-${track.uri}`}
plain
label={fitText(track.name, Math.min(TITLE_MAX, [...track.name].length))}
onPress={() => view.onPlay(track)}
/>
</Box>
<Text dimColor>{track.durationMs ? ` ${formatClock(track.durationMs)}` : ''}</Text>
</Box>
<Text dimColor wrap="truncate">{` ${sub}`}</Text>
</Box>
)
})}
</Box>
{found ? (
<Box flexDirection="column" marginTop={1}>
<Text dimColor wrap="truncate">{RULE}</Text>
<Text dimColor wrap="truncate">
<Text color={SPOTIFY_GREEN}>{'▶ '}</Text>
{'↑↓ or Tab · Enter plays · Esc closes'}
</Text>
</Box>
) : null}
</Box>
)
}mod/statusline-band/hooks/register.tsx 1048〜1091 行 · バンド
on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
const s = await read($, snap)
if (e.props.hasSurvey || s === null) return next(e)
const isWorking = e.props.isWorking
// A playing track's position counts on between Spotify's reads, so the bar, the time and the lyric move
// with each of Beatbot's steps
const kept = runtime.config.spotify && (await read($, musicOn)) ? await read($, music) : null
const playing = kept && { ...kept, positionMs: livePosition(kept, await $.clock.now()) }
const words = await read($, lyrics)
const isLyricsOn = await read($, lyricsOn)
const lyric = playing && isLyricsOn && words?.trackId === playing.trackId && words.lines.length > 0 ? lyricAt(words.lines, playing.positionMs) : null
return drawBand($.ui.resolve(e), {
s,
config: runtime.config,
effort: runtime.effort,
isWorking,
bodyColumns: e.props.bodyColumns,
isCompacting: await read($, isCompacting),
turn: await read($, lastTurn),
feeling: isWorking ? 'idle' : await read($, mood),
beat: await read($, moodTick),
danceTick: await read($, danceTick),
tick: isWorking ? await read($, frame) : null,
isBlinking: await read($, isBlinking),
music: playing,
lyric,
isLyricsOn: runtime.config.spotify && (await read($, musicOn)) ? isLyricsOn : null,
onLyricsSwitch: () => void toggleLyrics($),
isMusicCompact: await read($, musicCompact),
isMusicOn: runtime.config.spotify ? await read($, musicOn) : null,
onMusicSwitch: () => void toggleMusic($),
isCardCompact: await read($, cardCompact),
onCardCompact: () => void toggleCardCompact($),
canDrawArt: e.surface === 'terminal',
logoFile: e.surface === 'terminal' ? `${$.plugin.root}/assets/spotify.png` : undefined,
actions: ACTIONS,
onHistory: () => void openHistory($, s.day),
onCompact: () => void compactNow($),
onAction: action =>
void (action.prompt === undefined ? quickCommit($) : $.prompt.submit({ text: action.prompt, asUser: true })),
onSwitch: step => void toggleGitAuto($, step),
onMusic: command => void controlSpotify($, command),
})
})mod/statusline-band/hooks/band.tsx 169〜328 行 · バンド
export function drawBand({ Box, Button, Text, Raster, Image }: Kit, view: BandView) {
const { s, config, turn, feeling, beat, tick, isWorking } = view
// Pieces of text whose widths are known, so the frame can be drawn to fit them
type Seg = { text: string; color?: string; bold?: boolean; dim?: boolean }
const width = (segs: Seg[]) => segs.reduce((n, seg) => n + [...seg.text].length, 0)
const draw = (segs: Seg[]) =>
segs.map(seg => (
<Text color={seg.color} bold={seg.bold} dimColor={seg.dim}>{seg.text}</Text>
))
const border = isWorking ? COLORS.borderBusy : feeling === 'sweat' ? COLORS.hot : COLORS.border
const line = (text: string): Seg => ({ text, color: border })
const total = Math.max(40, view.bodyColumns - 2 - CLAWD_WIDTH - ENGINE_MARK_WIDTH - CARD_INSET * 2)
// Top edge: the project as the panel's title, then the model and its effort
const g = s.git
const sep: Seg = { text: ' · ', dim: true }
const diffSegs = (added: number, removed: number): Seg[] => [
...(added > 0 ? [{ text: ` +${added}`, color: COLORS.ok }] : []),
...(removed > 0 ? [{ text: ` −${removed}`, color: COLORS.hot }] : []),
]
// Each git fact is its own group: uncommitted work, commits to push and pull, then the last commit
const gitGroups: Seg[][] =
g === null
? []
: [
...(g.changed > 0
? [[{ text: `✎ ${g.changed} ${g.changed === 1 ? 'file' : 'files'}`, color: COLORS.warn }, ...diffSegs(g.added, g.removed)]]
: []),
...(g.ahead > 0
? [
[
{ text: `↑ ${g.ahead} ${g.ahead === 1 ? 'commit' : 'commits'}`, color: COLORS.warn },
...diffSegs(g.unpushedAdded, g.unpushedRemoved),
],
]
: []),
...(g.behind > 0 ? [[{ text: `↓ ${g.behind} behind`, color: COLORS.hot }]] : []),
...(g.stashed > 0 ? [[{ text: `≡ ${g.stashed} stash`, color: COLORS.model }]] : []),
...(g.changed === 0 && g.hasUpstream && g.ahead === 0 && g.behind === 0
? [[{ text: '✓ synced', color: COLORS.ok }]]
: []),
...(g.lastCommitAt !== null
? [[{ text: `committed ${s.now - g.lastCommitAt < 60_000 ? 'just now' : `${formatReset(s.now - g.lastCommitAt)} ago`}`, dim: true }]]
: []),
...(!g.hasUpstream ? [[{ text: 'no upstream', color: COLORS.warn }]] : []),
]
const effort = view.effort ?? s.effort
const title: Seg[] = [
line('╭─ '),
{ text: `◆ ${s.folder}`, color: COLORS.folder, bold: true },
...(s.subdir ? [{ text: s.subdir, dim: true }] : []),
...(g === null ? [] : [line(' ─ '), { text: g.branch, color: COLORS.branch }]),
line(' ─ '),
{ text: `✦ ${s.model}`, color: COLORS.model },
...(effort ? [{ text: ` · ${effort}`, dim: true }] : []),
...(s.plan ? [{ text: ' · ', dim: true }, { text: s.plan, color: CLAWD_COLOR, bold: true }] : []),
{ text: ' ' },
]
// Top right: what the session, today and the history window have cost, each with its tokens
const hours = (s.now - s.startedAt) / 3_600_000
const cost: Seg[] = []
const costShort: Seg[] = []
// A snapshot kept from before a reload may predate the token counts
const counted = (s.tokens as Snapshot['tokens'] | undefined) ?? { session: 0, today: 0, rolling: 0 }
if (s.costUsd !== null) {
const tokens = (n: number): Seg[] => (n > 0 ? [{ text: ` ${formatTokens(n)}`, color: COLORS.model }] : [])
cost.push(
{ text: ' ' },
{ text: formatUsd(s.costUsd), color: COLORS.ok, bold: true },
...tokens(counted.session),
{ text: ' session', dim: true },
)
costShort.push(...cost, { text: ' ' })
if (hours > 0.05) cost.push({ text: ` ${formatUsd(s.costUsd / hours)}/h`, dim: true })
const addTotal = (usd: number, n: number) =>
cost.push({ text: ' · ', dim: true }, { text: formatUsd(usd), color: COLORS.ok }, ...tokens(n), { text: ' ' })
// Today only when it adds to the session; the history window always, even while it matches today
if (s.todayUsd !== null && s.todayUsd - s.costUsd >= 0.01) {
addTotal(s.todayUsd, counted.today)
cost.push({ text: 'today', dim: true })
}
// The window's label is a button that opens the history pane, so it is drawn apart
if (s.rollingUsd !== null) addTotal(s.rollingUsd, counted.rolling)
}
const historyLabel = `${config.rollingDays}d`
const hasHistory = s.costUsd !== null && s.rollingUsd !== null
const costWidth = width(cost) + (hasHistory ? historyLabel.length : 0) + 1
// When the whole line does not fit beside the title, the session cost alone still shows
const fits = (n: number) => width(title) + n + 3 <= total
const showFull = cost.length > 0 && fits(costWidth)
const right = showFull ? cost : fits(width(costShort)) ? costShort : []
const rightWidth = showFull ? costWidth : width(right)
const topLeft = [...title, line('─'.repeat(Math.max(1, total - width(title) - rightWidth - 2))), ...right]
const topRight = [...(showFull ? [{ text: ' ' }] : []), line('─╮')]
// Bottom edge: running subagents and git on the left; the last reply's tokens, how long the session has
// run and the time on the right
const running = (s.agents as number | undefined) ?? 0
const groups: Seg[][] = [
...(running > 0 ? [[{ text: `↻ ${running} ${running === 1 ? 'agent' : 'agents'}`, color: COLORS.model }]] : []),
...gitGroups,
]
const changes: Seg[] =
groups.length === 0 ? [] : [{ text: ' ' }, ...groups.flatMap((group, i) => (i === 0 ? group : [sep, ...group])), { text: ' ' }]
const clock: Seg[] = [
{ text: ' ' },
// The last turn's tokens, its responses summed: read in (cache included) and written out
...(turn
? [
{ text: 'in ', dim: true },
{ text: formatTokens(turn.input), color: COLORS.model },
...(turn.input > 0 && turn.cached !== undefined
? [{ text: ` (${Math.floor((turn.cached / turn.input) * 100)}% cache)`, dim: true }]
: []),
{ text: ' · out ', dim: true },
{ text: formatTokens(turn.output), color: COLORS.model },
{ text: ' · ', dim: true },
]
: []),
{ text: `session ${formatDuration(s.now - s.startedAt)}`, dim: true },
{ text: ' · ', dim: true },
{ text: s.time, dim: true },
{ text: ' ' },
]
// On its right, after the time, the button that shrinks the card to one line
const [mainDot = '', minimizeLabel = '', mainCorner = ''] = MAIN_BOTTOM_TAIL
const fill = bottomFill(total, width(changes) + width(clock), MAIN_BOTTOM_TAIL)
const bottom = [line('╰─'), ...changes, line('─'.repeat(fill)), ...clock, { text: mainDot, dim: true }]
// Shrunk: one line from the band's left edge, in place of the card and Clawd: the repo and branch, the model, each limit and the
// context as a percent, the first git fact, and the session cost, with the button that brings it back
const compactSegs: Seg[] = [
{ text: `◆ ${s.folder}`, color: COLORS.folder, bold: true },
...(g === null ? [] : [{ text: ' ' }, { text: g.branch, color: COLORS.branch }]),
sep,
{ text: `✦ ${s.model}`, color: COLORS.model },
...s.limits.flatMap((l): Seg[] => [
sep,
{ text: `${ring(l.percent)} `, color: toneHex(l.percent) },
{ text: `${Math.round(l.percent)}%`, bold: true, color: l.percent >= 50 ? toneHex(l.percent) : undefined },
{ text: ` ${LIMIT_LABELS[l.kind] ?? l.kind}`, dim: true },
]),
...(s.context
? [
sep,
{ text: 'ctx ', dim: true },
{ text: `${Math.round(s.context.percent)}%`, bold: true, color: s.context.percent >= 50 ? toneHex(s.context.percent) : undefined },
]
: []),
...(gitGroups[0] ? [sep, ...gitGroups[0]] : []),
...(s.costUsd !== null ? [sep, { text: formatUsd(s.costUsd), color: COLORS.ok, bold: true }] : []),
]
// Clawd
const step = tick === null ? 0 : Math.floor(tick / 2)
const pose =
tick !== null
? CLAWD_RUN[step % CLAWD_RUN.length] ?? CLAWD_IDLEライセンスの全文(MIT)
MIT License Copyright (c) 2026 Asyraf Hussin 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 に読んだコミット 779b070b5057 のソースから。最初のまとまりが載せる条件で、残りは自分で判断するための材料です。後のコミットは、次に読むまで見ていません。
| 載せる条件: 確かめやすいコード | |
|---|---|
| 入口を読んだ | hooks/hooks.json が名指すモジュールをすべて読んだ。mod/statusline-band/hooks/register.tsx |
| 解析できる | すべてのファイルが TypeScript か JavaScript として解析できる。7 ファイルを解析 |
| コードが 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/… などは無い)。mod/statusline-band/hooks/register.tsx:229 date(Windows にない); mod/statusline-band/hooks/register.tsx:230 date(Windows にない); mod/statusline-band/hooks/register.tsx:364 date(Windows にない); mod/statusline-band/hooks/register.tsx:920 date(Windows にない); mod/statusline-band/hooks/register.tsx:1014 date(Windows にない) |
| 通信 | fetch の送り先(https のホスト)がコードに書いてあるか。mod/statusline-band/hooks/register.tsx:565 fetch(lyricsUrl(m)) |
| プログラム | 起動するプログラムの名前がコードに書いてあり、シェル・インタプリタ・通信用の道具でないか。mod/statusline-band/hooks/register.tsx:535 osascript(シェル・インタプリタ); mod/statusline-band/hooks/register.tsx:616 osascript(シェル・インタプリタ) |
| 読んで送る | ファイルや環境変数を読み、かつ通信するか。reads environment variables and files and reaches the network |
| ソースの鍵 | ソースに API キーや秘密鍵らしきものがあるか。ソースに鍵なし |
| ライセンス | オープンなライセンス(MIT・Apache-2.0・BSD・ISC・Unlicense・0BSD・CC0)で全文があれば、modscode にコードを載せる。違えばリンクだけ。MIT |
コードの文面を読んだだけで、安全の審査ではありません。動かしてはおらず、起動するプログラムの中で何が起きるかも見えません。入れる前の確認はあなたの役目です。 載せる条件
入れる
入れる前に、必ず自分で確かめてください。Mod はサンドボックスなしで、あなたの権限で動きます。modscode はこのコードの安全を保証しません。下のコードを読み(またはフォルダーで claude plugin validate .)、触るものを見て、読んだコミットを入れてください。
リポジトリがそのままマーケットプレイスです。このマーケットプレイスを足し(ターミナルでは次のコマンド、デスクトップアプリではプラグインの設定)、そこから Mod を入れます。
/plugin marketplace add AsyrafHussin/claude-code-statusline/plugin install statusline-band@claude-code-statusline入るのはマーケットプレイスの最新のコミットで、ここで読んだもの(779b070b5057)と違うことがあります。入れる前に見比べてください。
Claude に聞く
modscode のコネクタを入れると、Claude がこのデザイン・コードが触るもの・コードを読んで、それをもとに作れます。たとえば:
modscode のデザイン「asyrafhussin-statusline-band」をコードごと読んで、同じようなペインを作って似たデザイン
-
Claude に頼む…2h 10m · █████░░░✓ build ✓ build ✓ buildJavaKotlin3 Python■ ok 3 ■ ok 3 ■ ok 3 Razor proven 3 Razor proven 3 Razor proven 3Phases ──────── 3/3build Pythonbuild Pythonbuild Python… 3 more phasesLua ──────── 3/Kotlin■ the whole upgrade Ruby■ build build Ruby■ build build Ruby■ build build Ruby … 3 moreNext ──────── PythonRuby (by hand)Podsclick a button, or ctrl+x tab then Tab, EnterAttention ──────── 3! Scala ! Scala ! Scala … 3 moreSession ──────── okJava
-
slop Edit1 of 3accepteditrejectClaude に頼む…
-
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
-
Claude に頼む…agent-discoverbuildbuildbuildRefreshMCP Browse/3Tab / shift+Tab move · Enter presses · ↑↓ scroll · Esc back to the promptBrowse...Audit asks:DeclineAcceptDeclineCancelAudit asks:DeclineAcceptDeclineCancelAudit asks:DeclineAcceptDeclineCancel
-
Claude に頼む…Fanyi settingsOnAPI · OpusenOn this MacAPIHost src/ SaveKey K · paste a new one, Enter SaveOpus↻ RefreshCustom model model id, for an API that lists none UseFanyi settingsHostClose
-
Claude に頼む…Glossary BrowserGlossary openContextsContextsContexts▲ prevWrite1/Glossary▼ nextContexts