Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
TypeScript agentic-aiagentsaiai-agentsaiagentsdeveloper-toolsfunction-callinggpt-4javascriptjsllmllmopsmcppythonremote-mcp-serverssetypescript
feat(cli): compact root help, fix project-environment-detector empty dir test (#2813)
Musthaq Ahamad389fab620eca
diff --git a/ts/packages/cli/src/bin.ts b/ts/packages/cli/src/bin.tsindex e2af4be04..45b7a5f15 100644--- a/ts/packages/cli/src/bin.ts+++ b/ts/packages/cli/src/bin.ts@@ -224,7 +224,6 @@ runWithArgs.pipe(),Effect.provide(layers),Effect.withConfigProvider(extendConfigProvider(BaseConfigProviderLive)),- BunRuntime.runMain({- teardown,- })+ effect =>+ (BunRuntime.runMain({ teardown }) as (e: Effect.Effect<void, unknown, unknown>) => void)(effect));diff --git a/ts/packages/cli/src/commands/index.ts b/ts/packages/cli/src/commands/index.tsindex 7004352b4..99b3e6926 100644--- a/ts/packages/cli/src/commands/index.ts+++ b/ts/packages/cli/src/commands/index.ts@@ -21,6 +21,7 @@ import { logsCmd } from './logs-cmd/logs.cmd';import { orgsCmd } from './orgs/orgs.cmd';import { projectsCmd } from './projects/projects.cmd';import { showToolsExecuteInputHelp } from './tools/commands/tools.execute.cmd';+import { printRootHelp } from './root-help';const $cmd = $defaultCmd.pipe(Command.withSubcommands([@@ -99,6 +100,11 @@ const normalizeVersionShortFlag = (argv: ReadonlyArray<string>): ReadonlyArray<sreturn argv;};+const isRootHelp = (argv: ReadonlyArray<string>): boolean => {+ const args = argv.slice(2);+ return args.length === 1 && (args[0] === '--help' || args[0] === '-h');+};+export const runWithConfig = Effect.gen(function* () {const version = yield* getVersion;const run = Command.run($cmd, {@@ -109,6 +115,9 @@ export const runWithConfig = Effect.gen(function* () {return (argv: ReadonlyArray<string>) => {const normalizedArgv = normalizeVersionShortFlag(argv);+ if (isRootHelp(normalizedArgv)) {+ return printRootHelp();+ }const executeHelpSlug = parseExecuteInputHelpSlug(normalizedArgv);if (executeHelpSlug) {return showToolsExecuteInputHelp(executeHelpSlug);diff --git a/ts/packages/cli/src/commands/root-help.ts b/ts/packages/cli/src/commands/root-help.tsnew file mode 100644index 000000000..812252cc6--- /dev/null+++ b/ts/packages/cli/src/commands/root-help.ts@@ -0,0 +1,61 @@+import { Console, Effect } from 'effect';+import { bold } from 'src/ui/colors';++/**+ * Top-level commands for the root help output.+ * Order and descriptions must match the commands in index.ts.+ */+const ROOT_COMMANDS: ReadonlyArray<{ name: string; description: string }> = [+ { name: 'version', description: 'Display the current Composio CLI version.' },+ { name: 'upgrade', description: 'Upgrade your Composio CLI to the latest available version.' },+ { name: 'whoami', description: 'Display your account information.' },+ { name: 'login', description: 'Log in to the Composio CLI session.' },+ { name: 'logout', description: 'Log out from the Composio CLI session.' },+ { name: 'init', description: 'Initialize a Composio project in the current directory.' },+ {+ name: 'generate',+ description:+ 'Generate type stubs for toolkits, tools, and triggers, auto-detecting project language (TypeScript | Python)',+ },+ { name: 'py', description: 'Handle Python projects.' },+ { name: 'ts', description: 'Handle TypeScript projects.' },+ { name: 'toolkits', description: 'Discover and inspect Composio toolkits.' },+ { name: 'tools', description: 'Discover and inspect Composio tools.' },+ { name: 'auth-configs', description: 'View and manage Composio auth configs.' },+ { name: 'connected-accounts', description: 'View and manage Composio connected accounts.' },+ { name: 'triggers', description: 'Inspect and subscribe to trigger events.' },+ { name: 'logs', description: 'Inspect trigger and tool execution logs.' },+ { name: 'orgs', description: 'Manage default global organization/project context.' },+ { name: 'projects', description: 'Manage default global project context.' },+];++/**+ * Prints the root-level help output in gh-style format.+ * Shows only top-level commands, not nested subcommands.+ */+export function printRootHelp(): Effect.Effect<void> {+ const name = 'composio';+ const maxNameLen = Math.max(...ROOT_COMMANDS.map(c => c.name.length), 10);++ const lines: string[] = [+ '',+ 'Connect AI agents to external tools. Link accounts, discover tools, and execute them.',+ '',+ bold('USAGE'),+ ` ${name} <command> [options]`,+ '',+ bold('COMMANDS'),+ ...ROOT_COMMANDS.map(cmd => ` ${cmd.name.padEnd(maxNameLen)} ${cmd.description}`),+ '',+ bold('FLAGS'),+ ` -h, --help Show help for command`,+ ` --version Show ${name} version`,+ '',+ bold('LEARN MORE'),+ ` Use \`${name} <command> --help\` for more information about a command.`,+ ` Documentation: https://docs.composio.dev`,+ '',+ ];++ return Console.log(lines.join('\n'));+}diff --git a/ts/packages/cli/src/services/project-environment-detector.ts b/ts/packages/cli/src/services/project-environment-detector.tsindex e0abc877f..4e928636c 100644--- a/ts/packages/cli/src/services/project-environment-detector.ts+++ b/ts/packages/cli/src/services/project-environment-detector.ts@@ -144,6 +144,26 @@ const pickBestWeak = (candidate: DirEvidence, depth: number) => {} as const;};+/** Known system paths that must not be treated as project roots for weak detection. */+const SYSTEM_ROOTS = new Set([+ '/',+ '/tmp',+ '/var',+ '/usr',+ '/private',+ '/private/tmp',+ '/private/var',+]);++/** Reject system roots (/, /tmp, /var, /private/tmp, etc.) as project roots for weak detection. */+const isSystemRoot = (dir: string): boolean => {+ const resolved = path.resolve(dir);+ if (SYSTEM_ROOTS.has(resolved)) return true;+ const parent = path.dirname(resolved);+ if (parent === resolved) return true; // root+ return parent === path.resolve('/'); // direct child of root, e.g. /tmp, /var, /usr+};+const parsePackageManagerField = (pm: string) =>Match.value(pm).pipe(Match.when(@@ -416,7 +436,7 @@ const detectLanguage = (fs: FileSystem.FileSystem, cwd: string) =>bestWeak = weakCandidate;}- if (bestWeak)+ if (bestWeak && !isSystemRoot(bestWeak.dir))return {language: bestWeak.language,rootDir: bestWeak.dir,diff --git a/ts/packages/cli/test/src/commands/$default.cmd.test.ts b/ts/packages/cli/test/src/commands/$default.cmd.test.tsindex a9bb2e989..0c34cc3aa 100644--- a/ts/packages/cli/test/src/commands/$default.cmd.test.ts+++ b/ts/packages/cli/test/src/commands/$default.cmd.test.ts@@ -28,7 +28,7 @@ describe('CLI: composio', () => {Effect.gen(function* () {const args = ['--help'];yield* cli(args);- const lines = yield* MockConsole.getLines();+ const lines = yield* MockConsole.getLines({ stripAnsi: true });const output = lines.join('\n');expect(yield* sanitize(output)).toMatchSnapshot();})diff --git a/ts/packages/cli/test/src/commands/__snapshots__/$default.cmd.test.ts.snap b/ts/packages/cli/test/src/commands/__snapshots__/$default.cmd.test.ts.snapindex aae253c88..c15b58648 100644--- a/ts/packages/cli/test/src/commands/__snapshots__/$default.cmd.test.ts.snap+++ b/ts/packages/cli/test/src/commands/__snapshots__/$default.cmd.test.ts.snap@@ -1,136 +1,37 @@// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.htmlexports[`CLI: composio > [Given] --help flag [Then] prints help message 1`] = `-"[0;1m[0;37;1mcomposio[0;1m[0m--composio <VERSION>--[0;1mUSAGE[0m--$ composio [--log-level all | trace | debug | info | warning | error | fatal | none]--[0;1mDESCRIPTION[0m--Composio CLI - A tool for managing Python and TypeScript composio.dev projects.--[0;1mOPTIONS[0m--[0;1m--log-level all | trace | debug | info | warning | error | fatal | none[0m-- One of the following: all, trace, debug, info, warning, error, fatal, none-- Define log level-- This setting is optional.--[0;1mCOMMANDS[0m-- - version Display the current Composio CLI version.-- - upgrade Upgrade your Composio CLI to the latest available version.-- - whoami Display your account information.-- - login [--no-browser] [--api-key text] [--org-id text] [--project-id text] Log in to the Composio SDK.-- - logout Log out from the Composio SDK.-- - init [--org-id text] [--project-id text] [--no-browser] [(-y, --yes)] Initialize a Composio project in the current directory.-- - generate [(-o, --output-dir directory)] [--type-tools] --toolkits text... Generate type stubs for toolkits, tools, and triggers, auto-detecting project language (TypeScript | Python)-- - py Handle Python projects.-- - py generate [(-o, --output-dir directory)] --toolkits text... Generate Python type stubs for toolkits, tools, and triggers from the Composio API.--Environment Variables:- COMPOSIO_TOOLKIT_VERSION_<TOOLKIT> Override toolkit version (e.g., COMPOSIO_TOOLKIT_VERSION_GMAIL=20250901_00)- Use "latest" or unset to use the latest version.-- - ts Handle TypeScript projects.-- - ts generate [(-o, --output-dir directory)] [--compact] [--transpiled] [--type-tools] --toolkits text... Generate TypeScript types for toolkits, tools, and triggers from the Composio API.--Environment Variables:- COMPOSIO_TOOLKIT_VERSION_<TOOLKIT> Override toolkit version (e.g., COMPOSIO_TOOLKIT_VERSION_GMAIL=20250901_00)- Use "latest" or unset to use the latest version.-- - toolkits Discover and inspect Composio toolkits.-- - toolkits list [--query text] [--limit integer] [--connected] [--user-id text] List available toolkits with connection status.-- - toolkits info [--user-id text] [(-a, --all)] [<slug>] View details of a specific toolkit.-- - toolkits search [--limit integer] <query> Search toolkits by use case.-- - toolkits version <slug> Show latest and recent versions for a toolkit.-- - tools Discover and inspect Composio tools.-- - tools list [--query text] [--toolkits text] [--tags text] [--limit integer] List available tools.-- - tools info [<slug>] View details of a specific tool.-- - tools search [--toolkits text] [--limit integer] <query> Semantically search tools by use case; returns best-fit tools plus recommended usage guidance.-- - tools execute [(-d, --data text)] [--user-id text] <slug> Execute a tool by slug with JSON arguments.-- - auth-configs View and manage Composio auth configs.-- - auth-configs list [--toolkits text] [--query text] [--limit integer] List auth configs.-- - auth-configs info [<id>] View details of a specific auth config.-- - auth-configs create --toolkit text [--auth-scheme text] [--scopes text] [--custom-credentials text] [<name>] Create a new auth config.-- - auth-configs delete [(-y, --yes)] [<id>] Delete an auth config.-- - connected-accounts View and manage Composio connected accounts.-- - connected-accounts list [--toolkits text] [--user-id text] [--status INITIALIZING | INITIATED | ACTIVE | FAILED | EXPIRED | INACTIVE] [--limit integer] List connected accounts.-- - connected-accounts info [<id>] View details of a specific connected account.-- - connected-accounts whoami [<id>] Show the external account profile for a connected account.-- - connected-accounts delete [(-y, --yes)] [<id>] Delete a connected account.-- - connected-accounts link [--auth-config text] [--user-id text] [--no-browser] [<toolkit>] Link an external account via OAuth redirect.-- - triggers Inspect and subscribe to trigger events.-- - triggers list [--toolkits text] [--limit integer] List available trigger types.-- - triggers info [<slug>] View details of a specific trigger type.-- - triggers listen [--toolkits text] [--trigger-id text] [--connected-account-id text] [--trigger-slug text] [--user-id text] [--json] [--table] [--max-events integer] [--forward text] [--out text] Listen to realtime trigger events for your project.-- - triggers status [--user-ids text] [--connected-account-ids text] [--toolkits text] [--trigger-ids text] [--trigger-names text] [--show-disabled] [--limit integer] Show active triggers with optional filters.-- - triggers create [--connected-account-id text] [--trigger-config text] [<trigger-name>] Create a new trigger instance.-- - triggers enable [<id>] Enable a trigger instance.-- - triggers disable [<id>] Disable a trigger instance.-- - triggers delete [(-y, --yes)] [<id>] Delete a trigger instance.-- - logs Inspect trigger and tool execution logs.-- - logs triggers [--cursor text] [--user-id text] [--connected-account-id text] [--trigger text] [--trigger-id text] [--log-id text] [--from integer] [--to integer] [--limit integer] [--time 5m | 30m | 6h | 1d | 1w | 1month | 1y] [--search text] [--include-payload] [<log_id>] List trigger logs.-- - logs tools [--cursor integer] [--from integer] [--to integer] [--limit integer] [--case-sensitive] [--toolkit text] [--tool text] [--connected-account-id text] [--auth-config-id text] [--status text] [--user-id text] [--log-id text] [--tool-router-session-id text] [--session-id text] [<log_id>] List tool execution logs, or pass a log_id to fetch a specific log.-- - orgs Manage default global organization/project context.-- - orgs list [--limit integer] List organizations and show current global selection.-- - orgs switch [--org-id text] [--project-id text] [--limit integer] Switch default global organization/project context.-- - projects Manage default global project context.-- - projects list [--org-id text] [--limit integer] List projects and show current global selection.-- - projects switch [--org-id text] [--project-id text] [--limit integer] Switch default global project context.+"+Connect AI agents to external tools. Link accounts, discover tools, and execute them.++USAGE+ composio <command> [options]++COMMANDS+ version Display the current Composio CLI version.+ upgrade Upgrade your Composio CLI to the latest available version.+ whoami Display your account information.+ login Log in to the Composio CLI session.+ logout Log out from the Composio CLI session.+ init Initialize a Composio project in the current directory.+ generate Generate type stubs for toolkits, tools, and triggers, auto-detecting project language (TypeScript | Python)+ py Handle Python projects.+ ts Handle TypeScript projects.+ toolkits Discover and inspect Composio toolkits.+ tools Discover and inspect Composio tools.+ auth-configs View and manage Composio auth configs.+ connected-accounts View and manage Composio connected accounts.+ triggers Inspect and subscribe to trigger events.+ logs Inspect trigger and tool execution logs.+ orgs Manage default global organization/project context.+ projects Manage default global project context.++FLAGS+ -h, --help Show help for command+ --version Show composio version++LEARN MORE+ Use \`composio <command> --help\` for more information about a command.+ Documentation: https://docs.composio.dev"`;diff --git a/ts/packages/cli/test/src/services/project-environment-detector.test.ts b/ts/packages/cli/test/src/services/project-environment-detector.test.tsindex 480765942..a9cf5ad30 100644--- a/ts/packages/cli/test/src/services/project-environment-detector.test.ts+++ b/ts/packages/cli/test/src/services/project-environment-detector.test.ts@@ -251,10 +251,13 @@ describe('ProjectEnvironmentDetector', () => {layer(testLayer)('Edge cases', it => {it.scoped('[Given] empty directory [Then] fails with no-detection error', () =>Effect.gen(function* () {+ const fs = yield* FileSystem.FileSystem;const detector = yield* ProjectEnvironmentDetector;- const cwd = tempy.temporaryDirectory();+ const tempRoot = tempy.temporaryDirectory();+ const emptyDir = path.join(tempRoot, 'a', 'b', 'c');+ yield* fs.makeDirectory(emptyDir, { recursive: true });- const result = yield* detector.detectProjectEnvironment(cwd).pipe(Effect.either);+ const result = yield* detector.detectProjectEnvironment(emptyDir).pipe(Effect.either);assert(Either.isLeft(result));expect(result.left.message).toContain('No recognizable');