mirror of
https://github.com/sst/opencode.git
synced 2025-12-23 10:11:41 +00:00
Added opencode agent list command to show all available agents with details.
Co-authored-by: rekram1-node <rekram1-node@users.noreply.github.com>
This commit is contained in:
parent
ce6436280a
commit
092cb0509f
1 changed files with 45 additions and 1 deletions
|
|
@ -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() {},
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue