modscode EN

modscode / 図鑑 / stash

stash

dima's command center above the prompt, one folded row with three features: asks (every live session's open ⏳ asks, copy all per thread), afk (one switch every session obeys) and holds (no two sessions write the same file)

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

何をするか

  • 欄・プロンプトの上の帯を描く
  • /board を足す
  • Bash の呼び出しを見張る(止めることがある)
  • classic.Stop・prompt.submit・session.end・session.measure ほか 3 個にフックする
  • ターンをまたいで自分の状態を持つ

良いところ

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

作り始めるためのコード

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

雛形(register.tsx)

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

// Drawn like stash by dvakatsiienko (pane, band), as modscode read it from the mod's code:
// https://modscode.com/gallery/dvakatsiienko-stash/
// 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: "fleet board" })
  on('ui.render', { component: 'Pane', requestId: 'my-pane' }, async ($, e) => {
    const { Text } = $.ui.resolve(e)
    return (
      <Text dimColor>
        the session registry is unreadable
      </Text>
    )
  })

  // the band above the prompt; what else goes there is drawn under it
  on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
    const { Box, Text } = $.ui.resolve(e)
    const n = '…'
    const length = '…'
    const sid = '…'
    const name = '…'
    const command = '…'
    const target = '…'
    const key = '…'
    const length2 = '…'
    return (
      <Box flexDirection="column">
        <Box flexDirection="row" justifyContent="space-between" marginBottom={0.25}>
          <Box flexDirection="row" gap={1}>
            <Text bold color="#d97757">
              {"⏳ "}
              {`${n}${length}`}
              {" open"}
            </Text>
            counts
            holds
          </Box>
          <Box flexDirection="row" gap={1}>
            {`copy:${sid}`}
            hot
            afk
            board
            asks-toggle
          </Box>
        </Box>
        <Box flexDirection="row" gap={1} justifyContent="space-between">
          <Text wrap="truncate-end">
            {`🛡️ ${name} — ${command} → ran on dima-ok: ${target}`}
          </Text>
          {`dismiss:${key}`}
        </Box>
        <Box flexDirection="row" gap={1} justifyContent="space-between">
          <Text wrap="truncate-end">
            {`🛡️ ${name} — ${command} → ran on dima-ok: ${target}`}
          </Text>
          {`dismiss:${key}`}
        </Box>
        <Box flexDirection="row" gap={1} justifyContent="space-between">
          <Text wrap="truncate-end">
            {`🛡️ ${name} — ${command} → ran on dima-ok: ${target}`}
          </Text>
          {`dismiss:${key}`}
        </Box>
        <Text dimColor>
          +
          {length}
          {" more guard lines"}
        </Text>
        <Text dimColor>
          +
          {length2}
          {" more"}
        </Text>
        {await next(e)}
      </Box>
    )
  })
}

Mod 自身のコード

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

home/.claude/plugin-x/mods/stash/hooks/register.tsx 825〜943 行 · ペイン
    on('ui.render', { component: 'Pane', requestId: BOARD }, async ($, e) => {
        const ui = $.ui.resolve(e);
        const { Box, Text, Button, Link } = ui;
        const now = await $.clock.now();
        const me = await $.session.id().catch(() => selfId);
        const list = await members($).catch(() => null);
        if (!list)
            return <Text dimColor>the session registry is unreadable</Text>;
        if (!list.length) return <Text dimColor>no live sessions</Text>;
        const row = (m: Member, i: number) => {
            const state = stateWord(m.status);
            const isBusy = state === 'busy';
            const ticket = ticketOf(m.name);
            const door = m.door;
            const name = m.sid === me ? `${m.name} (here)` : m.name;
            const line = m.wait && `🔭 ${m.wait}`;
            return (
                <Box
                    flexDirection='column'
                    key={`m:${m.sid}`}
                    marginTop={i > 0 ? 1 : 0}>
                    <Box
                        flexDirection='row'
                        gap={1}
                        justifyContent='space-between'>
                        {/* the name side gives way, clipped, so a long name never pushes the fact columns out of line */}
                        <Box
                            flexDirection='row'
                            flexGrow={1}
                            flexShrink={1}
                            gap={1}
                            minWidth={0}
                            overflow='hidden'>
                            {/* the whole name is the control; the coordinator's name stays bold text, since a Button label takes no weight */}
                            {door && !isCoordinator(m.name) ? (
                                <Button
                                    key={`door:${m.sid}`}
                                    onPress={(p) =>
                                        void pressDoor($, door, p.surface)
                                    }
                                    plain>
                                    {`${name} ${doorGlyph(door)}`}
                                </Button>
                            ) : (
                                <Text
                                    bold={isCoordinator(m.name)}
                                    wrap='truncate-end'>
                                    {name}
                                </Text>
                            )}
                            {door && isCoordinator(m.name) ? (
                                <Button
                                    key={`door:${m.sid}`}
                                    onPress={(p) =>
                                        void pressDoor($, door, p.surface)
                                    }
                                    plain>
                                    {doorGlyph(door)}
                                </Button>
                            ) : null}
                            {m.offPattern ? (
                                <Text color={ACCENT}>⚠</Text>
                            ) : null}
                        </Box>
                        {/* one fixed-width, right-aligned cell per fact, drawn empty when it has no reading, so the columns line up across rows (dima, 2026-10-05) */}
                        <Box
                            flexDirection='row'
                            flexShrink={0}
                            gap={e.surface === 'desktop' ? 0.5 : 1}>
                            {/* no hover card in the pane: an absolute card in a narrow row wraps and clips (dima, 2026-10-05) */}
                            <Box
                                justifyContent='flex-end'
                                width={COLUMNS.ticket}>
                                {ticket ? (
                                    // never wraps: `FRM-306` broke at its hyphen in the desktop font
                                    <Text dimColor wrap='truncate-end'>
                                        <Link
                                            href={`https://linear.app/x-com/issue/${ticket}`}>
                                            {ticket}
                                        </Link>
                                    </Text>
                                ) : null}
                            </Box>
                            <Box
                                justifyContent='flex-end'
                                width={COLUMNS.context}>
                                {m.context === undefined ? null : (
                                    <Text dimColor>ctx {m.context}%</Text>
                                )}
                            </Box>
                            <Box
                                justifyContent='flex-end'
                                width={COLUMNS.state}>
                                <Text
                                    bold={isBusy}
                                    color={isBusy ? ACCENT : undefined}
                                    dimColor={state === 'idle'}
                                    wrap='truncate-end'>
                                    {m.statusSince
                                        ? `${state} ${span(now - m.statusSince)}`
                                        : state}
                                </Text>
                            </Box>
                            {/* the asks close the row, always drawn: `⏳ 0` dimmed when none (dima, 2026-10-05) */}
                            <Box justifyContent='flex-end' width={COLUMNS.asks}>
                                <Text
                                    color={m.asks ? ACCENT : undefined}
                                    dimColor={!m.asks}>
                                    ⏳ {m.asks}
                                </Text>
                            </Box>
                        </Box>
                    </Box>
                    {line ? <Text wrap='truncate-end'>{line}</Text> : null}
                </Box>
            );
        };
        return <Box flexDirection='column'>{list.map(row)}</Box>;
    });
home/.claude/plugin-x/mods/stash/hooks/register.tsx 991〜1150 行 · バンド
    on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
        if (e.surface !== 'terminal' && e.surface !== 'desktop') return next(e);
        const groups = Object.entries(entries).sort(([a], [b]) =>
            a === selfId ? -1 : b === selfId ? 1 : 0,
        );
        const total = groups.reduce((n, [, v]) => n + v.asks.length, 0);
        const ui = $.ui.resolve(e);
        const { Box, Text, Button } = ui;
        const surface = e.surface;
        // a thread reads its session name; the repo joins only when two sessions share one
        const title = (v: Entry) => {
            const base = v.name ?? v.label;
            const shared = groups.filter(
                ([, o]) => (o.name ?? o.label) === base,
            ).length;
            return shared > 1 && v.name ? `${base} · ${v.label}` : base;
        };
        // the head stays short; the per-session breakdown lives in its hover card
        const here = entries[selfId ?? '']?.asks.length ?? 0;
        const counts = `here ${here}, parallel ${total - here}`;
        const breakdown = groups
            .map(
                ([sid, v]) =>
                    `${sid === selfId ? `${title(v)} (here)` : title(v)} ${v.asks.length}`,
            )
            .join(', ');
        const toggle = () => {
            open = !open;
            void $.state.set(OPEN, open).catch(() => undefined);
            $.ui.invalidate('ui.render');
        };
        const flipAfk = async () => {
            afk = !afk;
            await $.store.set(AFK_KEY, { at: await $.clock.now(), on: afk });
            $.ui.invalidate('ui.render');
        };
        const flipHot = async () => {
            const now = await $.clock.now();
            const reset = fiveHour?.resetsAt;
            hot = hot
                ? undefined
                : {
                      since: now,
                      until: reset && reset > now ? reset : undefined,
                  };
            await saveHot($);
            await armHot($);
            $.ui.invalidate('ui.render');
        };
        const tip = (
            key: string,
            words: string,
            control: RenderElement,
            place: { left: number } | { right: number },
            press?: { hotkey: string; onPress: () => void },
        ) => hoverTip(ui, key, words, control, place, press);
        const boardOpen = await isBoardOpen($);
        const flipBoard = async () => {
            if (await isBoardOpen($)) await $.ui.close({ id: BOARD });
            else await openBoard($);
            $.ui.invalidate('ui.render');
        };
        // a terminal draws a chromed Button as `[ label ]`
        const leftOf = (label: string, chrome: boolean) => ({
            right: [...label].length + (chrome ? 4 : 0) + 1,
        });
        // only the head's copy takes `c`: two Buttons on one key clash, and the later wins
        const copyButton = (sid: string, asks: string[], hotkey?: string) => {
            const copy = () =>
                void $.ui.copy({
                    surface,
                    text: [
                        'lane',
                        ...asks.map((a, i) => `${i + 1}. ${a}`),
                    ].join('\n'),
                });
            return tip(
                `copy:${sid}`,
                "copy this thread's asks",
                <Button key={`copy:${sid}`} onPress={copy} variant='secondary'>
                    📋
                </Button>,
                leftOf('📋', true),
                hotkey ? { hotkey, onPress: copy } : undefined,
            );
        };
        const [first] = groups;
        const many = groups.length > 1;
        // other sessions' holds in this repo; ⚠ when a session was refused one of this session's files
        const chipText = [
            holds.warned ? '⚠' : '',
            holds.others ? `🔒 ${holds.others}` : '',
        ]
            .filter(Boolean)
            .join(' ');
        const chipName = [
            holds.warned
                ? 'a session was refused a file this session holds'
                : '',
            holds.others
                ? `${holds.others} ${holds.others === 1 ? 'file' : 'files'} held by other sessions`
                : '',
        ]
            .filter(Boolean)
            .join('; ');
        const holdsChip = chipText
            ? tip(
                  'holds',
                  chipName,
                  <Text color={holds.warned ? ACCENT : undefined}>
                      {chipText}
                  </Text>,
                  { left: [...chipText].length + 1 },
              )
            : null;
        // icons only; each card says what a press does (dima)
        const hotLabel = '🔥';
        // one icon; the accent background says afk is on (dima)
        const afkLabel = '💨';
        const foldLabel = open ? '📂' : '📁';

        // ~4px under the head on desktop when the asks show; a terminal cell is a whole line, so none there
        const head = (
            <Box
                flexDirection='row'
                justifyContent='space-between'
                marginBottom={
                    open && total && surface === 'desktop' ? 0.25 : 0
                }>
                {first ? (
                    <Box flexDirection='row' gap={1}>
                        <Text bold color={ACCENT}>
                            ⏳ {total} open
                        </Text>
                        {many
                            ? tip(
                                  'counts',
                                  breakdown,
                                  <Text dimColor>{counts}</Text>,
                                  { left: counts.length + 1 },
                              )
                            : null}
                        {holdsChip}
                    </Box>
                ) : (
                    <Box flexDirection='row' gap={1}>
                        <Text dimColor>no open asks</Text>
                        {holdsChip}
                    </Box>
                )}
                <Box flexDirection='row' gap={1}>
                    {first ? copyButton(first[0], first[1].asks, 'c') : null}
                    {tip(
                        'hot',
                        hot
                            ? "stop keeping this session's cache hot"
                            : "keep this session's cache hot: ping every 50 min",
                        <Button
                            key='hot'
                            onPress={() => void flipHot()}
ライセンスの全文(MIT)
MIT License

Copyright (c) 2026 Dima Vakatsiienko

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 に読んだコミット a3a6862b7eda のソースから。最初のまとまりが載せる条件で、残りは自分で判断するための材料です。後のコミットは、次に読むまで見ていません。

載せる条件: 確かめやすいコード
入口を読んだhooks/hooks.json が名指すモジュールをすべて読んだ。home/.claude/plugin-x/mods/stash/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/… などは無い)。home/.claude/plugin-x/mods/stash/hooks/register.tsx:205 ps(Windows にない); home/.claude/plugin-x/mods/stash/hooks/register.tsx:580 ps(Windows にない); home/.claude/plugin-x/mods/stash/hooks/register.tsx:654 open(Windows にない)
通信fetch の送り先(https のホスト)がコードに書いてあるか。通信なし
プログラム起動するプログラムの名前がコードに書いてあり、シェル・インタプリタ・通信用の道具でないか。home/.claude/plugin-x/mods/stash/hooks/register.tsx:161 sh(シェル・インタプリタ)
読んで送るファイルや環境変数を読み、かつ通信するか。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 .)、触るものを見て、読んだコミットを入れてください。

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

Claude に聞く

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

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

Claude から探す: MCP コネクタ

似たデザイン