Compare commits

...
Author SHA1 Message Date
Aiden Cline 12ed49eab7 feat(cli): add auth command to list authenticated providers 2026-06-29 17:04:42 -05:00
3 changed files with 35 additions and 0 deletions
+1
View File
@@ -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",
@@ -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)
}),
)
+1
View File
@@ -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"),
},