opencode-agents 1.1.1 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-agents",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "description": "CLI for managing AI coding agents",
5
5
  "type": "module",
6
6
  "bin": {
@@ -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, renderTree, renderSkillCard, success, error } 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
- // 步骤 1: 获取源码
94
- p.log.step(pc.cyan(`Source: ${pc.dim(`https://github.com/${source}.git`)}`));
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,30 +100,34 @@ 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('Repository cloned');
103
+ s.stop(`${pc.green('✓')} Repository cloned`);
103
104
  } catch (err) {
104
- s.stop('Failed to clone repository');
105
- error(`Failed to fetch source: ${err instanceof Error ? err.message : String(err)}`);
105
+ s.stop(`${pc.red('✗')} Failed to clone repository`);
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(`Found ${pc.green(String(agents.length))} agent(s)`);
117
+ s.stop(`${pc.green('✓')} Found ${agents.length} agent(s)`);
115
118
  } catch (err) {
116
- s.stop('Failed to discover agents');
117
- error(`Failed to discover agents: ${err instanceof Error ? err.message : String(err)}`);
119
+ s.stop(`${pc.red('✗')} Failed to discover agents`);
120
+ p.log.error(`Failed to discover agents: ${err instanceof Error ? err.message : String(err)}`);
118
121
  process.exit(1);
119
122
  }
120
123
 
121
124
  if (agents.length === 0) {
122
- error('No agents found in the source');
125
+ p.log.error('No agents found in the source');
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,18 @@ export async function addCommand(source: string, options: AddCommandOptions): Pr
136
141
  process.exit(0);
137
142
  }
138
143
 
139
- // 显示选中的 agents
140
- console.log();
141
- for (const agent of selectedAgents) {
142
- renderSkillCard(
143
- agent.agent.name || basename(agent.path, '.md'),
144
- agent.agent.description || 'No description available',
145
- 0
146
- );
147
- }
144
+ // 显示选中的 agents - 作为树的分支
145
+ console.log(`${S_BAR} ${S_BRANCH} ${pc.dim('Selected:')}`);
146
+ selectedAgents.forEach((agent, index) => {
147
+ const isLast = index === selectedAgents.length - 1;
148
+ const prefix = isLast ? S_BRANCH_END : S_BRANCH;
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
+ });
148
152
 
149
153
  // 步骤 4: 安装
150
- s.start(`Installing ${selectedAgents.length} agent(s)...`);
154
+ console.log(S_BAR);
155
+ s.start('Installing agents...');
151
156
 
152
157
  try {
153
158
  let platforms: AgentPlatform[];
@@ -171,17 +176,15 @@ export async function addCommand(source: string, options: AddCommandOptions): Pr
171
176
 
172
177
  await installAgent(installOptions);
173
178
 
174
- s.stop(pc.green(`Successfully installed ${selectedAgents.length} agent(s)`));
179
+ s.stop(`${pc.green('✓')} Successfully installed ${selectedAgents.length} agent(s)`);
175
180
 
176
181
  console.log();
177
- success('Installation complete!');
178
- console.log();
179
- console.log(pc.dim(' Try:'));
180
- console.log(pc.dim(` npx opencode-agents list`));
182
+ console.log(pc.dim(' Next steps:'));
183
+ console.log(pc.dim(` npx opencode-agents list View installed agents`));
181
184
  console.log();
182
185
  } catch (err) {
183
- s.stop('Installation failed');
184
- error(`Failed to install agent: ${err instanceof Error ? err.message : String(err)}`);
186
+ s.stop(`${pc.red('✗')} Installation failed`);
187
+ p.log.error(`Failed to install agent: ${err instanceof Error ? err.message : String(err)}`);
185
188
  process.exit(1);
186
189
  } finally {
187
190
  if (existsSync(tempDir) && tempDir.startsWith(tmpdir())) {
@@ -32,24 +32,24 @@ export async function listCommand(options: ListCommandOptions): Promise<void> {
32
32
 
33
33
  hasAnyAgents = true;
34
34
 
35
- console.log(pc.bold(pc.cyan(`${platform} agents`)));
35
+ console.log(pc.bold(pc.cyan(`◆ ${platform} agents`)));
36
36
  console.log();
37
37
 
38
38
  // 项目级别
39
39
  if (projectAgents.length > 0) {
40
- console.log(` ${S_BRANCH} ${pc.dim('Project')} ${pc.dim('(./.opencode/agents/)')}`);
40
+ console.log(` ${globalAgents.length > 0 ? S_BRANCH : S_BRANCH_END} ${pc.dim('Project')} ${pc.dim('(./.opencode/agents/)')}`);
41
41
 
42
42
  projectAgents.forEach((agent, index) => {
43
- const isLast = index === projectAgents.length - 1 && globalAgents.length === 0;
43
+ const isLast = index === projectAgents.length - 1;
44
44
  const prefix = isLast ? S_BRANCH_END : S_BRANCH;
45
45
 
46
46
  const name = agent.agent.name || agent.path.split(/[/\\]/).pop()?.replace('.md', '') || 'unknown';
47
47
  const mode = agent.agent.mode || 'subagent';
48
48
 
49
- console.log(` ${S_BAR} ${prefix} ${S_BULLET} ${pc.bold(name)} ${pc.dim(`[${mode}]`)}`);
49
+ console.log(` ${globalAgents.length > 0 ? S_BAR : ' '} ${prefix} ${S_BULLET} ${pc.bold(name)} ${pc.dim(`[${mode}]`)}`);
50
50
 
51
51
  if (agent.agent.description) {
52
- console.log(` ${S_BAR} ${isLast ? ' ' : `${S_BAR} `} ${pc.dim(agent.agent.description)}`);
52
+ console.log(` ${globalAgents.length > 0 ? S_BAR : ' '} ${isLast ? ' ' : `${S_BAR} `} ${pc.dim(agent.agent.description)}`);
53
53
  }
54
54
  });
55
55
 
@@ -58,7 +58,7 @@ export async function listCommand(options: ListCommandOptions): Promise<void> {
58
58
 
59
59
  // 全局级别
60
60
  if (globalAgents.length > 0) {
61
- console.log(` ${projectAgents.length > 0 ? S_BRANCH : S_BRANCH_END} ${pc.dim('Global')} ${pc.dim('(~/.config/opencode/agents/)')}`);
61
+ console.log(` ${S_BRANCH_END} ${pc.dim('Global')} ${pc.dim('(~/.config/opencode/agents/)')}`);
62
62
 
63
63
  globalAgents.forEach((agent, index) => {
64
64
  const isLast = index === globalAgents.length - 1;
@@ -67,10 +67,10 @@ export async function listCommand(options: ListCommandOptions): Promise<void> {
67
67
  const name = agent.agent.name || agent.path.split(/[/\\]/).pop()?.replace('.md', '') || 'unknown';
68
68
  const mode = agent.agent.mode || 'subagent';
69
69
 
70
- console.log(` ${projectAgents.length > 0 ? S_BAR : ' '} ${prefix} ${S_BULLET} ${pc.bold(name)} ${pc.dim(`[${mode}]`)}`);
70
+ console.log(` ${prefix} ${S_BULLET} ${pc.bold(name)} ${pc.dim(`[${mode}]`)}`);
71
71
 
72
72
  if (agent.agent.description) {
73
- console.log(` ${projectAgents.length > 0 ? S_BAR : ' '} ${isLast ? ' ' : `${S_BAR} `} ${pc.dim(agent.agent.description)}`);
73
+ console.log(` ${isLast ? ' ' : `${S_BAR} `} ${pc.dim(agent.agent.description)}`);
74
74
  }
75
75
  });
76
76
 
@@ -81,7 +81,7 @@ export async function listCommand(options: ListCommandOptions): Promise<void> {
81
81
  if (!hasAnyAgents) {
82
82
  p.log.info(pc.dim('No agents installed'));
83
83
  console.log();
84
- console.log(pc.dim(' Try:'));
84
+ console.log(pc.dim(' To install an agent:'));
85
85
  console.log(pc.dim(` npx opencode-agents add <repo>`));
86
86
  console.log();
87
87
  }
@@ -11,8 +11,6 @@ import type { AgentPlatform, AgentFile, InstallOptions } from '../types/index.js
11
11
  export async function installAgent(options: InstallOptions): Promise<void> {
12
12
  const { source, sourcePath, global, platforms, agentName, copy, selectedAgents } = options;
13
13
 
14
- logger.info(`Installing agent from: ${source}`);
15
-
16
14
  let tempDir: string;
17
15
  let agents: AgentFile[];
18
16
 
@@ -53,7 +51,6 @@ export async function installAgent(options: InstallOptions): Promise<void> {
53
51
  } else {
54
52
  copyFileSync(sourcePath, finalPath);
55
53
  }
56
- logger.success(`Copied agent "${name}" to ${finalPath}`);
57
54
  }
58
55
  }
59
56
  }