modscode EN

modscode / 図鑑 / sc-workspace

sc-workspace

A workspace pane for Claude Code: agents and worktrees, checkpoints, notes, changes and memory files in one tabbed pane

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

何をするか

  • 欄を描く
  • ツールの呼び出しを見張る(止めることがある)
  • agent.spawn・prompt.submit・session.end・session.start ほか 5 個にフックする
  • ターンをまたいで自分の状態を持つ
  • プロセスを起こす

良いところ

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

作り始めるためのコード

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

雛形(register.tsx)

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

// Drawn like sc-workspace by SimpleCORE (pane, band, toast), as modscode read it from the mod's code:
// https://modscode.com/gallery/simplecore-inc-sc-workspace/
// 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: "Workspace" })
  on('ui.render', { component: 'Pane', requestId: 'my-pane' }, async ($, e) => {
    const { Box, Text, Button } = $.ui.resolve(e)
    const brand = '…'
    const release = '…'
    const label = '…'
    const printable = '…'
    const details = '…'
    const details2 = '…'
    const details3 = '…'
    return (
      <Box flexDirection="column">
        <Box justifyContent="space-between" marginTop={1}>
          <Text bold wrap="truncate-end">
            {brand}
          </Text>
          <Box gap={2} flexShrink={0}>
            <Text dimColor>
              {release}
            </Text>
            <Box paddingX={1} flexShrink={0} backgroundColor="#2a2f38">
              <Button label={`${label}`} plain role="dismiss" />
            </Box>
          </Box>
        </Box>
        <Box flexDirection="column" borderStyle="round" borderColor="cyan" paddingX={1}>
          <Text bold>
            {printable}
          </Text>
          <Box flexDirection="column" marginTop={1}>
            <Box gap={1}>
              <Text color="cyan">
                ●
              </Text>
              <Button label={`${printable}`} plain />
              <Box flexShrink={0}>
                <Text dimColor wrap="truncate-end">
                  {details}
                </Text>
              </Box>
            </Box>
            <Box gap={1}>
              <Text color="cyan">
                ●
              </Text>
              <Button label={`${printable}`} plain />
              <Box flexShrink={0}>
                <Text dimColor wrap="truncate-end">
                  {details2}
                </Text>
              </Box>
            </Box>
            <Box gap={1}>
              <Text color="cyan">
                ●
              </Text>
              <Button label={`${printable}`} plain />
              <Box flexShrink={0}>
                <Text dimColor wrap="truncate-end">
                  {details3}
                </Text>
              </Box>
            </Box>
          </Box>
          <Box flexDirection="column" marginTop={1} rowGap={1}>
            <Box gap={1}>
              <Box justifyContent="center" alignItems="center" backgroundColor="#1f4650">
                <Button label={`${label}`} plain />
              </Box>
              <Box justifyContent="center" alignItems="center" backgroundColor="#1f4650">
                <Button label={`${label}`} plain />
              </Box>
              <Box justifyContent="center" alignItems="center" backgroundColor="#1f4650">
                <Button label={`${label}`} plain />
              </Box>
            </Box>
            <Box gap={1}>
              <Box justifyContent="center" alignItems="center" backgroundColor="#1f4650">
                <Button label={`${label}`} plain />
              </Box>
              <Box justifyContent="center" alignItems="center" backgroundColor="#1f4650">
                <Button label={`${label}`} plain />
              </Box>
              <Box justifyContent="center" alignItems="center" backgroundColor="#1f4650">
                <Button label={`${label}`} plain />
              </Box>
            </Box>
            <Box gap={1}>
              <Box justifyContent="center" alignItems="center" backgroundColor="#1f4650">
                <Button label={`${label}`} plain />
              </Box>
              <Box justifyContent="center" alignItems="center" backgroundColor="#1f4650">
                <Button label={`${label}`} plain />
              </Box>
              <Box justifyContent="center" alignItems="center" backgroundColor="#1f4650">
                <Button label={`${label}`} plain />
              </Box>
            </Box>
          </Box>
        </Box>
      </Box>
    )
  })
}

Mod 自身のコード

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

mods/workspace/hooks/register.tsx 1183〜1342 行 · ペイン
  on('ui.render', { component: 'Pane', requestId: PANE }, async ($, e) => {
    const ui = $.ui.resolve(e)
    const { Box } = ui
    const bodyColumns = e.props.bodyColumns ?? 60
    // A reader page wraps at the pane's width, kept from every draw so a search hit opens at the right page.
    readerRoom = { rows: READER_PAGE_ROWS, columns: bodyColumns - 6 }
    // With another mod's pane open beside it, the engine draws a tab row above the header.
    const isUnderTabs = isBesideOtherPanes('sc-workspace', {
      'sc-accounts': (await $.state.get({ plugin: 'sc-accounts', key: 'paneOpen' })).value === true,
      'sc-workspace': (await $.state.get({ plugin: 'sc-workspace', key: 'paneOpen' })).value === true,
      'sc-toolbox': (await $.state.get({ plugin: 'sc-toolbox', key: 'paneOpen' })).value === true,
    })
    const header = {
      brand: paneTitle(MOD_NAME),
      release: release.version ? m.release(release.version, release.date) : undefined,
      isUnderTabs,
      columns: bodyColumns,
      exit: { label: `✕ ${m.closeButton}`, onPress: () => void closePane($).catch((error: unknown) => $.ui.toast(message(error))) },
      backLabel: m.backButton,
    }
    // A dialog in progress takes the whole pane: the header, then the dialog.
    const asked = await read($, dialog)
    const dismiss = async () => {
      await update($, dialog, () => null)
      await update($, focused, () => null)
    }
    if (asked?.kind === 'base') {
      const now = await $.clock.now()
      const choices = baseChoices(await baseCandidates($), (await read($, diff))?.base, now, locale, m)

      return ChoiceDialog(
        ui,
        bodyColumns,
        header,
        m.baseTitle,
        choices.map(choice => ({
          ...choice,
          onPress: () => {
            void (async () => {
              await dismiss()
              if (!choice.isCurrent) await refreshDiff($, choice.base)
            })().catch((error: unknown) => $.ui.toast(message(error)))
          },
        })),
        { label: m.cancel, onPress: () => void dismiss().catch((error: unknown) => debug($, error)) },
        await read($, focused),
      )
    }
    if (asked?.kind === 'target') {
      const now = await $.clock.now()
      const view = await read($, diff)
      if (view) {
        const candidates = (await baseCandidates($)).map(({ since: _since, ...point }) => point)

        return ChoiceDialog(
          ui,
          bodyColumns,
          header,
          m.targetTitle,
          targetChoices(candidates, view, now, locale, m).map(choice => ({
            ...choice,
            onPress: () => {
              void (async () => {
                await dismiss()
                if (!choice.isCurrent) await refreshDiff($, undefined, choice.target)
              })().catch((error: unknown) => $.ui.toast(message(error)))
            },
          })),
          { label: m.cancel, onPress: () => void dismiss().catch((error: unknown) => debug($, error)) },
          await read($, focused),
        )
      }
    }
    if (asked?.kind === 'diff') {
      const view = await read($, diff)
      const files = view?.files ?? []
      const at = files.findIndex(one => one.path === asked.ref)
      const file = files[at]
      const selected = view?.selected?.path === asked.ref ? view.selected : undefined
      if (view && file && selected) {
        // Whole hunks on every page, each under a header of its own, so every page draws as a diff.
        const pages = diffPages(selected.text, DIFF_PAGE_LINES)
        const count = pages.length
        const index = Math.min(Math.max(0, await read($, diffPage)), count - 1)
        const turn = (step: number) => () => {
          void update($, diffPage, () => index + step).catch((error: unknown) => debug($, error))
        }
        const open = (path: string) => () => void openFile($, path).catch((error: unknown) => $.ui.toast(message(error)))
        const previousFile = files[at - 1]
        const nextFile = files[at + 1]
        const counts = file.added === null ? m.binary : `+${file.added} −${file.removed ?? 0}`
        const omitted = selected.omitted > 0 && index === count - 1 ? ` · ${m.linesOmitted(selected.omitted)}` : ''

        return CodeDialog(
          ui,
          bodyColumns,
          header,
          file.path,
          `${counts} · ${m.diffDialogSince(view.base.label)}${omitted}`,
          { source: pages[index] ?? '', format: 'diff', path: file.path, empty: m.binary },
          { index, count, label: m.readerPage(index + 1, count) },
          {
            previous: { label: m.readerPrevious, onPress: turn(-1) },
            next: { label: m.readerNext, onPress: turn(1) },
            extra: [
              ...(previousFile ? [{ key: 'diff-previous-file', label: m.diffPreviousFile, onPress: open(previousFile.path) }] : []),
              ...(nextFile ? [{ key: 'diff-next-file', label: m.diffNextFile, onPress: open(nextFile.path) }] : []),
              // Only the working tree can be written back: a file compared between two checkpoints, or another worktree's, has no restore.
              ...(!view.target && !view.worktree ? [{ key: 'diff-file-restore', label: m.diffRestoreFile, onPress: () => void update($, dialog, () => ({ kind: 'file', ref: file.path })).catch((error: unknown) => debug($, error)) }] : []),
            ],
            close: { label: m.closeButton, onPress: () => void dismiss().catch((error: unknown) => debug($, error)) },
          },
          await read($, focused),
        )
      }
    }
    if (asked?.kind === 'memoryRead') {
      const file = (await read($, memory))?.find(one => one.path === asked.ref)
      const text = memoryTexts.get(asked.ref)
      if (file && text !== undefined) {
        const pages = markdownPages(text, readerRoom)
        const index = Math.min(Math.max(0, await read($, memoryPage)), pages.length - 1)
        const front = frontmatterOf(text)
        const turn = (step: number) => () => {
          void update($, memoryPage, () => index + step).catch((error: unknown) => debug($, error))
        }
        // An auto-memory file leads with its name and description; its frontmatter is not drawn.
        const lead = front.name ? `**${front.name}**${front.description ? `: ${front.description}` : ''}\n\n` : ''

        return ReaderDialog(
          ui,
          bodyColumns,
          header,
          file.display,
          m.readerSubtitle(file.path.replace(home ?? '\u0000', '~'), m.memoryKind[file.kind], m.memoryLines(file.lines)),
          // Lines wrapped in the file read as the paragraphs they are.
          reflow(index === 0 ? `${lead}${pages[index]?.text ?? ''}` : (pages[index]?.text ?? '')),
          { index, count: pages.length, label: m.readerPage(index + 1, pages.length) },
          {
            previous: { label: m.readerPrevious, onPress: turn(-1) },
            next: { label: m.readerNext, onPress: turn(1) },
            close: { label: m.closeButton, onPress: () => void dismiss().catch((error: unknown) => debug($, error)) },
          },
          await read($, focused),
        )
      }
    }
    if (asked?.kind === 'memoryScope') {
      const current = await read($, memoryScope)
      const scopes = ['all', 'global', 'project'] as const

      return ChoiceDialog(
        ui,
        bodyColumns,
        header,
        m.memoryScopeTitle,
        scopes.map(scope => ({
          key: `memory-scope-${scope}`,
          label: m.memoryScope[scope],
          isCurrent: scope === current,
mods/workspace/hooks/shared/kit.tsx 1013〜1058 行 · ペイン
export function ChoiceDialog(
  ui: ElementTable,
  bodyColumns: number,
  header: HeaderInfo,
  title: string,
  choices: Choice[],
  cancel: { label: string; onPress: () => void },
  /** The key of the element holding the keyboard, so the Cancel tile can show it. */
  focused: string | null = null,
) {
  const { Box, Text } = ui
  // Every row is one line: the details share one column at the right, and the labels
  // take what is left of the dialog's width and are cut to it, never wrapped.
  const details = choices.map(choice => (choice.detail === undefined ? undefined : printable(choice.detail)))
  const detailWidth = Math.max(0, ...details.map(detail => displayWidth(detail ?? '')))
  const labelRoom = Math.max(6, bodyColumns - CARD_CHROME - 2 - (detailWidth > 0 ? detailWidth + 1 : 0))
  const labels = choices.map(choice => truncate(printable(choice.label).replace(/\s+/g, ' ').trim(), labelRoom))
  const labelWidth = Math.max(0, ...labels.map(displayWidth))

  return DialogFrame(
    ui,
    dialogHeader(header, cancel.onPress),
    theme.accent,
    title,
    <Box key="dialog-choices" flexDirection="column" marginTop={1}>
      {choices.map((choice, index) => (
        <Box key={`choice-${choice.key}`} gap={1}>
          <Text color={choice.isCurrent ? theme.accent : undefined} dimColor={!choice.isCurrent}>
            {choice.isCurrent ? '●' : '○'}
          </Text>
          {LinkButton(ui, choice.key, padCells(labels[index] ?? '', labelWidth), choice.onPress, { autoFocus: choice.isCurrent === true })}
          {details[index] && (
            <Box flexShrink={0}>
              <Text dimColor wrap="truncate-end">
                {details[index]}
              </Text>
            </Box>
          )}
        </Box>
      ))}
    </Box>,
    Tiles(ui, Math.max(20, bodyColumns - CARD_CHROME), [{ key: 'dialog-cancel', label: cancel.label, isDismiss: true, onPress: cancel.onPress }], {
      focused,
    }),
  )
}
mods/workspace/hooks/shared/kit.tsx 646〜666 行 · ペイン
export function DialogFrame(
  ui: ElementTable,
  header: HeaderInfo,
  borderColor: string,
  title: string,
  body: ReturnType<typeof Header>,
  tiles: ReturnType<typeof Tiles>,
) {
  const { Box, Text } = ui

  return (
    <Box key="dialog-pane" flexDirection="column">
      {Header(ui, header)}
      <Box key="dialog" flexDirection="column" borderStyle="round" borderColor={borderColor} paddingX={1}>
        <Text bold>{printable(title)}</Text>
        {body}
        {tiles}
      </Box>
    </Box>
  )
}
mods/workspace/hooks/shared/kit.tsx 258〜262 行 · ペイン
export function LinkButton(ui: ElementTable, key: string, label: string, onPress: () => void, extra: { autoFocus?: boolean } = {}) {
  const { Button } = ui

  return <Button key={key} label={printable(label)} plain hover={{ color: theme.accent, bold: true }} {...(extra.autoFocus ? { autoFocus: true as const } : {})} onPress={onPress} />
}
mods/workspace/hooks/shared/kit.tsx 518〜561 行 · ペイン
export function Tiles(ui: ElementTable, bodyColumns: number, given: Tile[], outline?: { focused: string | null }) {
  const { Box, Button } = ui
  if (given.length === 0) return null
  const tiles = given.map(tile => ({ ...tile, label: printable(tile.label) }))
  const needed = Math.max(...tiles.map(tile => displayWidth(tile.label))) + TILE_PADDING * 2
  const perRow = Math.max(1, Math.min(tiles.length, Math.floor((bodyColumns + TILE_GAP) / (needed + TILE_GAP))))
  const width = Math.max(needed, Math.floor((bodyColumns - TILE_GAP * (perRow - 1)) / perRow))
  const rows: Tile[][] = []
  for (let start = 0; start < tiles.length; start += perRow) rows.push(tiles.slice(start, start + perRow))

  return (
    <Box key="footer" flexDirection="column" marginTop={1} rowGap={1}>
      {rows.map((row, index) => (
        <Box key={`footer-row-${index}`} gap={TILE_GAP}>
          {row.map(tile => (
            <Box
              key={`tile-${tile.key}`}
              width={width}
              justifyContent="center"
              alignItems="center"
              backgroundColor={tile.isMain ? theme.tileMain : theme.tile}
              hover={{ backgroundColor: theme.tileHover }}
              // Outlined tiles show where the keyboard is: the focused one in the accent colour.
              {...(outline
                ? outline.focused === tile.key
                  ? { borderStyle: 'round', borderColor: theme.accent }
                  : { borderStyle: 'round', borderColor: 'gray', borderDimColor: true }
                : {})}
            >
              <Button
                key={tile.key}
                label={tile.label}
                plain
                {...(tile.isDismiss ? { role: 'dismiss' as const } : {})}
                {...(tile.isFocused ? { autoFocus: true as const } : {})}
                onPress={tile.onPress}
              />
            </Box>
          ))}
        </Box>
      ))}
    </Box>
  )
}
mods/workspace/hooks/shared/kit.tsx 85〜109 行 · ペイン
export function Header(ui: ElementTable, header: HeaderInfo) {
  const { Box, Button, Text } = ui
  const brand = printable(header.brand)
  const release = header.release === undefined ? undefined : printable(header.release)
  const exit = header.exit ? { ...header.exit, label: printable(header.exit.label) } : undefined
  const exitWidth = exit ? displayWidth(exit.label) + 2 : 0
  const room = (header.columns ?? 80) - displayWidth(brand) - exitWidth - 2
  const isReleaseShown = release !== undefined && displayWidth(release) <= room

  return (
    <Box key="header" justifyContent="space-between" marginTop={header.isUnderTabs ? 1 : 0}>
      <Text bold wrap="truncate-end">
        {brand}
      </Text>
      <Box gap={2} flexShrink={0}>
        {isReleaseShown && <Text dimColor>{release}</Text>}
        {exit && (
          <Box key="header-exit-ground" paddingX={1} flexShrink={0} backgroundColor={theme.tile} hover={{ backgroundColor: theme.tileHover }}>
            <Button key="close" label={exit.label} plain role="dismiss" onPress={exit.onPress} />
          </Box>
        )}
      </Box>
    </Box>
  )
}
ライセンスの全文(MIT)
MIT License

Copyright (c) 2026 SimpleCORE Inc.

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 を動かすツール呼び出し保存

コードから読めること

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

載せる条件: 確かめやすいコード
入口を読んだhooks/hooks.json が名指すモジュールをすべて読んだ。mods/workspace/hooks/register.tsx
解析できるすべてのファイルが TypeScript か JavaScript として解析できる。19 ファイルを解析
コードが 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 のホスト)がコードに書いてあるか。通信なし
プログラム起動するプログラムの名前がコードに書いてあり、シェル・インタプリタ・通信用の道具でないか。mods/workspace/hooks/register.tsx:151 実行時に決まるプログラム; mods/workspace/hooks/register.tsx:1033 実行時に決まるプログラム
読んで送るファイルや環境変数を読み、かつ通信するか。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 simplecore-inc/claude-mods
/plugin install sc-workspace@simplecore-mods

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

Claude に聞く

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

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

Claude から探す: MCP コネクタ

似たデザイン