modscode EN

modscode / 図鑑 / work-view

work-view

Day 22:把工作清單與 hook 的退回紀錄列成看板,看每件事卡在哪一步、缺哪份證據

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

何をするか

  • 欄を描く
  • /work-view を足す
  • session.startにフックする

良いところ

  • ネットワークに出ない
  • プロセスを起こさない
  • 小さい(114 行)
  • TypeScript で書かれている

作り始めるためのコード

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

雛形(register.tsx)

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

// Drawn like work-view by <AUTHOR> (pane), as modscode read it from the mod's code:
// https://modscode.com/gallery/marcustung-work-view/
// 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: "今天的工作看板" })
  on('ui.render', { component: 'Pane', requestId: 'my-pane' }, async ($, e) => {
    const { Box, Text } = $.ui.resolve(e)
    const length = '…'
    const items = '…'
    const items2 = '…'
    const items3 = '…'
    const length2 = '…'
    const title = '…'
    const waiting = '…'
    const title2 = '…'
    const waiting2 = '…'
    const title3 = '…'
    const waiting3 = '…'
    const source = '…'
    const length3 = '…'
    return (
      <Box flexDirection="column">
        <Text bold>
          {"hook 擋過 "}
          {length}
          {" 次"}
          ,已退回重排
        </Text>
        <Text color="red">
          {" 退回:"}
          {items}
        </Text>
        <Text color="red">
          {" 退回:"}
          {items2}
        </Text>
        <Text color="red">
          {" 退回:"}
          {items3}
        </Text>
        <Box marginTop={1}>
          <Text bold>
            今天的工作(
            {length2}
            {" 件)"}
          </Text>
        </Box>
        <Box flexDirection="column" marginTop={1}>
          <Text bold color="red">
            {title}
            (曾被 hook 退回)
          </Text>
          <Text dimColor>
            {" ① 發送端:"}
            —
          </Text>
          <Text dimColor>
            {" ② 接收端:"}
            —
          </Text>
          <Text dimColor>
            {" ③ 自動檢查:"}
            —
          </Text>
          <Text color="green">
            {" ④ 交給:"}
            (未填)
            {" 今天做:"}
            是
          </Text>
          <Text dimColor>
            {" 在等:"}
            {waiting}
          </Text>
        </Box>
        <Box flexDirection="column" marginTop={1}>
          <Text bold color="red">
            {title2}
            (曾被 hook 退回)
          </Text>
          <Text dimColor>
            {" ① 發送端:"}
            —
          </Text>
          <Text dimColor>
            {" ② 接收端:"}
            —
          </Text>
          <Text dimColor>
            {" ③ 自動檢查:"}
            —
          </Text>
          <Text color="green">
            {" ④ 交給:"}
            (未填)
            {" 今天做:"}
            是
          </Text>
          <Text dimColor>
            {" 在等:"}
            {waiting2}
          </Text>
        </Box>
        <Box flexDirection="column" marginTop={1}>
          <Text bold color="red">
            {title3}
            (曾被 hook 退回)
          </Text>
          <Text dimColor>
            {" ① 發送端:"}
            —
          </Text>
          <Text dimColor>
            {" ② 接收端:"}
            —
          </Text>
          <Text dimColor>
            {" ③ 自動檢查:"}
            —
          </Text>
          <Text color="green">
            {" ④ 交給:"}
            (未填)
            {" 今天做:"}
            是
          </Text>
          <Text dimColor>
            {" 在等:"}
            {waiting3}
          </Text>
        </Box>
        <Box marginTop={1}>
          <Text dimColor>
            資料來源:
            {source}
            (
            {length3}
            {" 筆查核結果)"}
          </Text>
        </Box>
      </Box>
    )
  })
}

Mod 自身のコード

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

days/day22/lab-view/mod/hooks/register.tsx 83〜113 行 · ペイン
  on('ui.render', { component: 'Pane', requestId: PANE }, async ($, e) => {
    const { Box, Text } = $.ui.resolve(e)
    const s = await read($, snapshot)
    if (s.error) return <Text color="yellow">{s.error}</Text>
    if (!s.items.length) return <Text dimColor>讀取中…</Text>

    const blocked = s.blocks.filter(b => b.action === 'block')
    const hit = new Set(blocked.flatMap(b => b.items ?? []).map(t => t.slice(0, 20)))
    const res = (it: Item) => it.ids.map(id => s.results[id]).filter(Boolean)

    return (
      <Box flexDirection="column">
        <Text bold>hook 擋過 {blocked.length} 次{blocked.length ? ',已退回重排' : ''}</Text>
        {blocked.map(b => <Text color="red">  退回:{(b.items ?? []).join('、').slice(0, 80)}</Text>)}
        <Box marginTop={1}><Text bold>今天的工作({s.items.length} 件)</Text></Box>
        {s.items.map(it => (
          <Box flexDirection="column" marginTop={1}>
            <Text bold color={hit.has(it.title.slice(0, 20)) ? 'red' : undefined}>
              {it.title.slice(0, 42)}{hit.has(it.title.slice(0, 20)) ? '(曾被 hook 退回)' : ''}
            </Text>
            <Text dimColor>  ① 發送端:{tally(res(it).map(r => r.sender))}</Text>
            <Text dimColor>  ② 接收端:{tally(res(it).map(r => r.receiver))}</Text>
            <Text dimColor>  ③ 自動檢查:{tally(res(it).map(r => r.gate))}</Text>
            <Text color={it.owner.includes('Owner') ? 'green' : 'cyan'}>  ④ 交給:{it.owner || '(未填)'} 今天做:{it.today === 'true' ? '是' : '否'}</Text>
            {it.waiting && <Text dimColor>     在等:{it.waiting.slice(0, 56)}</Text>}
          </Box>
        ))}
        <Box marginTop={1}><Text dimColor>資料來源:{s.source}({Object.keys(s.results).length} 筆查核結果)</Text></Box>
      </Box>
    )
  })
ライセンスの全文(MIT)
MIT License

Copyright (c) 2026 Marcus Tung

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

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

Claude から探す: MCP コネクタ

似たデザイン