modscode EN

modscode / 図鑑 / collaborative-notes

collaborative-notes

A shared notes pane beside the conversation: capture, quote, and come back to what matters.

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

何をするか

  • プロンプトの上の帯・欄を描く
  • /notes を足す
  • ツールの呼び出しを見張る(止めることがある)
  • classic.SessionStart・prompt.submit・session.start・ui.close ほか 1 個にフックする
  • ターンをまたいで自分の状態を持つ

良いところ

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

作り始めるためのコード

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

雛形(register.tsx)

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

// Drawn like collaborative-notes by aprilxuMLC (pane, band, toast), as modscode read it from the mod's code:
// https://modscode.com/gallery/aprilxumlc-collaborative-notes/
// 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 band above the prompt; what else goes there is drawn under it
  on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
    const { Box, Button, Text } = $.ui.resolve(e)
    const quoteCopied = '…'
    const bandTicked = '…'
    const clearTicks = '…'
    return (
      <Box flexDirection="column">
        <Box gap={2} flexWrap="wrap">
          <Button plain label={`${quoteCopied}`} />
          <Box gap={1}>
            <Text color="magenta">
              {`${bandTicked}`}
            </Text>
            <Button plain dimColor label={`${clearTicks}`} />
          </Box>
        </Box>
        {await next(e)}
      </Box>
    )
  })

  // the pane: open it with $.ui.open({ id: 'my-pane', title: "‹t›" })
  on('ui.render', { component: 'Pane', requestId: 'my-pane' }, async ($, e) => {
    const { Box, Text, Button, Input } = $.ui.resolve(e)
    const t = '…'
    const changeLocation = '…'
    const langSwitch = '…'
    const text = '…'
    const conflictEdit = '…'
    const body = '…'
    const loadLatest = '…'
    const searchPlaceholder = '…'
    const closeSearch = '…'
    const searchResults = '…'
    const laneLabel = '…'
    const t2 = '…'
    const noteLabel = '…'
    const tickOn = '…'
    const body2 = '…'
    const syncApp = '…'
    const finishEditing = '…'
    const discardUnsavedChanges = '…'
    const editInEditor = '…'
    const returnToSource = '…'
    const confirmDelete = '…'
    const laneLabel2 = '…'
    const t3 = '…'
    const body3 = '…'
    const laneLabel3 = '…'
    const t4 = '…'
    const body4 = '…'
    const laneLabel4 = '…'
    const t5 = '…'
    const body5 = '…'
    const laneLabel5 = '…'
    const t6 = '…'
    const body6 = '…'
    const laneLabel6 = '…'
    const t7 = '…'
    const body7 = '…'
    const laneLabel7 = '…'
    const t8 = '…'
    const body8 = '…'
    const laneLabel8 = '…'
    const t9 = '…'
    const body9 = '…'
    const laneLabel9 = '…'
    const t10 = '…'
    const body10 = '…'
    return (
      <Box flexDirection="column" gap={1}>
        <Box justifyContent="space-between">
          <Text bold>
            {t}
          </Text>
          <Box gap={1}>
            <Button plain label={`⌕ ${t}`} />
            <Button plain label={`↻ ${t}`} />
            <Button plain label={`⚙ ${changeLocation}`} />
            <Button plain label={`${langSwitch}`} />
            <Button plain label={`${t}`} />
          </Box>
        </Box>
        <Box paddingX={1} borderStyle="round" borderColor="red">
          <Text color="red">
            {text}
          </Text>
        </Box>
        <Box flexDirection="column" borderStyle="round" borderColor="yellow" paddingX={1}>
          <Text>
            {`${conflictEdit}`}
          </Text>
          <Text dimColor>
            {body}
          </Text>
          <Box gap={1}>
            <Button label={`${loadLatest}`} />
            <Button variant="primary" label={`${t}`} />
            <Button plain label={`${t}`} />
          </Box>
        </Box>
        <Box gap={1}>
          <Input placeholder={`${searchPlaceholder}`} autoFocus submitLabel={`${t}`} />
          <Button plain label={`${closeSearch}`} />
        </Box>
        <Text bold>
          {`${searchResults}`}
        </Text>
        <Box flexDirection="column" borderStyle="round" borderColor="blue" paddingX={1}>
          <Text dimColor>
            {laneLabel}
          </Text>
          <Text dimColor>
            {t2}
          </Text>
          <Box flexDirection="column">
            <Box justifyContent="space-between">
              <Text bold color="blue">
                {`📌 ${noteLabel}`}
              </Text>
              <Button variant="primary" label={`${tickOn}`} />
            </Box>
            <Text>
              {body2}
            </Text>
          </Box>
          <Text dimColor>
            ┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
          </Text>
          <Box flexDirection="column">
            <Text dimColor>
              {`${syncApp}`}
            </Text>
            <Button variant="primary" label={`${finishEditing}`} />
            <Button plain label={`${discardUnsavedChanges}`} />
          </Box>
          <Box gap={1} flexWrap="wrap">
            <Button plain label={`${t}`} />
            <Button plain label={`${t}`} />
            <Button plain label={`${editInEditor}`} />
            <Button plain label={`${returnToSource}`} />
            <Box gap={1}>
              <Button variant="primary" label={`${confirmDelete}`} />
              <Button plain label={`${t}`} />
            </Box>
          </Box>
          <Button plain label={`${t}`} />
        </Box>
        <Box flexDirection="column" borderStyle="round" borderColor="blue" paddingX={1}>
          <Text dimColor>
            {laneLabel2}
          </Text>
          <Text dimColor>
            {t3}
          </Text>
          <Box flexDirection="column">
            <Box justifyContent="space-between">
              <Text bold color="blue">
                {`📌 ${noteLabel}`}
              </Text>
              <Button variant="primary" label={`${tickOn}`} />
            </Box>
            <Text>
              {body3}
            </Text>
          </Box>
          <Text dimColor>
            ┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
          </Text>
          <Box flexDirection="column">
            <Text dimColor>
              {`${syncApp}`}
            </Text>
            <Button variant="primary" label={`${finishEditing}`} />
            <Button plain label={`${discardUnsavedChanges}`} />
          </Box>
          <Box gap={1} flexWrap="wrap">
            <Button plain label={`${t}`} />
            <Button plain label={`${t}`} />
            <Button plain label={`${editInEditor}`} />
            <Button plain label={`${returnToSource}`} />
            <Box gap={1}>
              <Button variant="primary" label={`${confirmDelete}`} />
              <Button plain label={`${t}`} />
            </Box>
          </Box>
          <Button plain label={`${t}`} />
        </Box>
        <Box flexDirection="column" borderStyle="round" borderColor="blue" paddingX={1}>
          <Text dimColor>
            {laneLabel3}
          </Text>
          <Text dimColor>
            {t4}
          </Text>
          <Box flexDirection="column">
            <Box justifyContent="space-between">
              <Text bold color="blue">
                {`📌 ${noteLabel}`}
              </Text>
              <Button variant="primary" label={`${tickOn}`} />
            </Box>
            <Text>
              {body4}
            </Text>
          </Box>
          <Text dimColor>
            ┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
          </Text>
          <Box flexDirection="column">
            <Text dimColor>
              {`${syncApp}`}
            </Text>
            <Button variant="primary" label={`${finishEditing}`} />
            <Button plain label={`${discardUnsavedChanges}`} />
          </Box>
          <Box gap={1} flexWrap="wrap">
            <Button plain label={`${t}`} />
            <Button plain label={`${t}`} />
            <Button plain label={`${editInEditor}`} />
            <Button plain label={`${returnToSource}`} />
            <Box gap={1}>
              <Button variant="primary" label={`${confirmDelete}`} />
              <Button plain label={`${t}`} />
            </Box>
          </Box>
          <Button plain label={`${t}`} />
        </Box>
        <Box flexDirection="column" borderStyle="round" borderColor="blue" paddingX={1}>
          <Text dimColor>
            {laneLabel4}
          </Text>
          <Text dimColor>
            {t5}
          </Text>
          <Box flexDirection="column">
            <Box justifyContent="space-between">
              <Text bold color="blue">
                {`📌 ${noteLabel}`}
              </Text>
              <Button variant="primary" label={`${tickOn}`} />
            </Box>
            <Text>
              {body5}
            </Text>
          </Box>
          <Text dimColor>
            ┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
          </Text>
          <Box flexDirection="column">
            <Text dimColor>
              {`${syncApp}`}
            </Text>
            <Button variant="primary" label={`${finishEditing}`} />
            <Button plain label={`${discardUnsavedChanges}`} />
          </Box>
          <Box gap={1} flexWrap="wrap">
            <Button plain label={`${t}`} />
            <Button plain label={`${t}`} />
            <Button plain label={`${editInEditor}`} />
            <Button plain label={`${returnToSource}`} />
            <Box gap={1}>
              <Button variant="primary" label={`${confirmDelete}`} />
              <Button plain label={`${t}`} />
            </Box>
          </Box>
          <Button plain label={`${t}`} />
        </Box>
        <Box flexDirection="column" borderStyle="round" borderColor="blue" paddingX={1}>
          <Text dimColor>
            {laneLabel5}
          </Text>
          <Text dimColor>
            {t6}
          </Text>
          <Box flexDirection="column">
            <Box justifyContent="space-between">
              <Text bold color="blue">
                {`📌 ${noteLabel}`}
              </Text>
              <Button variant="primary" label={`${tickOn}`} />
            </Box>
            <Text>
              {body6}
            </Text>
          </Box>
          <Text dimColor>
            ┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
          </Text>
          <Box flexDirection="column">
            <Text dimColor>
              {`${syncApp}`}
            </Text>
            <Button variant="primary" label={`${finishEditing}`} />
            <Button plain label={`${discardUnsavedChanges}`} />
          </Box>
          <Box gap={1} flexWrap="wrap">
            <Button plain label={`${t}`} />
            <Button plain label={`${t}`} />
            <Button plain label={`${editInEditor}`} />
            <Button plain label={`${returnToSource}`} />
            <Box gap={1}>
              <Button variant="primary" label={`${confirmDelete}`} />
              <Button plain label={`${t}`} />
            </Box>
          </Box>
          <Button plain label={`${t}`} />
        </Box>
        <Box flexDirection="column" borderStyle="round" borderColor="blue" paddingX={1}>
          <Text dimColor>
            {laneLabel6}
          </Text>
          <Text dimColor>
            {t7}
          </Text>
          <Box flexDirection="column">
            <Box justifyContent="space-between">
              <Text bold color="blue">
                {`📌 ${noteLabel}`}
              </Text>
              <Button variant="primary" label={`${tickOn}`} />
            </Box>
            <Text>
              {body7}
            </Text>
          </Box>
          <Text dimColor>
            ┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
          </Text>
          <Box flexDirection="column">
            <Text dimColor>
              {`${syncApp}`}
            </Text>
            <Button variant="primary" label={`${finishEditing}`} />
            <Button plain label={`${discardUnsavedChanges}`} />
          </Box>
          <Box gap={1} flexWrap="wrap">
            <Button plain label={`${t}`} />
            <Button plain label={`${t}`} />
            <Button plain label={`${editInEditor}`} />
            <Button plain label={`${returnToSource}`} />
            <Box gap={1}>
              <Button variant="primary" label={`${confirmDelete}`} />
              <Button plain label={`${t}`} />
            </Box>
          </Box>
          <Button plain label={`${t}`} />
        </Box>
        <Box flexDirection="column" borderStyle="round" borderColor="blue" paddingX={1}>
          <Text dimColor>
            {laneLabel7}
          </Text>
          <Text dimColor>
            {t8}
          </Text>
          <Box flexDirection="column">
            <Box justifyContent="space-between">
              <Text bold color="blue">
                {`📌 ${noteLabel}`}
              </Text>
              <Button variant="primary" label={`${tickOn}`} />
            </Box>
            <Text>
              {body8}
            </Text>
          </Box>
          <Text dimColor>
            ┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
          </Text>
          <Box flexDirection="column">
            <Text dimColor>
              {`${syncApp}`}
            </Text>
            <Button variant="primary" label={`${finishEditing}`} />
            <Button plain label={`${discardUnsavedChanges}`} />
          </Box>
          <Box gap={1} flexWrap="wrap">
            <Button plain label={`${t}`} />
            <Button plain label={`${t}`} />
            <Button plain label={`${editInEditor}`} />
            <Button plain label={`${returnToSource}`} />
            <Box gap={1}>
              <Button variant="primary" label={`${confirmDelete}`} />
              <Button plain label={`${t}`} />
            </Box>
          </Box>
          <Button plain label={`${t}`} />
        </Box>
        <Box flexDirection="column" borderStyle="round" borderColor="blue" paddingX={1}>
          <Text dimColor>
            {laneLabel8}
          </Text>
          <Text dimColor>
            {t9}
          </Text>
          <Box flexDirection="column">
            <Box justifyContent="space-between">
              <Text bold color="blue">
                {`📌 ${noteLabel}`}
              </Text>
              <Button variant="primary" label={`${tickOn}`} />
            </Box>
            <Text>
              {body9}
            </Text>
          </Box>
          <Text dimColor>
            ┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
          </Text>
          <Box flexDirection="column">
            <Text dimColor>
              {`${syncApp}`}
            </Text>
            <Button variant="primary" label={`${finishEditing}`} />
            <Button plain label={`${discardUnsavedChanges}`} />
          </Box>
          <Box gap={1} flexWrap="wrap">
            <Button plain label={`${t}`} />
            <Button plain label={`${t}`} />
            <Button plain label={`${editInEditor}`} />
            <Button plain label={`${returnToSource}`} />
            <Box gap={1}>
              <Button variant="primary" label={`${confirmDelete}`} />
              <Button plain label={`${t}`} />
            </Box>
          </Box>
          <Button plain label={`${t}`} />
        </Box>
        <Box flexDirection="column" borderStyle="round" borderColor="blue" paddingX={1}>
          <Text dimColor>
            {laneLabel9}
          </Text>
          <Text dimColor>
            {t10}
          </Text>
          <Box flexDirection="column">
            <Box justifyContent="space-between">
              <Text bold color="blue">
                {`📌 ${noteLabel}`}
              </Text>
              <Button variant="primary" label={`${tickOn}`} />
            </Box>
            <Text>
              {body10}
            </Text>
          </Box>
          <Text dimColor>
            ┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
          </Text>
          <Box flexDirection="column">
            <Text dimColor>
              {`${syncApp}`}
            </Text>
            <Button variant="primary" label={`${finishEditing}`} />
            <Button plain label={`${discardUnsavedChanges}`} />
          </Box>
          <Box gap={1} flexWrap="wrap">
            <Button plain label={`${t}`} />
            <Button plain label={`${t}`} />
            <Button plain label={`${editInEditor}`} />
            <Button plain label={`${returnToSource}`} />
            <Box gap={1}>
              <Button variant="primary" label={`${confirmDelete}`} />
              <Button plain label={`${t}`} />
            </Box>
          </Box>
          <Button plain label={`${t}`} />
        </Box>
      </Box>
    )
  })
}

Mod 自身のコード

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

plugins/collaborative-notes/hooks/register.tsx 790〜810 行 · バンド
  on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
    const v = await read($, view)
    if (!v?.root) return next(e)
    const held = await read($, ticks)
    await read($, lang)
    const { Box, Button, Text } = $.ui.resolve(e) as any
    return (
      <Box gap={2} flexWrap="wrap">
        <Button key="band-quote" plain label={t('quoteCopied')} onPress={async () => {
          await $.ui.open({ id: PANE, title: t('title') })
          await quoteClipboard($)
        }} />
        {held.length > 0
          ? <Box gap={1}>
            <Text color="magenta">{t('bandTicked', { n: held.length })}</Text>
            <Button key="band-clear" plain dimColor label={t('clearTicks')} onPress={() => setTicks($, v, () => [])} />
          </Box>
          : null}
      </Box>
    )
  })
plugins/collaborative-notes/hooks/register.tsx 892〜912 行 · ペイン
  on('ui.render', { component: 'Pane', requestId: PANE }, async ($, e) => {
    try {
      return await renderPane($, e)
    } catch (err) {
      // Never leave the pane blank: say what failed and offer a way back.
      const { Box, Text, Button } = $.ui.resolve(e) as any
      return (
        <Box flexDirection="column" gap={1}>
          <Text color="red">{t('renderFailed')}</Text>
          <Text dimColor>{String(err).slice(0, 300)}</Text>
          <Button key="reset-view" variant="primary" label={t('backToNotes')} onPress={async () => {
            await update($, mirror, () => null)
            await update($, reentry, () => null)
            await update($, spotlight, () => null)
            await update($, search, () => null)
            await update($, candidates, () => null)
          }} />
        </Box>
      )
    }
  })
plugins/collaborative-notes/hooks/register.tsx 915〜1074 行 · ペイン
const renderPane = async ($: any, e: any) => {
    const { Box, Text, Button, Input, Select, Markdown } = $.ui.resolve(e) as any
    const v = await read($, view)
    const note = await read($, toast)
    if (!v) return <Text dimColor>…</Text>

    const banner = note
      ? <Box paddingX={1} borderStyle="round" borderColor={note.error ? 'red' : 'green'}><Text color={note.error ? 'red' : undefined}>{note.text}</Text></Box>
      : null

    // ---- setup gate ------------------------------------------------------
    if (!v.root && v.setup) {
      // A setup kept from an older version may lack the newer fields.
      const s = { ...v.setup, browsePath: v.setup.browsePath ?? v.project, folders: v.setup.folders ?? [], laneNames: v.setup.laneNames ?? lanes.map((entry: any) => entry.descriptive) }
      const bind = async () => {
        if (s.notDir) return
        const stored = await $.store.get('laneConfig')
        const existing = sanitizeLaneConfig(stored ?? {})
        if (!existing.ok) { await say($, t('laneNamesInvalid'), true); return }
        const source = existing.config
        const overrides = source.laneOverrides
        const merged: any = {
          ...source,
          displayOrder: source.displayOrder ?? [],
          laneOverrides: { ...overrides },
        }
        const defaults = defaultLabels(language)
        lanes.forEach((entry: any, index: number) => {
          const name = String(s.laneNames[index] ?? '').trim() || entry.descriptive
          const override = { ...(merged.laneOverrides[entry.key] ?? {}) }
          if (name === defaults[entry.key]) delete override.label
          else override.label = name
          merged.laneOverrides[entry.key] = override
        })
        const checked = sanitizeLaneConfig(merged)
        if (!checked.ok) { await say($, t('laneNamesInvalid'), true); return }
        if (!s.exists && !(await createRoot(io($), s.candidate))) { await say($, t('setupFailed'), true); return }
        await $.store.set('laneConfig', checked.config)
        laneConfig = checked.config
        lanes = resolveLanes(laneConfig, language)
        await setBinding(io($), v.project, s.candidate)
        await showBound($, { ...v, root: s.candidate, setup: null })
        watchDisk($)
      }
      // The system's own folder dialog (Finder / Windows), as in the Codex
      // release; typing a path stays as a fallback.
      const chooseFolder = async () => {
        const picked = await pickFolderWithDialog($, t('pickFolderTitle'), s.candidate)
        if (picked.path) { await startSetup($, v, normalizePath(picked.path), true); return }
        if (picked.error) await say($, t('pickFolderFailed', { detail: picked.error }), true)
        await update($, view, (cur: NotesView | null) => cur?.setup ? { ...cur, setup: { ...cur.setup, other: true } } : cur)
      }
      return (
        <Box flexDirection="column" gap={1}>
          <Text bold>{t('setupTitle')}</Text>
          {banner}
          <Text>{t('setupIntro')}</Text>
          <Text dimColor>{t('setupProposed')}</Text>
          <Text bold>{s.candidate}</Text>
          {s.lanes.length > 0 ? <Text>{t('setupExisting', { lanes: s.lanes.length })}</Text> : null}
          {s.nested
            ? <Box flexDirection="column">
              <Text color="yellow">{t('setupNested', { path: s.nested })}</Text>
              <Button key="setup-nested" variant="primary" label={t('setupUseNested')} onPress={() => startSetup($, v, s.nested as string, s.other)} />
            </Box>
            : null}
          {s.notDir ? <Text color="red">{t('setupNotDir')}</Text> : null}
          {s.other
            ? <Input key="setup-path" placeholder={t('setupOtherPlaceholder')} submitLabel={t('setupOtherSubmit')} onSubmit={async (value: string) => {
              const candidate = resolveLocation(v.project, value)
              if (!candidate) { await say($, t('setupInvalid'), true); return }
              await startSetup($, v, candidate, true)
            }} />
            : null}
          <Text bold>{t('laneNamesTitle')}</Text>
          <Text dimColor>{t('laneNamesHint')}</Text>
          {lanes.map((entry: any, index: number) => <Input
            key={`setup-lane-${entry.key}`}
            label={`${entry.displayId}`}
            value={s.laneNames[index]}
            onInput={(value: string) => update($, view, (cur: NotesView | null) => cur?.setup ? {
              ...cur, setup: { ...cur.setup, laneNames: (cur.setup.laneNames ?? s.laneNames).map((name: string, at: number) => at === index ? value : name) },
            } : cur)}
            onSubmit={(value: string) => update($, view, (cur: NotesView | null) => cur?.setup ? {
              ...cur, setup: { ...cur.setup, laneNames: (cur.setup.laneNames ?? s.laneNames).map((name: string, at: number) => at === index ? value : name) },
            } : cur)} />)}
          <Box gap={1}>
            {s.notDir ? null : <Button key="setup-use" variant="primary" label={t('setupUse')} onPress={bind} />}
            <Button key="setup-other" plain label={t('setupOther')} onPress={chooseFolder} />
            {s.other ? <Button key="setup-back" plain label={t('setupBack')} onPress={() => startSetup($, v, proposedRoot(v.project))} /> : null}
            {s.previous
              ? <Button key="setup-cancel" plain label={t('cancel')} onPress={async () => { await showBound($, { ...v, root: s.previous as string, setup: null }) }} />
              : null}
          </Box>
        </Box>
      )
    }

    // ---- notes ------------------------------------------------------------
    const current = await read($, lane)
    const order = await read($, sort)
    const all = await read($, cards)
    const n = await read($, composer)
    const vers = await read($, versions)
    const pinned = await read($, pins)
    const ed = await read($, editing)
    const confirming = await read($, confirm)
    const query = await read($, search)
    const clash = await read($, conflict)
    const q = await read($, quote)
    const cands = await read($, candidates)
    const mir = await read($, mirror)
    const held = await read($, ticks)
    const langNow = await read($, lang)
    const showHelp = await read($, help)
    const fork = await read($, carry)
    const again = await read($, reuse)
    const back = await read($, reentry)
    const opened = await read($, openSources)
    await read($, tick)
    const root = v.root as string
    const base = { root, sessionId: v.sessionId }

    const save = async (value: string, laneKey = current, afterPersist?: () => Promise<void>) => {
      const body = value.replace(/^\s*\n|\s+$/g, '')
      if (!body.trim() && !q) { await say($, t('emptyBody'), true); return false }
      const written = await addPlainNote(io($), { ...base, lane: laneKey, body, quote: q ? { snapshot: q.snapshot, source: q.source } : undefined })
      if (!written.ok) { await say($, failureText(written.code, v, written.detail), true); return false }
      try {
        if (afterPersist) await afterPersist()
        await update($, quote, () => null)
        await update($, composer, k => k + 1)
        await say($, t('saved'))
        await loadCards($, v)
      } catch {
        try { await say($, t('saveRefreshFailed'), true) } catch { /* persistence already succeeded */ }
      }
      return true
    }

    const applyEdit = async (laneKey: string, key: string, body: string, expected: string, overwrite = false) => {
      const written = await editNote(io($), { ...base, lane: laneKey, key, expected, body, overwrite })
      if (written.ok) {
        await setEditorState($, null)
        await update($, conflict, () => null)
        await loadCards($, v)
        await say($, t('edited'))
      } else if (written.code === 'STALE') {
        await update($, conflict, () => ({ lane: laneKey, key, action: 'edit', body }))
      } else {
        if (written.code === 'ITEM_UNRESOLVED') { await setEditorState($, null); await loadCards($, v) }
        await say($, failureText(written.code, v, written.detail), true)
      }
    }

    const remove = async (laneKey: string, key: string) => {
      const written = await deleteNote(io($), { ...base, lane: laneKey, key, expected: vers[laneKey] })
      await update($, confirm, () => '')
      if (written.ok) {
        await loadCards($, v)
ライセンスの全文(MIT)
MIT License

Copyright (c) 2026 April Xu (aprilxuMLC)

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.

コードが呼ぶもの

プログラム起動ファイル書き込み環境変数ツール呼び出し保存

コードから読めること

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

載せる条件: 確かめやすいコード
入口を読んだhooks/hooks.json が名指すモジュールをすべて読んだ。plugins/collaborative-notes/hooks/register.tsx
解析できるすべてのファイルが TypeScript か JavaScript として解析できる。11 ファイルを解析
コードが 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 のホスト)がコードに書いてあるか。通信なし
プログラム起動するプログラムの名前がコードに書いてあり、シェル・インタプリタ・通信用の道具でないか。plugins/collaborative-notes/hooks/register.tsx:48 実行時に決まるプログラム; plugins/collaborative-notes/hooks/register.tsx:173 実行時に決まるプログラム; plugins/collaborative-notes/hooks/register.tsx:323 実行時に決まるプログラム
読んで送るファイルや環境変数を読み、かつ通信するか。通信しない
ソースの鍵ソースに API キーや秘密鍵らしきものがあるか。ソースに鍵なし
ライセンスオープンなライセンス(MIT・Apache-2.0・BSD・ISC・Unlicense・0BSD・CC0)で全文があれば、modscode にコードを載せる。違えばリンクだけ。MIT

コードの文面を読んだだけで、安全の審査ではありません。動かしてはおらず、起動するプログラムの中で何が起きるかも見えません。入れる前の確認はあなたの役目です。 載せる条件

入れる

入れる前に、必ず自分で確かめてください。Mod はサンドボックスなしで、あなたの権限で動きます。modscode はこのコードの安全を保証しません。下のコードを読み(またはフォルダーで claude plugin validate .)、触るものを見て、読んだコミットを入れてください。

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

/plugin marketplace add aprilxuMLC/claude-collaborative-notes
/plugin install collaborative-notes@collaborative-notes

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

Claude に聞く

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

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

Claude から探す: MCP コネクタ

似たデザイン