modscode JA

modscode / Gallery / ptt

ptt

在 Claude Code 面板裡滑 PTT,可自訂看板,附老闆鍵

Code you can checkTerminal + desktopPaneBoxButtonInputMarkdownText

What it does

  • Draws a pane
  • Adds /ptt
  • Hooks session.start
  • Keeps its own state between turns
  • Calls the network

Good points

  • Starts no processes
  • Written in TypeScript
  • Writes no files

Code to start from

Two kinds: a starter modscode writes from the design above, and the lines of the mod's own code that draw it.

Starter (register.tsx)

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

// Drawn like ptt by chenyao0910 (pane), as modscode read it from the mod's code:
// https://modscode.com/gallery/chenyao0910-ptt/
// 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: "PTT" })
  on('ui.render', { component: 'Pane', requestId: 'my-pane' }, async ($, e) => {
    const { Box, Text, Button, Markdown } = $.ui.resolve(e)
    const name = '…'
    const b = '…'
    const b2 = '…'
    const b3 = '…'
    const msg = '…'
    const prefix = '…'
    const tag = '…'
    const rest = '…'
    const author = '…'
    const date = '…'
    const prefix2 = '…'
    const author2 = '…'
    const date2 = '…'
    const prefix3 = '…'
    const author3 = '…'
    const date3 = '…'
    return (
      <Box flexDirection="column" gap={1}>
        <Box flexDirection="row" columnGap={1}>
          <Text backgroundColor="blue" color="white" bold>
            {" PTT "}
          </Text>
          <Text dimColor>
            批踢踢實業坊 ›
          </Text>
          <Text color="yellow" bold>
            {`${name} › 文章`}
          </Text>
        </Box>
        <Box flexDirection="column">
          <Box flexDirection="row" flexWrap="wrap" columnGap={1}>
            <Text color="cyan" bold>
              看板
            </Text>
            <Text dimColor>
              |
            </Text>
            <Button variant="primary" plain label={`${b}`} />
            <Text dimColor>
              |
            </Text>
            <Button variant="primary" plain label={`${b}`} />
            <Text dimColor>
              |
            </Text>
            <Button variant="primary" plain label={`${b}`} />
          </Box>
          <Text color="blue" dimColor>
            ────────
          </Text>
          <Box flexDirection="row" flexWrap="wrap" columnGap={1}>
            <Text color="magenta" bold>
              操作
            </Text>
            <Button hotkey="r" variant="secondary" label="重新整理" />
            <Button hotkey="e" variant="primary" label="完成" />
            <Button hotkey="b" variant="secondary" label="老闆鍵" />
          </Box>
        </Box>
        <Box flexDirection="column" borderStyle="round" borderColor="cyan" paddingX={1}>
          <Text color="cyan" bold>
            管理看板
          </Text>
          <Text dimColor>
            清單是空的,新增一個看板吧
          </Text>
          <Box flexDirection="row" columnGap={1}>
            <Text color="yellow">
              {b}
            </Text>
            <Button plain label="✕ 移除" />
          </Box>
          <Box flexDirection="row" columnGap={1}>
            <Text color="yellow">
              {b2}
            </Text>
            <Button plain label="✕ 移除" />
          </Box>
          <Box flexDirection="row" columnGap={1}>
            <Text color="yellow">
              {b3}
            </Text>
            <Button plain label="✕ 移除" />
          </Box>
          <Text dimColor>
            新增看板:輸入 /ptt add 看板名稱
          </Text>
          <Button plain dimColor label="恢復預設看板" />
        </Box>
        <Text>
          {msg}
        </Text>
        <Box flexDirection="column">
          <Markdown text="_還沒載入,按上面的看板或「重新整理」_" />
          <Box flexDirection="row" columnGap={1}>
            <Text bold>
              {"  "}
            </Text>
            <Text dimColor>
              {prefix}
            </Text>
            <Text>
              {`[${tag}]`}
            </Text>
            <Button plain label={`${rest}`} />
            <Text color="cyan" dimColor wrap="truncate">
              {author}
            </Text>
            <Text dimColor>
              {date}
            </Text>
          </Box>
          <Box flexDirection="row" columnGap={1}>
            <Text bold>
              {"  "}
            </Text>
            <Text dimColor>
              {prefix2}
            </Text>
            <Text>
              {`[${tag}]`}
            </Text>
            <Button plain label={`${rest}`} />
            <Text color="cyan" dimColor wrap="truncate">
              {author2}
            </Text>
            <Text dimColor>
              {date2}
            </Text>
          </Box>
          <Box flexDirection="row" columnGap={1}>
            <Text bold>
              {"  "}
            </Text>
            <Text dimColor>
              {prefix3}
            </Text>
            <Text>
              {`[${tag}]`}
            </Text>
            <Button plain label={`${rest}`} />
            <Text color="cyan" dimColor wrap="truncate">
              {author3}
            </Text>
            <Text dimColor>
              {date3}
            </Text>
          </Box>
        </Box>
        <Button hotkey="n" variant="secondary" label="載入更舊的文章" />
      </Box>
    )
  })
}

The mod's own code

Shown under the mod's licence (MIT); its text is below. Keep the notice if you copy these lines.

plugins/ptt/hooks/register.tsx lines 194–353 · Pane
  on('ui.render', { component: 'Pane', requestId: PANE }, async ($, e) => {
    const ui = $.ui.resolve(e)
    const { Box, Text, Button, Markdown } = ui
    const m = await read($, mode)
    const msg = await read($, status)

    if (m === 'boss') {
      return (
        <Box flexDirection="column">
          {FAKE_LOG.map(line => (
            <Text dimColor={line.startsWith('[debug]')} color={line.startsWith('[warn]') ? 'yellow' : undefined}>
              {line}
            </Text>
          ))}
          <Button key="boss" plain dimColor hotkey="b" label="_" onPress={() => void toggleBoss($)} />
        </Box>
      )
    }

    const name = await read($, board)
    const list = await read($, boards)
    const isEditing = await read($, editing)
    const width = Math.max(20, Math.min(e.props.bodyColumns, 100))
    const divider = <Text color="blue" dimColor>{'─'.repeat(width)}</Text>

    const header = (
      <Box key="header" flexDirection="row" columnGap={1}>
        <Text backgroundColor="blue" color="white" bold>{' PTT '}</Text>
        <Text dimColor>批踢踢實業坊 ›</Text>
        <Text color="yellow" bold>{m === 'article' ? `${name} › 文章` : name}</Text>
      </Box>
    )

    const statusLine = msg !== '' && <Text color={statusColor(msg)}>{msg}</Text>

    if (m === 'article') {
      const a = await read($, article)
      if (a) {
        const good = a.pushes.filter(p => p.tag.startsWith('推')).length
        const bad = a.pushes.filter(p => p.tag.startsWith('噓')).length
        const body = a.body.length > MAX_BODY ? `${a.body.slice(0, MAX_BODY)}\n…(內文太長,後面省略)` : a.body
        const shown = a.pushes.slice(-MAX_PUSHES)
        const t = splitTitle(a.title)
        return (
          <Box flexDirection="column" gap={1}>
            {header}
            <Box key="nav" flexDirection="row" columnGap={1}>
              <Button key="back" hotkey="h" variant="primary" label="← 回列表" onPress={() => void update($, mode, () => 'list')} />
              <Button key="boss" hotkey="b" variant="secondary" label="老闆鍵" onPress={() => void toggleBoss($)} />
            </Box>
            <Box key="head" flexDirection="column" borderStyle="round" borderColor="blue" paddingX={1}>
              <Box key="title-row" flexDirection="row" columnGap={1}>
                {t.prefix !== '' && <Text dimColor>{t.prefix}</Text>}
                {t.tag !== '' && <Text color={tagColor(t.tag)} bold>{`[${t.tag}]`}</Text>}
                <Text bold>{t.rest}</Text>
              </Box>
              <Box key="meta-row" flexDirection="row" columnGap={1}>
                <Text dimColor>作者</Text>
                <Text color="cyan">{a.author}</Text>
                <Text dimColor>{`· ${a.time}`}</Text>
              </Box>
            </Box>
            <Text wrap="wrap">{body}</Text>
            {divider}
            <Box key="score" flexDirection="row" columnGap={1}>
              <Text color="green" bold>{`推 ${good}`}</Text>
              <Text color="red" bold>{`噓 ${bad}`}</Text>
              <Text dimColor>{`共 ${a.pushes.length} 則${shown.length < a.pushes.length ? `(只顯示最後 ${shown.length} 則)` : ''}`}</Text>
            </Box>
            <Box key="pushes" flexDirection="column">
              {shown.map((p, i) => (
                <Box key={`push${i}`} flexDirection="row" columnGap={1}>
                  <Text color={pushColor(p.tag)} bold>{p.tag}</Text>
                  <Text color="yellow">{p.user}</Text>
                  <Text wrap="wrap">{p.text}</Text>
                  <Text dimColor>{p.time}</Text>
                </Box>
              ))}
            </Box>
          </Box>
        )
      }
    }

    // 看板一列、操作一列,中間用線分開
    const boardRow = (
      <Box key="boards" flexDirection="row" flexWrap="wrap" columnGap={1}>
        <Text color="cyan" bold>看板</Text>
        {list.flatMap((b, i) => [
          ...(i > 0 ? [<Text dimColor>|</Text>] : []),
          <Button
            key={`board-${b}`}
            variant={b === name ? 'primary' : undefined}
            plain={b === name ? undefined : true}
            label={b}
            onPress={() => void loadBoard($, b)}
          />,
        ])}
      </Box>
    )
    const actionRow = (
      <Box key="actions" flexDirection="row" flexWrap="wrap" columnGap={1}>
        <Text color="magenta" bold>操作</Text>
        <Button key="refresh" hotkey="r" variant="secondary" label="重新整理" onPress={() => void loadBoard($, name)} />
        <Button key="edit" hotkey="e" variant={isEditing ? 'primary' : 'secondary'} label={isEditing ? '完成' : '管理看板'} onPress={() => void update($, editing, v => !v)} />
        <Button key="boss" hotkey="b" variant="secondary" label="老闆鍵" onPress={() => void toggleBoss($)} />
      </Box>
    )

    const manage = isEditing && (
      <Box key="manage" flexDirection="column" borderStyle="round" borderColor="cyan" paddingX={1}>
        <Text color="cyan" bold>管理看板</Text>
        {list.length === 0 && <Text dimColor>清單是空的,新增一個看板吧</Text>}
        {list.map(b => (
          <Box key={`row-${b}`} flexDirection="row" columnGap={1}>
            <Text color="yellow">{b}</Text>
            <Button key={`remove-${b}`} plain label="✕ 移除" hover={{ color: 'red', bold: true }} onPress={() => void removeBoard($, b)} />
          </Box>
        ))}
        {'Input' in ui ? (
          <ui.Input key="add-board" label="新增看板" placeholder="輸入看板英文名稱,例如 NBA,按 Enter" onSubmit={(v: string) => void addBoard($, v)} />
        ) : (
          <Text dimColor>新增看板:輸入 /ptt add 看板名稱</Text>
        )}
        <Button key="reset" plain dimColor label="恢復預設看板" onPress={() => void resetBoards($)} />
      </Box>
    )

    const items = await read($, posts)
    const older = await read($, prevPage)
    return (
      <Box flexDirection="column" gap={1}>
        {header}
        <Box key="controls" flexDirection="column">
          {boardRow}
          {divider}
          {actionRow}
        </Box>
        {manage}
        {statusLine}
        <Box key="list" flexDirection="column">
          {items.length === 0 && msg === '' && <Markdown key="empty" text="_還沒載入,按上面的看板或「重新整理」_" />}
          {items.map(p => {
            const t = splitTitle(p.title)
            return (
              <Box key={p.url} flexDirection="row" columnGap={1}>
                <Text color={nrecColor(p.nrec)} bold>{p.nrec.padStart(2, ' ') || '  '}</Text>
                {t.prefix !== '' && <Text dimColor>{t.prefix}</Text>}
                {t.tag !== '' && <Text color={tagColor(t.tag)}>{`[${t.tag}]`}</Text>}
                <Button key={`open-${p.url}`} plain label={t.rest} hover={{ color: 'cyan', bold: true }} onPress={() => void openArticle($, p.url)} />
                <Text color="cyan" dimColor wrap="truncate">{p.author}</Text>
                <Text dimColor>{p.date}</Text>
              </Box>
            )
          })}
        </Box>
        {older !== '' && <Button key="older" hotkey="n" variant="secondary" label="載入更舊的文章" onPress={() => void loadBoard($, name, older)} />}
      </Box>
    )
  })
Licence text (MIT)
MIT License

Copyright (c) 2026 chenyao0910

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.

What its code calls

networkremembers

The design, read from code

Drawn from the mod's source at the commit read, not from a run: a list is drawn three times, a condition takes its first branch that draws in the desktop app, and a value only the run time knows is shown as a made-up sample (dotted underline) or left out. Colours and type are this site's.

What its code shows

Read from the source at commit 0b13fdd72b6c on 2026-10-06. The first group decides whether a mod is listed; the rest is for you to weigh. A later commit is not read until the next crawl.

Decides the listing: code you can check
Entry readEvery module hooks/hooks.json names was read.plugins/ptt/hooks/register.tsx
ParsesEvery file parses as TypeScript or JavaScript.2 files parsed
All its code is in the modEvery import is a file of the mod or the engine's own module; no packages, no require.all its code is in the mod
ReadableNo minified lines, no eval or new Function, no import of a computed path, no encoded blobs.no minified code, no eval, no encoded blobs
Calls in the openNetwork and programs are reached as $.http.fetch and $.process.run in place, never passed around.every call outside goes through $ in the open
For you to weigh before installing
Where it drawsThe terminal, the desktop app, both, or nothing (hooks only: a guard or a prompt rewriter), as its code says. Shown, never a reason to leave a mod out.draws in the terminal and the desktop app, the same in both
Install lineWhether its repository's own .claude-plugin/marketplace.json lists it, so it installs from that marketplace with the lines on its page.listed in its repository's .claude-plugin/marketplace.json: installs from there
Programs on WindowsWhether every program it starts through $.process exists on Windows (tail, date, open, osascript, /usr/… do not).runs no program a Windows PC lacks
NetworkWhether every fetch names its https host in the code.plugins/ptt/hooks/register.tsx:29 fetch(HOST + path); plugins/ptt/hooks/register.tsx:87 fetch(`${HOST}/bbs/${name}/index.html`)
ProgramsWhether every program it starts is named in the code and is not a shell, an interpreter or a network tool.starts no programs
Reads and sendsWhether it both reads files or environment variables and reaches the network.reaches the network, but reads no files and no environment variables
Keys in the sourceWhether the source holds what looks like an API key or a private key.no keys in the source
LicenceAn open licence (MIT, Apache-2.0, BSD, ISC, Unlicense, 0BSD, CC0) with its text lets modscode show its code; otherwise the code is linked.MIT

This is a reading of the code text, not a security review: it does not run the mod, and it cannot see what a program the mod starts does. The check before installing is yours. How mods are chosen

Install it

Check it yourself before you install it. Mods run unsandboxed, with your permissions, and modscode does not vouch for what this code does. Read the code below (or run claude plugin validate . in its folder), weigh what it reaches, and install the commit you read.

Its repository is its marketplace. Add that marketplace (in the terminal with these commands, or in the desktop app's plugin settings) and install the mod from it:

/plugin marketplace add chenyao0910/claude-ptt-mod
/plugin install ptt@claude-ptt-mod

This installs the marketplace's latest commit, which may not be the one read here (0b13fdd72b6c). Compare them before you install.

Ask Claude about it

With the modscode connector added, Claude can read this design, what its code reaches and its code, and build on them. Ask it like this:

Read the modscode design "chenyao0910-ptt" with its code and make me a pane like it

Search them from Claude: the MCP connector

Similar designs