Skip to content

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

fix(cli): address code review findings for tools command

jkomyno86ac439c1814
diff --git a/ts/packages/cli/recordings/recordings.yaml b/ts/packages/cli/recordings/recordings.yaml
index c39320147..3f6e1e341 100644
--- a/ts/packages/cli/recordings/recordings.yaml
+++ b/ts/packages/cli/recordings/recordings.yaml
@@ -103,3 +103,50 @@ recordings:
- name: list-query-gmaxx
description: List with no results
command: "composio toolkits list --query 'gmaxx'"
+
+ tools:
+ - name: help
+ description: Show tools subcommand help
+ command: "composio tools --help"
+ height: dynamic
+
+ - name: list-toolkit-gmail
+ description: List tools in a toolkit
+ command: "composio tools list --toolkits gmail"
+ height: dynamic
+
+ - name: list-toolkit-gmail-limit-3
+ description: List with --limit flag
+ command: "composio tools list --toolkits gmail --limit 3"
+
+ - name: list-search-send-email
+ description: List with --search filter
+ command: "composio tools list --search 'send email'"
+ height: dynamic
+
+ - name: list-search-no-results
+ description: List with no results
+ command: "composio tools list --toolkits 'nonexistent'"
+
+ - name: search-send-email
+ description: Search tools by use case
+ command: "composio tools search 'send email'"
+ height: dynamic
+
+ - name: search-no-results
+ description: Search with no results
+ command: "composio tools search 'xyznonexistent'"
+
+ - name: info
+ description: Show info without arguments
+ command: "composio tools info"
+
+ - name: info-gmail-send-email
+ description: Show tool details
+ command: "composio tools info GMAIL_SEND_EMAIL"
+ height: dynamic
+
+ - name: info-nonexistent
+ description: Info with nonexistent tool
+ command: "composio tools info NONEXISTENT_TOOL"
+ height: dynamic
diff --git a/ts/packages/cli/src/commands/tools/commands/tools.list.cmd.ts b/ts/packages/cli/src/commands/tools/commands/tools.list.cmd.ts
index 822a3ed99..e98e16c6a 100644
--- a/ts/packages/cli/src/commands/tools/commands/tools.list.cmd.ts
+++ b/ts/packages/cli/src/commands/tools/commands/tools.list.cmd.ts
@@ -5,7 +5,7 @@ import { ComposioUserContext } from 'src/services/user-context';
import { TerminalUI } from 'src/services/terminal-ui';
import { formatToolsTable, formatToolsJson } from '../format';
-const search = Options.text('search').pipe(
+const query = Options.text('query').pipe(
Options.withDescription('Text search by name, slug, or description'),
Options.optional
);
@@ -33,14 +33,14 @@ const limit = Options.integer('limit').pipe(
* @example
* ```bash
* composio tools list --toolkits "gmail"
- * composio tools list --search "send email" --toolkits "gmail"
+ * composio tools list --query "send email" --toolkits "gmail"
* composio tools list --tags "important" --limit 10
* ```
*/
export const toolsCmd$List = Command.make(
'list',
- { search, toolkits, tags, limit },
- ({ search, toolkits, tags, limit }) =>
+ { query, toolkits, tags, limit },
+ ({ query, toolkits, tags, limit }) =>
Effect.gen(function* () {
const ui = yield* TerminalUI;
const ctx = yield* ComposioUserContext;
@@ -57,7 +57,7 @@ export const toolsCmd$List = Command.make(
const result = yield* ui.withSpinner(
'Fetching tools...',
repo.searchTools({
- search: Option.getOrUndefined(search),
+ search: Option.getOrUndefined(query),
toolkit_slug: Option.getOrUndefined(toolkits),
tags: Option.getOrUndefined(tags),
limit: clampedLimit,
diff --git a/ts/packages/cli/src/commands/tools/format.ts b/ts/packages/cli/src/commands/tools/format.ts
index c15e3b8f5..5124d59bf 100644
--- a/ts/packages/cli/src/commands/tools/format.ts
+++ b/ts/packages/cli/src/commands/tools/format.ts
@@ -62,10 +62,6 @@ function formatSchemaProperties(schema: Record<string, unknown>): string {
return { name, type, label, description };
});
- if (entries.length === 0) {
- return ' (none)';
- }
-
const nameWidth = Math.max(...entries.map(e => e.name.length));
const typeWidth = Math.max(...entries.map(e => e.type.length));
const labelWidth = Math.max(...entries.map(e => e.label.length));
diff --git a/ts/packages/cli/test/__utils__/services/test-layer.ts b/ts/packages/cli/test/__utils__/services/test-layer.ts
index 115d077f1..0eadde1a3 100644
--- a/ts/packages/cli/test/__utils__/services/test-layer.ts
+++ b/ts/packages/cli/test/__utils__/services/test-layer.ts
@@ -270,6 +270,13 @@ export const TestLayer = (input?: TestLiveInput) =>
);
}
+ if (params.tags) {
+ const tagList = params.tags.split(',').map(t => t.trim().toLowerCase());
+ results = results.filter(t =>
+ tagList.some(tag => t.tags.map(tt => tt.toLowerCase()).includes(tag))
+ );
+ }
+
const limit = params.limit ?? 30;
const items = results.slice(0, limit);
return Effect.succeed({
@@ -285,10 +292,13 @@ export const TestLayer = (input?: TestLiveInput) =>
new HttpServerError({ cause: `Tool "${slug}" not found`, status: 404 })
);
}
+ // Derive toolkit slug from tool slug prefix (e.g. GMAIL_SEND_EMAIL -> gmail)
+ const parts = found.slug.split('_');
+ const toolkitSlug = parts.length > 1 ? parts[0]!.toLowerCase() : '';
return Effect.succeed({
...found,
no_auth: false,
- toolkit: { name: '', slug: '' },
+ toolkit: { name: toolkitSlug, slug: toolkitSlug },
});
},
getToolkitDetailed: (slug: string) => {
diff --git a/ts/packages/cli/test/src/commands/$default.cmd.test.ts b/ts/packages/cli/test/src/commands/$default.cmd.test.ts
index b0419f739..d1905253f 100644
--- a/ts/packages/cli/test/src/commands/$default.cmd.test.ts
+++ b/ts/packages/cli/test/src/commands/$default.cmd.test.ts
@@ -94,7 +94,7 @@ describe('CLI: composio', () => {
- tools Discover and inspect Composio tools.
- - tools list [--search text] [--toolkits text] [--tags text] [--limit integer] List available tools.
+ - tools list [--query text] [--toolkits text] [--tags text] [--limit integer] List available tools.
- tools info [<slug>] View details of a specific tool.
diff --git a/ts/packages/cli/test/src/commands/tools/tools.info.cmd.test.ts b/ts/packages/cli/test/src/commands/tools/tools.info.cmd.test.ts
index 989c2e0b8..ce39fbe12 100644
--- a/ts/packages/cli/test/src/commands/tools/tools.info.cmd.test.ts
+++ b/ts/packages/cli/test/src/commands/tools/tools.info.cmd.test.ts
@@ -66,6 +66,8 @@ describe('CLI: composio tools info', () => {
expect(output).toContain('required');
expect(output).toContain('Output Parameters');
expect(output).toContain('message_id');
+ // Verify next-step hint includes derived toolkit slug
+ expect(output).toContain('composio tools list --toolkits "gmail"');
})
);
}
diff --git a/ts/packages/cli/test/src/commands/tools/tools.list.cmd.test.ts b/ts/packages/cli/test/src/commands/tools/tools.list.cmd.test.ts
index ccbf4756c..b993752e9 100644
--- a/ts/packages/cli/test/src/commands/tools/tools.list.cmd.test.ts
+++ b/ts/packages/cli/test/src/commands/tools/tools.list.cmd.test.ts
@@ -92,11 +92,11 @@ describe('CLI: composio tools list', () => {
);
layer(TestLive({ baseConfigProvider: testConfigProvider, toolkitsData }))(
- '[Given] --search "send" [Then] shows filtered results',
+ '[Given] --query "send" [Then] shows filtered results',
it => {
it.scoped('filters by search query', () =>
Effect.gen(function* () {
- yield* cli(['tools', 'list', '--search', 'send']);
+ yield* cli(['tools', 'list', '--query', 'send']);
const lines = yield* MockConsole.getLines({ stripAnsi: true });
const output = lines.join('\n');
@@ -150,6 +150,23 @@ describe('CLI: composio tools list', () => {
}
);
+ layer(TestLive({ baseConfigProvider: testConfigProvider, toolkitsData }))(
+ '[Given] --tags "email" [Then] filters by tag',
+ it => {
+ it.scoped('filters by tag', () =>
+ Effect.gen(function* () {
+ yield* cli(['tools', 'list', '--tags', 'email']);
+ const lines = yield* MockConsole.getLines({ stripAnsi: true });
+ const output = lines.join('\n');
+
+ expect(output).toContain('GMAIL_SEND_EMAIL');
+ expect(output).toContain('GMAIL_CREATE_DRAFT');
+ expect(output).not.toContain('SLACK_SEND_MESSAGE');
+ })
+ );
+ }
+ );
+
layer(TestLive({ baseConfigProvider: testConfigProvider, toolkitsData }))(
'[Given] --toolkits "nonexistent" [Then] shows no tools found with hint',
it => {