kairn-cli 1.2.0 → 1.3.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.
- package/dist/cli.js +138 -3
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
- package/src/registry/tools.json +322 -0
package/dist/cli.js
CHANGED
|
@@ -217,6 +217,37 @@ You must output a JSON object matching the EnvironmentSpec schema.
|
|
|
217
217
|
- **Concise CLAUDE.md.** Under 100 lines. No generic text like "be helpful." Include build/test commands, reference docs/ and skills/.
|
|
218
218
|
- **Security by default.** Always include deny rules for destructive commands and secret file access.
|
|
219
219
|
|
|
220
|
+
## CLAUDE.md Template (mandatory structure)
|
|
221
|
+
|
|
222
|
+
The \`claude_md\` field MUST follow this exact structure (max 100 lines):
|
|
223
|
+
|
|
224
|
+
\`\`\`
|
|
225
|
+
# {Project Name}
|
|
226
|
+
|
|
227
|
+
## Purpose
|
|
228
|
+
{one-line description}
|
|
229
|
+
|
|
230
|
+
## Tech Stack
|
|
231
|
+
{bullet list of frameworks/languages}
|
|
232
|
+
|
|
233
|
+
## Commands
|
|
234
|
+
{concrete build/test/lint/dev commands}
|
|
235
|
+
|
|
236
|
+
## Architecture
|
|
237
|
+
{brief folder structure, max 10 lines}
|
|
238
|
+
|
|
239
|
+
## Conventions
|
|
240
|
+
{3-5 specific coding rules}
|
|
241
|
+
|
|
242
|
+
## Key Commands
|
|
243
|
+
{list /project: commands with descriptions}
|
|
244
|
+
|
|
245
|
+
## Output
|
|
246
|
+
{where results go, key files}
|
|
247
|
+
\`\`\`
|
|
248
|
+
|
|
249
|
+
Do not add generic filler. Every line must be specific to the user's workflow.
|
|
250
|
+
|
|
220
251
|
## What You Must Always Include
|
|
221
252
|
|
|
222
253
|
1. A concise, workflow-specific \`claude_md\` (the CLAUDE.md content)
|
|
@@ -228,6 +259,95 @@ You must output a JSON object matching the EnvironmentSpec schema.
|
|
|
228
259
|
7. A \`rules/continuity.md\` rule encouraging updates to DECISIONS.md and LEARNINGS.md
|
|
229
260
|
8. A \`rules/security.md\` rule with essential security instructions
|
|
230
261
|
9. settings.json with deny rules for \`rm -rf\`, \`curl|sh\`, reading \`.env\` and \`secrets/\`
|
|
262
|
+
10. A \`/project:status\` command for code projects (uses ! for live git/test output)
|
|
263
|
+
11. A \`/project:fix\` command for code projects (uses $ARGUMENTS for issue number)
|
|
264
|
+
|
|
265
|
+
## Shell-Integrated Commands
|
|
266
|
+
|
|
267
|
+
Commands that reference live project state should use Claude Code's \`!\` prefix for shell output:
|
|
268
|
+
|
|
269
|
+
\`\`\`markdown
|
|
270
|
+
# Example: .claude/commands/review.md
|
|
271
|
+
Review the staged changes for quality and security:
|
|
272
|
+
|
|
273
|
+
!git diff --staged
|
|
274
|
+
|
|
275
|
+
Run tests and check for failures:
|
|
276
|
+
|
|
277
|
+
!npm test 2>&1 | tail -20
|
|
278
|
+
|
|
279
|
+
Focus on: security, error handling, test coverage.
|
|
280
|
+
\`\`\`
|
|
281
|
+
|
|
282
|
+
Use \`!\` when a command needs: git status, test results, build output, or file listings.
|
|
283
|
+
|
|
284
|
+
## Path-Scoped Rules
|
|
285
|
+
|
|
286
|
+
For code projects with multiple domains (API, frontend, tests), generate path-scoped rules using YAML frontmatter:
|
|
287
|
+
|
|
288
|
+
\`\`\`markdown
|
|
289
|
+
# Example: rules/api.md
|
|
290
|
+
---
|
|
291
|
+
paths:
|
|
292
|
+
- "src/api/**"
|
|
293
|
+
- "src/routes/**"
|
|
294
|
+
---
|
|
295
|
+
- All handlers return { data, error } shape
|
|
296
|
+
- Use Zod for request validation
|
|
297
|
+
- Log errors with request ID context
|
|
298
|
+
\`\`\`
|
|
299
|
+
|
|
300
|
+
\`\`\`markdown
|
|
301
|
+
# Example: rules/testing.md
|
|
302
|
+
---
|
|
303
|
+
paths:
|
|
304
|
+
- "tests/**"
|
|
305
|
+
- "**/*.test.*"
|
|
306
|
+
- "**/*.spec.*"
|
|
307
|
+
---
|
|
308
|
+
- Use AAA pattern: Arrange-Act-Assert
|
|
309
|
+
- One assertion per test when possible
|
|
310
|
+
- Mock external dependencies, never real APIs
|
|
311
|
+
\`\`\`
|
|
312
|
+
|
|
313
|
+
Keep \`security.md\` and \`continuity.md\` as unconditional (no paths frontmatter).
|
|
314
|
+
Only generate scoped rules when the workflow involves multiple code domains.
|
|
315
|
+
|
|
316
|
+
## Hooks
|
|
317
|
+
|
|
318
|
+
Generate hooks in settings.json based on project type:
|
|
319
|
+
|
|
320
|
+
**All code projects** \u2014 block destructive commands:
|
|
321
|
+
\`\`\`json
|
|
322
|
+
{
|
|
323
|
+
"hooks": {
|
|
324
|
+
"PreToolUse": [{
|
|
325
|
+
"matcher": "Bash",
|
|
326
|
+
"hooks": [{
|
|
327
|
+
"type": "command",
|
|
328
|
+
"command": "CMD=$(cat | jq -r '.tool_input.command // empty') && echo \\"$CMD\\" | grep -qiE 'rm\\\\s+-rf\\\\s+/|DROP\\\\s+TABLE|curl.*\\\\|\\\\s*sh' && echo 'Blocked destructive command' >&2 && exit 2 || true"
|
|
329
|
+
}]
|
|
330
|
+
}]
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
\`\`\`
|
|
334
|
+
|
|
335
|
+
**Projects with Prettier/ESLint/Black** \u2014 auto-format on write:
|
|
336
|
+
\`\`\`json
|
|
337
|
+
{
|
|
338
|
+
"hooks": {
|
|
339
|
+
"PostToolUse": [{
|
|
340
|
+
"matcher": "Edit|Write",
|
|
341
|
+
"hooks": [{
|
|
342
|
+
"type": "command",
|
|
343
|
+
"command": "FILE=$(cat | jq -r '.tool_input.file_path // empty') && [ -n \\"$FILE\\" ] && npx prettier --write \\"$FILE\\" 2>/dev/null || true"
|
|
344
|
+
}]
|
|
345
|
+
}]
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
\`\`\`
|
|
349
|
+
|
|
350
|
+
Merge hooks into the \`settings\` object alongside permissions. Choose the formatter hook based on detected dependencies (Prettier \u2192 prettier, ESLint \u2192 eslint, Black \u2192 black).
|
|
231
351
|
|
|
232
352
|
## Tool Selection Rules
|
|
233
353
|
|
|
@@ -244,7 +364,13 @@ You must output a JSON object matching the EnvironmentSpec schema.
|
|
|
244
364
|
- \`/project:review\` command (review changes)
|
|
245
365
|
- \`/project:test\` command (run and fix tests)
|
|
246
366
|
- \`/project:commit\` command (conventional commits)
|
|
247
|
-
-
|
|
367
|
+
- \`/project:status\` command (live git status, recent commits, TODO overview using ! prefix)
|
|
368
|
+
- \`/project:fix\` command (takes $ARGUMENTS as issue number, plans fix, implements, tests, commits)
|
|
369
|
+
- A TDD skill using the 3-phase isolation pattern (RED \u2192 GREEN \u2192 REFACTOR):
|
|
370
|
+
- RED: Write failing test only. Verify it FAILS.
|
|
371
|
+
- GREEN: Write MINIMUM code to pass. Nothing extra.
|
|
372
|
+
- REFACTOR: Improve while keeping tests green.
|
|
373
|
+
Rules: never write tests and implementation in same step, AAA pattern, one assertion per test.
|
|
248
374
|
- A reviewer agent (read-only, Sonnet model)
|
|
249
375
|
|
|
250
376
|
## For Research Projects, Additionally Include
|
|
@@ -284,7 +410,9 @@ Return ONLY valid JSON matching this structure:
|
|
|
284
410
|
},
|
|
285
411
|
"commands": {
|
|
286
412
|
"help": "markdown content for /project:help",
|
|
287
|
-
"tasks": "markdown content for /project:tasks"
|
|
413
|
+
"tasks": "markdown content for /project:tasks",
|
|
414
|
+
"status": "Show project status:\\n\\n!git status --short\\n\\n!git log --oneline -5\\n\\nRead TODO.md and summarize progress.",
|
|
415
|
+
"fix": "Fix issue #$ARGUMENTS:\\n\\n1. Read the issue and understand the problem\\n2. Plan the fix\\n3. Implement the fix\\n4. Run tests:\\n\\n!npm test 2>&1 | tail -20\\n\\n5. Commit with: fix: resolve #$ARGUMENTS"
|
|
288
416
|
},
|
|
289
417
|
"rules": {
|
|
290
418
|
"continuity": "markdown content for continuity rule",
|
|
@@ -1080,6 +1208,10 @@ ${profile.existingClaudeMd}`);
|
|
|
1080
1208
|
parts.push("- Are security rules present?");
|
|
1081
1209
|
parts.push("- Is there a continuity rule for session memory?");
|
|
1082
1210
|
parts.push("- Are there unnecessary MCP servers adding context bloat?");
|
|
1211
|
+
parts.push("- Are hooks configured in settings.json for destructive command blocking?");
|
|
1212
|
+
parts.push("- Are there path-scoped rules for different code domains (api, testing, frontend)?");
|
|
1213
|
+
parts.push("- Does the project have a /project:status command with live git output?");
|
|
1214
|
+
parts.push("- Is there a /project:fix command for issue-driven development?");
|
|
1083
1215
|
if (profile.claudeMdLineCount > 200) {
|
|
1084
1216
|
parts.push(`- CLAUDE.md is ${profile.claudeMdLineCount} lines \u2014 needs aggressive trimming`);
|
|
1085
1217
|
}
|
|
@@ -1136,6 +1268,9 @@ var optimizeCommand = new Command6("optimize").description("Scan an existing pro
|
|
|
1136
1268
|
if (profile.mcpServerCount === 0 && profile.dependencies.length > 0) issues.push("No MCP servers configured");
|
|
1137
1269
|
if (profile.hasTests && !profile.existingCommands.includes("test")) issues.push("Has tests but no /project:test command");
|
|
1138
1270
|
if (!profile.existingCommands.includes("tasks")) issues.push("Missing /project:tasks command");
|
|
1271
|
+
if (!profile.existingSettings?.hooks) issues.push("No hooks configured \u2014 missing destructive command blocking");
|
|
1272
|
+
const scopedRules = profile.existingRules.filter((r) => r !== "security" && r !== "continuity");
|
|
1273
|
+
if (profile.hasSrc && scopedRules.length === 0) issues.push("No path-scoped rules \u2014 consider adding api.md, testing.md, or frontend.md rules");
|
|
1139
1274
|
if (issues.length > 0) {
|
|
1140
1275
|
console.log(chalk6.yellow("\n Issues Found:\n"));
|
|
1141
1276
|
for (const issue of issues) {
|
|
@@ -1244,7 +1379,7 @@ var optimizeCommand = new Command6("optimize").description("Scan an existing pro
|
|
|
1244
1379
|
var program = new Command7();
|
|
1245
1380
|
program.name("kairn").description(
|
|
1246
1381
|
"Compile natural language intent into optimized Claude Code environments"
|
|
1247
|
-
).version("1.
|
|
1382
|
+
).version("1.3.0");
|
|
1248
1383
|
program.addCommand(initCommand);
|
|
1249
1384
|
program.addCommand(describeCommand);
|
|
1250
1385
|
program.addCommand(optimizeCommand);
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/cli.ts","../src/commands/init.ts","../src/config.ts","../src/commands/describe.ts","../src/compiler/compile.ts","../src/compiler/prompt.ts","../src/adapter/claude-code.ts","../src/commands/list.ts","../src/commands/activate.ts","../src/commands/update-registry.ts","../src/commands/optimize.ts","../src/scanner/scan.ts"],"sourcesContent":["import { Command } from \"commander\";\nimport { initCommand } from \"./commands/init.js\";\nimport { describeCommand } from \"./commands/describe.js\";\nimport { listCommand } from \"./commands/list.js\";\nimport { activateCommand } from \"./commands/activate.js\";\nimport { updateRegistryCommand } from \"./commands/update-registry.js\";\nimport { optimizeCommand } from \"./commands/optimize.js\";\n\nconst program = new Command();\n\nprogram\n .name(\"kairn\")\n .description(\n \"Compile natural language intent into optimized Claude Code environments\"\n )\n .version(\"1.0.0\");\n\nprogram.addCommand(initCommand);\nprogram.addCommand(describeCommand);\nprogram.addCommand(optimizeCommand);\nprogram.addCommand(listCommand);\nprogram.addCommand(activateCommand);\nprogram.addCommand(updateRegistryCommand);\n\nprogram.parse();\n","import { Command } from \"commander\";\nimport { password, select } from \"@inquirer/prompts\";\nimport chalk from \"chalk\";\nimport Anthropic from \"@anthropic-ai/sdk\";\nimport OpenAI from \"openai\";\nimport { execFileSync } from \"child_process\";\nimport { loadConfig, saveConfig, getConfigPath } from \"../config.js\";\nimport type { KairnConfig, LLMProvider } from \"../types.js\";\n\nconst PROVIDER_MODELS: Record<LLMProvider, { name: string; models: { name: string; value: string }[] }> = {\n anthropic: {\n name: \"Anthropic\",\n models: [\n { name: \"Claude Sonnet 4.6 (recommended — fast, smart)\", value: \"claude-sonnet-4-6\" },\n { name: \"Claude Opus 4.6 (highest quality)\", value: \"claude-opus-4-6\" },\n { name: \"Claude Haiku 4.5 (fastest, cheapest)\", value: \"claude-haiku-4-5-20251001\" },\n ],\n },\n openai: {\n name: \"OpenAI\",\n models: [\n { name: \"GPT-4o (recommended)\", value: \"gpt-4o\" },\n { name: \"GPT-4o mini (faster, cheaper)\", value: \"gpt-4o-mini\" },\n { name: \"o3 (reasoning)\", value: \"o3\" },\n ],\n },\n google: {\n name: \"Google Gemini\",\n models: [\n { name: \"Gemini 2.5 Flash (recommended)\", value: \"gemini-2.5-flash-preview-05-20\" },\n { name: \"Gemini 2.5 Pro (highest quality)\", value: \"gemini-2.5-pro-preview-05-06\" },\n ],\n },\n};\n\nasync function verifyKey(provider: LLMProvider, apiKey: string, model: string): Promise<boolean> {\n try {\n if (provider === \"anthropic\") {\n const client = new Anthropic({ apiKey });\n await client.messages.create({\n model: \"claude-haiku-4-5-20251001\",\n max_tokens: 10,\n messages: [{ role: \"user\", content: \"ping\" }],\n });\n return true;\n } else if (provider === \"openai\") {\n const client = new OpenAI({ apiKey });\n await client.chat.completions.create({\n model: \"gpt-4o-mini\",\n max_tokens: 10,\n messages: [{ role: \"user\", content: \"ping\" }],\n });\n return true;\n } else if (provider === \"google\") {\n // Google uses OpenAI-compatible API\n const client = new OpenAI({\n apiKey,\n baseURL: \"https://generativelanguage.googleapis.com/v1beta/openai/\",\n });\n await client.chat.completions.create({\n model: \"gemini-2.5-flash-preview-05-20\",\n max_tokens: 10,\n messages: [{ role: \"user\", content: \"ping\" }],\n });\n return true;\n }\n return false;\n } catch {\n return false;\n }\n}\n\nfunction detectClaudeCode(): boolean {\n try {\n execFileSync(\"which\", [\"claude\"], { stdio: \"ignore\" });\n return true;\n } catch {\n return false;\n }\n}\n\nexport const initCommand = new Command(\"init\")\n .description(\"Set up Kairn with your API key\")\n .action(async () => {\n console.log(chalk.cyan(\"\\n Kairn Setup\\n\"));\n\n const existing = await loadConfig();\n if (existing) {\n console.log(\n chalk.yellow(\" Config already exists at \") +\n chalk.dim(getConfigPath())\n );\n console.log(chalk.yellow(\" Running setup will overwrite it.\\n\"));\n }\n\n const provider = await select<LLMProvider>({\n message: \"LLM provider\",\n choices: [\n { name: \"Anthropic (Claude) — recommended\", value: \"anthropic\" as LLMProvider },\n { name: \"OpenAI (GPT)\", value: \"openai\" as LLMProvider },\n { name: \"Google (Gemini)\", value: \"google\" as LLMProvider },\n ],\n });\n\n const providerInfo = PROVIDER_MODELS[provider];\n\n const model = await select({\n message: \"Compilation model\",\n choices: providerInfo.models,\n });\n\n const apiKey = await password({\n message: `${providerInfo.name} API key`,\n mask: \"*\",\n });\n\n if (!apiKey) {\n console.log(chalk.red(\"\\n No API key provided. Aborting.\"));\n process.exit(1);\n }\n\n console.log(chalk.dim(\"\\n Verifying API key...\"));\n const valid = await verifyKey(provider, apiKey, model);\n\n if (!valid) {\n console.log(\n chalk.red(\" Invalid API key. Check your key and try again.\")\n );\n process.exit(1);\n }\n\n console.log(chalk.green(\" ✓ API key verified\"));\n\n const config: KairnConfig = {\n provider,\n api_key: apiKey,\n model,\n default_runtime: \"claude-code\",\n created_at: new Date().toISOString(),\n };\n\n await saveConfig(config);\n console.log(\n chalk.green(\" ✓ Config saved to \") + chalk.dim(getConfigPath())\n );\n console.log(\n chalk.dim(` ✓ Provider: ${providerInfo.name}, Model: ${model}`)\n );\n\n const hasClaude = detectClaudeCode();\n if (hasClaude) {\n console.log(chalk.green(\" ✓ Claude Code detected\"));\n } else {\n console.log(\n chalk.yellow(\n \" ⚠ Claude Code not found. Install it: npm install -g @anthropic-ai/claude-code\"\n )\n );\n }\n\n console.log(\n chalk.cyan(\"\\n Ready! Run \") +\n chalk.bold(\"kairn describe\") +\n chalk.cyan(\" to create your first environment.\\n\")\n );\n });\n","import fs from \"fs/promises\";\nimport path from \"path\";\nimport os from \"os\";\nimport type { KairnConfig } from \"./types.js\";\n\nconst KAIRN_DIR = path.join(os.homedir(), \".kairn\");\nconst CONFIG_PATH = path.join(KAIRN_DIR, \"config.json\");\nconst ENVS_DIR = path.join(KAIRN_DIR, \"envs\");\n\nexport function getKairnDir(): string {\n return KAIRN_DIR;\n}\n\nexport function getConfigPath(): string {\n return CONFIG_PATH;\n}\n\nexport function getEnvsDir(): string {\n return ENVS_DIR;\n}\n\nexport async function ensureDirs(): Promise<void> {\n await fs.mkdir(KAIRN_DIR, { recursive: true });\n await fs.mkdir(ENVS_DIR, { recursive: true });\n}\n\nexport async function loadConfig(): Promise<KairnConfig | null> {\n try {\n const data = await fs.readFile(CONFIG_PATH, \"utf-8\");\n const raw = JSON.parse(data) as Record<string, unknown>;\n\n // Handle old config format (v1.0.0: anthropic_api_key)\n if (raw.anthropic_api_key && !raw.provider) {\n return {\n provider: \"anthropic\",\n api_key: raw.anthropic_api_key as string,\n model: \"claude-sonnet-4-6\",\n default_runtime: \"claude-code\",\n created_at: (raw.created_at as string) || new Date().toISOString(),\n };\n }\n\n return raw as unknown as KairnConfig;\n } catch {\n return null;\n }\n}\n\nexport async function saveConfig(config: KairnConfig): Promise<void> {\n await ensureDirs();\n await fs.writeFile(CONFIG_PATH, JSON.stringify(config, null, 2), \"utf-8\");\n}\n","import { Command } from \"commander\";\nimport { input, confirm } from \"@inquirer/prompts\";\nimport chalk from \"chalk\";\nimport fs from \"fs/promises\";\nimport path from \"path\";\nimport { loadConfig } from \"../config.js\";\nimport { compile } from \"../compiler/compile.js\";\nimport { writeEnvironment, summarizeSpec } from \"../adapter/claude-code.js\";\nimport { fileURLToPath } from \"url\";\nimport type { RegistryTool } from \"../types.js\";\n\nasync function loadRegistry(): Promise<RegistryTool[]> {\n const __filename = fileURLToPath(import.meta.url);\n const __dirname = path.dirname(__filename);\n const candidates = [\n path.resolve(__dirname, \"../registry/tools.json\"),\n path.resolve(__dirname, \"../src/registry/tools.json\"),\n path.resolve(__dirname, \"../../src/registry/tools.json\"),\n ];\n for (const candidate of candidates) {\n try {\n const data = await fs.readFile(candidate, \"utf-8\");\n return JSON.parse(data) as RegistryTool[];\n } catch {\n continue;\n }\n }\n throw new Error(\"Could not find tools.json registry\");\n}\n\nexport const describeCommand = new Command(\"describe\")\n .description(\"Describe your workflow and generate a Claude Code environment\")\n .argument(\"[intent]\", \"What you want your agent to do\")\n .option(\"-y, --yes\", \"Skip confirmation prompt\")\n .action(async (intentArg: string | undefined, options: { yes?: boolean }) => {\n // 1. Check config\n const config = await loadConfig();\n if (!config) {\n console.log(\n chalk.red(\"\\n No config found. Run \") +\n chalk.bold(\"kairn init\") +\n chalk.red(\" first.\\n\")\n );\n process.exit(1);\n }\n\n // 2. Get intent\n const intent =\n intentArg ||\n (await input({\n message: \"What do you want your agent to do?\",\n }));\n\n if (!intent.trim()) {\n console.log(chalk.red(\"\\n No description provided. Aborting.\\n\"));\n process.exit(1);\n }\n\n // 3. Compile with progress\n console.log(\"\");\n let spec;\n try {\n spec = await compile(intent, (msg) => {\n process.stdout.write(`\\r ${chalk.dim(msg)} `);\n });\n process.stdout.write(\"\\r \\r\");\n } catch (err) {\n process.stdout.write(\"\\r \\r\");\n const msg = err instanceof Error ? err.message : String(err);\n console.log(chalk.red(`\\n Compilation failed: ${msg}\\n`));\n process.exit(1);\n }\n\n // 4. Show results\n const registry = await loadRegistry();\n const summary = summarizeSpec(spec, registry);\n\n console.log(chalk.green(\"\\n ✓ Environment compiled\\n\"));\n console.log(chalk.cyan(\" Name: \") + spec.name);\n console.log(chalk.cyan(\" Description: \") + spec.description);\n console.log(chalk.cyan(\" Tools: \") + summary.toolCount);\n console.log(chalk.cyan(\" Commands: \") + summary.commandCount);\n console.log(chalk.cyan(\" Rules: \") + summary.ruleCount);\n console.log(chalk.cyan(\" Skills: \") + summary.skillCount);\n console.log(chalk.cyan(\" Agents: \") + summary.agentCount);\n\n if (spec.tools.length > 0) {\n console.log(chalk.dim(\"\\n Selected tools:\"));\n for (const tool of spec.tools) {\n const regTool = registry.find((t) => t.id === tool.tool_id);\n const name = regTool?.name || tool.tool_id;\n console.log(chalk.dim(` - ${name}: ${tool.reason}`));\n }\n }\n\n if (summary.pluginCommands.length > 0) {\n console.log(chalk.yellow(\"\\n Plugins to install manually:\"));\n for (const cmd of summary.pluginCommands) {\n console.log(chalk.yellow(` ${cmd}`));\n }\n }\n\n // 5. Confirm\n console.log(\"\");\n const proceed = options.yes || await confirm({\n message: \"Generate environment in current directory?\",\n default: true,\n });\n\n if (!proceed) {\n console.log(chalk.dim(\"\\n Aborted. Environment saved to ~/.kairn/envs/\\n\"));\n return;\n }\n\n // 6. Write\n const targetDir = process.cwd();\n const written = await writeEnvironment(spec, targetDir);\n\n console.log(chalk.green(\"\\n ✓ Environment written\\n\"));\n for (const file of written) {\n console.log(chalk.dim(` ${file}`));\n }\n\n if (summary.envSetup.length > 0) {\n console.log(chalk.yellow(\"\\n API keys needed (set these environment variables):\\n\"));\n const seen = new Set<string>();\n for (const env of summary.envSetup) {\n if (seen.has(env.envVar)) continue;\n seen.add(env.envVar);\n console.log(chalk.bold(` export ${env.envVar}=\"your-key-here\"`));\n console.log(chalk.dim(` ${env.description}`));\n if (env.signupUrl) {\n console.log(chalk.dim(` Get one at: ${env.signupUrl}`));\n }\n console.log(\"\");\n }\n }\n\n if (summary.pluginCommands.length > 0) {\n console.log(chalk.yellow(\" Install plugins by running these in Claude Code:\"));\n for (const cmd of summary.pluginCommands) {\n console.log(chalk.bold(` ${cmd}`));\n }\n }\n\n console.log(\n chalk.cyan(\"\\n Ready! Run \") +\n chalk.bold(\"claude\") +\n chalk.cyan(\" to start.\\n\")\n );\n });\n","import fs from \"fs/promises\";\nimport path from \"path\";\nimport { fileURLToPath } from \"url\";\nimport crypto from \"crypto\";\nimport Anthropic from \"@anthropic-ai/sdk\";\nimport OpenAI from \"openai\";\nimport { loadConfig, getEnvsDir, ensureDirs } from \"../config.js\";\nimport { SYSTEM_PROMPT } from \"./prompt.js\";\nimport type { EnvironmentSpec, RegistryTool, KairnConfig } from \"../types.js\";\n\nasync function loadRegistry(): Promise<RegistryTool[]> {\n const __filename = fileURLToPath(import.meta.url);\n const __dirname = path.dirname(__filename);\n const candidates = [\n path.resolve(__dirname, \"../registry/tools.json\"),\n path.resolve(__dirname, \"../src/registry/tools.json\"),\n path.resolve(__dirname, \"../../src/registry/tools.json\"),\n ];\n for (const candidate of candidates) {\n try {\n const data = await fs.readFile(candidate, \"utf-8\");\n return JSON.parse(data) as RegistryTool[];\n } catch {\n continue;\n }\n }\n throw new Error(\"Could not find tools.json registry\");\n}\n\nfunction buildUserMessage(intent: string, registry: RegistryTool[]): string {\n const registrySummary = registry\n .map(\n (t) =>\n `- ${t.id} (${t.type}, tier ${t.tier}, auth: ${t.auth}): ${t.description} [best_for: ${t.best_for.join(\", \")}]`\n )\n .join(\"\\n\");\n\n return `## User Intent\\n\\n${intent}\\n\\n## Available Tool Registry\\n\\n${registrySummary}\\n\\nGenerate the EnvironmentSpec JSON now.`;\n}\n\nfunction parseSpecResponse(text: string): Omit<EnvironmentSpec, \"id\" | \"intent\" | \"created_at\"> {\n let cleaned = text.trim();\n // Strip markdown code fences\n if (cleaned.startsWith(\"```\")) {\n cleaned = cleaned.replace(/^```(?:json)?\\n?/, \"\").replace(/\\n?```$/, \"\");\n }\n // Try to extract JSON if there's surrounding text\n const jsonMatch = cleaned.match(/\\{[\\s\\S]*\\}/);\n if (!jsonMatch) {\n throw new Error(\n \"LLM response did not contain valid JSON. Try again or use a different model.\"\n );\n }\n try {\n return JSON.parse(jsonMatch[0]);\n } catch (err) {\n throw new Error(\n `Failed to parse LLM response as JSON: ${err instanceof Error ? err.message : String(err)}\\n` +\n `Response started with: ${cleaned.slice(0, 200)}...`\n );\n }\n}\n\nfunction classifyError(err: unknown, provider: string): string {\n const msg = err instanceof Error ? err.message : String(err);\n const status = (err as { status?: number })?.status;\n const code = (err as { code?: string })?.code;\n\n // Network errors\n if (code === \"ECONNREFUSED\" || code === \"ENOTFOUND\" || code === \"ETIMEDOUT\") {\n return `Network error: could not reach ${provider} API. Check your internet connection.`;\n }\n\n // Auth errors\n if (status === 401 || msg.includes(\"invalid\") && msg.includes(\"key\")) {\n return `Invalid API key for ${provider}. Run \\`kairn init\\` to reconfigure.`;\n }\n if (status === 403) {\n return `Access denied by ${provider}. Your API key may lack permissions for this model.`;\n }\n\n // Rate limiting\n if (status === 429 || msg.includes(\"rate limit\") || msg.includes(\"quota\")) {\n return `Rate limited by ${provider}. Wait a moment and try again, or switch to a cheaper model with \\`kairn init\\`.`;\n }\n\n // Model errors\n if (status === 404 || msg.includes(\"not found\") || msg.includes(\"does not exist\")) {\n return `Model not found on ${provider}. Run \\`kairn init\\` to select a valid model.`;\n }\n\n // Overloaded\n if (status === 529 || status === 503 || msg.includes(\"overloaded\")) {\n return `${provider} is temporarily overloaded. Try again in a few seconds.`;\n }\n\n // Token/context limit\n if (msg.includes(\"token\") && (msg.includes(\"limit\") || msg.includes(\"exceed\"))) {\n return `Request too large for the selected model. Try a shorter workflow description.`;\n }\n\n // Billing\n if (msg.includes(\"billing\") || msg.includes(\"payment\") || msg.includes(\"insufficient\")) {\n return `Billing issue with your ${provider} account. Check your account dashboard.`;\n }\n\n // Fallback\n return `${provider} API error: ${msg}`;\n}\n\nasync function callLLM(config: KairnConfig, userMessage: string): Promise<string> {\n if (config.provider === \"anthropic\") {\n const client = new Anthropic({ apiKey: config.api_key });\n try {\n const response = await client.messages.create({\n model: config.model,\n max_tokens: 8192,\n system: SYSTEM_PROMPT,\n messages: [{ role: \"user\", content: userMessage }],\n });\n const textBlock = response.content.find((block) => block.type === \"text\");\n if (!textBlock || textBlock.type !== \"text\") {\n throw new Error(\"No text response from compiler LLM\");\n }\n return textBlock.text;\n } catch (err) {\n throw new Error(classifyError(err, \"Anthropic\"));\n }\n } else if (config.provider === \"openai\" || config.provider === \"google\") {\n const providerName = config.provider === \"google\" ? \"Google\" : \"OpenAI\";\n const clientOptions: { apiKey: string; baseURL?: string } = { apiKey: config.api_key };\n if (config.provider === \"google\") {\n clientOptions.baseURL = \"https://generativelanguage.googleapis.com/v1beta/openai/\";\n }\n const client = new OpenAI(clientOptions);\n try {\n const response = await client.chat.completions.create({\n model: config.model,\n max_tokens: 8192,\n messages: [\n { role: \"system\", content: SYSTEM_PROMPT },\n { role: \"user\", content: userMessage },\n ],\n });\n const text = response.choices[0]?.message?.content;\n if (!text) {\n throw new Error(\"No text response from compiler LLM\");\n }\n return text;\n } catch (err) {\n throw new Error(classifyError(err, providerName));\n }\n }\n throw new Error(`Unsupported provider: ${config.provider}. Run \\`kairn init\\` to reconfigure.`);\n}\n\nexport async function compile(\n intent: string,\n onProgress?: (msg: string) => void\n): Promise<EnvironmentSpec> {\n const config = await loadConfig();\n if (!config) {\n throw new Error(\"No config found. Run `kairn init` first.\");\n }\n\n onProgress?.(\"Loading tool registry...\");\n const registry = await loadRegistry();\n\n onProgress?.(`Compiling with ${config.provider} (${config.model})...`);\n const userMessage = buildUserMessage(intent, registry);\n const responseText = await callLLM(config, userMessage);\n\n onProgress?.(\"Parsing environment spec...\");\n const parsed = parseSpecResponse(responseText);\n\n const spec: EnvironmentSpec = {\n id: `env_${crypto.randomUUID()}`,\n intent,\n created_at: new Date().toISOString(),\n ...parsed,\n };\n\n // Save to ~/.kairn/envs/\n await ensureDirs();\n const envPath = path.join(getEnvsDir(), `${spec.id}.json`);\n await fs.writeFile(envPath, JSON.stringify(spec, null, 2), \"utf-8\");\n\n return spec;\n}\n","export const SYSTEM_PROMPT = `You are the Kairn environment compiler. Your job is to generate a minimal, optimal Claude Code agent environment from a user's natural language description of what they want their agent to do.\n\nYou will receive:\n1. The user's intent (what they want to build/do)\n2. A tool registry (available MCP servers, plugins, and hooks)\n\nYou must output a JSON object matching the EnvironmentSpec schema.\n\n## Core Principles\n\n- **Minimalism over completeness.** Fewer, well-chosen tools beat many generic ones. Each MCP server costs 500-2000 context tokens.\n- **Workflow-specific, not generic.** Every instruction, command, and rule must relate to the user's actual workflow.\n- **Concise CLAUDE.md.** Under 100 lines. No generic text like \"be helpful.\" Include build/test commands, reference docs/ and skills/.\n- **Security by default.** Always include deny rules for destructive commands and secret file access.\n\n## What You Must Always Include\n\n1. A concise, workflow-specific \\`claude_md\\` (the CLAUDE.md content)\n2. A \\`/project:help\\` command that explains the environment\n3. A \\`/project:tasks\\` command for task management via TODO.md\n4. A \\`docs/TODO.md\\` file for continuity\n5. A \\`docs/DECISIONS.md\\` file for architectural decisions\n6. A \\`docs/LEARNINGS.md\\` file for non-obvious discoveries\n7. A \\`rules/continuity.md\\` rule encouraging updates to DECISIONS.md and LEARNINGS.md\n8. A \\`rules/security.md\\` rule with essential security instructions\n9. settings.json with deny rules for \\`rm -rf\\`, \\`curl|sh\\`, reading \\`.env\\` and \\`secrets/\\`\n\n## Tool Selection Rules\n\n- Only select tools directly relevant to the described workflow\n- Prefer free tools (auth: \"none\") when quality is comparable\n- Tier 1 tools (Context7, Sequential Thinking, security-guidance) should be included in most environments\n- For tools requiring API keys (auth: \"api_key\"), use \\${ENV_VAR} syntax — never hardcode keys\n- Maximum 6-8 MCP servers to avoid context bloat\n- Include a \\`reason\\` for each selected tool explaining why it fits this workflow\n\n## For Code Projects, Additionally Include\n\n- \\`/project:plan\\` command (plan before coding)\n- \\`/project:review\\` command (review changes)\n- \\`/project:test\\` command (run and fix tests)\n- \\`/project:commit\\` command (conventional commits)\n- A TDD skill if testing is relevant\n- A reviewer agent (read-only, Sonnet model)\n\n## For Research Projects, Additionally Include\n\n- \\`/project:research\\` command (deep research on a topic)\n- \\`/project:summarize\\` command (summarize findings)\n- A research-synthesis skill\n- A researcher agent\n\n## For Content/Writing Projects, Additionally Include\n\n- \\`/project:draft\\` command (write first draft)\n- \\`/project:edit\\` command (review and improve writing)\n- A writing-workflow skill\n\n## Output Schema\n\nReturn ONLY valid JSON matching this structure:\n\n\\`\\`\\`json\n{\n \"name\": \"short-kebab-case-name\",\n \"description\": \"One-line description of the environment\",\n \"tools\": [\n { \"tool_id\": \"id-from-registry\", \"reason\": \"why this tool fits\" }\n ],\n \"harness\": {\n \"claude_md\": \"The full CLAUDE.md content (under 100 lines)\",\n \"settings\": {\n \"permissions\": {\n \"allow\": [\"Bash(npm run *)\", \"Read\", \"Write\", \"Edit\"],\n \"deny\": [\"Bash(rm -rf *)\", \"Bash(curl * | sh)\", \"Read(./.env)\", \"Read(./secrets/**)\"]\n }\n },\n \"mcp_config\": {\n \"server-name\": { \"command\": \"npx\", \"args\": [\"...\"], \"env\": {} }\n },\n \"commands\": {\n \"help\": \"markdown content for /project:help\",\n \"tasks\": \"markdown content for /project:tasks\"\n },\n \"rules\": {\n \"continuity\": \"markdown content for continuity rule\",\n \"security\": \"markdown content for security rule\"\n },\n \"skills\": {\n \"skill-name/SKILL\": \"markdown content with YAML frontmatter\"\n },\n \"agents\": {\n \"agent-name\": \"markdown content with YAML frontmatter\"\n },\n \"docs\": {\n \"TODO\": \"# TODO\\\\n\\\\n- [ ] First task based on workflow\",\n \"DECISIONS\": \"# Decisions\\\\n\\\\nArchitectural decisions for this project.\",\n \"LEARNINGS\": \"# Learnings\\\\n\\\\nNon-obvious discoveries and gotchas.\"\n }\n }\n}\n\\`\\`\\`\n\nDo not include any text outside the JSON object. Do not wrap in markdown code fences.`;\n","import fs from \"fs/promises\";\nimport path from \"path\";\nimport type { EnvironmentSpec, RegistryTool } from \"../types.js\";\n\nasync function writeFile(filePath: string, content: string): Promise<void> {\n await fs.mkdir(path.dirname(filePath), { recursive: true });\n await fs.writeFile(filePath, content, \"utf-8\");\n}\n\nexport async function writeEnvironment(\n spec: EnvironmentSpec,\n targetDir: string\n): Promise<string[]> {\n const claudeDir = path.join(targetDir, \".claude\");\n const written: string[] = [];\n\n // 1. CLAUDE.md\n if (spec.harness.claude_md) {\n const p = path.join(claudeDir, \"CLAUDE.md\");\n await writeFile(p, spec.harness.claude_md);\n written.push(\".claude/CLAUDE.md\");\n }\n\n // 2. settings.json\n if (spec.harness.settings && Object.keys(spec.harness.settings).length > 0) {\n const p = path.join(claudeDir, \"settings.json\");\n await writeFile(p, JSON.stringify(spec.harness.settings, null, 2));\n written.push(\".claude/settings.json\");\n }\n\n // 3. .mcp.json (project-scoped, goes in project root)\n if (\n spec.harness.mcp_config &&\n Object.keys(spec.harness.mcp_config).length > 0\n ) {\n const p = path.join(targetDir, \".mcp.json\");\n const mcpContent = { mcpServers: spec.harness.mcp_config };\n await writeFile(p, JSON.stringify(mcpContent, null, 2));\n written.push(\".mcp.json\");\n }\n\n // 4. Commands\n if (spec.harness.commands) {\n for (const [name, content] of Object.entries(spec.harness.commands)) {\n const p = path.join(claudeDir, \"commands\", `${name}.md`);\n await writeFile(p, content);\n written.push(`.claude/commands/${name}.md`);\n }\n }\n\n // 5. Rules\n if (spec.harness.rules) {\n for (const [name, content] of Object.entries(spec.harness.rules)) {\n const p = path.join(claudeDir, \"rules\", `${name}.md`);\n await writeFile(p, content);\n written.push(`.claude/rules/${name}.md`);\n }\n }\n\n // 6. Skills\n if (spec.harness.skills) {\n for (const [skillPath, content] of Object.entries(spec.harness.skills)) {\n const p = path.join(claudeDir, \"skills\", `${skillPath}.md`);\n await writeFile(p, content);\n written.push(`.claude/skills/${skillPath}.md`);\n }\n }\n\n // 7. Agents\n if (spec.harness.agents) {\n for (const [name, content] of Object.entries(spec.harness.agents)) {\n const p = path.join(claudeDir, \"agents\", `${name}.md`);\n await writeFile(p, content);\n written.push(`.claude/agents/${name}.md`);\n }\n }\n\n // 8. Docs\n if (spec.harness.docs) {\n for (const [name, content] of Object.entries(spec.harness.docs)) {\n const p = path.join(claudeDir, \"docs\", `${name}.md`);\n await writeFile(p, content);\n written.push(`.claude/docs/${name}.md`);\n }\n }\n\n return written;\n}\n\nexport interface EnvSetupInfo {\n toolName: string;\n envVar: string;\n description: string;\n signupUrl?: string;\n}\n\nexport function summarizeSpec(\n spec: EnvironmentSpec,\n registry: RegistryTool[]\n): {\n toolCount: number;\n commandCount: number;\n ruleCount: number;\n skillCount: number;\n agentCount: number;\n pluginCommands: string[];\n envSetup: EnvSetupInfo[];\n} {\n const pluginCommands: string[] = [];\n const envSetup: EnvSetupInfo[] = [];\n\n for (const selected of spec.tools) {\n const tool = registry.find((t) => t.id === selected.tool_id);\n if (!tool) continue;\n\n if (tool.install.plugin_command) {\n pluginCommands.push(tool.install.plugin_command);\n }\n\n if (tool.env_vars) {\n for (const ev of tool.env_vars) {\n envSetup.push({\n toolName: tool.name,\n envVar: ev.name,\n description: ev.description,\n signupUrl: tool.signup_url,\n });\n }\n }\n }\n\n return {\n toolCount: spec.tools.length,\n commandCount: Object.keys(spec.harness.commands || {}).length,\n ruleCount: Object.keys(spec.harness.rules || {}).length,\n skillCount: Object.keys(spec.harness.skills || {}).length,\n agentCount: Object.keys(spec.harness.agents || {}).length,\n pluginCommands,\n envSetup,\n };\n}\n","import { Command } from \"commander\";\nimport chalk from \"chalk\";\nimport fs from \"fs/promises\";\nimport path from \"path\";\nimport { getEnvsDir } from \"../config.js\";\nimport type { EnvironmentSpec } from \"../types.js\";\n\nexport const listCommand = new Command(\"list\")\n .description(\"Show saved environments\")\n .action(async () => {\n const envsDir = getEnvsDir();\n\n let files: string[];\n try {\n files = await fs.readdir(envsDir);\n } catch {\n console.log(chalk.dim(\"\\n No environments yet. Run \") +\n chalk.bold(\"kairn describe\") +\n chalk.dim(\" to create one.\\n\"));\n return;\n }\n\n const jsonFiles = files.filter((f) => f.endsWith(\".json\"));\n\n if (jsonFiles.length === 0) {\n console.log(chalk.dim(\"\\n No environments yet. Run \") +\n chalk.bold(\"kairn describe\") +\n chalk.dim(\" to create one.\\n\"));\n return;\n }\n\n console.log(chalk.cyan(\"\\n Saved Environments\\n\"));\n\n for (const file of jsonFiles) {\n try {\n const data = await fs.readFile(path.join(envsDir, file), \"utf-8\");\n const spec = JSON.parse(data) as EnvironmentSpec;\n const date = new Date(spec.created_at).toLocaleDateString();\n const toolCount = spec.tools?.length ?? 0;\n\n console.log(chalk.bold(` ${spec.name}`));\n console.log(chalk.dim(` ${spec.description}`));\n console.log(\n chalk.dim(` ${date} · ${toolCount} tools · ${spec.id}`)\n );\n console.log(\"\");\n } catch {\n // Skip malformed files\n }\n }\n });\n","import { Command } from \"commander\";\nimport chalk from \"chalk\";\nimport fs from \"fs/promises\";\nimport path from \"path\";\nimport { getEnvsDir } from \"../config.js\";\nimport { writeEnvironment } from \"../adapter/claude-code.js\";\nimport type { EnvironmentSpec } from \"../types.js\";\n\nexport const activateCommand = new Command(\"activate\")\n .description(\"Re-deploy a saved environment to the current directory\")\n .argument(\"<env_id>\", \"Environment ID (from kairn list)\")\n .action(async (envId: string) => {\n const envsDir = getEnvsDir();\n\n // Find the env file — accept full ID or partial match\n let files: string[];\n try {\n files = await fs.readdir(envsDir);\n } catch {\n console.log(chalk.red(\"\\n No saved environments found.\\n\"));\n process.exit(1);\n }\n\n const match = files.find(\n (f) => f === `${envId}.json` || f.startsWith(envId)\n );\n\n if (!match) {\n console.log(chalk.red(`\\n Environment \"${envId}\" not found.`));\n console.log(chalk.dim(\" Run kairn list to see saved environments.\\n\"));\n process.exit(1);\n }\n\n const data = await fs.readFile(path.join(envsDir, match), \"utf-8\");\n const spec = JSON.parse(data) as EnvironmentSpec;\n\n console.log(chalk.cyan(`\\n Activating: ${spec.name}`));\n console.log(chalk.dim(` ${spec.description}\\n`));\n\n const targetDir = process.cwd();\n const written = await writeEnvironment(spec, targetDir);\n\n console.log(chalk.green(\" ✓ Environment written\\n\"));\n for (const file of written) {\n console.log(chalk.dim(` ${file}`));\n }\n\n console.log(\n chalk.cyan(\"\\n Ready! Run \") +\n chalk.bold(\"claude\") +\n chalk.cyan(\" to start.\\n\")\n );\n });\n","import { Command } from \"commander\";\nimport chalk from \"chalk\";\nimport fs from \"fs/promises\";\nimport path from \"path\";\nimport { fileURLToPath } from \"url\";\n\nconst REGISTRY_URL =\n \"https://raw.githubusercontent.com/ashtonperlroth/kairn/main/src/registry/tools.json\";\n\nasync function getLocalRegistryPath(): Promise<string> {\n const __filename = fileURLToPath(import.meta.url);\n const __dirname = path.dirname(__filename);\n const candidates = [\n path.resolve(__dirname, \"../registry/tools.json\"),\n path.resolve(__dirname, \"../src/registry/tools.json\"),\n path.resolve(__dirname, \"../../src/registry/tools.json\"),\n ];\n for (const candidate of candidates) {\n try {\n await fs.access(candidate);\n return candidate;\n } catch {\n continue;\n }\n }\n throw new Error(\"Could not find local tools.json registry\");\n}\n\nexport const updateRegistryCommand = new Command(\"update-registry\")\n .description(\"Fetch the latest tool registry from GitHub\")\n .option(\"--url <url>\", \"Custom registry URL\")\n .action(async (options: { url?: string }) => {\n const url = options.url || REGISTRY_URL;\n\n console.log(chalk.dim(`\\n Fetching registry from ${url}...`));\n\n try {\n const response = await fetch(url);\n\n if (!response.ok) {\n console.log(\n chalk.red(` Failed to fetch registry: ${response.status} ${response.statusText}`)\n );\n console.log(\n chalk.dim(\" The remote registry may not be available yet.\")\n );\n console.log(\n chalk.dim(\" Your local registry is still active.\\n\")\n );\n return;\n }\n\n const text = await response.text();\n\n // Validate it's valid JSON and has the expected structure\n let tools: unknown[];\n try {\n tools = JSON.parse(text);\n if (!Array.isArray(tools)) throw new Error(\"Not an array\");\n if (tools.length === 0) throw new Error(\"Empty registry\");\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n console.log(chalk.red(` Invalid registry format: ${msg}\\n`));\n return;\n }\n\n const registryPath = await getLocalRegistryPath();\n\n // Back up existing registry\n const backupPath = registryPath + \".bak\";\n try {\n await fs.copyFile(registryPath, backupPath);\n } catch {\n // No existing file to back up\n }\n\n await fs.writeFile(registryPath, JSON.stringify(tools, null, 2), \"utf-8\");\n\n console.log(chalk.green(` ✓ Registry updated: ${tools.length} tools`));\n console.log(chalk.dim(` Saved to: ${registryPath}`));\n console.log(chalk.dim(` Backup: ${backupPath}\\n`));\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n console.log(chalk.red(` Network error: ${msg}`));\n console.log(chalk.dim(\" Your local registry is still active.\\n\"));\n }\n });\n","import { Command } from \"commander\";\nimport { input, confirm, checkbox } from \"@inquirer/prompts\";\nimport chalk from \"chalk\";\nimport fs from \"fs/promises\";\nimport path from \"path\";\nimport { fileURLToPath } from \"url\";\nimport { loadConfig } from \"../config.js\";\nimport { compile } from \"../compiler/compile.js\";\nimport { writeEnvironment, summarizeSpec } from \"../adapter/claude-code.js\";\nimport { scanProject } from \"../scanner/scan.js\";\nimport type { ProjectProfile } from \"../scanner/scan.js\";\nimport type { RegistryTool } from \"../types.js\";\n\nasync function loadRegistry(): Promise<RegistryTool[]> {\n const __filename = fileURLToPath(import.meta.url);\n const __dirname = path.dirname(__filename);\n const candidates = [\n path.resolve(__dirname, \"../registry/tools.json\"),\n path.resolve(__dirname, \"../src/registry/tools.json\"),\n path.resolve(__dirname, \"../../src/registry/tools.json\"),\n ];\n for (const candidate of candidates) {\n try {\n const data = await fs.readFile(candidate, \"utf-8\");\n return JSON.parse(data) as RegistryTool[];\n } catch {\n continue;\n }\n }\n throw new Error(\"Could not find tools.json registry\");\n}\n\nfunction buildProfileSummary(profile: ProjectProfile): string {\n const lines: string[] = [];\n lines.push(`Project: ${profile.name}`);\n if (profile.description) lines.push(`Description: ${profile.description}`);\n if (profile.language) lines.push(`Language: ${profile.language}`);\n if (profile.framework) lines.push(`Framework: ${profile.framework}`);\n if (profile.dependencies.length > 0) {\n lines.push(`Dependencies: ${profile.dependencies.join(\", \")}`);\n }\n if (profile.testCommand) lines.push(`Test command: ${profile.testCommand}`);\n if (profile.buildCommand) lines.push(`Build command: ${profile.buildCommand}`);\n if (profile.lintCommand) lines.push(`Lint command: ${profile.lintCommand}`);\n if (profile.hasDocker) lines.push(\"Has Docker configuration\");\n if (profile.hasCi) lines.push(\"Has CI/CD (GitHub Actions)\");\n if (profile.envKeys.length > 0) {\n lines.push(`Env keys needed: ${profile.envKeys.join(\", \")}`);\n }\n return lines.join(\"\\n\");\n}\n\nfunction buildAuditSummary(profile: ProjectProfile): string {\n const lines: string[] = [];\n lines.push(`\\nExisting .claude/ harness found:`);\n lines.push(` CLAUDE.md: ${profile.claudeMdLineCount} lines${profile.claudeMdLineCount > 200 ? \" (⚠ over 200 — may degrade adherence)\" : \"\"}`);\n lines.push(` MCP servers: ${profile.mcpServerCount}`);\n lines.push(` Commands: ${profile.existingCommands.length > 0 ? profile.existingCommands.map(c => `/project:${c}`).join(\", \") : \"none\"}`);\n lines.push(` Rules: ${profile.existingRules.length > 0 ? profile.existingRules.join(\", \") : \"none\"}`);\n lines.push(` Skills: ${profile.existingSkills.length > 0 ? profile.existingSkills.join(\", \") : \"none\"}`);\n lines.push(` Agents: ${profile.existingAgents.length > 0 ? profile.existingAgents.join(\", \") : \"none\"}`);\n return lines.join(\"\\n\");\n}\n\nfunction buildOptimizeIntent(profile: ProjectProfile): string {\n const parts: string[] = [];\n\n parts.push(\"## Project Profile (scanned from actual codebase)\\n\");\n parts.push(buildProfileSummary(profile));\n\n if (profile.hasClaudeDir) {\n parts.push(buildAuditSummary(profile));\n\n if (profile.existingClaudeMd) {\n parts.push(`\\n## Existing CLAUDE.md Content\\n\\n${profile.existingClaudeMd}`);\n }\n\n parts.push(`\\n## Task\\n`);\n parts.push(\"Analyze this existing Claude Code environment and generate an OPTIMIZED version.\");\n parts.push(\"Preserve what works. Fix what's wrong. Add what's missing. Remove what's bloat.\");\n parts.push(\"Key optimizations to consider:\");\n parts.push(\"- Is CLAUDE.md under 100 lines? If not, move detail to rules/ or docs/\");\n parts.push(\"- Are the right MCP servers selected for these dependencies?\");\n parts.push(\"- Are there missing slash commands (help, tasks, plan, test, commit)?\");\n parts.push(\"- Are security rules present?\");\n parts.push(\"- Is there a continuity rule for session memory?\");\n parts.push(\"- Are there unnecessary MCP servers adding context bloat?\");\n if (profile.claudeMdLineCount > 200) {\n parts.push(`- CLAUDE.md is ${profile.claudeMdLineCount} lines — needs aggressive trimming`);\n }\n if (!profile.existingCommands.includes(\"help\")) {\n parts.push(\"- Missing /project:help command\");\n }\n if (!profile.existingRules.includes(\"security\")) {\n parts.push(\"- Missing security rules\");\n }\n } else {\n parts.push(`\\n## Task\\n`);\n parts.push(\"Generate an optimal Claude Code environment for this existing project.\");\n parts.push(\"Use the scanned project profile — this is a real codebase, not a description.\");\n parts.push(\"The environment should match the actual tech stack, dependencies, and workflows.\");\n }\n\n return parts.join(\"\\n\");\n}\n\nexport const optimizeCommand = new Command(\"optimize\")\n .description(\"Scan an existing project and generate or optimize its Claude Code environment\")\n .option(\"-y, --yes\", \"Skip confirmation prompts\")\n .option(\"--audit-only\", \"Only audit the existing harness, don't generate changes\")\n .action(async (options: { yes?: boolean; auditOnly?: boolean }) => {\n const config = await loadConfig();\n if (!config) {\n console.log(\n chalk.red(\"\\n No config found. Run \") +\n chalk.bold(\"kairn init\") +\n chalk.red(\" first.\\n\")\n );\n process.exit(1);\n }\n\n const targetDir = process.cwd();\n\n // 1. Scan\n console.log(chalk.dim(\"\\n Scanning project...\"));\n const profile = await scanProject(targetDir);\n\n // 2. Show profile\n console.log(chalk.cyan(\"\\n Project Profile\\n\"));\n if (profile.language) console.log(chalk.dim(` Language: ${profile.language}`));\n if (profile.framework) console.log(chalk.dim(` Framework: ${profile.framework}`));\n console.log(chalk.dim(` Dependencies: ${profile.dependencies.length}`));\n if (profile.testCommand) console.log(chalk.dim(` Tests: ${profile.testCommand}`));\n if (profile.buildCommand) console.log(chalk.dim(` Build: ${profile.buildCommand}`));\n if (profile.hasDocker) console.log(chalk.dim(\" Docker: yes\"));\n if (profile.hasCi) console.log(chalk.dim(\" CI/CD: yes\"));\n if (profile.envKeys.length > 0) console.log(chalk.dim(` Env keys: ${profile.envKeys.join(\", \")}`));\n\n // 3. Audit existing harness\n if (profile.hasClaudeDir) {\n console.log(chalk.yellow(\"\\n Existing .claude/ harness detected\\n\"));\n console.log(chalk.dim(` CLAUDE.md: ${profile.claudeMdLineCount} lines${profile.claudeMdLineCount > 200 ? chalk.yellow(\" ⚠ bloated\") : chalk.green(\" ✓\")}`));\n console.log(chalk.dim(` MCP servers: ${profile.mcpServerCount}`));\n console.log(chalk.dim(` Commands: ${profile.existingCommands.length > 0 ? profile.existingCommands.map(c => c).join(\", \") : \"none\"}`));\n console.log(chalk.dim(` Rules: ${profile.existingRules.length > 0 ? profile.existingRules.join(\", \") : \"none\"}`));\n console.log(chalk.dim(` Skills: ${profile.existingSkills.length > 0 ? profile.existingSkills.join(\", \") : \"none\"}`));\n console.log(chalk.dim(` Agents: ${profile.existingAgents.length > 0 ? profile.existingAgents.join(\", \") : \"none\"}`));\n\n // Quick audit checks\n const issues: string[] = [];\n if (profile.claudeMdLineCount > 200) issues.push(\"CLAUDE.md over 200 lines — move detail to rules/ or docs/\");\n if (!profile.existingCommands.includes(\"help\")) issues.push(\"Missing /project:help command\");\n if (!profile.existingRules.includes(\"security\")) issues.push(\"Missing security rules\");\n if (!profile.existingRules.includes(\"continuity\")) issues.push(\"Missing continuity rule for session memory\");\n if (profile.mcpServerCount > 8) issues.push(`${profile.mcpServerCount} MCP servers — may cause context bloat`);\n if (profile.mcpServerCount === 0 && profile.dependencies.length > 0) issues.push(\"No MCP servers configured\");\n if (profile.hasTests && !profile.existingCommands.includes(\"test\")) issues.push(\"Has tests but no /project:test command\");\n if (!profile.existingCommands.includes(\"tasks\")) issues.push(\"Missing /project:tasks command\");\n\n if (issues.length > 0) {\n console.log(chalk.yellow(\"\\n Issues Found:\\n\"));\n for (const issue of issues) {\n console.log(chalk.yellow(` ⚠ ${issue}`));\n }\n } else {\n console.log(chalk.green(\"\\n ✓ No obvious issues found\"));\n }\n\n if (options.auditOnly) {\n console.log(chalk.dim(\"\\n Audit complete. Run without --audit-only to generate optimized environment.\\n\"));\n return;\n }\n\n // Ask before overwriting\n if (!options.yes) {\n console.log(\"\");\n const proceed = await confirm({\n message: \"Generate optimized environment? This will overwrite existing .claude/ files.\",\n default: false,\n });\n if (!proceed) {\n console.log(chalk.dim(\"\\n Aborted.\\n\"));\n return;\n }\n }\n } else {\n console.log(chalk.dim(\"\\n No existing .claude/ directory found — generating from scratch.\\n\"));\n\n if (!options.yes) {\n const proceed = await confirm({\n message: \"Generate Claude Code environment for this project?\",\n default: true,\n });\n if (!proceed) {\n console.log(chalk.dim(\"\\n Aborted.\\n\"));\n return;\n }\n }\n }\n\n // 4. Compile with scanned profile\n const intent = buildOptimizeIntent(profile);\n let spec;\n try {\n spec = await compile(intent, (msg) => {\n process.stdout.write(`\\r ${chalk.dim(msg)} `);\n });\n process.stdout.write(\"\\r \\r\");\n } catch (err) {\n process.stdout.write(\"\\r \\r\");\n const msg = err instanceof Error ? err.message : String(err);\n console.log(chalk.red(`\\n Optimization failed: ${msg}\\n`));\n process.exit(1);\n }\n\n // 5. Show results\n const registry = await loadRegistry();\n const summary = summarizeSpec(spec, registry);\n\n console.log(chalk.green(\" ✓ Environment compiled\\n\"));\n console.log(chalk.cyan(\" Name: \") + spec.name);\n console.log(chalk.cyan(\" Tools: \") + summary.toolCount);\n console.log(chalk.cyan(\" Commands: \") + summary.commandCount);\n console.log(chalk.cyan(\" Rules: \") + summary.ruleCount);\n console.log(chalk.cyan(\" Skills: \") + summary.skillCount);\n console.log(chalk.cyan(\" Agents: \") + summary.agentCount);\n\n if (spec.tools.length > 0) {\n console.log(chalk.dim(\"\\n Selected tools:\"));\n for (const tool of spec.tools) {\n const regTool = registry.find((t) => t.id === tool.tool_id);\n const name = regTool?.name || tool.tool_id;\n console.log(chalk.dim(` - ${name}: ${tool.reason}`));\n }\n }\n\n if (summary.pluginCommands.length > 0) {\n console.log(chalk.yellow(\"\\n Plugins to install manually:\"));\n for (const cmd of summary.pluginCommands) {\n console.log(chalk.yellow(` ${cmd}`));\n }\n }\n\n // 6. Write\n const written = await writeEnvironment(spec, targetDir);\n\n console.log(chalk.green(\"\\n ✓ Environment written\\n\"));\n for (const file of written) {\n console.log(chalk.dim(` ${file}`));\n }\n\n if (summary.envSetup.length > 0) {\n console.log(chalk.yellow(\"\\n API keys needed (set these environment variables):\\n\"));\n const seen = new Set<string>();\n for (const env of summary.envSetup) {\n if (seen.has(env.envVar)) continue;\n seen.add(env.envVar);\n console.log(chalk.bold(` export ${env.envVar}=\"your-key-here\"`));\n console.log(chalk.dim(` ${env.description}`));\n if (env.signupUrl) {\n console.log(chalk.dim(` Get one at: ${env.signupUrl}`));\n }\n console.log(\"\");\n }\n }\n\n if (summary.pluginCommands.length > 0) {\n console.log(chalk.yellow(\" Install plugins by running these in Claude Code:\"));\n for (const cmd of summary.pluginCommands) {\n console.log(chalk.bold(` ${cmd}`));\n }\n }\n\n console.log(\n chalk.cyan(\"\\n Ready! Run \") +\n chalk.bold(\"claude\") +\n chalk.cyan(\" to start.\\n\")\n );\n });\n","import fs from \"fs/promises\";\nimport path from \"path\";\n\nexport interface ProjectProfile {\n // Core identity\n name: string;\n description: string;\n directory: string;\n\n // Language & framework\n language: string | null;\n framework: string | null;\n typescript: boolean;\n\n // Dependencies\n dependencies: string[];\n devDependencies: string[];\n\n // Scripts & commands\n scripts: Record<string, string>;\n hasTests: boolean;\n testCommand: string | null;\n buildCommand: string | null;\n lintCommand: string | null;\n\n // Project structure\n hasSrc: boolean;\n hasDocker: boolean;\n hasCi: boolean;\n hasEnvFile: boolean;\n envKeys: string[]; // from .env.example only — never read .env values\n\n // Existing harness\n hasClaudeDir: boolean;\n existingClaudeMd: string | null;\n existingSettings: Record<string, unknown> | null;\n existingMcpConfig: Record<string, unknown> | null;\n existingCommands: string[];\n existingRules: string[];\n existingSkills: string[];\n existingAgents: string[];\n mcpServerCount: number;\n claudeMdLineCount: number;\n\n // Key files found\n keyFiles: string[];\n}\n\nasync function fileExists(p: string): Promise<boolean> {\n try {\n await fs.access(p);\n return true;\n } catch {\n return false;\n }\n}\n\nasync function readJsonSafe(p: string): Promise<Record<string, unknown> | null> {\n try {\n const data = await fs.readFile(p, \"utf-8\");\n return JSON.parse(data);\n } catch {\n return null;\n }\n}\n\nasync function readFileSafe(p: string): Promise<string | null> {\n try {\n return await fs.readFile(p, \"utf-8\");\n } catch {\n return null;\n }\n}\n\nasync function listDirSafe(p: string): Promise<string[]> {\n try {\n const entries = await fs.readdir(p);\n return entries.filter((e) => !e.startsWith(\".\"));\n } catch {\n return [];\n }\n}\n\nfunction detectFramework(deps: string[]): string | null {\n const frameworks: [string[], string][] = [\n [[\"next\"], \"Next.js\"],\n [[\"nuxt\"], \"Nuxt\"],\n [[\"@remix-run/node\", \"@remix-run/react\"], \"Remix\"],\n [[\"svelte\", \"@sveltejs/kit\"], \"SvelteKit\"],\n [[\"express\"], \"Express\"],\n [[\"fastify\"], \"Fastify\"],\n [[\"hono\"], \"Hono\"],\n [[\"react\", \"react-dom\"], \"React\"],\n [[\"vue\"], \"Vue\"],\n [[\"angular\"], \"Angular\"],\n [[\"django\"], \"Django\"],\n [[\"flask\"], \"Flask\"],\n [[\"fastapi\"], \"FastAPI\"],\n [[\"@supabase/supabase-js\"], \"Supabase\"],\n [[\"prisma\", \"@prisma/client\"], \"Prisma\"],\n [[\"drizzle-orm\"], \"Drizzle\"],\n [[\"tailwindcss\"], \"Tailwind CSS\"],\n ];\n\n const detected: string[] = [];\n for (const [packages, name] of frameworks) {\n if (packages.some((pkg) => deps.includes(pkg))) {\n detected.push(name);\n }\n }\n return detected.length > 0 ? detected.join(\" + \") : null;\n}\n\nfunction detectLanguage(dir: string, keyFiles: string[]): string | null {\n if (keyFiles.some((f) => f === \"tsconfig.json\")) return \"TypeScript\";\n if (keyFiles.some((f) => f === \"package.json\")) return \"JavaScript\";\n if (keyFiles.some((f) => f === \"pyproject.toml\" || f === \"setup.py\" || f === \"requirements.txt\")) return \"Python\";\n if (keyFiles.some((f) => f === \"Cargo.toml\")) return \"Rust\";\n if (keyFiles.some((f) => f === \"go.mod\")) return \"Go\";\n if (keyFiles.some((f) => f === \"Gemfile\")) return \"Ruby\";\n return null;\n}\n\nfunction extractEnvKeys(content: string): string[] {\n const keys: string[] = [];\n for (const line of content.split(\"\\n\")) {\n const match = line.match(/^([A-Z][A-Z0-9_]*)=/);\n if (match) keys.push(match[1]);\n }\n return keys;\n}\n\nexport async function scanProject(dir: string): Promise<ProjectProfile> {\n // Read package.json\n const pkg = await readJsonSafe(path.join(dir, \"package.json\")) as Record<string, unknown> | null;\n const deps = pkg?.dependencies ? Object.keys(pkg.dependencies as Record<string, string>) : [];\n const devDeps = pkg?.devDependencies ? Object.keys(pkg.devDependencies as Record<string, string>) : [];\n const allDeps = [...deps, ...devDeps];\n const scripts = (pkg?.scripts || {}) as Record<string, string>;\n\n // Detect key files\n const rootFiles = await listDirSafe(dir);\n const keyFiles = rootFiles.filter((f) =>\n [\n \"package.json\", \"tsconfig.json\", \"pyproject.toml\", \"setup.py\",\n \"requirements.txt\", \"Cargo.toml\", \"go.mod\", \"Gemfile\",\n \"docker-compose.yml\", \"Dockerfile\", \".env.example\", \".env\",\n \"README.md\", \"CLAUDE.md\",\n ].includes(f)\n );\n\n // Detect language & framework\n const language = detectLanguage(dir, keyFiles);\n const framework = detectFramework(allDeps);\n const typescript = keyFiles.includes(\"tsconfig.json\") || allDeps.includes(\"typescript\");\n\n // Test detection\n const testCommand = scripts.test && scripts.test !== 'echo \"Error: no test specified\" && exit 1'\n ? scripts.test : null;\n const hasTests = testCommand !== null ||\n await fileExists(path.join(dir, \"tests\")) ||\n await fileExists(path.join(dir, \"__tests__\")) ||\n await fileExists(path.join(dir, \"test\"));\n\n // Build & lint\n const buildCommand = scripts.build || null;\n const lintCommand = scripts.lint || null;\n\n // Structure\n const hasSrc = await fileExists(path.join(dir, \"src\"));\n const hasDocker = await fileExists(path.join(dir, \"docker-compose.yml\")) ||\n await fileExists(path.join(dir, \"Dockerfile\"));\n const hasCi = await fileExists(path.join(dir, \".github/workflows\"));\n\n // Env keys (from .env.example only — never read actual .env values)\n const hasEnvFile = await fileExists(path.join(dir, \".env\")) ||\n await fileExists(path.join(dir, \".env.example\"));\n let envKeys: string[] = [];\n const envExample = await readFileSafe(path.join(dir, \".env.example\"));\n if (envExample) {\n envKeys = extractEnvKeys(envExample);\n }\n\n // Existing .claude/ harness\n const claudeDir = path.join(dir, \".claude\");\n const hasClaudeDir = await fileExists(claudeDir);\n let existingClaudeMd: string | null = null;\n let existingSettings: Record<string, unknown> | null = null;\n let existingMcpConfig: Record<string, unknown> | null = null;\n let existingCommands: string[] = [];\n let existingRules: string[] = [];\n let existingSkills: string[] = [];\n let existingAgents: string[] = [];\n let mcpServerCount = 0;\n let claudeMdLineCount = 0;\n\n if (hasClaudeDir) {\n existingClaudeMd = await readFileSafe(path.join(claudeDir, \"CLAUDE.md\"));\n if (existingClaudeMd) {\n claudeMdLineCount = existingClaudeMd.split(\"\\n\").length;\n }\n\n existingSettings = await readJsonSafe(path.join(claudeDir, \"settings.json\"));\n existingMcpConfig = await readJsonSafe(path.join(dir, \".mcp.json\"));\n if (existingMcpConfig?.mcpServers) {\n mcpServerCount = Object.keys(existingMcpConfig.mcpServers as Record<string, unknown>).length;\n }\n\n existingCommands = (await listDirSafe(path.join(claudeDir, \"commands\")))\n .filter((f) => f.endsWith(\".md\"))\n .map((f) => f.replace(\".md\", \"\"));\n existingRules = (await listDirSafe(path.join(claudeDir, \"rules\")))\n .filter((f) => f.endsWith(\".md\"))\n .map((f) => f.replace(\".md\", \"\"));\n existingSkills = await listDirSafe(path.join(claudeDir, \"skills\"));\n existingAgents = (await listDirSafe(path.join(claudeDir, \"agents\")))\n .filter((f) => f.endsWith(\".md\"))\n .map((f) => f.replace(\".md\", \"\"));\n }\n\n // Project name & description\n const name = (pkg?.name as string) || path.basename(dir);\n const description = (pkg?.description as string) || \"\";\n\n return {\n name,\n description,\n directory: dir,\n language,\n framework,\n typescript,\n dependencies: deps,\n devDependencies: devDeps,\n scripts,\n hasTests,\n testCommand,\n buildCommand,\n lintCommand,\n hasSrc,\n hasDocker,\n hasCi,\n hasEnvFile,\n envKeys,\n hasClaudeDir,\n existingClaudeMd,\n existingSettings,\n existingMcpConfig,\n existingCommands,\n existingRules,\n existingSkills,\n existingAgents,\n mcpServerCount,\n claudeMdLineCount,\n keyFiles,\n };\n}\n"],"mappings":";AAAA,SAAS,WAAAA,gBAAe;;;ACAxB,SAAS,eAAe;AACxB,SAAS,UAAU,cAAc;AACjC,OAAO,WAAW;AAClB,OAAO,eAAe;AACtB,OAAO,YAAY;AACnB,SAAS,oBAAoB;;;ACL7B,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,OAAO,QAAQ;AAGf,IAAM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AqB;AAExC,QAAQ,MAAM;","names":["Command","Command","chalk","fs","path","fs","path","Anthropic","OpenAI","path","fs","Anthropic","OpenAI","fs","path","fileURLToPath","loadRegistry","path","fs","Command","chalk","Command","chalk","fs","path","Command","fs","chalk","path","Command","chalk","fs","path","Command","fs","chalk","path","Command","chalk","fs","path","fileURLToPath","Command","confirm","chalk","fs","path","fileURLToPath","fs","path","loadRegistry","fileURLToPath","path","fs","Command","chalk","confirm","Command"]}
|
|
1
|
+
{"version":3,"sources":["../src/cli.ts","../src/commands/init.ts","../src/config.ts","../src/commands/describe.ts","../src/compiler/compile.ts","../src/compiler/prompt.ts","../src/adapter/claude-code.ts","../src/commands/list.ts","../src/commands/activate.ts","../src/commands/update-registry.ts","../src/commands/optimize.ts","../src/scanner/scan.ts"],"sourcesContent":["import { Command } from \"commander\";\nimport { initCommand } from \"./commands/init.js\";\nimport { describeCommand } from \"./commands/describe.js\";\nimport { listCommand } from \"./commands/list.js\";\nimport { activateCommand } from \"./commands/activate.js\";\nimport { updateRegistryCommand } from \"./commands/update-registry.js\";\nimport { optimizeCommand } from \"./commands/optimize.js\";\n\nconst program = new Command();\n\nprogram\n .name(\"kairn\")\n .description(\n \"Compile natural language intent into optimized Claude Code environments\"\n )\n .version(\"1.3.0\");\n\nprogram.addCommand(initCommand);\nprogram.addCommand(describeCommand);\nprogram.addCommand(optimizeCommand);\nprogram.addCommand(listCommand);\nprogram.addCommand(activateCommand);\nprogram.addCommand(updateRegistryCommand);\n\nprogram.parse();\n","import { Command } from \"commander\";\nimport { password, select } from \"@inquirer/prompts\";\nimport chalk from \"chalk\";\nimport Anthropic from \"@anthropic-ai/sdk\";\nimport OpenAI from \"openai\";\nimport { execFileSync } from \"child_process\";\nimport { loadConfig, saveConfig, getConfigPath } from \"../config.js\";\nimport type { KairnConfig, LLMProvider } from \"../types.js\";\n\nconst PROVIDER_MODELS: Record<LLMProvider, { name: string; models: { name: string; value: string }[] }> = {\n anthropic: {\n name: \"Anthropic\",\n models: [\n { name: \"Claude Sonnet 4.6 (recommended — fast, smart)\", value: \"claude-sonnet-4-6\" },\n { name: \"Claude Opus 4.6 (highest quality)\", value: \"claude-opus-4-6\" },\n { name: \"Claude Haiku 4.5 (fastest, cheapest)\", value: \"claude-haiku-4-5-20251001\" },\n ],\n },\n openai: {\n name: \"OpenAI\",\n models: [\n { name: \"GPT-4o (recommended)\", value: \"gpt-4o\" },\n { name: \"GPT-4o mini (faster, cheaper)\", value: \"gpt-4o-mini\" },\n { name: \"o3 (reasoning)\", value: \"o3\" },\n ],\n },\n google: {\n name: \"Google Gemini\",\n models: [\n { name: \"Gemini 2.5 Flash (recommended)\", value: \"gemini-2.5-flash-preview-05-20\" },\n { name: \"Gemini 2.5 Pro (highest quality)\", value: \"gemini-2.5-pro-preview-05-06\" },\n ],\n },\n};\n\nasync function verifyKey(provider: LLMProvider, apiKey: string, model: string): Promise<boolean> {\n try {\n if (provider === \"anthropic\") {\n const client = new Anthropic({ apiKey });\n await client.messages.create({\n model: \"claude-haiku-4-5-20251001\",\n max_tokens: 10,\n messages: [{ role: \"user\", content: \"ping\" }],\n });\n return true;\n } else if (provider === \"openai\") {\n const client = new OpenAI({ apiKey });\n await client.chat.completions.create({\n model: \"gpt-4o-mini\",\n max_tokens: 10,\n messages: [{ role: \"user\", content: \"ping\" }],\n });\n return true;\n } else if (provider === \"google\") {\n // Google uses OpenAI-compatible API\n const client = new OpenAI({\n apiKey,\n baseURL: \"https://generativelanguage.googleapis.com/v1beta/openai/\",\n });\n await client.chat.completions.create({\n model: \"gemini-2.5-flash-preview-05-20\",\n max_tokens: 10,\n messages: [{ role: \"user\", content: \"ping\" }],\n });\n return true;\n }\n return false;\n } catch {\n return false;\n }\n}\n\nfunction detectClaudeCode(): boolean {\n try {\n execFileSync(\"which\", [\"claude\"], { stdio: \"ignore\" });\n return true;\n } catch {\n return false;\n }\n}\n\nexport const initCommand = new Command(\"init\")\n .description(\"Set up Kairn with your API key\")\n .action(async () => {\n console.log(chalk.cyan(\"\\n Kairn Setup\\n\"));\n\n const existing = await loadConfig();\n if (existing) {\n console.log(\n chalk.yellow(\" Config already exists at \") +\n chalk.dim(getConfigPath())\n );\n console.log(chalk.yellow(\" Running setup will overwrite it.\\n\"));\n }\n\n const provider = await select<LLMProvider>({\n message: \"LLM provider\",\n choices: [\n { name: \"Anthropic (Claude) — recommended\", value: \"anthropic\" as LLMProvider },\n { name: \"OpenAI (GPT)\", value: \"openai\" as LLMProvider },\n { name: \"Google (Gemini)\", value: \"google\" as LLMProvider },\n ],\n });\n\n const providerInfo = PROVIDER_MODELS[provider];\n\n const model = await select({\n message: \"Compilation model\",\n choices: providerInfo.models,\n });\n\n const apiKey = await password({\n message: `${providerInfo.name} API key`,\n mask: \"*\",\n });\n\n if (!apiKey) {\n console.log(chalk.red(\"\\n No API key provided. Aborting.\"));\n process.exit(1);\n }\n\n console.log(chalk.dim(\"\\n Verifying API key...\"));\n const valid = await verifyKey(provider, apiKey, model);\n\n if (!valid) {\n console.log(\n chalk.red(\" Invalid API key. Check your key and try again.\")\n );\n process.exit(1);\n }\n\n console.log(chalk.green(\" ✓ API key verified\"));\n\n const config: KairnConfig = {\n provider,\n api_key: apiKey,\n model,\n default_runtime: \"claude-code\",\n created_at: new Date().toISOString(),\n };\n\n await saveConfig(config);\n console.log(\n chalk.green(\" ✓ Config saved to \") + chalk.dim(getConfigPath())\n );\n console.log(\n chalk.dim(` ✓ Provider: ${providerInfo.name}, Model: ${model}`)\n );\n\n const hasClaude = detectClaudeCode();\n if (hasClaude) {\n console.log(chalk.green(\" ✓ Claude Code detected\"));\n } else {\n console.log(\n chalk.yellow(\n \" ⚠ Claude Code not found. Install it: npm install -g @anthropic-ai/claude-code\"\n )\n );\n }\n\n console.log(\n chalk.cyan(\"\\n Ready! Run \") +\n chalk.bold(\"kairn describe\") +\n chalk.cyan(\" to create your first environment.\\n\")\n );\n });\n","import fs from \"fs/promises\";\nimport path from \"path\";\nimport os from \"os\";\nimport type { KairnConfig } from \"./types.js\";\n\nconst KAIRN_DIR = path.join(os.homedir(), \".kairn\");\nconst CONFIG_PATH = path.join(KAIRN_DIR, \"config.json\");\nconst ENVS_DIR = path.join(KAIRN_DIR, \"envs\");\n\nexport function getKairnDir(): string {\n return KAIRN_DIR;\n}\n\nexport function getConfigPath(): string {\n return CONFIG_PATH;\n}\n\nexport function getEnvsDir(): string {\n return ENVS_DIR;\n}\n\nexport async function ensureDirs(): Promise<void> {\n await fs.mkdir(KAIRN_DIR, { recursive: true });\n await fs.mkdir(ENVS_DIR, { recursive: true });\n}\n\nexport async function loadConfig(): Promise<KairnConfig | null> {\n try {\n const data = await fs.readFile(CONFIG_PATH, \"utf-8\");\n const raw = JSON.parse(data) as Record<string, unknown>;\n\n // Handle old config format (v1.0.0: anthropic_api_key)\n if (raw.anthropic_api_key && !raw.provider) {\n return {\n provider: \"anthropic\",\n api_key: raw.anthropic_api_key as string,\n model: \"claude-sonnet-4-6\",\n default_runtime: \"claude-code\",\n created_at: (raw.created_at as string) || new Date().toISOString(),\n };\n }\n\n return raw as unknown as KairnConfig;\n } catch {\n return null;\n }\n}\n\nexport async function saveConfig(config: KairnConfig): Promise<void> {\n await ensureDirs();\n await fs.writeFile(CONFIG_PATH, JSON.stringify(config, null, 2), \"utf-8\");\n}\n","import { Command } from \"commander\";\nimport { input, confirm } from \"@inquirer/prompts\";\nimport chalk from \"chalk\";\nimport fs from \"fs/promises\";\nimport path from \"path\";\nimport { loadConfig } from \"../config.js\";\nimport { compile } from \"../compiler/compile.js\";\nimport { writeEnvironment, summarizeSpec } from \"../adapter/claude-code.js\";\nimport { fileURLToPath } from \"url\";\nimport type { RegistryTool } from \"../types.js\";\n\nasync function loadRegistry(): Promise<RegistryTool[]> {\n const __filename = fileURLToPath(import.meta.url);\n const __dirname = path.dirname(__filename);\n const candidates = [\n path.resolve(__dirname, \"../registry/tools.json\"),\n path.resolve(__dirname, \"../src/registry/tools.json\"),\n path.resolve(__dirname, \"../../src/registry/tools.json\"),\n ];\n for (const candidate of candidates) {\n try {\n const data = await fs.readFile(candidate, \"utf-8\");\n return JSON.parse(data) as RegistryTool[];\n } catch {\n continue;\n }\n }\n throw new Error(\"Could not find tools.json registry\");\n}\n\nexport const describeCommand = new Command(\"describe\")\n .description(\"Describe your workflow and generate a Claude Code environment\")\n .argument(\"[intent]\", \"What you want your agent to do\")\n .option(\"-y, --yes\", \"Skip confirmation prompt\")\n .action(async (intentArg: string | undefined, options: { yes?: boolean }) => {\n // 1. Check config\n const config = await loadConfig();\n if (!config) {\n console.log(\n chalk.red(\"\\n No config found. Run \") +\n chalk.bold(\"kairn init\") +\n chalk.red(\" first.\\n\")\n );\n process.exit(1);\n }\n\n // 2. Get intent\n const intent =\n intentArg ||\n (await input({\n message: \"What do you want your agent to do?\",\n }));\n\n if (!intent.trim()) {\n console.log(chalk.red(\"\\n No description provided. Aborting.\\n\"));\n process.exit(1);\n }\n\n // 3. Compile with progress\n console.log(\"\");\n let spec;\n try {\n spec = await compile(intent, (msg) => {\n process.stdout.write(`\\r ${chalk.dim(msg)} `);\n });\n process.stdout.write(\"\\r \\r\");\n } catch (err) {\n process.stdout.write(\"\\r \\r\");\n const msg = err instanceof Error ? err.message : String(err);\n console.log(chalk.red(`\\n Compilation failed: ${msg}\\n`));\n process.exit(1);\n }\n\n // 4. Show results\n const registry = await loadRegistry();\n const summary = summarizeSpec(spec, registry);\n\n console.log(chalk.green(\"\\n ✓ Environment compiled\\n\"));\n console.log(chalk.cyan(\" Name: \") + spec.name);\n console.log(chalk.cyan(\" Description: \") + spec.description);\n console.log(chalk.cyan(\" Tools: \") + summary.toolCount);\n console.log(chalk.cyan(\" Commands: \") + summary.commandCount);\n console.log(chalk.cyan(\" Rules: \") + summary.ruleCount);\n console.log(chalk.cyan(\" Skills: \") + summary.skillCount);\n console.log(chalk.cyan(\" Agents: \") + summary.agentCount);\n\n if (spec.tools.length > 0) {\n console.log(chalk.dim(\"\\n Selected tools:\"));\n for (const tool of spec.tools) {\n const regTool = registry.find((t) => t.id === tool.tool_id);\n const name = regTool?.name || tool.tool_id;\n console.log(chalk.dim(` - ${name}: ${tool.reason}`));\n }\n }\n\n if (summary.pluginCommands.length > 0) {\n console.log(chalk.yellow(\"\\n Plugins to install manually:\"));\n for (const cmd of summary.pluginCommands) {\n console.log(chalk.yellow(` ${cmd}`));\n }\n }\n\n // 5. Confirm\n console.log(\"\");\n const proceed = options.yes || await confirm({\n message: \"Generate environment in current directory?\",\n default: true,\n });\n\n if (!proceed) {\n console.log(chalk.dim(\"\\n Aborted. Environment saved to ~/.kairn/envs/\\n\"));\n return;\n }\n\n // 6. Write\n const targetDir = process.cwd();\n const written = await writeEnvironment(spec, targetDir);\n\n console.log(chalk.green(\"\\n ✓ Environment written\\n\"));\n for (const file of written) {\n console.log(chalk.dim(` ${file}`));\n }\n\n if (summary.envSetup.length > 0) {\n console.log(chalk.yellow(\"\\n API keys needed (set these environment variables):\\n\"));\n const seen = new Set<string>();\n for (const env of summary.envSetup) {\n if (seen.has(env.envVar)) continue;\n seen.add(env.envVar);\n console.log(chalk.bold(` export ${env.envVar}=\"your-key-here\"`));\n console.log(chalk.dim(` ${env.description}`));\n if (env.signupUrl) {\n console.log(chalk.dim(` Get one at: ${env.signupUrl}`));\n }\n console.log(\"\");\n }\n }\n\n if (summary.pluginCommands.length > 0) {\n console.log(chalk.yellow(\" Install plugins by running these in Claude Code:\"));\n for (const cmd of summary.pluginCommands) {\n console.log(chalk.bold(` ${cmd}`));\n }\n }\n\n console.log(\n chalk.cyan(\"\\n Ready! Run \") +\n chalk.bold(\"claude\") +\n chalk.cyan(\" to start.\\n\")\n );\n });\n","import fs from \"fs/promises\";\nimport path from \"path\";\nimport { fileURLToPath } from \"url\";\nimport crypto from \"crypto\";\nimport Anthropic from \"@anthropic-ai/sdk\";\nimport OpenAI from \"openai\";\nimport { loadConfig, getEnvsDir, ensureDirs } from \"../config.js\";\nimport { SYSTEM_PROMPT } from \"./prompt.js\";\nimport type { EnvironmentSpec, RegistryTool, KairnConfig } from \"../types.js\";\n\nasync function loadRegistry(): Promise<RegistryTool[]> {\n const __filename = fileURLToPath(import.meta.url);\n const __dirname = path.dirname(__filename);\n const candidates = [\n path.resolve(__dirname, \"../registry/tools.json\"),\n path.resolve(__dirname, \"../src/registry/tools.json\"),\n path.resolve(__dirname, \"../../src/registry/tools.json\"),\n ];\n for (const candidate of candidates) {\n try {\n const data = await fs.readFile(candidate, \"utf-8\");\n return JSON.parse(data) as RegistryTool[];\n } catch {\n continue;\n }\n }\n throw new Error(\"Could not find tools.json registry\");\n}\n\nfunction buildUserMessage(intent: string, registry: RegistryTool[]): string {\n const registrySummary = registry\n .map(\n (t) =>\n `- ${t.id} (${t.type}, tier ${t.tier}, auth: ${t.auth}): ${t.description} [best_for: ${t.best_for.join(\", \")}]`\n )\n .join(\"\\n\");\n\n return `## User Intent\\n\\n${intent}\\n\\n## Available Tool Registry\\n\\n${registrySummary}\\n\\nGenerate the EnvironmentSpec JSON now.`;\n}\n\nfunction parseSpecResponse(text: string): Omit<EnvironmentSpec, \"id\" | \"intent\" | \"created_at\"> {\n let cleaned = text.trim();\n // Strip markdown code fences\n if (cleaned.startsWith(\"```\")) {\n cleaned = cleaned.replace(/^```(?:json)?\\n?/, \"\").replace(/\\n?```$/, \"\");\n }\n // Try to extract JSON if there's surrounding text\n const jsonMatch = cleaned.match(/\\{[\\s\\S]*\\}/);\n if (!jsonMatch) {\n throw new Error(\n \"LLM response did not contain valid JSON. Try again or use a different model.\"\n );\n }\n try {\n return JSON.parse(jsonMatch[0]);\n } catch (err) {\n throw new Error(\n `Failed to parse LLM response as JSON: ${err instanceof Error ? err.message : String(err)}\\n` +\n `Response started with: ${cleaned.slice(0, 200)}...`\n );\n }\n}\n\nfunction classifyError(err: unknown, provider: string): string {\n const msg = err instanceof Error ? err.message : String(err);\n const status = (err as { status?: number })?.status;\n const code = (err as { code?: string })?.code;\n\n // Network errors\n if (code === \"ECONNREFUSED\" || code === \"ENOTFOUND\" || code === \"ETIMEDOUT\") {\n return `Network error: could not reach ${provider} API. Check your internet connection.`;\n }\n\n // Auth errors\n if (status === 401 || msg.includes(\"invalid\") && msg.includes(\"key\")) {\n return `Invalid API key for ${provider}. Run \\`kairn init\\` to reconfigure.`;\n }\n if (status === 403) {\n return `Access denied by ${provider}. Your API key may lack permissions for this model.`;\n }\n\n // Rate limiting\n if (status === 429 || msg.includes(\"rate limit\") || msg.includes(\"quota\")) {\n return `Rate limited by ${provider}. Wait a moment and try again, or switch to a cheaper model with \\`kairn init\\`.`;\n }\n\n // Model errors\n if (status === 404 || msg.includes(\"not found\") || msg.includes(\"does not exist\")) {\n return `Model not found on ${provider}. Run \\`kairn init\\` to select a valid model.`;\n }\n\n // Overloaded\n if (status === 529 || status === 503 || msg.includes(\"overloaded\")) {\n return `${provider} is temporarily overloaded. Try again in a few seconds.`;\n }\n\n // Token/context limit\n if (msg.includes(\"token\") && (msg.includes(\"limit\") || msg.includes(\"exceed\"))) {\n return `Request too large for the selected model. Try a shorter workflow description.`;\n }\n\n // Billing\n if (msg.includes(\"billing\") || msg.includes(\"payment\") || msg.includes(\"insufficient\")) {\n return `Billing issue with your ${provider} account. Check your account dashboard.`;\n }\n\n // Fallback\n return `${provider} API error: ${msg}`;\n}\n\nasync function callLLM(config: KairnConfig, userMessage: string): Promise<string> {\n if (config.provider === \"anthropic\") {\n const client = new Anthropic({ apiKey: config.api_key });\n try {\n const response = await client.messages.create({\n model: config.model,\n max_tokens: 8192,\n system: SYSTEM_PROMPT,\n messages: [{ role: \"user\", content: userMessage }],\n });\n const textBlock = response.content.find((block) => block.type === \"text\");\n if (!textBlock || textBlock.type !== \"text\") {\n throw new Error(\"No text response from compiler LLM\");\n }\n return textBlock.text;\n } catch (err) {\n throw new Error(classifyError(err, \"Anthropic\"));\n }\n } else if (config.provider === \"openai\" || config.provider === \"google\") {\n const providerName = config.provider === \"google\" ? \"Google\" : \"OpenAI\";\n const clientOptions: { apiKey: string; baseURL?: string } = { apiKey: config.api_key };\n if (config.provider === \"google\") {\n clientOptions.baseURL = \"https://generativelanguage.googleapis.com/v1beta/openai/\";\n }\n const client = new OpenAI(clientOptions);\n try {\n const response = await client.chat.completions.create({\n model: config.model,\n max_tokens: 8192,\n messages: [\n { role: \"system\", content: SYSTEM_PROMPT },\n { role: \"user\", content: userMessage },\n ],\n });\n const text = response.choices[0]?.message?.content;\n if (!text) {\n throw new Error(\"No text response from compiler LLM\");\n }\n return text;\n } catch (err) {\n throw new Error(classifyError(err, providerName));\n }\n }\n throw new Error(`Unsupported provider: ${config.provider}. Run \\`kairn init\\` to reconfigure.`);\n}\n\nexport async function compile(\n intent: string,\n onProgress?: (msg: string) => void\n): Promise<EnvironmentSpec> {\n const config = await loadConfig();\n if (!config) {\n throw new Error(\"No config found. Run `kairn init` first.\");\n }\n\n onProgress?.(\"Loading tool registry...\");\n const registry = await loadRegistry();\n\n onProgress?.(`Compiling with ${config.provider} (${config.model})...`);\n const userMessage = buildUserMessage(intent, registry);\n const responseText = await callLLM(config, userMessage);\n\n onProgress?.(\"Parsing environment spec...\");\n const parsed = parseSpecResponse(responseText);\n\n const spec: EnvironmentSpec = {\n id: `env_${crypto.randomUUID()}`,\n intent,\n created_at: new Date().toISOString(),\n ...parsed,\n };\n\n // Save to ~/.kairn/envs/\n await ensureDirs();\n const envPath = path.join(getEnvsDir(), `${spec.id}.json`);\n await fs.writeFile(envPath, JSON.stringify(spec, null, 2), \"utf-8\");\n\n return spec;\n}\n","export const SYSTEM_PROMPT = `You are the Kairn environment compiler. Your job is to generate a minimal, optimal Claude Code agent environment from a user's natural language description of what they want their agent to do.\n\nYou will receive:\n1. The user's intent (what they want to build/do)\n2. A tool registry (available MCP servers, plugins, and hooks)\n\nYou must output a JSON object matching the EnvironmentSpec schema.\n\n## Core Principles\n\n- **Minimalism over completeness.** Fewer, well-chosen tools beat many generic ones. Each MCP server costs 500-2000 context tokens.\n- **Workflow-specific, not generic.** Every instruction, command, and rule must relate to the user's actual workflow.\n- **Concise CLAUDE.md.** Under 100 lines. No generic text like \"be helpful.\" Include build/test commands, reference docs/ and skills/.\n- **Security by default.** Always include deny rules for destructive commands and secret file access.\n\n## CLAUDE.md Template (mandatory structure)\n\nThe \\`claude_md\\` field MUST follow this exact structure (max 100 lines):\n\n\\`\\`\\`\n# {Project Name}\n\n## Purpose\n{one-line description}\n\n## Tech Stack\n{bullet list of frameworks/languages}\n\n## Commands\n{concrete build/test/lint/dev commands}\n\n## Architecture\n{brief folder structure, max 10 lines}\n\n## Conventions\n{3-5 specific coding rules}\n\n## Key Commands\n{list /project: commands with descriptions}\n\n## Output\n{where results go, key files}\n\\`\\`\\`\n\nDo not add generic filler. Every line must be specific to the user's workflow.\n\n## What You Must Always Include\n\n1. A concise, workflow-specific \\`claude_md\\` (the CLAUDE.md content)\n2. A \\`/project:help\\` command that explains the environment\n3. A \\`/project:tasks\\` command for task management via TODO.md\n4. A \\`docs/TODO.md\\` file for continuity\n5. A \\`docs/DECISIONS.md\\` file for architectural decisions\n6. A \\`docs/LEARNINGS.md\\` file for non-obvious discoveries\n7. A \\`rules/continuity.md\\` rule encouraging updates to DECISIONS.md and LEARNINGS.md\n8. A \\`rules/security.md\\` rule with essential security instructions\n9. settings.json with deny rules for \\`rm -rf\\`, \\`curl|sh\\`, reading \\`.env\\` and \\`secrets/\\`\n10. A \\`/project:status\\` command for code projects (uses ! for live git/test output)\n11. A \\`/project:fix\\` command for code projects (uses $ARGUMENTS for issue number)\n\n## Shell-Integrated Commands\n\nCommands that reference live project state should use Claude Code's \\`!\\` prefix for shell output:\n\n\\`\\`\\`markdown\n# Example: .claude/commands/review.md\nReview the staged changes for quality and security:\n\n!git diff --staged\n\nRun tests and check for failures:\n\n!npm test 2>&1 | tail -20\n\nFocus on: security, error handling, test coverage.\n\\`\\`\\`\n\nUse \\`!\\` when a command needs: git status, test results, build output, or file listings.\n\n## Path-Scoped Rules\n\nFor code projects with multiple domains (API, frontend, tests), generate path-scoped rules using YAML frontmatter:\n\n\\`\\`\\`markdown\n# Example: rules/api.md\n---\npaths:\n - \"src/api/**\"\n - \"src/routes/**\"\n---\n- All handlers return { data, error } shape\n- Use Zod for request validation\n- Log errors with request ID context\n\\`\\`\\`\n\n\\`\\`\\`markdown\n# Example: rules/testing.md\n---\npaths:\n - \"tests/**\"\n - \"**/*.test.*\"\n - \"**/*.spec.*\"\n---\n- Use AAA pattern: Arrange-Act-Assert\n- One assertion per test when possible\n- Mock external dependencies, never real APIs\n\\`\\`\\`\n\nKeep \\`security.md\\` and \\`continuity.md\\` as unconditional (no paths frontmatter).\nOnly generate scoped rules when the workflow involves multiple code domains.\n\n## Hooks\n\nGenerate hooks in settings.json based on project type:\n\n**All code projects** — block destructive commands:\n\\`\\`\\`json\n{\n \"hooks\": {\n \"PreToolUse\": [{\n \"matcher\": \"Bash\",\n \"hooks\": [{\n \"type\": \"command\",\n \"command\": \"CMD=$(cat | jq -r '.tool_input.command // empty') && echo \\\\\"$CMD\\\\\" | grep -qiE 'rm\\\\\\\\s+-rf\\\\\\\\s+/|DROP\\\\\\\\s+TABLE|curl.*\\\\\\\\|\\\\\\\\s*sh' && echo 'Blocked destructive command' >&2 && exit 2 || true\"\n }]\n }]\n }\n}\n\\`\\`\\`\n\n**Projects with Prettier/ESLint/Black** — auto-format on write:\n\\`\\`\\`json\n{\n \"hooks\": {\n \"PostToolUse\": [{\n \"matcher\": \"Edit|Write\",\n \"hooks\": [{\n \"type\": \"command\",\n \"command\": \"FILE=$(cat | jq -r '.tool_input.file_path // empty') && [ -n \\\\\"$FILE\\\\\" ] && npx prettier --write \\\\\"$FILE\\\\\" 2>/dev/null || true\"\n }]\n }]\n }\n}\n\\`\\`\\`\n\nMerge hooks into the \\`settings\\` object alongside permissions. Choose the formatter hook based on detected dependencies (Prettier → prettier, ESLint → eslint, Black → black).\n\n## Tool Selection Rules\n\n- Only select tools directly relevant to the described workflow\n- Prefer free tools (auth: \"none\") when quality is comparable\n- Tier 1 tools (Context7, Sequential Thinking, security-guidance) should be included in most environments\n- For tools requiring API keys (auth: \"api_key\"), use \\${ENV_VAR} syntax — never hardcode keys\n- Maximum 6-8 MCP servers to avoid context bloat\n- Include a \\`reason\\` for each selected tool explaining why it fits this workflow\n\n## For Code Projects, Additionally Include\n\n- \\`/project:plan\\` command (plan before coding)\n- \\`/project:review\\` command (review changes)\n- \\`/project:test\\` command (run and fix tests)\n- \\`/project:commit\\` command (conventional commits)\n- \\`/project:status\\` command (live git status, recent commits, TODO overview using ! prefix)\n- \\`/project:fix\\` command (takes $ARGUMENTS as issue number, plans fix, implements, tests, commits)\n- A TDD skill using the 3-phase isolation pattern (RED → GREEN → REFACTOR):\n - RED: Write failing test only. Verify it FAILS.\n - GREEN: Write MINIMUM code to pass. Nothing extra.\n - REFACTOR: Improve while keeping tests green.\n Rules: never write tests and implementation in same step, AAA pattern, one assertion per test.\n- A reviewer agent (read-only, Sonnet model)\n\n## For Research Projects, Additionally Include\n\n- \\`/project:research\\` command (deep research on a topic)\n- \\`/project:summarize\\` command (summarize findings)\n- A research-synthesis skill\n- A researcher agent\n\n## For Content/Writing Projects, Additionally Include\n\n- \\`/project:draft\\` command (write first draft)\n- \\`/project:edit\\` command (review and improve writing)\n- A writing-workflow skill\n\n## Output Schema\n\nReturn ONLY valid JSON matching this structure:\n\n\\`\\`\\`json\n{\n \"name\": \"short-kebab-case-name\",\n \"description\": \"One-line description of the environment\",\n \"tools\": [\n { \"tool_id\": \"id-from-registry\", \"reason\": \"why this tool fits\" }\n ],\n \"harness\": {\n \"claude_md\": \"The full CLAUDE.md content (under 100 lines)\",\n \"settings\": {\n \"permissions\": {\n \"allow\": [\"Bash(npm run *)\", \"Read\", \"Write\", \"Edit\"],\n \"deny\": [\"Bash(rm -rf *)\", \"Bash(curl * | sh)\", \"Read(./.env)\", \"Read(./secrets/**)\"]\n }\n },\n \"mcp_config\": {\n \"server-name\": { \"command\": \"npx\", \"args\": [\"...\"], \"env\": {} }\n },\n \"commands\": {\n \"help\": \"markdown content for /project:help\",\n \"tasks\": \"markdown content for /project:tasks\",\n \"status\": \"Show project status:\\\\n\\\\n!git status --short\\\\n\\\\n!git log --oneline -5\\\\n\\\\nRead TODO.md and summarize progress.\",\n \"fix\": \"Fix issue #$ARGUMENTS:\\\\n\\\\n1. Read the issue and understand the problem\\\\n2. Plan the fix\\\\n3. Implement the fix\\\\n4. Run tests:\\\\n\\\\n!npm test 2>&1 | tail -20\\\\n\\\\n5. Commit with: fix: resolve #$ARGUMENTS\"\n },\n \"rules\": {\n \"continuity\": \"markdown content for continuity rule\",\n \"security\": \"markdown content for security rule\"\n },\n \"skills\": {\n \"skill-name/SKILL\": \"markdown content with YAML frontmatter\"\n },\n \"agents\": {\n \"agent-name\": \"markdown content with YAML frontmatter\"\n },\n \"docs\": {\n \"TODO\": \"# TODO\\\\n\\\\n- [ ] First task based on workflow\",\n \"DECISIONS\": \"# Decisions\\\\n\\\\nArchitectural decisions for this project.\",\n \"LEARNINGS\": \"# Learnings\\\\n\\\\nNon-obvious discoveries and gotchas.\"\n }\n }\n}\n\\`\\`\\`\n\nDo not include any text outside the JSON object. Do not wrap in markdown code fences.`;\n","import fs from \"fs/promises\";\nimport path from \"path\";\nimport type { EnvironmentSpec, RegistryTool } from \"../types.js\";\n\nasync function writeFile(filePath: string, content: string): Promise<void> {\n await fs.mkdir(path.dirname(filePath), { recursive: true });\n await fs.writeFile(filePath, content, \"utf-8\");\n}\n\nexport async function writeEnvironment(\n spec: EnvironmentSpec,\n targetDir: string\n): Promise<string[]> {\n const claudeDir = path.join(targetDir, \".claude\");\n const written: string[] = [];\n\n // 1. CLAUDE.md\n if (spec.harness.claude_md) {\n const p = path.join(claudeDir, \"CLAUDE.md\");\n await writeFile(p, spec.harness.claude_md);\n written.push(\".claude/CLAUDE.md\");\n }\n\n // 2. settings.json\n if (spec.harness.settings && Object.keys(spec.harness.settings).length > 0) {\n const p = path.join(claudeDir, \"settings.json\");\n await writeFile(p, JSON.stringify(spec.harness.settings, null, 2));\n written.push(\".claude/settings.json\");\n }\n\n // 3. .mcp.json (project-scoped, goes in project root)\n if (\n spec.harness.mcp_config &&\n Object.keys(spec.harness.mcp_config).length > 0\n ) {\n const p = path.join(targetDir, \".mcp.json\");\n const mcpContent = { mcpServers: spec.harness.mcp_config };\n await writeFile(p, JSON.stringify(mcpContent, null, 2));\n written.push(\".mcp.json\");\n }\n\n // 4. Commands\n if (spec.harness.commands) {\n for (const [name, content] of Object.entries(spec.harness.commands)) {\n const p = path.join(claudeDir, \"commands\", `${name}.md`);\n await writeFile(p, content);\n written.push(`.claude/commands/${name}.md`);\n }\n }\n\n // 5. Rules\n if (spec.harness.rules) {\n for (const [name, content] of Object.entries(spec.harness.rules)) {\n const p = path.join(claudeDir, \"rules\", `${name}.md`);\n await writeFile(p, content);\n written.push(`.claude/rules/${name}.md`);\n }\n }\n\n // 6. Skills\n if (spec.harness.skills) {\n for (const [skillPath, content] of Object.entries(spec.harness.skills)) {\n const p = path.join(claudeDir, \"skills\", `${skillPath}.md`);\n await writeFile(p, content);\n written.push(`.claude/skills/${skillPath}.md`);\n }\n }\n\n // 7. Agents\n if (spec.harness.agents) {\n for (const [name, content] of Object.entries(spec.harness.agents)) {\n const p = path.join(claudeDir, \"agents\", `${name}.md`);\n await writeFile(p, content);\n written.push(`.claude/agents/${name}.md`);\n }\n }\n\n // 8. Docs\n if (spec.harness.docs) {\n for (const [name, content] of Object.entries(spec.harness.docs)) {\n const p = path.join(claudeDir, \"docs\", `${name}.md`);\n await writeFile(p, content);\n written.push(`.claude/docs/${name}.md`);\n }\n }\n\n return written;\n}\n\nexport interface EnvSetupInfo {\n toolName: string;\n envVar: string;\n description: string;\n signupUrl?: string;\n}\n\nexport function summarizeSpec(\n spec: EnvironmentSpec,\n registry: RegistryTool[]\n): {\n toolCount: number;\n commandCount: number;\n ruleCount: number;\n skillCount: number;\n agentCount: number;\n pluginCommands: string[];\n envSetup: EnvSetupInfo[];\n} {\n const pluginCommands: string[] = [];\n const envSetup: EnvSetupInfo[] = [];\n\n for (const selected of spec.tools) {\n const tool = registry.find((t) => t.id === selected.tool_id);\n if (!tool) continue;\n\n if (tool.install.plugin_command) {\n pluginCommands.push(tool.install.plugin_command);\n }\n\n if (tool.env_vars) {\n for (const ev of tool.env_vars) {\n envSetup.push({\n toolName: tool.name,\n envVar: ev.name,\n description: ev.description,\n signupUrl: tool.signup_url,\n });\n }\n }\n }\n\n return {\n toolCount: spec.tools.length,\n commandCount: Object.keys(spec.harness.commands || {}).length,\n ruleCount: Object.keys(spec.harness.rules || {}).length,\n skillCount: Object.keys(spec.harness.skills || {}).length,\n agentCount: Object.keys(spec.harness.agents || {}).length,\n pluginCommands,\n envSetup,\n };\n}\n","import { Command } from \"commander\";\nimport chalk from \"chalk\";\nimport fs from \"fs/promises\";\nimport path from \"path\";\nimport { getEnvsDir } from \"../config.js\";\nimport type { EnvironmentSpec } from \"../types.js\";\n\nexport const listCommand = new Command(\"list\")\n .description(\"Show saved environments\")\n .action(async () => {\n const envsDir = getEnvsDir();\n\n let files: string[];\n try {\n files = await fs.readdir(envsDir);\n } catch {\n console.log(chalk.dim(\"\\n No environments yet. Run \") +\n chalk.bold(\"kairn describe\") +\n chalk.dim(\" to create one.\\n\"));\n return;\n }\n\n const jsonFiles = files.filter((f) => f.endsWith(\".json\"));\n\n if (jsonFiles.length === 0) {\n console.log(chalk.dim(\"\\n No environments yet. Run \") +\n chalk.bold(\"kairn describe\") +\n chalk.dim(\" to create one.\\n\"));\n return;\n }\n\n console.log(chalk.cyan(\"\\n Saved Environments\\n\"));\n\n for (const file of jsonFiles) {\n try {\n const data = await fs.readFile(path.join(envsDir, file), \"utf-8\");\n const spec = JSON.parse(data) as EnvironmentSpec;\n const date = new Date(spec.created_at).toLocaleDateString();\n const toolCount = spec.tools?.length ?? 0;\n\n console.log(chalk.bold(` ${spec.name}`));\n console.log(chalk.dim(` ${spec.description}`));\n console.log(\n chalk.dim(` ${date} · ${toolCount} tools · ${spec.id}`)\n );\n console.log(\"\");\n } catch {\n // Skip malformed files\n }\n }\n });\n","import { Command } from \"commander\";\nimport chalk from \"chalk\";\nimport fs from \"fs/promises\";\nimport path from \"path\";\nimport { getEnvsDir } from \"../config.js\";\nimport { writeEnvironment } from \"../adapter/claude-code.js\";\nimport type { EnvironmentSpec } from \"../types.js\";\n\nexport const activateCommand = new Command(\"activate\")\n .description(\"Re-deploy a saved environment to the current directory\")\n .argument(\"<env_id>\", \"Environment ID (from kairn list)\")\n .action(async (envId: string) => {\n const envsDir = getEnvsDir();\n\n // Find the env file — accept full ID or partial match\n let files: string[];\n try {\n files = await fs.readdir(envsDir);\n } catch {\n console.log(chalk.red(\"\\n No saved environments found.\\n\"));\n process.exit(1);\n }\n\n const match = files.find(\n (f) => f === `${envId}.json` || f.startsWith(envId)\n );\n\n if (!match) {\n console.log(chalk.red(`\\n Environment \"${envId}\" not found.`));\n console.log(chalk.dim(\" Run kairn list to see saved environments.\\n\"));\n process.exit(1);\n }\n\n const data = await fs.readFile(path.join(envsDir, match), \"utf-8\");\n const spec = JSON.parse(data) as EnvironmentSpec;\n\n console.log(chalk.cyan(`\\n Activating: ${spec.name}`));\n console.log(chalk.dim(` ${spec.description}\\n`));\n\n const targetDir = process.cwd();\n const written = await writeEnvironment(spec, targetDir);\n\n console.log(chalk.green(\" ✓ Environment written\\n\"));\n for (const file of written) {\n console.log(chalk.dim(` ${file}`));\n }\n\n console.log(\n chalk.cyan(\"\\n Ready! Run \") +\n chalk.bold(\"claude\") +\n chalk.cyan(\" to start.\\n\")\n );\n });\n","import { Command } from \"commander\";\nimport chalk from \"chalk\";\nimport fs from \"fs/promises\";\nimport path from \"path\";\nimport { fileURLToPath } from \"url\";\n\nconst REGISTRY_URL =\n \"https://raw.githubusercontent.com/ashtonperlroth/kairn/main/src/registry/tools.json\";\n\nasync function getLocalRegistryPath(): Promise<string> {\n const __filename = fileURLToPath(import.meta.url);\n const __dirname = path.dirname(__filename);\n const candidates = [\n path.resolve(__dirname, \"../registry/tools.json\"),\n path.resolve(__dirname, \"../src/registry/tools.json\"),\n path.resolve(__dirname, \"../../src/registry/tools.json\"),\n ];\n for (const candidate of candidates) {\n try {\n await fs.access(candidate);\n return candidate;\n } catch {\n continue;\n }\n }\n throw new Error(\"Could not find local tools.json registry\");\n}\n\nexport const updateRegistryCommand = new Command(\"update-registry\")\n .description(\"Fetch the latest tool registry from GitHub\")\n .option(\"--url <url>\", \"Custom registry URL\")\n .action(async (options: { url?: string }) => {\n const url = options.url || REGISTRY_URL;\n\n console.log(chalk.dim(`\\n Fetching registry from ${url}...`));\n\n try {\n const response = await fetch(url);\n\n if (!response.ok) {\n console.log(\n chalk.red(` Failed to fetch registry: ${response.status} ${response.statusText}`)\n );\n console.log(\n chalk.dim(\" The remote registry may not be available yet.\")\n );\n console.log(\n chalk.dim(\" Your local registry is still active.\\n\")\n );\n return;\n }\n\n const text = await response.text();\n\n // Validate it's valid JSON and has the expected structure\n let tools: unknown[];\n try {\n tools = JSON.parse(text);\n if (!Array.isArray(tools)) throw new Error(\"Not an array\");\n if (tools.length === 0) throw new Error(\"Empty registry\");\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n console.log(chalk.red(` Invalid registry format: ${msg}\\n`));\n return;\n }\n\n const registryPath = await getLocalRegistryPath();\n\n // Back up existing registry\n const backupPath = registryPath + \".bak\";\n try {\n await fs.copyFile(registryPath, backupPath);\n } catch {\n // No existing file to back up\n }\n\n await fs.writeFile(registryPath, JSON.stringify(tools, null, 2), \"utf-8\");\n\n console.log(chalk.green(` ✓ Registry updated: ${tools.length} tools`));\n console.log(chalk.dim(` Saved to: ${registryPath}`));\n console.log(chalk.dim(` Backup: ${backupPath}\\n`));\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n console.log(chalk.red(` Network error: ${msg}`));\n console.log(chalk.dim(\" Your local registry is still active.\\n\"));\n }\n });\n","import { Command } from \"commander\";\nimport { input, confirm, checkbox } from \"@inquirer/prompts\";\nimport chalk from \"chalk\";\nimport fs from \"fs/promises\";\nimport path from \"path\";\nimport { fileURLToPath } from \"url\";\nimport { loadConfig } from \"../config.js\";\nimport { compile } from \"../compiler/compile.js\";\nimport { writeEnvironment, summarizeSpec } from \"../adapter/claude-code.js\";\nimport { scanProject } from \"../scanner/scan.js\";\nimport type { ProjectProfile } from \"../scanner/scan.js\";\nimport type { RegistryTool } from \"../types.js\";\n\nasync function loadRegistry(): Promise<RegistryTool[]> {\n const __filename = fileURLToPath(import.meta.url);\n const __dirname = path.dirname(__filename);\n const candidates = [\n path.resolve(__dirname, \"../registry/tools.json\"),\n path.resolve(__dirname, \"../src/registry/tools.json\"),\n path.resolve(__dirname, \"../../src/registry/tools.json\"),\n ];\n for (const candidate of candidates) {\n try {\n const data = await fs.readFile(candidate, \"utf-8\");\n return JSON.parse(data) as RegistryTool[];\n } catch {\n continue;\n }\n }\n throw new Error(\"Could not find tools.json registry\");\n}\n\nfunction buildProfileSummary(profile: ProjectProfile): string {\n const lines: string[] = [];\n lines.push(`Project: ${profile.name}`);\n if (profile.description) lines.push(`Description: ${profile.description}`);\n if (profile.language) lines.push(`Language: ${profile.language}`);\n if (profile.framework) lines.push(`Framework: ${profile.framework}`);\n if (profile.dependencies.length > 0) {\n lines.push(`Dependencies: ${profile.dependencies.join(\", \")}`);\n }\n if (profile.testCommand) lines.push(`Test command: ${profile.testCommand}`);\n if (profile.buildCommand) lines.push(`Build command: ${profile.buildCommand}`);\n if (profile.lintCommand) lines.push(`Lint command: ${profile.lintCommand}`);\n if (profile.hasDocker) lines.push(\"Has Docker configuration\");\n if (profile.hasCi) lines.push(\"Has CI/CD (GitHub Actions)\");\n if (profile.envKeys.length > 0) {\n lines.push(`Env keys needed: ${profile.envKeys.join(\", \")}`);\n }\n return lines.join(\"\\n\");\n}\n\nfunction buildAuditSummary(profile: ProjectProfile): string {\n const lines: string[] = [];\n lines.push(`\\nExisting .claude/ harness found:`);\n lines.push(` CLAUDE.md: ${profile.claudeMdLineCount} lines${profile.claudeMdLineCount > 200 ? \" (⚠ over 200 — may degrade adherence)\" : \"\"}`);\n lines.push(` MCP servers: ${profile.mcpServerCount}`);\n lines.push(` Commands: ${profile.existingCommands.length > 0 ? profile.existingCommands.map(c => `/project:${c}`).join(\", \") : \"none\"}`);\n lines.push(` Rules: ${profile.existingRules.length > 0 ? profile.existingRules.join(\", \") : \"none\"}`);\n lines.push(` Skills: ${profile.existingSkills.length > 0 ? profile.existingSkills.join(\", \") : \"none\"}`);\n lines.push(` Agents: ${profile.existingAgents.length > 0 ? profile.existingAgents.join(\", \") : \"none\"}`);\n return lines.join(\"\\n\");\n}\n\nfunction buildOptimizeIntent(profile: ProjectProfile): string {\n const parts: string[] = [];\n\n parts.push(\"## Project Profile (scanned from actual codebase)\\n\");\n parts.push(buildProfileSummary(profile));\n\n if (profile.hasClaudeDir) {\n parts.push(buildAuditSummary(profile));\n\n if (profile.existingClaudeMd) {\n parts.push(`\\n## Existing CLAUDE.md Content\\n\\n${profile.existingClaudeMd}`);\n }\n\n parts.push(`\\n## Task\\n`);\n parts.push(\"Analyze this existing Claude Code environment and generate an OPTIMIZED version.\");\n parts.push(\"Preserve what works. Fix what's wrong. Add what's missing. Remove what's bloat.\");\n parts.push(\"Key optimizations to consider:\");\n parts.push(\"- Is CLAUDE.md under 100 lines? If not, move detail to rules/ or docs/\");\n parts.push(\"- Are the right MCP servers selected for these dependencies?\");\n parts.push(\"- Are there missing slash commands (help, tasks, plan, test, commit)?\");\n parts.push(\"- Are security rules present?\");\n parts.push(\"- Is there a continuity rule for session memory?\");\n parts.push(\"- Are there unnecessary MCP servers adding context bloat?\");\n parts.push(\"- Are hooks configured in settings.json for destructive command blocking?\");\n parts.push(\"- Are there path-scoped rules for different code domains (api, testing, frontend)?\");\n parts.push(\"- Does the project have a /project:status command with live git output?\");\n parts.push(\"- Is there a /project:fix command for issue-driven development?\");\n if (profile.claudeMdLineCount > 200) {\n parts.push(`- CLAUDE.md is ${profile.claudeMdLineCount} lines — needs aggressive trimming`);\n }\n if (!profile.existingCommands.includes(\"help\")) {\n parts.push(\"- Missing /project:help command\");\n }\n if (!profile.existingRules.includes(\"security\")) {\n parts.push(\"- Missing security rules\");\n }\n } else {\n parts.push(`\\n## Task\\n`);\n parts.push(\"Generate an optimal Claude Code environment for this existing project.\");\n parts.push(\"Use the scanned project profile — this is a real codebase, not a description.\");\n parts.push(\"The environment should match the actual tech stack, dependencies, and workflows.\");\n }\n\n return parts.join(\"\\n\");\n}\n\nexport const optimizeCommand = new Command(\"optimize\")\n .description(\"Scan an existing project and generate or optimize its Claude Code environment\")\n .option(\"-y, --yes\", \"Skip confirmation prompts\")\n .option(\"--audit-only\", \"Only audit the existing harness, don't generate changes\")\n .action(async (options: { yes?: boolean; auditOnly?: boolean }) => {\n const config = await loadConfig();\n if (!config) {\n console.log(\n chalk.red(\"\\n No config found. Run \") +\n chalk.bold(\"kairn init\") +\n chalk.red(\" first.\\n\")\n );\n process.exit(1);\n }\n\n const targetDir = process.cwd();\n\n // 1. Scan\n console.log(chalk.dim(\"\\n Scanning project...\"));\n const profile = await scanProject(targetDir);\n\n // 2. Show profile\n console.log(chalk.cyan(\"\\n Project Profile\\n\"));\n if (profile.language) console.log(chalk.dim(` Language: ${profile.language}`));\n if (profile.framework) console.log(chalk.dim(` Framework: ${profile.framework}`));\n console.log(chalk.dim(` Dependencies: ${profile.dependencies.length}`));\n if (profile.testCommand) console.log(chalk.dim(` Tests: ${profile.testCommand}`));\n if (profile.buildCommand) console.log(chalk.dim(` Build: ${profile.buildCommand}`));\n if (profile.hasDocker) console.log(chalk.dim(\" Docker: yes\"));\n if (profile.hasCi) console.log(chalk.dim(\" CI/CD: yes\"));\n if (profile.envKeys.length > 0) console.log(chalk.dim(` Env keys: ${profile.envKeys.join(\", \")}`));\n\n // 3. Audit existing harness\n if (profile.hasClaudeDir) {\n console.log(chalk.yellow(\"\\n Existing .claude/ harness detected\\n\"));\n console.log(chalk.dim(` CLAUDE.md: ${profile.claudeMdLineCount} lines${profile.claudeMdLineCount > 200 ? chalk.yellow(\" ⚠ bloated\") : chalk.green(\" ✓\")}`));\n console.log(chalk.dim(` MCP servers: ${profile.mcpServerCount}`));\n console.log(chalk.dim(` Commands: ${profile.existingCommands.length > 0 ? profile.existingCommands.map(c => c).join(\", \") : \"none\"}`));\n console.log(chalk.dim(` Rules: ${profile.existingRules.length > 0 ? profile.existingRules.join(\", \") : \"none\"}`));\n console.log(chalk.dim(` Skills: ${profile.existingSkills.length > 0 ? profile.existingSkills.join(\", \") : \"none\"}`));\n console.log(chalk.dim(` Agents: ${profile.existingAgents.length > 0 ? profile.existingAgents.join(\", \") : \"none\"}`));\n\n // Quick audit checks\n const issues: string[] = [];\n if (profile.claudeMdLineCount > 200) issues.push(\"CLAUDE.md over 200 lines — move detail to rules/ or docs/\");\n if (!profile.existingCommands.includes(\"help\")) issues.push(\"Missing /project:help command\");\n if (!profile.existingRules.includes(\"security\")) issues.push(\"Missing security rules\");\n if (!profile.existingRules.includes(\"continuity\")) issues.push(\"Missing continuity rule for session memory\");\n if (profile.mcpServerCount > 8) issues.push(`${profile.mcpServerCount} MCP servers — may cause context bloat`);\n if (profile.mcpServerCount === 0 && profile.dependencies.length > 0) issues.push(\"No MCP servers configured\");\n if (profile.hasTests && !profile.existingCommands.includes(\"test\")) issues.push(\"Has tests but no /project:test command\");\n if (!profile.existingCommands.includes(\"tasks\")) issues.push(\"Missing /project:tasks command\");\n if (!profile.existingSettings?.hooks) issues.push(\"No hooks configured — missing destructive command blocking\");\n const scopedRules = profile.existingRules.filter(r => r !== \"security\" && r !== \"continuity\");\n if (profile.hasSrc && scopedRules.length === 0) issues.push(\"No path-scoped rules — consider adding api.md, testing.md, or frontend.md rules\");\n\n if (issues.length > 0) {\n console.log(chalk.yellow(\"\\n Issues Found:\\n\"));\n for (const issue of issues) {\n console.log(chalk.yellow(` ⚠ ${issue}`));\n }\n } else {\n console.log(chalk.green(\"\\n ✓ No obvious issues found\"));\n }\n\n if (options.auditOnly) {\n console.log(chalk.dim(\"\\n Audit complete. Run without --audit-only to generate optimized environment.\\n\"));\n return;\n }\n\n // Ask before overwriting\n if (!options.yes) {\n console.log(\"\");\n const proceed = await confirm({\n message: \"Generate optimized environment? This will overwrite existing .claude/ files.\",\n default: false,\n });\n if (!proceed) {\n console.log(chalk.dim(\"\\n Aborted.\\n\"));\n return;\n }\n }\n } else {\n console.log(chalk.dim(\"\\n No existing .claude/ directory found — generating from scratch.\\n\"));\n\n if (!options.yes) {\n const proceed = await confirm({\n message: \"Generate Claude Code environment for this project?\",\n default: true,\n });\n if (!proceed) {\n console.log(chalk.dim(\"\\n Aborted.\\n\"));\n return;\n }\n }\n }\n\n // 4. Compile with scanned profile\n const intent = buildOptimizeIntent(profile);\n let spec;\n try {\n spec = await compile(intent, (msg) => {\n process.stdout.write(`\\r ${chalk.dim(msg)} `);\n });\n process.stdout.write(\"\\r \\r\");\n } catch (err) {\n process.stdout.write(\"\\r \\r\");\n const msg = err instanceof Error ? err.message : String(err);\n console.log(chalk.red(`\\n Optimization failed: ${msg}\\n`));\n process.exit(1);\n }\n\n // 5. Show results\n const registry = await loadRegistry();\n const summary = summarizeSpec(spec, registry);\n\n console.log(chalk.green(\" ✓ Environment compiled\\n\"));\n console.log(chalk.cyan(\" Name: \") + spec.name);\n console.log(chalk.cyan(\" Tools: \") + summary.toolCount);\n console.log(chalk.cyan(\" Commands: \") + summary.commandCount);\n console.log(chalk.cyan(\" Rules: \") + summary.ruleCount);\n console.log(chalk.cyan(\" Skills: \") + summary.skillCount);\n console.log(chalk.cyan(\" Agents: \") + summary.agentCount);\n\n if (spec.tools.length > 0) {\n console.log(chalk.dim(\"\\n Selected tools:\"));\n for (const tool of spec.tools) {\n const regTool = registry.find((t) => t.id === tool.tool_id);\n const name = regTool?.name || tool.tool_id;\n console.log(chalk.dim(` - ${name}: ${tool.reason}`));\n }\n }\n\n if (summary.pluginCommands.length > 0) {\n console.log(chalk.yellow(\"\\n Plugins to install manually:\"));\n for (const cmd of summary.pluginCommands) {\n console.log(chalk.yellow(` ${cmd}`));\n }\n }\n\n // 6. Write\n const written = await writeEnvironment(spec, targetDir);\n\n console.log(chalk.green(\"\\n ✓ Environment written\\n\"));\n for (const file of written) {\n console.log(chalk.dim(` ${file}`));\n }\n\n if (summary.envSetup.length > 0) {\n console.log(chalk.yellow(\"\\n API keys needed (set these environment variables):\\n\"));\n const seen = new Set<string>();\n for (const env of summary.envSetup) {\n if (seen.has(env.envVar)) continue;\n seen.add(env.envVar);\n console.log(chalk.bold(` export ${env.envVar}=\"your-key-here\"`));\n console.log(chalk.dim(` ${env.description}`));\n if (env.signupUrl) {\n console.log(chalk.dim(` Get one at: ${env.signupUrl}`));\n }\n console.log(\"\");\n }\n }\n\n if (summary.pluginCommands.length > 0) {\n console.log(chalk.yellow(\" Install plugins by running these in Claude Code:\"));\n for (const cmd of summary.pluginCommands) {\n console.log(chalk.bold(` ${cmd}`));\n }\n }\n\n console.log(\n chalk.cyan(\"\\n Ready! Run \") +\n chalk.bold(\"claude\") +\n chalk.cyan(\" to start.\\n\")\n );\n });\n","import fs from \"fs/promises\";\nimport path from \"path\";\n\nexport interface ProjectProfile {\n // Core identity\n name: string;\n description: string;\n directory: string;\n\n // Language & framework\n language: string | null;\n framework: string | null;\n typescript: boolean;\n\n // Dependencies\n dependencies: string[];\n devDependencies: string[];\n\n // Scripts & commands\n scripts: Record<string, string>;\n hasTests: boolean;\n testCommand: string | null;\n buildCommand: string | null;\n lintCommand: string | null;\n\n // Project structure\n hasSrc: boolean;\n hasDocker: boolean;\n hasCi: boolean;\n hasEnvFile: boolean;\n envKeys: string[]; // from .env.example only — never read .env values\n\n // Existing harness\n hasClaudeDir: boolean;\n existingClaudeMd: string | null;\n existingSettings: Record<string, unknown> | null;\n existingMcpConfig: Record<string, unknown> | null;\n existingCommands: string[];\n existingRules: string[];\n existingSkills: string[];\n existingAgents: string[];\n mcpServerCount: number;\n claudeMdLineCount: number;\n\n // Key files found\n keyFiles: string[];\n}\n\nasync function fileExists(p: string): Promise<boolean> {\n try {\n await fs.access(p);\n return true;\n } catch {\n return false;\n }\n}\n\nasync function readJsonSafe(p: string): Promise<Record<string, unknown> | null> {\n try {\n const data = await fs.readFile(p, \"utf-8\");\n return JSON.parse(data);\n } catch {\n return null;\n }\n}\n\nasync function readFileSafe(p: string): Promise<string | null> {\n try {\n return await fs.readFile(p, \"utf-8\");\n } catch {\n return null;\n }\n}\n\nasync function listDirSafe(p: string): Promise<string[]> {\n try {\n const entries = await fs.readdir(p);\n return entries.filter((e) => !e.startsWith(\".\"));\n } catch {\n return [];\n }\n}\n\nfunction detectFramework(deps: string[]): string | null {\n const frameworks: [string[], string][] = [\n [[\"next\"], \"Next.js\"],\n [[\"nuxt\"], \"Nuxt\"],\n [[\"@remix-run/node\", \"@remix-run/react\"], \"Remix\"],\n [[\"svelte\", \"@sveltejs/kit\"], \"SvelteKit\"],\n [[\"express\"], \"Express\"],\n [[\"fastify\"], \"Fastify\"],\n [[\"hono\"], \"Hono\"],\n [[\"react\", \"react-dom\"], \"React\"],\n [[\"vue\"], \"Vue\"],\n [[\"angular\"], \"Angular\"],\n [[\"django\"], \"Django\"],\n [[\"flask\"], \"Flask\"],\n [[\"fastapi\"], \"FastAPI\"],\n [[\"@supabase/supabase-js\"], \"Supabase\"],\n [[\"prisma\", \"@prisma/client\"], \"Prisma\"],\n [[\"drizzle-orm\"], \"Drizzle\"],\n [[\"tailwindcss\"], \"Tailwind CSS\"],\n ];\n\n const detected: string[] = [];\n for (const [packages, name] of frameworks) {\n if (packages.some((pkg) => deps.includes(pkg))) {\n detected.push(name);\n }\n }\n return detected.length > 0 ? detected.join(\" + \") : null;\n}\n\nfunction detectLanguage(dir: string, keyFiles: string[]): string | null {\n if (keyFiles.some((f) => f === \"tsconfig.json\")) return \"TypeScript\";\n if (keyFiles.some((f) => f === \"package.json\")) return \"JavaScript\";\n if (keyFiles.some((f) => f === \"pyproject.toml\" || f === \"setup.py\" || f === \"requirements.txt\")) return \"Python\";\n if (keyFiles.some((f) => f === \"Cargo.toml\")) return \"Rust\";\n if (keyFiles.some((f) => f === \"go.mod\")) return \"Go\";\n if (keyFiles.some((f) => f === \"Gemfile\")) return \"Ruby\";\n return null;\n}\n\nfunction extractEnvKeys(content: string): string[] {\n const keys: string[] = [];\n for (const line of content.split(\"\\n\")) {\n const match = line.match(/^([A-Z][A-Z0-9_]*)=/);\n if (match) keys.push(match[1]);\n }\n return keys;\n}\n\nexport async function scanProject(dir: string): Promise<ProjectProfile> {\n // Read package.json\n const pkg = await readJsonSafe(path.join(dir, \"package.json\")) as Record<string, unknown> | null;\n const deps = pkg?.dependencies ? Object.keys(pkg.dependencies as Record<string, string>) : [];\n const devDeps = pkg?.devDependencies ? Object.keys(pkg.devDependencies as Record<string, string>) : [];\n const allDeps = [...deps, ...devDeps];\n const scripts = (pkg?.scripts || {}) as Record<string, string>;\n\n // Detect key files\n const rootFiles = await listDirSafe(dir);\n const keyFiles = rootFiles.filter((f) =>\n [\n \"package.json\", \"tsconfig.json\", \"pyproject.toml\", \"setup.py\",\n \"requirements.txt\", \"Cargo.toml\", \"go.mod\", \"Gemfile\",\n \"docker-compose.yml\", \"Dockerfile\", \".env.example\", \".env\",\n \"README.md\", \"CLAUDE.md\",\n ].includes(f)\n );\n\n // Detect language & framework\n const language = detectLanguage(dir, keyFiles);\n const framework = detectFramework(allDeps);\n const typescript = keyFiles.includes(\"tsconfig.json\") || allDeps.includes(\"typescript\");\n\n // Test detection\n const testCommand = scripts.test && scripts.test !== 'echo \"Error: no test specified\" && exit 1'\n ? scripts.test : null;\n const hasTests = testCommand !== null ||\n await fileExists(path.join(dir, \"tests\")) ||\n await fileExists(path.join(dir, \"__tests__\")) ||\n await fileExists(path.join(dir, \"test\"));\n\n // Build & lint\n const buildCommand = scripts.build || null;\n const lintCommand = scripts.lint || null;\n\n // Structure\n const hasSrc = await fileExists(path.join(dir, \"src\"));\n const hasDocker = await fileExists(path.join(dir, \"docker-compose.yml\")) ||\n await fileExists(path.join(dir, \"Dockerfile\"));\n const hasCi = await fileExists(path.join(dir, \".github/workflows\"));\n\n // Env keys (from .env.example only — never read actual .env values)\n const hasEnvFile = await fileExists(path.join(dir, \".env\")) ||\n await fileExists(path.join(dir, \".env.example\"));\n let envKeys: string[] = [];\n const envExample = await readFileSafe(path.join(dir, \".env.example\"));\n if (envExample) {\n envKeys = extractEnvKeys(envExample);\n }\n\n // Existing .claude/ harness\n const claudeDir = path.join(dir, \".claude\");\n const hasClaudeDir = await fileExists(claudeDir);\n let existingClaudeMd: string | null = null;\n let existingSettings: Record<string, unknown> | null = null;\n let existingMcpConfig: Record<string, unknown> | null = null;\n let existingCommands: string[] = [];\n let existingRules: string[] = [];\n let existingSkills: string[] = [];\n let existingAgents: string[] = [];\n let mcpServerCount = 0;\n let claudeMdLineCount = 0;\n\n if (hasClaudeDir) {\n existingClaudeMd = await readFileSafe(path.join(claudeDir, \"CLAUDE.md\"));\n if (existingClaudeMd) {\n claudeMdLineCount = existingClaudeMd.split(\"\\n\").length;\n }\n\n existingSettings = await readJsonSafe(path.join(claudeDir, \"settings.json\"));\n existingMcpConfig = await readJsonSafe(path.join(dir, \".mcp.json\"));\n if (existingMcpConfig?.mcpServers) {\n mcpServerCount = Object.keys(existingMcpConfig.mcpServers as Record<string, unknown>).length;\n }\n\n existingCommands = (await listDirSafe(path.join(claudeDir, \"commands\")))\n .filter((f) => f.endsWith(\".md\"))\n .map((f) => f.replace(\".md\", \"\"));\n existingRules = (await listDirSafe(path.join(claudeDir, \"rules\")))\n .filter((f) => f.endsWith(\".md\"))\n .map((f) => f.replace(\".md\", \"\"));\n existingSkills = await listDirSafe(path.join(claudeDir, \"skills\"));\n existingAgents = (await listDirSafe(path.join(claudeDir, \"agents\")))\n .filter((f) => f.endsWith(\".md\"))\n .map((f) => f.replace(\".md\", \"\"));\n }\n\n // Project name & description\n const name = (pkg?.name as string) || path.basename(dir);\n const description = (pkg?.description as string) || \"\";\n\n return {\n name,\n description,\n directory: dir,\n language,\n framework,\n typescript,\n dependencies: deps,\n devDependencies: devDeps,\n scripts,\n hasTests,\n testCommand,\n buildCommand,\n lintCommand,\n hasSrc,\n hasDocker,\n hasCi,\n hasEnvFile,\n envKeys,\n hasClaudeDir,\n existingClaudeMd,\n existingSettings,\n existingMcpConfig,\n existingCommands,\n existingRules,\n existingSkills,\n existingAgents,\n mcpServerCount,\n claudeMdLineCount,\n keyFiles,\n };\n}\n"],"mappings":";AAAA,SAAS,WAAAA,gBAAe;;;ACAxB,SAAS,eAAe;AACxB,SAAS,UAAU,cAAc;AACjC,OAAO,WAAW;AAClB,OAAO,eAAe;AACtB,OAAO,YAAY;AACnB,SAAS,oBAAoB;;;ACL7B,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,OAAO,QAAQ;AAGf,IAAM,YAAY,KAAK,KAAK,GAAG,QAAQ,GAAG,QAAQ;AAClD,IAAM,cAAc,KAAK,KAAK,WAAW,aAAa;AACtD,IAAM,WAAW,KAAK,KAAK,WAAW,MAAM;AAMrC,SAAS,gBAAwB;AACtC,SAAO;AACT;AAEO,SAAS,aAAqB;AACnC,SAAO;AACT;AAEA,eAAsB,aAA4B;AAChD,QAAM,GAAG,MAAM,WAAW,EAAE,WAAW,KAAK,CAAC;AAC7C,QAAM,GAAG,MAAM,UAAU,EAAE,WAAW,KAAK,CAAC;AAC9C;AAEA,eAAsB,aAA0C;AAC9D,MAAI;AACF,UAAM,OAAO,MAAM,GAAG,SAAS,aAAa,OAAO;AACnD,UAAM,MAAM,KAAK,MAAM,IAAI;AAG3B,QAAI,IAAI,qBAAqB,CAAC,IAAI,UAAU;AAC1C,aAAO;AAAA,QACL,UAAU;AAAA,QACV,SAAS,IAAI;AAAA,QACb,OAAO;AAAA,QACP,iBAAiB;AAAA,QACjB,YAAa,IAAI,eAAyB,oBAAI,KAAK,GAAE,YAAY;AAAA,MACnE;AAAA,IACF;AAEA,WAAO;AAAA,EACT,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEA,eAAsB,WAAW,QAAoC;AACnE,QAAM,WAAW;AAC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BA,OAAM,KAAK,cAAc;AAAA,EAC7B;AACF,CAAC;;;AVrRH,IAAM,UAAU,IAAIE,SAAQ;AAE5B,QACG,KAAK,OAAO,EACZ;AAAA,EACC;AACF,EACC,QAAQ,OAAO;AAElB,QAAQ,WAAW,WAAW;AAC9B,QAAQ,WAAW,eAAe;AAClC,QAAQ,WAAW,eAAe;AAClC,QAAQ,WAAW,WAAW;AAC9B,QAAQ,WAAW,eAAe;AAClC,QAAQ,WAAW,qBAAqB;AAExC,QAAQ,MAAM;","names":["Command","Command","chalk","fs","path","fs","path","Anthropic","OpenAI","path","fs","Anthropic","OpenAI","fs","path","fileURLToPath","loadRegistry","path","fs","Command","chalk","Command","chalk","fs","path","Command","fs","chalk","path","Command","chalk","fs","path","Command","fs","chalk","path","Command","chalk","fs","path","fileURLToPath","Command","confirm","chalk","fs","path","fileURLToPath","fs","path","loadRegistry","fileURLToPath","path","fs","Command","chalk","confirm","Command"]}
|
package/package.json
CHANGED
package/src/registry/tools.json
CHANGED
|
@@ -554,5 +554,327 @@
|
|
|
554
554
|
"install": {
|
|
555
555
|
"plugin_command": "/plugin install frontend-design@claude-plugins-official"
|
|
556
556
|
}
|
|
557
|
+
},
|
|
558
|
+
{
|
|
559
|
+
"id": "sentry",
|
|
560
|
+
"name": "Sentry",
|
|
561
|
+
"description": "Error monitoring, performance tracking, and issue management for production applications.",
|
|
562
|
+
"category": "code_devtools",
|
|
563
|
+
"tier": 3,
|
|
564
|
+
"type": "mcp_server",
|
|
565
|
+
"auth": "api_key",
|
|
566
|
+
"best_for": [
|
|
567
|
+
"error-tracking",
|
|
568
|
+
"monitoring",
|
|
569
|
+
"debugging",
|
|
570
|
+
"production"
|
|
571
|
+
],
|
|
572
|
+
"install": {
|
|
573
|
+
"mcp_config": {
|
|
574
|
+
"sentry": {
|
|
575
|
+
"command": "npx",
|
|
576
|
+
"args": [
|
|
577
|
+
"-y",
|
|
578
|
+
"@sentry/mcp-server"
|
|
579
|
+
],
|
|
580
|
+
"env": {
|
|
581
|
+
"SENTRY_AUTH_TOKEN": "${SENTRY_AUTH_TOKEN}"
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
},
|
|
586
|
+
"env_vars": [
|
|
587
|
+
{
|
|
588
|
+
"name": "SENTRY_AUTH_TOKEN",
|
|
589
|
+
"description": "Sentry auth token (Settings > Auth Tokens)"
|
|
590
|
+
}
|
|
591
|
+
],
|
|
592
|
+
"signup_url": "https://sentry.io/signup/"
|
|
593
|
+
},
|
|
594
|
+
{
|
|
595
|
+
"id": "vercel",
|
|
596
|
+
"name": "Vercel",
|
|
597
|
+
"description": "Deploy, manage, and monitor Vercel projects and serverless functions.",
|
|
598
|
+
"category": "data_infrastructure",
|
|
599
|
+
"tier": 3,
|
|
600
|
+
"type": "mcp_server",
|
|
601
|
+
"auth": "api_key",
|
|
602
|
+
"best_for": [
|
|
603
|
+
"deployment",
|
|
604
|
+
"hosting",
|
|
605
|
+
"serverless",
|
|
606
|
+
"vercel"
|
|
607
|
+
],
|
|
608
|
+
"install": {
|
|
609
|
+
"mcp_config": {
|
|
610
|
+
"vercel": {
|
|
611
|
+
"command": "npx",
|
|
612
|
+
"args": [
|
|
613
|
+
"-y",
|
|
614
|
+
"@vercel/mcp-server"
|
|
615
|
+
],
|
|
616
|
+
"env": {
|
|
617
|
+
"VERCEL_TOKEN": "${VERCEL_TOKEN}"
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
},
|
|
622
|
+
"env_vars": [
|
|
623
|
+
{
|
|
624
|
+
"name": "VERCEL_TOKEN",
|
|
625
|
+
"description": "Vercel personal access token (Settings > Tokens)"
|
|
626
|
+
}
|
|
627
|
+
],
|
|
628
|
+
"signup_url": "https://vercel.com/account/tokens"
|
|
629
|
+
},
|
|
630
|
+
{
|
|
631
|
+
"id": "docker",
|
|
632
|
+
"name": "Docker Toolkit",
|
|
633
|
+
"description": "Build, run, and manage Docker containers and images.",
|
|
634
|
+
"category": "data_infrastructure",
|
|
635
|
+
"tier": 3,
|
|
636
|
+
"type": "mcp_server",
|
|
637
|
+
"auth": "none",
|
|
638
|
+
"best_for": [
|
|
639
|
+
"containers",
|
|
640
|
+
"docker",
|
|
641
|
+
"devops",
|
|
642
|
+
"infrastructure"
|
|
643
|
+
],
|
|
644
|
+
"install": {
|
|
645
|
+
"mcp_config": {
|
|
646
|
+
"docker": {
|
|
647
|
+
"command": "npx",
|
|
648
|
+
"args": [
|
|
649
|
+
"-y",
|
|
650
|
+
"@docker/mcp-server"
|
|
651
|
+
]
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
},
|
|
656
|
+
{
|
|
657
|
+
"id": "chrome-devtools",
|
|
658
|
+
"name": "Chrome DevTools",
|
|
659
|
+
"description": "Browser debugging, network inspection, and performance profiling.",
|
|
660
|
+
"category": "browser_automation",
|
|
661
|
+
"tier": 3,
|
|
662
|
+
"type": "plugin",
|
|
663
|
+
"auth": "none",
|
|
664
|
+
"best_for": [
|
|
665
|
+
"debugging",
|
|
666
|
+
"frontend",
|
|
667
|
+
"web-dev",
|
|
668
|
+
"performance"
|
|
669
|
+
],
|
|
670
|
+
"install": {
|
|
671
|
+
"plugin_command": "/plugin install chrome-devtools@claude-plugins-official"
|
|
672
|
+
}
|
|
673
|
+
},
|
|
674
|
+
{
|
|
675
|
+
"id": "sqlite",
|
|
676
|
+
"name": "SQLite",
|
|
677
|
+
"description": "Local SQLite database operations for development and prototyping.",
|
|
678
|
+
"category": "data_infrastructure",
|
|
679
|
+
"tier": 3,
|
|
680
|
+
"type": "mcp_server",
|
|
681
|
+
"auth": "none",
|
|
682
|
+
"best_for": [
|
|
683
|
+
"database",
|
|
684
|
+
"prototyping",
|
|
685
|
+
"local-dev",
|
|
686
|
+
"sql"
|
|
687
|
+
],
|
|
688
|
+
"install": {
|
|
689
|
+
"mcp_config": {
|
|
690
|
+
"sqlite": {
|
|
691
|
+
"command": "npx",
|
|
692
|
+
"args": [
|
|
693
|
+
"-y",
|
|
694
|
+
"@anthropic/mcp-server-sqlite"
|
|
695
|
+
]
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
},
|
|
700
|
+
{
|
|
701
|
+
"id": "stripe",
|
|
702
|
+
"name": "Stripe",
|
|
703
|
+
"description": "Payment processing, subscription management, and billing operations.",
|
|
704
|
+
"category": "data_infrastructure",
|
|
705
|
+
"tier": 4,
|
|
706
|
+
"type": "mcp_server",
|
|
707
|
+
"auth": "api_key",
|
|
708
|
+
"best_for": [
|
|
709
|
+
"payments",
|
|
710
|
+
"billing",
|
|
711
|
+
"e-commerce",
|
|
712
|
+
"stripe"
|
|
713
|
+
],
|
|
714
|
+
"install": {
|
|
715
|
+
"mcp_config": {
|
|
716
|
+
"stripe": {
|
|
717
|
+
"command": "npx",
|
|
718
|
+
"args": [
|
|
719
|
+
"-y",
|
|
720
|
+
"@stripe/mcp-server"
|
|
721
|
+
],
|
|
722
|
+
"env": {
|
|
723
|
+
"STRIPE_SECRET_KEY": "${STRIPE_SECRET_KEY}"
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
},
|
|
728
|
+
"env_vars": [
|
|
729
|
+
{
|
|
730
|
+
"name": "STRIPE_SECRET_KEY",
|
|
731
|
+
"description": "Stripe secret key (Dashboard > Developers > API keys)"
|
|
732
|
+
}
|
|
733
|
+
],
|
|
734
|
+
"signup_url": "https://dashboard.stripe.com/apikeys"
|
|
735
|
+
},
|
|
736
|
+
{
|
|
737
|
+
"id": "memory",
|
|
738
|
+
"name": "Memory (Knowledge Graph)",
|
|
739
|
+
"description": "Persistent knowledge graph for storing entities, relations, and project context across sessions.",
|
|
740
|
+
"category": "reasoning",
|
|
741
|
+
"tier": 4,
|
|
742
|
+
"type": "mcp_server",
|
|
743
|
+
"auth": "none",
|
|
744
|
+
"best_for": [
|
|
745
|
+
"context-management",
|
|
746
|
+
"knowledge-base",
|
|
747
|
+
"memory",
|
|
748
|
+
"long-running"
|
|
749
|
+
],
|
|
750
|
+
"install": {
|
|
751
|
+
"mcp_config": {
|
|
752
|
+
"memory": {
|
|
753
|
+
"command": "npx",
|
|
754
|
+
"args": [
|
|
755
|
+
"-y",
|
|
756
|
+
"@anthropic/mcp-server-memory"
|
|
757
|
+
]
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
},
|
|
762
|
+
{
|
|
763
|
+
"id": "e2b",
|
|
764
|
+
"name": "E2B Sandbox",
|
|
765
|
+
"description": "Secure cloud sandboxes for executing untrusted code and running experiments.",
|
|
766
|
+
"category": "code_devtools",
|
|
767
|
+
"tier": 4,
|
|
768
|
+
"type": "mcp_server",
|
|
769
|
+
"auth": "api_key",
|
|
770
|
+
"best_for": [
|
|
771
|
+
"code-execution",
|
|
772
|
+
"sandboxing",
|
|
773
|
+
"experiments",
|
|
774
|
+
"data-science"
|
|
775
|
+
],
|
|
776
|
+
"install": {
|
|
777
|
+
"mcp_config": {
|
|
778
|
+
"e2b": {
|
|
779
|
+
"command": "npx",
|
|
780
|
+
"args": [
|
|
781
|
+
"-y",
|
|
782
|
+
"@e2b/mcp-server"
|
|
783
|
+
],
|
|
784
|
+
"env": {
|
|
785
|
+
"E2B_API_KEY": "${E2B_API_KEY}"
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
},
|
|
790
|
+
"env_vars": [
|
|
791
|
+
{
|
|
792
|
+
"name": "E2B_API_KEY",
|
|
793
|
+
"description": "E2B API key for cloud sandboxes"
|
|
794
|
+
}
|
|
795
|
+
],
|
|
796
|
+
"signup_url": "https://e2b.dev/dashboard"
|
|
797
|
+
},
|
|
798
|
+
{
|
|
799
|
+
"id": "gpt-researcher",
|
|
800
|
+
"name": "GPT Researcher",
|
|
801
|
+
"description": "Autonomous deep research agent for comprehensive topic investigation.",
|
|
802
|
+
"category": "search_research",
|
|
803
|
+
"tier": 5,
|
|
804
|
+
"type": "mcp_server",
|
|
805
|
+
"auth": "api_key",
|
|
806
|
+
"best_for": [
|
|
807
|
+
"deep-research",
|
|
808
|
+
"literature-review",
|
|
809
|
+
"investigation",
|
|
810
|
+
"analysis"
|
|
811
|
+
],
|
|
812
|
+
"install": {
|
|
813
|
+
"mcp_config": {
|
|
814
|
+
"gpt-researcher": {
|
|
815
|
+
"command": "npx",
|
|
816
|
+
"args": [
|
|
817
|
+
"-y",
|
|
818
|
+
"gpt-researcher-mcp"
|
|
819
|
+
],
|
|
820
|
+
"env": {
|
|
821
|
+
"OPENAI_API_KEY": "${OPENAI_API_KEY}"
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
},
|
|
826
|
+
"env_vars": [
|
|
827
|
+
{
|
|
828
|
+
"name": "OPENAI_API_KEY",
|
|
829
|
+
"description": "OpenAI API key for GPT Researcher"
|
|
830
|
+
}
|
|
831
|
+
],
|
|
832
|
+
"signup_url": "https://platform.openai.com/api-keys"
|
|
833
|
+
},
|
|
834
|
+
{
|
|
835
|
+
"id": "jira",
|
|
836
|
+
"name": "Jira",
|
|
837
|
+
"description": "Issue tracking, sprint management, and project boards for Jira.",
|
|
838
|
+
"category": "communication",
|
|
839
|
+
"tier": 5,
|
|
840
|
+
"type": "mcp_server",
|
|
841
|
+
"auth": "oauth",
|
|
842
|
+
"best_for": [
|
|
843
|
+
"project-management",
|
|
844
|
+
"issue-tracking",
|
|
845
|
+
"agile",
|
|
846
|
+
"jira"
|
|
847
|
+
],
|
|
848
|
+
"install": {
|
|
849
|
+
"mcp_config": {
|
|
850
|
+
"jira": {
|
|
851
|
+
"command": "npx",
|
|
852
|
+
"args": [
|
|
853
|
+
"-y",
|
|
854
|
+
"@anthropic/mcp-server-jira"
|
|
855
|
+
],
|
|
856
|
+
"env": {
|
|
857
|
+
"JIRA_URL": "${JIRA_URL}",
|
|
858
|
+
"JIRA_EMAIL": "${JIRA_EMAIL}",
|
|
859
|
+
"JIRA_API_TOKEN": "${JIRA_API_TOKEN}"
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
},
|
|
864
|
+
"env_vars": [
|
|
865
|
+
{
|
|
866
|
+
"name": "JIRA_URL",
|
|
867
|
+
"description": "Jira instance URL (e.g., https://yourteam.atlassian.net)"
|
|
868
|
+
},
|
|
869
|
+
{
|
|
870
|
+
"name": "JIRA_EMAIL",
|
|
871
|
+
"description": "Your Jira account email"
|
|
872
|
+
},
|
|
873
|
+
{
|
|
874
|
+
"name": "JIRA_API_TOKEN",
|
|
875
|
+
"description": "Jira API token"
|
|
876
|
+
}
|
|
877
|
+
],
|
|
878
|
+
"signup_url": "https://id.atlassian.com/manage-profile/security/api-tokens"
|
|
557
879
|
}
|
|
558
880
|
]
|