modscode EN

modscode / 図鑑 / katharsis

katharsis

An output style that classifies each message by exchange type and shapes the reply to fit it: the answer first, a ceiling per type, reference codes that survive the session, and decisions handed back as questions

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

何をするか

  • プロンプトの上の帯・欄を描く
  • classic.Stop・prompt.submit・session.end・session.start ほか 3 個にフックする
  • プロセスを起こす

良いところ

  • ネットワークに出ない
  • TypeScript で書かれている
  • エラーを扱う

作り始めるためのコード

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

雛形(register.tsx)

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

// Drawn like katharsis by Holden Hewett (pane, band), as modscode read it from the mod's code:
// https://modscode.com/gallery/openscribbler-katharsis/
// 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 groupName = '…'
    const length = '…'
    const value = '…'
    const hint = '…'
    const p = '…'
    return (
      <Box flexDirection="column">
        <Box flexDirection="column">
          <Box display="none" flexDirection="column" overflow="hidden" borderStyle="round" paddingX={1}>
            <Box flexDirection="row" gap={2}>
              <Text bold>
                {`${groupName} · ${length}`}
              </Text>
              <Text dimColor>
                {`latest ${length}`}
              </Text>
              <Button label={`list all ${length} ▸`} plain />
            </Box>
            <Button label={`${value}`} plain />
            <Button label={`${value}`} plain />
            <Button label={`${value}`} plain />
          </Box>
          <Box display="none" flexDirection="column" overflow="hidden" borderStyle="round" paddingX={1}>
            <Box flexDirection="row" gap={2}>
              <Text bold>
                {`${groupName} · ${length}`}
              </Text>
              <Text dimColor>
                {`latest ${length}`}
              </Text>
              <Button label={`list all ${length} ▸`} plain />
            </Box>
            <Button label={`${value}`} plain />
            <Button label={`${value}`} plain />
            <Button label={`${value}`} plain />
          </Box>
          <Box display="none" flexDirection="column" overflow="hidden" borderStyle="round" paddingX={1}>
            <Box flexDirection="row" gap={2}>
              <Text bold>
                {`${groupName} · ${length}`}
              </Text>
              <Text dimColor>
                {`latest ${length}`}
              </Text>
              <Button label={`list all ${length} ▸`} plain />
            </Box>
            <Button label={`${value}`} plain />
            <Button label={`${value}`} plain />
            <Button label={`${value}`} plain />
          </Box>
          <Box flexDirection="row" gap={1} height={1} overflow="hidden">
            <Box flexDirection="row" gap={1} flexShrink={0}>
              <Text color="#14B8A6">
                ▸ Katharsis
              </Text>
              <Text dimColor>
                ·
              </Text>
              <Button label="open" plain />
              <Text dimColor>
                {hint}
              </Text>
            </Box>
            <Text dimColor>
              no codes yet
            </Text>
            <Box flexDirection="row">
              <Box flexDirection="row" flexShrink={0}>
                <Button label={`${p}:${length}`} plain dimColor />
                <Text dimColor>
                  |
                </Text>
              </Box>
              <Box flexDirection="row" flexShrink={0}>
                <Button label={`${p}:${length}`} plain dimColor />
                <Text dimColor>
                  |
                </Text>
              </Box>
              <Box flexDirection="row" flexShrink={0}>
                <Button label={`${p}:${length}`} plain dimColor />
                <Text dimColor>
                  |
                </Text>
              </Box>
            </Box>
          </Box>
        </Box>
        {await next(e)}
      </Box>
    )
  })

  // the pane: open it with $.ui.open({ id: 'my-pane', title: "Katharsis" })
  on('ui.render', { component: 'Pane', requestId: 'my-pane' }, async ($, e) => {
    const { Box, Input, Button, Text } = $.ui.resolve(e)
    const filterLabel = '…'
    const showLabel = '…'
    const viewLabel = '…'
    const length = '…'
    const heading = '…'
    const heading2 = '…'
    const heading3 = '…'
    const menuRow = '…'
    const g = '…'
    const text = '…'
    const g2 = '…'
    const text2 = '…'
    const g3 = '…'
    const text3 = '…'
    return (
      <Box flexDirection="column">
        <Box flexDirection="row">
          <Box flexGrow={1} flexShrink={1}>
            <Input label="Search" placeholder="code, title, body, option" value="" submitLabel="" autoFocus />
          </Box>
        </Box>
        <Box flexDirection="row" flexWrap="wrap" columnGap={2} paddingRight={2}>
          <Button label={`${filterLabel}`} hotkey="f" />
          <Button label={`${showLabel}`} hotkey="s" />
          <Button label="Clear" />
          <Box flexGrow={1} flexDirection="row" justifyContent="flex-end">
            <Button label={`${viewLabel}`} hotkey="v" />
          </Box>
        </Box>
        <Text dimColor>
          {`${length} of ${length} items`}
        </Text>
        <Text dimColor>
          Nothing matches.
        </Text>
        <Box flexDirection="column" marginTop={1}>
          <Text bold color="cyan">
            {heading}
          </Text>
        </Box>
        <Box flexDirection="column" marginTop={1}>
          <Text bold color="cyan">
            {heading2}
          </Text>
        </Box>
        <Box flexDirection="column" marginTop={1}>
          <Text bold color="cyan">
            {heading3}
          </Text>
        </Box>
        <Box position="absolute" left={0} flexDirection="column" borderStyle="round" backgroundColor="userMessageBackground" paddingX={1}>
          <Button label={`${menuRow}`} plain />
          <Button label={`${menuRow}`} plain />
          <Button label={`${menuRow}`} plain />
        </Box>
        <Box position="absolute" flexDirection="column" borderStyle="round" backgroundColor="userMessageBackground" paddingX={1}>
          <Button label={`${menuRow}`} plain />
          <Button label={`${menuRow}`} plain />
          <Button label={`${menuRow}`} plain />
          <Box flexDirection="column" marginTop={1}>
            <Box flexDirection="row">
              <Box width={2} flexShrink={0}>
                <Text color="success">
                  {g}
                </Text>
              </Box>
              <Text dimColor>
                {text}
              </Text>
            </Box>
            <Box flexDirection="row">
              <Box width={2} flexShrink={0}>
                <Text color="success">
                  {g2}
                </Text>
              </Box>
              <Text dimColor>
                {text2}
              </Text>
            </Box>
            <Box flexDirection="row">
              <Box width={2} flexShrink={0}>
                <Text color="success">
                  {g3}
                </Text>
              </Box>
              <Text dimColor>
                {text3}
              </Text>
            </Box>
          </Box>
        </Box>
      </Box>
    )
  })
}

Mod 自身のコード

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

hooks/drawer.tsx 586〜678 行 · バンド
  on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
    if (e.props.hasSurvey) return next(e);
    if (!S.loaded) await refresh($);
    if (!S.active) return next(e);
    // Another plugin's band draws beneath this one rather than being replaced.
    const below = await next(e);
    const { Box, Text, Button } = $.ui.resolve(e);
    const present = byCode(prefixes());
    const most = Math.max(0, ...present.map((p) => ofPrefix(p).length));
    // Border 2, header 1, band row 1; what is left holds titles, at most 10.
    const listRows = Math.max(1, Math.min(REVEAL_MAX, most, e.props.maxRows - 4));
    const revealHeight = listRows + 3;
    const titleWidth = Math.max(10, e.props.bodyColumns - 4);
    // The hint goes when the row would not fit, as beside a docked pane: a row
    // too wide shrinks its Texts to nothing rather than cutting the tail.
    const labels = present.map((p) => `${p}:${ofPrefix(p).length}`).join('|');
    const hint = `▸ ${TITLE} · open | use /${PANE} · ${labels}`.length <= e.props.bodyColumns ? `| use /${PANE} ·` : '·';
    const openType = (p: string, code = '') => {
      S.query = code;
      S.selected = code;
      S.prefix = p;
      void openPane($).then(() => $.ui.invalidate('ui.render'));
    };
    const band = (
      <Box flexDirection="column">
        {(S.paneOpen ? [] : present).map((p) => {
          const items = ofPrefix(p);
          const shown = items.slice(-listRows);
          return (
            <Box
              key={`reveal-${p}`}
              display="none"
              hover={{ scope: `kband-${p}`, display: 'flex' }}
              flexDirection="column"
              height={revealHeight}
              overflow="hidden"
              borderStyle="round"
              paddingX={1}
            >
              <Box key={`reveal-head-${p}`} flexDirection="row" gap={2}>
                <Text bold>{`${groupName(p)} · ${items.length}`}</Text>
                {items.length > shown.length ? <Text dimColor>{`latest ${shown.length}`}</Text> : null}
                <Button key={`reveal-all-${p}`} label={`list all ${items.length} ▸`} plain onPress={() => openType(p)} />
              </Box>
              {shown.map((i) => (
                <Button
                  key={`reveal-${i.code}`}
                  label={clip(`${i.code}${mark(i)}  ${i.title}`, titleWidth)}
                  plain
                  onPress={() => openType(p, i.code)}
                />
              ))}
            </Box>
          );
        })}
        <Box key="band-row" flexDirection="row" gap={1} height={1} overflow="hidden">
          <Box key="band-head" flexDirection="row" gap={1} flexShrink={0}>
            <Text color={TEAL}>{`▸ ${TITLE}`}</Text>
            <Text dimColor>·</Text>
            <Button
              key="open"
              label="open"
              plain
              hover={{ scope: 'kband-open', underline: true }}
              // An empty query, as /kdrawer with no argument sends, so a code
              // the band opened last time does not stay listed past Status.
              onPress={() => {
                void openPane($, '').then(() => refresh($)).then(() => $.ui.invalidate('ui.render'));
              }}
            />
            <Text dimColor>{hint}</Text>
          </Box>
          {present.length === 0 ? <Text dimColor>no codes yet</Text> : null}
          <Box key="band-labels" flexDirection="row">
            {present.map((p, k) => (
              <Box key={`label-${p}`} flexDirection="row" flexShrink={0} hover={{ scope: `kband-${p}` }}>
                <Button
                  key={`band-${p}`}
                  label={`${p}:${ofPrefix(p).length}`}
                  plain
                  dimColor
                  hover={{ scope: `kband-${p}`, bold: true }}
                  onPress={() => openType(p)}
                />
                {k < present.length - 1 ? <Text dimColor>|</Text> : null}
              </Box>
            ))}
          </Box>
        </Box>
      </Box>
    );
    return below ? <Box flexDirection="column">{band}{below}</Box> : band;
  }).catch(($, e, next) => next(e));
hooks/drawer.tsx 680〜839 行 · ペイン
  on('ui.render', { component: 'Pane', requestId: PANE }, ($, e, next) => {
    if (!S.active) return next(e);
    const T = $.ui.resolve(e);
    const { Box, Text, Button } = T;
    const redraw = () => $.ui.invalidate('ui.render');
    const rows = visible();
    const width = Math.max(20, e.props.bodyColumns);
    const present = byName(prefixes());
    const groups = byName([...new Set(rows.map((i) => i.prefix))]);
    // The pane losing focus, a click in the transcript or the prompt, closes the menu.
    if (!e.props.isFocused) S.filterOpen = S.statusOpen = false;
    // Row 2 names the filter by its code when the full name would push the
    // view toggle onto a line of its own, as in a docked pane. A Button draws
    // as `[ label ]`, the controls sit 2 apart, and the row keeps 2 of padding.
    // Past that the row wraps, and the menu drops below its last line.
    const viewLabel = S.full ? 'Show short view' : 'Show full view';
    // Status opens a menu of all, open, and resolved, with the key to the row
    // glyphs below them. Clear leaves it alone: Status is a standing
    // preference that outlives the pane, and Clear undoes one visit's search.
    const showLabel = `Status: ${S.show} ${S.statusOpen ? '▴' : '▾'}`;
    const named = S.only.length > 0 ? 'still open' : S.prefix === 'all' ? 'all types' : groupName(S.prefix);
    const controls = (filter: string) => [filter.length + 4, showLabel.length + 4, 'Clear'.length + 4, viewLabel.length + 4];
    const fits = lines(controls(`Filter: ${named} ▾`), width - 2, 2) === 1;
    const filterLabel = `Filter: ${fits ? named : S.only.length > 0 ? 'open' : S.prefix} ${S.filterOpen ? '▴' : '▾'}`;
    const menuTop = 1 + lines(controls(filterLabel), width - 2, 2);
    const menu = [
      { value: 'all', name: 'All types', n: S.items.length },
      ...present.map((p) => ({ value: p, name: groupName(p), n: ofPrefix(p).length })),
    ];
    // The menu reaches the Clear button's right edge, wider only for a long name.
    const reach = filterLabel.length + 4 + 2 + showLabel.length + 4 + 2 + 'Clear'.length + 4;
    const longest = Math.max(...menu.map((f) => `● ${f.name} ${f.n}`.length)) + 4;
    const menuWidth = Math.min(width, Math.max(reach, longest));
    // The Status menu drops below the Status button, or from the left edge
    // when the button wrapped onto a line of its own.
    const statusMenu = SHOWS.map((s) => ({
      value: s,
      n: S.items.filter((i) => (S.prefix === 'all' || i.prefix === S.prefix) && shows(i, s)).length,
    }));
    const legend = [
      { g: '○', text: 'open, or never closes' },
      { g: '✓', text: 'answered, settled, or done' },
      { g: '✗', text: 'dismissed, dropped, or withdrawn' },
      { g: '!', text: 'corrected, title not restated' },
    ];
    const statusWidth = Math.min(width, Math.max(...legend.map((l) => l.text.length + 2), ...statusMenu.map((f) => `● ${f.value} ${f.n}`.length)) + 4);
    // A menu wider than the room right of the button shifts left to stay inside the drawer.
    const statusLeft = Math.max(0, Math.min(width - statusWidth, lines([filterLabel.length + 4, showLabel.length + 4], width - 2, 2) === 1 ? filterLabel.length + 4 + 2 : 0));

    const body = (i: Item) => [
      closingLine(Text, i, `closed-${i.code}`),
      correctionLine(Text, i, `corrected-${i.code}`),
      backlinks(i) ? <Text key={`cited-${i.code}`} wrap="wrap" dimColor>{backlinks(i)}</Text> : null,
      i.summary ? <Text key={`sum-${i.code}`} wrap="wrap" dimColor={i.prefix === 'Q'}>{i.summary}</Text> : null,
      ...i.options.map((o) => <Text key={`opt-${i.code}-${o.key}`} wrap="wrap">{`  ${o.key}. ${o.text}`}</Text>),
      i.rec ? <Text key={`rec-${i.code}`} wrap="wrap"><Text bold>Recommended:</Text>{` ${i.rec}`}</Text> : null,
    ];

    // A row is a table line: the code, the status glyph, and the title, which
    // wraps in the cells left. Every row keeps the glyph cell, blank or not, so
    // every title starts in one column. The code cell fits the widest code
    // shown and its marker.
    const codeWidth = Math.max(0, ...rows.map((i) => i.code.length)) + 4;
    // A heading counts its type under the search and filters but not Status,
    // and for a type that closes, how many are open, so Status open never
    // reads "1 open of 1".
    const every = visible('all');
    const heading = (p: string) => {
      const of = every.filter((i) => i.prefix === p);
      const open = of.filter((i) => !isClosed(i)).length;
      return CLOSING.has(p) ? `${groupName(p)} · ${open} open of ${of.length}` : `${groupName(p)} · ${of.length}`;
    };
    // A check is green, a cross red, and a circle grey, in a row and in the key.
    const paint = (g: string) =>
      g === '✓' ? <Text color="success">{g}</Text> : g === '✗' ? <Text color="error">{g}</Text> : g === '!' ? <Text color="warning">{g}</Text> : <Text dimColor>{g}</Text>;

    // The code is a button: pressing it opens the item as a card beneath the
    // row, in a frame, and pressing it again closes the card.
    const entry = (i: Item) => {
      const open = S.selected === i.code;
      return (
        <Box key={`row-${i.code}`} flexDirection="column" marginTop={S.full ? 1 : 0}>
          <Box key={`line-${i.code}`} flexDirection="row" alignItems="flex-start">
            <Box key={`cell-code-${i.code}`} width={codeWidth} flexShrink={0}>
              <Button
                key={`pick-${i.code}`}
                label={`${open ? '▾' : '▸'} ${i.code}`}
                plain
                hover={{ scope: `kref-${i.code}`, inverse: true }}
                onPress={() => {
                  S.selected = open ? '' : i.code;
                  S.filterOpen = S.statusOpen = false;
                  redraw();
                }}
              />
            </Box>
            <Box key={`cell-status-${i.code}`} width={2} flexShrink={0}>
              {paint(glyph(i))}
            </Box>
            <Box key={`cell-title-${i.code}`} flexGrow={1} flexShrink={1} minWidth={0}>
              <Text wrap="wrap">{i.title}</Text>
            </Box>
          </Box>
          {open ? (
            <Box
              key={`card-${i.code}`}
              flexDirection="column"
              borderStyle="round"
              backgroundColor="userMessageBackground"
              paddingX={1}
            >
              <Text color="cyan">{`${i.code}${mark(i)} · ${nameOf(i)}`}</Text>
              {body(i)}
            </Box>
          ) : S.full ? (
            body(i)
          ) : null}
        </Box>
      );
    };

    return (
      <Box flexDirection="column" width={width}>
        <Box key="top" flexDirection="row">
          {'Input' in T ? (
            <Box key="q-box" flexGrow={1} flexShrink={1}>
              <T.Input
                key="q"
                label="Search"
                placeholder="code, title, body, option"
                value={S.query}
                submitLabel=""
                autoFocus
                onInput={(v) => {
                  S.query = v;
                  redraw();
                }}
                onSubmit={(v) => {
                  S.query = v;
                  redraw();
                }}
              />
            </Box>
          ) : null}
        </Box>
        <Box key="filters" flexDirection="row" flexWrap="wrap" columnGap={2} paddingRight={2}>
          <Button
            key="filter"
            label={filterLabel}
            hotkey="f"
            onPress={() => {
              S.filterOpen = !S.filterOpen;
              S.statusOpen = false;
              redraw();
            }}
          />
          <Button
            key="show"
            label={showLabel}
            hotkey="s"
ライセンスの全文(MIT)
MIT License

Copyright (c) 2026 Holden Hewett

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

載せる条件: 確かめやすいコード
入口を読んだhooks/hooks.json が名指すモジュールをすべて読んだ。hooks/register.ts
解析できるすべてのファイルが 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/… などは無い)。hooks/register.ts:138 rm(Windows にない)
通信fetch の送り先(https のホスト)がコードに書いてあるか。通信なし
プログラム起動するプログラムの名前がコードに書いてあり、シェル・インタプリタ・通信用の道具でないか。git(通信する), rm
読んで送るファイルや環境変数を読み、かつ通信するか。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 OpenScribbler/Katharsis
/plugin install katharsis@openscribbler

入るのはマーケットプレイスの最新のコミットで、ここで読んだもの(f53e560879cb)と違うことがあります。入れる前に見比べてください。

Claude に聞く

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

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

Claude から探す: MCP コネクタ

似たデザイン