modscode EN

modscode / 図鑑 / lcu-approve

lcu-approve

Native per-app approval for LCU computer use in the Claude app and Claude Code (Allow this conversation, Always allow, Deny), and the /computer-use-apps panel of approved apps.

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

何をするか

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

良いところ

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

作り始めるためのコード

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

雛形(register.tsx)

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

// Drawn like lcu-approve by LCU (pane, toast), as modscode read it from the mod's code:
// https://modscode.com/gallery/amontlabs-lcu-approve/
// 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: "Approved apps" })
  on('ui.render', { component: 'Pane', requestId: 'my-pane' }, async ($, e) => {
    const { Box, Text, Button, Input } = $.ui.resolve(e)
    const length = '…'
    const name = '…'
    const bundleId = '…'
    const name2 = '…'
    const bundleId2 = '…'
    const name3 = '…'
    const bundleId3 = '…'
    const text = '…'
    return (
      <Box flexDirection="column" gap={1}>
        <Box flexDirection="column">
          <Text bold>
            Approved apps
          </Text>
          <Box flexDirection="row" gap={2} alignItems="center">
            <Box flexGrow={1}>
              <Text dimColor>
                Computer use can control these apps without asking.
              </Text>
            </Box>
            <Button>
              Refresh
            </Button>
          </Box>
        </Box>
        <Box flexDirection="column" gap={1}>
          <Box flexDirection="column">
            <Text bold dimColor>
              {`Always allowed (${length})`}
            </Text>
            <Text dimColor>
              None. Allow one below.
            </Text>
          </Box>
          <Box flexDirection="column">
            <Text bold dimColor>
              {`Not installed (${length})`}
            </Text>
          </Box>
          <Box flexDirection="column">
            <Text bold dimColor>
              {`This conversation (${length})`}
            </Text>
            <Text dimColor>
              None.
            </Text>
            <Box flexDirection="row" gap={2} alignItems="center">
              <Box flexShrink={0}>
                <Text bold>
                  {name}
                </Text>
              </Box>
              <Box flexShrink={1}>
                <Text dimColor wrap="truncate-end">
                  {bundleId}
                </Text>
              </Box>
              <Box flexGrow={1} />
            </Box>
            <Box flexDirection="row" gap={2} alignItems="center">
              <Box flexShrink={0}>
                <Text bold>
                  {name2}
                </Text>
              </Box>
              <Box flexShrink={1}>
                <Text dimColor wrap="truncate-end">
                  {bundleId2}
                </Text>
              </Box>
              <Box flexGrow={1} />
            </Box>
            <Box flexDirection="row" gap={2} alignItems="center">
              <Box flexShrink={0}>
                <Text bold>
                  {name3}
                </Text>
              </Box>
              <Box flexShrink={1}>
                <Text dimColor wrap="truncate-end">
                  {bundleId3}
                </Text>
              </Box>
              <Box flexGrow={1} />
            </Box>
          </Box>
          <Input label="Allow an app" placeholder="App name, bundle id or path" submitLabel="allow" />
        </Box>
        <Text color="red">
          {text}
        </Text>
      </Box>
    )
  })

  on('session.start', async ($, e, next) => {
    const label = '…'
    const text = '…'
    await $.ui.toast(`Approval for ${label} dismissed`)
    await $.ui.toast(`Computer use approval: ${text}`)
    return next(e)
  })
}

Mod 自身のコード

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

adapters/claude-mod/lcu-approve/hooks/register.tsx 74〜83 行 · ペイン
  on('ui.render', { component: 'Pane' }, async ($, e, next) => {
    if (e.requestId === APPS_PANE) {
      const state = await read($, apps)
      return <AppsView ui={$.ui.resolve(e)} state={state} />
    }
    const entry = shown.get(e.requestId)
    if (!entry) return next(e)
    // Presses are handled by the `ui.press` hook below, with that dispatch's own `$`.
    return <ApprovalView ui={$.ui.resolve(e)} surface={e.surface} approval={entry.approval} icon={entry.icon} graphics={entry.graphics} />
  })
adapters/claude-mod/lcu-approve/hooks/views.tsx 142〜208 行 · ペイン
export function AppsView({ ui, state }: { ui: any; state: AppsState }) {
  const { Box, Text, Button, Input } = ui
  const busy = Boolean(state.busy)
  const present = state.always.filter(app => app.installed)
  const missing = state.always.filter(app => !app.installed)
  const row = (app: AppRow) => (
    <AppRowView key={app.bundleId} ui={ui} name={app.name} bundleId={app.bundleId}>
      {app.risk === 'high' && <RiskBadge ui={ui} />}
      {app.blocked && <Text color="red">Blocked by Computer use</Text>}
      <Button key={`${APPS_PREFIX}revoke:${app.bundleId}`} onPress={noop}>Revoke</Button>
    </AppRowView>
  )
  return (
    <Box flexDirection="column" gap={1}>
      <Box flexDirection="column">
        <Text bold>Approved apps</Text>
        <Box flexDirection="row" gap={2} alignItems="center">
          <Box flexGrow={1}>
            <Text dimColor>Computer use can control these apps without asking.</Text>
          </Box>
          <Button key={`${APPS_PREFIX}refresh`} onPress={noop}>Refresh</Button>
        </Box>
      </Box>
      {state.unavailable ? (
        <Text color="yellow">{state.unavailable}</Text>
      ) : !state.isLoaded ? (
        <Text dimColor>Loading...</Text>
      ) : (
        <Box flexDirection="column" gap={1}>
          <Box flexDirection="column">
            <Text bold dimColor>{`Always allowed (${present.length})`}</Text>
            {present.length === 0 && <Text dimColor>None. Allow one below.</Text>}
            {present.map(row)}
          </Box>
          {missing.length > 0 && (
            <Box flexDirection="column">
              <Text bold dimColor>{`Not installed (${missing.length})`}</Text>
              {missing.map(row)}
            </Box>
          )}
          <Box flexDirection="column">
            <Text bold dimColor>{`This conversation (${state.session.length})`}</Text>
            {state.session.length === 0 && <Text dimColor>None.</Text>}
            {state.session.map(app => (
              <AppRowView key={app.bundleId} ui={ui} name={app.name} bundleId={app.bundleId}>
                {app.risk === 'high' && <RiskBadge ui={ui} />}
                <Text dimColor>Ends with this conversation</Text>
              </AppRowView>
            ))}
          </Box>
          <Input
            key={`${APPS_PREFIX}allow:${state.nonce}`}
            label="Allow an app"
            placeholder="App name, bundle id or path"
            submitLabel="allow"
            onSubmit={noop}
          />
        </Box>
      )}
      {(state.busy || state.notice) && (
        <Text color={state.busy ? undefined : state.notice?.tone === 'error' ? 'red' : 'green'} dimColor={busy}>
          {state.busy ?? state.notice?.text}
        </Text>
      )}
    </Box>
  )
}
adapters/claude-mod/lcu-approve/hooks/views.tsx 122〜138 行 · ペイン
function AppRowView({ ui, name, bundleId, children }: { ui: any; name: string; bundleId: string; children: any }) {
  const { Box, Text } = ui
  return (
    <Box flexDirection="row" gap={2} alignItems="center">
      <Box flexShrink={0}>
        <Text bold>{name}</Text>
      </Box>
      {bundleId !== name && (
        <Box flexShrink={1}>
          <Text dimColor wrap="truncate-end">{bundleId}</Text>
        </Box>
      )}
      <Box flexGrow={1} />
      {children}
    </Box>
  )
}
adapters/claude-mod/lcu-approve/hooks/views.tsx 85〜119 行 · ペイン
export function ApprovalView({ ui, surface, approval, icon, graphics = true }: { ui: any; surface: string; approval: Approval; icon?: string; graphics?: boolean }) {
  const { Box, Text, Button } = ui
  const isHigh = approval.riskLevel === 'high'
  // A terminal that cannot draw the picture gets no icon cell, so the name starts at the pane's edge.
  const shownIcon = surface === 'terminal' && !graphics ? undefined : icon
  const key = (choice: string) => `${KEY_PREFIX}${approval.id}:${choice}`
  return (
    <Box flexDirection="column" gap={1} paddingY={surface === 'terminal' ? 0 : 1}>
      <Box flexDirection="row" gap={surface === 'terminal' && !shownIcon ? 0 : 2} alignItems="center">
        <Icon ui={ui} surface={surface} name={approval.label} icon={shownIcon} />
        <AppTitle ui={ui} name={approval.label} bundleId={approval.app} />
      </Box>
      <Text>{`Computer use will be able to see and control ${approval.label}.`}</Text>
      {isHigh && (
        <Box flexDirection="column">
          <RiskBadge ui={ui} />
          {approval.warning && <Text color="yellow">{plainWarning(approval.warning)}</Text>}
        </Box>
      )}
      <Box flexDirection="row" gap={1}>
        <Button key={key('session')} variant="primary" autoFocus hotkey="a" onPress={noop}>
          {LABEL_SESSION}
        </Button>
        {approval.scopes.includes('always') && (
          <Button key={key('always')} variant="secondary" hotkey="l" onPress={noop}>
            {LABEL_ALWAYS}
          </Button>
        )}
        <Button key={key('deny')} role="dismiss" hotkey="d" onPress={noop}>
          {LABEL_DENY}
        </Button>
      </Box>
    </Box>
  )
}
adapters/claude-mod/lcu-approve/hooks/views.tsx 52〜67 行 · ペイン
function Icon({ ui, surface, name, icon }: { ui: any; surface: string; name: string; icon?: string }) {
  if (surface === 'terminal') {
    const { Image } = ui
    return icon ? <Image source={{ png: icon }} columns={6} rows={3} alt=" " /> : null
  }
  const { Svg } = ui
  const initial = esc([...name.trim()][0]?.toUpperCase() ?? '?')
  const picture = icon
    ? `<image href="data:image/png;base64,${icon}" xlink:href="data:image/png;base64,${icon}" x="0" y="0" width="48" height="48"/>`
    : ''
  const source =
    '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 48 48" width="48" height="48">' +
    '<rect width="48" height="48" rx="11" fill="#8a8a8a" fill-opacity="0.28"/>' +
    `<text x="24" y="32" font-size="22" font-family="sans-serif" text-anchor="middle" fill="#8a8a8a">${initial}</text>${picture}</svg>`
  return <Svg source={source} alt={`${name} icon`} width={48} height={48} />
}
adapters/claude-mod/lcu-approve/hooks/views.tsx 69〜77 行 · ペイン
function AppTitle({ ui, name, bundleId }: { ui: any; name: string; bundleId: string }) {
  const { Box, Text } = ui
  return (
    <Box flexDirection="column" flexGrow={1}>
      <Text bold>{name}</Text>
      {bundleId !== name && <Text dimColor>{bundleId}</Text>}
    </Box>
  )
}
ライセンスの全文(MIT)
MIT License

Copyright (c) 2026 Amont Labs

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

載せる条件: 確かめやすいコード
入口を読んだhooks/hooks.json が名指すモジュールをすべて読んだ。adapters/claude-mod/lcu-approve/hooks/register.tsx
解析できるすべてのファイルが TypeScript か JavaScript として解析できる。3 ファイルを解析
コードが 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/… などは無い)。adapters/claude-mod/lcu-approve/hooks/register.tsx:259 /usr/bin/mdfind(Windows にない); adapters/claude-mod/lcu-approve/hooks/register.tsx:311 /usr/bin/mktemp(Windows にない); adapters/claude-mod/lcu-approve/hooks/register.tsx:317 /usr/bin/plutil(Windows にない); adapters/claude-mod/lcu-approve/hooks/register.tsx:324 /usr/bin/sips(Windows にない); adapters/claude-mod/lcu-approve/hooks/register.tsx:332 /usr/bin/osascript(Windows にない)
通信fetch の送り先(https のホスト)がコードに書いてあるか。通信なし
プログラム起動するプログラムの名前がコードに書いてあり、シェル・インタプリタ・通信用の道具でないか。adapters/claude-mod/lcu-approve/hooks/register.tsx:221 実行時に決まるプログラム; adapters/claude-mod/lcu-approve/hooks/register.tsx:283 実行時に決まるプログラム; adapters/claude-mod/lcu-approve/hooks/register.tsx:332 /usr/bin/osascript(シェル・インタプリタ); adapters/claude-mod/lcu-approve/hooks/register.tsx:402 実行時に決まるプログラム
読んで送るファイルや環境変数を読み、かつ通信するか。通信しない
ソースの鍵ソースに 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 のデザイン「amontlabs-lcu-approve」をコードごと読んで、同じようなペインを作って

Claude から探す: MCP コネクタ

似たデザイン