opencode-agents 1.1.2 → 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 -44
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
- package/src/commands/add.ts +19 -31
- 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,30 +90,28 @@ export async function addCommand(source: string, options: AddCommandOptions): Pr
|
|
|
90
90
|
isGlobal = await promptInstallLocation();
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
|
|
94
|
-
p.log.step(pc.cyan(`Source: ${pc.dim(`https://github.com/${source}.git`)}`));
|
|
93
|
+
p.log.step(`Source: ${pc.cyan(`https://github.com/${source}.git`)}`);
|
|
95
94
|
|
|
96
95
|
const s = p.spinner();
|
|
97
|
-
s.start('Cloning repository
|
|
96
|
+
s.start('Cloning repository');
|
|
98
97
|
|
|
99
98
|
let tempDir: string;
|
|
100
99
|
try {
|
|
101
100
|
tempDir = await fetchSource(source);
|
|
102
|
-
s.stop(
|
|
101
|
+
s.stop('Repository cloned');
|
|
103
102
|
} catch (err) {
|
|
104
|
-
s.stop(
|
|
103
|
+
s.stop('Failed to clone repository');
|
|
105
104
|
p.log.error(`Failed to fetch source: ${err instanceof Error ? err.message : String(err)}`);
|
|
106
105
|
process.exit(1);
|
|
107
106
|
}
|
|
108
107
|
|
|
109
|
-
|
|
110
|
-
s.start('Discovering agents...');
|
|
108
|
+
s.start('Discovering agents');
|
|
111
109
|
let agents: AgentFile[];
|
|
112
110
|
try {
|
|
113
111
|
agents = await discoverFromDirectory(tempDir);
|
|
114
|
-
s.stop(pc.green(
|
|
112
|
+
s.stop(`Found ${pc.green(String(agents.length))} agent(s)`);
|
|
115
113
|
} catch (err) {
|
|
116
|
-
s.stop(
|
|
114
|
+
s.stop('Failed to discover agents');
|
|
117
115
|
p.log.error(`Failed to discover agents: ${err instanceof Error ? err.message : String(err)}`);
|
|
118
116
|
process.exit(1);
|
|
119
117
|
}
|
|
@@ -123,7 +121,6 @@ export async function addCommand(source: string, options: AddCommandOptions): Pr
|
|
|
123
121
|
process.exit(1);
|
|
124
122
|
}
|
|
125
123
|
|
|
126
|
-
// 步骤 3: 选择 agents
|
|
127
124
|
let selectedAgents: AgentFile[];
|
|
128
125
|
if (options.yes) {
|
|
129
126
|
selectedAgents = agents;
|
|
@@ -136,19 +133,13 @@ export async function addCommand(source: string, options: AddCommandOptions): Pr
|
|
|
136
133
|
process.exit(0);
|
|
137
134
|
}
|
|
138
135
|
|
|
139
|
-
// 显示选中的 agents
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
const prefix = isLast ? S_BRANCH_END : S_BRANCH;
|
|
145
|
-
const name = agent.agent.name || basename(agent.path, '.md');
|
|
146
|
-
console.log(` ${S_BAR} ${prefix} ${S_BULLET} ${pc.bold(name)}`);
|
|
147
|
-
});
|
|
148
|
-
console.log();
|
|
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');
|
|
149
141
|
|
|
150
|
-
|
|
151
|
-
s.start('Installing agents...');
|
|
142
|
+
s.start(`Installing ${selectedAgents.length} agent(s)`);
|
|
152
143
|
|
|
153
144
|
try {
|
|
154
145
|
let platforms: AgentPlatform[];
|
|
@@ -172,14 +163,11 @@ export async function addCommand(source: string, options: AddCommandOptions): Pr
|
|
|
172
163
|
|
|
173
164
|
await installAgent(installOptions);
|
|
174
165
|
|
|
175
|
-
s.stop(pc.green(
|
|
166
|
+
s.stop(pc.green(`Successfully installed ${selectedAgents.length} agent(s)`));
|
|
176
167
|
|
|
177
|
-
|
|
178
|
-
console.log(pc.dim(' Next steps:'));
|
|
179
|
-
console.log(pc.dim(` npx opencode-agents list View installed agents`));
|
|
180
|
-
console.log();
|
|
168
|
+
p.outro('Installation complete! Run `npx opencode-agents list` to see installed agents.');
|
|
181
169
|
} catch (err) {
|
|
182
|
-
s.stop(
|
|
170
|
+
s.stop('Installation failed');
|
|
183
171
|
p.log.error(`Failed to install agent: ${err instanceof Error ? err.message : String(err)}`);
|
|
184
172
|
process.exit(1);
|
|
185
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
|
}
|