@wix/evalforge-evaluator 0.163.0 → 0.165.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 +53 -34
- package/build/index.js.map +3 -3
- package/build/index.mjs +62 -40
- package/build/index.mjs.map +3 -3
- package/package.json +5 -5
package/build/index.js
CHANGED
|
@@ -433,6 +433,7 @@ var import_eval_assertions = require("@wix/eval-assertions");
|
|
|
433
433
|
|
|
434
434
|
// src/run-scenario/environment.ts
|
|
435
435
|
var import_fs = require("fs");
|
|
436
|
+
var import_promises2 = require("fs/promises");
|
|
436
437
|
var import_os = require("os");
|
|
437
438
|
var import_path2 = __toESM(require("path"));
|
|
438
439
|
var import_evalforge_github_client = require("@wix/evalforge-github-client");
|
|
@@ -456,16 +457,34 @@ async function writeFilesToDirectory(targetDir, files) {
|
|
|
456
457
|
|
|
457
458
|
// src/run-scenario/environment.ts
|
|
458
459
|
async function fetchAndWriteTemplateFiles(template, workDir) {
|
|
459
|
-
|
|
460
|
+
let sourceFiles = [];
|
|
461
|
+
if (template.source) {
|
|
462
|
+
sourceFiles = await (0, import_evalforge_github_client.fetchGitHubFolder)(template.source, {
|
|
463
|
+
userAgent: "EvalForge-Evaluator"
|
|
464
|
+
});
|
|
465
|
+
} else if (template.sourceFiles?.length) {
|
|
466
|
+
sourceFiles = template.sourceFiles;
|
|
467
|
+
} else {
|
|
460
468
|
console.warn(
|
|
461
469
|
`Template "${template.name}" has no source configured, creating empty directory`
|
|
462
470
|
);
|
|
463
|
-
return;
|
|
464
471
|
}
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
472
|
+
await writeFilesToDirectory(workDir, sourceFiles);
|
|
473
|
+
await Promise.all(
|
|
474
|
+
(template.extraFiles ?? []).map(async (ef) => {
|
|
475
|
+
const content = ef.gitSource ? await (0, import_evalforge_github_client.fetchGitHubFile)(ef.gitSource, {
|
|
476
|
+
userAgent: "EvalForge-Evaluator"
|
|
477
|
+
}) : ef.content ?? "";
|
|
478
|
+
const dest = import_path2.default.resolve(workDir, ef.path);
|
|
479
|
+
if (!dest.startsWith(workDir + import_path2.sep)) {
|
|
480
|
+
throw new Error(
|
|
481
|
+
`Extra file path escapes working directory: "${ef.path}"`
|
|
482
|
+
);
|
|
483
|
+
}
|
|
484
|
+
await (0, import_promises2.mkdir)(import_path2.default.dirname(dest), { recursive: true });
|
|
485
|
+
await (0, import_promises2.writeFile)(dest, content, "utf8");
|
|
486
|
+
})
|
|
487
|
+
);
|
|
469
488
|
}
|
|
470
489
|
function writeWixEnvFile(workDir) {
|
|
471
490
|
const configPath = import_path2.default.join(workDir, "wix.config.json");
|
|
@@ -623,7 +642,7 @@ var import_evalforge_types5 = require("@wix/evalforge-types");
|
|
|
623
642
|
var import_evalforge_types4 = require("@wix/evalforge-types");
|
|
624
643
|
|
|
625
644
|
// src/run-scenario/agents/claude-code/write-skills.ts
|
|
626
|
-
var
|
|
645
|
+
var import_promises3 = require("fs/promises");
|
|
627
646
|
var import_path3 = require("path");
|
|
628
647
|
var import_evalforge_github_client2 = require("@wix/evalforge-github-client");
|
|
629
648
|
async function writeSkillsToFilesystem(cwd, skills, fetchFn = import_evalforge_github_client2.fetchGitHubFolder) {
|
|
@@ -634,7 +653,7 @@ async function writeSkillsToFilesystem(cwd, skills, fetchFn = import_evalforge_g
|
|
|
634
653
|
async function writeSkillToFilesystem(cwd, skill, fetchFn = import_evalforge_github_client2.fetchGitHubFolder) {
|
|
635
654
|
const skillName = skill.name;
|
|
636
655
|
const skillDir = (0, import_path3.join)(cwd, ".claude", "skills", skillName);
|
|
637
|
-
await (0,
|
|
656
|
+
await (0, import_promises3.mkdir)(skillDir, { recursive: true });
|
|
638
657
|
const version = skill.latestVersion;
|
|
639
658
|
if (version?.files && version.files.length > 0) {
|
|
640
659
|
await writeFilesToDirectory(skillDir, version.files);
|
|
@@ -676,18 +695,18 @@ function resolveTimeoutMs(maxTurns, maxDurationMs) {
|
|
|
676
695
|
var import_crypto = require("crypto");
|
|
677
696
|
|
|
678
697
|
// src/run-scenario/agents/claude-code/write-mcp.ts
|
|
679
|
-
var
|
|
698
|
+
var import_promises5 = require("fs/promises");
|
|
680
699
|
var import_path5 = require("path");
|
|
681
700
|
var import_evalforge_types2 = require("@wix/evalforge-types");
|
|
682
701
|
|
|
683
702
|
// src/run-scenario/agents/shared/resolve-mcp-placeholders.ts
|
|
684
|
-
var
|
|
703
|
+
var import_promises4 = require("fs/promises");
|
|
685
704
|
var import_path4 = require("path");
|
|
686
705
|
var import_os2 = require("os");
|
|
687
706
|
var WIX_AUTH_FILE = (0, import_path4.join)((0, import_os2.homedir)(), ".wix", "auth", "api-key.json");
|
|
688
707
|
async function loadWixAuthPlaceholders(authFilePath = WIX_AUTH_FILE) {
|
|
689
708
|
try {
|
|
690
|
-
const content = await (0,
|
|
709
|
+
const content = await (0, import_promises4.readFile)(authFilePath, "utf-8");
|
|
691
710
|
const auth = JSON.parse(content);
|
|
692
711
|
if (!auth.token || !auth.userInfo?.userId) {
|
|
693
712
|
return {};
|
|
@@ -744,12 +763,12 @@ async function writeMcpToFilesystem(cwd, mcps) {
|
|
|
744
763
|
2
|
|
745
764
|
);
|
|
746
765
|
const filePath = (0, import_path5.join)(cwd, ".mcp.json");
|
|
747
|
-
await (0,
|
|
766
|
+
await (0, import_promises5.writeFile)(filePath, content, "utf8");
|
|
748
767
|
console.log(`[MCP] Written to ${filePath}`);
|
|
749
768
|
}
|
|
750
769
|
|
|
751
770
|
// src/run-scenario/agents/claude-code/write-sub-agents.ts
|
|
752
|
-
var
|
|
771
|
+
var import_promises6 = require("fs/promises");
|
|
753
772
|
var import_path6 = require("path");
|
|
754
773
|
var import_evalforge_github_client3 = require("@wix/evalforge-github-client");
|
|
755
774
|
var AGENTS_DIR = ".claude/agents";
|
|
@@ -789,19 +808,19 @@ async function resolveSubAgentContent(agent, fetchFn) {
|
|
|
789
808
|
async function writeSubAgentsToFilesystem(cwd, subAgents, fetchFn = import_evalforge_github_client3.fetchGitHubFile) {
|
|
790
809
|
if (subAgents.length === 0) return;
|
|
791
810
|
const agentsDir = (0, import_path6.join)(cwd, AGENTS_DIR);
|
|
792
|
-
await (0,
|
|
811
|
+
await (0, import_promises6.mkdir)(agentsDir, { recursive: true });
|
|
793
812
|
const nameCount = /* @__PURE__ */ new Map();
|
|
794
813
|
for (const [i, agent] of subAgents.entries()) {
|
|
795
814
|
const filename = toAgentFilename(agent.name, i, nameCount);
|
|
796
815
|
const filePath = (0, import_path6.join)(agentsDir, `${filename}.md`);
|
|
797
816
|
const content = await resolveSubAgentContent(agent, fetchFn);
|
|
798
|
-
await (0,
|
|
817
|
+
await (0, import_promises6.writeFile)(filePath, content, "utf8");
|
|
799
818
|
}
|
|
800
819
|
console.log(`[SubAgents] Written to ${agentsDir}`);
|
|
801
820
|
}
|
|
802
821
|
|
|
803
822
|
// src/run-scenario/agents/claude-code/write-rules.ts
|
|
804
|
-
var
|
|
823
|
+
var import_promises7 = require("fs/promises");
|
|
805
824
|
var import_path7 = require("path");
|
|
806
825
|
var CURSOR_RULES_DIR = ".cursor/rules";
|
|
807
826
|
function toRuleFilename(name, index, nameCount) {
|
|
@@ -813,13 +832,13 @@ function toRuleFilename(name, index, nameCount) {
|
|
|
813
832
|
async function appendToFile(filePath, content) {
|
|
814
833
|
let existing = "";
|
|
815
834
|
try {
|
|
816
|
-
existing = await (0,
|
|
835
|
+
existing = await (0, import_promises7.readFile)(filePath, "utf8");
|
|
817
836
|
} catch {
|
|
818
837
|
}
|
|
819
838
|
const merged = existing ? `${existing.trimEnd()}
|
|
820
839
|
|
|
821
840
|
${content}` : content;
|
|
822
|
-
await (0,
|
|
841
|
+
await (0, import_promises7.writeFile)(filePath, merged, "utf8");
|
|
823
842
|
}
|
|
824
843
|
function validateGenericDirectory(dir, cwd) {
|
|
825
844
|
const trimmed = dir.trim();
|
|
@@ -860,12 +879,12 @@ async function writeRulesToFilesystem(cwd, rules) {
|
|
|
860
879
|
}
|
|
861
880
|
case "cursor-rule": {
|
|
862
881
|
if (!hasCursorRules) {
|
|
863
|
-
await (0,
|
|
882
|
+
await (0, import_promises7.mkdir)((0, import_path7.join)(cwd, CURSOR_RULES_DIR), { recursive: true });
|
|
864
883
|
hasCursorRules = true;
|
|
865
884
|
}
|
|
866
885
|
const filename = toRuleFilename(rule.name, i, nameCount);
|
|
867
886
|
const filePath = (0, import_path7.join)(cwd, CURSOR_RULES_DIR, `${filename}.md`);
|
|
868
|
-
await (0,
|
|
887
|
+
await (0, import_promises7.writeFile)(filePath, rule.content, "utf8");
|
|
869
888
|
break;
|
|
870
889
|
}
|
|
871
890
|
case "generic": {
|
|
@@ -874,9 +893,9 @@ async function writeRulesToFilesystem(cwd, rules) {
|
|
|
874
893
|
cwd
|
|
875
894
|
);
|
|
876
895
|
const dirPath = (0, import_path7.join)(cwd, directory);
|
|
877
|
-
await (0,
|
|
896
|
+
await (0, import_promises7.mkdir)(dirPath, { recursive: true });
|
|
878
897
|
const filename = toRuleFilename(rule.name, i, nameCount);
|
|
879
|
-
await (0,
|
|
898
|
+
await (0, import_promises7.writeFile)((0, import_path7.join)(dirPath, `${filename}.md`), rule.content, "utf8");
|
|
880
899
|
break;
|
|
881
900
|
}
|
|
882
901
|
default: {
|
|
@@ -1185,10 +1204,10 @@ function createTraceEventFromAnyMessage(message, context, stepNumber, isComplete
|
|
|
1185
1204
|
};
|
|
1186
1205
|
}
|
|
1187
1206
|
async function prepareClaudeCodeEnvironment(cwd, skills, options) {
|
|
1188
|
-
const { mkdir: mkdirAsync, writeFile:
|
|
1207
|
+
const { mkdir: mkdirAsync, writeFile: writeFile8 } = await import("fs/promises");
|
|
1189
1208
|
const claudeDir = `${cwd}/.claude`;
|
|
1190
1209
|
await mkdirAsync(claudeDir, { recursive: true });
|
|
1191
|
-
await
|
|
1210
|
+
await writeFile8(`${claudeDir}/settings.json`, "{}", {
|
|
1192
1211
|
flag: "wx"
|
|
1193
1212
|
}).catch(() => {
|
|
1194
1213
|
});
|
|
@@ -2186,7 +2205,7 @@ function tryParseJson(text) {
|
|
|
2186
2205
|
}
|
|
2187
2206
|
|
|
2188
2207
|
// src/run-scenario/agents/opencode/write-skills.ts
|
|
2189
|
-
var
|
|
2208
|
+
var import_promises8 = require("fs/promises");
|
|
2190
2209
|
var import_path8 = require("path");
|
|
2191
2210
|
var import_evalforge_github_client4 = require("@wix/evalforge-github-client");
|
|
2192
2211
|
async function writeSkillsToFilesystem2(cwd, skills, fetchFn = import_evalforge_github_client4.fetchGitHubFolder) {
|
|
@@ -2197,7 +2216,7 @@ async function writeSkillsToFilesystem2(cwd, skills, fetchFn = import_evalforge_
|
|
|
2197
2216
|
async function writeSkillToFilesystem2(cwd, skill, fetchFn) {
|
|
2198
2217
|
const skillName = skill.name;
|
|
2199
2218
|
const skillDir = (0, import_path8.join)(cwd, ".opencode", "skills", skillName);
|
|
2200
|
-
await (0,
|
|
2219
|
+
await (0, import_promises8.mkdir)(skillDir, { recursive: true });
|
|
2201
2220
|
const version = skill.latestVersion;
|
|
2202
2221
|
if (version?.files && version.files.length > 0) {
|
|
2203
2222
|
await writeFilesToDirectory(skillDir, version.files);
|
|
@@ -2228,7 +2247,7 @@ async function writeSkillToFilesystem2(cwd, skill, fetchFn) {
|
|
|
2228
2247
|
}
|
|
2229
2248
|
|
|
2230
2249
|
// src/run-scenario/agents/opencode/write-sub-agents.ts
|
|
2231
|
-
var
|
|
2250
|
+
var import_promises9 = require("fs/promises");
|
|
2232
2251
|
var import_path9 = require("path");
|
|
2233
2252
|
var import_evalforge_github_client5 = require("@wix/evalforge-github-client");
|
|
2234
2253
|
var AGENTS_DIR2 = ".opencode/agents";
|
|
@@ -2268,13 +2287,13 @@ async function resolveSubAgentContent2(agent, fetchFn) {
|
|
|
2268
2287
|
async function writeSubAgentsToFilesystem2(cwd, subAgents, fetchFn = import_evalforge_github_client5.fetchGitHubFile) {
|
|
2269
2288
|
if (subAgents.length === 0) return;
|
|
2270
2289
|
const agentsDir = (0, import_path9.join)(cwd, AGENTS_DIR2);
|
|
2271
|
-
await (0,
|
|
2290
|
+
await (0, import_promises9.mkdir)(agentsDir, { recursive: true });
|
|
2272
2291
|
const nameCount = /* @__PURE__ */ new Map();
|
|
2273
2292
|
for (const [i, agent] of subAgents.entries()) {
|
|
2274
2293
|
const filename = toAgentFilename2(agent.name, i, nameCount);
|
|
2275
2294
|
const filePath = (0, import_path9.join)(agentsDir, `${filename}.md`);
|
|
2276
2295
|
const content = await resolveSubAgentContent2(agent, fetchFn);
|
|
2277
|
-
await (0,
|
|
2296
|
+
await (0, import_promises9.writeFile)(filePath, content, "utf8");
|
|
2278
2297
|
}
|
|
2279
2298
|
console.log(`[SubAgents] Written to ${agentsDir}`);
|
|
2280
2299
|
}
|
|
@@ -2735,7 +2754,7 @@ function buildConversation2(timestampedEvents) {
|
|
|
2735
2754
|
}
|
|
2736
2755
|
|
|
2737
2756
|
// src/run-scenario/agents/opencode/execute.ts
|
|
2738
|
-
var
|
|
2757
|
+
var import_promises10 = require("fs/promises");
|
|
2739
2758
|
var import_path10 = require("path");
|
|
2740
2759
|
var KILL_GRACE_PERIOD_MS = 5e3;
|
|
2741
2760
|
var IDLE_TIMEOUT_MS = 12e4;
|
|
@@ -2762,7 +2781,7 @@ function extractToolAction(toolName, args) {
|
|
|
2762
2781
|
}
|
|
2763
2782
|
async function writePromptImages(cwd, images) {
|
|
2764
2783
|
const imagesDir = (0, import_path10.join)(cwd, "prompt-images");
|
|
2765
|
-
await (0,
|
|
2784
|
+
await (0, import_promises10.mkdir)(imagesDir, { recursive: true });
|
|
2766
2785
|
const filePaths = [];
|
|
2767
2786
|
for (let i = 0; i < images.length; i++) {
|
|
2768
2787
|
const img = images[i];
|
|
@@ -2770,7 +2789,7 @@ async function writePromptImages(cwd, images) {
|
|
|
2770
2789
|
const filename = `image-${i}.${ext}`;
|
|
2771
2790
|
const filepath = (0, import_path10.join)(imagesDir, filename);
|
|
2772
2791
|
const buffer = Buffer.from(img.base64, "base64");
|
|
2773
|
-
await (0,
|
|
2792
|
+
await (0, import_promises10.writeFile)(filepath, buffer);
|
|
2774
2793
|
filePaths.push(filepath);
|
|
2775
2794
|
}
|
|
2776
2795
|
return filePaths;
|
|
@@ -2862,8 +2881,8 @@ async function prepareOpenCodeEnvironment(cwd, skills, options) {
|
|
|
2862
2881
|
}
|
|
2863
2882
|
async function writeSystemPromptRule(cwd, systemPrompt) {
|
|
2864
2883
|
const rulesDir = (0, import_path10.join)(cwd, ".opencode", "rules");
|
|
2865
|
-
await (0,
|
|
2866
|
-
await (0,
|
|
2884
|
+
await (0, import_promises10.mkdir)(rulesDir, { recursive: true });
|
|
2885
|
+
await (0, import_promises10.writeFile)(
|
|
2867
2886
|
(0, import_path10.join)(rulesDir, "evalforge-system-prompt.md"),
|
|
2868
2887
|
systemPrompt,
|
|
2869
2888
|
"utf-8"
|