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): ignore blank plugin host paths

Kshitij Jhunjhunwalafaaed16fa941
diff --git a/ts/packages/cli/src/services/plugin-hint.ts b/ts/packages/cli/src/services/plugin-hint.ts
index 774a4fb4c..e3b3e77d7 100644
--- a/ts/packages/cli/src/services/plugin-hint.ts
+++ b/ts/packages/cli/src/services/plugin-hint.ts
@@ -24,6 +24,9 @@ export interface HostEnvMarkers {
const isPresent = (value: string | undefined): boolean =>
value !== undefined && value.trim().length > 0;
+const nonBlankOrUndefined = (value: string | undefined): string | undefined =>
+ value === undefined || value.trim().length === 0 ? undefined : value;
+
export function detectPluginHost(markers: HostEnvMarkers): AgentHost | undefined {
if (isPresent(markers.claudeCode)) return 'claude';
if (isPresent(markers.codexThreadId) || isPresent(markers.codexSandbox)) return 'codex';
@@ -155,8 +158,8 @@ const rawEnvironment = Effect.gen(function* () {
const codexThreadId = yield* readOptionalEnv('CODEX_THREAD_ID');
const codexSandbox = yield* readOptionalEnv('CODEX_SANDBOX');
const invocationOrigin = yield* readOptionalEnv('COMPOSIO_CLI_INVOCATION_ORIGIN');
- const claudeConfigDir = yield* readOptionalEnv('CLAUDE_CONFIG_DIR');
- const codexHome = yield* readOptionalEnv('CODEX_HOME');
+ const claudeConfigDir = nonBlankOrUndefined(yield* readOptionalEnv('CLAUDE_CONFIG_DIR'));
+ const codexHome = nonBlankOrUndefined(yield* readOptionalEnv('CODEX_HOME'));
return {
claudeCode,
codexThreadId,
diff --git a/ts/packages/cli/test/src/services/plugin-hint.test.ts b/ts/packages/cli/test/src/services/plugin-hint.test.ts
index adf75a6dc..0f41b6e47 100644
--- a/ts/packages/cli/test/src/services/plugin-hint.test.ts
+++ b/ts/packages/cli/test/src/services/plugin-hint.test.ts
@@ -105,6 +105,46 @@ describe('resolvePluginHintConfig', () => {
)
);
});
+
+ it.effect('falls back to host defaults for blank path overrides', () => {
+ vi.stubEnv('CLAUDE_CONFIG_DIR', '');
+ vi.stubEnv('CODEX_HOME', ' ');
+
+ return Effect.gen(function* () {
+ const config = yield* resolvePluginHintConfig(['/bin/bun', '/cli/bin.ts', 'version']);
+
+ expect(config.claudeInstalledPluginsFile).toBe(
+ join(tempDir, '.claude', 'plugins', 'installed_plugins.json')
+ );
+ expect(config.codexConfigFile).toBe(join(tempDir, '.codex', 'config.toml'));
+ }).pipe(
+ Effect.withConfigProvider(extendConfigProvider(ConfigProvider.fromEnv())),
+ Effect.provide(
+ Layer.merge(PlatformLayers, Layer.succeed(NodeOs, defaultNodeOs({ homedir: tempDir })))
+ )
+ );
+ });
+
+ it.effect('preserves nonblank path overrides', () => {
+ const claudeConfigDir = ` ${join(tempDir, 'claude profile')} `;
+ const codexHome = ` ${join(tempDir, 'codex profile')} `;
+ vi.stubEnv('CLAUDE_CONFIG_DIR', claudeConfigDir);
+ vi.stubEnv('CODEX_HOME', codexHome);
+
+ return Effect.gen(function* () {
+ const config = yield* resolvePluginHintConfig(['/bin/bun', '/cli/bin.ts', 'version']);
+
+ expect(config.claudeInstalledPluginsFile).toBe(
+ join(claudeConfigDir, 'plugins', 'installed_plugins.json')
+ );
+ expect(config.codexConfigFile).toBe(join(codexHome, 'config.toml'));
+ }).pipe(
+ Effect.withConfigProvider(extendConfigProvider(ConfigProvider.fromEnv())),
+ Effect.provide(
+ Layer.merge(PlatformLayers, Layer.succeed(NodeOs, defaultNodeOs({ homedir: tempDir })))
+ )
+ );
+ });
});
describe('findRootCommandName', () => {