@waniwani/cli 0.0.32 → 0.0.33

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/index.js CHANGED
@@ -1286,7 +1286,7 @@ var deployCommand = new Command8("deploy").description("Deploy MCP server to Git
1286
1286
  }
1287
1287
  const spinner = ora5("Deploying to GitHub...").start();
1288
1288
  const result = await api.post(
1289
- `/api/admin/mcps/${mcpId}/deploy`,
1289
+ `/api/mcp/sandboxes/${mcpId}/deploy`,
1290
1290
  {
1291
1291
  repoName: options.repo,
1292
1292
  org: options.org,
@@ -1791,7 +1791,7 @@ var startCommand = new Command16("start").description("Start the MCP server (npm
1791
1791
  console.log();
1792
1792
  console.log(chalk9.bold("Test with MCP Inspector:"));
1793
1793
  console.log(
1794
- ` npx @modelcontextprotocol/inspector --url ${result.previewUrl}`
1794
+ ` npx @modelcontextprotocol/inspector --url ${result.previewUrl}/mcp`
1795
1795
  );
1796
1796
  console.log();
1797
1797
  console.log(
@@ -1908,7 +1908,7 @@ var useCommand = new Command19("use").description("Select an MCP to use for subs
1908
1908
  const json = globalOptions.json ?? false;
1909
1909
  try {
1910
1910
  const spinner = ora15("Fetching MCPs...").start();
1911
- const mcps = await api.get("/api/admin/mcps");
1911
+ const mcps = await api.get("/api/mcp/sandboxes");
1912
1912
  spinner.stop();
1913
1913
  const mcp = mcps.find((m) => m.name === name);
1914
1914
  if (!mcp) {
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/cli.ts","../src/commands/config/index.ts","../src/commands/config/init.ts","../src/lib/config.ts","../src/lib/errors.ts","../src/lib/output.ts","../src/commands/dev.ts","../src/lib/auth.ts","../src/lib/api.ts","../src/lib/sync.ts","../src/lib/utils.ts","../src/commands/init.ts","../src/commands/login.ts","../src/commands/logout.ts","../src/commands/mcp/index.ts","../src/commands/mcp/delete.ts","../src/commands/mcp/deploy.ts","../src/commands/mcp/file/index.ts","../src/commands/mcp/file/list.ts","../src/commands/mcp/file/read.ts","../src/commands/mcp/file/write.ts","../src/commands/mcp/list.ts","../src/commands/mcp/logs.ts","../src/commands/mcp/run-command.ts","../src/commands/mcp/start.ts","../src/commands/mcp/status.ts","../src/commands/mcp/stop.ts","../src/commands/mcp/use.ts","../src/commands/org/index.ts","../src/commands/org/list.ts","../src/commands/org/switch.ts","../src/commands/push.ts","../src/index.ts"],"sourcesContent":["import { Command } from \"commander\";\nimport { configCommand } from \"./commands/config/index.js\";\nimport { devCommand } from \"./commands/dev.js\";\nimport { initCommand } from \"./commands/init.js\";\nimport { loginCommand } from \"./commands/login.js\";\nimport { logoutCommand } from \"./commands/logout.js\";\nimport { mcpCommand } from \"./commands/mcp/index.js\";\nimport { orgCommand } from \"./commands/org/index.js\";\nimport { pushCommand } from \"./commands/push.js\";\n\nconst version = \"0.1.0\";\n\nexport const program = new Command()\n\t.name(\"waniwani\")\n\t.description(\"WaniWani CLI for MCP development workflow\")\n\t.version(version)\n\t.option(\"--json\", \"Output results as JSON\")\n\t.option(\"--verbose\", \"Enable verbose logging\");\n\n// Auth commands\nprogram.addCommand(loginCommand);\nprogram.addCommand(logoutCommand);\n\n// Main commands\nprogram.addCommand(initCommand);\nprogram.addCommand(pushCommand);\nprogram.addCommand(devCommand);\nprogram.addCommand(mcpCommand);\nprogram.addCommand(orgCommand);\nprogram.addCommand(configCommand);\n","import { Command } from \"commander\";\nimport { configInitCommand } from \"./init.js\";\n\nexport const configCommand = new Command(\"config\")\n\t.description(\"Manage WaniWani configuration\")\n\t.addCommand(configInitCommand);\n","import { existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { Command } from \"commander\";\nimport {\n\tCONFIG_FILE_NAME,\n\tinitConfigAt,\n\tLOCAL_CONFIG_DIR,\n} from \"../../lib/config.js\";\nimport { CLIError, handleError } from \"../../lib/errors.js\";\nimport { formatOutput, formatSuccess } from \"../../lib/output.js\";\n\nexport const configInitCommand = new Command(\"init\")\n\t.description(\"Initialize .waniwani config in the current directory\")\n\t.option(\"--force\", \"Overwrite existing config\")\n\t.action(async (options, command) => {\n\t\tconst globalOptions = command.optsWithGlobals();\n\t\tconst json = globalOptions.json ?? false;\n\n\t\ttry {\n\t\t\tconst cwd = process.cwd();\n\t\t\tconst configPath = join(cwd, LOCAL_CONFIG_DIR, CONFIG_FILE_NAME);\n\n\t\t\t// Check if config already exists\n\t\t\tif (existsSync(configPath) && !options.force) {\n\t\t\t\tthrow new CLIError(\n\t\t\t\t\t`Config already exists at ${configPath}. Use --force to overwrite.`,\n\t\t\t\t\t\"CONFIG_EXISTS\",\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Create .waniwani/settings.json with defaults\n\t\t\tconst result = await initConfigAt(cwd);\n\n\t\t\tif (json) {\n\t\t\t\tformatOutput({ created: result.path, config: result.config }, true);\n\t\t\t} else {\n\t\t\t\tformatSuccess(`Created ${result.path}`, false);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\thandleError(error, json);\n\t\t\tprocess.exit(1);\n\t\t}\n\t});\n","import { existsSync } from \"node:fs\";\nimport { mkdir, readFile, writeFile } from \"node:fs/promises\";\nimport { homedir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { z } from \"zod\";\n\nexport const LOCAL_CONFIG_DIR = \".waniwani\";\nexport const CONFIG_FILE_NAME = \"settings.json\";\n\nconst LOCAL_DIR = join(process.cwd(), LOCAL_CONFIG_DIR);\nconst LOCAL_FILE = join(LOCAL_DIR, CONFIG_FILE_NAME);\nconst GLOBAL_DIR = join(homedir(), LOCAL_CONFIG_DIR);\nconst GLOBAL_FILE = join(GLOBAL_DIR, CONFIG_FILE_NAME);\nconst DEFAULT_API_URL = \"https://app.waniwani.ai\";\n\nconst ConfigSchema = z.object({\n\tmcpId: z.string().nullable().default(null),\n\tapiUrl: z.string().nullable().default(null),\n});\n\ntype ConfigData = z.infer<typeof ConfigSchema>;\n\nclass Config {\n\tprivate dir: string;\n\tprivate file: string;\n\tprivate cache: ConfigData | null = null;\n\treadonly scope: \"local\" | \"global\";\n\n\tconstructor(forceGlobal = false) {\n\t\tconst useLocal = !forceGlobal && existsSync(LOCAL_DIR);\n\t\tthis.dir = useLocal ? LOCAL_DIR : GLOBAL_DIR;\n\t\tthis.file = useLocal ? LOCAL_FILE : GLOBAL_FILE;\n\t\tthis.scope = useLocal ? \"local\" : \"global\";\n\t}\n\n\tprivate async load(): Promise<ConfigData> {\n\t\tif (!this.cache) {\n\t\t\ttry {\n\t\t\t\tthis.cache = ConfigSchema.parse(\n\t\t\t\t\tJSON.parse(await readFile(this.file, \"utf-8\")),\n\t\t\t\t);\n\t\t\t} catch {\n\t\t\t\tthis.cache = ConfigSchema.parse({});\n\t\t\t}\n\t\t}\n\t\treturn this.cache;\n\t}\n\n\tprivate async save(data: ConfigData): Promise<void> {\n\t\tthis.cache = data;\n\t\tawait mkdir(this.dir, { recursive: true });\n\t\tawait writeFile(this.file, JSON.stringify(data, null, \"\\t\"));\n\t}\n\n\tasync getMcpId() {\n\t\treturn (await this.load()).mcpId;\n\t}\n\n\tasync setMcpId(id: string | null) {\n\t\tconst data = await this.load();\n\t\tdata.mcpId = id;\n\t\tawait this.save(data);\n\t}\n\n\tasync getApiUrl() {\n\t\tif (process.env.WANIWANI_API_URL) return process.env.WANIWANI_API_URL;\n\t\treturn (await this.load()).apiUrl || DEFAULT_API_URL;\n\t}\n\n\tasync setApiUrl(url: string | null) {\n\t\tconst data = await this.load();\n\t\tdata.apiUrl = url;\n\t\tawait this.save(data);\n\t}\n\n\tasync clear() {\n\t\tawait this.save(ConfigSchema.parse({}));\n\t}\n}\n\nexport const config = new Config();\nexport const globalConfig = new Config(true);\n\n/**\n * Initialize a .waniwani/settings.json at the given directory.\n * Returns the created config data and path.\n */\nexport async function initConfigAt(\n\tdir: string,\n\toverrides: Partial<ConfigData> = {},\n): Promise<{ path: string; config: ConfigData }> {\n\tconst configDir = join(dir, LOCAL_CONFIG_DIR);\n\tconst configPath = join(configDir, CONFIG_FILE_NAME);\n\n\tawait mkdir(configDir, { recursive: true });\n\n\tconst data = ConfigSchema.parse(overrides);\n\tawait writeFile(configPath, JSON.stringify(data, null, \"\\t\"), \"utf-8\");\n\n\treturn { path: configPath, config: data };\n}\n","import chalk from \"chalk\";\nimport { ZodError } from \"zod\";\n\nexport class CLIError extends Error {\n\tconstructor(\n\t\tmessage: string,\n\t\tpublic code: string,\n\t\tpublic details?: Record<string, unknown>,\n\t) {\n\t\tsuper(message);\n\t\tthis.name = \"CLIError\";\n\t}\n}\n\nexport class ConfigError extends CLIError {\n\tconstructor(message: string, details?: Record<string, unknown>) {\n\t\tsuper(message, \"CONFIG_ERROR\", details);\n\t}\n}\n\nexport class AuthError extends CLIError {\n\tconstructor(message: string, details?: Record<string, unknown>) {\n\t\tsuper(message, \"AUTH_ERROR\", details);\n\t}\n}\n\nexport class SandboxError extends CLIError {\n\tconstructor(message: string, details?: Record<string, unknown>) {\n\t\tsuper(message, \"SANDBOX_ERROR\", details);\n\t}\n}\n\nexport class GitHubError extends CLIError {\n\tconstructor(message: string, details?: Record<string, unknown>) {\n\t\tsuper(message, \"GITHUB_ERROR\", details);\n\t}\n}\n\nexport class McpError extends CLIError {\n\tconstructor(message: string, details?: Record<string, unknown>) {\n\t\tsuper(message, \"MCP_ERROR\", details);\n\t}\n}\n\nexport function handleError(error: unknown, json: boolean): void {\n\tif (error instanceof ZodError) {\n\t\tconst message = error.issues\n\t\t\t.map((e) => `${e.path.join(\".\")}: ${e.message}`)\n\t\t\t.join(\", \");\n\t\toutputError(\"VALIDATION_ERROR\", `Invalid input: ${message}`, json);\n\t} else if (error instanceof CLIError) {\n\t\toutputError(error.code, error.message, json, error.details);\n\t} else if (error instanceof Error) {\n\t\toutputError(\"UNKNOWN_ERROR\", error.message, json);\n\t} else {\n\t\toutputError(\"UNKNOWN_ERROR\", String(error), json);\n\t}\n}\n\nfunction outputError(\n\tcode: string,\n\tmessage: string,\n\tjson: boolean,\n\tdetails?: Record<string, unknown>,\n): void {\n\tif (json) {\n\t\tconsole.error(\n\t\t\tJSON.stringify({ success: false, error: { code, message, details } }),\n\t\t);\n\t} else {\n\t\tconsole.error(chalk.red(`Error [${code}]:`), message);\n\t\tif (details) {\n\t\t\tconsole.error(chalk.gray(\"Details:\"), JSON.stringify(details, null, 2));\n\t\t}\n\t}\n}\n","import chalk from \"chalk\";\n\nexport function formatOutput<T>(data: T, json: boolean): void {\n\tif (json) {\n\t\tconsole.log(JSON.stringify({ success: true, data }, null, 2));\n\t} else {\n\t\tprettyPrint(data);\n\t}\n}\n\nexport function formatSuccess(message: string, json: boolean): void {\n\tif (json) {\n\t\tconsole.log(JSON.stringify({ success: true, message }));\n\t} else {\n\t\tconsole.log(chalk.green(\"✓\"), message);\n\t}\n}\n\nexport function formatError(error: Error | string, json: boolean): void {\n\tconst message = error instanceof Error ? error.message : error;\n\tif (json) {\n\t\tconsole.error(JSON.stringify({ success: false, error: message }));\n\t} else {\n\t\tconsole.error(chalk.red(\"✗\"), message);\n\t}\n}\n\nexport function formatTable(\n\theaders: string[],\n\trows: string[][],\n\tjson: boolean,\n): void {\n\tif (json) {\n\t\tconst data = rows.map((row) =>\n\t\t\tObject.fromEntries(headers.map((header, i) => [header, row[i]])),\n\t\t);\n\t\tconsole.log(JSON.stringify({ success: true, data }, null, 2));\n\t} else {\n\t\t// Simple table formatting without external dependency\n\t\tconst colWidths = headers.map((h, i) =>\n\t\t\tMath.max(h.length, ...rows.map((r) => (r[i] || \"\").length)),\n\t\t);\n\n\t\tconst separator = colWidths.map((w) => \"-\".repeat(w + 2)).join(\"+\");\n\t\tconst formatRow = (row: string[]) =>\n\t\t\trow.map((cell, i) => ` ${(cell || \"\").padEnd(colWidths[i])} `).join(\"|\");\n\n\t\tconsole.log(chalk.cyan(formatRow(headers)));\n\t\tconsole.log(separator);\n\t\tfor (const row of rows) {\n\t\t\tconsole.log(formatRow(row));\n\t\t}\n\t}\n}\n\nexport function formatList(\n\titems: Array<{ label: string; value: string }>,\n\tjson: boolean,\n): void {\n\tif (json) {\n\t\tconst data = Object.fromEntries(\n\t\t\titems.map((item) => [item.label, item.value]),\n\t\t);\n\t\tconsole.log(JSON.stringify({ success: true, data }, null, 2));\n\t} else {\n\t\tconst maxLabelLength = Math.max(...items.map((i) => i.label.length));\n\t\titems.forEach((item) => {\n\t\t\tconsole.log(\n\t\t\t\t`${chalk.gray(item.label.padEnd(maxLabelLength))} ${chalk.white(item.value)}`,\n\t\t\t);\n\t\t});\n\t}\n}\n\nfunction prettyPrint(data: unknown, indent = 0): void {\n\tconst prefix = \" \".repeat(indent);\n\n\tif (Array.isArray(data)) {\n\t\tdata.forEach((item, index) => {\n\t\t\tconsole.log(`${prefix}${chalk.gray(`[${index}]`)}`);\n\t\t\tprettyPrint(item, indent + 1);\n\t\t});\n\t} else if (typeof data === \"object\" && data !== null) {\n\t\tfor (const [key, value] of Object.entries(data)) {\n\t\t\tif (typeof value === \"object\" && value !== null) {\n\t\t\t\tconsole.log(`${prefix}${chalk.gray(key)}:`);\n\t\t\t\tprettyPrint(value, indent + 1);\n\t\t\t} else {\n\t\t\t\tconsole.log(\n\t\t\t\t\t`${prefix}${chalk.gray(key)}: ${chalk.white(String(value))}`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t} else {\n\t\tconsole.log(`${prefix}${chalk.white(String(data))}`);\n\t}\n}\n","import { relative } from \"node:path\";\nimport chalk from \"chalk\";\nimport chokidar from \"chokidar\";\nimport { Command } from \"commander\";\nimport ora from \"ora\";\nimport { api } from \"../lib/api.js\";\nimport { CLIError, handleError } from \"../lib/errors.js\";\nimport {\n\tcollectFiles,\n\tcollectSingleFile,\n\tfindProjectRoot,\n\tloadIgnorePatterns,\n\tloadProjectMcpId,\n} from \"../lib/sync.js\";\nimport { debounce } from \"../lib/utils.js\";\nimport type { WriteFilesResponse } from \"../types/index.js\";\n\nconst BATCH_SIZE = 50;\nconst DEFAULT_DEBOUNCE_MS = 300;\n\nexport const devCommand = new Command(\"dev\")\n\t.description(\"Watch and sync files to MCP sandbox\")\n\t.option(\"--no-initial-sync\", \"Skip initial sync of all files\")\n\t.option(\n\t\t\"--debounce <ms>\",\n\t\t\"Debounce delay in milliseconds\",\n\t\tString(DEFAULT_DEBOUNCE_MS),\n\t)\n\t.action(async (options, command) => {\n\t\tconst globalOptions = command.optsWithGlobals();\n\t\tconst json = globalOptions.json ?? false;\n\n\t\ttry {\n\t\t\tconst cwd = process.cwd();\n\n\t\t\t// Find project root\n\t\t\tconst projectRoot = await findProjectRoot(cwd);\n\t\t\tif (!projectRoot) {\n\t\t\t\tthrow new CLIError(\n\t\t\t\t\t\"Not in a WaniWani project. Run 'waniwani init <name>' first.\",\n\t\t\t\t\t\"NOT_IN_PROJECT\",\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Load MCP ID\n\t\t\tconst mcpId = await loadProjectMcpId(projectRoot);\n\t\t\tif (!mcpId) {\n\t\t\t\tthrow new CLIError(\n\t\t\t\t\t\"No MCP ID found in project config. Run 'waniwani init <name>' first.\",\n\t\t\t\t\t\"NO_MCP_ID\",\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Initial sync if not disabled\n\t\t\tif (options.initialSync !== false) {\n\t\t\t\tconst spinner = ora(\"Initial sync...\").start();\n\t\t\t\tconst files = await collectFiles(projectRoot);\n\n\t\t\t\tif (files.length > 0) {\n\t\t\t\t\tconst totalBatches = Math.ceil(files.length / BATCH_SIZE);\n\t\t\t\t\tlet synced = 0;\n\n\t\t\t\t\tfor (let i = 0; i < totalBatches; i++) {\n\t\t\t\t\t\tconst batch = files.slice(i * BATCH_SIZE, (i + 1) * BATCH_SIZE);\n\t\t\t\t\t\tspinner.text = `Syncing (${i + 1}/${totalBatches})...`;\n\n\t\t\t\t\t\tconst result = await api.post<WriteFilesResponse>(\n\t\t\t\t\t\t\t`/api/mcp/sandboxes/${mcpId}/files`,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tfiles: batch.map((f) => ({\n\t\t\t\t\t\t\t\t\tpath: f.path,\n\t\t\t\t\t\t\t\t\tcontent: f.content,\n\t\t\t\t\t\t\t\t\tencoding: f.encoding,\n\t\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t);\n\t\t\t\t\t\tsynced += result.written.length;\n\t\t\t\t\t}\n\n\t\t\t\t\tspinner.succeed(`Initial sync complete (${synced} files)`);\n\t\t\t\t} else {\n\t\t\t\t\tspinner.info(\"No files to sync\");\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Load ignore patterns for watcher\n\t\t\tconst ig = await loadIgnorePatterns(projectRoot);\n\n\t\t\t// Set up debounced sync function\n\t\t\tconst debounceMs =\n\t\t\t\tNumber.parseInt(options.debounce, 10) || DEFAULT_DEBOUNCE_MS;\n\n\t\t\tconst syncFile = debounce(async (filePath: string) => {\n\t\t\t\tconst relativePath = relative(projectRoot, filePath);\n\n\t\t\t\t// Check if file should be ignored\n\t\t\t\tif (ig.ignores(relativePath)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst file = await collectSingleFile(projectRoot, relativePath);\n\t\t\t\tif (!file) {\n\t\t\t\t\tconsole.log(chalk.yellow(\"Skipped:\"), relativePath);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tawait api.post<WriteFilesResponse>(\n\t\t\t\t\t\t`/api/mcp/sandboxes/${mcpId}/files`,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tfiles: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tpath: file.path,\n\t\t\t\t\t\t\t\t\tcontent: file.content,\n\t\t\t\t\t\t\t\t\tencoding: file.encoding,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t\tconsole.log(chalk.green(\"Synced:\"), relativePath);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconsole.log(chalk.red(\"Failed:\"), relativePath);\n\t\t\t\t\tif (globalOptions.verbose) {\n\t\t\t\t\t\tconsole.error(error);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}, debounceMs);\n\n\t\t\t// Start watcher\n\t\t\tconsole.log();\n\t\t\tconsole.log(chalk.bold(\"Watching for changes...\"));\n\t\t\tconsole.log(chalk.dim(\"Press Ctrl+C to stop\"));\n\t\t\tconsole.log();\n\n\t\t\tconst watcher = chokidar.watch(projectRoot, {\n\t\t\t\tignored: (path: string) => {\n\t\t\t\t\tconst relativePath = relative(projectRoot, path);\n\t\t\t\t\treturn ig.ignores(relativePath);\n\t\t\t\t},\n\t\t\t\tpersistent: true,\n\t\t\t\tignoreInitial: true,\n\t\t\t\tawaitWriteFinish: {\n\t\t\t\t\tstabilityThreshold: 100,\n\t\t\t\t\tpollInterval: 100,\n\t\t\t\t},\n\t\t\t});\n\n\t\t\twatcher\n\t\t\t\t.on(\"add\", (path) => syncFile(path))\n\t\t\t\t.on(\"change\", (path) => syncFile(path))\n\t\t\t\t.on(\"unlink\", (path) => {\n\t\t\t\t\tconst relativePath = relative(projectRoot, path);\n\t\t\t\t\tconsole.log(chalk.yellow(\"Deleted (local only):\"), relativePath);\n\t\t\t\t});\n\n\t\t\t// Handle graceful shutdown\n\t\t\tconst cleanup = () => {\n\t\t\t\tconsole.log();\n\t\t\t\tconsole.log(chalk.dim(\"Stopping watcher...\"));\n\t\t\t\twatcher.close().then(() => {\n\t\t\t\t\tprocess.exit(0);\n\t\t\t\t});\n\t\t\t};\n\n\t\t\tprocess.on(\"SIGINT\", cleanup);\n\t\t\tprocess.on(\"SIGTERM\", cleanup);\n\t\t} catch (error) {\n\t\t\thandleError(error, json);\n\t\t\tprocess.exit(1);\n\t\t}\n\t});\n","import { access, mkdir, readFile, writeFile } from \"node:fs/promises\";\nimport { homedir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { z } from \"zod\";\nimport { config } from \"./config.js\";\n\nconst CONFIG_DIR = join(homedir(), \".waniwani\");\nconst AUTH_FILE = join(CONFIG_DIR, \"auth.json\");\n\nconst AuthStoreSchema = z.object({\n\taccessToken: z.string().nullable().default(null),\n\trefreshToken: z.string().nullable().default(null),\n\texpiresAt: z.string().nullable().default(null),\n\tclientId: z.string().nullable().default(null),\n});\n\ntype AuthStore = z.infer<typeof AuthStoreSchema>;\n\nasync function ensureConfigDir(): Promise<void> {\n\tawait mkdir(CONFIG_DIR, { recursive: true });\n}\n\nasync function readAuthStore(): Promise<AuthStore> {\n\tawait ensureConfigDir();\n\ttry {\n\t\tawait access(AUTH_FILE);\n\t\tconst content = await readFile(AUTH_FILE, \"utf-8\");\n\t\treturn AuthStoreSchema.parse(JSON.parse(content));\n\t} catch {\n\t\treturn AuthStoreSchema.parse({});\n\t}\n}\n\nasync function writeAuthStore(store: AuthStore): Promise<void> {\n\tawait ensureConfigDir();\n\tawait writeFile(AUTH_FILE, JSON.stringify(store, null, 2), \"utf-8\");\n}\n\nclass AuthManager {\n\tprivate storeCache: AuthStore | null = null;\n\n\tprivate async getStore(): Promise<AuthStore> {\n\t\tif (!this.storeCache) {\n\t\t\tthis.storeCache = await readAuthStore();\n\t\t}\n\t\treturn this.storeCache;\n\t}\n\n\tprivate async saveStore(store: AuthStore): Promise<void> {\n\t\tthis.storeCache = store;\n\t\tawait writeAuthStore(store);\n\t}\n\n\tasync isLoggedIn(): Promise<boolean> {\n\t\tconst store = await this.getStore();\n\t\treturn !!store.accessToken;\n\t}\n\n\tasync getAccessToken(): Promise<string | null> {\n\t\tconst store = await this.getStore();\n\t\treturn store.accessToken;\n\t}\n\n\tasync getRefreshToken(): Promise<string | null> {\n\t\tconst store = await this.getStore();\n\t\treturn store.refreshToken;\n\t}\n\n\tasync setTokens(\n\t\taccessToken: string,\n\t\trefreshToken: string,\n\t\texpiresIn: number,\n\t\tclientId?: string,\n\t): Promise<void> {\n\t\tconst expiresAt = new Date(Date.now() + expiresIn * 1000).toISOString();\n\t\tconst store = await this.getStore();\n\t\tstore.accessToken = accessToken;\n\t\tstore.refreshToken = refreshToken;\n\t\tstore.expiresAt = expiresAt;\n\t\tif (clientId) {\n\t\t\tstore.clientId = clientId;\n\t\t}\n\t\tawait this.saveStore(store);\n\t}\n\n\tasync clear(): Promise<void> {\n\t\tconst emptyStore = AuthStoreSchema.parse({});\n\t\tawait this.saveStore(emptyStore);\n\t}\n\n\tasync isTokenExpired(): Promise<boolean> {\n\t\tconst store = await this.getStore();\n\t\tif (!store.expiresAt) return true;\n\t\t// Consider expired 5 minutes before actual expiry\n\t\treturn new Date(store.expiresAt).getTime() - 5 * 60 * 1000 < Date.now();\n\t}\n\n\tasync tryRefreshToken(): Promise<boolean> {\n\t\tconst store = await this.getStore();\n\t\tconst { refreshToken, clientId } = store;\n\t\tif (!refreshToken || !clientId) return false;\n\n\t\ttry {\n\t\t\tconst apiUrl = await config.getApiUrl();\n\t\t\tconst response = await fetch(`${apiUrl}/api/auth/oauth2/token`, {\n\t\t\t\tmethod: \"POST\",\n\t\t\t\theaders: { \"Content-Type\": \"application/x-www-form-urlencoded\" },\n\t\t\t\tbody: new URLSearchParams({\n\t\t\t\t\tgrant_type: \"refresh_token\",\n\t\t\t\t\trefresh_token: refreshToken,\n\t\t\t\t\tclient_id: clientId,\n\t\t\t\t}).toString(),\n\t\t\t});\n\n\t\t\tif (!response.ok) {\n\t\t\t\tawait this.clear();\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst data = (await response.json()) as {\n\t\t\t\taccess_token: string;\n\t\t\t\trefresh_token: string;\n\t\t\t\texpires_in: number;\n\t\t\t};\n\n\t\t\tawait this.setTokens(\n\t\t\t\tdata.access_token,\n\t\t\t\tdata.refresh_token,\n\t\t\t\tdata.expires_in,\n\t\t\t);\n\n\t\t\treturn true;\n\t\t} catch {\n\t\t\tawait this.clear();\n\t\t\treturn false;\n\t\t}\n\t}\n}\n\nexport const auth = new AuthManager();\n","import { auth } from \"./auth.js\";\nimport { config } from \"./config.js\";\nimport { AuthError, CLIError } from \"./errors.js\";\n\nexport interface ApiResponse<T> {\n\tsuccess: boolean;\n\tdata?: T;\n\terror?: {\n\t\tcode: string;\n\t\tmessage: string;\n\t\tdetails?: Record<string, unknown>;\n\t};\n}\n\nexport class ApiError extends CLIError {\n\tconstructor(\n\t\tmessage: string,\n\t\tcode: string,\n\t\tpublic statusCode: number,\n\t\tdetails?: Record<string, unknown>,\n\t) {\n\t\tsuper(message, code, details);\n\t\tthis.name = \"ApiError\";\n\t}\n}\n\nasync function request<T>(\n\tmethod: string,\n\tpath: string,\n\toptions?: {\n\t\tbody?: unknown;\n\t\trequireAuth?: boolean;\n\t\theaders?: Record<string, string>;\n\t},\n): Promise<T> {\n\tconst {\n\t\tbody,\n\t\trequireAuth = true,\n\t\theaders: extraHeaders = {},\n\t} = options || {};\n\n\tconst headers: Record<string, string> = {\n\t\t\"Content-Type\": \"application/json\",\n\t\t...extraHeaders,\n\t};\n\n\tif (requireAuth) {\n\t\tconst token = await auth.getAccessToken();\n\t\tif (!token) {\n\t\t\tthrow new AuthError(\n\t\t\t\t\"Not logged in. Run 'waniwani login' to authenticate.\",\n\t\t\t);\n\t\t}\n\t\theaders.Authorization = `Bearer ${token}`;\n\t}\n\n\tconst baseUrl = await config.getApiUrl();\n\tconst url = `${baseUrl}${path}`;\n\n\tconst response = await fetch(url, {\n\t\tmethod,\n\t\theaders,\n\t\tbody: body ? JSON.stringify(body) : undefined,\n\t});\n\n\t// Handle empty responses (204 No Content)\n\tif (response.status === 204) {\n\t\treturn undefined as T;\n\t}\n\n\tlet data: ApiResponse<T>;\n\tlet rawBody: string | undefined;\n\n\ttry {\n\t\trawBody = await response.text();\n\t\tdata = JSON.parse(rawBody) as ApiResponse<T>;\n\t} catch {\n\t\t// JSON parsing failed - use raw body as error message\n\t\tthrow new ApiError(\n\t\t\trawBody || `Request failed with status ${response.status}`,\n\t\t\t\"API_ERROR\",\n\t\t\tresponse.status,\n\t\t\t{ statusText: response.statusText },\n\t\t);\n\t}\n\n\tif (!response.ok || data.error) {\n\t\t// Try to extract error message from various possible response formats\n\t\tconst errorMessage =\n\t\t\tdata.error?.message ||\n\t\t\t(data as unknown as { message?: string }).message ||\n\t\t\t(data as unknown as { error?: string }).error ||\n\t\t\trawBody ||\n\t\t\t`Request failed with status ${response.status}`;\n\n\t\tconst errorCode =\n\t\t\tdata.error?.code ||\n\t\t\t(data as unknown as { code?: string }).code ||\n\t\t\t\"API_ERROR\";\n\n\t\tconst errorDetails = {\n\t\t\t...data.error?.details,\n\t\t\tstatusText: response.statusText,\n\t\t\t...(data.error ? {} : { rawResponse: data }),\n\t\t};\n\n\t\tconst error = {\n\t\t\tcode: errorCode,\n\t\t\tmessage: errorMessage,\n\t\t\tdetails: errorDetails,\n\t\t};\n\n\t\t// Handle token expiration\n\t\tif (response.status === 401) {\n\t\t\tconst refreshed = await auth.tryRefreshToken();\n\t\t\tif (refreshed) {\n\t\t\t\t// Retry with new token\n\t\t\t\treturn request<T>(method, path, options);\n\t\t\t}\n\t\t\tthrow new AuthError(\n\t\t\t\t\"Session expired. Run 'waniwani login' to re-authenticate.\",\n\t\t\t);\n\t\t}\n\n\t\tthrow new ApiError(\n\t\t\terror.message,\n\t\t\terror.code,\n\t\t\tresponse.status,\n\t\t\terror.details,\n\t\t);\n\t}\n\n\treturn data.data as T;\n}\n\nexport const api = {\n\tget: <T>(path: string, options?: { requireAuth?: boolean }) =>\n\t\trequest<T>(\"GET\", path, options),\n\n\tpost: <T>(\n\t\tpath: string,\n\t\tbody?: unknown,\n\t\toptions?: { requireAuth?: boolean; headers?: Record<string, string> },\n\t) => request<T>(\"POST\", path, { body, ...options }),\n\n\tdelete: <T>(path: string, options?: { requireAuth?: boolean }) =>\n\t\trequest<T>(\"DELETE\", path, options),\n\n\tgetBaseUrl: () => config.getApiUrl(),\n};\n","import { existsSync } from \"node:fs\";\nimport { mkdir, readdir, readFile, stat, writeFile } from \"node:fs/promises\";\nimport { dirname, join, relative } from \"node:path\";\nimport ignore from \"ignore\";\nimport type { PullFilesResponse } from \"../types/index.js\";\nimport { api } from \"./api.js\";\nimport { detectBinary, isBinaryPath } from \"./utils.js\";\n\nconst PROJECT_DIR = \".waniwani\";\nconst SETTINGS_FILE = \"settings.json\";\n\n/**\n * Find the project root by walking up from the given directory\n * looking for a .waniwani directory\n */\nexport async function findProjectRoot(\n\tstartDir: string,\n): Promise<string | null> {\n\tlet current = startDir;\n\tconst root = dirname(current);\n\n\twhile (current !== root) {\n\t\tif (existsSync(join(current, PROJECT_DIR))) {\n\t\t\treturn current;\n\t\t}\n\t\tconst parent = dirname(current);\n\t\tif (parent === current) break;\n\t\tcurrent = parent;\n\t}\n\n\t// Check root as well\n\tif (existsSync(join(current, PROJECT_DIR))) {\n\t\treturn current;\n\t}\n\n\treturn null;\n}\n\n/**\n * Load the MCP ID from the project's .waniwani/settings.json\n */\nexport async function loadProjectMcpId(\n\tprojectRoot: string,\n): Promise<string | null> {\n\tconst settingsPath = join(projectRoot, PROJECT_DIR, SETTINGS_FILE);\n\ttry {\n\t\tconst content = await readFile(settingsPath, \"utf-8\");\n\t\tconst settings = JSON.parse(content);\n\t\treturn settings.mcpId ?? null;\n\t} catch {\n\t\treturn null;\n\t}\n}\n\n/**\n * Default patterns to always ignore\n */\nconst DEFAULT_IGNORE_PATTERNS = [\n\t\".waniwani\",\n\t\".git\",\n\t\"node_modules\",\n\t\".env\",\n\t\".env.*\",\n\t\".DS_Store\",\n\t\"*.log\",\n\t\".cache\",\n\t\"dist\",\n\t\"coverage\",\n\t\".turbo\",\n\t\".next\",\n\t\".nuxt\",\n\t\".vercel\",\n];\n\n/**\n * Load ignore patterns from .gitignore and add defaults\n */\nexport async function loadIgnorePatterns(\n\tprojectRoot: string,\n): Promise<ReturnType<typeof ignore>> {\n\tconst ig = ignore();\n\n\t// Add default patterns\n\tig.add(DEFAULT_IGNORE_PATTERNS);\n\n\t// Load .gitignore if it exists\n\tconst gitignorePath = join(projectRoot, \".gitignore\");\n\tif (existsSync(gitignorePath)) {\n\t\ttry {\n\t\t\tconst content = await readFile(gitignorePath, \"utf-8\");\n\t\t\tig.add(content);\n\t\t} catch {\n\t\t\t// Ignore read errors\n\t\t}\n\t}\n\n\treturn ig;\n}\n\nexport interface FileToSync {\n\tpath: string;\n\tcontent: string;\n\tencoding: \"utf8\" | \"base64\";\n}\n\n/**\n * Collect all files in a directory that should be synced\n * Respects .gitignore and default ignore patterns\n */\nexport async function collectFiles(projectRoot: string): Promise<FileToSync[]> {\n\tconst ig = await loadIgnorePatterns(projectRoot);\n\tconst files: FileToSync[] = [];\n\n\tasync function walk(dir: string) {\n\t\tconst entries = await readdir(dir, { withFileTypes: true });\n\n\t\tfor (const entry of entries) {\n\t\t\tconst fullPath = join(dir, entry.name);\n\t\t\tconst relativePath = relative(projectRoot, fullPath);\n\n\t\t\t// Check if path is ignored\n\t\t\tif (ig.ignores(relativePath)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (entry.isDirectory()) {\n\t\t\t\tawait walk(fullPath);\n\t\t\t} else if (entry.isFile()) {\n\t\t\t\ttry {\n\t\t\t\t\tconst content = await readFile(fullPath);\n\t\t\t\t\tconst isBinary = isBinaryPath(fullPath) || detectBinary(content);\n\n\t\t\t\t\tfiles.push({\n\t\t\t\t\t\tpath: relativePath,\n\t\t\t\t\t\tcontent: isBinary\n\t\t\t\t\t\t\t? content.toString(\"base64\")\n\t\t\t\t\t\t\t: content.toString(\"utf8\"),\n\t\t\t\t\t\tencoding: isBinary ? \"base64\" : \"utf8\",\n\t\t\t\t\t});\n\t\t\t\t} catch {\n\t\t\t\t\t// Skip files that can't be read\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tawait walk(projectRoot);\n\treturn files;\n}\n\n/**\n * Pull all files from a sandbox to a local directory.\n * Uses a single API call to fetch all files recursively.\n */\nexport async function pullFilesFromSandbox(\n\tmcpId: string,\n\ttargetDir: string,\n): Promise<{ count: number; files: string[] }> {\n\t// Fetch all files from the sandbox in one request\n\tconst result = await api.get<PullFilesResponse>(\n\t\t`/api/mcp/sandboxes/${mcpId}/files/pull`,\n\t);\n\n\tconst writtenFiles: string[] = [];\n\n\tfor (const file of result.files) {\n\t\tconst localPath = join(targetDir, file.path);\n\t\tconst dir = dirname(localPath);\n\n\t\t// Ensure directory exists\n\t\tawait mkdir(dir, { recursive: true });\n\n\t\t// Write file content\n\t\tif (file.encoding === \"base64\") {\n\t\t\tawait writeFile(localPath, Buffer.from(file.content, \"base64\"));\n\t\t} else {\n\t\t\tawait writeFile(localPath, file.content, \"utf8\");\n\t\t}\n\n\t\twrittenFiles.push(file.path);\n\t}\n\n\treturn { count: writtenFiles.length, files: writtenFiles };\n}\n\n/**\n * Collect a single file for syncing\n */\nexport async function collectSingleFile(\n\tprojectRoot: string,\n\tfilePath: string,\n): Promise<FileToSync | null> {\n\tconst fullPath = join(projectRoot, filePath);\n\tconst relativePath = relative(projectRoot, fullPath);\n\n\t// Check if file exists\n\tif (!existsSync(fullPath)) {\n\t\treturn null;\n\t}\n\n\ttry {\n\t\tconst fileStat = await stat(fullPath);\n\t\tif (!fileStat.isFile()) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst content = await readFile(fullPath);\n\t\tconst isBinary = isBinaryPath(fullPath) || detectBinary(content);\n\n\t\treturn {\n\t\t\tpath: relativePath,\n\t\t\tcontent: isBinary ? content.toString(\"base64\") : content.toString(\"utf8\"),\n\t\t\tencoding: isBinary ? \"base64\" : \"utf8\",\n\t\t};\n\t} catch {\n\t\treturn null;\n\t}\n}\n","/**\n * Debounce a function to limit how often it can be called\n */\n// biome-ignore lint/suspicious/noExplicitAny: Necessary for generic debounce\nexport function debounce<T extends (...args: any[]) => any>(\n\tfn: T,\n\tdelay: number,\n): (...args: Parameters<T>) => void {\n\tlet timeoutId: ReturnType<typeof setTimeout>;\n\treturn (...args: Parameters<T>) => {\n\t\tclearTimeout(timeoutId);\n\t\ttimeoutId = setTimeout(() => fn(...args), delay);\n\t};\n}\n\n/**\n * Binary file extensions that should be base64 encoded\n */\nconst BINARY_EXTENSIONS = new Set([\n\t\".png\",\n\t\".jpg\",\n\t\".jpeg\",\n\t\".gif\",\n\t\".ico\",\n\t\".webp\",\n\t\".svg\",\n\t\".woff\",\n\t\".woff2\",\n\t\".ttf\",\n\t\".eot\",\n\t\".otf\",\n\t\".zip\",\n\t\".tar\",\n\t\".gz\",\n\t\".pdf\",\n\t\".exe\",\n\t\".dll\",\n\t\".so\",\n\t\".dylib\",\n\t\".bin\",\n\t\".mp3\",\n\t\".mp4\",\n\t\".wav\",\n\t\".ogg\",\n\t\".webm\",\n]);\n\n/**\n * Check if a file path is likely a binary file based on extension\n */\nexport function isBinaryPath(filePath: string): boolean {\n\tconst ext = filePath.slice(filePath.lastIndexOf(\".\")).toLowerCase();\n\treturn BINARY_EXTENSIONS.has(ext);\n}\n\n/**\n * Detect if a buffer contains binary data by checking for null bytes\n */\nexport function detectBinary(buffer: Buffer): boolean {\n\t// Check first 8KB for null bytes\n\tconst sample = buffer.subarray(0, 8192);\n\treturn sample.includes(0);\n}\n","import { existsSync } from \"node:fs\";\nimport { mkdir, readFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { Command } from \"commander\";\nimport ora from \"ora\";\nimport { api } from \"../lib/api.js\";\nimport {\n\tCONFIG_FILE_NAME,\n\tinitConfigAt,\n\tLOCAL_CONFIG_DIR,\n} from \"../lib/config.js\";\nimport { handleError } from \"../lib/errors.js\";\nimport { formatOutput, formatSuccess } from \"../lib/output.js\";\nimport { pullFilesFromSandbox } from \"../lib/sync.js\";\nimport type { CreateMcpResponse } from \"../types/index.js\";\n\n/**\n * Load parent .waniwani/settings.json if it exists\n */\nasync function loadParentConfig(\n\tcwd: string,\n): Promise<Record<string, unknown> | null> {\n\tconst parentConfigPath = join(cwd, LOCAL_CONFIG_DIR, CONFIG_FILE_NAME);\n\tif (!existsSync(parentConfigPath)) {\n\t\treturn null;\n\t}\n\n\ttry {\n\t\tconst content = await readFile(parentConfigPath, \"utf-8\");\n\t\tconst config = JSON.parse(content);\n\t\t// Remove mcpId from parent - the new project gets its own\n\t\tconst { mcpId: _, ...rest } = config;\n\t\treturn rest;\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nexport const initCommand = new Command(\"init\")\n\t.description(\"Create a new MCP project from template\")\n\t.argument(\"<name>\", \"Name for the MCP project\")\n\t.action(async (name: string, _, command) => {\n\t\tconst globalOptions = command.optsWithGlobals();\n\t\tconst json = globalOptions.json ?? false;\n\n\t\ttry {\n\t\t\tconst cwd = process.cwd();\n\t\t\tconst projectDir = join(cwd, name);\n\n\t\t\t// Check if directory already exists\n\t\t\tif (existsSync(projectDir)) {\n\t\t\t\tif (json) {\n\t\t\t\t\tformatOutput(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tsuccess: false,\n\t\t\t\t\t\t\terror: `Directory \"${name}\" already exists`,\n\t\t\t\t\t\t},\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tconsole.error(`Error: Directory \"${name}\" already exists`);\n\t\t\t\t}\n\t\t\t\tprocess.exit(1);\n\t\t\t}\n\n\t\t\t// Create sandbox on backend (API pushes template files to sandbox)\n\t\t\tconst spinner = ora(\"Creating MCP sandbox...\").start();\n\n\t\t\tconst result = await api.post<CreateMcpResponse>(\"/api/mcp/sandboxes\", {\n\t\t\t\tname,\n\t\t\t});\n\n\t\t\tspinner.text = \"Downloading template files...\";\n\n\t\t\t// Create project directory\n\t\t\tawait mkdir(projectDir, { recursive: true });\n\n\t\t\t// Pull template files from sandbox to local directory\n\t\t\tawait pullFilesFromSandbox(result.id, projectDir);\n\n\t\t\tspinner.text = \"Setting up project config...\";\n\n\t\t\t// Create .waniwani/settings.json with mcpId\n\t\t\t// Inherit settings from parent .waniwani if it exists\n\t\t\tconst parentConfig = await loadParentConfig(cwd);\n\t\t\tawait initConfigAt(projectDir, {\n\t\t\t\t...parentConfig,\n\t\t\t\tmcpId: result.id, // Always use the new sandbox's mcpId\n\t\t\t});\n\n\t\t\tspinner.succeed(\"MCP project created\");\n\n\t\t\tif (json) {\n\t\t\t\tformatOutput(\n\t\t\t\t\t{\n\t\t\t\t\t\tsuccess: true,\n\t\t\t\t\t\tprojectDir,\n\t\t\t\t\t\tmcpId: result.id,\n\t\t\t\t\t\tsandboxId: result.sandboxId,\n\t\t\t\t\t\tpreviewUrl: result.previewUrl,\n\t\t\t\t\t},\n\t\t\t\t\ttrue,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tconsole.log();\n\t\t\t\tformatSuccess(`MCP project \"${name}\" created!`, false);\n\t\t\t\tconsole.log();\n\t\t\t\tconsole.log(` Project: ${projectDir}`);\n\t\t\t\tconsole.log(` MCP ID: ${result.id}`);\n\t\t\t\tconsole.log(` Preview URL: ${result.previewUrl}`);\n\t\t\t\tconsole.log();\n\t\t\t\tconsole.log(\"Next steps:\");\n\t\t\t\tconsole.log(` cd ${name}`);\n\t\t\t\tconsole.log(\" waniwani push # Sync files to sandbox\");\n\t\t\t\tconsole.log(\" waniwani dev # Watch mode with auto-sync\");\n\t\t\t\tconsole.log(' waniwani task \"...\" # Send tasks to Claude');\n\t\t\t}\n\t\t} catch (error) {\n\t\t\thandleError(error, json);\n\t\t\tprocess.exit(1);\n\t\t}\n\t});\n","import { spawn } from \"node:child_process\";\nimport { createServer, type Server } from \"node:http\";\nimport type { Socket } from \"node:net\";\nimport chalk from \"chalk\";\nimport { Command } from \"commander\";\nimport ora from \"ora\";\nimport { auth } from \"../lib/auth.js\";\nimport { config } from \"../lib/config.js\";\nimport { CLIError, handleError } from \"../lib/errors.js\";\nimport { formatOutput, formatSuccess } from \"../lib/output.js\";\nimport type {\n\tOAuthClientRegistrationResponse,\n\tOAuthTokenResponse,\n} from \"../types/index.js\";\n\nconst CALLBACK_PORT = 54321;\nconst CALLBACK_URL = `http://localhost:${CALLBACK_PORT}/callback`;\nconst CLIENT_NAME = \"waniwani-cli\";\n\nfunction generateCodeVerifier(): string {\n\tconst array = new Uint8Array(32);\n\tcrypto.getRandomValues(array);\n\treturn btoa(String.fromCharCode(...array))\n\t\t.replace(/\\+/g, \"-\")\n\t\t.replace(/\\//g, \"_\")\n\t\t.replace(/=+$/, \"\");\n}\n\nasync function generateCodeChallenge(verifier: string): Promise<string> {\n\tconst encoder = new TextEncoder();\n\tconst data = encoder.encode(verifier);\n\tconst hash = await crypto.subtle.digest(\"SHA-256\", data);\n\treturn btoa(String.fromCharCode(...new Uint8Array(hash)))\n\t\t.replace(/\\+/g, \"-\")\n\t\t.replace(/\\//g, \"_\")\n\t\t.replace(/=+$/, \"\");\n}\n\nfunction generateState(): string {\n\tconst array = new Uint8Array(16);\n\tcrypto.getRandomValues(array);\n\treturn Array.from(array, (b) => b.toString(16).padStart(2, \"0\")).join(\"\");\n}\n\nasync function registerClient(): Promise<OAuthClientRegistrationResponse> {\n\tconst apiUrl = await config.getApiUrl();\n\tconst response = await fetch(`${apiUrl}/api/auth/oauth2/register`, {\n\t\tmethod: \"POST\",\n\t\theaders: {\n\t\t\t\"Content-Type\": \"application/json\",\n\t\t},\n\t\tbody: JSON.stringify({\n\t\t\tclient_name: CLIENT_NAME,\n\t\t\tredirect_uris: [CALLBACK_URL],\n\t\t\tgrant_types: [\"authorization_code\", \"refresh_token\"],\n\t\t\tresponse_types: [\"code\"],\n\t\t\ttoken_endpoint_auth_method: \"none\",\n\t\t}),\n\t});\n\n\tif (!response.ok) {\n\t\tconst error = await response.json().catch(() => ({}));\n\t\tthrow new CLIError(\n\t\t\t(error as { error_description?: string }).error_description ||\n\t\t\t\t\"Failed to register OAuth client\",\n\t\t\t\"CLIENT_REGISTRATION_FAILED\",\n\t\t);\n\t}\n\n\treturn response.json() as Promise<OAuthClientRegistrationResponse>;\n}\n\nasync function openBrowser(url: string): Promise<void> {\n\tconst [cmd, ...args] =\n\t\tprocess.platform === \"darwin\"\n\t\t\t? [\"open\", url]\n\t\t\t: process.platform === \"win32\"\n\t\t\t\t? [\"cmd\", \"/c\", \"start\", url]\n\t\t\t\t: [\"xdg-open\", url];\n\n\tspawn(cmd, args, { stdio: \"ignore\", detached: true }).unref();\n}\n\nasync function waitForCallback(\n\texpectedState: string,\n\ttimeoutMs: number = 300000,\n): Promise<string> {\n\treturn new Promise((resolve, reject) => {\n\t\tlet server: Server | null = null;\n\t\tconst sockets = new Set<Socket>();\n\n\t\tconst timeout = setTimeout(() => {\n\t\t\tcleanup();\n\t\t\treject(new CLIError(\"Login timed out\", \"LOGIN_TIMEOUT\"));\n\t\t}, timeoutMs);\n\n\t\tconst cleanup = () => {\n\t\t\tclearTimeout(timeout);\n\t\t\t// Destroy all active connections to allow process to exit\n\t\t\tfor (const socket of sockets) {\n\t\t\t\tsocket.destroy();\n\t\t\t}\n\t\t\tsockets.clear();\n\t\t\tserver?.close();\n\t\t};\n\n\t\tconst htmlResponse = (title: string, message: string, isSuccess: boolean) =>\n\t\t\t`<!DOCTYPE html>\n<html>\n<head>\n <meta charset=\"UTF-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n <title>${title} - WaniWani</title>\n <style>\n * { margin: 0; padding: 0; box-sizing: border-box; }\n body {\n font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n min-height: 100vh;\n display: flex;\n align-items: center;\n justify-content: center;\n background: #fafafa;\n position: relative;\n overflow: hidden;\n }\n .blob {\n position: absolute;\n border-radius: 50%;\n filter: blur(60px);\n pointer-events: none;\n }\n .blob-1 {\n top: 0;\n left: 25%;\n width: 24rem;\n height: 24rem;\n background: linear-gradient(to bottom right, rgba(253, 224, 71, 0.3), rgba(251, 146, 60, 0.3));\n }\n .blob-2 {\n bottom: 0;\n right: 25%;\n width: 24rem;\n height: 24rem;\n background: linear-gradient(to bottom right, rgba(134, 239, 172, 0.3), rgba(52, 211, 153, 0.3));\n }\n .blob-3 {\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n width: 40rem;\n height: 40rem;\n background: linear-gradient(to bottom right, rgba(255, 237, 213, 0.2), rgba(254, 249, 195, 0.2));\n }\n .container {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 2rem;\n padding: 2rem;\n z-index: 10;\n text-align: center;\n }\n .logo {\n height: 40px;\n }\n .icon-circle {\n width: 80px;\n height: 80px;\n border-radius: 50%;\n display: flex;\n align-items: center;\n justify-content: center;\n background: ${isSuccess ? \"rgba(52, 211, 153, 0.15)\" : \"rgba(239, 68, 68, 0.15)\"};\n }\n .icon {\n width: 40px;\n height: 40px;\n color: ${isSuccess ? \"#10b981\" : \"#ef4444\"};\n }\n h1 {\n font-size: 2rem;\n font-weight: 700;\n color: #1e293b;\n }\n p {\n font-size: 1.125rem;\n color: #64748b;\n max-width: 400px;\n }\n </style>\n</head>\n<body>\n <div class=\"blob blob-1\"></div>\n <div class=\"blob blob-2\"></div>\n <div class=\"blob blob-3\"></div>\n <div class=\"container\">\n <svg class=\"logo\" viewBox=\"0 0 248 40\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <text x=\"0\" y=\"32\" font-family=\"system-ui\" font-size=\"28\" font-weight=\"bold\" fill=\"#1e293b\">WaniWani</text>\n </svg>\n <div class=\"icon-circle\">\n ${\n\t\t\t\tisSuccess\n\t\t\t\t\t? '<svg class=\"icon\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M20 6 9 17l-5-5\"></path></svg>'\n\t\t\t\t\t: '<svg class=\"icon\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M18 6 6 18\"></path><path d=\"m6 6 12 12\"></path></svg>'\n\t\t\t}\n </div>\n <h1>${title}</h1>\n <p>${message}</p>\n </div>\n</body>\n</html>`;\n\n\t\ttry {\n\t\t\tserver = createServer((req, res) => {\n\t\t\t\tconst url = new URL(\n\t\t\t\t\treq.url || \"/\",\n\t\t\t\t\t`http://localhost:${CALLBACK_PORT}`,\n\t\t\t\t);\n\n\t\t\t\tif (url.pathname === \"/callback\") {\n\t\t\t\t\tconst code = url.searchParams.get(\"code\");\n\t\t\t\t\tconst state = url.searchParams.get(\"state\");\n\t\t\t\t\tconst error = url.searchParams.get(\"error\");\n\n\t\t\t\t\tres.setHeader(\"Content-Type\", \"text/html\");\n\n\t\t\t\t\tif (error) {\n\t\t\t\t\t\tres.statusCode = 400;\n\t\t\t\t\t\tres.end(htmlResponse(\"Login Failed\", `Error: ${error}`, false));\n\t\t\t\t\t\tcleanup();\n\t\t\t\t\t\treject(new CLIError(`OAuth error: ${error}`, \"OAUTH_ERROR\"));\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (state !== expectedState) {\n\t\t\t\t\t\tres.statusCode = 400;\n\t\t\t\t\t\tres.end(\n\t\t\t\t\t\t\thtmlResponse(\n\t\t\t\t\t\t\t\t\"Login Failed\",\n\t\t\t\t\t\t\t\t\"Invalid state parameter. Please try again.\",\n\t\t\t\t\t\t\t\tfalse,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tcleanup();\n\t\t\t\t\t\treject(new CLIError(\"Invalid state parameter\", \"INVALID_STATE\"));\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (!code) {\n\t\t\t\t\t\tres.statusCode = 400;\n\t\t\t\t\t\tres.end(\n\t\t\t\t\t\t\thtmlResponse(\n\t\t\t\t\t\t\t\t\"Login Failed\",\n\t\t\t\t\t\t\t\t\"No authorization code received.\",\n\t\t\t\t\t\t\t\tfalse,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tcleanup();\n\t\t\t\t\t\treject(new CLIError(\"No authorization code\", \"NO_CODE\"));\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tres.statusCode = 200;\n\t\t\t\t\tres.end(\n\t\t\t\t\t\thtmlResponse(\n\t\t\t\t\t\t\t\"Login Successful!\",\n\t\t\t\t\t\t\t\"You can close this window and return to the terminal.\",\n\t\t\t\t\t\t\ttrue,\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\n\t\t\t\t\t// Schedule cleanup after response is sent\n\t\t\t\t\tsetTimeout(() => {\n\t\t\t\t\t\tcleanup();\n\t\t\t\t\t\tresolve(code);\n\t\t\t\t\t}, 100);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tres.statusCode = 404;\n\t\t\t\tres.end(\"Not found\");\n\t\t\t});\n\n\t\t\t// Track connections so we can force-close them\n\t\t\tserver.on(\"connection\", (socket) => {\n\t\t\t\tsockets.add(socket);\n\t\t\t\tsocket.on(\"close\", () => sockets.delete(socket));\n\t\t\t});\n\n\t\t\tserver.on(\"error\", (err: NodeJS.ErrnoException) => {\n\t\t\t\tcleanup();\n\t\t\t\tif (err.code === \"EADDRINUSE\") {\n\t\t\t\t\treject(\n\t\t\t\t\t\tnew CLIError(\n\t\t\t\t\t\t\t`Port ${CALLBACK_PORT} is already in use. Close any other WaniWani CLI instances and try again.`,\n\t\t\t\t\t\t\t\"PORT_IN_USE\",\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\treject(err);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tserver.listen(CALLBACK_PORT);\n\t\t} catch (err: unknown) {\n\t\t\tcleanup();\n\t\t\treject(err);\n\t\t}\n\t});\n}\n\nasync function exchangeCodeForToken(\n\tcode: string,\n\tcodeVerifier: string,\n\tclientId: string,\n\tresource: string,\n): Promise<OAuthTokenResponse> {\n\tconst apiUrl = await config.getApiUrl();\n\tconst response = await fetch(`${apiUrl}/api/auth/oauth2/token`, {\n\t\tmethod: \"POST\",\n\t\theaders: {\n\t\t\t\"Content-Type\": \"application/x-www-form-urlencoded\",\n\t\t},\n\t\tbody: new URLSearchParams({\n\t\t\tgrant_type: \"authorization_code\",\n\t\t\tcode,\n\t\t\tredirect_uri: CALLBACK_URL,\n\t\t\tclient_id: clientId,\n\t\t\tcode_verifier: codeVerifier,\n\t\t\tresource, // RFC 8707 - required to get JWT token\n\t\t}).toString(),\n\t});\n\n\tif (!response.ok) {\n\t\tconst error = await response.json().catch(() => ({}));\n\t\tthrow new CLIError(\n\t\t\t(error as { error_description?: string }).error_description ||\n\t\t\t\t\"Failed to exchange code for token\",\n\t\t\t\"TOKEN_EXCHANGE_FAILED\",\n\t\t);\n\t}\n\n\treturn response.json() as Promise<OAuthTokenResponse>;\n}\n\nexport const loginCommand = new Command(\"login\")\n\t.description(\"Log in to WaniWani\")\n\t.option(\"--no-browser\", \"Don't open the browser automatically\")\n\t.action(async (options, command) => {\n\t\tconst globalOptions = command.optsWithGlobals();\n\t\tconst json = globalOptions.json ?? false;\n\n\t\ttry {\n\t\t\t// Check if already logged in with a valid session\n\t\t\tif (await auth.isLoggedIn()) {\n\t\t\t\t// Check if token is expired\n\t\t\t\tif (await auth.isTokenExpired()) {\n\t\t\t\t\t// Try to refresh the token\n\t\t\t\t\tconst refreshed = await auth.tryRefreshToken();\n\t\t\t\t\tif (refreshed) {\n\t\t\t\t\t\tif (json) {\n\t\t\t\t\t\t\tformatOutput({ alreadyLoggedIn: true, refreshed: true }, true);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\tchalk.green(\"Session refreshed. You're still logged in.\"),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\t// Refresh failed, clear and proceed with login\n\t\t\t\t\tif (!json) {\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\tchalk.yellow(\"Session expired. Starting new login flow...\"),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tawait auth.clear();\n\t\t\t\t} else {\n\t\t\t\t\t// Token is valid\n\t\t\t\t\tif (json) {\n\t\t\t\t\t\tformatOutput({ alreadyLoggedIn: true }, true);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\tchalk.yellow(\n\t\t\t\t\t\t\t\t\"Already logged in. Use 'waniwani logout' to log out first.\",\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (!json) {\n\t\t\t\tconsole.log(chalk.bold(\"\\nWaniWani CLI Login\\n\"));\n\t\t\t}\n\n\t\t\tconst spinner = ora(\"Registering client...\").start();\n\n\t\t\t// Register OAuth client dynamically\n\t\t\tconst { client_id: clientId } = await registerClient();\n\n\t\t\tspinner.text = \"Preparing authentication...\";\n\n\t\t\t// Generate PKCE values\n\t\t\tconst codeVerifier = generateCodeVerifier();\n\t\t\tconst codeChallenge = await generateCodeChallenge(codeVerifier);\n\t\t\tconst state = generateState();\n\n\t\t\t// Build authorization URL\n\t\t\tconst apiUrl = await config.getApiUrl();\n\t\t\tconst authUrl = new URL(`${apiUrl}/api/auth/oauth2/authorize`);\n\t\t\tauthUrl.searchParams.set(\"client_id\", clientId);\n\t\t\tauthUrl.searchParams.set(\"redirect_uri\", CALLBACK_URL);\n\t\t\tauthUrl.searchParams.set(\"response_type\", \"code\");\n\t\t\tauthUrl.searchParams.set(\"code_challenge\", codeChallenge);\n\t\t\tauthUrl.searchParams.set(\"code_challenge_method\", \"S256\");\n\t\t\tauthUrl.searchParams.set(\"state\", state);\n\t\t\tauthUrl.searchParams.set(\"resource\", apiUrl); // RFC 8707 - request JWT token\n\n\t\t\tspinner.stop();\n\n\t\t\tif (!json) {\n\t\t\t\tconsole.log(\"Opening browser for authentication...\\n\");\n\t\t\t\tconsole.log(`If the browser doesn't open, visit:\\n`);\n\t\t\t\tconsole.log(chalk.cyan(` ${authUrl.toString()}`));\n\t\t\t\tconsole.log();\n\t\t\t}\n\n\t\t\t// Start callback server and open browser\n\t\t\tconst callbackPromise = waitForCallback(state);\n\n\t\t\tif (options.browser !== false) {\n\t\t\t\tawait openBrowser(authUrl.toString());\n\t\t\t}\n\n\t\t\tspinner.start(\"Waiting for authorization...\");\n\n\t\t\t// Wait for callback with auth code\n\t\t\tconst code = await callbackPromise;\n\n\t\t\tspinner.text = \"Exchanging code for token...\";\n\n\t\t\t// Exchange code for token\n\t\t\tconst tokenResponse = await exchangeCodeForToken(\n\t\t\t\tcode,\n\t\t\t\tcodeVerifier,\n\t\t\t\tclientId,\n\t\t\t\tapiUrl, // RFC 8707 resource parameter\n\t\t\t);\n\n\t\t\t// Store tokens and client ID for refresh\n\t\t\tawait auth.setTokens(\n\t\t\t\ttokenResponse.access_token,\n\t\t\t\ttokenResponse.refresh_token,\n\t\t\t\ttokenResponse.expires_in,\n\t\t\t\tclientId,\n\t\t\t);\n\n\t\t\tspinner.succeed(\"Logged in successfully!\");\n\n\t\t\tif (json) {\n\t\t\t\tformatOutput({ success: true, loggedIn: true }, true);\n\t\t\t} else {\n\t\t\t\tconsole.log();\n\t\t\t\tformatSuccess(\"You're now logged in to WaniWani!\", false);\n\t\t\t\tconsole.log();\n\t\t\t\tconsole.log(\"Get started:\");\n\t\t\t\tconsole.log(\n\t\t\t\t\t\" waniwani mcp create my-server Create a new MCP sandbox\",\n\t\t\t\t);\n\t\t\t\tconsole.log(' waniwani task \"Add a tool\" Send tasks to Claude');\n\t\t\t\tconsole.log(\n\t\t\t\t\t\" waniwani org list View your organizations\",\n\t\t\t\t);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\thandleError(error, json);\n\t\t\tprocess.exit(1);\n\t\t}\n\t});\n","import { Command } from \"commander\";\nimport { auth } from \"../lib/auth.js\";\nimport { handleError } from \"../lib/errors.js\";\nimport { formatOutput, formatSuccess } from \"../lib/output.js\";\n\nexport const logoutCommand = new Command(\"logout\")\n\t.description(\"Log out from WaniWani\")\n\t.action(async (_, command) => {\n\t\tconst globalOptions = command.optsWithGlobals();\n\t\tconst json = globalOptions.json ?? false;\n\n\t\ttry {\n\t\t\tif (!(await auth.isLoggedIn())) {\n\t\t\t\tif (json) {\n\t\t\t\t\tformatOutput({ alreadyLoggedOut: true }, true);\n\t\t\t\t} else {\n\t\t\t\t\tconsole.log(\"Not currently logged in.\");\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Clear auth tokens only (keep config like apiUrl intact)\n\t\t\tawait auth.clear();\n\n\t\t\tif (json) {\n\t\t\t\tformatOutput({ success: true }, true);\n\t\t\t} else {\n\t\t\t\tformatSuccess(\"You have been logged out.\", false);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\thandleError(error, json);\n\t\t\tprocess.exit(1);\n\t\t}\n\t});\n","import { Command } from \"commander\";\nimport { deleteCommand } from \"./delete.js\";\nimport { deployCommand } from \"./deploy.js\";\nimport { fileCommand } from \"./file/index.js\";\nimport { listCommand } from \"./list.js\";\nimport { logsCommand } from \"./logs.js\";\nimport { runCommandCommand } from \"./run-command.js\";\nimport { startCommand } from \"./start.js\";\nimport { statusCommand } from \"./status.js\";\nimport { stopCommand } from \"./stop.js\";\nimport { useCommand } from \"./use.js\";\n\nexport const mcpCommand = new Command(\"mcp\")\n\t.description(\"MCP sandbox management commands\")\n\t.addCommand(listCommand)\n\t.addCommand(useCommand)\n\t.addCommand(statusCommand)\n\t.addCommand(startCommand)\n\t.addCommand(stopCommand)\n\t.addCommand(logsCommand)\n\t.addCommand(deleteCommand)\n\t.addCommand(deployCommand)\n\t.addCommand(fileCommand)\n\t.addCommand(runCommandCommand);\n","import { Command } from \"commander\";\nimport ora from \"ora\";\nimport { api } from \"../../lib/api.js\";\nimport { config } from \"../../lib/config.js\";\nimport { handleError, McpError } from \"../../lib/errors.js\";\nimport { formatOutput, formatSuccess } from \"../../lib/output.js\";\n\nexport const deleteCommand = new Command(\"delete\")\n\t.description(\"Delete the MCP sandbox\")\n\t.option(\"--mcp-id <id>\", \"Specific MCP ID\")\n\t.action(async (options, command) => {\n\t\tconst globalOptions = command.optsWithGlobals();\n\t\tconst json = globalOptions.json ?? false;\n\n\t\ttry {\n\t\t\tlet mcpId = options.mcpId;\n\n\t\t\tif (!mcpId) {\n\t\t\t\tmcpId = await config.getMcpId();\n\t\t\t\tif (!mcpId) {\n\t\t\t\t\tthrow new McpError(\"No active MCP. Use --mcp-id to specify one.\");\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst spinner = ora(\"Deleting MCP sandbox...\").start();\n\t\t\tawait api.delete(`/api/mcp/sandboxes/${mcpId}`);\n\t\t\tspinner.succeed(\"MCP sandbox deleted\");\n\n\t\t\t// Clear active MCP if it was the one we deleted\n\t\t\tif ((await config.getMcpId()) === mcpId) {\n\t\t\t\tawait config.setMcpId(null);\n\t\t\t}\n\n\t\t\tif (json) {\n\t\t\t\tformatOutput({ deleted: mcpId }, true);\n\t\t\t} else {\n\t\t\t\tformatSuccess(\"MCP sandbox deleted and cleaned up.\", false);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\thandleError(error, json);\n\t\t\tprocess.exit(1);\n\t\t}\n\t});\n","import { Command } from \"commander\";\nimport ora from \"ora\";\nimport { api } from \"../../lib/api.js\";\nimport { config } from \"../../lib/config.js\";\nimport { handleError, McpError } from \"../../lib/errors.js\";\nimport { formatOutput, formatSuccess } from \"../../lib/output.js\";\nimport type { DeployResponse } from \"../../types/index.js\";\n\nexport const deployCommand = new Command(\"deploy\")\n\t.description(\"Deploy MCP server to GitHub + Vercel from sandbox\")\n\t.option(\"--repo <name>\", \"GitHub repository name\")\n\t.option(\"--org <name>\", \"GitHub organization\")\n\t.option(\"--private\", \"Create private repository\")\n\t.option(\"--mcp-id <id>\", \"Specific MCP ID\")\n\t.action(async (options, command) => {\n\t\tconst globalOptions = command.optsWithGlobals();\n\t\tconst json = globalOptions.json ?? false;\n\n\t\ttry {\n\t\t\tlet mcpId = options.mcpId;\n\n\t\t\tif (!mcpId) {\n\t\t\t\tmcpId = await config.getMcpId();\n\t\t\t\tif (!mcpId) {\n\t\t\t\t\tthrow new McpError(\n\t\t\t\t\t\t\"No active MCP. Run 'waniwani mcp create <name>' or 'waniwani mcp use <name>'.\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst spinner = ora(\"Deploying to GitHub...\").start();\n\n\t\t\tconst result = await api.post<DeployResponse>(\n\t\t\t\t`/api/admin/mcps/${mcpId}/deploy`,\n\t\t\t\t{\n\t\t\t\t\trepoName: options.repo,\n\t\t\t\t\torg: options.org,\n\t\t\t\t\tprivate: options.private ?? false,\n\t\t\t\t},\n\t\t\t);\n\n\t\t\tspinner.succeed(\"Deployment complete!\");\n\n\t\t\tif (json) {\n\t\t\t\tformatOutput(result, true);\n\t\t\t} else {\n\t\t\t\tconsole.log();\n\t\t\t\tformatSuccess(\"MCP server deployed!\", false);\n\t\t\t\tconsole.log();\n\t\t\t\tconsole.log(` Repository: ${result.repository.url}`);\n\t\t\t\tif (result.deployment.url) {\n\t\t\t\t\tconsole.log(` Deployment: ${result.deployment.url}`);\n\t\t\t\t}\n\t\t\t\tconsole.log();\n\t\t\t\tif (result.deployment.note) {\n\t\t\t\t\tconsole.log(`Note: ${result.deployment.note}`);\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (error) {\n\t\t\thandleError(error, json);\n\t\t\tprocess.exit(1);\n\t\t}\n\t});\n","import { Command } from \"commander\";\nimport { listCommand } from \"./list.js\";\nimport { readCommand } from \"./read.js\";\nimport { writeCommand } from \"./write.js\";\n\nexport const fileCommand = new Command(\"file\")\n\t.description(\"File operations in MCP sandbox\")\n\t.addCommand(readCommand)\n\t.addCommand(writeCommand)\n\t.addCommand(listCommand);\n","import chalk from \"chalk\";\nimport { Command } from \"commander\";\nimport ora from \"ora\";\nimport { api } from \"../../../lib/api.js\";\nimport { config } from \"../../../lib/config.js\";\nimport { handleError, McpError } from \"../../../lib/errors.js\";\nimport { formatOutput, formatTable } from \"../../../lib/output.js\";\nimport type { ListFilesResponse } from \"../../../types/index.js\";\n\nexport const listCommand = new Command(\"list\")\n\t.description(\"List files in the MCP sandbox\")\n\t.argument(\"[path]\", \"Directory path (defaults to /app)\", \"/app\")\n\t.option(\"--mcp-id <id>\", \"Specific MCP ID\")\n\t.action(async (path: string, options, command) => {\n\t\tconst globalOptions = command.optsWithGlobals();\n\t\tconst json = globalOptions.json ?? false;\n\n\t\ttry {\n\t\t\tlet mcpId = options.mcpId;\n\n\t\t\tif (!mcpId) {\n\t\t\t\tmcpId = await config.getMcpId();\n\t\t\t\tif (!mcpId) {\n\t\t\t\t\tthrow new McpError(\n\t\t\t\t\t\t\"No active MCP. Run 'waniwani mcp create <name>' or 'waniwani mcp use <name>'.\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst spinner = ora(`Listing ${path}...`).start();\n\n\t\t\tconst result = await api.get<ListFilesResponse>(\n\t\t\t\t`/api/mcp/sandboxes/${mcpId}/files/list?path=${encodeURIComponent(path)}`,\n\t\t\t);\n\n\t\t\tspinner.stop();\n\n\t\t\tif (json) {\n\t\t\t\tformatOutput(result, true);\n\t\t\t} else {\n\t\t\t\tconsole.log(chalk.bold(`\\nDirectory: ${result.path}\\n`));\n\n\t\t\t\tif (result.entries.length === 0) {\n\t\t\t\t\tconsole.log(\" (empty)\");\n\t\t\t\t} else {\n\t\t\t\t\tconst rows = result.entries.map((entry) => {\n\t\t\t\t\t\tconst name =\n\t\t\t\t\t\t\tentry.type === \"directory\"\n\t\t\t\t\t\t\t\t? chalk.blue(`${entry.name}/`)\n\t\t\t\t\t\t\t\t: entry.name;\n\t\t\t\t\t\tconst size =\n\t\t\t\t\t\t\tentry.type === \"directory\"\n\t\t\t\t\t\t\t\t? chalk.gray(\"<dir>\")\n\t\t\t\t\t\t\t\t: formatSize(entry.size);\n\t\t\t\t\t\treturn [name, size];\n\t\t\t\t\t});\n\n\t\t\t\t\tformatTable([\"Name\", \"Size\"], rows, false);\n\t\t\t\t}\n\t\t\t\tconsole.log();\n\t\t\t}\n\t\t} catch (error) {\n\t\t\thandleError(error, json);\n\t\t\tprocess.exit(1);\n\t\t}\n\t});\n\nfunction formatSize(bytes?: number): string {\n\tif (bytes === undefined) return \"\";\n\tif (bytes < 1024) return `${bytes} B`;\n\tif (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;\n\treturn `${(bytes / (1024 * 1024)).toFixed(1)} MB`;\n}\n","import { writeFile } from \"node:fs/promises\";\nimport { Command } from \"commander\";\nimport ora from \"ora\";\nimport { api } from \"../../../lib/api.js\";\nimport { config } from \"../../../lib/config.js\";\nimport { handleError, McpError } from \"../../../lib/errors.js\";\nimport { formatOutput, formatSuccess } from \"../../../lib/output.js\";\nimport type { ReadFileResponse } from \"../../../types/index.js\";\n\nexport const readCommand = new Command(\"read\")\n\t.description(\"Read a file from the MCP sandbox\")\n\t.argument(\"<path>\", \"Path in sandbox (e.g., /app/src/index.ts)\")\n\t.option(\"--mcp-id <id>\", \"Specific MCP ID\")\n\t.option(\"--output <file>\", \"Write to local file instead of stdout\")\n\t.option(\"--base64\", \"Output as base64 (for binary files)\")\n\t.action(async (path: string, options, command) => {\n\t\tconst globalOptions = command.optsWithGlobals();\n\t\tconst json = globalOptions.json ?? false;\n\n\t\ttry {\n\t\t\tlet mcpId = options.mcpId;\n\n\t\t\tif (!mcpId) {\n\t\t\t\tmcpId = await config.getMcpId();\n\t\t\t\tif (!mcpId) {\n\t\t\t\t\tthrow new McpError(\n\t\t\t\t\t\t\"No active MCP. Run 'waniwani mcp create <name>' or 'waniwani mcp use <name>'.\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst encoding = options.base64 ? \"base64\" : \"utf8\";\n\t\t\tconst spinner = ora(`Reading ${path}...`).start();\n\n\t\t\tconst result = await api.get<ReadFileResponse>(\n\t\t\t\t`/api/mcp/sandboxes/${mcpId}/files?path=${encodeURIComponent(path)}&encoding=${encoding}`,\n\t\t\t);\n\n\t\t\tspinner.stop();\n\n\t\t\tif (!result.exists) {\n\t\t\t\tthrow new McpError(`File not found: ${path}`);\n\t\t\t}\n\n\t\t\tif (options.output) {\n\t\t\t\t// Write to local file\n\t\t\t\tconst buffer =\n\t\t\t\t\tresult.encoding === \"base64\"\n\t\t\t\t\t\t? Buffer.from(result.content, \"base64\")\n\t\t\t\t\t\t: Buffer.from(result.content, \"utf8\");\n\t\t\t\tawait writeFile(options.output, buffer);\n\t\t\t\tif (json) {\n\t\t\t\t\tformatOutput({ path, savedTo: options.output }, true);\n\t\t\t\t} else {\n\t\t\t\t\tformatSuccess(`Saved to ${options.output}`, false);\n\t\t\t\t}\n\t\t\t} else if (json) {\n\t\t\t\tformatOutput(result, true);\n\t\t\t} else {\n\t\t\t\t// Print to stdout\n\t\t\t\tprocess.stdout.write(result.content);\n\t\t\t\t// Add newline if content doesn't end with one\n\t\t\t\tif (!result.content.endsWith(\"\\n\")) {\n\t\t\t\t\tprocess.stdout.write(\"\\n\");\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (error) {\n\t\t\thandleError(error, json);\n\t\t\tprocess.exit(1);\n\t\t}\n\t});\n","import { readFile } from \"node:fs/promises\";\nimport { Command } from \"commander\";\nimport ora from \"ora\";\nimport { api } from \"../../../lib/api.js\";\nimport { config } from \"../../../lib/config.js\";\nimport { CLIError, handleError, McpError } from \"../../../lib/errors.js\";\nimport { formatOutput, formatSuccess } from \"../../../lib/output.js\";\nimport type { WriteFilesResponse } from \"../../../types/index.js\";\n\nexport const writeCommand = new Command(\"write\")\n\t.description(\"Write a file to the MCP sandbox\")\n\t.argument(\"<path>\", \"Path in sandbox (e.g., /app/src/index.ts)\")\n\t.option(\"--mcp-id <id>\", \"Specific MCP ID\")\n\t.option(\"--content <content>\", \"Content to write\")\n\t.option(\"--file <localFile>\", \"Local file to upload\")\n\t.option(\"--base64\", \"Treat content as base64 encoded\")\n\t.action(async (path: string, options, command) => {\n\t\tconst globalOptions = command.optsWithGlobals();\n\t\tconst json = globalOptions.json ?? false;\n\n\t\ttry {\n\t\t\tlet mcpId = options.mcpId;\n\n\t\t\tif (!mcpId) {\n\t\t\t\tmcpId = await config.getMcpId();\n\t\t\t\tif (!mcpId) {\n\t\t\t\t\tthrow new McpError(\n\t\t\t\t\t\t\"No active MCP. Run 'waniwani mcp create <name>' or 'waniwani mcp use <name>'.\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Get content from --content or --file\n\t\t\tlet content: string;\n\t\t\tlet encoding: \"utf8\" | \"base64\" = \"utf8\";\n\n\t\t\tif (options.content) {\n\t\t\t\tcontent = options.content;\n\t\t\t\tif (options.base64) {\n\t\t\t\t\tencoding = \"base64\";\n\t\t\t\t}\n\t\t\t} else if (options.file) {\n\t\t\t\tconst fileBuffer = await readFile(options.file);\n\t\t\t\tif (options.base64) {\n\t\t\t\t\tcontent = fileBuffer.toString(\"base64\");\n\t\t\t\t\tencoding = \"base64\";\n\t\t\t\t} else {\n\t\t\t\t\tcontent = fileBuffer.toString(\"utf8\");\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthrow new CLIError(\n\t\t\t\t\t\"Either --content or --file is required\",\n\t\t\t\t\t\"MISSING_CONTENT\",\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst spinner = ora(`Writing ${path}...`).start();\n\n\t\t\tconst result = await api.post<WriteFilesResponse>(\n\t\t\t\t`/api/mcp/sandboxes/${mcpId}/files`,\n\t\t\t\t{\n\t\t\t\t\tfiles: [{ path, content, encoding }],\n\t\t\t\t},\n\t\t\t);\n\n\t\t\tspinner.succeed(`Wrote ${path}`);\n\n\t\t\tif (json) {\n\t\t\t\tformatOutput(result, true);\n\t\t\t} else {\n\t\t\t\tformatSuccess(`File written: ${path}`, false);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\thandleError(error, json);\n\t\t\tprocess.exit(1);\n\t\t}\n\t});\n","import chalk from \"chalk\";\nimport { Command } from \"commander\";\nimport ora from \"ora\";\nimport { api } from \"../../lib/api.js\";\nimport { config } from \"../../lib/config.js\";\nimport { handleError } from \"../../lib/errors.js\";\nimport { formatOutput, formatTable } from \"../../lib/output.js\";\nimport type { Mcp, McpListResponse } from \"../../types/index.js\";\n\nexport const listCommand = new Command(\"list\")\n\t.description(\"List all MCPs in your organization\")\n\t.option(\"--all\", \"Include stopped/expired MCPs\")\n\t.action(async (options, command) => {\n\t\tconst globalOptions = command.optsWithGlobals();\n\t\tconst json = globalOptions.json ?? false;\n\n\t\ttry {\n\t\t\tconst spinner = ora(\"Fetching MCPs...\").start();\n\n\t\t\tconst mcps = await api.get<McpListResponse>(\n\t\t\t\t`/api/mcp/sandboxes${options.all ? \"?all=true\" : \"\"}`,\n\t\t\t);\n\n\t\t\tspinner.stop();\n\n\t\t\tconst activeMcpId = await config.getMcpId();\n\n\t\t\tif (json) {\n\t\t\t\tformatOutput(\n\t\t\t\t\t{\n\t\t\t\t\t\tmcps: mcps.map((m: Mcp) => ({\n\t\t\t\t\t\t\t...m,\n\t\t\t\t\t\t\tisActive: m.id === activeMcpId,\n\t\t\t\t\t\t})),\n\t\t\t\t\t\tactiveMcpId,\n\t\t\t\t\t},\n\t\t\t\t\ttrue,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tif (mcps.length === 0) {\n\t\t\t\t\tconsole.log(\"No MCPs found.\");\n\t\t\t\t\tconsole.log(\"\\nCreate a new MCP sandbox: waniwani mcp create <name>\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconsole.log(chalk.bold(\"\\nMCPs:\\n\"));\n\n\t\t\t\tconst rows = mcps.map((m: Mcp) => {\n\t\t\t\t\tconst isActive = m.id === activeMcpId;\n\t\t\t\t\tconst statusColor =\n\t\t\t\t\t\tm.status === \"active\"\n\t\t\t\t\t\t\t? chalk.green\n\t\t\t\t\t\t\t: m.status === \"stopped\"\n\t\t\t\t\t\t\t\t? chalk.red\n\t\t\t\t\t\t\t\t: chalk.yellow;\n\n\t\t\t\t\treturn [\n\t\t\t\t\t\tisActive\n\t\t\t\t\t\t\t? chalk.cyan(`* ${m.id.slice(0, 8)}`)\n\t\t\t\t\t\t\t: ` ${m.id.slice(0, 8)}`,\n\t\t\t\t\t\tm.name,\n\t\t\t\t\t\tstatusColor(m.status),\n\t\t\t\t\t\tm.previewUrl,\n\t\t\t\t\t\tm.createdAt ? new Date(m.createdAt).toLocaleString() : \"N/A\",\n\t\t\t\t\t];\n\t\t\t\t});\n\n\t\t\t\tformatTable(\n\t\t\t\t\t[\"ID\", \"Name\", \"Status\", \"Preview URL\", \"Created\"],\n\t\t\t\t\trows,\n\t\t\t\t\tfalse,\n\t\t\t\t);\n\n\t\t\t\tconsole.log();\n\t\t\t\tif (activeMcpId) {\n\t\t\t\t\tconsole.log(`Active MCP: ${chalk.cyan(activeMcpId.slice(0, 8))}`);\n\t\t\t\t}\n\t\t\t\tconsole.log(\"\\nSelect an MCP: waniwani mcp use <name>\");\n\t\t\t}\n\t\t} catch (error) {\n\t\t\thandleError(error, json);\n\t\t\tprocess.exit(1);\n\t\t}\n\t});\n","import chalk from \"chalk\";\nimport { Command } from \"commander\";\nimport ora from \"ora\";\nimport { api } from \"../../lib/api.js\";\nimport { auth } from \"../../lib/auth.js\";\nimport { config } from \"../../lib/config.js\";\nimport { AuthError, handleError, McpError } from \"../../lib/errors.js\";\nimport { formatOutput } from \"../../lib/output.js\";\nimport type { LogEvent, ServerStatusResponse } from \"../../types/index.js\";\n\nexport const logsCommand = new Command(\"logs\")\n\t.description(\"Stream logs from the MCP server\")\n\t.argument(\"[cmdId]\", \"Command ID (defaults to running server)\")\n\t.option(\"--mcp-id <id>\", \"Specific MCP ID\")\n\t.option(\"-f, --follow\", \"Keep streaming logs (default)\", true)\n\t.option(\"--no-follow\", \"Fetch logs and exit\")\n\t.action(async (cmdIdArg: string | undefined, options, command) => {\n\t\tconst globalOptions = command.optsWithGlobals();\n\t\tconst json = globalOptions.json ?? false;\n\n\t\tlet reader: ReadableStreamDefaultReader<Uint8Array> | undefined;\n\n\t\t// Handle Ctrl+C gracefully\n\t\tconst cleanup = () => {\n\t\t\tif (reader) {\n\t\t\t\treader.cancel().catch(() => {});\n\t\t\t}\n\t\t\tprocess.exit(0);\n\t\t};\n\t\tprocess.on(\"SIGINT\", cleanup);\n\t\tprocess.on(\"SIGTERM\", cleanup);\n\n\t\ttry {\n\t\t\tlet mcpId = options.mcpId;\n\n\t\t\tif (!mcpId) {\n\t\t\t\tmcpId = await config.getMcpId();\n\t\t\t\tif (!mcpId) {\n\t\t\t\t\tthrow new McpError(\n\t\t\t\t\t\t\"No active MCP. Run 'waniwani mcp create <name>' or 'waniwani mcp use <name>'.\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst token = await auth.getAccessToken();\n\t\t\tif (!token) {\n\t\t\t\tthrow new AuthError(\n\t\t\t\t\t\"Not logged in. Run 'waniwani login' to authenticate.\",\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tlet cmdId = cmdIdArg;\n\n\t\t\t// If no cmdId provided, get it from server status\n\t\t\tif (!cmdId) {\n\t\t\t\tconst spinner = ora(\"Getting server status...\").start();\n\t\t\t\tconst status = await api.post<ServerStatusResponse>(\n\t\t\t\t\t`/api/mcp/sandboxes/${mcpId}/server`,\n\t\t\t\t\t{ action: \"status\" },\n\t\t\t\t);\n\t\t\t\tspinner.stop();\n\n\t\t\t\tif (!status.running || !status.cmdId) {\n\t\t\t\t\tthrow new McpError(\n\t\t\t\t\t\t\"No server is running. Run 'waniwani mcp start' first.\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tcmdId = status.cmdId;\n\t\t\t}\n\n\t\t\tconst baseUrl = await api.getBaseUrl();\n\t\t\tconst streamParam = options.follow ? \"?stream=true\" : \"\";\n\t\t\tconst url = `${baseUrl}/api/mcp/sandboxes/${mcpId}/commands/${cmdId}${streamParam}`;\n\n\t\t\tif (!json) {\n\t\t\t\tconsole.log(chalk.gray(`Streaming logs for command ${cmdId}...`));\n\t\t\t\tconsole.log(chalk.gray(\"Press Ctrl+C to stop\\n\"));\n\t\t\t}\n\n\t\t\tconst response = await fetch(url, {\n\t\t\t\tmethod: \"GET\",\n\t\t\t\theaders: {\n\t\t\t\t\tAuthorization: `Bearer ${token}`,\n\t\t\t\t\tAccept: options.follow ? \"text/event-stream\" : \"application/json\",\n\t\t\t\t},\n\t\t\t});\n\n\t\t\tif (!response.ok) {\n\t\t\t\tconst error = await response\n\t\t\t\t\t.json()\n\t\t\t\t\t.catch(() => ({ message: response.statusText }));\n\t\t\t\tthrow new Error(\n\t\t\t\t\terror.message || `Request failed with status ${response.status}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Non-streaming mode\n\t\t\tif (!options.follow) {\n\t\t\t\tconst data = await response.json();\n\t\t\t\tif (json) {\n\t\t\t\t\tformatOutput(data, true);\n\t\t\t\t} else {\n\t\t\t\t\tif (data.stdout) {\n\t\t\t\t\t\tprocess.stdout.write(data.stdout);\n\t\t\t\t\t}\n\t\t\t\t\tif (data.stderr) {\n\t\t\t\t\t\tprocess.stderr.write(chalk.red(data.stderr));\n\t\t\t\t\t}\n\t\t\t\t\tif (data.exitCode !== undefined) {\n\t\t\t\t\t\tconsole.log(chalk.gray(`\\nExit code: ${data.exitCode}`));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Streaming mode\n\t\t\treader = response.body?.getReader();\n\t\t\tif (!reader) {\n\t\t\t\tthrow new Error(\"No response body\");\n\t\t\t}\n\n\t\t\tconst decoder = new TextDecoder();\n\t\t\tlet buffer = \"\";\n\t\t\tconst collectedLogs: LogEvent[] = [];\n\n\t\t\twhile (true) {\n\t\t\t\tconst { done, value } = await reader.read();\n\t\t\t\tif (done) break;\n\n\t\t\t\tbuffer += decoder.decode(value, { stream: true });\n\t\t\t\tconst lines = buffer.split(\"\\n\");\n\t\t\t\tbuffer = lines.pop() || \"\";\n\n\t\t\t\tfor (const line of lines) {\n\t\t\t\t\tif (line.startsWith(\"event: \")) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (line.startsWith(\"data: \")) {\n\t\t\t\t\t\tconst data = line.slice(6);\n\t\t\t\t\t\tif (!data || data === \"[DONE]\") continue;\n\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst event = JSON.parse(data) as LogEvent;\n\t\t\t\t\t\t\tcollectedLogs.push(event);\n\n\t\t\t\t\t\t\tif (json) {\n\t\t\t\t\t\t\t\t// In JSON mode, we'll output at the end\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// Handle different event types\n\t\t\t\t\t\t\tif (event.cmdId) {\n\t\t\t\t\t\t\t\t// Initial event with cmdId\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (event.stream && event.data !== undefined) {\n\t\t\t\t\t\t\t\tif (event.stream === \"stdout\") {\n\t\t\t\t\t\t\t\t\tprocess.stdout.write(event.data);\n\t\t\t\t\t\t\t\t} else if (event.stream === \"stderr\") {\n\t\t\t\t\t\t\t\t\tprocess.stderr.write(chalk.red(event.data));\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (event.exitCode !== undefined) {\n\t\t\t\t\t\t\t\tconst exitColor =\n\t\t\t\t\t\t\t\t\tevent.exitCode === 0 ? chalk.green : chalk.red;\n\t\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\t\texitColor(`\\nProcess exited with code ${event.exitCode}`),\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (event.error) {\n\t\t\t\t\t\t\t\tconsole.error(chalk.red(`\\nError: ${event.error}`));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t// Ignore malformed JSON\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Output collected logs in JSON mode\n\t\t\tif (json) {\n\t\t\t\tformatOutput(collectedLogs, true);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\thandleError(error, json);\n\t\t\tprocess.exit(1);\n\t\t} finally {\n\t\t\tprocess.off(\"SIGINT\", cleanup);\n\t\t\tprocess.off(\"SIGTERM\", cleanup);\n\t\t}\n\t});\n","import chalk from \"chalk\";\nimport { Command } from \"commander\";\nimport ora from \"ora\";\nimport { api } from \"../../lib/api.js\";\nimport { config } from \"../../lib/config.js\";\nimport { handleError, McpError } from \"../../lib/errors.js\";\nimport { formatOutput } from \"../../lib/output.js\";\nimport type { RunCommandResponse } from \"../../types/index.js\";\n\nexport const runCommandCommand = new Command(\"run-command\")\n\t.description(\"Run a command in the MCP sandbox\")\n\t.argument(\"<command>\", \"Command to run\")\n\t.argument(\"[args...]\", \"Command arguments\")\n\t.option(\"--mcp-id <id>\", \"Specific MCP ID\")\n\t.option(\"--cwd <path>\", \"Working directory\")\n\t.option(\n\t\t\"--timeout <ms>\",\n\t\t\"Command timeout in milliseconds (default: 30000, max: 300000)\",\n\t)\n\t.action(async (cmd: string, args: string[], options, command) => {\n\t\tconst globalOptions = command.optsWithGlobals();\n\t\tconst json = globalOptions.json ?? false;\n\n\t\ttry {\n\t\t\tlet mcpId = options.mcpId;\n\n\t\t\tif (!mcpId) {\n\t\t\t\tmcpId = await config.getMcpId();\n\t\t\t\tif (!mcpId) {\n\t\t\t\t\tthrow new McpError(\n\t\t\t\t\t\t\"No active MCP. Run 'waniwani mcp create <name>' or 'waniwani mcp use <name>'.\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst timeout = options.timeout\n\t\t\t\t? Number.parseInt(options.timeout, 10)\n\t\t\t\t: undefined;\n\n\t\t\tconst spinner = ora(`Running: ${cmd} ${args.join(\" \")}`.trim()).start();\n\n\t\t\tconst result = await api.post<RunCommandResponse>(\n\t\t\t\t`/api/mcp/sandboxes/${mcpId}/commands`,\n\t\t\t\t{\n\t\t\t\t\tcommand: cmd,\n\t\t\t\t\targs: args.length > 0 ? args : undefined,\n\t\t\t\t\tcwd: options.cwd,\n\t\t\t\t\ttimeout,\n\t\t\t\t},\n\t\t\t);\n\n\t\t\tspinner.stop();\n\n\t\t\tif (json) {\n\t\t\t\tformatOutput(result, true);\n\t\t\t} else {\n\t\t\t\t// Show command\n\t\t\t\tconst cmdLine = [cmd, ...args].join(\" \");\n\t\t\t\tconsole.log(chalk.gray(`$ ${cmdLine}`));\n\t\t\t\tconsole.log();\n\n\t\t\t\t// Show stdout\n\t\t\t\tif (result.stdout) {\n\t\t\t\t\tprocess.stdout.write(result.stdout);\n\t\t\t\t\tif (!result.stdout.endsWith(\"\\n\")) {\n\t\t\t\t\t\tprocess.stdout.write(\"\\n\");\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Show stderr\n\t\t\t\tif (result.stderr) {\n\t\t\t\t\tprocess.stderr.write(chalk.red(result.stderr));\n\t\t\t\t\tif (!result.stderr.endsWith(\"\\n\")) {\n\t\t\t\t\t\tprocess.stderr.write(\"\\n\");\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Show exit code and duration\n\t\t\t\tconsole.log();\n\t\t\t\tconst exitColor = result.exitCode === 0 ? chalk.green : chalk.red;\n\t\t\t\tconsole.log(\n\t\t\t\t\texitColor(`Exit code: ${result.exitCode}`),\n\t\t\t\t\tchalk.gray(`(${(result.duration / 1000).toFixed(2)}s)`),\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Exit with the command's exit code\n\t\t\tif (result.exitCode !== 0) {\n\t\t\t\tprocess.exit(result.exitCode);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\thandleError(error, json);\n\t\t\tprocess.exit(1);\n\t\t}\n\t});\n","import chalk from \"chalk\";\nimport { Command } from \"commander\";\nimport ora from \"ora\";\nimport { api } from \"../../lib/api.js\";\nimport { config } from \"../../lib/config.js\";\nimport { handleError, McpError } from \"../../lib/errors.js\";\nimport { formatList, formatOutput } from \"../../lib/output.js\";\nimport type { ServerStartResponse } from \"../../types/index.js\";\n\nexport const startCommand = new Command(\"start\")\n\t.description(\"Start the MCP server (npm run dev)\")\n\t.option(\"--mcp-id <id>\", \"Specific MCP ID\")\n\t.action(async (options, command) => {\n\t\tconst globalOptions = command.optsWithGlobals();\n\t\tconst json = globalOptions.json ?? false;\n\n\t\ttry {\n\t\t\tlet mcpId = options.mcpId;\n\n\t\t\tif (!mcpId) {\n\t\t\t\tmcpId = await config.getMcpId();\n\t\t\t\tif (!mcpId) {\n\t\t\t\t\tthrow new McpError(\n\t\t\t\t\t\t\"No active MCP. Run 'waniwani mcp create <name>' or 'waniwani mcp use <name>'.\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst spinner = ora(\"Starting MCP server...\").start();\n\n\t\t\tconst result = await api.post<ServerStartResponse>(\n\t\t\t\t`/api/mcp/sandboxes/${mcpId}/server`,\n\t\t\t\t{ action: \"start\" },\n\t\t\t);\n\n\t\t\tspinner.succeed(\"MCP server started\");\n\n\t\t\tif (json) {\n\t\t\t\tformatOutput(result, true);\n\t\t\t} else {\n\t\t\t\tconsole.log();\n\t\t\t\tformatList(\n\t\t\t\t\t[\n\t\t\t\t\t\t{ label: \"Command ID\", value: result.cmdId },\n\t\t\t\t\t\t{ label: \"Preview URL\", value: chalk.cyan(result.previewUrl) },\n\t\t\t\t\t],\n\t\t\t\t\tfalse,\n\t\t\t\t);\n\t\t\t\tconsole.log();\n\t\t\t\tconsole.log(chalk.bold(\"Test with MCP Inspector:\"));\n\t\t\t\tconsole.log(\n\t\t\t\t\t` npx @modelcontextprotocol/inspector --url ${result.previewUrl}`,\n\t\t\t\t);\n\t\t\t\tconsole.log();\n\t\t\t\tconsole.log(\n\t\t\t\t\tchalk.gray(\"Run 'waniwani mcp logs' to stream server output\"),\n\t\t\t\t);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\thandleError(error, json);\n\t\t\tprocess.exit(1);\n\t\t}\n\t});\n","import chalk from \"chalk\";\nimport { Command } from \"commander\";\nimport ora from \"ora\";\nimport { api } from \"../../lib/api.js\";\nimport { config } from \"../../lib/config.js\";\nimport { handleError, McpError } from \"../../lib/errors.js\";\nimport { formatList, formatOutput } from \"../../lib/output.js\";\nimport type { Mcp, ServerStatusResponse } from \"../../types/index.js\";\n\nexport const statusCommand = new Command(\"status\")\n\t.description(\"Show current MCP sandbox status\")\n\t.option(\"--mcp-id <id>\", \"Specific MCP ID\")\n\t.action(async (options, command) => {\n\t\tconst globalOptions = command.optsWithGlobals();\n\t\tconst json = globalOptions.json ?? false;\n\n\t\ttry {\n\t\t\tlet mcpId = options.mcpId;\n\n\t\t\tif (!mcpId) {\n\t\t\t\tmcpId = await config.getMcpId();\n\t\t\t\tif (!mcpId) {\n\t\t\t\t\tthrow new McpError(\n\t\t\t\t\t\t\"No active MCP. Run 'waniwani mcp create <name>' to create one or 'waniwani mcp use <name>' to select one.\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst spinner = ora(\"Fetching MCP status...\").start();\n\n\t\t\t// Fetch sandbox status and server status in parallel\n\t\t\tconst [result, serverStatus] = await Promise.all([\n\t\t\t\tapi.get<Mcp>(`/api/mcp/sandboxes/${mcpId}`),\n\t\t\t\tapi\n\t\t\t\t\t.post<ServerStatusResponse>(`/api/mcp/sandboxes/${mcpId}/server`, {\n\t\t\t\t\t\taction: \"status\",\n\t\t\t\t\t})\n\t\t\t\t\t.catch(() => ({\n\t\t\t\t\t\trunning: false,\n\t\t\t\t\t\tcmdId: undefined,\n\t\t\t\t\t\tpreviewUrl: undefined,\n\t\t\t\t\t})),\n\t\t\t]);\n\n\t\t\tspinner.stop();\n\n\t\t\tif (json) {\n\t\t\t\tformatOutput({ ...result, server: serverStatus }, true);\n\t\t\t} else {\n\t\t\t\tconst statusColor =\n\t\t\t\t\tresult.status === \"active\" ? chalk.green : chalk.red;\n\t\t\t\tconst serverRunning = serverStatus.running;\n\t\t\t\tconst serverStatusColor = serverRunning ? chalk.green : chalk.yellow;\n\n\t\t\t\tformatList(\n\t\t\t\t\t[\n\t\t\t\t\t\t{ label: \"MCP ID\", value: result.id },\n\t\t\t\t\t\t{ label: \"Name\", value: result.name },\n\t\t\t\t\t\t{ label: \"Status\", value: statusColor(result.status) },\n\t\t\t\t\t\t{ label: \"Sandbox ID\", value: result.sandboxId },\n\t\t\t\t\t\t{ label: \"Preview URL\", value: result.previewUrl },\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: \"Server\",\n\t\t\t\t\t\t\tvalue: serverStatusColor(serverRunning ? \"Running\" : \"Stopped\"),\n\t\t\t\t\t\t},\n\t\t\t\t\t\t...(serverStatus.cmdId\n\t\t\t\t\t\t\t? [{ label: \"Server Cmd ID\", value: serverStatus.cmdId }]\n\t\t\t\t\t\t\t: []),\n\t\t\t\t\t\t{ label: \"Created\", value: result.createdAt },\n\t\t\t\t\t\t{ label: \"Expires\", value: result.expiresAt ?? \"N/A\" },\n\t\t\t\t\t],\n\t\t\t\t\tfalse,\n\t\t\t\t);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\thandleError(error, json);\n\t\t\tprocess.exit(1);\n\t\t}\n\t});\n","import { Command } from \"commander\";\nimport ora from \"ora\";\nimport { api } from \"../../lib/api.js\";\nimport { config } from \"../../lib/config.js\";\nimport { handleError, McpError } from \"../../lib/errors.js\";\nimport { formatOutput, formatSuccess } from \"../../lib/output.js\";\nimport type { ServerStopResponse } from \"../../types/index.js\";\n\nexport const stopCommand = new Command(\"stop\")\n\t.description(\"Stop the MCP server process\")\n\t.option(\"--mcp-id <id>\", \"Specific MCP ID\")\n\t.action(async (options, command) => {\n\t\tconst globalOptions = command.optsWithGlobals();\n\t\tconst json = globalOptions.json ?? false;\n\n\t\ttry {\n\t\t\tlet mcpId = options.mcpId;\n\n\t\t\tif (!mcpId) {\n\t\t\t\tmcpId = await config.getMcpId();\n\t\t\t\tif (!mcpId) {\n\t\t\t\t\tthrow new McpError(\n\t\t\t\t\t\t\"No active MCP. Run 'waniwani mcp create <name>' or 'waniwani mcp use <name>'.\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst spinner = ora(\"Stopping MCP server...\").start();\n\n\t\t\tconst result = await api.post<ServerStopResponse>(\n\t\t\t\t`/api/mcp/sandboxes/${mcpId}/server`,\n\t\t\t\t{ action: \"stop\" },\n\t\t\t);\n\n\t\t\tif (result.stopped) {\n\t\t\t\tspinner.succeed(\"MCP server stopped\");\n\t\t\t} else {\n\t\t\t\tspinner.warn(\"Server was not running\");\n\t\t\t}\n\n\t\t\tif (json) {\n\t\t\t\tformatOutput(result, true);\n\t\t\t} else {\n\t\t\t\tformatSuccess(\"MCP server stopped.\", false);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\thandleError(error, json);\n\t\t\tprocess.exit(1);\n\t\t}\n\t});\n","import { Command } from \"commander\";\nimport ora from \"ora\";\nimport { api } from \"../../lib/api.js\";\nimport { config, globalConfig } from \"../../lib/config.js\";\nimport { handleError, McpError } from \"../../lib/errors.js\";\nimport { formatOutput, formatSuccess } from \"../../lib/output.js\";\nimport type { Mcp, McpListResponse } from \"../../types/index.js\";\n\nexport const useCommand = new Command(\"use\")\n\t.description(\"Select an MCP to use for subsequent commands\")\n\t.argument(\"<name>\", \"Name of the MCP to use\")\n\t.option(\"--global\", \"Save to global config instead of project config\")\n\t.action(async (name: string, options, command) => {\n\t\tconst globalOptions = command.optsWithGlobals();\n\t\tconst json = globalOptions.json ?? false;\n\n\t\ttry {\n\t\t\tconst spinner = ora(\"Fetching MCPs...\").start();\n\n\t\t\t// Fetch all MCPs\n\t\t\tconst mcps = await api.get<McpListResponse>(\"/api/admin/mcps\");\n\n\t\t\tspinner.stop();\n\n\t\t\t// Find MCP by name\n\t\t\tconst mcp = mcps.find((m: Mcp) => m.name === name);\n\n\t\t\tif (!mcp) {\n\t\t\t\tthrow new McpError(\n\t\t\t\t\t`MCP \"${name}\" not found. Run 'waniwani mcp list' to see available MCPs.`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (mcp.status !== \"active\") {\n\t\t\t\tthrow new McpError(\n\t\t\t\t\t`MCP \"${name}\" is ${mcp.status}. Only active MCPs can be used.`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst cfg = options.global ? globalConfig : config;\n\t\t\tawait cfg.setMcpId(mcp.id);\n\n\t\t\tif (json) {\n\t\t\t\tformatOutput({ selected: mcp, scope: cfg.scope }, true);\n\t\t\t} else {\n\t\t\t\tformatSuccess(`Now using MCP \"${name}\" (${cfg.scope})`, false);\n\t\t\t\tconsole.log();\n\t\t\t\tconsole.log(` MCP ID: ${mcp.id}`);\n\t\t\t\tconsole.log(` Preview URL: ${mcp.previewUrl}`);\n\t\t\t\tconsole.log();\n\t\t\t\tconsole.log(\"Next steps:\");\n\t\t\t\tconsole.log(' waniwani task \"Add a tool\"');\n\t\t\t\tconsole.log(\" waniwani mcp test\");\n\t\t\t\tconsole.log(\" waniwani mcp status\");\n\t\t\t}\n\t\t} catch (error) {\n\t\t\thandleError(error, json);\n\t\t\tprocess.exit(1);\n\t\t}\n\t});\n","import { Command } from \"commander\";\nimport { listCommand } from \"./list.js\";\nimport { switchCommand } from \"./switch.js\";\n\nexport const orgCommand = new Command(\"org\")\n\t.description(\"Organization management commands\")\n\t.addCommand(listCommand)\n\t.addCommand(switchCommand);\n","import chalk from \"chalk\";\nimport { Command } from \"commander\";\nimport ora from \"ora\";\nimport { api } from \"../../lib/api.js\";\nimport { handleError } from \"../../lib/errors.js\";\nimport { formatOutput, formatTable } from \"../../lib/output.js\";\nimport type { Org, OrgListResponse } from \"../../types/index.js\";\n\nexport const listCommand = new Command(\"list\")\n\t.description(\"List your organizations\")\n\t.action(async (_, command) => {\n\t\tconst globalOptions = command.optsWithGlobals();\n\t\tconst json = globalOptions.json ?? false;\n\n\t\ttry {\n\t\t\tconst spinner = ora(\"Fetching organizations...\").start();\n\n\t\t\tconst result = await api.get<OrgListResponse>(\"/api/oauth/orgs\");\n\n\t\t\tspinner.stop();\n\n\t\t\tconst { orgs, activeOrgId } = result;\n\n\t\t\tif (json) {\n\t\t\t\tformatOutput(\n\t\t\t\t\t{\n\t\t\t\t\t\torgs: orgs.map((o: Org) => ({\n\t\t\t\t\t\t\t...o,\n\t\t\t\t\t\t\tisActive: o.id === activeOrgId,\n\t\t\t\t\t\t})),\n\t\t\t\t\t\tactiveOrgId,\n\t\t\t\t\t},\n\t\t\t\t\ttrue,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tif (orgs.length === 0) {\n\t\t\t\t\tconsole.log(\"No organizations found.\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconsole.log(chalk.bold(\"\\nOrganizations:\\n\"));\n\n\t\t\t\tconst rows = orgs.map((o: Org) => {\n\t\t\t\t\tconst isActive = o.id === activeOrgId;\n\t\t\t\t\treturn [\n\t\t\t\t\t\tisActive ? chalk.cyan(`* ${o.name}`) : ` ${o.name}`,\n\t\t\t\t\t\to.slug,\n\t\t\t\t\t\to.role,\n\t\t\t\t\t];\n\t\t\t\t});\n\n\t\t\t\tformatTable([\"Name\", \"Slug\", \"Role\"], rows, false);\n\n\t\t\t\tconsole.log();\n\t\t\t\tif (activeOrgId) {\n\t\t\t\t\tconst activeOrg = orgs.find((o: Org) => o.id === activeOrgId);\n\t\t\t\t\tif (activeOrg) {\n\t\t\t\t\t\tconsole.log(`Active organization: ${chalk.cyan(activeOrg.name)}`);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconsole.log(\"\\nSwitch organization: waniwani org switch <name>\");\n\t\t\t}\n\t\t} catch (error) {\n\t\t\thandleError(error, json);\n\t\t\tprocess.exit(1);\n\t\t}\n\t});\n","import { Command } from \"commander\";\nimport ora from \"ora\";\nimport { api } from \"../../lib/api.js\";\nimport { config } from \"../../lib/config.js\";\nimport { CLIError, handleError } from \"../../lib/errors.js\";\nimport { formatOutput, formatSuccess } from \"../../lib/output.js\";\nimport type {\n\tOrg,\n\tOrgListResponse,\n\tOrgSwitchResponse,\n} from \"../../types/index.js\";\n\nexport const switchCommand = new Command(\"switch\")\n\t.description(\"Switch to a different organization\")\n\t.argument(\"<name>\", \"Name or slug of the organization to switch to\")\n\t.action(async (name: string, _, command) => {\n\t\tconst globalOptions = command.optsWithGlobals();\n\t\tconst json = globalOptions.json ?? false;\n\n\t\ttry {\n\t\t\tconst spinner = ora(\"Fetching organizations...\").start();\n\n\t\t\t// First fetch orgs to find the org ID\n\t\t\tconst { orgs } = await api.get<OrgListResponse>(\"/api/oauth/orgs\");\n\n\t\t\t// Find org by name or slug\n\t\t\tconst org = orgs.find((o: Org) => o.name === name || o.slug === name);\n\n\t\t\tif (!org) {\n\t\t\t\tspinner.stop();\n\t\t\t\tthrow new CLIError(\n\t\t\t\t\t`Organization \"${name}\" not found. Run 'waniwani org list' to see available organizations.`,\n\t\t\t\t\t\"ORG_NOT_FOUND\",\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tspinner.text = \"Switching organization...\";\n\n\t\t\t// Switch to the org\n\t\t\tawait api.post<OrgSwitchResponse>(\"/api/oauth/orgs/switch\", {\n\t\t\t\torgId: org.id,\n\t\t\t});\n\n\t\t\tspinner.succeed(\"Organization switched\");\n\n\t\t\t// Clear local MCP selection since we switched orgs\n\t\t\tconfig.setMcpId(null);\n\n\t\t\tif (json) {\n\t\t\t\tformatOutput({ switched: org }, true);\n\t\t\t} else {\n\t\t\t\tformatSuccess(`Switched to organization \"${org.name}\"`, false);\n\t\t\t\tconsole.log();\n\t\t\t\tconsole.log(\"Note: Active MCP selection has been cleared.\");\n\t\t\t\tconsole.log(\n\t\t\t\t\t\"Run 'waniwani mcp list' to see MCPs in this organization.\",\n\t\t\t\t);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\thandleError(error, json);\n\t\t\tprocess.exit(1);\n\t\t}\n\t});\n","import chalk from \"chalk\";\nimport { Command } from \"commander\";\nimport ora from \"ora\";\nimport { api } from \"../lib/api.js\";\nimport { CLIError, handleError } from \"../lib/errors.js\";\nimport { formatOutput, formatSuccess } from \"../lib/output.js\";\nimport {\n\tcollectFiles,\n\tfindProjectRoot,\n\tloadProjectMcpId,\n} from \"../lib/sync.js\";\nimport type { WriteFilesResponse } from \"../types/index.js\";\n\nconst BATCH_SIZE = 50;\n\nexport const pushCommand = new Command(\"push\")\n\t.description(\"Sync local files to MCP sandbox\")\n\t.option(\"--dry-run\", \"Show what would be synced without uploading\")\n\t.action(async (options, command) => {\n\t\tconst globalOptions = command.optsWithGlobals();\n\t\tconst json = globalOptions.json ?? false;\n\n\t\ttry {\n\t\t\tconst cwd = process.cwd();\n\n\t\t\t// Find project root\n\t\t\tconst projectRoot = await findProjectRoot(cwd);\n\t\t\tif (!projectRoot) {\n\t\t\t\tthrow new CLIError(\n\t\t\t\t\t\"Not in a WaniWani project. Run 'waniwani init <name>' first.\",\n\t\t\t\t\t\"NOT_IN_PROJECT\",\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Load MCP ID\n\t\t\tconst mcpId = await loadProjectMcpId(projectRoot);\n\t\t\tif (!mcpId) {\n\t\t\t\tthrow new CLIError(\n\t\t\t\t\t\"No MCP ID found in project config. Run 'waniwani init <name>' first.\",\n\t\t\t\t\t\"NO_MCP_ID\",\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Collect files\n\t\t\tconst spinner = ora(\"Collecting files...\").start();\n\t\t\tconst files = await collectFiles(projectRoot);\n\n\t\t\tif (files.length === 0) {\n\t\t\t\tspinner.info(\"No files to sync\");\n\t\t\t\tif (json) {\n\t\t\t\t\tformatOutput({ synced: 0, files: [] }, true);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tspinner.text = `Found ${files.length} files`;\n\n\t\t\tif (options.dryRun) {\n\t\t\t\tspinner.stop();\n\t\t\t\tconsole.log();\n\t\t\t\tconsole.log(chalk.bold(\"Files that would be synced:\"));\n\t\t\t\tfor (const file of files) {\n\t\t\t\t\tconsole.log(` ${file.path}`);\n\t\t\t\t}\n\t\t\t\tconsole.log();\n\t\t\t\tconsole.log(`Total: ${files.length} files`);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Sync files in batches\n\t\t\tconst allWritten: string[] = [];\n\t\t\tconst totalBatches = Math.ceil(files.length / BATCH_SIZE);\n\n\t\t\tfor (let i = 0; i < totalBatches; i++) {\n\t\t\t\tconst batch = files.slice(i * BATCH_SIZE, (i + 1) * BATCH_SIZE);\n\t\t\t\tspinner.text = `Syncing files (${i + 1}/${totalBatches})...`;\n\n\t\t\t\tconst result = await api.post<WriteFilesResponse>(\n\t\t\t\t\t`/api/mcp/sandboxes/${mcpId}/files`,\n\t\t\t\t\t{\n\t\t\t\t\t\tfiles: batch.map((f) => ({\n\t\t\t\t\t\t\tpath: f.path,\n\t\t\t\t\t\t\tcontent: f.content,\n\t\t\t\t\t\t\tencoding: f.encoding,\n\t\t\t\t\t\t})),\n\t\t\t\t\t},\n\t\t\t\t);\n\n\t\t\t\tallWritten.push(...result.written);\n\t\t\t}\n\n\t\t\tspinner.succeed(`Synced ${allWritten.length} files`);\n\n\t\t\tif (json) {\n\t\t\t\tformatOutput(\n\t\t\t\t\t{\n\t\t\t\t\t\tsynced: allWritten.length,\n\t\t\t\t\t\tfiles: allWritten,\n\t\t\t\t\t},\n\t\t\t\t\ttrue,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tconsole.log();\n\t\t\t\tformatSuccess(`${allWritten.length} files synced to sandbox`, false);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\thandleError(error, json);\n\t\t\tprocess.exit(1);\n\t\t}\n\t});\n","import { program } from \"./cli.js\";\n\nprogram.parse(process.argv);\n"],"mappings":";;;AAAA,SAAS,WAAAA,iBAAe;;;ACAxB,SAAS,WAAAC,gBAAe;;;ACAxB,SAAS,cAAAC,mBAAkB;AAC3B,SAAS,QAAAC,aAAY;AAC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AO,UAAU,wBAAwB,EACzC,OAAO,aAAa,wBAAwB;AAG9C,QAAQ,WAAW,YAAY;AAC/B,QAAQ,WAAW,aAAa;AAGhC,QAAQ,WAAW,WAAW;AAC9B,QAAQ,WAAW,WAAW;AAC9B,QAAQ,WAAW,UAAU;AAC7B,QAAQ,WAAW,UAAU;AAC7B,QAAQ,WAAW,UAAU;AAC7B,QAAQ,WAAW,aAAa;;;AgC3BhC,QAAQ,MAAM,QAAQ,IAAI;","names":["Command","Command","existsSync","join","chalk","chalk","join","existsSync","Command","relative","chalk","Command","mkdir","readFile","writeFile","homedir","join","z","join","homedir","z","mkdir","readFile","writeFile","existsSync","mkdir","readFile","writeFile","join","existsSync","join","readFile","mkdir","writeFile","Command","relative","chalk","existsSync","mkdir","readFile","join","Command","ora","join","existsSync","readFile","config","Command","ora","mkdir","chalk","Command","ora","Command","chalk","ora","Command","Command","Command","Command","ora","Command","ora","Command","ora","Command","ora","Command","chalk","Command","ora","Command","ora","chalk","writeFile","Command","ora","Command","ora","writeFile","readFile","Command","ora","Command","readFile","ora","Command","chalk","Command","ora","listCommand","Command","ora","chalk","chalk","Command","ora","Command","ora","chalk","chalk","Command","ora","Command","ora","chalk","chalk","Command","ora","Command","ora","chalk","chalk","Command","ora","Command","ora","chalk","Command","ora","Command","ora","Command","ora","Command","ora","Command","listCommand","Command","chalk","Command","ora","listCommand","Command","ora","chalk","Command","ora","Command","ora","Command","listCommand","chalk","Command","ora","BATCH_SIZE","Command","ora","chalk","Command"]}
1
+ {"version":3,"sources":["../src/cli.ts","../src/commands/config/index.ts","../src/commands/config/init.ts","../src/lib/config.ts","../src/lib/errors.ts","../src/lib/output.ts","../src/commands/dev.ts","../src/lib/auth.ts","../src/lib/api.ts","../src/lib/sync.ts","../src/lib/utils.ts","../src/commands/init.ts","../src/commands/login.ts","../src/commands/logout.ts","../src/commands/mcp/index.ts","../src/commands/mcp/delete.ts","../src/commands/mcp/deploy.ts","../src/commands/mcp/file/index.ts","../src/commands/mcp/file/list.ts","../src/commands/mcp/file/read.ts","../src/commands/mcp/file/write.ts","../src/commands/mcp/list.ts","../src/commands/mcp/logs.ts","../src/commands/mcp/run-command.ts","../src/commands/mcp/start.ts","../src/commands/mcp/status.ts","../src/commands/mcp/stop.ts","../src/commands/mcp/use.ts","../src/commands/org/index.ts","../src/commands/org/list.ts","../src/commands/org/switch.ts","../src/commands/push.ts","../src/index.ts"],"sourcesContent":["import { Command } from \"commander\";\nimport { configCommand } from \"./commands/config/index.js\";\nimport { devCommand } from \"./commands/dev.js\";\nimport { initCommand } from \"./commands/init.js\";\nimport { loginCommand } from \"./commands/login.js\";\nimport { logoutCommand } from \"./commands/logout.js\";\nimport { mcpCommand } from \"./commands/mcp/index.js\";\nimport { orgCommand } from \"./commands/org/index.js\";\nimport { pushCommand } from \"./commands/push.js\";\n\nconst version = \"0.1.0\";\n\nexport const program = new Command()\n\t.name(\"waniwani\")\n\t.description(\"WaniWani CLI for MCP development workflow\")\n\t.version(version)\n\t.option(\"--json\", \"Output results as JSON\")\n\t.option(\"--verbose\", \"Enable verbose logging\");\n\n// Auth commands\nprogram.addCommand(loginCommand);\nprogram.addCommand(logoutCommand);\n\n// Main commands\nprogram.addCommand(initCommand);\nprogram.addCommand(pushCommand);\nprogram.addCommand(devCommand);\nprogram.addCommand(mcpCommand);\nprogram.addCommand(orgCommand);\nprogram.addCommand(configCommand);\n","import { Command } from \"commander\";\nimport { configInitCommand } from \"./init.js\";\n\nexport const configCommand = new Command(\"config\")\n\t.description(\"Manage WaniWani configuration\")\n\t.addCommand(configInitCommand);\n","import { existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { Command } from \"commander\";\nimport {\n\tCONFIG_FILE_NAME,\n\tinitConfigAt,\n\tLOCAL_CONFIG_DIR,\n} from \"../../lib/config.js\";\nimport { CLIError, handleError } from \"../../lib/errors.js\";\nimport { formatOutput, formatSuccess } from \"../../lib/output.js\";\n\nexport const configInitCommand = new Command(\"init\")\n\t.description(\"Initialize .waniwani config in the current directory\")\n\t.option(\"--force\", \"Overwrite existing config\")\n\t.action(async (options, command) => {\n\t\tconst globalOptions = command.optsWithGlobals();\n\t\tconst json = globalOptions.json ?? false;\n\n\t\ttry {\n\t\t\tconst cwd = process.cwd();\n\t\t\tconst configPath = join(cwd, LOCAL_CONFIG_DIR, CONFIG_FILE_NAME);\n\n\t\t\t// Check if config already exists\n\t\t\tif (existsSync(configPath) && !options.force) {\n\t\t\t\tthrow new CLIError(\n\t\t\t\t\t`Config already exists at ${configPath}. Use --force to overwrite.`,\n\t\t\t\t\t\"CONFIG_EXISTS\",\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Create .waniwani/settings.json with defaults\n\t\t\tconst result = await initConfigAt(cwd);\n\n\t\t\tif (json) {\n\t\t\t\tformatOutput({ created: result.path, config: result.config }, true);\n\t\t\t} else {\n\t\t\t\tformatSuccess(`Created ${result.path}`, false);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\thandleError(error, json);\n\t\t\tprocess.exit(1);\n\t\t}\n\t});\n","import { existsSync } from \"node:fs\";\nimport { mkdir, readFile, writeFile } from \"node:fs/promises\";\nimport { homedir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { z } from \"zod\";\n\nexport const LOCAL_CONFIG_DIR = \".waniwani\";\nexport const CONFIG_FILE_NAME = \"settings.json\";\n\nconst LOCAL_DIR = join(process.cwd(), LOCAL_CONFIG_DIR);\nconst LOCAL_FILE = join(LOCAL_DIR, CONFIG_FILE_NAME);\nconst GLOBAL_DIR = join(homedir(), LOCAL_CONFIG_DIR);\nconst GLOBAL_FILE = join(GLOBAL_DIR, CONFIG_FILE_NAME);\nconst DEFAULT_API_URL = \"https://app.waniwani.ai\";\n\nconst ConfigSchema = z.object({\n\tmcpId: z.string().nullable().default(null),\n\tapiUrl: z.string().nullable().default(null),\n});\n\ntype ConfigData = z.infer<typeof ConfigSchema>;\n\nclass Config {\n\tprivate dir: string;\n\tprivate file: string;\n\tprivate cache: ConfigData | null = null;\n\treadonly scope: \"local\" | \"global\";\n\n\tconstructor(forceGlobal = false) {\n\t\tconst useLocal = !forceGlobal && existsSync(LOCAL_DIR);\n\t\tthis.dir = useLocal ? LOCAL_DIR : GLOBAL_DIR;\n\t\tthis.file = useLocal ? LOCAL_FILE : GLOBAL_FILE;\n\t\tthis.scope = useLocal ? \"local\" : \"global\";\n\t}\n\n\tprivate async load(): Promise<ConfigData> {\n\t\tif (!this.cache) {\n\t\t\ttry {\n\t\t\t\tthis.cache = ConfigSchema.parse(\n\t\t\t\t\tJSON.parse(await readFile(this.file, \"utf-8\")),\n\t\t\t\t);\n\t\t\t} catch {\n\t\t\t\tthis.cache = ConfigSchema.parse({});\n\t\t\t}\n\t\t}\n\t\treturn this.cache;\n\t}\n\n\tprivate async save(data: ConfigData): Promise<void> {\n\t\tthis.cache = data;\n\t\tawait mkdir(this.dir, { recursive: true });\n\t\tawait writeFile(this.file, JSON.stringify(data, null, \"\\t\"));\n\t}\n\n\tasync getMcpId() {\n\t\treturn (await this.load()).mcpId;\n\t}\n\n\tasync setMcpId(id: string | null) {\n\t\tconst data = await this.load();\n\t\tdata.mcpId = id;\n\t\tawait this.save(data);\n\t}\n\n\tasync getApiUrl() {\n\t\tif (process.env.WANIWANI_API_URL) return process.env.WANIWANI_API_URL;\n\t\treturn (await this.load()).apiUrl || DEFAULT_API_URL;\n\t}\n\n\tasync setApiUrl(url: string | null) {\n\t\tconst data = await this.load();\n\t\tdata.apiUrl = url;\n\t\tawait this.save(data);\n\t}\n\n\tasync clear() {\n\t\tawait this.save(ConfigSchema.parse({}));\n\t}\n}\n\nexport const config = new Config();\nexport const globalConfig = new Config(true);\n\n/**\n * Initialize a .waniwani/settings.json at the given directory.\n * Returns the created config data and path.\n */\nexport async function initConfigAt(\n\tdir: string,\n\toverrides: Partial<ConfigData> = {},\n): Promise<{ path: string; config: ConfigData }> {\n\tconst configDir = join(dir, LOCAL_CONFIG_DIR);\n\tconst configPath = join(configDir, CONFIG_FILE_NAME);\n\n\tawait mkdir(configDir, { recursive: true });\n\n\tconst data = ConfigSchema.parse(overrides);\n\tawait writeFile(configPath, JSON.stringify(data, null, \"\\t\"), \"utf-8\");\n\n\treturn { path: configPath, config: data };\n}\n","import chalk from \"chalk\";\nimport { ZodError } from \"zod\";\n\nexport class CLIError extends Error {\n\tconstructor(\n\t\tmessage: string,\n\t\tpublic code: string,\n\t\tpublic details?: Record<string, unknown>,\n\t) {\n\t\tsuper(message);\n\t\tthis.name = \"CLIError\";\n\t}\n}\n\nexport class ConfigError extends CLIError {\n\tconstructor(message: string, details?: Record<string, unknown>) {\n\t\tsuper(message, \"CONFIG_ERROR\", details);\n\t}\n}\n\nexport class AuthError extends CLIError {\n\tconstructor(message: string, details?: Record<string, unknown>) {\n\t\tsuper(message, \"AUTH_ERROR\", details);\n\t}\n}\n\nexport class SandboxError extends CLIError {\n\tconstructor(message: string, details?: Record<string, unknown>) {\n\t\tsuper(message, \"SANDBOX_ERROR\", details);\n\t}\n}\n\nexport class GitHubError extends CLIError {\n\tconstructor(message: string, details?: Record<string, unknown>) {\n\t\tsuper(message, \"GITHUB_ERROR\", details);\n\t}\n}\n\nexport class McpError extends CLIError {\n\tconstructor(message: string, details?: Record<string, unknown>) {\n\t\tsuper(message, \"MCP_ERROR\", details);\n\t}\n}\n\nexport function handleError(error: unknown, json: boolean): void {\n\tif (error instanceof ZodError) {\n\t\tconst message = error.issues\n\t\t\t.map((e) => `${e.path.join(\".\")}: ${e.message}`)\n\t\t\t.join(\", \");\n\t\toutputError(\"VALIDATION_ERROR\", `Invalid input: ${message}`, json);\n\t} else if (error instanceof CLIError) {\n\t\toutputError(error.code, error.message, json, error.details);\n\t} else if (error instanceof Error) {\n\t\toutputError(\"UNKNOWN_ERROR\", error.message, json);\n\t} else {\n\t\toutputError(\"UNKNOWN_ERROR\", String(error), json);\n\t}\n}\n\nfunction outputError(\n\tcode: string,\n\tmessage: string,\n\tjson: boolean,\n\tdetails?: Record<string, unknown>,\n): void {\n\tif (json) {\n\t\tconsole.error(\n\t\t\tJSON.stringify({ success: false, error: { code, message, details } }),\n\t\t);\n\t} else {\n\t\tconsole.error(chalk.red(`Error [${code}]:`), message);\n\t\tif (details) {\n\t\t\tconsole.error(chalk.gray(\"Details:\"), JSON.stringify(details, null, 2));\n\t\t}\n\t}\n}\n","import chalk from \"chalk\";\n\nexport function formatOutput<T>(data: T, json: boolean): void {\n\tif (json) {\n\t\tconsole.log(JSON.stringify({ success: true, data }, null, 2));\n\t} else {\n\t\tprettyPrint(data);\n\t}\n}\n\nexport function formatSuccess(message: string, json: boolean): void {\n\tif (json) {\n\t\tconsole.log(JSON.stringify({ success: true, message }));\n\t} else {\n\t\tconsole.log(chalk.green(\"✓\"), message);\n\t}\n}\n\nexport function formatError(error: Error | string, json: boolean): void {\n\tconst message = error instanceof Error ? error.message : error;\n\tif (json) {\n\t\tconsole.error(JSON.stringify({ success: false, error: message }));\n\t} else {\n\t\tconsole.error(chalk.red(\"✗\"), message);\n\t}\n}\n\nexport function formatTable(\n\theaders: string[],\n\trows: string[][],\n\tjson: boolean,\n): void {\n\tif (json) {\n\t\tconst data = rows.map((row) =>\n\t\t\tObject.fromEntries(headers.map((header, i) => [header, row[i]])),\n\t\t);\n\t\tconsole.log(JSON.stringify({ success: true, data }, null, 2));\n\t} else {\n\t\t// Simple table formatting without external dependency\n\t\tconst colWidths = headers.map((h, i) =>\n\t\t\tMath.max(h.length, ...rows.map((r) => (r[i] || \"\").length)),\n\t\t);\n\n\t\tconst separator = colWidths.map((w) => \"-\".repeat(w + 2)).join(\"+\");\n\t\tconst formatRow = (row: string[]) =>\n\t\t\trow.map((cell, i) => ` ${(cell || \"\").padEnd(colWidths[i])} `).join(\"|\");\n\n\t\tconsole.log(chalk.cyan(formatRow(headers)));\n\t\tconsole.log(separator);\n\t\tfor (const row of rows) {\n\t\t\tconsole.log(formatRow(row));\n\t\t}\n\t}\n}\n\nexport function formatList(\n\titems: Array<{ label: string; value: string }>,\n\tjson: boolean,\n): void {\n\tif (json) {\n\t\tconst data = Object.fromEntries(\n\t\t\titems.map((item) => [item.label, item.value]),\n\t\t);\n\t\tconsole.log(JSON.stringify({ success: true, data }, null, 2));\n\t} else {\n\t\tconst maxLabelLength = Math.max(...items.map((i) => i.label.length));\n\t\titems.forEach((item) => {\n\t\t\tconsole.log(\n\t\t\t\t`${chalk.gray(item.label.padEnd(maxLabelLength))} ${chalk.white(item.value)}`,\n\t\t\t);\n\t\t});\n\t}\n}\n\nfunction prettyPrint(data: unknown, indent = 0): void {\n\tconst prefix = \" \".repeat(indent);\n\n\tif (Array.isArray(data)) {\n\t\tdata.forEach((item, index) => {\n\t\t\tconsole.log(`${prefix}${chalk.gray(`[${index}]`)}`);\n\t\t\tprettyPrint(item, indent + 1);\n\t\t});\n\t} else if (typeof data === \"object\" && data !== null) {\n\t\tfor (const [key, value] of Object.entries(data)) {\n\t\t\tif (typeof value === \"object\" && value !== null) {\n\t\t\t\tconsole.log(`${prefix}${chalk.gray(key)}:`);\n\t\t\t\tprettyPrint(value, indent + 1);\n\t\t\t} else {\n\t\t\t\tconsole.log(\n\t\t\t\t\t`${prefix}${chalk.gray(key)}: ${chalk.white(String(value))}`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t} else {\n\t\tconsole.log(`${prefix}${chalk.white(String(data))}`);\n\t}\n}\n","import { relative } from \"node:path\";\nimport chalk from \"chalk\";\nimport chokidar from \"chokidar\";\nimport { Command } from \"commander\";\nimport ora from \"ora\";\nimport { api } from \"../lib/api.js\";\nimport { CLIError, handleError } from \"../lib/errors.js\";\nimport {\n\tcollectFiles,\n\tcollectSingleFile,\n\tfindProjectRoot,\n\tloadIgnorePatterns,\n\tloadProjectMcpId,\n} from \"../lib/sync.js\";\nimport { debounce } from \"../lib/utils.js\";\nimport type { WriteFilesResponse } from \"../types/index.js\";\n\nconst BATCH_SIZE = 50;\nconst DEFAULT_DEBOUNCE_MS = 300;\n\nexport const devCommand = new Command(\"dev\")\n\t.description(\"Watch and sync files to MCP sandbox\")\n\t.option(\"--no-initial-sync\", \"Skip initial sync of all files\")\n\t.option(\n\t\t\"--debounce <ms>\",\n\t\t\"Debounce delay in milliseconds\",\n\t\tString(DEFAULT_DEBOUNCE_MS),\n\t)\n\t.action(async (options, command) => {\n\t\tconst globalOptions = command.optsWithGlobals();\n\t\tconst json = globalOptions.json ?? false;\n\n\t\ttry {\n\t\t\tconst cwd = process.cwd();\n\n\t\t\t// Find project root\n\t\t\tconst projectRoot = await findProjectRoot(cwd);\n\t\t\tif (!projectRoot) {\n\t\t\t\tthrow new CLIError(\n\t\t\t\t\t\"Not in a WaniWani project. Run 'waniwani init <name>' first.\",\n\t\t\t\t\t\"NOT_IN_PROJECT\",\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Load MCP ID\n\t\t\tconst mcpId = await loadProjectMcpId(projectRoot);\n\t\t\tif (!mcpId) {\n\t\t\t\tthrow new CLIError(\n\t\t\t\t\t\"No MCP ID found in project config. Run 'waniwani init <name>' first.\",\n\t\t\t\t\t\"NO_MCP_ID\",\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Initial sync if not disabled\n\t\t\tif (options.initialSync !== false) {\n\t\t\t\tconst spinner = ora(\"Initial sync...\").start();\n\t\t\t\tconst files = await collectFiles(projectRoot);\n\n\t\t\t\tif (files.length > 0) {\n\t\t\t\t\tconst totalBatches = Math.ceil(files.length / BATCH_SIZE);\n\t\t\t\t\tlet synced = 0;\n\n\t\t\t\t\tfor (let i = 0; i < totalBatches; i++) {\n\t\t\t\t\t\tconst batch = files.slice(i * BATCH_SIZE, (i + 1) * BATCH_SIZE);\n\t\t\t\t\t\tspinner.text = `Syncing (${i + 1}/${totalBatches})...`;\n\n\t\t\t\t\t\tconst result = await api.post<WriteFilesResponse>(\n\t\t\t\t\t\t\t`/api/mcp/sandboxes/${mcpId}/files`,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tfiles: batch.map((f) => ({\n\t\t\t\t\t\t\t\t\tpath: f.path,\n\t\t\t\t\t\t\t\t\tcontent: f.content,\n\t\t\t\t\t\t\t\t\tencoding: f.encoding,\n\t\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t);\n\t\t\t\t\t\tsynced += result.written.length;\n\t\t\t\t\t}\n\n\t\t\t\t\tspinner.succeed(`Initial sync complete (${synced} files)`);\n\t\t\t\t} else {\n\t\t\t\t\tspinner.info(\"No files to sync\");\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Load ignore patterns for watcher\n\t\t\tconst ig = await loadIgnorePatterns(projectRoot);\n\n\t\t\t// Set up debounced sync function\n\t\t\tconst debounceMs =\n\t\t\t\tNumber.parseInt(options.debounce, 10) || DEFAULT_DEBOUNCE_MS;\n\n\t\t\tconst syncFile = debounce(async (filePath: string) => {\n\t\t\t\tconst relativePath = relative(projectRoot, filePath);\n\n\t\t\t\t// Check if file should be ignored\n\t\t\t\tif (ig.ignores(relativePath)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst file = await collectSingleFile(projectRoot, relativePath);\n\t\t\t\tif (!file) {\n\t\t\t\t\tconsole.log(chalk.yellow(\"Skipped:\"), relativePath);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tawait api.post<WriteFilesResponse>(\n\t\t\t\t\t\t`/api/mcp/sandboxes/${mcpId}/files`,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tfiles: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tpath: file.path,\n\t\t\t\t\t\t\t\t\tcontent: file.content,\n\t\t\t\t\t\t\t\t\tencoding: file.encoding,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t\tconsole.log(chalk.green(\"Synced:\"), relativePath);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconsole.log(chalk.red(\"Failed:\"), relativePath);\n\t\t\t\t\tif (globalOptions.verbose) {\n\t\t\t\t\t\tconsole.error(error);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}, debounceMs);\n\n\t\t\t// Start watcher\n\t\t\tconsole.log();\n\t\t\tconsole.log(chalk.bold(\"Watching for changes...\"));\n\t\t\tconsole.log(chalk.dim(\"Press Ctrl+C to stop\"));\n\t\t\tconsole.log();\n\n\t\t\tconst watcher = chokidar.watch(projectRoot, {\n\t\t\t\tignored: (path: string) => {\n\t\t\t\t\tconst relativePath = relative(projectRoot, path);\n\t\t\t\t\treturn ig.ignores(relativePath);\n\t\t\t\t},\n\t\t\t\tpersistent: true,\n\t\t\t\tignoreInitial: true,\n\t\t\t\tawaitWriteFinish: {\n\t\t\t\t\tstabilityThreshold: 100,\n\t\t\t\t\tpollInterval: 100,\n\t\t\t\t},\n\t\t\t});\n\n\t\t\twatcher\n\t\t\t\t.on(\"add\", (path) => syncFile(path))\n\t\t\t\t.on(\"change\", (path) => syncFile(path))\n\t\t\t\t.on(\"unlink\", (path) => {\n\t\t\t\t\tconst relativePath = relative(projectRoot, path);\n\t\t\t\t\tconsole.log(chalk.yellow(\"Deleted (local only):\"), relativePath);\n\t\t\t\t});\n\n\t\t\t// Handle graceful shutdown\n\t\t\tconst cleanup = () => {\n\t\t\t\tconsole.log();\n\t\t\t\tconsole.log(chalk.dim(\"Stopping watcher...\"));\n\t\t\t\twatcher.close().then(() => {\n\t\t\t\t\tprocess.exit(0);\n\t\t\t\t});\n\t\t\t};\n\n\t\t\tprocess.on(\"SIGINT\", cleanup);\n\t\t\tprocess.on(\"SIGTERM\", cleanup);\n\t\t} catch (error) {\n\t\t\thandleError(error, json);\n\t\t\tprocess.exit(1);\n\t\t}\n\t});\n","import { access, mkdir, readFile, writeFile } from \"node:fs/promises\";\nimport { homedir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { z } from \"zod\";\nimport { config } from \"./config.js\";\n\nconst CONFIG_DIR = join(homedir(), \".waniwani\");\nconst AUTH_FILE = join(CONFIG_DIR, \"auth.json\");\n\nconst AuthStoreSchema = z.object({\n\taccessToken: z.string().nullable().default(null),\n\trefreshToken: z.string().nullable().default(null),\n\texpiresAt: z.string().nullable().default(null),\n\tclientId: z.string().nullable().default(null),\n});\n\ntype AuthStore = z.infer<typeof AuthStoreSchema>;\n\nasync function ensureConfigDir(): Promise<void> {\n\tawait mkdir(CONFIG_DIR, { recursive: true });\n}\n\nasync function readAuthStore(): Promise<AuthStore> {\n\tawait ensureConfigDir();\n\ttry {\n\t\tawait access(AUTH_FILE);\n\t\tconst content = await readFile(AUTH_FILE, \"utf-8\");\n\t\treturn AuthStoreSchema.parse(JSON.parse(content));\n\t} catch {\n\t\treturn AuthStoreSchema.parse({});\n\t}\n}\n\nasync function writeAuthStore(store: AuthStore): Promise<void> {\n\tawait ensureConfigDir();\n\tawait writeFile(AUTH_FILE, JSON.stringify(store, null, 2), \"utf-8\");\n}\n\nclass AuthManager {\n\tprivate storeCache: AuthStore | null = null;\n\n\tprivate async getStore(): Promise<AuthStore> {\n\t\tif (!this.storeCache) {\n\t\t\tthis.storeCache = await readAuthStore();\n\t\t}\n\t\treturn this.storeCache;\n\t}\n\n\tprivate async saveStore(store: AuthStore): Promise<void> {\n\t\tthis.storeCache = store;\n\t\tawait writeAuthStore(store);\n\t}\n\n\tasync isLoggedIn(): Promise<boolean> {\n\t\tconst store = await this.getStore();\n\t\treturn !!store.accessToken;\n\t}\n\n\tasync getAccessToken(): Promise<string | null> {\n\t\tconst store = await this.getStore();\n\t\treturn store.accessToken;\n\t}\n\n\tasync getRefreshToken(): Promise<string | null> {\n\t\tconst store = await this.getStore();\n\t\treturn store.refreshToken;\n\t}\n\n\tasync setTokens(\n\t\taccessToken: string,\n\t\trefreshToken: string,\n\t\texpiresIn: number,\n\t\tclientId?: string,\n\t): Promise<void> {\n\t\tconst expiresAt = new Date(Date.now() + expiresIn * 1000).toISOString();\n\t\tconst store = await this.getStore();\n\t\tstore.accessToken = accessToken;\n\t\tstore.refreshToken = refreshToken;\n\t\tstore.expiresAt = expiresAt;\n\t\tif (clientId) {\n\t\t\tstore.clientId = clientId;\n\t\t}\n\t\tawait this.saveStore(store);\n\t}\n\n\tasync clear(): Promise<void> {\n\t\tconst emptyStore = AuthStoreSchema.parse({});\n\t\tawait this.saveStore(emptyStore);\n\t}\n\n\tasync isTokenExpired(): Promise<boolean> {\n\t\tconst store = await this.getStore();\n\t\tif (!store.expiresAt) return true;\n\t\t// Consider expired 5 minutes before actual expiry\n\t\treturn new Date(store.expiresAt).getTime() - 5 * 60 * 1000 < Date.now();\n\t}\n\n\tasync tryRefreshToken(): Promise<boolean> {\n\t\tconst store = await this.getStore();\n\t\tconst { refreshToken, clientId } = store;\n\t\tif (!refreshToken || !clientId) return false;\n\n\t\ttry {\n\t\t\tconst apiUrl = await config.getApiUrl();\n\t\t\tconst response = await fetch(`${apiUrl}/api/auth/oauth2/token`, {\n\t\t\t\tmethod: \"POST\",\n\t\t\t\theaders: { \"Content-Type\": \"application/x-www-form-urlencoded\" },\n\t\t\t\tbody: new URLSearchParams({\n\t\t\t\t\tgrant_type: \"refresh_token\",\n\t\t\t\t\trefresh_token: refreshToken,\n\t\t\t\t\tclient_id: clientId,\n\t\t\t\t}).toString(),\n\t\t\t});\n\n\t\t\tif (!response.ok) {\n\t\t\t\tawait this.clear();\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst data = (await response.json()) as {\n\t\t\t\taccess_token: string;\n\t\t\t\trefresh_token: string;\n\t\t\t\texpires_in: number;\n\t\t\t};\n\n\t\t\tawait this.setTokens(\n\t\t\t\tdata.access_token,\n\t\t\t\tdata.refresh_token,\n\t\t\t\tdata.expires_in,\n\t\t\t);\n\n\t\t\treturn true;\n\t\t} catch {\n\t\t\tawait this.clear();\n\t\t\treturn false;\n\t\t}\n\t}\n}\n\nexport const auth = new AuthManager();\n","import { auth } from \"./auth.js\";\nimport { config } from \"./config.js\";\nimport { AuthError, CLIError } from \"./errors.js\";\n\nexport interface ApiResponse<T> {\n\tsuccess: boolean;\n\tdata?: T;\n\terror?: {\n\t\tcode: string;\n\t\tmessage: string;\n\t\tdetails?: Record<string, unknown>;\n\t};\n}\n\nexport class ApiError extends CLIError {\n\tconstructor(\n\t\tmessage: string,\n\t\tcode: string,\n\t\tpublic statusCode: number,\n\t\tdetails?: Record<string, unknown>,\n\t) {\n\t\tsuper(message, code, details);\n\t\tthis.name = \"ApiError\";\n\t}\n}\n\nasync function request<T>(\n\tmethod: string,\n\tpath: string,\n\toptions?: {\n\t\tbody?: unknown;\n\t\trequireAuth?: boolean;\n\t\theaders?: Record<string, string>;\n\t},\n): Promise<T> {\n\tconst {\n\t\tbody,\n\t\trequireAuth = true,\n\t\theaders: extraHeaders = {},\n\t} = options || {};\n\n\tconst headers: Record<string, string> = {\n\t\t\"Content-Type\": \"application/json\",\n\t\t...extraHeaders,\n\t};\n\n\tif (requireAuth) {\n\t\tconst token = await auth.getAccessToken();\n\t\tif (!token) {\n\t\t\tthrow new AuthError(\n\t\t\t\t\"Not logged in. Run 'waniwani login' to authenticate.\",\n\t\t\t);\n\t\t}\n\t\theaders.Authorization = `Bearer ${token}`;\n\t}\n\n\tconst baseUrl = await config.getApiUrl();\n\tconst url = `${baseUrl}${path}`;\n\n\tconst response = await fetch(url, {\n\t\tmethod,\n\t\theaders,\n\t\tbody: body ? JSON.stringify(body) : undefined,\n\t});\n\n\t// Handle empty responses (204 No Content)\n\tif (response.status === 204) {\n\t\treturn undefined as T;\n\t}\n\n\tlet data: ApiResponse<T>;\n\tlet rawBody: string | undefined;\n\n\ttry {\n\t\trawBody = await response.text();\n\t\tdata = JSON.parse(rawBody) as ApiResponse<T>;\n\t} catch {\n\t\t// JSON parsing failed - use raw body as error message\n\t\tthrow new ApiError(\n\t\t\trawBody || `Request failed with status ${response.status}`,\n\t\t\t\"API_ERROR\",\n\t\t\tresponse.status,\n\t\t\t{ statusText: response.statusText },\n\t\t);\n\t}\n\n\tif (!response.ok || data.error) {\n\t\t// Try to extract error message from various possible response formats\n\t\tconst errorMessage =\n\t\t\tdata.error?.message ||\n\t\t\t(data as unknown as { message?: string }).message ||\n\t\t\t(data as unknown as { error?: string }).error ||\n\t\t\trawBody ||\n\t\t\t`Request failed with status ${response.status}`;\n\n\t\tconst errorCode =\n\t\t\tdata.error?.code ||\n\t\t\t(data as unknown as { code?: string }).code ||\n\t\t\t\"API_ERROR\";\n\n\t\tconst errorDetails = {\n\t\t\t...data.error?.details,\n\t\t\tstatusText: response.statusText,\n\t\t\t...(data.error ? {} : { rawResponse: data }),\n\t\t};\n\n\t\tconst error = {\n\t\t\tcode: errorCode,\n\t\t\tmessage: errorMessage,\n\t\t\tdetails: errorDetails,\n\t\t};\n\n\t\t// Handle token expiration\n\t\tif (response.status === 401) {\n\t\t\tconst refreshed = await auth.tryRefreshToken();\n\t\t\tif (refreshed) {\n\t\t\t\t// Retry with new token\n\t\t\t\treturn request<T>(method, path, options);\n\t\t\t}\n\t\t\tthrow new AuthError(\n\t\t\t\t\"Session expired. Run 'waniwani login' to re-authenticate.\",\n\t\t\t);\n\t\t}\n\n\t\tthrow new ApiError(\n\t\t\terror.message,\n\t\t\terror.code,\n\t\t\tresponse.status,\n\t\t\terror.details,\n\t\t);\n\t}\n\n\treturn data.data as T;\n}\n\nexport const api = {\n\tget: <T>(path: string, options?: { requireAuth?: boolean }) =>\n\t\trequest<T>(\"GET\", path, options),\n\n\tpost: <T>(\n\t\tpath: string,\n\t\tbody?: unknown,\n\t\toptions?: { requireAuth?: boolean; headers?: Record<string, string> },\n\t) => request<T>(\"POST\", path, { body, ...options }),\n\n\tdelete: <T>(path: string, options?: { requireAuth?: boolean }) =>\n\t\trequest<T>(\"DELETE\", path, options),\n\n\tgetBaseUrl: () => config.getApiUrl(),\n};\n","import { existsSync } from \"node:fs\";\nimport { mkdir, readdir, readFile, stat, writeFile } from \"node:fs/promises\";\nimport { dirname, join, relative } from \"node:path\";\nimport ignore from \"ignore\";\nimport type { PullFilesResponse } from \"../types/index.js\";\nimport { api } from \"./api.js\";\nimport { detectBinary, isBinaryPath } from \"./utils.js\";\n\nconst PROJECT_DIR = \".waniwani\";\nconst SETTINGS_FILE = \"settings.json\";\n\n/**\n * Find the project root by walking up from the given directory\n * looking for a .waniwani directory\n */\nexport async function findProjectRoot(\n\tstartDir: string,\n): Promise<string | null> {\n\tlet current = startDir;\n\tconst root = dirname(current);\n\n\twhile (current !== root) {\n\t\tif (existsSync(join(current, PROJECT_DIR))) {\n\t\t\treturn current;\n\t\t}\n\t\tconst parent = dirname(current);\n\t\tif (parent === current) break;\n\t\tcurrent = parent;\n\t}\n\n\t// Check root as well\n\tif (existsSync(join(current, PROJECT_DIR))) {\n\t\treturn current;\n\t}\n\n\treturn null;\n}\n\n/**\n * Load the MCP ID from the project's .waniwani/settings.json\n */\nexport async function loadProjectMcpId(\n\tprojectRoot: string,\n): Promise<string | null> {\n\tconst settingsPath = join(projectRoot, PROJECT_DIR, SETTINGS_FILE);\n\ttry {\n\t\tconst content = await readFile(settingsPath, \"utf-8\");\n\t\tconst settings = JSON.parse(content);\n\t\treturn settings.mcpId ?? null;\n\t} catch {\n\t\treturn null;\n\t}\n}\n\n/**\n * Default patterns to always ignore\n */\nconst DEFAULT_IGNORE_PATTERNS = [\n\t\".waniwani\",\n\t\".git\",\n\t\"node_modules\",\n\t\".env\",\n\t\".env.*\",\n\t\".DS_Store\",\n\t\"*.log\",\n\t\".cache\",\n\t\"dist\",\n\t\"coverage\",\n\t\".turbo\",\n\t\".next\",\n\t\".nuxt\",\n\t\".vercel\",\n];\n\n/**\n * Load ignore patterns from .gitignore and add defaults\n */\nexport async function loadIgnorePatterns(\n\tprojectRoot: string,\n): Promise<ReturnType<typeof ignore>> {\n\tconst ig = ignore();\n\n\t// Add default patterns\n\tig.add(DEFAULT_IGNORE_PATTERNS);\n\n\t// Load .gitignore if it exists\n\tconst gitignorePath = join(projectRoot, \".gitignore\");\n\tif (existsSync(gitignorePath)) {\n\t\ttry {\n\t\t\tconst content = await readFile(gitignorePath, \"utf-8\");\n\t\t\tig.add(content);\n\t\t} catch {\n\t\t\t// Ignore read errors\n\t\t}\n\t}\n\n\treturn ig;\n}\n\nexport interface FileToSync {\n\tpath: string;\n\tcontent: string;\n\tencoding: \"utf8\" | \"base64\";\n}\n\n/**\n * Collect all files in a directory that should be synced\n * Respects .gitignore and default ignore patterns\n */\nexport async function collectFiles(projectRoot: string): Promise<FileToSync[]> {\n\tconst ig = await loadIgnorePatterns(projectRoot);\n\tconst files: FileToSync[] = [];\n\n\tasync function walk(dir: string) {\n\t\tconst entries = await readdir(dir, { withFileTypes: true });\n\n\t\tfor (const entry of entries) {\n\t\t\tconst fullPath = join(dir, entry.name);\n\t\t\tconst relativePath = relative(projectRoot, fullPath);\n\n\t\t\t// Check if path is ignored\n\t\t\tif (ig.ignores(relativePath)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (entry.isDirectory()) {\n\t\t\t\tawait walk(fullPath);\n\t\t\t} else if (entry.isFile()) {\n\t\t\t\ttry {\n\t\t\t\t\tconst content = await readFile(fullPath);\n\t\t\t\t\tconst isBinary = isBinaryPath(fullPath) || detectBinary(content);\n\n\t\t\t\t\tfiles.push({\n\t\t\t\t\t\tpath: relativePath,\n\t\t\t\t\t\tcontent: isBinary\n\t\t\t\t\t\t\t? content.toString(\"base64\")\n\t\t\t\t\t\t\t: content.toString(\"utf8\"),\n\t\t\t\t\t\tencoding: isBinary ? \"base64\" : \"utf8\",\n\t\t\t\t\t});\n\t\t\t\t} catch {\n\t\t\t\t\t// Skip files that can't be read\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tawait walk(projectRoot);\n\treturn files;\n}\n\n/**\n * Pull all files from a sandbox to a local directory.\n * Uses a single API call to fetch all files recursively.\n */\nexport async function pullFilesFromSandbox(\n\tmcpId: string,\n\ttargetDir: string,\n): Promise<{ count: number; files: string[] }> {\n\t// Fetch all files from the sandbox in one request\n\tconst result = await api.get<PullFilesResponse>(\n\t\t`/api/mcp/sandboxes/${mcpId}/files/pull`,\n\t);\n\n\tconst writtenFiles: string[] = [];\n\n\tfor (const file of result.files) {\n\t\tconst localPath = join(targetDir, file.path);\n\t\tconst dir = dirname(localPath);\n\n\t\t// Ensure directory exists\n\t\tawait mkdir(dir, { recursive: true });\n\n\t\t// Write file content\n\t\tif (file.encoding === \"base64\") {\n\t\t\tawait writeFile(localPath, Buffer.from(file.content, \"base64\"));\n\t\t} else {\n\t\t\tawait writeFile(localPath, file.content, \"utf8\");\n\t\t}\n\n\t\twrittenFiles.push(file.path);\n\t}\n\n\treturn { count: writtenFiles.length, files: writtenFiles };\n}\n\n/**\n * Collect a single file for syncing\n */\nexport async function collectSingleFile(\n\tprojectRoot: string,\n\tfilePath: string,\n): Promise<FileToSync | null> {\n\tconst fullPath = join(projectRoot, filePath);\n\tconst relativePath = relative(projectRoot, fullPath);\n\n\t// Check if file exists\n\tif (!existsSync(fullPath)) {\n\t\treturn null;\n\t}\n\n\ttry {\n\t\tconst fileStat = await stat(fullPath);\n\t\tif (!fileStat.isFile()) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst content = await readFile(fullPath);\n\t\tconst isBinary = isBinaryPath(fullPath) || detectBinary(content);\n\n\t\treturn {\n\t\t\tpath: relativePath,\n\t\t\tcontent: isBinary ? content.toString(\"base64\") : content.toString(\"utf8\"),\n\t\t\tencoding: isBinary ? \"base64\" : \"utf8\",\n\t\t};\n\t} catch {\n\t\treturn null;\n\t}\n}\n","/**\n * Debounce a function to limit how often it can be called\n */\n// biome-ignore lint/suspicious/noExplicitAny: Necessary for generic debounce\nexport function debounce<T extends (...args: any[]) => any>(\n\tfn: T,\n\tdelay: number,\n): (...args: Parameters<T>) => void {\n\tlet timeoutId: ReturnType<typeof setTimeout>;\n\treturn (...args: Parameters<T>) => {\n\t\tclearTimeout(timeoutId);\n\t\ttimeoutId = setTimeout(() => fn(...args), delay);\n\t};\n}\n\n/**\n * Binary file extensions that should be base64 encoded\n */\nconst BINARY_EXTENSIONS = new Set([\n\t\".png\",\n\t\".jpg\",\n\t\".jpeg\",\n\t\".gif\",\n\t\".ico\",\n\t\".webp\",\n\t\".svg\",\n\t\".woff\",\n\t\".woff2\",\n\t\".ttf\",\n\t\".eot\",\n\t\".otf\",\n\t\".zip\",\n\t\".tar\",\n\t\".gz\",\n\t\".pdf\",\n\t\".exe\",\n\t\".dll\",\n\t\".so\",\n\t\".dylib\",\n\t\".bin\",\n\t\".mp3\",\n\t\".mp4\",\n\t\".wav\",\n\t\".ogg\",\n\t\".webm\",\n]);\n\n/**\n * Check if a file path is likely a binary file based on extension\n */\nexport function isBinaryPath(filePath: string): boolean {\n\tconst ext = filePath.slice(filePath.lastIndexOf(\".\")).toLowerCase();\n\treturn BINARY_EXTENSIONS.has(ext);\n}\n\n/**\n * Detect if a buffer contains binary data by checking for null bytes\n */\nexport function detectBinary(buffer: Buffer): boolean {\n\t// Check first 8KB for null bytes\n\tconst sample = buffer.subarray(0, 8192);\n\treturn sample.includes(0);\n}\n","import { existsSync } from \"node:fs\";\nimport { mkdir, readFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { Command } from \"commander\";\nimport ora from \"ora\";\nimport { api } from \"../lib/api.js\";\nimport {\n\tCONFIG_FILE_NAME,\n\tinitConfigAt,\n\tLOCAL_CONFIG_DIR,\n} from \"../lib/config.js\";\nimport { handleError } from \"../lib/errors.js\";\nimport { formatOutput, formatSuccess } from \"../lib/output.js\";\nimport { pullFilesFromSandbox } from \"../lib/sync.js\";\nimport type { CreateMcpResponse } from \"../types/index.js\";\n\n/**\n * Load parent .waniwani/settings.json if it exists\n */\nasync function loadParentConfig(\n\tcwd: string,\n): Promise<Record<string, unknown> | null> {\n\tconst parentConfigPath = join(cwd, LOCAL_CONFIG_DIR, CONFIG_FILE_NAME);\n\tif (!existsSync(parentConfigPath)) {\n\t\treturn null;\n\t}\n\n\ttry {\n\t\tconst content = await readFile(parentConfigPath, \"utf-8\");\n\t\tconst config = JSON.parse(content);\n\t\t// Remove mcpId from parent - the new project gets its own\n\t\tconst { mcpId: _, ...rest } = config;\n\t\treturn rest;\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nexport const initCommand = new Command(\"init\")\n\t.description(\"Create a new MCP project from template\")\n\t.argument(\"<name>\", \"Name for the MCP project\")\n\t.action(async (name: string, _, command) => {\n\t\tconst globalOptions = command.optsWithGlobals();\n\t\tconst json = globalOptions.json ?? false;\n\n\t\ttry {\n\t\t\tconst cwd = process.cwd();\n\t\t\tconst projectDir = join(cwd, name);\n\n\t\t\t// Check if directory already exists\n\t\t\tif (existsSync(projectDir)) {\n\t\t\t\tif (json) {\n\t\t\t\t\tformatOutput(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tsuccess: false,\n\t\t\t\t\t\t\terror: `Directory \"${name}\" already exists`,\n\t\t\t\t\t\t},\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tconsole.error(`Error: Directory \"${name}\" already exists`);\n\t\t\t\t}\n\t\t\t\tprocess.exit(1);\n\t\t\t}\n\n\t\t\t// Create sandbox on backend (API pushes template files to sandbox)\n\t\t\tconst spinner = ora(\"Creating MCP sandbox...\").start();\n\n\t\t\tconst result = await api.post<CreateMcpResponse>(\"/api/mcp/sandboxes\", {\n\t\t\t\tname,\n\t\t\t});\n\n\t\t\tspinner.text = \"Downloading template files...\";\n\n\t\t\t// Create project directory\n\t\t\tawait mkdir(projectDir, { recursive: true });\n\n\t\t\t// Pull template files from sandbox to local directory\n\t\t\tawait pullFilesFromSandbox(result.id, projectDir);\n\n\t\t\tspinner.text = \"Setting up project config...\";\n\n\t\t\t// Create .waniwani/settings.json with mcpId\n\t\t\t// Inherit settings from parent .waniwani if it exists\n\t\t\tconst parentConfig = await loadParentConfig(cwd);\n\t\t\tawait initConfigAt(projectDir, {\n\t\t\t\t...parentConfig,\n\t\t\t\tmcpId: result.id, // Always use the new sandbox's mcpId\n\t\t\t});\n\n\t\t\tspinner.succeed(\"MCP project created\");\n\n\t\t\tif (json) {\n\t\t\t\tformatOutput(\n\t\t\t\t\t{\n\t\t\t\t\t\tsuccess: true,\n\t\t\t\t\t\tprojectDir,\n\t\t\t\t\t\tmcpId: result.id,\n\t\t\t\t\t\tsandboxId: result.sandboxId,\n\t\t\t\t\t\tpreviewUrl: result.previewUrl,\n\t\t\t\t\t},\n\t\t\t\t\ttrue,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tconsole.log();\n\t\t\t\tformatSuccess(`MCP project \"${name}\" created!`, false);\n\t\t\t\tconsole.log();\n\t\t\t\tconsole.log(` Project: ${projectDir}`);\n\t\t\t\tconsole.log(` MCP ID: ${result.id}`);\n\t\t\t\tconsole.log(` Preview URL: ${result.previewUrl}`);\n\t\t\t\tconsole.log();\n\t\t\t\tconsole.log(\"Next steps:\");\n\t\t\t\tconsole.log(` cd ${name}`);\n\t\t\t\tconsole.log(\" waniwani push # Sync files to sandbox\");\n\t\t\t\tconsole.log(\" waniwani dev # Watch mode with auto-sync\");\n\t\t\t\tconsole.log(' waniwani task \"...\" # Send tasks to Claude');\n\t\t\t}\n\t\t} catch (error) {\n\t\t\thandleError(error, json);\n\t\t\tprocess.exit(1);\n\t\t}\n\t});\n","import { spawn } from \"node:child_process\";\nimport { createServer, type Server } from \"node:http\";\nimport type { Socket } from \"node:net\";\nimport chalk from \"chalk\";\nimport { Command } from \"commander\";\nimport ora from \"ora\";\nimport { auth } from \"../lib/auth.js\";\nimport { config } from \"../lib/config.js\";\nimport { CLIError, handleError } from \"../lib/errors.js\";\nimport { formatOutput, formatSuccess } from \"../lib/output.js\";\nimport type {\n\tOAuthClientRegistrationResponse,\n\tOAuthTokenResponse,\n} from \"../types/index.js\";\n\nconst CALLBACK_PORT = 54321;\nconst CALLBACK_URL = `http://localhost:${CALLBACK_PORT}/callback`;\nconst CLIENT_NAME = \"waniwani-cli\";\n\nfunction generateCodeVerifier(): string {\n\tconst array = new Uint8Array(32);\n\tcrypto.getRandomValues(array);\n\treturn btoa(String.fromCharCode(...array))\n\t\t.replace(/\\+/g, \"-\")\n\t\t.replace(/\\//g, \"_\")\n\t\t.replace(/=+$/, \"\");\n}\n\nasync function generateCodeChallenge(verifier: string): Promise<string> {\n\tconst encoder = new TextEncoder();\n\tconst data = encoder.encode(verifier);\n\tconst hash = await crypto.subtle.digest(\"SHA-256\", data);\n\treturn btoa(String.fromCharCode(...new Uint8Array(hash)))\n\t\t.replace(/\\+/g, \"-\")\n\t\t.replace(/\\//g, \"_\")\n\t\t.replace(/=+$/, \"\");\n}\n\nfunction generateState(): string {\n\tconst array = new Uint8Array(16);\n\tcrypto.getRandomValues(array);\n\treturn Array.from(array, (b) => b.toString(16).padStart(2, \"0\")).join(\"\");\n}\n\nasync function registerClient(): Promise<OAuthClientRegistrationResponse> {\n\tconst apiUrl = await config.getApiUrl();\n\tconst response = await fetch(`${apiUrl}/api/auth/oauth2/register`, {\n\t\tmethod: \"POST\",\n\t\theaders: {\n\t\t\t\"Content-Type\": \"application/json\",\n\t\t},\n\t\tbody: JSON.stringify({\n\t\t\tclient_name: CLIENT_NAME,\n\t\t\tredirect_uris: [CALLBACK_URL],\n\t\t\tgrant_types: [\"authorization_code\", \"refresh_token\"],\n\t\t\tresponse_types: [\"code\"],\n\t\t\ttoken_endpoint_auth_method: \"none\",\n\t\t}),\n\t});\n\n\tif (!response.ok) {\n\t\tconst error = await response.json().catch(() => ({}));\n\t\tthrow new CLIError(\n\t\t\t(error as { error_description?: string }).error_description ||\n\t\t\t\t\"Failed to register OAuth client\",\n\t\t\t\"CLIENT_REGISTRATION_FAILED\",\n\t\t);\n\t}\n\n\treturn response.json() as Promise<OAuthClientRegistrationResponse>;\n}\n\nasync function openBrowser(url: string): Promise<void> {\n\tconst [cmd, ...args] =\n\t\tprocess.platform === \"darwin\"\n\t\t\t? [\"open\", url]\n\t\t\t: process.platform === \"win32\"\n\t\t\t\t? [\"cmd\", \"/c\", \"start\", url]\n\t\t\t\t: [\"xdg-open\", url];\n\n\tspawn(cmd, args, { stdio: \"ignore\", detached: true }).unref();\n}\n\nasync function waitForCallback(\n\texpectedState: string,\n\ttimeoutMs: number = 300000,\n): Promise<string> {\n\treturn new Promise((resolve, reject) => {\n\t\tlet server: Server | null = null;\n\t\tconst sockets = new Set<Socket>();\n\n\t\tconst timeout = setTimeout(() => {\n\t\t\tcleanup();\n\t\t\treject(new CLIError(\"Login timed out\", \"LOGIN_TIMEOUT\"));\n\t\t}, timeoutMs);\n\n\t\tconst cleanup = () => {\n\t\t\tclearTimeout(timeout);\n\t\t\t// Destroy all active connections to allow process to exit\n\t\t\tfor (const socket of sockets) {\n\t\t\t\tsocket.destroy();\n\t\t\t}\n\t\t\tsockets.clear();\n\t\t\tserver?.close();\n\t\t};\n\n\t\tconst htmlResponse = (title: string, message: string, isSuccess: boolean) =>\n\t\t\t`<!DOCTYPE html>\n<html>\n<head>\n <meta charset=\"UTF-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n <title>${title} - WaniWani</title>\n <style>\n * { margin: 0; padding: 0; box-sizing: border-box; }\n body {\n font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n min-height: 100vh;\n display: flex;\n align-items: center;\n justify-content: center;\n background: #fafafa;\n position: relative;\n overflow: hidden;\n }\n .blob {\n position: absolute;\n border-radius: 50%;\n filter: blur(60px);\n pointer-events: none;\n }\n .blob-1 {\n top: 0;\n left: 25%;\n width: 24rem;\n height: 24rem;\n background: linear-gradient(to bottom right, rgba(253, 224, 71, 0.3), rgba(251, 146, 60, 0.3));\n }\n .blob-2 {\n bottom: 0;\n right: 25%;\n width: 24rem;\n height: 24rem;\n background: linear-gradient(to bottom right, rgba(134, 239, 172, 0.3), rgba(52, 211, 153, 0.3));\n }\n .blob-3 {\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n width: 40rem;\n height: 40rem;\n background: linear-gradient(to bottom right, rgba(255, 237, 213, 0.2), rgba(254, 249, 195, 0.2));\n }\n .container {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 2rem;\n padding: 2rem;\n z-index: 10;\n text-align: center;\n }\n .logo {\n height: 40px;\n }\n .icon-circle {\n width: 80px;\n height: 80px;\n border-radius: 50%;\n display: flex;\n align-items: center;\n justify-content: center;\n background: ${isSuccess ? \"rgba(52, 211, 153, 0.15)\" : \"rgba(239, 68, 68, 0.15)\"};\n }\n .icon {\n width: 40px;\n height: 40px;\n color: ${isSuccess ? \"#10b981\" : \"#ef4444\"};\n }\n h1 {\n font-size: 2rem;\n font-weight: 700;\n color: #1e293b;\n }\n p {\n font-size: 1.125rem;\n color: #64748b;\n max-width: 400px;\n }\n </style>\n</head>\n<body>\n <div class=\"blob blob-1\"></div>\n <div class=\"blob blob-2\"></div>\n <div class=\"blob blob-3\"></div>\n <div class=\"container\">\n <svg class=\"logo\" viewBox=\"0 0 248 40\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <text x=\"0\" y=\"32\" font-family=\"system-ui\" font-size=\"28\" font-weight=\"bold\" fill=\"#1e293b\">WaniWani</text>\n </svg>\n <div class=\"icon-circle\">\n ${\n\t\t\t\tisSuccess\n\t\t\t\t\t? '<svg class=\"icon\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M20 6 9 17l-5-5\"></path></svg>'\n\t\t\t\t\t: '<svg class=\"icon\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M18 6 6 18\"></path><path d=\"m6 6 12 12\"></path></svg>'\n\t\t\t}\n </div>\n <h1>${title}</h1>\n <p>${message}</p>\n </div>\n</body>\n</html>`;\n\n\t\ttry {\n\t\t\tserver = createServer((req, res) => {\n\t\t\t\tconst url = new URL(\n\t\t\t\t\treq.url || \"/\",\n\t\t\t\t\t`http://localhost:${CALLBACK_PORT}`,\n\t\t\t\t);\n\n\t\t\t\tif (url.pathname === \"/callback\") {\n\t\t\t\t\tconst code = url.searchParams.get(\"code\");\n\t\t\t\t\tconst state = url.searchParams.get(\"state\");\n\t\t\t\t\tconst error = url.searchParams.get(\"error\");\n\n\t\t\t\t\tres.setHeader(\"Content-Type\", \"text/html\");\n\n\t\t\t\t\tif (error) {\n\t\t\t\t\t\tres.statusCode = 400;\n\t\t\t\t\t\tres.end(htmlResponse(\"Login Failed\", `Error: ${error}`, false));\n\t\t\t\t\t\tcleanup();\n\t\t\t\t\t\treject(new CLIError(`OAuth error: ${error}`, \"OAUTH_ERROR\"));\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (state !== expectedState) {\n\t\t\t\t\t\tres.statusCode = 400;\n\t\t\t\t\t\tres.end(\n\t\t\t\t\t\t\thtmlResponse(\n\t\t\t\t\t\t\t\t\"Login Failed\",\n\t\t\t\t\t\t\t\t\"Invalid state parameter. Please try again.\",\n\t\t\t\t\t\t\t\tfalse,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tcleanup();\n\t\t\t\t\t\treject(new CLIError(\"Invalid state parameter\", \"INVALID_STATE\"));\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (!code) {\n\t\t\t\t\t\tres.statusCode = 400;\n\t\t\t\t\t\tres.end(\n\t\t\t\t\t\t\thtmlResponse(\n\t\t\t\t\t\t\t\t\"Login Failed\",\n\t\t\t\t\t\t\t\t\"No authorization code received.\",\n\t\t\t\t\t\t\t\tfalse,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tcleanup();\n\t\t\t\t\t\treject(new CLIError(\"No authorization code\", \"NO_CODE\"));\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tres.statusCode = 200;\n\t\t\t\t\tres.end(\n\t\t\t\t\t\thtmlResponse(\n\t\t\t\t\t\t\t\"Login Successful!\",\n\t\t\t\t\t\t\t\"You can close this window and return to the terminal.\",\n\t\t\t\t\t\t\ttrue,\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\n\t\t\t\t\t// Schedule cleanup after response is sent\n\t\t\t\t\tsetTimeout(() => {\n\t\t\t\t\t\tcleanup();\n\t\t\t\t\t\tresolve(code);\n\t\t\t\t\t}, 100);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tres.statusCode = 404;\n\t\t\t\tres.end(\"Not found\");\n\t\t\t});\n\n\t\t\t// Track connections so we can force-close them\n\t\t\tserver.on(\"connection\", (socket) => {\n\t\t\t\tsockets.add(socket);\n\t\t\t\tsocket.on(\"close\", () => sockets.delete(socket));\n\t\t\t});\n\n\t\t\tserver.on(\"error\", (err: NodeJS.ErrnoException) => {\n\t\t\t\tcleanup();\n\t\t\t\tif (err.code === \"EADDRINUSE\") {\n\t\t\t\t\treject(\n\t\t\t\t\t\tnew CLIError(\n\t\t\t\t\t\t\t`Port ${CALLBACK_PORT} is already in use. Close any other WaniWani CLI instances and try again.`,\n\t\t\t\t\t\t\t\"PORT_IN_USE\",\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\treject(err);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tserver.listen(CALLBACK_PORT);\n\t\t} catch (err: unknown) {\n\t\t\tcleanup();\n\t\t\treject(err);\n\t\t}\n\t});\n}\n\nasync function exchangeCodeForToken(\n\tcode: string,\n\tcodeVerifier: string,\n\tclientId: string,\n\tresource: string,\n): Promise<OAuthTokenResponse> {\n\tconst apiUrl = await config.getApiUrl();\n\tconst response = await fetch(`${apiUrl}/api/auth/oauth2/token`, {\n\t\tmethod: \"POST\",\n\t\theaders: {\n\t\t\t\"Content-Type\": \"application/x-www-form-urlencoded\",\n\t\t},\n\t\tbody: new URLSearchParams({\n\t\t\tgrant_type: \"authorization_code\",\n\t\t\tcode,\n\t\t\tredirect_uri: CALLBACK_URL,\n\t\t\tclient_id: clientId,\n\t\t\tcode_verifier: codeVerifier,\n\t\t\tresource, // RFC 8707 - required to get JWT token\n\t\t}).toString(),\n\t});\n\n\tif (!response.ok) {\n\t\tconst error = await response.json().catch(() => ({}));\n\t\tthrow new CLIError(\n\t\t\t(error as { error_description?: string }).error_description ||\n\t\t\t\t\"Failed to exchange code for token\",\n\t\t\t\"TOKEN_EXCHANGE_FAILED\",\n\t\t);\n\t}\n\n\treturn response.json() as Promise<OAuthTokenResponse>;\n}\n\nexport const loginCommand = new Command(\"login\")\n\t.description(\"Log in to WaniWani\")\n\t.option(\"--no-browser\", \"Don't open the browser automatically\")\n\t.action(async (options, command) => {\n\t\tconst globalOptions = command.optsWithGlobals();\n\t\tconst json = globalOptions.json ?? false;\n\n\t\ttry {\n\t\t\t// Check if already logged in with a valid session\n\t\t\tif (await auth.isLoggedIn()) {\n\t\t\t\t// Check if token is expired\n\t\t\t\tif (await auth.isTokenExpired()) {\n\t\t\t\t\t// Try to refresh the token\n\t\t\t\t\tconst refreshed = await auth.tryRefreshToken();\n\t\t\t\t\tif (refreshed) {\n\t\t\t\t\t\tif (json) {\n\t\t\t\t\t\t\tformatOutput({ alreadyLoggedIn: true, refreshed: true }, true);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\tchalk.green(\"Session refreshed. You're still logged in.\"),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\t// Refresh failed, clear and proceed with login\n\t\t\t\t\tif (!json) {\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\tchalk.yellow(\"Session expired. Starting new login flow...\"),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tawait auth.clear();\n\t\t\t\t} else {\n\t\t\t\t\t// Token is valid\n\t\t\t\t\tif (json) {\n\t\t\t\t\t\tformatOutput({ alreadyLoggedIn: true }, true);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\tchalk.yellow(\n\t\t\t\t\t\t\t\t\"Already logged in. Use 'waniwani logout' to log out first.\",\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (!json) {\n\t\t\t\tconsole.log(chalk.bold(\"\\nWaniWani CLI Login\\n\"));\n\t\t\t}\n\n\t\t\tconst spinner = ora(\"Registering client...\").start();\n\n\t\t\t// Register OAuth client dynamically\n\t\t\tconst { client_id: clientId } = await registerClient();\n\n\t\t\tspinner.text = \"Preparing authentication...\";\n\n\t\t\t// Generate PKCE values\n\t\t\tconst codeVerifier = generateCodeVerifier();\n\t\t\tconst codeChallenge = await generateCodeChallenge(codeVerifier);\n\t\t\tconst state = generateState();\n\n\t\t\t// Build authorization URL\n\t\t\tconst apiUrl = await config.getApiUrl();\n\t\t\tconst authUrl = new URL(`${apiUrl}/api/auth/oauth2/authorize`);\n\t\t\tauthUrl.searchParams.set(\"client_id\", clientId);\n\t\t\tauthUrl.searchParams.set(\"redirect_uri\", CALLBACK_URL);\n\t\t\tauthUrl.searchParams.set(\"response_type\", \"code\");\n\t\t\tauthUrl.searchParams.set(\"code_challenge\", codeChallenge);\n\t\t\tauthUrl.searchParams.set(\"code_challenge_method\", \"S256\");\n\t\t\tauthUrl.searchParams.set(\"state\", state);\n\t\t\tauthUrl.searchParams.set(\"resource\", apiUrl); // RFC 8707 - request JWT token\n\n\t\t\tspinner.stop();\n\n\t\t\tif (!json) {\n\t\t\t\tconsole.log(\"Opening browser for authentication...\\n\");\n\t\t\t\tconsole.log(`If the browser doesn't open, visit:\\n`);\n\t\t\t\tconsole.log(chalk.cyan(` ${authUrl.toString()}`));\n\t\t\t\tconsole.log();\n\t\t\t}\n\n\t\t\t// Start callback server and open browser\n\t\t\tconst callbackPromise = waitForCallback(state);\n\n\t\t\tif (options.browser !== false) {\n\t\t\t\tawait openBrowser(authUrl.toString());\n\t\t\t}\n\n\t\t\tspinner.start(\"Waiting for authorization...\");\n\n\t\t\t// Wait for callback with auth code\n\t\t\tconst code = await callbackPromise;\n\n\t\t\tspinner.text = \"Exchanging code for token...\";\n\n\t\t\t// Exchange code for token\n\t\t\tconst tokenResponse = await exchangeCodeForToken(\n\t\t\t\tcode,\n\t\t\t\tcodeVerifier,\n\t\t\t\tclientId,\n\t\t\t\tapiUrl, // RFC 8707 resource parameter\n\t\t\t);\n\n\t\t\t// Store tokens and client ID for refresh\n\t\t\tawait auth.setTokens(\n\t\t\t\ttokenResponse.access_token,\n\t\t\t\ttokenResponse.refresh_token,\n\t\t\t\ttokenResponse.expires_in,\n\t\t\t\tclientId,\n\t\t\t);\n\n\t\t\tspinner.succeed(\"Logged in successfully!\");\n\n\t\t\tif (json) {\n\t\t\t\tformatOutput({ success: true, loggedIn: true }, true);\n\t\t\t} else {\n\t\t\t\tconsole.log();\n\t\t\t\tformatSuccess(\"You're now logged in to WaniWani!\", false);\n\t\t\t\tconsole.log();\n\t\t\t\tconsole.log(\"Get started:\");\n\t\t\t\tconsole.log(\n\t\t\t\t\t\" waniwani mcp create my-server Create a new MCP sandbox\",\n\t\t\t\t);\n\t\t\t\tconsole.log(' waniwani task \"Add a tool\" Send tasks to Claude');\n\t\t\t\tconsole.log(\n\t\t\t\t\t\" waniwani org list View your organizations\",\n\t\t\t\t);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\thandleError(error, json);\n\t\t\tprocess.exit(1);\n\t\t}\n\t});\n","import { Command } from \"commander\";\nimport { auth } from \"../lib/auth.js\";\nimport { handleError } from \"../lib/errors.js\";\nimport { formatOutput, formatSuccess } from \"../lib/output.js\";\n\nexport const logoutCommand = new Command(\"logout\")\n\t.description(\"Log out from WaniWani\")\n\t.action(async (_, command) => {\n\t\tconst globalOptions = command.optsWithGlobals();\n\t\tconst json = globalOptions.json ?? false;\n\n\t\ttry {\n\t\t\tif (!(await auth.isLoggedIn())) {\n\t\t\t\tif (json) {\n\t\t\t\t\tformatOutput({ alreadyLoggedOut: true }, true);\n\t\t\t\t} else {\n\t\t\t\t\tconsole.log(\"Not currently logged in.\");\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Clear auth tokens only (keep config like apiUrl intact)\n\t\t\tawait auth.clear();\n\n\t\t\tif (json) {\n\t\t\t\tformatOutput({ success: true }, true);\n\t\t\t} else {\n\t\t\t\tformatSuccess(\"You have been logged out.\", false);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\thandleError(error, json);\n\t\t\tprocess.exit(1);\n\t\t}\n\t});\n","import { Command } from \"commander\";\nimport { deleteCommand } from \"./delete.js\";\nimport { deployCommand } from \"./deploy.js\";\nimport { fileCommand } from \"./file/index.js\";\nimport { listCommand } from \"./list.js\";\nimport { logsCommand } from \"./logs.js\";\nimport { runCommandCommand } from \"./run-command.js\";\nimport { startCommand } from \"./start.js\";\nimport { statusCommand } from \"./status.js\";\nimport { stopCommand } from \"./stop.js\";\nimport { useCommand } from \"./use.js\";\n\nexport const mcpCommand = new Command(\"mcp\")\n\t.description(\"MCP sandbox management commands\")\n\t.addCommand(listCommand)\n\t.addCommand(useCommand)\n\t.addCommand(statusCommand)\n\t.addCommand(startCommand)\n\t.addCommand(stopCommand)\n\t.addCommand(logsCommand)\n\t.addCommand(deleteCommand)\n\t.addCommand(deployCommand)\n\t.addCommand(fileCommand)\n\t.addCommand(runCommandCommand);\n","import { Command } from \"commander\";\nimport ora from \"ora\";\nimport { api } from \"../../lib/api.js\";\nimport { config } from \"../../lib/config.js\";\nimport { handleError, McpError } from \"../../lib/errors.js\";\nimport { formatOutput, formatSuccess } from \"../../lib/output.js\";\n\nexport const deleteCommand = new Command(\"delete\")\n\t.description(\"Delete the MCP sandbox\")\n\t.option(\"--mcp-id <id>\", \"Specific MCP ID\")\n\t.action(async (options, command) => {\n\t\tconst globalOptions = command.optsWithGlobals();\n\t\tconst json = globalOptions.json ?? false;\n\n\t\ttry {\n\t\t\tlet mcpId = options.mcpId;\n\n\t\t\tif (!mcpId) {\n\t\t\t\tmcpId = await config.getMcpId();\n\t\t\t\tif (!mcpId) {\n\t\t\t\t\tthrow new McpError(\"No active MCP. Use --mcp-id to specify one.\");\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst spinner = ora(\"Deleting MCP sandbox...\").start();\n\t\t\tawait api.delete(`/api/mcp/sandboxes/${mcpId}`);\n\t\t\tspinner.succeed(\"MCP sandbox deleted\");\n\n\t\t\t// Clear active MCP if it was the one we deleted\n\t\t\tif ((await config.getMcpId()) === mcpId) {\n\t\t\t\tawait config.setMcpId(null);\n\t\t\t}\n\n\t\t\tif (json) {\n\t\t\t\tformatOutput({ deleted: mcpId }, true);\n\t\t\t} else {\n\t\t\t\tformatSuccess(\"MCP sandbox deleted and cleaned up.\", false);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\thandleError(error, json);\n\t\t\tprocess.exit(1);\n\t\t}\n\t});\n","import { Command } from \"commander\";\nimport ora from \"ora\";\nimport { api } from \"../../lib/api.js\";\nimport { config } from \"../../lib/config.js\";\nimport { handleError, McpError } from \"../../lib/errors.js\";\nimport { formatOutput, formatSuccess } from \"../../lib/output.js\";\nimport type { DeployResponse } from \"../../types/index.js\";\n\nexport const deployCommand = new Command(\"deploy\")\n\t.description(\"Deploy MCP server to GitHub + Vercel from sandbox\")\n\t.option(\"--repo <name>\", \"GitHub repository name\")\n\t.option(\"--org <name>\", \"GitHub organization\")\n\t.option(\"--private\", \"Create private repository\")\n\t.option(\"--mcp-id <id>\", \"Specific MCP ID\")\n\t.action(async (options, command) => {\n\t\tconst globalOptions = command.optsWithGlobals();\n\t\tconst json = globalOptions.json ?? false;\n\n\t\ttry {\n\t\t\tlet mcpId = options.mcpId;\n\n\t\t\tif (!mcpId) {\n\t\t\t\tmcpId = await config.getMcpId();\n\t\t\t\tif (!mcpId) {\n\t\t\t\t\tthrow new McpError(\n\t\t\t\t\t\t\"No active MCP. Run 'waniwani mcp create <name>' or 'waniwani mcp use <name>'.\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst spinner = ora(\"Deploying to GitHub...\").start();\n\n\t\t\tconst result = await api.post<DeployResponse>(\n\t\t\t\t`/api/mcp/sandboxes/${mcpId}/deploy`,\n\t\t\t\t{\n\t\t\t\t\trepoName: options.repo,\n\t\t\t\t\torg: options.org,\n\t\t\t\t\tprivate: options.private ?? false,\n\t\t\t\t},\n\t\t\t);\n\n\t\t\tspinner.succeed(\"Deployment complete!\");\n\n\t\t\tif (json) {\n\t\t\t\tformatOutput(result, true);\n\t\t\t} else {\n\t\t\t\tconsole.log();\n\t\t\t\tformatSuccess(\"MCP server deployed!\", false);\n\t\t\t\tconsole.log();\n\t\t\t\tconsole.log(` Repository: ${result.repository.url}`);\n\t\t\t\tif (result.deployment.url) {\n\t\t\t\t\tconsole.log(` Deployment: ${result.deployment.url}`);\n\t\t\t\t}\n\t\t\t\tconsole.log();\n\t\t\t\tif (result.deployment.note) {\n\t\t\t\t\tconsole.log(`Note: ${result.deployment.note}`);\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (error) {\n\t\t\thandleError(error, json);\n\t\t\tprocess.exit(1);\n\t\t}\n\t});\n","import { Command } from \"commander\";\nimport { listCommand } from \"./list.js\";\nimport { readCommand } from \"./read.js\";\nimport { writeCommand } from \"./write.js\";\n\nexport const fileCommand = new Command(\"file\")\n\t.description(\"File operations in MCP sandbox\")\n\t.addCommand(readCommand)\n\t.addCommand(writeCommand)\n\t.addCommand(listCommand);\n","import chalk from \"chalk\";\nimport { Command } from \"commander\";\nimport ora from \"ora\";\nimport { api } from \"../../../lib/api.js\";\nimport { config } from \"../../../lib/config.js\";\nimport { handleError, McpError } from \"../../../lib/errors.js\";\nimport { formatOutput, formatTable } from \"../../../lib/output.js\";\nimport type { ListFilesResponse } from \"../../../types/index.js\";\n\nexport const listCommand = new Command(\"list\")\n\t.description(\"List files in the MCP sandbox\")\n\t.argument(\"[path]\", \"Directory path (defaults to /app)\", \"/app\")\n\t.option(\"--mcp-id <id>\", \"Specific MCP ID\")\n\t.action(async (path: string, options, command) => {\n\t\tconst globalOptions = command.optsWithGlobals();\n\t\tconst json = globalOptions.json ?? false;\n\n\t\ttry {\n\t\t\tlet mcpId = options.mcpId;\n\n\t\t\tif (!mcpId) {\n\t\t\t\tmcpId = await config.getMcpId();\n\t\t\t\tif (!mcpId) {\n\t\t\t\t\tthrow new McpError(\n\t\t\t\t\t\t\"No active MCP. Run 'waniwani mcp create <name>' or 'waniwani mcp use <name>'.\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst spinner = ora(`Listing ${path}...`).start();\n\n\t\t\tconst result = await api.get<ListFilesResponse>(\n\t\t\t\t`/api/mcp/sandboxes/${mcpId}/files/list?path=${encodeURIComponent(path)}`,\n\t\t\t);\n\n\t\t\tspinner.stop();\n\n\t\t\tif (json) {\n\t\t\t\tformatOutput(result, true);\n\t\t\t} else {\n\t\t\t\tconsole.log(chalk.bold(`\\nDirectory: ${result.path}\\n`));\n\n\t\t\t\tif (result.entries.length === 0) {\n\t\t\t\t\tconsole.log(\" (empty)\");\n\t\t\t\t} else {\n\t\t\t\t\tconst rows = result.entries.map((entry) => {\n\t\t\t\t\t\tconst name =\n\t\t\t\t\t\t\tentry.type === \"directory\"\n\t\t\t\t\t\t\t\t? chalk.blue(`${entry.name}/`)\n\t\t\t\t\t\t\t\t: entry.name;\n\t\t\t\t\t\tconst size =\n\t\t\t\t\t\t\tentry.type === \"directory\"\n\t\t\t\t\t\t\t\t? chalk.gray(\"<dir>\")\n\t\t\t\t\t\t\t\t: formatSize(entry.size);\n\t\t\t\t\t\treturn [name, size];\n\t\t\t\t\t});\n\n\t\t\t\t\tformatTable([\"Name\", \"Size\"], rows, false);\n\t\t\t\t}\n\t\t\t\tconsole.log();\n\t\t\t}\n\t\t} catch (error) {\n\t\t\thandleError(error, json);\n\t\t\tprocess.exit(1);\n\t\t}\n\t});\n\nfunction formatSize(bytes?: number): string {\n\tif (bytes === undefined) return \"\";\n\tif (bytes < 1024) return `${bytes} B`;\n\tif (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;\n\treturn `${(bytes / (1024 * 1024)).toFixed(1)} MB`;\n}\n","import { writeFile } from \"node:fs/promises\";\nimport { Command } from \"commander\";\nimport ora from \"ora\";\nimport { api } from \"../../../lib/api.js\";\nimport { config } from \"../../../lib/config.js\";\nimport { handleError, McpError } from \"../../../lib/errors.js\";\nimport { formatOutput, formatSuccess } from \"../../../lib/output.js\";\nimport type { ReadFileResponse } from \"../../../types/index.js\";\n\nexport const readCommand = new Command(\"read\")\n\t.description(\"Read a file from the MCP sandbox\")\n\t.argument(\"<path>\", \"Path in sandbox (e.g., /app/src/index.ts)\")\n\t.option(\"--mcp-id <id>\", \"Specific MCP ID\")\n\t.option(\"--output <file>\", \"Write to local file instead of stdout\")\n\t.option(\"--base64\", \"Output as base64 (for binary files)\")\n\t.action(async (path: string, options, command) => {\n\t\tconst globalOptions = command.optsWithGlobals();\n\t\tconst json = globalOptions.json ?? false;\n\n\t\ttry {\n\t\t\tlet mcpId = options.mcpId;\n\n\t\t\tif (!mcpId) {\n\t\t\t\tmcpId = await config.getMcpId();\n\t\t\t\tif (!mcpId) {\n\t\t\t\t\tthrow new McpError(\n\t\t\t\t\t\t\"No active MCP. Run 'waniwani mcp create <name>' or 'waniwani mcp use <name>'.\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst encoding = options.base64 ? \"base64\" : \"utf8\";\n\t\t\tconst spinner = ora(`Reading ${path}...`).start();\n\n\t\t\tconst result = await api.get<ReadFileResponse>(\n\t\t\t\t`/api/mcp/sandboxes/${mcpId}/files?path=${encodeURIComponent(path)}&encoding=${encoding}`,\n\t\t\t);\n\n\t\t\tspinner.stop();\n\n\t\t\tif (!result.exists) {\n\t\t\t\tthrow new McpError(`File not found: ${path}`);\n\t\t\t}\n\n\t\t\tif (options.output) {\n\t\t\t\t// Write to local file\n\t\t\t\tconst buffer =\n\t\t\t\t\tresult.encoding === \"base64\"\n\t\t\t\t\t\t? Buffer.from(result.content, \"base64\")\n\t\t\t\t\t\t: Buffer.from(result.content, \"utf8\");\n\t\t\t\tawait writeFile(options.output, buffer);\n\t\t\t\tif (json) {\n\t\t\t\t\tformatOutput({ path, savedTo: options.output }, true);\n\t\t\t\t} else {\n\t\t\t\t\tformatSuccess(`Saved to ${options.output}`, false);\n\t\t\t\t}\n\t\t\t} else if (json) {\n\t\t\t\tformatOutput(result, true);\n\t\t\t} else {\n\t\t\t\t// Print to stdout\n\t\t\t\tprocess.stdout.write(result.content);\n\t\t\t\t// Add newline if content doesn't end with one\n\t\t\t\tif (!result.content.endsWith(\"\\n\")) {\n\t\t\t\t\tprocess.stdout.write(\"\\n\");\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (error) {\n\t\t\thandleError(error, json);\n\t\t\tprocess.exit(1);\n\t\t}\n\t});\n","import { readFile } from \"node:fs/promises\";\nimport { Command } from \"commander\";\nimport ora from \"ora\";\nimport { api } from \"../../../lib/api.js\";\nimport { config } from \"../../../lib/config.js\";\nimport { CLIError, handleError, McpError } from \"../../../lib/errors.js\";\nimport { formatOutput, formatSuccess } from \"../../../lib/output.js\";\nimport type { WriteFilesResponse } from \"../../../types/index.js\";\n\nexport const writeCommand = new Command(\"write\")\n\t.description(\"Write a file to the MCP sandbox\")\n\t.argument(\"<path>\", \"Path in sandbox (e.g., /app/src/index.ts)\")\n\t.option(\"--mcp-id <id>\", \"Specific MCP ID\")\n\t.option(\"--content <content>\", \"Content to write\")\n\t.option(\"--file <localFile>\", \"Local file to upload\")\n\t.option(\"--base64\", \"Treat content as base64 encoded\")\n\t.action(async (path: string, options, command) => {\n\t\tconst globalOptions = command.optsWithGlobals();\n\t\tconst json = globalOptions.json ?? false;\n\n\t\ttry {\n\t\t\tlet mcpId = options.mcpId;\n\n\t\t\tif (!mcpId) {\n\t\t\t\tmcpId = await config.getMcpId();\n\t\t\t\tif (!mcpId) {\n\t\t\t\t\tthrow new McpError(\n\t\t\t\t\t\t\"No active MCP. Run 'waniwani mcp create <name>' or 'waniwani mcp use <name>'.\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Get content from --content or --file\n\t\t\tlet content: string;\n\t\t\tlet encoding: \"utf8\" | \"base64\" = \"utf8\";\n\n\t\t\tif (options.content) {\n\t\t\t\tcontent = options.content;\n\t\t\t\tif (options.base64) {\n\t\t\t\t\tencoding = \"base64\";\n\t\t\t\t}\n\t\t\t} else if (options.file) {\n\t\t\t\tconst fileBuffer = await readFile(options.file);\n\t\t\t\tif (options.base64) {\n\t\t\t\t\tcontent = fileBuffer.toString(\"base64\");\n\t\t\t\t\tencoding = \"base64\";\n\t\t\t\t} else {\n\t\t\t\t\tcontent = fileBuffer.toString(\"utf8\");\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthrow new CLIError(\n\t\t\t\t\t\"Either --content or --file is required\",\n\t\t\t\t\t\"MISSING_CONTENT\",\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst spinner = ora(`Writing ${path}...`).start();\n\n\t\t\tconst result = await api.post<WriteFilesResponse>(\n\t\t\t\t`/api/mcp/sandboxes/${mcpId}/files`,\n\t\t\t\t{\n\t\t\t\t\tfiles: [{ path, content, encoding }],\n\t\t\t\t},\n\t\t\t);\n\n\t\t\tspinner.succeed(`Wrote ${path}`);\n\n\t\t\tif (json) {\n\t\t\t\tformatOutput(result, true);\n\t\t\t} else {\n\t\t\t\tformatSuccess(`File written: ${path}`, false);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\thandleError(error, json);\n\t\t\tprocess.exit(1);\n\t\t}\n\t});\n","import chalk from \"chalk\";\nimport { Command } from \"commander\";\nimport ora from \"ora\";\nimport { api } from \"../../lib/api.js\";\nimport { config } from \"../../lib/config.js\";\nimport { handleError } from \"../../lib/errors.js\";\nimport { formatOutput, formatTable } from \"../../lib/output.js\";\nimport type { Mcp, McpListResponse } from \"../../types/index.js\";\n\nexport const listCommand = new Command(\"list\")\n\t.description(\"List all MCPs in your organization\")\n\t.option(\"--all\", \"Include stopped/expired MCPs\")\n\t.action(async (options, command) => {\n\t\tconst globalOptions = command.optsWithGlobals();\n\t\tconst json = globalOptions.json ?? false;\n\n\t\ttry {\n\t\t\tconst spinner = ora(\"Fetching MCPs...\").start();\n\n\t\t\tconst mcps = await api.get<McpListResponse>(\n\t\t\t\t`/api/mcp/sandboxes${options.all ? \"?all=true\" : \"\"}`,\n\t\t\t);\n\n\t\t\tspinner.stop();\n\n\t\t\tconst activeMcpId = await config.getMcpId();\n\n\t\t\tif (json) {\n\t\t\t\tformatOutput(\n\t\t\t\t\t{\n\t\t\t\t\t\tmcps: mcps.map((m: Mcp) => ({\n\t\t\t\t\t\t\t...m,\n\t\t\t\t\t\t\tisActive: m.id === activeMcpId,\n\t\t\t\t\t\t})),\n\t\t\t\t\t\tactiveMcpId,\n\t\t\t\t\t},\n\t\t\t\t\ttrue,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tif (mcps.length === 0) {\n\t\t\t\t\tconsole.log(\"No MCPs found.\");\n\t\t\t\t\tconsole.log(\"\\nCreate a new MCP sandbox: waniwani mcp create <name>\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconsole.log(chalk.bold(\"\\nMCPs:\\n\"));\n\n\t\t\t\tconst rows = mcps.map((m: Mcp) => {\n\t\t\t\t\tconst isActive = m.id === activeMcpId;\n\t\t\t\t\tconst statusColor =\n\t\t\t\t\t\tm.status === \"active\"\n\t\t\t\t\t\t\t? chalk.green\n\t\t\t\t\t\t\t: m.status === \"stopped\"\n\t\t\t\t\t\t\t\t? chalk.red\n\t\t\t\t\t\t\t\t: chalk.yellow;\n\n\t\t\t\t\treturn [\n\t\t\t\t\t\tisActive\n\t\t\t\t\t\t\t? chalk.cyan(`* ${m.id.slice(0, 8)}`)\n\t\t\t\t\t\t\t: ` ${m.id.slice(0, 8)}`,\n\t\t\t\t\t\tm.name,\n\t\t\t\t\t\tstatusColor(m.status),\n\t\t\t\t\t\tm.previewUrl,\n\t\t\t\t\t\tm.createdAt ? new Date(m.createdAt).toLocaleString() : \"N/A\",\n\t\t\t\t\t];\n\t\t\t\t});\n\n\t\t\t\tformatTable(\n\t\t\t\t\t[\"ID\", \"Name\", \"Status\", \"Preview URL\", \"Created\"],\n\t\t\t\t\trows,\n\t\t\t\t\tfalse,\n\t\t\t\t);\n\n\t\t\t\tconsole.log();\n\t\t\t\tif (activeMcpId) {\n\t\t\t\t\tconsole.log(`Active MCP: ${chalk.cyan(activeMcpId.slice(0, 8))}`);\n\t\t\t\t}\n\t\t\t\tconsole.log(\"\\nSelect an MCP: waniwani mcp use <name>\");\n\t\t\t}\n\t\t} catch (error) {\n\t\t\thandleError(error, json);\n\t\t\tprocess.exit(1);\n\t\t}\n\t});\n","import chalk from \"chalk\";\nimport { Command } from \"commander\";\nimport ora from \"ora\";\nimport { api } from \"../../lib/api.js\";\nimport { auth } from \"../../lib/auth.js\";\nimport { config } from \"../../lib/config.js\";\nimport { AuthError, handleError, McpError } from \"../../lib/errors.js\";\nimport { formatOutput } from \"../../lib/output.js\";\nimport type { LogEvent, ServerStatusResponse } from \"../../types/index.js\";\n\nexport const logsCommand = new Command(\"logs\")\n\t.description(\"Stream logs from the MCP server\")\n\t.argument(\"[cmdId]\", \"Command ID (defaults to running server)\")\n\t.option(\"--mcp-id <id>\", \"Specific MCP ID\")\n\t.option(\"-f, --follow\", \"Keep streaming logs (default)\", true)\n\t.option(\"--no-follow\", \"Fetch logs and exit\")\n\t.action(async (cmdIdArg: string | undefined, options, command) => {\n\t\tconst globalOptions = command.optsWithGlobals();\n\t\tconst json = globalOptions.json ?? false;\n\n\t\tlet reader: ReadableStreamDefaultReader<Uint8Array> | undefined;\n\n\t\t// Handle Ctrl+C gracefully\n\t\tconst cleanup = () => {\n\t\t\tif (reader) {\n\t\t\t\treader.cancel().catch(() => {});\n\t\t\t}\n\t\t\tprocess.exit(0);\n\t\t};\n\t\tprocess.on(\"SIGINT\", cleanup);\n\t\tprocess.on(\"SIGTERM\", cleanup);\n\n\t\ttry {\n\t\t\tlet mcpId = options.mcpId;\n\n\t\t\tif (!mcpId) {\n\t\t\t\tmcpId = await config.getMcpId();\n\t\t\t\tif (!mcpId) {\n\t\t\t\t\tthrow new McpError(\n\t\t\t\t\t\t\"No active MCP. Run 'waniwani mcp create <name>' or 'waniwani mcp use <name>'.\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst token = await auth.getAccessToken();\n\t\t\tif (!token) {\n\t\t\t\tthrow new AuthError(\n\t\t\t\t\t\"Not logged in. Run 'waniwani login' to authenticate.\",\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tlet cmdId = cmdIdArg;\n\n\t\t\t// If no cmdId provided, get it from server status\n\t\t\tif (!cmdId) {\n\t\t\t\tconst spinner = ora(\"Getting server status...\").start();\n\t\t\t\tconst status = await api.post<ServerStatusResponse>(\n\t\t\t\t\t`/api/mcp/sandboxes/${mcpId}/server`,\n\t\t\t\t\t{ action: \"status\" },\n\t\t\t\t);\n\t\t\t\tspinner.stop();\n\n\t\t\t\tif (!status.running || !status.cmdId) {\n\t\t\t\t\tthrow new McpError(\n\t\t\t\t\t\t\"No server is running. Run 'waniwani mcp start' first.\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tcmdId = status.cmdId;\n\t\t\t}\n\n\t\t\tconst baseUrl = await api.getBaseUrl();\n\t\t\tconst streamParam = options.follow ? \"?stream=true\" : \"\";\n\t\t\tconst url = `${baseUrl}/api/mcp/sandboxes/${mcpId}/commands/${cmdId}${streamParam}`;\n\n\t\t\tif (!json) {\n\t\t\t\tconsole.log(chalk.gray(`Streaming logs for command ${cmdId}...`));\n\t\t\t\tconsole.log(chalk.gray(\"Press Ctrl+C to stop\\n\"));\n\t\t\t}\n\n\t\t\tconst response = await fetch(url, {\n\t\t\t\tmethod: \"GET\",\n\t\t\t\theaders: {\n\t\t\t\t\tAuthorization: `Bearer ${token}`,\n\t\t\t\t\tAccept: options.follow ? \"text/event-stream\" : \"application/json\",\n\t\t\t\t},\n\t\t\t});\n\n\t\t\tif (!response.ok) {\n\t\t\t\tconst error = await response\n\t\t\t\t\t.json()\n\t\t\t\t\t.catch(() => ({ message: response.statusText }));\n\t\t\t\tthrow new Error(\n\t\t\t\t\terror.message || `Request failed with status ${response.status}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Non-streaming mode\n\t\t\tif (!options.follow) {\n\t\t\t\tconst data = await response.json();\n\t\t\t\tif (json) {\n\t\t\t\t\tformatOutput(data, true);\n\t\t\t\t} else {\n\t\t\t\t\tif (data.stdout) {\n\t\t\t\t\t\tprocess.stdout.write(data.stdout);\n\t\t\t\t\t}\n\t\t\t\t\tif (data.stderr) {\n\t\t\t\t\t\tprocess.stderr.write(chalk.red(data.stderr));\n\t\t\t\t\t}\n\t\t\t\t\tif (data.exitCode !== undefined) {\n\t\t\t\t\t\tconsole.log(chalk.gray(`\\nExit code: ${data.exitCode}`));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Streaming mode\n\t\t\treader = response.body?.getReader();\n\t\t\tif (!reader) {\n\t\t\t\tthrow new Error(\"No response body\");\n\t\t\t}\n\n\t\t\tconst decoder = new TextDecoder();\n\t\t\tlet buffer = \"\";\n\t\t\tconst collectedLogs: LogEvent[] = [];\n\n\t\t\twhile (true) {\n\t\t\t\tconst { done, value } = await reader.read();\n\t\t\t\tif (done) break;\n\n\t\t\t\tbuffer += decoder.decode(value, { stream: true });\n\t\t\t\tconst lines = buffer.split(\"\\n\");\n\t\t\t\tbuffer = lines.pop() || \"\";\n\n\t\t\t\tfor (const line of lines) {\n\t\t\t\t\tif (line.startsWith(\"event: \")) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (line.startsWith(\"data: \")) {\n\t\t\t\t\t\tconst data = line.slice(6);\n\t\t\t\t\t\tif (!data || data === \"[DONE]\") continue;\n\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst event = JSON.parse(data) as LogEvent;\n\t\t\t\t\t\t\tcollectedLogs.push(event);\n\n\t\t\t\t\t\t\tif (json) {\n\t\t\t\t\t\t\t\t// In JSON mode, we'll output at the end\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// Handle different event types\n\t\t\t\t\t\t\tif (event.cmdId) {\n\t\t\t\t\t\t\t\t// Initial event with cmdId\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (event.stream && event.data !== undefined) {\n\t\t\t\t\t\t\t\tif (event.stream === \"stdout\") {\n\t\t\t\t\t\t\t\t\tprocess.stdout.write(event.data);\n\t\t\t\t\t\t\t\t} else if (event.stream === \"stderr\") {\n\t\t\t\t\t\t\t\t\tprocess.stderr.write(chalk.red(event.data));\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (event.exitCode !== undefined) {\n\t\t\t\t\t\t\t\tconst exitColor =\n\t\t\t\t\t\t\t\t\tevent.exitCode === 0 ? chalk.green : chalk.red;\n\t\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\t\texitColor(`\\nProcess exited with code ${event.exitCode}`),\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (event.error) {\n\t\t\t\t\t\t\t\tconsole.error(chalk.red(`\\nError: ${event.error}`));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t// Ignore malformed JSON\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Output collected logs in JSON mode\n\t\t\tif (json) {\n\t\t\t\tformatOutput(collectedLogs, true);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\thandleError(error, json);\n\t\t\tprocess.exit(1);\n\t\t} finally {\n\t\t\tprocess.off(\"SIGINT\", cleanup);\n\t\t\tprocess.off(\"SIGTERM\", cleanup);\n\t\t}\n\t});\n","import chalk from \"chalk\";\nimport { Command } from \"commander\";\nimport ora from \"ora\";\nimport { api } from \"../../lib/api.js\";\nimport { config } from \"../../lib/config.js\";\nimport { handleError, McpError } from \"../../lib/errors.js\";\nimport { formatOutput } from \"../../lib/output.js\";\nimport type { RunCommandResponse } from \"../../types/index.js\";\n\nexport const runCommandCommand = new Command(\"run-command\")\n\t.description(\"Run a command in the MCP sandbox\")\n\t.argument(\"<command>\", \"Command to run\")\n\t.argument(\"[args...]\", \"Command arguments\")\n\t.option(\"--mcp-id <id>\", \"Specific MCP ID\")\n\t.option(\"--cwd <path>\", \"Working directory\")\n\t.option(\n\t\t\"--timeout <ms>\",\n\t\t\"Command timeout in milliseconds (default: 30000, max: 300000)\",\n\t)\n\t.action(async (cmd: string, args: string[], options, command) => {\n\t\tconst globalOptions = command.optsWithGlobals();\n\t\tconst json = globalOptions.json ?? false;\n\n\t\ttry {\n\t\t\tlet mcpId = options.mcpId;\n\n\t\t\tif (!mcpId) {\n\t\t\t\tmcpId = await config.getMcpId();\n\t\t\t\tif (!mcpId) {\n\t\t\t\t\tthrow new McpError(\n\t\t\t\t\t\t\"No active MCP. Run 'waniwani mcp create <name>' or 'waniwani mcp use <name>'.\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst timeout = options.timeout\n\t\t\t\t? Number.parseInt(options.timeout, 10)\n\t\t\t\t: undefined;\n\n\t\t\tconst spinner = ora(`Running: ${cmd} ${args.join(\" \")}`.trim()).start();\n\n\t\t\tconst result = await api.post<RunCommandResponse>(\n\t\t\t\t`/api/mcp/sandboxes/${mcpId}/commands`,\n\t\t\t\t{\n\t\t\t\t\tcommand: cmd,\n\t\t\t\t\targs: args.length > 0 ? args : undefined,\n\t\t\t\t\tcwd: options.cwd,\n\t\t\t\t\ttimeout,\n\t\t\t\t},\n\t\t\t);\n\n\t\t\tspinner.stop();\n\n\t\t\tif (json) {\n\t\t\t\tformatOutput(result, true);\n\t\t\t} else {\n\t\t\t\t// Show command\n\t\t\t\tconst cmdLine = [cmd, ...args].join(\" \");\n\t\t\t\tconsole.log(chalk.gray(`$ ${cmdLine}`));\n\t\t\t\tconsole.log();\n\n\t\t\t\t// Show stdout\n\t\t\t\tif (result.stdout) {\n\t\t\t\t\tprocess.stdout.write(result.stdout);\n\t\t\t\t\tif (!result.stdout.endsWith(\"\\n\")) {\n\t\t\t\t\t\tprocess.stdout.write(\"\\n\");\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Show stderr\n\t\t\t\tif (result.stderr) {\n\t\t\t\t\tprocess.stderr.write(chalk.red(result.stderr));\n\t\t\t\t\tif (!result.stderr.endsWith(\"\\n\")) {\n\t\t\t\t\t\tprocess.stderr.write(\"\\n\");\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Show exit code and duration\n\t\t\t\tconsole.log();\n\t\t\t\tconst exitColor = result.exitCode === 0 ? chalk.green : chalk.red;\n\t\t\t\tconsole.log(\n\t\t\t\t\texitColor(`Exit code: ${result.exitCode}`),\n\t\t\t\t\tchalk.gray(`(${(result.duration / 1000).toFixed(2)}s)`),\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Exit with the command's exit code\n\t\t\tif (result.exitCode !== 0) {\n\t\t\t\tprocess.exit(result.exitCode);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\thandleError(error, json);\n\t\t\tprocess.exit(1);\n\t\t}\n\t});\n","import chalk from \"chalk\";\nimport { Command } from \"commander\";\nimport ora from \"ora\";\nimport { api } from \"../../lib/api.js\";\nimport { config } from \"../../lib/config.js\";\nimport { handleError, McpError } from \"../../lib/errors.js\";\nimport { formatList, formatOutput } from \"../../lib/output.js\";\nimport type { ServerStartResponse } from \"../../types/index.js\";\n\nexport const startCommand = new Command(\"start\")\n\t.description(\"Start the MCP server (npm run dev)\")\n\t.option(\"--mcp-id <id>\", \"Specific MCP ID\")\n\t.action(async (options, command) => {\n\t\tconst globalOptions = command.optsWithGlobals();\n\t\tconst json = globalOptions.json ?? false;\n\n\t\ttry {\n\t\t\tlet mcpId = options.mcpId;\n\n\t\t\tif (!mcpId) {\n\t\t\t\tmcpId = await config.getMcpId();\n\t\t\t\tif (!mcpId) {\n\t\t\t\t\tthrow new McpError(\n\t\t\t\t\t\t\"No active MCP. Run 'waniwani mcp create <name>' or 'waniwani mcp use <name>'.\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst spinner = ora(\"Starting MCP server...\").start();\n\n\t\t\tconst result = await api.post<ServerStartResponse>(\n\t\t\t\t`/api/mcp/sandboxes/${mcpId}/server`,\n\t\t\t\t{ action: \"start\" },\n\t\t\t);\n\n\t\t\tspinner.succeed(\"MCP server started\");\n\n\t\t\tif (json) {\n\t\t\t\tformatOutput(result, true);\n\t\t\t} else {\n\t\t\t\tconsole.log();\n\t\t\t\tformatList(\n\t\t\t\t\t[\n\t\t\t\t\t\t{ label: \"Command ID\", value: result.cmdId },\n\t\t\t\t\t\t{ label: \"Preview URL\", value: chalk.cyan(result.previewUrl) },\n\t\t\t\t\t],\n\t\t\t\t\tfalse,\n\t\t\t\t);\n\t\t\t\tconsole.log();\n\t\t\t\tconsole.log(chalk.bold(\"Test with MCP Inspector:\"));\n\t\t\t\tconsole.log(\n\t\t\t\t\t` npx @modelcontextprotocol/inspector --url ${result.previewUrl}/mcp`,\n\t\t\t\t);\n\t\t\t\tconsole.log();\n\t\t\t\tconsole.log(\n\t\t\t\t\tchalk.gray(\"Run 'waniwani mcp logs' to stream server output\"),\n\t\t\t\t);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\thandleError(error, json);\n\t\t\tprocess.exit(1);\n\t\t}\n\t});\n","import chalk from \"chalk\";\nimport { Command } from \"commander\";\nimport ora from \"ora\";\nimport { api } from \"../../lib/api.js\";\nimport { config } from \"../../lib/config.js\";\nimport { handleError, McpError } from \"../../lib/errors.js\";\nimport { formatList, formatOutput } from \"../../lib/output.js\";\nimport type { Mcp, ServerStatusResponse } from \"../../types/index.js\";\n\nexport const statusCommand = new Command(\"status\")\n\t.description(\"Show current MCP sandbox status\")\n\t.option(\"--mcp-id <id>\", \"Specific MCP ID\")\n\t.action(async (options, command) => {\n\t\tconst globalOptions = command.optsWithGlobals();\n\t\tconst json = globalOptions.json ?? false;\n\n\t\ttry {\n\t\t\tlet mcpId = options.mcpId;\n\n\t\t\tif (!mcpId) {\n\t\t\t\tmcpId = await config.getMcpId();\n\t\t\t\tif (!mcpId) {\n\t\t\t\t\tthrow new McpError(\n\t\t\t\t\t\t\"No active MCP. Run 'waniwani mcp create <name>' to create one or 'waniwani mcp use <name>' to select one.\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst spinner = ora(\"Fetching MCP status...\").start();\n\n\t\t\t// Fetch sandbox status and server status in parallel\n\t\t\tconst [result, serverStatus] = await Promise.all([\n\t\t\t\tapi.get<Mcp>(`/api/mcp/sandboxes/${mcpId}`),\n\t\t\t\tapi\n\t\t\t\t\t.post<ServerStatusResponse>(`/api/mcp/sandboxes/${mcpId}/server`, {\n\t\t\t\t\t\taction: \"status\",\n\t\t\t\t\t})\n\t\t\t\t\t.catch(() => ({\n\t\t\t\t\t\trunning: false,\n\t\t\t\t\t\tcmdId: undefined,\n\t\t\t\t\t\tpreviewUrl: undefined,\n\t\t\t\t\t})),\n\t\t\t]);\n\n\t\t\tspinner.stop();\n\n\t\t\tif (json) {\n\t\t\t\tformatOutput({ ...result, server: serverStatus }, true);\n\t\t\t} else {\n\t\t\t\tconst statusColor =\n\t\t\t\t\tresult.status === \"active\" ? chalk.green : chalk.red;\n\t\t\t\tconst serverRunning = serverStatus.running;\n\t\t\t\tconst serverStatusColor = serverRunning ? chalk.green : chalk.yellow;\n\n\t\t\t\tformatList(\n\t\t\t\t\t[\n\t\t\t\t\t\t{ label: \"MCP ID\", value: result.id },\n\t\t\t\t\t\t{ label: \"Name\", value: result.name },\n\t\t\t\t\t\t{ label: \"Status\", value: statusColor(result.status) },\n\t\t\t\t\t\t{ label: \"Sandbox ID\", value: result.sandboxId },\n\t\t\t\t\t\t{ label: \"Preview URL\", value: result.previewUrl },\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: \"Server\",\n\t\t\t\t\t\t\tvalue: serverStatusColor(serverRunning ? \"Running\" : \"Stopped\"),\n\t\t\t\t\t\t},\n\t\t\t\t\t\t...(serverStatus.cmdId\n\t\t\t\t\t\t\t? [{ label: \"Server Cmd ID\", value: serverStatus.cmdId }]\n\t\t\t\t\t\t\t: []),\n\t\t\t\t\t\t{ label: \"Created\", value: result.createdAt },\n\t\t\t\t\t\t{ label: \"Expires\", value: result.expiresAt ?? \"N/A\" },\n\t\t\t\t\t],\n\t\t\t\t\tfalse,\n\t\t\t\t);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\thandleError(error, json);\n\t\t\tprocess.exit(1);\n\t\t}\n\t});\n","import { Command } from \"commander\";\nimport ora from \"ora\";\nimport { api } from \"../../lib/api.js\";\nimport { config } from \"../../lib/config.js\";\nimport { handleError, McpError } from \"../../lib/errors.js\";\nimport { formatOutput, formatSuccess } from \"../../lib/output.js\";\nimport type { ServerStopResponse } from \"../../types/index.js\";\n\nexport const stopCommand = new Command(\"stop\")\n\t.description(\"Stop the MCP server process\")\n\t.option(\"--mcp-id <id>\", \"Specific MCP ID\")\n\t.action(async (options, command) => {\n\t\tconst globalOptions = command.optsWithGlobals();\n\t\tconst json = globalOptions.json ?? false;\n\n\t\ttry {\n\t\t\tlet mcpId = options.mcpId;\n\n\t\t\tif (!mcpId) {\n\t\t\t\tmcpId = await config.getMcpId();\n\t\t\t\tif (!mcpId) {\n\t\t\t\t\tthrow new McpError(\n\t\t\t\t\t\t\"No active MCP. Run 'waniwani mcp create <name>' or 'waniwani mcp use <name>'.\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst spinner = ora(\"Stopping MCP server...\").start();\n\n\t\t\tconst result = await api.post<ServerStopResponse>(\n\t\t\t\t`/api/mcp/sandboxes/${mcpId}/server`,\n\t\t\t\t{ action: \"stop\" },\n\t\t\t);\n\n\t\t\tif (result.stopped) {\n\t\t\t\tspinner.succeed(\"MCP server stopped\");\n\t\t\t} else {\n\t\t\t\tspinner.warn(\"Server was not running\");\n\t\t\t}\n\n\t\t\tif (json) {\n\t\t\t\tformatOutput(result, true);\n\t\t\t} else {\n\t\t\t\tformatSuccess(\"MCP server stopped.\", false);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\thandleError(error, json);\n\t\t\tprocess.exit(1);\n\t\t}\n\t});\n","import { Command } from \"commander\";\nimport ora from \"ora\";\nimport { api } from \"../../lib/api.js\";\nimport { config, globalConfig } from \"../../lib/config.js\";\nimport { handleError, McpError } from \"../../lib/errors.js\";\nimport { formatOutput, formatSuccess } from \"../../lib/output.js\";\nimport type { Mcp, McpListResponse } from \"../../types/index.js\";\n\nexport const useCommand = new Command(\"use\")\n\t.description(\"Select an MCP to use for subsequent commands\")\n\t.argument(\"<name>\", \"Name of the MCP to use\")\n\t.option(\"--global\", \"Save to global config instead of project config\")\n\t.action(async (name: string, options, command) => {\n\t\tconst globalOptions = command.optsWithGlobals();\n\t\tconst json = globalOptions.json ?? false;\n\n\t\ttry {\n\t\t\tconst spinner = ora(\"Fetching MCPs...\").start();\n\n\t\t\t// Fetch all MCPs\n\t\t\tconst mcps = await api.get<McpListResponse>(\"/api/mcp/sandboxes\");\n\n\t\t\tspinner.stop();\n\n\t\t\t// Find MCP by name\n\t\t\tconst mcp = mcps.find((m: Mcp) => m.name === name);\n\n\t\t\tif (!mcp) {\n\t\t\t\tthrow new McpError(\n\t\t\t\t\t`MCP \"${name}\" not found. Run 'waniwani mcp list' to see available MCPs.`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (mcp.status !== \"active\") {\n\t\t\t\tthrow new McpError(\n\t\t\t\t\t`MCP \"${name}\" is ${mcp.status}. Only active MCPs can be used.`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst cfg = options.global ? globalConfig : config;\n\t\t\tawait cfg.setMcpId(mcp.id);\n\n\t\t\tif (json) {\n\t\t\t\tformatOutput({ selected: mcp, scope: cfg.scope }, true);\n\t\t\t} else {\n\t\t\t\tformatSuccess(`Now using MCP \"${name}\" (${cfg.scope})`, false);\n\t\t\t\tconsole.log();\n\t\t\t\tconsole.log(` MCP ID: ${mcp.id}`);\n\t\t\t\tconsole.log(` Preview URL: ${mcp.previewUrl}`);\n\t\t\t\tconsole.log();\n\t\t\t\tconsole.log(\"Next steps:\");\n\t\t\t\tconsole.log(' waniwani task \"Add a tool\"');\n\t\t\t\tconsole.log(\" waniwani mcp test\");\n\t\t\t\tconsole.log(\" waniwani mcp status\");\n\t\t\t}\n\t\t} catch (error) {\n\t\t\thandleError(error, json);\n\t\t\tprocess.exit(1);\n\t\t}\n\t});\n","import { Command } from \"commander\";\nimport { listCommand } from \"./list.js\";\nimport { switchCommand } from \"./switch.js\";\n\nexport const orgCommand = new Command(\"org\")\n\t.description(\"Organization management commands\")\n\t.addCommand(listCommand)\n\t.addCommand(switchCommand);\n","import chalk from \"chalk\";\nimport { Command } from \"commander\";\nimport ora from \"ora\";\nimport { api } from \"../../lib/api.js\";\nimport { handleError } from \"../../lib/errors.js\";\nimport { formatOutput, formatTable } from \"../../lib/output.js\";\nimport type { Org, OrgListResponse } from \"../../types/index.js\";\n\nexport const listCommand = new Command(\"list\")\n\t.description(\"List your organizations\")\n\t.action(async (_, command) => {\n\t\tconst globalOptions = command.optsWithGlobals();\n\t\tconst json = globalOptions.json ?? false;\n\n\t\ttry {\n\t\t\tconst spinner = ora(\"Fetching organizations...\").start();\n\n\t\t\tconst result = await api.get<OrgListResponse>(\"/api/oauth/orgs\");\n\n\t\t\tspinner.stop();\n\n\t\t\tconst { orgs, activeOrgId } = result;\n\n\t\t\tif (json) {\n\t\t\t\tformatOutput(\n\t\t\t\t\t{\n\t\t\t\t\t\torgs: orgs.map((o: Org) => ({\n\t\t\t\t\t\t\t...o,\n\t\t\t\t\t\t\tisActive: o.id === activeOrgId,\n\t\t\t\t\t\t})),\n\t\t\t\t\t\tactiveOrgId,\n\t\t\t\t\t},\n\t\t\t\t\ttrue,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tif (orgs.length === 0) {\n\t\t\t\t\tconsole.log(\"No organizations found.\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconsole.log(chalk.bold(\"\\nOrganizations:\\n\"));\n\n\t\t\t\tconst rows = orgs.map((o: Org) => {\n\t\t\t\t\tconst isActive = o.id === activeOrgId;\n\t\t\t\t\treturn [\n\t\t\t\t\t\tisActive ? chalk.cyan(`* ${o.name}`) : ` ${o.name}`,\n\t\t\t\t\t\to.slug,\n\t\t\t\t\t\to.role,\n\t\t\t\t\t];\n\t\t\t\t});\n\n\t\t\t\tformatTable([\"Name\", \"Slug\", \"Role\"], rows, false);\n\n\t\t\t\tconsole.log();\n\t\t\t\tif (activeOrgId) {\n\t\t\t\t\tconst activeOrg = orgs.find((o: Org) => o.id === activeOrgId);\n\t\t\t\t\tif (activeOrg) {\n\t\t\t\t\t\tconsole.log(`Active organization: ${chalk.cyan(activeOrg.name)}`);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconsole.log(\"\\nSwitch organization: waniwani org switch <name>\");\n\t\t\t}\n\t\t} catch (error) {\n\t\t\thandleError(error, json);\n\t\t\tprocess.exit(1);\n\t\t}\n\t});\n","import { Command } from \"commander\";\nimport ora from \"ora\";\nimport { api } from \"../../lib/api.js\";\nimport { config } from \"../../lib/config.js\";\nimport { CLIError, handleError } from \"../../lib/errors.js\";\nimport { formatOutput, formatSuccess } from \"../../lib/output.js\";\nimport type {\n\tOrg,\n\tOrgListResponse,\n\tOrgSwitchResponse,\n} from \"../../types/index.js\";\n\nexport const switchCommand = new Command(\"switch\")\n\t.description(\"Switch to a different organization\")\n\t.argument(\"<name>\", \"Name or slug of the organization to switch to\")\n\t.action(async (name: string, _, command) => {\n\t\tconst globalOptions = command.optsWithGlobals();\n\t\tconst json = globalOptions.json ?? false;\n\n\t\ttry {\n\t\t\tconst spinner = ora(\"Fetching organizations...\").start();\n\n\t\t\t// First fetch orgs to find the org ID\n\t\t\tconst { orgs } = await api.get<OrgListResponse>(\"/api/oauth/orgs\");\n\n\t\t\t// Find org by name or slug\n\t\t\tconst org = orgs.find((o: Org) => o.name === name || o.slug === name);\n\n\t\t\tif (!org) {\n\t\t\t\tspinner.stop();\n\t\t\t\tthrow new CLIError(\n\t\t\t\t\t`Organization \"${name}\" not found. Run 'waniwani org list' to see available organizations.`,\n\t\t\t\t\t\"ORG_NOT_FOUND\",\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tspinner.text = \"Switching organization...\";\n\n\t\t\t// Switch to the org\n\t\t\tawait api.post<OrgSwitchResponse>(\"/api/oauth/orgs/switch\", {\n\t\t\t\torgId: org.id,\n\t\t\t});\n\n\t\t\tspinner.succeed(\"Organization switched\");\n\n\t\t\t// Clear local MCP selection since we switched orgs\n\t\t\tconfig.setMcpId(null);\n\n\t\t\tif (json) {\n\t\t\t\tformatOutput({ switched: org }, true);\n\t\t\t} else {\n\t\t\t\tformatSuccess(`Switched to organization \"${org.name}\"`, false);\n\t\t\t\tconsole.log();\n\t\t\t\tconsole.log(\"Note: Active MCP selection has been cleared.\");\n\t\t\t\tconsole.log(\n\t\t\t\t\t\"Run 'waniwani mcp list' to see MCPs in this organization.\",\n\t\t\t\t);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\thandleError(error, json);\n\t\t\tprocess.exit(1);\n\t\t}\n\t});\n","import chalk from \"chalk\";\nimport { Command } from \"commander\";\nimport ora from \"ora\";\nimport { api } from \"../lib/api.js\";\nimport { CLIError, handleError } from \"../lib/errors.js\";\nimport { formatOutput, formatSuccess } from \"../lib/output.js\";\nimport {\n\tcollectFiles,\n\tfindProjectRoot,\n\tloadProjectMcpId,\n} from \"../lib/sync.js\";\nimport type { WriteFilesResponse } from \"../types/index.js\";\n\nconst BATCH_SIZE = 50;\n\nexport const pushCommand = new Command(\"push\")\n\t.description(\"Sync local files to MCP sandbox\")\n\t.option(\"--dry-run\", \"Show what would be synced without uploading\")\n\t.action(async (options, command) => {\n\t\tconst globalOptions = command.optsWithGlobals();\n\t\tconst json = globalOptions.json ?? false;\n\n\t\ttry {\n\t\t\tconst cwd = process.cwd();\n\n\t\t\t// Find project root\n\t\t\tconst projectRoot = await findProjectRoot(cwd);\n\t\t\tif (!projectRoot) {\n\t\t\t\tthrow new CLIError(\n\t\t\t\t\t\"Not in a WaniWani project. Run 'waniwani init <name>' first.\",\n\t\t\t\t\t\"NOT_IN_PROJECT\",\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Load MCP ID\n\t\t\tconst mcpId = await loadProjectMcpId(projectRoot);\n\t\t\tif (!mcpId) {\n\t\t\t\tthrow new CLIError(\n\t\t\t\t\t\"No MCP ID found in project config. Run 'waniwani init <name>' first.\",\n\t\t\t\t\t\"NO_MCP_ID\",\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Collect files\n\t\t\tconst spinner = ora(\"Collecting files...\").start();\n\t\t\tconst files = await collectFiles(projectRoot);\n\n\t\t\tif (files.length === 0) {\n\t\t\t\tspinner.info(\"No files to sync\");\n\t\t\t\tif (json) {\n\t\t\t\t\tformatOutput({ synced: 0, files: [] }, true);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tspinner.text = `Found ${files.length} files`;\n\n\t\t\tif (options.dryRun) {\n\t\t\t\tspinner.stop();\n\t\t\t\tconsole.log();\n\t\t\t\tconsole.log(chalk.bold(\"Files that would be synced:\"));\n\t\t\t\tfor (const file of files) {\n\t\t\t\t\tconsole.log(` ${file.path}`);\n\t\t\t\t}\n\t\t\t\tconsole.log();\n\t\t\t\tconsole.log(`Total: ${files.length} files`);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Sync files in batches\n\t\t\tconst allWritten: string[] = [];\n\t\t\tconst totalBatches = Math.ceil(files.length / BATCH_SIZE);\n\n\t\t\tfor (let i = 0; i < totalBatches; i++) {\n\t\t\t\tconst batch = files.slice(i * BATCH_SIZE, (i + 1) * BATCH_SIZE);\n\t\t\t\tspinner.text = `Syncing files (${i + 1}/${totalBatches})...`;\n\n\t\t\t\tconst result = await api.post<WriteFilesResponse>(\n\t\t\t\t\t`/api/mcp/sandboxes/${mcpId}/files`,\n\t\t\t\t\t{\n\t\t\t\t\t\tfiles: batch.map((f) => ({\n\t\t\t\t\t\t\tpath: f.path,\n\t\t\t\t\t\t\tcontent: f.content,\n\t\t\t\t\t\t\tencoding: f.encoding,\n\t\t\t\t\t\t})),\n\t\t\t\t\t},\n\t\t\t\t);\n\n\t\t\t\tallWritten.push(...result.written);\n\t\t\t}\n\n\t\t\tspinner.succeed(`Synced ${allWritten.length} files`);\n\n\t\t\tif (json) {\n\t\t\t\tformatOutput(\n\t\t\t\t\t{\n\t\t\t\t\t\tsynced: allWritten.length,\n\t\t\t\t\t\tfiles: allWritten,\n\t\t\t\t\t},\n\t\t\t\t\ttrue,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tconsole.log();\n\t\t\t\tformatSuccess(`${allWritten.length} files synced to sandbox`, false);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\thandleError(error, json);\n\t\t\tprocess.exit(1);\n\t\t}\n\t});\n","import { program } from \"./cli.js\";\n\nprogram.parse(process.argv);\n"],"mappings":";;;AAAA,SAAS,WAAAA,iBAAe;;;ACAxB,SAAS,WAAAC,gBAAe;;;ACAxB,SAAS,cAAAC,mBAAkB;AAC3B,S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,QAAQ,OAAO,EACf,OAAO,UAAU,wBAAwB,EACzC,OAAO,aAAa,wBAAwB;AAG9C,QAAQ,WAAW,YAAY;AAC/B,QAAQ,WAAW,aAAa;AAGhC,QAAQ,WAAW,WAAW;AAC9B,QAAQ,WAAW,WAAW;AAC9B,QAAQ,WAAW,UAAU;AAC7B,QAAQ,WAAW,UAAU;AAC7B,QAAQ,WAAW,UAAU;AAC7B,QAAQ,WAAW,aAAa;;;AgC3BhC,QAAQ,MAAM,QAAQ,IAAI;","names":["Command","Command","existsSync","join","chalk","chalk","join","existsSync","Command","relative","chalk","Command","mkdir","readFile","writeFile","homedir","join","z","join","homedir","z","mkdir","readFile","writeFile","existsSync","mkdir","readFile","writeFile","join","existsSync","join","readFile","mkdir","writeFile","Command","relative","chalk","existsSync","mkdir","readFile","join","Command","ora","join","existsSync","readFile","config","Command","ora","mkdir","chalk","Command","ora","Command","chalk","ora","Command","Command","Command","Command","ora","Command","ora","Command","ora","Command","ora","Command","chalk","Command","ora","Command","ora","chalk","writeFile","Command","ora","Command","ora","writeFile","readFile","Command","ora","Command","readFile","ora","Command","chalk","Command","ora","listCommand","Command","ora","chalk","chalk","Command","ora","Command","ora","chalk","chalk","Command","ora","Command","ora","chalk","chalk","Command","ora","Command","ora","chalk","chalk","Command","ora","Command","ora","chalk","Command","ora","Command","ora","Command","ora","Command","ora","Command","listCommand","Command","chalk","Command","ora","listCommand","Command","ora","chalk","Command","ora","Command","ora","Command","listCommand","chalk","Command","ora","BATCH_SIZE","Command","ora","chalk","Command"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@waniwani/cli",
3
- "version": "0.0.32",
3
+ "version": "0.0.33",
4
4
  "description": "WaniWani CLI for MCP development workflow",
5
5
  "type": "module",
6
6
  "exports": {