diff options
| author | opencode-agent[bot] <219766164+opencode-agent[bot]@users.noreply.github.com> | 2025-11-18 13:25:53 -0600 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-11-18 13:25:53 -0600 |
| commit | 37d5099728613f73edf773d0ea3b88c97a124206 (patch) | |
| tree | af315ede69b5349251d36f91f17f1701d6059c05 /packages | |
| parent | d45fc030b281f8a20cefd053be5f2489ead3205c (diff) | |
| download | opencode-37d5099728613f73edf773d0ea3b88c97a124206.tar.gz opencode-37d5099728613f73edf773d0ea3b88c97a124206.zip | |
Added `opencode agent list` command to show all available agents with details. (#4446)
Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com>
Co-authored-by: rekram1-node <[email protected]>
Co-authored-by: Aiden Cline <[email protected]>
Diffstat (limited to 'packages')
| -rw-r--r-- | packages/opencode/src/cli/cmd/agent.ts | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/packages/opencode/src/cli/cmd/agent.ts b/packages/opencode/src/cli/cmd/agent.ts index 54f873f9c..a774c6d02 100644 --- a/packages/opencode/src/cli/cmd/agent.ts +++ b/packages/opencode/src/cli/cmd/agent.ts @@ -6,6 +6,7 @@ import { Agent } from "../../agent/agent" import path from "path" import matter from "gray-matter" import { Instance } from "../../project/instance" +import { EOL } from "os" const AgentCreateCommand = cmd({ command: "create", @@ -133,9 +134,32 @@ const AgentCreateCommand = cmd({ }, }) +const AgentListCommand = cmd({ + command: "list", + describe: "list all available agents", + async handler() { + await Instance.provide({ + directory: process.cwd(), + async fn() { + const agents = await Agent.list() + 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) { + process.stdout.write(`${agent.name} (${agent.mode})${EOL}`) + } + }, + }) + }, +}) + 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() {}, }) |
