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,34 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __esm = (fn, res) => function __init() {
6
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
7
+ };
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
+
22
+ // src/providers/index.ts
23
+ var providers = /* @__PURE__ */ new Map();
24
+ function registerProvider(provider) {
25
+ providers.set(provider.name, provider);
26
+ }
27
+
28
+ export {
29
+ __esm,
30
+ __export,
31
+ __toCommonJS,
32
+ registerProvider
33
+ };
34
+ //# sourceMappingURL=chunk-OO3V32L6.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/providers/index.ts"],"sourcesContent":["/**\n * Provider Template System\n *\n * Abstracts code generation for different storage backends.\n * Each provider generates bash/SQL skills for state operations.\n */\n\nimport type { StateSchema, OperationNode } from '../ir/nodes.js';\n\n/**\n * Generated skill content\n */\nexport interface GeneratedSkill {\n /** Skill filename (e.g., \"releases.read.md\") */\n filename: string;\n /** Full markdown content for the skill file */\n content: string;\n}\n\n/**\n * Provider configuration passed to generators\n */\nexport interface ProviderContext {\n /** State name (e.g., \"releases\") */\n stateName: string;\n /** Database path from config */\n database: string;\n /** Parsed schema with flattened fields */\n schema: StateSchema;\n}\n\n/**\n * Provider template interface\n *\n * Each provider implements these methods to generate\n * storage-specific skill code.\n */\nexport interface ProviderTemplate {\n /** Provider identifier */\n readonly name: string;\n\n /**\n * Generate init skill - creates schema/table\n */\n generateInit(ctx: ProviderContext): GeneratedSkill;\n\n /**\n * Generate read skill - SELECT with optional field filter\n */\n generateRead(ctx: ProviderContext): GeneratedSkill;\n\n /**\n * Generate write skill - UPDATE field with value\n */\n generateWrite(ctx: ProviderContext): GeneratedSkill;\n\n /**\n * Generate delete skill - DELETE/reset state\n */\n generateDelete(ctx: ProviderContext): GeneratedSkill;\n\n /**\n * Generate custom operation skill\n */\n generateOperation(ctx: ProviderContext, operation: OperationNode): GeneratedSkill;\n}\n\n// Provider registry\nconst providers = new Map<string, ProviderTemplate>();\n\n/**\n * Register a provider template\n */\nexport function registerProvider(provider: ProviderTemplate): void {\n providers.set(provider.name, provider);\n}\n\n// Lazy initialization flag\nlet initialized = false;\n\n/**\n * Ensure built-in providers are registered\n * Uses dynamic import to avoid circular dependency issues\n */\nasync function ensureProviders(): Promise<void> {\n if (initialized) return;\n initialized = true;\n await import('./sqlite.js');\n}\n\n/**\n * Initialize providers synchronously (call at module load time)\n * This ensures providers are available for sync getProvider calls\n */\nexport function initializeProviders(): void {\n // Trigger async initialization\n ensureProviders();\n}\n\n/**\n * Get a provider by name\n * @throws Error if provider not registered\n */\nexport function getProvider(name: string): ProviderTemplate {\n const provider = providers.get(name);\n if (!provider) {\n throw new Error(`Unknown provider: ${name}. Available: ${Array.from(providers.keys()).join(', ')}`);\n }\n return provider;\n}\n\n/**\n * Get a provider by name with automatic initialization\n * Ensures providers are loaded before lookup\n */\nexport async function getProviderAsync(name: string): Promise<ProviderTemplate> {\n await ensureProviders();\n return getProvider(name);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAoEA,IAAM,YAAY,oBAAI,IAA8B;AAK7C,SAAS,iBAAiB,UAAkC;AACjE,YAAU,IAAI,SAAS,MAAM,QAAQ;AACvC;","names":[]}
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node
@@ -0,0 +1,416 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ TranspileError,
4
+ buildRuntimeFile,
5
+ bundleCodeSplit,
6
+ bundleSingleEntryRuntime,
7
+ createProject,
8
+ formatTranspileError,
9
+ init_project
10
+ } from "../chunk-263OAOFB.js";
11
+ import "../chunk-OO3V32L6.js";
12
+
13
+ // src/cli/index.ts
14
+ import { Command as Command2 } from "commander";
15
+ import { readFile as readFile2 } from "fs/promises";
16
+ import { fileURLToPath } from "url";
17
+ import path3 from "path";
18
+
19
+ // src/cli/commands/build.ts
20
+ init_project();
21
+ import { Command } from "commander";
22
+ import { globby } from "globby";
23
+ import { writeFile, mkdir } from "fs/promises";
24
+ import path2 from "path";
25
+
26
+ // src/cli/output.ts
27
+ import pc from "picocolors";
28
+ function logSuccess(inputFile, outputFile) {
29
+ console.log(`${pc.green("\u2713")} ${pc.dim(inputFile)} \u2192 ${pc.cyan(outputFile)}`);
30
+ }
31
+ function logError(inputFile, message) {
32
+ console.error(`${pc.red("\u2717")} ${pc.dim(inputFile)}: ${message}`);
33
+ }
34
+ function logInfo(message) {
35
+ console.log(pc.dim(message));
36
+ }
37
+ function logSummary(successCount, errorCount) {
38
+ console.log("");
39
+ if (errorCount === 0) {
40
+ console.log(pc.green(`Built ${successCount} file(s) successfully`));
41
+ } else {
42
+ console.log(
43
+ pc.yellow(`Built ${successCount} file(s) with ${pc.red(String(errorCount))} error(s)`)
44
+ );
45
+ }
46
+ }
47
+ function logWarning(message) {
48
+ console.log(pc.yellow(message));
49
+ }
50
+ function logTranspileError(error) {
51
+ console.error(formatTranspileError(error));
52
+ }
53
+ function formatBytes(bytes) {
54
+ if (bytes < 1024) {
55
+ return `${bytes} B`;
56
+ }
57
+ if (bytes < 1024 * 1024) {
58
+ return `${(bytes / 1024).toFixed(1)} KB`;
59
+ }
60
+ return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
61
+ }
62
+ function logBuildTree(results, dryRun) {
63
+ const header = dryRun ? "Would create:" : "Output:";
64
+ console.log(pc.bold(header));
65
+ for (const result of results) {
66
+ const sizeStr = formatBytes(result.size).padStart(8);
67
+ console.log(` ${pc.cyan(result.outputPath)} ${pc.dim(sizeStr)}`);
68
+ }
69
+ console.log("");
70
+ }
71
+
72
+ // src/cli/watcher.ts
73
+ import chokidar from "chokidar";
74
+
75
+ // src/constants.ts
76
+ var DEFAULT_DEBOUNCE_MS = 200;
77
+ var WRITE_STABILITY_THRESHOLD_MS = 100;
78
+ var WRITE_STABILITY_POLL_MS = 50;
79
+ var EXIT_CODES = {
80
+ /** Successful execution */
81
+ SUCCESS: 0,
82
+ /** User/validation error (bad arguments, conflicts) */
83
+ VALIDATION_ERROR: 1,
84
+ /** Build/compilation error */
85
+ BUILD_ERROR: 1
86
+ };
87
+ var DEFAULT_OUTPUT_DIR = ".claude/commands";
88
+ var DEFAULT_RUNTIME_DIR = ".claude/runtime";
89
+ var DEFAULT_WATCH_PATTERN = "src/app/**/*.tsx";
90
+
91
+ // src/cli/watcher.ts
92
+ function createWatcher(files, onRebuild, options = {}) {
93
+ const debounceMs = options.debounceMs ?? DEFAULT_DEBOUNCE_MS;
94
+ let timeout = null;
95
+ let pending = /* @__PURE__ */ new Set();
96
+ let isRebuilding = false;
97
+ const watcher = chokidar.watch(files, {
98
+ ignoreInitial: true,
99
+ // Don't fire on startup - do full build first
100
+ awaitWriteFinish: {
101
+ stabilityThreshold: WRITE_STABILITY_THRESHOLD_MS,
102
+ pollInterval: WRITE_STABILITY_POLL_MS
103
+ }
104
+ });
105
+ const triggerRebuild = async () => {
106
+ if (isRebuilding) {
107
+ timeout = setTimeout(triggerRebuild, debounceMs);
108
+ return;
109
+ }
110
+ const changedFiles = Array.from(pending);
111
+ pending.clear();
112
+ if (changedFiles.length === 0) return;
113
+ isRebuilding = true;
114
+ try {
115
+ await onRebuild(changedFiles);
116
+ } finally {
117
+ isRebuilding = false;
118
+ }
119
+ };
120
+ watcher.on("all", (event, filePath) => {
121
+ if (event === "add" || event === "change" || event === "unlink") {
122
+ pending.add(filePath);
123
+ if (timeout) clearTimeout(timeout);
124
+ timeout = setTimeout(triggerRebuild, debounceMs);
125
+ }
126
+ });
127
+ if (options.onReady) {
128
+ watcher.on("ready", options.onReady);
129
+ }
130
+ watcher.on("error", (error) => {
131
+ const message = error instanceof Error ? error.message : String(error);
132
+ console.error("Watcher error:", message);
133
+ });
134
+ return {
135
+ async close() {
136
+ if (timeout) clearTimeout(timeout);
137
+ await watcher.close();
138
+ }
139
+ };
140
+ }
141
+
142
+ // src/cli/config.ts
143
+ import { readFile } from "fs/promises";
144
+ import { existsSync } from "fs";
145
+ import path from "path";
146
+ var DEFAULT_CONFIG = {
147
+ outputDir: DEFAULT_OUTPUT_DIR,
148
+ runtimeDir: DEFAULT_RUNTIME_DIR,
149
+ minify: false,
150
+ codeSplit: false
151
+ };
152
+ var CONFIG_FILENAME = "react-agentic.config.json";
153
+ async function loadConfigFile(cwd = process.cwd()) {
154
+ const configPath = path.join(cwd, CONFIG_FILENAME);
155
+ if (!existsSync(configPath)) {
156
+ return {};
157
+ }
158
+ try {
159
+ const content = await readFile(configPath, "utf-8");
160
+ const parsed = JSON.parse(content);
161
+ const config = {};
162
+ if (typeof parsed.outputDir === "string") {
163
+ config.outputDir = parsed.outputDir;
164
+ }
165
+ if (typeof parsed.runtimeDir === "string") {
166
+ config.runtimeDir = parsed.runtimeDir;
167
+ }
168
+ if (typeof parsed.minify === "boolean") {
169
+ config.minify = parsed.minify;
170
+ }
171
+ if (typeof parsed.codeSplit === "boolean") {
172
+ config.codeSplit = parsed.codeSplit;
173
+ }
174
+ return config;
175
+ } catch (error) {
176
+ const message = error instanceof Error ? error.message : String(error);
177
+ throw new Error(`Failed to load ${CONFIG_FILENAME}: ${message}`);
178
+ }
179
+ }
180
+ var ConfigValidationError = class extends Error {
181
+ constructor(message) {
182
+ super(message);
183
+ this.name = "ConfigValidationError";
184
+ }
185
+ };
186
+ function validateConfig(config) {
187
+ const normalizedOutput = path.normalize(config.outputDir);
188
+ const normalizedRuntime = path.normalize(config.runtimeDir);
189
+ if (normalizedOutput === normalizedRuntime) {
190
+ throw new ConfigValidationError(
191
+ `outputDir and runtimeDir cannot be the same: ${config.outputDir}`
192
+ );
193
+ }
194
+ if (normalizedRuntime.startsWith(normalizedOutput + path.sep)) {
195
+ throw new ConfigValidationError(
196
+ `runtimeDir (${config.runtimeDir}) cannot be inside outputDir (${config.outputDir})`
197
+ );
198
+ }
199
+ if (normalizedOutput.startsWith(normalizedRuntime + path.sep)) {
200
+ throw new ConfigValidationError(
201
+ `outputDir (${config.outputDir}) cannot be inside runtimeDir (${config.runtimeDir})`
202
+ );
203
+ }
204
+ }
205
+ async function resolveConfig(cliOptions, cwd = process.cwd()) {
206
+ const fileConfig = await loadConfigFile(cwd);
207
+ const config = {
208
+ outputDir: cliOptions.out ?? fileConfig.outputDir ?? DEFAULT_CONFIG.outputDir,
209
+ runtimeDir: cliOptions.runtimeOut ?? fileConfig.runtimeDir ?? DEFAULT_CONFIG.runtimeDir,
210
+ minify: cliOptions.minify ?? fileConfig.minify ?? DEFAULT_CONFIG.minify,
211
+ codeSplit: cliOptions.codeSplit ?? fileConfig.codeSplit ?? DEFAULT_CONFIG.codeSplit
212
+ };
213
+ validateConfig(config);
214
+ return config;
215
+ }
216
+
217
+ // src/cli/commands/build.ts
218
+ async function processFile(inputFile, project, options) {
219
+ const sourceFile = project.addSourceFileAtPath(inputFile);
220
+ const buildResult = await buildRuntimeFile(sourceFile, project, {
221
+ commandsOut: options.out,
222
+ runtimeOut: options.runtimeOut,
223
+ dryRun: options.dryRun
224
+ });
225
+ for (const warning of buildResult.warnings) {
226
+ logWarning(warning);
227
+ }
228
+ return {
229
+ result: {
230
+ inputFile,
231
+ outputPath: buildResult.markdownPath,
232
+ content: buildResult.markdown,
233
+ size: Buffer.byteLength(buildResult.markdown, "utf8")
234
+ },
235
+ runtimeFileInfo: buildResult.runtimeFileInfo,
236
+ runtimePath: buildResult.runtimePath
237
+ };
238
+ }
239
+ async function processFiles(tsxFiles, project, options) {
240
+ const results = [];
241
+ const runtimeFiles = [];
242
+ let runtimePath = "";
243
+ let errorCount = 0;
244
+ for (const inputFile of tsxFiles) {
245
+ try {
246
+ const processed = await processFile(inputFile, project, options);
247
+ results.push(processed.result);
248
+ if (processed.runtimeFileInfo) {
249
+ runtimeFiles.push(processed.runtimeFileInfo);
250
+ runtimePath = processed.runtimePath;
251
+ }
252
+ } catch (error) {
253
+ errorCount++;
254
+ if (error instanceof TranspileError) {
255
+ logTranspileError(error);
256
+ } else {
257
+ const message = error instanceof Error ? error.message : String(error);
258
+ logError(inputFile, message);
259
+ }
260
+ }
261
+ }
262
+ return { results, runtimeFiles, runtimePath, errorCount };
263
+ }
264
+ async function bundleRuntimes(runtimeFiles, runtimePath, options, results) {
265
+ if (runtimeFiles.length === 0) {
266
+ return;
267
+ }
268
+ const runtimeOutDir = options.runtimeOut;
269
+ if (options.codeSplit) {
270
+ const bundleResult = await bundleCodeSplit({
271
+ runtimeFiles,
272
+ outputDir: runtimeOutDir,
273
+ minify: options.minify
274
+ });
275
+ results.push({
276
+ inputFile: `${runtimeFiles.length} file(s) (dispatcher)`,
277
+ outputPath: path2.join(runtimeOutDir, "runtime.js"),
278
+ content: bundleResult.dispatcherContent,
279
+ size: Buffer.byteLength(bundleResult.dispatcherContent, "utf8")
280
+ });
281
+ for (const [namespace, content] of bundleResult.moduleContents) {
282
+ results.push({
283
+ inputFile: `${namespace} module`,
284
+ outputPath: path2.join(runtimeOutDir, `${namespace}.js`),
285
+ content,
286
+ size: Buffer.byteLength(content, "utf8")
287
+ });
288
+ }
289
+ for (const warning of bundleResult.warnings) {
290
+ logWarning(warning);
291
+ }
292
+ } else {
293
+ const bundleResult = await bundleSingleEntryRuntime({
294
+ runtimeFiles,
295
+ outputPath: runtimePath,
296
+ minify: options.minify
297
+ });
298
+ results.push({
299
+ inputFile: `${runtimeFiles.length} file(s)`,
300
+ outputPath: runtimePath,
301
+ content: bundleResult.content,
302
+ size: Buffer.byteLength(bundleResult.content, "utf8")
303
+ });
304
+ for (const warning of bundleResult.warnings) {
305
+ logWarning(warning);
306
+ }
307
+ }
308
+ }
309
+ async function writeResults(results) {
310
+ for (const result of results) {
311
+ if (result.skipWrite) continue;
312
+ const outputDir = path2.dirname(result.outputPath);
313
+ await mkdir(outputDir, { recursive: true });
314
+ await writeFile(result.outputPath, result.content, "utf-8");
315
+ logSuccess(result.inputFile, result.outputPath);
316
+ }
317
+ }
318
+ async function runBuild(tsxFiles, options, project, clearScreen) {
319
+ if (clearScreen) {
320
+ console.clear();
321
+ }
322
+ const { results, runtimeFiles, runtimePath, errorCount } = await processFiles(
323
+ tsxFiles,
324
+ project,
325
+ options
326
+ );
327
+ await bundleRuntimes(runtimeFiles, runtimePath, options, results);
328
+ if (!options.dryRun) {
329
+ await writeResults(results);
330
+ }
331
+ if (results.length > 0) {
332
+ console.log("");
333
+ logBuildTree(results, options.dryRun ?? false);
334
+ }
335
+ logSummary(results.length, errorCount);
336
+ return { successCount: results.length, errorCount };
337
+ }
338
+ var buildCommand = new Command("build").description("Transpile TSX command files to Markdown").argument("[patterns...]", "Glob patterns for TSX files (e.g., src/**/*.tsx)").option("-o, --out <dir>", "Output directory (default: .claude/commands)").option("-d, --dry-run", "Preview output without writing files").option("-w, --watch", "Watch for changes and rebuild automatically").option("--runtime-out <dir>", "Runtime output directory (default: .claude/runtime)").option("--code-split", "Split runtime into per-namespace modules").option("--minify", "Minify runtime bundles").action(async (patterns, cliOptions) => {
339
+ const config = await resolveConfig(cliOptions);
340
+ const options = {
341
+ out: config.outputDir,
342
+ runtimeOut: config.runtimeDir,
343
+ codeSplit: config.codeSplit,
344
+ minify: config.minify,
345
+ dryRun: cliOptions.dryRun,
346
+ watch: cliOptions.watch
347
+ };
348
+ if (options.watch && options.dryRun) {
349
+ console.error("Cannot use --dry-run with --watch");
350
+ process.exit(EXIT_CODES.VALIDATION_ERROR);
351
+ }
352
+ if (patterns.length === 0) {
353
+ if (options.watch) {
354
+ patterns = [DEFAULT_WATCH_PATTERN];
355
+ } else {
356
+ console.error(`No patterns provided. Specify glob patterns or use --watch for default ${DEFAULT_WATCH_PATTERN}`);
357
+ process.exit(EXIT_CODES.VALIDATION_ERROR);
358
+ }
359
+ }
360
+ const files = await globby(patterns, {
361
+ onlyFiles: true,
362
+ gitignore: true
363
+ });
364
+ const tsxFiles = files.filter((f) => f.endsWith(".tsx"));
365
+ if (tsxFiles.length === 0) {
366
+ logWarning("No .tsx files found matching patterns");
367
+ process.exit(EXIT_CODES.SUCCESS);
368
+ }
369
+ const project = createProject();
370
+ if (options.watch) {
371
+ logInfo(`Watching ${tsxFiles.length} file(s) for changes...
372
+ `);
373
+ await runBuild(tsxFiles, options, project, false);
374
+ const watcher = createWatcher(tsxFiles, async (changedFiles) => {
375
+ logInfo(`
376
+ File changed: ${changedFiles.join(", ")}`);
377
+ for (const file of changedFiles) {
378
+ const existing = project.getSourceFile(file);
379
+ if (existing) {
380
+ project.removeSourceFile(existing);
381
+ }
382
+ }
383
+ await runBuild(tsxFiles, options, project, true);
384
+ });
385
+ const shutdown = async () => {
386
+ console.log("\nStopping watch...");
387
+ await watcher.close();
388
+ process.exit(EXIT_CODES.SUCCESS);
389
+ };
390
+ process.on("SIGINT", shutdown);
391
+ process.on("SIGTERM", shutdown);
392
+ return;
393
+ }
394
+ logInfo(`Found ${tsxFiles.length} file(s) to process
395
+ `);
396
+ const { errorCount } = await runBuild(tsxFiles, options, project, false);
397
+ if (errorCount > 0) {
398
+ process.exit(EXIT_CODES.BUILD_ERROR);
399
+ }
400
+ });
401
+
402
+ // src/cli/index.ts
403
+ async function main() {
404
+ const __dirname = path3.dirname(fileURLToPath(import.meta.url));
405
+ const pkgPath = path3.resolve(__dirname, "../../package.json");
406
+ const pkg = JSON.parse(await readFile2(pkgPath, "utf-8"));
407
+ const program = new Command2();
408
+ program.name("react-agentic").description("Compile-time safety for Claude Code commands").version(pkg.version);
409
+ program.addCommand(buildCommand);
410
+ program.parse();
411
+ }
412
+ main().catch((err) => {
413
+ console.error(err.message);
414
+ process.exit(1);
415
+ });
416
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/cli/index.ts","../../src/cli/commands/build.ts","../../src/cli/output.ts","../../src/cli/watcher.ts","../../src/constants.ts","../../src/cli/config.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { Command } from 'commander';\nimport { readFile } from 'fs/promises';\nimport { fileURLToPath } from 'url';\nimport path from 'path';\nimport { buildCommand } from './commands/build.js';\n\nasync function main() {\n // Read version from package.json (stays in sync)\n const __dirname = path.dirname(fileURLToPath(import.meta.url));\n const pkgPath = path.resolve(__dirname, '../../package.json');\n const pkg = JSON.parse(await readFile(pkgPath, 'utf-8'));\n\n const program = new Command();\n\n program\n .name('react-agentic')\n .description('Compile-time safety for Claude Code commands')\n .version(pkg.version);\n\n program.addCommand(buildCommand);\n\n program.parse();\n}\n\nmain().catch((err) => {\n console.error(err.message);\n process.exit(1);\n});\n","/**\n * Build Command - Transpile TSX command files to Markdown\n */\nimport { Command } from 'commander';\nimport { globby } from 'globby';\nimport { writeFile, mkdir } from 'fs/promises';\nimport path from 'path';\nimport type { Project } from 'ts-morph';\nimport { createProject } from '../../parser/utils/project.js';\nimport {\n logSuccess,\n logError,\n logInfo,\n logSummary,\n logWarning,\n logBuildTree,\n logTranspileError,\n BuildResult,\n} from '../output.js';\nimport { TranspileError } from '../errors.js';\nimport { createWatcher } from '../watcher.js';\nimport { resolveConfig, type CLIConfigOverrides } from '../config.js';\nimport { DEFAULT_WATCH_PATTERN, EXIT_CODES } from '../../constants.js';\n\n// Build imports\nimport { buildRuntimeFile, hasRuntimeImports } from '../runtime-build.js';\nimport { bundleSingleEntryRuntime, bundleCodeSplit } from '../../emitter/index.js';\nimport type { RuntimeFileInfo } from '../../emitter/index.js';\n\ninterface BuildOptions {\n out: string;\n runtimeOut: string;\n codeSplit: boolean;\n minify: boolean;\n dryRun?: boolean;\n watch?: boolean;\n}\n\n/**\n * Result of processing a single file\n */\ninterface ProcessFileResult {\n result: BuildResult;\n runtimeFileInfo: RuntimeFileInfo | null;\n runtimePath: string;\n}\n\n/**\n * Process a single TSX file and return build results\n */\nasync function processFile(\n inputFile: string,\n project: Project,\n options: BuildOptions\n): Promise<ProcessFileResult> {\n // Parse file\n const sourceFile = project.addSourceFileAtPath(inputFile);\n\n // Build runtime file\n const buildResult = await buildRuntimeFile(sourceFile, project, {\n commandsOut: options.out,\n runtimeOut: options.runtimeOut,\n dryRun: options.dryRun,\n });\n\n // Log warnings\n for (const warning of buildResult.warnings) {\n logWarning(warning);\n }\n\n return {\n result: {\n inputFile,\n outputPath: buildResult.markdownPath,\n content: buildResult.markdown,\n size: Buffer.byteLength(buildResult.markdown, 'utf8'),\n },\n runtimeFileInfo: buildResult.runtimeFileInfo,\n runtimePath: buildResult.runtimePath,\n };\n}\n\n/**\n * Process all TSX files and collect results\n */\nasync function processFiles(\n tsxFiles: string[],\n project: Project,\n options: BuildOptions\n): Promise<{ results: BuildResult[]; runtimeFiles: RuntimeFileInfo[]; runtimePath: string; errorCount: number }> {\n const results: BuildResult[] = [];\n const runtimeFiles: RuntimeFileInfo[] = [];\n let runtimePath = '';\n let errorCount = 0;\n\n for (const inputFile of tsxFiles) {\n try {\n const processed = await processFile(inputFile, project, options);\n results.push(processed.result);\n\n if (processed.runtimeFileInfo) {\n runtimeFiles.push(processed.runtimeFileInfo);\n runtimePath = processed.runtimePath;\n }\n } catch (error) {\n errorCount++;\n if (error instanceof TranspileError) {\n logTranspileError(error);\n } else {\n const message = error instanceof Error ? error.message : String(error);\n logError(inputFile, message);\n }\n }\n }\n\n return { results, runtimeFiles, runtimePath, errorCount };\n}\n\n/**\n * Bundle runtime files and add results to the results array\n */\nasync function bundleRuntimes(\n runtimeFiles: RuntimeFileInfo[],\n runtimePath: string,\n options: BuildOptions,\n results: BuildResult[]\n): Promise<void> {\n if (runtimeFiles.length === 0) {\n return;\n }\n\n const runtimeOutDir = options.runtimeOut;\n\n if (options.codeSplit) {\n // Code-split mode: generate dispatcher + per-namespace modules\n const bundleResult = await bundleCodeSplit({\n runtimeFiles,\n outputDir: runtimeOutDir,\n minify: options.minify,\n });\n\n // Add dispatcher\n results.push({\n inputFile: `${runtimeFiles.length} file(s) (dispatcher)`,\n outputPath: path.join(runtimeOutDir, 'runtime.js'),\n content: bundleResult.dispatcherContent,\n size: Buffer.byteLength(bundleResult.dispatcherContent, 'utf8'),\n });\n\n // Add each namespace module\n for (const [namespace, content] of bundleResult.moduleContents) {\n results.push({\n inputFile: `${namespace} module`,\n outputPath: path.join(runtimeOutDir, `${namespace}.js`),\n content,\n size: Buffer.byteLength(content, 'utf8'),\n });\n }\n\n // Log any bundle warnings\n for (const warning of bundleResult.warnings) {\n logWarning(warning);\n }\n } else {\n // Single-entry mode (default): one bundled runtime.js\n const bundleResult = await bundleSingleEntryRuntime({\n runtimeFiles,\n outputPath: runtimePath,\n minify: options.minify,\n });\n\n results.push({\n inputFile: `${runtimeFiles.length} file(s)`,\n outputPath: runtimePath,\n content: bundleResult.content,\n size: Buffer.byteLength(bundleResult.content, 'utf8'),\n });\n\n // Log any bundle warnings\n for (const warning of bundleResult.warnings) {\n logWarning(warning);\n }\n }\n}\n\n/**\n * Write build results to disk\n */\nasync function writeResults(results: BuildResult[]): Promise<void> {\n for (const result of results) {\n if (result.skipWrite) continue;\n\n const outputDir = path.dirname(result.outputPath);\n await mkdir(outputDir, { recursive: true });\n await writeFile(result.outputPath, result.content, 'utf-8');\n logSuccess(result.inputFile, result.outputPath);\n }\n}\n\n/**\n * Run a build cycle for the given files\n * Returns counts for summary reporting\n */\nasync function runBuild(\n tsxFiles: string[],\n options: BuildOptions,\n project: Project,\n clearScreen: boolean\n): Promise<{ successCount: number; errorCount: number }> {\n if (clearScreen) {\n console.clear();\n }\n\n // Process all files\n const { results, runtimeFiles, runtimePath, errorCount } = await processFiles(\n tsxFiles,\n project,\n options\n );\n\n // Bundle runtimes\n await bundleRuntimes(runtimeFiles, runtimePath, options, results);\n\n // Write files (unless dry-run)\n if (!options.dryRun) {\n await writeResults(results);\n }\n\n // Show build tree\n if (results.length > 0) {\n console.log('');\n logBuildTree(results, options.dryRun ?? false);\n }\n\n // Summary\n logSummary(results.length, errorCount);\n\n return { successCount: results.length, errorCount };\n}\n\nexport const buildCommand = new Command('build')\n .description('Transpile TSX command files to Markdown')\n .argument('[patterns...]', 'Glob patterns for TSX files (e.g., src/**/*.tsx)')\n .option('-o, --out <dir>', 'Output directory (default: .claude/commands)')\n .option('-d, --dry-run', 'Preview output without writing files')\n .option('-w, --watch', 'Watch for changes and rebuild automatically')\n .option('--runtime-out <dir>', 'Runtime output directory (default: .claude/runtime)')\n .option('--code-split', 'Split runtime into per-namespace modules')\n .option('--minify', 'Minify runtime bundles')\n .action(async (patterns: string[], cliOptions: CLIConfigOverrides & { dryRun?: boolean; watch?: boolean }) => {\n // Resolve config: defaults → config file → CLI flags\n const config = await resolveConfig(cliOptions);\n\n const options: BuildOptions = {\n out: config.outputDir,\n runtimeOut: config.runtimeDir,\n codeSplit: config.codeSplit,\n minify: config.minify,\n dryRun: cliOptions.dryRun,\n watch: cliOptions.watch,\n };\n\n // Disallow --dry-run with --watch (validate early before expensive operations)\n if (options.watch && options.dryRun) {\n console.error('Cannot use --dry-run with --watch');\n process.exit(EXIT_CODES.VALIDATION_ERROR);\n }\n\n // Default to src/app/**/*.tsx in watch mode if no patterns provided\n if (patterns.length === 0) {\n if (options.watch) {\n patterns = [DEFAULT_WATCH_PATTERN];\n } else {\n console.error(`No patterns provided. Specify glob patterns or use --watch for default ${DEFAULT_WATCH_PATTERN}`);\n process.exit(EXIT_CODES.VALIDATION_ERROR);\n }\n }\n\n // Expand glob patterns\n const files = await globby(patterns, {\n onlyFiles: true,\n gitignore: true,\n });\n\n // Filter to .tsx files only\n const tsxFiles = files.filter((f) => f.endsWith('.tsx'));\n\n if (tsxFiles.length === 0) {\n logWarning('No .tsx files found matching patterns');\n process.exit(EXIT_CODES.SUCCESS);\n }\n\n // Create ts-morph project once\n const project = createProject();\n\n if (options.watch) {\n // Watch mode\n logInfo(`Watching ${tsxFiles.length} file(s) for changes...\\n`);\n\n // Initial build\n await runBuild(tsxFiles, options, project, false);\n\n // Setup watcher\n const watcher = createWatcher(tsxFiles, async (changedFiles) => {\n logInfo(`\\nFile changed: ${changedFiles.join(', ')}`);\n\n // Clear stale source files and re-add for fresh parse\n for (const file of changedFiles) {\n const existing = project.getSourceFile(file);\n if (existing) {\n project.removeSourceFile(existing);\n }\n }\n\n await runBuild(tsxFiles, options, project, true);\n });\n\n // Graceful shutdown\n const shutdown = async () => {\n console.log('\\nStopping watch...');\n await watcher.close();\n process.exit(EXIT_CODES.SUCCESS);\n };\n\n process.on('SIGINT', shutdown);\n process.on('SIGTERM', shutdown);\n\n // Keep process running (watcher keeps event loop alive)\n return;\n }\n\n // Non-watch mode: single build\n logInfo(`Found ${tsxFiles.length} file(s) to process\\n`);\n const { errorCount } = await runBuild(tsxFiles, options, project, false);\n\n // Exit with error code if any failures\n if (errorCount > 0) {\n process.exit(EXIT_CODES.BUILD_ERROR);\n }\n });\n","/**\n * CLI Output Utilities - Colored terminal output with NO_COLOR support\n */\nimport pc from 'picocolors';\nimport { TranspileError, formatTranspileError } from './errors.js';\n\n/**\n * Log successful file processing\n */\nexport function logSuccess(inputFile: string, outputFile: string): void {\n console.log(`${pc.green('✓')} ${pc.dim(inputFile)} → ${pc.cyan(outputFile)}`);\n}\n\n/**\n * Log file processing error\n */\nexport function logError(inputFile: string, message: string): void {\n console.error(`${pc.red('✗')} ${pc.dim(inputFile)}: ${message}`);\n}\n\n/**\n * Log informational message\n */\nexport function logInfo(message: string): void {\n console.log(pc.dim(message));\n}\n\n/**\n * Log build summary\n */\nexport function logSummary(successCount: number, errorCount: number): void {\n console.log('');\n if (errorCount === 0) {\n console.log(pc.green(`Built ${successCount} file(s) successfully`));\n } else {\n console.log(\n pc.yellow(`Built ${successCount} file(s) with ${pc.red(String(errorCount))} error(s)`)\n );\n }\n}\n\n/**\n * Log warning message\n */\nexport function logWarning(message: string): void {\n console.log(pc.yellow(message));\n}\n\n/**\n * Log a TranspileError with source location context\n *\n * Outputs TypeScript-style error format with file:line:col,\n * code snippet, and caret indicator.\n */\nexport function logTranspileError(error: TranspileError): void {\n console.error(formatTranspileError(error));\n}\n\n/**\n * Build result for tree output\n */\nexport interface BuildResult {\n inputFile: string;\n outputPath: string;\n content: string;\n size: number;\n /** Static files to copy (skills only) */\n statics?: Array<{ src: string; dest: string }>;\n /** Skip writing this file (already written by merge logic, e.g., settings.json) */\n skipWrite?: boolean;\n}\n\n/**\n * Format bytes to human-readable string\n */\nfunction formatBytes(bytes: number): string {\n if (bytes < 1024) {\n return `${bytes} B`;\n }\n if (bytes < 1024 * 1024) {\n return `${(bytes / 1024).toFixed(1)} KB`;\n }\n return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;\n}\n\n/**\n * Log build tree output (Next.js-style)\n */\nexport function logBuildTree(results: BuildResult[], dryRun: boolean): void {\n const header = dryRun ? 'Would create:' : 'Output:';\n console.log(pc.bold(header));\n\n for (const result of results) {\n const sizeStr = formatBytes(result.size).padStart(8);\n console.log(` ${pc.cyan(result.outputPath)} ${pc.dim(sizeStr)}`);\n }\n\n console.log('');\n}\n","/**\n * File Watcher - Watch for file changes with debouncing\n */\nimport chokidar from 'chokidar';\nimport type { FSWatcher } from 'chokidar';\nimport {\n DEFAULT_DEBOUNCE_MS,\n WRITE_STABILITY_THRESHOLD_MS,\n WRITE_STABILITY_POLL_MS,\n} from '../constants.js';\n\nexport interface Watcher {\n close(): Promise<void>;\n}\n\nexport interface WatcherOptions {\n debounceMs?: number;\n onReady?: () => void;\n}\n\n/**\n * Create a file watcher with debounced rebuild callback\n *\n * @param files - Array of file paths to watch (use globby to expand first)\n * @param onRebuild - Callback when files change (receives changed file paths)\n * @param options - Configuration options\n */\nexport function createWatcher(\n files: string[],\n onRebuild: (changedFiles: string[]) => Promise<void>,\n options: WatcherOptions = {}\n): Watcher {\n const debounceMs = options.debounceMs ?? DEFAULT_DEBOUNCE_MS;\n\n let timeout: NodeJS.Timeout | null = null;\n let pending: Set<string> = new Set();\n let isRebuilding = false;\n\n const watcher: FSWatcher = chokidar.watch(files, {\n ignoreInitial: true, // Don't fire on startup - do full build first\n awaitWriteFinish: {\n stabilityThreshold: WRITE_STABILITY_THRESHOLD_MS,\n pollInterval: WRITE_STABILITY_POLL_MS,\n },\n });\n\n const triggerRebuild = async () => {\n if (isRebuilding) {\n // If already rebuilding, reschedule\n timeout = setTimeout(triggerRebuild, debounceMs);\n return;\n }\n\n const changedFiles = Array.from(pending);\n pending.clear();\n\n if (changedFiles.length === 0) return;\n\n isRebuilding = true;\n try {\n await onRebuild(changedFiles);\n } finally {\n isRebuilding = false;\n }\n };\n\n watcher.on('all', (event, filePath) => {\n if (event === 'add' || event === 'change' || event === 'unlink') {\n pending.add(filePath);\n\n if (timeout) clearTimeout(timeout);\n timeout = setTimeout(triggerRebuild, debounceMs);\n }\n });\n\n if (options.onReady) {\n watcher.on('ready', options.onReady);\n }\n\n watcher.on('error', (error: unknown) => {\n const message = error instanceof Error ? error.message : String(error);\n console.error('Watcher error:', message);\n });\n\n return {\n async close() {\n if (timeout) clearTimeout(timeout);\n await watcher.close();\n },\n };\n}\n","/**\n * Shared constants for react-agentic\n *\n * Centralized location for magic numbers and configuration values\n * used across multiple modules.\n */\n\n// ============================================================================\n// Root Element Tags\n// ============================================================================\n\n/**\n * Supported root element tags for document files\n */\nexport const SUPPORTED_ROOT_TAGS = ['Command', 'RuntimeCommand', 'Agent'] as const;\n\nexport type SupportedRootTag = (typeof SUPPORTED_ROOT_TAGS)[number];\n\n// ============================================================================\n// File Watcher Constants\n// ============================================================================\n\n/**\n * Default debounce time in milliseconds for file watcher\n */\nexport const DEFAULT_DEBOUNCE_MS = 200;\n\n/**\n * Time to wait for file writes to stabilize before triggering rebuild\n */\nexport const WRITE_STABILITY_THRESHOLD_MS = 100;\n\n/**\n * Poll interval for write stability detection\n */\nexport const WRITE_STABILITY_POLL_MS = 50;\n\n// ============================================================================\n// Exit Codes\n// ============================================================================\n\n/**\n * Standard exit codes for CLI operations\n */\nexport const EXIT_CODES = {\n /** Successful execution */\n SUCCESS: 0,\n /** User/validation error (bad arguments, conflicts) */\n VALIDATION_ERROR: 1,\n /** Build/compilation error */\n BUILD_ERROR: 1,\n} as const;\n\nexport type ExitCode = (typeof EXIT_CODES)[keyof typeof EXIT_CODES];\n\n// ============================================================================\n// Build Configuration\n// ============================================================================\n\n/**\n * Default output directory for generated markdown files\n */\nexport const DEFAULT_OUTPUT_DIR = '.claude/commands';\n\n/**\n * Default output directory for runtime bundles\n */\nexport const DEFAULT_RUNTIME_DIR = '.claude/runtime';\n\n/**\n * Default glob pattern for watch mode when no patterns provided\n */\nexport const DEFAULT_WATCH_PATTERN = 'src/app/**/*.tsx';\n","/**\n * Configuration loading and merging for react-agentic\n *\n * Priority (highest to lowest):\n * 1. CLI flags\n * 2. react-agentic.config.json\n * 3. Built-in defaults\n */\nimport { readFile } from 'fs/promises';\nimport { existsSync } from 'fs';\nimport path from 'path';\nimport { DEFAULT_OUTPUT_DIR, DEFAULT_RUNTIME_DIR } from '../constants.js';\n\n/**\n * Configuration options for react-agentic builds\n */\nexport interface ReactAgenticConfig {\n /** Output directory for markdown files (default: .claude/commands) */\n outputDir: string;\n /** Output directory for runtime bundles (default: .claude/runtime) */\n runtimeDir: string;\n /** Minify runtime bundles (default: false) */\n minify: boolean;\n /** Split runtime into per-namespace modules (default: false) */\n codeSplit: boolean;\n}\n\n/**\n * Built-in default configuration\n */\nexport const DEFAULT_CONFIG: ReactAgenticConfig = {\n outputDir: DEFAULT_OUTPUT_DIR,\n runtimeDir: DEFAULT_RUNTIME_DIR,\n minify: false,\n codeSplit: false,\n};\n\nconst CONFIG_FILENAME = 'react-agentic.config.json';\n\n/**\n * Load configuration from react-agentic.config.json if it exists\n * Returns partial config (only fields present in file)\n */\nexport async function loadConfigFile(cwd: string = process.cwd()): Promise<Partial<ReactAgenticConfig>> {\n const configPath = path.join(cwd, CONFIG_FILENAME);\n\n if (!existsSync(configPath)) {\n return {};\n }\n\n try {\n const content = await readFile(configPath, 'utf-8');\n const parsed = JSON.parse(content);\n\n // Validate and extract known fields only\n const config: Partial<ReactAgenticConfig> = {};\n\n if (typeof parsed.outputDir === 'string') {\n config.outputDir = parsed.outputDir;\n }\n if (typeof parsed.runtimeDir === 'string') {\n config.runtimeDir = parsed.runtimeDir;\n }\n if (typeof parsed.minify === 'boolean') {\n config.minify = parsed.minify;\n }\n if (typeof parsed.codeSplit === 'boolean') {\n config.codeSplit = parsed.codeSplit;\n }\n\n return config;\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n throw new Error(`Failed to load ${CONFIG_FILENAME}: ${message}`);\n }\n}\n\n/**\n * CLI options that can override config\n */\nexport interface CLIConfigOverrides {\n out?: string;\n runtimeOut?: string;\n minify?: boolean;\n codeSplit?: boolean;\n}\n\n/**\n * Configuration validation errors\n */\nexport class ConfigValidationError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'ConfigValidationError';\n }\n}\n\n/**\n * Validate configuration for common issues\n *\n * Checks:\n * - Output directories are not the same (would cause conflicts)\n * - Paths don't contain problematic characters\n */\nfunction validateConfig(config: ReactAgenticConfig): void {\n // Normalize paths for comparison\n const normalizedOutput = path.normalize(config.outputDir);\n const normalizedRuntime = path.normalize(config.runtimeDir);\n\n // Check for output directory conflicts\n if (normalizedOutput === normalizedRuntime) {\n throw new ConfigValidationError(\n `outputDir and runtimeDir cannot be the same: ${config.outputDir}`\n );\n }\n\n // Check if one is a parent of the other (would cause nested writes)\n if (normalizedRuntime.startsWith(normalizedOutput + path.sep)) {\n throw new ConfigValidationError(\n `runtimeDir (${config.runtimeDir}) cannot be inside outputDir (${config.outputDir})`\n );\n }\n if (normalizedOutput.startsWith(normalizedRuntime + path.sep)) {\n throw new ConfigValidationError(\n `outputDir (${config.outputDir}) cannot be inside runtimeDir (${config.runtimeDir})`\n );\n }\n}\n\n/**\n * Resolve final configuration by merging:\n * defaults → config file → CLI flags\n *\n * @throws {ConfigValidationError} if configuration is invalid\n */\nexport async function resolveConfig(\n cliOptions: CLIConfigOverrides,\n cwd: string = process.cwd()\n): Promise<ReactAgenticConfig> {\n // Load config file (if exists)\n const fileConfig = await loadConfigFile(cwd);\n\n // Merge: defaults → file → CLI\n const config: ReactAgenticConfig = {\n outputDir: cliOptions.out ?? fileConfig.outputDir ?? DEFAULT_CONFIG.outputDir,\n runtimeDir: cliOptions.runtimeOut ?? fileConfig.runtimeDir ?? DEFAULT_CONFIG.runtimeDir,\n minify: cliOptions.minify ?? fileConfig.minify ?? DEFAULT_CONFIG.minify,\n codeSplit: cliOptions.codeSplit ?? fileConfig.codeSplit ?? DEFAULT_CONFIG.codeSplit,\n };\n\n // Validate the merged config\n validateConfig(config);\n\n return config;\n}\n"],"mappings":";;;;;;;;;;;;;AACA,SAAS,WAAAA,gBAAe;AACxB,SAAS,YAAAC,iBAAgB;AACzB,SAAS,qBAAqB;AAC9B,OAAOC,WAAU;;;ACIjB;AALA,SAAS,eAAe;AACxB,SAAS,cAAc;AACvB,SAAS,WAAW,aAAa;AACjC,OAAOC,WAAU;;;ACHjB,OAAO,QAAQ;AAMR,SAAS,WAAW,WAAmB,YAA0B;AACtE,UAAQ,IAAI,GAAG,GAAG,MAAM,QAAG,CAAC,IAAI,GAAG,IAAI,SAAS,CAAC,WAAM,GAAG,KAAK,UAAU,CAAC,EAAE;AAC9E;AAKO,SAAS,SAAS,WAAmB,SAAuB;AACjE,UAAQ,MAAM,GAAG,GAAG,IAAI,QAAG,CAAC,IAAI,GAAG,IAAI,SAAS,CAAC,KAAK,OAAO,EAAE;AACjE;AAKO,SAAS,QAAQ,SAAuB;AAC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