modscode EN

modscode / 図鑑 / boot-sequence

boot-sequence

A BIOS-style boot screen when a session starts: real checks of git, toolchains, devices, ports, context and disk, typed out and flipped to OK, WARN or FAIL

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

何をするか

  • プロンプトの上の帯・欄を描く
  • /boot を足す
  • prompt.submit・session.startにフックする
  • プロセスを起こす

良いところ

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

作り始めるためのコード

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

雛形(register.tsx)

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

// Drawn like boot-sequence by Chris Dwyer (pane, band), as modscode read it from the mod's code:
// https://modscode.com/gallery/ccdwyer-boot-sequence/
// 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 label = '…'
    return (
      <Box flexDirection="column">
        <Box>
          <Text color="#6c7086">
            {label}
          </Text>
          <Text dimColor>
            {"  /boot "}
          </Text>
          <Button label="x" plain />
        </Box>
        {await next(e)}
      </Box>
    )
  })

  // the pane: open it with $.ui.open({ id: 'my-pane', title: "Boot sequence" })
  on('ui.render', { component: 'Pane', requestId: 'my-pane' }, async ($, e) => {
    const { Box, Text } = $.ui.resolve(e)
    const summaryText = '…'
    return (
      <Box flexDirection="column">
        <Text color="#94e2d5">
          {`
${summaryText}  ·  READY.`}
        </Text>
      </Box>
    )
  })
}

Mod 自身のコード

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

hooks/register.tsx 612〜650 行 · バンド
  on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
    const b = await read($, boot)
    if (b === null || e.props.hasSurvey || (await read($, isHidden))) return next(e)
    const below = await next(e)
    const { Box, Text, Button } = $.ui.resolve(e)
    // The rows the band shows at once, less what the mods beneath it need and the skip row.
    const window = Math.max(1, e.props.scroll?.bodyRows ?? e.props.maxRows)
    const cols = Math.max(20, e.props.bodyColumns)
    const room = window - heightOf(below, cols) - 1
    const collapsed = (await read($, isCollapsed)) || b.where === 'pane' || room < 4
    if (collapsed) {
      if (!b.isDone && b.where === 'pane') return below
      // The band is full with the mods beneath: add nothing rather than push them out.
      if (room < 0) return below
      const full = b.isDone ? summaryText(b) : `▣ BOOT  running ${b.lines.filter(l => l.status !== 'run').length}/${IDS.length}`
      const label = full.length > cols - 10 ? `${full.slice(0, Math.max(10, cols - 11))}…` : full
      return (
        <Box flexDirection="column">
          <Box>
            <Text color={b.isDone ? summaryColor(b) : COLOR.run}>{label}</Text>
            <Text dimColor>{'  /boot '}</Text>
            <Button key="hide" label="x" plain onPress={() => update($, isHidden, () => true)} />
          </Box>
          {below}
        </Box>
      )
    }
    const at = await read($, tick)
    const columns = Math.max(20, e.props.bodyColumns)
    return (
      <Box flexDirection="column">
        {logTree($.ui.resolve(e), b, at, columns, Math.min(room, 16), e.surface === 'terminal')}
        <Box>
          <Button key="skip" label="skip" hotkey="s" onPress={() => update($, isCollapsed, () => true)} />
        </Box>
        {below}
      </Box>
    )
  })
hooks/register.tsx 508〜565 行 · バンド
function logTree(els: Els, b: Boot, at: number, columns: number, room: number, isTerminal: boolean): RenderElement[] {
  const { Box, Text } = els
  const rows: RenderElement[] = []
  let used = 0
  const hasRaster = isTerminal && 'Raster' in els && columns >= LOGO_COLS + 2 && room >= LOGO_ROWS + 4
  if (hasRaster) {
    const Raster = (els as { Raster: (p: { key: string; columns: number; rows: number; cells: string }) => RenderElement }).Raster
    rows.push(<Raster key="logo" columns={LOGO_COLS} rows={LOGO_ROWS} cells={logoCells(at)} />)
    used += LOGO_ROWS
  } else {
    rows.push(<Text key="logo" color="#89dceb" bold>{'▓▒░ CLAUDE CODE ░▒▓'}</Text>)
    used += 1
  }
  const sinceLogo = Math.max(0, at - LOGO_TICKS)
  let budget = sinceLogo * CHARS_PER_TICK
  const header = 'CLAUDE CODE BIOS · POWER-ON SELF TEST'
  if (room - used >= 2) {
    rows.push(<Text key="hdr" color="#94e2d5">{typed(header, budget)}</Text>)
    used += 1
  }
  budget -= header.length
  if (b.memoryMb > 0 && budget > 0 && room - used >= 2) {
    const target = b.memoryMb * 1024
    const shown = Math.min(target, Math.round((target * Math.min(sinceLogo, 30)) / 30))
    const done = shown >= target
    rows.push(
      <Box key="mem">
        <Text color="#cdd6f4">{`MEMORY TEST  ${String(shown).padStart(9)}K `}</Text>
        <Text color={done ? COLOR.ok : COLOR.run}>{done ? 'OK' : '..'}</Text>
      </Box>,
    )
    used += 1
  }
  const lineRows: RenderElement[] = []
  // Short of room, warnings and failures come first, then the rest in check order.
  const keep = Math.max(1, room - used)
  const ordered = b.lines.length <= keep ? b.lines : [...b.lines.filter(l => l.status === 'fail' || l.status === 'warn'), ...b.lines.filter(l => l.status !== 'fail' && l.status !== 'warn')].slice(0, keep)
  const shownIds = new Set(ordered.map(l => l.id))
  for (const l of b.lines.filter(x => shownIds.has(x.id))) {
    if (budget <= 0) break
    const left = `${l.label.padEnd(10)} `
    const detailRoom = Math.max(8, columns - left.length - 11)
    const detail = l.detail.length > detailRoom ? `${l.detail.slice(0, detailRoom - 1)}…` : l.detail
    const shownLeft = typed(left + detail, budget)
    budget -= left.length + detail.length
    const finished = budget >= 0
    const spin = '⣾⣽⣻⢿⡿⣟⣯⣷'[at % 8] as string
    const badge = l.status === 'run' ? `[ ${spin}${spin}${spin}${spin} ]` : BADGE[l.status]
    lineRows.push(
      <Box key={`l-${l.id}`}>
        <Text color={COLOR[l.status]}>{finished ? badge : '[      ]'}</Text>
        <Text color="#cdd6f4">{` ${shownLeft}`}</Text>
        {!finished && <Text color="#a6e3a1">{at % 2 === 0 ? '█' : ' '}</Text>}
      </Box>,
    )
  }
  return [...rows, ...lineRows]
}
hooks/register.tsx 652〜665 行 · ペイン
  on('ui.render', { component: 'Pane', requestId: PANE }, async ($, e) => {
    const { Box, Text } = $.ui.resolve(e)
    const b = await read($, boot)
    if (b === null) return <Text dimColor>Starting…</Text>
    const at = await read($, tick)
    const columns = Math.max(20, e.props.bodyColumns)
    const room = Math.max(6, (e.viewport?.rows ?? 30) - 4)
    return (
      <Box flexDirection="column">
        {logTree($.ui.resolve(e), b, at, columns, room, e.surface === 'terminal')}
        {b.isDone && <Text color="#94e2d5">{`\n${summaryText(b)}  ·  READY.`}</Text>}
      </Box>
    )
  })
ライセンスの全文(MIT)
MIT License

Copyright (c) 2026 Chris Dwyer

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.

コードが呼ぶもの

プログラム起動ファイル読み取り

コードから読めること

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

載せる条件: 確かめやすいコード
入口を読んだhooks/hooks.json が名指すモジュールをすべて読んだ。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 のホスト)がコードに書いてあるか。通信なし
プログラム起動するプログラムの名前がコードに書いてあり、シェル・インタプリタ・通信用の道具でないか。hooks/register.tsx:137 実行時に決まるプログラム
読んで送るファイルや環境変数を読み、かつ通信するか。通信しない
ソースの鍵ソースに 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 のデザイン「ccdwyer-boot-sequence」をコードごと読んで、同じようなペインを作って

Claude から探す: MCP コネクタ

似たデザイン