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
refactor(cli): extract shared truncate utility from format modules
jkomynoa72466f4c289
diff --git a/ts/packages/cli/src/commands/toolkits/format.ts b/ts/packages/cli/src/commands/toolkits/format.tsindex f1d4709f4..94b877149 100644--- a/ts/packages/cli/src/commands/toolkits/format.ts+++ b/ts/packages/cli/src/commands/toolkits/format.ts@@ -1,13 +1,6 @@import type { Toolkit } from 'src/models/toolkits';import { bold, gray } from 'src/ui/colors';--/**- * Truncate a string to the given max length, appending "..." if truncated.- */-function truncate(str: string, max: number): string {- if (str.length <= max) return str;- return str.slice(0, max - 3) + '...';-}+import { truncate } from 'src/ui/truncate';/*** Format a list of toolkits as a human-readable table.diff --git a/ts/packages/cli/src/commands/tools/format.ts b/ts/packages/cli/src/commands/tools/format.tsindex 5124d59bf..af732675a 100644--- a/ts/packages/cli/src/commands/tools/format.ts+++ b/ts/packages/cli/src/commands/tools/format.ts@@ -1,14 +1,7 @@import type { Tool } from 'src/models/tools';import type { ToolDetailedResponse } from 'src/services/composio-clients';import { bold, gray } from 'src/ui/colors';--/**- * Truncate a string to the given max length, appending "..." if truncated.- */-function truncate(str: string, max: number): string {- if (str.length <= max) return str;- return str.slice(0, max - 3) + '...';-}+import { truncate } from 'src/ui/truncate';/*** Format a list of tools as a human-readable table.diff --git a/ts/packages/cli/src/ui/truncate.ts b/ts/packages/cli/src/ui/truncate.tsnew file mode 100644index 000000000..907ce136b--- /dev/null+++ b/ts/packages/cli/src/ui/truncate.ts@@ -0,0 +1,7 @@+/**+ * Truncate a string to the given max length, appending "..." if truncated.+ */+export function truncate(str: string, max: number): string {+ if (str.length <= max) return str;+ return str.slice(0, max - 3) + '...';+}