modscode EN

modscode / 図鑑 / korus-inbox

korus-inbox

Gathers what only the owner can act on across sessions: open questions, refusals that hand the act to the person, and owner_action signals, each with its recommended action, in an /inbox pane and an inbox N band

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

何をするか

  • プロンプトの上の帯・欄・トーストを描く
  • ツールの呼び出しを見張る(止めることがある)
  • classic.PreToolUse・classic.SessionStart・classic.UserPromptSubmit・session.end ほか 1 個にフックする
  • ターンをまたいで自分の状態を持つ
  • プロセスを起こす

良いところ

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

作り始めるためのコード

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

雛形(register.tsx)

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

// Drawn like korus-inbox by MEFORORG (pane, band, status, toast), as modscode read it from the mod's code:
// https://modscode.com/gallery/mefororg-korus-inbox/
// 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, Button } = $.ui.resolve(e)
    const count = '…'
    return (
      <Box flexDirection="column">
        <Button label={`inbox ${count}`} hotkey="i" />
        {await next(e)}
      </Box>
    )
  })

  // the pane: open it with $.ui.open({ id: 'my-pane', title: "Owner inbox" })
  on('ui.render', { component: 'Pane', requestId: 'my-pane' }, async ($, e) => {
    const { Box, Text, Button } = $.ui.resolve(e)
    const count = '…'
    const moreRemote = '…'
    const length = '…'
    const note = '…'
    const headOf = '…'
    const how = '…'
    const how2 = '…'
    const how3 = '…'
    return (
      <Box flexDirection="column">
        <Text bold>
          {`${count} waiting on the owner`}
        </Text>
        <Text dimColor wrap="wrap">
          {`${moreRemote} more waiting from other sessions are not shown. /inbox shows the newest ${length}.`}
        </Text>
        <Text color="yellow">
          {note}
        </Text>
        <Text dimColor>
          Nothing waits on the owner.
        </Text>
        <Box flexDirection="column" marginTop={1}>
          <Button label={`Hide done (${length})`} />
          <Box flexDirection="column" marginTop={1}>
            <Text dimColor wrap="wrap">
              {`Done: ${headOf}`}
            </Text>
            <Text dimColor wrap="wrap">
              {how}
            </Text>
            <Box>
              <Button label="Dismiss" />
            </Box>
          </Box>
          <Box flexDirection="column" marginTop={1}>
            <Text dimColor wrap="wrap">
              {`Done: ${headOf}`}
            </Text>
            <Text dimColor wrap="wrap">
              {how2}
            </Text>
            <Box>
              <Button label="Dismiss" />
            </Box>
          </Box>
          <Box flexDirection="column" marginTop={1}>
            <Text dimColor wrap="wrap">
              {`Done: ${headOf}`}
            </Text>
            <Text dimColor wrap="wrap">
              {how3}
            </Text>
            <Box>
              <Button label="Dismiss" />
            </Box>
          </Box>
        </Box>
      </Box>
    )
  })

  on('session.start', async ($, e, next) => {
    await $.ui.toast(`Go to session: that session has gone quiet, so its app window may be closed.`)
    await $.ui.toast(`Go to session: that session names no app instance on this machine.`)
    return next(e)
  })
}

Mod 自身のコード

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

plugins/korus-inbox/hooks/register.tsx 1731〜1755 行 · バンド
  on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
    const below = await next(e)
    const { count } = await waiting($)
    if (count === 0 || e.props.hasSurvey) return below
    const { Box, Button } = $.ui.resolve(e)
    const band = (
      <Button
        key="korus-inbox:open"
        label={`inbox ${count}`}
        hotkey="i"
        onPress={() => {
          void openInbox($).catch(() => $.ui.toast('Owner inbox did not open.'))
        }}
      />
    )
    // The engine draws nothing of its own here, so an engine element means
    // no other hook drew a band.
    if (below.type === 'engine') return band
    return (
      <Box flexDirection="column">
        {band}
        {below}
      </Box>
    )
  })
plugins/korus-inbox/hooks/register.tsx 1919〜2078 行 · ペイン
  on('ui.render', { component: 'Pane', requestId: PANE }, async ($, e) => {
    const { Box, Button, Text } = $.ui.resolve(e)
    const now = await $.clock.now()
    const mine = await read($, own)
    const theirs = await read($, remote)
    const note = await read($, folderNote)
    const opened = new Set(await read($, expanded))
    const myLabel = await shownName($)
    const list = waitingOf(mine, theirs)
    const done = mine.filter(isDone)

    // Rows the card draws itself, each cut at the edge and never wrapped, so
    // a row starts only where these rows say it does.
    const drawRows = (prefix: string, lines: readonly string[]) =>
      lines.map((line, index) => (
        <Text key={`${prefix}:${index}`} wrap="truncate-end">
          {line}
        </Text>
      ))

    const copyButton = (key: string, text: string | undefined) =>
      text !== undefined && text !== '' ? (
        <Button
          key={key}
          label="Copy"
          onPress={async press => {
            const copied = await $.ui.copy({ text, surface: press.surface })
            $.ui.toast(copied.isCopied ? 'Copied.' : `Not copied: ${copied.reason}`)
          }}
        />
      ) : null

    // The lines every card shares, in order: Do this, Needs you for, Why, For
    // you, From, Folder. The headline is drawn by the caller.
    const commonLines = (card: Card, from: string, where: string, folderText: string | undefined, keyBase: string) => {
      const needs = needsOf(card)
      const why = whyLineOf(card)
      return (
        <Box key={`${keyBase}:common`} flexDirection="column">
          <Text color="cyan" wrap="wrap">{`Do this: ${doThisOf(card, where)}`}</Text>
          <Text dimColor wrap="wrap">{`Needs you for: ${needs.needs} | confidence: ${needs.confidence}`}</Text>
          {why !== undefined && why !== '' && <Text wrap="wrap">{`Why: ${why}`}</Text>}
          {card.kind === 'refused' && card.ask !== undefined && <Text wrap="wrap">{`For you: ${card.ask}`}</Text>}
          {card.kind === 'question' && <Text wrap="wrap">{questionText(card.questions)}</Text>}
          <Text dimColor wrap="wrap">{`From: ${from}`}</Text>
          {folderText !== undefined && <Text dimColor wrap="wrap">{`Folder: ${folderText}`}</Text>}
        </Box>
      )
    }

    const detailsLines = (card: Card, keyBase: string) => (
      <Box key={`${keyBase}:details`} flexDirection="column">
        {card.command !== undefined && <Text dimColor>Full command:</Text>}
        {card.command !== undefined && <Text wrap="wrap">{clean(card.command, MAX_COMMAND)}</Text>}
        {card.kind === 'refused' && <Text dimColor>Full refusal:</Text>}
        {card.kind === 'refused' && <Text wrap="wrap">{card.detail ?? card.refusal ?? ''}</Text>}
        <Text dimColor wrap="wrap">{`Review: ${needsOf(card).review}`}</Text>
      </Box>
    )

    const partNote = (card: Card, canRun: boolean) => {
      if (card.kind !== 'refused' || card.command === undefined) return null
      const part = card.part?.part
      if (part === undefined) {
        return <Text dimColor wrap="wrap">Copy takes the whole command, not the blocked part alone.</Text>
      }
      if (part === card.command) return null
      return (
        <Text dimColor wrap="wrap">
          {canRun
            ? 'Copy and Run use only the blocked part above, not the whole line.'
            : 'Copy takes only the blocked part above, not the whole line.'}
        </Text>
      )
    }

    // Every Button key names its entry, never its row: a row that moves
    // between the draw and the press cannot carry a press to another entry.
    // Own keys are minted UUIDs; remote keys are checked to a safe alphabet.
    const ownCard = (entry: InboxEntry) => {
      const card = cardOf(entry)
      const where = entry.cwd !== undefined && entry.cwd !== '' ? entry.cwd : '(unknown)'
      const from = `${entry.agentId !== undefined ? 'a subagent of this session' : 'this session'}, ${age(now - entry.createdAt)} ago`
      const run = entry.run
      const isArmed = entry.armedAt !== undefined && now - entry.armedAt < ARM_MS
      const text = runText(entry, card.part)
      const textBlock = entry.kind === 'question' ? undefined : runBlock(entry, card.part)
      // A pane too narrow for a whole row would cut it short, so it offers
      // Copy only; the claim needs a drawn Run now, so it cannot run there.
      const block =
        entry.kind !== 'question' && textBlock === undefined && e.props.bodyColumns < RUN_COLUMNS
          ? `Copy only here: the pane is ${e.props.bodyColumns} columns wide, and Run needs ${RUN_COLUMNS} so that no row is cut short.`
          : textBlock
      const canRun = entry.kind !== 'question' && block === undefined && text !== undefined && run?.status !== 'running'
      const tailHead = run?.status === 'failed' ? 'error: ' : 'out: '
      const isOpen = opened.has(`details:${entry.id}`)
      return (
        <Box key={`own:${entry.id}`} flexDirection="column" marginTop={1}>
          {entry.kind === 'refused' && canRun && text !== undefined ? (
            <Box flexDirection="column">{drawRows(`head:${entry.id}`, labelledRows('Blocked: ', text))}</Box>
          ) : (
            <Text bold wrap="wrap">
              {headOf(card)}
            </Text>
          )}
          {commonLines(card, from, entry.kind === 'question' ? `${myLabel} (this session)` : 'this session', entry.kind === 'question' ? undefined : where, `own:${entry.id}`)}
          {entry.kind === 'signal' && entry.command !== undefined && canRun && (
            <Box flexDirection="column">{drawRows(`cmd:${entry.id}`, labelledRows('Command: ', entry.command))}</Box>
          )}
          {entry.kind === 'signal' && entry.command === undefined && entry.withheld !== undefined && (
            <Text dimColor wrap="wrap">{`(${entry.withheld})`}</Text>
          )}
          {partNote(card, canRun)}
          {run !== undefined && (
            <Box flexDirection="column">
              <Text wrap="wrap">
                {run.status === 'running'
                  ? 'running:'
                  : run.status === 'done'
                    ? `ran, exit ${run.exitCode ?? '?'}:`
                    : 'could not run:'}
              </Text>
              {run.argv !== undefined ? (
                <Box flexDirection="column">
                  {drawRows(`rfolder:${entry.id}`, labelledRows('folder: ', where))}
                  {drawRows(`rargv:${entry.id}`, argvRows(run.argv))}
                </Box>
              ) : (
                <Text dimColor>argv: none, nothing ran</Text>
              )}
              {/* The command writes its own output, so every line of it is
                  marked and cut, and none can draw a row of the views. */}
              {run.tail !== undefined && run.tail !== '' && (
                <Box flexDirection="column">
                  {run.tail.split('\n').map((line, index) => (
                    <Text key={`tail:${entry.id}:${index}`} dimColor wrap="truncate-end">
                      {`${tailHead}${line}`}
                    </Text>
                  ))}
                </Box>
              )}
            </Box>
          )}
          {isArmed && canRun && (
            <Box flexDirection="column">
              <Text color="yellow" wrap="wrap">
                {entry.armedArgv !== undefined
                  ? 'Run now runs this:'
                  : `Run now runs nothing: ${entry.armedError ?? 'no shell was found'}`}
              </Text>
              {entry.armedArgv !== undefined && (
                <Box flexDirection="column">
                  {drawRows(`folder:${entry.id}`, labelledRows('folder: ', where))}
                  {drawRows(`argv:${entry.id}`, argvRows(entry.armedArgv))}
                </Box>
              )}
              <Text dimColor wrap="wrap">
                {`Run now ignores a press within ${ARM_GAP_MS} ms of the last press, so one double press cannot run it.`}
              </Text>
            </Box>
ライセンスの全文(MIT)
MIT License

Copyright (c) 2026 KORUS contributors

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.

コードが呼ぶもの

プログラム起動ファイル書き込み環境変数ツール呼び出し保存

コードから読み取ったデザイン

読み取ったコミットのソースから描いたもので、動かした結果ではありません。一覧は 3 回描き、条件はデスクトップアプリで描く最初の分岐を取り、動かしたときにだけ決まる値は仮の例(点線の下線)にするか省きます。色と書体はこのサイトのものです。

コードから読めること

2026-10-06 に読んだコミット 6d1275193839 のソースから。最初のまとまりが載せる条件で、残りは自分で判断するための材料です。後のコミットは、次に読むまで見ていません。

載せる条件: 確かめやすいコード
入口を読んだhooks/hooks.json が名指すモジュールをすべて読んだ。plugins/korus-inbox/hooks/register.tsx
解析できるすべてのファイルが TypeScript か JavaScript として解析できる。1 ファイルを解析
コードが 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/… などは無い)。Windows にないプログラムを使わない
通信fetch の送り先(https のホスト)がコードに書いてあるか。通信なし
プログラム起動するプログラムの名前がコードに書いてあり、シェル・インタプリタ・通信用の道具でないか。plugins/korus-inbox/hooks/register.tsx:600 実行時に決まるプログラム; plugins/korus-inbox/hooks/register.tsx:650 実行時に決まるプログラム; plugins/korus-inbox/hooks/register.tsx:1263 実行時に決まるプログラム
読んで送るファイルや環境変数を読み、かつ通信するか。通信しない
ソースの鍵ソースに API キーや秘密鍵らしきものがあるか。ソースに鍵なし
ライセンスオープンなライセンス(MIT・Apache-2.0・BSD・ISC・Unlicense・0BSD・CC0)で全文があれば、modscode にコードを載せる。違えばリンクだけ。MIT

コードの文面を読んだだけで、安全の審査ではありません。動かしてはおらず、起動するプログラムの中で何が起きるかも見えません。入れる前の確認はあなたの役目です。 載せる条件

入れる

入れる前に、必ず自分で確かめてください。Mod はサンドボックスなしで、あなたの権限で動きます。modscode はこのコードの安全を保証しません。下のコードを読み(またはフォルダーで claude plugin validate .)、触るものを見て、読んだコミットを入れてください。

リポジトリがそのままマーケットプレイスです。このマーケットプレイスを足し(ターミナルでは次のコマンド、デスクトップアプリではプラグインの設定)、そこから Mod を入れます。

/plugin marketplace add MEFORORG/korus
/plugin install korus-inbox@korus

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

Claude に聞く

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

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

Claude から探す: MCP コネクタ

似たデザイン