react-agentic 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/markdown.ts","../src/components/structured.ts","../src/components/Command.ts","../src/components/Agent.ts","../src/components/runtime-var.ts","../src/components/runtime-fn.ts","../src/components/control.ts","../src/components/ask-user.ts","../src/ir/nodes.ts","../src/ir/runtime-nodes.ts","../src/index.ts","../src/parser/index.ts","../src/parser/transformer.ts","../src/primitives/schema.ts","../src/workflow/sections/semantic.ts"],"sourcesContent":["/**\n * Markdown Primitives - Compile-time JSX components\n *\n * These components are compile-time only - they're transformed by the transpiler\n * and never executed at runtime. They exist to provide TypeScript type checking.\n */\n\nimport type { ReactNode } from 'react';\n\n// ============================================================================\n// Markdown Component\n// ============================================================================\n\n/**\n * Props for the Markdown component\n */\nexport interface MarkdownProps {\n /** Raw Markdown content to pass through */\n children?: ReactNode;\n}\n\n/**\n * Markdown component - passes content through as raw Markdown\n *\n * This is a compile-time component transformed by react-agentic.\n * It's never executed at runtime.\n *\n * @example\n * <Markdown>\n * ## Pre-formatted Section\n *\n * Content that is already in Markdown format.\n * </Markdown>\n */\nexport function Markdown(_props: MarkdownProps): null {\n return null;\n}\n\n// ============================================================================\n// XmlBlock Component\n// ============================================================================\n\n/**\n * Props for the XmlBlock component\n */\nexport interface XmlBlockProps {\n /** XML tag name for the block */\n name: string;\n /** Block content */\n children?: ReactNode;\n}\n\n/**\n * XmlBlock component - creates a named XML block\n *\n * This is a compile-time component transformed by react-agentic.\n * It's never executed at runtime.\n *\n * @example\n * <XmlBlock name=\"instructions\">\n * <p>Content inside the block</p>\n * </XmlBlock>\n *\n * Outputs:\n * <instructions>\n * Content inside the block\n * </instructions>\n */\nexport function XmlBlock(_props: XmlBlockProps): null {\n return null;\n}\n\n// ============================================================================\n// Indent Component\n// ============================================================================\n\n/**\n * Props for the Indent component\n */\nexport interface IndentProps {\n /** Number of spaces to indent (default: 2) */\n spaces?: number;\n /** Block content to indent */\n children?: ReactNode;\n}\n\n/**\n * Indent component - indents content by a specified number of spaces\n *\n * This is a compile-time component transformed by react-agentic.\n * It's never executed at runtime.\n *\n * @example\n * <Indent spaces={4}>\n * This content will be indented by 4 spaces.\n * Each line gets the same indentation.\n * </Indent>\n *\n * Outputs:\n * This content will be indented by 4 spaces.\n * Each line gets the same indentation.\n */\nexport function Indent(_props: IndentProps): null {\n return null;\n}\n","/**\n * Structured Data Components - Compile-time JSX components\n *\n * These components are compile-time only - they're transformed by the transpiler\n * and never executed at runtime. They exist to provide TypeScript type checking.\n */\n\n// ============================================================================\n// Table Component\n// ============================================================================\n\n/**\n * Alignment options for table columns\n */\nexport type TableAlignment = 'left' | 'center' | 'right';\n\n/**\n * Props for the Table component\n */\nexport interface TableProps {\n /** Optional header row */\n headers?: string[];\n /** Data rows - each row is an array of cell values (null/undefined use emptyCell) */\n rows: (string | number | null | undefined)[][];\n /** Per-column alignment (defaults to 'left' for all columns) */\n align?: TableAlignment[];\n /** Content for empty cells (defaults to empty string) */\n emptyCell?: string;\n}\n\n/**\n * Table component - emits markdown table from structured props\n *\n * This is a compile-time component transformed by react-agentic.\n * It's never executed at runtime.\n *\n * @example\n * <Table\n * headers={[\"Name\", \"Age\", \"City\"]}\n * rows={[\n * [\"Alice\", 30, \"NYC\"],\n * [\"Bob\", 25, \"LA\"],\n * ]}\n * align={[\"left\", \"right\", \"center\"]}\n * />\n *\n * Outputs:\n * | Name | Age | City |\n * | :--- | ---: | :---: |\n * | Alice | 30 | NYC |\n * | Bob | 25 | LA |\n */\nexport function Table(_props: TableProps): null {\n return null;\n}\n\n// ============================================================================\n// List Component\n// ============================================================================\n\n/**\n * Props for the List component\n */\nexport interface ListProps {\n /** List items */\n items: (string | number)[];\n /** Use ordered (numbered) list (default: false for bullet list) */\n ordered?: boolean;\n /** Starting number for ordered lists (default: 1) */\n start?: number;\n}\n\n/**\n * List component - emits markdown list from structured props\n *\n * This is a compile-time component transformed by react-agentic.\n * It's never executed at runtime.\n *\n * @example\n * <List items={[\"First item\", \"Second item\", \"Third item\"]} />\n *\n * Outputs:\n * - First item\n * - Second item\n * - Third item\n *\n * @example\n * <List items={[\"Step one\", \"Step two\"]} ordered start={5} />\n *\n * Outputs:\n * 5. Step one\n * 6. Step two\n */\nexport function List(_props: ListProps): null {\n return null;\n}\n","/**\n * Command Component - Compile-time JSX component\n *\n * This component is compile-time only - it's transformed by the transpiler\n * and never executed at runtime. It exists to provide TypeScript type checking.\n */\n\nimport type { ReactNode } from 'react';\n\n// ============================================================================\n// Types\n// ============================================================================\n\n/**\n * Command argument definition\n * Used for commands that accept arguments via the skill system\n */\nexport interface CommandArgument {\n /** Argument name */\n name: string;\n /** Description of the argument */\n description: string;\n /** Whether the argument is required (default: false) */\n required?: boolean;\n}\n\n/**\n * Context available in Command render props pattern\n * All values resolved at compile time, static in output\n */\nexport interface CommandContext {\n /** Command name from props */\n name: string;\n /** Command description from props */\n description: string;\n /** Skill name if invoked via skill (undefined otherwise) */\n skill?: string;\n /** Subfolder for output path (e.g., \"gsd\" → .claude/commands/gsd/my-cmd.md) */\n folder?: string;\n /** Resolved output path (e.g., .claude/commands/my-cmd.md) */\n outputPath: string;\n /** Source TSX file path */\n sourcePath: string;\n}\n\n/**\n * Props for the Command component\n */\nexport interface CommandProps {\n /** Command name (used in frontmatter) */\n name: string;\n /** Command description (used in frontmatter) */\n description: string;\n /** Optional argument hint (maps to argument-hint in frontmatter) */\n argumentHint?: string;\n /** Optional agent name (maps to agent in frontmatter) */\n agent?: string;\n /** Optional list of allowed tools (maps to allowed-tools in frontmatter) */\n allowedTools?: string[];\n /** Subfolder for output path (e.g., \"gsd\" → .claude/commands/gsd/my-cmd.md) */\n folder?: string;\n /** Arguments array (maps to arguments in frontmatter) */\n arguments?: CommandArgument[];\n /**\n * Command body content - either regular JSX or render props function\n * Render props: (ctx: CommandContext) => ReactNode\n */\n children?: ReactNode | ((ctx: CommandContext) => ReactNode);\n}\n\n// ============================================================================\n// Component\n// ============================================================================\n\n/**\n * Command component - creates a Claude Code command with frontmatter\n *\n * This is a compile-time component transformed by react-agentic.\n * It's never executed at runtime.\n *\n * @example\n * <Command name=\"my-command\" description=\"Does something useful\">\n * <p>Command instructions here</p>\n * </Command>\n */\nexport function Command(_props: CommandProps): null {\n return null;\n}\n","/**\n * Agent Components - Compile-time JSX components\n *\n * These components are compile-time only - they're transformed by the transpiler\n * and never executed at runtime. They exist to provide TypeScript type checking.\n */\n\nimport type { ReactNode } from 'react';\nimport type { CommandContext } from './Command.js';\nimport type { RuntimeVarProxy, OrRuntimeVar, AllowRuntimeVars } from './runtime-var.js';\n\n// ============================================================================\n// Types\n// ============================================================================\n\n/**\n * Standard agent status values\n */\nexport type AgentStatus = 'SUCCESS' | 'BLOCKED' | 'NOT_FOUND' | 'ERROR' | 'CHECKPOINT';\n\n/**\n * Base output interface for all agents\n */\nexport interface BaseOutput {\n /** Agent completion status */\n status: AgentStatus;\n /** Explanation when blocked */\n blockedBy?: string;\n /** Error message if failed */\n error?: string;\n}\n\n/**\n * Context available in Agent render props pattern\n * Extends CommandContext with agent-specific fields\n */\nexport interface AgentContext extends CommandContext {\n /** Space-separated tool names if defined */\n tools?: string;\n /** Model name if specified in agent */\n model?: string;\n}\n\n/**\n * Props for the Agent component\n * @typeParam TInput - Type interface for agent input contract (compile-time only)\n * @typeParam TOutput - Type interface for agent output contract (compile-time only)\n */\nexport interface AgentProps<TInput = unknown, TOutput = unknown> {\n /** Agent name (used in frontmatter and Task() spawning) */\n name: string;\n /** Agent description (used in frontmatter) */\n description: string;\n /** Space-separated tool names (optional) */\n tools?: string;\n /** Terminal color for agent output (optional) */\n color?: string;\n /** Subfolder for output path (optional) - determines namespaced agent name */\n folder?: string;\n /** Model name (optional) - for AgentContext access */\n model?: string;\n /**\n * Agent body content - either regular JSX or render props function\n * Render props: (ctx: AgentContext) => ReactNode\n */\n children?: ReactNode | ((ctx: AgentContext) => ReactNode);\n // TInput and TOutput are compile-time only - used for cross-file type validation\n}\n\n// ============================================================================\n// AgentRef Types\n// ============================================================================\n\n/**\n * Configuration for defining an agent reference\n */\nexport interface DefineAgentConfig<TInput = unknown> {\n /** Agent name (must match the Agent's name prop) */\n name: string;\n /** Optional path to the agent markdown file for loadFromFile pattern */\n path?: string;\n /** Input type - only for compile-time inference, not used at runtime */\n _inputType?: TInput;\n}\n\n/**\n * Type-safe reference to an agent definition\n */\nexport interface AgentRef<TInput = unknown> {\n /** Agent name for Task() subagent_type */\n name: string;\n /** Optional path for loadFromFile pattern */\n path?: string;\n /** Marker for type guard */\n readonly __isAgentRef: true;\n /** Phantom type for input validation */\n readonly __inputType?: TInput;\n}\n\n/**\n * Define a type-safe reference to an agent\n */\nexport function defineAgent<TInput = unknown>(\n config: DefineAgentConfig<TInput>\n): AgentRef<TInput> {\n return {\n name: config.name,\n path: config.path,\n __isAgentRef: true,\n };\n}\n\n/**\n * Type guard for AgentRef\n */\nexport function isAgentRef(value: unknown): value is AgentRef {\n if (!value || typeof value !== 'object') return false;\n return (value as AgentRef).__isAgentRef === true;\n}\n\n/**\n * Get agent name from string or AgentRef\n */\nexport function getAgentName(agent: string | AgentRef): string {\n return isAgentRef(agent) ? agent.name : agent;\n}\n\n/**\n * Get agent path from AgentRef (undefined for string)\n */\nexport function getAgentPath(agent: string | AgentRef): string | undefined {\n return isAgentRef(agent) ? agent.path : undefined;\n}\n\n// ============================================================================\n// SpawnAgent Types\n// ============================================================================\n\n/**\n * Props for the SpawnAgent component\n * @typeParam TInput - Type interface to validate against Agent's contract (compile-time only)\n */\nexport interface SpawnAgentProps<TInput = unknown> {\n /**\n * Agent to spawn - either:\n * - String: Agent name directly (e.g., 'gsd-researcher')\n * - AgentRef: Type-safe reference from defineAgent()\n */\n agent: string | AgentRef<TInput>;\n /** Model to use - supports {variable} placeholders */\n model: string;\n /** Human-readable description of the task */\n description: string;\n /**\n * Enable \"load from file\" pattern for spawning.\n */\n loadFromFile?: boolean | string;\n /** Prompt content - supports multi-line and {variable} placeholders */\n prompt?: string;\n /** Variable name containing the prompt (for runtime concatenation) */\n promptVariable?: string;\n /** Typed input - either a variable ref or an object literal */\n input?: Partial<TInput>;\n /** Optional extra instructions appended to the auto-generated prompt */\n children?: ReactNode;\n}\n\n/**\n * V3-compatible SpawnAgent props with RuntimeVar support\n */\nexport interface V3SpawnAgentProps<TInput = unknown> {\n /** Agent to spawn - accepts RuntimeVar for runtime resolution */\n agent: OrRuntimeVar<string> | AgentRef<TInput>;\n /** Model to use - supports static string or RuntimeVar */\n model: OrRuntimeVar<string>;\n /** Human-readable description - accepts static or RuntimeVar */\n description: OrRuntimeVar<string>;\n /** Enable \"load from file\" pattern - accepts RuntimeVar */\n loadFromFile?: OrRuntimeVar<string | boolean>;\n /** Prompt content - supports RuntimeVar interpolation */\n prompt?: OrRuntimeVar<string>;\n /** Typed input - accepts RuntimeVar values */\n input?: RuntimeVarProxy<TInput> | Partial<AllowRuntimeVars<TInput>>;\n /** RuntimeVar to store the agent's output */\n output?: RuntimeVarProxy<string>;\n /** Optional extra instructions */\n children?: ReactNode;\n}\n\n// ============================================================================\n// OnStatus Types\n// ============================================================================\n\n/**\n * Output reference for OnStatus matching\n */\nexport interface OutputRef {\n agent: string;\n}\n\n/**\n * Create an output reference for OnStatus\n */\nexport function useOutput<T = unknown>(agent: string): OutputRef & { field: (name: keyof T) => string } {\n return {\n agent,\n field: (name: keyof T) => `{${agent}.${String(name)}}`,\n };\n}\n\n/**\n * Props for the OnStatus component\n */\nexport interface OnStatusProps {\n /** Output reference from useOutput */\n output: OutputRef;\n /** Status value to match (SUCCESS, BLOCKED, etc.) */\n status: AgentStatus;\n /** Block content for this status */\n children?: ReactNode;\n}\n\n// ============================================================================\n// Components\n// ============================================================================\n\n/**\n * Agent component - creates a Claude Code agent with frontmatter\n *\n * @typeParam TInput - Type interface for agent input contract\n * @typeParam TOutput - Type interface for agent output contract\n */\nexport function Agent<TInput = unknown, TOutput = unknown>(_props: AgentProps<TInput, TOutput>): null {\n return null;\n}\n\n/**\n * SpawnAgent component - emits Task() syntax inside a Command\n *\n * @typeParam TInput - Type interface to validate against Agent's contract\n */\nexport function SpawnAgent<TInput = unknown>(_props: SpawnAgentProps<TInput> | V3SpawnAgentProps<TInput>): null {\n return null;\n}\n\n/**\n * OnStatus component - conditional block for agent status handling\n */\nexport function OnStatus(_props: OnStatusProps): null {\n return null;\n}\n","/**\n * Runtime Variable System for Hybrid Runtime\n *\n * RuntimeVar is a branded type that tracks JSON variable paths at compile time.\n * The proxy pattern captures property access for jq expression generation.\n *\n * Usage:\n * const ctx = useRuntimeVar<MyType>('CTX');\n * // ctx.error becomes $(echo \"$CTX\" | jq -r '.error')\n * // ctx.user.name becomes $(echo \"$CTX\" | jq -r '.user.name')\n */\n\n// ============================================================================\n// Branded Types\n// ============================================================================\n\n/**\n * Brand symbol for compile-time type safety\n * Prevents accidental mixing of RuntimeVar with regular values\n */\ndeclare const __runtimeVarBrand: unique symbol;\n\n/**\n * Internal RuntimeVar metadata interface\n */\ninterface RuntimeVarMeta<T> {\n readonly [__runtimeVarBrand]: T;\n /** Shell variable name (e.g., 'CTX') */\n readonly __varName: string;\n /** Property access path (e.g., ['user', 'name']) */\n readonly __path: readonly string[];\n}\n\n/**\n * Base RuntimeVar type - branded string intersection\n *\n * By intersecting with `string`, RuntimeVar becomes assignable to:\n * - string (for comparisons like `ctx.status === 'SUCCESS'`)\n * - ReactNode (for JSX interpolation like `{ctx.message}`)\n *\n * The brand ensures type safety while allowing ergonomic usage in JSX.\n * At runtime, the proxy's toString() returns the jq expression.\n */\nexport type RuntimeVar<T> = string & RuntimeVarMeta<T>;\n\n/**\n * RuntimeVarProxy enables deep property access tracking\n * Each property access returns a new proxy with extended path\n *\n * @example\n * const ctx = useRuntimeVar<{user: {name: string}}>('CTX');\n * ctx.__path // []\n * ctx.user.__path // ['user']\n * ctx.user.name.__path // ['user', 'name']\n *\n * // Works in JSX:\n * <p>Hello, {ctx.user.name}</p>\n *\n * // Works in comparisons:\n * if (ctx.status === 'SUCCESS') { ... }\n */\nexport type RuntimeVarProxy<T> = RuntimeVar<T> & {\n readonly [K in keyof T]: T[K] extends object\n ? RuntimeVarProxy<T[K]>\n : RuntimeVar<T[K]>;\n};\n\n// ============================================================================\n// Internal Proxy Creation\n// ============================================================================\n\n/**\n * Special symbols for RuntimeVar identification\n */\nconst RUNTIME_VAR_MARKER = Symbol.for('react-agentic:runtime-var');\n\n/**\n * Create a RuntimeVarProxy that tracks property access paths\n *\n * Uses ES6 Proxy to intercept property access and build path arrays.\n * Each nested access returns a new proxy with the extended path.\n *\n * @param varName - Shell variable name\n * @param path - Current property path (starts empty)\n * @returns Proxy that tracks all property accesses\n */\nfunction createRuntimeVarProxy<T>(varName: string, path: string[]): RuntimeVarProxy<T> {\n const target = {\n __varName: varName,\n __path: path,\n [RUNTIME_VAR_MARKER]: true,\n };\n\n return new Proxy(target as unknown as RuntimeVarProxy<T>, {\n get(_target, prop: string | symbol) {\n // Handle known properties\n if (prop === '__varName') return varName;\n if (prop === '__path') return path;\n if (prop === RUNTIME_VAR_MARKER) return true;\n\n // Handle symbol properties (like Symbol.toStringTag)\n if (typeof prop === 'symbol') return undefined;\n\n // Create nested proxy for property access\n return createRuntimeVarProxy<unknown>(varName, [...path, prop]);\n },\n });\n}\n\n// ============================================================================\n// Public API\n// ============================================================================\n\n/**\n * Create a typed runtime variable reference\n *\n * This hook-style function creates a compile-time reference to a shell variable\n * that will be populated at runtime by a RuntimeFn call.\n *\n * The returned proxy tracks property access paths, which the transformer\n * converts to jq expressions for shell execution.\n *\n * @param name - Shell variable name (should be UPPER_SNAKE_CASE)\n * @returns RuntimeVarProxy that tracks property access\n *\n * @example\n * interface Context {\n * error?: string;\n * data: { count: number };\n * }\n *\n * const ctx = useRuntimeVar<Context>('CTX');\n *\n * // In JSX:\n * <If condition={ctx.error}>...</If>\n * // Emits: **If $(echo \"$CTX\" | jq -r '.error'):**\n *\n * <p>Count: {ctx.data.count}</p>\n * // Emits: Count: $(echo \"$CTX\" | jq -r '.data.count')\n */\nexport function useRuntimeVar<T>(name: string): RuntimeVarProxy<T> {\n return createRuntimeVarProxy<T>(name, []);\n}\n\n// ============================================================================\n// Type Guards\n// ============================================================================\n\n/**\n * Check if a value is a RuntimeVar proxy\n *\n * Used by transformers to detect when to generate jq expressions\n * instead of literal values.\n *\n * @param value - Value to check\n * @returns true if value is a RuntimeVar proxy\n */\nexport function isRuntimeVar(value: unknown): value is RuntimeVar<unknown> {\n if (!value || typeof value !== 'object') return false;\n return (value as Record<symbol, unknown>)[RUNTIME_VAR_MARKER] === true;\n}\n\n/**\n * Extract RuntimeVar metadata from a proxy\n *\n * @param runtimeVar - RuntimeVar proxy\n * @returns Object with varName and path\n */\nexport function getRuntimeVarInfo(runtimeVar: RuntimeVar<unknown>): {\n varName: string;\n path: readonly string[];\n} {\n return {\n varName: runtimeVar.__varName,\n path: runtimeVar.__path,\n };\n}\n\n// ============================================================================\n// jq Expression Generation\n// ============================================================================\n\n/**\n * Convert RuntimeVar to jq shell expression\n *\n * @param runtimeVar - RuntimeVar proxy\n * @returns Shell command string like $(echo \"$VAR\" | jq -r '.path')\n *\n * @example\n * toJqExpression(ctx.user.name)\n * // Returns: $(echo \"$CTX\" | jq -r '.user.name')\n */\nexport function toJqExpression(runtimeVar: RuntimeVar<unknown>): string {\n const { varName, path } = getRuntimeVarInfo(runtimeVar);\n const jqPath = path.length === 0 ? '.' : '.' + path.join('.');\n return `$(echo \"$${varName}\" | jq -r '${jqPath}')`;\n}\n\n/**\n * Convert RuntimeVar to raw jq path expression (without shell wrapper)\n *\n * @param runtimeVar - RuntimeVar proxy\n * @returns jq path string like '.user.name'\n */\nexport function toJqPath(runtimeVar: RuntimeVar<unknown>): string {\n const { path } = getRuntimeVarInfo(runtimeVar);\n return path.length === 0 ? '.' : '.' + path.join('.');\n}\n\n// ============================================================================\n// Utility Types for Component Props\n// ============================================================================\n\n/**\n * Allow a value OR its RuntimeVar equivalent\n *\n * Use for component props that should accept runtime interpolation.\n * This enables props to accept either static values or RuntimeVar references.\n *\n * @example\n * interface MyProps {\n * count: OrRuntimeVar<number>; // Accepts 5 or ctx.count\n * name: OrRuntimeVar<string>; // Accepts \"hello\" or ctx.name\n * }\n */\nexport type OrRuntimeVar<T> = T | RuntimeVar<T> | RuntimeVarProxy<T>;\n\n/**\n * Transform object type so each property accepts RuntimeVar\n *\n * Use for complex props like RuntimeFn args where each property\n * can be either a static value or a RuntimeVar reference.\n *\n * @example\n * interface Args { x: number; y: string; }\n * type FlexibleArgs = AllowRuntimeVars<Args>;\n * // { x: number | RuntimeVar<number>; y: string | RuntimeVar<string>; }\n */\nexport type AllowRuntimeVars<T> = T extends object\n ? { [K in keyof T]: OrRuntimeVar<T[K]> }\n : OrRuntimeVar<T>;\n\n","/**\n * Runtime Function System for Hybrid Runtime\n *\n * RuntimeFn wraps TypeScript functions for extraction to runtime.js.\n * Each wrapped function gets a `.Call` component for JSX invocation.\n *\n * Usage:\n * // Define function\n * async function init(args: InitArgs): Promise<InitResult> { ... }\n *\n * // Wrap for compile-time\n * const Init = runtimeFn(init);\n *\n * // Use in JSX\n * <Init.Call args={{ x: \"1\" }} output={ctx} />\n *\n * // Emits: CTX=$(node runtime.js init '{\"x\":\"1\"}')\n */\n\nimport type { RuntimeVarProxy, AllowRuntimeVars } from './runtime-var.js';\n\n// ============================================================================\n// Types\n// ============================================================================\n\n/**\n * Async function that can be wrapped as a RuntimeFn\n * Must be a named async function for extraction\n */\nexport type RuntimeFunction<TArgs extends object, TReturn> = (\n args: TArgs\n) => Promise<TReturn>;\n\n/**\n * Props for the .Call component\n *\n * @param args - Arguments to pass to the function (each can be static or RuntimeVar)\n * @param output - RuntimeVar to store the result (must match TReturn type)\n */\nexport interface RuntimeCallProps<TArgs extends object, TReturn> {\n /** Arguments passed to the runtime function. Each property can be static or RuntimeVar. */\n args: AllowRuntimeVars<TArgs>;\n /** RuntimeVar to store the function result */\n output: RuntimeVarProxy<TReturn>;\n}\n\n/**\n * The .Call component type\n * This is what users invoke in JSX\n */\nexport type RuntimeCallComponent<TArgs extends object, TReturn> = (\n props: RuntimeCallProps<TArgs, TReturn>\n) => null;\n\n/**\n * Wrapper returned by runtimeFn()\n * Contains the .Call component and metadata for extraction\n */\nexport interface RuntimeFnComponent<TArgs extends object, TReturn> {\n /** JSX component for invoking the function */\n Call: RuntimeCallComponent<TArgs, TReturn>;\n /** Original function name for extraction */\n readonly fnName: string;\n /** Original function reference for extraction */\n readonly fn: RuntimeFunction<TArgs, TReturn>;\n /** Marker for type guard */\n readonly __isRuntimeFn: true;\n}\n\n// ============================================================================\n// Internal Symbols\n// ============================================================================\n\n/**\n * Symbol for identifying RuntimeFn wrappers\n */\nconst RUNTIME_FN_MARKER = Symbol.for('react-agentic:runtime-fn');\n\n/**\n * Registry of all runtime functions for extraction\n * Maps function name -> function reference\n */\nconst runtimeFnRegistry = new Map<string, RuntimeFunction<object, unknown>>();\n\n// ============================================================================\n// Public API\n// ============================================================================\n\n/**\n * Wrap a TypeScript function for runtime extraction\n *\n * The wrapped function:\n * 1. Gets extracted to runtime.js during build\n * 2. Provides a .Call component for JSX invocation\n * 3. Maintains full type safety between args/output\n *\n * @param fn - Async function to wrap\n * @returns RuntimeFnComponent with .Call and metadata\n *\n * @example\n * // Define the function\n * interface InitArgs { projectPath: string }\n * interface InitResult { success: boolean; error?: string }\n *\n * async function initProject(args: InitArgs): Promise<InitResult> {\n * const exists = await checkPath(args.projectPath);\n * return exists\n * ? { success: true }\n * : { success: false, error: 'Path not found' };\n * }\n *\n * // Wrap for JSX use\n * const Init = runtimeFn(initProject);\n *\n * // Use in Command\n * export default (\n * <Command name=\"setup\">\n * {() => {\n * const result = useRuntimeVar<InitResult>('RESULT');\n * return (\n * <>\n * <Init.Call args={{ projectPath: \".\" }} output={result} />\n * <If condition={result.error}>\n * <p>Error: {result.error}</p>\n * </If>\n * </>\n * );\n * }}\n * </Command>\n * );\n */\nexport function runtimeFn<TArgs extends object, TReturn>(\n fn: RuntimeFunction<TArgs, TReturn>\n): RuntimeFnComponent<TArgs, TReturn> {\n // Get function name (required for extraction)\n const fnName = fn.name;\n if (!fnName) {\n throw new Error(\n 'runtimeFn requires a named function. Anonymous functions cannot be extracted to runtime.js.'\n );\n }\n\n // Register for extraction\n runtimeFnRegistry.set(fnName, fn as RuntimeFunction<object, unknown>);\n\n // Create the Call component stub (compile-time only)\n const Call: RuntimeCallComponent<TArgs, TReturn> = (_props) => {\n // This function is never actually called at runtime\n // It exists only for TypeScript type checking\n return null;\n };\n\n // Create wrapper with marker\n const wrapper = {\n Call,\n fnName,\n fn,\n __isRuntimeFn: true as const,\n [RUNTIME_FN_MARKER]: true,\n };\n\n return wrapper;\n}\n\n// ============================================================================\n// Type Guards\n// ============================================================================\n\n/**\n * Check if a value is a RuntimeFn wrapper\n *\n * @param value - Value to check\n * @returns true if value is a RuntimeFnComponent\n */\nexport function isRuntimeFn(value: unknown): value is RuntimeFnComponent<object, unknown> {\n if (!value || typeof value !== 'object') return false;\n return (value as Record<string, unknown>).__isRuntimeFn === true;\n}\n\n// ============================================================================\n// Registry Access (for emitter)\n// ============================================================================\n\n/**\n * Get all registered runtime functions\n *\n * Used by the runtime emitter to extract functions to runtime.js\n *\n * @returns Map of function name -> function\n */\nexport function getRuntimeFnRegistry(): Map<string, RuntimeFunction<object, unknown>> {\n return new Map(runtimeFnRegistry);\n}\n\n/**\n * Clear the runtime function registry\n *\n * Used between builds to ensure clean state\n */\nexport function clearRuntimeFnRegistry(): void {\n runtimeFnRegistry.clear();\n}\n\n/**\n * Get a specific runtime function by name\n *\n * @param name - Function name\n * @returns Function if found, undefined otherwise\n */\nexport function getRuntimeFn(name: string): RuntimeFunction<object, unknown> | undefined {\n return runtimeFnRegistry.get(name);\n}\n","/**\n * Control Flow Components\n *\n * These components provide typed control flow for commands:\n * - If: Conditional based on RuntimeVar (not shell test strings)\n * - Else: Paired with If for else blocks\n * - Loop: Bounded iteration with max count\n * - Break: Exit current loop\n * - Return: Exit command early\n *\n * Key difference from v1: conditions are RuntimeVar<boolean> expressions,\n * not shell test strings. This enables proper TypeScript type checking.\n */\n\nimport type { RuntimeVar, RuntimeVarProxy, OrRuntimeVar } from './runtime-var.js';\n\n// ============================================================================\n// Condition Types\n// ============================================================================\n\n/**\n * Condition can be:\n * - RuntimeVar<boolean> (direct reference)\n * - RuntimeVar<T> (truthy check - undefined/null/empty string = false)\n * - Boolean expression combining RuntimeVars\n * - undefined (from optional property access - treated as falsy)\n *\n * The transformer parses these to Condition IR nodes.\n */\nexport type Condition<T = unknown> = RuntimeVar<T> | RuntimeVarProxy<T> | boolean | undefined;\n\n// ============================================================================\n// If Component\n// ============================================================================\n\n/**\n * Props for If component\n *\n * Takes a `condition: RuntimeVar` for type-safe conditions.\n */\nexport interface IfProps {\n /**\n * Condition to evaluate\n *\n * Can be:\n * - RuntimeVar<boolean> for direct boolean check\n * - RuntimeVar<T> for truthy check (falsy = false, truthy = true)\n *\n * @example\n * <If condition={ctx.error}>...</If>\n * // Emits: **If $(echo \"$CTX\" | jq -r '.error'):**\n *\n * @example\n * <If condition={ctx.flags.verbose}>...</If>\n * // Emits: **If $(echo \"$CTX\" | jq -r '.flags.verbose') = \"true\":**\n */\n condition: Condition;\n\n /** Content to render when condition is true */\n children?: React.ReactNode;\n}\n\n/**\n * Conditional block\n *\n * Renders children only if condition is truthy.\n * Works with RuntimeVar for type-safe runtime checks.\n *\n * @example\n * const ctx = useRuntimeVar<{ error?: string }>('CTX');\n *\n * <If condition={ctx.error}>\n * <p>Error occurred: {ctx.error}</p>\n * </If>\n */\nexport function If(_props: IfProps): null {\n // Compile-time only - transformer handles actual logic\n return null;\n}\n\n// ============================================================================\n// Else Component\n// ============================================================================\n\n/**\n * Props for Else component\n */\nexport interface ElseProps {\n /** Content to render when preceding If condition is false */\n children?: React.ReactNode;\n}\n\n/**\n * Else block - must follow If as sibling\n *\n * @example\n * <If condition={ctx.success}>\n * <p>Operation succeeded</p>\n * </If>\n * <Else>\n * <p>Operation failed</p>\n * </Else>\n */\nexport function Else(_props: ElseProps): null {\n // Compile-time only\n return null;\n}\n\n// ============================================================================\n// Loop Component\n// ============================================================================\n\n/**\n * Props for Loop component\n *\n * Loop is bounded iteration, not array iteration.\n * It executes up to `max` times, with optional counter variable.\n */\nexport interface LoopProps {\n /**\n * Maximum number of iterations\n *\n * Required for loops to prevent infinite loops.\n * Claude will stop after this many iterations.\n * Accepts static number or RuntimeVar<number> for runtime resolution.\n */\n max: OrRuntimeVar<number>;\n\n /**\n * Optional counter variable\n *\n * If provided, stores the current iteration number (0-indexed).\n * Useful for conditional logic based on iteration count.\n *\n * @example\n * const i = useRuntimeVar<number>('I');\n * <Loop max={5} counter={i}>\n * <p>Iteration: {i}</p>\n * </Loop>\n */\n counter?: RuntimeVarProxy<number>;\n\n /** Loop body content */\n children?: React.ReactNode;\n}\n\n/**\n * Bounded loop\n *\n * Executes children up to `max` times.\n * Use Break to exit early, Return to exit the entire command.\n *\n * @example\n * <Loop max={10}>\n * <RuntimeFn.Call args={{}} output={result} />\n * <If condition={result.done}>\n * <Break />\n * </If>\n * </Loop>\n */\nexport function Loop(_props: LoopProps): null {\n // Compile-time only\n return null;\n}\n\n// ============================================================================\n// Break Component\n// ============================================================================\n\n/**\n * Props for Break component\n */\nexport interface BreakProps {\n /** Optional message to display when breaking. Accepts static string or RuntimeVar. */\n message?: OrRuntimeVar<string>;\n}\n\n/**\n * Exit the current loop early\n *\n * Only valid inside a Loop component.\n * Execution continues after the Loop.\n *\n * @example\n * <Loop max={10}>\n * <RuntimeFn.Call args={{}} output={result} />\n * <If condition={result.error}>\n * <Break message=\"Error encountered, stopping retry loop\" />\n * </If>\n * </Loop>\n */\nexport function Break(_props: BreakProps): null {\n // Compile-time only\n return null;\n}\n\n// ============================================================================\n// Return Component\n// ============================================================================\n\n/**\n * Standard return status values\n */\nexport type ReturnStatus = 'SUCCESS' | 'BLOCKED' | 'NOT_FOUND' | 'ERROR' | 'CHECKPOINT';\n\n/**\n * Props for Return component\n */\nexport interface ReturnProps {\n /**\n * Optional status to return\n *\n * Used when the command needs to indicate success/failure\n * to a parent orchestrator. Accepts static status or RuntimeVar.\n */\n status?: OrRuntimeVar<ReturnStatus>;\n\n /** Optional message to display when returning. Accepts static string or RuntimeVar. */\n message?: OrRuntimeVar<string>;\n}\n\n/**\n * Exit the command early\n *\n * Stops execution of the entire command.\n * Use for early exit conditions or error handling.\n *\n * @example\n * <If condition={ctx.alreadyExists}>\n * <Return status=\"SUCCESS\" message=\"Already initialized, nothing to do\" />\n * </If>\n *\n * @example\n * <If condition={ctx.criticalError}>\n * <Return status=\"ERROR\" message=\"Cannot continue due to error\" />\n * </If>\n */\nexport function Return(_props: ReturnProps): null {\n // Compile-time only\n return null;\n}\n\n// ============================================================================\n// Type Guards (Markers)\n// ============================================================================\n\n/**\n * Marker symbols for control components\n */\nexport const IF_MARKER = Symbol.for('react-agentic:if');\nexport const ELSE_MARKER = Symbol.for('react-agentic:else');\nexport const LOOP_MARKER = Symbol.for('react-agentic:loop');\nexport const BREAK_MARKER = Symbol.for('react-agentic:break');\nexport const RETURN_MARKER = Symbol.for('react-agentic:return');\n\n// Add markers to components\nObject.defineProperty(If, IF_MARKER, { value: true });\nObject.defineProperty(Else, ELSE_MARKER, { value: true });\nObject.defineProperty(Loop, LOOP_MARKER, { value: true });\nObject.defineProperty(Break, BREAK_MARKER, { value: true });\nObject.defineProperty(Return, RETURN_MARKER, { value: true });\n","/**\n * AskUser Component for Hybrid Runtime\n *\n * Prompts the user with a question and stores the response\n * in a RuntimeVar for subsequent logic.\n *\n * Emits as Claude Code's AskUserQuestion tool syntax.\n */\n\nimport type { RuntimeVar, RuntimeVarProxy, OrRuntimeVar } from './runtime-var.js';\n\n// ============================================================================\n// Types\n// ============================================================================\n\n/**\n * Option in the AskUser question\n */\nexport interface AskUserOption {\n /** Internal value stored in output variable */\n value: string;\n /** Display label shown to user */\n label: string;\n /** Optional description for the option */\n description?: string;\n}\n\n/**\n * Props for AskUser component\n */\nexport interface AskUserProps {\n /**\n * Question to ask the user\n *\n * Should be clear and specific, ending with a question mark.\n * Accepts static string or RuntimeVar for runtime interpolation.\n *\n * @example \"Which database should we use?\"\n */\n question: OrRuntimeVar<string>;\n\n /**\n * Available options for the user to choose from\n *\n * Must have 2-4 options. User can always select \"Other\" to provide custom input.\n * Accepts static array or RuntimeVar<AskUserOption[]> for runtime resolution.\n *\n * @example\n * options={[\n * { value: 'postgres', label: 'PostgreSQL', description: 'Recommended for production' },\n * { value: 'sqlite', label: 'SQLite', description: 'Good for development' },\n * ]}\n */\n options: AskUserOption[] | RuntimeVar<AskUserOption[]> | RuntimeVarProxy<AskUserOption[]>;\n\n /**\n * RuntimeVar to store the user's response\n *\n * Will contain the `value` from the selected option,\n * or custom text if user selected \"Other\".\n */\n output: RuntimeVarProxy<string>;\n\n /**\n * Optional header/chip label (max 12 chars)\n *\n * Short label displayed as a chip/tag above the question.\n * Accepts static string or RuntimeVar.\n *\n * @example \"Database\"\n */\n header?: OrRuntimeVar<string>;\n\n /**\n * Allow multiple selections\n *\n * When true, user can select multiple options.\n * Output will contain comma-separated values.\n * Accepts static boolean or RuntimeVar.\n *\n * @default false\n */\n multiSelect?: OrRuntimeVar<boolean>;\n}\n\n/**\n * Ask the user a question and store their response\n *\n * Emits as Claude Code's AskUserQuestion tool invocation.\n * The response is stored in the output RuntimeVar for use\n * in subsequent If conditions or interpolation.\n *\n * @example\n * const dbChoice = useRuntimeVar<string>('DB_CHOICE');\n *\n * <AskUser\n * question=\"Which database should we use?\"\n * header=\"Database\"\n * options={[\n * { value: 'postgres', label: 'PostgreSQL (Recommended)', description: 'Best for production' },\n * { value: 'sqlite', label: 'SQLite', description: 'Good for development' },\n * ]}\n * output={dbChoice}\n * />\n *\n * <If condition={dbChoice === 'postgres'}>\n * <p>Setting up PostgreSQL...</p>\n * </If>\n */\nexport function AskUser(_props: AskUserProps): null {\n // Compile-time only - transformer handles emission\n return null;\n}\n\n// ============================================================================\n// Type Guard\n// ============================================================================\n\n/**\n * Marker symbol for AskUser component\n */\nexport const ASK_USER_MARKER = Symbol.for('react-agentic:ask-user');\n\n// Add marker to component\nObject.defineProperty(AskUser, ASK_USER_MARKER, { value: true });\n","/**\n * IR Node Types - Discriminated unions for intermediate representation\n *\n * All nodes have a `kind` property that serves as the discriminator,\n * enabling exhaustive type checking in switch statements.\n */\n\n// ============================================================================\n// Inline Nodes (within paragraphs, headings, etc.)\n// ============================================================================\n\n/**\n * Plain text content\n */\nexport interface TextNode {\n kind: 'text';\n value: string;\n}\n\n/**\n * Bold/strong text - uses asterisks (**text**)\n */\nexport interface BoldNode {\n kind: 'bold';\n children: InlineNode[];\n}\n\n/**\n * Italic/emphasis text - uses asterisks (*text*)\n */\nexport interface ItalicNode {\n kind: 'italic';\n children: InlineNode[];\n}\n\n/**\n * Inline code - uses backticks (`code`)\n */\nexport interface InlineCodeNode {\n kind: 'inlineCode';\n value: string;\n}\n\n/**\n * Hyperlink with optional text\n */\nexport interface LinkNode {\n kind: 'link';\n url: string;\n children: InlineNode[];\n}\n\n/**\n * Line break within a block element\n */\nexport interface LineBreakNode {\n kind: 'lineBreak';\n}\n\n/**\n * Union of all inline node types\n */\nexport type InlineNode =\n | TextNode\n | BoldNode\n | ItalicNode\n | InlineCodeNode\n | LinkNode\n | LineBreakNode;\n\n// ============================================================================\n// Block Nodes (standalone elements)\n// ============================================================================\n\n/**\n * Heading levels 1-6\n */\nexport interface HeadingNode {\n kind: 'heading';\n level: 1 | 2 | 3 | 4 | 5 | 6;\n children: InlineNode[];\n}\n\n/**\n * Paragraph containing inline content\n */\nexport interface ParagraphNode {\n kind: 'paragraph';\n children: InlineNode[];\n}\n\n/**\n * List item containing block content\n */\nexport interface ListItemNode {\n kind: 'listItem';\n children: BaseBlockNode[];\n}\n\n/**\n * Ordered or unordered list\n */\nexport interface ListNode {\n kind: 'list';\n ordered: boolean;\n items: ListItemNode[];\n start?: number; // Start number for ordered lists\n}\n\n/**\n * Fenced code block with optional language\n */\nexport interface CodeBlockNode {\n kind: 'codeBlock';\n language?: string;\n content: string;\n}\n\n/**\n * Blockquote containing block content\n */\nexport interface BlockquoteNode {\n kind: 'blockquote';\n children: BaseBlockNode[];\n}\n\n/**\n * Horizontal rule / thematic break\n */\nexport interface ThematicBreakNode {\n kind: 'thematicBreak';\n}\n\n/**\n * Markdown table with optional headers and column alignment\n */\nexport interface TableNode {\n kind: 'table';\n headers?: string[]; // Optional header row\n rows: string[][]; // Data rows (can be empty)\n align?: ('left' | 'center' | 'right')[]; // Per-column alignment\n emptyCell?: string; // Empty cell content (default: \"\")\n}\n\n/**\n * ExecutionContext - emits <execution_context> XML with file paths\n */\nexport interface ExecutionContextNode {\n kind: 'executionContext';\n paths: string[]; // File paths to reference\n prefix: string; // Path prefix (default: '@')\n children: BaseBlockNode[]; // Optional additional content\n}\n\n/**\n * SuccessCriteria item data\n */\nexport interface SuccessCriteriaItemData {\n text: string;\n checked: boolean;\n}\n\n/**\n * SuccessCriteria - emits <success_criteria> XML with checkbox list\n */\nexport interface SuccessCriteriaNode {\n kind: 'successCriteria';\n items: SuccessCriteriaItemData[]; // Checkbox items\n}\n\n/**\n * OfferNext route data\n */\nexport interface OfferNextRouteData {\n name: string;\n description?: string;\n path: string;\n}\n\n/**\n * OfferNext - emits <offer_next> XML with route bullet list\n */\nexport interface OfferNextNode {\n kind: 'offerNext';\n routes: OfferNextRouteData[]; // Route navigation items\n}\n\n/**\n * XML-style block element (e.g., <example>content</example>)\n * Used for Claude Code's special sections\n */\nexport interface XmlBlockNode {\n kind: 'xmlBlock';\n name: string;\n attributes?: Record<string, string>;\n children: BaseBlockNode[];\n}\n\n/**\n * Invisible grouping container for tight block spacing\n * Used for <div> without name attribute - no wrapper output, single newlines between children\n */\nexport interface GroupNode {\n kind: 'group';\n children: BaseBlockNode[];\n}\n\n/**\n * Raw markdown content passed through without transformation\n */\nexport interface RawMarkdownNode {\n kind: 'raw';\n content: string;\n}\n\n/**\n * Indented block - prepends spaces to each line of content\n */\nexport interface IndentNode {\n kind: 'indent';\n spaces: number; // Number of spaces to indent (default: 2)\n children: BaseBlockNode[];\n}\n\n// SpawnAgent types moved to runtime-nodes.ts\n\n/**\n * Shell variable assignment from useVariable/Assign\n * Emits as bash code block with variable assignment\n */\nexport interface AssignNode {\n kind: 'assign';\n variableName: string; // Shell variable name (e.g., 'PHASE_DIR')\n assignment: {\n type: 'bash' | 'value' | 'env'; // bash: VAR=$(...), value: VAR=..., env: VAR=$ENV\n content: string; // The bash command, static value, or env var name\n };\n comment?: string; // Optional inline comment (e.g., \"Get phase from roadmap\")\n blankBefore?: boolean; // Insert extra blank line before this assignment (from <br/>)\n}\n\n/**\n * Group of shell variable assignments\n * Emits as single bash code block with all assignments\n */\nexport interface AssignGroupNode {\n kind: 'assignGroup';\n assignments: AssignNode[]; // Child Assign nodes\n}\n\n// IfNode, ElseNode, LoopNode moved to runtime-nodes.ts\n\n/**\n * Reference to an agent's output in the IR\n * Captures the agent name for output binding\n */\nexport interface OutputReference {\n kind: 'outputReference';\n /** Agent name this output refers to */\n agent: string;\n}\n\n/**\n * OnStatus block - conditional based on agent return status\n * Emits as **On {status}:** prose pattern\n */\nexport interface OnStatusNode {\n kind: 'onStatus';\n /** Output reference from useOutput */\n outputRef: OutputReference;\n /** Status to match (SUCCESS, BLOCKED, etc.) */\n status: 'SUCCESS' | 'BLOCKED' | 'NOT_FOUND' | 'ERROR' | 'CHECKPOINT';\n /** Block content for this status */\n children: BaseBlockNode[];\n}\n\n/**\n * Read state value from registry\n * Emits as bash JSON read operation\n */\nexport interface ReadStateNode {\n kind: 'readState';\n /** State key identifier (e.g., 'projectContext') */\n stateKey: string;\n /** Variable to store result (from useVariable) */\n variableName: string;\n /** Optional: nested field path (e.g., 'user.preferences.theme') */\n field?: string;\n}\n\n/**\n * Write state value to registry\n * Emits as bash JSON write operation\n */\nexport interface WriteStateNode {\n kind: 'writeState';\n /** State key identifier (e.g., 'projectContext') */\n stateKey: string;\n /** Write mode: 'field' for single field, 'merge' for partial update */\n mode: 'field' | 'merge';\n /** For field mode: nested field path (e.g., 'user.name') */\n field?: string;\n /** Value to write - either variable reference or literal */\n value: {\n type: 'variable' | 'literal';\n content: string;\n };\n}\n\n/**\n * PromptTemplate node - wraps children in markdown code fence\n * Used to avoid nested escaping in prompt content\n */\nexport interface PromptTemplateNode {\n kind: 'promptTemplate';\n children: BaseBlockNode[];\n}\n\n/**\n * File entry for ReadFilesNode\n */\nexport interface ReadFileEntry {\n /** Variable name for content (e.g., \"STATE_CONTENT\") */\n varName: string;\n /** File path (may contain variable references) */\n path: string;\n /** Whether file is required (affects error suppression) */\n required: boolean;\n}\n\n/**\n * ReadFiles node - emit bash commands to read multiple files\n * Emits as single bash code block with cat commands\n */\nexport interface ReadFilesNode {\n kind: 'readFiles';\n files: ReadFileEntry[];\n}\n\n/**\n * Step output variant\n */\nexport type StepVariant = 'heading' | 'bold' | 'xml';\n\n/**\n * Numbered workflow step\n * Emits formatted step section based on variant\n */\nexport interface StepNode {\n kind: 'step';\n /** Step number (string to support \"1.1\" sub-steps) */\n number: string;\n /** Step name/title */\n name: string;\n /** Output format variant (default: 'heading') */\n variant: StepVariant;\n /** Step body content */\n children: BaseBlockNode[];\n}\n\n/**\n * Base union of all block node types (without runtime nodes)\n * Use BlockNode from runtime-nodes.ts for the full union including runtime nodes\n */\nexport type BaseBlockNode =\n | HeadingNode\n | ParagraphNode\n | ListNode\n | CodeBlockNode\n | BlockquoteNode\n | ThematicBreakNode\n | TableNode\n | ExecutionContextNode\n | SuccessCriteriaNode\n | OfferNextNode\n | XmlBlockNode\n | GroupNode\n | RawMarkdownNode\n | IndentNode\n | AssignNode\n | AssignGroupNode\n | OnStatusNode\n | ReadStateNode\n | WriteStateNode\n | ReadFilesNode\n | PromptTemplateNode\n | MCPServerNode\n | StepNode;\n\n/**\n * Internal alias for backward compatibility within this file\n * @internal\n */\ntype BlockNode = BaseBlockNode;\n\n// ============================================================================\n// Special Nodes\n// ============================================================================\n\n// FrontmatterNode moved to runtime-nodes.ts\n\n/**\n * Agent YAML frontmatter data\n * Uses GSD format: tools as space-separated string, not array like Command\n */\nexport interface AgentFrontmatterNode {\n kind: 'agentFrontmatter';\n name: string; // Required: agent identifier (e.g., 'researcher')\n description: string; // Required: agent purpose\n tools?: string; // Optional: space-separated tool names (e.g., 'Read Grep Glob')\n color?: string; // Optional: terminal color (e.g., 'cyan')\n inputType?: TypeReference; // Optional: generic type parameter if provided (e.g., 'ResearcherInput')\n outputType?: TypeReference; // Optional: second generic type parameter (e.g., 'ResearcherOutput')\n}\n\n// DocumentNode moved to runtime-nodes.ts\n\n/**\n * Agent document root node\n * Similar to DocumentNode but with required AgentFrontmatterNode\n */\nexport interface AgentDocumentNode {\n kind: 'agentDocument';\n frontmatter: AgentFrontmatterNode; // Required for agents (vs optional for Command)\n children: BaseBlockNode[];\n}\n\n// ============================================================================\n// MCP Configuration Nodes\n// ============================================================================\n\n/**\n * MCP Server configuration node\n * Represents a single MCP server definition\n */\nexport interface MCPServerNode {\n kind: 'mcpServer';\n name: string; // Server name (key in mcpServers object)\n type: 'stdio' | 'http' | 'sse'; // Transport type\n // Stdio-specific\n command?: string; // Executable command\n args?: string[]; // Command arguments\n // HTTP/SSE-specific\n url?: string; // Remote URL\n headers?: Record<string, string>; // Request headers\n // Common\n env?: Record<string, string>; // Environment variables\n}\n\n/**\n * MCP configuration document root node\n * Contains one or more MCP server definitions\n */\nexport interface MCPConfigDocumentNode {\n kind: 'mcpConfigDocument';\n servers: MCPServerNode[];\n}\n\n// ============================================================================\n// State Document Nodes\n// ============================================================================\n\n/**\n * Flattened state schema field\n * Represents a single column in the generated SQLite table\n */\nexport interface StateSchemaField {\n /** Column name (flattened path, e.g., \"config_debug\") */\n name: string;\n /** TypeScript type (string, number, boolean, Date) */\n tsType: string;\n /** SQL type (TEXT, INTEGER) */\n sqlType: 'TEXT' | 'INTEGER';\n /** Default value for init SQL */\n defaultValue: string;\n /** Optional: enum values for CHECK constraint */\n enumValues?: string[];\n}\n\n/**\n * Parsed state schema from TypeScript interface\n * Fields are flattened (nested objects become underscore-separated)\n */\nexport interface StateSchema {\n /** Interface name (e.g., \"ReleasesState\") */\n interfaceName: string;\n /** Flattened fields for SQL columns */\n fields: StateSchemaField[];\n}\n\n/**\n * Custom operation node\n * Represents an Operation child of State component\n */\nexport interface OperationNode {\n kind: 'operation';\n /** Operation name (e.g., \"record\") - becomes skill suffix */\n name: string;\n /** SQL template body with $variable placeholders */\n sqlTemplate: string;\n /** Inferred argument names from $variable references */\n args: string[];\n}\n\n/**\n * State node representing parsed State component\n */\nexport interface StateNode {\n kind: 'state';\n /** State name (e.g., \"releases\") - becomes skill prefix */\n name: string;\n /** Provider type (only \"sqlite\" for now) */\n provider: 'sqlite';\n /** Provider-specific configuration */\n config: {\n /** Database file path */\n database: string;\n };\n /** Parsed schema from generic type parameter */\n schema: StateSchema;\n /** Custom operations defined as children */\n operations: OperationNode[];\n}\n\n/**\n * State document root node\n * Produces multiple skill files in .claude/skills/\n */\nexport interface StateDocumentNode {\n kind: 'stateDocument';\n /** The State definition */\n state: StateNode;\n}\n\n// ============================================================================\n// Skill Nodes\n// ============================================================================\n\n/**\n * Skill YAML frontmatter data\n * Uses Claude Code skills format with kebab-case field names\n */\nexport interface SkillFrontmatterNode {\n kind: 'skillFrontmatter';\n name: string; // Required: skill directory name\n description: string; // Required: what/when description\n disableModelInvocation?: boolean; // Optional: prevent auto-invoke\n userInvocable?: boolean; // Optional: hide from / menu\n allowedTools?: string[]; // Optional: tools without permission\n argumentHint?: string; // Optional: [filename] hint\n model?: string; // Optional: model override\n context?: 'fork'; // Optional: run in subagent\n agent?: string; // Optional: which subagent\n}\n\n/**\n * SkillFile node for generated files within skill\n * Each SkillFile produces an output file in the skill directory\n */\nexport interface SkillFileNode {\n kind: 'skillFile';\n name: string; // Output filename (e.g., \"reference.md\")\n children: BaseBlockNode[]; // Content to generate\n}\n\n/**\n * SkillStatic node for static file copying\n * Copies files from source location to skill directory\n */\nexport interface SkillStaticNode {\n kind: 'skillStatic';\n src: string; // Source path relative to TSX file\n dest?: string; // Optional destination path override\n}\n\n/**\n * Skill document root node\n * Produces a skill directory with SKILL.md plus optional supporting files\n */\nexport interface SkillDocumentNode {\n kind: 'skillDocument';\n frontmatter: SkillFrontmatterNode; // Required (like Agent)\n children: BaseBlockNode[]; // SKILL.md body content\n files: SkillFileNode[]; // Generated files from SkillFile\n statics: SkillStaticNode[]; // Static files from SkillStatic\n}\n\n/**\n * Reference to a TypeScript type across files\n * Used for tracking Agent interface imports in SpawnAgent\n * Actual validation happens in Phase 11\n */\nexport interface TypeReference {\n kind: 'typeReference';\n name: string; // Type/interface name (e.g., 'ResearcherInput')\n sourceFile?: string; // Relative path to defining file\n resolved?: boolean; // Whether type was successfully resolved\n}\n\n// ============================================================================\n// Union Types\n// ============================================================================\n\n/**\n * Union of all IR node types\n */\nexport type IRNode =\n | BlockNode\n | InlineNode\n | AgentFrontmatterNode\n | SkillFrontmatterNode\n | SkillFileNode\n | SkillStaticNode\n | ListItemNode\n | AgentDocumentNode\n | SkillDocumentNode\n | MCPConfigDocumentNode\n | StateDocumentNode\n | TypeReference;\n\n// ============================================================================\n// Utilities\n// ============================================================================\n\n/**\n * Helper for exhaustiveness checking in switch statements.\n * If TypeScript complains that the argument is not of type 'never',\n * it means there's an unhandled case in the switch.\n */\nexport function assertNever(x: never): never {\n throw new Error(`Unexpected node: ${JSON.stringify(x)}`);\n}\n","/**\n * Runtime IR Node Types\n *\n * Node types for runtime-enabled commands:\n * - Runtime variable declarations and references\n * - Runtime function calls\n * - Typed control flow (condition-based)\n * - User prompts\n *\n * All nodes follow the discriminated union pattern with `kind` property.\n */\n\nimport type { BaseBlockNode, InlineNode } from './nodes.js';\n\n// ============================================================================\n// Runtime Variable Nodes\n// ============================================================================\n\n/**\n * Runtime variable declaration\n *\n * Created from useRuntimeVar<T>('NAME') calls.\n * Tracks the variable name and TypeScript type for validation.\n */\nexport interface RuntimeVarDeclNode {\n kind: 'runtimeVarDecl';\n /** Shell variable name (e.g., 'CTX') */\n varName: string;\n /** TypeScript type name for documentation (e.g., 'InitResult') */\n tsType?: string;\n}\n\n/**\n * Runtime variable reference\n *\n * Created from property access on RuntimeVar proxies.\n * Tracks the full path for jq expression generation.\n */\nexport interface RuntimeVarRefNode {\n kind: 'runtimeVarRef';\n /** Shell variable name (e.g., 'CTX') */\n varName: string;\n /** Property access path (e.g., ['user', 'name']) */\n path: string[];\n}\n\n// ============================================================================\n// Runtime Function Nodes\n// ============================================================================\n\n/**\n * Runtime function call\n *\n * Created from <RuntimeFn.Call args={...} output={...} /> elements.\n * Emits as: VAR=$(node runtime.js fnName '{\"args\"}')\n */\nexport interface RuntimeCallNode {\n kind: 'runtimeCall';\n /** Function name in the runtime registry */\n fnName: string;\n /** JSON-serializable arguments */\n args: Record<string, unknown>;\n /** Output variable name to store result */\n outputVar: string;\n}\n\n// ============================================================================\n// Condition Types\n// ============================================================================\n\n/**\n * Condition expression tree\n *\n * Represents parsed condition expressions for If.\n * Supports references, literals, and logical operators.\n */\nexport type Condition =\n | ConditionRef\n | ConditionLiteral\n | ConditionNot\n | ConditionAnd\n | ConditionOr\n | ConditionEq\n | ConditionNeq\n | ConditionGt\n | ConditionGte\n | ConditionLt\n | ConditionLte;\n\n/**\n * Reference to a runtime variable (truthy check)\n */\nexport interface ConditionRef {\n type: 'ref';\n ref: RuntimeVarRefNode;\n}\n\n/**\n * Literal boolean value\n */\nexport interface ConditionLiteral {\n type: 'literal';\n value: boolean;\n}\n\n/**\n * Logical NOT\n */\nexport interface ConditionNot {\n type: 'not';\n operand: Condition;\n}\n\n/**\n * Logical AND\n */\nexport interface ConditionAnd {\n type: 'and';\n left: Condition;\n right: Condition;\n}\n\n/**\n * Logical OR\n */\nexport interface ConditionOr {\n type: 'or';\n left: Condition;\n right: Condition;\n}\n\n/**\n * Equality check\n */\nexport interface ConditionEq {\n type: 'eq';\n left: Condition;\n right: string | number | boolean;\n}\n\n/**\n * Inequality check\n */\nexport interface ConditionNeq {\n type: 'neq';\n left: Condition;\n right: string | number | boolean;\n}\n\n/**\n * Greater than check\n */\nexport interface ConditionGt {\n type: 'gt';\n left: Condition;\n right: number;\n}\n\n/**\n * Greater than or equal check\n */\nexport interface ConditionGte {\n type: 'gte';\n left: Condition;\n right: number;\n}\n\n/**\n * Less than check\n */\nexport interface ConditionLt {\n type: 'lt';\n left: Condition;\n right: number;\n}\n\n/**\n * Less than or equal check\n */\nexport interface ConditionLte {\n type: 'lte';\n left: Condition;\n right: number;\n}\n\n// ============================================================================\n// Control Flow Nodes\n// ============================================================================\n\n/**\n * If node - condition-based conditional\n *\n * Uses a Condition tree for typed conditional logic.\n */\nexport interface IfNode {\n kind: 'if';\n /** Parsed condition expression tree */\n condition: Condition;\n /** \"then\" block content */\n children: BlockNode[];\n}\n\n/**\n * Else node - paired with If\n */\nexport interface ElseNode {\n kind: 'else';\n /** \"else\" block content */\n children: BlockNode[];\n}\n\n/**\n * Loop node - bounded iteration\n *\n * Executes up to `max` times.\n */\nexport interface LoopNode {\n kind: 'loop';\n /** Maximum iteration count */\n max: number;\n /** Optional counter variable name */\n counterVar?: string;\n /** Loop body content */\n children: BlockNode[];\n}\n\n/**\n * Break node - exit current loop\n */\nexport interface BreakNode {\n kind: 'break';\n /** Optional message to display */\n message?: string;\n}\n\n/**\n * Return node - exit command early\n */\nexport interface ReturnNode {\n kind: 'return';\n /** Optional status code */\n status?: 'SUCCESS' | 'BLOCKED' | 'NOT_FOUND' | 'ERROR' | 'CHECKPOINT';\n /** Optional message to display */\n message?: string;\n}\n\n// ============================================================================\n// AskUser Node\n// ============================================================================\n\n/**\n * Option for AskUser\n */\nexport interface AskUserOptionNode {\n value: string;\n label: string;\n description?: string;\n}\n\n/**\n * AskUser node - prompt user for input\n *\n * Emits as AskUserQuestion tool syntax.\n */\nexport interface AskUserNode {\n kind: 'askUser';\n /** Question text */\n question: string;\n /** Available options */\n options: AskUserOptionNode[];\n /** Output variable name */\n outputVar: string;\n /** Optional header/chip label */\n header?: string;\n /** Allow multiple selections */\n multiSelect: boolean;\n}\n\n// ============================================================================\n// SpawnAgent Node\n// ============================================================================\n\n/**\n * SpawnAgent with output capture\n */\nexport interface SpawnAgentNode {\n kind: 'spawnAgent';\n /** Agent name/reference */\n agent: string;\n /** Model to use */\n model: string;\n /** Human-readable description */\n description: string;\n /** Prompt content or variable */\n prompt?: string;\n /** Input object (alternative to prompt) */\n input?: SpawnAgentInput;\n /** Output variable name to store agent result */\n outputVar?: string;\n /** Load agent from file path */\n loadFromFile?: string;\n}\n\n/**\n * SpawnAgent input types\n */\nexport type SpawnAgentInput =\n | { type: 'object'; properties: InputProperty[] }\n | { type: 'variable'; varName: string };\n\n/**\n * Property in SpawnAgent input object\n */\nexport interface InputProperty {\n name: string;\n value: InputValue;\n}\n\n/**\n * Value types for SpawnAgent input\n */\nexport type InputValue =\n | { type: 'string'; value: string }\n | { type: 'runtimeVarRef'; ref: RuntimeVarRefNode }\n | { type: 'json'; value: unknown };\n\n// ============================================================================\n// Block Node Union\n// ============================================================================\n\n/**\n * Runtime-specific block nodes\n */\nexport type RuntimeBlockNode =\n | RuntimeVarDeclNode\n | RuntimeCallNode\n | IfNode\n | ElseNode\n | LoopNode\n | BreakNode\n | ReturnNode\n | AskUserNode\n | SpawnAgentNode;\n\n/**\n * Union of base and runtime block nodes\n */\nexport type BlockNode = BaseBlockNode | RuntimeBlockNode;\n\n// ============================================================================\n// Document Nodes\n// ============================================================================\n\n/**\n * Command frontmatter\n */\nexport interface FrontmatterNode {\n kind: 'frontmatter';\n data: Record<string, unknown>;\n}\n\n/**\n * Build-time metadata (not emitted to output)\n */\nexport interface DocumentMetadata {\n /** Subfolder for output path (e.g., \"gsd\" → .claude/commands/gsd/cmd.md) */\n folder?: string;\n}\n\n/**\n * Document root node\n *\n * Represents a command that produces dual output:\n * - COMMAND.md (markdown for Claude)\n * - runtime.js (extracted TypeScript functions)\n */\nexport interface DocumentNode {\n kind: 'document';\n frontmatter?: FrontmatterNode;\n /** Build-time metadata (not emitted to output) */\n metadata?: DocumentMetadata;\n /** Runtime variable declarations */\n runtimeVars: RuntimeVarDeclNode[];\n /** Runtime function names used (for extraction) */\n runtimeFunctions: string[];\n /** Body content */\n children: BlockNode[];\n}\n\n// ============================================================================\n// Utilities\n// ============================================================================\n\n/**\n * Type guard for runtime-specific nodes\n */\nexport function isRuntimeNode(node: unknown): node is RuntimeBlockNode {\n if (!node || typeof node !== 'object') return false;\n const kind = (node as { kind?: string }).kind;\n return [\n 'runtimeVarDecl',\n 'runtimeCall',\n 'if',\n 'else',\n 'loop',\n 'break',\n 'return',\n 'askUser',\n 'spawnAgent',\n ].includes(kind ?? '');\n}\n\n/**\n * Type guard for document\n */\nexport function isDocument(node: unknown): node is DocumentNode {\n if (!node || typeof node !== 'object') return false;\n return (node as { kind?: string }).kind === 'document';\n}\n","/**\n * react-agentic - Compile-time safety for Claude Code commands\n *\n * Main entry point - exports components, IR types, and build functions.\n */\n\n// ============================================================================\n// Components - Compile-time JSX components\n// ============================================================================\n\nexport {\n // Core components\n Command,\n Agent,\n SpawnAgent,\n OnStatus,\n Markdown,\n XmlBlock,\n Indent,\n Table,\n List,\n\n // Control flow\n If,\n Else,\n Loop,\n Break,\n Return,\n AskUser,\n\n // Runtime primitives\n useRuntimeVar,\n runtimeFn,\n\n // Agent utilities\n useOutput,\n defineAgent,\n isAgentRef,\n getAgentName,\n getAgentPath,\n\n // RuntimeVar utilities\n isRuntimeVar,\n getRuntimeVarInfo,\n toJqExpression,\n toJqPath,\n // RuntimeFn utilities\n isRuntimeFn,\n getRuntimeFnRegistry,\n clearRuntimeFnRegistry,\n getRuntimeFn,\n\n // Markers\n IF_MARKER,\n ELSE_MARKER,\n LOOP_MARKER,\n BREAK_MARKER,\n RETURN_MARKER,\n ASK_USER_MARKER,\n\n // Types\n type CommandProps,\n type CommandContext,\n type CommandArgument,\n type AgentProps,\n type AgentContext,\n type AgentStatus,\n type BaseOutput,\n type SpawnAgentProps,\n type V3SpawnAgentProps,\n type OnStatusProps,\n type OutputRef,\n type AgentRef,\n type DefineAgentConfig,\n type MarkdownProps,\n type XmlBlockProps,\n type IndentProps,\n type TableProps,\n type TableAlignment,\n type ListProps,\n type IfProps,\n type ElseProps,\n type LoopProps,\n type BreakProps,\n type ReturnProps,\n type ReturnStatus,\n type Condition,\n type AskUserProps,\n type AskUserOption,\n type RuntimeVar,\n type RuntimeVarProxy,\n type OrRuntimeVar,\n type AllowRuntimeVars,\n type RuntimeFunction,\n type RuntimeCallProps,\n type RuntimeCallComponent,\n type RuntimeFnComponent,\n} from './components/index.js';\n\n// ============================================================================\n// IR Types\n// ============================================================================\n\nexport * from './ir/index.js';\n\n// ============================================================================\n// Emitters (Runtime)\n// ============================================================================\n\nexport {\n RuntimeMarkdownEmitter,\n emitDocument,\n emitRuntime,\n extractFunctions,\n generateRuntime,\n isRuntimeFile,\n bundleSingleEntryRuntime,\n bundleCodeSplit,\n extractExportedFunctionNames,\n type ExtractedFunction,\n type RuntimeEmitResult,\n type RuntimeFileInfo,\n type SingleEntryBundleResult,\n type CodeSplitBundleResult,\n} from './emitter/index.js';\n\n// ============================================================================\n// Transformers\n// ============================================================================\n\nexport {\n type RuntimeTransformContext,\n type RuntimeTransformResult,\n type RuntimeVarInfo,\n type RuntimeFunctionInfo,\n type LocalComponentInfo,\n createRuntimeContext,\n extractRuntimeVarDeclarations,\n extractRuntimeFnDeclarations,\n extractLocalComponentDeclarations,\n extractExternalComponentDeclarations,\n transformRuntimeCommand,\n transformToRuntimeBlock,\n transformRuntimeBlockChildren,\n getRuntimeFunctionNames,\n getRuntimeImportPaths,\n} from './parser/transformers/index.js';\n\n// ============================================================================\n// Build Functions\n// ============================================================================\n\nexport {\n buildRuntimeFile,\n detectRuntime,\n hasRuntimeImports,\n type RuntimeBuildResult,\n type RuntimeBuildOptions,\n} from './cli/runtime-build.js';\n\n// ============================================================================\n// Parser Utilities (for CLI compatibility)\n// ============================================================================\n\nexport { createProject } from './parser/utils/project.js';\nexport {\n findRootJsxElement,\n transform,\n getAttributeValue,\n resolveTypeImport,\n extractInterfaceProperties,\n extractPromptPlaceholders,\n // Additional parser utilities\n parseSource,\n parseFile,\n getElementName,\n getJsxChildren,\n isWhitespaceOnlyText,\n normalizeWhitespace,\n extractText,\n extractTypeArguments,\n getArrayAttributeValue,\n extractVariableDeclarations,\n extractInputObjectLiteral,\n // V1 Transformer class\n Transformer,\n type JsxChild,\n type ExtractedVariable,\n} from './parser/index.js';\n\n// ============================================================================\n// Schema Primitives\n// ============================================================================\n\nexport { defineVars, defineFiles, defineContext } from './primitives/schema.js';\n\n// ============================================================================\n// Additional Emitters\n// ============================================================================\n\nexport { emit, emitAgent, emitSkill, emitSkillFile, emitSettings, mergeSettings } from './emitter/index.js';\n\n// ============================================================================\n// Semantic Components\n// ============================================================================\n\nexport {\n ExecutionContext,\n type ExecutionContextProps,\n} from './workflow/sections/index.js';\n","/**\n * Parser module - TSX parsing and JSX extraction\n */\n\nexport * from './parser.js';\nexport * from './transformer.js';\n","/**\n * Transformer - JSX AST to IR Node transformation\n *\n * Converts parsed JSX elements from ts-morph into IR nodes\n * for emission to Markdown.\n */\n\nimport {\n Node,\n JsxElement,\n JsxSelfClosingElement,\n JsxFragment,\n JsxOpeningElement,\n JsxSpreadAttribute,\n SourceFile,\n TemplateExpression,\n PropertyAccessExpression,\n ObjectLiteralExpression,\n BinaryExpression,\n} from 'ts-morph';\nimport { TranspileError, getNodeLocation, getSourceCode } from '../cli/errors.js';\nimport type {\n BaseBlockNode,\n BlockNode,\n InlineNode,\n AgentDocumentNode,\n AgentFrontmatterNode,\n ListNode,\n ListItemNode,\n BlockquoteNode,\n CodeBlockNode,\n LinkNode,\n FrontmatterNode,\n XmlBlockNode,\n GroupNode,\n SpawnAgentNode,\n SpawnAgentInput,\n TypeReference,\n AssignNode,\n AssignGroupNode,\n IfNode,\n ElseNode,\n LoopNode,\n OnStatusNode,\n SkillDocumentNode,\n SkillFrontmatterNode,\n SkillFileNode,\n SkillStaticNode,\n ReadStateNode,\n WriteStateNode,\n MCPServerNode,\n MCPConfigDocumentNode,\n StateDocumentNode,\n StateNode,\n OperationNode,\n StateSchema,\n TableNode,\n ExecutionContextNode,\n SuccessCriteriaNode,\n SuccessCriteriaItemData,\n OfferNextNode,\n OfferNextRouteData,\n StepNode,\n StepVariant,\n ReadFilesNode,\n ReadFileEntry,\n PromptTemplateNode,\n} from '../ir/index.js';\nimport { getElementName, getAttributeValue, getTestAttributeValue, extractText, extractInlineText, getArrayAttributeValue, resolveSpreadAttribute, resolveComponentImport, extractTypeArguments, extractVariableDeclarations, extractInputObjectLiteral, resolveTypeImport, extractInterfaceProperties, extractStateSchema, extractSqlArguments, analyzeRenderPropsChildren, type ExtractedVariable, type RenderPropsInfo } from './parser.js';\n\n// Document transformers - extracted functions for Agent, Skill, MCPConfig, State\nimport {\n transformAgent as documentTransformAgent,\n transformSkill as documentTransformSkill,\n transformMCPConfig as documentTransformMCPConfig,\n transformState as documentTransformState,\n} from './transformers/document.js';\nimport type { TransformContext } from './transformers/types.js';\n\n// ============================================================================\n// Utility Functions\n// ============================================================================\n\n/**\n * Convert PascalCase component name to snake_case XML tag name\n * Example: DeviationRules -> deviation_rules\n */\nfunction toSnakeCase(name: string): string {\n return name.replace(/([A-Z])/g, '_$1').toLowerCase().replace(/^_/, '');\n}\n\n// ============================================================================\n// Element Classification\n// ============================================================================\n\n/**\n * HTML elements supported by the transformer\n */\nconst HTML_ELEMENTS = new Set([\n 'h1', 'h2', 'h3', 'h4', 'h5', 'h6',\n 'p', 'div', 'span', 'ul', 'ol', 'li',\n 'a', 'b', 'i', 'strong', 'em', 'code',\n 'pre', 'blockquote', 'br', 'hr',\n]);\n\n/**\n * Inline HTML elements that should be wrapped in paragraphs when at block level\n */\nconst INLINE_ELEMENTS = new Set([\n 'a', 'b', 'i', 'strong', 'em', 'code', 'span', 'br',\n]);\n\n/**\n * Check if a tag name represents an inline element\n */\nfunction isInlineElement(tagName: string): boolean {\n return INLINE_ELEMENTS.has(tagName);\n}\n\n/**\n * Special component names that are NOT custom user components\n */\nconst SPECIAL_COMPONENTS = new Set([\n 'Command', 'Markdown', 'XmlBlock', 'Agent', 'SpawnAgent', 'Assign', 'AssignGroup', 'If', 'Else', 'Loop', 'OnStatus',\n 'Skill', 'SkillFile', 'SkillStatic', 'ReadState', 'WriteState',\n 'MCPServer', 'MCPStdioServer', 'MCPHTTPServer', 'MCPConfig', 'State', 'Operation', 'Table', 'List',\n // Semantic workflow components\n 'ExecutionContext', 'SuccessCriteria', 'OfferNext', 'XmlSection',\n 'DeviationRules', 'CommitRules', 'WaveExecution', 'CheckpointHandling',\n // Step workflow primitive\n 'Step',\n // Code block primitives\n 'Bash',\n // File reading\n 'ReadFiles',\n // Template primitives\n 'PromptTemplate',\n]);\n\n/**\n * Check if a tag name represents a custom user-defined component\n *\n * Custom components:\n * - Are NOT HTML elements\n * - Are NOT special components (Command, Markdown)\n * - Start with uppercase (React convention)\n */\nexport function isCustomComponent(tagName: string): boolean {\n if (HTML_ELEMENTS.has(tagName)) return false;\n if (SPECIAL_COMPONENTS.has(tagName)) return false;\n // React convention: custom components start with uppercase\n return /^[A-Z]/.test(tagName);\n}\n\n/**\n * Validate that a string is a valid XML tag name\n * Per XML 1.0 spec (simplified): starts with letter or underscore,\n * followed by letters, digits, underscores, hyphens, or periods.\n * Cannot start with 'xml' (case-insensitive).\n */\nconst XML_NAME_REGEX = /^[a-zA-Z_][a-zA-Z0-9_.\\-]*$/;\n\nfunction isValidXmlName(name: string): boolean {\n if (!name) return false;\n if (!XML_NAME_REGEX.test(name)) return false;\n if (name.toLowerCase().startsWith('xml')) return false;\n return true;\n}\n\n/**\n * Context values available for render props interpolation\n */\ninterface RenderPropsContext {\n /** Parameter name used in arrow function (e.g., 'ctx') */\n paramName: string;\n /** Context values that can be interpolated */\n values: Record<string, string>;\n}\n\nexport class Transformer {\n /** Source file for component resolution (optional - only needed for composition) */\n private sourceFile: SourceFile | undefined;\n /** Visited paths for circular import detection */\n private visitedPaths: Set<string> = new Set();\n /** Extracted useVariable declarations from source file */\n private variables: Map<string, ExtractedVariable> = new Map();\n /** Extracted useOutput declarations: identifier name -> agent name */\n private outputs: Map<string, string> = new Map();\n /** Extracted useStateRef declarations: identifier name -> state key */\n private stateRefs: Map<string, string> = new Map();\n /** Current render props context for interpolation (set during Command/Agent transformation) */\n private renderPropsContext: RenderPropsContext | undefined;\n\n /**\n * Create a TranspileError with source location context from a node\n */\n private createError(message: string, node: Node): TranspileError {\n const location = getNodeLocation(node);\n const sourceCode = getSourceCode(node.getSourceFile());\n return new TranspileError(message, location, sourceCode);\n }\n\n /**\n * Build a TransformContext from instance state for delegation to document transformers\n */\n private buildContext(): TransformContext {\n return {\n sourceFile: this.sourceFile,\n visitedPaths: this.visitedPaths,\n variables: this.variables,\n outputs: this.outputs,\n stateRefs: this.stateRefs,\n renderPropsContext: this.renderPropsContext,\n createError: this.createError.bind(this),\n // Provide V1 transformBlockChildren - ignores ctx since we use instance state\n transformBlockChildren: (children: Node[], _ctx: TransformContext) =>\n this.transformBlockChildren(children),\n };\n }\n\n /**\n * Transform a root JSX element/fragment into AgentDocumentNode, SkillDocumentNode, MCPConfigDocumentNode, or StateDocumentNode\n *\n * Note: Command documents use the runtime transformer (transformRuntimeCommand) for runtime feature support.\n *\n * @param node - The root JSX element/fragment to transform\n * @param sourceFile - Optional source file for component composition resolution\n */\n transform(node: JsxElement | JsxSelfClosingElement | JsxFragment, sourceFile?: SourceFile): AgentDocumentNode | SkillDocumentNode | MCPConfigDocumentNode | StateDocumentNode {\n // Initialize state for this transformation\n this.sourceFile = sourceFile;\n this.visitedPaths = new Set();\n this.variables = new Map();\n this.outputs = new Map();\n this.stateRefs = new Map();\n\n if (sourceFile) {\n this.visitedPaths.add(sourceFile.getFilePath());\n // Extract useVariable declarations before JSX processing\n this.variables = extractVariableDeclarations(sourceFile);\n // Extract useOutput declarations for OnStatus tracking\n this.outputs = this.extractOutputDeclarations(sourceFile);\n // Extract useStateRef declarations for ReadState/WriteState tracking\n this.stateRefs = this.extractStateRefDeclarations(sourceFile);\n }\n\n // Check for Command, Agent, Skill, or MCPConfig wrapper at root level\n if (Node.isJsxElement(node) || Node.isJsxSelfClosingElement(node)) {\n const name = getElementName(node);\n if (name === 'Command') {\n return this.transformCommand(node);\n }\n if (name === 'Agent') {\n return this.transformAgent(node);\n }\n if (name === 'Skill') {\n return this.transformSkill(node);\n }\n if (name === 'MCPConfig') {\n return this.transformMCPConfig(node);\n }\n if (name === 'State') {\n return this.transformState(node);\n }\n }\n\n // Fragment or unwrapped element: not supported in V1 transformer\n // Documents must use a wrapper component (Command, Agent, Skill, MCPConfig, State)\n // For Commands, use the runtime transformer which supports runtime features\n if (Node.isJsxFragment(node)) {\n throw new Error(\n 'JSX Fragment not supported. Use a document wrapper: <Agent>, <Skill>, <MCPConfig>, <State>, or use runtime transformer for <Command>.'\n );\n }\n\n // Single element without wrapper\n throw new Error(\n `Unknown root element. Use a document wrapper: <Agent>, <Skill>, <MCPConfig>, <State>, or use runtime transformer for <Command>.`\n );\n }\n\n /**\n * Merge Command props from spread attributes and explicit attributes\n *\n * Processes attributes in order - later props override earlier ones.\n * Supports spread attributes: {...baseProps}\n * Supports explicit attributes: name=\"value\" or name={\"value\"} or name={[\"a\", \"b\"]}\n */\n private mergeCommandProps(opening: JsxOpeningElement | JsxSelfClosingElement): Record<string, unknown> {\n const merged: Record<string, unknown> = {};\n\n for (const attr of opening.getAttributes()) {\n if (Node.isJsxSpreadAttribute(attr)) {\n // Resolve spread and merge\n const spreadProps = resolveSpreadAttribute(attr);\n Object.assign(merged, spreadProps);\n } else if (Node.isJsxAttribute(attr)) {\n // Explicit prop\n const attrName = attr.getNameNode().getText();\n\n // Try string value first\n const stringValue = getAttributeValue(opening, attrName);\n if (stringValue !== undefined) {\n merged[attrName] = stringValue;\n continue;\n }\n\n // Try array value\n const arrayValue = getArrayAttributeValue(opening, attrName);\n if (arrayValue !== undefined) {\n merged[attrName] = arrayValue;\n }\n }\n }\n\n return merged;\n }\n\n /**\n * Transform a Command element\n *\n * NOTE: This transformer is deprecated for Commands. Commands should use the runtime transformer\n * which supports runtime features (useRuntimeVar, If/Else/Loop, etc.).\n */\n private transformCommand(node: JsxElement | JsxSelfClosingElement): never {\n throw this.createError(\n 'This transformer is deprecated for Commands. Use the runtime transformer (transformRuntimeCommand) instead. ' +\n 'Commands should import from react-agentic and use runtime features (useRuntimeVar, If, Else, Loop).',\n node\n );\n }\n\n /**\n * Transform an Agent element to AgentDocumentNode with frontmatter\n * Delegates to document.ts transformAgent()\n */\n private transformAgent(node: JsxElement | JsxSelfClosingElement): AgentDocumentNode {\n return documentTransformAgent(node, this.buildContext());\n }\n\n /**\n * Transform a Skill element to SkillDocumentNode with frontmatter, body, files, and statics\n * Delegates to document.ts transformSkill()\n */\n private transformSkill(node: JsxElement | JsxSelfClosingElement): SkillDocumentNode {\n return documentTransformSkill(node, this.buildContext());\n }\n\n private transformFragmentChildren(node: JsxFragment): BlockNode[] {\n // Use helper for If/Else sibling detection\n return this.transformBlockChildren(node.getJsxChildren());\n }\n\n /**\n * Transform arrow function body to IR blocks\n * Handles both block body { return ... } and expression body\n */\n private transformArrowFunctionBody(arrowFn: import('ts-morph').ArrowFunction): BlockNode[] {\n const body = arrowFn.getBody();\n\n // Handle block body: { return <div>...</div>; }\n if (Node.isBlock(body)) {\n const returnStmt = body.getStatements()\n .find(stmt => Node.isReturnStatement(stmt));\n\n if (returnStmt && Node.isReturnStatement(returnStmt)) {\n const returnExpr = returnStmt.getExpression();\n if (returnExpr) {\n // Check if it's JSX\n if (Node.isJsxElement(returnExpr) || Node.isJsxSelfClosingElement(returnExpr)) {\n const block = this.transformToBlock(returnExpr);\n return block ? [block] : [];\n }\n if (Node.isJsxFragment(returnExpr)) {\n return this.transformFragmentChildren(returnExpr);\n }\n // Handle parenthesized JSX: return (<div>...</div>)\n if (Node.isParenthesizedExpression(returnExpr)) {\n const inner = returnExpr.getExpression();\n if (Node.isJsxElement(inner) || Node.isJsxSelfClosingElement(inner)) {\n const block = this.transformToBlock(inner);\n return block ? [block] : [];\n }\n if (Node.isJsxFragment(inner)) {\n return this.transformFragmentChildren(inner);\n }\n }\n }\n }\n return [];\n }\n\n // Handle expression body: (ctx) => <div>...</div>\n if (Node.isJsxElement(body) || Node.isJsxSelfClosingElement(body)) {\n const block = this.transformToBlock(body);\n return block ? [block] : [];\n }\n if (Node.isJsxFragment(body)) {\n return this.transformFragmentChildren(body);\n }\n // Handle parenthesized expression body: (ctx) => (<div>...</div>)\n if (Node.isParenthesizedExpression(body)) {\n const inner = body.getExpression();\n if (Node.isJsxElement(inner) || Node.isJsxSelfClosingElement(inner)) {\n const block = this.transformToBlock(inner);\n return block ? [block] : [];\n }\n if (Node.isJsxFragment(inner)) {\n return this.transformFragmentChildren(inner);\n }\n }\n\n return [];\n }\n\n private transformToBlock(node: Node): BlockNode | null {\n if (Node.isJsxText(node)) {\n // Whitespace-only text between block elements - skip\n const text = extractText(node);\n if (!text) return null;\n // Standalone text becomes paragraph\n return { kind: 'paragraph', children: [{ kind: 'text', value: text }] };\n }\n\n if (Node.isJsxElement(node) || Node.isJsxSelfClosingElement(node)) {\n const name = getElementName(node);\n return this.transformElement(name, node);\n }\n\n return null; // JsxExpression etc - handle later\n }\n\n private transformElement(name: string, node: JsxElement | JsxSelfClosingElement): BlockNode | null {\n // Heading elements\n const headingMatch = name.match(/^h([1-6])$/);\n if (headingMatch) {\n const level = parseInt(headingMatch[1], 10) as 1 | 2 | 3 | 4 | 5 | 6;\n const children = Node.isJsxElement(node)\n ? this.transformInlineChildren(node)\n : [];\n return { kind: 'heading', level, children };\n }\n\n // Paragraph\n if (name === 'p') {\n const children = Node.isJsxElement(node)\n ? this.transformInlineChildren(node)\n : [];\n return { kind: 'paragraph', children };\n }\n\n // Self-closing hr\n if (name === 'hr') {\n return { kind: 'thematicBreak' };\n }\n\n // Unordered list\n if (name === 'ul') {\n return this.transformList(node, false);\n }\n\n // Ordered list\n if (name === 'ol') {\n return this.transformList(node, true);\n }\n\n // Blockquote\n if (name === 'blockquote') {\n return this.transformBlockquote(node);\n }\n\n // Code block (pre containing code)\n if (name === 'pre') {\n return this.transformCodeBlock(node);\n }\n\n // XML block via div with name attribute\n if (name === 'div') {\n return this.transformDiv(node);\n }\n\n // XmlBlock component\n if (name === 'XmlBlock') {\n return this.transformXmlBlock(node);\n }\n\n // SpawnAgent block element (inside Command)\n if (name === 'SpawnAgent') {\n return this.transformSpawnAgent(node);\n }\n\n // Assign block element (variable assignment)\n if (name === 'Assign') {\n return this.transformAssign(node);\n }\n\n // AssignGroup block element (grouped variable assignments)\n if (name === 'AssignGroup') {\n return this.transformAssignGroup(node);\n }\n\n // If component - conditional block\n if (name === 'If') {\n return this.transformIf(node);\n }\n\n // Else component - standalone is an error (must follow If as sibling)\n if (name === 'Else') {\n throw this.createError('<Else> must follow <If> as sibling', node);\n }\n\n // Loop component - iteration block\n if (name === 'Loop') {\n return this.transformLoop(node);\n }\n\n // OnStatus component - status-based conditional block\n if (name === 'OnStatus') {\n return this.transformOnStatus(node);\n }\n\n // ReadState component - read state from registry\n if (name === 'ReadState') {\n return this.transformReadState(node);\n }\n\n // WriteState component - write state to registry\n if (name === 'WriteState') {\n return this.transformWriteState(node);\n }\n\n // Table component - structured props\n if (name === 'Table') {\n return this.transformTable(node);\n }\n\n // List component - structured props\n if (name === 'List') {\n return this.transformPropList(node);\n }\n\n // Semantic workflow components\n if (name === 'ExecutionContext') {\n return this.transformExecutionContext(node);\n }\n\n if (name === 'SuccessCriteria') {\n return this.transformSuccessCriteria(node);\n }\n\n if (name === 'OfferNext') {\n return this.transformOfferNext(node);\n }\n\n if (name === 'XmlSection') {\n return this.transformXmlSection(node);\n }\n\n if (name === 'DeviationRules' || name === 'CommitRules' || name === 'WaveExecution' || name === 'CheckpointHandling') {\n return this.transformXmlWrapper(name, node);\n }\n\n // Step workflow primitive\n if (name === 'Step') {\n return this.transformStep(node);\n }\n\n // Bash code block primitive\n if (name === 'Bash') {\n return this.transformBash(node);\n }\n\n // ReadFiles - batch file reading\n if (name === 'ReadFiles') {\n return this.transformReadFiles(node);\n }\n\n // PromptTemplate - wrap content in markdown code fence\n if (name === 'PromptTemplate') {\n return this.transformPromptTemplate(node);\n }\n\n // Markdown passthrough\n if (name === 'Markdown') {\n return this.transformMarkdown(node);\n }\n\n // Custom component composition\n if (isCustomComponent(name)) {\n return this.transformCustomComponent(name, node);\n }\n\n throw this.createError(`Unsupported block element: <${name}>`, node);\n }\n\n private transformList(node: JsxElement | JsxSelfClosingElement, ordered: boolean): ListNode {\n if (Node.isJsxSelfClosingElement(node)) {\n return { kind: 'list', ordered, items: [] };\n }\n\n const items: ListItemNode[] = [];\n for (const child of node.getJsxChildren()) {\n if (Node.isJsxElement(child)) {\n const childName = getElementName(child);\n if (childName === 'li') {\n items.push(this.transformListItem(child));\n } else {\n throw this.createError(`Expected <li> inside list, got <${childName}>`, child);\n }\n } else if (Node.isJsxText(child) && !child.containsOnlyTriviaWhiteSpaces()) {\n throw this.createError('Lists can only contain <li> elements', child);\n }\n // Skip whitespace-only text nodes\n }\n\n return { kind: 'list', ordered, items };\n }\n\n private transformListItem(node: JsxElement): ListItemNode {\n // List items can contain blocks (paragraphs, nested lists) or inline content\n // We need to collect inline content together to preserve spacing between elements\n const children: BlockNode[] = [];\n const jsxChildren = node.getJsxChildren();\n\n // Helper to check if a child is block-level content\n const isBlockContent = (child: Node): boolean => {\n if (Node.isJsxElement(child) || Node.isJsxSelfClosingElement(child)) {\n const name = getElementName(child);\n return name === 'ul' || name === 'ol' || name === 'p';\n }\n return false;\n };\n\n // Collect inline content sequences and process them together\n let inlineSequence: Node[] = [];\n\n const flushInlineSequence = () => {\n if (inlineSequence.length === 0) return;\n\n // Process all inline nodes together, preserving spacing\n const inlines: InlineNode[] = [];\n for (const child of inlineSequence) {\n const inline = this.transformToInline(child);\n if (inline) inlines.push(inline);\n }\n\n // Trim only the outer boundaries (preserves internal spacing)\n this.trimBoundaryTextNodes(inlines);\n\n if (inlines.length > 0) {\n // Merge into last paragraph or create new one\n const lastChild = children[children.length - 1];\n if (lastChild?.kind === 'paragraph') {\n lastChild.children.push(...inlines);\n } else {\n children.push({ kind: 'paragraph', children: inlines });\n }\n }\n\n inlineSequence = [];\n };\n\n for (const child of jsxChildren) {\n if (isBlockContent(child)) {\n // Flush any pending inline content before block\n flushInlineSequence();\n\n // Process block content\n const childName = getElementName(child as JsxElement | JsxSelfClosingElement);\n if (childName === 'ul' || childName === 'ol') {\n const nestedList = this.transformElement(childName, child as JsxElement);\n if (nestedList) children.push(nestedList);\n } else if (childName === 'p') {\n const para = this.transformElement(childName, child as JsxElement);\n if (para) children.push(para);\n }\n } else {\n // Accumulate inline content (text, expressions, inline elements)\n inlineSequence.push(child);\n }\n }\n\n // Flush any remaining inline content\n flushInlineSequence();\n\n return { kind: 'listItem', children: children as BaseBlockNode[] };\n }\n\n private transformBlockquote(node: JsxElement | JsxSelfClosingElement): BlockquoteNode {\n if (Node.isJsxSelfClosingElement(node)) {\n return { kind: 'blockquote', children: [] };\n }\n\n // Transform children as blocks (with If/Else sibling detection)\n const children = this.transformBlockChildren(node.getJsxChildren());\n\n return { kind: 'blockquote', children: children as BaseBlockNode[] };\n }\n\n private transformCodeBlock(node: JsxElement | JsxSelfClosingElement): CodeBlockNode {\n if (Node.isJsxSelfClosingElement(node)) {\n return { kind: 'codeBlock', content: '' };\n }\n\n // Look for <code> child with optional language\n const children = node.getJsxChildren();\n for (const child of children) {\n if (Node.isJsxElement(child) && getElementName(child) === 'code') {\n const language = getAttributeValue(\n child.getOpeningElement(),\n 'className'\n )?.replace(/^language-/, '');\n\n // Extract raw text content preserving whitespace\n const content = this.extractCodeContent(child);\n return { kind: 'codeBlock', language, content };\n }\n }\n\n // Pre without code child - extract text directly\n const content = this.extractCodeContent(node);\n return { kind: 'codeBlock', content };\n }\n\n private extractCodeContent(node: JsxElement): string {\n // Preserve whitespace in code blocks - don't normalize\n const parts: string[] = [];\n for (const child of node.getJsxChildren()) {\n if (Node.isJsxText(child)) {\n parts.push(child.getText());\n } else if (Node.isJsxExpression(child)) {\n // Handle {`template`} and {\"string\"} expressions\n const expr = child.getExpression();\n if (expr) {\n if (Node.isStringLiteral(expr)) {\n parts.push(expr.getLiteralValue());\n } else if (Node.isNoSubstitutionTemplateLiteral(expr)) {\n parts.push(expr.getLiteralValue());\n } else if (Node.isTemplateExpression(expr)) {\n // Template with substitutions: {`text ${var} more`}\n parts.push(this.extractTemplateText(expr));\n }\n }\n }\n }\n // Trim only the outermost whitespace (leading/trailing)\n return parts.join('').trim();\n }\n\n private transformInlineChildren(node: JsxElement): InlineNode[] {\n const children = node.getJsxChildren();\n const inlines: InlineNode[] = [];\n\n for (const child of children) {\n const inline = this.transformToInline(child);\n if (inline) inlines.push(inline);\n }\n\n // Trim leading/trailing whitespace from first and last text nodes\n // (preserves internal spacing between inline elements)\n this.trimBoundaryTextNodes(inlines);\n\n return inlines;\n }\n\n private trimBoundaryTextNodes(inlines: InlineNode[]): void {\n if (inlines.length === 0) return;\n\n // Trim leading whitespace from first text node\n const first = inlines[0];\n if (first.kind === 'text') {\n first.value = first.value.trimStart();\n if (!first.value) {\n inlines.shift();\n }\n }\n\n if (inlines.length === 0) return;\n\n // Trim trailing whitespace from last text node\n const last = inlines[inlines.length - 1];\n if (last.kind === 'text') {\n last.value = last.value.trimEnd();\n if (!last.value) {\n inlines.pop();\n }\n }\n }\n\n private transformToInline(node: Node): InlineNode | null {\n if (Node.isJsxText(node)) {\n // Use extractInlineText to preserve leading/trailing spaces\n const text = extractInlineText(node);\n if (!text) return null;\n return { kind: 'text', value: text };\n }\n\n if (Node.isJsxSelfClosingElement(node)) {\n const name = getElementName(node);\n if (name === 'br') {\n return { kind: 'lineBreak' };\n }\n throw this.createError(`Unsupported inline self-closing element: <${name}>`, node);\n }\n\n if (Node.isJsxElement(node)) {\n const name = getElementName(node);\n return this.transformInlineElement(name, node);\n }\n\n // Handle JSX expressions\n if (Node.isJsxExpression(node)) {\n const expr = node.getExpression();\n if (!expr) return null;\n\n // String literals: {' '} or {'text'}\n if (Node.isStringLiteral(expr)) {\n const value = expr.getLiteralValue();\n if (value) {\n return { kind: 'text', value };\n }\n return null;\n }\n\n // Call expressions: output.field('key') -> '{output.key}'\n if (Node.isCallExpression(expr)) {\n const propAccess = expr.getExpression();\n // Check if it's a method call like output.field('key')\n if (Node.isPropertyAccessExpression(propAccess)) {\n const methodName = propAccess.getName();\n const objExpr = propAccess.getExpression();\n\n // Check if it's calling .field() on a useOutput result\n if (methodName === 'field' && Node.isIdentifier(objExpr)) {\n const outputName = objExpr.getText();\n // Verify this is a tracked output\n if (this.outputs.has(outputName)) {\n // Get the field key from the argument\n const args = expr.getArguments();\n if (args.length >= 1) {\n const keyArg = args[0];\n if (Node.isStringLiteral(keyArg)) {\n const fieldKey = keyArg.getLiteralValue();\n return { kind: 'text', value: `{output.${fieldKey}}` };\n }\n }\n }\n }\n }\n }\n\n // Property access expressions: ctx.name, ctx.outputPath, etc.\n if (Node.isPropertyAccessExpression(expr)) {\n const objExpr = expr.getExpression();\n const propName = expr.getName();\n\n // Check if accessing render props context (e.g., ctx.name)\n if (Node.isIdentifier(objExpr) && this.renderPropsContext) {\n const objName = objExpr.getText();\n if (objName === this.renderPropsContext.paramName) {\n const value = this.renderPropsContext.values[propName];\n if (value !== undefined) {\n return { kind: 'text', value };\n }\n }\n }\n }\n\n // Other expressions are ignored\n return null;\n }\n\n return null;\n }\n\n private transformInlineElement(name: string, node: JsxElement): InlineNode {\n // Bold\n if (name === 'b' || name === 'strong') {\n return { kind: 'bold', children: this.transformInlineChildren(node) };\n }\n\n // Italic\n if (name === 'i' || name === 'em') {\n return { kind: 'italic', children: this.transformInlineChildren(node) };\n }\n\n // Inline code\n if (name === 'code') {\n // Inline code: extract raw text content\n const text = this.extractAllText(node);\n return { kind: 'inlineCode', value: text };\n }\n\n // Link\n if (name === 'a') {\n return this.transformLink(node);\n }\n\n throw this.createError(`Unsupported inline element: <${name}>`, node);\n }\n\n private extractAllText(node: JsxElement): string {\n // Recursively extract all text content from children\n // Handles both JsxText and JsxExpression (string literals, template literals)\n const parts: string[] = [];\n for (const child of node.getJsxChildren()) {\n if (Node.isJsxText(child)) {\n const text = extractText(child);\n if (text) parts.push(text);\n } else if (Node.isJsxExpression(child)) {\n // Handle {`template`}, {\"string\"}, and {'string'} expressions\n const expr = child.getExpression();\n if (expr) {\n if (Node.isStringLiteral(expr)) {\n parts.push(expr.getLiteralValue());\n } else if (Node.isNoSubstitutionTemplateLiteral(expr)) {\n parts.push(expr.getLiteralValue());\n } else if (Node.isTemplateExpression(expr)) {\n // Template with substitutions: {`text ${var} more`}\n parts.push(this.extractTemplateText(expr));\n }\n }\n }\n }\n return parts.join('');\n }\n\n private transformLink(node: JsxElement): LinkNode {\n const href = getAttributeValue(node.getOpeningElement(), 'href');\n if (!href) {\n throw this.createError('<a> element requires href attribute', node);\n }\n\n const children = this.transformInlineChildren(node);\n return { kind: 'link', url: href, children };\n }\n\n private transformDiv(node: JsxElement | JsxSelfClosingElement): XmlBlockNode | GroupNode {\n const openingElement = Node.isJsxElement(node)\n ? node.getOpeningElement()\n : node;\n\n // Get name attribute (optional - if missing, create invisible group)\n const nameAttr = getAttributeValue(openingElement, 'name');\n\n // Transform children as mixed content (inline elements get wrapped in paragraphs)\n const children = Node.isJsxElement(node)\n ? this.transformMixedChildren(node.getJsxChildren())\n : [];\n\n // No name attribute: invisible grouping container with tight spacing\n if (!nameAttr) {\n return {\n kind: 'group',\n children: children as BaseBlockNode[],\n };\n }\n\n // Has name attribute: XML block with wrapper tags\n // Validate XML name\n if (!isValidXmlName(nameAttr)) {\n throw this.createError(\n `Invalid XML tag name '${nameAttr}' - must start with letter/underscore, contain only letters, digits, underscores, hyphens, or periods, and not start with 'xml'`,\n node\n );\n }\n\n // Extract other attributes (excluding 'name' which becomes the tag)\n const attributes: Record<string, string> = {};\n for (const attr of openingElement.getAttributes()) {\n if (Node.isJsxAttribute(attr)) {\n const attrName = attr.getNameNode().getText();\n if (attrName !== 'name') {\n const value = getAttributeValue(openingElement, attrName);\n if (value !== undefined) {\n attributes[attrName] = value;\n }\n }\n }\n }\n\n return {\n kind: 'xmlBlock',\n name: nameAttr,\n attributes: Object.keys(attributes).length > 0 ? attributes : undefined,\n children: children as BaseBlockNode[],\n };\n }\n\n /**\n * Transform mixed children (inline + block elements)\n * Consecutive inline elements and text are wrapped in a single paragraph\n * Block elements are transformed normally\n */\n private transformMixedChildren(jsxChildren: Node[]): BlockNode[] {\n const blocks: BlockNode[] = [];\n let inlineAccumulator: Node[] = [];\n\n const flushInline = () => {\n if (inlineAccumulator.length > 0) {\n // Transform accumulated inline content as a paragraph\n const inlineNodes = this.transformInlineNodes(inlineAccumulator);\n if (inlineNodes.length > 0) {\n blocks.push({ kind: 'paragraph', children: inlineNodes });\n }\n inlineAccumulator = [];\n }\n };\n\n for (const child of jsxChildren) {\n // Check if this is an inline element or text\n if (Node.isJsxText(child)) {\n const text = extractText(child);\n if (text) {\n inlineAccumulator.push(child);\n }\n // Skip whitespace-only text if accumulator is empty\n continue;\n }\n\n if (Node.isJsxElement(child) || Node.isJsxSelfClosingElement(child)) {\n const name = getElementName(child);\n\n if (isInlineElement(name)) {\n // Accumulate inline elements\n inlineAccumulator.push(child);\n } else {\n // Flush any accumulated inline content before block element\n flushInline();\n // Transform block element\n const block = this.transformToBlock(child);\n if (block) blocks.push(block);\n }\n } else if (Node.isJsxExpression(child)) {\n // JSX expressions treated as inline\n inlineAccumulator.push(child);\n }\n }\n\n // Flush remaining inline content\n flushInline();\n\n return blocks;\n }\n\n /**\n * Transform a list of nodes to inline nodes\n * Used by transformMixedChildren for inline accumulation\n */\n private transformInlineNodes(nodes: Node[]): InlineNode[] {\n const result: InlineNode[] = [];\n\n for (const node of nodes) {\n if (Node.isJsxText(node)) {\n const text = extractText(node);\n if (text) {\n result.push({ kind: 'text', value: text });\n }\n } else if (Node.isJsxElement(node)) {\n const name = getElementName(node);\n const inlineNode = this.transformInlineElement(name, node);\n if (inlineNode) result.push(inlineNode);\n } else if (Node.isJsxSelfClosingElement(node)) {\n // Handle self-closing inline elements (like <br />)\n const name = getElementName(node);\n if (name === 'br') {\n result.push({ kind: 'lineBreak' });\n }\n } else if (Node.isJsxExpression(node)) {\n // Extract text from JSX expression\n const expr = node.getExpression();\n if (expr) {\n const text = expr.getText();\n // Remove surrounding quotes if it's a string literal\n const cleaned = text.replace(/^['\"`]|['\"`]$/g, '');\n if (cleaned) {\n result.push({ kind: 'text', value: cleaned });\n }\n }\n }\n }\n\n return result;\n }\n\n private transformXmlBlock(node: JsxElement | JsxSelfClosingElement): XmlBlockNode {\n const openingElement = Node.isJsxElement(node)\n ? node.getOpeningElement()\n : node;\n\n // Get required name attribute\n const nameAttr = getAttributeValue(openingElement, 'name');\n if (!nameAttr) {\n throw this.createError('XmlBlock requires name prop', node);\n }\n\n // Validate XML name\n if (!isValidXmlName(nameAttr)) {\n throw this.createError(\n `Invalid XML tag name '${nameAttr}' - must start with letter/underscore, contain only letters, digits, underscores, hyphens, or periods, and not start with 'xml'`,\n node\n );\n }\n\n // Transform children as blocks (with If/Else sibling detection)\n const children = Node.isJsxElement(node)\n ? this.transformBlockChildren(node.getJsxChildren())\n : [];\n\n return {\n kind: 'xmlBlock',\n name: nameAttr,\n children: children as BaseBlockNode[],\n };\n }\n\n /**\n * Transform Table component to TableNode IR\n */\n private transformTable(node: JsxElement | JsxSelfClosingElement): TableNode {\n const opening = Node.isJsxElement(node) ? node.getOpeningElement() : node;\n\n // Parse array props\n const headers = getArrayAttributeValue(opening, 'headers');\n const rows = this.parseRowsAttribute(opening);\n const alignRaw = getArrayAttributeValue(opening, 'align');\n const emptyCell = getAttributeValue(opening, 'emptyCell');\n\n // Convert align strings to typed array\n const align = alignRaw?.map(a => {\n if (a === 'left' || a === 'center' || a === 'right') return a;\n return 'left'; // Default invalid values to left\n }) as ('left' | 'center' | 'right')[] | undefined;\n\n return {\n kind: 'table',\n headers: headers?.length ? headers : undefined,\n rows: rows,\n align: align,\n emptyCell: emptyCell || undefined,\n };\n }\n\n /**\n * Parse rows attribute (array of arrays)\n */\n private parseRowsAttribute(opening: JsxOpeningElement | JsxSelfClosingElement): string[][] {\n const attr = opening.getAttribute('rows');\n if (!attr || !Node.isJsxAttribute(attr)) return [];\n\n const init = attr.getInitializer();\n if (!init || !Node.isJsxExpression(init)) return [];\n\n const expr = init.getExpression();\n if (!expr || !Node.isArrayLiteralExpression(expr)) return [];\n\n const rows: string[][] = [];\n for (const element of expr.getElements()) {\n if (Node.isArrayLiteralExpression(element)) {\n const row: string[] = [];\n for (const cell of element.getElements()) {\n // Handle string literals, numbers, and expressions\n if (Node.isStringLiteral(cell)) {\n row.push(cell.getLiteralValue());\n } else if (Node.isNumericLiteral(cell)) {\n row.push(cell.getLiteralValue().toString());\n } else if (Node.isPropertyAccessExpression(cell)) {\n // Handle context property access (e.g., ctx.name)\n const interpolated = this.interpolatePropertyAccess(cell);\n row.push(interpolated ?? cell.getText());\n } else {\n row.push(cell.getText());\n }\n }\n rows.push(row);\n }\n }\n return rows;\n }\n\n /**\n * Interpolate a PropertyAccessExpression if it references render props context\n * Returns the interpolated value or null if not a context access\n */\n private interpolatePropertyAccess(expr: PropertyAccessExpression): string | null {\n const objExpr = expr.getExpression();\n const propName = expr.getName();\n\n if (Node.isIdentifier(objExpr) && this.renderPropsContext) {\n const objName = objExpr.getText();\n if (objName === this.renderPropsContext.paramName) {\n const value = this.renderPropsContext.values[propName];\n if (value !== undefined) {\n return value;\n }\n }\n }\n return null;\n }\n\n /**\n * Transform List component (prop-based) to ListNode IR\n * This is separate from HTML <ul>/<ol> transformation\n */\n private transformPropList(node: JsxElement | JsxSelfClosingElement): ListNode {\n const opening = Node.isJsxElement(node) ? node.getOpeningElement() : node;\n\n // Parse props\n const items = getArrayAttributeValue(opening, 'items') ?? [];\n const ordered = getAttributeValue(opening, 'ordered') === 'true' ||\n opening.getAttribute('ordered') !== undefined; // Handle boolean attr\n\n // Parse start attribute (numeric)\n let start: number | undefined = undefined;\n const startAttr = opening.getAttribute('start');\n if (startAttr && Node.isJsxAttribute(startAttr)) {\n const init = startAttr.getInitializer();\n if (init && Node.isJsxExpression(init)) {\n const expr = init.getExpression();\n if (expr && Node.isNumericLiteral(expr)) {\n start = expr.getLiteralValue();\n }\n }\n }\n\n // Convert items to ListItemNode[]\n const listItems: ListItemNode[] = items.map(item => ({\n kind: 'listItem' as const,\n children: [{\n kind: 'paragraph' as const,\n children: [{ kind: 'text' as const, value: String(item) }]\n }]\n }));\n\n return {\n kind: 'list',\n ordered,\n items: listItems,\n start,\n };\n }\n\n // ============================================================================\n // Semantic Workflow Components\n // ============================================================================\n\n private transformExecutionContext(node: JsxElement | JsxSelfClosingElement): ExecutionContextNode {\n const opening = Node.isJsxElement(node) ? node.getOpeningElement() : node;\n\n const paths = getArrayAttributeValue(opening, 'paths') ?? [];\n const prefix = getAttributeValue(opening, 'prefix') ?? '@';\n\n // Transform children if present\n const children: BlockNode[] = [];\n if (Node.isJsxElement(node)) {\n for (const child of node.getJsxChildren()) {\n const block = this.transformToBlock(child);\n if (block) children.push(block);\n }\n }\n\n return {\n kind: 'executionContext',\n paths,\n prefix,\n children: children as BaseBlockNode[],\n };\n }\n\n private transformSuccessCriteria(node: JsxElement | JsxSelfClosingElement): SuccessCriteriaNode {\n const opening = Node.isJsxElement(node) ? node.getOpeningElement() : node;\n\n const items = this.parseSuccessCriteriaItems(opening);\n\n return {\n kind: 'successCriteria',\n items,\n };\n }\n\n /**\n * Parse items attribute for SuccessCriteria\n * Handles both string shorthand and {text, checked} objects\n */\n private parseSuccessCriteriaItems(opening: JsxOpeningElement | JsxSelfClosingElement): SuccessCriteriaItemData[] {\n const attr = opening.getAttribute('items');\n if (!attr || !Node.isJsxAttribute(attr)) return [];\n\n const init = attr.getInitializer();\n if (!init || !Node.isJsxExpression(init)) return [];\n\n const expr = init.getExpression();\n if (!expr || !Node.isArrayLiteralExpression(expr)) return [];\n\n const items: SuccessCriteriaItemData[] = [];\n for (const element of expr.getElements()) {\n if (Node.isStringLiteral(element)) {\n // String shorthand: \"item text\"\n items.push({ text: element.getLiteralValue(), checked: false });\n } else if (Node.isObjectLiteralExpression(element)) {\n // Object: { text: \"...\", checked: true }\n let text = '';\n let checked = false;\n\n for (const prop of element.getProperties()) {\n if (Node.isPropertyAssignment(prop)) {\n const propName = prop.getName();\n const propInit = prop.getInitializer();\n\n if (propName === 'text' && propInit && Node.isStringLiteral(propInit)) {\n text = propInit.getLiteralValue();\n } else if (propName === 'checked' && propInit) {\n // Handle both boolean literal and truthy values\n if (propInit.getKind() === 112) { // TrueKeyword\n checked = true;\n } else if (propInit.getKind() === 97) { // FalseKeyword\n checked = false;\n }\n }\n }\n }\n\n items.push({ text, checked });\n }\n }\n\n return items;\n }\n\n private transformOfferNext(node: JsxElement | JsxSelfClosingElement): OfferNextNode {\n const opening = Node.isJsxElement(node) ? node.getOpeningElement() : node;\n\n const routes = this.parseOfferNextRoutes(opening);\n\n return {\n kind: 'offerNext',\n routes,\n };\n }\n\n /**\n * Parse routes attribute for OfferNext\n * Each route is an object with name, path, and optional description\n */\n private parseOfferNextRoutes(opening: JsxOpeningElement | JsxSelfClosingElement): OfferNextRouteData[] {\n const attr = opening.getAttribute('routes');\n if (!attr || !Node.isJsxAttribute(attr)) return [];\n\n const init = attr.getInitializer();\n if (!init || !Node.isJsxExpression(init)) return [];\n\n const expr = init.getExpression();\n if (!expr || !Node.isArrayLiteralExpression(expr)) return [];\n\n const routes: OfferNextRouteData[] = [];\n for (const element of expr.getElements()) {\n if (Node.isObjectLiteralExpression(element)) {\n let name = '';\n let path = '';\n let description: string | undefined = undefined;\n\n for (const prop of element.getProperties()) {\n if (Node.isPropertyAssignment(prop)) {\n const propName = prop.getName();\n const propInit = prop.getInitializer();\n\n if (propInit && Node.isStringLiteral(propInit)) {\n const value = propInit.getLiteralValue();\n if (propName === 'name') {\n name = value;\n } else if (propName === 'path') {\n path = value;\n } else if (propName === 'description') {\n description = value;\n }\n }\n }\n }\n\n if (name && path) {\n routes.push({ name, path, description });\n }\n }\n }\n\n return routes;\n }\n\n /**\n * Transform Step component to StepNode IR\n */\n private transformStep(node: JsxElement | JsxSelfClosingElement): StepNode {\n const openingElement = Node.isJsxElement(node)\n ? node.getOpeningElement()\n : node;\n\n // Extract number prop (supports both string and numeric literals)\n let stepNumber: string | undefined = undefined;\n const numberAttr = openingElement.getAttribute('number');\n if (numberAttr && Node.isJsxAttribute(numberAttr)) {\n const init = numberAttr.getInitializer();\n if (init) {\n // String literal: number=\"1.1\"\n if (Node.isStringLiteral(init)) {\n stepNumber = init.getLiteralValue();\n }\n // JSX expression: number={1} or number={\"1.1\"}\n else if (Node.isJsxExpression(init)) {\n const expr = init.getExpression();\n if (expr) {\n if (Node.isNumericLiteral(expr)) {\n stepNumber = String(expr.getLiteralValue());\n } else if (Node.isStringLiteral(expr)) {\n stepNumber = expr.getLiteralValue();\n }\n }\n }\n }\n }\n\n // Extract name prop\n const name = getAttributeValue(openingElement, 'name');\n\n if (!stepNumber) {\n throw this.createError('Step requires number prop', openingElement);\n }\n if (!name) {\n throw this.createError('Step requires name prop', openingElement);\n }\n\n // Extract variant with default\n const variantAttr = getAttributeValue(openingElement, 'variant');\n let variant: StepVariant = 'heading'; // Default\n if (variantAttr === 'heading' || variantAttr === 'bold' || variantAttr === 'xml') {\n variant = variantAttr;\n }\n\n // Transform children\n const children = Node.isJsxElement(node)\n ? this.transformBlockChildren(node.getJsxChildren())\n : [];\n\n return {\n kind: 'step',\n number: stepNumber,\n name,\n variant,\n children: children as BaseBlockNode[],\n };\n }\n\n /**\n * Transform <Bash> to CodeBlockNode with language 'bash'\n *\n * <Bash>ls -la</Bash>\n * becomes:\n * ```bash\n * ls -la\n * ```\n */\n private transformBash(node: JsxElement | JsxSelfClosingElement): CodeBlockNode {\n if (Node.isJsxSelfClosingElement(node)) {\n return { kind: 'codeBlock', language: 'bash', content: '' };\n }\n\n // Use extractCodeContent to preserve whitespace\n const content = this.extractCodeContent(node);\n\n return {\n kind: 'codeBlock',\n language: 'bash',\n content,\n };\n }\n\n /**\n * Transform <ReadFiles> to ReadFilesNode\n *\n * Extracts the files prop (which should be a defineFiles() result)\n * and creates a ReadFilesNode with file entries.\n */\n private transformReadFiles(node: JsxElement | JsxSelfClosingElement): ReadFilesNode {\n const opening = Node.isJsxElement(node) ? node.getOpeningElement() : node;\n\n // Get the 'files' prop - should be an identifier referencing defineFiles result\n const filesAttr = opening.getAttribute('files');\n if (!filesAttr || !Node.isJsxAttribute(filesAttr)) {\n throw this.createError('ReadFiles requires files prop', node);\n }\n\n const init = filesAttr.getInitializer();\n if (!init || !Node.isJsxExpression(init)) {\n throw this.createError('ReadFiles files prop must be a JSX expression', node);\n }\n\n const expr = init.getExpression();\n if (!expr) {\n throw this.createError('ReadFiles files prop expression is empty', node);\n }\n\n // The files prop should reference a variable that holds defineFiles() result\n // We need to trace back to find the defineFiles() call and extract its schema\n const files: ReadFileEntry[] = [];\n\n // If it's an identifier, look up the variable declaration\n if (Node.isIdentifier(expr)) {\n const varName = expr.getText();\n // Find the variable declaration in the source file\n const sourceFile = this.sourceFile;\n if (sourceFile) {\n const statements = sourceFile.getStatements();\n for (const stmt of statements) {\n if (Node.isVariableStatement(stmt)) {\n for (const decl of stmt.getDeclarationList().getDeclarations()) {\n if (decl.getName() === varName) {\n const initializer = decl.getInitializer();\n if (initializer && Node.isCallExpression(initializer)) {\n const callee = initializer.getExpression();\n if (Node.isIdentifier(callee) && callee.getText() === 'defineFiles') {\n // Found the defineFiles call - extract the schema\n const args = initializer.getArguments();\n if (args.length > 0 && Node.isObjectLiteralExpression(args[0])) {\n this.extractFilesFromSchema(args[0], files);\n }\n }\n }\n }\n }\n }\n }\n }\n }\n // If it's a call expression directly: <ReadFiles files={defineFiles({...})} />\n else if (Node.isCallExpression(expr)) {\n const callee = expr.getExpression();\n if (Node.isIdentifier(callee) && callee.getText() === 'defineFiles') {\n const args = expr.getArguments();\n if (args.length > 0 && Node.isObjectLiteralExpression(args[0])) {\n this.extractFilesFromSchema(args[0], files);\n }\n }\n }\n\n if (files.length === 0) {\n throw this.createError('ReadFiles: could not extract files from defineFiles schema', node);\n }\n\n return {\n kind: 'readFiles',\n files,\n };\n }\n\n /**\n * Extract file entries from defineFiles schema object literal\n */\n private extractFilesFromSchema(obj: ObjectLiteralExpression, files: ReadFileEntry[]): void {\n for (const prop of obj.getProperties()) {\n if (Node.isPropertyAssignment(prop)) {\n const key = prop.getName();\n const value = prop.getInitializer();\n\n if (value && Node.isObjectLiteralExpression(value)) {\n // Extract path and required from the FileDef object\n let path: string | undefined;\n let required = true; // Default true\n\n for (const fileProp of value.getProperties()) {\n if (Node.isPropertyAssignment(fileProp)) {\n const propName = fileProp.getName();\n const propValue = fileProp.getInitializer();\n\n if (propName === 'path' && propValue) {\n if (Node.isStringLiteral(propValue)) {\n path = propValue.getLiteralValue();\n } else if (Node.isNoSubstitutionTemplateLiteral(propValue)) {\n path = propValue.getLiteralValue();\n } else if (Node.isTemplateExpression(propValue)) {\n // Template with ${} - preserve as-is for shell interpolation\n path = this.extractTemplatePath(propValue);\n }\n } else if (propName === 'required' && propValue) {\n if (propValue.getText() === 'false') {\n required = false;\n }\n }\n }\n }\n\n if (path) {\n // Convert key to UPPER_SNAKE_CASE + _CONTENT\n const varName = key.replace(/([a-z])([A-Z])/g, '$1_$2').toUpperCase() + '_CONTENT';\n files.push({ varName, path, required });\n }\n }\n }\n }\n }\n\n /**\n * Extract path from template expression, preserving ${} for shell\n */\n private extractTemplatePath(tmpl: TemplateExpression): string {\n let result = tmpl.getHead().getLiteralText();\n\n for (const span of tmpl.getTemplateSpans()) {\n const spanExpr = span.getExpression();\n // Convert TS ${expr} to shell ${expr}\n result += '${' + spanExpr.getText() + '}';\n result += span.getLiteral().getLiteralText();\n }\n\n return result;\n }\n\n /**\n * Transform <PromptTemplate> to PromptTemplateNode\n *\n * <PromptTemplate>\n * <XmlBlock name=\"objective\">...</XmlBlock>\n * </PromptTemplate>\n *\n * Becomes:\n * ```markdown\n * <objective>\n * ...\n * </objective>\n * ```\n */\n private transformPromptTemplate(node: JsxElement | JsxSelfClosingElement): PromptTemplateNode {\n if (Node.isJsxSelfClosingElement(node)) {\n return { kind: 'promptTemplate', children: [] };\n }\n\n // Transform children normally\n const children = this.transformBlockChildren(node.getJsxChildren());\n\n return {\n kind: 'promptTemplate',\n children: children as BaseBlockNode[],\n };\n }\n\n private transformXmlSection(node: JsxElement | JsxSelfClosingElement): XmlBlockNode {\n const opening = Node.isJsxElement(node) ? node.getOpeningElement() : node;\n\n const name = getAttributeValue(opening, 'name') ?? 'section';\n\n // Transform children\n const children: BlockNode[] = [];\n if (Node.isJsxElement(node)) {\n for (const child of node.getJsxChildren()) {\n const block = this.transformToBlock(child);\n if (block) children.push(block);\n }\n }\n\n return {\n kind: 'xmlBlock',\n name,\n children: children as BaseBlockNode[],\n };\n }\n\n private transformXmlWrapper(componentName: string, node: JsxElement | JsxSelfClosingElement): XmlBlockNode {\n // Convert component name to snake_case for XML tag\n const tagName = toSnakeCase(componentName);\n\n // Transform children\n const children: BlockNode[] = [];\n if (Node.isJsxElement(node)) {\n for (const child of node.getJsxChildren()) {\n const block = this.transformToBlock(child);\n if (block) children.push(block);\n }\n }\n\n return {\n kind: 'xmlBlock',\n name: tagName,\n children: children as BaseBlockNode[],\n };\n }\n\n private transformMarkdown(node: JsxElement | JsxSelfClosingElement): BlockNode {\n if (Node.isJsxSelfClosingElement(node)) {\n // Self-closing <Markdown /> - empty content\n return { kind: 'raw', content: '' };\n }\n\n // Extract raw content from children\n // JSX strips whitespace after expressions, so we need to detect and restore it\n //\n // In markdown, we need to preserve:\n // - Newlines before section headers (## )\n // - Newlines between paragraphs/blocks\n // - Spaces between inline elements\n const parts: string[] = [];\n const jsxChildren = node.getJsxChildren();\n\n for (let i = 0; i < jsxChildren.length; i++) {\n const child = jsxChildren[i];\n const prev = parts[parts.length - 1];\n\n if (Node.isJsxText(child)) {\n let text = child.getText();\n\n // Empty text between two expressions likely had a newline that JSX stripped\n // We restore it as a newline (inside code blocks, between list items, etc.)\n if (text === '' && i > 0 && i < jsxChildren.length - 1) {\n const prevChild = jsxChildren[i - 1];\n const nextChild = jsxChildren[i + 1];\n if (Node.isJsxExpression(prevChild) && Node.isJsxExpression(nextChild)) {\n // Two adjacent expressions had whitespace between them that was stripped\n parts.push('\\n');\n continue;\n }\n }\n\n // Check if we need to restore stripped whitespace before this text\n // JSX eats leading whitespace from text following an expression\n if (prev && !/\\s$/.test(prev) && !/^\\s/.test(text) && text !== '') {\n // Detect what kind of whitespace was likely stripped:\n // - If text starts with ## (heading), add double newline\n // - If text starts with ``` (code fence), add double newline\n // - If text starts with ** (bold), add newline (often a new paragraph)\n // - If text starts with - or * or digit. (list item), add newline\n // - For | (table), only add newline if prev ends with | (new row)\n // Otherwise it's a cell separator, just needs space\n // - Otherwise add space\n if (/^#{1,6}\\s/.test(text) || /^```/.test(text)) {\n parts.push('\\n\\n');\n } else if (/^\\*\\*/.test(text)) {\n // Bold at start of line usually means new paragraph or list item\n parts.push('\\n');\n } else if (/^[-*]\\s/.test(text) || /^\\d+\\.\\s/.test(text)) {\n parts.push('\\n');\n } else if (/^[|]/.test(text)) {\n // Table pipe: if previous content ended with | it's a new row\n // Otherwise it's a cell separator (just needs space)\n if (/[|]\\s*$/.test(prev)) {\n parts.push('\\n');\n } else {\n parts.push(' ');\n }\n } else if (!/^[.,;:!?)}\\]>`\"'/]/.test(text)) {\n parts.push(' ');\n }\n }\n\n parts.push(text);\n } else if (Node.isJsxExpression(child)) {\n // Handle {variable} or {\"literal\"} or {`template`} expressions\n const expr = child.getExpression();\n if (expr) {\n if (Node.isStringLiteral(expr)) {\n // String literal: {\"text\"} -> text\n parts.push(expr.getLiteralValue());\n } else if (Node.isNoSubstitutionTemplateLiteral(expr)) {\n // Template literal without substitutions: {`text`} -> text\n parts.push(expr.getLiteralValue());\n } else if (Node.isTemplateExpression(expr)) {\n // Template expression with substitutions: {`text ${var} more`}\n // Reconstruct the template by joining head, spans, and tail\n let result = expr.getHead().getLiteralText();\n for (const span of expr.getTemplateSpans()) {\n // Get the expression between ${...}\n const spanExpr = span.getExpression();\n // Try to get static value, otherwise use ${expr}\n if (Node.isIdentifier(spanExpr)) {\n result += `\\${${spanExpr.getText()}}`;\n } else if (Node.isStringLiteral(spanExpr)) {\n result += spanExpr.getLiteralValue();\n } else {\n // For complex expressions, preserve the ${...} syntax\n result += `\\${${spanExpr.getText()}}`;\n }\n // Add the literal text after the expression\n const literal = span.getLiteral();\n if (Node.isTemplateMiddle(literal)) {\n result += literal.getLiteralText();\n } else if (Node.isTemplateTail(literal)) {\n result += literal.getLiteralText();\n }\n }\n parts.push(result);\n } else if (Node.isIdentifier(expr)) {\n // Identifier expression: {var} was likely ${var} in bash\n // JSX splits ${var} into \"$\" + {var}, so reconstruct as {var}\n // which preserves the intent for code blocks\n parts.push(`{${expr.getText()}}`);\n } else if (Node.isBinaryExpression(expr)) {\n // Binary expression: string concatenation like `text ` + var + ` more`\n const concat = this.evaluateStringConcatenation(expr);\n if (concat !== null) {\n parts.push(concat);\n }\n } else if (Node.isPropertyAccessExpression(expr)) {\n // Property access: obj.prop (like AGENT_PATHS.researcher)\n // Try to resolve the value from a const declaration\n const value = this.resolvePropertyAccess(expr);\n if (value !== null) {\n parts.push(value);\n }\n }\n // Other expressions (function calls, etc.) cannot be evaluated at transpile time\n }\n }\n }\n\n // Trim outer boundaries, preserve internal whitespace\n const content = parts.join('').trim();\n\n return { kind: 'raw', content };\n }\n\n /**\n * Transform a custom component by resolving its import and inlining its JSX\n *\n * Custom components are user-defined TSX fragments that get inlined at\n * transpile time. Component props are NOT supported in v1 - only parameterless\n * composition.\n */\n private transformCustomComponent(name: string, node: JsxElement | JsxSelfClosingElement): BlockNode | null {\n // Validate no props on the component (v1 limitation)\n const openingElement = Node.isJsxElement(node) ? node.getOpeningElement() : node;\n const attributes = openingElement.getAttributes();\n if (attributes.length > 0) {\n throw this.createError(`Component props not supported: <${name}> has ${attributes.length} prop(s)`, node);\n }\n\n // Require source file for component resolution\n if (!this.sourceFile) {\n throw this.createError(\n `Cannot resolve component '${name}': no source file context. ` +\n `Pass sourceFile to transformer.transform() for component composition.`,\n node\n );\n }\n\n // Resolve the component import\n const resolved = resolveComponentImport(name, this.sourceFile, this.visitedPaths);\n\n // Update visited paths for nested resolution\n this.visitedPaths = resolved.visitedPaths;\n\n // Save current sourceFile and set to component's sourceFile for nested resolution\n const previousSourceFile = this.sourceFile;\n this.sourceFile = resolved.sourceFile;\n\n let result: BlockNode | null = null;\n\n // Transform the resolved JSX\n if (Node.isJsxFragment(resolved.jsx)) {\n // Fragment: transform children and return first block\n // (multiple root blocks from a component isn't fully supported - take first)\n const blocks = this.transformFragmentChildren(resolved.jsx);\n result = blocks[0] ?? null;\n } else {\n // Single element or self-closing\n result = this.transformToBlock(resolved.jsx);\n }\n\n // Restore sourceFile\n this.sourceFile = previousSourceFile;\n\n return result;\n }\n\n /**\n * Transform a SpawnAgent element to SpawnAgentNode\n * SpawnAgent is a block-level element that emits Task() syntax\n *\n * Supports two modes:\n * 1. prompt prop (deprecated): Manual prompt string\n * 2. input prop (preferred): Typed input - VariableRef or object literal\n *\n * Also supports:\n * - agent={AgentRef} for type-safe agent references\n * - loadFromFile prop for \"load from file\" pattern\n */\n private transformSpawnAgent(node: JsxElement | JsxSelfClosingElement): SpawnAgentNode {\n const openingElement = Node.isJsxElement(node)\n ? node.getOpeningElement()\n : node;\n\n // Extract agent prop - can be string OR AgentRef identifier\n const { agentName, agentPath } = this.extractAgentProp(openingElement);\n const model = getAttributeValue(openingElement, 'model');\n const description = getAttributeValue(openingElement, 'description');\n\n // Extract loadFromFile prop\n const loadFromFile = this.extractLoadFromFileProp(openingElement, agentPath);\n\n // Extract prompt, promptVariable, and input props\n const prompt = this.extractPromptProp(openingElement);\n const promptVariable = getAttributeValue(openingElement, 'promptVariable');\n const input = this.extractInputProp(openingElement);\n\n // Extract extra instructions from children (when using input prop)\n const extraInstructions = Node.isJsxElement(node)\n ? this.extractExtraInstructions(node)\n : undefined;\n\n // Validate required props\n if (!agentName) {\n throw this.createError('SpawnAgent requires agent prop', openingElement);\n }\n if (!model) {\n throw this.createError('SpawnAgent requires model prop', openingElement);\n }\n if (!description) {\n throw this.createError('SpawnAgent requires description prop', openingElement);\n }\n\n // Validate mutual exclusivity of prompt, promptVariable, and input\n const promptProps = [prompt, promptVariable, input].filter(Boolean).length;\n if (promptProps > 1) {\n throw this.createError(\n 'Cannot use multiple prompt props on SpawnAgent. Use one of: prompt, promptVariable, or input.',\n openingElement\n );\n }\n\n // Require one of prompt, promptVariable, or input\n if (promptProps === 0) {\n throw this.createError(\n 'SpawnAgent requires either prompt, promptVariable, or input prop',\n openingElement\n );\n }\n\n // Extract generic type argument if present\n const typeArgs = extractTypeArguments(node);\n let inputType: TypeReference | undefined;\n const typeParam = typeArgs && typeArgs.length > 0 ? typeArgs[0] : undefined;\n if (typeParam) {\n inputType = {\n kind: 'typeReference',\n name: typeParam,\n resolved: false, // Will be resolved in validation phase\n };\n }\n\n // Validate input object against interface if both present\n if (input) {\n this.validateInputAgainstInterface(input, typeParam, openingElement);\n }\n\n return {\n kind: 'spawnAgent',\n agent: agentName,\n model,\n description,\n ...(prompt && { prompt }),\n ...(promptVariable && { promptVariable }),\n ...(input && { input }),\n ...(extraInstructions && { extraInstructions }),\n ...(inputType && { inputType }),\n ...(loadFromFile && { loadFromFile }),\n };\n }\n\n /**\n * Extract agent prop - handles string OR AgentRef identifier\n *\n * Returns:\n * - agentName: The agent name string (required)\n * - agentPath: The agent's file path (if AgentRef with path)\n */\n private extractAgentProp(\n element: JsxOpeningElement | JsxSelfClosingElement\n ): { agentName: string | undefined; agentPath: string | undefined } {\n const attr = element.getAttribute('agent');\n if (!attr || !Node.isJsxAttribute(attr)) {\n return { agentName: undefined, agentPath: undefined };\n }\n\n const init = attr.getInitializer();\n\n // Case 1: String literal - agent=\"my-agent\"\n if (init && Node.isStringLiteral(init)) {\n return { agentName: init.getLiteralValue(), agentPath: undefined };\n }\n\n // Case 2: JSX expression - agent={AgentRef}\n if (init && Node.isJsxExpression(init)) {\n const expr = init.getExpression();\n\n // Case 2a: Identifier referencing an AgentRef (e.g., agent={PhaseResearcher})\n if (expr && Node.isIdentifier(expr)) {\n const identName = expr.getText();\n\n // Try to resolve the identifier to find AgentRef properties\n const agentRef = this.resolveAgentRef(identName);\n if (agentRef) {\n return { agentName: agentRef.name, agentPath: agentRef.path };\n }\n\n // If not resolvable as AgentRef, treat identifier text as agent name\n // This allows for dynamic agent names from variables\n return { agentName: identName, agentPath: undefined };\n }\n\n // Case 2b: String literal in expression - agent={\"my-agent\"}\n if (expr && Node.isStringLiteral(expr)) {\n return { agentName: expr.getLiteralValue(), agentPath: undefined };\n }\n }\n\n return { agentName: undefined, agentPath: undefined };\n }\n\n /**\n * Try to resolve an identifier to an AgentRef definition\n *\n * Looks for:\n * 1. Imported AgentRef (from defineAgent call in source file)\n * 2. Local AgentRef constant\n */\n private resolveAgentRef(\n identName: string\n ): { name: string; path?: string } | undefined {\n if (!this.sourceFile) return undefined;\n\n // Find the symbol for this identifier\n const symbol = this.sourceFile.getLocal(identName);\n if (!symbol) return undefined;\n\n // Get the declaration\n const declarations = symbol.getDeclarations();\n if (!declarations || declarations.length === 0) return undefined;\n\n for (const decl of declarations) {\n // Check for import declaration\n if (Node.isImportSpecifier(decl)) {\n // Trace through import to find the defineAgent call in source file\n const resolved = this.resolveImportedAgentRef(decl, identName);\n if (resolved) return resolved;\n continue;\n }\n\n // Check for variable declaration with defineAgent call\n if (Node.isVariableDeclaration(decl)) {\n const init = decl.getInitializer();\n if (init && Node.isCallExpression(init)) {\n const callExpr = init.getExpression();\n if (callExpr && callExpr.getText() === 'defineAgent') {\n // Extract the config object from defineAgent({...})\n const args = init.getArguments();\n if (args.length > 0 && Node.isObjectLiteralExpression(args[0])) {\n return this.extractAgentRefFromObject(args[0]);\n }\n }\n }\n }\n }\n\n return undefined;\n }\n\n /**\n * Resolve an imported AgentRef by tracing to its source file\n */\n private resolveImportedAgentRef(\n importSpec: Node,\n identName: string\n ): { name: string; path?: string } | undefined {\n // Navigate up the tree to find ImportDeclaration\n // ImportSpecifier -> NamedImports -> ImportClause -> ImportDeclaration\n let current: Node | undefined = importSpec;\n while (current && !Node.isImportDeclaration(current)) {\n current = current.getParent();\n }\n\n if (!current || !Node.isImportDeclaration(current)) {\n return undefined;\n }\n\n const importDecl = current;\n\n // Resolve the source file\n const resolvedSourceFile = importDecl.getModuleSpecifierSourceFile();\n if (!resolvedSourceFile) {\n return undefined;\n }\n\n // Find the exported variable with the same name\n const exportedVar = resolvedSourceFile.getVariableDeclaration(identName);\n if (!exportedVar) {\n return undefined;\n }\n\n // Check if it's a defineAgent call\n const init = exportedVar.getInitializer();\n if (init && Node.isCallExpression(init)) {\n const callExpr = init.getExpression();\n if (callExpr && callExpr.getText() === 'defineAgent') {\n const args = init.getArguments();\n if (args.length > 0 && Node.isObjectLiteralExpression(args[0])) {\n return this.extractAgentRefFromObject(args[0]);\n }\n }\n }\n\n return undefined;\n }\n\n /**\n * Extract AgentRef properties from defineAgent config object\n */\n private extractAgentRefFromObject(\n obj: ObjectLiteralExpression\n ): { name: string; path?: string } | undefined {\n let name: string | undefined;\n let path: string | undefined;\n\n for (const prop of obj.getProperties()) {\n if (Node.isPropertyAssignment(prop)) {\n const propName = prop.getName();\n const init = prop.getInitializer();\n\n if (propName === 'name' && init && Node.isStringLiteral(init)) {\n name = init.getLiteralValue();\n }\n if (propName === 'path' && init && Node.isStringLiteral(init)) {\n path = init.getLiteralValue();\n }\n }\n }\n\n if (name) {\n return { name, path };\n }\n return undefined;\n }\n\n /**\n * Extract loadFromFile prop\n *\n * Supports:\n * - loadFromFile (boolean true shorthand)\n * - loadFromFile={true}\n * - loadFromFile=\"explicit/path.md\"\n *\n * When true, uses agentPath from AgentRef.\n * Returns resolved path string or undefined.\n */\n private extractLoadFromFileProp(\n element: JsxOpeningElement | JsxSelfClosingElement,\n agentPath: string | undefined\n ): string | undefined {\n const attr = element.getAttribute('loadFromFile');\n if (!attr || !Node.isJsxAttribute(attr)) {\n return undefined;\n }\n\n const init = attr.getInitializer();\n\n // Case 1: Boolean shorthand - loadFromFile (no value = true)\n if (!init) {\n if (!agentPath) {\n throw this.createError(\n 'loadFromFile={true} requires an AgentRef with a path property. ' +\n 'Either use agent={AgentRef} where AgentRef has a path, or provide an explicit path: loadFromFile=\"path/to/agent.md\"',\n element\n );\n }\n return agentPath;\n }\n\n // Case 2: String literal - loadFromFile=\"path/to/agent.md\"\n if (Node.isStringLiteral(init)) {\n return init.getLiteralValue();\n }\n\n // Case 3: JSX expression\n if (Node.isJsxExpression(init)) {\n const expr = init.getExpression();\n\n // Case 3a: Boolean true - loadFromFile={true}\n if (expr && expr.getText() === 'true') {\n if (!agentPath) {\n throw this.createError(\n 'loadFromFile={true} requires an AgentRef with a path property. ' +\n 'Either use agent={AgentRef} where AgentRef has a path, or provide an explicit path: loadFromFile=\"path/to/agent.md\"',\n element\n );\n }\n return agentPath;\n }\n\n // Case 3b: Boolean false - loadFromFile={false}\n if (expr && expr.getText() === 'false') {\n return undefined;\n }\n\n // Case 3c: String literal - loadFromFile={\"path/to/agent.md\"}\n if (expr && Node.isStringLiteral(expr)) {\n return expr.getLiteralValue();\n }\n\n // Case 3d: Property access - loadFromFile={AGENT_PATHS.researcher}\n if (expr && Node.isPropertyAccessExpression(expr)) {\n const resolvedPath = this.resolvePropertyAccess(expr);\n if (resolvedPath) {\n return resolvedPath;\n }\n throw this.createError(\n `Cannot resolve property access ${expr.getText()} for loadFromFile. ` +\n 'Make sure the object is a const with string literal values.',\n element\n );\n }\n }\n\n throw this.createError(\n 'loadFromFile must be a boolean or string path',\n element\n );\n }\n\n /**\n * Extract input prop - handles VariableRef identifier or object literal\n *\n * Supports:\n * - input={varRef} - Reference to useVariable result\n * - input={{ key: \"value\" }} - Object literal with properties\n */\n private extractInputProp(\n element: JsxOpeningElement | JsxSelfClosingElement\n ): SpawnAgentInput | undefined {\n const attr = element.getAttribute('input');\n if (!attr || !Node.isJsxAttribute(attr)) return undefined;\n\n const init = attr.getInitializer();\n if (!init || !Node.isJsxExpression(init)) return undefined;\n\n const expr = init.getExpression();\n if (!expr) return undefined;\n\n // Case 1: Identifier referencing useVariable result\n if (Node.isIdentifier(expr)) {\n const variable = this.variables.get(expr.getText());\n if (variable) {\n return { type: 'variable', varName: variable.envName };\n }\n // Not a known variable - error\n throw this.createError(\n `Input '${expr.getText()}' not found. Use useVariable() or object literal.`,\n element\n );\n }\n\n // Case 2: Object literal\n if (Node.isObjectLiteralExpression(expr)) {\n const properties = extractInputObjectLiteral(expr, this.variables);\n return { type: 'object', properties };\n }\n\n throw this.createError('Input must be a VariableRef or object literal', element);\n }\n\n /**\n * Extract extra instructions from SpawnAgent children\n *\n * Treats children as raw text content (like Markdown component).\n * Returns undefined if no children or only whitespace.\n */\n private extractExtraInstructions(node: JsxElement): string | undefined {\n const parts: string[] = [];\n\n for (const child of node.getJsxChildren()) {\n if (Node.isJsxText(child)) {\n const text = child.getText();\n if (text.trim()) {\n parts.push(text);\n }\n } else if (Node.isJsxExpression(child)) {\n // Handle {`template`} and {\"string\"} expressions\n const expr = child.getExpression();\n if (expr) {\n if (Node.isStringLiteral(expr)) {\n parts.push(expr.getLiteralValue());\n } else if (Node.isNoSubstitutionTemplateLiteral(expr)) {\n parts.push(expr.getLiteralValue());\n } else if (Node.isTemplateExpression(expr)) {\n parts.push(this.extractTemplateText(expr));\n }\n }\n }\n }\n\n const content = parts.join('').trim();\n return content || undefined;\n }\n\n /**\n * Extract type argument from SpawnAgent<T> syntax\n *\n * Returns the type name string (e.g., \"ResearcherInput\") or undefined\n * if no type argument is present.\n */\n private extractSpawnAgentTypeParam(\n element: JsxOpeningElement | JsxSelfClosingElement\n ): string | undefined {\n // Use existing extractTypeArguments helper (works on both JsxElement and self-closing)\n // We need to reconstruct the full node for extractTypeArguments\n const parent = element.getParent();\n if (!parent) return undefined;\n\n // extractTypeArguments expects JsxElement or JsxSelfClosingElement\n if (Node.isJsxElement(parent)) {\n const typeArgs = extractTypeArguments(parent);\n return typeArgs && typeArgs.length > 0 ? typeArgs[0] : undefined;\n }\n if (Node.isJsxSelfClosingElement(element)) {\n const typeArgs = extractTypeArguments(element);\n return typeArgs && typeArgs.length > 0 ? typeArgs[0] : undefined;\n }\n\n return undefined;\n }\n\n /**\n * Validate input object properties against SpawnAgent<T> type parameter.\n *\n * Throws compile error if required interface properties are missing.\n * Only validates object literal inputs (VariableRef is runtime-checked).\n *\n * @param input - The parsed SpawnAgentInput (may be variable or object)\n * @param typeParam - The type parameter name (e.g., \"ResearcherInput\")\n * @param element - The JSX element for error reporting\n */\n private validateInputAgainstInterface(\n input: SpawnAgentInput,\n typeParam: string | undefined,\n element: JsxOpeningElement | JsxSelfClosingElement\n ): void {\n // Only validate object literal inputs (VariableRef is runtime-checked)\n if (input.type !== 'object') return;\n\n // No type param = no validation (backward compat)\n if (!typeParam) return;\n\n // Require source file for type resolution\n if (!this.sourceFile) {\n // Can't resolve types without source file context - skip validation\n return;\n }\n\n // Resolve the interface (local or imported)\n const resolved = resolveTypeImport(typeParam, this.sourceFile);\n if (!resolved?.interface) {\n // Interface not found - skip validation (warning logged elsewhere)\n return;\n }\n\n // Extract required properties from interface\n const interfaceProps = extractInterfaceProperties(resolved.interface);\n const requiredProps = interfaceProps.filter(p => p.required);\n\n // Get property names from input object\n const inputPropNames = input.properties.map(p => p.name);\n\n // Find missing required properties\n const missing = requiredProps.filter(p => !inputPropNames.includes(p.name));\n\n if (missing.length > 0) {\n const missingNames = missing.map(p => p.name).join(', ');\n const requiredNames = requiredProps.map(p => p.name).join(', ');\n throw this.createError(\n `SpawnAgent input missing required properties: ${missingNames}. ` +\n `Interface '${typeParam}' requires: ${requiredNames}`,\n element\n );\n }\n }\n\n /**\n * Transform an If element to IfNode\n *\n * NOTE: V1 control flow is deprecated. Use V3 transformer with useRuntimeVar and condition-based If.\n */\n private transformIf(node: JsxElement | JsxSelfClosingElement): never {\n throw this.createError(\n 'V1 If control flow is deprecated. Use V3 transformer with useRuntimeVar and condition-based If.',\n node\n );\n }\n\n /**\n * Transform an Else element to ElseNode\n *\n * NOTE: V1 control flow is deprecated. Use V3 transformer with useRuntimeVar and condition-based If/Else.\n */\n private transformElse(node: JsxElement | JsxSelfClosingElement): never {\n throw this.createError(\n 'V1 Else control flow is deprecated. Use V3 transformer with useRuntimeVar and condition-based Else.',\n node\n );\n }\n\n /**\n * Transform Loop component to LoopNode IR\n *\n * NOTE: V1 control flow is deprecated. Use V3 transformer with useRuntimeVar and max-based Loop.\n */\n private transformLoop(node: JsxElement | JsxSelfClosingElement): never {\n throw this.createError(\n 'V1 Loop control flow is deprecated. Use V3 transformer with useRuntimeVar and max-based Loop.',\n node\n );\n }\n\n /**\n * Extract useOutput declarations from source file\n * Returns map of identifier name -> agent name\n *\n * Uses forEachDescendant to find declarations inside function bodies,\n * following the same pattern as extractVariableDeclarations in parser.ts\n */\n private extractOutputDeclarations(sourceFile: SourceFile): Map<string, string> {\n const outputs = new Map<string, string>();\n\n // Find all variable declarations (including inside functions)\n sourceFile.forEachDescendant((node) => {\n if (!Node.isVariableDeclaration(node)) return;\n\n const init = node.getInitializer();\n if (!init || !Node.isCallExpression(init)) return;\n\n // Check if it's a useOutput call\n const expr = init.getExpression();\n if (!Node.isIdentifier(expr) || expr.getText() !== 'useOutput') return;\n\n const args = init.getArguments();\n if (args.length < 1) return;\n\n const agentArg = args[0];\n // Get the string literal value (agent name)\n if (Node.isStringLiteral(agentArg)) {\n const agentName = agentArg.getLiteralValue();\n const identName = node.getName();\n outputs.set(identName, agentName);\n }\n });\n\n return outputs;\n }\n\n /**\n * Extract useStateRef declarations from source file\n * Returns map of identifier name -> state key\n *\n * Uses forEachDescendant to find declarations inside function bodies,\n * following the same pattern as extractOutputDeclarations\n */\n private extractStateRefDeclarations(sourceFile: SourceFile): Map<string, string> {\n const stateRefs = new Map<string, string>();\n\n // Find all variable declarations (including inside functions)\n sourceFile.forEachDescendant((node) => {\n if (!Node.isVariableDeclaration(node)) return;\n\n const init = node.getInitializer();\n if (!init || !Node.isCallExpression(init)) return;\n\n // Check if it's a useStateRef call\n const expr = init.getExpression();\n if (!Node.isIdentifier(expr) || expr.getText() !== 'useStateRef') return;\n\n const args = init.getArguments();\n if (args.length < 1) return;\n\n const keyArg = args[0];\n // Get the string literal value (state key)\n if (Node.isStringLiteral(keyArg)) {\n const stateKey = keyArg.getLiteralValue();\n const identName = node.getName();\n stateRefs.set(identName, stateKey);\n }\n });\n\n return stateRefs;\n }\n\n /**\n * Transform ReadState JSX element into IR node\n *\n * Extracts:\n * - state: StateRef with key property\n * - into: VariableRef with name property\n * - field: optional nested path string\n */\n private transformReadState(node: JsxElement | JsxSelfClosingElement): ReadStateNode {\n const openingElement = Node.isJsxElement(node)\n ? node.getOpeningElement()\n : node;\n\n // Extract state prop (StateRef object with key property)\n const stateAttr = openingElement.getAttribute('state');\n if (!stateAttr || !Node.isJsxAttribute(stateAttr)) {\n throw this.createError('ReadState requires state prop', openingElement);\n }\n const stateInit = stateAttr.getInitializer();\n if (!stateInit || !Node.isJsxExpression(stateInit)) {\n throw this.createError('ReadState state prop must be JSX expression', openingElement);\n }\n // Extract key from StateRef: { key: \"...\" }\n const stateExpr = stateInit.getExpression();\n if (!stateExpr) {\n throw this.createError('ReadState state prop expression is empty', openingElement);\n }\n // Get the identifier name, then resolve to find the key\n const stateKey = this.extractStateKey(stateExpr, openingElement);\n\n // Extract into prop (VariableRef)\n const intoAttr = openingElement.getAttribute('into');\n if (!intoAttr || !Node.isJsxAttribute(intoAttr)) {\n throw this.createError('ReadState requires into prop', openingElement);\n }\n const intoInit = intoAttr.getInitializer();\n if (!intoInit || !Node.isJsxExpression(intoInit)) {\n throw this.createError('ReadState into prop must be JSX expression', openingElement);\n }\n const intoExpr = intoInit.getExpression();\n if (!intoExpr) {\n throw this.createError('ReadState into prop expression is empty', openingElement);\n }\n const variableName = this.extractVariableName(intoExpr, openingElement);\n\n // Extract optional field prop (string)\n const fieldAttr = openingElement.getAttribute('field');\n let field: string | undefined;\n if (fieldAttr && Node.isJsxAttribute(fieldAttr)) {\n const fieldInit = fieldAttr.getInitializer();\n if (fieldInit && Node.isStringLiteral(fieldInit)) {\n field = fieldInit.getLiteralText();\n }\n }\n\n return {\n kind: 'readState',\n stateKey,\n variableName,\n field,\n };\n }\n\n /**\n * Extract state key from StateRef expression\n * Handles: identifier pointing to useStateRef result\n */\n private extractStateKey(expr: Node, element: JsxOpeningElement | JsxSelfClosingElement): string {\n // Handle identifier (e.g., projectState from useStateRef)\n if (Node.isIdentifier(expr)) {\n const name = expr.getText();\n // Look up in tracked state refs (similar to variables tracking)\n const tracked = this.stateRefs.get(name);\n if (tracked) return tracked;\n // Not found - error\n throw this.createError(\n `State reference '${name}' not found. Did you declare it with useStateRef()?`,\n element\n );\n }\n throw this.createError(`Cannot extract state key from: ${expr.getText()}`, element);\n }\n\n /**\n * Extract variable name from VariableRef expression\n * Handles: identifier pointing to useVariable result\n */\n private extractVariableName(expr: Node, element: JsxOpeningElement | JsxSelfClosingElement): string {\n // Handle identifier (e.g., nameVar from useVariable)\n if (Node.isIdentifier(expr)) {\n const name = expr.getText();\n // Look up in tracked variables\n const tracked = this.variables.get(name);\n if (tracked) return tracked.envName;\n // Not found - error\n throw this.createError(\n `Variable '${name}' not found. Did you declare it with useVariable()?`,\n element\n );\n }\n throw this.createError(`Cannot extract variable name from: ${expr.getText()}`, element);\n }\n\n /**\n * Transform WriteState JSX element into IR node\n *\n * Two modes:\n * 1. Field mode: field=\"path\" value={val}\n * 2. Merge mode: merge={partial}\n */\n private transformWriteState(node: JsxElement | JsxSelfClosingElement): WriteStateNode {\n const openingElement = Node.isJsxElement(node)\n ? node.getOpeningElement()\n : node;\n\n // Extract state prop (required)\n const stateAttr = openingElement.getAttribute('state');\n if (!stateAttr || !Node.isJsxAttribute(stateAttr)) {\n throw this.createError('WriteState requires state prop', openingElement);\n }\n const stateInit = stateAttr.getInitializer();\n if (!stateInit || !Node.isJsxExpression(stateInit)) {\n throw this.createError('WriteState state prop must be JSX expression', openingElement);\n }\n const stateExpr = stateInit.getExpression();\n if (!stateExpr) {\n throw this.createError('WriteState state prop expression is empty', openingElement);\n }\n const stateKey = this.extractStateKey(stateExpr, openingElement);\n\n // Check for field prop (field mode)\n const fieldAttr = openingElement.getAttribute('field');\n const mergeAttr = openingElement.getAttribute('merge');\n\n if (fieldAttr && Node.isJsxAttribute(fieldAttr)) {\n // Field mode: field + value\n const fieldInit = fieldAttr.getInitializer();\n if (!fieldInit || !Node.isStringLiteral(fieldInit)) {\n throw this.createError('WriteState field prop must be string literal', openingElement);\n }\n const field = fieldInit.getLiteralText();\n\n // Extract value prop\n const valueAttr = openingElement.getAttribute('value');\n if (!valueAttr || !Node.isJsxAttribute(valueAttr)) {\n throw this.createError('WriteState with field requires value prop', openingElement);\n }\n const valueInit = valueAttr.getInitializer();\n if (!valueInit) {\n throw this.createError('WriteState value prop is empty', openingElement);\n }\n\n let value: { type: 'variable' | 'literal'; content: string };\n if (Node.isStringLiteral(valueInit)) {\n value = { type: 'literal', content: valueInit.getLiteralText() };\n } else if (Node.isJsxExpression(valueInit)) {\n const valueExpr = valueInit.getExpression();\n if (!valueExpr) {\n throw this.createError('WriteState value expression is empty', openingElement);\n }\n // Check if it's a variable reference\n if (Node.isIdentifier(valueExpr)) {\n const varName = valueExpr.getText();\n const tracked = this.variables.get(varName);\n if (tracked) {\n value = { type: 'variable', content: tracked.envName };\n } else {\n // Not a tracked variable - treat as literal expression text\n value = { type: 'literal', content: valueExpr.getText() };\n }\n } else {\n // Treat as literal expression\n value = { type: 'literal', content: valueExpr.getText() };\n }\n } else {\n throw this.createError('WriteState value must be string or expression', openingElement);\n }\n\n return {\n kind: 'writeState',\n stateKey,\n mode: 'field',\n field,\n value,\n };\n } else if (mergeAttr && Node.isJsxAttribute(mergeAttr)) {\n // Merge mode\n const mergeInit = mergeAttr.getInitializer();\n if (!mergeInit || !Node.isJsxExpression(mergeInit)) {\n throw this.createError('WriteState merge prop must be JSX expression', openingElement);\n }\n const mergeExpr = mergeInit.getExpression();\n if (!mergeExpr) {\n throw this.createError('WriteState merge expression is empty', openingElement);\n }\n\n // For merge, we serialize the object literal to JSON\n // This supports simple object literals at compile time\n const content = mergeExpr.getText();\n\n return {\n kind: 'writeState',\n stateKey,\n mode: 'merge',\n value: { type: 'literal', content },\n };\n } else {\n throw this.createError('WriteState requires either field+value or merge prop', openingElement);\n }\n }\n\n /**\n * Transform an OnStatus element to OnStatusNode\n * OnStatus is a block-level element that emits status-based conditionals\n */\n private transformOnStatus(node: JsxElement | JsxSelfClosingElement): OnStatusNode {\n const openingElement = Node.isJsxElement(node)\n ? node.getOpeningElement()\n : node;\n\n // Extract output prop (required) - must be a JSX expression referencing an identifier\n const outputAttr = openingElement.getAttribute('output');\n if (!outputAttr || !Node.isJsxAttribute(outputAttr)) {\n throw this.createError('OnStatus requires output prop', openingElement);\n }\n\n const outputInit = outputAttr.getInitializer();\n if (!outputInit || !Node.isJsxExpression(outputInit)) {\n throw this.createError('OnStatus output must be a JSX expression: output={outputRef}', openingElement);\n }\n\n const outputExpr = outputInit.getExpression();\n if (!outputExpr || !Node.isIdentifier(outputExpr)) {\n throw this.createError('OnStatus output must reference a useOutput result', openingElement);\n }\n\n // Get the identifier text\n const outputIdentifier = outputExpr.getText();\n\n // Look up agent name from outputs map\n const agentName = this.outputs.get(outputIdentifier);\n if (!agentName) {\n throw this.createError(\n `Output '${outputIdentifier}' not found. Did you declare it with useOutput()?`,\n openingElement\n );\n }\n\n // Extract status prop (required)\n const status = getAttributeValue(openingElement, 'status');\n if (!status) {\n throw this.createError('OnStatus requires status prop', openingElement);\n }\n\n // Validate status is one of the allowed values\n const validStatuses = ['SUCCESS', 'BLOCKED', 'NOT_FOUND', 'ERROR', 'CHECKPOINT'];\n if (!validStatuses.includes(status)) {\n throw this.createError(\n `OnStatus status must be one of: ${validStatuses.join(', ')}. Got: ${status}`,\n openingElement\n );\n }\n\n // Transform children as block content\n const children = Node.isJsxElement(node)\n ? this.transformBlockChildren(node.getJsxChildren())\n : [];\n\n return {\n kind: 'onStatus',\n outputRef: {\n kind: 'outputReference',\n agent: agentName,\n },\n status: status as OnStatusNode['status'],\n children: children as BaseBlockNode[],\n };\n }\n\n // ============================================================================\n // MCP Configuration Transformation\n // ============================================================================\n\n /**\n * Transform an MCPConfig element to MCPConfigDocumentNode\n * MCPConfig wraps multiple MCPServer elements into a single document\n * Delegates to document.ts transformMCPConfig()\n */\n private transformMCPConfig(node: JsxElement | JsxSelfClosingElement): MCPConfigDocumentNode {\n return documentTransformMCPConfig(node, this.buildContext());\n }\n\n /**\n * Transform JSX children to BlockNodes, handling If/Else sibling pairs\n */\n private transformBlockChildren(jsxChildren: Node[]): BlockNode[] {\n const blocks: BlockNode[] = [];\n let i = 0;\n\n while (i < jsxChildren.length) {\n const child = jsxChildren[i];\n\n // Skip whitespace-only text\n if (Node.isJsxText(child)) {\n const text = extractText(child);\n if (!text) {\n i++;\n continue;\n }\n }\n\n if (Node.isJsxElement(child) || Node.isJsxSelfClosingElement(child)) {\n const childName = getElementName(child);\n\n if (childName === 'If') {\n // Transform If\n const ifNode = this.transformIf(child);\n blocks.push(ifNode);\n\n // Check for Else sibling\n let nextIndex = i + 1;\n while (nextIndex < jsxChildren.length) {\n const sibling = jsxChildren[nextIndex];\n // Skip whitespace-only text\n if (Node.isJsxText(sibling)) {\n const text = extractText(sibling);\n if (!text) {\n nextIndex++;\n continue;\n }\n }\n // Check if next non-whitespace is Else\n if ((Node.isJsxElement(sibling) || Node.isJsxSelfClosingElement(sibling))\n && getElementName(sibling) === 'Else') {\n const elseNode = this.transformElse(sibling);\n blocks.push(elseNode);\n i = nextIndex; // Skip past Else in outer loop\n }\n break;\n }\n } else {\n const block = this.transformToBlock(child);\n if (block) blocks.push(block);\n }\n } else {\n const block = this.transformToBlock(child);\n if (block) blocks.push(block);\n }\n\n i++;\n }\n\n return blocks;\n }\n\n /**\n * Transform an Assign element to AssignNode\n * Assign emits a bash code block with variable assignment\n *\n * Supports three assignment types (exactly one required):\n * - bash: VAR=$(command)\n * - value: VAR=value (quoted if spaces)\n * - env: VAR=$ENV_VAR\n */\n private transformAssign(node: JsxElement | JsxSelfClosingElement): AssignNode {\n const openingElement = Node.isJsxElement(node)\n ? node.getOpeningElement()\n : node;\n\n // Get the var prop - must be a JSX expression referencing an identifier\n const varAttr = openingElement.getAttribute('var');\n if (!varAttr || !Node.isJsxAttribute(varAttr)) {\n throw this.createError('Assign requires var prop', openingElement);\n }\n\n const init = varAttr.getInitializer();\n if (!init || !Node.isJsxExpression(init)) {\n throw this.createError('Assign var must be a JSX expression: var={variableName}', openingElement);\n }\n\n const expr = init.getExpression();\n if (!expr) {\n throw this.createError('Assign var must reference a useVariable or defineVars result', openingElement);\n }\n\n // Support both patterns:\n // - Identifier: var={phaseDir} (from useVariable)\n // - PropertyAccessExpression: var={vars.PHASE_DIR} (from defineVars)\n let localName: string;\n if (Node.isIdentifier(expr)) {\n localName = expr.getText();\n } else if (Node.isPropertyAccessExpression(expr)) {\n // e.g., vars.MODEL_PROFILE -> \"vars.MODEL_PROFILE\"\n localName = expr.getText();\n } else {\n throw this.createError('Assign var must reference a useVariable or defineVars result', openingElement);\n }\n\n // Look up in extracted variables to get the env name\n const variable = this.variables.get(localName);\n if (!variable) {\n throw this.createError(\n `Variable '${localName}' not found. Did you declare it with useVariable() or defineVars()?`,\n openingElement\n );\n }\n\n // Extract assignment from props (exactly one of bash, value, env)\n const bashProp = this.extractAssignPropValue(openingElement, 'bash');\n const valueProp = this.extractAssignPropValue(openingElement, 'value');\n const envProp = this.extractAssignPropValue(openingElement, 'env');\n\n const propCount = [bashProp, valueProp, envProp].filter(p => p !== undefined).length;\n if (propCount === 0) {\n throw this.createError(\n 'Assign requires one of: bash, value, or env prop',\n openingElement\n );\n }\n if (propCount > 1) {\n throw this.createError(\n 'Assign accepts only one of: bash, value, or env prop',\n openingElement\n );\n }\n\n let assignment: { type: 'bash' | 'value' | 'env'; content: string };\n if (bashProp !== undefined) {\n assignment = { type: 'bash', content: bashProp };\n } else if (valueProp !== undefined) {\n assignment = { type: 'value', content: valueProp };\n } else {\n assignment = { type: 'env', content: envProp! };\n }\n\n // Extract optional comment prop\n const commentProp = this.extractAssignPropValue(openingElement, 'comment');\n\n return {\n kind: 'assign',\n variableName: variable.envName,\n assignment,\n ...(commentProp && { comment: commentProp }),\n };\n }\n\n /**\n * Transform an AssignGroup element to AssignGroupNode\n * AssignGroup collects Assign children into a single bash code block\n */\n private transformAssignGroup(node: JsxElement | JsxSelfClosingElement): AssignGroupNode {\n // AssignGroup must have children\n if (Node.isJsxSelfClosingElement(node)) {\n throw this.createError('AssignGroup must have Assign children', node);\n }\n\n const children = node.getJsxChildren();\n const assignments: AssignNode[] = [];\n let pendingBlankBefore = false; // Track <br/> for next assignment\n\n for (const child of children) {\n // Skip whitespace text nodes\n if (Node.isJsxText(child)) {\n const text = child.getText().trim();\n if (text === '') continue;\n throw this.createError('AssignGroup can only contain Assign or br elements, not text', child);\n }\n\n // Must be JSX element\n if (!Node.isJsxElement(child) && !Node.isJsxSelfClosingElement(child)) {\n throw this.createError('AssignGroup can only contain Assign or br elements', child);\n }\n\n // Get element name\n const opening = Node.isJsxElement(child) ? child.getOpeningElement() : child;\n const tagNameNode = opening.getTagNameNode();\n const name = tagNameNode.getText();\n\n // Handle <br/> - mark that next assignment should have extra blank line\n if (name === 'br') {\n pendingBlankBefore = true;\n continue;\n }\n\n // Must be Assign\n if (name !== 'Assign') {\n throw this.createError(`AssignGroup can only contain Assign or br elements, found: ${name}`, child);\n }\n\n // Transform the Assign element\n const assignNode = this.transformAssign(child);\n\n // Apply pending blank before flag\n if (pendingBlankBefore) {\n assignNode.blankBefore = true;\n pendingBlankBefore = false;\n }\n\n assignments.push(assignNode);\n }\n\n if (assignments.length === 0) {\n throw this.createError('AssignGroup must contain at least one Assign element', node);\n }\n\n return {\n kind: 'assignGroup',\n assignments,\n };\n }\n\n /**\n * Extract assignment prop value from Assign element\n * Handles string literals, JSX expressions with strings, and template literals\n */\n private extractAssignPropValue(\n element: JsxOpeningElement | JsxSelfClosingElement,\n propName: string\n ): string | undefined {\n const attr = element.getAttribute(propName);\n if (!attr || !Node.isJsxAttribute(attr)) return undefined;\n\n const init = attr.getInitializer();\n if (!init) return undefined;\n\n // String literal: prop=\"value\"\n if (Node.isStringLiteral(init)) {\n return init.getLiteralValue();\n }\n\n // JSX expression: prop={...}\n if (Node.isJsxExpression(init)) {\n const expr = init.getExpression();\n if (!expr) return undefined;\n\n // String literal: prop={\"value\"}\n if (Node.isStringLiteral(expr)) {\n return expr.getLiteralValue();\n }\n\n // Template literal without substitution: prop={`value`}\n if (Node.isNoSubstitutionTemplateLiteral(expr)) {\n return expr.getLiteralValue();\n }\n\n // Template expression with substitution: prop={`ls ${VAR}`}\n if (Node.isTemplateExpression(expr)) {\n return this.extractBashTemplate(expr);\n }\n }\n\n return undefined;\n }\n\n /**\n * Extract template literal content preserving ${VAR} syntax for bash\n */\n private extractBashTemplate(expr: TemplateExpression): string {\n const parts: string[] = [];\n\n // Head: text before first ${...}\n parts.push(expr.getHead().getLiteralText());\n\n // Spans: each has expression + literal text after\n for (const span of expr.getTemplateSpans()) {\n const spanExpr = span.getExpression();\n // Preserve ${...} syntax for bash\n parts.push(`\\${${spanExpr.getText()}}`);\n parts.push(span.getLiteral().getLiteralText());\n }\n\n return parts.join('');\n }\n\n /**\n * Extract prompt prop value, preserving multi-line content and {variable} placeholders\n * Supports: prompt=\"string\", prompt={\"string\"}, prompt={`template`}\n */\n private extractPromptProp(element: JsxOpeningElement | JsxSelfClosingElement): string | undefined {\n const attr = element.getAttribute('prompt');\n if (!attr || !Node.isJsxAttribute(attr)) {\n return undefined;\n }\n\n const init = attr.getInitializer();\n if (!init) {\n return undefined;\n }\n\n // String literal: prompt=\"simple string\"\n if (Node.isStringLiteral(init)) {\n return init.getLiteralValue();\n }\n\n // JSX expression: prompt={...}\n if (Node.isJsxExpression(init)) {\n const expr = init.getExpression();\n if (!expr) {\n return undefined;\n }\n\n // String literal in JSX expression: prompt={\"string\"}\n if (Node.isStringLiteral(expr)) {\n return expr.getLiteralValue();\n }\n\n // No-substitution template literal: prompt={`simple template`}\n if (Node.isNoSubstitutionTemplateLiteral(expr)) {\n return expr.getLiteralValue();\n }\n\n // Template expression with substitutions: prompt={`text ${var}`}\n // Note: ${var} in TSX templates become {var} in output (GSD format)\n if (Node.isTemplateExpression(expr)) {\n return this.extractTemplateText(expr);\n }\n }\n\n return undefined;\n }\n\n /**\n * Extract text from a template expression, converting ${var} to {var}\n * This preserves GSD's {variable} placeholder syntax\n */\n private extractTemplateText(expr: TemplateExpression): string {\n const parts: string[] = [];\n\n // Head: text before first ${...}\n parts.push(expr.getHead().getLiteralText());\n\n // Spans: each has expression + literal text after\n for (const span of expr.getTemplateSpans()) {\n const spanExpr = span.getExpression();\n // Convert ${variable} to {variable} for GSD format\n parts.push(`{${spanExpr.getText()}}`);\n parts.push(span.getLiteral().getLiteralText());\n }\n\n return parts.join('');\n }\n\n // ============================================================================\n // State Document Transformation\n // ============================================================================\n\n /**\n * Transform a State component into StateDocumentNode\n * Delegates to document.ts transformState()\n */\n private transformState(node: JsxElement | JsxSelfClosingElement): StateDocumentNode {\n return documentTransformState(node, this.buildContext());\n }\n\n /**\n * Evaluate a binary expression that represents string concatenation.\n * Handles chains like: `text ` + AGENT_PATHS.researcher + ` more`\n * Returns the concatenated string or null if not evaluable.\n */\n private evaluateStringConcatenation(expr: BinaryExpression): string | null {\n const operator = expr.getOperatorToken().getText();\n if (operator !== '+') {\n return null;\n }\n\n const left = expr.getLeft();\n const right = expr.getRight();\n\n const leftValue = this.evaluateStringExpression(left);\n const rightValue = this.evaluateStringExpression(right);\n\n if (leftValue === null || rightValue === null) {\n return null;\n }\n\n return leftValue + rightValue;\n }\n\n /**\n * Evaluate an expression that should resolve to a string value.\n * Handles: string literals, template literals, property access, binary expressions.\n */\n private evaluateStringExpression(expr: Node): string | null {\n if (Node.isStringLiteral(expr)) {\n return expr.getLiteralValue();\n }\n if (Node.isNoSubstitutionTemplateLiteral(expr)) {\n return expr.getLiteralValue();\n }\n if (Node.isTemplateExpression(expr)) {\n // Template expression with substitutions - get the literal text\n let result = expr.getHead().getLiteralText();\n for (const span of expr.getTemplateSpans()) {\n const spanExpr = span.getExpression();\n // Try to evaluate the span expression\n const spanValue = this.evaluateStringExpression(spanExpr);\n if (spanValue !== null) {\n result += spanValue;\n } else if (Node.isIdentifier(spanExpr)) {\n result += `\\${${spanExpr.getText()}}`;\n } else {\n result += `\\${${spanExpr.getText()}}`;\n }\n const literal = span.getLiteral();\n if (Node.isTemplateMiddle(literal)) {\n result += literal.getLiteralText();\n } else if (Node.isTemplateTail(literal)) {\n result += literal.getLiteralText();\n }\n }\n return result;\n }\n if (Node.isPropertyAccessExpression(expr)) {\n return this.resolvePropertyAccess(expr);\n }\n if (Node.isBinaryExpression(expr)) {\n return this.evaluateStringConcatenation(expr);\n }\n if (Node.isParenthesizedExpression(expr)) {\n return this.evaluateStringExpression(expr.getExpression());\n }\n\n return null;\n }\n\n /**\n * Resolve a property access expression (e.g., AGENT_PATHS.researcher) to its value.\n * Only works for const declarations with object literals.\n */\n private resolvePropertyAccess(expr: PropertyAccessExpression): string | null {\n const objectExpr = expr.getExpression();\n const propertyName = expr.getName();\n\n if (!Node.isIdentifier(objectExpr)) {\n return null;\n }\n\n const objectName = objectExpr.getText();\n\n // Find the variable declaration in the source file\n const sourceFile = expr.getSourceFile();\n const varDecls = sourceFile.getVariableDeclarations();\n\n for (const varDecl of varDecls) {\n if (varDecl.getName() === objectName) {\n let initializer = varDecl.getInitializer();\n // Unwrap AsExpression (from \"as const\" syntax)\n if (initializer && Node.isAsExpression(initializer)) {\n initializer = initializer.getExpression();\n }\n if (initializer && Node.isObjectLiteralExpression(initializer)) {\n // Look for the property in the object literal\n for (const prop of initializer.getProperties()) {\n if (Node.isPropertyAssignment(prop) && prop.getName() === propertyName) {\n const propInit = prop.getInitializer();\n if (propInit && Node.isStringLiteral(propInit)) {\n return propInit.getLiteralValue();\n }\n if (propInit && Node.isNoSubstitutionTemplateLiteral(propInit)) {\n return propInit.getLiteralValue();\n }\n }\n }\n }\n break;\n }\n }\n\n return null;\n }\n}\n\n/**\n * Convenience function to transform a JSX element to an AgentDocumentNode, SkillDocumentNode, MCPConfigDocumentNode, or StateDocumentNode\n */\nexport function transform(node: JsxElement | JsxSelfClosingElement | JsxFragment, sourceFile?: SourceFile): AgentDocumentNode | SkillDocumentNode | MCPConfigDocumentNode | StateDocumentNode {\n const transformer = new Transformer();\n return transformer.transform(node, sourceFile);\n}\n","/**\n * Schema-based declarations for react-agentic\n *\n * Provides compile-time helpers for declaring variables, files, and context\n * with TypeScript type safety.\n */\n\nimport type { VariableRef } from './variables.js';\n\n// ============================================================================\n// Variable Schema\n// ============================================================================\n\n/**\n * Definition for a single variable in defineVars schema\n */\nexport interface VarDef {\n /** TypeScript type hint (compile-time only) */\n type?: 'string' | 'number' | 'boolean';\n /** Default value if not assigned */\n default?: string | number | boolean;\n}\n\n/**\n * Schema type for defineVars - maps names to VarDef\n */\nexport type VarSchema = Record<string, VarDef | undefined>;\n\n/**\n * Infer TypeScript type from VarDef\n */\ntype InferVarType<T extends VarDef | undefined> = T extends { type: 'number' }\n ? number\n : T extends { type: 'boolean' }\n ? boolean\n : string;\n\n/**\n * Output type from defineVars - maps schema keys to VariableRefs\n */\nexport type VarsFromSchema<T extends VarSchema> = {\n [K in keyof T]: VariableRef<InferVarType<T[K]>>;\n};\n\n/**\n * Declare multiple shell variables from a schema\n *\n * This is a compile-time helper that creates VariableRef objects.\n * The actual assignment is specified on <Assign> where you emit it.\n *\n * @param schema - Object mapping variable names to VarDef options\n * @returns Object with VariableRef for each schema key\n *\n * @example Basic usage\n * const vars = defineVars({\n * PHASE: { type: 'string' },\n * MODEL_PROFILE: { default: 'balanced' },\n * DEBUG: { type: 'boolean' },\n * });\n *\n * // Use in JSX:\n * <Assign var={vars.PHASE} bash={`echo $PHASE_NUMBER`} />\n * <If test={`[ \"${vars.MODEL_PROFILE.ref}\" = \"quality\" ]`}>\n *\n * @example Replaces multiple useVariable calls\n * // Before:\n * const phase = useVariable('PHASE');\n * const model = useVariable('MODEL_PROFILE');\n * const debug = useVariable('DEBUG');\n *\n * // After:\n * const vars = defineVars({\n * PHASE: {},\n * MODEL_PROFILE: { default: 'balanced' },\n * DEBUG: { type: 'boolean' },\n * });\n */\nexport function defineVars<T extends VarSchema>(schema: T): VarsFromSchema<T> {\n const result: Record<string, VariableRef> = {};\n\n for (const key of Object.keys(schema)) {\n result[key] = { name: key, ref: key };\n }\n\n return result as VarsFromSchema<T>;\n}\n\n// ============================================================================\n// File Schema\n// ============================================================================\n\n/**\n * Definition for a single file in defineFiles schema\n */\nexport interface FileDef {\n /** File path - static string or function using vars */\n path: string | ((vars: Record<string, string>) => string);\n /** Whether file must exist (default: true) */\n required?: boolean;\n}\n\n/**\n * Schema type for defineFiles - maps names to FileDef\n */\nexport type FileSchema = Record<string, FileDef>;\n\n/**\n * Reference to a file defined in schema\n */\nexport interface FileRef {\n /** Variable name for content (e.g., \"STATE_CONTENT\") */\n varName: string;\n /** Original key from schema (e.g., \"state\") */\n key: string;\n /** File path (may contain variable references) */\n path: string;\n /** Whether file is required */\n required: boolean;\n}\n\n/**\n * Output type from defineFiles - maps schema keys to FileRefs\n */\nexport type FilesFromSchema<T extends FileSchema> = {\n [K in keyof T]: FileRef;\n} & {\n /** Get all FileRefs as array (for ReadFiles component) */\n _refs: FileRef[];\n};\n\n/**\n * Declare file contracts with paths and requirements\n *\n * This is a compile-time helper that creates FileRef objects for use\n * with the <ReadFiles> component.\n *\n * @param schema - Object mapping file names to FileDef options\n * @returns Object with FileRef for each schema key, plus _refs array\n *\n * @example Basic usage\n * const files = defineFiles({\n * state: { path: '.planning/STATE.md', required: true },\n * requirements: { path: '.planning/REQUIREMENTS.md', required: false },\n * });\n *\n * // Use with ReadFiles:\n * <ReadFiles files={files} />\n *\n * // Access individual file content variable:\n * <If test={`[ -n \"${files.state.varName}\" ]`}>\n *\n * @example Dynamic paths using variables\n * const files = defineFiles({\n * context: {\n * path: (v) => `${v.PHASE_DIR}/*-CONTEXT.md`,\n * required: false,\n * },\n * });\n */\nexport function defineFiles<T extends FileSchema>(schema: T): FilesFromSchema<T> {\n const result: Record<string, FileRef> = {};\n const refs: FileRef[] = [];\n\n for (const key of Object.keys(schema)) {\n const def = schema[key];\n // Convert key to UPPER_SNAKE_CASE variable name + _CONTENT suffix\n const varName = key.replace(/([a-z])([A-Z])/g, '$1_$2').toUpperCase() + '_CONTENT';\n\n // Resolve path - if function, mark for runtime resolution\n const pathValue = typeof def.path === 'function'\n ? def.path({}) // Placeholder - actual resolution happens at transform time\n : def.path;\n\n const fileRef: FileRef = {\n varName,\n key,\n path: pathValue,\n required: def.required !== false, // Default true\n };\n\n result[key] = fileRef;\n refs.push(fileRef);\n }\n\n return {\n ...result,\n _refs: refs,\n } as FilesFromSchema<T>;\n}\n\n// ============================================================================\n// Context Schema\n// ============================================================================\n\n/**\n * Agent reference for defineContext\n */\nexport interface AgentDef {\n /** Path to agent markdown file */\n path: string;\n /** Optional model override */\n model?: string;\n}\n\n/**\n * Definition for defineContext\n */\nexport interface ContextDef {\n /** Agent definitions */\n agents?: Record<string, string | AgentDef>;\n /** Variable definitions (from defineVars) */\n vars?: VarsFromSchema<VarSchema>;\n /** File definitions (from defineFiles) */\n files?: FilesFromSchema<FileSchema>;\n}\n\n/**\n * Output type from defineContext\n */\nexport interface Context {\n /** Resolved agent references */\n agents: Record<string, { path: string; model?: string }>;\n /** Variable refs (passthrough from defineVars) */\n vars: VarsFromSchema<VarSchema>;\n /** File refs (passthrough from defineFiles) */\n files: FilesFromSchema<FileSchema>;\n}\n\n/**\n * Create unified context for Command or Agent\n *\n * Combines agents, variables, and files into a single context object.\n * This is a compile-time helper - the context is available for\n * use in the component body.\n *\n * @param def - Context definition with agents, vars, and files\n * @returns Unified context object\n *\n * @example Basic usage\n * const ctx = defineContext({\n * agents: {\n * researcher: '~/.claude/agents/gsd-phase-researcher.md',\n * planner: { path: '~/.claude/agents/gsd-planner.md', model: 'sonnet' },\n * },\n * vars: defineVars({\n * PHASE: { type: 'string' },\n * MODEL_PROFILE: { default: 'balanced' },\n * }),\n * files: defineFiles({\n * state: { path: '.planning/STATE.md', required: true },\n * }),\n * });\n *\n * <Command name=\"my-cmd\" context={ctx}>\n * <Assign var={ctx.vars.PHASE} bash={`...`} />\n * <ReadFiles files={ctx.files} />\n * <SpawnAgent agent={ctx.agents.researcher} ... />\n * </Command>\n */\nexport function defineContext(def: ContextDef): Context {\n // Normalize agents\n const agents: Record<string, { path: string; model?: string }> = {};\n if (def.agents) {\n for (const [key, value] of Object.entries(def.agents)) {\n if (typeof value === 'string') {\n agents[key] = { path: value };\n } else {\n agents[key] = value;\n }\n }\n }\n\n return {\n agents,\n vars: def.vars || ({} as unknown as VarsFromSchema<VarSchema>),\n files: def.files || ({ _refs: [] } as unknown as FilesFromSchema<FileSchema>),\n };\n}\n","/**\n * JSX component stubs for react-agentic - Semantic wrapper components\n *\n * These components are compile-time only - they're transformed by the transpiler\n * and never executed at runtime. They exist to provide TypeScript type checking.\n */\n\nimport type { ReactNode } from 'react';\n\n// ============================================================================\n// ExecutionContext\n// ============================================================================\n\n/**\n * Props for the ExecutionContext component\n */\nexport interface ExecutionContextProps {\n /** File paths to include in execution context */\n paths: string[];\n /** Prefix for paths (defaults to '@') */\n prefix?: string;\n /** Optional additional content inside execution_context block */\n children?: ReactNode;\n}\n\n/**\n * ExecutionContext component - emits <execution_context> XML with file paths\n *\n * This is a compile-time component transformed by react-agentic.\n * It's never executed at runtime.\n *\n * @example\n * <ExecutionContext\n * paths={[\n * \"/Users/user/.claude/workflow.md\",\n * \"/Users/user/.claude/templates/summary.md\"\n * ]}\n * />\n *\n * Outputs:\n * <execution_context>\n * @/Users/user/.claude/workflow.md\n * @/Users/user/.claude/templates/summary.md\n * </execution_context>\n *\n * @example\n * <ExecutionContext\n * paths={[\"~/docs/guide.md\"]}\n * prefix=\"$\"\n * >\n * <Markdown>See these files for context.</Markdown>\n * </ExecutionContext>\n *\n * Outputs:\n * <execution_context>\n * $/Users/user/docs/guide.md\n * See these files for context.\n * </execution_context>\n */\nexport function ExecutionContext(_props: ExecutionContextProps): null {\n return null;\n}\n\n// ============================================================================\n// SuccessCriteria\n// ============================================================================\n\n/**\n * Single success criteria item\n */\nexport interface SuccessCriteriaItem {\n /** Criteria description text */\n text: string;\n /** Whether item is initially checked (defaults to false) */\n checked?: boolean;\n}\n\n/**\n * Props for the SuccessCriteria component\n */\nexport interface SuccessCriteriaProps {\n /** Checklist items - can be strings or objects with checked state */\n items: (string | SuccessCriteriaItem)[];\n}\n\n/**\n * SuccessCriteria component - emits <success_criteria> XML with checkbox list\n *\n * This is a compile-time component transformed by react-agentic.\n * It's never executed at runtime.\n *\n * @example\n * <SuccessCriteria\n * items={[\n * \"All tests passing\",\n * \"Documentation updated\",\n * \"Code reviewed\"\n * ]}\n * />\n *\n * Outputs:\n * <success_criteria>\n * - [ ] All tests passing\n * - [ ] Documentation updated\n * - [ ] Code reviewed\n * </success_criteria>\n *\n * @example\n * <SuccessCriteria\n * items={[\n * { text: \"Setup complete\", checked: true },\n * { text: \"Tests passing\", checked: false }\n * ]}\n * />\n *\n * Outputs:\n * <success_criteria>\n * - [x] Setup complete\n * - [ ] Tests passing\n * </success_criteria>\n */\nexport function SuccessCriteria(_props: SuccessCriteriaProps): null {\n return null;\n}\n\n// ============================================================================\n// XmlSection\n// ============================================================================\n\n/**\n * Props for the XmlSection component\n */\nexport interface XmlSectionProps {\n /** XML tag name (e.g., 'objective', 'verification', 'notes') */\n name: string;\n /** Content to wrap in XML tags */\n children: ReactNode;\n}\n\n/**\n * XmlSection component - emits custom XML tags wrapping content\n *\n * This is a compile-time component transformed by react-agentic.\n * It's never executed at runtime.\n *\n * Generic wrapper for custom XML sections not covered by specific components.\n *\n * @example\n * <XmlSection name=\"objective\">\n * <Markdown>Implement authentication system</Markdown>\n * </XmlSection>\n *\n * Outputs:\n * <objective>\n * Implement authentication system\n * </objective>\n *\n * @example\n * <XmlSection name=\"verification\">\n * <List items={[\"Run tests\", \"Check logs\", \"Verify output\"]} />\n * </XmlSection>\n *\n * Outputs:\n * <verification>\n * - Run tests\n * - Check logs\n * - Verify output\n * </verification>\n */\nexport function XmlSection(_props: XmlSectionProps): null {\n return null;\n}\n\n// ============================================================================\n// OfferNext\n// ============================================================================\n\n/**\n * Route definition for OfferNext\n */\nexport interface OfferNextRoute {\n name: string;\n description?: string;\n path: string;\n}\n\n/**\n * Props for the OfferNext component\n */\nexport interface OfferNextProps {\n routes: OfferNextRoute[];\n}\n\n/**\n * OfferNext component - emits route navigation section\n *\n * This is a compile-time component transformed by react-agentic.\n * It's never executed at runtime.\n *\n * @example\n * <OfferNext routes={[\n * { name: \"Execute\", description: \"Run the plan\", path: \"/gsd:execute-phase\" },\n * { name: \"Revise\", path: \"/gsd:plan-phase --revise\" }\n * ]} />\n *\n * Outputs:\n * <offer_next>\n * - **Execute**: Run the plan\n * `/gsd:execute-phase`\n * - **Revise**\n * `/gsd:plan-phase --revise`\n * </offer_next>\n */\nexport function OfferNext(_props: OfferNextProps): null {\n return null;\n}\n\n// ============================================================================\n// XML Wrapper Components\n// ============================================================================\n\n/**\n * Common props for XML wrapper components\n */\nexport interface XmlWrapperProps {\n children: ReactNode;\n}\n\n/**\n * DeviationRules component - emits deviation_rules XML section\n * Used in GSD workflows for handling plan deviations\n *\n * This is a compile-time component transformed by react-agentic.\n * It's never executed at runtime.\n */\nexport function DeviationRules(_props: XmlWrapperProps): null {\n return null;\n}\n\n/**\n * CommitRules component - emits commit_rules XML section\n * Used in GSD workflows for git commit guidelines\n *\n * This is a compile-time component transformed by react-agentic.\n * It's never executed at runtime.\n */\nexport function CommitRules(_props: XmlWrapperProps): null {\n return null;\n}\n\n/**\n * WaveExecution component - emits wave_execution XML section\n * Used in GSD workflows for parallel execution patterns\n *\n * This is a compile-time component transformed by react-agentic.\n * It's never executed at runtime.\n */\nexport function WaveExecution(_props: XmlWrapperProps): null {\n return null;\n}\n\n/**\n * CheckpointHandling component - emits checkpoint_handling XML section\n * Used in GSD workflows for verification checkpoints\n *\n * This is a compile-time component transformed by react-agentic.\n * It's never executed at runtime.\n */\nexport function CheckpointHandling(_props: XmlWrapperProps): null {\n return null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCO,SAAS,SAAS,QAA6B;AACpD,SAAO;AACT;AAgCO,SAAS,SAAS,QAA6B;AACpD,SAAO;AACT;AAgCO,SAAS,OAAO,QAA2B;AAChD,SAAO;AACT;;;ACpDO,SAAS,MAAM,QAA0B;AAC9C,SAAO;AACT;AAuCO,SAAS,KAAK,QAAyB;AAC5C,SAAO;AACT;;;ACVO,SAAS,QAAQ,QAA4B;AAClD,SAAO;AACT;;;ACeO,SAAS,YACd,QACkB;AAClB,SAAO;AAAA,IACL,MAAM,OAAO;AAAA,IACb,MAAM,OAAO;AAAA,IACb,cAAc;AAAA,EAChB;AACF;AAKO,SAAS,WAAW,OAAmC;AAC5D,MAAI,CAAC,SAAS,OAAO,UAAU,SAAU,QAAO;AAChD,SAAQ,MAAmB,iBAAiB;AAC9C;AAKO,SAAS,aAAa,OAAkC;AAC7D,SAAO,WAAW,KAAK,IAAI,MAAM,OAAO;AAC1C;AAKO,SAAS,aAAa,OAA8C;AACzE,SAAO,WAAW,KAAK,IAAI,MAAM,OAAO;AAC1C;AAuEO,SAAS,UAAuB,OAAiE;AACtG,SAAO;AAAA,IACL;AAAA,IACA,OAAO,CAAC,SAAkB,IAAI,KAAK,IAAI,OAAO,IAAI,CAAC;AAAA,EACrD;AACF;AAwBO,SAAS,MAA2C,QAA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