opencode-agents 1.1.3 → 1.1.4
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 +57 -46
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
- package/src/commands/add.ts +19 -35
- package/src/commands/list.ts +15 -23
package/package.json
CHANGED
package/src/commands/add.ts
CHANGED
|
@@ -8,7 +8,7 @@ import type { AgentPlatform, InstallOptions, AgentFile } from '../types/index.js
|
|
|
8
8
|
import { basename, join } from 'path';
|
|
9
9
|
import { mkdtempSync } from 'fs';
|
|
10
10
|
import degit from 'degit';
|
|
11
|
-
import { showLogo
|
|
11
|
+
import { showLogo } from '../utils/ui.js';
|
|
12
12
|
|
|
13
13
|
interface AddCommandOptions {
|
|
14
14
|
global: boolean | undefined;
|
|
@@ -39,11 +39,11 @@ async function promptSelectAgents(agents: AgentFile[]): Promise<AgentFile[]> {
|
|
|
39
39
|
const options = agents.map(agent => ({
|
|
40
40
|
value: agent,
|
|
41
41
|
label: agent.agent.name || basename(agent.path, '.md'),
|
|
42
|
-
hint: agent.agent.description?.slice(0, 50)
|
|
42
|
+
hint: agent.agent.description?.slice(0, 50),
|
|
43
43
|
}));
|
|
44
44
|
|
|
45
45
|
const selected = await p.multiselect({
|
|
46
|
-
message: 'Select agents to install
|
|
46
|
+
message: 'Select agents to install:',
|
|
47
47
|
options,
|
|
48
48
|
required: true,
|
|
49
49
|
});
|
|
@@ -90,33 +90,28 @@ export async function addCommand(source: string, options: AddCommandOptions): Pr
|
|
|
90
90
|
isGlobal = await promptInstallLocation();
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
|
|
94
|
-
console.log(`${S_STEP_ACTIVE} ${pc.cyan('Source:')} ${pc.dim(`https://github.com/${source}.git`)}`);
|
|
95
|
-
console.log(S_BAR);
|
|
93
|
+
p.log.step(`Source: ${pc.cyan(`https://github.com/${source}.git`)}`);
|
|
96
94
|
|
|
97
95
|
const s = p.spinner();
|
|
98
|
-
s.start('Cloning repository
|
|
96
|
+
s.start('Cloning repository');
|
|
99
97
|
|
|
100
98
|
let tempDir: string;
|
|
101
99
|
try {
|
|
102
100
|
tempDir = await fetchSource(source);
|
|
103
|
-
s.stop(
|
|
101
|
+
s.stop('Repository cloned');
|
|
104
102
|
} catch (err) {
|
|
105
|
-
s.stop(
|
|
103
|
+
s.stop('Failed to clone repository');
|
|
106
104
|
p.log.error(`Failed to fetch source: ${err instanceof Error ? err.message : String(err)}`);
|
|
107
105
|
process.exit(1);
|
|
108
106
|
}
|
|
109
107
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
// 步骤 2: 发现 agents
|
|
113
|
-
s.start('Discovering agents...');
|
|
108
|
+
s.start('Discovering agents');
|
|
114
109
|
let agents: AgentFile[];
|
|
115
110
|
try {
|
|
116
111
|
agents = await discoverFromDirectory(tempDir);
|
|
117
|
-
s.stop(
|
|
112
|
+
s.stop(`Found ${pc.green(String(agents.length))} agent(s)`);
|
|
118
113
|
} catch (err) {
|
|
119
|
-
s.stop(
|
|
114
|
+
s.stop('Failed to discover agents');
|
|
120
115
|
p.log.error(`Failed to discover agents: ${err instanceof Error ? err.message : String(err)}`);
|
|
121
116
|
process.exit(1);
|
|
122
117
|
}
|
|
@@ -126,9 +121,6 @@ export async function addCommand(source: string, options: AddCommandOptions): Pr
|
|
|
126
121
|
process.exit(1);
|
|
127
122
|
}
|
|
128
123
|
|
|
129
|
-
console.log(S_BAR);
|
|
130
|
-
|
|
131
|
-
// 步骤 3: 选择 agents
|
|
132
124
|
let selectedAgents: AgentFile[];
|
|
133
125
|
if (options.yes) {
|
|
134
126
|
selectedAgents = agents;
|
|
@@ -141,18 +133,13 @@ export async function addCommand(source: string, options: AddCommandOptions): Pr
|
|
|
141
133
|
process.exit(0);
|
|
142
134
|
}
|
|
143
135
|
|
|
144
|
-
// 显示选中的 agents
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
const name = agent.agent.name || basename(agent.path, '.md');
|
|
150
|
-
console.log(`${S_BAR} ${isLast ? ' ' : S_BAR} ${prefix} ${S_BULLET} ${pc.bold(name)}`);
|
|
151
|
-
});
|
|
136
|
+
// 显示选中的 agents
|
|
137
|
+
const selectedList = selectedAgents.map(agent =>
|
|
138
|
+
` ${pc.bold(agent.agent.name || basename(agent.path, '.md'))}`
|
|
139
|
+
).join('\n');
|
|
140
|
+
p.note(selectedList, 'Selected agents');
|
|
152
141
|
|
|
153
|
-
|
|
154
|
-
console.log(S_BAR);
|
|
155
|
-
s.start('Installing agents...');
|
|
142
|
+
s.start(`Installing ${selectedAgents.length} agent(s)`);
|
|
156
143
|
|
|
157
144
|
try {
|
|
158
145
|
let platforms: AgentPlatform[];
|
|
@@ -176,14 +163,11 @@ export async function addCommand(source: string, options: AddCommandOptions): Pr
|
|
|
176
163
|
|
|
177
164
|
await installAgent(installOptions);
|
|
178
165
|
|
|
179
|
-
s.stop(
|
|
166
|
+
s.stop(pc.green(`Successfully installed ${selectedAgents.length} agent(s)`));
|
|
180
167
|
|
|
181
|
-
|
|
182
|
-
console.log(pc.dim(' Next steps:'));
|
|
183
|
-
console.log(pc.dim(` npx opencode-agents list View installed agents`));
|
|
184
|
-
console.log();
|
|
168
|
+
p.outro('Installation complete! Run `npx opencode-agents list` to see installed agents.');
|
|
185
169
|
} catch (err) {
|
|
186
|
-
s.stop(
|
|
170
|
+
s.stop('Installation failed');
|
|
187
171
|
p.log.error(`Failed to install agent: ${err instanceof Error ? err.message : String(err)}`);
|
|
188
172
|
process.exit(1);
|
|
189
173
|
} finally {
|
package/src/commands/list.ts
CHANGED
|
@@ -2,7 +2,6 @@ import * as p from '@clack/prompts';
|
|
|
2
2
|
import pc from 'picocolors';
|
|
3
3
|
import { listInstalledAgents } from '../core/installer.js';
|
|
4
4
|
import type { AgentPlatform } from '../types/index.js';
|
|
5
|
-
import { S_BAR, S_BRANCH, S_BRANCH_END, S_BULLET } from '../utils/ui.js';
|
|
6
5
|
|
|
7
6
|
interface ListCommandOptions {
|
|
8
7
|
global: boolean;
|
|
@@ -18,8 +17,6 @@ export async function listCommand(options: ListCommandOptions): Promise<void> {
|
|
|
18
17
|
platforms = ['opencode'];
|
|
19
18
|
}
|
|
20
19
|
|
|
21
|
-
console.log();
|
|
22
|
-
|
|
23
20
|
let hasAnyAgents = false;
|
|
24
21
|
|
|
25
22
|
for (const platform of platforms) {
|
|
@@ -32,57 +29,52 @@ export async function listCommand(options: ListCommandOptions): Promise<void> {
|
|
|
32
29
|
|
|
33
30
|
hasAnyAgents = true;
|
|
34
31
|
|
|
35
|
-
console.log(
|
|
32
|
+
console.log();
|
|
33
|
+
console.log(pc.bold(pc.cyan(`${platform} agents`)));
|
|
36
34
|
console.log();
|
|
37
35
|
|
|
38
36
|
// 项目级别
|
|
39
37
|
if (projectAgents.length > 0) {
|
|
40
|
-
console.log(
|
|
38
|
+
console.log(pc.dim('Project (./.opencode/agents/)'));
|
|
41
39
|
|
|
42
|
-
|
|
43
|
-
const isLast = index === projectAgents.length - 1;
|
|
44
|
-
const prefix = isLast ? S_BRANCH_END : S_BRANCH;
|
|
45
|
-
|
|
40
|
+
for (const agent of projectAgents) {
|
|
46
41
|
const name = agent.agent.name || agent.path.split(/[/\\]/).pop()?.replace('.md', '') || 'unknown';
|
|
47
42
|
const mode = agent.agent.mode || 'subagent';
|
|
48
43
|
|
|
49
|
-
console.log(` ${
|
|
44
|
+
console.log(` ${pc.bold(name)} ${pc.dim(`[${mode}]`)}`);
|
|
50
45
|
|
|
51
46
|
if (agent.agent.description) {
|
|
52
|
-
console.log(`
|
|
47
|
+
console.log(` ${pc.dim(agent.agent.description)}`);
|
|
53
48
|
}
|
|
54
|
-
}
|
|
49
|
+
}
|
|
55
50
|
|
|
56
51
|
console.log();
|
|
57
52
|
}
|
|
58
53
|
|
|
59
54
|
// 全局级别
|
|
60
55
|
if (globalAgents.length > 0) {
|
|
61
|
-
console.log(
|
|
56
|
+
console.log(pc.dim('Global (~/.config/opencode/agents/)'));
|
|
62
57
|
|
|
63
|
-
|
|
64
|
-
const isLast = index === globalAgents.length - 1;
|
|
65
|
-
const prefix = isLast ? S_BRANCH_END : S_BRANCH;
|
|
66
|
-
|
|
58
|
+
for (const agent of globalAgents) {
|
|
67
59
|
const name = agent.agent.name || agent.path.split(/[/\\]/).pop()?.replace('.md', '') || 'unknown';
|
|
68
60
|
const mode = agent.agent.mode || 'subagent';
|
|
69
61
|
|
|
70
|
-
console.log(`
|
|
62
|
+
console.log(` ${pc.bold(name)} ${pc.dim(`[${mode}]`)}`);
|
|
71
63
|
|
|
72
64
|
if (agent.agent.description) {
|
|
73
|
-
console.log(` ${
|
|
65
|
+
console.log(` ${pc.dim(agent.agent.description)}`);
|
|
74
66
|
}
|
|
75
|
-
}
|
|
67
|
+
}
|
|
76
68
|
|
|
77
69
|
console.log();
|
|
78
70
|
}
|
|
79
71
|
}
|
|
80
72
|
|
|
81
73
|
if (!hasAnyAgents) {
|
|
82
|
-
p.log.info(
|
|
74
|
+
p.log.info('No agents installed');
|
|
83
75
|
console.log();
|
|
84
|
-
console.log(pc.dim('
|
|
85
|
-
console.log(pc.dim(`
|
|
76
|
+
console.log(pc.dim('To install an agent:'));
|
|
77
|
+
console.log(pc.dim(` npx opencode-agents add <repo>`));
|
|
86
78
|
console.log();
|
|
87
79
|
}
|
|
88
80
|
}
|