opencode-agents 1.1.3 → 1.1.5
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 +87 -52
- 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/src/core/discover.ts +14 -9
- package/src/core/installer.ts +3 -1
- package/src/core/parser.ts +33 -2
package/dist/index.js
CHANGED
|
@@ -26036,6 +26036,12 @@ var R2 = { message: (t = [], { symbol: r = import_picocolors.default.gray(d), se
|
|
|
26036
26036
|
var Ne = (t = "", r) => {
|
|
26037
26037
|
(r?.output ?? process.stdout).write(`${import_picocolors.default.gray(x2)} ${import_picocolors.default.red(t)}
|
|
26038
26038
|
|
|
26039
|
+
`);
|
|
26040
|
+
};
|
|
26041
|
+
var Le = (t = "", r) => {
|
|
26042
|
+
(r?.output ?? process.stdout).write(`${import_picocolors.default.gray(d)}
|
|
26043
|
+
${import_picocolors.default.gray(x2)} ${t}
|
|
26044
|
+
|
|
26039
26045
|
`);
|
|
26040
26046
|
};
|
|
26041
26047
|
var Z2 = (t, r) => t.split(`
|
|
@@ -26091,6 +26097,25 @@ ${import_picocolors.default.cyan(x2)}
|
|
|
26091
26097
|
}
|
|
26092
26098
|
} }).prompt();
|
|
26093
26099
|
};
|
|
26100
|
+
var Ge = (t) => import_picocolors.default.dim(t);
|
|
26101
|
+
var ke = (t, r, s) => {
|
|
26102
|
+
const i = { hard: true, trim: false }, a = J2(t, r, i).split(`
|
|
26103
|
+
`), o = a.reduce((n, c) => Math.max(M2(c), n), 0), u = a.map(s).reduce((n, c) => Math.max(M2(c), n), 0), l = r - (u - o);
|
|
26104
|
+
return J2(t, l, i);
|
|
26105
|
+
};
|
|
26106
|
+
var Ve = (t = "", r = "", s) => {
|
|
26107
|
+
const i = s?.output ?? N2.stdout, a = s?.withGuide ?? _.withGuide, o = s?.format ?? Ge, u = ["", ...ke(t, rt(i) - 6, o).split(`
|
|
26108
|
+
`).map(o), ""], l = M2(r), n = Math.max(u.reduce((p, E) => {
|
|
26109
|
+
const $ = M2(E);
|
|
26110
|
+
return $ > p ? $ : p;
|
|
26111
|
+
}, 0), l) + 2, c = u.map((p) => `${import_picocolors.default.gray(d)} ${p}${" ".repeat(n - M2(p))}${import_picocolors.default.gray(d)}`).join(`
|
|
26112
|
+
`), g = a ? `${import_picocolors.default.gray(d)}
|
|
26113
|
+
` : "", F = a ? Wt2 : gt2;
|
|
26114
|
+
i.write(`${g}${import_picocolors.default.green(V)} ${import_picocolors.default.reset(r)} ${import_picocolors.default.gray(rt2.repeat(Math.max(n - l - 1, 1)) + mt2)}
|
|
26115
|
+
${c}
|
|
26116
|
+
${import_picocolors.default.gray(F + rt2.repeat(n + 2) + pt2)}
|
|
26117
|
+
`);
|
|
26118
|
+
};
|
|
26094
26119
|
var Ke = import_picocolors.default.magenta;
|
|
26095
26120
|
var bt2 = ({ indicator: t = "dots", onCancel: r, output: s = process.stdout, cancelMessage: i, errorMessage: a, frames: o = et2 ? ["\u25D2", "\u25D0", "\u25D3", "\u25D1"] : ["\u2022", "o", "O", "0"], delay: u = et2 ? 80 : 120, signal: l, ...n } = {}) => {
|
|
26096
26121
|
const c = ct2();
|
|
@@ -26205,8 +26230,30 @@ import { mkdtempSync } from "fs";
|
|
|
26205
26230
|
|
|
26206
26231
|
// src/core/parser.ts
|
|
26207
26232
|
var import_gray_matter = __toESM(require_gray_matter(), 1);
|
|
26233
|
+
var AGENT_SPECIFIC_FIELDS = [
|
|
26234
|
+
"mode",
|
|
26235
|
+
"model",
|
|
26236
|
+
"temperature",
|
|
26237
|
+
"maxSteps",
|
|
26238
|
+
"color",
|
|
26239
|
+
"trigger",
|
|
26240
|
+
"tools",
|
|
26241
|
+
"permission",
|
|
26242
|
+
"mcp"
|
|
26243
|
+
];
|
|
26244
|
+
function isAgentContent(content) {
|
|
26245
|
+
try {
|
|
26246
|
+
const { data } = (0, import_gray_matter.default)(content);
|
|
26247
|
+
return AGENT_SPECIFIC_FIELDS.some((field) => field in data);
|
|
26248
|
+
} catch {
|
|
26249
|
+
return false;
|
|
26250
|
+
}
|
|
26251
|
+
}
|
|
26208
26252
|
function parseAgentFile(content, path) {
|
|
26209
26253
|
const { data, content: body } = (0, import_gray_matter.default)(content);
|
|
26254
|
+
if (!isAgentContent(content)) {
|
|
26255
|
+
return null;
|
|
26256
|
+
}
|
|
26210
26257
|
if (!data.description) {
|
|
26211
26258
|
throw new Error(`Agent at ${path} is missing required "description" field in frontmatter`);
|
|
26212
26259
|
}
|
|
@@ -26361,7 +26408,6 @@ var SEARCH_DIRECTORIES = [
|
|
|
26361
26408
|
];
|
|
26362
26409
|
var PRIORITY_FILES = [
|
|
26363
26410
|
"AGENTS.md",
|
|
26364
|
-
"SKILL.md",
|
|
26365
26411
|
"AGENT.md"
|
|
26366
26412
|
];
|
|
26367
26413
|
async function discoverFromDirectory(dir) {
|
|
@@ -26376,8 +26422,9 @@ async function discoverFromDirectory(dir) {
|
|
|
26376
26422
|
if (fileName === "README.md") continue;
|
|
26377
26423
|
try {
|
|
26378
26424
|
const content = readFileSync2(file, "utf-8");
|
|
26379
|
-
const
|
|
26380
|
-
|
|
26425
|
+
const result = parseAgentFile(content, file);
|
|
26426
|
+
if (result === null) continue;
|
|
26427
|
+
agents.push(result);
|
|
26381
26428
|
} catch (err) {
|
|
26382
26429
|
continue;
|
|
26383
26430
|
}
|
|
@@ -26388,10 +26435,11 @@ async function discoverFromDirectory(dir) {
|
|
|
26388
26435
|
if (existsSync2(priorityFile)) {
|
|
26389
26436
|
try {
|
|
26390
26437
|
const content = readFileSync2(priorityFile, "utf-8");
|
|
26391
|
-
const
|
|
26392
|
-
|
|
26438
|
+
const result = parseAgentFile(content, priorityFile);
|
|
26439
|
+
if (result === null) continue;
|
|
26440
|
+
const exists = agents.some((a) => a.path === result.path);
|
|
26393
26441
|
if (!exists) {
|
|
26394
|
-
agents.unshift(
|
|
26442
|
+
agents.unshift(result);
|
|
26395
26443
|
}
|
|
26396
26444
|
} catch (err) {
|
|
26397
26445
|
continue;
|
|
@@ -27001,6 +27049,7 @@ function listInstalledAgents(platform, global2) {
|
|
|
27001
27049
|
try {
|
|
27002
27050
|
const content = readFileSync3(file, "utf-8");
|
|
27003
27051
|
const agentFile = parseAgentFile(content, file);
|
|
27052
|
+
if (agentFile === null) continue;
|
|
27004
27053
|
agents.push(agentFile);
|
|
27005
27054
|
} catch (err) {
|
|
27006
27055
|
continue;
|
|
@@ -27117,10 +27166,10 @@ async function promptSelectAgents(agents) {
|
|
|
27117
27166
|
const options2 = agents.map((agent) => ({
|
|
27118
27167
|
value: agent,
|
|
27119
27168
|
label: agent.agent.name || basename4(agent.path, ".md"),
|
|
27120
|
-
hint: agent.agent.description?.slice(0, 50)
|
|
27169
|
+
hint: agent.agent.description?.slice(0, 50)
|
|
27121
27170
|
}));
|
|
27122
27171
|
const selected = await je({
|
|
27123
|
-
message: "Select agents to install
|
|
27172
|
+
message: "Select agents to install:",
|
|
27124
27173
|
options: options2,
|
|
27125
27174
|
required: true
|
|
27126
27175
|
});
|
|
@@ -27157,27 +27206,25 @@ async function addCommand(source, options2) {
|
|
|
27157
27206
|
if (isGlobal === void 0) {
|
|
27158
27207
|
isGlobal = await promptInstallLocation();
|
|
27159
27208
|
}
|
|
27160
|
-
|
|
27161
|
-
console.log(S_BAR);
|
|
27209
|
+
R2.step(`Source: ${import_picocolors3.default.cyan(`https://github.com/${source}.git`)}`);
|
|
27162
27210
|
const s = bt2();
|
|
27163
|
-
s.start("Cloning repository
|
|
27211
|
+
s.start("Cloning repository");
|
|
27164
27212
|
let tempDir;
|
|
27165
27213
|
try {
|
|
27166
27214
|
tempDir = await fetchSource2(source);
|
|
27167
|
-
s.stop(
|
|
27215
|
+
s.stop("Repository cloned");
|
|
27168
27216
|
} catch (err) {
|
|
27169
|
-
s.stop(
|
|
27217
|
+
s.stop("Failed to clone repository");
|
|
27170
27218
|
R2.error(`Failed to fetch source: ${err instanceof Error ? err.message : String(err)}`);
|
|
27171
27219
|
process.exit(1);
|
|
27172
27220
|
}
|
|
27173
|
-
|
|
27174
|
-
s.start("Discovering agents...");
|
|
27221
|
+
s.start("Discovering agents");
|
|
27175
27222
|
let agents;
|
|
27176
27223
|
try {
|
|
27177
27224
|
agents = await discoverFromDirectory(tempDir);
|
|
27178
|
-
s.stop(
|
|
27225
|
+
s.stop(`Found ${import_picocolors3.default.green(String(agents.length))} agent(s)`);
|
|
27179
27226
|
} catch (err) {
|
|
27180
|
-
s.stop(
|
|
27227
|
+
s.stop("Failed to discover agents");
|
|
27181
27228
|
R2.error(`Failed to discover agents: ${err instanceof Error ? err.message : String(err)}`);
|
|
27182
27229
|
process.exit(1);
|
|
27183
27230
|
}
|
|
@@ -27185,7 +27232,6 @@ async function addCommand(source, options2) {
|
|
|
27185
27232
|
R2.error("No agents found in the source");
|
|
27186
27233
|
process.exit(1);
|
|
27187
27234
|
}
|
|
27188
|
-
console.log(S_BAR);
|
|
27189
27235
|
let selectedAgents;
|
|
27190
27236
|
if (options2.yes) {
|
|
27191
27237
|
selectedAgents = agents;
|
|
@@ -27196,15 +27242,11 @@ async function addCommand(source, options2) {
|
|
|
27196
27242
|
Ne("No agents selected, aborting");
|
|
27197
27243
|
process.exit(0);
|
|
27198
27244
|
}
|
|
27199
|
-
|
|
27200
|
-
|
|
27201
|
-
|
|
27202
|
-
|
|
27203
|
-
|
|
27204
|
-
console.log(`${S_BAR} ${isLast ? " " : S_BAR} ${prefix} ${S_BULLET} ${import_picocolors3.default.bold(name)}`);
|
|
27205
|
-
});
|
|
27206
|
-
console.log(S_BAR);
|
|
27207
|
-
s.start("Installing agents...");
|
|
27245
|
+
const selectedList = selectedAgents.map(
|
|
27246
|
+
(agent) => ` ${import_picocolors3.default.bold(agent.agent.name || basename4(agent.path, ".md"))}`
|
|
27247
|
+
).join("\n");
|
|
27248
|
+
Ve(selectedList, "Selected agents");
|
|
27249
|
+
s.start(`Installing ${selectedAgents.length} agent(s)`);
|
|
27208
27250
|
try {
|
|
27209
27251
|
let platforms;
|
|
27210
27252
|
if (options2.agent && options2.agent.length > 0) {
|
|
@@ -27223,13 +27265,10 @@ async function addCommand(source, options2) {
|
|
|
27223
27265
|
selectedAgents
|
|
27224
27266
|
};
|
|
27225
27267
|
await installAgent(installOptions);
|
|
27226
|
-
s.stop(
|
|
27227
|
-
|
|
27228
|
-
console.log(import_picocolors3.default.dim(" Next steps:"));
|
|
27229
|
-
console.log(import_picocolors3.default.dim(` npx opencode-agents list View installed agents`));
|
|
27230
|
-
console.log();
|
|
27268
|
+
s.stop(import_picocolors3.default.green(`Successfully installed ${selectedAgents.length} agent(s)`));
|
|
27269
|
+
Le("Installation complete! Run `npx opencode-agents list` to see installed agents.");
|
|
27231
27270
|
} catch (err) {
|
|
27232
|
-
s.stop(
|
|
27271
|
+
s.stop("Installation failed");
|
|
27233
27272
|
R2.error(`Failed to install agent: ${err instanceof Error ? err.message : String(err)}`);
|
|
27234
27273
|
process.exit(1);
|
|
27235
27274
|
} finally {
|
|
@@ -27248,7 +27287,6 @@ async function listCommand(options2) {
|
|
|
27248
27287
|
} else {
|
|
27249
27288
|
platforms = ["opencode"];
|
|
27250
27289
|
}
|
|
27251
|
-
console.log();
|
|
27252
27290
|
let hasAnyAgents = false;
|
|
27253
27291
|
for (const platform of platforms) {
|
|
27254
27292
|
const projectAgents = listInstalledAgents(platform, false);
|
|
@@ -27257,42 +27295,39 @@ async function listCommand(options2) {
|
|
|
27257
27295
|
continue;
|
|
27258
27296
|
}
|
|
27259
27297
|
hasAnyAgents = true;
|
|
27260
|
-
console.log(
|
|
27298
|
+
console.log();
|
|
27299
|
+
console.log(import_picocolors4.default.bold(import_picocolors4.default.cyan(`${platform} agents`)));
|
|
27261
27300
|
console.log();
|
|
27262
27301
|
if (projectAgents.length > 0) {
|
|
27263
|
-
console.log(
|
|
27264
|
-
|
|
27265
|
-
const isLast = index === projectAgents.length - 1;
|
|
27266
|
-
const prefix = isLast ? S_BRANCH_END : S_BRANCH;
|
|
27302
|
+
console.log(import_picocolors4.default.dim("Project (./.opencode/agents/)"));
|
|
27303
|
+
for (const agent of projectAgents) {
|
|
27267
27304
|
const name = agent.agent.name || agent.path.split(/[/\\]/).pop()?.replace(".md", "") || "unknown";
|
|
27268
27305
|
const mode = agent.agent.mode || "subagent";
|
|
27269
|
-
console.log(` ${
|
|
27306
|
+
console.log(` ${import_picocolors4.default.bold(name)} ${import_picocolors4.default.dim(`[${mode}]`)}`);
|
|
27270
27307
|
if (agent.agent.description) {
|
|
27271
|
-
console.log(`
|
|
27308
|
+
console.log(` ${import_picocolors4.default.dim(agent.agent.description)}`);
|
|
27272
27309
|
}
|
|
27273
|
-
}
|
|
27310
|
+
}
|
|
27274
27311
|
console.log();
|
|
27275
27312
|
}
|
|
27276
27313
|
if (globalAgents.length > 0) {
|
|
27277
|
-
console.log(
|
|
27278
|
-
|
|
27279
|
-
const isLast = index === globalAgents.length - 1;
|
|
27280
|
-
const prefix = isLast ? S_BRANCH_END : S_BRANCH;
|
|
27314
|
+
console.log(import_picocolors4.default.dim("Global (~/.config/opencode/agents/)"));
|
|
27315
|
+
for (const agent of globalAgents) {
|
|
27281
27316
|
const name = agent.agent.name || agent.path.split(/[/\\]/).pop()?.replace(".md", "") || "unknown";
|
|
27282
27317
|
const mode = agent.agent.mode || "subagent";
|
|
27283
|
-
console.log(`
|
|
27318
|
+
console.log(` ${import_picocolors4.default.bold(name)} ${import_picocolors4.default.dim(`[${mode}]`)}`);
|
|
27284
27319
|
if (agent.agent.description) {
|
|
27285
|
-
console.log(` ${
|
|
27320
|
+
console.log(` ${import_picocolors4.default.dim(agent.agent.description)}`);
|
|
27286
27321
|
}
|
|
27287
|
-
}
|
|
27322
|
+
}
|
|
27288
27323
|
console.log();
|
|
27289
27324
|
}
|
|
27290
27325
|
}
|
|
27291
27326
|
if (!hasAnyAgents) {
|
|
27292
|
-
R2.info(
|
|
27327
|
+
R2.info("No agents installed");
|
|
27293
27328
|
console.log();
|
|
27294
|
-
console.log(import_picocolors4.default.dim("
|
|
27295
|
-
console.log(import_picocolors4.default.dim(`
|
|
27329
|
+
console.log(import_picocolors4.default.dim("To install an agent:"));
|
|
27330
|
+
console.log(import_picocolors4.default.dim(` npx opencode-agents add <repo>`));
|
|
27296
27331
|
console.log();
|
|
27297
27332
|
}
|
|
27298
27333
|
}
|