{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "tool-group",
  "title": "Tool Group",
  "description": "Consecutive tool calls in one readable group with collapsible outputs for each call.",
  "dependencies": [
    "@solar-icons/react@^2.2.0",
    "cn@^0.3.0",
    "motion@^13.4.0",
    "prism-react-renderer@^2.4.1"
  ],
  "registryDependencies": [
    "button",
    "https://pastaui.com/r/pastaui-styles.json"
  ],
  "files": [
    {
      "path": "src/components/ai/tool-group.tsx",
      "content": "import { AltArrowRightIcon as ChevronRightIcon } from '@solar-icons/react/linear/alt-arrow-right'\nimport { FilePenIcon } from '@solar-icons/react/linear/file-pen'\nimport { StarsMinimalisticIcon as SparklesIcon } from '@solar-icons/react/linear/stars-minimalistic'\nimport { ProgrammingIcon as TerminalIcon } from '@solar-icons/react/linear/programming'\nimport { ToolboxIcon as WrenchIcon } from '@solar-icons/react/linear/toolbox'\nimport { LoaderIcon } from '@solar-icons/react/linear/loader'\nimport { AnimatePresence, LazyMotion, domAnimation, useReducedMotion } from 'motion/react'\nimport * as m from 'motion/react-m'\nimport * as React from 'react'\n\nimport { ToolGroupOutput } from '@/components/ai/tool-group-output'\nimport { Button } from '@/components/ui/button'\nimport { cn } from 'cn'\n\ntype ToolGroupItemKind = 'command' | 'file' | 'tool'\n\ninterface ToolGroupItem {\n  id: string\n  kind?: ToolGroupItemKind\n  name: string\n  output?: string\n  outputLanguage?: string\n  status: 'complete' | 'running'\n}\n\ninterface ToolGroupProps extends React.ComponentProps<'section'> {\n  defaultExpandedIds?: string[]\n  duration?: string\n  items: ToolGroupItem[]\n  onOpenChange?: (open: boolean) => void\n  open?: boolean\n  title?: string\n}\n\nconst ease = [0.23, 1, 0.32, 1] as const\nconst spring = { type: 'spring', stiffness: 500, damping: 30 } as const\nconst shimmer = 'agent-text-shimmer'\n\nfunction DoneCheck() {\n  return (\n    <svg aria-hidden=\"true\" className=\"size-4 text-emerald-500\" viewBox=\"0 0 16 16\">\n      <circle cx=\"8\" cy=\"8\" fill=\"currentColor\" r=\"7.5\" />\n      <m.path\n        animate={{ pathLength: 1 }}\n        d=\"M5 8.25 7 10.25 11 6\"\n        fill=\"none\"\n        initial={{ pathLength: 0 }}\n        stroke=\"white\"\n        strokeLinecap=\"round\"\n        strokeLinejoin=\"round\"\n        strokeWidth=\"1.5\"\n        transition={{ delay: 0.1, duration: 0.3, ease }}\n      />\n    </svg>\n  )\n}\n\nfunction ToolGroup({\n  className,\n  defaultExpandedIds = [],\n  duration,\n  items,\n  onOpenChange,\n  open = false,\n  title = 'Tool calls',\n  ...props\n}: ToolGroupProps) {\n  const shouldReduceMotion = useReducedMotion()\n  const running = items.some((item) => item.status === 'running')\n  const [expanded, setExpanded] = React.useState(() => new Set(defaultExpandedIds))\n  const seen = React.useRef(new Set<string>())\n\n  React.useEffect(() => {\n    const fresh = items.filter((item) => item.output && !seen.current.has(item.id))\n    if (!fresh.length) return\n    fresh.forEach((item) => seen.current.add(item.id))\n    setExpanded(new Set([fresh.at(-1)!.id]))\n  }, [items])\n\n  function toggleItem(id: string) {\n    setExpanded((current) => {\n      const next = new Set(current)\n      if (next.has(id)) next.delete(id)\n      else next.add(id)\n      return next\n    })\n  }\n\n  return (\n    <section\n      data-slot=\"tool-group\"\n      className={cn(\n        'bg-transparent font-sans text-sm font-[450] tracking-[-0.05px] text-muted-foreground',\n        className,\n      )}\n      {...props}\n    >\n      <LazyMotion features={domAnimation} strict>\n        <header className=\"grid grid-cols-[minmax(0,1fr)_auto_auto] items-center gap-3 px-1\">\n          <div className=\"flex min-w-0 items-center gap-3\">\n            <span className=\"flex size-5 shrink-0 -translate-y-px items-center justify-center text-muted-foreground\">\n              <SparklesIcon\n                className={cn(\n                  'size-5 [&_*]:[stroke-width:1.5]',\n                  running && 'animate-pulse motion-reduce:animate-none',\n                )}\n              />\n            </span>\n            <AnimatePresence initial={false} mode=\"popLayout\">\n              <m.h3\n                animate={{ opacity: 1, y: 0 }}\n                className=\"truncate card-heading leading-5\"\n                exit={{ opacity: 0, y: -6 }}\n                initial={{ opacity: 0, y: 6 }}\n                key={title}\n                transition={{ duration: 0.2, ease }}\n              >\n                {title}\n              </m.h3>\n            </AnimatePresence>\n          </div>\n          <Button\n            aria-label={open ? 'Collapse tool calls' : 'Expand tool calls'}\n            aria-expanded={open}\n            className=\"aria-expanded:bg-transparent\"\n            onClick={() => onOpenChange?.(!open)}\n            size=\"icon-sm\"\n            type=\"button\"\n            variant=\"ghost\"\n          >\n            <ChevronRightIcon\n              className={cn(\n                'size-4 transition-[rotate] duration-200 ease-[cubic-bezier(0.23,1,0.32,1)] motion-reduce:transition-none [&_*]:[stroke-width:1.5]',\n                open && 'rotate-90',\n              )}\n            />\n          </Button>\n          {duration && (\n            <span className=\"min-w-14 text-right text-xs leading-5 text-muted-foreground tabular-nums\">\n              {duration}\n            </span>\n          )}\n        </header>\n        <AnimatePresence initial={false}>\n          {open && (\n            <m.div\n              animate={shouldReduceMotion ? { opacity: 1 } : { height: 'auto', opacity: 1 }}\n              className=\"overflow-hidden\"\n              exit={shouldReduceMotion ? { opacity: 0 } : { height: 0, opacity: 0 }}\n              initial={shouldReduceMotion ? { opacity: 0 } : { height: 0, opacity: 0 }}\n              key=\"tool-group-disclosure\"\n              transition={shouldReduceMotion ? { duration: 0.12 } : { duration: 0.2, ease }}\n            >\n              <ol className=\"px-1 pt-4\">\n                <AnimatePresence initial={false}>\n                  {items.map((item, index) => {\n                    const ItemIcon =\n                      item.kind === 'command'\n                        ? TerminalIcon\n                        : item.kind === 'file'\n                          ? FilePenIcon\n                          : WrenchIcon\n\n                    return (\n                      <m.li\n                        animate={{ opacity: 1, y: 0 }}\n                        className=\"relative grid grid-cols-[1.25rem_minmax(0,1fr)] gap-x-3 pb-4 last:pb-0\"\n                        exit={{ opacity: 0 }}\n                        initial={shouldReduceMotion ? { opacity: 0 } : { opacity: 0, y: 8 }}\n                        key={item.id}\n                        transition={{ duration: 0.3, ease }}\n                      >\n                        {(index < items.length - 1 || !running) && (\n                          <m.span\n                            animate={{ scaleY: 1 }}\n                            aria-hidden=\"true\"\n                            className=\"absolute top-6 bottom-0 left-2.5 w-px origin-top -translate-x-1/2 bg-border\"\n                            initial={{ scaleY: 0 }}\n                            transition={{ duration: 0.35, ease }}\n                          />\n                        )}\n                        <span className=\"relative flex size-5 items-center justify-center text-muted-foreground\">\n                          <AnimatePresence initial={false} mode=\"popLayout\">\n                            <m.span\n                              animate={{ opacity: 1, scale: 1 }}\n                              className=\"flex\"\n                              exit={{ opacity: 0, scale: 0.6 }}\n                              initial={{ opacity: 0, scale: 0.6 }}\n                              key={item.status}\n                              transition={spring}\n                            >\n                              {item.status === 'running' ? (\n                                <LoaderIcon className=\"size-4 animate-spin motion-reduce:animate-none\" />\n                              ) : (\n                                <ItemIcon className=\"size-4 [&_*]:[stroke-width:1.5]\" />\n                              )}\n                            </m.span>\n                          </AnimatePresence>\n                          <span className=\"sr-only\">{item.status}</span>\n                        </span>\n                        {item.output ? (\n                          <button\n                            aria-expanded={expanded.has(item.id)}\n                            className=\"group/row -mx-1 flex min-w-0 items-center gap-1.5 rounded-md px-1 text-left text-sm transition-colors outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/40\"\n                            onClick={() => toggleItem(item.id)}\n                            type=\"button\"\n                          >\n                            <span className=\"min-w-0 truncate\">{item.name}</span>\n                            <ChevronRightIcon\n                              className={cn(\n                                'size-3.5 shrink-0 opacity-60 transition-[rotate,opacity] duration-200 ease-[cubic-bezier(0.23,1,0.32,1)] group-hover/row:opacity-100 motion-reduce:transition-none [&_*]:[stroke-width:1.5]',\n                                expanded.has(item.id) && 'rotate-90',\n                              )}\n                            />\n                          </button>\n                        ) : (\n                          <p\n                            className={cn(\n                              'min-w-0 truncate text-sm transition-colors duration-300',\n                              item.status === 'running' && shimmer,\n                            )}\n                          >\n                            {item.name}\n                          </p>\n                        )}\n                        <AnimatePresence initial={false}>\n                          {item.output && expanded.has(item.id) && (\n                            <m.div\n                              animate={{ height: 'auto', opacity: 1 }}\n                              className=\"col-span-2 overflow-hidden\"\n                              exit={{ height: 0, opacity: 0 }}\n                              initial={{ height: 0, opacity: 0 }}\n                              transition={{ duration: 0.3, ease }}\n                            >\n                              <ToolGroupOutput\n                                className=\"mx-px mt-3 mb-px\"\n                                code={item.output}\n                                language={item.outputLanguage}\n                              />\n                            </m.div>\n                          )}\n                        </AnimatePresence>\n                      </m.li>\n                    )\n                  })}\n                  {!running && items.length > 0 && (\n                    <m.li\n                      animate={{ opacity: 1, y: 0 }}\n                      className=\"grid grid-cols-[1.25rem_minmax(0,1fr)] items-center gap-3 pt-1\"\n                      exit={{ opacity: 0 }}\n                      initial={shouldReduceMotion ? { opacity: 0 } : { opacity: 0, y: 8 }}\n                      key=\"done\"\n                      transition={{ duration: 0.3, ease }}\n                    >\n                      <m.span\n                        animate={{ scale: 1 }}\n                        className=\"flex size-5 items-center justify-center\"\n                        initial={{ scale: 0.5 }}\n                        transition={spring}\n                      >\n                        <DoneCheck />\n                      </m.span>\n                      <span className=\"text-sm\">Done</span>\n                    </m.li>\n                  )}\n                </AnimatePresence>\n              </ol>\n            </m.div>\n          )}\n        </AnimatePresence>\n      </LazyMotion>\n    </section>\n  )\n}\n\nexport { ToolGroup }\nexport type { ToolGroupItemKind, ToolGroupItem, ToolGroupProps }\nexport default ToolGroup\n",
      "type": "registry:component",
      "target": "@components/ai/tool-group.tsx"
    },
    {
      "path": "src/components/ai/tool-group-output.tsx",
      "content": "import { CheckCircleIcon as CheckIcon } from '@solar-icons/react/linear/check-circle'\nimport { CopyIcon } from '@solar-icons/react/linear/copy'\nimport { Highlight, type PrismTheme } from 'prism-react-renderer'\nimport * as React from 'react'\nimport { useState } from 'react'\n\nimport { Button } from '@/components/ui/button'\nimport { cn } from 'cn'\n\nconst codeTheme: PrismTheme = {\n  plain: {\n    backgroundColor: 'transparent',\n    color: 'var(--foreground)',\n  },\n  styles: [\n    {\n      types: ['comment', 'prolog', 'doctype', 'cdata'],\n      style: { color: 'var(--syntax-comment)', fontStyle: 'italic' },\n    },\n    {\n      types: ['keyword', 'atrule'],\n      style: { color: 'var(--syntax-keyword)' },\n    },\n    {\n      types: ['string', 'char', 'attr-value', 'inserted'],\n      style: { color: 'var(--syntax-string)' },\n    },\n    {\n      types: ['function', 'class-name'],\n      style: { color: 'var(--syntax-function)' },\n    },\n    {\n      types: ['number', 'boolean', 'constant'],\n      style: { color: 'var(--syntax-number)' },\n    },\n    {\n      types: ['tag', 'property', 'attr-name', 'selector', 'symbol', 'deleted'],\n      style: { color: 'var(--syntax-property)' },\n    },\n    {\n      types: ['punctuation', 'operator'],\n      style: { color: 'var(--syntax-punctuation)' },\n    },\n  ],\n}\n\ninterface ToolGroupOutputProps extends React.ComponentProps<'figure'> {\n  code: string\n  language?: string\n}\n\nfunction ToolGroupOutput({ className, code, language = 'json', ...props }: ToolGroupOutputProps) {\n  const [copied, setCopied] = useState(false)\n  const syntaxLanguage = language === 'shell' ? 'bash' : language\n\n  async function copyOutput() {\n    await navigator.clipboard.writeText(code)\n    setCopied(true)\n    window.setTimeout(() => setCopied(false), 1400)\n  }\n\n  return (\n    <figure\n      className={cn('relative z-10 overflow-hidden rounded-[16px] bg-card shadow-card', className)}\n      {...props}\n    >\n      <figcaption className=\"flex h-10 items-center px-4 text-xs leading-5 font-[450] text-muted-foreground uppercase\">\n        {language}\n        <Button\n          aria-label={copied ? 'Copied output' : 'Copy output'}\n          className=\"ml-auto\"\n          onClick={copyOutput}\n          size=\"icon-sm\"\n          title={copied ? 'Copied' : 'Copy'}\n          type=\"button\"\n          variant=\"ghost\"\n        >\n          <span className=\"grid *:col-start-1 *:row-start-1 *:transition-[opacity,scale] *:duration-150 *:ease-[cubic-bezier(0.23,1,0.32,1)] motion-reduce:*:transition-opacity\">\n            <CopyIcon\n              className={cn('size-4 [&_*]:[stroke-width:1.5]', copied && 'scale-75 opacity-0')}\n            />\n            <CheckIcon\n              className={cn('size-4 [&_*]:[stroke-width:1.5]', !copied && 'scale-75 opacity-0')}\n            />\n          </span>\n        </Button>\n      </figcaption>\n      <Highlight code={code.trim()} language={syntaxLanguage} theme={codeTheme}>\n        {({ getLineProps, getTokenProps, style, tokens }) => (\n          <pre className=\"overflow-x-auto px-4 pt-1 pb-4 font-mono text-xs leading-6\" style={style}>\n            <code>\n              {tokens.map((line, lineIndex) => (\n                <span {...getLineProps({ line })} className=\"block min-w-max\" key={lineIndex}>\n                  {line.map((token, tokenIndex) => (\n                    <span {...getTokenProps({ token })} key={tokenIndex} />\n                  ))}\n                </span>\n              ))}\n            </code>\n          </pre>\n        )}\n      </Highlight>\n    </figure>\n  )\n}\n\nexport { ToolGroupOutput }\nexport type { ToolGroupOutputProps }\n",
      "type": "registry:component",
      "target": "@components/ai/tool-group-output.tsx"
    }
  ],
  "css": {
    ".agent-text-shimmer": {
      "color": "transparent",
      "background-image": "linear-gradient( 90deg, var(--muted-foreground), var(--foreground), var(--muted-foreground) )",
      "background-size": "200% 100%",
      "background-clip": "text",
      "animation": "agent-text-shimmer 1.6s linear infinite"
    },
    "@keyframes agent-text-shimmer": {
      "from": {
        "background-position": "200% 0"
      },
      "to": {
        "background-position": "-200% 0"
      }
    },
    "@media (prefers-reduced-motion: reduce)": {
      ".agent-text-shimmer": {
        "color": "var(--muted-foreground)",
        "background-image": "none",
        "animation": "none"
      }
    }
  },
  "type": "registry:component"
}