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,3320 @@
1
+ import { ReactNode } from 'react';
2
+ import { SourceFile, Project, JsxElement, JsxSelfClosingElement, JsxFragment, JsxOpeningElement, InterfaceDeclaration, JsxText, JsxExpression, ObjectLiteralExpression, Node } from 'ts-morph';
3
+
4
+ /**
5
+ * Markdown Primitives - Compile-time JSX components
6
+ *
7
+ * These components are compile-time only - they're transformed by the transpiler
8
+ * and never executed at runtime. They exist to provide TypeScript type checking.
9
+ */
10
+
11
+ /**
12
+ * Props for the Markdown component
13
+ */
14
+ interface MarkdownProps {
15
+ /** Raw Markdown content to pass through */
16
+ children?: ReactNode;
17
+ }
18
+ /**
19
+ * Markdown component - passes content through as raw Markdown
20
+ *
21
+ * This is a compile-time component transformed by react-agentic.
22
+ * It's never executed at runtime.
23
+ *
24
+ * @example
25
+ * <Markdown>
26
+ * ## Pre-formatted Section
27
+ *
28
+ * Content that is already in Markdown format.
29
+ * </Markdown>
30
+ */
31
+ declare function Markdown(_props: MarkdownProps): null;
32
+ /**
33
+ * Props for the XmlBlock component
34
+ */
35
+ interface XmlBlockProps {
36
+ /** XML tag name for the block */
37
+ name: string;
38
+ /** Block content */
39
+ children?: ReactNode;
40
+ }
41
+ /**
42
+ * XmlBlock component - creates a named XML block
43
+ *
44
+ * This is a compile-time component transformed by react-agentic.
45
+ * It's never executed at runtime.
46
+ *
47
+ * @example
48
+ * <XmlBlock name="instructions">
49
+ * <p>Content inside the block</p>
50
+ * </XmlBlock>
51
+ *
52
+ * Outputs:
53
+ * <instructions>
54
+ * Content inside the block
55
+ * </instructions>
56
+ */
57
+ declare function XmlBlock(_props: XmlBlockProps): null;
58
+ /**
59
+ * Props for the Indent component
60
+ */
61
+ interface IndentProps {
62
+ /** Number of spaces to indent (default: 2) */
63
+ spaces?: number;
64
+ /** Block content to indent */
65
+ children?: ReactNode;
66
+ }
67
+ /**
68
+ * Indent component - indents content by a specified number of spaces
69
+ *
70
+ * This is a compile-time component transformed by react-agentic.
71
+ * It's never executed at runtime.
72
+ *
73
+ * @example
74
+ * <Indent spaces={4}>
75
+ * This content will be indented by 4 spaces.
76
+ * Each line gets the same indentation.
77
+ * </Indent>
78
+ *
79
+ * Outputs:
80
+ * This content will be indented by 4 spaces.
81
+ * Each line gets the same indentation.
82
+ */
83
+ declare function Indent(_props: IndentProps): null;
84
+
85
+ /**
86
+ * Structured Data Components - Compile-time JSX components
87
+ *
88
+ * These components are compile-time only - they're transformed by the transpiler
89
+ * and never executed at runtime. They exist to provide TypeScript type checking.
90
+ */
91
+ /**
92
+ * Alignment options for table columns
93
+ */
94
+ type TableAlignment = 'left' | 'center' | 'right';
95
+ /**
96
+ * Props for the Table component
97
+ */
98
+ interface TableProps {
99
+ /** Optional header row */
100
+ headers?: string[];
101
+ /** Data rows - each row is an array of cell values (null/undefined use emptyCell) */
102
+ rows: (string | number | null | undefined)[][];
103
+ /** Per-column alignment (defaults to 'left' for all columns) */
104
+ align?: TableAlignment[];
105
+ /** Content for empty cells (defaults to empty string) */
106
+ emptyCell?: string;
107
+ }
108
+ /**
109
+ * Table component - emits markdown table from structured props
110
+ *
111
+ * This is a compile-time component transformed by react-agentic.
112
+ * It's never executed at runtime.
113
+ *
114
+ * @example
115
+ * <Table
116
+ * headers={["Name", "Age", "City"]}
117
+ * rows={[
118
+ * ["Alice", 30, "NYC"],
119
+ * ["Bob", 25, "LA"],
120
+ * ]}
121
+ * align={["left", "right", "center"]}
122
+ * />
123
+ *
124
+ * Outputs:
125
+ * | Name | Age | City |
126
+ * | :--- | ---: | :---: |
127
+ * | Alice | 30 | NYC |
128
+ * | Bob | 25 | LA |
129
+ */
130
+ declare function Table(_props: TableProps): null;
131
+ /**
132
+ * Props for the List component
133
+ */
134
+ interface ListProps {
135
+ /** List items */
136
+ items: (string | number)[];
137
+ /** Use ordered (numbered) list (default: false for bullet list) */
138
+ ordered?: boolean;
139
+ /** Starting number for ordered lists (default: 1) */
140
+ start?: number;
141
+ }
142
+ /**
143
+ * List component - emits markdown list from structured props
144
+ *
145
+ * This is a compile-time component transformed by react-agentic.
146
+ * It's never executed at runtime.
147
+ *
148
+ * @example
149
+ * <List items={["First item", "Second item", "Third item"]} />
150
+ *
151
+ * Outputs:
152
+ * - First item
153
+ * - Second item
154
+ * - Third item
155
+ *
156
+ * @example
157
+ * <List items={["Step one", "Step two"]} ordered start={5} />
158
+ *
159
+ * Outputs:
160
+ * 5. Step one
161
+ * 6. Step two
162
+ */
163
+ declare function List(_props: ListProps): null;
164
+
165
+ /**
166
+ * Command Component - Compile-time JSX component
167
+ *
168
+ * This component is compile-time only - it's transformed by the transpiler
169
+ * and never executed at runtime. It exists to provide TypeScript type checking.
170
+ */
171
+
172
+ /**
173
+ * Command argument definition
174
+ * Used for commands that accept arguments via the skill system
175
+ */
176
+ interface CommandArgument {
177
+ /** Argument name */
178
+ name: string;
179
+ /** Description of the argument */
180
+ description: string;
181
+ /** Whether the argument is required (default: false) */
182
+ required?: boolean;
183
+ }
184
+ /**
185
+ * Context available in Command render props pattern
186
+ * All values resolved at compile time, static in output
187
+ */
188
+ interface CommandContext {
189
+ /** Command name from props */
190
+ name: string;
191
+ /** Command description from props */
192
+ description: string;
193
+ /** Skill name if invoked via skill (undefined otherwise) */
194
+ skill?: string;
195
+ /** Subfolder for output path (e.g., "gsd" → .claude/commands/gsd/my-cmd.md) */
196
+ folder?: string;
197
+ /** Resolved output path (e.g., .claude/commands/my-cmd.md) */
198
+ outputPath: string;
199
+ /** Source TSX file path */
200
+ sourcePath: string;
201
+ }
202
+ /**
203
+ * Props for the Command component
204
+ */
205
+ interface CommandProps {
206
+ /** Command name (used in frontmatter) */
207
+ name: string;
208
+ /** Command description (used in frontmatter) */
209
+ description: string;
210
+ /** Optional argument hint (maps to argument-hint in frontmatter) */
211
+ argumentHint?: string;
212
+ /** Optional agent name (maps to agent in frontmatter) */
213
+ agent?: string;
214
+ /** Optional list of allowed tools (maps to allowed-tools in frontmatter) */
215
+ allowedTools?: string[];
216
+ /** Subfolder for output path (e.g., "gsd" → .claude/commands/gsd/my-cmd.md) */
217
+ folder?: string;
218
+ /** Arguments array (maps to arguments in frontmatter) */
219
+ arguments?: CommandArgument[];
220
+ /**
221
+ * Command body content - either regular JSX or render props function
222
+ * Render props: (ctx: CommandContext) => ReactNode
223
+ */
224
+ children?: ReactNode | ((ctx: CommandContext) => ReactNode);
225
+ }
226
+ /**
227
+ * Command component - creates a Claude Code command with frontmatter
228
+ *
229
+ * This is a compile-time component transformed by react-agentic.
230
+ * It's never executed at runtime.
231
+ *
232
+ * @example
233
+ * <Command name="my-command" description="Does something useful">
234
+ * <p>Command instructions here</p>
235
+ * </Command>
236
+ */
237
+ declare function Command(_props: CommandProps): null;
238
+
239
+ /**
240
+ * Runtime Variable System for Hybrid Runtime
241
+ *
242
+ * RuntimeVar is a branded type that tracks JSON variable paths at compile time.
243
+ * The proxy pattern captures property access for jq expression generation.
244
+ *
245
+ * Usage:
246
+ * const ctx = useRuntimeVar<MyType>('CTX');
247
+ * // ctx.error becomes $(echo "$CTX" | jq -r '.error')
248
+ * // ctx.user.name becomes $(echo "$CTX" | jq -r '.user.name')
249
+ */
250
+ /**
251
+ * Brand symbol for compile-time type safety
252
+ * Prevents accidental mixing of RuntimeVar with regular values
253
+ */
254
+ declare const __runtimeVarBrand: unique symbol;
255
+ /**
256
+ * Internal RuntimeVar metadata interface
257
+ */
258
+ interface RuntimeVarMeta<T> {
259
+ readonly [__runtimeVarBrand]: T;
260
+ /** Shell variable name (e.g., 'CTX') */
261
+ readonly __varName: string;
262
+ /** Property access path (e.g., ['user', 'name']) */
263
+ readonly __path: readonly string[];
264
+ }
265
+ /**
266
+ * Base RuntimeVar type - branded string intersection
267
+ *
268
+ * By intersecting with `string`, RuntimeVar becomes assignable to:
269
+ * - string (for comparisons like `ctx.status === 'SUCCESS'`)
270
+ * - ReactNode (for JSX interpolation like `{ctx.message}`)
271
+ *
272
+ * The brand ensures type safety while allowing ergonomic usage in JSX.
273
+ * At runtime, the proxy's toString() returns the jq expression.
274
+ */
275
+ type RuntimeVar<T> = string & RuntimeVarMeta<T>;
276
+ /**
277
+ * RuntimeVarProxy enables deep property access tracking
278
+ * Each property access returns a new proxy with extended path
279
+ *
280
+ * @example
281
+ * const ctx = useRuntimeVar<{user: {name: string}}>('CTX');
282
+ * ctx.__path // []
283
+ * ctx.user.__path // ['user']
284
+ * ctx.user.name.__path // ['user', 'name']
285
+ *
286
+ * // Works in JSX:
287
+ * <p>Hello, {ctx.user.name}</p>
288
+ *
289
+ * // Works in comparisons:
290
+ * if (ctx.status === 'SUCCESS') { ... }
291
+ */
292
+ type RuntimeVarProxy<T> = RuntimeVar<T> & {
293
+ readonly [K in keyof T]: T[K] extends object ? RuntimeVarProxy<T[K]> : RuntimeVar<T[K]>;
294
+ };
295
+ /**
296
+ * Create a typed runtime variable reference
297
+ *
298
+ * This hook-style function creates a compile-time reference to a shell variable
299
+ * that will be populated at runtime by a RuntimeFn call.
300
+ *
301
+ * The returned proxy tracks property access paths, which the transformer
302
+ * converts to jq expressions for shell execution.
303
+ *
304
+ * @param name - Shell variable name (should be UPPER_SNAKE_CASE)
305
+ * @returns RuntimeVarProxy that tracks property access
306
+ *
307
+ * @example
308
+ * interface Context {
309
+ * error?: string;
310
+ * data: { count: number };
311
+ * }
312
+ *
313
+ * const ctx = useRuntimeVar<Context>('CTX');
314
+ *
315
+ * // In JSX:
316
+ * <If condition={ctx.error}>...</If>
317
+ * // Emits: **If $(echo "$CTX" | jq -r '.error'):**
318
+ *
319
+ * <p>Count: {ctx.data.count}</p>
320
+ * // Emits: Count: $(echo "$CTX" | jq -r '.data.count')
321
+ */
322
+ declare function useRuntimeVar<T>(name: string): RuntimeVarProxy<T>;
323
+ /**
324
+ * Check if a value is a RuntimeVar proxy
325
+ *
326
+ * Used by transformers to detect when to generate jq expressions
327
+ * instead of literal values.
328
+ *
329
+ * @param value - Value to check
330
+ * @returns true if value is a RuntimeVar proxy
331
+ */
332
+ declare function isRuntimeVar(value: unknown): value is RuntimeVar<unknown>;
333
+ /**
334
+ * Extract RuntimeVar metadata from a proxy
335
+ *
336
+ * @param runtimeVar - RuntimeVar proxy
337
+ * @returns Object with varName and path
338
+ */
339
+ declare function getRuntimeVarInfo(runtimeVar: RuntimeVar<unknown>): {
340
+ varName: string;
341
+ path: readonly string[];
342
+ };
343
+ /**
344
+ * Convert RuntimeVar to jq shell expression
345
+ *
346
+ * @param runtimeVar - RuntimeVar proxy
347
+ * @returns Shell command string like $(echo "$VAR" | jq -r '.path')
348
+ *
349
+ * @example
350
+ * toJqExpression(ctx.user.name)
351
+ * // Returns: $(echo "$CTX" | jq -r '.user.name')
352
+ */
353
+ declare function toJqExpression(runtimeVar: RuntimeVar<unknown>): string;
354
+ /**
355
+ * Convert RuntimeVar to raw jq path expression (without shell wrapper)
356
+ *
357
+ * @param runtimeVar - RuntimeVar proxy
358
+ * @returns jq path string like '.user.name'
359
+ */
360
+ declare function toJqPath(runtimeVar: RuntimeVar<unknown>): string;
361
+ /**
362
+ * Allow a value OR its RuntimeVar equivalent
363
+ *
364
+ * Use for component props that should accept runtime interpolation.
365
+ * This enables props to accept either static values or RuntimeVar references.
366
+ *
367
+ * @example
368
+ * interface MyProps {
369
+ * count: OrRuntimeVar<number>; // Accepts 5 or ctx.count
370
+ * name: OrRuntimeVar<string>; // Accepts "hello" or ctx.name
371
+ * }
372
+ */
373
+ type OrRuntimeVar<T> = T | RuntimeVar<T> | RuntimeVarProxy<T>;
374
+ /**
375
+ * Transform object type so each property accepts RuntimeVar
376
+ *
377
+ * Use for complex props like RuntimeFn args where each property
378
+ * can be either a static value or a RuntimeVar reference.
379
+ *
380
+ * @example
381
+ * interface Args { x: number; y: string; }
382
+ * type FlexibleArgs = AllowRuntimeVars<Args>;
383
+ * // { x: number | RuntimeVar<number>; y: string | RuntimeVar<string>; }
384
+ */
385
+ type AllowRuntimeVars<T> = T extends object ? {
386
+ [K in keyof T]: OrRuntimeVar<T[K]>;
387
+ } : OrRuntimeVar<T>;
388
+
389
+ /**
390
+ * Agent Components - Compile-time JSX components
391
+ *
392
+ * These components are compile-time only - they're transformed by the transpiler
393
+ * and never executed at runtime. They exist to provide TypeScript type checking.
394
+ */
395
+
396
+ /**
397
+ * Standard agent status values
398
+ */
399
+ type AgentStatus = 'SUCCESS' | 'BLOCKED' | 'NOT_FOUND' | 'ERROR' | 'CHECKPOINT';
400
+ /**
401
+ * Base output interface for all agents
402
+ */
403
+ interface BaseOutput {
404
+ /** Agent completion status */
405
+ status: AgentStatus;
406
+ /** Explanation when blocked */
407
+ blockedBy?: string;
408
+ /** Error message if failed */
409
+ error?: string;
410
+ }
411
+ /**
412
+ * Context available in Agent render props pattern
413
+ * Extends CommandContext with agent-specific fields
414
+ */
415
+ interface AgentContext extends CommandContext {
416
+ /** Space-separated tool names if defined */
417
+ tools?: string;
418
+ /** Model name if specified in agent */
419
+ model?: string;
420
+ }
421
+ /**
422
+ * Props for the Agent component
423
+ * @typeParam TInput - Type interface for agent input contract (compile-time only)
424
+ * @typeParam TOutput - Type interface for agent output contract (compile-time only)
425
+ */
426
+ interface AgentProps<TInput = unknown, TOutput = unknown> {
427
+ /** Agent name (used in frontmatter and Task() spawning) */
428
+ name: string;
429
+ /** Agent description (used in frontmatter) */
430
+ description: string;
431
+ /** Space-separated tool names (optional) */
432
+ tools?: string;
433
+ /** Terminal color for agent output (optional) */
434
+ color?: string;
435
+ /** Subfolder for output path (optional) - determines namespaced agent name */
436
+ folder?: string;
437
+ /** Model name (optional) - for AgentContext access */
438
+ model?: string;
439
+ /**
440
+ * Agent body content - either regular JSX or render props function
441
+ * Render props: (ctx: AgentContext) => ReactNode
442
+ */
443
+ children?: ReactNode | ((ctx: AgentContext) => ReactNode);
444
+ }
445
+ /**
446
+ * Configuration for defining an agent reference
447
+ */
448
+ interface DefineAgentConfig<TInput = unknown> {
449
+ /** Agent name (must match the Agent's name prop) */
450
+ name: string;
451
+ /** Optional path to the agent markdown file for loadFromFile pattern */
452
+ path?: string;
453
+ /** Input type - only for compile-time inference, not used at runtime */
454
+ _inputType?: TInput;
455
+ }
456
+ /**
457
+ * Type-safe reference to an agent definition
458
+ */
459
+ interface AgentRef<TInput = unknown> {
460
+ /** Agent name for Task() subagent_type */
461
+ name: string;
462
+ /** Optional path for loadFromFile pattern */
463
+ path?: string;
464
+ /** Marker for type guard */
465
+ readonly __isAgentRef: true;
466
+ /** Phantom type for input validation */
467
+ readonly __inputType?: TInput;
468
+ }
469
+ /**
470
+ * Define a type-safe reference to an agent
471
+ */
472
+ declare function defineAgent<TInput = unknown>(config: DefineAgentConfig<TInput>): AgentRef<TInput>;
473
+ /**
474
+ * Type guard for AgentRef
475
+ */
476
+ declare function isAgentRef(value: unknown): value is AgentRef;
477
+ /**
478
+ * Get agent name from string or AgentRef
479
+ */
480
+ declare function getAgentName(agent: string | AgentRef): string;
481
+ /**
482
+ * Get agent path from AgentRef (undefined for string)
483
+ */
484
+ declare function getAgentPath(agent: string | AgentRef): string | undefined;
485
+ /**
486
+ * Props for the SpawnAgent component
487
+ * @typeParam TInput - Type interface to validate against Agent's contract (compile-time only)
488
+ */
489
+ interface SpawnAgentProps<TInput = unknown> {
490
+ /**
491
+ * Agent to spawn - either:
492
+ * - String: Agent name directly (e.g., 'gsd-researcher')
493
+ * - AgentRef: Type-safe reference from defineAgent()
494
+ */
495
+ agent: string | AgentRef<TInput>;
496
+ /** Model to use - supports {variable} placeholders */
497
+ model: string;
498
+ /** Human-readable description of the task */
499
+ description: string;
500
+ /**
501
+ * Enable "load from file" pattern for spawning.
502
+ */
503
+ loadFromFile?: boolean | string;
504
+ /** Prompt content - supports multi-line and {variable} placeholders */
505
+ prompt?: string;
506
+ /** Variable name containing the prompt (for runtime concatenation) */
507
+ promptVariable?: string;
508
+ /** Typed input - either a variable ref or an object literal */
509
+ input?: Partial<TInput>;
510
+ /** Optional extra instructions appended to the auto-generated prompt */
511
+ children?: ReactNode;
512
+ }
513
+ /**
514
+ * V3-compatible SpawnAgent props with RuntimeVar support
515
+ */
516
+ interface V3SpawnAgentProps<TInput = unknown> {
517
+ /** Agent to spawn - accepts RuntimeVar for runtime resolution */
518
+ agent: OrRuntimeVar<string> | AgentRef<TInput>;
519
+ /** Model to use - supports static string or RuntimeVar */
520
+ model: OrRuntimeVar<string>;
521
+ /** Human-readable description - accepts static or RuntimeVar */
522
+ description: OrRuntimeVar<string>;
523
+ /** Enable "load from file" pattern - accepts RuntimeVar */
524
+ loadFromFile?: OrRuntimeVar<string | boolean>;
525
+ /** Prompt content - supports RuntimeVar interpolation */
526
+ prompt?: OrRuntimeVar<string>;
527
+ /** Typed input - accepts RuntimeVar values */
528
+ input?: RuntimeVarProxy<TInput> | Partial<AllowRuntimeVars<TInput>>;
529
+ /** RuntimeVar to store the agent's output */
530
+ output?: RuntimeVarProxy<string>;
531
+ /** Optional extra instructions */
532
+ children?: ReactNode;
533
+ }
534
+ /**
535
+ * Output reference for OnStatus matching
536
+ */
537
+ interface OutputRef {
538
+ agent: string;
539
+ }
540
+ /**
541
+ * Create an output reference for OnStatus
542
+ */
543
+ declare function useOutput<T = unknown>(agent: string): OutputRef & {
544
+ field: (name: keyof T) => string;
545
+ };
546
+ /**
547
+ * Props for the OnStatus component
548
+ */
549
+ interface OnStatusProps {
550
+ /** Output reference from useOutput */
551
+ output: OutputRef;
552
+ /** Status value to match (SUCCESS, BLOCKED, etc.) */
553
+ status: AgentStatus;
554
+ /** Block content for this status */
555
+ children?: ReactNode;
556
+ }
557
+ /**
558
+ * Agent component - creates a Claude Code agent with frontmatter
559
+ *
560
+ * @typeParam TInput - Type interface for agent input contract
561
+ * @typeParam TOutput - Type interface for agent output contract
562
+ */
563
+ declare function Agent<TInput = unknown, TOutput = unknown>(_props: AgentProps<TInput, TOutput>): null;
564
+ /**
565
+ * SpawnAgent component - emits Task() syntax inside a Command
566
+ *
567
+ * @typeParam TInput - Type interface to validate against Agent's contract
568
+ */
569
+ declare function SpawnAgent<TInput = unknown>(_props: SpawnAgentProps<TInput> | V3SpawnAgentProps<TInput>): null;
570
+ /**
571
+ * OnStatus component - conditional block for agent status handling
572
+ */
573
+ declare function OnStatus(_props: OnStatusProps): null;
574
+
575
+ /**
576
+ * Runtime Function System for Hybrid Runtime
577
+ *
578
+ * RuntimeFn wraps TypeScript functions for extraction to runtime.js.
579
+ * Each wrapped function gets a `.Call` component for JSX invocation.
580
+ *
581
+ * Usage:
582
+ * // Define function
583
+ * async function init(args: InitArgs): Promise<InitResult> { ... }
584
+ *
585
+ * // Wrap for compile-time
586
+ * const Init = runtimeFn(init);
587
+ *
588
+ * // Use in JSX
589
+ * <Init.Call args={{ x: "1" }} output={ctx} />
590
+ *
591
+ * // Emits: CTX=$(node runtime.js init '{"x":"1"}')
592
+ */
593
+
594
+ /**
595
+ * Async function that can be wrapped as a RuntimeFn
596
+ * Must be a named async function for extraction
597
+ */
598
+ type RuntimeFunction<TArgs extends object, TReturn> = (args: TArgs) => Promise<TReturn>;
599
+ /**
600
+ * Props for the .Call component
601
+ *
602
+ * @param args - Arguments to pass to the function (each can be static or RuntimeVar)
603
+ * @param output - RuntimeVar to store the result (must match TReturn type)
604
+ */
605
+ interface RuntimeCallProps<TArgs extends object, TReturn> {
606
+ /** Arguments passed to the runtime function. Each property can be static or RuntimeVar. */
607
+ args: AllowRuntimeVars<TArgs>;
608
+ /** RuntimeVar to store the function result */
609
+ output: RuntimeVarProxy<TReturn>;
610
+ }
611
+ /**
612
+ * The .Call component type
613
+ * This is what users invoke in JSX
614
+ */
615
+ type RuntimeCallComponent<TArgs extends object, TReturn> = (props: RuntimeCallProps<TArgs, TReturn>) => null;
616
+ /**
617
+ * Wrapper returned by runtimeFn()
618
+ * Contains the .Call component and metadata for extraction
619
+ */
620
+ interface RuntimeFnComponent<TArgs extends object, TReturn> {
621
+ /** JSX component for invoking the function */
622
+ Call: RuntimeCallComponent<TArgs, TReturn>;
623
+ /** Original function name for extraction */
624
+ readonly fnName: string;
625
+ /** Original function reference for extraction */
626
+ readonly fn: RuntimeFunction<TArgs, TReturn>;
627
+ /** Marker for type guard */
628
+ readonly __isRuntimeFn: true;
629
+ }
630
+ /**
631
+ * Wrap a TypeScript function for runtime extraction
632
+ *
633
+ * The wrapped function:
634
+ * 1. Gets extracted to runtime.js during build
635
+ * 2. Provides a .Call component for JSX invocation
636
+ * 3. Maintains full type safety between args/output
637
+ *
638
+ * @param fn - Async function to wrap
639
+ * @returns RuntimeFnComponent with .Call and metadata
640
+ *
641
+ * @example
642
+ * // Define the function
643
+ * interface InitArgs { projectPath: string }
644
+ * interface InitResult { success: boolean; error?: string }
645
+ *
646
+ * async function initProject(args: InitArgs): Promise<InitResult> {
647
+ * const exists = await checkPath(args.projectPath);
648
+ * return exists
649
+ * ? { success: true }
650
+ * : { success: false, error: 'Path not found' };
651
+ * }
652
+ *
653
+ * // Wrap for JSX use
654
+ * const Init = runtimeFn(initProject);
655
+ *
656
+ * // Use in Command
657
+ * export default (
658
+ * <Command name="setup">
659
+ * {() => {
660
+ * const result = useRuntimeVar<InitResult>('RESULT');
661
+ * return (
662
+ * <>
663
+ * <Init.Call args={{ projectPath: "." }} output={result} />
664
+ * <If condition={result.error}>
665
+ * <p>Error: {result.error}</p>
666
+ * </If>
667
+ * </>
668
+ * );
669
+ * }}
670
+ * </Command>
671
+ * );
672
+ */
673
+ declare function runtimeFn<TArgs extends object, TReturn>(fn: RuntimeFunction<TArgs, TReturn>): RuntimeFnComponent<TArgs, TReturn>;
674
+ /**
675
+ * Check if a value is a RuntimeFn wrapper
676
+ *
677
+ * @param value - Value to check
678
+ * @returns true if value is a RuntimeFnComponent
679
+ */
680
+ declare function isRuntimeFn(value: unknown): value is RuntimeFnComponent<object, unknown>;
681
+ /**
682
+ * Get all registered runtime functions
683
+ *
684
+ * Used by the runtime emitter to extract functions to runtime.js
685
+ *
686
+ * @returns Map of function name -> function
687
+ */
688
+ declare function getRuntimeFnRegistry(): Map<string, RuntimeFunction<object, unknown>>;
689
+ /**
690
+ * Clear the runtime function registry
691
+ *
692
+ * Used between builds to ensure clean state
693
+ */
694
+ declare function clearRuntimeFnRegistry(): void;
695
+ /**
696
+ * Get a specific runtime function by name
697
+ *
698
+ * @param name - Function name
699
+ * @returns Function if found, undefined otherwise
700
+ */
701
+ declare function getRuntimeFn(name: string): RuntimeFunction<object, unknown> | undefined;
702
+
703
+ /**
704
+ * Control Flow Components
705
+ *
706
+ * These components provide typed control flow for commands:
707
+ * - If: Conditional based on RuntimeVar (not shell test strings)
708
+ * - Else: Paired with If for else blocks
709
+ * - Loop: Bounded iteration with max count
710
+ * - Break: Exit current loop
711
+ * - Return: Exit command early
712
+ *
713
+ * Key difference from v1: conditions are RuntimeVar<boolean> expressions,
714
+ * not shell test strings. This enables proper TypeScript type checking.
715
+ */
716
+
717
+ /**
718
+ * Condition can be:
719
+ * - RuntimeVar<boolean> (direct reference)
720
+ * - RuntimeVar<T> (truthy check - undefined/null/empty string = false)
721
+ * - Boolean expression combining RuntimeVars
722
+ * - undefined (from optional property access - treated as falsy)
723
+ *
724
+ * The transformer parses these to Condition IR nodes.
725
+ */
726
+ type Condition$1<T = unknown> = RuntimeVar<T> | RuntimeVarProxy<T> | boolean | undefined;
727
+ /**
728
+ * Props for If component
729
+ *
730
+ * Takes a `condition: RuntimeVar` for type-safe conditions.
731
+ */
732
+ interface IfProps {
733
+ /**
734
+ * Condition to evaluate
735
+ *
736
+ * Can be:
737
+ * - RuntimeVar<boolean> for direct boolean check
738
+ * - RuntimeVar<T> for truthy check (falsy = false, truthy = true)
739
+ *
740
+ * @example
741
+ * <If condition={ctx.error}>...</If>
742
+ * // Emits: **If $(echo "$CTX" | jq -r '.error'):**
743
+ *
744
+ * @example
745
+ * <If condition={ctx.flags.verbose}>...</If>
746
+ * // Emits: **If $(echo "$CTX" | jq -r '.flags.verbose') = "true":**
747
+ */
748
+ condition: Condition$1;
749
+ /** Content to render when condition is true */
750
+ children?: React.ReactNode;
751
+ }
752
+ /**
753
+ * Conditional block
754
+ *
755
+ * Renders children only if condition is truthy.
756
+ * Works with RuntimeVar for type-safe runtime checks.
757
+ *
758
+ * @example
759
+ * const ctx = useRuntimeVar<{ error?: string }>('CTX');
760
+ *
761
+ * <If condition={ctx.error}>
762
+ * <p>Error occurred: {ctx.error}</p>
763
+ * </If>
764
+ */
765
+ declare function If(_props: IfProps): null;
766
+ /**
767
+ * Props for Else component
768
+ */
769
+ interface ElseProps {
770
+ /** Content to render when preceding If condition is false */
771
+ children?: React.ReactNode;
772
+ }
773
+ /**
774
+ * Else block - must follow If as sibling
775
+ *
776
+ * @example
777
+ * <If condition={ctx.success}>
778
+ * <p>Operation succeeded</p>
779
+ * </If>
780
+ * <Else>
781
+ * <p>Operation failed</p>
782
+ * </Else>
783
+ */
784
+ declare function Else(_props: ElseProps): null;
785
+ /**
786
+ * Props for Loop component
787
+ *
788
+ * Loop is bounded iteration, not array iteration.
789
+ * It executes up to `max` times, with optional counter variable.
790
+ */
791
+ interface LoopProps {
792
+ /**
793
+ * Maximum number of iterations
794
+ *
795
+ * Required for loops to prevent infinite loops.
796
+ * Claude will stop after this many iterations.
797
+ * Accepts static number or RuntimeVar<number> for runtime resolution.
798
+ */
799
+ max: OrRuntimeVar<number>;
800
+ /**
801
+ * Optional counter variable
802
+ *
803
+ * If provided, stores the current iteration number (0-indexed).
804
+ * Useful for conditional logic based on iteration count.
805
+ *
806
+ * @example
807
+ * const i = useRuntimeVar<number>('I');
808
+ * <Loop max={5} counter={i}>
809
+ * <p>Iteration: {i}</p>
810
+ * </Loop>
811
+ */
812
+ counter?: RuntimeVarProxy<number>;
813
+ /** Loop body content */
814
+ children?: React.ReactNode;
815
+ }
816
+ /**
817
+ * Bounded loop
818
+ *
819
+ * Executes children up to `max` times.
820
+ * Use Break to exit early, Return to exit the entire command.
821
+ *
822
+ * @example
823
+ * <Loop max={10}>
824
+ * <RuntimeFn.Call args={{}} output={result} />
825
+ * <If condition={result.done}>
826
+ * <Break />
827
+ * </If>
828
+ * </Loop>
829
+ */
830
+ declare function Loop(_props: LoopProps): null;
831
+ /**
832
+ * Props for Break component
833
+ */
834
+ interface BreakProps {
835
+ /** Optional message to display when breaking. Accepts static string or RuntimeVar. */
836
+ message?: OrRuntimeVar<string>;
837
+ }
838
+ /**
839
+ * Exit the current loop early
840
+ *
841
+ * Only valid inside a Loop component.
842
+ * Execution continues after the Loop.
843
+ *
844
+ * @example
845
+ * <Loop max={10}>
846
+ * <RuntimeFn.Call args={{}} output={result} />
847
+ * <If condition={result.error}>
848
+ * <Break message="Error encountered, stopping retry loop" />
849
+ * </If>
850
+ * </Loop>
851
+ */
852
+ declare function Break(_props: BreakProps): null;
853
+ /**
854
+ * Standard return status values
855
+ */
856
+ type ReturnStatus = 'SUCCESS' | 'BLOCKED' | 'NOT_FOUND' | 'ERROR' | 'CHECKPOINT';
857
+ /**
858
+ * Props for Return component
859
+ */
860
+ interface ReturnProps {
861
+ /**
862
+ * Optional status to return
863
+ *
864
+ * Used when the command needs to indicate success/failure
865
+ * to a parent orchestrator. Accepts static status or RuntimeVar.
866
+ */
867
+ status?: OrRuntimeVar<ReturnStatus>;
868
+ /** Optional message to display when returning. Accepts static string or RuntimeVar. */
869
+ message?: OrRuntimeVar<string>;
870
+ }
871
+ /**
872
+ * Exit the command early
873
+ *
874
+ * Stops execution of the entire command.
875
+ * Use for early exit conditions or error handling.
876
+ *
877
+ * @example
878
+ * <If condition={ctx.alreadyExists}>
879
+ * <Return status="SUCCESS" message="Already initialized, nothing to do" />
880
+ * </If>
881
+ *
882
+ * @example
883
+ * <If condition={ctx.criticalError}>
884
+ * <Return status="ERROR" message="Cannot continue due to error" />
885
+ * </If>
886
+ */
887
+ declare function Return(_props: ReturnProps): null;
888
+ /**
889
+ * Marker symbols for control components
890
+ */
891
+ declare const IF_MARKER: unique symbol;
892
+ declare const ELSE_MARKER: unique symbol;
893
+ declare const LOOP_MARKER: unique symbol;
894
+ declare const BREAK_MARKER: unique symbol;
895
+ declare const RETURN_MARKER: unique symbol;
896
+
897
+ /**
898
+ * AskUser Component for Hybrid Runtime
899
+ *
900
+ * Prompts the user with a question and stores the response
901
+ * in a RuntimeVar for subsequent logic.
902
+ *
903
+ * Emits as Claude Code's AskUserQuestion tool syntax.
904
+ */
905
+
906
+ /**
907
+ * Option in the AskUser question
908
+ */
909
+ interface AskUserOption {
910
+ /** Internal value stored in output variable */
911
+ value: string;
912
+ /** Display label shown to user */
913
+ label: string;
914
+ /** Optional description for the option */
915
+ description?: string;
916
+ }
917
+ /**
918
+ * Props for AskUser component
919
+ */
920
+ interface AskUserProps {
921
+ /**
922
+ * Question to ask the user
923
+ *
924
+ * Should be clear and specific, ending with a question mark.
925
+ * Accepts static string or RuntimeVar for runtime interpolation.
926
+ *
927
+ * @example "Which database should we use?"
928
+ */
929
+ question: OrRuntimeVar<string>;
930
+ /**
931
+ * Available options for the user to choose from
932
+ *
933
+ * Must have 2-4 options. User can always select "Other" to provide custom input.
934
+ * Accepts static array or RuntimeVar<AskUserOption[]> for runtime resolution.
935
+ *
936
+ * @example
937
+ * options={[
938
+ * { value: 'postgres', label: 'PostgreSQL', description: 'Recommended for production' },
939
+ * { value: 'sqlite', label: 'SQLite', description: 'Good for development' },
940
+ * ]}
941
+ */
942
+ options: AskUserOption[] | RuntimeVar<AskUserOption[]> | RuntimeVarProxy<AskUserOption[]>;
943
+ /**
944
+ * RuntimeVar to store the user's response
945
+ *
946
+ * Will contain the `value` from the selected option,
947
+ * or custom text if user selected "Other".
948
+ */
949
+ output: RuntimeVarProxy<string>;
950
+ /**
951
+ * Optional header/chip label (max 12 chars)
952
+ *
953
+ * Short label displayed as a chip/tag above the question.
954
+ * Accepts static string or RuntimeVar.
955
+ *
956
+ * @example "Database"
957
+ */
958
+ header?: OrRuntimeVar<string>;
959
+ /**
960
+ * Allow multiple selections
961
+ *
962
+ * When true, user can select multiple options.
963
+ * Output will contain comma-separated values.
964
+ * Accepts static boolean or RuntimeVar.
965
+ *
966
+ * @default false
967
+ */
968
+ multiSelect?: OrRuntimeVar<boolean>;
969
+ }
970
+ /**
971
+ * Ask the user a question and store their response
972
+ *
973
+ * Emits as Claude Code's AskUserQuestion tool invocation.
974
+ * The response is stored in the output RuntimeVar for use
975
+ * in subsequent If conditions or interpolation.
976
+ *
977
+ * @example
978
+ * const dbChoice = useRuntimeVar<string>('DB_CHOICE');
979
+ *
980
+ * <AskUser
981
+ * question="Which database should we use?"
982
+ * header="Database"
983
+ * options={[
984
+ * { value: 'postgres', label: 'PostgreSQL (Recommended)', description: 'Best for production' },
985
+ * { value: 'sqlite', label: 'SQLite', description: 'Good for development' },
986
+ * ]}
987
+ * output={dbChoice}
988
+ * />
989
+ *
990
+ * <If condition={dbChoice === 'postgres'}>
991
+ * <p>Setting up PostgreSQL...</p>
992
+ * </If>
993
+ */
994
+ declare function AskUser(_props: AskUserProps): null;
995
+ /**
996
+ * Marker symbol for AskUser component
997
+ */
998
+ declare const ASK_USER_MARKER: unique symbol;
999
+
1000
+ /**
1001
+ * IR Node Types - Discriminated unions for intermediate representation
1002
+ *
1003
+ * All nodes have a `kind` property that serves as the discriminator,
1004
+ * enabling exhaustive type checking in switch statements.
1005
+ */
1006
+ /**
1007
+ * Plain text content
1008
+ */
1009
+ interface TextNode {
1010
+ kind: 'text';
1011
+ value: string;
1012
+ }
1013
+ /**
1014
+ * Bold/strong text - uses asterisks (**text**)
1015
+ */
1016
+ interface BoldNode {
1017
+ kind: 'bold';
1018
+ children: InlineNode[];
1019
+ }
1020
+ /**
1021
+ * Italic/emphasis text - uses asterisks (*text*)
1022
+ */
1023
+ interface ItalicNode {
1024
+ kind: 'italic';
1025
+ children: InlineNode[];
1026
+ }
1027
+ /**
1028
+ * Inline code - uses backticks (`code`)
1029
+ */
1030
+ interface InlineCodeNode {
1031
+ kind: 'inlineCode';
1032
+ value: string;
1033
+ }
1034
+ /**
1035
+ * Hyperlink with optional text
1036
+ */
1037
+ interface LinkNode {
1038
+ kind: 'link';
1039
+ url: string;
1040
+ children: InlineNode[];
1041
+ }
1042
+ /**
1043
+ * Line break within a block element
1044
+ */
1045
+ interface LineBreakNode {
1046
+ kind: 'lineBreak';
1047
+ }
1048
+ /**
1049
+ * Union of all inline node types
1050
+ */
1051
+ type InlineNode = TextNode | BoldNode | ItalicNode | InlineCodeNode | LinkNode | LineBreakNode;
1052
+ /**
1053
+ * Heading levels 1-6
1054
+ */
1055
+ interface HeadingNode {
1056
+ kind: 'heading';
1057
+ level: 1 | 2 | 3 | 4 | 5 | 6;
1058
+ children: InlineNode[];
1059
+ }
1060
+ /**
1061
+ * Paragraph containing inline content
1062
+ */
1063
+ interface ParagraphNode {
1064
+ kind: 'paragraph';
1065
+ children: InlineNode[];
1066
+ }
1067
+ /**
1068
+ * List item containing block content
1069
+ */
1070
+ interface ListItemNode {
1071
+ kind: 'listItem';
1072
+ children: BaseBlockNode[];
1073
+ }
1074
+ /**
1075
+ * Ordered or unordered list
1076
+ */
1077
+ interface ListNode {
1078
+ kind: 'list';
1079
+ ordered: boolean;
1080
+ items: ListItemNode[];
1081
+ start?: number;
1082
+ }
1083
+ /**
1084
+ * Fenced code block with optional language
1085
+ */
1086
+ interface CodeBlockNode {
1087
+ kind: 'codeBlock';
1088
+ language?: string;
1089
+ content: string;
1090
+ }
1091
+ /**
1092
+ * Blockquote containing block content
1093
+ */
1094
+ interface BlockquoteNode {
1095
+ kind: 'blockquote';
1096
+ children: BaseBlockNode[];
1097
+ }
1098
+ /**
1099
+ * Horizontal rule / thematic break
1100
+ */
1101
+ interface ThematicBreakNode {
1102
+ kind: 'thematicBreak';
1103
+ }
1104
+ /**
1105
+ * Markdown table with optional headers and column alignment
1106
+ */
1107
+ interface TableNode {
1108
+ kind: 'table';
1109
+ headers?: string[];
1110
+ rows: string[][];
1111
+ align?: ('left' | 'center' | 'right')[];
1112
+ emptyCell?: string;
1113
+ }
1114
+ /**
1115
+ * ExecutionContext - emits <execution_context> XML with file paths
1116
+ */
1117
+ interface ExecutionContextNode {
1118
+ kind: 'executionContext';
1119
+ paths: string[];
1120
+ prefix: string;
1121
+ children: BaseBlockNode[];
1122
+ }
1123
+ /**
1124
+ * SuccessCriteria item data
1125
+ */
1126
+ interface SuccessCriteriaItemData {
1127
+ text: string;
1128
+ checked: boolean;
1129
+ }
1130
+ /**
1131
+ * SuccessCriteria - emits <success_criteria> XML with checkbox list
1132
+ */
1133
+ interface SuccessCriteriaNode {
1134
+ kind: 'successCriteria';
1135
+ items: SuccessCriteriaItemData[];
1136
+ }
1137
+ /**
1138
+ * OfferNext route data
1139
+ */
1140
+ interface OfferNextRouteData {
1141
+ name: string;
1142
+ description?: string;
1143
+ path: string;
1144
+ }
1145
+ /**
1146
+ * OfferNext - emits <offer_next> XML with route bullet list
1147
+ */
1148
+ interface OfferNextNode {
1149
+ kind: 'offerNext';
1150
+ routes: OfferNextRouteData[];
1151
+ }
1152
+ /**
1153
+ * XML-style block element (e.g., <example>content</example>)
1154
+ * Used for Claude Code's special sections
1155
+ */
1156
+ interface XmlBlockNode {
1157
+ kind: 'xmlBlock';
1158
+ name: string;
1159
+ attributes?: Record<string, string>;
1160
+ children: BaseBlockNode[];
1161
+ }
1162
+ /**
1163
+ * Invisible grouping container for tight block spacing
1164
+ * Used for <div> without name attribute - no wrapper output, single newlines between children
1165
+ */
1166
+ interface GroupNode {
1167
+ kind: 'group';
1168
+ children: BaseBlockNode[];
1169
+ }
1170
+ /**
1171
+ * Raw markdown content passed through without transformation
1172
+ */
1173
+ interface RawMarkdownNode {
1174
+ kind: 'raw';
1175
+ content: string;
1176
+ }
1177
+ /**
1178
+ * Indented block - prepends spaces to each line of content
1179
+ */
1180
+ interface IndentNode {
1181
+ kind: 'indent';
1182
+ spaces: number;
1183
+ children: BaseBlockNode[];
1184
+ }
1185
+ /**
1186
+ * Shell variable assignment from useVariable/Assign
1187
+ * Emits as bash code block with variable assignment
1188
+ */
1189
+ interface AssignNode {
1190
+ kind: 'assign';
1191
+ variableName: string;
1192
+ assignment: {
1193
+ type: 'bash' | 'value' | 'env';
1194
+ content: string;
1195
+ };
1196
+ comment?: string;
1197
+ blankBefore?: boolean;
1198
+ }
1199
+ /**
1200
+ * Group of shell variable assignments
1201
+ * Emits as single bash code block with all assignments
1202
+ */
1203
+ interface AssignGroupNode {
1204
+ kind: 'assignGroup';
1205
+ assignments: AssignNode[];
1206
+ }
1207
+ /**
1208
+ * Reference to an agent's output in the IR
1209
+ * Captures the agent name for output binding
1210
+ */
1211
+ interface OutputReference {
1212
+ kind: 'outputReference';
1213
+ /** Agent name this output refers to */
1214
+ agent: string;
1215
+ }
1216
+ /**
1217
+ * OnStatus block - conditional based on agent return status
1218
+ * Emits as **On {status}:** prose pattern
1219
+ */
1220
+ interface OnStatusNode {
1221
+ kind: 'onStatus';
1222
+ /** Output reference from useOutput */
1223
+ outputRef: OutputReference;
1224
+ /** Status to match (SUCCESS, BLOCKED, etc.) */
1225
+ status: 'SUCCESS' | 'BLOCKED' | 'NOT_FOUND' | 'ERROR' | 'CHECKPOINT';
1226
+ /** Block content for this status */
1227
+ children: BaseBlockNode[];
1228
+ }
1229
+ /**
1230
+ * Read state value from registry
1231
+ * Emits as bash JSON read operation
1232
+ */
1233
+ interface ReadStateNode {
1234
+ kind: 'readState';
1235
+ /** State key identifier (e.g., 'projectContext') */
1236
+ stateKey: string;
1237
+ /** Variable to store result (from useVariable) */
1238
+ variableName: string;
1239
+ /** Optional: nested field path (e.g., 'user.preferences.theme') */
1240
+ field?: string;
1241
+ }
1242
+ /**
1243
+ * Write state value to registry
1244
+ * Emits as bash JSON write operation
1245
+ */
1246
+ interface WriteStateNode {
1247
+ kind: 'writeState';
1248
+ /** State key identifier (e.g., 'projectContext') */
1249
+ stateKey: string;
1250
+ /** Write mode: 'field' for single field, 'merge' for partial update */
1251
+ mode: 'field' | 'merge';
1252
+ /** For field mode: nested field path (e.g., 'user.name') */
1253
+ field?: string;
1254
+ /** Value to write - either variable reference or literal */
1255
+ value: {
1256
+ type: 'variable' | 'literal';
1257
+ content: string;
1258
+ };
1259
+ }
1260
+ /**
1261
+ * PromptTemplate node - wraps children in markdown code fence
1262
+ * Used to avoid nested escaping in prompt content
1263
+ */
1264
+ interface PromptTemplateNode {
1265
+ kind: 'promptTemplate';
1266
+ children: BaseBlockNode[];
1267
+ }
1268
+ /**
1269
+ * File entry for ReadFilesNode
1270
+ */
1271
+ interface ReadFileEntry {
1272
+ /** Variable name for content (e.g., "STATE_CONTENT") */
1273
+ varName: string;
1274
+ /** File path (may contain variable references) */
1275
+ path: string;
1276
+ /** Whether file is required (affects error suppression) */
1277
+ required: boolean;
1278
+ }
1279
+ /**
1280
+ * ReadFiles node - emit bash commands to read multiple files
1281
+ * Emits as single bash code block with cat commands
1282
+ */
1283
+ interface ReadFilesNode {
1284
+ kind: 'readFiles';
1285
+ files: ReadFileEntry[];
1286
+ }
1287
+ /**
1288
+ * Step output variant
1289
+ */
1290
+ type StepVariant = 'heading' | 'bold' | 'xml';
1291
+ /**
1292
+ * Numbered workflow step
1293
+ * Emits formatted step section based on variant
1294
+ */
1295
+ interface StepNode {
1296
+ kind: 'step';
1297
+ /** Step number (string to support "1.1" sub-steps) */
1298
+ number: string;
1299
+ /** Step name/title */
1300
+ name: string;
1301
+ /** Output format variant (default: 'heading') */
1302
+ variant: StepVariant;
1303
+ /** Step body content */
1304
+ children: BaseBlockNode[];
1305
+ }
1306
+ /**
1307
+ * Base union of all block node types (without runtime nodes)
1308
+ * Use BlockNode from runtime-nodes.ts for the full union including runtime nodes
1309
+ */
1310
+ type BaseBlockNode = HeadingNode | ParagraphNode | ListNode | CodeBlockNode | BlockquoteNode | ThematicBreakNode | TableNode | ExecutionContextNode | SuccessCriteriaNode | OfferNextNode | XmlBlockNode | GroupNode | RawMarkdownNode | IndentNode | AssignNode | AssignGroupNode | OnStatusNode | ReadStateNode | WriteStateNode | ReadFilesNode | PromptTemplateNode | MCPServerNode | StepNode;
1311
+ /**
1312
+ * Internal alias for backward compatibility within this file
1313
+ * @internal
1314
+ */
1315
+ type BlockNode$1 = BaseBlockNode;
1316
+ /**
1317
+ * Agent YAML frontmatter data
1318
+ * Uses GSD format: tools as space-separated string, not array like Command
1319
+ */
1320
+ interface AgentFrontmatterNode {
1321
+ kind: 'agentFrontmatter';
1322
+ name: string;
1323
+ description: string;
1324
+ tools?: string;
1325
+ color?: string;
1326
+ inputType?: TypeReference;
1327
+ outputType?: TypeReference;
1328
+ }
1329
+ /**
1330
+ * Agent document root node
1331
+ * Similar to DocumentNode but with required AgentFrontmatterNode
1332
+ */
1333
+ interface AgentDocumentNode {
1334
+ kind: 'agentDocument';
1335
+ frontmatter: AgentFrontmatterNode;
1336
+ children: BaseBlockNode[];
1337
+ }
1338
+ /**
1339
+ * MCP Server configuration node
1340
+ * Represents a single MCP server definition
1341
+ */
1342
+ interface MCPServerNode {
1343
+ kind: 'mcpServer';
1344
+ name: string;
1345
+ type: 'stdio' | 'http' | 'sse';
1346
+ command?: string;
1347
+ args?: string[];
1348
+ url?: string;
1349
+ headers?: Record<string, string>;
1350
+ env?: Record<string, string>;
1351
+ }
1352
+ /**
1353
+ * MCP configuration document root node
1354
+ * Contains one or more MCP server definitions
1355
+ */
1356
+ interface MCPConfigDocumentNode {
1357
+ kind: 'mcpConfigDocument';
1358
+ servers: MCPServerNode[];
1359
+ }
1360
+ /**
1361
+ * Flattened state schema field
1362
+ * Represents a single column in the generated SQLite table
1363
+ */
1364
+ interface StateSchemaField {
1365
+ /** Column name (flattened path, e.g., "config_debug") */
1366
+ name: string;
1367
+ /** TypeScript type (string, number, boolean, Date) */
1368
+ tsType: string;
1369
+ /** SQL type (TEXT, INTEGER) */
1370
+ sqlType: 'TEXT' | 'INTEGER';
1371
+ /** Default value for init SQL */
1372
+ defaultValue: string;
1373
+ /** Optional: enum values for CHECK constraint */
1374
+ enumValues?: string[];
1375
+ }
1376
+ /**
1377
+ * Parsed state schema from TypeScript interface
1378
+ * Fields are flattened (nested objects become underscore-separated)
1379
+ */
1380
+ interface StateSchema {
1381
+ /** Interface name (e.g., "ReleasesState") */
1382
+ interfaceName: string;
1383
+ /** Flattened fields for SQL columns */
1384
+ fields: StateSchemaField[];
1385
+ }
1386
+ /**
1387
+ * Custom operation node
1388
+ * Represents an Operation child of State component
1389
+ */
1390
+ interface OperationNode {
1391
+ kind: 'operation';
1392
+ /** Operation name (e.g., "record") - becomes skill suffix */
1393
+ name: string;
1394
+ /** SQL template body with $variable placeholders */
1395
+ sqlTemplate: string;
1396
+ /** Inferred argument names from $variable references */
1397
+ args: string[];
1398
+ }
1399
+ /**
1400
+ * State node representing parsed State component
1401
+ */
1402
+ interface StateNode {
1403
+ kind: 'state';
1404
+ /** State name (e.g., "releases") - becomes skill prefix */
1405
+ name: string;
1406
+ /** Provider type (only "sqlite" for now) */
1407
+ provider: 'sqlite';
1408
+ /** Provider-specific configuration */
1409
+ config: {
1410
+ /** Database file path */
1411
+ database: string;
1412
+ };
1413
+ /** Parsed schema from generic type parameter */
1414
+ schema: StateSchema;
1415
+ /** Custom operations defined as children */
1416
+ operations: OperationNode[];
1417
+ }
1418
+ /**
1419
+ * State document root node
1420
+ * Produces multiple skill files in .claude/skills/
1421
+ */
1422
+ interface StateDocumentNode {
1423
+ kind: 'stateDocument';
1424
+ /** The State definition */
1425
+ state: StateNode;
1426
+ }
1427
+ /**
1428
+ * Skill YAML frontmatter data
1429
+ * Uses Claude Code skills format with kebab-case field names
1430
+ */
1431
+ interface SkillFrontmatterNode {
1432
+ kind: 'skillFrontmatter';
1433
+ name: string;
1434
+ description: string;
1435
+ disableModelInvocation?: boolean;
1436
+ userInvocable?: boolean;
1437
+ allowedTools?: string[];
1438
+ argumentHint?: string;
1439
+ model?: string;
1440
+ context?: 'fork';
1441
+ agent?: string;
1442
+ }
1443
+ /**
1444
+ * SkillFile node for generated files within skill
1445
+ * Each SkillFile produces an output file in the skill directory
1446
+ */
1447
+ interface SkillFileNode {
1448
+ kind: 'skillFile';
1449
+ name: string;
1450
+ children: BaseBlockNode[];
1451
+ }
1452
+ /**
1453
+ * SkillStatic node for static file copying
1454
+ * Copies files from source location to skill directory
1455
+ */
1456
+ interface SkillStaticNode {
1457
+ kind: 'skillStatic';
1458
+ src: string;
1459
+ dest?: string;
1460
+ }
1461
+ /**
1462
+ * Skill document root node
1463
+ * Produces a skill directory with SKILL.md plus optional supporting files
1464
+ */
1465
+ interface SkillDocumentNode {
1466
+ kind: 'skillDocument';
1467
+ frontmatter: SkillFrontmatterNode;
1468
+ children: BaseBlockNode[];
1469
+ files: SkillFileNode[];
1470
+ statics: SkillStaticNode[];
1471
+ }
1472
+ /**
1473
+ * Reference to a TypeScript type across files
1474
+ * Used for tracking Agent interface imports in SpawnAgent
1475
+ * Actual validation happens in Phase 11
1476
+ */
1477
+ interface TypeReference {
1478
+ kind: 'typeReference';
1479
+ name: string;
1480
+ sourceFile?: string;
1481
+ resolved?: boolean;
1482
+ }
1483
+ /**
1484
+ * Union of all IR node types
1485
+ */
1486
+ type IRNode = BlockNode$1 | InlineNode | AgentFrontmatterNode | SkillFrontmatterNode | SkillFileNode | SkillStaticNode | ListItemNode | AgentDocumentNode | SkillDocumentNode | MCPConfigDocumentNode | StateDocumentNode | TypeReference;
1487
+ /**
1488
+ * Helper for exhaustiveness checking in switch statements.
1489
+ * If TypeScript complains that the argument is not of type 'never',
1490
+ * it means there's an unhandled case in the switch.
1491
+ */
1492
+ declare function assertNever(x: never): never;
1493
+
1494
+ /**
1495
+ * Runtime IR Node Types
1496
+ *
1497
+ * Node types for runtime-enabled commands:
1498
+ * - Runtime variable declarations and references
1499
+ * - Runtime function calls
1500
+ * - Typed control flow (condition-based)
1501
+ * - User prompts
1502
+ *
1503
+ * All nodes follow the discriminated union pattern with `kind` property.
1504
+ */
1505
+
1506
+ /**
1507
+ * Runtime variable declaration
1508
+ *
1509
+ * Created from useRuntimeVar<T>('NAME') calls.
1510
+ * Tracks the variable name and TypeScript type for validation.
1511
+ */
1512
+ interface RuntimeVarDeclNode {
1513
+ kind: 'runtimeVarDecl';
1514
+ /** Shell variable name (e.g., 'CTX') */
1515
+ varName: string;
1516
+ /** TypeScript type name for documentation (e.g., 'InitResult') */
1517
+ tsType?: string;
1518
+ }
1519
+ /**
1520
+ * Runtime variable reference
1521
+ *
1522
+ * Created from property access on RuntimeVar proxies.
1523
+ * Tracks the full path for jq expression generation.
1524
+ */
1525
+ interface RuntimeVarRefNode {
1526
+ kind: 'runtimeVarRef';
1527
+ /** Shell variable name (e.g., 'CTX') */
1528
+ varName: string;
1529
+ /** Property access path (e.g., ['user', 'name']) */
1530
+ path: string[];
1531
+ }
1532
+ /**
1533
+ * Runtime function call
1534
+ *
1535
+ * Created from <RuntimeFn.Call args={...} output={...} /> elements.
1536
+ * Emits as: VAR=$(node runtime.js fnName '{"args"}')
1537
+ */
1538
+ interface RuntimeCallNode {
1539
+ kind: 'runtimeCall';
1540
+ /** Function name in the runtime registry */
1541
+ fnName: string;
1542
+ /** JSON-serializable arguments */
1543
+ args: Record<string, unknown>;
1544
+ /** Output variable name to store result */
1545
+ outputVar: string;
1546
+ }
1547
+ /**
1548
+ * Condition expression tree
1549
+ *
1550
+ * Represents parsed condition expressions for If.
1551
+ * Supports references, literals, and logical operators.
1552
+ */
1553
+ type Condition = ConditionRef | ConditionLiteral | ConditionNot | ConditionAnd | ConditionOr | ConditionEq | ConditionNeq | ConditionGt | ConditionGte | ConditionLt | ConditionLte;
1554
+ /**
1555
+ * Reference to a runtime variable (truthy check)
1556
+ */
1557
+ interface ConditionRef {
1558
+ type: 'ref';
1559
+ ref: RuntimeVarRefNode;
1560
+ }
1561
+ /**
1562
+ * Literal boolean value
1563
+ */
1564
+ interface ConditionLiteral {
1565
+ type: 'literal';
1566
+ value: boolean;
1567
+ }
1568
+ /**
1569
+ * Logical NOT
1570
+ */
1571
+ interface ConditionNot {
1572
+ type: 'not';
1573
+ operand: Condition;
1574
+ }
1575
+ /**
1576
+ * Logical AND
1577
+ */
1578
+ interface ConditionAnd {
1579
+ type: 'and';
1580
+ left: Condition;
1581
+ right: Condition;
1582
+ }
1583
+ /**
1584
+ * Logical OR
1585
+ */
1586
+ interface ConditionOr {
1587
+ type: 'or';
1588
+ left: Condition;
1589
+ right: Condition;
1590
+ }
1591
+ /**
1592
+ * Equality check
1593
+ */
1594
+ interface ConditionEq {
1595
+ type: 'eq';
1596
+ left: Condition;
1597
+ right: string | number | boolean;
1598
+ }
1599
+ /**
1600
+ * Inequality check
1601
+ */
1602
+ interface ConditionNeq {
1603
+ type: 'neq';
1604
+ left: Condition;
1605
+ right: string | number | boolean;
1606
+ }
1607
+ /**
1608
+ * Greater than check
1609
+ */
1610
+ interface ConditionGt {
1611
+ type: 'gt';
1612
+ left: Condition;
1613
+ right: number;
1614
+ }
1615
+ /**
1616
+ * Greater than or equal check
1617
+ */
1618
+ interface ConditionGte {
1619
+ type: 'gte';
1620
+ left: Condition;
1621
+ right: number;
1622
+ }
1623
+ /**
1624
+ * Less than check
1625
+ */
1626
+ interface ConditionLt {
1627
+ type: 'lt';
1628
+ left: Condition;
1629
+ right: number;
1630
+ }
1631
+ /**
1632
+ * Less than or equal check
1633
+ */
1634
+ interface ConditionLte {
1635
+ type: 'lte';
1636
+ left: Condition;
1637
+ right: number;
1638
+ }
1639
+ /**
1640
+ * If node - condition-based conditional
1641
+ *
1642
+ * Uses a Condition tree for typed conditional logic.
1643
+ */
1644
+ interface IfNode {
1645
+ kind: 'if';
1646
+ /** Parsed condition expression tree */
1647
+ condition: Condition;
1648
+ /** "then" block content */
1649
+ children: BlockNode[];
1650
+ }
1651
+ /**
1652
+ * Else node - paired with If
1653
+ */
1654
+ interface ElseNode {
1655
+ kind: 'else';
1656
+ /** "else" block content */
1657
+ children: BlockNode[];
1658
+ }
1659
+ /**
1660
+ * Loop node - bounded iteration
1661
+ *
1662
+ * Executes up to `max` times.
1663
+ */
1664
+ interface LoopNode {
1665
+ kind: 'loop';
1666
+ /** Maximum iteration count */
1667
+ max: number;
1668
+ /** Optional counter variable name */
1669
+ counterVar?: string;
1670
+ /** Loop body content */
1671
+ children: BlockNode[];
1672
+ }
1673
+ /**
1674
+ * Break node - exit current loop
1675
+ */
1676
+ interface BreakNode {
1677
+ kind: 'break';
1678
+ /** Optional message to display */
1679
+ message?: string;
1680
+ }
1681
+ /**
1682
+ * Return node - exit command early
1683
+ */
1684
+ interface ReturnNode {
1685
+ kind: 'return';
1686
+ /** Optional status code */
1687
+ status?: 'SUCCESS' | 'BLOCKED' | 'NOT_FOUND' | 'ERROR' | 'CHECKPOINT';
1688
+ /** Optional message to display */
1689
+ message?: string;
1690
+ }
1691
+ /**
1692
+ * Option for AskUser
1693
+ */
1694
+ interface AskUserOptionNode {
1695
+ value: string;
1696
+ label: string;
1697
+ description?: string;
1698
+ }
1699
+ /**
1700
+ * AskUser node - prompt user for input
1701
+ *
1702
+ * Emits as AskUserQuestion tool syntax.
1703
+ */
1704
+ interface AskUserNode {
1705
+ kind: 'askUser';
1706
+ /** Question text */
1707
+ question: string;
1708
+ /** Available options */
1709
+ options: AskUserOptionNode[];
1710
+ /** Output variable name */
1711
+ outputVar: string;
1712
+ /** Optional header/chip label */
1713
+ header?: string;
1714
+ /** Allow multiple selections */
1715
+ multiSelect: boolean;
1716
+ }
1717
+ /**
1718
+ * SpawnAgent with output capture
1719
+ */
1720
+ interface SpawnAgentNode {
1721
+ kind: 'spawnAgent';
1722
+ /** Agent name/reference */
1723
+ agent: string;
1724
+ /** Model to use */
1725
+ model: string;
1726
+ /** Human-readable description */
1727
+ description: string;
1728
+ /** Prompt content or variable */
1729
+ prompt?: string;
1730
+ /** Input object (alternative to prompt) */
1731
+ input?: SpawnAgentInput;
1732
+ /** Output variable name to store agent result */
1733
+ outputVar?: string;
1734
+ /** Load agent from file path */
1735
+ loadFromFile?: string;
1736
+ }
1737
+ /**
1738
+ * SpawnAgent input types
1739
+ */
1740
+ type SpawnAgentInput = {
1741
+ type: 'object';
1742
+ properties: InputProperty[];
1743
+ } | {
1744
+ type: 'variable';
1745
+ varName: string;
1746
+ };
1747
+ /**
1748
+ * Property in SpawnAgent input object
1749
+ */
1750
+ interface InputProperty {
1751
+ name: string;
1752
+ value: InputValue;
1753
+ }
1754
+ /**
1755
+ * Value types for SpawnAgent input
1756
+ */
1757
+ type InputValue = {
1758
+ type: 'string';
1759
+ value: string;
1760
+ } | {
1761
+ type: 'runtimeVarRef';
1762
+ ref: RuntimeVarRefNode;
1763
+ } | {
1764
+ type: 'json';
1765
+ value: unknown;
1766
+ };
1767
+ /**
1768
+ * Runtime-specific block nodes
1769
+ */
1770
+ type RuntimeBlockNode = RuntimeVarDeclNode | RuntimeCallNode | IfNode | ElseNode | LoopNode | BreakNode | ReturnNode | AskUserNode | SpawnAgentNode;
1771
+ /**
1772
+ * Union of base and runtime block nodes
1773
+ */
1774
+ type BlockNode = BaseBlockNode | RuntimeBlockNode;
1775
+ /**
1776
+ * Command frontmatter
1777
+ */
1778
+ interface FrontmatterNode {
1779
+ kind: 'frontmatter';
1780
+ data: Record<string, unknown>;
1781
+ }
1782
+ /**
1783
+ * Build-time metadata (not emitted to output)
1784
+ */
1785
+ interface DocumentMetadata {
1786
+ /** Subfolder for output path (e.g., "gsd" → .claude/commands/gsd/cmd.md) */
1787
+ folder?: string;
1788
+ }
1789
+ /**
1790
+ * Document root node
1791
+ *
1792
+ * Represents a command that produces dual output:
1793
+ * - COMMAND.md (markdown for Claude)
1794
+ * - runtime.js (extracted TypeScript functions)
1795
+ */
1796
+ interface DocumentNode {
1797
+ kind: 'document';
1798
+ frontmatter?: FrontmatterNode;
1799
+ /** Build-time metadata (not emitted to output) */
1800
+ metadata?: DocumentMetadata;
1801
+ /** Runtime variable declarations */
1802
+ runtimeVars: RuntimeVarDeclNode[];
1803
+ /** Runtime function names used (for extraction) */
1804
+ runtimeFunctions: string[];
1805
+ /** Body content */
1806
+ children: BlockNode[];
1807
+ }
1808
+ /**
1809
+ * Type guard for runtime-specific nodes
1810
+ */
1811
+ declare function isRuntimeNode(node: unknown): node is RuntimeBlockNode;
1812
+ /**
1813
+ * Type guard for document
1814
+ */
1815
+ declare function isDocument(node: unknown): node is DocumentNode;
1816
+
1817
+ /**
1818
+ * Markdown Emitter - Converts IR to Markdown output
1819
+ *
1820
+ * Uses switch-based emission with exhaustiveness checking.
1821
+ * Handles nested structures (lists, inline formatting) through recursive calls.
1822
+ */
1823
+
1824
+ /**
1825
+ * Convenience function for emitting a document
1826
+ */
1827
+ declare function emit(doc: DocumentNode): string;
1828
+ /**
1829
+ * Convenience function for emitting an agent document
1830
+ */
1831
+ declare function emitAgent(doc: AgentDocumentNode, sourceFile?: SourceFile): string;
1832
+ /**
1833
+ * Convenience function for emitting a skill document
1834
+ */
1835
+ declare function emitSkill(doc: SkillDocumentNode): string;
1836
+ /**
1837
+ * Convenience function for emitting a skill file
1838
+ */
1839
+ declare function emitSkillFile(node: SkillFileNode): string;
1840
+
1841
+ /**
1842
+ * MCP server configuration format for settings.json
1843
+ */
1844
+ interface MCPServerConfig {
1845
+ type: 'stdio' | 'http' | 'sse';
1846
+ command?: string;
1847
+ args?: string[];
1848
+ url?: string;
1849
+ headers?: Record<string, string>;
1850
+ env?: Record<string, string>;
1851
+ }
1852
+ /**
1853
+ * Convert MCPConfigDocumentNode to mcpServers object
1854
+ *
1855
+ * @param doc - MCP config document from transformer
1856
+ * @returns mcpServers object keyed by server name
1857
+ */
1858
+ declare function emitSettings(doc: MCPConfigDocumentNode): Record<string, MCPServerConfig>;
1859
+ /**
1860
+ * Merge MCP servers into existing .mcp.json
1861
+ *
1862
+ * Read-modify-write pattern:
1863
+ * 1. Read existing .mcp.json (or start fresh)
1864
+ * 2. Update only mcpServers section
1865
+ * 3. Write back with pretty formatting
1866
+ *
1867
+ * @param mcpPath - Path to .mcp.json (typically in project root)
1868
+ * @param servers - New mcpServers to merge
1869
+ */
1870
+ declare function mergeSettings(mcpPath: string, servers: Record<string, MCPServerConfig>): Promise<void>;
1871
+
1872
+ /**
1873
+ * V3 Markdown Emitter
1874
+ *
1875
+ * Converts V3 IR nodes to Markdown output with jq expressions.
1876
+ * Extends v1 emitter patterns for shared block types.
1877
+ *
1878
+ * Key differences from v1:
1879
+ * - RuntimeCallNode emits as bash code block with node invocation
1880
+ * - IfNode emits with jq-based conditions
1881
+ * - RuntimeVar interpolation uses jq expressions
1882
+ */
1883
+
1884
+ /**
1885
+ * Emitter for V3 documents
1886
+ */
1887
+ declare class RuntimeMarkdownEmitter {
1888
+ /**
1889
+ * Emit a complete V3 document
1890
+ */
1891
+ emit(doc: DocumentNode): string;
1892
+ /**
1893
+ * Emit a block node
1894
+ */
1895
+ private emitBlock;
1896
+ /**
1897
+ * Emit RuntimeCallNode as bash code block
1898
+ *
1899
+ * Output:
1900
+ * ```bash
1901
+ * CTX=$(node runtime.js fnName '{"args"}')
1902
+ * ```
1903
+ */
1904
+ private emitRuntimeCall;
1905
+ /**
1906
+ * Emit IfNode as prose conditional with jq
1907
+ *
1908
+ * Output:
1909
+ * **If ctx.error:**
1910
+ *
1911
+ * {children}
1912
+ */
1913
+ private emitIf;
1914
+ /**
1915
+ * Emit ElseNode
1916
+ */
1917
+ private emitElse;
1918
+ /**
1919
+ * Emit LoopNode as bounded loop
1920
+ *
1921
+ * Output:
1922
+ * **Loop up to N times:**
1923
+ *
1924
+ * {children}
1925
+ */
1926
+ private emitLoop;
1927
+ /**
1928
+ * Emit BreakNode
1929
+ */
1930
+ private emitBreak;
1931
+ /**
1932
+ * Emit ReturnNode
1933
+ */
1934
+ private emitReturn;
1935
+ /**
1936
+ * Emit AskUserNode as AskUserQuestion syntax
1937
+ */
1938
+ private emitAskUser;
1939
+ /**
1940
+ * Emit SpawnAgentNode as Task() syntax
1941
+ */
1942
+ private emitSpawnAgent;
1943
+ /**
1944
+ * Format V3 input for prompt
1945
+ */
1946
+ private formatInput;
1947
+ /**
1948
+ * Format InputValue
1949
+ */
1950
+ private formatInputValue;
1951
+ private emitInlineChildren;
1952
+ private emitInline;
1953
+ private emitList;
1954
+ private emitBlockquote;
1955
+ private emitTable;
1956
+ private emitXmlBlock;
1957
+ /**
1958
+ * Format a value for YAML output
1959
+ * Quotes strings that contain special YAML characters
1960
+ */
1961
+ private formatYamlValue;
1962
+ private emitExecutionContext;
1963
+ private emitIndent;
1964
+ }
1965
+ /**
1966
+ * Emit a V3 document to markdown
1967
+ */
1968
+ declare function emitDocument(doc: DocumentNode): string;
1969
+
1970
+ /**
1971
+ * Runtime Emitter
1972
+ *
1973
+ * Extracts runtime functions from source files and generates runtime.js.
1974
+ * The runtime.js file is a CLI-invocable bundle that Claude calls via bash.
1975
+ *
1976
+ * Output format:
1977
+ * ```javascript
1978
+ * #!/usr/bin/env node
1979
+ * // Extracted functions
1980
+ * async function init(args) { ... }
1981
+ * async function getContext(args) { ... }
1982
+ *
1983
+ * // Registry
1984
+ * const registry = { init, getContext };
1985
+ *
1986
+ * // CLI entry
1987
+ * const [,, fnName, argsJson] = process.argv;
1988
+ * const result = await registry[fnName](JSON.parse(argsJson));
1989
+ * console.log(JSON.stringify(result));
1990
+ * ```
1991
+ */
1992
+
1993
+ /**
1994
+ * Extracted function information
1995
+ */
1996
+ interface ExtractedFunction {
1997
+ /** Function name */
1998
+ name: string;
1999
+ /** Function source code (body only, without signature) */
2000
+ body: string;
2001
+ /** Parameter names */
2002
+ params: string[];
2003
+ /** Whether it's async */
2004
+ isAsync: boolean;
2005
+ /** Original source file path */
2006
+ sourcePath: string;
2007
+ }
2008
+ /**
2009
+ * Extracted constant information
2010
+ */
2011
+ interface ExtractedConstant {
2012
+ /** Constant name */
2013
+ name: string;
2014
+ /** Constant value as source code */
2015
+ value: string;
2016
+ /** Original source file path */
2017
+ sourcePath: string;
2018
+ }
2019
+ /**
2020
+ * Runtime emission result
2021
+ */
2022
+ interface RuntimeEmitResult {
2023
+ /** Generated runtime.js content */
2024
+ content: string;
2025
+ /** List of functions included (namespaced if applicable) */
2026
+ functions: string[];
2027
+ /** Function bodies for merging (keyed by namespaced name) */
2028
+ functionBodies: Map<string, string>;
2029
+ /** Constants for merging (keyed by name) */
2030
+ constants: Map<string, string>;
2031
+ /** Any warnings during extraction */
2032
+ warnings: string[];
2033
+ }
2034
+ /**
2035
+ * Extract ALL function declarations from a source file
2036
+ *
2037
+ * When extractAll is true, extracts all functions (for runtime files).
2038
+ * Otherwise, only extracts functions in functionNames set.
2039
+ *
2040
+ * @param sourceFile - Source file to scan
2041
+ * @param functionNames - Names of functions to extract (if extractAll is false)
2042
+ * @param extractAll - If true, extract all functions regardless of names
2043
+ * @returns Map of function name -> extracted info
2044
+ */
2045
+ declare function extractFunctions(sourceFile: SourceFile, functionNames: Set<string>, extractAll?: boolean): Map<string, ExtractedFunction>;
2046
+ /**
2047
+ * Generate runtime.js content from extracted functions and constants
2048
+ *
2049
+ * @param functions - Map of original function name -> extracted info
2050
+ * @param constants - Map of constant name -> extracted info
2051
+ * @param namespace - Optional namespace prefix for function names
2052
+ */
2053
+ declare function generateRuntime(functions: Map<string, ExtractedFunction>, constants?: Map<string, ExtractedConstant>, namespace?: string): RuntimeEmitResult;
2054
+ /**
2055
+ * Emit runtime.js from a V3 document's runtime function usage
2056
+ *
2057
+ * @param project - ts-morph project for file resolution
2058
+ * @param mainSourcePath - Path to the main TSX source file
2059
+ * @param functionNames - Names of functions that need to be extracted
2060
+ * @param importPaths - Import paths where functions might be defined
2061
+ * @param namespace - Optional namespace prefix for function names (e.g., 'planPhase')
2062
+ * @returns Runtime emit result with content and metadata
2063
+ */
2064
+ declare function emitRuntime(project: Project, mainSourcePath: string, functionNames: string[], importPaths: string[], namespace?: string): RuntimeEmitResult;
2065
+ /**
2066
+ * Check if a source file contains V3 runtime usage
2067
+ *
2068
+ * Looks for:
2069
+ * - useRuntimeVar imports/usage
2070
+ * - runtimeFn imports/usage
2071
+ *
2072
+ * @param sourceFile - Source file to check
2073
+ * @returns true if file uses V3 runtime features
2074
+ */
2075
+ declare function isRuntimeFile(sourceFile: SourceFile): boolean;
2076
+
2077
+ /**
2078
+ * esbuild-based Runtime Bundler
2079
+ *
2080
+ * Uses esbuild to bundle .runtime.ts files with full npm package support.
2081
+ * This replaces the manual type-stripping approach with proper bundling.
2082
+ */
2083
+
2084
+ /**
2085
+ * Information about a runtime file for single-entry bundling
2086
+ */
2087
+ interface RuntimeFileInfo {
2088
+ /** Absolute path to the .runtime.ts source file */
2089
+ sourcePath: string;
2090
+ /** Namespace prefix for functions (e.g., 'planPhase') */
2091
+ namespace: string;
2092
+ /** Exported function names found in source (without namespace prefix) */
2093
+ exportedFunctions: string[];
2094
+ }
2095
+ /**
2096
+ * Options for single-entry bundling
2097
+ */
2098
+ interface SingleEntryBundleOptions {
2099
+ /** Runtime file info from all V3 files */
2100
+ runtimeFiles: RuntimeFileInfo[];
2101
+ /** Output path for the final runtime.js */
2102
+ outputPath: string;
2103
+ /** Directory for temporary entry file (default: .generated) */
2104
+ entryDir?: string;
2105
+ /** Minify the output bundle (default: false) */
2106
+ minify?: boolean;
2107
+ }
2108
+ /**
2109
+ * Options for code-split bundling
2110
+ */
2111
+ interface CodeSplitBundleOptions {
2112
+ /** Runtime file info from all V3 files */
2113
+ runtimeFiles: RuntimeFileInfo[];
2114
+ /** Output directory for split bundles */
2115
+ outputDir: string;
2116
+ /** Directory for temporary entry files (default: .generated) */
2117
+ entryDir?: string;
2118
+ /** Minify output bundles (default: false) */
2119
+ minify?: boolean;
2120
+ }
2121
+ /**
2122
+ * Result from code-split bundling
2123
+ */
2124
+ interface CodeSplitBundleResult {
2125
+ /** Dispatcher runtime.js content */
2126
+ dispatcherContent: string;
2127
+ /** Map of namespace -> bundled module content */
2128
+ moduleContents: Map<string, string>;
2129
+ /** All function names (with namespace prefixes) */
2130
+ functions: string[];
2131
+ /** Warnings from bundling */
2132
+ warnings: string[];
2133
+ }
2134
+ /**
2135
+ * Result from single-entry bundling
2136
+ */
2137
+ interface SingleEntryBundleResult {
2138
+ /** Final runtime.js content */
2139
+ content: string;
2140
+ /** All function names in registry (with namespace prefixes) */
2141
+ functions: string[];
2142
+ /** Warnings from bundling */
2143
+ warnings: string[];
2144
+ }
2145
+ /**
2146
+ * Extract exported function names from a TypeScript source file
2147
+ */
2148
+ declare function extractExportedFunctionNames(sourceFile: SourceFile): string[];
2149
+ /**
2150
+ * Bundle all runtime files using a single entry point
2151
+ *
2152
+ * This approach:
2153
+ * 1. Generates a TypeScript entry file that imports all runtime modules
2154
+ * 2. Bundles with esbuild (deduplicates shared code automatically)
2155
+ * 3. Wraps with CLI entry point
2156
+ * 4. Cleans up temporary files
2157
+ */
2158
+ declare function bundleSingleEntryRuntime(options: SingleEntryBundleOptions): Promise<SingleEntryBundleResult>;
2159
+ /**
2160
+ * Bundle all runtime files using code-split approach
2161
+ *
2162
+ * This approach:
2163
+ * 1. Generates a TypeScript entry file for each namespace
2164
+ * 2. Bundles each namespace separately with esbuild (in parallel)
2165
+ * 3. Generates a small dispatcher that loads modules on-demand
2166
+ * 4. Cleans up temporary files
2167
+ *
2168
+ * Benefits:
2169
+ * - Faster startup (only loads dispatcher, ~2KB)
2170
+ * - Modules loaded on-demand when function is called
2171
+ * - Each module independently tree-shaken
2172
+ */
2173
+ declare function bundleCodeSplit(options: CodeSplitBundleOptions): Promise<CodeSplitBundleResult>;
2174
+
2175
+ /**
2176
+ * ts-morph Parser - TSX file parsing and JSX AST extraction
2177
+ *
2178
+ * Provides utilities for parsing TSX files and extracting JSX elements
2179
+ * for transformation into IR nodes.
2180
+ */
2181
+
2182
+ /**
2183
+ * Add and parse a file from the filesystem
2184
+ */
2185
+ declare function parseFile(project: Project, filePath: string): SourceFile;
2186
+ /**
2187
+ * Parse an in-memory TSX string
2188
+ */
2189
+ declare function parseSource(project: Project, source: string, fileName?: string): SourceFile;
2190
+ /**
2191
+ * Get the element tag name from a JSX element or self-closing element
2192
+ */
2193
+ declare function getElementName(node: JsxElement | JsxSelfClosingElement): string;
2194
+ /**
2195
+ * JSX child node types
2196
+ */
2197
+ type JsxChild = JsxElement | JsxSelfClosingElement | JsxText | JsxExpression;
2198
+ /**
2199
+ * Get the JSX children of an element
2200
+ */
2201
+ declare function getJsxChildren(node: JsxElement): JsxChild[];
2202
+ /**
2203
+ * Get the value of a JSX attribute by name
2204
+ *
2205
+ * Handles both string literals (attr="value") and JSX expressions with
2206
+ * string literals (attr={"value"}).
2207
+ *
2208
+ * Returns undefined if attribute is missing or not a string.
2209
+ */
2210
+ declare function getAttributeValue(element: JsxOpeningElement | JsxSelfClosingElement, name: string): string | undefined;
2211
+ /**
2212
+ * Find the root JSX element returned by the default export function
2213
+ *
2214
+ * Searches for a ReturnStatement containing JSX within the file.
2215
+ * Returns null if no JSX is found.
2216
+ */
2217
+ declare function findRootJsxElement(sourceFile: SourceFile): JsxElement | JsxSelfClosingElement | JsxFragment | null;
2218
+ /**
2219
+ * Check if a JsxText node contains only whitespace (formatting between elements)
2220
+ */
2221
+ declare function isWhitespaceOnlyText(node: JsxText): boolean;
2222
+ /**
2223
+ * Normalize whitespace in text content
2224
+ *
2225
+ * Collapses multiple spaces/newlines to a single space and trims edges.
2226
+ */
2227
+ declare function normalizeWhitespace(text: string): string;
2228
+ /**
2229
+ * Extract text content from a JsxText node
2230
+ *
2231
+ * Returns null for whitespace-only nodes (formatting between elements).
2232
+ * Otherwise returns normalized text content.
2233
+ */
2234
+ declare function extractText(node: JsxText): string | null;
2235
+ /**
2236
+ * Get the value of a JSX array attribute by name
2237
+ *
2238
+ * Handles JSX expressions containing array literals: attr={["a", "b"]}
2239
+ * Returns undefined if attribute is missing or not a string array.
2240
+ */
2241
+ declare function getArrayAttributeValue(element: JsxOpeningElement | JsxSelfClosingElement, name: string): string[] | undefined;
2242
+ /**
2243
+ * Extract the JSX returned by a component function
2244
+ *
2245
+ * Handles:
2246
+ * - Function declarations: function Foo() { return <div />; }
2247
+ * - Arrow functions: const Foo = () => <div />;
2248
+ * - Arrow functions with body: const Foo = () => { return <div />; };
2249
+ *
2250
+ * @param decl - The component's declaration node
2251
+ * @returns The JSX element/fragment returned, or null if not found
2252
+ */
2253
+ /**
2254
+ * Extract generic type arguments from a JSX element
2255
+ *
2256
+ * For <SpawnAgent<ResearcherInput>> returns ['ResearcherInput']
2257
+ * For <Agent<MyInput>> returns ['MyInput']
2258
+ * Returns undefined if no type arguments present
2259
+ *
2260
+ * Uses ts-morph's getDescendantsOfKind to find TypeReference nodes within the
2261
+ * opening element's tag, which is where JSX type arguments are attached.
2262
+ */
2263
+ declare function extractTypeArguments(element: JsxElement | JsxSelfClosingElement): string[] | undefined;
2264
+ /**
2265
+ * Result of resolving a type import
2266
+ */
2267
+ interface ResolvedType {
2268
+ sourceFile: SourceFile;
2269
+ interfaceName: string;
2270
+ interface: InterfaceDeclaration;
2271
+ }
2272
+ /**
2273
+ * Resolve a type name to its interface declaration
2274
+ * Follows import declarations to find the source file and interface
2275
+ *
2276
+ * @param typeName - Name of the type to resolve (e.g., 'ResearcherInput')
2277
+ * @param sourceFile - Source file containing the import
2278
+ * @returns ResolvedType with source file and interface, or undefined if not found
2279
+ */
2280
+ declare function resolveTypeImport(typeName: string, sourceFile: SourceFile): ResolvedType | undefined;
2281
+ /**
2282
+ * Property information extracted from an interface
2283
+ */
2284
+ interface InterfaceProperty {
2285
+ name: string;
2286
+ required: boolean;
2287
+ type: string;
2288
+ }
2289
+ /**
2290
+ * Extract property information from an interface
2291
+ *
2292
+ * @param iface - Interface declaration to extract from
2293
+ * @returns Array of property information
2294
+ */
2295
+ declare function extractInterfaceProperties(iface: InterfaceDeclaration): InterfaceProperty[];
2296
+ /**
2297
+ * Extract {placeholder} patterns from a prompt string
2298
+ *
2299
+ * @param prompt - Prompt string with {variable} placeholders
2300
+ * @returns Set of placeholder names (without braces)
2301
+ */
2302
+ declare function extractPromptPlaceholders(prompt: string): Set<string>;
2303
+ /**
2304
+ * Extracted variable information from useVariable() call
2305
+ */
2306
+ interface ExtractedVariable {
2307
+ /** Local const name (e.g., "phaseDir") */
2308
+ localName: string;
2309
+ /** Shell variable name (e.g., "PHASE_DIR") */
2310
+ envName: string;
2311
+ }
2312
+ /**
2313
+ * Extract all useVariable() and defineVars() declarations from a source file
2314
+ *
2315
+ * Finds patterns like:
2316
+ * const phaseDir = useVariable("PHASE_DIR");
2317
+ * const vars = defineVars({ MODEL_PROFILE: { type: 'string' } });
2318
+ *
2319
+ * For defineVars, each property becomes a separate entry:
2320
+ * vars.MODEL_PROFILE -> { localName: 'vars.MODEL_PROFILE', envName: 'MODEL_PROFILE' }
2321
+ *
2322
+ * @param sourceFile - Source file to extract from
2323
+ * @returns Map from local variable name to ExtractedVariable info
2324
+ */
2325
+ declare function extractVariableDeclarations(sourceFile: SourceFile): Map<string, ExtractedVariable>;
2326
+
2327
+ /**
2328
+ * Extract SpawnAgent input object literal properties
2329
+ *
2330
+ * Handles property values:
2331
+ * - String literal: { propName: "value" } -> { type: 'string', value: str }
2332
+ * - {placeholder} pattern: { propName: "{var}" } -> { type: 'placeholder', name: var }
2333
+ * - Identifier referencing variable: { propName: varRef } -> { type: 'variable', name: envName }
2334
+ *
2335
+ * @param objLiteral - The ObjectLiteralExpression from JSX input prop
2336
+ * @param variables - Map of declared useVariable results
2337
+ * @returns Array of InputProperty with proper InputValue types
2338
+ */
2339
+ declare function extractInputObjectLiteral(objLiteral: ObjectLiteralExpression, variables: Map<string, ExtractedVariable>): InputProperty[];
2340
+
2341
+ /**
2342
+ * Information about a useRuntimeVar declaration
2343
+ */
2344
+ interface RuntimeVarInfo {
2345
+ /** Variable name (shell variable) */
2346
+ varName: string;
2347
+ /** TypeScript identifier name in source */
2348
+ identifierName: string;
2349
+ /** TypeScript type argument (if provided) */
2350
+ tsType?: string;
2351
+ /** Source location for error messages */
2352
+ location: {
2353
+ line: number;
2354
+ column: number;
2355
+ };
2356
+ }
2357
+ /**
2358
+ * Information about a runtimeFn declaration
2359
+ */
2360
+ interface RuntimeFunctionInfo {
2361
+ /** Function name */
2362
+ fnName: string;
2363
+ /** Identifier name of the wrapper (e.g., 'Init' from 'const Init = runtimeFn(init)') */
2364
+ wrapperName: string;
2365
+ /** Source file path where function is defined */
2366
+ sourceFilePath: string;
2367
+ /** Whether the function is imported vs defined locally */
2368
+ isImported: boolean;
2369
+ /** Import path if imported (e.g., './runtime/init') */
2370
+ importPath?: string;
2371
+ }
2372
+ /**
2373
+ * Information about a local component definition
2374
+ *
2375
+ * Tracks PascalCase function components defined in the same file
2376
+ * or imported from external files for build-time inlining.
2377
+ */
2378
+ interface LocalComponentInfo {
2379
+ /** Component name (PascalCase) */
2380
+ name: string;
2381
+ /** The AST node of the declaration (VariableDeclaration or FunctionDeclaration) */
2382
+ declaration: Node;
2383
+ /** Names of props (from destructured params or single param name) */
2384
+ propNames: string[];
2385
+ /** Cached JSX returned by the component (filled on first expansion) */
2386
+ jsx?: JsxElement | JsxSelfClosingElement | JsxFragment;
2387
+ /** Source file path where component is defined (for external components) */
2388
+ sourceFilePath?: string;
2389
+ /** Whether this component is imported from an external file */
2390
+ isExternal?: boolean;
2391
+ /** Import path if imported (e.g., './components/banner') */
2392
+ importPath?: string;
2393
+ }
2394
+ /**
2395
+ * Context for runtime transformers
2396
+ *
2397
+ * Tracks:
2398
+ * - RuntimeVar declarations (for type-safe references)
2399
+ * - RuntimeFn usage (for extraction to runtime.js)
2400
+ */
2401
+ interface RuntimeTransformContext {
2402
+ /** Source file being transformed */
2403
+ sourceFile: SourceFile | undefined;
2404
+ /** Namespace for runtime functions (derived from filename) */
2405
+ namespace: string;
2406
+ /** Visited paths for circular import detection */
2407
+ visitedPaths: Set<string>;
2408
+ /** Runtime variable declarations: identifier name -> info */
2409
+ runtimeVars: Map<string, RuntimeVarInfo>;
2410
+ /** Runtime function wrappers: wrapper name -> info */
2411
+ runtimeFunctions: Map<string, RuntimeFunctionInfo>;
2412
+ /** Runtime function imports: paths to extract from */
2413
+ runtimeImports: Set<string>;
2414
+ /** Create error with source location */
2415
+ createError: (message: string, node: Node) => Error;
2416
+ /** Track runtime function usage during transformation */
2417
+ usedRuntimeFunctions: Set<string>;
2418
+ /** Local component definitions: name -> info */
2419
+ localComponents: Map<string, LocalComponentInfo>;
2420
+ /** Component expansion stack for circular reference detection */
2421
+ componentExpansionStack: Set<string>;
2422
+ /** Current component props during expansion (for prop substitution) */
2423
+ componentProps: Map<string, unknown> | null;
2424
+ /** Current component children during expansion (for children substitution) */
2425
+ componentChildren: BlockNode[] | null;
2426
+ }
2427
+ /**
2428
+ * Create a fresh runtime transform context
2429
+ *
2430
+ * @param sourceFile - Source file being transformed (optional)
2431
+ * @param namespace - Namespace for runtime functions (defaults to basename of sourceFile)
2432
+ */
2433
+ declare function createRuntimeContext(sourceFile?: SourceFile, namespace?: string): RuntimeTransformContext;
2434
+ /**
2435
+ * Result of runtime transformation
2436
+ *
2437
+ * Contains the document node and metadata needed for dual emission.
2438
+ */
2439
+ interface RuntimeTransformResult {
2440
+ /** Transformed document */
2441
+ document: DocumentNode;
2442
+ /** Runtime variable declarations (for markdown emission) */
2443
+ runtimeVars: RuntimeVarDeclNode[];
2444
+ /** Runtime function names used (for runtime.js extraction) */
2445
+ runtimeFunctions: string[];
2446
+ /** Import paths to extract functions from */
2447
+ runtimeImportPaths: string[];
2448
+ }
2449
+
2450
+ /**
2451
+ * Runtime Component Transformer
2452
+ *
2453
+ * Handles build-time inlining of local function components.
2454
+ * Enables React-style component definitions:
2455
+ *
2456
+ * ```tsx
2457
+ * const Glenn = () => <h2>Glenn</h2>;
2458
+ * const Greeting = ({ name }: { name: string }) => <p>Hello {name}</p>;
2459
+ *
2460
+ * // Usage
2461
+ * <Glenn />
2462
+ * <Greeting name="World" />
2463
+ * ```
2464
+ */
2465
+
2466
+ /**
2467
+ * Extract all local component definitions from a source file
2468
+ *
2469
+ * Scans for:
2470
+ * - Variable declarations: `const Glenn = () => <h2>Glenn</h2>`
2471
+ * - Function declarations: `function Glenn() { return <h2>Glenn</h2> }`
2472
+ *
2473
+ * Components must:
2474
+ * - Have PascalCase names
2475
+ * - Be arrow functions, function expressions, or function declarations
2476
+ * - Return JSX
2477
+ */
2478
+ declare function extractLocalComponentDeclarations(sourceFile: SourceFile, ctx: RuntimeTransformContext): void;
2479
+ /**
2480
+ * Extract external component declarations from imports
2481
+ *
2482
+ * Scans for relative imports that reference PascalCase components
2483
+ * and registers them in the context for build-time inlining.
2484
+ *
2485
+ * Supports:
2486
+ * - Default imports: `import Banner from './banner'`
2487
+ * - Named imports: `import { Header, Footer } from './ui'`
2488
+ */
2489
+ declare function extractExternalComponentDeclarations(sourceFile: SourceFile, ctx: RuntimeTransformContext): void;
2490
+
2491
+ /**
2492
+ * Runtime Variable Transformer
2493
+ *
2494
+ * Extracts useRuntimeVar<T>('NAME') declarations from source files.
2495
+ * Populates the RuntimeTransformContext with variable info for reference resolution.
2496
+ */
2497
+
2498
+ /**
2499
+ * Extract all useRuntimeVar declarations from a source file
2500
+ *
2501
+ * Searches for patterns like:
2502
+ * - const ctx = useRuntimeVar<Type>('NAME')
2503
+ * - const { a, b } = useRuntimeVar<Type>('NAME') (not supported, error)
2504
+ *
2505
+ * @param sourceFile - Source file to scan
2506
+ * @param ctx - Transform context to populate
2507
+ */
2508
+ declare function extractRuntimeVarDeclarations(sourceFile: SourceFile, ctx: RuntimeTransformContext): void;
2509
+
2510
+ /**
2511
+ * Runtime Function Transformer
2512
+ *
2513
+ * Extracts runtimeFn(fn) declarations from source files.
2514
+ * Tracks wrapper names and import paths for runtime.js extraction.
2515
+ */
2516
+
2517
+ /**
2518
+ * Extract all runtimeFn declarations from a source file
2519
+ *
2520
+ * Searches for patterns like:
2521
+ * - const Init = runtimeFn(initFunction)
2522
+ * - const GetContext = runtimeFn(getContext)
2523
+ *
2524
+ * Also tracks imports of the wrapped functions for extraction.
2525
+ *
2526
+ * @param sourceFile - Source file to scan
2527
+ * @param ctx - Transform context to populate
2528
+ */
2529
+ declare function extractRuntimeFnDeclarations(sourceFile: SourceFile, ctx: RuntimeTransformContext): void;
2530
+ /**
2531
+ * Get runtime function names from context
2532
+ *
2533
+ * Returns the list of function names (not wrapper names) that need
2534
+ * to be extracted to runtime.js.
2535
+ */
2536
+ declare function getRuntimeFunctionNames(ctx: RuntimeTransformContext): string[];
2537
+ /**
2538
+ * Get runtime import paths from context
2539
+ *
2540
+ * Returns paths that need to be parsed for function extraction.
2541
+ */
2542
+ declare function getRuntimeImportPaths(ctx: RuntimeTransformContext): string[];
2543
+
2544
+ /**
2545
+ * Runtime Central Transform Dispatcher
2546
+ *
2547
+ * Routes JSX elements to appropriate runtime transformers.
2548
+ * Delegates unchanged elements (headings, lists, etc.) to shared transformers.
2549
+ */
2550
+
2551
+ /**
2552
+ * Transform a JSX node to BlockNode
2553
+ */
2554
+ declare function transformToRuntimeBlock(node: Node, ctx: RuntimeTransformContext): BlockNode | null;
2555
+ /**
2556
+ * Transform JSX children to BlockNodes, handling If/Else sibling pairs
2557
+ */
2558
+ declare function transformRuntimeBlockChildren(parent: JsxElement, ctx: RuntimeTransformContext): BlockNode[];
2559
+ /**
2560
+ * Transform a V3 Command element to DocumentNode
2561
+ *
2562
+ * Supports two patterns:
2563
+ * 1. Render props: <Command>{() => { return (<>...</>) }}</Command>
2564
+ * 2. Direct children: <Command>...</Command>
2565
+ */
2566
+ declare function transformRuntimeCommand(root: JsxElement | JsxSelfClosingElement, ctx: RuntimeTransformContext): DocumentNode;
2567
+
2568
+ /**
2569
+ * Runtime Build Pipeline
2570
+ *
2571
+ * Transforms TSX files to dual output:
2572
+ * - COMMAND.md (markdown for Claude)
2573
+ * - runtime.js (bundled TypeScript functions via esbuild)
2574
+ */
2575
+
2576
+ /**
2577
+ * V3 build result
2578
+ */
2579
+ interface RuntimeBuildResult {
2580
+ /** Generated markdown content */
2581
+ markdown: string;
2582
+ /** Generated runtime.js content (empty - bundling happens at end) */
2583
+ runtime: string;
2584
+ /** Full runtime result for merging (null if no runtime functions) - LEGACY */
2585
+ runtimeResult: RuntimeEmitResult | null;
2586
+ /** Runtime file info for single-entry bundling (null if no runtime functions) */
2587
+ runtimeFileInfo: RuntimeFileInfo | null;
2588
+ /** Path where markdown should be written */
2589
+ markdownPath: string;
2590
+ /** Path where runtime should be written */
2591
+ runtimePath: string;
2592
+ /** List of runtime functions extracted (without namespace prefix) */
2593
+ runtimeFunctions: string[];
2594
+ /** Any warnings during build */
2595
+ warnings: string[];
2596
+ }
2597
+ /**
2598
+ * V3 build options
2599
+ */
2600
+ interface RuntimeBuildOptions {
2601
+ /** Output directory for commands */
2602
+ commandsOut: string;
2603
+ /** Output directory for runtime */
2604
+ runtimeOut: string;
2605
+ /** Dry run - don't write files */
2606
+ dryRun?: boolean;
2607
+ }
2608
+ /**
2609
+ * Build a Runtime file to markdown and runtime.js
2610
+ *
2611
+ * @param sourceFile - Source file to build
2612
+ * @param project - ts-morph project for resolution
2613
+ * @param options - Build options
2614
+ * @returns Build result with content and paths
2615
+ */
2616
+ declare function buildRuntimeFile(sourceFile: SourceFile, project: Project, options: RuntimeBuildOptions): Promise<RuntimeBuildResult>;
2617
+ /**
2618
+ * Check if a source file is a runtime file
2619
+ *
2620
+ * Uses import detection to determine if file uses runtime features.
2621
+ */
2622
+ declare function detectRuntime(sourceFile: SourceFile): boolean;
2623
+ /**
2624
+ * Quick check for runtime markers in file content
2625
+ *
2626
+ * Faster than full parse - checks for import patterns.
2627
+ */
2628
+ declare function hasRuntimeImports(content: string): boolean;
2629
+
2630
+ /**
2631
+ * ts-morph Project creation and file parsing utilities
2632
+ */
2633
+
2634
+ interface CreateProjectOptions {
2635
+ /**
2636
+ * Use in-memory filesystem (default: false)
2637
+ * Set to true for test scenarios where files don't exist on disk
2638
+ */
2639
+ inMemory?: boolean;
2640
+ }
2641
+ /**
2642
+ * Create a ts-morph Project configured for JSX parsing
2643
+ *
2644
+ * @param options.inMemory - Use in-memory filesystem (default: false)
2645
+ */
2646
+ declare function createProject(options?: CreateProjectOptions): Project;
2647
+
2648
+ /**
2649
+ * Transformer - JSX AST to IR Node transformation
2650
+ *
2651
+ * Converts parsed JSX elements from ts-morph into IR nodes
2652
+ * for emission to Markdown.
2653
+ */
2654
+
2655
+ declare class Transformer {
2656
+ /** Source file for component resolution (optional - only needed for composition) */
2657
+ private sourceFile;
2658
+ /** Visited paths for circular import detection */
2659
+ private visitedPaths;
2660
+ /** Extracted useVariable declarations from source file */
2661
+ private variables;
2662
+ /** Extracted useOutput declarations: identifier name -> agent name */
2663
+ private outputs;
2664
+ /** Extracted useStateRef declarations: identifier name -> state key */
2665
+ private stateRefs;
2666
+ /** Current render props context for interpolation (set during Command/Agent transformation) */
2667
+ private renderPropsContext;
2668
+ /**
2669
+ * Create a TranspileError with source location context from a node
2670
+ */
2671
+ private createError;
2672
+ /**
2673
+ * Build a TransformContext from instance state for delegation to document transformers
2674
+ */
2675
+ private buildContext;
2676
+ /**
2677
+ * Transform a root JSX element/fragment into AgentDocumentNode, SkillDocumentNode, MCPConfigDocumentNode, or StateDocumentNode
2678
+ *
2679
+ * Note: Command documents use the runtime transformer (transformRuntimeCommand) for runtime feature support.
2680
+ *
2681
+ * @param node - The root JSX element/fragment to transform
2682
+ * @param sourceFile - Optional source file for component composition resolution
2683
+ */
2684
+ transform(node: JsxElement | JsxSelfClosingElement | JsxFragment, sourceFile?: SourceFile): AgentDocumentNode | SkillDocumentNode | MCPConfigDocumentNode | StateDocumentNode;
2685
+ /**
2686
+ * Merge Command props from spread attributes and explicit attributes
2687
+ *
2688
+ * Processes attributes in order - later props override earlier ones.
2689
+ * Supports spread attributes: {...baseProps}
2690
+ * Supports explicit attributes: name="value" or name={"value"} or name={["a", "b"]}
2691
+ */
2692
+ private mergeCommandProps;
2693
+ /**
2694
+ * Transform a Command element
2695
+ *
2696
+ * NOTE: This transformer is deprecated for Commands. Commands should use the runtime transformer
2697
+ * which supports runtime features (useRuntimeVar, If/Else/Loop, etc.).
2698
+ */
2699
+ private transformCommand;
2700
+ /**
2701
+ * Transform an Agent element to AgentDocumentNode with frontmatter
2702
+ * Delegates to document.ts transformAgent()
2703
+ */
2704
+ private transformAgent;
2705
+ /**
2706
+ * Transform a Skill element to SkillDocumentNode with frontmatter, body, files, and statics
2707
+ * Delegates to document.ts transformSkill()
2708
+ */
2709
+ private transformSkill;
2710
+ private transformFragmentChildren;
2711
+ /**
2712
+ * Transform arrow function body to IR blocks
2713
+ * Handles both block body { return ... } and expression body
2714
+ */
2715
+ private transformArrowFunctionBody;
2716
+ private transformToBlock;
2717
+ private transformElement;
2718
+ private transformList;
2719
+ private transformListItem;
2720
+ private transformBlockquote;
2721
+ private transformCodeBlock;
2722
+ private extractCodeContent;
2723
+ private transformInlineChildren;
2724
+ private trimBoundaryTextNodes;
2725
+ private transformToInline;
2726
+ private transformInlineElement;
2727
+ private extractAllText;
2728
+ private transformLink;
2729
+ private transformDiv;
2730
+ /**
2731
+ * Transform mixed children (inline + block elements)
2732
+ * Consecutive inline elements and text are wrapped in a single paragraph
2733
+ * Block elements are transformed normally
2734
+ */
2735
+ private transformMixedChildren;
2736
+ /**
2737
+ * Transform a list of nodes to inline nodes
2738
+ * Used by transformMixedChildren for inline accumulation
2739
+ */
2740
+ private transformInlineNodes;
2741
+ private transformXmlBlock;
2742
+ /**
2743
+ * Transform Table component to TableNode IR
2744
+ */
2745
+ private transformTable;
2746
+ /**
2747
+ * Parse rows attribute (array of arrays)
2748
+ */
2749
+ private parseRowsAttribute;
2750
+ /**
2751
+ * Interpolate a PropertyAccessExpression if it references render props context
2752
+ * Returns the interpolated value or null if not a context access
2753
+ */
2754
+ private interpolatePropertyAccess;
2755
+ /**
2756
+ * Transform List component (prop-based) to ListNode IR
2757
+ * This is separate from HTML <ul>/<ol> transformation
2758
+ */
2759
+ private transformPropList;
2760
+ private transformExecutionContext;
2761
+ private transformSuccessCriteria;
2762
+ /**
2763
+ * Parse items attribute for SuccessCriteria
2764
+ * Handles both string shorthand and {text, checked} objects
2765
+ */
2766
+ private parseSuccessCriteriaItems;
2767
+ private transformOfferNext;
2768
+ /**
2769
+ * Parse routes attribute for OfferNext
2770
+ * Each route is an object with name, path, and optional description
2771
+ */
2772
+ private parseOfferNextRoutes;
2773
+ /**
2774
+ * Transform Step component to StepNode IR
2775
+ */
2776
+ private transformStep;
2777
+ /**
2778
+ * Transform <Bash> to CodeBlockNode with language 'bash'
2779
+ *
2780
+ * <Bash>ls -la</Bash>
2781
+ * becomes:
2782
+ * ```bash
2783
+ * ls -la
2784
+ * ```
2785
+ */
2786
+ private transformBash;
2787
+ /**
2788
+ * Transform <ReadFiles> to ReadFilesNode
2789
+ *
2790
+ * Extracts the files prop (which should be a defineFiles() result)
2791
+ * and creates a ReadFilesNode with file entries.
2792
+ */
2793
+ private transformReadFiles;
2794
+ /**
2795
+ * Extract file entries from defineFiles schema object literal
2796
+ */
2797
+ private extractFilesFromSchema;
2798
+ /**
2799
+ * Extract path from template expression, preserving ${} for shell
2800
+ */
2801
+ private extractTemplatePath;
2802
+ /**
2803
+ * Transform <PromptTemplate> to PromptTemplateNode
2804
+ *
2805
+ * <PromptTemplate>
2806
+ * <XmlBlock name="objective">...</XmlBlock>
2807
+ * </PromptTemplate>
2808
+ *
2809
+ * Becomes:
2810
+ * ```markdown
2811
+ * <objective>
2812
+ * ...
2813
+ * </objective>
2814
+ * ```
2815
+ */
2816
+ private transformPromptTemplate;
2817
+ private transformXmlSection;
2818
+ private transformXmlWrapper;
2819
+ private transformMarkdown;
2820
+ /**
2821
+ * Transform a custom component by resolving its import and inlining its JSX
2822
+ *
2823
+ * Custom components are user-defined TSX fragments that get inlined at
2824
+ * transpile time. Component props are NOT supported in v1 - only parameterless
2825
+ * composition.
2826
+ */
2827
+ private transformCustomComponent;
2828
+ /**
2829
+ * Transform a SpawnAgent element to SpawnAgentNode
2830
+ * SpawnAgent is a block-level element that emits Task() syntax
2831
+ *
2832
+ * Supports two modes:
2833
+ * 1. prompt prop (deprecated): Manual prompt string
2834
+ * 2. input prop (preferred): Typed input - VariableRef or object literal
2835
+ *
2836
+ * Also supports:
2837
+ * - agent={AgentRef} for type-safe agent references
2838
+ * - loadFromFile prop for "load from file" pattern
2839
+ */
2840
+ private transformSpawnAgent;
2841
+ /**
2842
+ * Extract agent prop - handles string OR AgentRef identifier
2843
+ *
2844
+ * Returns:
2845
+ * - agentName: The agent name string (required)
2846
+ * - agentPath: The agent's file path (if AgentRef with path)
2847
+ */
2848
+ private extractAgentProp;
2849
+ /**
2850
+ * Try to resolve an identifier to an AgentRef definition
2851
+ *
2852
+ * Looks for:
2853
+ * 1. Imported AgentRef (from defineAgent call in source file)
2854
+ * 2. Local AgentRef constant
2855
+ */
2856
+ private resolveAgentRef;
2857
+ /**
2858
+ * Resolve an imported AgentRef by tracing to its source file
2859
+ */
2860
+ private resolveImportedAgentRef;
2861
+ /**
2862
+ * Extract AgentRef properties from defineAgent config object
2863
+ */
2864
+ private extractAgentRefFromObject;
2865
+ /**
2866
+ * Extract loadFromFile prop
2867
+ *
2868
+ * Supports:
2869
+ * - loadFromFile (boolean true shorthand)
2870
+ * - loadFromFile={true}
2871
+ * - loadFromFile="explicit/path.md"
2872
+ *
2873
+ * When true, uses agentPath from AgentRef.
2874
+ * Returns resolved path string or undefined.
2875
+ */
2876
+ private extractLoadFromFileProp;
2877
+ /**
2878
+ * Extract input prop - handles VariableRef identifier or object literal
2879
+ *
2880
+ * Supports:
2881
+ * - input={varRef} - Reference to useVariable result
2882
+ * - input={{ key: "value" }} - Object literal with properties
2883
+ */
2884
+ private extractInputProp;
2885
+ /**
2886
+ * Extract extra instructions from SpawnAgent children
2887
+ *
2888
+ * Treats children as raw text content (like Markdown component).
2889
+ * Returns undefined if no children or only whitespace.
2890
+ */
2891
+ private extractExtraInstructions;
2892
+ /**
2893
+ * Extract type argument from SpawnAgent<T> syntax
2894
+ *
2895
+ * Returns the type name string (e.g., "ResearcherInput") or undefined
2896
+ * if no type argument is present.
2897
+ */
2898
+ private extractSpawnAgentTypeParam;
2899
+ /**
2900
+ * Validate input object properties against SpawnAgent<T> type parameter.
2901
+ *
2902
+ * Throws compile error if required interface properties are missing.
2903
+ * Only validates object literal inputs (VariableRef is runtime-checked).
2904
+ *
2905
+ * @param input - The parsed SpawnAgentInput (may be variable or object)
2906
+ * @param typeParam - The type parameter name (e.g., "ResearcherInput")
2907
+ * @param element - The JSX element for error reporting
2908
+ */
2909
+ private validateInputAgainstInterface;
2910
+ /**
2911
+ * Transform an If element to IfNode
2912
+ *
2913
+ * NOTE: V1 control flow is deprecated. Use V3 transformer with useRuntimeVar and condition-based If.
2914
+ */
2915
+ private transformIf;
2916
+ /**
2917
+ * Transform an Else element to ElseNode
2918
+ *
2919
+ * NOTE: V1 control flow is deprecated. Use V3 transformer with useRuntimeVar and condition-based If/Else.
2920
+ */
2921
+ private transformElse;
2922
+ /**
2923
+ * Transform Loop component to LoopNode IR
2924
+ *
2925
+ * NOTE: V1 control flow is deprecated. Use V3 transformer with useRuntimeVar and max-based Loop.
2926
+ */
2927
+ private transformLoop;
2928
+ /**
2929
+ * Extract useOutput declarations from source file
2930
+ * Returns map of identifier name -> agent name
2931
+ *
2932
+ * Uses forEachDescendant to find declarations inside function bodies,
2933
+ * following the same pattern as extractVariableDeclarations in parser.ts
2934
+ */
2935
+ private extractOutputDeclarations;
2936
+ /**
2937
+ * Extract useStateRef declarations from source file
2938
+ * Returns map of identifier name -> state key
2939
+ *
2940
+ * Uses forEachDescendant to find declarations inside function bodies,
2941
+ * following the same pattern as extractOutputDeclarations
2942
+ */
2943
+ private extractStateRefDeclarations;
2944
+ /**
2945
+ * Transform ReadState JSX element into IR node
2946
+ *
2947
+ * Extracts:
2948
+ * - state: StateRef with key property
2949
+ * - into: VariableRef with name property
2950
+ * - field: optional nested path string
2951
+ */
2952
+ private transformReadState;
2953
+ /**
2954
+ * Extract state key from StateRef expression
2955
+ * Handles: identifier pointing to useStateRef result
2956
+ */
2957
+ private extractStateKey;
2958
+ /**
2959
+ * Extract variable name from VariableRef expression
2960
+ * Handles: identifier pointing to useVariable result
2961
+ */
2962
+ private extractVariableName;
2963
+ /**
2964
+ * Transform WriteState JSX element into IR node
2965
+ *
2966
+ * Two modes:
2967
+ * 1. Field mode: field="path" value={val}
2968
+ * 2. Merge mode: merge={partial}
2969
+ */
2970
+ private transformWriteState;
2971
+ /**
2972
+ * Transform an OnStatus element to OnStatusNode
2973
+ * OnStatus is a block-level element that emits status-based conditionals
2974
+ */
2975
+ private transformOnStatus;
2976
+ /**
2977
+ * Transform an MCPConfig element to MCPConfigDocumentNode
2978
+ * MCPConfig wraps multiple MCPServer elements into a single document
2979
+ * Delegates to document.ts transformMCPConfig()
2980
+ */
2981
+ private transformMCPConfig;
2982
+ /**
2983
+ * Transform JSX children to BlockNodes, handling If/Else sibling pairs
2984
+ */
2985
+ private transformBlockChildren;
2986
+ /**
2987
+ * Transform an Assign element to AssignNode
2988
+ * Assign emits a bash code block with variable assignment
2989
+ *
2990
+ * Supports three assignment types (exactly one required):
2991
+ * - bash: VAR=$(command)
2992
+ * - value: VAR=value (quoted if spaces)
2993
+ * - env: VAR=$ENV_VAR
2994
+ */
2995
+ private transformAssign;
2996
+ /**
2997
+ * Transform an AssignGroup element to AssignGroupNode
2998
+ * AssignGroup collects Assign children into a single bash code block
2999
+ */
3000
+ private transformAssignGroup;
3001
+ /**
3002
+ * Extract assignment prop value from Assign element
3003
+ * Handles string literals, JSX expressions with strings, and template literals
3004
+ */
3005
+ private extractAssignPropValue;
3006
+ /**
3007
+ * Extract template literal content preserving ${VAR} syntax for bash
3008
+ */
3009
+ private extractBashTemplate;
3010
+ /**
3011
+ * Extract prompt prop value, preserving multi-line content and {variable} placeholders
3012
+ * Supports: prompt="string", prompt={"string"}, prompt={`template`}
3013
+ */
3014
+ private extractPromptProp;
3015
+ /**
3016
+ * Extract text from a template expression, converting ${var} to {var}
3017
+ * This preserves GSD's {variable} placeholder syntax
3018
+ */
3019
+ private extractTemplateText;
3020
+ /**
3021
+ * Transform a State component into StateDocumentNode
3022
+ * Delegates to document.ts transformState()
3023
+ */
3024
+ private transformState;
3025
+ /**
3026
+ * Evaluate a binary expression that represents string concatenation.
3027
+ * Handles chains like: `text ` + AGENT_PATHS.researcher + ` more`
3028
+ * Returns the concatenated string or null if not evaluable.
3029
+ */
3030
+ private evaluateStringConcatenation;
3031
+ /**
3032
+ * Evaluate an expression that should resolve to a string value.
3033
+ * Handles: string literals, template literals, property access, binary expressions.
3034
+ */
3035
+ private evaluateStringExpression;
3036
+ /**
3037
+ * Resolve a property access expression (e.g., AGENT_PATHS.researcher) to its value.
3038
+ * Only works for const declarations with object literals.
3039
+ */
3040
+ private resolvePropertyAccess;
3041
+ }
3042
+ /**
3043
+ * Convenience function to transform a JSX element to an AgentDocumentNode, SkillDocumentNode, MCPConfigDocumentNode, or StateDocumentNode
3044
+ */
3045
+ declare function transform(node: JsxElement | JsxSelfClosingElement | JsxFragment, sourceFile?: SourceFile): AgentDocumentNode | SkillDocumentNode | MCPConfigDocumentNode | StateDocumentNode;
3046
+
3047
+ /**
3048
+ * JSX component stubs for react-agentic - Variable primitives
3049
+ *
3050
+ * These components are compile-time only - they're transformed by the transpiler
3051
+ * and never executed at runtime. They exist to provide TypeScript type checking.
3052
+ */
3053
+ /**
3054
+ * Reference to a shell variable created by useVariable
3055
+ * @typeParam T - Phantom type for value (compile-time only)
3056
+ */
3057
+ interface VariableRef<T = string> {
3058
+ /** Shell variable name (e.g., "PHASE_DIR") */
3059
+ name: string;
3060
+ /** Same as name - for interpolation in bash strings */
3061
+ ref: string;
3062
+ /** Phantom type marker (compile-time only) */
3063
+ _type?: T;
3064
+ }
3065
+
3066
+ /**
3067
+ * Schema-based declarations for react-agentic
3068
+ *
3069
+ * Provides compile-time helpers for declaring variables, files, and context
3070
+ * with TypeScript type safety.
3071
+ */
3072
+
3073
+ /**
3074
+ * Definition for a single variable in defineVars schema
3075
+ */
3076
+ interface VarDef {
3077
+ /** TypeScript type hint (compile-time only) */
3078
+ type?: 'string' | 'number' | 'boolean';
3079
+ /** Default value if not assigned */
3080
+ default?: string | number | boolean;
3081
+ }
3082
+ /**
3083
+ * Schema type for defineVars - maps names to VarDef
3084
+ */
3085
+ type VarSchema = Record<string, VarDef | undefined>;
3086
+ /**
3087
+ * Infer TypeScript type from VarDef
3088
+ */
3089
+ type InferVarType<T extends VarDef | undefined> = T extends {
3090
+ type: 'number';
3091
+ } ? number : T extends {
3092
+ type: 'boolean';
3093
+ } ? boolean : string;
3094
+ /**
3095
+ * Output type from defineVars - maps schema keys to VariableRefs
3096
+ */
3097
+ type VarsFromSchema<T extends VarSchema> = {
3098
+ [K in keyof T]: VariableRef<InferVarType<T[K]>>;
3099
+ };
3100
+ /**
3101
+ * Declare multiple shell variables from a schema
3102
+ *
3103
+ * This is a compile-time helper that creates VariableRef objects.
3104
+ * The actual assignment is specified on <Assign> where you emit it.
3105
+ *
3106
+ * @param schema - Object mapping variable names to VarDef options
3107
+ * @returns Object with VariableRef for each schema key
3108
+ *
3109
+ * @example Basic usage
3110
+ * const vars = defineVars({
3111
+ * PHASE: { type: 'string' },
3112
+ * MODEL_PROFILE: { default: 'balanced' },
3113
+ * DEBUG: { type: 'boolean' },
3114
+ * });
3115
+ *
3116
+ * // Use in JSX:
3117
+ * <Assign var={vars.PHASE} bash={`echo $PHASE_NUMBER`} />
3118
+ * <If test={`[ "${vars.MODEL_PROFILE.ref}" = "quality" ]`}>
3119
+ *
3120
+ * @example Replaces multiple useVariable calls
3121
+ * // Before:
3122
+ * const phase = useVariable('PHASE');
3123
+ * const model = useVariable('MODEL_PROFILE');
3124
+ * const debug = useVariable('DEBUG');
3125
+ *
3126
+ * // After:
3127
+ * const vars = defineVars({
3128
+ * PHASE: {},
3129
+ * MODEL_PROFILE: { default: 'balanced' },
3130
+ * DEBUG: { type: 'boolean' },
3131
+ * });
3132
+ */
3133
+ declare function defineVars<T extends VarSchema>(schema: T): VarsFromSchema<T>;
3134
+ /**
3135
+ * Definition for a single file in defineFiles schema
3136
+ */
3137
+ interface FileDef {
3138
+ /** File path - static string or function using vars */
3139
+ path: string | ((vars: Record<string, string>) => string);
3140
+ /** Whether file must exist (default: true) */
3141
+ required?: boolean;
3142
+ }
3143
+ /**
3144
+ * Schema type for defineFiles - maps names to FileDef
3145
+ */
3146
+ type FileSchema = Record<string, FileDef>;
3147
+ /**
3148
+ * Reference to a file defined in schema
3149
+ */
3150
+ interface FileRef {
3151
+ /** Variable name for content (e.g., "STATE_CONTENT") */
3152
+ varName: string;
3153
+ /** Original key from schema (e.g., "state") */
3154
+ key: string;
3155
+ /** File path (may contain variable references) */
3156
+ path: string;
3157
+ /** Whether file is required */
3158
+ required: boolean;
3159
+ }
3160
+ /**
3161
+ * Output type from defineFiles - maps schema keys to FileRefs
3162
+ */
3163
+ type FilesFromSchema<T extends FileSchema> = {
3164
+ [K in keyof T]: FileRef;
3165
+ } & {
3166
+ /** Get all FileRefs as array (for ReadFiles component) */
3167
+ _refs: FileRef[];
3168
+ };
3169
+ /**
3170
+ * Declare file contracts with paths and requirements
3171
+ *
3172
+ * This is a compile-time helper that creates FileRef objects for use
3173
+ * with the <ReadFiles> component.
3174
+ *
3175
+ * @param schema - Object mapping file names to FileDef options
3176
+ * @returns Object with FileRef for each schema key, plus _refs array
3177
+ *
3178
+ * @example Basic usage
3179
+ * const files = defineFiles({
3180
+ * state: { path: '.planning/STATE.md', required: true },
3181
+ * requirements: { path: '.planning/REQUIREMENTS.md', required: false },
3182
+ * });
3183
+ *
3184
+ * // Use with ReadFiles:
3185
+ * <ReadFiles files={files} />
3186
+ *
3187
+ * // Access individual file content variable:
3188
+ * <If test={`[ -n "${files.state.varName}" ]`}>
3189
+ *
3190
+ * @example Dynamic paths using variables
3191
+ * const files = defineFiles({
3192
+ * context: {
3193
+ * path: (v) => `${v.PHASE_DIR}/*-CONTEXT.md`,
3194
+ * required: false,
3195
+ * },
3196
+ * });
3197
+ */
3198
+ declare function defineFiles<T extends FileSchema>(schema: T): FilesFromSchema<T>;
3199
+ /**
3200
+ * Agent reference for defineContext
3201
+ */
3202
+ interface AgentDef {
3203
+ /** Path to agent markdown file */
3204
+ path: string;
3205
+ /** Optional model override */
3206
+ model?: string;
3207
+ }
3208
+ /**
3209
+ * Definition for defineContext
3210
+ */
3211
+ interface ContextDef {
3212
+ /** Agent definitions */
3213
+ agents?: Record<string, string | AgentDef>;
3214
+ /** Variable definitions (from defineVars) */
3215
+ vars?: VarsFromSchema<VarSchema>;
3216
+ /** File definitions (from defineFiles) */
3217
+ files?: FilesFromSchema<FileSchema>;
3218
+ }
3219
+ /**
3220
+ * Output type from defineContext
3221
+ */
3222
+ interface Context {
3223
+ /** Resolved agent references */
3224
+ agents: Record<string, {
3225
+ path: string;
3226
+ model?: string;
3227
+ }>;
3228
+ /** Variable refs (passthrough from defineVars) */
3229
+ vars: VarsFromSchema<VarSchema>;
3230
+ /** File refs (passthrough from defineFiles) */
3231
+ files: FilesFromSchema<FileSchema>;
3232
+ }
3233
+ /**
3234
+ * Create unified context for Command or Agent
3235
+ *
3236
+ * Combines agents, variables, and files into a single context object.
3237
+ * This is a compile-time helper - the context is available for
3238
+ * use in the component body.
3239
+ *
3240
+ * @param def - Context definition with agents, vars, and files
3241
+ * @returns Unified context object
3242
+ *
3243
+ * @example Basic usage
3244
+ * const ctx = defineContext({
3245
+ * agents: {
3246
+ * researcher: '~/.claude/agents/gsd-phase-researcher.md',
3247
+ * planner: { path: '~/.claude/agents/gsd-planner.md', model: 'sonnet' },
3248
+ * },
3249
+ * vars: defineVars({
3250
+ * PHASE: { type: 'string' },
3251
+ * MODEL_PROFILE: { default: 'balanced' },
3252
+ * }),
3253
+ * files: defineFiles({
3254
+ * state: { path: '.planning/STATE.md', required: true },
3255
+ * }),
3256
+ * });
3257
+ *
3258
+ * <Command name="my-cmd" context={ctx}>
3259
+ * <Assign var={ctx.vars.PHASE} bash={`...`} />
3260
+ * <ReadFiles files={ctx.files} />
3261
+ * <SpawnAgent agent={ctx.agents.researcher} ... />
3262
+ * </Command>
3263
+ */
3264
+ declare function defineContext(def: ContextDef): Context;
3265
+
3266
+ /**
3267
+ * JSX component stubs for react-agentic - Semantic wrapper components
3268
+ *
3269
+ * These components are compile-time only - they're transformed by the transpiler
3270
+ * and never executed at runtime. They exist to provide TypeScript type checking.
3271
+ */
3272
+
3273
+ /**
3274
+ * Props for the ExecutionContext component
3275
+ */
3276
+ interface ExecutionContextProps {
3277
+ /** File paths to include in execution context */
3278
+ paths: string[];
3279
+ /** Prefix for paths (defaults to '@') */
3280
+ prefix?: string;
3281
+ /** Optional additional content inside execution_context block */
3282
+ children?: ReactNode;
3283
+ }
3284
+ /**
3285
+ * ExecutionContext component - emits <execution_context> XML with file paths
3286
+ *
3287
+ * This is a compile-time component transformed by react-agentic.
3288
+ * It's never executed at runtime.
3289
+ *
3290
+ * @example
3291
+ * <ExecutionContext
3292
+ * paths={[
3293
+ * "/Users/user/.claude/workflow.md",
3294
+ * "/Users/user/.claude/templates/summary.md"
3295
+ * ]}
3296
+ * />
3297
+ *
3298
+ * Outputs:
3299
+ * <execution_context>
3300
+ * @/Users/user/.claude/workflow.md
3301
+ * @/Users/user/.claude/templates/summary.md
3302
+ * </execution_context>
3303
+ *
3304
+ * @example
3305
+ * <ExecutionContext
3306
+ * paths={["~/docs/guide.md"]}
3307
+ * prefix="$"
3308
+ * >
3309
+ * <Markdown>See these files for context.</Markdown>
3310
+ * </ExecutionContext>
3311
+ *
3312
+ * Outputs:
3313
+ * <execution_context>
3314
+ * $/Users/user/docs/guide.md
3315
+ * See these files for context.
3316
+ * </execution_context>
3317
+ */
3318
+ declare function ExecutionContext(_props: ExecutionContextProps): null;
3319
+
3320
+ export { ASK_USER_MARKER, Agent, type AgentContext, type AgentDocumentNode, type AgentFrontmatterNode, type AgentProps, type AgentRef, type AgentStatus, type AllowRuntimeVars, AskUser, type AskUserNode, type AskUserOption, type AskUserOptionNode, type AskUserProps, type AssignGroupNode, type AssignNode, BREAK_MARKER, type BaseBlockNode, type BaseOutput, type BlockNode, type BlockquoteNode, type BoldNode, Break, type BreakNode, type BreakProps, type CodeBlockNode, type CodeSplitBundleResult, Command, type CommandArgument, type CommandContext, type CommandProps, type Condition$1 as Condition, type ConditionAnd, type ConditionEq, type ConditionGt, type ConditionGte, type ConditionLiteral, type ConditionLt, type ConditionLte, type ConditionNeq, type ConditionNot, type ConditionOr, type ConditionRef, type DefineAgentConfig, type DocumentMetadata, type DocumentNode, ELSE_MARKER, Else, type ElseNode, type ElseProps, ExecutionContext, type ExecutionContextNode, type ExecutionContextProps, type ExtractedFunction, type ExtractedVariable, type FrontmatterNode, type GroupNode, type HeadingNode, IF_MARKER, type IRNode, If, type IfNode, type IfProps, Indent, type IndentNode, type IndentProps, type InlineCodeNode, type InlineNode, type InputProperty, type InputValue, type ItalicNode, type JsxChild, LOOP_MARKER, type LineBreakNode, type LinkNode, List, type ListItemNode, type ListNode, type ListProps, type LocalComponentInfo, Loop, type LoopNode, type LoopProps, type MCPConfigDocumentNode, type MCPServerNode, Markdown, type MarkdownProps, type OfferNextNode, type OfferNextRouteData, OnStatus, type OnStatusNode, type OnStatusProps, type OperationNode, type OrRuntimeVar, type OutputRef, type OutputReference, type ParagraphNode, type PromptTemplateNode, RETURN_MARKER, type RawMarkdownNode, type ReadFileEntry, type ReadFilesNode, type ReadStateNode, Return, type ReturnNode, type ReturnProps, type ReturnStatus, type RuntimeBlockNode, type RuntimeBuildOptions, type RuntimeBuildResult, type RuntimeCallComponent, type RuntimeCallNode, type RuntimeCallProps, type RuntimeEmitResult, type RuntimeFileInfo, type RuntimeFnComponent, type RuntimeFunction, type RuntimeFunctionInfo, RuntimeMarkdownEmitter, type RuntimeTransformContext, type RuntimeTransformResult, type RuntimeVar, type RuntimeVarDeclNode, type RuntimeVarInfo, type RuntimeVarProxy, type RuntimeVarRefNode, type SingleEntryBundleResult, type SkillDocumentNode, type SkillFileNode, type SkillFrontmatterNode, type SkillStaticNode, SpawnAgent, type SpawnAgentInput, type SpawnAgentNode, type SpawnAgentProps, type StateDocumentNode, type StateNode, type StateSchema, type StateSchemaField, type StepNode, type StepVariant, type SuccessCriteriaItemData, type SuccessCriteriaNode, Table, type TableAlignment, type TableNode, type TableProps, type TextNode, type ThematicBreakNode, Transformer, type TypeReference, type V3SpawnAgentProps, type WriteStateNode, XmlBlock, type XmlBlockNode, type XmlBlockProps, assertNever, buildRuntimeFile, bundleCodeSplit, bundleSingleEntryRuntime, clearRuntimeFnRegistry, createProject, createRuntimeContext, defineAgent, defineContext, defineFiles, defineVars, detectRuntime, emit, emitAgent, emitDocument, emitRuntime, emitSettings, emitSkill, emitSkillFile, extractExportedFunctionNames, extractExternalComponentDeclarations, extractFunctions, extractInputObjectLiteral, extractInterfaceProperties, extractLocalComponentDeclarations, extractPromptPlaceholders, extractRuntimeFnDeclarations, extractRuntimeVarDeclarations, extractText, extractTypeArguments, extractVariableDeclarations, findRootJsxElement, generateRuntime, getAgentName, getAgentPath, getArrayAttributeValue, getAttributeValue, getElementName, getJsxChildren, getRuntimeFn, getRuntimeFnRegistry, getRuntimeFunctionNames, getRuntimeImportPaths, getRuntimeVarInfo, hasRuntimeImports, isAgentRef, isDocument, isRuntimeFile, isRuntimeFn, isRuntimeNode, isRuntimeVar, isWhitespaceOnlyText, mergeSettings, normalizeWhitespace, parseFile, parseSource, resolveTypeImport, runtimeFn, toJqExpression, toJqPath, transform, transformRuntimeBlockChildren, transformRuntimeCommand, transformToRuntimeBlock, useOutput, useRuntimeVar };