@agentv/core 0.10.1 → 0.11.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/dist/index.cjs +30 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +30 -14
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -418,14 +418,13 @@ function formatSegment(segment) {
|
|
|
418
418
|
const text = asString(segment.text);
|
|
419
419
|
const filePath = asString(segment.path);
|
|
420
420
|
if (text && filePath) {
|
|
421
|
-
return
|
|
422
|
-
${text}`;
|
|
421
|
+
return formatFileContents([{ content: text.trim(), isFile: true, displayPath: filePath }]);
|
|
423
422
|
}
|
|
424
423
|
}
|
|
425
424
|
return void 0;
|
|
426
425
|
}
|
|
427
426
|
async function buildPromptInputs(testCase) {
|
|
428
|
-
const
|
|
427
|
+
const guidelineParts = [];
|
|
429
428
|
for (const rawPath of testCase.guideline_paths) {
|
|
430
429
|
const absolutePath = path.resolve(rawPath);
|
|
431
430
|
if (!await fileExists2(absolutePath)) {
|
|
@@ -433,14 +432,17 @@ async function buildPromptInputs(testCase) {
|
|
|
433
432
|
continue;
|
|
434
433
|
}
|
|
435
434
|
try {
|
|
436
|
-
const content = (await readFile(absolutePath, "utf8")).replace(/\r\n/g, "\n");
|
|
437
|
-
|
|
438
|
-
|
|
435
|
+
const content = (await readFile(absolutePath, "utf8")).replace(/\r\n/g, "\n").trim();
|
|
436
|
+
guidelineParts.push({
|
|
437
|
+
content,
|
|
438
|
+
isFile: true,
|
|
439
|
+
displayPath: path.basename(absolutePath)
|
|
440
|
+
});
|
|
439
441
|
} catch (error) {
|
|
440
442
|
logWarning(`Could not read guideline file ${absolutePath}: ${error.message}`);
|
|
441
443
|
}
|
|
442
444
|
}
|
|
443
|
-
const guidelines =
|
|
445
|
+
const guidelines = formatFileContents(guidelineParts);
|
|
444
446
|
const segmentsByMessage = [];
|
|
445
447
|
const fileContentsByPath = /* @__PURE__ */ new Map();
|
|
446
448
|
for (const segment of testCase.input_segments) {
|
|
@@ -642,6 +644,20 @@ function cloneJsonValue(value) {
|
|
|
642
644
|
}
|
|
643
645
|
return cloneJsonObject(value);
|
|
644
646
|
}
|
|
647
|
+
function formatFileContents(parts) {
|
|
648
|
+
const fileCount = parts.filter((p) => p.isFile).length;
|
|
649
|
+
if (fileCount > 0) {
|
|
650
|
+
return parts.map((part) => {
|
|
651
|
+
if (part.isFile && part.displayPath) {
|
|
652
|
+
return `<file path="${part.displayPath}">
|
|
653
|
+
${part.content}
|
|
654
|
+
</file>`;
|
|
655
|
+
}
|
|
656
|
+
return part.content;
|
|
657
|
+
}).join("\n\n");
|
|
658
|
+
}
|
|
659
|
+
return parts.map((p) => p.content).join(" ");
|
|
660
|
+
}
|
|
645
661
|
async function resolveAssistantContent(content, searchRoots, verbose) {
|
|
646
662
|
if (typeof content === "string") {
|
|
647
663
|
return content;
|
|
@@ -652,7 +668,7 @@ async function resolveAssistantContent(content, searchRoots, verbose) {
|
|
|
652
668
|
const parts = [];
|
|
653
669
|
for (const entry of content) {
|
|
654
670
|
if (typeof entry === "string") {
|
|
655
|
-
parts.push(entry);
|
|
671
|
+
parts.push({ content: entry, isFile: false });
|
|
656
672
|
continue;
|
|
657
673
|
}
|
|
658
674
|
if (!isJsonObject(entry)) {
|
|
@@ -674,8 +690,8 @@ async function resolveAssistantContent(content, searchRoots, verbose) {
|
|
|
674
690
|
continue;
|
|
675
691
|
}
|
|
676
692
|
try {
|
|
677
|
-
const fileContent = (await readFile(resolvedPath, "utf8")).replace(/\r\n/g, "\n");
|
|
678
|
-
parts.push(fileContent);
|
|
693
|
+
const fileContent = (await readFile(resolvedPath, "utf8")).replace(/\r\n/g, "\n").trim();
|
|
694
|
+
parts.push({ content: fileContent, isFile: true, displayPath });
|
|
679
695
|
if (verbose) {
|
|
680
696
|
console.log(` [Expected Assistant File] Found: ${displayPath}`);
|
|
681
697
|
console.log(` Resolved to: ${resolvedPath}`);
|
|
@@ -687,17 +703,17 @@ async function resolveAssistantContent(content, searchRoots, verbose) {
|
|
|
687
703
|
}
|
|
688
704
|
const textValue = asString(entry.text);
|
|
689
705
|
if (typeof textValue === "string") {
|
|
690
|
-
parts.push(textValue);
|
|
706
|
+
parts.push({ content: textValue, isFile: false });
|
|
691
707
|
continue;
|
|
692
708
|
}
|
|
693
709
|
const valueValue = asString(entry.value);
|
|
694
710
|
if (typeof valueValue === "string") {
|
|
695
|
-
parts.push(valueValue);
|
|
711
|
+
parts.push({ content: valueValue, isFile: false });
|
|
696
712
|
continue;
|
|
697
713
|
}
|
|
698
|
-
parts.push(JSON.stringify(entry));
|
|
714
|
+
parts.push({ content: JSON.stringify(entry), isFile: false });
|
|
699
715
|
}
|
|
700
|
-
return parts
|
|
716
|
+
return formatFileContents(parts);
|
|
701
717
|
}
|
|
702
718
|
async function parseEvaluators(rawEvalCase, globalExecution, searchRoots, evalId) {
|
|
703
719
|
const execution = rawEvalCase.execution;
|