{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "opencode",
  "title": "OpenCode",
  "description": "A recreation of an OpenCode terminal session with a transcript, the prompt and the sidebar.",
  "dependencies": [
    "@base-ui/react",
    "cn"
  ],
  "registryDependencies": [
    "button",
    "card",
    "collapsible",
    "input-group",
    "kbd"
  ],
  "files": [
    {
      "path": "registry/notra/opencode/components/opencode-window.tsx",
      "content": "import { cn } from \"cn\";\n\nimport { Card } from \"@/components/ui/card\";\n\nimport type { OpencodeWindowProps } from \"../types/opencode\";\n\nexport const OpencodeWindow = ({\n  className,\n  ...props\n}: OpencodeWindowProps) => (\n  <Card\n    className={cn(\n      \"border-opencode-subtle bg-opencode-bg font-opencode text-opencode-fg flex w-full flex-col gap-0 overflow-hidden rounded-xl border py-0 text-[0.8125rem] leading-5 antialiased ring-0\",\n      className\n    )}\n    data-slot=\"opencode-window\"\n    {...props}\n  />\n);\n",
      "type": "registry:component",
      "target": "components/opencode/components/opencode-window.tsx"
    },
    {
      "path": "registry/notra/opencode/types/opencode.ts",
      "content": "import type { ScrollArea as ScrollAreaPrimitive } from \"@base-ui/react/scroll-area\";\nimport type { ComponentProps, ReactNode } from \"react\";\n\nimport type { Collapsible } from \"@/components/ui/collapsible\";\n\nexport type OpencodeActivityKind = \"thought\" | \"read\" | \"search\" | \"tool\";\n\nexport type OpencodeMessageAuthor = \"user\" | \"assistant\";\n\nexport type OpencodeMcpStatus = \"Connected\" | \"Disconnected\" | \"Failed\";\n\nexport type OpencodeWindowProps = ComponentProps<\"div\">;\n\nexport type OpencodeScrollAreaProps = ScrollAreaPrimitive.Root.Props;\n\nexport interface OpencodeLogoProps extends Omit<\n  ComponentProps<\"svg\">,\n  \"height\" | \"width\"\n> {\n  /** Multiplies the 234 by 42 base size. */\n  scale?: number;\n}\n\nexport interface OpencodeMessageProps extends ComponentProps<\"div\"> {\n  /** Rendered under an assistant reply. */\n  actions?: ReactNode;\n  from?: OpencodeMessageAuthor;\n  /** Rendered above an assistant reply, usually `OpencodeSources`. */\n  search?: ReactNode;\n}\n\nexport interface OpencodeTurnFooterProps extends ComponentProps<\"div\"> {\n  agent?: string;\n  /** Marks a turn that was stopped with Escape. */\n  interrupted?: boolean;\n  /** Wall time of the turn. Omit it while the turn is still running. */\n  duration?: string;\n  model?: string;\n}\n\nexport interface OpencodeActivityProps extends ComponentProps<\n  typeof Collapsible\n> {\n  /** Arguments after the label, like a path or a query. */\n  detail?: string;\n  /** Shown after a dot, like `1.4s`. */\n  duration?: string;\n  kind?: OpencodeActivityKind;\n  /** Defaults to `Thought`, `Read` or `Web Search` by kind. */\n  label?: string;\n  /** Renders a running thought as an animated `Thinking` line. */\n  pending?: boolean;\n  /** Freezes the thinking spinner. Defaults to the user's preference. */\n  reducedMotion?: boolean;\n}\n\nexport interface OpencodeProgressProps extends ComponentProps<\"span\"> {\n  /** Animates the scanner. When false every cell rests as a dot. */\n  active?: boolean;\n  /** Freezes the scanner. Defaults to the user's preference. */\n  reducedMotion?: boolean;\n}\n\nexport interface OpencodeComposerProps extends Omit<\n  ComponentProps<\"input\">,\n  \"children\" | \"className\" | \"type\"\n> {\n  agent?: string;\n  /**\n   * Shows the scanner and `esc interrupt` instead of the cwd. Enter does not\n   * send while busy and Escape calls `onStop`.\n   */\n  busy?: boolean;\n  className?: string;\n  /** Context usage on the status row, like `63.4K (6%)`. */\n  context?: string;\n  /** Working directory shown on the status row while idle. */\n  cwd?: string;\n  effort?: string;\n  inputClassName?: string;\n  model?: string;\n  /**\n   * Called with the trimmed text on Enter. An uncontrolled composer clears\n   * afterwards; with `value`, clear it yourself here.\n   */\n  onSend?: (text: string) => void;\n  /** Called on Escape while `busy`, to interrupt the running turn. */\n  onStop?: () => void;\n  provider?: string;\n}\n\nexport interface OpencodeMcpServer {\n  name: string;\n  status?: OpencodeMcpStatus;\n}\n\nexport interface OpencodeSidebarProps extends Omit<\n  ComponentProps<\"aside\">,\n  \"title\"\n> {\n  /** Git branch appended to the cwd. Its last segment is highlighted. */\n  branch?: string;\n  cwd?: string;\n  lsp?: ReactNode;\n  mcpOpen?: ComponentProps<typeof Collapsible>[\"open\"];\n  onMcpOpenChange?: ComponentProps<typeof Collapsible>[\"onOpenChange\"];\n  servers?: OpencodeMcpServer[];\n  spent?: string;\n  title?: ReactNode;\n  tokens?: string;\n  used?: string;\n  version?: string;\n}\n\nexport interface OpencodeSource {\n  domain: string;\n  title: string;\n  url?: string;\n}\n\nexport interface OpencodeSourcesLabels {\n  citedSources: (count: number) => string;\n  openSource: (title: string, domain: string) => string;\n}\n\nexport interface OpencodeSourcesProps extends Omit<\n  ComponentProps<typeof Collapsible>,\n  \"children\"\n> {\n  labels?: OpencodeSourcesLabels;\n  queries?: readonly string[];\n  reducedMotion?: boolean;\n  sequential?: boolean;\n  sources: readonly OpencodeSource[];\n}\n\nexport interface OpencodeDemoActivity {\n  body?: string;\n  detail?: string;\n  duration?: string;\n  id: string;\n  kind: OpencodeActivityKind;\n  label?: string;\n}\n\n/** A run of reply text: plain, `code` (green) or strong (orange). */\nexport type OpencodeDemoSpan = string | { code: string } | { strong: string };\n\nexport interface OpencodeDemoListItem {\n  id: string;\n  spans: OpencodeDemoSpan[];\n}\n\nexport type OpencodeDemoBlock =\n  | { heading: string; id: string }\n  | { id: string; items: OpencodeDemoListItem[] }\n  | { id: string; text: OpencodeDemoSpan[] };\n\nexport interface OpencodeDemoTurn {\n  activities: OpencodeDemoActivity[];\n  duration?: string;\n  id: string;\n  prompt: string;\n  reply: OpencodeDemoBlock[];\n}\n\nexport interface OpencodeDemoSession {\n  agent: string;\n  branch: string;\n  context: string;\n  cwd: string;\n  effort: string;\n  model: string;\n  provider: string;\n  servers: OpencodeMcpServer[];\n  spent: string;\n  title: string;\n  tokens: string;\n  used: string;\n  version: string;\n}\n\nexport type OpencodeTurnStatus =\n  | \"working\"\n  | \"streaming\"\n  | \"done\"\n  | \"interrupted\";\n\n/** A scripted answer the demo plays back when you send a prompt. */\nexport interface OpencodeReply {\n  /** Thoughts and tool calls, played in order before the reply. */\n  activities: OpencodeDemoActivity[];\n  reply: OpencodeDemoBlock[];\n}\n\nexport interface OpencodeChatActivity extends OpencodeDemoActivity {\n  /** A thought still thinking, shown with the spinner. */\n  pending?: boolean;\n  /** Still playing back. Dropped from the transcript when interrupted. */\n  running?: boolean;\n}\n\nexport interface OpencodeChatTurn {\n  activities: OpencodeChatActivity[];\n  duration?: string;\n  id: string;\n  prompt: string;\n  reply: OpencodeDemoBlock[];\n  status: OpencodeTurnStatus;\n}\n\nexport interface OpencodeChat {\n  busy: boolean;\n  send: (text: string) => Promise<void>;\n  stop: () => void;\n  turns: OpencodeChatTurn[];\n}\n",
      "type": "registry:lib",
      "target": "components/opencode/types/opencode.ts"
    },
    {
      "path": "registry/notra/opencode/components/opencode-logo.tsx",
      "content": "import { cn } from \"cn\";\n\nimport { OPENCODE_LOGO_CELL, OPENCODE_LOGO_ROWS } from \"../constants/opencode\";\nimport type { OpencodeLogoProps } from \"../types/opencode\";\n\nconst COLUMNS = OPENCODE_LOGO_ROWS[0].length;\nconst WIDTH = COLUMNS * OPENCODE_LOGO_CELL;\nconst HEIGHT = OPENCODE_LOGO_ROWS.length * OPENCODE_LOGO_CELL;\n\nconst CELL_FILL: Record<string, string> = {\n  \"+\": \"fill-opencode-logo-fill\",\n  c: \"fill-opencode-logo-code\",\n  o: \"fill-opencode-logo-open\",\n};\n\nconst LOGO_CELLS = OPENCODE_LOGO_ROWS.flatMap((row, y) =>\n  [...row].flatMap((cell, x) =>\n    cell in CELL_FILL\n      ? [\n          {\n            className: CELL_FILL[cell],\n            key: `${x}-${y}`,\n            x: x * OPENCODE_LOGO_CELL,\n            y: y * OPENCODE_LOGO_CELL,\n          },\n        ]\n      : []\n  )\n);\n\nexport const OpencodeLogo = ({\n  \"aria-label\": ariaLabel = \"OpenCode\",\n  className,\n  scale = 1,\n  ...props\n}: OpencodeLogoProps) => (\n  <svg\n    aria-label={ariaLabel}\n    className={cn(\"block\", className)}\n    data-slot=\"opencode-logo\"\n    height={HEIGHT * scale}\n    role=\"img\"\n    shapeRendering=\"crispEdges\"\n    viewBox={`0 0 ${WIDTH} ${HEIGHT}`}\n    width={WIDTH * scale}\n    {...props}\n  >\n    {LOGO_CELLS.map((cell) => (\n      <rect\n        className={cell.className}\n        height={OPENCODE_LOGO_CELL}\n        key={cell.key}\n        width={OPENCODE_LOGO_CELL}\n        x={cell.x}\n        y={cell.y}\n      />\n    ))}\n  </svg>\n);\n",
      "type": "registry:component",
      "target": "components/opencode/components/opencode-logo.tsx"
    },
    {
      "path": "registry/notra/opencode/components/opencode-message.tsx",
      "content": "import { cn } from \"cn\";\n\nimport type { OpencodeMessageProps } from \"../types/opencode\";\n\nconst REPLY_MARKUP_CLASS =\n  \"[&_:is(h1,h2,h3,h4)]:text-opencode-orange [&_:is(h1,h2,h3,h4)]:text-[length:inherit] [&_:is(h1,h2,h3,h4)]:font-bold [&_code]:text-opencode-green [&_code]:font-[inherit] [&_code]:text-[length:inherit] [&_li]:ps-[2ch] [&_li]:before:-ms-[2ch] [&_li]:before:inline-block [&_li]:before:w-[2ch] [&_li]:before:text-opencode-orange [&_li]:before:content-['-'] [&_ol]:list-none [&_strong]:text-opencode-orange [&_strong]:font-bold [&_ul]:list-none [&>*+*]:mt-[1lh]\";\n\nexport const OpencodeMessage = ({\n  actions,\n  children,\n  className,\n  from = \"assistant\",\n  search,\n  ...props\n}: OpencodeMessageProps) => {\n  if (from === \"user\") {\n    return (\n      <div\n        className={cn(\n          \"border-opencode-blue bg-opencode-panel text-opencode-fg border-s-2 py-[1lh] ps-[calc(3ch-2px)] pe-[2ch] wrap-break-word whitespace-pre-wrap\",\n          className\n        )}\n        data-from=\"user\"\n        data-slot=\"opencode-message\"\n        {...props}\n      >\n        {children}\n      </div>\n    );\n  }\n\n  return (\n    <div\n      className={cn(\"flex w-full min-w-0 flex-col gap-[1lh]\", className)}\n      data-from=\"assistant\"\n      data-slot=\"opencode-message\"\n      {...props}\n    >\n      {search}\n      <div\n        className={cn(\n          \"text-opencode-fg max-w-full ps-[3ch] wrap-break-word\",\n          REPLY_MARKUP_CLASS\n        )}\n      >\n        {children}\n      </div>\n      {actions}\n    </div>\n  );\n};\n",
      "type": "registry:component",
      "target": "components/opencode/components/opencode-message.tsx"
    },
    {
      "path": "registry/notra/opencode/components/opencode-turn-footer.tsx",
      "content": "import { cn } from \"cn\";\n\nimport {\n  OPENCODE_DEFAULT_AGENT,\n  OPENCODE_DEFAULT_MODEL,\n} from \"../constants/opencode\";\nimport type { OpencodeTurnFooterProps } from \"../types/opencode\";\n\nexport const OpencodeTurnFooter = ({\n  agent = OPENCODE_DEFAULT_AGENT,\n  className,\n  duration,\n  interrupted = false,\n  model = OPENCODE_DEFAULT_MODEL,\n  ...props\n}: OpencodeTurnFooterProps) => (\n  <div\n    className={cn(\n      \"text-opencode-muted flex min-w-0 items-center gap-[1ch] ps-[3ch]\",\n      className\n    )}\n    data-slot=\"opencode-turn-footer\"\n    {...props}\n  >\n    <span\n      aria-hidden=\"true\"\n      className=\"border-opencode-blue grid size-[1.1em] shrink-0 place-items-center border-[1.5px]\"\n    >\n      <span className=\"bg-opencode-blue size-[0.5em]\" />\n    </span>\n    <span className=\"text-opencode-fg\">{agent}</span>\n    <span aria-hidden=\"true\">·</span>\n    <span className=\"min-w-0 truncate\">{model}</span>\n    {duration && (\n      <>\n        <span aria-hidden=\"true\">·</span>\n        <span className=\"shrink-0 tabular-nums\">{duration}</span>\n      </>\n    )}\n    {interrupted && (\n      <>\n        <span aria-hidden=\"true\">·</span>\n        <span className=\"text-opencode-orange shrink-0\">interrupted</span>\n      </>\n    )}\n  </div>\n);\n",
      "type": "registry:component",
      "target": "components/opencode/components/opencode-turn-footer.tsx"
    },
    {
      "path": "registry/notra/opencode/components/opencode-activity.tsx",
      "content": "\"use client\";\n\nimport { cn } from \"cn\";\n\nimport { Button } from \"@/components/ui/button\";\nimport {\n  Collapsible,\n  CollapsibleContent,\n  CollapsibleTrigger,\n} from \"@/components/ui/collapsible\";\n\nimport {\n  OPENCODE_ACTIVITY_GLYPH,\n  OPENCODE_ACTIVITY_LABEL,\n  OPENCODE_THINKING_FRAME_MS,\n  OPENCODE_THINKING_FRAMES,\n} from \"../constants/opencode\";\nimport { useOpencodeFrame } from \"../hooks/use-opencode-frame\";\nimport { useOpencodeReducedMotion } from \"../hooks/use-opencode-reduced-motion\";\nimport type { OpencodeActivityProps } from \"../types/opencode\";\n\nconst TRIGGER_CLASS =\n  \"focus-visible:ring-opencode-blue h-auto justify-start gap-0 rounded-none p-0 text-start text-[length:inherit] leading-[inherit] font-normal whitespace-normal text-current hover:bg-transparent hover:text-current focus-visible:border-transparent focus-visible:ring-1 aria-expanded:bg-transparent aria-expanded:text-current dark:hover:bg-transparent\";\n\nconst ThinkingGlyph = ({ reducedMotion }: { reducedMotion?: boolean }) => {\n  const reduced = useOpencodeReducedMotion(reducedMotion);\n  const frame = useOpencodeFrame(\n    OPENCODE_THINKING_FRAMES.length,\n    OPENCODE_THINKING_FRAME_MS,\n    !reduced\n  );\n  return (\n    <span aria-hidden=\"true\" className=\"inline-block w-[2ch] shrink-0\">\n      {OPENCODE_THINKING_FRAMES[frame]}\n    </span>\n  );\n};\n\nexport const OpencodeActivity = ({\n  children,\n  className,\n  defaultOpen = false,\n  detail,\n  duration,\n  kind = \"tool\",\n  label,\n  pending = false,\n  reducedMotion,\n  ...props\n}: OpencodeActivityProps) => {\n  const isThought = kind === \"thought\";\n  const glyph = OPENCODE_ACTIVITY_GLYPH[kind];\n  const name = label ?? OPENCODE_ACTIVITY_LABEL[kind];\n\n  const summary =\n    isThought && pending ? (\n      <>\n        <ThinkingGlyph reducedMotion={reducedMotion} />\n        <span>Thinking</span>\n      </>\n    ) : (\n      <>\n        {glyph && (\n          <span aria-hidden=\"true\" className=\"inline-block w-[2ch] shrink-0\">\n            {glyph}\n          </span>\n        )}\n        <span className=\"min-w-0 wrap-break-word\">\n          {name}\n          {detail && <> {detail}</>}\n          {duration && <> · {duration}</>}\n        </span>\n      </>\n    );\n\n  return (\n    <Collapsible\n      className={cn(\n        \"ps-[3ch]\",\n        isThought ? \"text-opencode-orange\" : \"text-opencode-muted\",\n        className\n      )}\n      data-kind={kind}\n      data-slot=\"opencode-activity\"\n      defaultOpen={defaultOpen}\n      {...props}\n    >\n      {children ? (\n        <CollapsibleTrigger\n          render={<Button className={TRIGGER_CLASS} variant=\"ghost\" />}\n        >\n          <span className=\"flex min-w-0\">{summary}</span>\n        </CollapsibleTrigger>\n      ) : (\n        <div className=\"flex min-w-0\">{summary}</div>\n      )}\n      {children && (\n        <CollapsibleContent>\n          <div\n            className={cn(\n              \"text-opencode-muted mt-[1lh] whitespace-pre-wrap\",\n              isThought ? \"italic\" : \"ps-[2ch]\"\n            )}\n          >\n            {children}\n          </div>\n        </CollapsibleContent>\n      )}\n    </Collapsible>\n  );\n};\n",
      "type": "registry:component",
      "target": "components/opencode/components/opencode-activity.tsx"
    },
    {
      "path": "registry/notra/opencode/components/opencode-sources.tsx",
      "content": "\"use client\";\n\nimport { cn } from \"cn\";\nimport type { CSSProperties } from \"react\";\n\nimport { Button } from \"@/components/ui/button\";\nimport {\n  Collapsible,\n  CollapsibleContent,\n  CollapsibleTrigger,\n} from \"@/components/ui/collapsible\";\n\nimport { OPENCODE_SEARCH_STAGGER_MS } from \"../constants/opencode\";\nimport { useOpencodeReducedMotion } from \"../hooks/use-opencode-reduced-motion\";\nimport { useOpencodeSourcesSequence } from \"../hooks/use-opencode-sources-sequence\";\nimport type {\n  OpencodeSource,\n  OpencodeSourcesLabels,\n  OpencodeSourcesProps,\n} from \"../types/opencode\";\nimport { OpencodeActivity } from \"./opencode-activity\";\n\nconst TRAILING_MARKDOWN_PATTERN = /\\)\\*+$/u;\nconst NO_QUERIES: readonly string[] = [];\n\nconst REVEAL_CLASS =\n  \"opacity-100 transition-opacity duration-200 ease-out delay-(--opencode-delay) starting:opacity-0 motion-reduce:transition-none\";\n\nconst DEFAULT_LABELS: OpencodeSourcesLabels = {\n  citedSources: (count) =>\n    count === 1 ? \"1 cited source\" : `${count} cited sources`,\n  openSource: (title, domain) => `Open ${title} on ${domain}`,\n};\n\nconst cleanUrl = (url: string) => url.replace(TRAILING_MARKDOWN_PATTERN, \"\");\n\nconst safeHref = (url: string | undefined) => {\n  if (!url) {\n    return null;\n  }\n  try {\n    const parsed = new URL(cleanUrl(url));\n    return parsed.protocol === \"http:\" || parsed.protocol === \"https:\"\n      ? parsed.href\n      : null;\n  } catch {\n    return null;\n  }\n};\n\nconst SourceLine = ({\n  delayMs,\n  openLabel,\n  source,\n}: {\n  delayMs?: number;\n  openLabel: OpencodeSourcesLabels[\"openSource\"];\n  source: OpencodeSource;\n}) => {\n  const href = safeHref(source.url);\n  const style =\n    delayMs === undefined\n      ? undefined\n      : ({ \"--opencode-delay\": `${delayMs}ms` } as CSSProperties);\n  const content = (\n    <>\n      <span className=\"text-opencode-fg truncate\">{source.domain}</span>\n      <span className=\"text-opencode-muted truncate\">\n        {source.url ? cleanUrl(source.url) : source.title}\n      </span>\n    </>\n  );\n  const lineClass = cn(\n    \"grid grid-cols-[minmax(0,18ch)_minmax(0,1fr)] gap-[2ch]\",\n    delayMs !== undefined && REVEAL_CLASS\n  );\n\n  return (\n    <li className={lineClass} style={style}>\n      {href ? (\n        <a\n          aria-label={openLabel(source.title, source.domain)}\n          className=\"focus-visible:ring-opencode-blue col-span-2 grid grid-cols-subgrid outline-none hover:underline focus-visible:ring-1\"\n          href={href}\n          rel=\"noopener noreferrer\"\n          target=\"_blank\"\n        >\n          {content}\n        </a>\n      ) : (\n        content\n      )}\n    </li>\n  );\n};\n\nexport const OpencodeSources = ({\n  className,\n  defaultOpen = false,\n  labels = DEFAULT_LABELS,\n  queries = NO_QUERIES,\n  reducedMotion,\n  sequential = false,\n  sources,\n  ...props\n}: OpencodeSourcesProps) => {\n  const reduced = useOpencodeReducedMotion(reducedMotion);\n  const staged = sequential && !reduced;\n  const progress = useOpencodeSourcesSequence(\n    staged,\n    queries.length,\n    sources.length\n  );\n\n  if (sources.length === 0 && queries.length === 0) {\n    return null;\n  }\n\n  const shownQueries = staged ? queries.slice(0, progress.queries) : queries;\n  const showSources = staged ? progress.sources : sources.length > 0;\n\n  return (\n    <Collapsible\n      aria-live={staged ? \"polite\" : undefined}\n      className={cn(\"flex w-full min-w-0 flex-col\", className)}\n      data-slot=\"opencode-sources\"\n      defaultOpen={defaultOpen}\n      {...props}\n    >\n      {shownQueries.map((query) => (\n        <OpencodeActivity\n          className={cn(staged && REVEAL_CLASS)}\n          detail={`\"${query}\"`}\n          key={query}\n          kind=\"search\"\n        />\n      ))}\n      {showSources && (\n        <div className={cn(\"ps-[5ch]\", staged && REVEAL_CLASS)}>\n          <CollapsibleTrigger\n            render={\n              <Button\n                className=\"group/sources text-opencode-muted hover:text-opencode-fg aria-expanded:text-opencode-muted focus-visible:ring-opencode-blue h-auto gap-[1ch] rounded-none p-0 text-[length:inherit] leading-[inherit] font-normal hover:bg-transparent focus-visible:border-transparent focus-visible:ring-1 aria-expanded:bg-transparent dark:hover:bg-transparent\"\n                variant=\"ghost\"\n              />\n            }\n          >\n            <span\n              aria-hidden=\"true\"\n              className=\"inline-block w-[1ch] text-[0.75em] transition-transform duration-150 group-aria-expanded/sources:rotate-90 motion-reduce:transition-none\"\n            >\n              ▶\n            </span>\n            {labels.citedSources(sources.length)}\n          </CollapsibleTrigger>\n          <CollapsibleContent>\n            <ul className=\"ps-[2ch]\">\n              {sources.map((source, index) => (\n                <SourceLine\n                  delayMs={\n                    staged\n                      ? (index + 1) * OPENCODE_SEARCH_STAGGER_MS\n                      : undefined\n                  }\n                  key={source.url ?? `${source.domain}-${source.title}`}\n                  openLabel={labels.openSource}\n                  source={source}\n                />\n              ))}\n            </ul>\n          </CollapsibleContent>\n        </div>\n      )}\n    </Collapsible>\n  );\n};\n",
      "type": "registry:component",
      "target": "components/opencode/components/opencode-sources.tsx"
    },
    {
      "path": "registry/notra/opencode/components/opencode-progress.tsx",
      "content": "\"use client\";\n\nimport { cn } from \"cn\";\nimport type { CSSProperties } from \"react\";\n\nimport {\n  OPENCODE_PROGRESS_CELLS,\n  OPENCODE_PROGRESS_FRAME_MS,\n  OPENCODE_PROGRESS_TRAIL,\n} from \"../constants/opencode\";\nimport { useOpencodeFrame } from \"../hooks/use-opencode-frame\";\nimport { useOpencodeReducedMotion } from \"../hooks/use-opencode-reduced-motion\";\nimport type { OpencodeProgressProps } from \"../types/opencode\";\n\nconst LAST_CELL = OPENCODE_PROGRESS_CELLS - 1;\nconst TRAIL_LENGTH = OPENCODE_PROGRESS_TRAIL.length;\nconst SWEEP_FRAMES = LAST_CELL * 2 + TRAIL_LENGTH;\nconst FRAME_COUNT = SWEEP_FRAMES + TRAIL_LENGTH;\nconst CELLS = Array.from(\n  { length: OPENCODE_PROGRESS_CELLS },\n  (_, cell) => cell\n);\n\nconst cellOpacity = (cell: number, frame: number): number | null => {\n  if (frame >= SWEEP_FRAMES) {\n    return null;\n  }\n  const forward = frame <= LAST_CELL;\n  const head = forward ? frame : LAST_CELL * 2 - frame;\n  const behind = forward ? head - cell : cell - head;\n  return OPENCODE_PROGRESS_TRAIL[behind] ?? null;\n};\n\nexport const OpencodeProgress = ({\n  active = true,\n  className,\n  reducedMotion,\n  ...props\n}: OpencodeProgressProps) => {\n  const reduced = useOpencodeReducedMotion(reducedMotion);\n  const animate = active && !reduced;\n  const frame = useOpencodeFrame(\n    FRAME_COUNT,\n    OPENCODE_PROGRESS_FRAME_MS,\n    animate\n  );\n\n  return (\n    <span\n      aria-hidden=\"true\"\n      className={cn(\"inline-flex h-[1lh] shrink-0 items-center\", className)}\n      data-slot=\"opencode-progress\"\n      {...props}\n    >\n      {CELLS.map((cell) => {\n        const opacity = animate ? cellOpacity(cell, frame) : null;\n        return (\n          <span\n            className=\"grid h-[0.9em] w-[1ch] place-items-center\"\n            key={cell}\n          >\n            {opacity === null ? (\n              <span className=\"bg-opencode-blue size-0.5 opacity-40\" />\n            ) : (\n              <span\n                className=\"bg-opencode-blue size-full opacity-(--opencode-cell)\"\n                style={{ \"--opencode-cell\": opacity } as CSSProperties}\n              />\n            )}\n          </span>\n        );\n      })}\n    </span>\n  );\n};\n",
      "type": "registry:component",
      "target": "components/opencode/components/opencode-progress.tsx"
    },
    {
      "path": "registry/notra/opencode/components/opencode-composer.tsx",
      "content": "\"use client\";\n\nimport { cn } from \"cn\";\nimport { useState } from \"react\";\nimport type { ChangeEvent, FormEvent, KeyboardEvent } from \"react\";\n\nimport {\n  InputGroup,\n  InputGroupAddon,\n  InputGroupInput,\n} from \"@/components/ui/input-group\";\nimport { Kbd } from \"@/components/ui/kbd\";\n\nimport {\n  OPENCODE_DEFAULT_AGENT,\n  OPENCODE_DEFAULT_EFFORT,\n  OPENCODE_DEFAULT_MODEL,\n  OPENCODE_DEFAULT_PLACEHOLDER,\n  OPENCODE_DEFAULT_PROVIDER,\n} from \"../constants/opencode\";\nimport type { OpencodeComposerProps } from \"../types/opencode\";\nimport { OpencodeProgress } from \"./opencode-progress\";\n\nconst KBD_CLASS =\n  \"text-opencode-fg font-opencode h-auto min-w-0 rounded-none bg-transparent p-0 text-[length:inherit] font-normal\";\n\nexport const OpencodeComposer = ({\n  agent = OPENCODE_DEFAULT_AGENT,\n  \"aria-label\": ariaLabel = \"Prompt\",\n  busy = false,\n  className,\n  context,\n  cwd,\n  defaultValue,\n  effort = OPENCODE_DEFAULT_EFFORT,\n  inputClassName,\n  model = OPENCODE_DEFAULT_MODEL,\n  onChange,\n  onKeyDown,\n  onSend,\n  onStop,\n  placeholder = OPENCODE_DEFAULT_PLACEHOLDER,\n  provider = OPENCODE_DEFAULT_PROVIDER,\n  value,\n  ...props\n}: OpencodeComposerProps) => {\n  const [draft, setDraft] = useState(String(defaultValue ?? \"\"));\n  const isControlled = value !== undefined;\n  const text = isControlled ? String(value) : draft;\n\n  const handleChange = (event: ChangeEvent<HTMLInputElement>) => {\n    setDraft(event.target.value);\n    onChange?.(event);\n  };\n\n  const handleKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {\n    if (event.key === \"Escape\" && busy && onStop) {\n      event.preventDefault();\n      onStop();\n    }\n    onKeyDown?.(event);\n  };\n\n  const handleSubmit = (event: FormEvent<HTMLFormElement>) => {\n    event.preventDefault();\n    const message = text.trim();\n    if (!message || busy || !onSend) {\n      return;\n    }\n    onSend(message);\n    if (!isControlled) {\n      setDraft(\"\");\n    }\n  };\n\n  return (\n    <form\n      className={cn(\"flex min-w-0 flex-col gap-[1lh]\", className)}\n      data-slot=\"opencode-composer\"\n      onSubmit={handleSubmit}\n    >\n      <InputGroup className=\"border-opencode-blue bg-opencode-panel dark:bg-opencode-panel has-[[data-slot=input-group-control]:focus-visible]:border-opencode-blue h-auto flex-col items-stretch gap-[0.5lh] rounded-none border-0 border-s-2 py-[0.5lh] ps-[calc(3ch-2px)] pe-[2ch] has-[[data-slot=input-group-control]:focus-visible]:ring-0 has-[>[data-align=block-end]]:[&>input]:pt-0\">\n        <InputGroupInput\n          aria-label={ariaLabel}\n          className={cn(\n            \"peer text-opencode-fg caret-opencode-fg placeholder:text-opencode-muted h-[1lh] px-0 py-0 text-[length:inherit] leading-[inherit] md:text-[length:inherit] [&:placeholder-shown:not(:focus)]:indent-[1ch]\",\n            inputClassName\n          )}\n          autoComplete=\"off\"\n          enterKeyHint=\"send\"\n          onChange={handleChange}\n          onKeyDown={handleKeyDown}\n          placeholder={placeholder}\n          type=\"text\"\n          value={text}\n          {...props}\n        />\n        <span\n          aria-hidden=\"true\"\n          className=\"bg-opencode-fg pointer-events-none absolute start-[calc(3ch-2px)] top-[0.5lh] hidden h-[1lh] w-[1ch] peer-[:placeholder-shown:not(:focus)]:block\"\n        />\n        <InputGroupAddon\n          align=\"block-end\"\n          className=\"min-w-0 cursor-default flex-wrap justify-start gap-x-[1ch] gap-y-0 p-0 text-[length:inherit] leading-[inherit] font-normal group-has-[>input]/input-group:pb-0\"\n        >\n          <span className=\"text-opencode-blue\">{agent}</span>\n          <span aria-hidden=\"true\" className=\"text-opencode-muted\">\n            ·\n          </span>\n          <span className=\"text-opencode-fg\">{model}</span>\n          <span className=\"text-opencode-muted\">{provider}</span>\n          <span aria-hidden=\"true\" className=\"text-opencode-muted\">\n            ·\n          </span>\n          <span className=\"text-opencode-orange font-bold\">{effort}</span>\n        </InputGroupAddon>\n      </InputGroup>\n      <div className=\"text-opencode-muted flex min-w-0 items-center justify-between gap-[2ch] ps-[1ch]\">\n        {busy ? (\n          <span className=\"flex min-w-0 items-center gap-[2ch]\">\n            <OpencodeProgress />\n            <span>\n              <Kbd className={KBD_CLASS}>esc</Kbd> interrupt\n            </span>\n          </span>\n        ) : (\n          <span className=\"min-w-0 truncate\">{cwd}</span>\n        )}\n        <span className=\"flex shrink-0 items-center gap-[2ch]\">\n          {context ? (\n            <span className=\"tabular-nums\">{context}</span>\n          ) : (\n            <span>\n              <Kbd className={KBD_CLASS}>tab</Kbd> agents\n            </span>\n          )}\n          <span>\n            <Kbd className={KBD_CLASS}>ctrl+p</Kbd> commands\n          </span>\n        </span>\n      </div>\n    </form>\n  );\n};\n",
      "type": "registry:component",
      "target": "components/opencode/components/opencode-composer.tsx"
    },
    {
      "path": "registry/notra/opencode/components/opencode-scroll-area.tsx",
      "content": "\"use client\";\n\nimport { ScrollArea as ScrollAreaPrimitive } from \"@base-ui/react/scroll-area\";\nimport { cn } from \"cn\";\n\nimport type { OpencodeScrollAreaProps } from \"../types/opencode\";\n\nexport const OpencodeScrollArea = ({\n  children,\n  className,\n  ...props\n}: OpencodeScrollAreaProps) => (\n  <ScrollAreaPrimitive.Root\n    className={cn(\"relative\", className)}\n    data-slot=\"opencode-scroll-area\"\n    {...props}\n  >\n    <ScrollAreaPrimitive.Viewport\n      className=\"focus-visible:outline-opencode-blue size-full outline-none focus-visible:outline-1 focus-visible:-outline-offset-1\"\n      data-slot=\"opencode-scroll-area-viewport\"\n    >\n      {children}\n    </ScrollAreaPrimitive.Viewport>\n    <ScrollAreaPrimitive.Scrollbar\n      className=\"flex w-[1.5ch] touch-none select-none\"\n      orientation=\"vertical\"\n    >\n      <ScrollAreaPrimitive.Thumb className=\"before:bg-opencode-subtle hover:before:bg-opencode-muted relative w-full before:absolute before:inset-y-0 before:right-0 before:w-[0.5ch] before:transition-colors\" />\n    </ScrollAreaPrimitive.Scrollbar>\n  </ScrollAreaPrimitive.Root>\n);\n",
      "type": "registry:component",
      "target": "components/opencode/components/opencode-scroll-area.tsx"
    },
    {
      "path": "registry/notra/opencode/components/opencode-sidebar.tsx",
      "content": "\"use client\";\n\nimport { cn } from \"cn\";\n\nimport { Button } from \"@/components/ui/button\";\nimport {\n  Collapsible,\n  CollapsibleContent,\n  CollapsibleTrigger,\n} from \"@/components/ui/collapsible\";\n\nimport {\n  OPENCODE_DEFAULT_CWD,\n  OPENCODE_DEFAULT_SERVERS,\n  OPENCODE_DEFAULT_VERSION,\n  OPENCODE_MCP_STATUS_CLASS,\n} from \"../constants/opencode\";\nimport type { OpencodeSidebarProps } from \"../types/opencode\";\nimport { OpencodeScrollArea } from \"./opencode-scroll-area\";\n\nconst splitBranch = (branch: string) => {\n  const cut = branch.lastIndexOf(\"/\") + 1;\n  return { head: branch.slice(cut), prefix: branch.slice(0, cut) };\n};\n\nconst SidebarLocation = ({ branch, cwd }: { branch?: string; cwd: string }) => {\n  if (!branch) {\n    return <div className=\"text-opencode-muted break-all\">{cwd}</div>;\n  }\n  const { head, prefix } = splitBranch(branch);\n  return (\n    <div className=\"break-all\">\n      <span className=\"text-opencode-muted\">\n        {cwd}:{prefix}\n      </span>\n      <span className=\"text-opencode-fg\">{head}</span>\n    </div>\n  );\n};\n\nexport const OpencodeSidebar = ({\n  branch,\n  className,\n  cwd = OPENCODE_DEFAULT_CWD,\n  lsp = \"LSPs are disabled\",\n  mcpOpen,\n  onMcpOpenChange,\n  servers = OPENCODE_DEFAULT_SERVERS,\n  spent = \"$0.00 spent\",\n  title = \"New session\",\n  tokens = \"0 tokens\",\n  used = \"0% used\",\n  version = OPENCODE_DEFAULT_VERSION,\n  ...props\n}: OpencodeSidebarProps) => (\n  <aside\n    className={cn(\n      \"bg-opencode-sidebar text-opencode-fg flex min-h-0 flex-col\",\n      className\n    )}\n    data-slot=\"opencode-sidebar\"\n    {...props}\n  >\n    <OpencodeScrollArea className=\"min-h-0 flex-1 [&>[data-slot=opencode-scroll-area-viewport]>div]:min-h-full\">\n      <div className=\"flex min-h-full flex-col gap-[1lh] px-[2ch] py-[1lh]\">\n        <h2 className=\"text-[length:inherit] leading-[inherit] font-bold wrap-break-word\">\n          {title}\n        </h2>\n\n        <section>\n          <h3 className=\"text-[length:inherit] leading-[inherit] font-bold\">\n            Context\n          </h3>\n          <p className=\"text-opencode-muted tabular-nums\">{tokens}</p>\n          <p className=\"text-opencode-muted tabular-nums\">{used}</p>\n          <p className=\"text-opencode-muted tabular-nums\">{spent}</p>\n        </section>\n\n        <Collapsible defaultOpen onOpenChange={onMcpOpenChange} open={mcpOpen}>\n          <CollapsibleTrigger\n            render={\n              <Button\n                className=\"group/mcp text-opencode-fg hover:text-opencode-fg aria-expanded:text-opencode-fg focus-visible:ring-opencode-blue h-auto gap-[1ch] rounded-none p-0 text-[length:inherit] leading-[inherit] font-bold hover:bg-transparent focus-visible:border-transparent focus-visible:ring-1 aria-expanded:bg-transparent dark:hover:bg-transparent\"\n                variant=\"ghost\"\n              />\n            }\n          >\n            <span\n              aria-hidden=\"true\"\n              className=\"inline-block w-[1ch] text-[0.75em] transition-transform duration-150 group-aria-expanded/mcp:rotate-90 motion-reduce:transition-none\"\n            >\n              ▶\n            </span>\n            MCP\n          </CollapsibleTrigger>\n          <CollapsibleContent>\n            <ul>\n              {servers.map((server) => {\n                const status = server.status ?? \"Connected\";\n                return (\n                  <li className=\"flex min-w-0 gap-[1ch]\" key={server.name}>\n                    <span\n                      aria-hidden=\"true\"\n                      className={OPENCODE_MCP_STATUS_CLASS[status]}\n                    >\n                      •\n                    </span>\n                    <span className=\"min-w-0 truncate\">\n                      {server.name}{\" \"}\n                      <span className=\"text-opencode-muted\">{status}</span>\n                    </span>\n                  </li>\n                );\n              })}\n            </ul>\n          </CollapsibleContent>\n        </Collapsible>\n\n        <section>\n          <h3 className=\"text-[length:inherit] leading-[inherit] font-bold\">\n            LSP\n          </h3>\n          <p className=\"text-opencode-muted\">{lsp}</p>\n        </section>\n\n        <div className=\"mt-auto flex flex-col gap-[1lh] pt-[1lh]\">\n          <SidebarLocation branch={branch} cwd={cwd} />\n          <p className=\"flex gap-[1ch]\">\n            <span aria-hidden=\"true\" className=\"text-opencode-green\">\n              •\n            </span>\n            <span className=\"font-bold\">\n              <span className=\"text-opencode-muted\">Open</span>Code\n            </span>\n            <span className=\"text-opencode-muted tabular-nums\">{version}</span>\n          </p>\n        </div>\n      </div>\n    </OpencodeScrollArea>\n  </aside>\n);\n",
      "type": "registry:component",
      "target": "components/opencode/components/opencode-sidebar.tsx"
    },
    {
      "path": "registry/notra/opencode/constants/opencode.ts",
      "content": "import type {\n  OpencodeActivityKind,\n  OpencodeMcpServer,\n  OpencodeMcpStatus,\n} from \"../types/opencode\";\n\nexport const OPENCODE_DEFAULT_AGENT = \"Build\";\n\nexport const OPENCODE_DEFAULT_MODEL = \"Writer 0.1\";\n\nexport const OPENCODE_DEFAULT_PROVIDER = \"Notra\";\n\nexport const OPENCODE_DEFAULT_EFFORT = \"high\";\n\nexport const OPENCODE_DEFAULT_PLACEHOLDER =\n  'Ask anything... \"Draft this week\\'s changelog\"';\n\nexport const OPENCODE_DEFAULT_VERSION = \"1.18.33\";\n\nexport const OPENCODE_DEFAULT_CWD = \"~/acme/web\";\n\nexport const OPENCODE_DEFAULT_SERVERS: OpencodeMcpServer[] = [\n  { name: \"notra\", status: \"Connected\" },\n  { name: \"github\", status: \"Connected\" },\n  { name: \"linear\", status: \"Connected\" },\n];\n\nexport const OPENCODE_MCP_STATUS_CLASS: Record<OpencodeMcpStatus, string> = {\n  Connected: \"text-opencode-green\",\n  Disconnected: \"text-opencode-muted\",\n  Failed: \"text-opencode-orange\",\n};\n\nexport const OPENCODE_ACTIVITY_GLYPH: Record<OpencodeActivityKind, string> = {\n  read: \"→\",\n  search: \"◈\",\n  thought: \"\",\n  tool: \"⚙\",\n};\n\nexport const OPENCODE_ACTIVITY_LABEL: Record<OpencodeActivityKind, string> = {\n  read: \"Read\",\n  search: \"Web Search\",\n  thought: \"Thought\",\n  tool: \"Tool\",\n};\n\nexport const OPENCODE_THINKING_FRAMES = [\n  \"⠋\",\n  \"⠙\",\n  \"⠹\",\n  \"⠸\",\n  \"⠼\",\n  \"⠴\",\n  \"⠦\",\n  \"⠧\",\n  \"⠇\",\n  \"⠏\",\n] as const;\n\nexport const OPENCODE_THINKING_FRAME_MS = 80;\n\nexport const OPENCODE_PROGRESS_CELLS = 8;\n\nexport const OPENCODE_PROGRESS_FRAME_MS = 90;\n\nexport const OPENCODE_PROGRESS_TRAIL = [1, 0.55, 0.32, 0.18] as const;\n\nexport const OPENCODE_SEARCH_HEADER_MS = 140;\n\nexport const OPENCODE_SEARCH_QUERY_MS = 280;\n\nexport const OPENCODE_SEARCH_STAGGER_MS = 56;\n\nexport const OPENCODE_SEARCH_SOURCES_MS = 160;\n\nexport const OPENCODE_CHAT_TIMING = {\n  thinkMs: 1300,\n  toolMs: 600,\n  blockMs: 260,\n  reducedMaxMs: 60,\n} as const;\n\nexport const OPENCODE_REDUCED_MOTION_QUERY = \"(prefers-reduced-motion: reduce)\";\n\nexport const OPENCODE_LOGO_ROWS = [\n  \".................................c.....\",\n  \"oooo.oooo.oooo.ooo..cccc.cccc.cccc.cccc\",\n  \"o++o.o++o.o++o.o..o.c....c++c.c++c.c++c\",\n  \"o++o.o++o.oooo.o..o.c....c++c.c++c.cccc\",\n  \"o++o.oooo.o....o..o.c....c++c.c++c.c...\",\n  \"oooo.o....oooo.o..o.cccc.cccc.cccc.cccc\",\n  \".....o.................................\",\n] as const;\n\nexport const OPENCODE_LOGO_CELL = 6;\n",
      "type": "registry:lib",
      "target": "components/opencode/constants/opencode.ts"
    },
    {
      "path": "registry/notra/opencode/constants/opencode-demo.ts",
      "content": "import type {\n  OpencodeDemoActivity,\n  OpencodeDemoSession,\n  OpencodeDemoTurn,\n  OpencodeReply,\n  OpencodeSource,\n} from \"../types/opencode\";\n\nexport const OPENCODE_DEMO_SESSION: OpencodeDemoSession = {\n  agent: \"Build\",\n  branch: \"feat/changelog-week-39\",\n  context: \"41.2K (4%)\",\n  cwd: \"~/acme/web\",\n  effort: \"high\",\n  model: \"Writer 0.1\",\n  provider: \"Notra\",\n  servers: [\n    { name: \"notra\", status: \"Connected\" },\n    { name: \"github\", status: \"Connected\" },\n    { name: \"linear\", status: \"Connected\" },\n    { name: \"vercel\", status: \"Disconnected\" },\n  ],\n  spent: \"$0.18 spent\",\n  title: \"Weekly changelog draft\",\n  tokens: \"41,207 tokens\",\n  used: \"4% used\",\n  version: \"1.18.33\",\n};\n\nexport const OPENCODE_DEMO_TURNS: OpencodeDemoTurn[] = [\n  {\n    activities: [{ duration: \"1.1s\", id: \"t1-thought\", kind: \"thought\" }],\n    duration: \"4.2s\",\n    id: \"greeting\",\n    prompt: \"is the notra mcp connected?\",\n    reply: [\n      {\n        id: \"greeting-reply\",\n        text: [\n          \"Yes. \",\n          { code: \"notra\" },\n          \" is connected, so I can read this week's events and publish posts.\",\n        ],\n      },\n    ],\n  },\n  {\n    activities: [\n      { duration: \"1.4s\", id: \"t2-thought\", kind: \"thought\" },\n      { detail: \"CHANGELOG.md\", id: \"t2-read-changelog\", kind: \"read\" },\n      { detail: \"brand-voice.md\", id: \"t2-read-voice\", kind: \"read\" },\n      {\n        detail: \"[range=week]\",\n        id: \"t2-events\",\n        kind: \"tool\",\n        label: \"notra_list_events\",\n      },\n      { duration: \"2.0s\", id: \"t2-thought-2\", kind: \"thought\" },\n    ],\n    duration: \"17.8s\",\n    id: \"changelog\",\n    prompt: \"draft this week's changelog from the merged PRs\",\n    reply: [\n      {\n        id: \"changelog-intro\",\n        text: [\n          \"Drafted \",\n          { strong: \"Acme v2.4\" },\n          \" from 14 merged PRs, grouped by area and written in your brand voice.\",\n        ],\n      },\n      { heading: \"Features:\", id: \"changelog-features\" },\n      {\n        id: \"changelog-feature-list\",\n        items: [\n          {\n            id: \"scheduler\",\n            spans: [\n              { code: \"apps/scheduler\" },\n              \" - Scheduled posts now publish on every plan\",\n            ],\n          },\n          {\n            id: \"geo\",\n            spans: [\n              { code: \"apps/geo\" },\n              \" - Share-of-voice chart per AI engine\",\n            ],\n          },\n          {\n            id: \"api\",\n            spans: [\n              { code: \"apps/api\" },\n              \", \",\n              { code: \"packages/sdk\" },\n              \" - Webhooks for published posts\",\n            ],\n          },\n        ],\n      },\n      { heading: \"Fixes:\", id: \"changelog-fixes\" },\n      {\n        id: \"changelog-fix-list\",\n        items: [\n          {\n            id: \"editor\",\n            spans: [\n              { code: \"apps/editor\" },\n              \" - Image uploads no longer drop alt text\",\n            ],\n          },\n          {\n            id: \"billing\",\n            spans: [\n              { code: \"packages/billing\" },\n              \" - Seat counts update right after an invite\",\n            ],\n          },\n        ],\n      },\n      {\n        id: \"changelog-next\",\n        text: [\n          \"Saved as a draft in Notra. Run \",\n          { code: \"notra_publish_post\" },\n          \" when you're ready to ship it.\",\n        ],\n      },\n    ],\n  },\n];\n\nexport const OPENCODE_DEMO_ACTIVITIES: OpencodeDemoActivity[] = [\n  {\n    body: \"The user wants the week's changes. Read the brand voice first, then pull merged PRs from Notra.\",\n    duration: \"1.4s\",\n    id: \"thought\",\n    kind: \"thought\",\n  },\n  { detail: \"CHANGELOG.md\", id: \"read-changelog\", kind: \"read\" },\n  { detail: \"brand-voice.md\", id: \"read-voice\", kind: \"read\" },\n  {\n    body: \"14 merged PRs, 2 releases\",\n    detail: \"[range=week]\",\n    id: \"tool\",\n    kind: \"tool\",\n    label: \"notra_list_events\",\n  },\n  {\n    detail: '\"AI changelog tools 2026\"',\n    id: \"search\",\n    kind: \"search\",\n  },\n];\n\nexport const OPENCODE_DEMO_SOURCES: OpencodeSource[] = [\n  {\n    domain: \"usenotra.com\",\n    title: \"Notra changelog\",\n    url: \"https://usenotra.com/changelog\",\n  },\n  {\n    domain: \"keepachangelog.com\",\n    title: \"Keep a Changelog\",\n    url: \"https://keepachangelog.com/\",\n  },\n  {\n    domain: \"github.blog\",\n    title: \"GitHub changelog\",\n    url: \"https://github.blog/changelog/\",\n  },\n  {\n    domain: \"linear.app\",\n    title: \"Linear changelog\",\n    url: \"https://linear.app/changelog\",\n  },\n];\n\nexport const OPENCODE_DEMO_QUERIES: string[] = [\n  \"best AI changelog tools 2026\",\n  \"how teams write release notes\",\n];\n\nexport const OPENCODE_REPLIES: OpencodeReply[] = [\n  {\n    activities: [\n      { id: \"thought\", kind: \"thought\" },\n      {\n        detail: \"[id=changelog-week-39]\",\n        id: \"publish\",\n        kind: \"tool\",\n        label: \"notra_publish_post\",\n      },\n    ],\n    reply: [\n      {\n        id: \"published\",\n        text: [\n          \"Published \",\n          { strong: \"Acme v2.4\" },\n          \". It's live at \",\n          { code: \"acme.com/changelog/v2-4\" },\n          \" and the RSS feed picked it up.\",\n        ],\n      },\n      {\n        id: \"next\",\n        text: [\"Want a short LinkedIn post for the release as well?\"],\n      },\n    ],\n  },\n  {\n    activities: [\n      { id: \"thought\", kind: \"thought\" },\n      { detail: \"apps/scheduler/src/publish.ts\", id: \"read\", kind: \"read\" },\n    ],\n    reply: [\n      {\n        id: \"retry\",\n        text: [\n          \"Failed publish jobs retry three times with backoff in \",\n          { code: \"apps/scheduler/src/publish.ts\" },\n          \".\",\n        ],\n      },\n      { heading: \"Covered by:\", id: \"tests-heading\" },\n      {\n        id: \"tests\",\n        items: [\n          {\n            id: \"retry-test\",\n            spans: [{ code: \"publish.test.ts\" }, \" - retries a failed publish\"],\n          },\n          {\n            id: \"fail-test\",\n            spans: [\n              { code: \"publish.test.ts\" },\n              \" - surfaces the error after the last attempt\",\n            ],\n          },\n        ],\n      },\n    ],\n  },\n  {\n    activities: [\n      { id: \"thought\", kind: \"thought\" },\n      {\n        detail: \"bun run test\",\n        id: \"tests\",\n        kind: \"tool\",\n        label: \"bash\",\n      },\n    ],\n    reply: [\n      {\n        id: \"green\",\n        text: [\n          \"All \",\n          { strong: \"212 tests\" },\n          \" pass. Nothing is blocking the release.\",\n        ],\n      },\n    ],\n  },\n];\n",
      "type": "registry:lib",
      "target": "components/opencode/constants/opencode-demo.ts"
    },
    {
      "path": "registry/notra/opencode/hooks/use-opencode-chat.ts",
      "content": "\"use client\";\n\nimport { useCallback, useEffect, useRef, useState } from \"react\";\n\nimport {\n  OPENCODE_CHAT_TIMING,\n  OPENCODE_REDUCED_MOTION_QUERY,\n} from \"../constants/opencode\";\nimport type {\n  OpencodeChat,\n  OpencodeChatTurn,\n  OpencodeDemoTurn,\n  OpencodeReply,\n} from \"../types/opencode\";\n\nconst wait = (ms: number) =>\n  new Promise<void>((resolve) => {\n    window.setTimeout(resolve, ms);\n  });\n\nconst formatSeconds = (ms: number) => `${(ms / 1000).toFixed(1)}s`;\n\nconst settle = (turn: OpencodeDemoTurn): OpencodeChatTurn => ({\n  ...turn,\n  status: \"done\",\n});\n\nexport const useOpencodeChat = (\n  history: readonly OpencodeDemoTurn[],\n  replies: readonly OpencodeReply[]\n): OpencodeChat => {\n  const [turns, setTurns] = useState<OpencodeChatTurn[]>(() =>\n    history.map(settle)\n  );\n  const [activeId, setActiveId] = useState<string | null>(null);\n  const runRef = useRef(0);\n  const activeRef = useRef<string | null>(null);\n  const replyRef = useRef(0);\n\n  useEffect(\n    () => () => {\n      runRef.current += 1;\n    },\n    []\n  );\n\n  const patch = useCallback(\n    (\n      id: string,\n      next: (turn: OpencodeChatTurn) => Partial<OpencodeChatTurn>\n    ) => {\n      setTurns((current) =>\n        current.map((turn) =>\n          turn.id === id ? { ...turn, ...next(turn) } : turn\n        )\n      );\n    },\n    []\n  );\n\n  const finish = useCallback(() => {\n    activeRef.current = null;\n    setActiveId(null);\n  }, []);\n\n  const stop = useCallback(() => {\n    const id = activeRef.current;\n    if (!id) {\n      return;\n    }\n    runRef.current += 1;\n    patch(id, (turn) => ({\n      activities: turn.activities.filter((activity) => !activity.running),\n      status: \"interrupted\",\n    }));\n    finish();\n  }, [finish, patch]);\n\n  const send = useCallback(\n    async (text: string) => {\n      const reply = replies[replyRef.current % replies.length];\n      if (activeRef.current || !reply) {\n        return;\n      }\n      replyRef.current += 1;\n      const run = runRef.current + 1;\n      runRef.current = run;\n      const alive = () => runRef.current === run;\n      const reduced = window.matchMedia(OPENCODE_REDUCED_MOTION_QUERY).matches;\n      const delay = (ms: number) =>\n        wait(reduced ? Math.min(ms, OPENCODE_CHAT_TIMING.reducedMaxMs) : ms);\n      const start = Date.now();\n      const id = `turn-${start}`;\n\n      activeRef.current = id;\n      setActiveId(id);\n      setTurns((current) => [\n        ...current,\n        { activities: [], id, prompt: text, reply: [], status: \"working\" },\n      ]);\n\n      for (const activity of reply.activities) {\n        if (!alive()) {\n          return;\n        }\n        const activityId = `${id}-${activity.id}`;\n        const isThought = activity.kind === \"thought\";\n        const thoughtStart = Date.now();\n        patch(id, (turn) => ({\n          activities: [\n            ...turn.activities,\n            { ...activity, id: activityId, pending: isThought, running: true },\n          ],\n        }));\n        // react-doctor-disable-next-line react-doctor/async-await-in-loop -- activity lines play one after another\n        await delay(\n          isThought ? OPENCODE_CHAT_TIMING.thinkMs : OPENCODE_CHAT_TIMING.toolMs\n        );\n        if (!alive()) {\n          return;\n        }\n        const duration = isThought\n          ? formatSeconds(Date.now() - thoughtStart)\n          : activity.duration;\n        patch(id, (turn) => ({\n          activities: turn.activities.map((item) =>\n            item.id === activityId\n              ? { ...item, duration, pending: false, running: false }\n              : item\n          ),\n        }));\n      }\n\n      if (!alive()) {\n        return;\n      }\n      patch(id, () => ({ status: \"streaming\" }));\n\n      for (const block of reply.reply) {\n        if (!alive()) {\n          return;\n        }\n        patch(id, (turn) => ({ reply: [...turn.reply, block] }));\n        // react-doctor-disable-next-line react-doctor/async-await-in-loop -- blocks render in order\n        await delay(OPENCODE_CHAT_TIMING.blockMs);\n      }\n\n      if (!alive()) {\n        return;\n      }\n      patch(id, () => ({\n        duration: formatSeconds(Date.now() - start),\n        status: \"done\",\n      }));\n      finish();\n    },\n    [finish, patch, replies]\n  );\n\n  return { busy: activeId !== null, send, stop, turns };\n};\n",
      "type": "registry:hook",
      "target": "components/opencode/hooks/use-opencode-chat.ts"
    },
    {
      "path": "registry/notra/opencode/examples/opencode-demo.tsx",
      "content": "\"use client\";\n\nimport { Fragment, useEffect, useLayoutEffect, useRef } from \"react\";\n\nimport { OpencodeActivity } from \"../components/opencode-activity\";\nimport { OpencodeComposer } from \"../components/opencode-composer\";\nimport { OpencodeMessage } from \"../components/opencode-message\";\nimport { OpencodeScrollArea } from \"../components/opencode-scroll-area\";\nimport { OpencodeSidebar } from \"../components/opencode-sidebar\";\nimport { OpencodeTurnFooter } from \"../components/opencode-turn-footer\";\nimport { OpencodeWindow } from \"../components/opencode-window\";\nimport {\n  OPENCODE_DEMO_SESSION,\n  OPENCODE_DEMO_TURNS,\n  OPENCODE_REPLIES,\n} from \"../constants/opencode-demo\";\nimport { useOpencodeChat } from \"../hooks/use-opencode-chat\";\nimport type {\n  OpencodeChatActivity,\n  OpencodeDemoBlock,\n  OpencodeDemoSpan,\n} from \"../types/opencode\";\n\nconst spanKey = (span: OpencodeDemoSpan, index: number) =>\n  `${index}-${typeof span === \"string\" ? span : Object.values(span)[0]}`;\n\nconst Spans = ({ spans }: { spans: OpencodeDemoSpan[] }) =>\n  spans.map((span, index) => {\n    const key = spanKey(span, index);\n    if (typeof span === \"string\") {\n      return <Fragment key={key}>{span}</Fragment>;\n    }\n    if (\"code\" in span) {\n      return <code key={key}>{span.code}</code>;\n    }\n    return <strong key={key}>{span.strong}</strong>;\n  });\n\nconst ReplyBlock = ({ block }: { block: OpencodeDemoBlock }) => {\n  if (\"heading\" in block) {\n    return <h3>{block.heading}</h3>;\n  }\n  if (\"items\" in block) {\n    return (\n      <ul>\n        {block.items.map((item) => (\n          <li key={item.id}>\n            <Spans spans={item.spans} />\n          </li>\n        ))}\n      </ul>\n    );\n  }\n  return (\n    <p>\n      <Spans spans={block.text} />\n    </p>\n  );\n};\n\nconst FOLLOW_THRESHOLD_PX = 48;\n\nconst groupActivities = (activities: OpencodeChatActivity[]) =>\n  activities.reduce<OpencodeChatActivity[][]>((groups, activity) => {\n    const last = groups.at(-1);\n    const stacks =\n      last && activity.kind !== \"thought\" && last[0]?.kind !== \"thought\";\n    if (stacks) {\n      last.push(activity);\n    } else {\n      groups.push([activity]);\n    }\n    return groups;\n  }, []);\n\nexport default function OpencodeDemo() {\n  const session = OPENCODE_DEMO_SESSION;\n  const chat = useOpencodeChat(OPENCODE_DEMO_TURNS, OPENCODE_REPLIES);\n  const scrollRef = useRef<HTMLDivElement>(null);\n  const followRef = useRef(true);\n\n  const viewportOf = () =>\n    scrollRef.current?.querySelector<HTMLElement>(\n      '[data-slot=\"opencode-scroll-area-viewport\"]'\n    );\n\n  useLayoutEffect(() => {\n    const viewport = viewportOf();\n    viewport?.scrollTo({ top: viewport.scrollHeight });\n  }, []);\n\n  useEffect(() => {\n    const viewport = viewportOf();\n    if (!viewport) {\n      return;\n    }\n    const handleScroll = () => {\n      followRef.current =\n        viewport.scrollHeight - viewport.scrollTop - viewport.clientHeight <\n        FOLLOW_THRESHOLD_PX;\n    };\n    viewport.addEventListener(\"scroll\", handleScroll, { passive: true });\n    return () => viewport.removeEventListener(\"scroll\", handleScroll);\n  }, []);\n\n  useEffect(() => {\n    if (!followRef.current) {\n      return;\n    }\n    const viewport = viewportOf();\n    viewport?.scrollTo({ top: viewport.scrollHeight });\n  }, [chat.turns]);\n\n  const handleSend = (text: string) => {\n    followRef.current = true;\n    return chat.send(text);\n  };\n\n  return (\n    <OpencodeWindow className=\"h-150\">\n      <div className=\"grid min-h-0 flex-1 md:grid-cols-[minmax(0,1fr)_minmax(16rem,30%)]\">\n        <div className=\"flex min-h-0 min-w-0 flex-col gap-[1lh] px-[2ch] pt-[1lh] pb-[0.5lh]\">\n          <OpencodeScrollArea className=\"min-h-0 flex-1\" ref={scrollRef}>\n            <div className=\"flex flex-col gap-[1lh] pr-[1.5ch]\">\n              {chat.turns.map((turn) => (\n                <Fragment key={turn.id}>\n                  <OpencodeMessage from=\"user\">{turn.prompt}</OpencodeMessage>\n                  {groupActivities(turn.activities).map((group) => (\n                    <div key={group[0]?.id}>\n                      {group.map(\n                        ({ body, id, running: _running, ...activity }) => (\n                          <OpencodeActivity key={id} {...activity}>\n                            {body}\n                          </OpencodeActivity>\n                        )\n                      )}\n                    </div>\n                  ))}\n                  {turn.reply.length > 0 && (\n                    <OpencodeMessage>\n                      {turn.reply.map((block) => (\n                        <ReplyBlock block={block} key={block.id} />\n                      ))}\n                    </OpencodeMessage>\n                  )}\n                  {(turn.status === \"done\" ||\n                    turn.status === \"interrupted\") && (\n                    <OpencodeTurnFooter\n                      agent={session.agent}\n                      duration={turn.duration}\n                      interrupted={turn.status === \"interrupted\"}\n                      model={session.model}\n                    />\n                  )}\n                </Fragment>\n              ))}\n            </div>\n          </OpencodeScrollArea>\n          <OpencodeComposer\n            agent={session.agent}\n            busy={chat.busy}\n            context={session.context}\n            cwd={session.cwd}\n            effort={session.effort}\n            model={session.model}\n            onSend={handleSend}\n            onStop={chat.stop}\n            placeholder=\"\"\n            provider={session.provider}\n          />\n        </div>\n        <OpencodeSidebar\n          branch={session.branch}\n          className=\"hidden md:flex\"\n          cwd={session.cwd}\n          servers={session.servers}\n          spent={session.spent}\n          title={session.title}\n          tokens={session.tokens}\n          used={session.used}\n          version={session.version}\n        />\n      </div>\n    </OpencodeWindow>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/opencode/examples/opencode-demo.tsx"
    },
    {
      "path": "registry/notra/opencode/hooks/use-opencode-frame.ts",
      "content": "\"use client\";\n\nimport { useEffect, useState } from \"react\";\n\nexport const useOpencodeFrame = (\n  frameCount: number,\n  intervalMs: number,\n  active: boolean\n): number => {\n  const [frame, setFrame] = useState(0);\n\n  useEffect(() => {\n    if (!active || frameCount < 2) {\n      return;\n    }\n    const timer = window.setInterval(() => {\n      setFrame((current) => (current + 1) % frameCount);\n    }, intervalMs);\n    return () => {\n      window.clearInterval(timer);\n      setFrame(0);\n    };\n  }, [active, frameCount, intervalMs]);\n\n  return active ? frame : 0;\n};\n",
      "type": "registry:hook",
      "target": "components/opencode/hooks/use-opencode-frame.ts"
    },
    {
      "path": "registry/notra/opencode/hooks/use-opencode-reduced-motion.ts",
      "content": "\"use client\";\n\nimport { useSyncExternalStore } from \"react\";\n\nimport { OPENCODE_REDUCED_MOTION_QUERY } from \"../constants/opencode\";\n\nconst subscribe = (onChange: () => void) => {\n  const media = window.matchMedia(OPENCODE_REDUCED_MOTION_QUERY);\n  media.addEventListener(\"change\", onChange);\n  return () => media.removeEventListener(\"change\", onChange);\n};\n\nconst readPreference = () =>\n  window.matchMedia(OPENCODE_REDUCED_MOTION_QUERY).matches;\n\nconst readServerPreference = () => false;\n\nexport const useOpencodeReducedMotion = (override?: boolean): boolean => {\n  const prefersReduced = useSyncExternalStore(\n    subscribe,\n    readPreference,\n    readServerPreference\n  );\n  return override ?? prefersReduced;\n};\n",
      "type": "registry:hook",
      "target": "components/opencode/hooks/use-opencode-reduced-motion.ts"
    },
    {
      "path": "registry/notra/opencode/hooks/use-opencode-sources-sequence.ts",
      "content": "\"use client\";\n\nimport { useEffect, useState } from \"react\";\n\nimport {\n  OPENCODE_SEARCH_HEADER_MS,\n  OPENCODE_SEARCH_QUERY_MS,\n  OPENCODE_SEARCH_SOURCES_MS,\n} from \"../constants/opencode\";\n\ninterface OpencodeSourcesSequence {\n  queries: number;\n  sources: boolean;\n}\n\nconst HIDDEN: OpencodeSourcesSequence = { queries: 0, sources: false };\n\nexport const useOpencodeSourcesSequence = (\n  enabled: boolean,\n  queryCount: number,\n  sourceCount: number\n): OpencodeSourcesSequence => {\n  const [sequence, setSequence] = useState(HIDDEN);\n\n  useEffect(() => {\n    if (!enabled) {\n      return;\n    }\n    const timers: number[] = [];\n    const schedule = (at: number, next: Partial<OpencodeSourcesSequence>) => {\n      timers.push(\n        window.setTimeout(() => {\n          setSequence((current) => ({ ...current, ...next }));\n        }, at)\n      );\n    };\n\n    let at = OPENCODE_SEARCH_HEADER_MS;\n    for (let shown = 1; shown <= queryCount; shown += 1) {\n      schedule(at, { queries: shown });\n      at += OPENCODE_SEARCH_QUERY_MS;\n    }\n    if (sourceCount > 0) {\n      schedule(at + OPENCODE_SEARCH_SOURCES_MS, { sources: true });\n    }\n\n    return () => {\n      for (const timer of timers) {\n        window.clearTimeout(timer);\n      }\n      setSequence(HIDDEN);\n    };\n  }, [enabled, queryCount, sourceCount]);\n\n  return sequence;\n};\n",
      "type": "registry:hook",
      "target": "components/opencode/hooks/use-opencode-sources-sequence.ts"
    }
  ],
  "cssVars": {
    "theme": {
      "color-opencode-bg": "var(--opencode-bg)",
      "color-opencode-panel": "var(--opencode-panel)",
      "color-opencode-sidebar": "var(--opencode-sidebar)",
      "color-opencode-fg": "var(--opencode-fg)",
      "color-opencode-muted": "var(--opencode-muted)",
      "color-opencode-subtle": "var(--opencode-subtle)",
      "color-opencode-blue": "var(--opencode-blue)",
      "color-opencode-orange": "var(--opencode-orange)",
      "color-opencode-green": "var(--opencode-green)",
      "color-opencode-logo-open": "var(--opencode-logo-open)",
      "color-opencode-logo-code": "var(--opencode-logo-code)",
      "color-opencode-logo-fill": "var(--opencode-logo-fill)",
      "font-opencode": "ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\", \"Courier New\", monospace"
    },
    "light": {
      "opencode-bg": "#ffffff",
      "opencode-panel": "#f5f5f5",
      "opencode-sidebar": "#fafafa",
      "opencode-fg": "#1a1a1a",
      "opencode-muted": "#6f6f6f",
      "opencode-subtle": "#e1e1e1",
      "opencode-blue": "#3b7dd8",
      "opencode-orange": "#c47a14",
      "opencode-green": "#2f8a4a",
      "opencode-logo-open": "#8a8a8a",
      "opencode-logo-code": "#1a1a1a",
      "opencode-logo-fill": "#dcdcdc"
    },
    "dark": {
      "opencode-bg": "#090909",
      "opencode-panel": "#191919",
      "opencode-sidebar": "#121212",
      "opencode-fg": "#e9e9e9",
      "opencode-muted": "#737373",
      "opencode-subtle": "#262626",
      "opencode-blue": "#3b91f9",
      "opencode-orange": "#fd9718",
      "opencode-green": "#4fd47b",
      "opencode-logo-open": "#737373",
      "opencode-logo-code": "#e9e9e9",
      "opencode-logo-fill": "#2a2a2a"
    }
  },
  "type": "registry:block"
}