modscode EN

modscode / 図鑑 / mokkan

mokkan

Cross-session reminders: /mokkan toggles a live pane with your TODOs, Reminders and Archived tabs, /mokkan <command> runs push, in, edit, ack, done and the rest at once, and the /mokkan:mokkan skill lets Claude do it for you.

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

何をするか

  • 欄・トーストを描く
  • classic.SessionStart・prompt.edit・session.start・ui.close ほか 1 個にフックする
  • ターンをまたいで自分の状態を持つ
  • プロセスを起こす

良いところ

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

作り始めるためのコード

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

雛形(register.tsx)

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

// Drawn like mokkan by Victor Benetatos (pane, toast), as modscode read it from the mod's code:
// https://modscode.com/gallery/vicmpen-mokkan/
// 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: "mokkan" })
  on('ui.render', { component: 'Pane', requestId: 'my-pane' }, async ($, e) => {
    const { Box, Text, Button, Input } = $.ui.resolve(e)
    const balance = '…'
    const name = '…'
    const length = '…'
    const glyph = '…'
    const n = '…'
    const time = '…'
    const line = '…'
    const time2 = '…'
    const time3 = '…'
    const label = '…'
    const hint = '…'
    const value = '…'
    const submit = '…'
    const line2 = '…'
    const line3 = '…'
    const url = '…'
    const flow = '…'
    const email = '…'
    const otp = '…'
    const masked = '…'
    const target = '…'
    const hotkey = '…'
    const verb = '…'
    return (
      <Box flexDirection="column">
        <Box>
          <Text bold>
            {" mokkan"}
          </Text>
          <Text color="red">
            {balance}
          </Text>
        </Box>
        <Text bold>
          {" Help"}
        </Text>
        <Text bold>
          {" Privacy policy updated"}
        </Text>
        <Box>
          <Text>
            {" "}
          </Text>
          <Box>
            <Text dimColor>
              {" │ "}
            </Text>
            <Button plain>
              {`${name} ${length}`}
            </Button>
          </Box>
          <Box>
            <Text dimColor>
              {" │ "}
            </Text>
            <Button plain>
              {`${name} ${length}`}
            </Button>
          </Box>
          <Box>
            <Text dimColor>
              {" │ "}
            </Text>
            <Button plain>
              {`${name} ${length}`}
            </Button>
          </Box>
        </Box>
        <Text dimColor>
          ────────
        </Text>
        <Box flexDirection="column">
          <Box flexDirection="column">
            <Text dimColor>
              {" Nothing archived yet."}
            </Text>
            <Text dimColor>
              {" d archives the selected row."}
            </Text>
          </Box>
          <Box flexDirection="column">
            <Box>
              <Text>
                {"▸ "}
              </Text>
              <Text>
                {`${glyph} `}
              </Text>
              <Text>
                {"        "}
              </Text>
              <Button plain hotkey={`${n}`} />
              <Text>
                {"        "}
              </Text>
              <Text color="red">
                {time}
              </Text>
            </Box>
            <Text>
              {`        ${line}`}
            </Text>
            <Text>
              {`        ${line}`}
            </Text>
            <Text>
              {`        ${line}`}
            </Text>
            <Text dimColor>
              {`        ${line}`}
            </Text>
            <Text dimColor>
              {`        ${line}`}
            </Text>
            <Text dimColor>
              {`        ${line}`}
            </Text>
          </Box>
          <Box flexDirection="column">
            <Box>
              <Text>
                {"▸ "}
              </Text>
              <Text>
                {`${glyph} `}
              </Text>
              <Text>
                {"        "}
              </Text>
              <Button plain hotkey={`${n}`} />
              <Text>
                {"        "}
              </Text>
              <Text color="red">
                {time2}
              </Text>
            </Box>
            <Text>
              {`        ${line}`}
            </Text>
            <Text>
              {`        ${line}`}
            </Text>
            <Text>
              {`        ${line}`}
            </Text>
            <Text dimColor>
              {`        ${line}`}
            </Text>
            <Text dimColor>
              {`        ${line}`}
            </Text>
            <Text dimColor>
              {`        ${line}`}
            </Text>
          </Box>
          <Box flexDirection="column">
            <Box>
              <Text>
                {"▸ "}
              </Text>
              <Text>
                {`${glyph} `}
              </Text>
              <Text>
                {"        "}
              </Text>
              <Button plain hotkey={`${n}`} />
              <Text>
                {"        "}
              </Text>
              <Text color="red">
                {time3}
              </Text>
            </Box>
            <Text>
              {`        ${line}`}
            </Text>
            <Text>
              {`        ${line}`}
            </Text>
            <Text>
              {`        ${line}`}
            </Text>
            <Text dimColor>
              {`        ${line}`}
            </Text>
            <Text dimColor>
              {`        ${line}`}
            </Text>
            <Text dimColor>
              {`        ${line}`}
            </Text>
          </Box>
        </Box>
        <Box flexGrow={1} />
        <Box paddingLeft={1}>
          <Text wrap="wrap">
            {" "}
          </Text>
        </Box>
        <Box flexDirection="column" paddingLeft={1}>
          <Input autoFocus label={`${label}`} placeholder={`${hint}`} value={`${value}`} submitLabel={`${submit}`} />
          <Box gap={1}>
            <Button plain>
              cancel
            </Button>
            <Text dimColor>
              (Tab to it, then Enter)
            </Text>
          </Box>
        </Box>
        <Box flexDirection="column" paddingLeft={1}>
          <Box flexDirection="column">
            <Text wrap="wrap">
              {line}
            </Text>
            <Text wrap="wrap">
              {line2}
            </Text>
            <Text wrap="wrap">
              {line3}
            </Text>
            <Text wrap="wrap">
              {url}
            </Text>
            <Box>
              <Button hotkey="y" plain>
                continue
              </Button>
              <Text dimColor>
                {" · "}
              </Text>
              <Button hotkey="n" plain>
                cancel
              </Button>
            </Box>
          </Box>
          <Input autoFocus label={`${flow} email`} placeholder="you@example.com" value={`${email}`} submitLabel="next" />
          <Input autoFocus label="one-time code" placeholder={`the code emailed to ${email}`} value={`${otp}`} submitLabel="next" />
          <Input autoFocus label={`password for ${email}`} placeholder="hidden as you type" value={`${masked}`} submitLabel="log in" />
          <Box gap={1}>
            <Button plain>
              cancel
            </Button>
            <Text dimColor>
              (Tab to it, then Enter)
            </Text>
          </Box>
        </Box>
        <Box flexDirection="column">
          <Text color="yellow">
            {` log out ${target}?`}
          </Text>
          <Box>
            <Text>
              {" "}
            </Text>
            <Button hotkey="y" plain>
              log out
            </Button>
            <Text dimColor>
              {" · "}
            </Text>
            <Button hotkey="n" plain>
              stay
            </Button>
          </Box>
        </Box>
        <Box flexDirection="column">
          <Box>
            <Text>
              {" "}
            </Text>
            <Box>
              <Text dimColor>
                {" · "}
              </Text>
              <Button hotkey={`${hotkey}`} plain role="dismiss" />
            </Box>
            <Box>
              <Text dimColor>
                {" · "}
              </Text>
              <Button hotkey={`${hotkey}`} plain role="dismiss" />
            </Box>
            <Box>
              <Text dimColor>
                {" · "}
              </Text>
              <Button hotkey={`${hotkey}`} plain role="dismiss" />
            </Box>
          </Box>
          <Box>
            <Text>
              {" "}
            </Text>
            <Box>
              <Text dimColor>
                {" · "}
              </Text>
              <Button hotkey={`${hotkey}`} plain role="dismiss" />
            </Box>
            <Box>
              <Text dimColor>
                {" · "}
              </Text>
              <Button hotkey={`${hotkey}`} plain role="dismiss" />
            </Box>
            <Box>
              <Text dimColor>
                {" · "}
              </Text>
              <Button hotkey={`${hotkey}`} plain role="dismiss" />
            </Box>
          </Box>
          <Box>
            <Text>
              {" "}
            </Text>
            <Box>
              <Text dimColor>
                {" · "}
              </Text>
              <Button hotkey={`${hotkey}`} plain role="dismiss" />
            </Box>
            <Box>
              <Text dimColor>
                {" · "}
              </Text>
              <Button hotkey={`${hotkey}`} plain role="dismiss" />
            </Box>
            <Box>
              <Text dimColor>
                {" · "}
              </Text>
              <Button hotkey={`${hotkey}`} plain role="dismiss" />
            </Box>
          </Box>
        </Box>
        <Text color="yellow">
          {` ${verb}`}
        </Text>
      </Box>
    )
  })

  on('session.start', async ($, e, next) => {
    const text = '…'
    await $.ui.toast(`mokkan: due · ${text}`)
    return next(e)
  })
}

Mod 自身のコード

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

claude-plugin/hooks/pane.tsx 452〜611 行 · ペイン
  on('ui.render', { component: 'Pane', requestId: PANE }, async ($, e) => {
    if (e.surface === 'terminal') {
      const holds = e.props.isFocused !== false
      if (heldKeys && !holds) lostAt = await $.clock.now()
      heldKeys = holds
    }
    const t = $.ui.resolve(e)
    const { Box, Text, Button } = t
    const Input = e.surface !== 'mobile' && 'Input' in t ? t.Input : null // mobile has no Input
    const [v, m, sel, tb, msg, verb, sync, helping, gated, now] = await Promise.all([
      read($, view), read($, mode), read($, selected), read($, tab), read($, message), read($, busy), read($, syncing), read($, help), read($, privacy), $.clock.now(),
    ])
    // The terminal gets the pane's own border, two columns of the body; the remote surfaces draw their own focus.
    const framed = e.surface === 'terminal'
    const width = (e.props.bodyColumns ?? e.viewport?.columns ?? COLUMNS) - (framed ? 2 : 0)
    const docked = e.props.placement === 'dock'
    const bodyRows = e.props.scroll?.bodyRows ?? e.viewport?.rows ?? 24
    const focused = e.surface !== 'terminal' || e.props.isFocused !== false
    const loggedOut = v.failure?.kind === 'loggedOut'
    const offline = v.failure?.kind === 'offline'
    const list = rowsOf(v, tb)
    const current = list.find(r => r.id === sel)

    /** Every key goes through here: dropped while a CLI call runs; it clears the message said before it. */
    const go = <A extends unknown[]>(f: (...a: A) => unknown) => (...a: A) => {
      if (running) return
      const before = said
      void update($, message, was => (was && was.id <= before ? null : was))
      return f(...a)
    }
    const needOne = () => say($, 'select a row first (its number or ↑↓)', 'note')
    const cancel = () => { secret = ''; return update($, mode, () => NORMAL) }
    const switchView = async (to?: MokkanTab) => {
      await update($, tab, was => to ?? after(was))
      await update($, selected, () => null)
    }
    // The ring follows a click or a digit too, so ↑/↓ and ←/→ walk on from the selected row.
    const select = async (r: MokkanReminder) => {
      await update($, selected, () => r.id)
      void reveal($, r.id)
      void $.ui.focus({ requestId: PANE, key: `row-${r.id}` }).catch(() => {})
    }
    const askDone = (r: MokkanReminder) =>
      update($, mode, (): MokkanMode => ({ kind: 'confirm', action: r.state === 'done' ? 'undone' : 'done', target: r.text, targetId: r.id }))
    /** A press on the row already selected (Enter under the focus, a click, its digit) asks to finish it, or reopen it. */
    const press = (r: MokkanReminder) => (r.id === sel ? askDone(r) : select(r))
    /** A digit key selects its row at once; within a second of the one before, the two make rows 10–99. */
    const typed = async (d: number) => {
      const at = await $.clock.now()
      const was = pending
      pending = null
      const two = was && at - was.at < 1000 ? list[was.digit * 10 + d - 1] : undefined
      if (two) return select(two)
      if (d === 0) return say($, 'type 1 then 0 for row 10', 'note')
      const r = list[d - 1]
      if (!r) return
      if (list.length < d * 10) return press(r)
      const mine = pending = { digit: d, at }
      // The selected row's own digit asks only once no second digit follows it.
      if (r.id === sel) $.clock.after(1000, async () => {
        if (pending !== mine || running) return
        pending = null
        const [still, md] = await Promise.all([read($, selected), read($, mode)])
        if (still === r.id && md.kind === 'normal') await askDone(r)
      })
      return select(r)
    }
    const toggleDone = (id: string, text: string, reopen: boolean, first?: () => Promise<unknown>) => reopen
      ? act($, 'reopening…', ['undone', id], `reopened · ${text}`, first)
      : act($, 'archiving…', ['done', id], `archived · ${text}`, first)
    const field = async (purpose: 'push' | 'in' | 'edit' | 'time' | 'feedback') => {
      const needsOne = purpose === 'edit' || purpose === 'time'
      if (needsOne && (!current || current.state === 'done')) return needOne()
      const next: MokkanMode = { kind: 'input', purpose, targetId: current?.id, value: purpose === 'edit' ? current?.text ?? '' : '' }
      await update($, mode, () => next)
      void $.ui.focus({ requestId: PANE, key: 'field' }).catch(() => {})
    }
    const confirm = async (action: 'pop' | 'dequeue' | 'logout') => {
      if (action === 'logout') {
        const r = await work($, 'checking account…', () => run($, ['status']))
        if (r === undefined) return
        const email = r.ok ? json<{ me?: { email?: string } }>(r.out)?.me?.email : undefined
        return update($, mode, (): MokkanMode => ({ kind: 'confirm', action, target: email ?? '' }))
      }
      const takes = v.reminders.filter(r => ACTIVE.has(r.state))
      const target = action === 'pop' ? takes[0] : takes[takes.length - 1]
      if (!target) return say($, 'the stack is empty', 'note')
      return update($, mode, (): MokkanMode => ({ kind: 'confirm', action, target: target.text }))
    }
    // Registration shows the policy's summary first, as `mokkan register` does in a terminal.
    const startAuth = async (flow: 'login' | 'register') => {
      secret = ''
      const p = flow === 'register' ? await work($, 'fetching the privacy policy…', () => policy($)) : null
      if (flow === 'register' && !p) return
      await update($, mode, (): MokkanMode => ({ kind: 'auth', flow, step: p ? 'policy' : 'email', email: '', otp: '', masked: '', policy: p ?? null }))
      if (!p) void $.ui.focus({ requestId: PANE, key: 'auth' }).catch(() => {})
    }
    /** y on the summary: on to the email, or back to the password when a changed policy was shown again after the code. */
    const continueAuth = async () => {
      await update($, mode, (was): MokkanMode => (was.kind === 'auth' ? { ...was, step: was.otp ? 'password' : 'email' } : was))
      void $.ui.focus({ requestId: PANE, key: 'auth' }).catch(() => {})
    }
    const accept = async (p: MokkanPolicy) => {
      const accepted = await work($, 'accepting…', async () => {
        const r = await run($, ['accept', '--yes', '--version', p.version])
        // 4: the policy changed while it was shown; run has shown the new one.
        if (r.code === PRIVACY_REQUIRED) return false
        if (!r.ok) {
          await say($, firstLine(r.out) || 'failed', 'error')
          return false
        }
        await update($, privacy, () => null)
        await say($, 'privacy policy accepted')
        return true
      })
      if (accepted) await refresh($)
    }

    const toggleHelp = () => update($, help, was => !was)
    // As `mokkan ui`'s b: the CLI opens the checkout itself, and only a Stripe address.
    const buy = () => work($, 'opening checkout…', async () => {
      const r = await run($, ['buy'])
      if (r.code === PRIVACY_REQUIRED) return
      if (!r.ok) return say($, firstLine(r.out) || 'failed', 'error')
      await say($, json<{ opened?: boolean }>(r.out)?.opened === true
        ? 'Opened Stripe Checkout in your browser; the balance updates after payment.'
        : 'Could not open a browser here. Run: mokkan buy --no-open (prints the link).')
    })
    const keys: Record<string, Action> = gated
      ? {
          accept: { label: 'accept', hotkey: 'y', run: () => accept(gated) },
          close: { label: 'close', hotkey: 'n', run: () => $.ui.close({ id: PANE }) },
        }
      : helping
      ? {
          help: { label: 'back', hotkey: 'h', run: toggleHelp },
          close: { label: 'close', hotkey: 'q', run: () => $.ui.close({ id: PANE }) },
        }
      : loggedOut
      ? {
          login: { label: 'log in', hotkey: 'l', needsField: true, run: () => startAuth('login') },
          register: { label: 'register', hotkey: 'r', needsField: true, run: () => startAuth('register') },
          refresh: { label: 'sync', hotkey: 's', run: () => refresh($) },
          help: { label: 'help', hotkey: 'h', run: toggleHelp },
          close: { label: 'close', hotkey: 'q', run: () => $.ui.close({ id: PANE }) },
        }
      // Each key is its label's first letter; a line per kind: add, the selected row, the stack, the rest.
      : {
          push: { label: 'todo', hotkey: 't', needsField: true, run: () => field('push') },
          in: { label: 'reminder', hotkey: 'r', needsField: true, run: () => field('in') },
          edit: { label: 'edit', hotkey: 'e', needsField: true, group: true, run: () => field('edit') },
          time: { label: 'when', hotkey: 'w', needsField: true, run: () => field('time') },
          done: { label: tb === 'archived' ? 'reopen' : 'archive', hotkey: 'd', run: () => (current ? toggleDone(current.id, current.text, current.state === 'done') : needOne()) },
          ack: { label: 'ack', hotkey: 'a', run: () => (current && current.state !== 'done' ? act($, 'acking…', ['ack', current.id], `acked · ${current.text}`) : needOne()) },
          // Pop and dequeue are off for now.
          // pop: { label: 'pop top', hotkey: 'p', group: true, run: () => confirm('pop') },
          // dequeue: { label: 'pop oldest', hotkey: 'o', run: () => confirm('dequeue') },
          view: { label: `view ${label(after(tb)).toLowerCase()}`, hotkey: 'v', group: true, run: () => switchView() },
          refresh: { label: 'sync', hotkey: 's', run: () => refresh($) },
          // The checkout opens on the machine running Claude Code: of no use to someone on a phone.
ライセンスの全文(MIT)
MIT License

Copyright (c) 2026 Victor Benetatos

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

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

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

入れる

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

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

/plugin marketplace add vicmpen/mokkan
/plugin install mokkan@mokkan

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

Claude に聞く

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

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

Claude から探す: MCP コネクタ

似たデザイン