@wix/evalforge-evaluator 0.106.0 → 0.107.0
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/build/index.js
CHANGED
|
@@ -1505,6 +1505,7 @@ async function writeMcpToFilesystem(cwd, mcps) {
|
|
|
1505
1505
|
// src/run-scenario/agents/claude-code/write-sub-agents.ts
|
|
1506
1506
|
var import_promises5 = require("fs/promises");
|
|
1507
1507
|
var import_path6 = require("path");
|
|
1508
|
+
var import_evalforge_github_client3 = require("@wix/evalforge-github-client");
|
|
1508
1509
|
var AGENTS_DIR = ".claude/agents";
|
|
1509
1510
|
function toAgentFilename(name26, index, nameCount) {
|
|
1510
1511
|
const base = (name26 || "").toLowerCase().replace(/\s+/g, "-").replace(/[^a-z0-9-]/g, "").replace(/^-+|-+$/g, "") || `sub-agent-${index}`;
|
|
@@ -1512,7 +1513,34 @@ function toAgentFilename(name26, index, nameCount) {
|
|
|
1512
1513
|
nameCount.set(base, count + 1);
|
|
1513
1514
|
return count === 0 ? base : `${base}-${count + 1}`;
|
|
1514
1515
|
}
|
|
1515
|
-
async function
|
|
1516
|
+
async function resolveSubAgentContent(agent, fetchFn) {
|
|
1517
|
+
if (agent.source) {
|
|
1518
|
+
try {
|
|
1519
|
+
const content = await fetchFn(agent.source, {
|
|
1520
|
+
userAgent: "EvalForge-Evaluator"
|
|
1521
|
+
});
|
|
1522
|
+
console.log(
|
|
1523
|
+
`[SubAgents] Fetched "${agent.name}" from ${agent.source.owner}/${agent.source.repo}/${agent.source.path}@${agent.source.ref}`
|
|
1524
|
+
);
|
|
1525
|
+
return content;
|
|
1526
|
+
} catch (error48) {
|
|
1527
|
+
const message = error48 instanceof Error ? error48.message : "Unknown error";
|
|
1528
|
+
console.error(
|
|
1529
|
+
`[SubAgents] "${agent.name}": GitHub fetch failed: ${message}`
|
|
1530
|
+
);
|
|
1531
|
+
throw new Error(
|
|
1532
|
+
`Failed to fetch sub-agent "${agent.name}" from GitHub: ${message}`
|
|
1533
|
+
);
|
|
1534
|
+
}
|
|
1535
|
+
}
|
|
1536
|
+
if (!agent.subAgentMd) {
|
|
1537
|
+
console.warn(
|
|
1538
|
+
`[SubAgents] "${agent.name}" has empty inline content \u2013 the agent file will be blank`
|
|
1539
|
+
);
|
|
1540
|
+
}
|
|
1541
|
+
return agent.subAgentMd;
|
|
1542
|
+
}
|
|
1543
|
+
async function writeSubAgentsToFilesystem(cwd, subAgents, fetchFn = import_evalforge_github_client3.fetchGitHubFile) {
|
|
1516
1544
|
if (subAgents.length === 0) return;
|
|
1517
1545
|
const agentsDir = (0, import_path6.join)(cwd, AGENTS_DIR);
|
|
1518
1546
|
await (0, import_promises5.mkdir)(agentsDir, { recursive: true });
|
|
@@ -1520,7 +1548,8 @@ async function writeSubAgentsToFilesystem(cwd, subAgents) {
|
|
|
1520
1548
|
for (const [i, agent] of subAgents.entries()) {
|
|
1521
1549
|
const filename = toAgentFilename(agent.name, i, nameCount);
|
|
1522
1550
|
const filePath = (0, import_path6.join)(agentsDir, `${filename}.md`);
|
|
1523
|
-
await (
|
|
1551
|
+
const content = await resolveSubAgentContent(agent, fetchFn);
|
|
1552
|
+
await (0, import_promises5.writeFile)(filePath, content, "utf8");
|
|
1524
1553
|
}
|
|
1525
1554
|
console.log(`[SubAgents] Written to ${agentsDir}`);
|
|
1526
1555
|
}
|