Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
Mirrored from https://github.com/Camo67/composio.git
Synced Nov 22, 05:45 UTC
feat(cli): compact root help, fix project-environment-detector empty dir test (#2813)
Musthaq Ahamad committed
Mar 3, 2026 at 18:47 UTC
389fab620ecad9ee9093c6ead5d8986180acc791
7 files changed
+131
-138
ts/packages/cli/src/bin.ts
+2
-3
@@ -224,7 +224,6 @@ runWithArgs.pipe(
224
),
225
Effect.provide(layers),
226
Effect.withConfigProvider(extendConfigProvider(BaseConfigProviderLive)),
227
- BunRuntime.runMain({
228
- teardown,
229
- })
227
+ effect =>
228
+ (BunRuntime.runMain({ teardown }) as (e: Effect.Effect<void, unknown, unknown>) => void)(effect)
229
);
ts/packages/cli/src/commands/index.ts
+9
@@ -21,6 +21,7 @@ import { logsCmd } from './logs-cmd/logs.cmd';
21
import { orgsCmd } from './orgs/orgs.cmd';
22
import { projectsCmd } from './projects/projects.cmd';
23
import { showToolsExecuteInputHelp } from './tools/commands/tools.execute.cmd';
24
+import { printRootHelp } from './root-help';
25
26
const $cmd = $defaultCmd.pipe(
27
Command.withSubcommands([
@@ -99,6 +100,11 @@ const normalizeVersionShortFlag = (argv: ReadonlyArray<string>): ReadonlyArray<s
100
return argv;
101
};
102
103
+const isRootHelp = (argv: ReadonlyArray<string>): boolean => {
104
+ const args = argv.slice(2);
105
+ return args.length === 1 && (args[0] === '--help' || args[0] === '-h');
106
+};
107
+
108
export const runWithConfig = Effect.gen(function* () {
109
const version = yield* getVersion;
110
const run = Command.run($cmd, {
@@ -109,6 +115,9 @@ export const runWithConfig = Effect.gen(function* () {
115
116
return (argv: ReadonlyArray<string>) => {
117
const normalizedArgv = normalizeVersionShortFlag(argv);
118
+ if (isRootHelp(normalizedArgv)) {
119
+ return printRootHelp();
120
+ }
121
const executeHelpSlug = parseExecuteInputHelpSlug(normalizedArgv);
122
if (executeHelpSlug) {
123
return showToolsExecuteInputHelp(executeHelpSlug);
ts/packages/cli/src/commands/root-help.ts
new
+61
@@ -0,0 +1,61 @@
1
+import { Console, Effect } from 'effect';
2
+import { bold } from 'src/ui/colors';
3
+
4
+/**
5
+ * Top-level commands for the root help output.
6
+ * Order and descriptions must match the commands in index.ts.
7
+ */
8
+const ROOT_COMMANDS: ReadonlyArray<{ name: string; description: string }> = [
9
+ { name: 'version', description: 'Display the current Composio CLI version.' },
10
+ { name: 'upgrade', description: 'Upgrade your Composio CLI to the latest available version.' },
11
+ { name: 'whoami', description: 'Display your account information.' },
12
+ { name: 'login', description: 'Log in to the Composio CLI session.' },
13
+ { name: 'logout', description: 'Log out from the Composio CLI session.' },
14
+ { name: 'init', description: 'Initialize a Composio project in the current directory.' },
15
+ {
16
+ name: 'generate',
17
+ description:
18
+ 'Generate type stubs for toolkits, tools, and triggers, auto-detecting project language (TypeScript | Python)',
19
+ },
20
+ { name: 'py', description: 'Handle Python projects.' },
21
+ { name: 'ts', description: 'Handle TypeScript projects.' },
22
+ { name: 'toolkits', description: 'Discover and inspect Composio toolkits.' },
23
+ { name: 'tools', description: 'Discover and inspect Composio tools.' },
24
+ { name: 'auth-configs', description: 'View and manage Composio auth configs.' },
25
+ { name: 'connected-accounts', description: 'View and manage Composio connected accounts.' },
26
+ { name: 'triggers', description: 'Inspect and subscribe to trigger events.' },
27
+ { name: 'logs', description: 'Inspect trigger and tool execution logs.' },
28
+ { name: 'orgs', description: 'Manage default global organization/project context.' },
29
+ { name: 'projects', description: 'Manage default global project context.' },
30
+];
31
+
32
+/**
33
+ * Prints the root-level help output in gh-style format.
34
+ * Shows only top-level commands, not nested subcommands.
35
+ */
36
+export function printRootHelp(): Effect.Effect<void> {
37
+ const name = 'composio';
38
+ const maxNameLen = Math.max(...ROOT_COMMANDS.map(c => c.name.length), 10);
39
+
40
+ const lines: string[] = [
41
+ '',
42
+ 'Connect AI agents to external tools. Link accounts, discover tools, and execute them.',
43
+ '',
44
+ bold('USAGE'),
45
+ ` ${name} <command> [options]`,
46
+ '',
47
+ bold('COMMANDS'),
48
+ ...ROOT_COMMANDS.map(cmd => ` ${cmd.name.padEnd(maxNameLen)} ${cmd.description}`),
49
+ '',
50
+ bold('FLAGS'),
51
+ ` -h, --help Show help for command`,
52
+ ` --version Show ${name} version`,
53
+ '',
54
+ bold('LEARN MORE'),
55
+ ` Use \`${name} <command> --help\` for more information about a command.`,
56
+ ` Documentation: https://docs.composio.dev`,
57
+ '',
58
+ ];
59
+
60
+ return Console.log(lines.join('\n'));
61
+}
ts/packages/cli/src/services/project-environment-detector.ts
+21
-1
@@ -144,6 +144,26 @@ const pickBestWeak = (candidate: DirEvidence, depth: number) => {
144
} as const;
145
};
146
147
+/** Known system paths that must not be treated as project roots for weak detection. */
148
+const SYSTEM_ROOTS = new Set([
149
+ '/',
150
+ '/tmp',
151
+ '/var',
152
+ '/usr',
153
+ '/private',
154
+ '/private/tmp',
155
+ '/private/var',
156
+]);
157
+
158
+/** Reject system roots (/, /tmp, /var, /private/tmp, etc.) as project roots for weak detection. */
159
+const isSystemRoot = (dir: string): boolean => {
160
+ const resolved = path.resolve(dir);
161
+ if (SYSTEM_ROOTS.has(resolved)) return true;
162
+ const parent = path.dirname(resolved);
163
+ if (parent === resolved) return true; // root
164
+ return parent === path.resolve('/'); // direct child of root, e.g. /tmp, /var, /usr
165
+};
166
+
167
const parsePackageManagerField = (pm: string) =>
168
Match.value(pm).pipe(
169
Match.when(
@@ -416,7 +436,7 @@ const detectLanguage = (fs: FileSystem.FileSystem, cwd: string) =>
436
bestWeak = weakCandidate;
437
}
438
419
- if (bestWeak)
439
+ if (bestWeak && !isSystemRoot(bestWeak.dir))
440
return {
441
language: bestWeak.language,
442
rootDir: bestWeak.dir,
ts/packages/cli/test/src/commands/$default.cmd.test.ts
+1
-1
@@ -28,7 +28,7 @@ describe('CLI: composio', () => {
28
Effect.gen(function* () {
29
const args = ['--help'];
30
yield* cli(args);
31
- const lines = yield* MockConsole.getLines();
31
+ const lines = yield* MockConsole.getLines({ stripAnsi: true });
32
const output = lines.join('\n');
33
expect(yield* sanitize(output)).toMatchSnapshot();
34
})
ts/packages/cli/test/src/commands/__snapshots__/$default.cmd.test.ts.snap
+32
-131
@@ -1,136 +1,37 @@
1
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
3
exports[`CLI: composio > [Given] --help flag [Then] prints help message 1`] = `
4
-"[0;1m[0;37;1mcomposio[0;1m[0m
5
-
6
-composio <VERSION>
7
-
8
-[0;1mUSAGE[0m
9
-
10
-$ composio [--log-level all | trace | debug | info | warning | error | fatal | none]
11
-
12
-[0;1mDESCRIPTION[0m
13
-
14
-Composio CLI - A tool for managing Python and TypeScript composio.dev projects.
15
-
16
-[0;1mOPTIONS[0m
17
-
18
-[0;1m--log-level all | trace | debug | info | warning | error | fatal | none[0m
19
-
20
- One of the following: all, trace, debug, info, warning, error, fatal, none
21
-
22
- Define log level
23
-
24
- This setting is optional.
25
-
26
-[0;1mCOMMANDS[0m
27
-
28
- - version Display the current Composio CLI version.
29
-
30
- - upgrade Upgrade your Composio CLI to the latest available version.
31
-
32
- - whoami Display your account information.
33
-
34
- - login [--no-browser] [--api-key text] [--org-id text] [--project-id text] Log in to the Composio SDK.
35
-
36
- - logout Log out from the Composio SDK.
37
-
38
- - init [--org-id text] [--project-id text] [--no-browser] [(-y, --yes)] Initialize a Composio project in the current directory.
39
-
40
- - generate [(-o, --output-dir directory)] [--type-tools] --toolkits text... Generate type stubs for toolkits, tools, and triggers, auto-detecting project language (TypeScript | Python)
41
-
42
- - py Handle Python projects.
43
-
44
- - py generate [(-o, --output-dir directory)] --toolkits text... Generate Python type stubs for toolkits, tools, and triggers from the Composio API.
45
-
46
-Environment Variables:
47
- COMPOSIO_TOOLKIT_VERSION_<TOOLKIT> Override toolkit version (e.g., COMPOSIO_TOOLKIT_VERSION_GMAIL=20250901_00)
48
- Use "latest" or unset to use the latest version.
49
-
50
- - ts Handle TypeScript projects.
51
-
52
- - ts generate [(-o, --output-dir directory)] [--compact] [--transpiled] [--type-tools] --toolkits text... Generate TypeScript types for toolkits, tools, and triggers from the Composio API.
53
-
54
-Environment Variables:
55
- COMPOSIO_TOOLKIT_VERSION_<TOOLKIT> Override toolkit version (e.g., COMPOSIO_TOOLKIT_VERSION_GMAIL=20250901_00)
56
- Use "latest" or unset to use the latest version.
57
-
58
- - toolkits Discover and inspect Composio toolkits.
59
-
60
- - toolkits list [--query text] [--limit integer] [--connected] [--user-id text] List available toolkits with connection status.
61
-
62
- - toolkits info [--user-id text] [(-a, --all)] [<slug>] View details of a specific toolkit.
63
-
64
- - toolkits search [--limit integer] <query> Search toolkits by use case.
65
-
66
- - toolkits version <slug> Show latest and recent versions for a toolkit.
67
-
68
- - tools Discover and inspect Composio tools.
69
-
70
- - tools list [--query text] [--toolkits text] [--tags text] [--limit integer] List available tools.
71
-
72
- - tools info [<slug>] View details of a specific tool.
73
-
74
- - tools search [--toolkits text] [--limit integer] <query> Semantically search tools by use case; returns best-fit tools plus recommended usage guidance.
75
-
76
- - tools execute [(-d, --data text)] [--user-id text] <slug> Execute a tool by slug with JSON arguments.
77
-
78
- - auth-configs View and manage Composio auth configs.
79
-
80
- - auth-configs list [--toolkits text] [--query text] [--limit integer] List auth configs.
81
-
82
- - auth-configs info [<id>] View details of a specific auth config.
83
-
84
- - auth-configs create --toolkit text [--auth-scheme text] [--scopes text] [--custom-credentials text] [<name>] Create a new auth config.
85
-
86
- - auth-configs delete [(-y, --yes)] [<id>] Delete an auth config.
87
-
88
- - connected-accounts View and manage Composio connected accounts.
89
-
90
- - connected-accounts list [--toolkits text] [--user-id text] [--status INITIALIZING | INITIATED | ACTIVE | FAILED | EXPIRED | INACTIVE] [--limit integer] List connected accounts.
91
-
92
- - connected-accounts info [<id>] View details of a specific connected account.
93
-
94
- - connected-accounts whoami [<id>] Show the external account profile for a connected account.
95
-
96
- - connected-accounts delete [(-y, --yes)] [<id>] Delete a connected account.
97
-
98
- - connected-accounts link [--auth-config text] [--user-id text] [--no-browser] [<toolkit>] Link an external account via OAuth redirect.
99
-
100
- - triggers Inspect and subscribe to trigger events.
101
-
102
- - triggers list [--toolkits text] [--limit integer] List available trigger types.
103
-
104
- - triggers info [<slug>] View details of a specific trigger type.
105
-
106
- - 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.
107
-
108
- - 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.
109
-
110
- - triggers create [--connected-account-id text] [--trigger-config text] [<trigger-name>] Create a new trigger instance.
111
-
112
- - triggers enable [<id>] Enable a trigger instance.
113
-
114
- - triggers disable [<id>] Disable a trigger instance.
115
-
116
- - triggers delete [(-y, --yes)] [<id>] Delete a trigger instance.
117
-
118
- - logs Inspect trigger and tool execution logs.
119
-
120
- - 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.
121
-
122
- - 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.
123
-
124
- - orgs Manage default global organization/project context.
125
-
126
- - orgs list [--limit integer] List organizations and show current global selection.
127
-
128
- - orgs switch [--org-id text] [--project-id text] [--limit integer] Switch default global organization/project context.
129
-
130
- - projects Manage default global project context.
131
-
132
- - projects list [--org-id text] [--limit integer] List projects and show current global selection.
133
-
134
- - projects switch [--org-id text] [--project-id text] [--limit integer] Switch default global project context.
4
+"
5
+Connect AI agents to external tools. Link accounts, discover tools, and execute them.
6
+
7
+USAGE
8
+ composio <command> [options]
9
+
10
+COMMANDS
11
+ version Display the current Composio CLI version.
12
+ upgrade Upgrade your Composio CLI to the latest available version.
13
+ whoami Display your account information.
14
+ login Log in to the Composio CLI session.
15
+ logout Log out from the Composio CLI session.
16
+ init Initialize a Composio project in the current directory.
17
+ generate Generate type stubs for toolkits, tools, and triggers, auto-detecting project language (TypeScript | Python)
18
+ py Handle Python projects.
19
+ ts Handle TypeScript projects.
20
+ toolkits Discover and inspect Composio toolkits.
21
+ tools Discover and inspect Composio tools.
22
+ auth-configs View and manage Composio auth configs.
23
+ connected-accounts View and manage Composio connected accounts.
24
+ triggers Inspect and subscribe to trigger events.
25
+ logs Inspect trigger and tool execution logs.
26
+ orgs Manage default global organization/project context.
27
+ projects Manage default global project context.
28
+
29
+FLAGS
30
+ -h, --help Show help for command
31
+ --version Show composio version
32
+
33
+LEARN MORE
34
+ Use \`composio <command> --help\` for more information about a command.
35
+ Documentation: https://docs.composio.dev
36
"
37
`;
ts/packages/cli/test/src/services/project-environment-detector.test.ts
+5
-2
@@ -251,10 +251,13 @@ describe('ProjectEnvironmentDetector', () => {
251
layer(testLayer)('Edge cases', it => {
252
it.scoped('[Given] empty directory [Then] fails with no-detection error', () =>
253
Effect.gen(function* () {
254
+ const fs = yield* FileSystem.FileSystem;
255
const detector = yield* ProjectEnvironmentDetector;
255
- const cwd = tempy.temporaryDirectory();
256
+ const tempRoot = tempy.temporaryDirectory();
257
+ const emptyDir = path.join(tempRoot, 'a', 'b', 'c');
258
+ yield* fs.makeDirectory(emptyDir, { recursive: true });
259
257
- const result = yield* detector.detectProjectEnvironment(cwd).pipe(Effect.either);
260
+ const result = yield* detector.detectProjectEnvironment(emptyDir).pipe(Effect.either);
261
262
assert(Either.isLeft(result));
263
expect(result.left.message).toContain('No recognizable');