Skip to content
This repository was archived by the owner on Apr 1, 2026. It is now read-only.

Commit 37d5099

Browse files
Added `opencode agent list` command to show all available agents with details. (anomalyco#4446) Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com> Co-authored-by: rekram1-node <rekram1-node@users.noreply.github.com> Co-authored-by: Aiden Cline <aidenpcline@gmail.com>
1 parent d45fc03 commit 37d5099

1 file changed

Lines changed: 25 additions & 1 deletion

File tree

packages/opencode/src/cli/cmd/agent.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { Agent } from "../../agent/agent"
66
import path from "path"
77
import matter from "gray-matter"
88
import { Instance } from "../../project/instance"
9+
import { EOL } from "os"
910

1011
const AgentCreateCommand = cmd({
1112
command: "create",
@@ -133,9 +134,32 @@ const AgentCreateCommand = cmd({
133134
},
134135
})
135136

137+
const AgentListCommand = cmd({
138+
command: "list",
139+
describe: "list all available agents",
140+
async handler() {
141+
await Instance.provide({
142+
directory: process.cwd(),
143+
async fn() {
144+
const agents = await Agent.list()
145+
const sortedAgents = agents.sort((a, b) => {
146+
if (a.builtIn !== b.builtIn) {
147+
return a.builtIn ? -1 : 1
148+
}
149+
return a.name.localeCompare(b.name)
150+
})
151+
152+
for (const agent of sortedAgents) {
153+
process.stdout.write(`${agent.name} (${agent.mode})${EOL}`)
154+
}
155+
},
156+
})
157+
},
158+
})
159+
136160
export const AgentCommand = cmd({
137161
command: "agent",
138162
describe: "manage agents",
139-
builder: (yargs) => yargs.command(AgentCreateCommand).demandCommand(),
163+
builder: (yargs) => yargs.command(AgentCreateCommand).command(AgentListCommand).demandCommand(),
140164
async handler() {},
141165
})

0 commit comments

Comments
 (0)