@bridgent/cli 0.1.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,9 +1,10 @@
1
- # bridgent
1
+ # @bridgent/cli
2
2
 
3
- > Bridgent CLI — `bridgent dev <file>` to launch an MCP server from any TS/JS file.
3
+ > Bridgent CLI — create, run, and inspect MCP server files.
4
4
 
5
5
  ```bash
6
- pnpm add -D bridgent @bridgent/core zod
6
+ pnpm add -D @bridgent/cli @bridgent/core zod
7
+ bridgent init ./server.ts
7
8
  bridgent dev ./server.ts
8
9
  ```
9
10
 
package/dist/cli.mjs CHANGED
@@ -2,9 +2,10 @@
2
2
  import { defineCommand, runMain } from "citty";
3
3
  import { spawn } from "node:child_process";
4
4
  import { existsSync } from "node:fs";
5
- import { resolve } from "node:path";
5
+ import { dirname, relative, resolve } from "node:path";
6
6
  import process from "node:process";
7
7
  import { consola } from "consola";
8
+ import { access, mkdir, writeFile } from "node:fs/promises";
8
9
  //#region src/commands/dev.ts
9
10
  const dev = defineCommand({
10
11
  meta: {
@@ -43,6 +44,111 @@ const dev = defineCommand({
43
44
  }
44
45
  });
45
46
  //#endregion
47
+ //#region src/commands/init.ts
48
+ var TargetExistsError = class extends Error {
49
+ filePath;
50
+ constructor(filePath) {
51
+ super(`Target file already exists: ${filePath}`);
52
+ this.filePath = filePath;
53
+ this.name = "TargetExistsError";
54
+ }
55
+ };
56
+ const init = defineCommand({
57
+ meta: {
58
+ name: "init",
59
+ description: "Create a starter Bridgent MCP server file."
60
+ },
61
+ args: {
62
+ file: {
63
+ type: "positional",
64
+ description: "Path to write the starter server file.",
65
+ required: false
66
+ },
67
+ force: {
68
+ type: "boolean",
69
+ description: "Overwrite the target file if it already exists.",
70
+ alias: "f"
71
+ }
72
+ },
73
+ async run({ args }) {
74
+ try {
75
+ const result = await writeStarterServer({
76
+ cwd: process.cwd(),
77
+ file: typeof args.file === "string" ? args.file : void 0,
78
+ force: Boolean(args.force)
79
+ });
80
+ const action = result.overwritten ? "Updated" : "Created";
81
+ consola.success(`${action} ${result.displayPath}`);
82
+ consola.info("Install packages if needed: pnpm add @bridgent/core zod && pnpm add -D @bridgent/cli");
83
+ consola.info(`Run locally: bridgent dev ${result.displayPath}`);
84
+ consola.info(`Inspect tools: bridgent inspect ${result.displayPath}`);
85
+ } catch (error) {
86
+ if (error instanceof TargetExistsError) {
87
+ consola.error(`File already exists: ${toDisplayPath(process.cwd(), error.filePath)}`);
88
+ consola.info("Use --force to overwrite it.");
89
+ process.exit(1);
90
+ }
91
+ throw error;
92
+ }
93
+ }
94
+ });
95
+ async function writeStarterServer(options) {
96
+ const filePath = resolve(options.cwd, options.file || "server.ts");
97
+ const existedBeforeWrite = options.force ? await pathExists(filePath) : false;
98
+ await mkdir(dirname(filePath), { recursive: true });
99
+ const flag = options.force ? "w" : "wx";
100
+ try {
101
+ await writeFile(filePath, generateStarterServer(), {
102
+ encoding: "utf8",
103
+ flag
104
+ });
105
+ } catch (error) {
106
+ if (isNodeError(error) && error.code === "EEXIST") throw new TargetExistsError(filePath);
107
+ throw error;
108
+ }
109
+ return {
110
+ filePath,
111
+ displayPath: toDisplayPath(options.cwd, filePath),
112
+ overwritten: existedBeforeWrite
113
+ };
114
+ }
115
+ function generateStarterServer() {
116
+ return `import { createStdioServer, defineTool } from '@bridgent/core'
117
+ import { z } from 'zod'
118
+
119
+ const echo = defineTool({
120
+ name: 'echo',
121
+ description: 'Echo a message back',
122
+ inputSchema: z.object({
123
+ message: z.string().describe('Message to echo'),
124
+ }),
125
+ run: ({ message }) => ({ message }),
126
+ })
127
+
128
+ // eslint-disable-next-line antfu/no-top-level-await
129
+ await createStdioServer({
130
+ name: 'bridgent-starter',
131
+ version: '0.1.0',
132
+ tools: [echo],
133
+ })
134
+ `;
135
+ }
136
+ function toDisplayPath(cwd, filePath) {
137
+ const displayPath = relative(cwd, filePath);
138
+ return displayPath && !displayPath.startsWith("..") ? displayPath : filePath;
139
+ }
140
+ async function pathExists(filePath) {
141
+ try {
142
+ await access(filePath);
143
+ return true;
144
+ } catch {
145
+ return false;
146
+ }
147
+ }
148
+ function isNodeError(error) {
149
+ return error instanceof Error && "code" in error;
150
+ }
151
+ //#endregion
46
152
  //#region src/commands/inspect.ts
47
153
  /**
48
154
  * `bridgent inspect <file>` is a thin wrapper around the official MCP Inspector.
@@ -119,6 +225,7 @@ runMain(defineCommand({
119
225
  description: "Expose your existing APIs, databases, and code as MCP servers"
120
226
  },
121
227
  subCommands: {
228
+ init,
122
229
  dev,
123
230
  serve: defineCommand({
124
231
  meta: {
package/dist/cli.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.mjs","names":[],"sources":["../src/commands/dev.ts","../src/commands/inspect.ts","../src/commands/serve.ts","../src/cli.ts"],"sourcesContent":["import { spawn } from 'node:child_process'\nimport { existsSync } from 'node:fs'\nimport { resolve } from 'node:path'\nimport process from 'node:process'\nimport { defineCommand } from 'citty'\nimport { consola } from 'consola'\n\nexport const dev = defineCommand({\n meta: {\n name: 'dev',\n description: 'Start an MCP server from a TypeScript or JavaScript file',\n },\n args: {\n file: {\n type: 'positional',\n description: 'Path to the server file (TS or JS)',\n required: true,\n },\n },\n async run({ args }): Promise<void> {\n const file = resolve(process.cwd(), args.file)\n if (!existsSync(file)) {\n consola.error(`File not found: ${file}`)\n process.exit(1)\n }\n\n const isTs = file.endsWith('.ts') || file.endsWith('.tsx') || file.endsWith('.mts')\n const nodeArgs = isTs\n ? ['--experimental-strip-types', '--no-warnings=ExperimentalWarning', file]\n : [file]\n\n consola.info(`Starting MCP server: ${file}`)\n\n const child = spawn(process.execPath, nodeArgs, {\n stdio: 'inherit',\n env: process.env,\n })\n\n child.on('exit', (code) => {\n process.exit(code ?? 0)\n })\n\n const forward = (signal: NodeJS.Signals): void => {\n if (!child.killed)\n child.kill(signal)\n }\n process.on('SIGINT', () => forward('SIGINT'))\n process.on('SIGTERM', () => forward('SIGTERM'))\n },\n})\n","import { spawn } from 'node:child_process'\nimport { existsSync } from 'node:fs'\nimport { resolve } from 'node:path'\nimport process from 'node:process'\nimport { defineCommand } from 'citty'\nimport { consola } from 'consola'\n\n/**\n * `bridgent inspect <file>` is a thin wrapper around the official MCP Inspector.\n *\n * It spawns Inspector via `pnpm dlx` (falling back to `npx -y` if unavailable)\n * and connects it to the user's server file using stdio. The Inspector opens\n * a browser window letting you list tools, send `tools/call`, and see traces.\n *\n * This is intentionally a thin wrapper — Bridgent's own inspector UI ships\n * later as a differentiated experience.\n */\nexport const inspect = defineCommand({\n meta: {\n name: 'inspect',\n description: 'Open MCP Inspector and connect it to your server (stdio).',\n },\n args: {\n file: {\n type: 'positional',\n description: 'Path to the server file (TS or JS).',\n required: true,\n },\n },\n async run({ args }): Promise<void> {\n const file = resolve(process.cwd(), args.file)\n if (!existsSync(file)) {\n consola.error(`File not found: ${file}`)\n process.exit(1)\n }\n\n const isTs = file.endsWith('.ts') || file.endsWith('.tsx') || file.endsWith('.mts')\n const targetArgs = isTs\n ? [process.execPath, '--experimental-strip-types', '--no-warnings=ExperimentalWarning', file]\n : [process.execPath, file]\n\n consola.info('Starting MCP Inspector …')\n\n // Prefer pnpm dlx (this monorepo uses pnpm); fall back to npx for users\n // running outside a pnpm shell.\n const launcher = pickLauncher()\n if (!launcher) {\n consola.error('Neither `pnpm` nor `npx` is on PATH. Install one of them and try again.')\n process.exit(1)\n }\n\n const child = spawn(launcher.cmd, [...launcher.args, '@modelcontextprotocol/inspector', ...targetArgs], {\n stdio: 'inherit',\n env: process.env,\n })\n\n child.on('exit', (code) => {\n process.exit(code ?? 0)\n })\n\n const forward = (signal: NodeJS.Signals): void => {\n if (!child.killed)\n child.kill(signal)\n }\n process.on('SIGINT', () => forward('SIGINT'))\n process.on('SIGTERM', () => forward('SIGTERM'))\n },\n})\n\nfunction pickLauncher(): { cmd: string, args: string[] } | undefined {\n // We can't synchronously check $PATH cheaply across platforms; pick by\n // env hint, then fall back at spawn time. spawn'll throw ENOENT if missing.\n if (process.env.npm_execpath?.includes('pnpm') || process.env.PNPM_HOME)\n return { cmd: 'pnpm', args: ['dlx'] }\n return { cmd: 'npx', args: ['-y'] }\n}\n","import { spawn } from 'node:child_process'\nimport { existsSync } from 'node:fs'\nimport { resolve } from 'node:path'\nimport process from 'node:process'\nimport { defineCommand } from 'citty'\nimport { consola } from 'consola'\n\nexport const serve = defineCommand({\n meta: {\n name: 'serve',\n description: 'Run a Bridgent server file (typically using createHttpServer).',\n },\n args: {\n file: {\n type: 'positional',\n description: 'Path to the server file (TS or JS).',\n required: true,\n },\n },\n async run({ args }): Promise<void> {\n const file = resolve(process.cwd(), args.file)\n if (!existsSync(file)) {\n consola.error(`File not found: ${file}`)\n process.exit(1)\n }\n\n const isTs = file.endsWith('.ts') || file.endsWith('.tsx') || file.endsWith('.mts')\n const nodeArgs = isTs\n ? ['--experimental-strip-types', '--no-warnings=ExperimentalWarning', file]\n : [file]\n\n consola.info(`Starting server: ${file}`)\n\n const child = spawn(process.execPath, nodeArgs, {\n stdio: 'inherit',\n env: process.env,\n })\n\n child.on('exit', (code) => {\n process.exit(code ?? 0)\n })\n\n const forward = (signal: NodeJS.Signals): void => {\n if (!child.killed)\n child.kill(signal)\n }\n process.on('SIGINT', () => forward('SIGINT'))\n process.on('SIGTERM', () => forward('SIGTERM'))\n },\n})\n","import { defineCommand, runMain } from 'citty'\nimport { dev } from './commands/dev'\nimport { inspect } from './commands/inspect'\nimport { serve } from './commands/serve'\n\nconst main = defineCommand({\n meta: {\n name: 'bridgent',\n version: '0.0.1',\n description: 'Expose your existing APIs, databases, and code as MCP servers',\n },\n subCommands: {\n dev,\n serve,\n inspect,\n },\n})\n\nrunMain(main)\n"],"mappings":";;;;;;;;AAOA,MAAa,MAAM,cAAc;CAC/B,MAAM;EACJ,MAAM;EACN,aAAa;CACf;CACA,MAAM,EACJ,MAAM;EACJ,MAAM;EACN,aAAa;EACb,UAAU;CACZ,EACF;CACA,MAAM,IAAI,EA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BAAoB,MAAM;IAEvC,MAAM,QAAQ,MAAM,QAAQ,UAAU,UAAU;KAC9C,OAAO;KACP,KAAK,QAAQ;IACf,CAAC;IAED,MAAM,GAAG,SAAS,SAAS;KACzB,QAAQ,KAAK,QAAQ,CAAC;IACxB,CAAC;IAED,MAAM,WAAW,WAAiC;KAChD,IAAI,CAAC,MAAM,QACT,MAAM,KAAK,MAAM;IACrB;IACA,QAAQ,GAAG,gBAAgB,QAAQ,QAAQ,CAAC;IAC5C,QAAQ,GAAG,iBAAiB,QAAQ,SAAS,CAAC;GAChD;EACF,CCpCI;EACA;CACF;AACF,CAEW,CAAC"}
1
+ {"version":3,"file":"cli.mjs","names":[],"sources":["../src/commands/dev.ts","../src/commands/init.ts","../src/commands/inspect.ts","../src/commands/serve.ts","../src/cli.ts"],"sourcesContent":["import { spawn } from 'node:child_process'\nimport { existsSync } from 'node:fs'\nimport { resolve } from 'node:path'\nimport process from 'node:process'\nimport { defineCommand } from 'citty'\nimport { consola } from 'consola'\n\nexport const dev = defineCommand({\n meta: {\n name: 'dev',\n description: 'Start an MCP server from a TypeScript or JavaScript file',\n },\n args: {\n file: {\n type: 'positional',\n description: 'Path to the server file (TS or JS)',\n required: true,\n },\n },\n async run({ args }): Promise<void> {\n const file = resolve(process.cwd(), args.file)\n if (!existsSync(file)) {\n consola.error(`File not found: ${file}`)\n process.exit(1)\n }\n\n const isTs = file.endsWith('.ts') || file.endsWith('.tsx') || file.endsWith('.mts')\n const nodeArgs = isTs\n ? ['--experimental-strip-types', '--no-warnings=ExperimentalWarning', file]\n : [file]\n\n consola.info(`Starting MCP server: ${file}`)\n\n const child = spawn(process.execPath, nodeArgs, {\n stdio: 'inherit',\n env: process.env,\n })\n\n child.on('exit', (code) => {\n process.exit(code ?? 0)\n })\n\n const forward = (signal: NodeJS.Signals): void => {\n if (!child.killed)\n child.kill(signal)\n }\n process.on('SIGINT', () => forward('SIGINT'))\n process.on('SIGTERM', () => forward('SIGTERM'))\n },\n})\n","import { access, mkdir, writeFile } from 'node:fs/promises'\nimport { dirname, relative, resolve } from 'node:path'\nimport process from 'node:process'\nimport { defineCommand } from 'citty'\nimport { consola } from 'consola'\n\nexport interface WriteStarterServerOptions {\n cwd: string\n file?: string\n force?: boolean\n}\n\nexport interface WriteStarterServerResult {\n filePath: string\n displayPath: string\n overwritten: boolean\n}\n\nexport class TargetExistsError extends Error {\n constructor(readonly filePath: string) {\n super(`Target file already exists: ${filePath}`)\n this.name = 'TargetExistsError'\n }\n}\n\nexport const init = defineCommand({\n meta: {\n name: 'init',\n description: 'Create a starter Bridgent MCP server file.',\n },\n args: {\n file: {\n type: 'positional',\n description: 'Path to write the starter server file.',\n required: false,\n },\n force: {\n type: 'boolean',\n description: 'Overwrite the target file if it already exists.',\n alias: 'f',\n },\n },\n async run({ args }): Promise<void> {\n try {\n const result = await writeStarterServer({\n cwd: process.cwd(),\n file: typeof args.file === 'string' ? args.file : undefined,\n force: Boolean(args.force),\n })\n\n const action = result.overwritten ? 'Updated' : 'Created'\n consola.success(`${action} ${result.displayPath}`)\n consola.info('Install packages if needed: pnpm add @bridgent/core zod && pnpm add -D @bridgent/cli')\n consola.info(`Run locally: bridgent dev ${result.displayPath}`)\n consola.info(`Inspect tools: bridgent inspect ${result.displayPath}`)\n }\n catch (error) {\n if (error instanceof TargetExistsError) {\n consola.error(`File already exists: ${toDisplayPath(process.cwd(), error.filePath)}`)\n consola.info('Use --force to overwrite it.')\n process.exit(1)\n }\n throw error\n }\n },\n})\n\nexport async function writeStarterServer(options: WriteStarterServerOptions): Promise<WriteStarterServerResult> {\n const filePath = resolve(options.cwd, options.file || 'server.ts')\n const existedBeforeWrite = options.force ? await pathExists(filePath) : false\n\n await mkdir(dirname(filePath), { recursive: true })\n const flag = options.force ? 'w' : 'wx'\n try {\n await writeFile(filePath, generateStarterServer(), { encoding: 'utf8', flag })\n }\n catch (error) {\n if (isNodeError(error) && error.code === 'EEXIST')\n throw new TargetExistsError(filePath)\n throw error\n }\n\n return {\n filePath,\n displayPath: toDisplayPath(options.cwd, filePath),\n overwritten: existedBeforeWrite,\n }\n}\n\nexport function generateStarterServer(): string {\n return `import { createStdioServer, defineTool } from '@bridgent/core'\nimport { z } from 'zod'\n\nconst echo = defineTool({\n name: 'echo',\n description: 'Echo a message back',\n inputSchema: z.object({\n message: z.string().describe('Message to echo'),\n }),\n run: ({ message }) => ({ message }),\n})\n\n// eslint-disable-next-line antfu/no-top-level-await\nawait createStdioServer({\n name: 'bridgent-starter',\n version: '0.1.0',\n tools: [echo],\n})\n`\n}\n\nfunction toDisplayPath(cwd: string, filePath: string): string {\n const displayPath = relative(cwd, filePath)\n return displayPath && !displayPath.startsWith('..') ? displayPath : filePath\n}\n\nasync function pathExists(filePath: string): Promise<boolean> {\n try {\n await access(filePath)\n return true\n }\n catch {\n return false\n }\n}\n\nfunction isNodeError(error: unknown): error is NodeJS.ErrnoException {\n return error instanceof Error && 'code' in error\n}\n","import { spawn } from 'node:child_process'\nimport { existsSync } from 'node:fs'\nimport { resolve } from 'node:path'\nimport process from 'node:process'\nimport { defineCommand } from 'citty'\nimport { consola } from 'consola'\n\n/**\n * `bridgent inspect <file>` is a thin wrapper around the official MCP Inspector.\n *\n * It spawns Inspector via `pnpm dlx` (falling back to `npx -y` if unavailable)\n * and connects it to the user's server file using stdio. The Inspector opens\n * a browser window letting you list tools, send `tools/call`, and see traces.\n *\n * This is intentionally a thin wrapper — Bridgent's own inspector UI ships\n * later as a differentiated experience.\n */\nexport const inspect = defineCommand({\n meta: {\n name: 'inspect',\n description: 'Open MCP Inspector and connect it to your server (stdio).',\n },\n args: {\n file: {\n type: 'positional',\n description: 'Path to the server file (TS or JS).',\n required: true,\n },\n },\n async run({ args }): Promise<void> {\n const file = resolve(process.cwd(), args.file)\n if (!existsSync(file)) {\n consola.error(`File not found: ${file}`)\n process.exit(1)\n }\n\n const isTs = file.endsWith('.ts') || file.endsWith('.tsx') || file.endsWith('.mts')\n const targetArgs = isTs\n ? [process.execPath, '--experimental-strip-types', '--no-warnings=ExperimentalWarning', file]\n : [process.execPath, file]\n\n consola.info('Starting MCP Inspector …')\n\n // Prefer pnpm dlx (this monorepo uses pnpm); fall back to npx for users\n // running outside a pnpm shell.\n const launcher = pickLauncher()\n if (!launcher) {\n consola.error('Neither `pnpm` nor `npx` is on PATH. Install one of them and try again.')\n process.exit(1)\n }\n\n const child = spawn(launcher.cmd, [...launcher.args, '@modelcontextprotocol/inspector', ...targetArgs], {\n stdio: 'inherit',\n env: process.env,\n })\n\n child.on('exit', (code) => {\n process.exit(code ?? 0)\n })\n\n const forward = (signal: NodeJS.Signals): void => {\n if (!child.killed)\n child.kill(signal)\n }\n process.on('SIGINT', () => forward('SIGINT'))\n process.on('SIGTERM', () => forward('SIGTERM'))\n },\n})\n\nfunction pickLauncher(): { cmd: string, args: string[] } | undefined {\n // We can't synchronously check $PATH cheaply across platforms; pick by\n // env hint, then fall back at spawn time. spawn'll throw ENOENT if missing.\n if (process.env.npm_execpath?.includes('pnpm') || process.env.PNPM_HOME)\n return { cmd: 'pnpm', args: ['dlx'] }\n return { cmd: 'npx', args: ['-y'] }\n}\n","import { spawn } from 'node:child_process'\nimport { existsSync } from 'node:fs'\nimport { resolve } from 'node:path'\nimport process from 'node:process'\nimport { defineCommand } from 'citty'\nimport { consola } from 'consola'\n\nexport const serve = defineCommand({\n meta: {\n name: 'serve',\n description: 'Run a Bridgent server file (typically using createHttpServer).',\n },\n args: {\n file: {\n type: 'positional',\n description: 'Path to the server file (TS or JS).',\n required: true,\n },\n },\n async run({ args }): Promise<void> {\n const file = resolve(process.cwd(), args.file)\n if (!existsSync(file)) {\n consola.error(`File not found: ${file}`)\n process.exit(1)\n }\n\n const isTs = file.endsWith('.ts') || file.endsWith('.tsx') || file.endsWith('.mts')\n const nodeArgs = isTs\n ? ['--experimental-strip-types', '--no-warnings=ExperimentalWarning', file]\n : [file]\n\n consola.info(`Starting server: ${file}`)\n\n const child = spawn(process.execPath, nodeArgs, {\n stdio: 'inherit',\n env: process.env,\n })\n\n child.on('exit', (code) => {\n process.exit(code ?? 0)\n })\n\n const forward = (signal: NodeJS.Signals): void => {\n if (!child.killed)\n child.kill(signal)\n }\n process.on('SIGINT', () => forward('SIGINT'))\n process.on('SIGTERM', () => forward('SIGTERM'))\n },\n})\n","import { defineCommand, runMain } from 'citty'\nimport { dev } from './commands/dev'\nimport { init } from './commands/init'\nimport { inspect } from './commands/inspect'\nimport { serve } from './commands/serve'\n\nconst main = defineCommand({\n meta: {\n name: 'bridgent',\n version: '0.0.1',\n description: 'Expose your existing APIs, databases, and code as MCP servers',\n },\n subCommands: {\n init,\n dev,\n serve,\n inspect,\n },\n})\n\nrunMain(main)\n"],"mappings":";;;;;;;;;AAOA,MAAa,MAAM,cAAc;CAC/B,MAAM;EACJ,MAAM;EACN,aAAa;CACf;CACA,MAAM,EACJ,MAAM;EACJ,MAAM;EACN,aAAa;EACb,UAAU;CACZ,EACF;CACA,MAAM,IAAI,EAAE,QAAuB;EACjC,MAAM,OAAO,QAAQ,QAAQ,IAAI,GAAG,KAAK,IAAI;EAC7C,IAAI,CAAC,WAAW,IAAI,GAAG;GACrB,QAAQ,MAAM,mBAAmB,MAAM;GACvC,QAAQ,KAAK,CAAC;EAChB;EAGA,MAAM,WADO,KAAK,SAAS,KAAK,KAAK,KAAK,SAAS,MAAM,KAAK,KAAK,SAAS,MAAM,IAE9E;GAAC;GAA8B;GAAqC;EAAI,IACxE,CAAC,IAAI;EAET,QAAQ,KAAK,wBAAwB,MAAM;EAE3C,MAAM,QAAQ,MAAM,QAAQ,UAAU,UAAU;GAC9C,OAAO;GACP,KAAK,QAAQ;EACf,CAAC;EAED,MAAM,GAAG,SAAS,SAAS;GACzB,QAAQ,KAAK,QAAQ,CAAC;EACxB,CAAC;EAED,MAAM,WAAW,WAAiC;GAChD,IAAI,CAAC,MAAM,QACT,MAAM,KAAK,MAAM;EACrB;EACA,QAAQ,GAAG,gBAAgB,QAAQ,QAAQ,CAAC;EAC5C,QAAQ,GA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AAO;KACP,KAAK,QAAQ;IACf,CAAC;IAED,MAAM,GAAG,SAAS,SAAS;KACzB,QAAQ,KAAK,QAAQ,CAAC;IACxB,CAAC;IAED,MAAM,WAAW,WAAiC;KAChD,IAAI,CAAC,MAAM,QACT,MAAM,KAAK,MAAM;IACrB;IACA,QAAQ,GAAG,gBAAgB,QAAQ,QAAQ,CAAC;IAC5C,QAAQ,GAAG,iBAAiB,QAAQ,SAAS,CAAC;GAChD;EACF,CClCI;EACA;CACF;AACF,CAEW,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bridgent/cli",
3
3
  "type": "module",
4
- "version": "0.1.0",
4
+ "version": "0.2.1",
5
5
  "description": "Bridgent AI CLI — expose any API, database, or code as a production-ready MCP server in one line.",
6
6
  "license": "MIT",
7
7
  "homepage": "https://bridgent.ai",
@@ -38,7 +38,7 @@
38
38
  "dependencies": {
39
39
  "citty": "^0.2.2",
40
40
  "consola": "^3.4.2",
41
- "@bridgent/core": "0.1.0"
41
+ "@bridgent/core": "0.2.1"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@types/node": "^25.9.1",