opencode-agents 1.1.0 → 1.1.2

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.0",
3
+ "version": "1.1.2",
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 } from '../utils/ui.js';
12
12
 
13
13
  interface AddCommandOptions {
14
14
  global: boolean | undefined;
@@ -99,10 +99,10 @@ export async function addCommand(source: string, options: AddCommandOptions): Pr
99
99
  let tempDir: string;
100
100
  try {
101
101
  tempDir = await fetchSource(source);
102
- s.stop('Repository cloned');
102
+ s.stop(pc.green('Repository cloned'));
103
103
  } catch (err) {
104
- s.stop('Failed to clone repository');
105
- error(`Failed to fetch source: ${err instanceof Error ? err.message : String(err)}`);
104
+ s.stop(pc.red('Failed to clone repository'));
105
+ p.log.error(`Failed to fetch source: ${err instanceof Error ? err.message : String(err)}`);
106
106
  process.exit(1);
107
107
  }
108
108
 
@@ -111,15 +111,15 @@ export async function addCommand(source: string, options: AddCommandOptions): Pr
111
111
  let agents: AgentFile[];
112
112
  try {
113
113
  agents = await discoverFromDirectory(tempDir);
114
- s.stop(`Found ${pc.green(String(agents.length))} agent(s)`);
114
+ s.stop(pc.green(`✓ Found ${agents.length} agent(s)`));
115
115
  } catch (err) {
116
- s.stop('Failed to discover agents');
117
- error(`Failed to discover agents: ${err instanceof Error ? err.message : String(err)}`);
116
+ s.stop(pc.red('Failed to discover agents'));
117
+ p.log.error(`Failed to discover agents: ${err instanceof Error ? err.message : String(err)}`);
118
118
  process.exit(1);
119
119
  }
120
120
 
121
121
  if (agents.length === 0) {
122
- error('No agents found in the source');
122
+ p.log.error('No agents found in the source');
123
123
  process.exit(1);
124
124
  }
125
125
 
@@ -136,18 +136,19 @@ export async function addCommand(source: string, options: AddCommandOptions): Pr
136
136
  process.exit(0);
137
137
  }
138
138
 
139
- // 显示选中的 agents
139
+ // 显示选中的 agents - 简洁的树状结构
140
+ console.log();
141
+ console.log(pc.dim(` ${S_BRANCH} Selected agents:`));
142
+ selectedAgents.forEach((agent, index) => {
143
+ const isLast = index === selectedAgents.length - 1;
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
+ });
140
148
  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
- }
148
149
 
149
150
  // 步骤 4: 安装
150
- s.start(`Installing ${selectedAgents.length} agent(s)...`);
151
+ s.start('Installing agents...');
151
152
 
152
153
  try {
153
154
  let platforms: AgentPlatform[];
@@ -171,17 +172,15 @@ export async function addCommand(source: string, options: AddCommandOptions): Pr
171
172
 
172
173
  await installAgent(installOptions);
173
174
 
174
- s.stop(pc.green(`Successfully installed ${selectedAgents.length} agent(s)`));
175
+ s.stop(pc.green(`✓ Successfully installed ${selectedAgents.length} agent(s)`));
175
176
 
176
177
  console.log();
177
- success('Installation complete!');
178
- console.log();
179
- console.log(pc.dim(' Try:'));
180
- console.log(pc.dim(` npx opencode-agents list`));
178
+ console.log(pc.dim(' Next steps:'));
179
+ console.log(pc.dim(` npx opencode-agents list View installed agents`));
181
180
  console.log();
182
181
  } catch (err) {
183
- s.stop('Installation failed');
184
- error(`Failed to install agent: ${err instanceof Error ? err.message : String(err)}`);
182
+ s.stop(pc.red('Installation failed'));
183
+ p.log.error(`Failed to install agent: ${err instanceof Error ? err.message : String(err)}`);
185
184
  process.exit(1);
186
185
  } finally {
187
186
  if (existsSync(tempDir) && tempDir.startsWith(tmpdir())) {
@@ -1,8 +1,8 @@
1
- import chalk from 'chalk';
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
- const scope = options.global ? 'global' : 'project';
21
+ console.log();
22
+
23
+ let hasAnyAgents = false;
22
24
 
23
25
  for (const platform of platforms) {
24
- const agents = listInstalledAgents(platform, options.global);
26
+ const projectAgents = listInstalledAgents(platform, false);
27
+ const globalAgents = listInstalledAgents(platform, true);
25
28
 
26
- if (agents.length === 0) {
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
- for (const agent of agents) {
34
- const name = agent.agent.name || agent.path.split(/[/\\]/).pop()?.replace('.md', '') || 'unknown';
35
- const mode = agent.agent.mode || 'subagent';
36
- const description = agent.agent.description || 'No description';
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(` ${globalAgents.length > 0 ? S_BRANCH : S_BRANCH_END} ${pc.dim('Project')} ${pc.dim('(./.opencode/agents/)')}`);
41
+
42
+ projectAgents.forEach((agent, index) => {
43
+ const isLast = index === projectAgents.length - 1;
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(` ${globalAgents.length > 0 ? S_BAR : ' '} ${prefix} ${S_BULLET} ${pc.bold(name)} ${pc.dim(`[${mode}]`)}`);
50
+
51
+ if (agent.agent.description) {
52
+ console.log(` ${globalAgents.length > 0 ? S_BAR : ' '} ${isLast ? ' ' : `${S_BAR} `} ${pc.dim(agent.agent.description)}`);
53
+ }
54
+ });
37
55
 
38
- console.log(` ${chalk.cyan(name)} ${chalk.gray(`[${mode}]`)}`);
39
- console.log(` ${chalk.dim(description)}\n`);
56
+ console.log();
40
57
  }
58
+
59
+ // 全局级别
60
+ if (globalAgents.length > 0) {
61
+ console.log(` ${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(` ${prefix} ${S_BULLET} ${pc.bold(name)} ${pc.dim(`[${mode}]`)}`);
71
+
72
+ if (agent.agent.description) {
73
+ console.log(` ${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(' To install an agent:'));
85
+ console.log(pc.dim(` npx opencode-agents add <repo>`));
86
+ console.log();
41
87
  }
42
88
  }
@@ -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
  }