@devries-cameron20 / composio Mirror · read-only / commits / 4afd5e062
Fork 0

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 21, 12:15 UTC

refactor(cli): resolve plugin hint host dirs via hostConfigDirectory

resolvePluginHintConfig inlined the same env-override-else-~/.claude and ~/.codex fallback expressions that agent-host-env.ts now owns, leaving the host-dir default written three times across two files. Use the shared helper for both file paths and drop the now-unused NodeOs yield. The 'preserves nonblank path overrides' test asserted verbatim pass-through of relative overrides, which was the cwd dependence the probe hardening removes. It now pins absolute overrides preserved as-is plus a new case asserting relative overrides anchor to the home directory.

jkomyno committed Sep 16, 2026 at 18:43 UTC 4afd5e0620b1605cbb5f8495dc6cbf17ed0dd518
2 files changed +27 -10
ts/packages/cli/src/services/plugin-hint.ts
+5 -8
@@ -8,7 +8,7 @@ import { APP_CONFIG } from 'src/effects/app-config';
8 import { setupCacheDir } from 'src/effects/setup-cache-dir';
9 import { APP_VERSION } from 'src/constants';
10 import { AGENT_HOST_LABELS, COMPOSIO_AGENT_PLUGIN_ID, type AgentHost } from './agent-host';
11 -import { detectPluginHost, rawHostEnvironment } from './agent-host-env';
11 +import { detectPluginHost, hostConfigDirectory, rawHostEnvironment } from './agent-host-env';
12 import { NodeOs } from './node-os';
13 import { DEFAULT_CLI_INVOCATION_ORIGIN } from './runtime-cli-context';
14 import { TerminalUI } from './terminal-ui';
@@ -148,21 +148,18 @@ export function findRootCommandName(argv: ReadonlyArray<string>): string | undef
148 export const resolvePluginHintConfig = (argv: ReadonlyArray<string>) =>
149 Effect.gen(function* () {
150 const path = yield* Path.Path;
151 - const os = yield* NodeOs;
151 const cacheDir = yield* setupCacheDir;
152 const invocationOrigin = yield* APP_CONFIG.CLI_INVOCATION_ORIGIN;
153 const env = yield* rawHostEnvironment;
154 + const claudeConfigDir = yield* hostConfigDirectory('claude');
155 + const codexConfigDir = yield* hostConfigDirectory('codex');
156 return {
157 stateDirectory: path.join(cacheDir, 'plugin-hints'),
158 host: detectPluginHost(env),
159 invocationOrigin,
160 commandName: findRootCommandName(argv),
160 - claudeInstalledPluginsFile: path.join(
161 - env.claudeConfigDir ?? path.join(os.homedir, '.claude'),
162 - 'plugins',
163 - 'installed_plugins.json'
164 - ),
165 - codexConfigFile: path.join(env.codexHome ?? path.join(os.homedir, '.codex'), 'config.toml'),
161 + claudeInstalledPluginsFile: path.join(claudeConfigDir, 'plugins', 'installed_plugins.json'),
162 + codexConfigFile: path.join(codexConfigDir, 'config.toml'),
163 hintIntervalMs: HINT_INTERVAL_MS,
164 } satisfies PluginHintConfig;
165 });
ts/packages/cli/test/src/services/plugin-hint.test.ts
+22 -2
@@ -148,8 +148,8 @@ describe('resolvePluginHintConfig', () => {
148 });
149
150 it.effect('preserves nonblank path overrides', () => {
151 - const claudeConfigDir = ` ${join(tempDir, 'claude profile')} `;
152 - const codexHome = ` ${join(tempDir, 'codex profile')} `;
151 + const claudeConfigDir = join(tempDir, 'claude profile');
152 + const codexHome = join(tempDir, 'codex profile');
153 vi.stubEnv('CLAUDE_CONFIG_DIR', claudeConfigDir);
154 vi.stubEnv('CODEX_HOME', codexHome);
155
@@ -168,6 +168,26 @@ describe('resolvePluginHintConfig', () => {
168 Effect.provide(hintLayers())
169 );
170 });
171 +
172 + it.effect('anchors relative path overrides to the home directory', () => {
173 + vi.stubEnv('CLAUDE_CONFIG_DIR', 'claude-relative');
174 + vi.stubEnv('CODEX_HOME', 'codex-relative');
175 +
176 + return Effect.gen(function* () {
177 + const config = yield* resolvePluginHintConfig(['/bin/bun', '/cli/bin.ts', 'version']);
178 +
179 + expect(config.claudeInstalledPluginsFile).toBe(
180 + join(tempDir, 'claude-relative', 'plugins', 'installed_plugins.json')
181 + );
182 + expect(config.codexConfigFile).toBe(join(tempDir, 'codex-relative', 'config.toml'));
183 + }).pipe(
184 + Effect.provideService(
185 + ConfigProvider.ConfigProvider,
186 + extendConfigProvider(ConfigProvider.fromEnv())
187 + ),
188 + Effect.provide(hintLayers())
189 + );
190 + });
191 });
192
193 describe('findRootCommandName', () => {