modscode EN

modscode / 図鑑 / context-window

context-window

A pane listing everything that entered the context window since the session started, by turn and by category

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

何をするか

  • 欄を描く
  • /context-window を足す
  • prompt.compose・prompt.context・session.append・session.compact ほか 5 個にフックする

良いところ

  • ネットワークに出ない
  • プロセスを起こさない
  • TypeScript で書かれている
  • エラーを扱う

作り始めるためのコード

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

雛形(register.tsx)

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

// Drawn like context-window by Chris Han (pane, toast), as modscode read it from the mod's code:
// https://modscode.com/gallery/chrishan17-context-window/
// 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: "Context" })
  on('ui.render', { component: 'Pane', requestId: 'my-pane' }, async ($, e) => {
    const { Box, Text, Button, Markdown } = $.ui.resolve(e)
    const t = '…'
    const hotkey = '…'
    const t2 = '…'
    const title = '…'
    const note = '…'
    const label = '…'
    const detail = '…'
    const fileLink = '…'
    const badge = '…'
    const label2 = '…'
    const detail2 = '…'
    const badge2 = '…'
    const label3 = '…'
    const detail3 = '…'
    const badge3 = '…'
    const label4 = '…'
    const detail4 = '…'
    const badge4 = '…'
    const label5 = '…'
    const detail5 = '…'
    const badge5 = '…'
    const label6 = '…'
    const detail6 = '…'
    const badge6 = '…'
    const label7 = '…'
    const detail7 = '…'
    const badge7 = '…'
    const label8 = '…'
    const detail8 = '…'
    const badge8 = '…'
    const label9 = '…'
    const detail9 = '…'
    const badge9 = '…'
    const label10 = '…'
    const detail10 = '…'
    const badge10 = '…'
    const label11 = '…'
    const detail11 = '…'
    const badge11 = '…'
    const label12 = '…'
    const detail12 = '…'
    const badge12 = '…'
    const title2 = '…'
    const label13 = '…'
    const detail13 = '…'
    const badge13 = '…'
    const label14 = '…'
    const detail14 = '…'
    const badge14 = '…'
    const label15 = '…'
    const detail15 = '…'
    const badge15 = '…'
    const label16 = '…'
    const detail16 = '…'
    const badge16 = '…'
    return (
      <Box flexDirection="column" paddingTop={1}>
        <Box flexDirection="column">
          <Box flexDirection="row">
            <Box flexShrink={0}>
              <Text>
                <Text bold>
                  {t}
                </Text>
                <Text bold>
                  {"  —"}
                </Text>
                <Text dimColor>
                  {`  ${t}`}
                </Text>
              </Text>
            </Box>
            <Box flexGrow={1} flexShrink={1} minWidth={0} justifyContent="flex-end" marginLeft={2} marginRight={3}>
              <Text dimColor wrap="truncate-start" />
            </Box>
          </Box>
          <Text>
            <Text>
              ━━━━━━━━
            </Text>
            <Text dimColor>
              ────────
            </Text>
          </Text>
          <Box flexDirection="row" flexWrap="wrap" columnGap={2}>
            <Button plain label={`${t}◂`} hotkey={`${hotkey}`} />
            <Button plain label={`${t}◂`} hotkey={`${hotkey}`} />
            <Button plain label={`${t}◂`} hotkey={`${hotkey}`} />
            <Button plain label={`${t}`} hotkey="r" dimColor />
          </Box>
          <Text dimColor wrap="wrap">
            {t2}
          </Text>
        </Box>
        <Box flexDirection="column">
          <Box flexDirection="column">
            <Box flexDirection="row" marginTop={1}>
              <Box flexShrink={0}>
                <Text bold>
                  {title}
                </Text>
                <Text dimColor>
                  {`  ${note}`}
                </Text>
              </Box>
              <Box flexGrow={1} flexShrink={1} minWidth={0} paddingLeft={1}>
                <Text dimColor wrap="truncate">
                  ────────
                </Text>
              </Box>
              <Box flexShrink={0} width={5} />
              <Box flexShrink={0} width={7} justifyContent="flex-end">
                <Text bold />
              </Box>
            </Box>
            <Text dimColor>
              {`  ${t}`}
            </Text>
            <Box flexDirection="column">
              <Box flexDirection="row">
                <Box flexShrink={0} width={2}>
                  <Text dimColor>
                    │
                  </Text>
                </Box>
                <Box flexShrink={0} width={2}>
                  <Button plain dimColor label="▾" />
                </Box>
                <Box flexShrink={0} width={2}>
                  <Text>
                    {"✗ "}
                  </Text>
                </Box>
                <Box flexGrow={1} flexShrink={1} minWidth={0} flexDirection="row">
                  <Box flexShrink={1} minWidth={0}>
                    <Text wrap="truncate-end">
                      {label}
                    </Text>
                  </Box>
                  <Box flexShrink={100} minWidth={0} marginLeft={2}>
                    <Text dimColor wrap="truncate-end">
                      {detail}
                    </Text>
                  </Box>
                  <Box flexShrink={0} marginLeft={2}>
                    <Markdown text={`${fileLink}`} dimColor />
                  </Box>
                </Box>
                <Box flexShrink={0} marginLeft={1}>
                  <Text>
                    {badge}
                  </Text>
                </Box>
                <Box flexShrink={0} width={5} justifyContent="flex-end">
                  <Text dimColor />
                </Box>
                <Box flexShrink={0} width={7} justifyContent="flex-end">
                  <Text />
                </Box>
              </Box>
              <Box flexDirection="column">
                <Box flexDirection="row">
                  <Box flexShrink={0} width={2}>
                    <Text dimColor>
                      │
                    </Text>
                  </Box>
                  <Box flexShrink={0} width={2}>
                    <Button plain dimColor label="▾" />
                  </Box>
                  <Box flexShrink={0} width={2}>
                    <Text>
                      {"✗ "}
                    </Text>
                  </Box>
                  <Box flexGrow={1} flexShrink={1} minWidth={0} flexDirection="row">
                    <Box flexShrink={1} minWidth={0}>
                      <Text wrap="truncate-end">
                        {label2}
                      </Text>
                    </Box>
                    <Box flexShrink={100} minWidth={0} marginLeft={2}>
                      <Text dimColor wrap="truncate-end">
                        {detail2}
                      </Text>
                    </Box>
                    <Box flexShrink={0} marginLeft={2}>
                      <Markdown text={`${fileLink}`} dimColor />
                    </Box>
                  </Box>
                  <Box flexShrink={0} marginLeft={1}>
                    <Text>
                      {badge2}
                    </Text>
                  </Box>
                  <Box flexShrink={0} width={5} justifyContent="flex-end">
                    <Text dimColor />
                  </Box>
                  <Box flexShrink={0} width={7} justifyContent="flex-end">
                    <Text />
                  </Box>
                </Box>
                <Box flexDirection="row">
                  <Box flexShrink={0} width={2}>
                    <Text dimColor>
                      │
                    </Text>
                  </Box>
                  <Box flexShrink={0} width={2}>
                    <Button plain dimColor label="▾" />
                  </Box>
                  <Box flexShrink={0} width={2}>
                    <Text>
                      {"✗ "}
                    </Text>
                  </Box>
                  <Box flexGrow={1} flexShrink={1} minWidth={0} flexDirection="row">
                    <Box flexShrink={1} minWidth={0}>
                      <Text wrap="truncate-end">
                        {label3}
                      </Text>
                    </Box>
                    <Box flexShrink={100} minWidth={0} marginLeft={2}>
                      <Text dimColor wrap="truncate-end">
                        {detail3}
                      </Text>
                    </Box>
                    <Box flexShrink={0} marginLeft={2}>
                      <Markdown text={`${fileLink}`} dimColor />
                    </Box>
                  </Box>
                  <Box flexShrink={0} marginLeft={1}>
                    <Text>
                      {badge3}
                    </Text>
                  </Box>
                  <Box flexShrink={0} width={5} justifyContent="flex-end">
                    <Text dimColor />
                  </Box>
                  <Box flexShrink={0} width={7} justifyContent="flex-end">
                    <Text />
                  </Box>
                </Box>
                <Box flexDirection="row">
                  <Box flexShrink={0} width={2}>
                    <Text dimColor>
                      │
                    </Text>
                  </Box>
                  <Box flexShrink={0} width={2}>
                    <Button plain dimColor label="▾" />
                  </Box>
                  <Box flexShrink={0} width={2}>
                    <Text>
                      {"✗ "}
                    </Text>
                  </Box>
                  <Box flexGrow={1} flexShrink={1} minWidth={0} flexDirection="row">
                    <Box flexShrink={1} minWidth={0}>
                      <Text wrap="truncate-end">
                        {label4}
                      </Text>
                    </Box>
                    <Box flexShrink={100} minWidth={0} marginLeft={2}>
                      <Text dimColor wrap="truncate-end">
                        {detail4}
                      </Text>
                    </Box>
                    <Box flexShrink={0} marginLeft={2}>
                      <Markdown text={`${fileLink}`} dimColor />
                    </Box>
                  </Box>
                  <Box flexShrink={0} marginLeft={1}>
                    <Text>
                      {badge4}
                    </Text>
                  </Box>
                  <Box flexShrink={0} width={5} justifyContent="flex-end">
                    <Text dimColor />
                  </Box>
                  <Box flexShrink={0} width={7} justifyContent="flex-end">
                    <Text />
                  </Box>
                </Box>
                <Box flexDirection="row">
                  <Box flexShrink={0} width={2}>
                    <Text dimColor>
                      │
                    </Text>
                  </Box>
                  <Box flexShrink={0} />
                  <Button plain dimColor label={`${t}`} />
                </Box>
              </Box>
            </Box>
            <Box flexDirection="column">
              <Box flexDirection="row">
                <Box flexShrink={0} width={2}>
                  <Text dimColor>
                    │
                  </Text>
                </Box>
                <Box flexShrink={0} width={2}>
                  <Button plain dimColor label="▾" />
                </Box>
                <Box flexShrink={0} width={2}>
                  <Text>
                    {"✗ "}
                  </Text>
                </Box>
                <Box flexGrow={1} flexShrink={1} minWidth={0} flexDirection="row">
                  <Box flexShrink={1} minWidth={0}>
                    <Text wrap="truncate-end">
                      {label5}
                    </Text>
                  </Box>
                  <Box flexShrink={100} minWidth={0} marginLeft={2}>
                    <Text dimColor wrap="truncate-end">
                      {detail5}
                    </Text>
                  </Box>
                  <Box flexShrink={0} marginLeft={2}>
                    <Markdown text={`${fileLink}`} dimColor />
                  </Box>
                </Box>
                <Box flexShrink={0} marginLeft={1}>
                  <Text>
                    {badge5}
                  </Text>
                </Box>
                <Box flexShrink={0} width={5} justifyContent="flex-end">
                  <Text dimColor />
                </Box>
                <Box flexShrink={0} width={7} justifyContent="flex-end">
                  <Text />
                </Box>
              </Box>
              <Box flexDirection="column">
                <Box flexDirection="row">
                  <Box flexShrink={0} width={2}>
                    <Text dimColor>
                      │
                    </Text>
                  </Box>
                  <Box flexShrink={0} width={2}>
                    <Button plain dimColor label="▾" />
                  </Box>
                  <Box flexShrink={0} width={2}>
                    <Text>
                      {"✗ "}
                    </Text>
                  </Box>
                  <Box flexGrow={1} flexShrink={1} minWidth={0} flexDirection="row">
                    <Box flexShrink={1} minWidth={0}>
                      <Text wrap="truncate-end">
                        {label6}
                      </Text>
                    </Box>
                    <Box flexShrink={100} minWidth={0} marginLeft={2}>
                      <Text dimColor wrap="truncate-end">
                        {detail6}
                      </Text>
                    </Box>
                    <Box flexShrink={0} marginLeft={2}>
                      <Markdown text={`${fileLink}`} dimColor />
                    </Box>
                  </Box>
                  <Box flexShrink={0} marginLeft={1}>
                    <Text>
                      {badge6}
                    </Text>
                  </Box>
                  <Box flexShrink={0} width={5} justifyContent="flex-end">
                    <Text dimColor />
                  </Box>
                  <Box flexShrink={0} width={7} justifyContent="flex-end">
                    <Text />
                  </Box>
                </Box>
                <Box flexDirection="row">
                  <Box flexShrink={0} width={2}>
                    <Text dimColor>
                      │
                    </Text>
                  </Box>
                  <Box flexShrink={0} width={2}>
                    <Button plain dimColor label="▾" />
                  </Box>
                  <Box flexShrink={0} width={2}>
                    <Text>
                      {"✗ "}
                    </Text>
                  </Box>
                  <Box flexGrow={1} flexShrink={1} minWidth={0} flexDirection="row">
                    <Box flexShrink={1} minWidth={0}>
                      <Text wrap="truncate-end">
                        {label7}
                      </Text>
                    </Box>
                    <Box flexShrink={100} minWidth={0} marginLeft={2}>
                      <Text dimColor wrap="truncate-end">
                        {detail7}
                      </Text>
                    </Box>
                    <Box flexShrink={0} marginLeft={2}>
                      <Markdown text={`${fileLink}`} dimColor />
                    </Box>
                  </Box>
                  <Box flexShrink={0} marginLeft={1}>
                    <Text>
                      {badge7}
                    </Text>
                  </Box>
                  <Box flexShrink={0} width={5} justifyContent="flex-end">
                    <Text dimColor />
                  </Box>
                  <Box flexShrink={0} width={7} justifyContent="flex-end">
                    <Text />
                  </Box>
                </Box>
                <Box flexDirection="row">
                  <Box flexShrink={0} width={2}>
                    <Text dimColor>
                      │
                    </Text>
                  </Box>
                  <Box flexShrink={0} width={2}>
                    <Button plain dimColor label="▾" />
                  </Box>
                  <Box flexShrink={0} width={2}>
                    <Text>
                      {"✗ "}
                    </Text>
                  </Box>
                  <Box flexGrow={1} flexShrink={1} minWidth={0} flexDirection="row">
                    <Box flexShrink={1} minWidth={0}>
                      <Text wrap="truncate-end">
                        {label8}
                      </Text>
                    </Box>
                    <Box flexShrink={100} minWidth={0} marginLeft={2}>
                      <Text dimColor wrap="truncate-end">
                        {detail8}
                      </Text>
                    </Box>
                    <Box flexShrink={0} marginLeft={2}>
                      <Markdown text={`${fileLink}`} dimColor />
                    </Box>
                  </Box>
                  <Box flexShrink={0} marginLeft={1}>
                    <Text>
                      {badge8}
                    </Text>
                  </Box>
                  <Box flexShrink={0} width={5} justifyContent="flex-end">
                    <Text dimColor />
                  </Box>
                  <Box flexShrink={0} width={7} justifyContent="flex-end">
                    <Text />
                  </Box>
                </Box>
                <Box flexDirection="row">
                  <Box flexShrink={0} width={2}>
                    <Text dimColor>
                      │
                    </Text>
                  </Box>
                  <Box flexShrink={0} />
                  <Button plain dimColor label={`${t}`} />
                </Box>
              </Box>
            </Box>
            <Box flexDirection="column">
              <Box flexDirection="row">
                <Box flexShrink={0} width={2}>
                  <Text dimColor>
                    │
                  </Text>
                </Box>
                <Box flexShrink={0} width={2}>
                  <Button plain dimColor label="▾" />
                </Box>
                <Box flexShrink={0} width={2}>
                  <Text>
                    {"✗ "}
                  </Text>
                </Box>
                <Box flexGrow={1} flexShrink={1} minWidth={0} flexDirection="row">
                  <Box flexShrink={1} minWidth={0}>
                    <Text wrap="truncate-end">
                      {label9}
                    </Text>
                  </Box>
                  <Box flexShrink={100} minWidth={0} marginLeft={2}>
                    <Text dimColor wrap="truncate-end">
                      {detail9}
                    </Text>
                  </Box>
                  <Box flexShrink={0} marginLeft={2}>
                    <Markdown text={`${fileLink}`} dimColor />
                  </Box>
                </Box>
                <Box flexShrink={0} marginLeft={1}>
                  <Text>
                    {badge9}
                  </Text>
                </Box>
                <Box flexShrink={0} width={5} justifyContent="flex-end">
                  <Text dimColor />
                </Box>
                <Box flexShrink={0} width={7} justifyContent="flex-end">
                  <Text />
                </Box>
              </Box>
              <Box flexDirection="column">
                <Box flexDirection="row">
                  <Box flexShrink={0} width={2}>
                    <Text dimColor>
                      │
                    </Text>
                  </Box>
                  <Box flexShrink={0} width={2}>
                    <Button plain dimColor label="▾" />
                  </Box>
                  <Box flexShrink={0} width={2}>
                    <Text>
                      {"✗ "}
                    </Text>
                  </Box>
                  <Box flexGrow={1} flexShrink={1} minWidth={0} flexDirection="row">
                    <Box flexShrink={1} minWidth={0}>
                      <Text wrap="truncate-end">
                        {label10}
                      </Text>
                    </Box>
                    <Box flexShrink={100} minWidth={0} marginLeft={2}>
                      <Text dimColor wrap="truncate-end">
                        {detail10}
                      </Text>
                    </Box>
                    <Box flexShrink={0} marginLeft={2}>
                      <Markdown text={`${fileLink}`} dimColor />
                    </Box>
                  </Box>
                  <Box flexShrink={0} marginLeft={1}>
                    <Text>
                      {badge10}
                    </Text>
                  </Box>
                  <Box flexShrink={0} width={5} justifyContent="flex-end">
                    <Text dimColor />
                  </Box>
                  <Box flexShrink={0} width={7} justifyContent="flex-end">
                    <Text />
                  </Box>
                </Box>
                <Box flexDirection="row">
                  <Box flexShrink={0} width={2}>
                    <Text dimColor>
                      │
                    </Text>
                  </Box>
                  <Box flexShrink={0} width={2}>
                    <Button plain dimColor label="▾" />
                  </Box>
                  <Box flexShrink={0} width={2}>
                    <Text>
                      {"✗ "}
                    </Text>
                  </Box>
                  <Box flexGrow={1} flexShrink={1} minWidth={0} flexDirection="row">
                    <Box flexShrink={1} minWidth={0}>
                      <Text wrap="truncate-end">
                        {label11}
                      </Text>
                    </Box>
                    <Box flexShrink={100} minWidth={0} marginLeft={2}>
                      <Text dimColor wrap="truncate-end">
                        {detail11}
                      </Text>
                    </Box>
                    <Box flexShrink={0} marginLeft={2}>
                      <Markdown text={`${fileLink}`} dimColor />
                    </Box>
                  </Box>
                  <Box flexShrink={0} marginLeft={1}>
                    <Text>
                      {badge11}
                    </Text>
                  </Box>
                  <Box flexShrink={0} width={5} justifyContent="flex-end">
                    <Text dimColor />
                  </Box>
                  <Box flexShrink={0} width={7} justifyContent="flex-end">
                    <Text />
                  </Box>
                </Box>
                <Box flexDirection="row">
                  <Box flexShrink={0} width={2}>
                    <Text dimColor>
                      │
                    </Text>
                  </Box>
                  <Box flexShrink={0} width={2}>
                    <Button plain dimColor label="▾" />
                  </Box>
                  <Box flexShrink={0} width={2}>
                    <Text>
                      {"✗ "}
                    </Text>
                  </Box>
                  <Box flexGrow={1} flexShrink={1} minWidth={0} flexDirection="row">
                    <Box flexShrink={1} minWidth={0}>
                      <Text wrap="truncate-end">
                        {label12}
                      </Text>
                    </Box>
                    <Box flexShrink={100} minWidth={0} marginLeft={2}>
                      <Text dimColor wrap="truncate-end">
                        {detail12}
                      </Text>
                    </Box>
                    <Box flexShrink={0} marginLeft={2}>
                      <Markdown text={`${fileLink}`} dimColor />
                    </Box>
                  </Box>
                  <Box flexShrink={0} marginLeft={1}>
                    <Text>
                      {badge12}
                    </Text>
                  </Box>
                  <Box flexShrink={0} width={5} justifyContent="flex-end">
                    <Text dimColor />
                  </Box>
                  <Box flexShrink={0} width={7} justifyContent="flex-end">
                    <Text />
                  </Box>
                </Box>
                <Box flexDirection="row">
                  <Box flexShrink={0} width={2}>
                    <Text dimColor>
                      │
                    </Text>
                  </Box>
                  <Box flexShrink={0} />
                  <Button plain dimColor label={`${t}`} />
                </Box>
              </Box>
            </Box>
          </Box>
          <Box flexDirection="column">
            <Box flexDirection="row" marginTop={1}>
              <Box flexShrink={0}>
                <Text bold>
                  {title2}
                </Text>
                <Text dimColor>
                  {`  ${note}`}
                </Text>
              </Box>
              <Box flexGrow={1} flexShrink={1} minWidth={0} paddingLeft={1}>
                <Text dimColor wrap="truncate">
                  ────────
                </Text>
              </Box>
              <Box flexShrink={0} width={5} />
              <Box flexShrink={0} width={7} justifyContent="flex-end">
                <Text bold />
              </Box>
            </Box>
            <Text dimColor>
              {`  ${t}`}
            </Text>
            <Box flexDirection="column">
              <Box flexDirection="row">
                <Box flexShrink={0} width={2}>
                  <Text dimColor>
                    │
                  </Text>
                </Box>
                <Box flexShrink={0} width={2}>
                  <Button plain dimColor label="▾" />
                </Box>
                <Box flexShrink={0} width={2}>
                  <Text>
                    {"✗ "}
                  </Text>
                </Box>
                <Box flexGrow={1} flexShrink={1} minWidth={0} flexDirection="row">
                  <Box flexShrink={1} minWidth={0}>
                    <Text wrap="truncate-end">
                      {label13}
                    </Text>
                  </Box>
                  <Box flexShrink={100} minWidth={0} marginLeft={2}>
                    <Text dimColor wrap="truncate-end">
                      {detail13}
                    </Text>
                  </Box>
                  <Box flexShrink={0} marginLeft={2}>
                    <Markdown text={`${fileLink}`} dimColor />
                  </Box>
                </Box>
                <Box flexShrink={0} marginLeft={1}>
                  <Text>
                    {badge13}
                  </Text>
                </Box>
                <Box flexShrink={0} width={5} justifyContent="flex-end">
                  <Text dimColor />
                </Box>
                <Box flexShrink={0} width={7} justifyContent="flex-end">
                  <Text />
                </Box>
              </Box>
              <Box flexDirection="column">
                <Box flexDirection="row">
                  <Box flexShrink={0} width={2}>
                    <Text dimColor>
                      │
                    </Text>
                  </Box>
                  <Box flexShrink={0} width={2}>
                    <Button plain dimColor label="▾" />
                  </Box>
                  <Box flexShrink={0} width={2}>
                    <Text>
                      {"✗ "}
                    </Text>
                  </Box>
                  <Box flexGrow={1} flexShrink={1} minWidth={0} flexDirection="row">
                    <Box flexShrink={1} minWidth={0}>
                      <Text wrap="truncate-end">
                        {label14}
                      </Text>
                    </Box>
                    <Box flexShrink={100} minWidth={0} marginLeft={2}>
                      <Text dimColor wrap="truncate-end">
                        {detail14}
                      </Text>
                    </Box>
                    <Box flexShrink={0} marginLeft={2}>
                      <Markdown text={`${fileLink}`} dimColor />
                    </Box>
                  </Box>
                  <Box flexShrink={0} marginLeft={1}>
                    <Text>
                      {badge14}
                    </Text>
                  </Box>
                  <Box flexShrink={0} width={5} justifyContent="flex-end">
                    <Text dimColor />
                  </Box>
                  <Box flexShrink={0} width={7} justifyContent="flex-end">
                    <Text />
                  </Box>
                </Box>
                <Box flexDirection="row">
                  <Box flexShrink={0} width={2}>
                    <Text dimColor>
                      │
                    </Text>
                  </Box>
                  <Box flexShrink={0} width={2}>
                    <Button plain dimColor label="▾" />
                  </Box>
                  <Box flexShrink={0} width={2}>
                    <Text>
                      {"✗ "}
                    </Text>
                  </Box>
                  <Box flexGrow={1} flexShrink={1} minWidth={0} flexDirection="row">
                    <Box flexShrink={1} minWidth={0}>
                      <Text wrap="truncate-end">
                        {label15}
                      </Text>
                    </Box>
                    <Box flexShrink={100} minWidth={0} marginLeft={2}>
                      <Text dimColor wrap="truncate-end">
                        {detail15}
                      </Text>
                    </Box>
                    <Box flexShrink={0} marginLeft={2}>
                      <Markdown text={`${fileLink}`} dimColor />
                    </Box>
                  </Box>
                  <Box flexShrink={0} marginLeft={1}>
                    <Text>
                      {badge15}
                    </Text>
                  </Box>
                  <Box flexShrink={0} width={5} justifyContent="flex-end">
                    <Text dimColor />
                  </Box>
                  <Box flexShrink={0} width={7} justifyContent="flex-end">
                    <Text />
                  </Box>
                </Box>
                <Box flexDirection="row">
                  <Box flexShrink={0} width={2}>
                    <Text dimColor>
                      │
                    </Text>
                  </Box>
                  <Box flexShrink={0} width={2}>
                    <Button plain dimColor label="▾" />
                  </Box>
                  <Box flexShrink={0} width={2}>
                    <Text>
                      {"✗ "}
                    </Text>
                  </Box>
                  <Box flexGrow={1} flexShrink={1} minWidth={0} flexDirection="row">
                    <Box flexShrink={1} minWidth={0}>
                      <Text wrap="truncate-end">
                        {label16}
                      </Text>
                    </Box>
                    <Box flexShrink={100} minWidth={0} marginLeft={2}>
                      <Text dimColor wrap="truncate-end">
                        {detail16}
                      </Text>
                    </Box>
                    <Box flexShrink={0} marginLeft={2}>
                      <Markdown text={`${fileLink}`} dimColor />
                    </Box>
                  </Box>
                  <Box flexShrink={0} marginLeft={1}>
                    <Text>
                      {badge16}
                    </Text>
                  </Box>
                  <Box flexShrink={0} width={5} justifyContent="flex-end">
                    <Text dimColor />
                  </Box>
                  <Box flexShrink={0} width={7} justifyContent="flex-end">
                    <Text />
                  </Box>
                </Box>
                <Box flexDirection="row">
                  <Box flexShrink={0} width={2}>
                    <Text dimColor>
                      │
                    </Text>
                  </Box>
                  <Box flexShrink={0} />
                  <Button plain dimColor label={`${t}`} />
                </Box>
              </Box>
            </Box>
            <Box flexDirection="column">
              <Box flexDirection="row">
                <Box flexShrink={0} width={2}>
                  <Text dimColor>
                    │
                  </Text>
                </Box>
                <Box flexShrink={0} width={2}>
                  <Button plain dimColor label="▾" />
                </Box>
                <Box flexShrink={0} width={2}>
                  <Text>
                    {"✗ "}
                  </Text>
                </Box>
                <Box flexGrow={1} flexShrink={1} minWidth={0} flexDirection="row" />
              </Box>
            </Box>
          </Box>
        </Box>
      </Box>
    )
  })
}

Mod 自身のコード

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

plugins/context-window/hooks/register.tsx 257〜287 行 · ペイン
  on('ui.render', { component: 'Pane', requestId: PANE }, async ($, e) => {
    const isInline = e.props.placement === 'inline'
    if (isInline && !(await read($, asked))) {
      // Opened at session start on a layout with no sidebar: step aside.
      void $.clock.after(0, () => void $.ui.close({ id: PANE }))
      const { Text } = $.ui.resolve(e)

      return <Text dimColor>context-window: /context-window to open</Text>
    }
    const current = normalizeLog(await read($, log))

    return drawPane(
      $.ui.resolve(e),
      {
        fill: await read($, fill),
        startup: await read($, startup),
        entries: current.entries,
        epoch: current.epoch,
        view: await read($, view),
        toggled: await read($, toggled),
        lang: await read($, lang),
        columns: Math.max(24, e.props.bodyColumns),
        isInline,
      },
      {
        toggle: key => void toggle($, key),
        setView: next => void update($, view, () => next),
        refresh: () => void refresh($),
      },
    )
  })
plugins/context-window/hooks/view.tsx 146〜305 行 · ペイン
export function drawPane(ui: Ui, data: PaneData, act: PaneActions) {
  const { Box, Text, Button, Markdown } = ui
  const { lang } = data
  const tr = (text: string | undefined, arg?: string | number) =>
    text === undefined ? undefined : hasKey(text) ? t(lang, text, arg ?? '') : text
  const isOpen = (key: string, byDefault: boolean) => byDefault !== data.toggled.includes(key)

  /** The indent guides for a row `depth` levels down, one fixed cell each. */
  const indent = (depth = 0) =>
    Array.from({ length: depth }, () => (
      <Box flexShrink={0} width={INDENT_WIDTH}>
        <Text dimColor>│</Text>
      </Box>
    ))
  const live = data.entries.filter(entry => entry.epoch === data.epoch)
  const inWindow = live.filter(entry => !entry.isOutside)
  const groups = data.startup?.groups ?? []
  const startupTokens = sum(groups)
  const hasShare = data.view === 'top' || data.view === 'category' || data.view === 'origin'

  /**
   * One row on a fixed grid: guides, toggle, glyph | name, detail or file link
   * (each truncated on its own, the detail first) | badge | share | tokens,
   * the last two right-aligned columns.
   */
  const row = (props: RowProps) => {
    const color = props.isError ? 'error' : props.color
    // A detail that only restates the name ("Environment  Environment") is dropped.
    const detail = props.detail && props.detail.toLowerCase() !== props.label.toLowerCase() ? props.detail : undefined
    const tokenColor = props.tokens === undefined || props.isQuiet ? undefined : sizeColor(props.tokens)

    return (
      <Box flexDirection="row">
        {indent(props.depth)}
        <Box flexShrink={0} width={TOGGLE_WIDTH}>
          {props.toggleKey ? (
            <Button
              key={props.toggleKey}
              plain
              dimColor
              label={props.isOpenNow ? '▾' : '▸'}
              onPress={() => act.toggle(props.toggleKey as string)}
            />
          ) : null}
        </Box>
        <Box flexShrink={0} width={GLYPH_WIDTH}>
          <Text color={color}>{`${props.isError ? '✗' : props.glyph} `}</Text>
        </Box>
        <Box flexGrow={1} flexShrink={1} minWidth={0} flexDirection="row">
          <Box flexShrink={1} minWidth={0}>
            <Text bold={props.isBold} dimColor={props.isQuiet} wrap="truncate-end">
              {props.label}
            </Text>
          </Box>
          {detail && !props.path ? (
            <Box flexShrink={100} minWidth={0} marginLeft={2}>
              <Text dimColor wrap="truncate-end">
                {detail}
              </Text>
            </Box>
          ) : null}
          {props.path ? (
            <Box flexShrink={0} marginLeft={2}>
              <Markdown text={fileLink(props.path)} dimColor />
            </Box>
          ) : null}
        </Box>
        {props.badge ? (
          <Box flexShrink={0} marginLeft={1}>
            <Text color={props.badgeColor} dimColor={!props.badgeColor}>
              {props.badge}
            </Text>
          </Box>
        ) : null}
        {hasShare ? (
          <Box flexShrink={0} width={SHARE_WIDTH} justifyContent="flex-end">
            <Text dimColor>{props.share ?? ''}</Text>
          </Box>
        ) : null}
        <Box flexShrink={0} width={TOKENS_WIDTH} justifyContent="flex-end">
          <Text color={tokenColor} dimColor={!tokenColor}>
            {props.tokens === undefined || (props.tokens === 0 && props.isQuiet) ? '' : formatTokens(props.tokens)}
          </Text>
        </Box>
      </Box>
    )
  }

  /** A section heading: title, dim note, a rule to the edge, its total. */
  const heading = (title: string, tokens?: number, note?: string) => {
    // Longer than any room it gets: the Box's edge cuts it, on any font.
    const rule = Math.max(2, data.columns)

    return (
      <Box flexDirection="row" marginTop={1}>
        <Box flexShrink={0}>
          <Text bold>{title}</Text>
          {note ? <Text dimColor>{`  ${note}`}</Text> : null}
        </Box>
        <Box flexGrow={1} flexShrink={1} minWidth={0} paddingLeft={1}>
          <Text dimColor wrap="truncate">
            {'─'.repeat(rule)}
          </Text>
        </Box>
        {hasShare ? <Box flexShrink={0} width={SHARE_WIDTH} /> : null}
        <Box flexShrink={0} width={TOKENS_WIDTH} justifyContent="flex-end">
          <Text bold>{tokens === undefined ? '' : formatTokens(tokens)}</Text>
        </Box>
      </Box>
    )
  }

  /** Items under an open group, each on a branch, the first few then "N more". */
  const itemRows = (items: readonly StartupItem[], depth: number, key: string, total?: number) => {
    const shown = isOpen(`${key}:all`, false) ? items : items.slice(0, TOP_ITEMS)
    const more = items.length - shown.length

    return (
      <Box flexDirection="column">
        {shown.map(item =>
          row({
            depth,
            glyph: '·',
            color: 'inactive',
            label: tr(item.label) ?? '',
            detail: tr(item.detail, item.detailArg),
            path: item.path,
            share: total ? `${Math.round((item.tokens / total) * 100)}%` : undefined,
            tokens: item.tokens > 0 ? item.tokens : undefined,
          }),
        )}
        {more > 0 && (
          <Box flexDirection="row">
            {indent(depth)}
            <Box flexShrink={0} width={TOGGLE_WIDTH + GLYPH_WIDTH} />
            <Button key={`${key}:all`} plain dimColor label={t(lang, 'more', more)} onPress={() => act.toggle(`${key}:all`)} />
          </Box>
        )}
      </Box>
    )
  }

  // ── Timeline ──────────────────────────────────────────────────────────────

  /** The entries under each parent, in the order they came. */
  const children = new Map<string, Entry[]>()
  const ids = new Set(live.map(entry => entry.id))
  for (const entry of live) {
    if (!entry.parent || !ids.has(entry.parent)) continue
    children.set(entry.parent, [...(children.get(entry.parent) ?? []), entry])
  }
  const subtree = (entry: Entry): Entry[] => [entry, ...(children.get(entry.id) ?? []).flatMap(subtree)]

  /** One entry on its branch and, while open, its children and preview. */
  const node = (entry: Entry, depth: number) => {
    const style = KINDS[entry.kind]
    const kids = children.get(entry.id) ?? []
    const key = `node:${entry.id}`
    // An Agent's own steps live in its window, a preview is long: shut until asked.
    const open = isOpen(key, entry.kind !== 'agent' && kids.length > 0)
ライセンスの全文(MIT)
MIT License

Copyright (c) 2026 Chris Han

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

載せる条件: 確かめやすいコード
入口を読んだhooks/hooks.json が名指すモジュールをすべて読んだ。plugins/context-window/hooks/register.tsx
解析できるすべてのファイルが TypeScript か JavaScript として解析できる。4 ファイルを解析
コードが 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 .)、触るものを見て、読んだコミットを入れてください。

リポジトリがそのままマーケットプレイスです。このマーケットプレイスを足し(ターミナルでは次のコマンド、デスクトップアプリではプラグインの設定)、そこから Mod を入れます。

/plugin marketplace add chrishan17/claude-mod-context-window
/plugin install context-window@claude-mod-context-window

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

Claude に聞く

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

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

Claude から探す: MCP コネクタ

似たデザイン