{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "agent-review-01",
  "title": "Task to merge",
  "description": "A task laid out like an issue: the status chip rolls from Planned to Merged while the activity grows, one approval starts the work, a failed check is re-run and Merge becomes Merging, then Merged.",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "https://ui.ndekocode.dev/r/agent-run.json",
    "https://ui.ndekocode.dev/r/avatar.json",
    "https://ui.ndekocode.dev/r/badge.json",
    "https://ui.ndekocode.dev/r/brand-tile.json",
    "https://ui.ndekocode.dev/r/button.json",
    "https://ui.ndekocode.dev/r/call-status.json",
    "https://ui.ndekocode.dev/r/chat-motion.json",
    "https://ui.ndekocode.dev/r/chip.json",
    "https://ui.ndekocode.dev/r/demonstration.json",
    "https://ui.ndekocode.dev/r/icons.json",
    "https://ui.ndekocode.dev/r/live-duration.json",
    "https://ui.ndekocode.dev/r/live-region.json",
    "https://ui.ndekocode.dev/r/mesh-tile.json",
    "https://ui.ndekocode.dev/r/morph-button.json",
    "https://ui.ndekocode.dev/r/motion-number.json",
    "https://ui.ndekocode.dev/r/motion-presets.json",
    "https://ui.ndekocode.dev/r/motion-word-roll.json",
    "https://ui.ndekocode.dev/r/replay-button.json",
    "https://ui.ndekocode.dev/r/theme.json",
    "https://ui.ndekocode.dev/r/use-prefers-reduced-motion.json",
    "https://ui.ndekocode.dev/r/use-session.json"
  ],
  "files": [
    {
      "path": "registry/ndeko/blocks/agent-review/agent-review-01/index.tsx",
      "content": "'use client';\n\nimport { WordRoll } from '@/components/core/word-roll';\nimport { useSession } from '@/registry/ndeko/hooks/use-session';\nimport {\n  pressedSolidOf,\n  spokenUnless,\n} from '@/registry/ndeko/lib/demonstration';\nimport { GitBranchIcon, GitMergeIcon } from '@/registry/ndeko/lib/icons';\nimport { Button } from '@/registry/ndeko/ui/button';\nimport { Swap } from '@/registry/ndeko/ui/chat-motion';\nimport { Chip } from '@/registry/ndeko/ui/chip';\nimport { ClockGate } from '@/registry/ndeko/ui/live-duration';\nimport { LiveRegion } from '@/registry/ndeko/ui/live-region';\nimport { MorphButton, type MorphState } from '@/registry/ndeko/ui/morph-button';\nimport { ReplayButton } from '@/registry/ndeko/ui/replay-button';\n\nimport { ChecksBox } from './checks';\nimport { CODER, ISSUE } from './data';\nimport {\n  allChecksPassed,\n  INITIAL,\n  LOOP_AFTER_MS,\n  reducer,\n  RESTING,\n  SCRIPT,\n  type IssueStatus,\n  type MergeStatus,\n  type PlanStatus,\n} from './session';\nimport { CoderTile, Timeline } from './timeline';\n\nconst SESSION = {\n  reducer,\n  initial: INITIAL,\n  resting: RESTING,\n  script: SCRIPT,\n  loopAfter: LOOP_AFTER_MS,\n};\n\nconst STATUS_WORD: Record<IssueStatus, string> = {\n  planned: 'Planned',\n  progress: 'In progress',\n  review: 'In review',\n  merged: 'Merged',\n};\n\nconst STATUS_LABELS = Object.values(STATUS_WORD);\n\nconst STATUS_COLOR: Record<IssueStatus, string> = {\n  planned: 'var(--muted-foreground)',\n  progress: 'var(--info)',\n  review: 'var(--warning)',\n  merged: 'var(--success)',\n};\n\nconst MERGE_LABELS: Record<MorphState, string> = {\n  idle: 'Merge pull request',\n  busy: 'Merging',\n  done: 'Merged',\n};\n\nfunction mergeHintOf(plan: PlanStatus, canMerge: boolean, merge: MergeStatus) {\n  if (merge === 'done') {\n    return 'Merged into main';\n  }\n  if (plan === 'pending') {\n    return 'Starts with your approval of the plan';\n  }\n  if (plan === 'changes') {\n    return 'Stopped: the plan needs a new brief';\n  }\n  if (canMerge) {\n    return 'Every check passed';\n  }\n  return 'Available once every check passes';\n}\n\nfunction branchWordOf(isDeleted: boolean) {\n  if (isDeleted) {\n    return 'Deleted';\n  }\n  return 'Open';\n}\n\nfunction StatusChip({ status }: { status: IssueStatus }) {\n  return (\n    <Chip\n      color={STATUS_COLOR[status]}\n      className='transition-colors duration-300'\n    >\n      <WordRoll text={STATUS_WORD[status]} labels={STATUS_LABELS} />\n    </Chip>\n  );\n}\n\nfunction PropertyRow({\n  label,\n  children,\n}: {\n  label: string;\n  children: React.ReactNode;\n}) {\n  return (\n    <div className='flex min-h-8 items-center gap-3 text-[13px]'>\n      <dt className='text-muted-foreground w-20 shrink-0'>{label}</dt>\n      <dd className='flex min-w-0 flex-1 items-center gap-2'>{children}</dd>\n    </div>\n  );\n}\n\nexport default function AgentReview01() {\n  const {\n    ref,\n    isInView,\n    isAutoplaying,\n    state,\n    act,\n    pressed,\n    isFinished,\n    restart,\n  } = useSession(SESSION);\n  const canMerge = allChecksPassed(state.checks);\n  const mergeHint = mergeHintOf(state.plan, canMerge, state.merge);\n  const hasStopped = state.plan === 'changes';\n  const isOver = isFinished || hasStopped;\n  const canReplay = isOver && !isAutoplaying;\n  const hasActivity = state.events.length > 0;\n  const branchWord = branchWordOf(state.isBranchDeleted);\n  const announcement = `${ISSUE.id} is ${STATUS_WORD[state.status]}. ${mergeHint}`;\n  const message = spokenUnless(isAutoplaying, announcement);\n\n  return (\n    <ClockGate isActive={isInView}>\n      <div\n        ref={ref}\n        className='bg-background text-foreground @container min-h-dvh w-full p-4 @3xl:p-8'\n      >\n        <div className='mx-auto flex max-w-5xl flex-col gap-6'>\n          <header className='flex flex-col gap-2'>\n            <div className='flex flex-wrap items-center gap-2'>\n              <span className='text-muted-foreground font-mono text-xs'>\n                {ISSUE.id}\n              </span>\n              <StatusChip status={state.status} />\n              <span className='ms-auto'>\n                <ReplayButton\n                  isShown={canReplay}\n                  onReplay={restart}\n                  label='Replay the task'\n                />\n              </span>\n            </div>\n            <h1 className='text-2xl font-semibold text-balance'>\n              {ISSUE.title}\n            </h1>\n          </header>\n\n          <div className='flex flex-col gap-6 @3xl:flex-row @3xl:items-start'>\n            <main className='flex min-w-0 flex-1 flex-col gap-6'>\n              <section aria-label='Request' className='flex flex-col gap-1.5'>\n                <h2 className='text-muted-foreground text-xs'>Request</h2>\n                <p className='text-sm leading-relaxed'>{ISSUE.request}</p>\n              </section>\n              <section className='flex flex-col gap-3'>\n                <h2 className='text-muted-foreground text-xs'>Activity</h2>\n                {!hasActivity && (\n                  <p className='text-muted-foreground text-[13px]'>\n                    Nothing yet. Coder starts with a plan for you to approve.\n                  </p>\n                )}\n                <Timeline\n                  events={state.events}\n                  plan={state.plan}\n                  pressed={pressed}\n                  onDecide={(decision) =>\n                    act({ type: 'planDecided', decision })\n                  }\n                />\n              </section>\n            </main>\n\n            <aside className='bg-card hairline-ring ring-border dark:bg-foreground/[0.03] flex flex-col gap-5 rounded-xl p-4 shadow-[0_1px_2px_rgb(0_0_0/0.04)] @3xl:w-80 @3xl:shrink-0'>\n              <dl className='flex flex-col'>\n                <PropertyRow label='Assignee'>\n                  <CoderTile />\n                  {CODER.name}\n                </PropertyRow>\n                <PropertyRow label='Branch'>\n                  <GitBranchIcon className='text-muted-foreground size-3.5 shrink-0' />\n                  <code className='min-w-0 truncate font-mono text-xs'>\n                    {ISSUE.branch}\n                  </code>\n                </PropertyRow>\n                <PropertyRow label='State'>\n                  <Swap swapKey={branchWord}>{branchWord}</Swap>\n                  {state.isBranchDeleted && (\n                    <Button\n                      type='button'\n                      variant='ghost'\n                      size='sm'\n                      onClick={() => act({ type: 'branch', isDeleted: false })}\n                      className='text-primary-ink -my-1 transition-opacity duration-300 starting:opacity-0'\n                    >\n                      Restore\n                    </Button>\n                  )}\n                </PropertyRow>\n              </dl>\n\n              <ChecksBox checks={state.checks} />\n\n              <div className='flex flex-col gap-2'>\n                <MorphButton\n                  type='button'\n                  size='lg'\n                  state={state.merge}\n                  labels={MERGE_LABELS}\n                  idleIcon={<GitMergeIcon />}\n                  disabled={!canMerge}\n                  onClick={() => act({ type: 'merge' })}\n                  className={pressedSolidOf(pressed === 'merge')}\n                />\n                <p className='text-muted-foreground text-center text-xs'>\n                  <Swap swapKey={mergeHint}>{mergeHint}</Swap>\n                </p>\n              </div>\n            </aside>\n          </div>\n        </div>\n        <LiveRegion message={message} />\n      </div>\n    </ClockGate>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/agent-review-01/index.tsx"
    },
    {
      "path": "registry/ndeko/blocks/agent-review/agent-review-01/timeline.tsx",
      "content": "'use client';\n\nimport { AnimatePresence, motion } from 'motion/react';\n\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport { seriesColorOf } from '@/registry/ndeko/lib/agent-run';\nimport { pressedSolidOf } from '@/registry/ndeko/lib/demonstration';\nimport { rowPresenceOf } from '@/registry/ndeko/lib/motion-presets';\nimport { Avatar } from '@/registry/ndeko/ui/avatar';\nimport { BrandTile } from '@/registry/ndeko/ui/brand-tile';\nimport { Button } from '@/registry/ndeko/ui/button';\nimport { Fold } from '@/registry/ndeko/ui/chat-motion';\nimport { MeshTile } from '@/registry/ndeko/ui/mesh-tile';\n\nimport {\n  ACTIVITY,\n  CODER,\n  DIFF_STATS,\n  ISSUE,\n  PLAN_STEPS,\n  REVIEWER,\n  type Activity,\n} from './data';\nimport type { PlanDecision, PlanStatus } from './session';\n\nexport function CoderTile() {\n  const color = seriesColorOf(CODER.series);\n\n  return (\n    <MeshTile seed={CODER.name} color={color} className='size-6 rounded-md' />\n  );\n}\n\nfunction ActorMark({ actor }: { actor: Activity['actor'] }) {\n  if (actor === 'coder') {\n    return <CoderTile />;\n  }\n  return <Avatar className='size-6' seed={REVIEWER.name} />;\n}\n\nfunction actorNameOf(actor: Activity['actor']) {\n  if (actor === 'coder') {\n    return CODER.name;\n  }\n  return REVIEWER.name;\n}\n\ntype PlanBodyProps = {\n  plan: PlanStatus;\n  pressed: string | null;\n  onDecide: (decision: PlanDecision) => void;\n};\n\nfunction PlanBody({ plan, pressed, onDecide }: PlanBodyProps) {\n  const isPending = plan === 'pending';\n\n  return (\n    <div className='bg-foreground/[0.04] mt-2 flex flex-col gap-1 rounded-lg p-3'>\n      <ol className='flex flex-col gap-1.5 text-[13px]'>\n        {PLAN_STEPS.map((step, index) => (\n          <li key={step} className='flex gap-2.5'>\n            <span className='text-muted-foreground w-3 shrink-0 tabular-nums'>\n              {index + 1}\n            </span>\n            {step}\n          </li>\n        ))}\n      </ol>\n      <Fold open={isPending}>\n        <div className='flex flex-wrap items-center gap-2 pt-2'>\n          <Button\n            type='button'\n            size='sm'\n            onClick={() => onDecide('approved')}\n            className={pressedSolidOf(pressed === 'approve')}\n          >\n            Approve the plan\n          </Button>\n          <Button\n            type='button'\n            size='sm'\n            variant='outline'\n            onClick={() => onDecide('changes')}\n          >\n            Ask for changes\n          </Button>\n          <span className='text-muted-foreground text-xs'>\n            Nothing is written before you approve\n          </span>\n        </div>\n      </Fold>\n    </div>\n  );\n}\n\nfunction DiffBar() {\n  const total = DIFF_STATS.additions + DIFF_STATS.deletions;\n  const addedShare = DIFF_STATS.additions / total;\n  const addedStyle = { transform: `scaleX(${addedShare})` };\n\n  return (\n    <span\n      aria-hidden='true'\n      className='bg-destructive/50 relative h-1.5 w-16 overflow-hidden rounded-full'\n    >\n      <span\n        style={addedStyle}\n        className='bg-success absolute inset-0 origin-left'\n      />\n    </span>\n  );\n}\n\nfunction PullRequestBody() {\n  return (\n    <div className='bg-foreground/[0.04] mt-2 flex flex-wrap items-center gap-x-3 gap-y-2 rounded-lg p-3'>\n      <BrandTile brand='github' size='lg' title='GitHub' />\n      <span className='min-w-40 flex-1 text-[13px] font-medium'>\n        {ISSUE.pullRequest}\n      </span>\n      <span className='flex items-center gap-2 text-xs tabular-nums'>\n        <span className='text-success-foreground'>+{DIFF_STATS.additions}</span>\n        <span className='text-destructive-ink'>-{DIFF_STATS.deletions}</span>\n        <DiffBar />\n        <span className='text-muted-foreground'>{DIFF_STATS.files} files</span>\n      </span>\n    </div>\n  );\n}\n\nfunction EntryText({ entry }: { entry: Activity }) {\n  const name = actorNameOf(entry.actor);\n\n  if (entry.kind === 'commit') {\n    return (\n      <p className='text-[13px] leading-6'>\n        <span className='font-medium'>{name}</span>{' '}\n        <span className='text-muted-foreground'>pushed</span>{' '}\n        <code className='bg-foreground/[0.05] rounded-sm px-1 py-0.5 font-mono text-xs'>\n          {entry.hash}\n        </code>{' '}\n        {entry.text}\n      </p>\n    );\n  }\n  return (\n    <p className='text-[13px] leading-6'>\n      <span className='font-medium'>{name}</span>{' '}\n      <span className='text-muted-foreground'>{entry.text}</span>\n    </p>\n  );\n}\n\ntype TimelineProps = PlanBodyProps & {\n  events: string[];\n};\n\nexport function Timeline({ events, plan, pressed, onDecide }: TimelineProps) {\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const rowPresence = rowPresenceOf(shouldReduceMotion);\n  const lastId = events.at(-1);\n\n  return (\n    <ol aria-label='Activity' className='flex flex-col'>\n      <AnimatePresence initial={false}>\n        {events.map((id) => {\n          const entry = ACTIVITY[id];\n          const isLast = id === lastId;\n          return (\n            <motion.li key={id} className='overflow-hidden' {...rowPresence}>\n              <div className='relative flex gap-3 pb-4'>\n                {!isLast && (\n                  <span\n                    aria-hidden='true'\n                    className='bg-border absolute top-7 bottom-1 left-3 w-px'\n                  />\n                )}\n                <ActorMark actor={entry.actor} />\n                <div className='min-w-0 flex-1'>\n                  <EntryText entry={entry} />\n                  {entry.kind === 'plan' && (\n                    <PlanBody\n                      plan={plan}\n                      pressed={pressed}\n                      onDecide={onDecide}\n                    />\n                  )}\n                  {entry.kind === 'pull-request' && <PullRequestBody />}\n                </div>\n              </div>\n            </motion.li>\n          );\n        })}\n      </AnimatePresence>\n    </ol>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/agent-review-01/timeline.tsx"
    },
    {
      "path": "registry/ndeko/blocks/agent-review/agent-review-01/checks.tsx",
      "content": "'use client';\n\nimport { MotionNumber } from '@/components/core/motion-number';\nimport { Badge } from '@/registry/ndeko/ui/badge';\nimport { CallStatusMark } from '@/registry/ndeko/ui/call-status';\nimport { LiveDuration } from '@/registry/ndeko/ui/live-duration';\n\nimport { CHECKS, type CheckId } from './data';\nimport { passedCountOf, type Check } from './session';\n\nfunction fillOf(passed: number) {\n  const share = passed / CHECKS.length;\n  return { transform: `scaleX(${share})` };\n}\n\nfunction CheckRow({ name, check }: { name: string; check: Check }) {\n  const isRunning = check.status === 'running';\n  const isRerun = check.attempt > 1;\n\n  return (\n    <li className='flex h-9 items-center gap-2.5 text-[13px]'>\n      <CallStatusMark status={check.status} />\n      <span className='min-w-0 flex-1 truncate'>{name}</span>\n      {isRerun && (\n        <Badge\n          variant='secondary'\n          className='transition-opacity duration-300 starting:opacity-0'\n        >\n          Run {check.attempt}\n        </Badge>\n      )}\n      <LiveDuration\n        item={check}\n        isRunning={isRunning}\n        className='text-muted-foreground w-10 shrink-0 text-end text-xs'\n      />\n    </li>\n  );\n}\n\ntype ChecksBoxProps = {\n  checks: Record<CheckId, Check> | null;\n};\n\nexport function ChecksBox({ checks }: ChecksBoxProps) {\n  const passed = passedCountOf(checks);\n\n  return (\n    <section aria-label='Checks' className='flex flex-col gap-3'>\n      <div className='flex items-end justify-between gap-3'>\n        <h3 className='text-sm font-medium'>Checks</h3>\n        <p className='text-muted-foreground text-xs'>\n          <MotionNumber\n            value={passed}\n            className='text-foreground text-xl leading-none font-semibold'\n          />{' '}\n          of {CHECKS.length} passed\n        </p>\n      </div>\n      <div\n        role='progressbar'\n        aria-label='Checks passed'\n        aria-valuemin={0}\n        aria-valuemax={CHECKS.length}\n        aria-valuenow={passed}\n        className='bg-foreground/[0.06] h-1.5 overflow-hidden rounded-full'\n      >\n        <div\n          style={fillOf(passed)}\n          className='bg-success h-full origin-left rounded-full transition-transform duration-500 ease-(--ease-out-strong)'\n        />\n      </div>\n      {!checks && (\n        <p className='text-muted-foreground text-[13px]'>\n          Checks start when the pull request opens\n        </p>\n      )}\n      {checks && (\n        <ul className='flex flex-col'>\n          {CHECKS.map((check) => (\n            <CheckRow\n              key={check.id}\n              name={check.name}\n              check={checks[check.id]}\n            />\n          ))}\n        </ul>\n      )}\n    </section>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/agent-review-01/checks.tsx"
    },
    {
      "path": "registry/ndeko/blocks/agent-review/agent-review-01/session.ts",
      "content": "import type { SessionStep } from '@/registry/ndeko/hooks/use-session';\nimport type { CallStatus } from '@/registry/ndeko/lib/agent-run';\n\nimport type { CheckId } from './data';\n\nexport type IssueStatus = 'planned' | 'progress' | 'review' | 'merged';\n\nexport type PlanStatus = 'pending' | 'approved' | 'changes';\n\nexport type MergeStatus = 'idle' | 'busy' | 'done';\n\nexport type Check = {\n  status: CallStatus;\n  attempt: number;\n  startedAt?: number;\n  endedAt?: number;\n};\n\nexport type TaskState = {\n  status: IssueStatus;\n  events: string[];\n  plan: PlanStatus;\n  checks: Record<CheckId, Check> | null;\n  merge: MergeStatus;\n  isBranchDeleted: boolean;\n};\n\nexport type PlanDecision = 'approved' | 'changes';\n\nexport type TaskAction =\n  | { type: 'event'; id: string }\n  | { type: 'status'; status: IssueStatus }\n  | { type: 'planDecided'; decision: PlanDecision }\n  | { type: 'checksStarted' }\n  | { type: 'check'; id: CheckId; status: CallStatus }\n  | { type: 'rerun'; id: CheckId }\n  | { type: 'merge' }\n  | { type: 'merged' }\n  | { type: 'branch'; isDeleted: boolean }\n  | { type: 'work'; actions: TaskAction[] };\n\ntype Step = SessionStep<TaskState, TaskAction>;\n\nexport const INITIAL: TaskState = {\n  status: 'planned',\n  events: [],\n  plan: 'pending',\n  checks: null,\n  merge: 'idle',\n  isBranchDeleted: false,\n};\n\nexport function allChecksPassed(checks: Record<CheckId, Check> | null) {\n  if (!checks) {\n    return false;\n  }\n  const all = Object.values(checks);\n  return all.every((check) => check.status === 'done');\n}\n\nexport function passedCountOf(checks: Record<CheckId, Check> | null) {\n  if (!checks) {\n    return 0;\n  }\n  const all = Object.values(checks);\n  const passed = all.filter((check) => check.status === 'done');\n  return passed.length;\n}\n\nfunction planDecided(state: TaskState, decision: PlanDecision): TaskState {\n  if (state.plan !== 'pending') {\n    return state;\n  }\n  if (decision === 'changes') {\n    return { ...state, plan: 'changes', events: [...state.events, 'changes'] };\n  }\n  return {\n    ...state,\n    plan: 'approved',\n    status: 'progress',\n    events: [...state.events, 'approved'],\n  };\n}\n\nfunction runningCheck(now: number, attempt: number): Check {\n  return { status: 'running', attempt, startedAt: now };\n}\n\nfunction checkUpdated(\n  state: TaskState,\n  id: CheckId,\n  status: CallStatus,\n  now: number\n): TaskState {\n  if (!state.checks) {\n    return state;\n  }\n  const check: Check = { ...state.checks[id], status, endedAt: now };\n  return { ...state, checks: { ...state.checks, [id]: check } };\n}\n\nfunction rerun(state: TaskState, id: CheckId, now: number): TaskState {\n  if (!state.checks) {\n    return state;\n  }\n  const attempt = state.checks[id].attempt + 1;\n  const check = runningCheck(now, attempt);\n  return { ...state, checks: { ...state.checks, [id]: check } };\n}\n\nfunction merge(state: TaskState): TaskState {\n  const canMerge = allChecksPassed(state.checks) && state.merge === 'idle';\n  if (!canMerge) {\n    return state;\n  }\n  return { ...state, merge: 'busy' };\n}\n\nfunction merged(state: TaskState): TaskState {\n  if (state.merge !== 'busy') {\n    return state;\n  }\n  return {\n    ...state,\n    merge: 'done',\n    status: 'merged',\n    events: [...state.events, 'merged'],\n  };\n}\n\nfunction branchChanged(state: TaskState, isDeleted: boolean): TaskState {\n  if (isDeleted) {\n    return { ...state, isBranchDeleted: true };\n  }\n  const events = [...state.events, 'restored'];\n  return { ...state, isBranchDeleted: false, events };\n}\n\n/** The agent only works once a person has approved its plan. */\nfunction work(state: TaskState, actions: TaskAction[], now: number) {\n  if (state.plan !== 'approved') {\n    return state;\n  }\n  let next = state;\n  for (const inner of actions) {\n    next = applyAt(next, inner, now);\n  }\n  return next;\n}\n\nexport function applyAt(\n  state: TaskState,\n  action: TaskAction,\n  now: number\n): TaskState {\n  switch (action.type) {\n    case 'event':\n      return { ...state, events: [...state.events, action.id] };\n    case 'status':\n      return { ...state, status: action.status };\n    case 'planDecided':\n      return planDecided(state, action.decision);\n    case 'checksStarted':\n      return {\n        ...state,\n        checks: {\n          lint: runningCheck(now, 1),\n          build: runningCheck(now, 1),\n          tests: runningCheck(now, 1),\n        },\n      };\n    case 'check':\n      return checkUpdated(state, action.id, action.status, now);\n    case 'rerun':\n      return rerun(state, action.id, now);\n    case 'merge':\n      return merge(state);\n    case 'merged':\n      return merged(state);\n    case 'branch':\n      return branchChanged(state, action.isDeleted);\n    case 'work':\n      return work(state, action.actions, now);\n  }\n}\n\nexport function reducer(state: TaskState, action: TaskAction) {\n  return applyAt(state, action, Date.now());\n}\n\nfunction workStep(after: number, actions: TaskAction[]): Step {\n  return { after, action: { type: 'work', actions } };\n}\n\nfunction hasDecidedPlan(state: TaskState) {\n  return state.plan !== 'pending';\n}\n\nfunction hasPressedMerge(state: TaskState) {\n  return state.merge !== 'idle';\n}\n\n/** A request that waits on a person is answered by the demonstration after this long. */\nconst DECIDE_AFTER_MS = 2500;\n\nexport const SCRIPT: Step[] = [\n  { after: 1100, action: { type: 'event', id: 'plan' } },\n  {\n    after: DECIDE_AFTER_MS,\n    by: 'person',\n    press: 'approve',\n    action: { type: 'planDecided', decision: 'approved' },\n    isAnswered: hasDecidedPlan,\n  },\n  workStep(1500, [{ type: 'event', id: 'commit1' }]),\n  workStep(1300, [{ type: 'event', id: 'commit2' }]),\n  workStep(1200, [\n    { type: 'event', id: 'pr' },\n    { type: 'status', status: 'review' },\n    { type: 'checksStarted' },\n  ]),\n  workStep(1200, [{ type: 'check', id: 'lint', status: 'done' }]),\n  workStep(700, [{ type: 'check', id: 'build', status: 'done' }]),\n  workStep(700, [\n    { type: 'check', id: 'tests', status: 'failed' },\n    { type: 'event', id: 'failed' },\n  ]),\n  workStep(1700, [\n    { type: 'event', id: 'commit3' },\n    { type: 'rerun', id: 'tests' },\n  ]),\n  workStep(1900, [{ type: 'check', id: 'tests', status: 'done' }]),\n  {\n    after: DECIDE_AFTER_MS,\n    by: 'person',\n    press: 'merge',\n    action: { type: 'merge' },\n    isAnswered: hasPressedMerge,\n  },\n  { after: 1100, action: { type: 'merged' } },\n  workStep(800, [\n    { type: 'event', id: 'branch' },\n    { type: 'branch', isDeleted: true },\n  ]),\n];\n\nfunction restingOf() {\n  let state = INITIAL;\n  let now = 1000;\n  for (const step of SCRIPT) {\n    now += step.after;\n    state = applyAt(state, step.action, now);\n  }\n  return state;\n}\n\nexport const RESTING = restingOf();\n\nexport const LOOP_AFTER_MS = 3800;\n",
      "type": "registry:component",
      "target": "components/blocks/agent-review-01/session.ts"
    },
    {
      "path": "registry/ndeko/blocks/agent-review/agent-review-01/data.ts",
      "content": "import type { SeriesSlot } from '@/registry/ndeko/lib/agent-run';\n\nexport const ISSUE = {\n  id: 'TAL-128',\n  title: 'Export invoices as CSV',\n  request:\n    'Finance exports invoices by hand every month. Add an Export button to the invoices table that downloads what the current filters show, with dates in ISO format and amounts in the invoice currency.',\n  branch: 'tal-128-csv-export',\n  pullRequest: 'Add CSV export to the invoices table',\n};\n\nexport const CODER = { name: 'Coder', series: 5 as SeriesSlot };\n\nexport const REVIEWER = {\n  name: 'Lena Brandt',\n};\n\nexport const PLAN_STEPS = [\n  'Add an export endpoint that streams the filtered rows',\n  'Add the Export button to the invoices table',\n  'Cover dates and currencies with tests',\n];\n\nexport type ActivityKind =\n  | 'plan'\n  | 'approved'\n  | 'changes'\n  | 'commit'\n  | 'pull-request'\n  | 'check-failed'\n  | 'merged'\n  | 'branch'\n  | 'restored';\n\nexport type Activity = {\n  id: string;\n  kind: ActivityKind;\n  actor: 'coder' | 'reviewer';\n  text: string;\n  /** A commit hash, shown in mono before the text. */\n  hash?: string;\n};\n\nexport const ACTIVITY: Record<string, Activity> = {\n  plan: {\n    id: 'plan',\n    kind: 'plan',\n    actor: 'coder',\n    text: 'proposed a plan',\n  },\n  approved: {\n    id: 'approved',\n    kind: 'approved',\n    actor: 'reviewer',\n    text: 'approved the plan',\n  },\n  changes: {\n    id: 'changes',\n    kind: 'changes',\n    actor: 'reviewer',\n    text: 'asked for changes to the plan. Coder waits for a new brief',\n  },\n  commit1: {\n    id: 'commit1',\n    kind: 'commit',\n    actor: 'coder',\n    hash: '4f2a91c',\n    text: 'Add a streaming CSV endpoint',\n  },\n  commit2: {\n    id: 'commit2',\n    kind: 'commit',\n    actor: 'coder',\n    hash: 'b07d3e2',\n    text: 'Add Export to the invoices table',\n  },\n  pr: {\n    id: 'pr',\n    kind: 'pull-request',\n    actor: 'coder',\n    text: 'opened a pull request',\n  },\n  failed: {\n    id: 'failed',\n    kind: 'check-failed',\n    actor: 'coder',\n    text: 'saw Unit tests fail on a date and is fixing it',\n  },\n  commit3: {\n    id: 'commit3',\n    kind: 'commit',\n    actor: 'coder',\n    hash: '9c1e5aa',\n    text: 'Make the date test independent of today',\n  },\n  merged: {\n    id: 'merged',\n    kind: 'merged',\n    actor: 'reviewer',\n    text: 'merged the pull request',\n  },\n  branch: {\n    id: 'branch',\n    kind: 'branch',\n    actor: 'coder',\n    text: 'deleted the branch',\n  },\n  restored: {\n    id: 'restored',\n    kind: 'restored',\n    actor: 'reviewer',\n    text: 'restored the branch',\n  },\n};\n\nexport const DIFF_STATS = { additions: 84, deletions: 12, files: 4 };\n\nexport type CheckId = 'lint' | 'build' | 'tests';\n\nexport const CHECKS: { id: CheckId; name: string }[] = [\n  { id: 'lint', name: 'Lint' },\n  { id: 'build', name: 'Build' },\n  { id: 'tests', name: 'Unit tests' },\n];\n",
      "type": "registry:component",
      "target": "components/blocks/agent-review-01/data.ts"
    }
  ],
  "categories": [
    "blocks",
    "agent-review"
  ],
  "type": "registry:block"
}