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): use Option combinators in place of isSome ternaries (#4909)
This PR: - Adds an "`Option`: combinators, not `isSome` ternaries" section to the effect-v4 skill (`references/core-patterns.md`, linked from `SKILL.md`): a rewrite table checked against `effect@4.0.3` and two excerpts quoted from code this PR rewrites (`upgradeCmd`, `isTelemetryDebugEnabled`). - Rewrites 13 sites in 12 CLI source files: - 5 × `Option.isSome(o) ? f(o.value) : undefined` → `Option.getOrUndefined(Option.map(o, f))`, each feeding a `?: T` field or return. - 2 × `Option.isSome(o) ? f(o.value) : x` → `Option.match(o, { onNone, onSome })`. - 2 × `Option.isSome(o) ? o.value : yield* fallback` → `yield* Option.match(o, { onSome: Effect.succeed, onNone: () => fallback })`. - 2 × `Option.match(o, { onNone: () => false, ... })` / `Option.isSome(o) && p(o.value)` → `Option.exists(o, p)`. - 1 × `Option.getOrUndefined(o) ?? x` → `Option.getOrElse(o, () => x)`. - 1 × `Option.getOrUndefined(a) ?? Option.getOrUndefined(b)` → `Option.getOrUndefined(Option.orElse(a, () => b))`. - Keeps behaviour the same: same values, fallbacks stay lazy, and effects run on the same branch as before with the same error types. - Leaves 20 candidate sites in 10 files untouched because open CLI PRs (#4897, #4804, #4754, #4745, #4849, #4817, #4900, #4457) change those files. They can follow once those PRs merge. - Leaves `if (Option.isSome(...))` guards and early returns as they are, along with one `isSome && length > 0 ? value : yield* fetch` site in `consumer-short-term-cache.ts` where the combinator form read worse. `cli-keyring`, `json-schema-to-effect-schema`, and the CLI tests had no candidates. ## Context The pattern came up while reviewing #4900 (https://github.com/ComposioHQ/composio/pull/4900). Once #4900 merges, the skill section will also get its examples (`Option.as`, `Option.filter`, `Effect.transposeOption`). This PR has no user-visible effect, so it has no changeset or CHANGELOG line. ## Verification - `pnpm typecheck`: 14/14 tasks successful - `pnpm --filter @composio/cli test`: validators OK (`command tests OK: 57 commands checked against 52 test files, 18 exemptions remaining.`), Vitest 152 files passed, 1676 tests passed, 1 skipped - `pnpm --filter @composio/cli run lint:effect`: 0 errors, 0 warnings - `pnpm --filter @composio/cli exec oxlint <12 touched files>`: 0 warnings, 0 errors - `npx prettier --check <touched files>`: all files formatted - `node .agents/skills/effect-v4/scripts/check-examples.mjs`: all checked blocks compile (5 in core-patterns.md) - `pnpm validate:agent-skills`: 19 skills validated - `pnpm validate:skill-routing`: 19 probes over 19 skills passed