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

refactor(cli): move `artifacts cwd` into the directory shape (#4973)

This PR: - turns `artifacts.cmd.ts` into the group entry `artifacts/artifacts.cmd.ts` and moves its one subcommand to `artifacts/cwd/artifacts.cwd.{cmd,handler}.ts` (`artifactsCmd$Cwd`, `runArtifactsCwd`) - adds `artifacts.cwd.cmd.test.ts`: no session with `COMPOSIO_SESSION_DIR`, no session and no configured root (`<tmpdir>/composio`), and a session bound to the cwd (`<root>/cli_s_…`) - adds `artifacts.cwd.handler.test.ts`, which pins that the path is written with `force: true` - removes `artifacts.cmd.ts` from `COMMAND_TEST_EXEMPTIONS` (15 to 14) Part of U9 of the CLI command-layout series. No user-visible change, so no CHANGELOG entry. Verified locally on the branch tip: | Check | Result | | --- | --- | | `pnpm --filter @composio/cli typecheck` | passes | | `pnpm --filter @composio/cli test` (skills, boundaries, command tests, Vitest) | 162 files, 1902 passed, 1 skipped | | `validate:command-tests` | 14 exemptions (was 15) | | `lint:effect` | 0 diagnostics | | `oxlint`, prettier on touched files | clean | | Binary smoke | `artifacts --help`, `artifacts cwd --help`, `artifacts cwd`, root `--help`: identical to an `origin/next` (231122de1) binary |

Alberto Schiabel committed Oct 20, 2026 at 16:24 UTC 2ebb4d25ed0b75a0cb4003dc68c5b7c927131662
8 files changed +131 -29
ts/packages/cli/scripts/command-tests.ts
-1
@@ -18,7 +18,6 @@ const TEST_SUFFIX = '.cmd.test.ts';
18 // Command paths are relative to src/commands/; tests are relative to
19 // test/src/commands/. Both use forward slashes.
20 export const COMMAND_TEST_EXEMPTIONS: readonly CommandTestExemption[] = [
21 - { command: 'artifacts.cmd.ts', reason: 'no test yet' },
21 { command: 'connections/commands/connections.remove.cmd.ts', reason: 'no test yet' },
22 { command: 'debug.cmd.ts', reason: 'no test yet' },
23 { command: 'signup.cmd.ts', reason: 'no test yet' },
ts/packages/cli/src/commands/artifacts.cmd.ts deleted
-27
@@ -1,27 +0,0 @@
1 -import { Command } from 'effect/cli';
2 -import { Effect, Option } from 'effect';
3 -import {
4 - resolveArtifactsRoot,
5 - resolveCliSessionArtifacts,
6 -} from 'src/services/cli-session-artifacts';
7 -import { TerminalUI } from 'src/services/terminal-ui';
8 -
9 -const cwdCmd = Command.make('cwd').pipe(
10 - Command.withDescription('Print the cwd-scoped session artifact directory.'),
11 - Command.withHandler(() =>
12 - Effect.gen(function* () {
13 - const ui = yield* TerminalUI;
14 - const artifacts = yield* resolveCliSessionArtifacts();
15 - const directoryPath = yield* Option.match(artifacts, {
16 - onSome: ({ directoryPath }) => Effect.succeed(directoryPath),
17 - onNone: () => resolveArtifactsRoot,
18 - });
19 - yield* ui.output(directoryPath, { force: true });
20 - })
21 - )
22 -);
23 -
24 -export const artifactsCmd = Command.make('artifacts').pipe(
25 - Command.withDescription('Inspect session artifact directories.'),
26 - Command.withSubcommands([cwdCmd])
27 -);
ts/packages/cli/src/commands/artifacts/artifacts.cmd.ts new
+7
@@ -0,0 +1,7 @@
1 +import { Command } from 'effect/cli';
2 +import { artifactsCmd$Cwd } from './cwd/artifacts.cwd.cmd';
3 +
4 +export const artifactsCmd = Command.make('artifacts').pipe(
5 + Command.withDescription('Inspect session artifact directories.'),
6 + Command.withSubcommands([artifactsCmd$Cwd])
7 +);
ts/packages/cli/src/commands/artifacts/cwd/artifacts.cwd.cmd.ts new
+6
@@ -0,0 +1,6 @@
1 +import { Command } from 'effect/cli';
2 +import { runArtifactsCwd } from './artifacts.cwd.handler';
3 +
4 +export const artifactsCmd$Cwd = Command.make('cwd', {}, runArtifactsCwd).pipe(
5 + Command.withDescription('Print the cwd-scoped session artifact directory.')
6 +);
ts/packages/cli/src/commands/artifacts/cwd/artifacts.cwd.handler.ts new
+22
@@ -0,0 +1,22 @@
1 +import { Effect, Option } from 'effect';
2 +import {
3 + resolveArtifactsRoot,
4 + resolveCliSessionArtifacts,
5 +} from 'src/services/cli-session-artifacts';
6 +import { TerminalUI } from 'src/services/terminal-ui';
7 +
8 +/**
9 + * Prints the artifact directory of the CLI session bound to the current directory, or the
10 + * artifacts root when no session is bound. The path is data, so it is written even when stdout
11 + * is a terminal.
12 + */
13 +export const runArtifactsCwd = () =>
14 + Effect.gen(function* () {
15 + const ui = yield* TerminalUI;
16 + const artifacts = yield* resolveCliSessionArtifacts();
17 + const directoryPath = yield* Option.match(artifacts, {
18 + onSome: ({ directoryPath }) => Effect.succeed(directoryPath),
19 + onNone: () => resolveArtifactsRoot,
20 + });
21 + yield* ui.output(directoryPath, { force: true });
22 + });
ts/packages/cli/src/commands/index.ts
+1 -1
@@ -12,7 +12,7 @@ import { listenCmd } from './listen.cmd';
12 import { logoutCmd } from './logout.cmd';
13 import { runCmd } from './run.cmd';
14 import { proxyCmd } from './proxy.cmd';
15 -import { artifactsCmd } from './artifacts.cmd';
15 +import { artifactsCmd } from './artifacts/artifacts.cmd';
16 import { installCmd } from './install/install.cmd';
17 import { generateCmd } from './generate/generate.cmd';
18 import { buildDevCommand } from './dev.cmd';
ts/packages/cli/test/src/commands/artifacts/cwd/artifacts.cwd.cmd.test.ts new
+62
@@ -0,0 +1,62 @@
1 +import { describe, expect, layer } from '@effect/vitest';
2 +import { ConfigProvider, Effect } from 'effect';
3 +import * as Path from 'effect/Path';
4 +import * as tempy from 'tempy';
5 +import { NodeOs } from 'src/services/node-os';
6 +import { cli, MockConsole, TestLive } from 'test/__utils__';
7 +
8 +const sessionRoot = tempy.temporaryDirectory();
9 +
10 +describe('CLI: composio artifacts cwd', () => {
11 + layer(
12 + TestLive({
13 + baseConfigProvider: ConfigProvider.fromEnvRecord({ COMPOSIO_SESSION_DIR: sessionRoot }),
14 + })
15 + )('[Given] no CLI session for the cwd and `COMPOSIO_SESSION_DIR`', it => {
16 + it.effect('[Then] prints the artifacts root on stdout', () =>
17 + Effect.gen(function* () {
18 + yield* cli(['artifacts', 'cwd']);
19 +
20 + expect(yield* MockConsole.getLines({ stream: 'stdout' })).toEqual([sessionRoot]);
21 + expect(yield* MockConsole.getLines({ stream: 'stderr' })).toEqual([]);
22 + })
23 + );
24 + });
25 +
26 + layer(TestLive())('[Given] no CLI session and no configured root', it => {
27 + it.effect('[Then] prints `composio` under the temporary directory', () =>
28 + Effect.gen(function* () {
29 + const path = yield* Path.Path;
30 + const os = yield* NodeOs;
31 + yield* cli(['artifacts', 'cwd']);
32 +
33 + expect(yield* MockConsole.getLines({ stream: 'stdout' })).toEqual([
34 + path.join(os.tmpdir, 'composio'),
35 + ]);
36 + })
37 + );
38 + });
39 +
40 + layer(
41 + TestLive({
42 + // The fixture stores a login with a current org, so the consumer scope resolves and a
43 + // session is bound to the cwd.
44 + fixture: 'user-config-with-global-context',
45 + baseConfigProvider: ConfigProvider.fromEnvRecord({
46 + COMPOSIO_SESSION_DIR: sessionRoot,
47 + COMPOSIO_DISABLE_CONNECTED_ACCOUNT_CACHE: 'false',
48 + }),
49 + })
50 + )('[Given] a CLI session bound to the cwd', it => {
51 + it.effect('[Then] prints that session directory under the artifacts root', () =>
52 + Effect.gen(function* () {
53 + const path = yield* Path.Path;
54 + yield* cli(['artifacts', 'cwd']);
55 +
56 + const [directoryPath] = yield* MockConsole.getLines({ stream: 'stdout' });
57 + expect(path.dirname(directoryPath ?? '')).toBe(sessionRoot);
58 + expect(path.basename(directoryPath ?? '')).toMatch(/^cli_s_[a-z0-9]+_[a-f0-9]{10}$/i);
59 + })
60 + );
61 + });
62 +});
ts/packages/cli/test/src/commands/artifacts/cwd/artifacts.cwd.handler.test.ts new
+33
@@ -0,0 +1,33 @@
1 +import { describe, expect, layer } from '@effect/vitest';
2 +import { ConfigProvider, Effect } from 'effect';
3 +import * as tempy from 'tempy';
4 +import { runArtifactsCwd } from 'src/commands/artifacts/cwd/artifacts.cwd.handler';
5 +import { TerminalUI } from 'src/services/terminal-ui';
6 +import { TestLive } from 'test/__utils__';
7 +import { terminalUITestImpl } from 'test/__utils__/services/terminal-ui-test';
8 +
9 +const sessionRoot = tempy.temporaryDirectory();
10 +const outputs: Array<{ readonly data: string; readonly force: boolean | undefined }> = [];
11 +
12 +describe('runArtifactsCwd', () => {
13 + layer(
14 + TestLive({
15 + baseConfigProvider: ConfigProvider.fromEnvRecord({ COMPOSIO_SESSION_DIR: sessionRoot }),
16 + terminalUI: TerminalUI.of({
17 + ...terminalUITestImpl,
18 + output: (data, options) =>
19 + Effect.sync(() => {
20 + outputs.push({ data, force: options?.force });
21 + }),
22 + }),
23 + })
24 + )(it => {
25 + it.effect('[Then] forces the directory onto stdout even when it is a terminal', () =>
26 + Effect.gen(function* () {
27 + yield* runArtifactsCwd();
28 +
29 + expect(outputs).toEqual([{ data: sessionRoot, force: true }]);
30 + })
31 + );
32 + });
33 +});