diff --git a/packages/cli/src/commands/new/templatehook.ts b/packages/cli/src/commands/new/templatehook.ts new file mode 100644 index 000000000..777f72032 --- /dev/null +++ b/packages/cli/src/commands/new/templatehook.ts @@ -0,0 +1,27 @@ +import { z } from 'zod'; + +import { ProjectBuilder } from '../../project'; + +type TemplateHook = (builder: ProjectBuilder) => Promise; + +export const templateHooks: Record = { + 'mcpagent': async (builder) => { + const readline = await import('node:readline/promises'); + const rl = readline.createInterface({ input: process.stdin, output: process.stdout }); + + const serverName = await rl.question('Enter MCP server name: '); + const mcpUrl = await rl.question('Enter MCP server URL: '); + rl.close(); + + // Validate the MCP URL + const result = z.string().url().safeParse(mcpUrl); + if (!result.success) { + console.error('❌ Invalid MCP URL.'); + process.exit(1); + } + + // Add env variables + builder.addEnv('SERVER_NAME', serverName); + builder.addEnv('MCP_URL', mcpUrl); + } +}; diff --git a/packages/cli/src/commands/new/typescript.ts b/packages/cli/src/commands/new/typescript.ts index f9955a048..2fd823645 100644 --- a/packages/cli/src/commands/new/typescript.ts +++ b/packages/cli/src/commands/new/typescript.ts @@ -12,6 +12,8 @@ import { IContext } from '../../context'; import { Project } from '../../project'; import { Settings } from '../../settings'; +import { templateHooks } from './templatehook'; + const ArgsSchema = z.object({ name: z.string(), template: z.string(), @@ -65,8 +67,8 @@ export function Typescript(_: IContext): CommandModule<{}, z.infer fs.existsSync(path.join(atkPath, type, 'typescript'))) - .flat() + .filter((type) => fs.existsSync(path.join(atkPath, type, 'typescript'))) + .flat() }) .option('client-id', { type: 'string', @@ -133,6 +135,11 @@ export function Typescript(_: IContext): CommandModule<{}, z.infer { + await send({ type: 'typing' }); + const res = await prompt.send(activity.text); + console.log(res); + + await send({ type: 'message', text: res.content }); +}); + +(async () => { + await app.start(); +})(); \ No newline at end of file diff --git a/packages/cli/templates/typescript/mcpagent/tsconfig.json b/packages/cli/templates/typescript/mcpagent/tsconfig.json new file mode 100644 index 000000000..c4efba63c --- /dev/null +++ b/packages/cli/templates/typescript/mcpagent/tsconfig.json @@ -0,0 +1,26 @@ +{ + "$schema": "https://json.schemastore.org/tsconfig", + "compilerOptions": { + "module": "NodeNext", + "target": "ESNext", + "moduleResolution": "NodeNext", + "strict": true, + "noImplicitAny": true, + "declaration": true, + "inlineSourceMap": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "experimentalDecorators": true, + "emitDecoratorMetadata": false, + "resolveJsonModule": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "pretty": true, + "outDir": "dist", + "rootDir": "src", + "types": ["node"] + }, + "ts-node": { + "transpileOnly": true + } +} diff --git a/packages/cli/templates/typescript/mcpagent/tsup.config.js b/packages/cli/templates/typescript/mcpagent/tsup.config.js new file mode 100644 index 000000000..32277a72f --- /dev/null +++ b/packages/cli/templates/typescript/mcpagent/tsup.config.js @@ -0,0 +1,13 @@ +/** @type {import('tsup').Options} */ +module.exports = { + dts: true, + minify: false, + bundle: false, + sourcemap: true, + treeshake: true, + splitting: true, + clean: true, + outDir: 'dist', + entry: ['src/index.ts'], + format: ['cjs'], +};