opencode-agents 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +43 -14
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
- package/src/commands/list.ts +61 -15
package/package.json
CHANGED
package/src/commands/list.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as p from '@clack/prompts';
|
|
2
|
+
import pc from 'picocolors';
|
|
2
3
|
import { listInstalledAgents } from '../core/installer.js';
|
|
3
|
-
import { detectPlatforms } from '../utils/filesystem.js';
|
|
4
|
-
import { logger } from '../utils/logger.js';
|
|
5
4
|
import type { AgentPlatform } from '../types/index.js';
|
|
5
|
+
import { S_BAR, S_BRANCH, S_BRANCH_END, S_BULLET } from '../utils/ui.js';
|
|
6
6
|
|
|
7
7
|
interface ListCommandOptions {
|
|
8
8
|
global: boolean;
|
|
@@ -18,25 +18,71 @@ export async function listCommand(options: ListCommandOptions): Promise<void> {
|
|
|
18
18
|
platforms = ['opencode'];
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
console.log();
|
|
22
|
+
|
|
23
|
+
let hasAnyAgents = false;
|
|
22
24
|
|
|
23
25
|
for (const platform of platforms) {
|
|
24
|
-
const
|
|
26
|
+
const projectAgents = listInstalledAgents(platform, false);
|
|
27
|
+
const globalAgents = listInstalledAgents(platform, true);
|
|
25
28
|
|
|
26
|
-
if (
|
|
27
|
-
logger.info(`No agents found for ${platform} (${scope})`);
|
|
29
|
+
if (projectAgents.length === 0 && globalAgents.length === 0) {
|
|
28
30
|
continue;
|
|
29
31
|
}
|
|
30
|
-
|
|
31
|
-
console.log(chalk.bold(`\n${platform} agents (${scope}):\n`));
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
hasAnyAgents = true;
|
|
34
|
+
|
|
35
|
+
console.log(pc.bold(pc.cyan(`${platform} agents`)));
|
|
36
|
+
console.log();
|
|
37
|
+
|
|
38
|
+
// 项目级别
|
|
39
|
+
if (projectAgents.length > 0) {
|
|
40
|
+
console.log(` ${S_BRANCH} ${pc.dim('Project')} ${pc.dim('(./.opencode/agents/)')}`);
|
|
41
|
+
|
|
42
|
+
projectAgents.forEach((agent, index) => {
|
|
43
|
+
const isLast = index === projectAgents.length - 1 && globalAgents.length === 0;
|
|
44
|
+
const prefix = isLast ? S_BRANCH_END : S_BRANCH;
|
|
45
|
+
|
|
46
|
+
const name = agent.agent.name || agent.path.split(/[/\\]/).pop()?.replace('.md', '') || 'unknown';
|
|
47
|
+
const mode = agent.agent.mode || 'subagent';
|
|
48
|
+
|
|
49
|
+
console.log(` ${S_BAR} ${prefix} ${S_BULLET} ${pc.bold(name)} ${pc.dim(`[${mode}]`)}`);
|
|
50
|
+
|
|
51
|
+
if (agent.agent.description) {
|
|
52
|
+
console.log(` ${S_BAR} ${isLast ? ' ' : `${S_BAR} `} ${pc.dim(agent.agent.description)}`);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
37
55
|
|
|
38
|
-
console.log(
|
|
39
|
-
console.log(` ${chalk.dim(description)}\n`);
|
|
56
|
+
console.log();
|
|
40
57
|
}
|
|
58
|
+
|
|
59
|
+
// 全局级别
|
|
60
|
+
if (globalAgents.length > 0) {
|
|
61
|
+
console.log(` ${projectAgents.length > 0 ? S_BRANCH : S_BRANCH_END} ${pc.dim('Global')} ${pc.dim('(~/.config/opencode/agents/)')}`);
|
|
62
|
+
|
|
63
|
+
globalAgents.forEach((agent, index) => {
|
|
64
|
+
const isLast = index === globalAgents.length - 1;
|
|
65
|
+
const prefix = isLast ? S_BRANCH_END : S_BRANCH;
|
|
66
|
+
|
|
67
|
+
const name = agent.agent.name || agent.path.split(/[/\\]/).pop()?.replace('.md', '') || 'unknown';
|
|
68
|
+
const mode = agent.agent.mode || 'subagent';
|
|
69
|
+
|
|
70
|
+
console.log(` ${projectAgents.length > 0 ? S_BAR : ' '} ${prefix} ${S_BULLET} ${pc.bold(name)} ${pc.dim(`[${mode}]`)}`);
|
|
71
|
+
|
|
72
|
+
if (agent.agent.description) {
|
|
73
|
+
console.log(` ${projectAgents.length > 0 ? S_BAR : ' '} ${isLast ? ' ' : `${S_BAR} `} ${pc.dim(agent.agent.description)}`);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
console.log();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (!hasAnyAgents) {
|
|
82
|
+
p.log.info(pc.dim('No agents installed'));
|
|
83
|
+
console.log();
|
|
84
|
+
console.log(pc.dim(' Try:'));
|
|
85
|
+
console.log(pc.dim(` npx opencode-agents add <repo>`));
|
|
86
|
+
console.log();
|
|
41
87
|
}
|
|
42
88
|
}
|