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
fix(cli): detect setup after root flags
Kshitij Jhunjhunwala533bfb44b9ef
diff --git a/ts/packages/cli/src/services/plugin-hint.ts b/ts/packages/cli/src/services/plugin-hint.tsindex 378da0b08..774a4fb4c 100644--- a/ts/packages/cli/src/services/plugin-hint.ts+++ b/ts/packages/cli/src/services/plugin-hint.ts@@ -132,6 +132,22 @@ const DefaultConfigLayers = Layer.mergeAll(Path.layer, NodeOs.Default, BunFileSyconst readOptionalEnv = (name: string) =>Effect.orDie(Config.option(Config.string(name)).pipe(Config.map(Option.getOrUndefined)));+export function findRootCommandName(argv: ReadonlyArray<string>): string | undefined {+ const args = argv.slice(2);+ for (let index = 0; index < args.length; index += 1) {+ const token = args[index];+ if (token === '--log-level') {+ index += 1;+ continue;+ }+ if (token?.startsWith('--log-level=') || token?.startsWith('-')) {+ continue;+ }+ return token;+ }+ return undefined;+}+// Host-owned variables must bypass the CLI ConfigProvider, which prefixes// application keys with COMPOSIO_.const rawEnvironment = Effect.gen(function* () {@@ -161,7 +177,7 @@ export const resolvePluginHintConfig = (argv: ReadonlyArray<string>) =>stateDirectory: path.join(cacheDir, 'plugin-hints'),host: detectPluginHost(env),invocationOrigin: env.invocationOrigin,- commandName: argv[2],+ commandName: findRootCommandName(argv),claudeInstalledPluginsFile: path.join(env.claudeConfigDir ?? path.join(os.homedir, '.claude'),'plugins',diff --git a/ts/packages/cli/test/src/services/plugin-hint.test.ts b/ts/packages/cli/test/src/services/plugin-hint.test.tsindex 4f03ff9f0..adf75a6dc 100644--- a/ts/packages/cli/test/src/services/plugin-hint.test.ts+++ b/ts/packages/cli/test/src/services/plugin-hint.test.ts@@ -10,6 +10,7 @@ import { defaultNodeOs, NodeOs } from 'src/services/node-os';import {createPluginHint,detectPluginHost,+ findRootCommandName,resolvePluginHintConfig,type PluginHintConfig,} from 'src/services/plugin-hint';@@ -106,6 +107,18 @@ describe('resolvePluginHintConfig', () => {});});+describe('findRootCommandName', () => {+ it('skips root log-level flags before the subcommand', () => {+ expect(findRootCommandName(['/bin/bun', '/cli/bin.ts', 'setup'])).toBe('setup');+ expect(findRootCommandName(['/bin/bun', '/cli/bin.ts', '--log-level', 'debug', 'setup'])).toBe(+ 'setup'+ );+ expect(findRootCommandName(['/bin/bun', '/cli/bin.ts', '--log-level=debug', 'setup'])).toBe(+ 'setup'+ );+ });+});+describe('showPluginHint', () => {let output: string[];