opencode-agents 1.1.2 → 1.1.3
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 +13 -11
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
- package/src/commands/add.ts +18 -14
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, S_BAR, S_BRANCH, S_BRANCH_END, S_BULLET } from '../utils/ui.js';
|
|
11
|
+
import { showLogo, S_BAR, S_BRANCH, S_BRANCH_END, S_BULLET, S_STEP_ACTIVE } from '../utils/ui.js';
|
|
12
12
|
|
|
13
13
|
interface AddCommandOptions {
|
|
14
14
|
global: boolean | undefined;
|
|
@@ -90,8 +90,9 @@ export async function addCommand(source: string, options: AddCommandOptions): Pr
|
|
|
90
90
|
isGlobal = await promptInstallLocation();
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
//
|
|
94
|
-
|
|
93
|
+
// 使用统一的树状结构
|
|
94
|
+
console.log(`${S_STEP_ACTIVE} ${pc.cyan('Source:')} ${pc.dim(`https://github.com/${source}.git`)}`);
|
|
95
|
+
console.log(S_BAR);
|
|
95
96
|
|
|
96
97
|
const s = p.spinner();
|
|
97
98
|
s.start('Cloning repository...');
|
|
@@ -99,21 +100,23 @@ export async function addCommand(source: string, options: AddCommandOptions): Pr
|
|
|
99
100
|
let tempDir: string;
|
|
100
101
|
try {
|
|
101
102
|
tempDir = await fetchSource(source);
|
|
102
|
-
s.stop(pc.green('✓ Repository cloned
|
|
103
|
+
s.stop(`${pc.green('✓')} Repository cloned`);
|
|
103
104
|
} catch (err) {
|
|
104
|
-
s.stop(pc.red('✗ Failed to clone repository
|
|
105
|
+
s.stop(`${pc.red('✗')} Failed to clone repository`);
|
|
105
106
|
p.log.error(`Failed to fetch source: ${err instanceof Error ? err.message : String(err)}`);
|
|
106
107
|
process.exit(1);
|
|
107
108
|
}
|
|
108
109
|
|
|
110
|
+
console.log(S_BAR);
|
|
111
|
+
|
|
109
112
|
// 步骤 2: 发现 agents
|
|
110
113
|
s.start('Discovering agents...');
|
|
111
114
|
let agents: AgentFile[];
|
|
112
115
|
try {
|
|
113
116
|
agents = await discoverFromDirectory(tempDir);
|
|
114
|
-
s.stop(pc.green(
|
|
117
|
+
s.stop(`${pc.green('✓')} Found ${agents.length} agent(s)`);
|
|
115
118
|
} catch (err) {
|
|
116
|
-
s.stop(pc.red('✗ Failed to discover agents
|
|
119
|
+
s.stop(`${pc.red('✗')} Failed to discover agents`);
|
|
117
120
|
p.log.error(`Failed to discover agents: ${err instanceof Error ? err.message : String(err)}`);
|
|
118
121
|
process.exit(1);
|
|
119
122
|
}
|
|
@@ -123,6 +126,8 @@ export async function addCommand(source: string, options: AddCommandOptions): Pr
|
|
|
123
126
|
process.exit(1);
|
|
124
127
|
}
|
|
125
128
|
|
|
129
|
+
console.log(S_BAR);
|
|
130
|
+
|
|
126
131
|
// 步骤 3: 选择 agents
|
|
127
132
|
let selectedAgents: AgentFile[];
|
|
128
133
|
if (options.yes) {
|
|
@@ -136,18 +141,17 @@ export async function addCommand(source: string, options: AddCommandOptions): Pr
|
|
|
136
141
|
process.exit(0);
|
|
137
142
|
}
|
|
138
143
|
|
|
139
|
-
// 显示选中的 agents -
|
|
140
|
-
console.log();
|
|
141
|
-
console.log(pc.dim(` ${S_BRANCH} Selected agents:`));
|
|
144
|
+
// 显示选中的 agents - 作为树的分支
|
|
145
|
+
console.log(`${S_BAR} ${S_BRANCH} ${pc.dim('Selected:')}`);
|
|
142
146
|
selectedAgents.forEach((agent, index) => {
|
|
143
147
|
const isLast = index === selectedAgents.length - 1;
|
|
144
148
|
const prefix = isLast ? S_BRANCH_END : S_BRANCH;
|
|
145
149
|
const name = agent.agent.name || basename(agent.path, '.md');
|
|
146
|
-
console.log(
|
|
150
|
+
console.log(`${S_BAR} ${isLast ? ' ' : S_BAR} ${prefix} ${S_BULLET} ${pc.bold(name)}`);
|
|
147
151
|
});
|
|
148
|
-
console.log();
|
|
149
152
|
|
|
150
153
|
// 步骤 4: 安装
|
|
154
|
+
console.log(S_BAR);
|
|
151
155
|
s.start('Installing agents...');
|
|
152
156
|
|
|
153
157
|
try {
|
|
@@ -172,14 +176,14 @@ export async function addCommand(source: string, options: AddCommandOptions): Pr
|
|
|
172
176
|
|
|
173
177
|
await installAgent(installOptions);
|
|
174
178
|
|
|
175
|
-
s.stop(pc.green(
|
|
179
|
+
s.stop(`${pc.green('✓')} Successfully installed ${selectedAgents.length} agent(s)`);
|
|
176
180
|
|
|
177
181
|
console.log();
|
|
178
182
|
console.log(pc.dim(' Next steps:'));
|
|
179
183
|
console.log(pc.dim(` npx opencode-agents list View installed agents`));
|
|
180
184
|
console.log();
|
|
181
185
|
} catch (err) {
|
|
182
|
-
s.stop(pc.red('✗ Installation failed
|
|
186
|
+
s.stop(`${pc.red('✗')} Installation failed`);
|
|
183
187
|
p.log.error(`Failed to install agent: ${err instanceof Error ? err.message : String(err)}`);
|
|
184
188
|
process.exit(1);
|
|
185
189
|
} finally {
|