{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "agent-plan",
  "type": "registry:ui",
  "title": "Agent plan",
  "description": "React AI agent plan and to-do list: pending, in progress, completed, failed and skipped tasks with subtasks, tool chips and a progress bar that fills.",
  "author": "MiniDev UI <https://ui.minidev.pro>",
  "dependencies": [
    "@base-ui/react",
    "lucide-react",
    "motion"
  ],
  "registryDependencies": [
    "utils"
  ],
  "files": [
    {
      "path": "registry/ui/agent-plan.tsx",
      "type": "registry:ui",
      "target": "components/ui/agent-plan.tsx",
      "content": "\"use client\"\nimport * as React from \"react\"\nimport { Collapsible } from \"@base-ui/react/collapsible\"\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\"\nimport { CheckIcon, ChevronDownIcon, MinusIcon, XIcon } from \"lucide-react\"\nimport { cn } from \"@/lib/utils\"\n\n/**\n * AgentPlan — an AI agent's live to-do list: tasks with statuses, subtasks, tools and a progress bar.\n *\n * Use it while an agent works through a plan, fed from a todo or plan tool call (Claude Code's\n * `TodoWrite`, Codex's `update_plan`, or your own AI SDK tool). Statuses are `pending`,\n * `in_progress`, `completed`, `failed` and `skipped`. The active row is highlighted and announced;\n * when the agent moves on, the highlight glides to the next row and the check pops in. For a log of\n * tool calls that already ran use AgentTrace; for a checklist the user ticks use OnboardingChecklist.\n *\n * @example\n * <AgentPlan\n *   title=\"Migrate billing to Stripe\"\n *   tasks={[\n *     { id: \"1\", title: \"Read the current billing module\", status: \"completed\" },\n *     { id: \"2\", title: \"Write the webhook handler\", status: \"in_progress\", tools: [\"edit_file\"] },\n *     { id: \"3\", title: \"Run the test suite\", status: \"pending\" },\n *   ]}\n * />\n */\n\ntype AgentPlanStatus = \"pending\" | \"in_progress\" | \"completed\" | \"failed\" | \"skipped\"\n\ntype AgentPlanSubtask = {\n  /** Stable key. Keep it the same across updates so rows animate in place. */\n  id: string\n  /** What the agent will do, in a few words. */\n  title: string\n  /** Where the task stands. */\n  status: AgentPlanStatus\n  /** One muted line under the title. */\n  description?: string\n  /** Tool names shown as chips when the row is expanded, e.g. `[\"read_file\", \"run_tests\"]`. */\n  tools?: string[]\n}\n\ntype AgentPlanTask = AgentPlanSubtask & {\n  /** Steps inside this task, shown when the row is expanded. */\n  subtasks?: AgentPlanSubtask[]\n}\n\ntype AgentPlanProps = {\n  /** Header label. */\n  title?: string\n  /** Tasks in plan order. */\n  tasks?: AgentPlanTask[]\n  /** Whether the task list starts expanded. */\n  defaultOpen?: boolean\n  /** Makes each task title a button. Fires with the clicked task, e.g. to scroll to its output. */\n  onTaskClick?: (task: AgentPlanTask) => void\n  className?: string\n}\n\nconst SAMPLE_TASKS: AgentPlanTask[] = [\n  { id: \"1\", title: \"Find where invoices are rendered\", status: \"completed\", tools: [\"grep\", \"read_file\"] },\n  {\n    id: \"2\",\n    title: \"Add a due date column to the invoice table\",\n    status: \"in_progress\",\n    description: \"Sortable, formatted in the customer's locale\",\n    tools: [\"edit_file\"],\n    subtasks: [\n      { id: \"2a\", title: \"Add dueDate to the Invoice type\", status: \"completed\" },\n      { id: \"2b\", title: \"Render the column\", status: \"in_progress\" },\n      { id: \"2c\", title: \"Sort by due date\", status: \"pending\" },\n    ],\n  },\n  { id: \"3\", title: \"Update the invoice snapshot tests\", status: \"pending\", tools: [\"run_tests\"] },\n  { id: \"4\", title: \"Backfill due dates for draft invoices\", status: \"skipped\", description: \"Drafts have no due date yet\" },\n]\n\nconst SNAPPY = { type: \"spring\", bounce: 0.18, duration: 0.42 } as const\n\nconst STATUS_TEXT: Record<AgentPlanStatus, string> = {\n  pending: \"pending\",\n  in_progress: \"in progress\",\n  completed: \"completed\",\n  failed: \"failed\",\n  skipped: \"skipped\",\n}\n\n/** The status glyph. A new status crossfades in; the check also pops from 60% scale. */\nfunction Glyph({ status, small, reduce }: { status: AgentPlanStatus; small?: boolean; reduce: boolean | null }) {\n  const size = small ? \"size-3.5\" : \"size-4\"\n  const icon = small ? \"size-2.5\" : \"size-3\"\n  return (\n    <span aria-hidden className={cn(\"relative grid shrink-0 place-items-center\", size)}>\n      <AnimatePresence initial={false} mode=\"popLayout\">\n        <motion.span\n          key={status}\n          initial={{ opacity: 0, scale: status === \"completed\" ? 0.6 : 1 }}\n          animate={{ opacity: 1, scale: 1 }}\n          exit={{ opacity: 0, transition: reduce ? { duration: 0 } : { duration: 0.12 } }}\n          transition={reduce ? { duration: 0 } : SNAPPY}\n          className={cn(\n            \"absolute inset-0 grid place-items-center rounded-full\",\n            status === \"pending\" && \"border-[1.5px] border-border-strong\",\n            status === \"in_progress\" && \"animate-spin border-[1.5px] border-accent-line border-t-accent\",\n            status === \"completed\" && \"bg-success text-bg\",\n            status === \"failed\" && \"bg-danger text-bg\",\n            status === \"skipped\" && \"border-[1.5px] border-dashed border-border-strong text-fg-subtle\"\n          )}\n        >\n          {status === \"completed\" ? <CheckIcon className={icon} strokeWidth={3} /> : null}\n          {status === \"failed\" ? <XIcon className={icon} strokeWidth={3} /> : null}\n          {status === \"skipped\" ? <MinusIcon className={icon} strokeWidth={2.5} /> : null}\n        </motion.span>\n      </AnimatePresence>\n    </span>\n  )\n}\n\nconst titleClass = (status: AgentPlanStatus) =>\n  cn(\n    \"transition-[color] duration-[70ms]\",\n    status === \"completed\" && \"text-fg-subtle line-through decoration-fg-subtle/60\",\n    status === \"skipped\" && \"text-fg-subtle\",\n    status === \"failed\" && \"text-fg\",\n    status === \"in_progress\" && \"font-medium text-fg\",\n    status === \"pending\" && \"text-fg-muted\"\n  )\n\nconst rowButton =\n  \"flex min-w-0 flex-1 items-start gap-2.5 rounded-md py-1 text-left outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface\"\n\nfunction AgentPlan({ title = \"Plan\", tasks = SAMPLE_TASKS, defaultOpen = true, onTaskClick, className }: AgentPlanProps) {\n  const reduce = useReducedMotion()\n  const highlightId = React.useId()\n  const counted = tasks.filter((t) => t.status !== \"skipped\")\n  const done = counted.filter((t) => t.status === \"completed\").length\n  const total = counted.length\n  const failed = tasks.some((t) => t.status === \"failed\")\n  const active = tasks.find((t) => t.status === \"in_progress\")\n  const announcement = active ? `Working on: ${active.title}` : total > 0 && done === total ? `${title} complete` : \"\"\n\n  return (\n    <Collapsible.Root\n      defaultOpen={defaultOpen}\n      data-slot=\"agent-plan\"\n      className={cn(\"w-full max-w-lg overflow-hidden rounded-xl border border-border bg-surface shadow-raised\", className)}\n    >\n      <Collapsible.Trigger\n        className={cn(\n          \"group/plan flex w-full items-center gap-2.5 px-4 pt-3 pb-2.5 text-left outline-none\",\n          \"transition-[background-color] duration-[70ms] hover:bg-sunken/60\",\n          \"focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-inset\"\n        )}\n      >\n        <span className=\"min-w-0 flex-1 truncate text-[0.8125rem] font-medium text-fg\">{title}</span>\n        <span className=\"font-mono text-[11px] tabular-nums text-fg-subtle\">\n          {done} of {total} done\n        </span>\n        <ChevronDownIcon\n          aria-hidden\n          className=\"size-4 shrink-0 text-fg-subtle transition-transform duration-200 ease-hairline group-data-[panel-open]/plan:rotate-180\"\n        />\n      </Collapsible.Trigger>\n      <div\n        role=\"progressbar\"\n        aria-label={`${title} progress`}\n        aria-valuemin={0}\n        aria-valuemax={total}\n        aria-valuenow={done}\n        aria-valuetext={`${done} of ${total} done`}\n        className=\"mx-4 mb-3 h-0.5 overflow-hidden rounded-full bg-sunken\"\n      >\n        <motion.div\n          data-slot=\"agent-plan-progress\"\n          className={cn(\"h-full origin-left rounded-full\", failed ? \"bg-danger\" : done === total && total > 0 ? \"bg-success\" : \"bg-accent\")}\n          initial={false}\n          animate={{ scaleX: total ? done / total : 0 }}\n          transition={reduce ? { duration: 0 } : SNAPPY}\n        />\n      </div>\n      <p aria-live=\"polite\" className=\"sr-only\">\n        {announcement}\n      </p>\n      <Collapsible.Panel\n        className={cn(\n          \"h-[var(--collapsible-panel-height)] overflow-hidden border-t border-border\",\n          \"transition-[height] duration-200 ease-hairline data-[ending-style]:duration-[160ms] data-[ending-style]:ease-exit\",\n          \"data-[ending-style]:h-0 data-[starting-style]:h-0\"\n        )}\n      >\n        <ol aria-label={title} className=\"isolate p-2\">\n          {tasks.map((task) => {\n            const hasDetails = !!(task.subtasks?.length || task.tools?.length)\n            const subDone = task.subtasks?.filter((s) => s.status === \"completed\").length ?? 0\n            const label = (\n              <>\n                <span className=\"pt-0.5\">\n                  <Glyph status={task.status} reduce={reduce} />\n                </span>\n                <span className=\"min-w-0 flex-1\">\n                  <span className={cn(\"block text-[0.8125rem] leading-5\", titleClass(task.status))}>{task.title}</span>\n                  {task.description ? <span className=\"block text-xs leading-[18px] text-fg-subtle\">{task.description}</span> : null}\n                  <span className=\"sr-only\">, {STATUS_TEXT[task.status]}</span>\n                </span>\n                {task.subtasks?.length ? (\n                  <span className=\"pt-0.5 font-mono text-[11px] tabular-nums text-fg-subtle\">\n                    {subDone}/{task.subtasks.length}\n                  </span>\n                ) : null}\n              </>\n            )\n            const chevron = (\n              <ChevronDownIcon\n                aria-hidden\n                className=\"mt-0.5 size-4 shrink-0 text-fg-subtle transition-transform duration-200 ease-hairline group-data-[panel-open]/row:rotate-180\"\n              />\n            )\n            return (\n              <Collapsible.Root\n                key={task.id}\n                defaultOpen={task.status === \"in_progress\" && hasDetails}\n                render={<li aria-current={task.status === \"in_progress\" ? \"step\" : undefined} />}\n                className=\"relative rounded-lg px-2 py-1\"\n              >\n                {task.status === \"in_progress\" ? (\n                  <motion.span\n                    layoutId={highlightId}\n                    aria-hidden\n                    className=\"absolute inset-0 -z-10 rounded-lg bg-sunken\"\n                    transition={reduce ? { duration: 0 } : SNAPPY}\n                  />\n                ) : null}\n                <div className=\"flex items-start gap-1\">\n                  {onTaskClick ? (\n                    <button type=\"button\" onClick={() => onTaskClick(task)} className={cn(rowButton, \"cursor-pointer\")}>\n                      {label}\n                    </button>\n                  ) : hasDetails ? (\n                    <Collapsible.Trigger className={cn(rowButton, \"group/row cursor-pointer\")}>\n                      {label}\n                      {chevron}\n                    </Collapsible.Trigger>\n                  ) : (\n                    <div className=\"flex min-w-0 flex-1 items-start gap-2.5 py-1\">{label}</div>\n                  )}\n                  {onTaskClick && hasDetails ? (\n                    <Collapsible.Trigger\n                      aria-label={`Details: ${task.title}`}\n                      className=\"group/row grid size-7 shrink-0 cursor-pointer place-items-center rounded-md outline-none transition-[background-color] duration-[70ms] hover:bg-sunken focus-visible:ring-2 focus-visible:ring-accent\"\n                    >\n                      {chevron}\n                    </Collapsible.Trigger>\n                  ) : null}\n                </div>\n                {hasDetails ? (\n                  <Collapsible.Panel\n                    className={cn(\n                      \"h-[var(--collapsible-panel-height)] overflow-hidden\",\n                      \"transition-[height] duration-200 ease-hairline data-[ending-style]:duration-[160ms] data-[ending-style]:ease-exit\",\n                      \"data-[ending-style]:h-0 data-[starting-style]:h-0\"\n                    )}\n                  >\n                    <div className=\"pt-1 pb-1.5 pl-[26px]\">\n                      {task.subtasks?.length ? (\n                        <ul aria-label={`Steps in ${task.title}`} className=\"space-y-1\">\n                          {task.subtasks.map((s) => (\n                            <li key={s.id} className=\"flex items-start gap-2\">\n                              <span className=\"pt-[3px]\">\n                                <Glyph status={s.status} small reduce={reduce} />\n                              </span>\n                              <span className=\"min-w-0 flex-1 text-xs leading-5\">\n                                <span className={titleClass(s.status)}>{s.title}</span>\n                                <span className=\"sr-only\">, {STATUS_TEXT[s.status]}</span>\n                                {s.description ? <span className=\"block leading-[18px] text-fg-subtle\">{s.description}</span> : null}\n                              </span>\n                            </li>\n                          ))}\n                        </ul>\n                      ) : null}\n                      {task.tools?.length ? (\n                        <ul aria-label=\"Tools\" className={cn(\"flex flex-wrap gap-1\", task.subtasks?.length && \"mt-2\")}>\n                          {task.tools.map((tool) => (\n                            <li\n                              key={tool}\n                              className=\"rounded-md border border-border bg-sunken px-1.5 py-0.5 font-mono text-[11px] leading-4 text-fg-muted\"\n                            >\n                              {tool}\n                            </li>\n                          ))}\n                        </ul>\n                      ) : null}\n                    </div>\n                  </Collapsible.Panel>\n                ) : null}\n              </Collapsible.Root>\n            )\n          })}\n        </ol>\n      </Collapsible.Panel>\n    </Collapsible.Root>\n  )\n}\n\nexport { AgentPlan }\nexport type { AgentPlanProps, AgentPlanTask, AgentPlanSubtask, AgentPlanStatus }\n"
    }
  ],
  "categories": [
    "ai-chat"
  ],
  "docs": "import { AgentPlan } from \"@/components/ui/agent-plan\"\nNeeds the MiniDev tokens stylesheet (https://ui.minidev.pro/r/styles.css) imported after Tailwind.\nDocs: https://ui.minidev.pro/docs/agent-plan · Markdown for agents: https://ui.minidev.pro/docs/agent-plan.md",
  "meta": {
    "tier": "free",
    "kind": "ui",
    "category": "ai-chat",
    "import": "@/components/ui/agent-plan",
    "npmImport": "minidev-ui-kit/ui/agent-plan",
    "exports": [
      "AgentPlan"
    ],
    "related": [
      "agent-trace",
      "onboarding-checklist"
    ],
    "docsUrl": "https://ui.minidev.pro/docs/agent-plan",
    "markdownUrl": "https://ui.minidev.pro/docs/agent-plan.md",
    "keywords": [
      "ai agent todo list react",
      "agent plan component",
      "ai task list ui"
    ]
  }
}
