From 092cb0509fd07fb4d59e4167670cbbcbc70d1956 Mon Sep 17 00:00:00 2001 From: "opencode-agent[bot]" Date: Tue, 18 Nov 2025 08:03:12 +0000 Subject: [PATCH] Added `opencode agent list` command to show all available agents with details. Co-authored-by: rekram1-node --- packages/opencode/src/cli/cmd/agent.ts | 46 +++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/packages/opencode/src/cli/cmd/agent.ts b/packages/opencode/src/cli/cmd/agent.ts index 54f873f9c..1b7b3273b 100644 --- a/packages/opencode/src/cli/cmd/agent.ts +++ b/packages/opencode/src/cli/cmd/agent.ts @@ -133,9 +133,53 @@ const AgentCreateCommand = cmd({ }, }) +const AgentListCommand = cmd({ + command: "list", + describe: "list all available agents", + aliases: ["ls"], + async handler() { + await Instance.provide({ + directory: process.cwd(), + async fn() { + UI.empty() + prompts.intro("Available agents") + + const agents = await Agent.list() + + if (agents.length === 0) { + prompts.log.warn("No agents found") + prompts.outro("Done") + return + } + + const sortedAgents = agents.sort((a, b) => { + if (a.builtIn !== b.builtIn) { + return a.builtIn ? -1 : 1 + } + return a.name.localeCompare(b.name) + }) + + for (const agent of sortedAgents) { + const type = agent.builtIn ? "built-in" : "custom" + const mode = agent.mode === "all" ? "primary/subagent" : agent.mode + const description = agent.description || "No description" + + prompts.log.info(`${agent.name} (${type}, ${mode})`) + if (description) { + console.log(` ${description}`) + } + console.log() + } + + prompts.outro(`Found ${agents.length} agent${agents.length === 1 ? "" : "s"}`) + }, + }) + }, +}) + export const AgentCommand = cmd({ command: "agent", describe: "manage agents", - builder: (yargs) => yargs.command(AgentCreateCommand).demandCommand(), + builder: (yargs) => yargs.command(AgentCreateCommand).command(AgentListCommand).demandCommand(), async handler() {}, })