capable-kit 0.0.1-alpha.1 → 0.0.1-alpha.2

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/README.md CHANGED
@@ -36,6 +36,22 @@ The package provides the `cap` CLI command. `capable` remains an alias:
36
36
  cap dev
37
37
  ```
38
38
 
39
+ ## Deploy
40
+
41
+ Capable detects supported build environments such as Vercel and emits their
42
+ native deployment output:
43
+
44
+ ```sh
45
+ vercel
46
+ ```
47
+
48
+ To create Vercel's Build Output API locally instead:
49
+
50
+ ```sh
51
+ cap build --preset vercel
52
+ vercel deploy --prebuilt
53
+ ```
54
+
39
55
  ## Package contents
40
56
 
41
57
  The published package includes compiled ESM in `dist/`, declaration files, and
package/dist/bin.mjs CHANGED
@@ -106,7 +106,7 @@ function createCapableNitroConfig(project, options) {
106
106
  return {
107
107
  rootDir: project.rootDir,
108
108
  dev: options.dev,
109
- preset: options.dev ? "nitro-dev" : options.preset ?? "node-server",
109
+ ...options.dev ? { preset: "nitro-dev" } : options.preset ? { preset: options.preset } : { defaultPreset: "node-server" },
110
110
  compatibilityDate: "2026-07-15",
111
111
  alias: serverEntry ? {
112
112
  "#capable/server": serverEntry,
@@ -188,7 +188,7 @@ const TOPICS = {
188
188
  },
189
189
  {
190
190
  label: "--preset <preset>",
191
- description: "Nitro preset (default: node-server)"
191
+ description: "Nitro preset (auto-detected; fallback: node-server)"
192
192
  },
193
193
  APP_OPTION,
194
194
  HELP_OPTION
@@ -344,7 +344,7 @@ const SCRIPTS = {
344
344
  preview: "cap preview"
345
345
  };
346
346
  const DEPENDENCIES = {
347
- "capable-kit": "latest",
347
+ "capable-kit": "alpha",
348
348
  zod: "^4.0.0"
349
349
  };
350
350
  async function initializeCapableProject(options) {
package/dist/bin.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"bin.mjs","names":[],"sources":["../../nitro-host/src/index.ts","../../toolchain/src/help.ts","../../toolchain/src/project.ts","../../toolchain/src/init.ts","../../toolchain/src/index.ts","../src/bin.ts"],"sourcesContent":["import { existsSync } from \"node:fs\";\nimport { readFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport {\n build,\n createDevServer,\n createNitro,\n prepare,\n} from \"nitro/builder\";\nimport type { NitroConfig } from \"nitro/types\";\n\nconst virtualServerEntry = \"#capable/entry\";\n\n/**\n * Support code for the virtual entry. It sits beside this module as\n * TypeScript in the repository and as bundled JavaScript in a published\n * package, so resolve whichever extension is actually there.\n */\nfunction runtimeSupportModule(): string {\n for (const extension of [\".ts\", \".mjs\", \".js\"]) {\n const candidate = fileURLToPath(\n new URL(`./runtime-support${extension}`, import.meta.url),\n );\n if (existsSync(candidate)) return candidate;\n }\n throw new Error(\"Missing the Capable Nitro runtime support module\");\n}\n\n/**\n * Render Nitro's in-memory server entry. Keeping the entry virtual lets Nitro\n * transform the project's `#capable/*` aliases without writing generated files\n * into the project.\n */\nfunction renderServerEntry(\n project: CapableNitroProject,\n options: { readonly dev: boolean },\n): string {\n const hasServer = Boolean(project.serverEntry);\n return [\n `import { createCapableNitroEntry } from ${\n JSON.stringify(runtimeSupportModule())\n };`,\n 'import definition from \"#capable/app\";',\n ...(hasServer ? ['import server from \"#capable/server\";'] : []),\n \"\",\n \"export default createCapableNitroEntry({\",\n \" definition,\",\n ...(hasServer ? [\" server,\"] : []),\n ` dev: ${options.dev},`,\n \"});\",\n \"\",\n ].join(\"\\n\");\n}\n\nexport type CapableNitroProject = {\n readonly rootDir: string;\n readonly entry: string | URL;\n readonly serverEntry?: string | URL;\n};\n\nexport type CapableNitroDevServer = {\n readonly origin: string;\n close(): Promise<void>;\n};\n\nexport async function startCapableNitroDevServer(options: {\n project: CapableNitroProject;\n hostname?: string;\n port?: number;\n}): Promise<CapableNitroDevServer> {\n const nitro = await createNitro(\n createCapableNitroConfig(options.project, { dev: true }),\n );\n const server = createDevServer(nitro);\n\n try {\n const listener = server.listen({\n port: options.port ?? 3000,\n hostname: options.hostname ?? \"localhost\",\n silent: true,\n });\n await listener.ready();\n await prepare(nitro);\n await build(nitro);\n\n if (!listener.url) {\n throw new Error(\"Nitro dev server started without a public URL\");\n }\n\n return {\n origin: listener.url.replace(/\\/$/, \"\"),\n close: () => nitro.close(),\n };\n } catch (error) {\n await nitro.close();\n throw error;\n }\n}\n\nexport async function buildCapableNitroApplication(options: {\n project: CapableNitroProject;\n outputDir?: string;\n preset?: string;\n}): Promise<{ outputDir: string }> {\n const outputDir = options.outputDir\n ? path.resolve(options.project.rootDir, options.outputDir)\n : undefined;\n const nitro = await createNitro(\n createCapableNitroConfig(options.project, {\n dev: false,\n ...(outputDir ? { outputDir } : {}),\n ...(options.preset ? { preset: options.preset } : {}),\n }),\n );\n\n try {\n await prepare(nitro);\n await build(nitro);\n return { outputDir: nitro.options.output.dir };\n } finally {\n await nitro.close();\n }\n}\n\nexport async function resolveCapableNitroPreviewCommand(outputDir: string): Promise<{\n command: string;\n cwd: string;\n}> {\n const cwd = path.resolve(outputDir);\n const manifestPath = path.join(cwd, \"nitro.json\");\n let manifest: {\n preset?: unknown;\n commands?: { preview?: unknown };\n };\n try {\n manifest = JSON.parse(await readFile(manifestPath, \"utf8\")) as {\n preset?: unknown;\n commands?: { preview?: unknown };\n };\n } catch {\n throw new Error(`Could not read a runnable Capable build at ${manifestPath}. Run \\`cap build\\` with the node-server preset first.`);\n }\n\n const command = manifest.commands?.preview;\n if (typeof command !== \"string\" || !command.trim()) {\n throw new Error(\n `The Nitro ${String(manifest.preset ?? \"deployment\")} preset does not produce a locally runnable preview command. Build with the node-server preset to use \\`cap preview\\`.`,\n );\n }\n return { command, cwd };\n}\n\nfunction createCapableNitroConfig(\n project: CapableNitroProject,\n options: {\n dev: boolean;\n outputDir?: string;\n preset?: string;\n },\n): NitroConfig {\n const entry = project.entry instanceof URL\n ? fileURLToPath(project.entry)\n : path.resolve(project.entry);\n const serverEntry = project.serverEntry instanceof URL\n ? fileURLToPath(project.serverEntry)\n : project.serverEntry\n ? path.resolve(project.serverEntry)\n : undefined;\n\n return {\n rootDir: project.rootDir,\n dev: options.dev,\n preset: options.dev ? \"nitro-dev\" : options.preset ?? \"node-server\",\n compatibilityDate: \"2026-07-15\",\n alias: serverEntry\n ? { \"#capable/server\": serverEntry, \"#capable/app\": entry }\n : { \"#capable/app\": entry },\n virtual: {\n [virtualServerEntry]: renderServerEntry(project, { dev: options.dev }),\n },\n serverEntry: virtualServerEntry,\n serverDir: false,\n scanDirs: [],\n imports: false,\n noPublicDir: true,\n logLevel: 2,\n logging: { buildSuccess: false },\n framework: { name: \"capable\" },\n ...(options.outputDir ? { output: { dir: options.outputDir } } : {}),\n };\n}\n","import {\n createCliStyle,\n descriptionColumn,\n MARGIN,\n renderRows,\n renderSection,\n supportsColor,\n type CliRow,\n type CliStyle,\n} from \"@capable/cli\";\n\nexport type HelpTopic = \"init\" | \"dev\" | \"build\" | \"preview\" | \"cli\";\n\nconst HELP_OPTION: CliRow = { label: \"-h, --help\", description: \"Show help\" };\n\nconst APP_OPTION: CliRow = {\n label: \"--app <path>\",\n description: \"Project directory or App entry\",\n};\n\nconst COMMANDS: readonly CliRow[] = [\n { label: \"init [directory]\", description: \"Create a starter Capable App\" },\n { label: \"dev [project]\", description: \"Run the development server\" },\n { label: \"build [project]\", description: \"Build the App for deployment\" },\n { label: \"preview [project]\", description: \"Serve the built App\" },\n { label: \"cli <command...>\", description: \"Call Capabilities from your terminal\" },\n];\n\nconst TOPICS: Record<HelpTopic, {\n readonly usage: string;\n readonly summary: string;\n readonly options: readonly CliRow[];\n readonly footer?: string;\n}> = {\n init: {\n usage: \"cap init [directory]\",\n summary: \"Create a runnable App package without overwriting existing work.\",\n options: [HELP_OPTION],\n },\n dev: {\n usage: \"cap dev [project] [options]\",\n summary: \"Run the development server with live reload.\",\n options: [\n { label: \"--host <host>\", description: \"Hostname to bind (default: localhost)\" },\n { label: \"--port <port>\", description: \"Port to bind (default: 3000)\" },\n APP_OPTION,\n HELP_OPTION,\n ],\n },\n build: {\n usage: \"cap build [project] [options]\",\n summary: \"Build the App for deployment.\",\n options: [\n { label: \"--output <dir>\", description: \"Build directory (default: .output)\" },\n { label: \"--preset <preset>\", description: \"Nitro preset (default: node-server)\" },\n APP_OPTION,\n HELP_OPTION,\n ],\n },\n preview: {\n usage: \"cap preview [project] [options]\",\n summary: \"Serve a previous build the way production will.\",\n options: [\n { label: \"--output <dir>\", description: \"Build directory (default: .output)\" },\n { label: \"--host <host>\", description: \"Hostname to bind (default: localhost)\" },\n { label: \"--port <port>\", description: \"Port to bind (default: 3000)\" },\n APP_OPTION,\n HELP_OPTION,\n ],\n },\n cli: {\n usage: \"cap cli [options] <command...>\",\n summary: \"Call your App's Capabilities from the terminal.\",\n options: [\n {\n label: \"--app <path|url>\",\n description: \"Project, App entry, or a running Capable server URL\",\n },\n HELP_OPTION,\n ],\n footer: \"Run `cap cli -- --help` to list the commands your App derives.\",\n },\n};\n\nexport function renderCapableHelp(\n topic?: HelpTopic,\n options: { readonly color?: boolean } = {},\n): string {\n const style = createCliStyle(options.color ?? supportsColor());\n return topic ? renderTopicHelp(topic, style) : renderRootHelp(style);\n}\n\nfunction renderRootHelp(style: CliStyle): string {\n const options = [HELP_OPTION];\n const column = descriptionColumn([...COMMANDS, ...options]);\n return page([\n banner(\"cap <command> [options]\", \"Develop, build, and call Capable Apps\", style, \"Capable\"),\n renderSection(\"Commands\", renderRows(COMMANDS, style, { column }), style),\n renderSection(\"Options\", renderRows(options, style, { column }), style),\n renderSection(\n \"Project discovery\",\n `${MARGIN}${MARGIN}${style.dim(\n '[project] or --app → CAPABLE_APP → package.json \"capable\" → capable.app.*',\n )}`,\n style,\n ),\n `${MARGIN}${style.dim(\"Run `cap <command> --help` for details on a command.\")}`,\n ]);\n}\n\nfunction renderTopicHelp(topic: HelpTopic, style: CliStyle): string {\n const { usage, summary, options, footer } = TOPICS[topic];\n return page([\n banner(usage, summary, style),\n renderSection(\"Options\", renderRows(options, style), style),\n footer ? `${MARGIN}${style.dim(footer)}` : undefined,\n ]);\n}\n\nfunction banner(\n usage: string,\n summary: string,\n style: CliStyle,\n title?: string,\n): string {\n return title\n ? [\n `${MARGIN}${style.bold(title)}\\n${MARGIN}${style.dim(summary)}`,\n `${MARGIN}${style.accent(usage)}`,\n ].join(\"\\n\\n\")\n : `${MARGIN}${style.bold(usage)}\\n\\n${MARGIN}${style.dim(summary)}`;\n}\n\nfunction page(sections: readonly (string | undefined)[]): string {\n return `\\n${sections.filter(Boolean).join(\"\\n\\n\")}\\n`;\n}\n","import { readFile, stat } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport type { CapableNitroProject } from \"@capable/nitro-host\";\n\nexport const CAPABLE_APPLICATION_ENTRIES = [\n \"capable.app.ts\",\n \"capable.app.tsx\",\n \"capable.app.js\",\n \"capable.app.mjs\",\n \"capable.app.cjs\",\n] as const;\n\nconst SERVER_ENTRIES = [\n \"capable.server.ts\",\n \"capable.server.tsx\",\n \"capable.server.js\",\n \"capable.server.mjs\",\n \"capable.server.cjs\",\n] as const;\n\nexport type ResolvedCapableProject = CapableNitroProject & {\n readonly entry: string;\n readonly serverEntry?: string;\n};\n\nexport async function resolveCapableProject(options: {\n readonly project?: string;\n readonly cwd?: string;\n readonly env?: Readonly<Record<string, string | undefined>>;\n} = {}): Promise<ResolvedCapableProject> {\n const cwd = path.resolve(options.cwd ?? process.cwd());\n const env = options.env ?? process.env;\n const configured =\n options.project ??\n env.CAPABLE_APP ??\n await readPackageEntry(cwd);\n const candidate = path.resolve(cwd, configured ?? \".\");\n const candidateStat = await stat(candidate).catch(() => undefined);\n\n let entry: string | undefined;\n let rootDir: string;\n if (candidateStat?.isFile()) {\n entry = candidate;\n rootDir = await findPackageRoot(path.dirname(candidate)) ??\n path.dirname(candidate);\n } else if (candidateStat?.isDirectory()) {\n entry = await findEntry(candidate, CAPABLE_APPLICATION_ENTRIES);\n rootDir = await findPackageRoot(candidate) ?? candidate;\n } else {\n throw projectNotFound(candidate, configured);\n }\n\n if (!entry) throw projectNotFound(candidate, configured);\n const serverEntry = await findEntry(rootDir, SERVER_ENTRIES);\n return {\n rootDir,\n entry,\n ...(serverEntry ? { serverEntry } : {}),\n };\n}\n\nasync function readPackageEntry(cwd: string): Promise<string | undefined> {\n try {\n const value = JSON.parse(\n await readFile(path.join(cwd, \"package.json\"), \"utf8\"),\n ) as { readonly capable?: unknown };\n return typeof value.capable === \"string\" ? value.capable : undefined;\n } catch {\n return undefined;\n }\n}\n\nasync function findPackageRoot(start: string): Promise<string | undefined> {\n let directory = start;\n while (true) {\n if ((await stat(path.join(directory, \"package.json\")).catch(() => undefined))\n ?.isFile()) {\n return directory;\n }\n const parent = path.dirname(directory);\n if (parent === directory) return undefined;\n directory = parent;\n }\n}\n\nasync function findEntry(\n directory: string,\n names: readonly string[],\n): Promise<string | undefined> {\n for (const name of names) {\n const candidate = path.join(directory, name);\n if ((await stat(candidate).catch(() => undefined))?.isFile()) {\n return candidate;\n }\n }\n return undefined;\n}\n\nfunction projectNotFound(candidate: string, configured?: string): Error {\n return new Error(\n configured\n ? `Could not find a Capable application at ${candidate}`\n : `Could not find ${CAPABLE_APPLICATION_ENTRIES.join(\", \")} in ${candidate}`,\n );\n}\n","import { mkdir, readFile, stat, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { CAPABLE_APPLICATION_ENTRIES } from \"./project.ts\";\n\nfunction starter(appName: string): string {\n return `import { capability, defineApp } from \"capable-kit\";\nimport { z } from \"zod\";\n\nconst hello = capability({\n id: \"hello\",\n title: \"Say hello\",\n effect: \"read\",\n output: z.object({ message: z.string() }),\n handler: () => ({ message: \"Hello from Capable\" }),\n});\n\nexport default defineApp({\n name: ${JSON.stringify(appName)},\n capabilities: { hello },\n});\n`;\n}\n\nconst SCRIPTS = {\n dev: \"cap dev\",\n build: \"cap build\",\n preview: \"cap preview\",\n} as const;\n\nconst DEPENDENCIES = {\n \"capable-kit\": \"latest\",\n zod: \"^4.0.0\",\n} as const;\n\nexport async function initializeCapableProject(options: {\n readonly directory: string;\n}): Promise<{\n readonly entry: string;\n readonly packageJson: string;\n readonly packageAction: \"created\" | \"updated\" | \"unchanged\";\n}> {\n const directory = path.resolve(options.directory);\n await mkdir(directory, { recursive: true });\n\n const packageJson = path.join(directory, \"package.json\");\n const existingPackage = await readPackageJson(packageJson);\n if (typeof existingPackage?.capable === \"string\") {\n throw new Error(\n `package.json already configures a Capable application at ${existingPackage.capable}`,\n );\n }\n\n for (const name of CAPABLE_APPLICATION_ENTRIES) {\n const existing = path.join(directory, name);\n if ((await stat(existing).catch(() => undefined))?.isFile()) {\n throw new Error(`A Capable application already exists at ${existing}`);\n }\n }\n\n const entry = path.join(directory, CAPABLE_APPLICATION_ENTRIES[0]);\n const packageResult = preparePackageJson(directory, existingPackage);\n await writeFile(\n entry,\n starter(applicationName(directory, packageResult.value)),\n { flag: \"wx\" },\n );\n if (packageResult.action !== \"unchanged\") {\n await writeFile(\n packageJson,\n `${JSON.stringify(packageResult.value, null, 2)}\\n`,\n existingPackage ? undefined : { flag: \"wx\" },\n );\n }\n return {\n entry,\n packageJson,\n packageAction: packageResult.action,\n };\n}\n\nasync function readPackageJson(\n filename: string,\n): Promise<Record<string, unknown> | undefined> {\n let source: string;\n try {\n source = await readFile(filename, \"utf8\");\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === \"ENOENT\") return undefined;\n throw error;\n }\n const value = JSON.parse(source) as unknown;\n if (!isRecord(value)) {\n throw new Error(`${filename} must contain a JSON object`);\n }\n return value;\n}\n\nfunction preparePackageJson(\n directory: string,\n existing: Record<string, unknown> | undefined,\n): {\n readonly value: Record<string, unknown>;\n readonly action: \"created\" | \"updated\" | \"unchanged\";\n} {\n if (!existing) {\n return {\n action: \"created\",\n value: {\n name: packageName(directory),\n private: true,\n version: \"0.0.0\",\n type: \"module\",\n scripts: SCRIPTS,\n dependencies: DEPENDENCIES,\n },\n };\n }\n\n let changed = false;\n const value = { ...existing };\n const scripts = readObjectField(value, \"scripts\");\n for (const [name, command] of Object.entries(SCRIPTS)) {\n if (name in scripts) continue;\n scripts[name] = command;\n changed = true;\n }\n if (changed || !(\"scripts\" in value)) value.scripts = scripts;\n\n const dependencies = readObjectField(value, \"dependencies\");\n for (const [name, version] of Object.entries(DEPENDENCIES)) {\n if (hasDeclaredDependency(value, name)) continue;\n dependencies[name] = version;\n changed = true;\n }\n if (Object.keys(dependencies).length || \"dependencies\" in value) {\n value.dependencies = dependencies;\n }\n\n return {\n value,\n action: changed ? \"updated\" : \"unchanged\",\n };\n}\n\nfunction readObjectField(\n value: Record<string, unknown>,\n field: string,\n): Record<string, unknown> {\n const current = value[field];\n if (current === undefined) return {};\n if (!isRecord(current)) {\n throw new Error(`package.json \"${field}\" must be an object`);\n }\n return { ...current };\n}\n\nfunction hasDeclaredDependency(\n packageJson: Record<string, unknown>,\n name: string,\n): boolean {\n return [\n \"dependencies\",\n \"devDependencies\",\n \"peerDependencies\",\n \"optionalDependencies\",\n ].some((field) => {\n const dependencies = packageJson[field];\n return isRecord(dependencies) && name in dependencies;\n });\n}\n\nfunction packageName(directory: string): string {\n return path.basename(directory)\n .toLowerCase()\n .replace(/[^a-z0-9._-]+/g, \"-\")\n .replace(/^[-._]+|[-._]+$/g, \"\") || \"capable-app\";\n}\n\nfunction applicationName(\n directory: string,\n packageJson: Record<string, unknown>,\n): string {\n const configured = typeof packageJson.name === \"string\"\n ? packageJson.name.split(\"/\").at(-1)\n : undefined;\n const name = configured || path.basename(directory);\n return name\n .split(/[-_.\\s]+/)\n .filter(Boolean)\n .map((part) => `${part[0]!.toUpperCase()}${part.slice(1)}`)\n .join(\" \") || \"Capable App\";\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return Boolean(value && typeof value === \"object\" && !Array.isArray(value));\n}\n","import path from \"node:path\";\nimport { spawn } from \"node:child_process\";\nimport { pathToFileURL } from \"node:url\";\nimport { runCli } from \"@capable/cli\";\nimport {\n APPLICATION_SYMBOL,\n type AppDefinition,\n} from \"@capable/core\";\nimport {\n buildCapableNitroApplication,\n resolveCapableNitroPreviewCommand,\n startCapableNitroDevServer,\n type CapableNitroDevServer,\n} from \"@capable/nitro-host\";\nimport {\n createApp,\n createRemoteApp,\n isApp,\n type AnyApp,\n type ApplicationManifest,\n type ManifestNode,\n} from \"@capable/app\";\nimport { createHttpTransport } from \"@capable/fetch\";\nimport { renderCapableHelp, type HelpTopic } from \"./help.ts\";\nimport { initializeCapableProject } from \"./init.ts\";\nimport { resolveCapableProject } from \"./project.ts\";\n\nexport { renderCapableHelp, type HelpTopic } from \"./help.ts\";\n\nexport { resolveCapableProject, type ResolvedCapableProject } from \"./project.ts\";\n\ntype Write = (text: string) => void;\n\nexport type RunCapableCommandOptions = {\n readonly cwd?: string;\n readonly env?: Readonly<Record<string, string | undefined>>;\n readonly stdout?: Write;\n readonly stderr?: Write;\n};\n\ntype LifecycleCommand = {\n readonly command: \"dev\" | \"build\" | \"preview\";\n readonly project?: string;\n readonly host?: string;\n readonly output?: string;\n readonly port?: number;\n readonly preset?: string;\n};\n\ntype CliCommand = {\n readonly command: \"cli\";\n readonly app?: string;\n readonly argv: readonly string[];\n};\n\ntype HelpCommand = {\n readonly command: \"help\";\n readonly topic?: HelpTopic;\n};\n\ntype InitCommand = {\n readonly command: \"init\";\n readonly project?: string;\n};\n\ntype ParsedCommand = LifecycleCommand | CliCommand | InitCommand | HelpCommand;\n\nclass UsageError extends Error {}\n\nexport async function runCapableCommand(\n argv: readonly string[],\n options: RunCapableCommandOptions = {},\n): Promise<number> {\n const stdout = options.stdout ?? ((text) => process.stdout.write(text));\n const stderr = options.stderr ?? ((text) => process.stderr.write(text));\n try {\n const command = parseCapableCommand(argv);\n if (command.command === \"help\") {\n stdout(renderCapableHelp(command.topic, {\n color: !options.stdout && Boolean(process.stdout.isTTY),\n }));\n return 0;\n }\n if (command.command === \"cli\") {\n return runCli({\n app: await resolveCliApp(command.app, options),\n argv: command.argv,\n ...(!options.stdout && process.stdout.isTTY\n ? { isTTY: true }\n : {}),\n ...(!options.stdout && process.stdout.columns\n ? { columns: process.stdout.columns }\n : {}),\n ...(options.stdout || options.stderr\n ? {\n io: {\n ...(options.stdout ? { stdout: options.stdout } : {}),\n ...(options.stderr ? { stderr: options.stderr } : {}),\n },\n }\n : {}),\n });\n }\n if (command.command === \"init\") {\n const cwd = path.resolve(options.cwd ?? process.cwd());\n const directory = path.resolve(cwd, command.project ?? \".\");\n const result = await initializeCapableProject({ directory });\n const entry = path.relative(cwd, result.entry) ||\n path.basename(result.entry);\n const packageJson = path.relative(cwd, result.packageJson) ||\n path.basename(result.packageJson);\n stdout([\n `Created ${entry}`,\n ...(result.packageAction === \"unchanged\"\n ? []\n : [`${capitalize(result.packageAction)} ${packageJson}`]),\n \"\",\n \"Next:\",\n ...(command.project\n ? [` cd ${shellArgument(command.project)}`]\n : []),\n \" pnpm install\",\n \" pnpm dev\",\n \"\",\n ].join(\"\\n\"));\n return 0;\n }\n\n const project = await resolveCapableProject({\n ...(command.project ? { project: command.project } : {}),\n ...(options.cwd ? { cwd: options.cwd } : {}),\n ...(options.env ? { env: options.env } : {}),\n });\n\n if (command.command === \"dev\") {\n const server = await startCapableNitroDevServer({\n project,\n ...(command.host ? { hostname: command.host } : {}),\n ...(command.port !== undefined ? { port: command.port } : {}),\n });\n try {\n stdout(await renderDevReady(server, {\n hasAuthoredServer: Boolean(project.serverEntry),\n color: !options.stdout && Boolean(process.stdout.isTTY),\n }));\n await waitForShutdown();\n } finally {\n await server.close();\n }\n return 0;\n }\n\n if (command.command === \"build\") {\n const result = await buildCapableNitroApplication({\n project,\n ...(command.output ? { outputDir: command.output } : {}),\n ...(command.preset ? { preset: command.preset } : {}),\n });\n stdout(`Built Capable application at ${result.outputDir}\\n`);\n return 0;\n }\n\n const outputDir = path.resolve(\n project.rootDir,\n command.output ?? \".output\",\n );\n const preview = await resolveCapableNitroPreviewCommand(outputDir);\n const child = spawn(preview.command, {\n cwd: preview.cwd,\n env: {\n ...process.env,\n ...(command.host ? { NITRO_HOST: command.host } : {}),\n ...(command.port !== undefined\n ? { NITRO_PORT: String(command.port) }\n : {}),\n },\n shell: true,\n stdio: \"inherit\",\n });\n return await new Promise<number>((resolve, reject) => {\n child.once(\"error\", reject);\n child.once(\"exit\", (code, signal) => {\n if (code !== null) return resolve(code);\n reject(new Error(`Preview process exited from signal ${signal ?? \"unknown\"}`));\n });\n });\n } catch (error) {\n stderr(`${error instanceof Error ? error.message : String(error)}\\n`);\n if (error instanceof UsageError) {\n stderr(\"Run `cap --help` for usage.\\n\");\n return 2;\n }\n return 1;\n }\n}\n\nexport function parseCapableCommand(argv: readonly string[]): ParsedCommand {\n const [rawCommand, ...rest] = argv;\n if (\n rawCommand === undefined ||\n rawCommand === \"help\" ||\n rawCommand === \"--help\" ||\n rawCommand === \"-h\"\n ) {\n return { command: \"help\" };\n }\n if (rawCommand === \"start\") {\n throw new UsageError(\"`cap start` was renamed to `cap preview`.\");\n }\n if (rawCommand === \"cli\") return parseCli(rest);\n if (rawCommand === \"init\") return parseInit(rest);\n if (\n rawCommand !== \"dev\" &&\n rawCommand !== \"build\" &&\n rawCommand !== \"preview\"\n ) {\n throw new UsageError(`Unknown Capable command: ${rawCommand}`);\n }\n if (rest.includes(\"--help\") || rest.includes(\"-h\")) {\n return { command: \"help\", topic: rawCommand };\n }\n\n const values = [...rest];\n let project: string | undefined;\n let host: string | undefined;\n let output: string | undefined;\n let port: number | undefined;\n let preset: string | undefined;\n\n while (values.length) {\n const token = values.shift()!;\n if (!token.startsWith(\"-\")) {\n if (project) {\n throw new UsageError(\n `Unexpected argument for cap ${rawCommand}: ${token}`,\n );\n }\n project = token;\n continue;\n }\n switch (token) {\n case \"--app\":\n if (project) {\n throw new UsageError(\"Specify a project path once.\");\n }\n project = takeValue(values, token);\n break;\n case \"--host\":\n if (rawCommand === \"build\") {\n throw unsupportedOption(rawCommand, token);\n }\n host = takeValue(values, token);\n break;\n case \"--port\":\n if (rawCommand === \"build\") {\n throw unsupportedOption(rawCommand, token);\n }\n port = parsePort(takeValue(values, token));\n break;\n case \"--output\":\n if (rawCommand === \"dev\") {\n throw unsupportedOption(rawCommand, token);\n }\n output = takeValue(values, token);\n break;\n case \"--preset\":\n if (rawCommand !== \"build\") {\n throw unsupportedOption(rawCommand, token);\n }\n preset = takeValue(values, token);\n break;\n default:\n throw unsupportedOption(rawCommand, token);\n }\n }\n\n return {\n command: rawCommand,\n ...(project ? { project } : {}),\n ...(host ? { host } : {}),\n ...(output ? { output } : {}),\n ...(port !== undefined ? { port } : {}),\n ...(preset ? { preset } : {}),\n };\n}\n\nfunction parseInit(argv: readonly string[]): InitCommand | HelpCommand {\n if (argv.includes(\"--help\") || argv.includes(\"-h\")) {\n return { command: \"help\", topic: \"init\" };\n }\n if (argv.length > 1) {\n throw new UsageError(`Unexpected argument for cap init: ${argv[1]}`);\n }\n const project = argv[0];\n if (project?.startsWith(\"-\")) {\n throw unsupportedOption(\"init\", project);\n }\n return {\n command: \"init\",\n ...(project ? { project } : {}),\n };\n}\n\nfunction parseCli(argv: readonly string[]): CliCommand | HelpCommand {\n const values = [...argv];\n let app: string | undefined;\n while (values.length) {\n const token = values[0]!;\n if (token === \"--help\" || token === \"-h\") {\n return { command: \"help\", topic: \"cli\" };\n }\n if (token === \"--\") {\n values.shift();\n break;\n }\n if (token !== \"--app\") break;\n values.shift();\n if (app) throw new UsageError(\"Specify a CLI App once.\");\n app = takeValue(values, token);\n }\n return {\n command: \"cli\",\n ...(app ? { app } : {}),\n argv: values,\n };\n}\n\nfunction takeValue(argv: string[], option: string): string {\n const value = argv.shift();\n if (!value || value.startsWith(\"-\")) {\n throw new UsageError(`${option} requires a value`);\n }\n return value;\n}\n\nfunction parsePort(value: string): number {\n const port = Number(value);\n if (!Number.isInteger(port) || port < 0 || port > 65_535) {\n throw new UsageError(`Invalid --port value: ${value}`);\n }\n return port;\n}\n\nfunction unsupportedOption(command: string, option: string): UsageError {\n return new UsageError(`Unknown option for cap ${command}: ${option}`);\n}\n\nfunction capitalize(value: string): string {\n return `${value[0]?.toUpperCase() ?? \"\"}${value.slice(1)}`;\n}\n\nfunction shellArgument(value: string): string {\n return /^[a-zA-Z0-9_./-]+$/.test(value)\n ? value\n : `'${value.replaceAll(\"'\", \"'\\\\''\")}'`;\n}\n\nasync function resolveCliApp(\n configured: string | undefined,\n options: Pick<RunCapableCommandOptions, \"cwd\" | \"env\">,\n): Promise<AnyApp> {\n if (configured && isHttpUrl(configured)) {\n return createRemoteApp(createHttpTransport({\n url: new URL(\"/_capable/\", configured),\n }));\n }\n\n const project = await resolveCapableProject({\n ...(configured ? { project: configured } : {}),\n ...(options.cwd ? { cwd: options.cwd } : {}),\n ...(options.env ? { env: options.env } : {}),\n });\n if (project.serverEntry) {\n const module = await import(pathToFileURL(project.serverEntry).href) as {\n readonly default?: unknown;\n };\n const server = module.default;\n if (!isFetchServer(server)) {\n throw new Error(\n `${project.serverEntry} must default-export a Capable server`,\n );\n }\n return createRemoteApp(createHttpTransport({\n url: \"http://capable.local/_capable/\",\n fetch: (request) => server.fetch(request),\n }));\n }\n\n const module = await import(pathToFileURL(project.entry).href) as {\n readonly default?: unknown;\n };\n const definition = module.default;\n if (isApp(definition)) return definition;\n if (\n !definition ||\n typeof definition !== \"object\" ||\n (definition as Partial<AppDefinition<any>>)[APPLICATION_SYMBOL] !== true\n ) {\n throw new Error(\n `${project.entry} must default-export a Capable App Definition`,\n );\n }\n return createApp(definition as AppDefinition<any, undefined>);\n}\n\nfunction isHttpUrl(value: string): boolean {\n try {\n const url = new URL(value);\n return url.protocol === \"http:\" || url.protocol === \"https:\";\n } catch {\n return false;\n }\n}\n\nfunction isFetchServer(value: unknown): value is {\n readonly fetch: (request: Request) => Response | Promise<Response>;\n} {\n return Boolean(\n value &&\n typeof value === \"object\" &&\n typeof (value as { readonly fetch?: unknown }).fetch === \"function\",\n );\n}\n\nasync function renderDevReady(\n server: CapableNitroDevServer,\n options: {\n readonly hasAuthoredServer: boolean;\n readonly color?: boolean;\n },\n): Promise<string> {\n const origin = server.origin;\n const manifest = await readJson<ApplicationManifest>(\n `${origin}/_capable/manifest`,\n );\n const openapi = await readJson<Record<string, unknown>>(\n `${origin}/openapi.json`,\n );\n const mcp = await probeMcp(origin);\n\n const paint = createPainter(options.color ?? false);\n const routes: Array<readonly [string, string]> = [\n [\"Local\", displayOrigin(origin)],\n ];\n if (manifest) routes.push([\"Standard\", \"/_capable\"]);\n if (openapi) {\n routes.push([\"HTTP\", \"/api\"], [\"OpenAPI\", \"/openapi.json\"]);\n }\n if (mcp) routes.push([\"MCP\", \"/mcp\"]);\n if (!manifest && !openapi && options.hasAuthoredServer) {\n routes.push([\"Server\", \"capable.server.ts\"]);\n }\n const width = routes.reduce((max, [label]) => Math.max(max, label.length), 0);\n\n const heading = manifest\n ? `${paint.bold(manifest.name)} ${paint.dim(manifest.version)}`\n : paint.bold(\"Capable\");\n const summary = manifest\n ? `${plural(\n countCapabilities(manifest.capabilities),\n \"capability\",\n \"capabilities\",\n )} ready, watching for changes`\n : \"Ready, watching for changes\";\n\n return [\n \"\",\n `${paint.accent(\"◆\")} ${heading}`,\n \"\",\n ...routes.map(([label, value]) =>\n `${paint.dim(label.padEnd(width))} ${value}`\n ),\n \"\",\n `${paint.accent(\"✓\")} ${paint.dim(summary)}`,\n \"\",\n ...(manifest\n ? [\n `${paint.dim(\"Call these capabilities from your terminal:\")}`,\n ` ${paint.bold(\"cap cli --help\")} ${paint.dim(\"every command, typed and documented\")}`,\n \"\",\n ]\n : []),\n \"\",\n ].join(\"\\n\");\n}\n\n/** Wildcard and loopback hosts are noise in a dev banner; show localhost. */\nfunction displayOrigin(origin: string): string {\n try {\n const url = new URL(origin);\n if (\n url.hostname === \"[::1]\" || url.hostname === \"::1\" ||\n url.hostname === \"127.0.0.1\" || url.hostname === \"0.0.0.0\" ||\n url.hostname === \"[::]\"\n ) {\n url.hostname = \"localhost\";\n }\n return url.toString().replace(/\\/$/, \"\");\n } catch {\n return origin;\n }\n}\n\nfunction plural(count: number, one: string, many: string): string {\n return `${count} ${count === 1 ? one : many}`;\n}\n\nfunction createPainter(enabled: boolean) {\n const wrap = (code: string) =>\n (text: string) => (enabled ? `\\u001B[${code}m${text}\\u001B[0m` : text);\n return {\n bold: wrap(\"1\"),\n dim: wrap(\"2\"),\n accent: wrap(\"36\"),\n };\n}\n\nasync function readJson<T>(url: string): Promise<T | undefined> {\n try {\n const response = await fetch(url);\n if (!response.ok) return undefined;\n return await response.json() as T;\n } catch {\n return undefined;\n }\n}\n\n/**\n * Probe the default MCP mount by issuing a JSON-RPC `initialize`. The mount\n * is stateless per request, so a successful response means an agent can\n * connect at `/mcp`.\n */\nasync function probeMcp(origin: string): Promise<boolean> {\n try {\n const response = await fetch(`${origin}/mcp`, {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n accept: \"application/json, text/event-stream\",\n },\n body: JSON.stringify({\n jsonrpc: \"2.0\",\n id: 1,\n method: \"initialize\",\n params: {\n protocolVersion: \"2025-06-18\",\n capabilities: {},\n clientInfo: { name: \"capable\", version: \"0.0.0\" },\n },\n }),\n });\n if (!response.ok) return false;\n const body = await response.json().catch(() => undefined);\n return Boolean(body && body.result);\n } catch {\n return false;\n }\n}\n\nfunction countCapabilities(nodes: readonly ManifestNode[]): number {\n return nodes.reduce(\n (count, node) =>\n count + (node.type === \"capability\"\n ? 1\n : countCapabilities(node.children)),\n 0,\n );\n}\n\nfunction waitForShutdown(): Promise<void> {\n return new Promise((resolve) => {\n const finish = () => {\n process.off(\"SIGINT\", finish);\n process.off(\"SIGTERM\", finish);\n resolve();\n };\n process.once(\"SIGINT\", finish);\n process.once(\"SIGTERM\", finish);\n });\n}\n","#!/usr/bin/env node\nimport { runCapableCommand } from \"@capable/toolchain\";\n\nprocess.exit(await runCapableCommand(process.argv.slice(2)));\n"],"mappings":";;;;;;;;;;;;AAYA,MAAM,qBAAqB;;;;;;AAO3B,SAAS,uBAA+B;CACtC,KAAK,MAAM,aAAa;EAAC;EAAO;EAAQ;CAAK,GAAG;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AU,MAAM;EAC7B,QAAQ,KAAK,WAAW,MAAM;CAChC,CAAC;AACH;;;AChkBA,QAAQ,KAAK,MAAM,kBAAkB,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"bin.mjs","names":[],"sources":["../../nitro-host/src/index.ts","../../toolchain/src/help.ts","../../toolchain/src/project.ts","../../toolchain/src/init.ts","../../toolchain/src/index.ts","../src/bin.ts"],"sourcesContent":["import { existsSync } from \"node:fs\";\nimport { readFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport {\n build,\n createDevServer,\n createNitro,\n prepare,\n} from \"nitro/builder\";\nimport type { NitroConfig } from \"nitro/types\";\n\nconst virtualServerEntry = \"#capable/entry\";\n\n/**\n * Support code for the virtual entry. It sits beside this module as\n * TypeScript in the repository and as bundled JavaScript in a published\n * package, so resolve whichever extension is actually there.\n */\nfunction runtimeSupportModule(): string {\n for (const extension of [\".ts\", \".mjs\", \".js\"]) {\n const candidate = fileURLToPath(\n new URL(`./runtime-support${extension}`, import.meta.url),\n );\n if (existsSync(candidate)) return candidate;\n }\n throw new Error(\"Missing the Capable Nitro runtime support module\");\n}\n\n/**\n * Render Nitro's in-memory server entry. Keeping the entry virtual lets Nitro\n * transform the project's `#capable/*` aliases without writing generated files\n * into the project.\n */\nfunction renderServerEntry(\n project: CapableNitroProject,\n options: { readonly dev: boolean },\n): string {\n const hasServer = Boolean(project.serverEntry);\n return [\n `import { createCapableNitroEntry } from ${\n JSON.stringify(runtimeSupportModule())\n };`,\n 'import definition from \"#capable/app\";',\n ...(hasServer ? ['import server from \"#capable/server\";'] : []),\n \"\",\n \"export default createCapableNitroEntry({\",\n \" definition,\",\n ...(hasServer ? [\" server,\"] : []),\n ` dev: ${options.dev},`,\n \"});\",\n \"\",\n ].join(\"\\n\");\n}\n\nexport type CapableNitroProject = {\n readonly rootDir: string;\n readonly entry: string | URL;\n readonly serverEntry?: string | URL;\n};\n\nexport type CapableNitroDevServer = {\n readonly origin: string;\n close(): Promise<void>;\n};\n\nexport async function startCapableNitroDevServer(options: {\n project: CapableNitroProject;\n hostname?: string;\n port?: number;\n}): Promise<CapableNitroDevServer> {\n const nitro = await createNitro(\n createCapableNitroConfig(options.project, { dev: true }),\n );\n const server = createDevServer(nitro);\n\n try {\n const listener = server.listen({\n port: options.port ?? 3000,\n hostname: options.hostname ?? \"localhost\",\n silent: true,\n });\n await listener.ready();\n await prepare(nitro);\n await build(nitro);\n\n if (!listener.url) {\n throw new Error(\"Nitro dev server started without a public URL\");\n }\n\n return {\n origin: listener.url.replace(/\\/$/, \"\"),\n close: () => nitro.close(),\n };\n } catch (error) {\n await nitro.close();\n throw error;\n }\n}\n\nexport async function buildCapableNitroApplication(options: {\n project: CapableNitroProject;\n outputDir?: string;\n preset?: string;\n}): Promise<{ outputDir: string }> {\n const outputDir = options.outputDir\n ? path.resolve(options.project.rootDir, options.outputDir)\n : undefined;\n const nitro = await createNitro(\n createCapableNitroConfig(options.project, {\n dev: false,\n ...(outputDir ? { outputDir } : {}),\n ...(options.preset ? { preset: options.preset } : {}),\n }),\n );\n\n try {\n await prepare(nitro);\n await build(nitro);\n return { outputDir: nitro.options.output.dir };\n } finally {\n await nitro.close();\n }\n}\n\nexport async function resolveCapableNitroPreviewCommand(outputDir: string): Promise<{\n command: string;\n cwd: string;\n}> {\n const cwd = path.resolve(outputDir);\n const manifestPath = path.join(cwd, \"nitro.json\");\n let manifest: {\n preset?: unknown;\n commands?: { preview?: unknown };\n };\n try {\n manifest = JSON.parse(await readFile(manifestPath, \"utf8\")) as {\n preset?: unknown;\n commands?: { preview?: unknown };\n };\n } catch {\n throw new Error(`Could not read a runnable Capable build at ${manifestPath}. Run \\`cap build\\` with the node-server preset first.`);\n }\n\n const command = manifest.commands?.preview;\n if (typeof command !== \"string\" || !command.trim()) {\n throw new Error(\n `The Nitro ${String(manifest.preset ?? \"deployment\")} preset does not produce a locally runnable preview command. Build with the node-server preset to use \\`cap preview\\`.`,\n );\n }\n return { command, cwd };\n}\n\nfunction createCapableNitroConfig(\n project: CapableNitroProject,\n options: {\n dev: boolean;\n outputDir?: string;\n preset?: string;\n },\n): NitroConfig {\n const entry = project.entry instanceof URL\n ? fileURLToPath(project.entry)\n : path.resolve(project.entry);\n const serverEntry = project.serverEntry instanceof URL\n ? fileURLToPath(project.serverEntry)\n : project.serverEntry\n ? path.resolve(project.serverEntry)\n : undefined;\n\n return {\n rootDir: project.rootDir,\n dev: options.dev,\n ...(options.dev\n ? { preset: \"nitro-dev\" }\n : options.preset\n ? { preset: options.preset }\n : { defaultPreset: \"node-server\" }),\n compatibilityDate: \"2026-07-15\",\n alias: serverEntry\n ? { \"#capable/server\": serverEntry, \"#capable/app\": entry }\n : { \"#capable/app\": entry },\n virtual: {\n [virtualServerEntry]: renderServerEntry(project, { dev: options.dev }),\n },\n serverEntry: virtualServerEntry,\n serverDir: false,\n scanDirs: [],\n imports: false,\n noPublicDir: true,\n logLevel: 2,\n logging: { buildSuccess: false },\n framework: { name: \"capable\" },\n ...(options.outputDir ? { output: { dir: options.outputDir } } : {}),\n };\n}\n","import {\n createCliStyle,\n descriptionColumn,\n MARGIN,\n renderRows,\n renderSection,\n supportsColor,\n type CliRow,\n type CliStyle,\n} from \"@capable/cli\";\n\nexport type HelpTopic = \"init\" | \"dev\" | \"build\" | \"preview\" | \"cli\";\n\nconst HELP_OPTION: CliRow = { label: \"-h, --help\", description: \"Show help\" };\n\nconst APP_OPTION: CliRow = {\n label: \"--app <path>\",\n description: \"Project directory or App entry\",\n};\n\nconst COMMANDS: readonly CliRow[] = [\n { label: \"init [directory]\", description: \"Create a starter Capable App\" },\n { label: \"dev [project]\", description: \"Run the development server\" },\n { label: \"build [project]\", description: \"Build the App for deployment\" },\n { label: \"preview [project]\", description: \"Serve the built App\" },\n { label: \"cli <command...>\", description: \"Call Capabilities from your terminal\" },\n];\n\nconst TOPICS: Record<HelpTopic, {\n readonly usage: string;\n readonly summary: string;\n readonly options: readonly CliRow[];\n readonly footer?: string;\n}> = {\n init: {\n usage: \"cap init [directory]\",\n summary: \"Create a runnable App package without overwriting existing work.\",\n options: [HELP_OPTION],\n },\n dev: {\n usage: \"cap dev [project] [options]\",\n summary: \"Run the development server with live reload.\",\n options: [\n { label: \"--host <host>\", description: \"Hostname to bind (default: localhost)\" },\n { label: \"--port <port>\", description: \"Port to bind (default: 3000)\" },\n APP_OPTION,\n HELP_OPTION,\n ],\n },\n build: {\n usage: \"cap build [project] [options]\",\n summary: \"Build the App for deployment.\",\n options: [\n { label: \"--output <dir>\", description: \"Build directory (default: .output)\" },\n {\n label: \"--preset <preset>\",\n description: \"Nitro preset (auto-detected; fallback: node-server)\",\n },\n APP_OPTION,\n HELP_OPTION,\n ],\n },\n preview: {\n usage: \"cap preview [project] [options]\",\n summary: \"Serve a previous build the way production will.\",\n options: [\n { label: \"--output <dir>\", description: \"Build directory (default: .output)\" },\n { label: \"--host <host>\", description: \"Hostname to bind (default: localhost)\" },\n { label: \"--port <port>\", description: \"Port to bind (default: 3000)\" },\n APP_OPTION,\n HELP_OPTION,\n ],\n },\n cli: {\n usage: \"cap cli [options] <command...>\",\n summary: \"Call your App's Capabilities from the terminal.\",\n options: [\n {\n label: \"--app <path|url>\",\n description: \"Project, App entry, or a running Capable server URL\",\n },\n HELP_OPTION,\n ],\n footer: \"Run `cap cli -- --help` to list the commands your App derives.\",\n },\n};\n\nexport function renderCapableHelp(\n topic?: HelpTopic,\n options: { readonly color?: boolean } = {},\n): string {\n const style = createCliStyle(options.color ?? supportsColor());\n return topic ? renderTopicHelp(topic, style) : renderRootHelp(style);\n}\n\nfunction renderRootHelp(style: CliStyle): string {\n const options = [HELP_OPTION];\n const column = descriptionColumn([...COMMANDS, ...options]);\n return page([\n banner(\"cap <command> [options]\", \"Develop, build, and call Capable Apps\", style, \"Capable\"),\n renderSection(\"Commands\", renderRows(COMMANDS, style, { column }), style),\n renderSection(\"Options\", renderRows(options, style, { column }), style),\n renderSection(\n \"Project discovery\",\n `${MARGIN}${MARGIN}${style.dim(\n '[project] or --app → CAPABLE_APP → package.json \"capable\" → capable.app.*',\n )}`,\n style,\n ),\n `${MARGIN}${style.dim(\"Run `cap <command> --help` for details on a command.\")}`,\n ]);\n}\n\nfunction renderTopicHelp(topic: HelpTopic, style: CliStyle): string {\n const { usage, summary, options, footer } = TOPICS[topic];\n return page([\n banner(usage, summary, style),\n renderSection(\"Options\", renderRows(options, style), style),\n footer ? `${MARGIN}${style.dim(footer)}` : undefined,\n ]);\n}\n\nfunction banner(\n usage: string,\n summary: string,\n style: CliStyle,\n title?: string,\n): string {\n return title\n ? [\n `${MARGIN}${style.bold(title)}\\n${MARGIN}${style.dim(summary)}`,\n `${MARGIN}${style.accent(usage)}`,\n ].join(\"\\n\\n\")\n : `${MARGIN}${style.bold(usage)}\\n\\n${MARGIN}${style.dim(summary)}`;\n}\n\nfunction page(sections: readonly (string | undefined)[]): string {\n return `\\n${sections.filter(Boolean).join(\"\\n\\n\")}\\n`;\n}\n","import { readFile, stat } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport type { CapableNitroProject } from \"@capable/nitro-host\";\n\nexport const CAPABLE_APPLICATION_ENTRIES = [\n \"capable.app.ts\",\n \"capable.app.tsx\",\n \"capable.app.js\",\n \"capable.app.mjs\",\n \"capable.app.cjs\",\n] as const;\n\nconst SERVER_ENTRIES = [\n \"capable.server.ts\",\n \"capable.server.tsx\",\n \"capable.server.js\",\n \"capable.server.mjs\",\n \"capable.server.cjs\",\n] as const;\n\nexport type ResolvedCapableProject = CapableNitroProject & {\n readonly entry: string;\n readonly serverEntry?: string;\n};\n\nexport async function resolveCapableProject(options: {\n readonly project?: string;\n readonly cwd?: string;\n readonly env?: Readonly<Record<string, string | undefined>>;\n} = {}): Promise<ResolvedCapableProject> {\n const cwd = path.resolve(options.cwd ?? process.cwd());\n const env = options.env ?? process.env;\n const configured =\n options.project ??\n env.CAPABLE_APP ??\n await readPackageEntry(cwd);\n const candidate = path.resolve(cwd, configured ?? \".\");\n const candidateStat = await stat(candidate).catch(() => undefined);\n\n let entry: string | undefined;\n let rootDir: string;\n if (candidateStat?.isFile()) {\n entry = candidate;\n rootDir = await findPackageRoot(path.dirname(candidate)) ??\n path.dirname(candidate);\n } else if (candidateStat?.isDirectory()) {\n entry = await findEntry(candidate, CAPABLE_APPLICATION_ENTRIES);\n rootDir = await findPackageRoot(candidate) ?? candidate;\n } else {\n throw projectNotFound(candidate, configured);\n }\n\n if (!entry) throw projectNotFound(candidate, configured);\n const serverEntry = await findEntry(rootDir, SERVER_ENTRIES);\n return {\n rootDir,\n entry,\n ...(serverEntry ? { serverEntry } : {}),\n };\n}\n\nasync function readPackageEntry(cwd: string): Promise<string | undefined> {\n try {\n const value = JSON.parse(\n await readFile(path.join(cwd, \"package.json\"), \"utf8\"),\n ) as { readonly capable?: unknown };\n return typeof value.capable === \"string\" ? value.capable : undefined;\n } catch {\n return undefined;\n }\n}\n\nasync function findPackageRoot(start: string): Promise<string | undefined> {\n let directory = start;\n while (true) {\n if ((await stat(path.join(directory, \"package.json\")).catch(() => undefined))\n ?.isFile()) {\n return directory;\n }\n const parent = path.dirname(directory);\n if (parent === directory) return undefined;\n directory = parent;\n }\n}\n\nasync function findEntry(\n directory: string,\n names: readonly string[],\n): Promise<string | undefined> {\n for (const name of names) {\n const candidate = path.join(directory, name);\n if ((await stat(candidate).catch(() => undefined))?.isFile()) {\n return candidate;\n }\n }\n return undefined;\n}\n\nfunction projectNotFound(candidate: string, configured?: string): Error {\n return new Error(\n configured\n ? `Could not find a Capable application at ${candidate}`\n : `Could not find ${CAPABLE_APPLICATION_ENTRIES.join(\", \")} in ${candidate}`,\n );\n}\n","import { mkdir, readFile, stat, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { CAPABLE_APPLICATION_ENTRIES } from \"./project.ts\";\n\nfunction starter(appName: string): string {\n return `import { capability, defineApp } from \"capable-kit\";\nimport { z } from \"zod\";\n\nconst hello = capability({\n id: \"hello\",\n title: \"Say hello\",\n effect: \"read\",\n output: z.object({ message: z.string() }),\n handler: () => ({ message: \"Hello from Capable\" }),\n});\n\nexport default defineApp({\n name: ${JSON.stringify(appName)},\n capabilities: { hello },\n});\n`;\n}\n\nconst SCRIPTS = {\n dev: \"cap dev\",\n build: \"cap build\",\n preview: \"cap preview\",\n} as const;\n\nconst DEPENDENCIES = {\n \"capable-kit\": \"alpha\",\n zod: \"^4.0.0\",\n} as const;\n\nexport async function initializeCapableProject(options: {\n readonly directory: string;\n}): Promise<{\n readonly entry: string;\n readonly packageJson: string;\n readonly packageAction: \"created\" | \"updated\" | \"unchanged\";\n}> {\n const directory = path.resolve(options.directory);\n await mkdir(directory, { recursive: true });\n\n const packageJson = path.join(directory, \"package.json\");\n const existingPackage = await readPackageJson(packageJson);\n if (typeof existingPackage?.capable === \"string\") {\n throw new Error(\n `package.json already configures a Capable application at ${existingPackage.capable}`,\n );\n }\n\n for (const name of CAPABLE_APPLICATION_ENTRIES) {\n const existing = path.join(directory, name);\n if ((await stat(existing).catch(() => undefined))?.isFile()) {\n throw new Error(`A Capable application already exists at ${existing}`);\n }\n }\n\n const entry = path.join(directory, CAPABLE_APPLICATION_ENTRIES[0]);\n const packageResult = preparePackageJson(directory, existingPackage);\n await writeFile(\n entry,\n starter(applicationName(directory, packageResult.value)),\n { flag: \"wx\" },\n );\n if (packageResult.action !== \"unchanged\") {\n await writeFile(\n packageJson,\n `${JSON.stringify(packageResult.value, null, 2)}\\n`,\n existingPackage ? undefined : { flag: \"wx\" },\n );\n }\n return {\n entry,\n packageJson,\n packageAction: packageResult.action,\n };\n}\n\nasync function readPackageJson(\n filename: string,\n): Promise<Record<string, unknown> | undefined> {\n let source: string;\n try {\n source = await readFile(filename, \"utf8\");\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === \"ENOENT\") return undefined;\n throw error;\n }\n const value = JSON.parse(source) as unknown;\n if (!isRecord(value)) {\n throw new Error(`${filename} must contain a JSON object`);\n }\n return value;\n}\n\nfunction preparePackageJson(\n directory: string,\n existing: Record<string, unknown> | undefined,\n): {\n readonly value: Record<string, unknown>;\n readonly action: \"created\" | \"updated\" | \"unchanged\";\n} {\n if (!existing) {\n return {\n action: \"created\",\n value: {\n name: packageName(directory),\n private: true,\n version: \"0.0.0\",\n type: \"module\",\n scripts: SCRIPTS,\n dependencies: DEPENDENCIES,\n },\n };\n }\n\n let changed = false;\n const value = { ...existing };\n const scripts = readObjectField(value, \"scripts\");\n for (const [name, command] of Object.entries(SCRIPTS)) {\n if (name in scripts) continue;\n scripts[name] = command;\n changed = true;\n }\n if (changed || !(\"scripts\" in value)) value.scripts = scripts;\n\n const dependencies = readObjectField(value, \"dependencies\");\n for (const [name, version] of Object.entries(DEPENDENCIES)) {\n if (hasDeclaredDependency(value, name)) continue;\n dependencies[name] = version;\n changed = true;\n }\n if (Object.keys(dependencies).length || \"dependencies\" in value) {\n value.dependencies = dependencies;\n }\n\n return {\n value,\n action: changed ? \"updated\" : \"unchanged\",\n };\n}\n\nfunction readObjectField(\n value: Record<string, unknown>,\n field: string,\n): Record<string, unknown> {\n const current = value[field];\n if (current === undefined) return {};\n if (!isRecord(current)) {\n throw new Error(`package.json \"${field}\" must be an object`);\n }\n return { ...current };\n}\n\nfunction hasDeclaredDependency(\n packageJson: Record<string, unknown>,\n name: string,\n): boolean {\n return [\n \"dependencies\",\n \"devDependencies\",\n \"peerDependencies\",\n \"optionalDependencies\",\n ].some((field) => {\n const dependencies = packageJson[field];\n return isRecord(dependencies) && name in dependencies;\n });\n}\n\nfunction packageName(directory: string): string {\n return path.basename(directory)\n .toLowerCase()\n .replace(/[^a-z0-9._-]+/g, \"-\")\n .replace(/^[-._]+|[-._]+$/g, \"\") || \"capable-app\";\n}\n\nfunction applicationName(\n directory: string,\n packageJson: Record<string, unknown>,\n): string {\n const configured = typeof packageJson.name === \"string\"\n ? packageJson.name.split(\"/\").at(-1)\n : undefined;\n const name = configured || path.basename(directory);\n return name\n .split(/[-_.\\s]+/)\n .filter(Boolean)\n .map((part) => `${part[0]!.toUpperCase()}${part.slice(1)}`)\n .join(\" \") || \"Capable App\";\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return Boolean(value && typeof value === \"object\" && !Array.isArray(value));\n}\n","import path from \"node:path\";\nimport { spawn } from \"node:child_process\";\nimport { pathToFileURL } from \"node:url\";\nimport { runCli } from \"@capable/cli\";\nimport {\n APPLICATION_SYMBOL,\n type AppDefinition,\n} from \"@capable/core\";\nimport {\n buildCapableNitroApplication,\n resolveCapableNitroPreviewCommand,\n startCapableNitroDevServer,\n type CapableNitroDevServer,\n} from \"@capable/nitro-host\";\nimport {\n createApp,\n createRemoteApp,\n isApp,\n type AnyApp,\n type ApplicationManifest,\n type ManifestNode,\n} from \"@capable/app\";\nimport { createHttpTransport } from \"@capable/fetch\";\nimport { renderCapableHelp, type HelpTopic } from \"./help.ts\";\nimport { initializeCapableProject } from \"./init.ts\";\nimport { resolveCapableProject } from \"./project.ts\";\n\nexport { renderCapableHelp, type HelpTopic } from \"./help.ts\";\n\nexport { resolveCapableProject, type ResolvedCapableProject } from \"./project.ts\";\n\ntype Write = (text: string) => void;\n\nexport type RunCapableCommandOptions = {\n readonly cwd?: string;\n readonly env?: Readonly<Record<string, string | undefined>>;\n readonly stdout?: Write;\n readonly stderr?: Write;\n};\n\ntype LifecycleCommand = {\n readonly command: \"dev\" | \"build\" | \"preview\";\n readonly project?: string;\n readonly host?: string;\n readonly output?: string;\n readonly port?: number;\n readonly preset?: string;\n};\n\ntype CliCommand = {\n readonly command: \"cli\";\n readonly app?: string;\n readonly argv: readonly string[];\n};\n\ntype HelpCommand = {\n readonly command: \"help\";\n readonly topic?: HelpTopic;\n};\n\ntype InitCommand = {\n readonly command: \"init\";\n readonly project?: string;\n};\n\ntype ParsedCommand = LifecycleCommand | CliCommand | InitCommand | HelpCommand;\n\nclass UsageError extends Error {}\n\nexport async function runCapableCommand(\n argv: readonly string[],\n options: RunCapableCommandOptions = {},\n): Promise<number> {\n const stdout = options.stdout ?? ((text) => process.stdout.write(text));\n const stderr = options.stderr ?? ((text) => process.stderr.write(text));\n try {\n const command = parseCapableCommand(argv);\n if (command.command === \"help\") {\n stdout(renderCapableHelp(command.topic, {\n color: !options.stdout && Boolean(process.stdout.isTTY),\n }));\n return 0;\n }\n if (command.command === \"cli\") {\n return runCli({\n app: await resolveCliApp(command.app, options),\n argv: command.argv,\n ...(!options.stdout && process.stdout.isTTY\n ? { isTTY: true }\n : {}),\n ...(!options.stdout && process.stdout.columns\n ? { columns: process.stdout.columns }\n : {}),\n ...(options.stdout || options.stderr\n ? {\n io: {\n ...(options.stdout ? { stdout: options.stdout } : {}),\n ...(options.stderr ? { stderr: options.stderr } : {}),\n },\n }\n : {}),\n });\n }\n if (command.command === \"init\") {\n const cwd = path.resolve(options.cwd ?? process.cwd());\n const directory = path.resolve(cwd, command.project ?? \".\");\n const result = await initializeCapableProject({ directory });\n const entry = path.relative(cwd, result.entry) ||\n path.basename(result.entry);\n const packageJson = path.relative(cwd, result.packageJson) ||\n path.basename(result.packageJson);\n stdout([\n `Created ${entry}`,\n ...(result.packageAction === \"unchanged\"\n ? []\n : [`${capitalize(result.packageAction)} ${packageJson}`]),\n \"\",\n \"Next:\",\n ...(command.project\n ? [` cd ${shellArgument(command.project)}`]\n : []),\n \" pnpm install\",\n \" pnpm dev\",\n \"\",\n ].join(\"\\n\"));\n return 0;\n }\n\n const project = await resolveCapableProject({\n ...(command.project ? { project: command.project } : {}),\n ...(options.cwd ? { cwd: options.cwd } : {}),\n ...(options.env ? { env: options.env } : {}),\n });\n\n if (command.command === \"dev\") {\n const server = await startCapableNitroDevServer({\n project,\n ...(command.host ? { hostname: command.host } : {}),\n ...(command.port !== undefined ? { port: command.port } : {}),\n });\n try {\n stdout(await renderDevReady(server, {\n hasAuthoredServer: Boolean(project.serverEntry),\n color: !options.stdout && Boolean(process.stdout.isTTY),\n }));\n await waitForShutdown();\n } finally {\n await server.close();\n }\n return 0;\n }\n\n if (command.command === \"build\") {\n const result = await buildCapableNitroApplication({\n project,\n ...(command.output ? { outputDir: command.output } : {}),\n ...(command.preset ? { preset: command.preset } : {}),\n });\n stdout(`Built Capable application at ${result.outputDir}\\n`);\n return 0;\n }\n\n const outputDir = path.resolve(\n project.rootDir,\n command.output ?? \".output\",\n );\n const preview = await resolveCapableNitroPreviewCommand(outputDir);\n const child = spawn(preview.command, {\n cwd: preview.cwd,\n env: {\n ...process.env,\n ...(command.host ? { NITRO_HOST: command.host } : {}),\n ...(command.port !== undefined\n ? { NITRO_PORT: String(command.port) }\n : {}),\n },\n shell: true,\n stdio: \"inherit\",\n });\n return await new Promise<number>((resolve, reject) => {\n child.once(\"error\", reject);\n child.once(\"exit\", (code, signal) => {\n if (code !== null) return resolve(code);\n reject(new Error(`Preview process exited from signal ${signal ?? \"unknown\"}`));\n });\n });\n } catch (error) {\n stderr(`${error instanceof Error ? error.message : String(error)}\\n`);\n if (error instanceof UsageError) {\n stderr(\"Run `cap --help` for usage.\\n\");\n return 2;\n }\n return 1;\n }\n}\n\nexport function parseCapableCommand(argv: readonly string[]): ParsedCommand {\n const [rawCommand, ...rest] = argv;\n if (\n rawCommand === undefined ||\n rawCommand === \"help\" ||\n rawCommand === \"--help\" ||\n rawCommand === \"-h\"\n ) {\n return { command: \"help\" };\n }\n if (rawCommand === \"start\") {\n throw new UsageError(\"`cap start` was renamed to `cap preview`.\");\n }\n if (rawCommand === \"cli\") return parseCli(rest);\n if (rawCommand === \"init\") return parseInit(rest);\n if (\n rawCommand !== \"dev\" &&\n rawCommand !== \"build\" &&\n rawCommand !== \"preview\"\n ) {\n throw new UsageError(`Unknown Capable command: ${rawCommand}`);\n }\n if (rest.includes(\"--help\") || rest.includes(\"-h\")) {\n return { command: \"help\", topic: rawCommand };\n }\n\n const values = [...rest];\n let project: string | undefined;\n let host: string | undefined;\n let output: string | undefined;\n let port: number | undefined;\n let preset: string | undefined;\n\n while (values.length) {\n const token = values.shift()!;\n if (!token.startsWith(\"-\")) {\n if (project) {\n throw new UsageError(\n `Unexpected argument for cap ${rawCommand}: ${token}`,\n );\n }\n project = token;\n continue;\n }\n switch (token) {\n case \"--app\":\n if (project) {\n throw new UsageError(\"Specify a project path once.\");\n }\n project = takeValue(values, token);\n break;\n case \"--host\":\n if (rawCommand === \"build\") {\n throw unsupportedOption(rawCommand, token);\n }\n host = takeValue(values, token);\n break;\n case \"--port\":\n if (rawCommand === \"build\") {\n throw unsupportedOption(rawCommand, token);\n }\n port = parsePort(takeValue(values, token));\n break;\n case \"--output\":\n if (rawCommand === \"dev\") {\n throw unsupportedOption(rawCommand, token);\n }\n output = takeValue(values, token);\n break;\n case \"--preset\":\n if (rawCommand !== \"build\") {\n throw unsupportedOption(rawCommand, token);\n }\n preset = takeValue(values, token);\n break;\n default:\n throw unsupportedOption(rawCommand, token);\n }\n }\n\n return {\n command: rawCommand,\n ...(project ? { project } : {}),\n ...(host ? { host } : {}),\n ...(output ? { output } : {}),\n ...(port !== undefined ? { port } : {}),\n ...(preset ? { preset } : {}),\n };\n}\n\nfunction parseInit(argv: readonly string[]): InitCommand | HelpCommand {\n if (argv.includes(\"--help\") || argv.includes(\"-h\")) {\n return { command: \"help\", topic: \"init\" };\n }\n if (argv.length > 1) {\n throw new UsageError(`Unexpected argument for cap init: ${argv[1]}`);\n }\n const project = argv[0];\n if (project?.startsWith(\"-\")) {\n throw unsupportedOption(\"init\", project);\n }\n return {\n command: \"init\",\n ...(project ? { project } : {}),\n };\n}\n\nfunction parseCli(argv: readonly string[]): CliCommand | HelpCommand {\n const values = [...argv];\n let app: string | undefined;\n while (values.length) {\n const token = values[0]!;\n if (token === \"--help\" || token === \"-h\") {\n return { command: \"help\", topic: \"cli\" };\n }\n if (token === \"--\") {\n values.shift();\n break;\n }\n if (token !== \"--app\") break;\n values.shift();\n if (app) throw new UsageError(\"Specify a CLI App once.\");\n app = takeValue(values, token);\n }\n return {\n command: \"cli\",\n ...(app ? { app } : {}),\n argv: values,\n };\n}\n\nfunction takeValue(argv: string[], option: string): string {\n const value = argv.shift();\n if (!value || value.startsWith(\"-\")) {\n throw new UsageError(`${option} requires a value`);\n }\n return value;\n}\n\nfunction parsePort(value: string): number {\n const port = Number(value);\n if (!Number.isInteger(port) || port < 0 || port > 65_535) {\n throw new UsageError(`Invalid --port value: ${value}`);\n }\n return port;\n}\n\nfunction unsupportedOption(command: string, option: string): UsageError {\n return new UsageError(`Unknown option for cap ${command}: ${option}`);\n}\n\nfunction capitalize(value: string): string {\n return `${value[0]?.toUpperCase() ?? \"\"}${value.slice(1)}`;\n}\n\nfunction shellArgument(value: string): string {\n return /^[a-zA-Z0-9_./-]+$/.test(value)\n ? value\n : `'${value.replaceAll(\"'\", \"'\\\\''\")}'`;\n}\n\nasync function resolveCliApp(\n configured: string | undefined,\n options: Pick<RunCapableCommandOptions, \"cwd\" | \"env\">,\n): Promise<AnyApp> {\n if (configured && isHttpUrl(configured)) {\n return createRemoteApp(createHttpTransport({\n url: new URL(\"/_capable/\", configured),\n }));\n }\n\n const project = await resolveCapableProject({\n ...(configured ? { project: configured } : {}),\n ...(options.cwd ? { cwd: options.cwd } : {}),\n ...(options.env ? { env: options.env } : {}),\n });\n if (project.serverEntry) {\n const module = await import(pathToFileURL(project.serverEntry).href) as {\n readonly default?: unknown;\n };\n const server = module.default;\n if (!isFetchServer(server)) {\n throw new Error(\n `${project.serverEntry} must default-export a Capable server`,\n );\n }\n return createRemoteApp(createHttpTransport({\n url: \"http://capable.local/_capable/\",\n fetch: (request) => server.fetch(request),\n }));\n }\n\n const module = await import(pathToFileURL(project.entry).href) as {\n readonly default?: unknown;\n };\n const definition = module.default;\n if (isApp(definition)) return definition;\n if (\n !definition ||\n typeof definition !== \"object\" ||\n (definition as Partial<AppDefinition<any>>)[APPLICATION_SYMBOL] !== true\n ) {\n throw new Error(\n `${project.entry} must default-export a Capable App Definition`,\n );\n }\n return createApp(definition as AppDefinition<any, undefined>);\n}\n\nfunction isHttpUrl(value: string): boolean {\n try {\n const url = new URL(value);\n return url.protocol === \"http:\" || url.protocol === \"https:\";\n } catch {\n return false;\n }\n}\n\nfunction isFetchServer(value: unknown): value is {\n readonly fetch: (request: Request) => Response | Promise<Response>;\n} {\n return Boolean(\n value &&\n typeof value === \"object\" &&\n typeof (value as { readonly fetch?: unknown }).fetch === \"function\",\n );\n}\n\nasync function renderDevReady(\n server: CapableNitroDevServer,\n options: {\n readonly hasAuthoredServer: boolean;\n readonly color?: boolean;\n },\n): Promise<string> {\n const origin = server.origin;\n const manifest = await readJson<ApplicationManifest>(\n `${origin}/_capable/manifest`,\n );\n const openapi = await readJson<Record<string, unknown>>(\n `${origin}/openapi.json`,\n );\n const mcp = await probeMcp(origin);\n\n const paint = createPainter(options.color ?? false);\n const routes: Array<readonly [string, string]> = [\n [\"Local\", displayOrigin(origin)],\n ];\n if (manifest) routes.push([\"Standard\", \"/_capable\"]);\n if (openapi) {\n routes.push([\"HTTP\", \"/api\"], [\"OpenAPI\", \"/openapi.json\"]);\n }\n if (mcp) routes.push([\"MCP\", \"/mcp\"]);\n if (!manifest && !openapi && options.hasAuthoredServer) {\n routes.push([\"Server\", \"capable.server.ts\"]);\n }\n const width = routes.reduce((max, [label]) => Math.max(max, label.length), 0);\n\n const heading = manifest\n ? `${paint.bold(manifest.name)} ${paint.dim(manifest.version)}`\n : paint.bold(\"Capable\");\n const summary = manifest\n ? `${plural(\n countCapabilities(manifest.capabilities),\n \"capability\",\n \"capabilities\",\n )} ready, watching for changes`\n : \"Ready, watching for changes\";\n\n return [\n \"\",\n `${paint.accent(\"◆\")} ${heading}`,\n \"\",\n ...routes.map(([label, value]) =>\n `${paint.dim(label.padEnd(width))} ${value}`\n ),\n \"\",\n `${paint.accent(\"✓\")} ${paint.dim(summary)}`,\n \"\",\n ...(manifest\n ? [\n `${paint.dim(\"Call these capabilities from your terminal:\")}`,\n ` ${paint.bold(\"cap cli --help\")} ${paint.dim(\"every command, typed and documented\")}`,\n \"\",\n ]\n : []),\n \"\",\n ].join(\"\\n\");\n}\n\n/** Wildcard and loopback hosts are noise in a dev banner; show localhost. */\nfunction displayOrigin(origin: string): string {\n try {\n const url = new URL(origin);\n if (\n url.hostname === \"[::1]\" || url.hostname === \"::1\" ||\n url.hostname === \"127.0.0.1\" || url.hostname === \"0.0.0.0\" ||\n url.hostname === \"[::]\"\n ) {\n url.hostname = \"localhost\";\n }\n return url.toString().replace(/\\/$/, \"\");\n } catch {\n return origin;\n }\n}\n\nfunction plural(count: number, one: string, many: string): string {\n return `${count} ${count === 1 ? one : many}`;\n}\n\nfunction createPainter(enabled: boolean) {\n const wrap = (code: string) =>\n (text: string) => (enabled ? `\\u001B[${code}m${text}\\u001B[0m` : text);\n return {\n bold: wrap(\"1\"),\n dim: wrap(\"2\"),\n accent: wrap(\"36\"),\n };\n}\n\nasync function readJson<T>(url: string): Promise<T | undefined> {\n try {\n const response = await fetch(url);\n if (!response.ok) return undefined;\n return await response.json() as T;\n } catch {\n return undefined;\n }\n}\n\n/**\n * Probe the default MCP mount by issuing a JSON-RPC `initialize`. The mount\n * is stateless per request, so a successful response means an agent can\n * connect at `/mcp`.\n */\nasync function probeMcp(origin: string): Promise<boolean> {\n try {\n const response = await fetch(`${origin}/mcp`, {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n accept: \"application/json, text/event-stream\",\n },\n body: JSON.stringify({\n jsonrpc: \"2.0\",\n id: 1,\n method: \"initialize\",\n params: {\n protocolVersion: \"2025-06-18\",\n capabilities: {},\n clientInfo: { name: \"capable\", version: \"0.0.0\" },\n },\n }),\n });\n if (!response.ok) return false;\n const body = await response.json().catch(() => undefined);\n return Boolean(body && body.result);\n } catch {\n return false;\n }\n}\n\nfunction countCapabilities(nodes: readonly ManifestNode[]): number {\n return nodes.reduce(\n (count, node) =>\n count + (node.type === \"capability\"\n ? 1\n : countCapabilities(node.children)),\n 0,\n );\n}\n\nfunction waitForShutdown(): Promise<void> {\n return new Promise((resolve) => {\n const finish = () => {\n process.off(\"SIGINT\", finish);\n process.off(\"SIGTERM\", finish);\n resolve();\n };\n process.once(\"SIGINT\", finish);\n process.once(\"SIGTERM\", finish);\n });\n}\n","#!/usr/bin/env node\nimport { runCapableCommand } from \"@capable/toolchain\";\n\nprocess.exit(await runCapableCommand(process.argv.slice(2)));\n"],"mappings":";;;;;;;;;;;;AAYA,MAAM,qBAAqB;;;;;;AAO3B,SAAS,uBAA+B;CACtC,KAAK,MAAM,aAAa;EAAC;EAAO;EAAQ;CAAK,GAAG;EAC9C,MAAM,YAAY,cAChB,IAAI,IAAI,oBAAoB,aAAa,OAAO,KAAK,GAAG,CAC1D;EACA,IAAI,WAAW,SAAS,GAAG,OAAO;CACpC;CACA,MAAM,IAAI,MAAM,kDAAkD;AACpE;;;;;;AAOA,SAAS,kBACP,SACA,SACQ;CACR,MAAM,YAAY,QAAQ,QAAQ,WAAW;CAC7C,OAAO;EACL,2CACE,KAAK,UAAU,qBAAqB,CAAC,EACtC;EACD;EACA,GAAI,YAAY,CAAC,yCAAuC,IAAI,CAAC;EAC7D;EACA;EACA;EACA,GAAI,YAAY,CAAC,WAAW,IAAI,CAAC;EACjC,UAAU,QAAQ,IAAI;EACtB;EACA;CACF,CAAC,CAAC,KAAK,IAAI;AACb;AAaA,eAAsB,2BAA2B,SAId;CACjC,MAAM,QAAQ,MAAM,YAClB,yBAAyB,QAAQ,SAAS,EAAE,KAAK,KAAK,CAAC,CACzD;CACA,MAAM,SAAS,gBAAgB,KAAK;CAEpC,IAAI;EACF,MAAM,WAAW,OAAO,OAAO;GAC7B,MAAM,QAAQ,QAAQ;GACtB,UAAU,QAAQ,YAAY;GAC9B,QAAQ;EACV,CAAC;EACD,MAAM,SAAS,MAAM;EACrB,MAAM,QAAQ,KAAK;EACnB,MAAM,MAAM,KAAK;EAEjB,IAAI,CAAC,SAAS,KACZ,MAAM,IAAI,MAAM,+CAA+C;EAGjE,OAAO;GACL,QAAQ,SAAS,IAAI,QAAQ,OAAO,EAAE;GACtC,aAAa,MAAM,MAAM;EAC3B;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QAAQ,KAAK,MAAM;CACpC,QAAQ;EACN,OAAO;CACT;AACF;AAEA,SAAS,kBAAkB,OAAwC;CACjE,OAAO,MAAM,QACV,OAAO,SACN,SAAS,KAAK,SAAS,eACnB,IACA,kBAAkB,KAAK,QAAQ,IACrC,CACF;AACF;AAEA,SAAS,kBAAiC;CACxC,OAAO,IAAI,SAAS,YAAY;EAC9B,MAAM,eAAe;GACnB,QAAQ,IAAI,UAAU,MAAM;GAC5B,QAAQ,IAAI,WAAW,MAAM;GAC7B,QAAQ;EACV;EACA,QAAQ,KAAK,UAAU,MAAM;EAC7B,QAAQ,KAAK,WAAW,MAAM;CAChC,CAAC;AACH;;;AChkBA,QAAQ,KAAK,MAAM,kBAAkB,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC"}
@@ -1,3 +1,4 @@
1
+ import { t as CapableServer } from "./index-CThfifn8.mjs";
1
2
  //#region packages/nitro-host/src/runtime-support.d.ts
2
3
  type CapableNitroEntryOptions = {
3
4
  /** The default export of the project's `capable.app.*`. */
@@ -12,9 +13,7 @@ type CapableNitroEntryOptions = {
12
13
  * Build the server Nitro hosts. The generated entry in the project supplies the
13
14
  * project's own modules, so nothing here depends on how they were resolved.
14
15
  */
15
- declare function createCapableNitroEntry(options: CapableNitroEntryOptions): {
16
- readonly fetch: (request: Request) => unknown;
17
- };
16
+ declare function createCapableNitroEntry(options: CapableNitroEntryOptions): CapableServer;
18
17
  //#endregion
19
18
  export { CapableNitroEntryOptions, createCapableNitroEntry };
20
19
  //# sourceMappingURL=runtime-support.d.mts.map
@@ -39,21 +39,21 @@ function renderDevIndex(app) {
39
39
  <article class="capability">
40
40
  <div class="capability-head">
41
41
  <div class="capability-title">
42
- <h3>${escapeHtml(capability.title ?? entry.path.at(-1))}</h3>
43
- <span class="effect ${escapeHtml(capability.effect ?? "unspecified")}">${escapeHtml(capability.effect ?? "unspecified")}</span>
44
- ${badges.map((badge) => `<span class="badge">${escapeHtml(badge)}</span>`).join("")}
42
+ <h3>${escapeHtml$1(capability.title ?? entry.path.at(-1))}</h3>
43
+ <span class="effect ${escapeHtml$1(capability.effect ?? "unspecified")}">${escapeHtml$1(capability.effect ?? "unspecified")}</span>
44
+ ${badges.map((badge) => `<span class="badge">${escapeHtml$1(badge)}</span>`).join("")}
45
45
  </div>
46
- ${canOpen ? `<a class="open" href="${escapeHtml(route.path)}">Open <span aria-hidden="true">↗</span></a>` : ""}
46
+ ${canOpen ? `<a class="open" href="${escapeHtml$1(route.path)}">Open <span aria-hidden="true">↗</span></a>` : ""}
47
47
  </div>
48
- ${capability.description ? `<p class="capability-description">${escapeHtml(capability.description)}</p>` : ""}
48
+ ${capability.description ? `<p class="capability-description">${escapeHtml$1(capability.description)}</p>` : ""}
49
49
  ${command ? command_(command) : ""}
50
50
  <div class="identity">
51
- <span class="method">${escapeHtml(route?.method ?? "OP")}</span>
51
+ <span class="method">${escapeHtml$1(route?.method ?? "OP")}</span>
52
52
  ${[
53
53
  route?.path ?? entry.path.join("."),
54
54
  entry.path.join("."),
55
55
  capability.id
56
- ].filter((value, index, all) => all.indexOf(value) === index).map((value) => `<code>${escapeHtml(value)}</code>`).join(`<span class="identity-sep" aria-hidden="true">·</span>`)}
56
+ ].filter((value, index, all) => all.indexOf(value) === index).map((value) => `<code>${escapeHtml$1(value)}</code>`).join(`<span class="identity-sep" aria-hidden="true">·</span>`)}
57
57
  </div>
58
58
  </article>`;
59
59
  }).join("");
@@ -63,8 +63,8 @@ function renderDevIndex(app) {
63
63
  <meta charset="utf-8">
64
64
  <meta name="viewport" content="width=device-width, initial-scale=1">
65
65
  <meta name="color-scheme" content="light dark">
66
- <title>${escapeHtml(app.name)} · Capable</title>
67
- <style>${styles}</style>
66
+ <title>${escapeHtml$1(app.name)} · Capable</title>
67
+ <style>${styles$1}</style>
68
68
  </head>
69
69
  <body>
70
70
  <header class="topbar">
@@ -80,10 +80,10 @@ function renderDevIndex(app) {
80
80
  <main class="shell">
81
81
  <section class="hero">
82
82
  <div class="title-row">
83
- <h1>${escapeHtml(app.name)}</h1>
84
- <span class="version">v${escapeHtml(app.version)}</span>
83
+ <h1>${escapeHtml$1(app.name)}</h1>
84
+ <span class="version">v${escapeHtml$1(app.version)}</span>
85
85
  </div>
86
- <p>${escapeHtml(app.description ?? "A capability application powered by Capable.")}</p>
86
+ <p>${escapeHtml$1(app.description ?? "A capability application powered by Capable.")}</p>
87
87
  </section>
88
88
 
89
89
  <section class="cli" aria-label="Command line">
@@ -126,11 +126,11 @@ function renderDevIndex(app) {
126
126
  function command_(command, label) {
127
127
  const full = `cap cli ${command}`;
128
128
  return `<div class="command">
129
- ${label ? `<span class="command-label">${escapeHtml(label)}</span>` : ""}
129
+ ${label ? `<span class="command-label">${escapeHtml$1(label)}</span>` : ""}
130
130
  <div class="command-line">
131
131
  <span class="prompt" aria-hidden="true">$</span>
132
- <code>${escapeHtml(full)}</code>
133
- <button type="button" class="copy" data-copy="${escapeHtml(full)}" aria-label="Copy command">Copy</button>
132
+ <code>${escapeHtml$1(full)}</code>
133
+ <button type="button" class="copy" data-copy="${escapeHtml$1(full)}" aria-label="Copy command">Copy</button>
134
134
  </div>
135
135
  </div>`;
136
136
  }
@@ -149,12 +149,12 @@ function cliCommand(entry) {
149
149
  }
150
150
  function protocolLink(name, path, navigable) {
151
151
  const content = `
152
- <span>${escapeHtml(name)}</span>
153
- <code>${escapeHtml(path)}</code>
152
+ <span>${escapeHtml$1(name)}</span>
153
+ <code>${escapeHtml$1(path)}</code>
154
154
  <span class="protocol-arrow" aria-hidden="true">${navigable ? "↗" : "●"}</span>`;
155
- return navigable ? `<a class="protocol" href="${escapeHtml(path)}">${content}</a>` : `<div class="protocol protocol-static">${content}</div>`;
155
+ return navigable ? `<a class="protocol" href="${escapeHtml$1(path)}">${content}</a>` : `<div class="protocol protocol-static">${content}</div>`;
156
156
  }
157
- function escapeHtml(value) {
157
+ function escapeHtml$1(value) {
158
158
  return value.replace(/[&<>"']/g, (character) => ({
159
159
  "&": "&amp;",
160
160
  "<": "&lt;",
@@ -163,7 +163,7 @@ function escapeHtml(value) {
163
163
  "'": "&#39;"
164
164
  })[character]);
165
165
  }
166
- const styles = String.raw`
166
+ const styles$1 = String.raw`
167
167
  :root {
168
168
  color-scheme: light;
169
169
  --background: #fff;
@@ -300,6 +300,247 @@ const script = String.raw`
300
300
  });
301
301
  `;
302
302
  //#endregion
303
+ //#region packages/nitro-host/src/production-splash.ts
304
+ const DEPLOYMENT_URL_PLACEHOLDER = "{{DEPLOYMENT_URL}}";
305
+ function productionSplash() {
306
+ return {
307
+ kind: "capable.server.mount",
308
+ compile(app) {
309
+ const html = renderProductionSplash(app);
310
+ return {
311
+ name: "production-splash",
312
+ fetch(request) {
313
+ const url = new URL(request.url);
314
+ if (request.method !== "GET" || url.pathname !== "/") return;
315
+ return productionSplashResponse(html, request);
316
+ }
317
+ };
318
+ }
319
+ };
320
+ }
321
+ function withProductionSplash(server, app) {
322
+ const splash = productionSplash().compile(app, void 0);
323
+ return Object.freeze({ async fetch(request) {
324
+ return await splash.fetch(request) ?? server.fetch(request);
325
+ } });
326
+ }
327
+ function renderProductionSplash(app) {
328
+ return `<!doctype html>
329
+ <html lang="en">
330
+ <head>
331
+ <meta charset="utf-8">
332
+ <meta name="viewport" content="width=device-width, initial-scale=1">
333
+ <meta name="color-scheme" content="light dark">
334
+ <meta name="robots" content="noindex">
335
+ <meta name="referrer" content="no-referrer">
336
+ <title>${escapeHtml(app.name)} · Capable</title>
337
+ <style>${styles}</style>
338
+ </head>
339
+ <body>
340
+ <main>
341
+ <section class="card" aria-label="Deployment status">
342
+ <header>
343
+ <h1>${escapeHtml(app.name)}</h1>
344
+ <p class="status">
345
+ <span class="status-state"><span class="status-dot" aria-hidden="true"></span>Ready</span>
346
+ <span class="status-separator" aria-hidden="true">·</span>
347
+ <span>Production</span>
348
+ </p>
349
+ </header>
350
+ <div class="command" role="group" aria-label="Inspect from your terminal">
351
+ <div class="command-line">
352
+ <span class="command-prompt" aria-hidden="true">$</span>
353
+ <code>capable cli --app ${DEPLOYMENT_URL_PLACEHOLDER} --help</code>
354
+ </div>
355
+ </div>
356
+ <section class="endpoints" aria-label="Deployment endpoints">
357
+ <a href="/openapi.json">
358
+ <span class="endpoint-name">OpenAPI</span>
359
+ <code class="endpoint-path">/openapi.json</code>
360
+ </a>
361
+ <a href="/_capable/manifest">
362
+ <span class="endpoint-name">Manifest</span>
363
+ <code class="endpoint-path">/_capable/manifest</code>
364
+ </a>
365
+ <div class="endpoint">
366
+ <span class="endpoint-name">MCP</span>
367
+ <code class="endpoint-path">/mcp</code>
368
+ </div>
369
+ </section>
370
+ </section>
371
+ </main>
372
+ </body>
373
+ </html>`;
374
+ }
375
+ function productionSplashResponse(html, request) {
376
+ return new Response(html.replace(DEPLOYMENT_URL_PLACEHOLDER, () => escapeHtml(resolveDeploymentUrl(request))), { headers: {
377
+ "cache-control": "no-store",
378
+ "content-security-policy": "default-src 'none'; style-src 'unsafe-inline'; base-uri 'none'; form-action 'none'",
379
+ "content-type": "text/html; charset=utf-8",
380
+ "referrer-policy": "no-referrer",
381
+ "x-content-type-options": "nosniff",
382
+ "x-robots-tag": "noindex"
383
+ } });
384
+ }
385
+ function resolveDeploymentUrl(request) {
386
+ const url = new URL(request.url);
387
+ const host = firstForwardedValue(request.headers.get("x-forwarded-host")) ?? request.headers.get("host") ?? url.host;
388
+ return `${firstForwardedValue(request.headers.get("x-forwarded-proto")) ?? url.protocol.slice(0, -1)}://${host}`;
389
+ }
390
+ function firstForwardedValue(value) {
391
+ return value?.split(",")[0]?.trim() || void 0;
392
+ }
393
+ function escapeHtml(value) {
394
+ return value.replace(/[&<>"']/g, (character) => ({
395
+ "&": "&amp;",
396
+ "<": "&lt;",
397
+ ">": "&gt;",
398
+ "\"": "&quot;",
399
+ "'": "&#39;"
400
+ })[character]);
401
+ }
402
+ const styles = String.raw`
403
+ :root {
404
+ color-scheme: light dark;
405
+ --background: #ffffff;
406
+ --foreground: #0a0a0a;
407
+ --muted: #575757;
408
+ --faint: #737373;
409
+ --border: rgba(0, 0, 0, .1);
410
+ --surface: #fafafa;
411
+ --accent: #087a4f;
412
+ --sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
413
+ --mono: ui-monospace, "SF Mono", Menlo, Monaco, Consolas, monospace;
414
+ }
415
+ @media (prefers-color-scheme: dark) {
416
+ :root {
417
+ --background: #0a0a0a;
418
+ --foreground: #ededed;
419
+ --muted: #a1a1a1;
420
+ --faint: #8a8a8a;
421
+ --border: rgba(255, 255, 255, .12);
422
+ --surface: #131313;
423
+ --accent: #3ecf8e;
424
+ }
425
+ }
426
+ * { box-sizing: border-box; }
427
+ html, body { margin: 0; }
428
+ body {
429
+ min-height: 100vh;
430
+ min-height: 100dvh;
431
+ display: grid;
432
+ place-items: center;
433
+ padding: 2rem;
434
+ background: var(--background);
435
+ color: var(--foreground);
436
+ font: 15px/1.55 var(--sans);
437
+ font-feature-settings: "cv11", "ss01";
438
+ -webkit-font-smoothing: antialiased;
439
+ -moz-osx-font-smoothing: grayscale;
440
+ text-rendering: optimizeLegibility;
441
+ }
442
+ main {
443
+ width: min(100%, 27rem);
444
+ }
445
+ .card { display: flex; flex-direction: column; gap: 1.5rem; min-width: 0; }
446
+ header { display: flex; flex-direction: column; gap: .5rem; }
447
+ h1 {
448
+ margin: 0;
449
+ overflow-wrap: anywhere;
450
+ font-size: 1.25rem;
451
+ font-weight: 600;
452
+ letter-spacing: -.021em;
453
+ line-height: 1.3;
454
+ }
455
+ .status {
456
+ display: flex;
457
+ flex-wrap: wrap;
458
+ align-items: center;
459
+ gap: .25rem .5rem;
460
+ margin: 0;
461
+ color: var(--muted);
462
+ font-size: .875rem;
463
+ line-height: 1.5;
464
+ }
465
+ .status-state {
466
+ display: inline-flex;
467
+ align-items: center;
468
+ gap: .5rem;
469
+ color: var(--accent);
470
+ font-weight: 500;
471
+ line-height: inherit;
472
+ }
473
+ .status-dot {
474
+ width: 6px;
475
+ height: 6px;
476
+ flex: none;
477
+ border-radius: 50%;
478
+ background: currentColor;
479
+ }
480
+ .status-separator { color: var(--faint); }
481
+ .command {
482
+ display: flex;
483
+ flex-direction: column;
484
+ gap: .5rem;
485
+ padding: 1rem 1.0625rem;
486
+ border: 1px solid var(--border);
487
+ border-radius: .5rem;
488
+ background: var(--surface);
489
+ }
490
+ .command-line {
491
+ display: flex;
492
+ align-items: center;
493
+ gap: .5rem;
494
+ min-width: 0;
495
+ }
496
+ .command-prompt { color: var(--faint); user-select: none; }
497
+ code {
498
+ color: var(--foreground);
499
+ font: .8125rem/1.6 var(--mono);
500
+ font-feature-settings: "zero", "ss01";
501
+ overflow-wrap: anywhere;
502
+ }
503
+ .endpoints {
504
+ display: flex;
505
+ flex-direction: column;
506
+ border-top: 1px solid var(--border);
507
+ }
508
+ .endpoints a, .endpoint {
509
+ display: flex;
510
+ align-items: baseline;
511
+ justify-content: space-between;
512
+ gap: 1rem;
513
+ padding: .6875rem .125rem;
514
+ border-bottom: 1px solid var(--border);
515
+ color: var(--foreground);
516
+ font-size: .8125rem;
517
+ }
518
+ .endpoints a {
519
+ text-decoration: none;
520
+ }
521
+ .endpoint-name {
522
+ font-weight: 500;
523
+ }
524
+ .endpoint-path {
525
+ color: var(--faint);
526
+ font-size: .75rem;
527
+ text-align: right;
528
+ transition: color .15s ease;
529
+ }
530
+ .endpoints a:hover .endpoint-path { color: var(--foreground); }
531
+ .endpoints a:focus-visible {
532
+ border-radius: 3px;
533
+ outline: 2px solid var(--foreground);
534
+ outline-offset: 2px;
535
+ }
536
+ @media (max-width: 30rem) {
537
+ body { align-items: start; padding: 3rem 1.5rem 2rem; }
538
+ }
539
+ @media (prefers-reduced-motion: reduce) {
540
+ * { transition: none !important; }
541
+ }
542
+ `;
543
+ //#endregion
303
544
  //#region packages/nitro-host/src/runtime-support.ts
304
545
  /**
305
546
  * Build the server Nitro hosts. The generated entry in the project supplies the
@@ -307,13 +548,14 @@ const script = String.raw`
307
548
  */
308
549
  function createCapableNitroEntry(options) {
309
550
  const definition = options.definition;
310
- if (options.server) return options.dev ? withDevIndex(options.server, definition) : options.server;
551
+ if (options.server) return options.dev ? withDevIndex(options.server, definition) : withProductionSplash(options.server, definition);
311
552
  return createServer(definition, { mounts: options.dev ? [
312
553
  devIndex(),
313
554
  standard(),
314
555
  http(),
315
556
  mcp()
316
557
  ] : [
558
+ productionSplash(),
317
559
  standard(),
318
560
  http(),
319
561
  mcp()
@@ -1 +1 @@
1
- {"version":3,"file":"runtime-support.mjs","names":[],"sources":["../../nitro-host/src/dev-index.ts","../../nitro-host/src/runtime-support.ts"],"sourcesContent":["import type {\n AppDefinition,\n LocatedCapability,\n} from \"@capable/core\";\nimport { createHttpHandler } from \"@capable/fetch\";\nimport type {\n CapableServer,\n ServerMount,\n} from \"@capable/server\";\n\nexport function devIndex(): ServerMount<any> {\n return {\n kind: \"capable.server.mount\",\n compile(app) {\n const html = renderDevIndex(app);\n return {\n name: \"dev-index\",\n fetch(request) {\n const url = new URL(request.url);\n if (request.method !== \"GET\" || url.pathname !== \"/\") {\n return undefined;\n }\n return new Response(html, {\n headers: { \"content-type\": \"text/html; charset=utf-8\" },\n });\n },\n };\n },\n };\n}\n\nexport function withDevIndex(\n server: CapableServer,\n app: AppDefinition<any, any>,\n): CapableServer {\n const index = devIndex().compile(app, undefined);\n return Object.freeze({\n async fetch(request) {\n return await index.fetch(request) ?? server.fetch(request);\n },\n });\n}\n\nexport function renderDevIndex(app: AppDefinition<any, any>): string {\n const routes = createHttpHandler(app).routes;\n const routeByCapability = new Map(\n routes.map((route) => [route.capability.capability, route]),\n );\n const capabilityCount = app.locatedCapabilities.length;\n const firstCommand = app.locatedCapabilities\n .map((entry) => cliCommand(entry))\n .find((command): command is string => command !== undefined);\n const capabilities = app.locatedCapabilities.map((entry) => {\n const capability = entry.capability;\n const route = routeByCapability.get(capability);\n const command = cliCommand(entry);\n const canOpen = route?.method === \"GET\" && capability.input === undefined;\n const badges = [\n capability.toMarkdown ? \"Markdown\" : undefined,\n capability.deprecated ? \"Deprecated\" : undefined,\n ].filter(Boolean) as string[];\n\n return `\n <article class=\"capability\">\n <div class=\"capability-head\">\n <div class=\"capability-title\">\n <h3>${escapeHtml(capability.title ?? entry.path.at(-1)!)}</h3>\n <span class=\"effect ${escapeHtml(capability.effect ?? \"unspecified\")}\">${escapeHtml(capability.effect ?? \"unspecified\")}</span>\n ${badges.map((badge) => `<span class=\"badge\">${escapeHtml(badge)}</span>`).join(\"\")}\n </div>\n ${canOpen\n ? `<a class=\"open\" href=\"${escapeHtml(route.path)}\">Open <span aria-hidden=\"true\">↗</span></a>`\n : \"\"}\n </div>\n ${capability.description\n ? `<p class=\"capability-description\">${escapeHtml(capability.description)}</p>`\n : \"\"}\n ${command ? command_(command) : \"\"}\n <div class=\"identity\">\n <span class=\"method\">${escapeHtml(route?.method ?? \"OP\")}</span>\n ${[\n route?.path ?? entry.path.join(\".\"),\n entry.path.join(\".\"),\n capability.id,\n ]\n .filter((value, index, all) => all.indexOf(value) === index)\n .map((value) => `<code>${escapeHtml(value)}</code>`)\n .join(`<span class=\"identity-sep\" aria-hidden=\"true\">·</span>`)}\n </div>\n </article>`;\n }).join(\"\");\n\n return `<!doctype html>\n<html lang=\"en\">\n <head>\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n <meta name=\"color-scheme\" content=\"light dark\">\n <title>${escapeHtml(app.name)} · Capable</title>\n <style>${styles}</style>\n </head>\n <body>\n <header class=\"topbar\">\n <div class=\"shell nav\">\n <a class=\"brand\" href=\"/\" aria-label=\"Capable development home\">\n <span class=\"brand-mark\" aria-hidden=\"true\">C</span>\n <span>Capable</span>\n </a>\n <span class=\"environment\"><span aria-hidden=\"true\"></span>Development</span>\n </div>\n </header>\n\n <main class=\"shell\">\n <section class=\"hero\">\n <div class=\"title-row\">\n <h1>${escapeHtml(app.name)}</h1>\n <span class=\"version\">v${escapeHtml(app.version)}</span>\n </div>\n <p>${escapeHtml(app.description ?? \"A capability application powered by Capable.\")}</p>\n </section>\n\n <section class=\"cli\" aria-label=\"Command line\">\n <div class=\"cli-copy\">\n <h2>Run it from your terminal</h2>\n <p>Every capability below is already a command. No client, no URL, no code generation.</p>\n </div>\n <div class=\"cli-commands\">\n ${command_(\"--help\", \"List every command\")}\n ${firstCommand ? command_(firstCommand, \"Call a capability\") : \"\"}\n </div>\n </section>\n\n <section class=\"protocols\" aria-label=\"Application surfaces\">\n ${protocolLink(\"OpenAPI\", \"/openapi.json\", true)}\n ${protocolLink(\"Manifest\", \"/_capable/manifest\", true)}\n ${protocolLink(\"MCP\", \"/mcp\", false)}\n </section>\n\n <section class=\"capabilities-section\">\n <div class=\"section-heading\">\n <h2>Capabilities</h2>\n <span class=\"count\">${capabilityCount}</span>\n </div>\n <div class=\"capabilities\">\n ${capabilities || `<div class=\"empty\">No capabilities have been defined yet.</div>`}\n </div>\n </section>\n </main>\n\n <footer class=\"shell\">\n <span>Generated from the application definition</span>\n <a href=\"/_capable/manifest\">Application manifest <span aria-hidden=\"true\">→</span></a>\n </footer>\n <script>${script}</script>\n </body>\n</html>`;\n}\n\n/** A copyable `cap cli` invocation. Paths are relative, so no URL is needed. */\nfunction command_(command: string, label?: string): string {\n const full = `cap cli ${command}`;\n return `<div class=\"command\">\n ${label ? `<span class=\"command-label\">${escapeHtml(label)}</span>` : \"\"}\n <div class=\"command-line\">\n <span class=\"prompt\" aria-hidden=\"true\">$</span>\n <code>${escapeHtml(full)}</code>\n <button type=\"button\" class=\"copy\" data-copy=\"${escapeHtml(full)}\" aria-label=\"Copy command\">Copy</button>\n </div>\n </div>`;\n}\n\nfunction cliCommand(entry: LocatedCapability): string | undefined {\n const capabilityMeta = entry.capability.meta.cli as\n | false\n | {\n readonly name?: string;\n readonly command?: readonly string[];\n readonly positional?: readonly string[];\n }\n | undefined;\n if (capabilityMeta === false) return undefined;\n\n const command = [...entry.path];\n for (let index = 0; index < entry.groups.length; index++) {\n const groupMeta = entry.groups[index]?.meta.cli as\n | { readonly name?: string }\n | undefined;\n const groupPath = entry.groupPaths[index];\n if (groupMeta?.name && groupPath) {\n command[groupPath.length - 1] = groupMeta.name;\n }\n }\n if (capabilityMeta?.command) {\n command.splice(0, command.length, ...capabilityMeta.command);\n } else if (capabilityMeta?.name) {\n command[command.length - 1] = capabilityMeta.name;\n }\n return [...command, ...(capabilityMeta?.positional ?? []).map((name) =>\n `<${name}>`\n )].join(\" \");\n}\n\nfunction protocolLink(name: string, path: string, navigable: boolean): string {\n const content = `\n <span>${escapeHtml(name)}</span>\n <code>${escapeHtml(path)}</code>\n <span class=\"protocol-arrow\" aria-hidden=\"true\">${navigable ? \"↗\" : \"●\"}</span>`;\n return navigable\n ? `<a class=\"protocol\" href=\"${escapeHtml(path)}\">${content}</a>`\n : `<div class=\"protocol protocol-static\">${content}</div>`;\n}\n\nfunction escapeHtml(value: string): string {\n return value.replace(/[&<>\"']/g, (character) => ({\n \"&\": \"&amp;\",\n \"<\": \"&lt;\",\n \">\": \"&gt;\",\n '\"': \"&quot;\",\n \"'\": \"&#39;\",\n })[character]!);\n}\n\nconst styles = String.raw`\n :root {\n color-scheme: light;\n --background: #fff;\n --foreground: #0a0a0a;\n --secondary: #666;\n --muted: #8f8f8f;\n --border: #ebebeb;\n --border-strong: #dcdcdc;\n --subtle: #fafafa;\n --hover: #f5f5f5;\n --mark-bg: #0a0a0a;\n --mark-fg: #fff;\n --accent: #0070f3;\n }\n @media (prefers-color-scheme: dark) {\n :root {\n color-scheme: dark;\n --background: #000;\n --foreground: #ededed;\n --secondary: #a1a1a1;\n --muted: #737373;\n --border: #1f1f1f;\n --border-strong: #2e2e2e;\n --subtle: #0a0a0a;\n --hover: #141414;\n --mark-bg: #ededed;\n --mark-fg: #000;\n --accent: #3291ff;\n }\n }\n * { box-sizing: border-box; }\n body {\n margin: 0;\n min-height: 100vh;\n background: var(--background);\n color: var(--foreground);\n font: 14px/1.5 ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Inter, sans-serif;\n -webkit-font-smoothing: antialiased;\n }\n a { color: inherit; text-decoration: none; }\n code { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }\n h1, h2, h3, p { margin: 0; }\n .shell { width: min(880px, calc(100% - 48px)); margin: 0 auto; }\n\n .topbar { position: sticky; top: 0; z-index: 10; height: 60px; border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--background) 85%, transparent); backdrop-filter: saturate(180%) blur(12px); }\n .nav { height: 100%; display: flex; align-items: center; justify-content: space-between; }\n .brand { display: inline-flex; align-items: center; gap: 9px; font-size: 14px; font-weight: 600; letter-spacing: -.01em; }\n .brand-mark { display: grid; width: 22px; height: 22px; place-items: center; border-radius: 6px; background: var(--mark-bg); color: var(--mark-fg); font-size: 12px; font-weight: 700; }\n .environment { display: inline-flex; align-items: center; gap: 7px; color: var(--secondary); font-size: 12px; }\n .environment > span { width: 6px; height: 6px; border-radius: 999px; background: #45a557; box-shadow: 0 0 0 3px color-mix(in srgb, #45a557 16%, transparent); }\n\n .hero { padding: 72px 0 40px; }\n .title-row { display: flex; align-items: baseline; gap: 12px; }\n h1 { font-size: clamp(30px, 5vw, 44px); font-weight: 600; letter-spacing: -.045em; line-height: 1.1; }\n .version { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }\n .hero > p { max-width: 600px; margin-top: 14px; color: var(--secondary); font-size: 16px; line-height: 1.6; }\n\n .cli { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 28px; align-items: center; padding: 24px; border: 1px solid var(--border); border-radius: 12px; background: var(--subtle); }\n .cli-copy h2 { font-size: 16px; font-weight: 600; letter-spacing: -.02em; }\n .cli-copy p { margin-top: 6px; color: var(--secondary); font-size: 13px; line-height: 1.6; }\n .cli-commands { display: grid; gap: 10px; }\n\n .command { display: grid; gap: 6px; min-width: 0; }\n .command-label { color: var(--muted); font-size: 11px; letter-spacing: .02em; }\n .command-line { display: flex; align-items: center; gap: 9px; padding: 9px 9px 9px 12px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--background); }\n .prompt { color: var(--muted); user-select: none; }\n .command-line code { flex: 1; overflow-x: auto; color: var(--foreground); font-size: 12.5px; white-space: nowrap; scrollbar-width: none; }\n .command-line code::-webkit-scrollbar { display: none; }\n .copy { flex: none; padding: 4px 8px; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--muted); font: inherit; font-size: 11px; cursor: pointer; transition: color 120ms ease, background 120ms ease; }\n .copy:hover { background: var(--hover); color: var(--foreground); }\n .copy[data-copied=\"true\"] { color: #45a557; }\n\n .protocols { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 16px; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }\n .protocol { position: relative; display: flex; min-width: 0; flex-direction: column; gap: 7px; padding: 16px 18px; border-right: 1px solid var(--border); transition: background 120ms ease; }\n .protocol:last-child { border-right: 0; }\n a.protocol:hover { background: var(--hover); }\n .protocol > span:first-child { font-size: 13px; font-weight: 550; }\n .protocol code { overflow: hidden; color: var(--secondary); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }\n .protocol-arrow { position: absolute; top: 16px; right: 16px; color: var(--muted); font-size: 11px; }\n .protocol-static .protocol-arrow { color: #45a557; font-size: 8px; }\n\n .capabilities-section { padding: 64px 0 40px; }\n .section-heading { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }\n h2 { font-size: 15px; font-weight: 600; letter-spacing: -.02em; }\n .count, .badge, .effect { border: 1px solid var(--border); border-radius: 999px; color: var(--secondary); font-size: 11px; line-height: 1; }\n .count { padding: 5px 8px; font-variant-numeric: tabular-nums; }\n .capabilities { display: grid; gap: 10px; }\n .capability { display: grid; gap: 12px; padding: 18px; border: 1px solid var(--border); border-radius: 12px; transition: border-color 120ms ease; }\n .capability:hover { border-color: var(--border-strong); }\n .capability-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }\n .capability-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }\n h3 { font-size: 14px; font-weight: 600; letter-spacing: -.01em; }\n .effect, .badge { padding: 4px 7px; text-transform: capitalize; }\n .effect.read { color: #27833d; border-color: color-mix(in srgb, #27833d 28%, transparent); }\n .effect.write { color: #a16207; border-color: color-mix(in srgb, #a16207 28%, transparent); }\n .effect.destructive { color: #c03a36; border-color: color-mix(in srgb, #c03a36 28%, transparent); }\n .open { flex: none; color: var(--secondary); font-size: 12px; white-space: nowrap; }\n .open:hover { color: var(--foreground); }\n .capability-description { max-width: 640px; margin-top: -4px; color: var(--secondary); line-height: 1.55; }\n .identity { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; color: var(--muted); font-size: 11.5px; }\n .identity code { color: var(--secondary); }\n .method { color: var(--foreground); font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: 11px; font-weight: 650; }\n .identity-sep { color: var(--border-strong); }\n .empty { padding: 40px; border: 1px dashed var(--border-strong); border-radius: 12px; color: var(--secondary); text-align: center; }\n\n footer { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 28px 0 48px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; }\n footer a:hover { color: var(--foreground); }\n\n @media (max-width: 720px) {\n .shell { width: min(100% - 32px, 880px); }\n .hero { padding: 48px 0 32px; }\n .title-row { align-items: flex-start; flex-direction: column; gap: 8px; }\n .cli { grid-template-columns: 1fr; gap: 18px; }\n .protocols { grid-template-columns: 1fr; }\n .protocol { border-right: 0; border-bottom: 1px solid var(--border); }\n .protocol:last-child { border-bottom: 0; }\n .capabilities-section { padding-top: 48px; }\n .capability-head { align-items: flex-start; flex-direction: column; gap: 10px; }\n footer { align-items: flex-start; flex-direction: column; }\n }\n`;\n\nconst script = String.raw`\n document.addEventListener(\"click\", (event) => {\n const button = event.target.closest(\"button.copy\");\n if (!button) return;\n navigator.clipboard?.writeText(button.dataset.copy ?? \"\").then(() => {\n button.textContent = \"Copied\";\n button.dataset.copied = \"true\";\n setTimeout(() => {\n button.textContent = \"Copy\";\n delete button.dataset.copied;\n }, 1400);\n });\n });\n`;\n","import { mcp } from \"@capable/mcp/mount\";\nimport { createServer, http, standard } from \"@capable/server\";\nimport type { AppDefinition } from \"@capable/core\";\nimport { devIndex, withDevIndex } from \"./dev-index.ts\";\n\nexport type CapableNitroEntryOptions = {\n /** The default export of the project's `capable.app.*`. */\n readonly definition: unknown;\n /** The default export of `capable.server.*`, when the project has one. */\n readonly server?: { readonly fetch: (request: Request) => unknown } | undefined;\n readonly dev: boolean;\n};\n\n/**\n * Build the server Nitro hosts. The generated entry in the project supplies the\n * project's own modules, so nothing here depends on how they were resolved.\n */\nexport function createCapableNitroEntry(options: CapableNitroEntryOptions) {\n const definition = options.definition as AppDefinition<any, undefined>;\n if (options.server) {\n return options.dev\n ? withDevIndex(options.server as never, definition)\n : options.server;\n }\n return createServer(definition, {\n mounts: options.dev\n ? [devIndex(), standard(), http(), mcp()]\n : [standard(), http(), mcp()],\n });\n}\n"],"mappings":";;;;AAUA,SAAgB,WAA6B;CAC3C,OAAO;EACL,MAAM;EACN,QAAQ,KAAK;GACX,MAAM,OAAO,eAAe,GAAG;GAC/B,OAAO;IACL,MAAM;IACN,MAAM,SAAS;KACb,MAAM,MAAM,IAAI,IAAI,QAAQ,GAAG;KAC/B,IAAI,QAAQ,WAAW,SAAS,IAAI,aAAa,KAC/C;KAEF,OAAO,IAAI,SAAS,MAAM,EACxB,SAAS,EAAE,gBAAgB,2BAA2B,EACxD,CAAC;IACH;GACF;EACF;CACF;AACF;AAEA,SAAgB,aACd,QACA,KACe;CACf,MAAM,QAAQ,SAAS,CAAC,CAAC,QAAQ,KAAK,KAAA,CAAS;CAC/C,OAAO,OAAO,OAAO,EACnB,MAAM,MAAM,SAAS;EACnB,OAAO,MAAM,MAAM,MAAM,OAAO,KAAK,OAAO,MAAM,OAAO;CAC3D,EACF,CAAC;AACH;AAEA,SAAgB,eAAe,KAAsC;CACnE,MAAM,SAAS,kBAAkB,GAAG,CAAC,CAAC;CACtC,MAAM,oB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CAAG,KAAK,SAC7D,IAAI,KAAK,EACX,CAAC,CAAC,CAAC,KAAK,GAAG;AACb;AAEA,SAAS,aAAa,MAAc,MAAc,WAA4B;CAC5E,MAAM,UAAU;YACN,WAAW,IAAI,EAAE;YACjB,WAAW,IAAI,EAAE;sDACyB,YAAY,MAAM,IAAI;CAC1E,OAAO,YACH,6BAA6B,WAAW,IAAI,EAAE,IAAI,QAAQ,QAC1D,yCAAyC,QAAQ;AACvD;AAEA,SAAS,WAAW,OAAuB;CACzC,OAAO,MAAM,QAAQ,aAAa,eAAe;EAC/C,KAAK;EACL,KAAK;EACL,KAAK;EACL,MAAK;EACL,KAAK;CACP,EAAA,CAAG,UAAW;AAChB;AAEA,MAAM,SAAS,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2HzB,MAAM,SAAS,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;ACxUzB,SAAgB,wBAAwB,SAAmC;CACzE,MAAM,aAAa,QAAQ;CAC3B,IAAI,QAAQ,QACV,OAAO,QAAQ,MACX,aAAa,QAAQ,QAAiB,UAAU,IAChD,QAAQ;CAEd,OAAO,aAAa,YAAY,EAC9B,QAAQ,QAAQ,MACZ;EAAC,SAAS;EAAG,SAAS;EAAG,KAAK;EAAG,IAAI;CAAC,IACtC;EAAC,SAAS;EAAG,KAAK;EAAG,IAAI;CAAC,EAChC,CAAC;AACH"}
1
+ {"version":3,"file":"runtime-support.mjs","names":["escapeHtml","styles"],"sources":["../../nitro-host/src/dev-index.ts","../../nitro-host/src/production-splash.ts","../../nitro-host/src/runtime-support.ts"],"sourcesContent":["import type {\n AppDefinition,\n LocatedCapability,\n} from \"@capable/core\";\nimport { createHttpHandler } from \"@capable/fetch\";\nimport type {\n CapableServer,\n ServerMount,\n} from \"@capable/server\";\n\nexport function devIndex(): ServerMount<any> {\n return {\n kind: \"capable.server.mount\",\n compile(app) {\n const html = renderDevIndex(app);\n return {\n name: \"dev-index\",\n fetch(request) {\n const url = new URL(request.url);\n if (request.method !== \"GET\" || url.pathname !== \"/\") {\n return undefined;\n }\n return new Response(html, {\n headers: { \"content-type\": \"text/html; charset=utf-8\" },\n });\n },\n };\n },\n };\n}\n\nexport function withDevIndex(\n server: CapableServer,\n app: AppDefinition<any, any>,\n): CapableServer {\n const index = devIndex().compile(app, undefined);\n return Object.freeze({\n async fetch(request) {\n return await index.fetch(request) ?? server.fetch(request);\n },\n });\n}\n\nexport function renderDevIndex(app: AppDefinition<any, any>): string {\n const routes = createHttpHandler(app).routes;\n const routeByCapability = new Map(\n routes.map((route) => [route.capability.capability, route]),\n );\n const capabilityCount = app.locatedCapabilities.length;\n const firstCommand = app.locatedCapabilities\n .map((entry) => cliCommand(entry))\n .find((command): command is string => command !== undefined);\n const capabilities = app.locatedCapabilities.map((entry) => {\n const capability = entry.capability;\n const route = routeByCapability.get(capability);\n const command = cliCommand(entry);\n const canOpen = route?.method === \"GET\" && capability.input === undefined;\n const badges = [\n capability.toMarkdown ? \"Markdown\" : undefined,\n capability.deprecated ? \"Deprecated\" : undefined,\n ].filter(Boolean) as string[];\n\n return `\n <article class=\"capability\">\n <div class=\"capability-head\">\n <div class=\"capability-title\">\n <h3>${escapeHtml(capability.title ?? entry.path.at(-1)!)}</h3>\n <span class=\"effect ${escapeHtml(capability.effect ?? \"unspecified\")}\">${escapeHtml(capability.effect ?? \"unspecified\")}</span>\n ${badges.map((badge) => `<span class=\"badge\">${escapeHtml(badge)}</span>`).join(\"\")}\n </div>\n ${canOpen\n ? `<a class=\"open\" href=\"${escapeHtml(route.path)}\">Open <span aria-hidden=\"true\">↗</span></a>`\n : \"\"}\n </div>\n ${capability.description\n ? `<p class=\"capability-description\">${escapeHtml(capability.description)}</p>`\n : \"\"}\n ${command ? command_(command) : \"\"}\n <div class=\"identity\">\n <span class=\"method\">${escapeHtml(route?.method ?? \"OP\")}</span>\n ${[\n route?.path ?? entry.path.join(\".\"),\n entry.path.join(\".\"),\n capability.id,\n ]\n .filter((value, index, all) => all.indexOf(value) === index)\n .map((value) => `<code>${escapeHtml(value)}</code>`)\n .join(`<span class=\"identity-sep\" aria-hidden=\"true\">·</span>`)}\n </div>\n </article>`;\n }).join(\"\");\n\n return `<!doctype html>\n<html lang=\"en\">\n <head>\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n <meta name=\"color-scheme\" content=\"light dark\">\n <title>${escapeHtml(app.name)} · Capable</title>\n <style>${styles}</style>\n </head>\n <body>\n <header class=\"topbar\">\n <div class=\"shell nav\">\n <a class=\"brand\" href=\"/\" aria-label=\"Capable development home\">\n <span class=\"brand-mark\" aria-hidden=\"true\">C</span>\n <span>Capable</span>\n </a>\n <span class=\"environment\"><span aria-hidden=\"true\"></span>Development</span>\n </div>\n </header>\n\n <main class=\"shell\">\n <section class=\"hero\">\n <div class=\"title-row\">\n <h1>${escapeHtml(app.name)}</h1>\n <span class=\"version\">v${escapeHtml(app.version)}</span>\n </div>\n <p>${escapeHtml(app.description ?? \"A capability application powered by Capable.\")}</p>\n </section>\n\n <section class=\"cli\" aria-label=\"Command line\">\n <div class=\"cli-copy\">\n <h2>Run it from your terminal</h2>\n <p>Every capability below is already a command. No client, no URL, no code generation.</p>\n </div>\n <div class=\"cli-commands\">\n ${command_(\"--help\", \"List every command\")}\n ${firstCommand ? command_(firstCommand, \"Call a capability\") : \"\"}\n </div>\n </section>\n\n <section class=\"protocols\" aria-label=\"Application surfaces\">\n ${protocolLink(\"OpenAPI\", \"/openapi.json\", true)}\n ${protocolLink(\"Manifest\", \"/_capable/manifest\", true)}\n ${protocolLink(\"MCP\", \"/mcp\", false)}\n </section>\n\n <section class=\"capabilities-section\">\n <div class=\"section-heading\">\n <h2>Capabilities</h2>\n <span class=\"count\">${capabilityCount}</span>\n </div>\n <div class=\"capabilities\">\n ${capabilities || `<div class=\"empty\">No capabilities have been defined yet.</div>`}\n </div>\n </section>\n </main>\n\n <footer class=\"shell\">\n <span>Generated from the application definition</span>\n <a href=\"/_capable/manifest\">Application manifest <span aria-hidden=\"true\">→</span></a>\n </footer>\n <script>${script}</script>\n </body>\n</html>`;\n}\n\n/** A copyable `cap cli` invocation. Paths are relative, so no URL is needed. */\nfunction command_(command: string, label?: string): string {\n const full = `cap cli ${command}`;\n return `<div class=\"command\">\n ${label ? `<span class=\"command-label\">${escapeHtml(label)}</span>` : \"\"}\n <div class=\"command-line\">\n <span class=\"prompt\" aria-hidden=\"true\">$</span>\n <code>${escapeHtml(full)}</code>\n <button type=\"button\" class=\"copy\" data-copy=\"${escapeHtml(full)}\" aria-label=\"Copy command\">Copy</button>\n </div>\n </div>`;\n}\n\nfunction cliCommand(entry: LocatedCapability): string | undefined {\n const capabilityMeta = entry.capability.meta.cli as\n | false\n | {\n readonly name?: string;\n readonly command?: readonly string[];\n readonly positional?: readonly string[];\n }\n | undefined;\n if (capabilityMeta === false) return undefined;\n\n const command = [...entry.path];\n for (let index = 0; index < entry.groups.length; index++) {\n const groupMeta = entry.groups[index]?.meta.cli as\n | { readonly name?: string }\n | undefined;\n const groupPath = entry.groupPaths[index];\n if (groupMeta?.name && groupPath) {\n command[groupPath.length - 1] = groupMeta.name;\n }\n }\n if (capabilityMeta?.command) {\n command.splice(0, command.length, ...capabilityMeta.command);\n } else if (capabilityMeta?.name) {\n command[command.length - 1] = capabilityMeta.name;\n }\n return [...command, ...(capabilityMeta?.positional ?? []).map((name) =>\n `<${name}>`\n )].join(\" \");\n}\n\nfunction protocolLink(name: string, path: string, navigable: boolean): string {\n const content = `\n <span>${escapeHtml(name)}</span>\n <code>${escapeHtml(path)}</code>\n <span class=\"protocol-arrow\" aria-hidden=\"true\">${navigable ? \"↗\" : \"●\"}</span>`;\n return navigable\n ? `<a class=\"protocol\" href=\"${escapeHtml(path)}\">${content}</a>`\n : `<div class=\"protocol protocol-static\">${content}</div>`;\n}\n\nfunction escapeHtml(value: string): string {\n return value.replace(/[&<>\"']/g, (character) => ({\n \"&\": \"&amp;\",\n \"<\": \"&lt;\",\n \">\": \"&gt;\",\n '\"': \"&quot;\",\n \"'\": \"&#39;\",\n })[character]!);\n}\n\nconst styles = String.raw`\n :root {\n color-scheme: light;\n --background: #fff;\n --foreground: #0a0a0a;\n --secondary: #666;\n --muted: #8f8f8f;\n --border: #ebebeb;\n --border-strong: #dcdcdc;\n --subtle: #fafafa;\n --hover: #f5f5f5;\n --mark-bg: #0a0a0a;\n --mark-fg: #fff;\n --accent: #0070f3;\n }\n @media (prefers-color-scheme: dark) {\n :root {\n color-scheme: dark;\n --background: #000;\n --foreground: #ededed;\n --secondary: #a1a1a1;\n --muted: #737373;\n --border: #1f1f1f;\n --border-strong: #2e2e2e;\n --subtle: #0a0a0a;\n --hover: #141414;\n --mark-bg: #ededed;\n --mark-fg: #000;\n --accent: #3291ff;\n }\n }\n * { box-sizing: border-box; }\n body {\n margin: 0;\n min-height: 100vh;\n background: var(--background);\n color: var(--foreground);\n font: 14px/1.5 ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Inter, sans-serif;\n -webkit-font-smoothing: antialiased;\n }\n a { color: inherit; text-decoration: none; }\n code { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }\n h1, h2, h3, p { margin: 0; }\n .shell { width: min(880px, calc(100% - 48px)); margin: 0 auto; }\n\n .topbar { position: sticky; top: 0; z-index: 10; height: 60px; border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--background) 85%, transparent); backdrop-filter: saturate(180%) blur(12px); }\n .nav { height: 100%; display: flex; align-items: center; justify-content: space-between; }\n .brand { display: inline-flex; align-items: center; gap: 9px; font-size: 14px; font-weight: 600; letter-spacing: -.01em; }\n .brand-mark { display: grid; width: 22px; height: 22px; place-items: center; border-radius: 6px; background: var(--mark-bg); color: var(--mark-fg); font-size: 12px; font-weight: 700; }\n .environment { display: inline-flex; align-items: center; gap: 7px; color: var(--secondary); font-size: 12px; }\n .environment > span { width: 6px; height: 6px; border-radius: 999px; background: #45a557; box-shadow: 0 0 0 3px color-mix(in srgb, #45a557 16%, transparent); }\n\n .hero { padding: 72px 0 40px; }\n .title-row { display: flex; align-items: baseline; gap: 12px; }\n h1 { font-size: clamp(30px, 5vw, 44px); font-weight: 600; letter-spacing: -.045em; line-height: 1.1; }\n .version { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }\n .hero > p { max-width: 600px; margin-top: 14px; color: var(--secondary); font-size: 16px; line-height: 1.6; }\n\n .cli { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 28px; align-items: center; padding: 24px; border: 1px solid var(--border); border-radius: 12px; background: var(--subtle); }\n .cli-copy h2 { font-size: 16px; font-weight: 600; letter-spacing: -.02em; }\n .cli-copy p { margin-top: 6px; color: var(--secondary); font-size: 13px; line-height: 1.6; }\n .cli-commands { display: grid; gap: 10px; }\n\n .command { display: grid; gap: 6px; min-width: 0; }\n .command-label { color: var(--muted); font-size: 11px; letter-spacing: .02em; }\n .command-line { display: flex; align-items: center; gap: 9px; padding: 9px 9px 9px 12px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--background); }\n .prompt { color: var(--muted); user-select: none; }\n .command-line code { flex: 1; overflow-x: auto; color: var(--foreground); font-size: 12.5px; white-space: nowrap; scrollbar-width: none; }\n .command-line code::-webkit-scrollbar { display: none; }\n .copy { flex: none; padding: 4px 8px; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--muted); font: inherit; font-size: 11px; cursor: pointer; transition: color 120ms ease, background 120ms ease; }\n .copy:hover { background: var(--hover); color: var(--foreground); }\n .copy[data-copied=\"true\"] { color: #45a557; }\n\n .protocols { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 16px; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }\n .protocol { position: relative; display: flex; min-width: 0; flex-direction: column; gap: 7px; padding: 16px 18px; border-right: 1px solid var(--border); transition: background 120ms ease; }\n .protocol:last-child { border-right: 0; }\n a.protocol:hover { background: var(--hover); }\n .protocol > span:first-child { font-size: 13px; font-weight: 550; }\n .protocol code { overflow: hidden; color: var(--secondary); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }\n .protocol-arrow { position: absolute; top: 16px; right: 16px; color: var(--muted); font-size: 11px; }\n .protocol-static .protocol-arrow { color: #45a557; font-size: 8px; }\n\n .capabilities-section { padding: 64px 0 40px; }\n .section-heading { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }\n h2 { font-size: 15px; font-weight: 600; letter-spacing: -.02em; }\n .count, .badge, .effect { border: 1px solid var(--border); border-radius: 999px; color: var(--secondary); font-size: 11px; line-height: 1; }\n .count { padding: 5px 8px; font-variant-numeric: tabular-nums; }\n .capabilities { display: grid; gap: 10px; }\n .capability { display: grid; gap: 12px; padding: 18px; border: 1px solid var(--border); border-radius: 12px; transition: border-color 120ms ease; }\n .capability:hover { border-color: var(--border-strong); }\n .capability-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }\n .capability-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }\n h3 { font-size: 14px; font-weight: 600; letter-spacing: -.01em; }\n .effect, .badge { padding: 4px 7px; text-transform: capitalize; }\n .effect.read { color: #27833d; border-color: color-mix(in srgb, #27833d 28%, transparent); }\n .effect.write { color: #a16207; border-color: color-mix(in srgb, #a16207 28%, transparent); }\n .effect.destructive { color: #c03a36; border-color: color-mix(in srgb, #c03a36 28%, transparent); }\n .open { flex: none; color: var(--secondary); font-size: 12px; white-space: nowrap; }\n .open:hover { color: var(--foreground); }\n .capability-description { max-width: 640px; margin-top: -4px; color: var(--secondary); line-height: 1.55; }\n .identity { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; color: var(--muted); font-size: 11.5px; }\n .identity code { color: var(--secondary); }\n .method { color: var(--foreground); font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: 11px; font-weight: 650; }\n .identity-sep { color: var(--border-strong); }\n .empty { padding: 40px; border: 1px dashed var(--border-strong); border-radius: 12px; color: var(--secondary); text-align: center; }\n\n footer { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 28px 0 48px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; }\n footer a:hover { color: var(--foreground); }\n\n @media (max-width: 720px) {\n .shell { width: min(100% - 32px, 880px); }\n .hero { padding: 48px 0 32px; }\n .title-row { align-items: flex-start; flex-direction: column; gap: 8px; }\n .cli { grid-template-columns: 1fr; gap: 18px; }\n .protocols { grid-template-columns: 1fr; }\n .protocol { border-right: 0; border-bottom: 1px solid var(--border); }\n .protocol:last-child { border-bottom: 0; }\n .capabilities-section { padding-top: 48px; }\n .capability-head { align-items: flex-start; flex-direction: column; gap: 10px; }\n footer { align-items: flex-start; flex-direction: column; }\n }\n`;\n\nconst script = String.raw`\n document.addEventListener(\"click\", (event) => {\n const button = event.target.closest(\"button.copy\");\n if (!button) return;\n navigator.clipboard?.writeText(button.dataset.copy ?? \"\").then(() => {\n button.textContent = \"Copied\";\n button.dataset.copied = \"true\";\n setTimeout(() => {\n button.textContent = \"Copy\";\n delete button.dataset.copied;\n }, 1400);\n });\n });\n`;\n","import type { AppDefinition } from \"@capable/core\";\nimport type {\n CapableServer,\n ServerMount,\n} from \"@capable/server\";\n\nconst DEPLOYMENT_URL_PLACEHOLDER = \"{{DEPLOYMENT_URL}}\";\n\nexport function productionSplash(): ServerMount<any> {\n return {\n kind: \"capable.server.mount\",\n compile(app) {\n const html = renderProductionSplash(app);\n return {\n name: \"production-splash\",\n fetch(request) {\n const url = new URL(request.url);\n if (request.method !== \"GET\" || url.pathname !== \"/\") {\n return undefined;\n }\n return productionSplashResponse(html, request);\n },\n };\n },\n };\n}\n\nexport function withProductionSplash(\n server: CapableServer,\n app: AppDefinition<any, any>,\n): CapableServer {\n const splash = productionSplash().compile(app, undefined);\n return Object.freeze({\n async fetch(request) {\n return await splash.fetch(request) ?? server.fetch(request);\n },\n });\n}\n\nexport function renderProductionSplash(app: AppDefinition<any, any>): string {\n return `<!doctype html>\n<html lang=\"en\">\n <head>\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n <meta name=\"color-scheme\" content=\"light dark\">\n <meta name=\"robots\" content=\"noindex\">\n <meta name=\"referrer\" content=\"no-referrer\">\n <title>${escapeHtml(app.name)} · Capable</title>\n <style>${styles}</style>\n </head>\n <body>\n <main>\n <section class=\"card\" aria-label=\"Deployment status\">\n <header>\n <h1>${escapeHtml(app.name)}</h1>\n <p class=\"status\">\n <span class=\"status-state\"><span class=\"status-dot\" aria-hidden=\"true\"></span>Ready</span>\n <span class=\"status-separator\" aria-hidden=\"true\">·</span>\n <span>Production</span>\n </p>\n </header>\n <div class=\"command\" role=\"group\" aria-label=\"Inspect from your terminal\">\n <div class=\"command-line\">\n <span class=\"command-prompt\" aria-hidden=\"true\">$</span>\n <code>capable cli --app ${DEPLOYMENT_URL_PLACEHOLDER} --help</code>\n </div>\n </div>\n <section class=\"endpoints\" aria-label=\"Deployment endpoints\">\n <a href=\"/openapi.json\">\n <span class=\"endpoint-name\">OpenAPI</span>\n <code class=\"endpoint-path\">/openapi.json</code>\n </a>\n <a href=\"/_capable/manifest\">\n <span class=\"endpoint-name\">Manifest</span>\n <code class=\"endpoint-path\">/_capable/manifest</code>\n </a>\n <div class=\"endpoint\">\n <span class=\"endpoint-name\">MCP</span>\n <code class=\"endpoint-path\">/mcp</code>\n </div>\n </section>\n </section>\n </main>\n </body>\n</html>`;\n}\n\nfunction productionSplashResponse(html: string, request: Request): Response {\n return new Response(\n html.replace(\n DEPLOYMENT_URL_PLACEHOLDER,\n () => escapeHtml(resolveDeploymentUrl(request)),\n ),\n {\n headers: {\n \"cache-control\": \"no-store\",\n \"content-security-policy\":\n \"default-src 'none'; style-src 'unsafe-inline'; base-uri 'none'; form-action 'none'\",\n \"content-type\": \"text/html; charset=utf-8\",\n \"referrer-policy\": \"no-referrer\",\n \"x-content-type-options\": \"nosniff\",\n \"x-robots-tag\": \"noindex\",\n },\n },\n );\n}\n\nfunction resolveDeploymentUrl(request: Request): string {\n const url = new URL(request.url);\n const host = firstForwardedValue(request.headers.get(\"x-forwarded-host\")) ??\n request.headers.get(\"host\") ??\n url.host;\n const protocol =\n firstForwardedValue(request.headers.get(\"x-forwarded-proto\")) ??\n url.protocol.slice(0, -1);\n return `${protocol}://${host}`;\n}\n\nfunction firstForwardedValue(value: string | null): string | undefined {\n const first = value?.split(\",\")[0]?.trim();\n return first || undefined;\n}\n\nfunction escapeHtml(value: string): string {\n return value.replace(/[&<>\"']/g, (character) => ({\n \"&\": \"&amp;\",\n \"<\": \"&lt;\",\n \">\": \"&gt;\",\n '\"': \"&quot;\",\n \"'\": \"&#39;\",\n })[character]!);\n}\n\nconst styles = String.raw`\n :root {\n color-scheme: light dark;\n --background: #ffffff;\n --foreground: #0a0a0a;\n --muted: #575757;\n --faint: #737373;\n --border: rgba(0, 0, 0, .1);\n --surface: #fafafa;\n --accent: #087a4f;\n --sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif;\n --mono: ui-monospace, \"SF Mono\", Menlo, Monaco, Consolas, monospace;\n }\n @media (prefers-color-scheme: dark) {\n :root {\n --background: #0a0a0a;\n --foreground: #ededed;\n --muted: #a1a1a1;\n --faint: #8a8a8a;\n --border: rgba(255, 255, 255, .12);\n --surface: #131313;\n --accent: #3ecf8e;\n }\n }\n * { box-sizing: border-box; }\n html, body { margin: 0; }\n body {\n min-height: 100vh;\n min-height: 100dvh;\n display: grid;\n place-items: center;\n padding: 2rem;\n background: var(--background);\n color: var(--foreground);\n font: 15px/1.55 var(--sans);\n font-feature-settings: \"cv11\", \"ss01\";\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n text-rendering: optimizeLegibility;\n }\n main {\n width: min(100%, 27rem);\n }\n .card { display: flex; flex-direction: column; gap: 1.5rem; min-width: 0; }\n header { display: flex; flex-direction: column; gap: .5rem; }\n h1 {\n margin: 0;\n overflow-wrap: anywhere;\n font-size: 1.25rem;\n font-weight: 600;\n letter-spacing: -.021em;\n line-height: 1.3;\n }\n .status {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: .25rem .5rem;\n margin: 0;\n color: var(--muted);\n font-size: .875rem;\n line-height: 1.5;\n }\n .status-state {\n display: inline-flex;\n align-items: center;\n gap: .5rem;\n color: var(--accent);\n font-weight: 500;\n line-height: inherit;\n }\n .status-dot {\n width: 6px;\n height: 6px;\n flex: none;\n border-radius: 50%;\n background: currentColor;\n }\n .status-separator { color: var(--faint); }\n .command {\n display: flex;\n flex-direction: column;\n gap: .5rem;\n padding: 1rem 1.0625rem;\n border: 1px solid var(--border);\n border-radius: .5rem;\n background: var(--surface);\n }\n .command-line {\n display: flex;\n align-items: center;\n gap: .5rem;\n min-width: 0;\n }\n .command-prompt { color: var(--faint); user-select: none; }\n code {\n color: var(--foreground);\n font: .8125rem/1.6 var(--mono);\n font-feature-settings: \"zero\", \"ss01\";\n overflow-wrap: anywhere;\n }\n .endpoints {\n display: flex;\n flex-direction: column;\n border-top: 1px solid var(--border);\n }\n .endpoints a, .endpoint {\n display: flex;\n align-items: baseline;\n justify-content: space-between;\n gap: 1rem;\n padding: .6875rem .125rem;\n border-bottom: 1px solid var(--border);\n color: var(--foreground);\n font-size: .8125rem;\n }\n .endpoints a {\n text-decoration: none;\n }\n .endpoint-name {\n font-weight: 500;\n }\n .endpoint-path {\n color: var(--faint);\n font-size: .75rem;\n text-align: right;\n transition: color .15s ease;\n }\n .endpoints a:hover .endpoint-path { color: var(--foreground); }\n .endpoints a:focus-visible {\n border-radius: 3px;\n outline: 2px solid var(--foreground);\n outline-offset: 2px;\n }\n @media (max-width: 30rem) {\n body { align-items: start; padding: 3rem 1.5rem 2rem; }\n }\n @media (prefers-reduced-motion: reduce) {\n * { transition: none !important; }\n }\n`;\n","import { mcp } from \"@capable/mcp/mount\";\nimport { createServer, http, standard } from \"@capable/server\";\nimport type { AppDefinition } from \"@capable/core\";\nimport { devIndex, withDevIndex } from \"./dev-index.ts\";\nimport {\n productionSplash,\n withProductionSplash,\n} from \"./production-splash.ts\";\n\nexport type CapableNitroEntryOptions = {\n /** The default export of the project's `capable.app.*`. */\n readonly definition: unknown;\n /** The default export of `capable.server.*`, when the project has one. */\n readonly server?: { readonly fetch: (request: Request) => unknown } | undefined;\n readonly dev: boolean;\n};\n\n/**\n * Build the server Nitro hosts. The generated entry in the project supplies the\n * project's own modules, so nothing here depends on how they were resolved.\n */\nexport function createCapableNitroEntry(options: CapableNitroEntryOptions) {\n const definition = options.definition as AppDefinition<any, undefined>;\n if (options.server) {\n return options.dev\n ? withDevIndex(options.server as never, definition)\n : withProductionSplash(options.server as never, definition);\n }\n return createServer(definition, {\n mounts: options.dev\n ? [devIndex(), standard(), http(), mcp()]\n : [productionSplash(), standard(), http(), mcp()],\n });\n}\n"],"mappings":";;;;AAUA,SAAgB,WAA6B;CAC3C,OAAO;EACL,MAAM;EACN,QAAQ,KAAK;GACX,MAAM,OAAO,eAAe,GAAG;GAC/B,OAAO;IACL,MAAM;IACN,MAAM,SAAS;KACb,MAAM,MAAM,IAAI,IAAI,QAAQ,GAAG;KAC/B,IAAI,QAAQ,WAAW,SAAS,IAAI,aAAa,KAC/C;KAEF,OAAO,IAAI,SAAS,MAAM,EACxB,SAAS,EAAE,gBAAgB,2BAA2B,EACxD,CAAC;IACH;GACF;EACF;CACF;AACF;AAEA,SAAgB,aACd,QACA,KACe;CACf,MAAM,QAAQ,SAAS,CAAC,CAAC,QAAQ,KAAK,KAAA,CAAS;CAC/C,OAAO,OAAO,OAAO,EACnB,MAAM,MAAM,SAAS;EACnB,OAAO,MAAM,MAAM,MAAM,OAAO,KAAK,OAAO,MAAM,OAAO;CAC3D,EACF,CAAC;AACH;AAEA,SAAgB,eAAe,KAAsC;CACnE,MAAM,SAAS,kBAAkB,GAAG,CAAC,CA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