From 12ed49eab740448ee99053fbf6002486f5d156e5 Mon Sep 17 00:00:00 2001 From: Aiden Cline Date: Mon, 29 Jun 2026 17:04:42 -0500 Subject: [PATCH] feat(cli): add auth command to list authenticated providers --- packages/cli/src/commands/commands.ts | 1 + packages/cli/src/commands/handlers/auth.ts | 33 ++++++++++++++++++++++ packages/cli/src/index.ts | 1 + 3 files changed, 35 insertions(+) create mode 100644 packages/cli/src/commands/handlers/auth.ts diff --git a/packages/cli/src/commands/commands.ts b/packages/cli/src/commands/commands.ts index 18db4006a8..5590028d59 100644 --- a/packages/cli/src/commands/commands.ts +++ b/packages/cli/src/commands/commands.ts @@ -36,6 +36,7 @@ export const Commands = Spec.make(typeof OPENCODE_CLI_NAME === "string" ? OPENCO description: "Debugging and troubleshooting tools", commands: [Spec.make("agents", { description: "List all agents" })], }), + Spec.make("auth", { description: "List authenticated providers" }), Spec.make("migrate", { description: "Migrate v1 data to v2" }), Spec.make("service", { description: "Manage the background server", diff --git a/packages/cli/src/commands/handlers/auth.ts b/packages/cli/src/commands/handlers/auth.ts new file mode 100644 index 0000000000..65c7a0bcdf --- /dev/null +++ b/packages/cli/src/commands/handlers/auth.ts @@ -0,0 +1,33 @@ +import { EOL } from "os" +import * as Effect from "effect/Effect" +import { Commands } from "../commands" +import { Runtime } from "../../framework/runtime" +import { Daemon } from "../../services/daemon" + +export default Runtime.handler( + Commands.commands.auth, + Effect.fn("cli.auth")(function* () { + const daemon = yield* Daemon.Service + const client = yield* daemon.client() + const response = yield* Effect.promise(() => + client.v2.integration.list({ location: { directory: process.cwd() } }), + ) + const connected = (response.data?.data ?? []) + .filter((integration) => integration.connections.length > 0) + .toSorted((a, b) => a.name.localeCompare(b.name)) + if (connected.length === 0) { + process.stdout.write("No authenticated providers" + EOL) + return + } + const width = Math.max(...connected.map((integration) => integration.name.length)) + const lines = connected.flatMap((integration) => + integration.connections.map( + (connection) => + `${integration.name.padEnd(width)} ${ + connection.type === "credential" ? `${connection.label} · credential` : `${connection.name} · env` + }`, + ), + ) + process.stdout.write(lines.join(EOL) + EOL) + }), +) diff --git a/packages/cli/src/index.ts b/packages/cli/src/index.ts index f8a95977df..4a3084a0de 100755 --- a/packages/cli/src/index.ts +++ b/packages/cli/src/index.ts @@ -21,6 +21,7 @@ const LoggingLayer = Logger.layer(Logging.loggers(), { mergeWithExisting: false const Handlers = Runtime.handlers(Commands, { $: () => import("./commands/handlers/default"), api: () => import("./commands/handlers/api"), + auth: () => import("./commands/handlers/auth"), debug: { agents: () => import("./commands/handlers/debug/agents"), },