agentix-cli 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/commands/chat.ts","../src/commands/generate.ts","../src/utils/generate-tui.ts","../src/utils/render-markdown.ts","../src/commands/evolve.ts","../src/commands/create.ts","../src/commands/run.ts","../src/commands/inspect.ts","../src/commands/skill.ts","../src/commands/serve.ts","../src/commands/model.ts","../src/commands/git.ts","../src/commands/a2a.ts","../src/commands/daemon.ts","../src/cli.ts"],"sourcesContent":["import { existsSync } from \"fs\"\nimport path from \"path\"\nimport { Command } from \"commander\"\nimport chalk from \"chalk\"\nimport { handleError } from \"@/utils/handle-error\"\nimport { logger } from \"@/utils/logger\"\nimport { getPackageInfo } from \"@/utils/get-package-info\"\nimport { ReplEngine } from \"@/repl\"\nimport { listSessions } from \"@/repl/session\"\nimport { setDebug } from \"@/observability\"\nimport { globalPermissions, type PermissionMode } from \"@/permissions\"\n\nexport const chat = new Command()\n .name(\"chat\")\n .description(\"start an interactive AI coding session\")\n .option(\"--resume\", \"resume the last session\", false)\n .option(\"-s, --session <id>\", \"resume a specific session\")\n .option(\"--list\", \"list saved sessions\", false)\n .option(\n \"-p, --provider <provider>\",\n \"AI provider (claude-code, claude)\",\n \"claude-code\"\n )\n .option(\"-m, --model <model>\", \"model to use\")\n .option(\"--api-key <key>\", \"API key for the provider\")\n .option(\"-c, --cwd <cwd>\", \"working directory\", process.cwd())\n .option(\"--debug\", \"enable debug mode with verbose logging\", false)\n .option(\"--mode <mode>\", \"permission mode (default, acceptEdits, plan, yolo)\", \"yolo\")\n .action(async (opts) => {\n try {\n // List sessions mode\n if (opts.list) {\n const sessions = listSessions()\n if (!sessions.length) {\n logger.info(\"No saved sessions\")\n return\n }\n\n console.log()\n console.log(chalk.bold(\" Saved sessions:\"))\n console.log()\n for (const s of sessions.slice(0, 20)) {\n const date = new Date(s.updatedAt).toLocaleDateString()\n const msgs = s.messages.length\n const tokens = s.tokensUsed.toLocaleString()\n console.log(\n ` ${chalk.cyan(s.id)} ${date} ${msgs} msgs ${tokens} tokens`\n )\n }\n console.log()\n return\n }\n\n if (opts.debug) {\n setDebug(true)\n }\n\n if (opts.mode) {\n globalPermissions.setMode(opts.mode as PermissionMode)\n }\n\n const cwd = path.resolve(opts.cwd)\n if (!existsSync(cwd)) {\n logger.error(`The path ${cwd} does not exist.`)\n process.exit(1)\n }\n\n const packageInfo = await getPackageInfo()\n\n const engine = new ReplEngine({\n cwd,\n provider: opts.provider,\n model: opts.model,\n apiKey: opts.apiKey,\n resume: opts.resume,\n sessionId: opts.session,\n version: packageInfo.version || \"1.0.0\",\n })\n\n await engine.start()\n } catch (error) {\n handleError(error)\n }\n })\n","import { existsSync } from \"fs\"\nimport path from \"path\"\nimport { handleError } from \"@/utils/handle-error\"\nimport { logger } from \"@/utils/logger\"\nimport { generateStream } from \"@/agent\"\nimport { OUTPUT_TYPES, outputTypeDescriptions } from \"@/agent/providers/types\"\nimport chalk from \"chalk\"\nimport { Command } from \"commander\"\nimport ora from \"ora\"\nimport prompts from \"prompts\"\nimport { z } from \"zod\"\nimport { setDebug } from \"@/observability\"\nimport { globalTracker } from \"@/observability\"\nimport { globalPermissions, type PermissionMode } from \"@/permissions\"\nimport { GenerateTui } from \"@/utils/generate-tui\"\nimport { renderMarkdownForTerminal } from \"@/utils/render-markdown\"\n\nconst generateOptionsSchema = z.object({\n task: z.string().optional(),\n type: z.string().default(\"auto\"),\n output: z.string().optional(),\n overwrite: z.boolean().default(false),\n dryRun: z.boolean().default(false),\n provider: z.enum([\"claude-code\", \"claude\", \"openai\", \"ollama\", \"custom\"]).default(\"claude-code\"),\n model: z.string().optional(),\n apiKey: z.string().optional(),\n cwd: z.string(),\n noContext7: z.boolean().default(false),\n yes: z.boolean().default(false),\n})\n\nexport const gen = new Command()\n .name(\"generate\")\n .aliases([\"gen\", \"g\"])\n .description(\"generate anything using AI — components, pages, APIs, docs, skills, and more\")\n .argument(\"[task...]\", \"describe what you want to generate\")\n .option(\n \"-t, --type <type>\",\n `output type: ${OUTPUT_TYPES.join(\", \")}`,\n \"auto\"\n )\n .option(\"-o, --output <dir>\", \"output directory\")\n .option(\"--overwrite\", \"overwrite existing files\", false)\n .option(\"--dry-run\", \"preview without writing files\", false)\n .option(\n \"-p, --provider <provider>\",\n \"AI provider (claude-code, claude, openai, ollama)\",\n \"claude-code\"\n )\n .option(\"-m, --model <model>\", \"model to use\")\n .option(\"--api-key <key>\", \"API key for the provider\")\n .option(\n \"-c, --cwd <cwd>\",\n \"working directory\",\n process.cwd()\n )\n .option(\"--no-context7\", \"disable Context7 documentation lookup\")\n .option(\n \"--max-steps <n>\",\n \"max agentic loop steps for complex generation (default: 5)\",\n \"5\"\n )\n .option(\"-y, --yes\", \"skip confirmation prompts\", false)\n .option(\"--debug\", \"enable debug mode with verbose logging\", false)\n .option(\"--no-tui\", \"disable interactive TUI output\")\n .option(\"--mode <mode>\", \"permission mode (default, acceptEdits, plan, yolo)\", \"yolo\")\n .option(\"--heal\", \"verify generated code and auto-fix errors\")\n .option(\"--no-heal\", \"skip verification after generation\")\n .option(\"--test-cmd <cmd>\", \"test command for heal verification\")\n .option(\"--build-cmd <cmd>\", \"build command for heal verification\")\n .action(async (taskParts, opts) => {\n try {\n let task = taskParts?.length ? taskParts.join(\" \") : opts.task\n\n if (opts.debug) {\n setDebug(true)\n }\n\n if (opts.mode) {\n globalPermissions.setMode(opts.mode as PermissionMode)\n }\n\n const cwd = path.resolve(opts.cwd)\n if (!existsSync(cwd)) {\n logger.error(`The path ${cwd} does not exist.`)\n process.exit(1)\n }\n\n // Interactive task input if not provided\n if (!task) {\n const response = await prompts({\n type: \"text\",\n name: \"task\",\n message: \"What would you like to generate?\",\n validate: (v) => (v.trim() ? true : \"Please describe what to generate\"),\n })\n\n if (!response.task) {\n logger.warn(\"No task provided. Exiting.\")\n process.exit(0)\n }\n task = response.task\n }\n\n // Show available output types if type is \"auto\" and user wants to choose\n if (opts.type === \"auto\" && !opts.yes) {\n const { type } = await prompts({\n type: \"select\",\n name: \"type\",\n message: \"Output type (or auto-detect)\",\n choices: [\n { title: \"Auto-detect\", value: \"auto\" },\n ...OUTPUT_TYPES.filter((t) => t !== \"auto\").map((t) => ({\n title: `${t} — ${outputTypeDescriptions[t]}`,\n value: t,\n })),\n ],\n initial: 0,\n })\n\n if (type !== undefined) {\n opts.type = type\n }\n }\n\n const options = generateOptionsSchema.parse({\n task,\n ...opts,\n apiKey: opts.apiKey,\n noContext7: !opts.context7,\n })\n\n const maxSteps = parseInt(opts.maxSteps || \"5\", 10)\n const useTui = Boolean(opts.tui) && Boolean(process.stdout.isTTY) && !Boolean(opts.debug)\n const spinner = (!useTui && !opts.debug) ? ora(\"Waiting for provider...\").start() : undefined\n\n const tui = useTui\n ? new GenerateTui({\n task,\n provider: options.provider,\n model: options.model,\n cwd,\n outputDir: options.output,\n outputType: options.type,\n maxSteps,\n overwrite: options.overwrite,\n dryRun: options.dryRun,\n })\n : undefined\n\n if (!useTui) {\n // Show what we're about to do (plain logs).\n logger.break()\n logger.info(`Task: ${chalk.bold(task)}`)\n logger.info(`Provider: ${chalk.bold(options.provider)}`)\n if (options.type !== \"auto\") {\n logger.info(`Type: ${chalk.bold(options.type)}`)\n }\n if (options.output) {\n logger.info(`Output: ${chalk.bold(options.output)}`)\n }\n if (options.dryRun) {\n logger.warn(\"Dry run mode — no files will be written\")\n }\n logger.break()\n }\n\n tui?.start()\n\n let result: any | undefined\n let streamError: string | undefined\n for await (const event of generateStream({\n task,\n outputType: options.type as any,\n outputDir: options.output,\n overwrite: options.overwrite,\n dryRun: options.dryRun,\n provider: options.provider as any,\n model: options.model,\n apiKey: options.apiKey,\n cwd,\n context7: !options.noContext7,\n interactive: !options.yes,\n maxSteps,\n heal: opts.heal,\n healConfig: (opts.testCmd || opts.buildCmd) ? {\n testCommand: opts.testCmd,\n buildCommand: opts.buildCmd,\n } : undefined,\n })) {\n tui?.onEvent(event as any)\n\n if (!useTui) {\n if (event.type === \"context_ready\") {\n if (spinner) spinner.text = \"Generating...\"\n }\n if (event.type === \"context_ready\") {\n logger.info(\"Analyzing project... done\")\n logger.info(`Output type: ${event.outputType}`)\n } else if (event.type === \"iteration\") {\n logger.info(`Step ${event.iteration}/${maxSteps}...`)\n } else if (event.type === \"tool_call\") {\n logger.info(`Tool: ${event.name}`)\n } else if (event.type === \"tool_result\") {\n logger.info(`Tool result: ${event.name}${event.is_error ? \" (error)\" : \"\"}`)\n } else if (event.type === \"error\") {\n logger.error(event.error)\n }\n }\n\n if (event.type === \"generate_result\") {\n result = event.result\n }\n if (event.type === \"error\") {\n streamError = event.error\n }\n }\n\n spinner?.stop()\n tui?.stop()\n if (streamError) {\n throw new Error(streamError)\n }\n if (!result) {\n throw new Error(\"Generation finished without a result\")\n }\n\n // Handle follow-up questions\n if (result.followUp) {\n // Ensure the terminal is back to normal before prompting.\n logger.break()\n logger.info(chalk.yellow(\"The agent needs more information:\"))\n logger.break()\n if (result.content) {\n const rendered = process.stdout.isTTY\n ? renderMarkdownForTerminal(result.content)\n : result.content\n console.log(rendered)\n logger.break()\n }\n console.log(process.stdout.isTTY ? renderMarkdownForTerminal(result.followUp) : result.followUp)\n logger.break()\n\n const { answer } = await prompts({\n type: \"text\",\n name: \"answer\",\n message: \"Your answer:\",\n })\n\n if (answer) {\n const task2 =\n `${task}\\n\\n` +\n `Previous agent output (for context):\\n${result.content || \"\"}\\n\\n` +\n `User response: ${answer}\\n\\n` +\n `If the above was a plan awaiting approval and the user approved, proceed to implementation now using create_files (do not ask for approval again).`\n const tui2 = useTui\n ? new GenerateTui({\n task: task2,\n provider: options.provider,\n model: options.model,\n cwd,\n outputDir: options.output,\n outputType: options.type,\n maxSteps,\n overwrite: options.overwrite,\n dryRun: options.dryRun,\n })\n : undefined\n\n tui2?.start()\n\n let result2: any | undefined\n let streamError2: string | undefined\n for await (const event of generateStream({\n task: task2,\n outputType: options.type as any,\n outputDir: options.output,\n overwrite: options.overwrite,\n dryRun: options.dryRun,\n provider: options.provider as any,\n model: options.model,\n apiKey: options.apiKey,\n cwd,\n context7: !options.noContext7,\n interactive: false,\n maxSteps,\n heal: opts.heal,\n healConfig: (opts.testCmd || opts.buildCmd) ? {\n testCommand: opts.testCmd,\n buildCommand: opts.buildCmd,\n } : undefined,\n })) {\n tui2?.onEvent(event as any)\n if (event.type === \"generate_result\") result2 = event.result\n if (event.type === \"error\") streamError2 = event.error\n }\n\n tui2?.stop()\n if (streamError2) throw new Error(streamError2)\n if (!result2) throw new Error(\"Generation finished without a result\")\n printResult(result2)\n }\n } else {\n printResult(result)\n }\n } catch (error) {\n handleError(error)\n }\n })\n\nfunction printResult(result: any) {\n logger.break()\n\n if (result.content) {\n const rendered = process.stdout.isTTY\n ? renderMarkdownForTerminal(result.content)\n : result.content\n console.log(rendered)\n logger.break()\n }\n\n if (result.files.written.length) {\n logger.success(`Created ${result.files.written.length} file(s):`)\n for (const file of result.files.written) {\n console.log(` ${chalk.green(\"+\")} ${file}`)\n }\n }\n\n if (result.files.skipped.length) {\n logger.warn(`Skipped ${result.files.skipped.length} existing file(s):`)\n for (const file of result.files.skipped) {\n console.log(` ${chalk.yellow(\"~\")} ${file} (use --overwrite)`)\n }\n }\n\n if (result.files.errors.length) {\n logger.error(`Failed ${result.files.errors.length} file(s):`)\n for (const err of result.files.errors) {\n console.log(` ${chalk.red(\"x\")} ${err}`)\n }\n }\n\n // Display heal results\n if (result.healResult) {\n logger.break()\n if (result.healResult.healed) {\n if (result.healResult.attempts === 0) {\n logger.success(\"Verification passed — generated code is clean\")\n } else {\n logger.success(\n `Auto-healed in ${result.healResult.attempts} attempt(s)` +\n (result.healResult.filesChanged?.length ? ` (fixed: ${result.healResult.filesChanged.join(\", \")})` : \"\")\n )\n }\n } else if (result.healResult.error) {\n logger.error(`Verification failed after ${result.healResult.attempts} attempt(s):`)\n console.log(chalk.dim(` ${result.healResult.error.split(\"\\n\").slice(0, 3).join(\"\\n \")}`))\n }\n }\n\n if (result.tokensUsed) {\n logger.break()\n const summary = globalTracker.getSummary()\n if (summary.steps.length > 1) {\n logger.info(`Tokens used: ${result.tokensUsed} across ${summary.steps.length} steps`)\n for (const step of summary.steps) {\n logger.info(` Step ${step.step}: ${(step.inputTokens + step.outputTokens).toLocaleString()} tokens ($${step.cost.toFixed(4)})`)\n }\n logger.info(` Total cost: $${summary.totalCost.toFixed(4)}`)\n } else {\n logger.info(`Tokens used: ${result.tokensUsed} ($${summary.totalCost.toFixed(4)})`)\n }\n }\n}\n","import chalk from \"chalk\"\n\nimport type { GenerateStreamEvent } from \"@/agent\"\n\nfunction nowMs(): number {\n return Date.now()\n}\n\nfunction formatDuration(ms: number): string {\n const s = Math.floor(ms / 1000)\n const m = Math.floor(s / 60)\n const h = Math.floor(m / 60)\n const ss = String(s % 60).padStart(2, \"0\")\n const mm = String(m % 60).padStart(2, \"0\")\n if (h > 0) return `${h}:${mm}:${ss}`\n return `${m}:${ss}`\n}\n\nfunction tailLines(text: string, maxLines: number): string[] {\n const lines = text.replace(/\\r\\n/g, \"\\n\").split(\"\\n\")\n if (lines.length <= maxLines) return lines\n return lines.slice(lines.length - maxLines)\n}\n\nfunction clampTail(text: string, maxChars: number): string {\n if (text.length <= maxChars) return text\n return text.slice(text.length - maxChars)\n}\n\nexport interface GenerateTuiOptions {\n task: string\n provider: string\n model?: string\n cwd: string\n outputDir?: string\n outputType?: string\n maxSteps?: number\n overwrite?: boolean\n dryRun?: boolean\n}\n\nexport class GenerateTui {\n private startedAt = nowMs()\n private phase: string = \"Analyzing project\"\n private outputType: string = \"auto\"\n private iteration: number = 0\n private maxSteps?: number\n private filesCreated: number = 0\n private filesWritten: number = 0\n private filesSkipped: number = 0\n private filesErrors: number = 0\n\n private eventLog: string[] = []\n private textTail: string = \"\"\n private lastActivityAt = nowMs()\n\n private dirty = true\n private renderTimer: NodeJS.Timeout | undefined\n private pulseTimer: NodeJS.Timeout | undefined\n private stopped = false\n private restoreHandlersInstalled = false\n private handleExit = () => this.stop()\n private handleSigint = () => {\n this.stop()\n process.exit(130)\n }\n private handleSigterm = () => {\n this.stop()\n process.exit(143)\n }\n\n constructor(private opts: GenerateTuiOptions) {\n this.outputType = opts.outputType || \"auto\"\n this.maxSteps = opts.maxSteps\n }\n\n start(): void {\n if (!process.stdout.isTTY) return\n\n // Hide cursor.\n process.stdout.write(\"\\x1b[?25l\")\n this.installRestoreHandlers()\n // Keep the UI alive even if the provider doesn't stream (loader/elapsed updates).\n this.pulseTimer = setInterval(() => {\n if (this.stopped) return\n this.scheduleRender()\n }, 120)\n this.render()\n }\n\n stop(): void {\n if (this.stopped) return\n this.stopped = true\n\n if (this.renderTimer) clearTimeout(this.renderTimer)\n this.renderTimer = undefined\n if (this.pulseTimer) clearInterval(this.pulseTimer)\n this.pulseTimer = undefined\n\n if (process.stdout.isTTY) {\n // Show cursor.\n process.stdout.write(\"\\x1b[?25h\")\n // Leave screen in a clean state for normal logs.\n process.stdout.write(\"\\n\")\n }\n\n this.uninstallRestoreHandlers()\n }\n\n onEvent(evt: GenerateStreamEvent): void {\n if (this.stopped) return\n this.lastActivityAt = nowMs()\n\n if (evt.type === \"context_ready\") {\n this.phase = \"Generating\"\n this.outputType = evt.outputType\n this.log(`Context ready. Output type: ${evt.outputType}`)\n } else if (evt.type === \"iteration\") {\n this.phase = \"Generating\"\n this.iteration = evt.iteration\n this.log(`Step ${evt.iteration}${this.maxSteps ? `/${this.maxSteps}` : \"\"}`)\n } else if (evt.type === \"tool_call\") {\n this.phase = \"Running tools\"\n this.log(`Tool: ${evt.name} (${evt.id})`)\n } else if (evt.type === \"tool_result\") {\n const status = evt.is_error ? chalk.red(\"error\") : chalk.green(\"ok\")\n this.log(`Tool result: ${evt.name} (${evt.id}) ${status}`)\n } else if (evt.type === \"step_complete\") {\n this.filesCreated += evt.filesCount\n this.log(`Created ${evt.filesCount} file(s)`)\n } else if (evt.type === \"text_delta\") {\n // Keep a small tail; rendering is throttled.\n this.textTail = clampTail(this.textTail + evt.text, 4000)\n } else if (evt.type === \"done\") {\n this.phase = \"Writing files\"\n this.log(\"Model completed. Writing files...\")\n } else if (evt.type === \"generate_result\") {\n this.phase = \"Done\"\n this.filesWritten = evt.result.files.written.length\n this.filesSkipped = evt.result.files.skipped.length\n this.filesErrors = evt.result.files.errors.length\n if (evt.result.healResult) {\n this.log(evt.result.healResult.healed ? \"Verification: ok\" : \"Verification: failed\")\n }\n if (evt.result.followUp) {\n this.phase = \"Needs input\"\n this.log(\"Waiting for your answer...\")\n }\n } else if (evt.type === \"error\") {\n this.phase = \"Error\"\n this.log(chalk.red(evt.error))\n }\n\n this.scheduleRender()\n }\n\n private log(line: string): void {\n const ts = formatDuration(nowMs() - this.startedAt)\n const msg = `${chalk.dim(ts)} ${line}`\n this.eventLog.push(msg)\n if (this.eventLog.length > 25) {\n this.eventLog = this.eventLog.slice(this.eventLog.length - 25)\n }\n }\n\n private scheduleRender(): void {\n if (!process.stdout.isTTY) return\n this.dirty = true\n if (this.renderTimer) return\n this.renderTimer = setTimeout(() => {\n this.renderTimer = undefined\n this.render()\n }, 50)\n }\n\n private render(): void {\n if (!process.stdout.isTTY) return\n if (!this.dirty) return\n this.dirty = false\n\n const cols = process.stdout.columns || 80\n const rows = process.stdout.rows || 24\n const spinnerFrames = [\"|\", \"/\", \"-\", \"\\\\\"] as const\n const spinner = spinnerFrames[Math.floor((nowMs() - this.startedAt) / 120) % spinnerFrames.length]\n const idleForMs = nowMs() - this.lastActivityAt\n\n const header = chalk.bold(\"agentx generate\") + chalk.dim(` ${formatDuration(nowMs() - this.startedAt)}`)\n const meta1 = `${chalk.dim(\"Task:\")} ${this.opts.task}`\n const meta2 =\n `${chalk.dim(\"Provider:\")} ${this.opts.provider}` +\n (this.opts.model ? ` ${chalk.dim(\"Model:\")} ${this.opts.model}` : \"\") +\n ` ${chalk.dim(\"Type:\")} ${this.outputType}`\n\n const meta3 =\n `${chalk.dim(\"CWD:\")} ${this.opts.cwd}` +\n (this.opts.outputDir ? ` ${chalk.dim(\"Out:\")} ${this.opts.outputDir}` : \"\") +\n (this.opts.overwrite ? ` ${chalk.dim(\"Overwrite:\")} yes` : \"\") +\n (this.opts.dryRun ? ` ${chalk.dim(\"Dry-run:\")} yes` : \"\")\n\n const status =\n `${chalk.dim(\"Status:\")} ${chalk.bold(this.phase)} ${chalk.dim(spinner)}` +\n (this.iteration ? ` ${chalk.dim(\"Step:\")} ${this.iteration}${this.maxSteps ? `/${this.maxSteps}` : \"\"}` : \"\") +\n (idleForMs > 1500 ? ` ${chalk.dim(\"Idle:\")} ${formatDuration(idleForMs)}` : \"\") +\n (this.filesWritten || this.filesSkipped || this.filesErrors\n ? ` ${chalk.dim(\"Files:\")} ${chalk.green(String(this.filesWritten))} written, ${chalk.yellow(String(this.filesSkipped))} skipped, ${chalk.red(String(this.filesErrors))} failed`\n : (this.filesCreated ? ` ${chalk.dim(\"Files:\")} ${this.filesCreated} created` : \"\"))\n\n const sep = chalk.dim(\"\".padEnd(Math.min(cols, 80), \"─\"))\n\n // Leave room for header/meta/status/sep lines.\n const fixedLines = 6\n const available = Math.max(0, rows - fixedLines)\n const outputLines = Math.max(6, Math.floor(available * 0.55))\n const eventLines = Math.max(4, available - outputLines)\n\n const eventTail = this.eventLog.slice(-eventLines)\n const outTailLines = tailLines(this.textTail, outputLines)\n\n const body = [\n header,\n meta1,\n meta2,\n meta3,\n status,\n sep,\n chalk.dim(\"Events:\"),\n ...eventTail.map((l) => l.slice(0, cols)),\n sep,\n chalk.dim(\"Output (tail):\"),\n ...outTailLines.map((l) => l.slice(0, cols)),\n ].join(\"\\n\")\n\n // Clear screen and render from top-left.\n process.stdout.write(\"\\x1b[H\\x1b[2J\")\n process.stdout.write(body)\n }\n\n private installRestoreHandlers(): void {\n if (this.restoreHandlersInstalled) return\n this.restoreHandlersInstalled = true\n process.once(\"exit\", this.handleExit)\n process.once(\"SIGINT\", this.handleSigint)\n process.once(\"SIGTERM\", this.handleSigterm)\n }\n\n private uninstallRestoreHandlers(): void {\n if (!this.restoreHandlersInstalled) return\n this.restoreHandlersInstalled = false\n process.off(\"exit\", this.handleExit)\n process.off(\"SIGINT\", this.handleSigint)\n process.off(\"SIGTERM\", this.handleSigterm)\n }\n}\n","import chalk from \"chalk\"\n\n// Minimal, dependency-free markdown pretty-printer for terminal output.\n// Goal: improve readability of plans/specs without trying to fully parse Markdown.\n\nfunction indentBlock(s: string, prefix: string): string {\n return s\n .replace(/\\r\\n/g, \"\\n\")\n .split(\"\\n\")\n .map((l) => (l.length ? prefix + l : l))\n .join(\"\\n\")\n}\n\nfunction renderInline(line: string): string {\n // Inline code\n line = line.replace(/`([^`]+)`/g, (_, code) => chalk.cyan(code))\n // Links: [text](url) -> text (url)\n line = line.replace(/\\[([^\\]]+)\\]\\(([^)]+)\\)/g, (_, text, url) => `${text} ${chalk.dim(`(${url})`)}`)\n // Bold (**text**). Keep this last-ish to avoid interfering with code/link replacements.\n line = line.replace(/\\*\\*([^*]+)\\*\\*/g, (_, t) => chalk.bold(t))\n return line\n}\n\nfunction renderTextBlock(block: string): string {\n const lines = block.replace(/\\r\\n/g, \"\\n\").split(\"\\n\")\n const out: string[] = []\n\n for (const raw of lines) {\n const line = raw.trimEnd()\n\n if (/^\\s*#{1,6}\\s+/.test(line)) {\n const title = line.replace(/^\\s*#{1,6}\\s+/, \"\")\n out.push(chalk.bold(renderInline(title)))\n continue\n }\n\n if (/^\\s*([-*_]\\s*){3,}$/.test(line)) {\n out.push(chalk.dim(\"─\".repeat(40)))\n continue\n }\n\n if (/^\\s*>\\s?/.test(line)) {\n out.push(chalk.dim(\"│ \") + renderInline(line.replace(/^\\s*>\\s?/, \"\")))\n continue\n }\n\n out.push(renderInline(line))\n }\n\n return out.join(\"\\n\")\n}\n\nexport function renderMarkdownForTerminal(md: string): string {\n const input = (md || \"\").replace(/\\r\\n/g, \"\\n\")\n if (!input.trim()) return \"\"\n\n // Split by fenced code blocks. Keep fences so output still looks like markdown,\n // but dim the code body to reduce noise for plan/spec output.\n const parts = input.split(/```/g)\n if (parts.length === 1) return renderTextBlock(input)\n\n const out: string[] = []\n for (let i = 0; i < parts.length; i++) {\n const chunk = parts[i]\n const isCode = i % 2 === 1\n\n if (!isCode) {\n out.push(renderTextBlock(chunk))\n continue\n }\n\n // chunk starts with optional \"lang\\n\"\n const firstNl = chunk.indexOf(\"\\n\")\n const info = firstNl === -1 ? chunk.trim() : chunk.slice(0, firstNl).trim()\n const body = firstNl === -1 ? \"\" : chunk.slice(firstNl + 1)\n\n const header = info ? chalk.dim(\"```\" + info) : chalk.dim(\"```\")\n const footer = chalk.dim(\"```\")\n const codeBody = chalk.dim(indentBlock(body.replace(/\\s+$/g, \"\"), \"\"))\n\n out.push([header, codeBody, footer].filter(Boolean).join(\"\\n\"))\n }\n\n // Avoid leading/trailing empty lines noise.\n return out.join(\"\\n\").replace(/^\\n+|\\n+$/g, \"\")\n}\n\n","import { existsSync, promises as fs } from \"fs\"\nimport path from \"path\"\nimport { handleError } from \"@/utils/handle-error\"\nimport { logger } from \"@/utils/logger\"\nimport { createAgentContext } from \"@/agent\"\nimport { createProvider, type ProviderName } from \"@/agent/providers\"\nimport { ensureCredentials } from \"@/utils/auth-store\"\nimport { loadAuthConfig } from \"@/utils/auth-store\"\nimport type { GenerationMessage, GeneratedFile } from \"@/agent/providers/types\"\nimport { formatTechStack } from \"@/agent/context/tech-stack\"\nimport { formatSchemas } from \"@/agent/context/schema\"\nimport { matchSkillsToTask } from \"@/agent/skills/loader\"\nimport { globalHooks } from \"@/hooks\"\nimport { globalPermissions, type PermissionMode } from \"@/permissions\"\nimport { globalTracker, debug, setDebug } from \"@/observability\"\nimport { MemoryHierarchy } from \"@/memory\"\nimport chalk from \"chalk\"\nimport { Command } from \"commander\"\nimport ora from \"ora\"\nimport prompts from \"prompts\"\nimport fg from \"fast-glob\"\n\n// --- `agentx evolve` — modify existing code with AI ---\n\ninterface FileChange {\n path: string\n original: string\n proposed: string\n description?: string\n}\n\nexport const evolve = new Command()\n .name(\"evolve\")\n .aliases([\"ev\", \"transform\"])\n .description(\"modify existing code using AI — add features, refactor, migrate patterns\")\n .argument(\"[task...]\", \"describe the transformation to apply\")\n .option(\n \"-g, --glob <pattern>\",\n \"glob pattern for files to evolve (e.g., src/components/**/*.tsx)\"\n )\n .option(\n \"--max-files <n>\",\n \"maximum number of files to process\",\n \"10\"\n )\n .option(\n \"-p, --provider <provider>\",\n \"AI provider (claude-code, claude)\",\n \"claude-code\"\n )\n .option(\"-m, --model <model>\", \"model to use\")\n .option(\"--api-key <key>\", \"API key\")\n .option(\n \"-c, --cwd <cwd>\",\n \"working directory\",\n process.cwd()\n )\n .option(\"--no-context7\", \"disable Context7 doc lookup\")\n .option(\"-y, --yes\", \"apply all changes without confirmation\", false)\n .option(\"--dry-run\", \"show proposed changes without writing\", false)\n .option(\"--debug\", \"enable debug mode with verbose logging\", false)\n .option(\"--mode <mode>\", \"permission mode (default, acceptEdits, plan, yolo)\")\n .option(\"--heal\", \"verify generated code and auto-fix errors\")\n .option(\"--no-heal\", \"skip verification after applying changes\")\n .option(\"--test-cmd <cmd>\", \"test command for heal verification\")\n .option(\"--build-cmd <cmd>\", \"build command for heal verification\")\n .action(async (taskParts, opts) => {\n try {\n let task = taskParts?.length ? taskParts.join(\" \") : undefined\n const cwd = path.resolve(opts.cwd)\n\n if (!existsSync(cwd)) {\n logger.error(`The path ${cwd} does not exist.`)\n process.exit(1)\n }\n\n // Debug/mode init\n if (opts.debug) {\n setDebug(true)\n }\n if (opts.mode) {\n globalPermissions.setMode(opts.mode as PermissionMode)\n }\n\n // Interactive task input\n if (!task) {\n const response = await prompts({\n type: \"text\",\n name: \"task\",\n message: \"Describe the transformation to apply:\",\n validate: (v) => (v.trim() ? true : \"Please describe the transformation\"),\n })\n if (!response.task) {\n logger.warn(\"No task provided. Exiting.\")\n process.exit(0)\n }\n task = response.task\n }\n\n // pre:prompt hook — can modify or block the task\n let effectiveTask = task!\n if (globalHooks.has(\"pre:prompt\")) {\n const promptResult = await globalHooks.execute(\"pre:prompt\", {\n event: \"pre:prompt\",\n task: effectiveTask,\n cwd,\n })\n if (promptResult.blocked) {\n logger.error(promptResult.message || \"Blocked by pre:prompt hook\")\n process.exit(1)\n }\n if (promptResult.modified?.task) {\n effectiveTask = String(promptResult.modified.task)\n }\n }\n\n // pre:generate hook — can block the entire generation\n if (globalHooks.has(\"pre:generate\")) {\n const genResult = await globalHooks.execute(\"pre:generate\", {\n event: \"pre:generate\",\n task: effectiveTask,\n cwd,\n })\n if (genResult.blocked) {\n logger.error(genResult.message || \"Blocked by pre:generate hook\")\n process.exit(1)\n }\n }\n\n // Get glob pattern\n let globPattern = opts.glob\n if (!globPattern) {\n const response = await prompts({\n type: \"text\",\n name: \"glob\",\n message: \"File pattern to evolve (glob):\",\n initial: \"src/**/*.{ts,tsx,js,jsx}\",\n validate: (v) => (v.trim() ? true : \"Pattern is required\"),\n })\n if (!response.glob) {\n logger.warn(\"No pattern provided. Exiting.\")\n process.exit(0)\n }\n globPattern = response.glob\n }\n\n // Find matching files\n const matchedFiles = await fg.glob(globPattern, {\n cwd,\n ignore: [\n \"**/node_modules/**\",\n \"**/dist/**\",\n \"**/build/**\",\n \"**/.next/**\",\n \"**/target/**\",\n \"**/.git/**\",\n ],\n onlyFiles: true,\n })\n\n const maxFiles = parseInt(opts.maxFiles, 10)\n if (!matchedFiles.length) {\n logger.warn(`No files matched pattern: ${globPattern}`)\n process.exit(0)\n }\n\n const filesToProcess = matchedFiles.slice(0, maxFiles)\n if (matchedFiles.length > maxFiles) {\n logger.warn(\n `Found ${matchedFiles.length} files, processing first ${maxFiles}. Use --max-files to increase.`\n )\n }\n\n logger.break()\n logger.info(`Task: ${chalk.bold(effectiveTask)}`)\n logger.info(`Files: ${chalk.bold(String(filesToProcess.length))} matching ${chalk.dim(globPattern)}`)\n logger.break()\n\n // Read all target files\n const spinner = ora(\"Reading files and analyzing project...\").start()\n\n const fileContents: { path: string; content: string }[] = []\n for (const file of filesToProcess) {\n const fullPath = path.resolve(cwd, file)\n const content = await fs.readFile(fullPath, \"utf8\")\n fileContents.push({ path: file, content })\n }\n\n // Gather agent context\n const context = await createAgentContext(cwd, effectiveTask, {\n provider: opts.provider,\n context7: { enabled: opts.context7 !== false },\n })\n\n // Match skills\n const matchedSkills = matchSkillsToTask(context.skills, effectiveTask, undefined)\n if (matchedSkills.length) {\n debug.context(\"skills\", `${matchedSkills.length} matched for evolve`)\n }\n\n spinner.text = \"Generating transformations...\"\n\n // Build the evolve prompt (now includes memory and project instructions)\n const systemPrompt = buildEvolveSystemPrompt(context, matchedSkills.map((m) => m.skill))\n\n const filesSummary = fileContents\n .map(\n (f) =>\n `## File: ${f.path}\\n\\`\\`\\`\\n${truncate(f.content, 4000)}\\n\\`\\`\\``\n )\n .join(\"\\n\\n\")\n\n const userMessage = `# Transformation Task\n${effectiveTask}\n\n# Files to Transform\n${filesSummary}\n\nTransform these files according to the task. For each file that needs changes, use \\`create_files\\` with the complete updated file content. Only include files that actually need changes — skip files that don't need modification.`\n\n // Ensure credentials exist (auto-prompt if missing)\n const hasCredentials = await ensureCredentials(opts.apiKey)\n if (!hasCredentials) {\n logger.error(\"No credentials configured. Run `agentx model` to set up.\")\n process.exit(1)\n }\n\n // Generate with provider\n const providerName = opts.provider as ProviderName\n const provider = createProvider(providerName, opts.apiKey)\n const resolvedModel = opts.model || loadAuthConfig()?.model\n const messages: GenerationMessage[] = [\n { role: \"system\", content: systemPrompt },\n { role: \"user\", content: userMessage },\n ]\n\n debug.step(1, `Starting evolve generation (model: ${resolvedModel || \"default\"})`)\n\n const result = await provider.generate(messages, {\n model: resolvedModel,\n maxTokens: 16384,\n })\n\n // Track usage\n const stepTokens = result.tokensUsed || 0\n const stepModel = resolvedModel || \"claude-sonnet-4-20250514\"\n const estInput = Math.round(stepTokens * 0.3)\n const estOutput = stepTokens - estInput\n globalTracker.recordStep(1, stepModel, estInput, estOutput)\n debug.api(\"evolve\", stepModel, stepTokens)\n\n spinner.stop()\n\n // Handle follow-up questions\n if (result.followUp) {\n logger.break()\n logger.info(chalk.yellow(\"The agent needs more information:\"))\n logger.break()\n console.log(result.followUp)\n logger.break()\n return\n }\n\n if (!result.files.length) {\n logger.info(\"No changes proposed.\")\n if (result.content) {\n logger.break()\n console.log(result.content)\n }\n return\n }\n\n // Build change set with diffs\n const changes: FileChange[] = []\n for (const file of result.files) {\n const original = fileContents.find((f) => f.path === file.path)\n changes.push({\n path: file.path,\n original: original?.content || \"\",\n proposed: file.content,\n description: file.description,\n })\n }\n\n // Display changes with diff preview\n logger.break()\n console.log(\n chalk.bold(` ${changes.length} file(s) with proposed changes:`)\n )\n logger.break()\n\n if (result.content) {\n console.log(chalk.dim(result.content))\n logger.break()\n }\n\n // Show diff for each file\n const approved: FileChange[] = []\n\n for (const change of changes) {\n console.log(chalk.bold.cyan(` ${change.path}`))\n if (change.description) {\n console.log(chalk.dim(` ${change.description}`))\n }\n logger.break()\n\n // Show a simplified diff\n const diffLines = generateSimpleDiff(change.original, change.proposed)\n for (const line of diffLines.slice(0, 40)) {\n if (line.startsWith(\"+\")) {\n console.log(chalk.green(` ${line}`))\n } else if (line.startsWith(\"-\")) {\n console.log(chalk.red(` ${line}`))\n } else {\n console.log(chalk.dim(` ${line}`))\n }\n }\n if (diffLines.length > 40) {\n console.log(chalk.dim(` ... ${diffLines.length - 40} more lines`))\n }\n logger.break()\n\n if (opts.yes || opts.dryRun) {\n approved.push(change)\n } else {\n const { action } = await prompts({\n type: \"select\",\n name: \"action\",\n message: `${change.path}`,\n choices: [\n { title: \"Accept\", value: \"accept\" },\n { title: \"Skip\", value: \"skip\" },\n { title: \"Accept all remaining\", value: \"accept-all\" },\n { title: \"Quit\", value: \"quit\" },\n ],\n })\n\n if (action === \"accept\") {\n approved.push(change)\n } else if (action === \"accept-all\") {\n approved.push(change)\n // Accept all remaining\n const remaining = changes.slice(changes.indexOf(change) + 1)\n approved.push(...remaining)\n break\n } else if (action === \"quit\") {\n break\n }\n // \"skip\" just continues\n }\n }\n\n // Write approved changes\n if (!approved.length) {\n logger.info(\"No changes applied.\")\n return\n }\n\n if (opts.dryRun) {\n logger.break()\n logger.success(`Dry run: ${approved.length} file(s) would be modified:`)\n for (const change of approved) {\n console.log(` ${chalk.green(\"~\")} ${change.path}`)\n }\n return\n }\n\n const writeSpinner = ora(\"Applying changes...\").start()\n\n let written = 0\n let errors = 0\n const writtenFiles: string[] = []\n\n for (const change of approved) {\n // Permissions-aware file writing\n if (globalHooks.has(\"pre:file-write\")) {\n const writeResult = await globalHooks.execute(\"pre:file-write\", {\n event: \"pre:file-write\",\n file: change.path,\n fileContent: change.proposed,\n cwd,\n })\n if (writeResult.blocked) {\n logger.warn(`Skipped ${change.path}: ${writeResult.message || \"blocked by hook\"}`)\n continue\n }\n }\n\n try {\n const fullPath = path.resolve(cwd, change.path)\n const dir = path.dirname(fullPath)\n await fs.mkdir(dir, { recursive: true })\n await fs.writeFile(fullPath, change.proposed, \"utf8\")\n written++\n writtenFiles.push(change.path)\n\n // post:file-write hook\n if (globalHooks.has(\"post:file-write\")) {\n await globalHooks.execute(\"post:file-write\", {\n event: \"post:file-write\",\n file: change.path,\n cwd,\n })\n }\n } catch (error: any) {\n logger.error(`Failed to write ${change.path}: ${error.message}`)\n errors++\n }\n }\n\n writeSpinner.stop()\n\n logger.break()\n logger.success(`Applied ${written} change(s):`)\n for (const change of approved) {\n if (writtenFiles.includes(change.path)) {\n console.log(` ${chalk.green(\"~\")} ${change.path}`)\n }\n }\n if (errors) {\n logger.error(`${errors} file(s) failed to write.`)\n }\n\n // Record in memory\n try {\n const memory = new MemoryHierarchy(cwd)\n await memory.load()\n await memory.recordGeneration({\n type: \"evolution\",\n task: effectiveTask,\n files: writtenFiles,\n success: errors === 0,\n error: errors > 0 ? `${errors} file(s) failed to write` : undefined,\n context: {\n techStack: context.techStack.languages.map(String),\n frameworks: context.techStack.frameworks.map(String),\n skillsUsed: matchedSkills.map((m) => m.skill.frontmatter.name),\n },\n })\n } catch {\n // Memory recording is non-critical\n }\n\n // Heal loop — verify and auto-fix if requested\n if (opts.heal !== false && writtenFiles.length > 0) {\n const { HealEngine } = await import(\"@/runtime/heal\")\n const healEngine = new HealEngine(cwd, {\n enabled: true,\n testCommand: opts.testCmd,\n buildCommand: opts.buildCmd,\n maxAttempts: 3,\n provider: providerName,\n model: resolvedModel,\n apiKey: opts.apiKey,\n })\n\n const healSpinner = ora(\"Verifying changes...\").start()\n const healResult = await healEngine.detectAndHeal(writtenFiles, effectiveTask)\n healSpinner.stop()\n\n if (healResult.healed) {\n if (healResult.attempts === 0) {\n logger.success(\"Verification passed — changes are clean\")\n } else {\n logger.success(\n `Auto-healed in ${healResult.attempts} attempt(s)` +\n (healResult.filesChanged.length ? ` (fixed: ${healResult.filesChanged.join(\", \")})` : \"\")\n )\n }\n } else if (healResult.error) {\n logger.error(`Verification failed after ${healResult.attempts} attempt(s):`)\n console.log(chalk.dim(` ${healResult.error.split(\"\\n\").slice(0, 3).join(\"\\n \")}`))\n\n await globalHooks.execute(\"on:error\", {\n event: \"on:error\",\n error: new Error(healResult.error),\n task: effectiveTask,\n cwd,\n })\n }\n }\n\n // post:generate hook\n if (globalHooks.has(\"post:generate\")) {\n await globalHooks.execute(\"post:generate\", {\n event: \"post:generate\",\n task: effectiveTask,\n content: result.content,\n cwd,\n })\n }\n\n if (result.tokensUsed) {\n logger.break()\n const summary = globalTracker.getSummary()\n logger.info(`Tokens used: ${result.tokensUsed} ($${summary.totalCost.toFixed(4)})`)\n }\n } catch (error) {\n handleError(error)\n }\n })\n\nfunction buildEvolveSystemPrompt(context: any, skills: any[]): string {\n const sections: string[] = []\n\n sections.push(`You are agentx evolve, an agentic code transformation tool. You modify existing code according to user instructions.\n\nYour primary tool is \\`create_files\\` — use it to output the COMPLETE updated content of each file that needs changes.\nIf the request is ambiguous, use \\`ask_user\\` to ask a clarifying question.\n\nCRITICAL RULES:\n- Output the FULL file content for each changed file (not just the diff)\n- Keep the file path exactly as given — do not rename files unless explicitly asked\n- Preserve existing code patterns, naming conventions, and style\n- Only modify what's necessary for the transformation\n- Do NOT remove unrelated code or comments\n- Do NOT add unrelated features or \"improvements\"\n- Include all existing imports — do not accidentally drop them\n- If a file doesn't need changes, do NOT include it in the output`)\n\n sections.push(`# Project Tech Stack\\n${formatTechStack(context.techStack)}`)\n\n const deps = Object.keys(context.techStack.dependencies).slice(0, 20)\n if (deps.length) {\n sections.push(`# Key Dependencies\\n${deps.join(\", \")}`)\n }\n\n const schemaStr = formatSchemas(context.schemas)\n if (schemaStr) {\n sections.push(`# Project Schemas\\n${schemaStr}`)\n }\n\n if (skills.length) {\n sections.push(\n `# Active Skills\\n` +\n skills\n .map(\n (s: any) =>\n `## ${s.frontmatter.name}\\n${s.frontmatter.description}\\n\\n${s.instructions}`\n )\n .join(\"\\n\\n---\\n\\n\")\n )\n }\n\n if (context.docs) {\n sections.push(context.docs)\n }\n\n // Project instructions (SHADXN.md / CLAUDE.md)\n if (context.projectInstructions) {\n sections.push(`# Project Instructions\\n${context.projectInstructions}`)\n }\n\n // Memory context (past generations, patterns, preferences)\n if (context.memoryContext) {\n sections.push(context.memoryContext)\n }\n\n return sections.join(\"\\n\\n\")\n}\n\nfunction generateSimpleDiff(original: string, proposed: string): string[] {\n const origLines = original.split(\"\\n\")\n const propLines = proposed.split(\"\\n\")\n const diff: string[] = []\n\n // Simple line-by-line comparison\n const maxLen = Math.max(origLines.length, propLines.length)\n let contextBuffer: string[] = []\n let lastChangeIdx = -10\n\n for (let i = 0; i < maxLen; i++) {\n const origLine = i < origLines.length ? origLines[i] : undefined\n const propLine = i < propLines.length ? propLines[i] : undefined\n\n if (origLine === propLine) {\n // Same line — keep as context near changes\n if (i - lastChangeIdx <= 2) {\n diff.push(` ${origLine}`)\n } else {\n contextBuffer.push(` ${origLine}`)\n // Only keep last 2 context lines\n if (contextBuffer.length > 2) {\n contextBuffer.shift()\n }\n }\n } else {\n // Add context buffer before this change\n if (i - lastChangeIdx > 3 && diff.length > 0) {\n diff.push(\" ...\")\n }\n diff.push(...contextBuffer)\n contextBuffer = []\n\n if (origLine !== undefined && propLine !== undefined) {\n diff.push(`-${origLine}`)\n diff.push(`+${propLine}`)\n } else if (origLine !== undefined) {\n diff.push(`-${origLine}`)\n } else if (propLine !== undefined) {\n diff.push(`+${propLine}`)\n }\n lastChangeIdx = i\n }\n }\n\n return diff\n}\n\nfunction truncate(str: string, max: number): string {\n if (str.length <= max) return str\n return str.slice(0, max) + \"\\n// ... (truncated)\"\n}\n","import { existsSync, promises as fs } from \"fs\"\nimport path from \"path\"\nimport { handleError } from \"@/utils/handle-error\"\nimport { logger } from \"@/utils/logger\"\nimport { generate } from \"@/agent\"\nimport type { ProviderName } from \"@/agent/providers\"\nimport chalk from \"chalk\"\nimport { Command } from \"commander\"\nimport ora from \"ora\"\nimport prompts from \"prompts\"\n\n// --- `agentx create` — template system for scaffolding entire projects ---\n\ninterface Template {\n name: string\n description: string\n prompt: string\n skills: string[]\n outputType: string\n tags: string[]\n}\n\nconst TEMPLATES: Template[] = [\n {\n name: \"saas-starter\",\n description: \"Full-stack SaaS starter with auth, billing, dashboard, and landing page\",\n prompt: `Create a full-stack SaaS starter project with:\n1. Authentication (sign up, sign in, forgot password, email verification)\n2. Billing integration with Stripe (pricing page, checkout, subscription management, webhooks)\n3. Dashboard with sidebar navigation, user profile, settings page\n4. Landing page with hero, features, pricing, testimonials, FAQ, footer\n5. Database schema for users, subscriptions, teams\n6. API routes for all CRUD operations\n7. Middleware for auth protection\n8. Environment variables template`,\n skills: [],\n outputType: \"website\",\n tags: [\"saas\", \"auth\", \"billing\", \"stripe\", \"dashboard\"],\n },\n {\n name: \"api-service\",\n description: \"REST API service with auth, validation, error handling, and tests\",\n prompt: `Create a REST API service with:\n1. Project structure with routes, controllers, middleware, models, utils\n2. Authentication middleware (JWT)\n3. Input validation using the project's validation library\n4. Centralized error handling with proper HTTP status codes\n5. Health check endpoint\n6. CRUD endpoints for a sample resource\n7. Request logging middleware\n8. Rate limiting\n9. Environment configuration\n10. Test suite for all endpoints`,\n skills: [],\n outputType: \"api\",\n tags: [\"api\", \"rest\", \"backend\", \"auth\", \"jwt\"],\n },\n {\n name: \"cli-tool\",\n description: \"CLI application with commands, flags, interactive prompts, and config\",\n prompt: `Create a CLI tool with:\n1. Command framework setup (commander or similar)\n2. Multiple subcommands with flags and arguments\n3. Interactive prompts for user input\n4. Configuration file support (read/write)\n5. Colored output and spinners\n6. Help text and version command\n7. Error handling with friendly messages\n8. A sample command that demonstrates all features`,\n skills: [],\n outputType: \"script\",\n tags: [\"cli\", \"tool\", \"command-line\"],\n },\n {\n name: \"component-library\",\n description: \"UI component library with Storybook, tests, and documentation\",\n prompt: `Create a UI component library with:\n1. Button, Input, Card, Modal, Dropdown, Alert, Badge, Avatar components\n2. Consistent theming system (colors, typography, spacing)\n3. All components are accessible (ARIA, keyboard navigation)\n4. Component props are typed and documented\n5. Each component has unit tests\n6. Storybook stories for each component\n7. Export barrel file\n8. Package.json configured for publishing`,\n skills: [],\n outputType: \"component\",\n tags: [\"components\", \"ui\", \"library\", \"storybook\"],\n },\n {\n name: \"fullstack-app\",\n description: \"Full-stack application with database, API, UI, and deployment config\",\n prompt: `Create a full-stack application with:\n1. Database schema with models for a practical app (e.g., task management)\n2. API layer with CRUD operations for all models\n3. Frontend pages: home, list view, detail view, create/edit forms\n4. Authentication flow (login, register, protected routes)\n5. Form validation on client and server\n6. Loading states and error handling in the UI\n7. Docker configuration for development\n8. CI/CD workflow for GitHub Actions\n9. Environment configuration template`,\n skills: [],\n outputType: \"website\",\n tags: [\"fullstack\", \"app\", \"database\", \"auth\"],\n },\n {\n name: \"mobile-app\",\n description: \"Mobile application with navigation, screens, and native features\",\n prompt: `Create a mobile application with:\n1. Navigation setup (tab navigation + stack navigation)\n2. Screens: Home, Profile, Settings, List, Detail\n3. Authentication flow (login, register)\n4. Theme system with dark mode support\n5. State management setup\n6. API client configuration\n7. Common components (Button, Card, Input, Header)\n8. App configuration and assets setup`,\n skills: [],\n outputType: \"page\",\n tags: [\"mobile\", \"react-native\", \"expo\", \"flutter\"],\n },\n {\n name: \"chrome-extension\",\n description: \"Browser extension with popup, content script, background worker, and options\",\n prompt: `Create a browser extension (Chrome/Firefox compatible) with:\n1. manifest.json (Manifest V3)\n2. Popup page with UI\n3. Content script that modifies web pages\n4. Background service worker for event handling\n5. Options/settings page\n6. Storage management for user preferences\n7. Message passing between popup, content script, and background\n8. Icons and assets structure\n9. Build script`,\n skills: [],\n outputType: \"website\",\n tags: [\"extension\", \"chrome\", \"browser\", \"plugin\"],\n },\n {\n name: \"data-pipeline\",\n description: \"Data processing pipeline with ingestion, transformation, and output stages\",\n prompt: `Create a data processing pipeline with:\n1. Data ingestion from multiple sources (file, API, database)\n2. Transformation stage with configurable processors\n3. Validation and error handling at each stage\n4. Output to multiple destinations (file, database, API)\n5. Logging and monitoring\n6. Configuration file for pipeline definition\n7. CLI runner with progress reporting\n8. Test suite with sample data\n9. Docker configuration`,\n skills: [],\n outputType: \"script\",\n tags: [\"data\", \"pipeline\", \"etl\", \"processing\"],\n },\n]\n\nexport const create = new Command()\n .name(\"create\")\n .description(\"scaffold a new project from a template using AI\")\n .argument(\"[name]\", \"project name\")\n .option(\n \"-t, --template <template>\",\n `template to use: ${TEMPLATES.map((t) => t.name).join(\", \")}`\n )\n .option(\n \"-p, --provider <provider>\",\n \"AI provider (claude-code, claude)\",\n \"claude-code\"\n )\n .option(\"-m, --model <model>\", \"model to use\")\n .option(\"--api-key <key>\", \"API key\")\n .option(\n \"-c, --cwd <cwd>\",\n \"parent directory\",\n process.cwd()\n )\n .option(\"--list\", \"list available templates\", false)\n .option(\"-y, --yes\", \"skip confirmation prompts\", false)\n .action(async (name, opts) => {\n try {\n // List templates\n if (opts.list) {\n logger.break()\n console.log(chalk.bold(\" Available templates:\"))\n logger.break()\n for (const t of TEMPLATES) {\n console.log(` ${chalk.green(t.name)}`)\n console.log(` ${chalk.dim(t.description)}`)\n console.log(\n ` ${chalk.dim(\"tags:\")} ${t.tags.map((tag) => chalk.cyan(tag)).join(\", \")}`\n )\n logger.break()\n }\n return\n }\n\n // Interactive project name\n if (!name) {\n const response = await prompts({\n type: \"text\",\n name: \"name\",\n message: \"Project name:\",\n validate: (v) =>\n v.trim()\n ? /^[a-z0-9-_.]+$/.test(v.trim())\n ? true\n : \"Use lowercase letters, numbers, hyphens, dots, or underscores\"\n : \"Name is required\",\n })\n if (!response.name) {\n logger.warn(\"No name provided. Exiting.\")\n process.exit(0)\n }\n name = response.name\n }\n\n // Select template\n let template: Template | undefined\n if (opts.template) {\n template = TEMPLATES.find((t) => t.name === opts.template)\n if (!template) {\n logger.error(\n `Template \"${opts.template}\" not found. Available: ${TEMPLATES.map((t) => t.name).join(\", \")}`\n )\n logger.info(`Run ${chalk.green(\"agentx create --list\")} to see all templates.`)\n process.exit(1)\n }\n } else {\n const { selected } = await prompts({\n type: \"select\",\n name: \"selected\",\n message: \"Choose a template:\",\n choices: [\n ...TEMPLATES.map((t) => ({\n title: `${t.name} — ${t.description}`,\n value: t.name,\n })),\n {\n title: \"Custom — describe your own project\",\n value: \"_custom\",\n },\n ],\n })\n\n if (!selected) {\n logger.warn(\"No template selected. Exiting.\")\n process.exit(0)\n }\n\n if (selected === \"_custom\") {\n const { description } = await prompts({\n type: \"text\",\n name: \"description\",\n message: \"Describe the project you want to create:\",\n validate: (v) => (v.trim() ? true : \"Description is required\"),\n })\n\n if (!description) {\n logger.warn(\"No description provided. Exiting.\")\n process.exit(0)\n }\n\n template = {\n name: \"custom\",\n description,\n prompt: description,\n skills: [],\n outputType: \"website\",\n tags: [],\n }\n } else {\n template = TEMPLATES.find((t) => t.name === selected)!\n }\n }\n\n // Create project directory\n const projectDir = path.resolve(opts.cwd, name)\n if (existsSync(projectDir)) {\n if (!opts.yes) {\n const { overwrite } = await prompts({\n type: \"confirm\",\n name: \"overwrite\",\n message: `Directory \"${name}\" already exists. Continue?`,\n initial: false,\n })\n if (!overwrite) {\n logger.info(\"Cancelled.\")\n return\n }\n }\n } else {\n await fs.mkdir(projectDir, { recursive: true })\n }\n\n logger.break()\n logger.info(`Project: ${chalk.bold(name)}`)\n logger.info(`Template: ${chalk.bold(template.name)}`)\n logger.info(`Directory: ${chalk.dim(projectDir)}`)\n logger.break()\n\n const spinner = ora(\"Generating project from template...\").start()\n\n const result = await generate({\n task: `Create a new project called \"${name}\" in the current directory.\\n\\n${template.prompt}\\n\\nGenerate all files relative to the project root. Include a README.md explaining the project and how to get started.`,\n outputType: template.outputType as any,\n cwd: projectDir,\n overwrite: true,\n dryRun: false,\n provider: opts.provider as ProviderName,\n model: opts.model,\n apiKey: opts.apiKey,\n context7: true,\n interactive: false,\n maxSteps: 5,\n })\n\n spinner.stop()\n\n // Show results\n logger.break()\n if (result.content) {\n console.log(result.content)\n logger.break()\n }\n\n if (result.files.written.length) {\n logger.success(\n `Created ${result.files.written.length} file(s) in ${chalk.bold(name)}/`\n )\n for (const file of result.files.written) {\n const relative = path.relative(projectDir, file)\n console.log(` ${chalk.green(\"+\")} ${relative}`)\n }\n }\n\n if (result.files.errors.length) {\n logger.error(`${result.files.errors.length} file(s) failed:`)\n for (const err of result.files.errors) {\n console.log(` ${chalk.red(\"x\")} ${err}`)\n }\n }\n\n logger.break()\n logger.info(\"Next steps:\")\n console.log(` ${chalk.green(\"cd\")} ${name}`)\n console.log(\n ` ${chalk.green(\"agentx inspect\")} — see what was generated`\n )\n console.log(\n ` ${chalk.green(\"agentx evolve\")} — modify and extend`\n )\n logger.break()\n\n if (result.tokensUsed) {\n logger.info(`Tokens used: ${result.tokensUsed}`)\n }\n } catch (error) {\n handleError(error)\n }\n })\n","import { existsSync, promises as fs } from \"fs\"\nimport path from \"path\"\nimport { handleError } from \"@/utils/handle-error\"\nimport { logger } from \"@/utils/logger\"\nimport { AgentXRuntime, type RuntimeConfig } from \"@/runtime\"\nimport chalk from \"chalk\"\nimport { Command } from \"commander\"\n\n// --- `agentx run` — start the intelligent runtime framework ---\n\nexport const run = new Command()\n .name(\"run\")\n .description(\n \"start the agentx runtime — an intelligent framework that receives requests, learns, auto-heals, and self-enhances\"\n )\n .option(\"--port <port>\", \"server port\", \"3170\")\n .option(\"--host <host>\", \"server host\", \"0.0.0.0\")\n .option(\n \"-p, --provider <provider>\",\n \"AI provider (claude-code, claude)\",\n \"claude-code\"\n )\n .option(\"-m, --model <model>\", \"model to use\")\n .option(\"--api-key <key>\", \"API key\")\n .option(\n \"-c, --cwd <cwd>\",\n \"working directory\",\n process.cwd()\n )\n .option(\"--no-memory\", \"disable memory/learning\")\n .option(\"--no-heal\", \"disable auto-heal\")\n .option(\"--no-enhance\", \"disable self-enhancement\")\n .option(\"--test-cmd <cmd>\", \"test command for auto-heal\")\n .option(\"--build-cmd <cmd>\", \"build command for auto-heal\")\n .option(\"--no-cors\", \"disable CORS\")\n .action(async (opts) => {\n try {\n const cwd = path.resolve(opts.cwd)\n if (!existsSync(cwd)) {\n logger.error(`The path ${cwd} does not exist.`)\n process.exit(1)\n }\n\n // Load config from agentx.config.json if it exists\n const configPath = path.resolve(cwd, \"agentx.config.json\")\n let fileConfig: Partial<RuntimeConfig> = {}\n if (existsSync(configPath)) {\n try {\n const raw = await fs.readFile(configPath, \"utf8\")\n fileConfig = JSON.parse(raw)\n logger.info(`Loaded config from ${chalk.dim(\"agentx.config.json\")}`)\n } catch {\n logger.warn(\"Failed to parse agentx.config.json, using defaults\")\n }\n }\n\n const config: Partial<RuntimeConfig> = {\n port: parseInt(opts.port, 10) || fileConfig.port,\n host: opts.host || fileConfig.host,\n provider: (opts.provider || fileConfig.provider) as any,\n model: opts.model || fileConfig.model,\n apiKey: opts.apiKey || fileConfig.apiKey,\n cwd,\n memory: {\n enabled: opts.memory !== false && (fileConfig.memory?.enabled !== false),\n },\n heal: {\n enabled: opts.heal !== false && (fileConfig.heal?.enabled !== false),\n testCommand: opts.testCmd || fileConfig.heal?.testCommand,\n buildCommand: opts.buildCmd || fileConfig.heal?.buildCommand,\n },\n enhance: {\n enabled: opts.enhance !== false && (fileConfig.enhance?.enabled !== false),\n autoSkills: fileConfig.enhance?.autoSkills !== false,\n },\n cors: opts.cors !== false,\n }\n\n // Banner\n console.log(\"\")\n console.log(chalk.bold.cyan(\" ░░░ agentx runtime ░░░\"))\n console.log(chalk.dim(\" the intelligent framework\"))\n console.log(\"\")\n\n const runtime = new AgentXRuntime(config)\n await runtime.start()\n } catch (error) {\n handleError(error)\n }\n })\n","import { existsSync } from \"fs\"\nimport path from \"path\"\nimport { handleError } from \"@/utils/handle-error\"\nimport { logger } from \"@/utils/logger\"\nimport { createAgentContext } from \"@/agent\"\nimport { formatTechStack } from \"@/agent/context/tech-stack\"\nimport { formatSchemas } from \"@/agent/context/schema\"\nimport { loadLocalSkills } from \"@/agent/skills/loader\"\nimport chalk from \"chalk\"\nimport { Command } from \"commander\"\nimport ora from \"ora\"\n\n// --- `agentx inspect` — show what the agent sees ---\n\nexport const inspect = new Command()\n .name(\"inspect\")\n .aliases([\"info\", \"ctx\"])\n .description(\"show what the agent knows about your project — tech stack, schemas, skills, and more\")\n .option(\n \"-c, --cwd <cwd>\",\n \"working directory\",\n process.cwd()\n )\n .option(\"--json\", \"output as JSON\", false)\n .option(\"--verbose\", \"show full schema and model contents\", false)\n .action(async (opts) => {\n try {\n const cwd = path.resolve(opts.cwd)\n if (!existsSync(cwd)) {\n logger.error(`The path ${cwd} does not exist.`)\n process.exit(1)\n }\n\n const spinner = ora(\"Analyzing project...\").start()\n\n const context = await createAgentContext(cwd, \"inspect\", {\n context7: { enabled: false },\n })\n\n spinner.stop()\n\n if (opts.json) {\n console.log(\n JSON.stringify(\n {\n techStack: context.techStack,\n schemas: context.schemas,\n skills: context.skills.map((s) => ({\n name: s.frontmatter.name,\n description: s.frontmatter.description,\n source: s.source,\n tags: s.frontmatter.tags,\n })),\n },\n null,\n 2\n )\n )\n return\n }\n\n // Header\n logger.break()\n console.log(chalk.bold.cyan(\" agentx inspect\"))\n console.log(chalk.dim(` ${cwd}`))\n logger.break()\n\n // Languages\n const { techStack } = context\n if (techStack.languages.length) {\n console.log(chalk.bold(\" Languages\"))\n for (const lang of techStack.languages) {\n console.log(\n ` ${chalk.green(\"●\")} ${lang.name}${lang.version ? chalk.dim(` ${lang.version}`) : \"\"}${lang.configFile ? chalk.dim(` (${lang.configFile})`) : \"\"}`\n )\n }\n logger.break()\n }\n\n // Frameworks\n if (techStack.frameworks.length) {\n console.log(chalk.bold(\" Frameworks\"))\n for (const fw of techStack.frameworks) {\n const typeColor =\n fw.type === \"frontend\"\n ? chalk.blue\n : fw.type === \"backend\"\n ? chalk.yellow\n : fw.type === \"fullstack\"\n ? chalk.magenta\n : fw.type === \"mobile\"\n ? chalk.green\n : chalk.dim\n console.log(\n ` ${chalk.green(\"●\")} ${fw.name}${fw.version ? chalk.dim(` @${fw.version}`) : \"\"} ${typeColor(`[${fw.type}]`)}`\n )\n }\n logger.break()\n }\n\n // Package manager\n if (techStack.packageManager) {\n console.log(chalk.bold(\" Package Manager\"))\n console.log(` ${chalk.green(\"●\")} ${techStack.packageManager}`)\n logger.break()\n }\n\n // Databases\n if (techStack.databases.length) {\n console.log(chalk.bold(\" Databases\"))\n for (const db of techStack.databases) {\n console.log(` ${chalk.green(\"●\")} ${db}`)\n }\n logger.break()\n }\n\n // Styling\n if (techStack.styling.length) {\n console.log(chalk.bold(\" Styling\"))\n for (const style of techStack.styling) {\n console.log(` ${chalk.green(\"●\")} ${style}`)\n }\n logger.break()\n }\n\n // Testing\n if (techStack.testing.length) {\n console.log(chalk.bold(\" Testing\"))\n for (const test of techStack.testing) {\n console.log(` ${chalk.green(\"●\")} ${test}`)\n }\n logger.break()\n }\n\n // Deployment\n if (techStack.deployment.length) {\n console.log(chalk.bold(\" Deployment\"))\n for (const dep of techStack.deployment) {\n console.log(` ${chalk.green(\"●\")} ${dep}`)\n }\n logger.break()\n }\n\n // Monorepo\n if (techStack.monorepo) {\n console.log(chalk.bold(\" Monorepo\"))\n console.log(` ${chalk.green(\"●\")} yes`)\n logger.break()\n }\n\n // Schemas\n const { schemas } = context\n const hasSchemas =\n schemas.database || schemas.api || schemas.env || schemas.models?.length\n\n if (hasSchemas) {\n console.log(chalk.bold(\" Schemas Detected\"))\n\n if (schemas.database) {\n console.log(\n ` ${chalk.green(\"●\")} Database: ${chalk.cyan(schemas.database.type)}${\n schemas.database.tables?.length\n ? chalk.dim(` (${schemas.database.tables.length} tables: ${schemas.database.tables.slice(0, 5).join(\", \")}${schemas.database.tables.length > 5 ? \"...\" : \"\"})`)\n : \"\"\n }`\n )\n if (opts.verbose && schemas.database.content) {\n console.log(chalk.dim(\" ┌─────────────────────\"))\n for (const line of schemas.database.content.split(\"\\n\").slice(0, 20)) {\n console.log(chalk.dim(` │ ${line}`))\n }\n console.log(chalk.dim(\" └─────────────────────\"))\n }\n }\n\n if (schemas.api) {\n console.log(` ${chalk.green(\"●\")} API: ${chalk.cyan(schemas.api.type)}`)\n }\n\n if (schemas.env) {\n console.log(\n ` ${chalk.green(\"●\")} Environment: ${chalk.cyan(`${schemas.env.variables.length} variables`)}${\n schemas.env.variables.filter((v) => v.required).length\n ? chalk.dim(` (${schemas.env.variables.filter((v) => v.required).length} required)`)\n : \"\"\n }`\n )\n }\n\n if (schemas.models?.length) {\n console.log(\n ` ${chalk.green(\"●\")} Models: ${chalk.cyan(`${schemas.models.length} file(s)`)} ${chalk.dim(schemas.models.map((m) => m.path).join(\", \"))}`\n )\n }\n\n logger.break()\n }\n\n // Skills\n if (context.skills.length) {\n console.log(chalk.bold(\" Skills\"))\n for (const s of context.skills) {\n const source =\n s.source === \"remote\"\n ? chalk.blue(`[${s.packageId || \"remote\"}]`)\n : s.source === \"generated\"\n ? chalk.magenta(\"[generated]\")\n : chalk.dim(\"[local]\")\n\n console.log(` ${chalk.green(\"●\")} ${s.frontmatter.name} ${source}`)\n console.log(` ${chalk.dim(s.frontmatter.description)}`)\n }\n logger.break()\n } else {\n console.log(chalk.bold(\" Skills\"))\n console.log(\n ` ${chalk.dim(\"none installed\")} — run ${chalk.green(\"agentx skill install <owner/repo>\")} or ${chalk.green(\"agentx skill create <name>\")}`\n )\n logger.break()\n }\n\n // Dependencies summary\n const depCount = Object.keys(techStack.dependencies).length\n const devDepCount = Object.keys(techStack.devDependencies).length\n if (depCount || devDepCount) {\n console.log(chalk.bold(\" Dependencies\"))\n console.log(\n ` ${chalk.green(\"●\")} ${depCount} dependencies, ${devDepCount} devDependencies`\n )\n if (opts.verbose) {\n const topDeps = Object.entries(techStack.dependencies).slice(0, 15)\n for (const [name, version] of topDeps) {\n console.log(` ${chalk.dim(name)} ${chalk.dim(version)}`)\n }\n if (depCount > 15) {\n console.log(chalk.dim(` ... and ${depCount - 15} more`))\n }\n }\n logger.break()\n }\n\n // Summary line\n const parts: string[] = []\n if (techStack.languages.length) parts.push(`${techStack.languages.length} lang(s)`)\n if (techStack.frameworks.length) parts.push(`${techStack.frameworks.length} framework(s)`)\n if (hasSchemas) parts.push(\"schemas detected\")\n if (context.skills.length) parts.push(`${context.skills.length} skill(s)`)\n console.log(chalk.dim(` Summary: ${parts.join(\" · \")}`))\n logger.break()\n } catch (error) {\n handleError(error)\n }\n })\n","import { existsSync, promises as fs } from \"fs\"\nimport path from \"path\"\nimport { handleError } from \"@/utils/handle-error\"\nimport { logger } from \"@/utils/logger\"\nimport { createProvider, type ProviderName } from \"@/agent/providers\"\nimport { ensureCredentials } from \"@/utils/auth-store\"\nimport { detectTechStack, formatTechStack } from \"@/agent/context/tech-stack\"\nimport { loadLocalSkills } from \"@/agent/skills/loader\"\nimport { installSkillPackage, generateSkillMd, listInstalledSkills } from \"@/agent/skills/registry\"\nimport { generateSkill } from \"@/agent/skills/generator\"\nimport chalk from \"chalk\"\nimport { Command } from \"commander\"\nimport ora from \"ora\"\nimport prompts from \"prompts\"\n\nexport const skill = new Command()\n .name(\"skill\")\n .description(\"manage agent skills — install, create, list, and generate\")\n\n// --- skill install ---\nskill\n .command(\"install\")\n .aliases([\"add\", \"i\"])\n .description(\"install a skill package from skills.sh or GitHub\")\n .argument(\"<package>\", \"skill package (e.g., intellectronica/agent-skills)\")\n .option(\n \"-c, --cwd <cwd>\",\n \"working directory\",\n process.cwd()\n )\n .action(async (packageId, opts) => {\n try {\n const cwd = path.resolve(opts.cwd)\n const spinner = ora(`Installing skill: ${packageId}`).start()\n\n const skills = await installSkillPackage(packageId, cwd)\n\n spinner.stop()\n\n if (skills.length) {\n logger.success(`Installed ${skills.length} skill(s):`)\n for (const s of skills) {\n console.log(\n ` ${chalk.green(\"+\")} ${s.frontmatter.name} — ${s.frontmatter.description}`\n )\n }\n } else {\n logger.warn(\"No skills found in the package.\")\n }\n } catch (error) {\n handleError(error)\n }\n })\n\n// --- skill list ---\nskill\n .command(\"list\")\n .aliases([\"ls\"])\n .description(\"list installed skills\")\n .option(\n \"-c, --cwd <cwd>\",\n \"working directory\",\n process.cwd()\n )\n .action(async (opts) => {\n try {\n const cwd = path.resolve(opts.cwd)\n const skills = await listInstalledSkills(cwd)\n\n if (!skills.length) {\n logger.info(\"No skills installed. Install one with:\")\n console.log(\n ` ${chalk.green(\"agentx skill install\")} ${chalk.dim(\"<owner/repo>\")}`\n )\n return\n }\n\n logger.info(`Found ${skills.length} skill(s):`)\n logger.break()\n\n for (const s of skills) {\n const source =\n s.source === \"remote\"\n ? chalk.blue(`[${s.packageId}]`)\n : s.source === \"generated\"\n ? chalk.magenta(\"[generated]\")\n : chalk.dim(\"[local]\")\n\n console.log(` ${chalk.bold(s.frontmatter.name)} ${source}`)\n console.log(` ${chalk.dim(s.frontmatter.description)}`)\n\n if (s.frontmatter.tags?.length) {\n console.log(\n ` ${chalk.dim(\"tags:\")} ${s.frontmatter.tags.map((t) => chalk.cyan(t)).join(\", \")}`\n )\n }\n\n if (s.path) {\n console.log(` ${chalk.dim(\"path:\")} ${s.path}`)\n }\n\n logger.break()\n }\n } catch (error) {\n handleError(error)\n }\n })\n\n// --- skill create ---\nskill\n .command(\"create\")\n .description(\"create a new skill interactively or from a description\")\n .argument(\"[name]\", \"skill name\")\n .option(\"-d, --description <desc>\", \"skill description\")\n .option(\"--tags <tags>\", \"comma-separated tags\")\n .option(\n \"-p, --provider <provider>\",\n \"AI provider for generation (claude-code, claude)\",\n \"claude-code\"\n )\n .option(\"-m, --model <model>\", \"model to use\")\n .option(\"--api-key <key>\", \"API key\")\n .option(\n \"-c, --cwd <cwd>\",\n \"working directory\",\n process.cwd()\n )\n .option(\"--no-ai\", \"create a blank skill template without AI\")\n .action(async (name, opts) => {\n try {\n const cwd = path.resolve(opts.cwd)\n\n // Interactive name input if not provided\n if (!name) {\n const response = await prompts({\n type: \"text\",\n name: \"name\",\n message: \"Skill name:\",\n validate: (v) =>\n v.trim()\n ? /^[a-z0-9-]+$/.test(v.trim())\n ? true\n : \"Use lowercase letters, numbers, and hyphens only\"\n : \"Name is required\",\n })\n if (!response.name) {\n logger.warn(\"No name provided. Exiting.\")\n process.exit(0)\n }\n name = response.name\n }\n\n // Get description\n let description = opts.description\n if (!description) {\n const response = await prompts({\n type: \"text\",\n name: \"description\",\n message: \"Skill description:\",\n validate: (v) => (v.trim() ? true : \"Description is required\"),\n })\n if (!response.description) {\n logger.warn(\"No description provided. Exiting.\")\n process.exit(0)\n }\n description = response.description\n }\n\n const tags = opts.tags\n ? opts.tags.split(\",\").map((t: string) => t.trim())\n : undefined\n\n const skillDir = path.resolve(cwd, \".skills\", name)\n const skillPath = path.resolve(skillDir, \"SKILL.md\")\n\n if (existsSync(skillPath)) {\n const { overwrite } = await prompts({\n type: \"confirm\",\n name: \"overwrite\",\n message: `Skill \"${name}\" already exists. Overwrite?`,\n initial: false,\n })\n if (!overwrite) {\n logger.info(\"Skipped.\")\n return\n }\n }\n\n let content: string\n\n if (opts.ai === false) {\n // Blank template\n content = await generateSkillMd(\n name,\n description,\n `# ${name}\\n\\n## Instructions\\n\\nAdd your skill instructions here.\\n\\n## Examples\\n\\nAdd examples here.`,\n tags\n )\n } else {\n // AI-generated skill — ensure credentials first\n const hasCredentials = await ensureCredentials(opts.apiKey)\n if (!hasCredentials) {\n logger.error(\"No credentials configured. Run `agentx model` to set up.\")\n process.exit(1)\n }\n\n const spinner = ora(\"Detecting tech stack...\").start()\n const techStack = await detectTechStack(cwd)\n spinner.text = \"Generating skill with AI...\"\n\n const provider = createProvider(\n opts.provider as ProviderName,\n opts.apiKey\n )\n\n const result = await generateSkill(\n provider,\n name,\n description,\n techStack,\n { tags }\n )\n\n spinner.stop()\n content = result.content\n }\n\n // Write skill file\n await fs.mkdir(skillDir, { recursive: true })\n await fs.writeFile(skillPath, content, \"utf8\")\n\n logger.success(`Created skill: ${skillPath}`)\n logger.break()\n logger.info(\"The skill will be automatically loaded for future generations.\")\n logger.info(\n `To share it, push to GitHub and others can install with: ${chalk.green(`agentx skill install <your-username>/<your-repo>`)}`\n )\n } catch (error) {\n handleError(error)\n }\n })\n\n// --- skill inspect ---\nskill\n .command(\"inspect\")\n .description(\"show details of an installed skill\")\n .argument(\"<name>\", \"skill name\")\n .option(\n \"-c, --cwd <cwd>\",\n \"working directory\",\n process.cwd()\n )\n .action(async (name, opts) => {\n try {\n const cwd = path.resolve(opts.cwd)\n const skills = await listInstalledSkills(cwd)\n\n const found = skills.find(\n (s) => s.frontmatter.name === name || s.path?.includes(name)\n )\n\n if (!found) {\n logger.error(`Skill \"${name}\" not found.`)\n logger.info(`Run ${chalk.green(\"agentx skill list\")} to see installed skills.`)\n return\n }\n\n console.log(chalk.bold(`\\n ${found.frontmatter.name}`))\n console.log(` ${found.frontmatter.description}`)\n logger.break()\n\n if (found.frontmatter.tags?.length) {\n console.log(\n ` ${chalk.dim(\"Tags:\")} ${found.frontmatter.tags.join(\", \")}`\n )\n }\n if (found.packageId) {\n console.log(` ${chalk.dim(\"Package:\")} ${found.packageId}`)\n }\n if (found.path) {\n console.log(` ${chalk.dim(\"Path:\")} ${found.path}`)\n }\n\n logger.break()\n console.log(chalk.dim(\" --- Instructions ---\"))\n logger.break()\n console.log(\n found.instructions\n .split(\"\\n\")\n .map((l) => ` ${l}`)\n .join(\"\\n\")\n )\n logger.break()\n } catch (error) {\n handleError(error)\n }\n })\n","import { handleError } from \"@/utils/handle-error\"\nimport { logger } from \"@/utils/logger\"\nimport { startMcpServer } from \"@/mcp\"\nimport chalk from \"chalk\"\nimport { Command } from \"commander\"\n\n// --- `agentx serve` — run as MCP server for AI editors ---\n\nexport const serve = new Command()\n .name(\"serve\")\n .description(\"run agentx as an MCP server for AI editors (Claude Code, Cursor, Windsurf, etc.)\")\n .option(\"--stdio\", \"use stdio transport (default)\", true)\n .option(\n \"-c, --cwd <cwd>\",\n \"working directory\",\n process.cwd()\n )\n .action(async (opts) => {\n try {\n if (opts.stdio !== false) {\n // stdio mode — all logging goes to stderr, stdout is JSON-RPC\n await startMcpServer()\n } else {\n logger.error(\"Only stdio transport is currently supported.\")\n logger.info(\n `Usage: ${chalk.green(\"agentx serve --stdio\")} or configure in your MCP client.`\n )\n logger.break()\n logger.info(\"Add to Claude Code:\")\n logger.info(\n chalk.dim(\n ' claude mcp add agentx -- npx agentx serve --stdio'\n )\n )\n logger.break()\n logger.info(\"Add to Cursor/MCP config:\")\n logger.info(\n chalk.dim(\n JSON.stringify(\n {\n mcpServers: {\n agentx: {\n command: \"npx\",\n args: [\"agentx\", \"serve\", \"--stdio\"],\n },\n },\n },\n null,\n 2\n )\n )\n )\n }\n } catch (error) {\n handleError(error)\n }\n })\n","import { handleError } from \"@/utils/handle-error\"\nimport { logger } from \"@/utils/logger\"\nimport { loadAuthConfig, runModelSetup, type AuthConfig } from \"@/utils/auth-store\"\nimport chalk from \"chalk\"\nimport { Command } from \"commander\"\n\nconst ANTHROPIC_MODELS = [\n { id: \"claude-sonnet-4-20250514\", label: \"anthropic/claude-sonnet-4\", hint: \"Claude Sonnet 4 · ctx 200k · recommended\" },\n { id: \"claude-opus-4-20250514\", label: \"anthropic/claude-opus-4-5\", hint: \"Claude Opus 4.5 · ctx 200k · reasoning\" },\n { id: \"claude-haiku-4-20250514\", label: \"anthropic/claude-haiku-4\", hint: \"Claude Haiku 4 · ctx 200k · fast\" },\n]\n\nexport const model = new Command()\n .name(\"model\")\n .description(\"configure AI provider, credentials, and model\")\n\n// --- model (default: interactive setup) ---\nmodel\n .command(\"setup\", { isDefault: true })\n .description(\"interactively configure provider and model\")\n .action(async () => {\n try {\n const result = await runModelSetup()\n if (!result) process.exit(0)\n } catch (e) {\n handleError(e)\n }\n })\n\n// --- model show ---\nmodel\n .command(\"show\")\n .description(\"display current provider and model configuration\")\n .action(async () => {\n try {\n const config = loadAuthConfig()\n\n if (!config) {\n logger.warn(\"No configuration found. Run `agentx model` to set up.\")\n process.exit(0)\n }\n\n const modelLabel = ANTHROPIC_MODELS.find((m) => m.id === config.model)?.label || config.model\n\n console.log(chalk.bold(\"\\nCurrent configuration:\"))\n console.log(` Provider: ${chalk.cyan(\"anthropic\")} (${config.authType})`)\n console.log(` Model: ${chalk.cyan(modelLabel)}`)\n console.log(` Token: ${chalk.dim(maskToken(config.token))}`)\n console.log(` File: ${chalk.dim(\"~/.agentx/auth.json\")}`)\n\n if (process.env.ANTHROPIC_API_KEY) {\n console.log(chalk.yellow(\"\\n Note: ANTHROPIC_API_KEY env var is set (takes priority)\"))\n }\n if (process.env.ANTHROPIC_OAUTH_TOKEN) {\n console.log(chalk.yellow(\"\\n Note: ANTHROPIC_OAUTH_TOKEN env var is set (takes priority)\"))\n }\n console.log()\n } catch (e) {\n handleError(e)\n }\n })\n\nfunction maskToken(token: string): string {\n if (token.length < 12) return \"***\"\n return token.slice(0, 10) + \"...\" + token.slice(-4)\n}\n","import { Command } from \"commander\"\nimport chalk from \"chalk\"\nimport ora from \"ora\"\nimport { handleError } from \"@/utils/handle-error\"\nimport { logger } from \"@/utils/logger\"\nimport { GitManager } from \"@/git\"\nimport { createProvider } from \"@/agent/providers\"\n\nexport const git = new Command()\n .name(\"git\")\n .description(\"AI-powered git operations\")\n\ngit\n .command(\"status\")\n .alias(\"s\")\n .description(\"show git status with summary\")\n .option(\"-c, --cwd <cwd>\", \"working directory\", process.cwd())\n .action(async (opts) => {\n try {\n const gm = new GitManager(opts.cwd)\n if (!(await gm.isRepo())) {\n logger.error(\"Not a git repository\")\n process.exit(1)\n }\n\n const status = await gm.status()\n\n logger.break()\n logger.info(`Branch: ${chalk.bold(status.branch)}`)\n logger.break()\n\n if (status.isClean) {\n logger.success(\"Working tree clean\")\n return\n }\n\n if (status.staged.length) {\n logger.success(`Staged (${status.staged.length}):`)\n for (const f of status.staged) {\n console.log(` ${chalk.green(\"+\")} ${f}`)\n }\n }\n\n if (status.modified.length) {\n logger.warn(`Modified (${status.modified.length}):`)\n for (const f of status.modified) {\n console.log(` ${chalk.yellow(\"~\")} ${f}`)\n }\n }\n\n if (status.untracked.length) {\n console.log(chalk.dim(`Untracked (${status.untracked.length}):`))\n for (const f of status.untracked) {\n console.log(` ${chalk.dim(\"?\")} ${f}`)\n }\n }\n\n if (status.deleted.length) {\n logger.error(`Deleted (${status.deleted.length}):`)\n for (const f of status.deleted) {\n console.log(` ${chalk.red(\"-\")} ${f}`)\n }\n }\n\n logger.break()\n } catch (error) {\n handleError(error)\n }\n })\n\ngit\n .command(\"commit\")\n .alias(\"c\")\n .description(\"create an AI-generated commit message and commit\")\n .option(\"-m, --message <message>\", \"use a custom commit message\")\n .option(\"-a, --all\", \"stage all changes before committing\", false)\n .option(\"--ai\", \"generate commit message with AI\", true)\n .option(\"-c, --cwd <cwd>\", \"working directory\", process.cwd())\n .action(async (opts) => {\n try {\n const gm = new GitManager(opts.cwd)\n if (!(await gm.isRepo())) {\n logger.error(\"Not a git repository\")\n process.exit(1)\n }\n\n // Stage all if requested\n if (opts.all) {\n await gm.addAll()\n }\n\n const status = await gm.status()\n if (status.staged.length === 0) {\n logger.warn(\"Nothing staged to commit. Use --all to stage everything.\")\n process.exit(0)\n }\n\n let message = opts.message\n if (!message) {\n if (opts.ai) {\n const spinner = ora(\"Generating commit message...\").start()\n try {\n const provider = createProvider()\n message = await gm.generateCommitMessage(provider)\n spinner.stop()\n logger.info(`Message: ${chalk.bold(message)}`)\n } catch {\n spinner.stop()\n message = await gm.generateCommitMessage()\n logger.info(`Message: ${chalk.bold(message)}`)\n }\n } else {\n message = await gm.generateCommitMessage()\n }\n }\n\n const result = await gm.commit(message)\n logger.break()\n logger.success(\n `[${result.hash}] ${result.message} (${result.filesChanged} file(s))`\n )\n } catch (error) {\n handleError(error)\n }\n })\n\ngit\n .command(\"diff\")\n .alias(\"d\")\n .description(\"show diff of changes\")\n .option(\"-s, --staged\", \"show staged changes\", false)\n .option(\"-c, --cwd <cwd>\", \"working directory\", process.cwd())\n .action(async (opts) => {\n try {\n const gm = new GitManager(opts.cwd)\n const diffOutput = await gm.diff(opts.staged)\n\n if (!diffOutput.trim()) {\n logger.info(opts.staged ? \"No staged changes\" : \"No changes\")\n return\n }\n\n console.log(diffOutput)\n } catch (error) {\n handleError(error)\n }\n })\n\ngit\n .command(\"log\")\n .alias(\"l\")\n .description(\"show recent commits\")\n .option(\"-n, --count <n>\", \"number of commits to show\", \"10\")\n .option(\"-c, --cwd <cwd>\", \"working directory\", process.cwd())\n .action(async (opts) => {\n try {\n const gm = new GitManager(opts.cwd)\n const entries = await gm.log(parseInt(opts.count))\n\n if (!entries.length) {\n logger.info(\"No commits yet\")\n return\n }\n\n logger.break()\n for (const entry of entries) {\n console.log(\n `${chalk.yellow(entry.shortHash)} ${entry.message} ${chalk.dim(`— ${entry.author}`)}`\n )\n }\n logger.break()\n } catch (error) {\n handleError(error)\n }\n })\n","import { Command } from \"commander\"\nimport { A2AServer } from \"@/a2a\"\nimport type { ProviderName } from \"@/agent/providers\"\n\nexport const a2a = new Command()\n .name(\"a2a\")\n .description(\"start an A2A (Agent-to-Agent) protocol server for external agent integration\")\n .option(\"--port <port>\", \"server port\", \"3171\")\n .option(\"--host <host>\", \"server host\", \"0.0.0.0\")\n .option(\"-p, --provider <provider>\", \"AI provider\", \"claude-code\")\n .option(\"-m, --model <model>\", \"model to use\")\n .option(\"--api-key <key>\", \"API key for the provider\")\n .option(\"-c, --cwd <cwd>\", \"working directory\", process.cwd())\n .option(\"--no-cors\", \"disable CORS headers\")\n .action(async (opts) => {\n const server = new A2AServer({\n port: parseInt(opts.port, 10),\n host: opts.host,\n provider: opts.provider as ProviderName,\n model: opts.model,\n apiKey: opts.apiKey,\n cwd: opts.cwd,\n cors: opts.cors !== false,\n })\n\n await server.start()\n })\n","import { Command } from \"commander\"\nimport { AgentXDaemon } from \"@/daemon\"\n\nexport const daemon = new Command()\n .name(\"daemon\")\n .description(\"start the agentx daemon — channels, crons, agents, and mesh\")\n .option(\"-c, --config <path>\", \"path to agentx.json config file\")\n .action(async (opts) => {\n const d = new AgentXDaemon(opts.config)\n await d.start()\n })\n","#!/usr/bin/env node\nimport { chat } from \"@/commands/chat\"\nimport { gen } from \"@/commands/generate\"\nimport { evolve } from \"@/commands/evolve\"\nimport { create } from \"@/commands/create\"\nimport { run } from \"@/commands/run\"\nimport { inspect } from \"@/commands/inspect\"\nimport { skill } from \"@/commands/skill\"\nimport { serve } from \"@/commands/serve\"\nimport { model } from \"@/commands/model\"\nimport { git } from \"@/commands/git\"\nimport { a2a } from \"@/commands/a2a\"\nimport { daemon } from \"@/commands/daemon\"\nimport { Command } from \"commander\"\nimport { globalHooks, loadHooks } from \"@/hooks\"\nimport { getPackageInfo } from \"@/utils/get-package-info\"\n\nprocess.on(\"SIGINT\", () => process.exit(0))\nprocess.on(\"SIGTERM\", () => process.exit(0))\n\nasync function main() {\n const packageInfo = await getPackageInfo()\n\n const cwd = process.cwd()\n loadHooks(cwd, globalHooks)\n\n const program = new Command()\n .name(\"agentx\")\n .description(\n \"the AI coding agent — generate, evolve, chat, and manage your codebase with AI\"\n )\n .version(\n packageInfo.version || \"1.0.0\",\n \"-v, --version\",\n \"display the version number\"\n )\n\n program\n .addCommand(chat)\n .addCommand(gen)\n .addCommand(evolve)\n .addCommand(git)\n .addCommand(create)\n .addCommand(run)\n .addCommand(inspect)\n .addCommand(skill)\n .addCommand(serve)\n .addCommand(model)\n .addCommand(a2a)\n .addCommand(daemon)\n\n // Default to chat when no command is given and stdin is a TTY\n const args = process.argv.slice(2)\n if (args.length === 0 && process.stdin.isTTY) {\n process.argv.push(\"chat\")\n }\n\n program.parse()\n}\n\nmain()\n"],"mappings":";ucAAA,OAAS,cAAAA,OAAkB,KAC3B,OAAOC,OAAU,OACjB,OAAS,WAAAC,OAAe,YACxB,OAAOC,OAAW,QASX,IAAMC,GAAO,IAAIC,GAAQ,EAC7B,KAAK,MAAM,EACX,YAAY,wCAAwC,EACpD,OAAO,WAAY,0BAA2B,EAAK,EACnD,OAAO,qBAAsB,2BAA2B,EACxD,OAAO,SAAU,sBAAuB,EAAK,EAC7C,OACC,4BACA,oCACA,aACF,EACC,OAAO,sBAAuB,cAAc,EAC5C,OAAO,kBAAmB,0BAA0B,EACpD,OAAO,kBAAmB,oBAAqB,QAAQ,IAAI,CAAC,EAC5D,OAAO,UAAW,yCAA0C,EAAK,EACjE,OAAO,gBAAiB,qDAAsD,MAAM,EACpF,OAAO,MAAOC,GAAS,CACtB,GAAI,CAEF,GAAIA,EAAK,KAAM,CACb,IAAMC,EAAWC,GAAa,EAC9B,GAAI,CAACD,EAAS,OAAQ,CACpBE,EAAO,KAAK,mBAAmB,EAC/B,OAGF,QAAQ,IAAI,EACZ,QAAQ,IAAIC,GAAM,KAAK,mBAAmB,CAAC,EAC3C,QAAQ,IAAI,EACZ,QAAW,KAAKH,EAAS,MAAM,EAAG,EAAE,EAAG,CACrC,IAAMI,EAAO,IAAI,KAAK,EAAE,SAAS,EAAE,mBAAmB,EAChDC,EAAO,EAAE,SAAS,OAClBC,EAAS,EAAE,WAAW,eAAe,EAC3C,QAAQ,IACN,KAAKH,GAAM,KAAK,EAAE,EAAE,MAAMC,MAASC,WAAcC,UACnD,EAEF,QAAQ,IAAI,EACZ,OAGEP,EAAK,OACPQ,EAAS,EAAI,EAGXR,EAAK,MACPS,EAAkB,QAAQT,EAAK,IAAsB,EAGvD,IAAMU,EAAMC,GA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","names":["existsSync","path","Command","chalk","chat","Command","opts","sessions","listSessions","logger","chalk","date","msgs","tokens","setDebug","globalPermissions","cwd","path","existsSync","packageInfo","getPackageInfo","ReplEngine","error","handleError","existsSync","path","chalk","Command","ora","prompts","z","chalk","nowMs","formatDuration","ms","s","m","h","ss","mm","tailLines","text","maxLines","lines","clampTail","maxChars","GenerateTui","opts","evt","status","line","ts","msg","cols","rows","spinnerFrames","spinner","idleForMs","header","meta1","meta2","meta3","sep","available","outputLines","eventLines","eventTail","outTailLines","body","l","chalk","indentBlock","s","prefix","l","renderInline","line","_","code","text","url","t","renderTextBlock","block","lines","out","raw","title","renderMarkdownForTerminal","md","input","parts","chunk","firstNl","info","body","header","footer","codeBody","generateOptionsSchema","z","gen","Command","OUTPUT_TYPES","taskParts","opts","task","setDebug","globalPermissions","cwd","path","existsSync","logger","response","prompts","v","type","t","outputTypeDescriptions","options","maxSteps","useTui","spinner","ora","tui","GenerateTui","chalk","result","streamError","event","generateStream","rendered","renderMarkdownForTerminal","answer","task2","tui2","result2","streamError2","printResult","error","handleError","file","err","summary","globalTracker","step","existsSync","fs","path","chalk","Command","ora","prompts","fg","evolve","taskParts","opts","task","cwd","path","existsSync","logger","setDebug","globalPermissions","response","v","effectiveTask","globalHooks","promptResult","genResult","globPattern","matchedFiles","maxFiles","filesToProcess","spinner","fileContents","file","fullPath","content","fs","context","createAgentContext","matchedSkills","matchSkillsToTask","debug","systemPrompt","buildEvolveSystemPrompt","m","filesSummary","f","truncate","userMessage","ensureCredentials","providerName","provider","createProvider","resolvedModel","loadAuthConfig","messages","result","stepTokens","stepModel","estInput","estOutput","globalTracker","changes","original","approved","change","diffLines","generateSimpleDiff","line","action","remaining","writeSpinner","written","errors","writtenFiles","writeResult","dir","error","memory","MemoryHierarchy","HealEngine","healEngine","healSpinner","healResult","summary","handleError","skills","sections","formatTechStack","deps","schemaStr","formatSchemas","proposed","origLines","propLines","diff","maxLen","contextBuffer","lastChangeIdx","i","origLine","propLine","str","max","existsSync","fs","path","chalk","Command","ora","prompts","TEMPLATES","create","t","name","opts","logger","tag","response","v","template","selected","description","projectDir","path","existsSync","overwrite","fs","spinner","result","generate","file","relative","err","error","handleError","existsSync","fs","path","chalk","Command","run","opts","cwd","path","existsSync","logger","configPath","fileConfig","raw","fs","config","AgentXRuntime","error","handleError","existsSync","path","chalk","Command","ora","inspect","opts","cwd","path","existsSync","logger","spinner","context","createAgentContext","s","techStack","lang","fw","typeColor","db","style","test","dep","schemas","hasSchemas","line","v","m","source","depCount","devDepCount","topDeps","name","version","parts","error","handleError","existsSync","fs","path","chalk","Command","ora","prompts","skill","packageId","opts","cwd","path","spinner","skills","installSkillPackage","logger","error","handleError","listInstalledSkills","s","source","t","name","response","v","description","tags","skillDir","skillPath","existsSync","overwrite","content","generateSkillMd","ensureCredentials","techStack","detectTechStack","provider","createProvider","result","generateSkill","fs","found","l","chalk","Command","serve","opts","startMcpServer","logger","error","handleError","chalk","Command","ANTHROPIC_MODELS","model","runModelSetup","e","handleError","config","loadAuthConfig","logger","modelLabel","m","maskToken","token","Command","chalk","ora","git","Command","opts","gm","GitManager","logger","status","chalk","f","error","handleError","message","spinner","ora","provider","createProvider","result","diffOutput","entries","entry","Command","a2a","Command","opts","A2AServer","Command","daemon","Command","opts","AgentXDaemon","Command","main","packageInfo","getPackageInfo","cwd","loadHooks","globalHooks","program","Command","chat","gen","evolve","git","create","run","inspect","skill","serve","model","a2a","daemon"]}
@@ -0,0 +1,2 @@
1
+ import{a}from"./chunk-6PVFYFUE.js";import"./chunk-SFQUP3BP.js";import"./chunk-FUYKPFUV.js";export{a as HealEngine};
2
+ //# sourceMappingURL=heal-MJLBETRV.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}