Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
| 1 | import { Command, Flag } from 'effect/cli'; |
| 2 | import { runGenerate } from './generate.handler'; |
| 3 | import { generateCmd$Py } from './py/generate.py.cmd'; |
| 4 | import { generateCmd$Ts } from './ts/generate.ts.cmd'; |
| 5 | import { withRegisteredSubcommands } from 'src/commands/registration'; |
| 6 | |
| 7 | const outputDir = Flag.optional(Flag.Directory('output-dir')).pipe( |
| 8 | Flag.withAlias('o'), |
| 9 | Flag.withDescription('Output directory for type stubs') |
| 10 | ); |
| 11 | |
| 12 | const typeTools = Flag.Boolean('type-tools').pipe( |
| 13 | Flag.withDefault(false), |
| 14 | Flag.withDescription( |
| 15 | 'Generate typed input/output schemas for each tool (TypeScript only, slower)' |
| 16 | ) |
| 17 | ); |
| 18 | |
| 19 | const toolkits = Flag.String('toolkits').pipe( |
| 20 | Flag.atLeast(0), |
| 21 | Flag.withDescription( |
| 22 | 'Only generate types for specific toolkits (e.g., --toolkits gmail --toolkits slack)' |
| 23 | ) |
| 24 | ); |
| 25 | |
| 26 | /** |
| 27 | * CLI entry point for code generation commands. |
| 28 | * |
| 29 | * When invoked without a subcommand, auto-detects the project language. |
| 30 | * Subcommands `py` and `ts` allow explicit language selection. |
| 31 | * |
| 32 | * @example |
| 33 | * ```bash |
| 34 | * composio generate |
| 35 | * composio generate py |
| 36 | * composio generate ts |
| 37 | * composio generate ts --type-tools |
| 38 | * ``` |
| 39 | */ |
| 40 | export const generateCmd = Command.make( |
| 41 | 'generate', |
| 42 | { outputDir, typeTools, toolkits }, |
| 43 | runGenerate |
| 44 | ).pipe( |
| 45 | Command.withDescription( |
| 46 | 'Generate type stubs for toolkits, tools, and triggers, auto-detecting project language (TypeScript | Python)' |
| 47 | ), |
| 48 | withRegisteredSubcommands([generateCmd$Py, generateCmd$Ts], { ownAction: true }) |
| 49 | ); |