@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.cjs
CHANGED
|
@@ -585,14 +585,13 @@ function formatSegment(segment) {
|
|
|
585
585
|
const text = asString(segment.text);
|
|
586
586
|
const filePath = asString(segment.path);
|
|
587
587
|
if (text && filePath) {
|
|
588
|
-
return
|
|
589
|
-
${text}`;
|
|
588
|
+
return formatFileContents([{ content: text.trim(), isFile: true, displayPath: filePath }]);
|
|
590
589
|
}
|
|
591
590
|
}
|
|
592
591
|
return void 0;
|
|
593
592
|
}
|
|
594
593
|
async function buildPromptInputs(testCase) {
|
|
595
|
-
const
|
|
594
|
+
const guidelineParts = [];
|
|
596
595
|
for (const rawPath of testCase.guideline_paths) {
|
|
597
596
|
const absolutePath = import_node_path2.default.resolve(rawPath);
|
|
598
597
|
if (!await fileExists2(absolutePath)) {
|
|
@@ -600,14 +599,17 @@ async function buildPromptInputs(testCase) {
|
|
|
600
599
|
continue;
|
|
601
600
|
}
|
|
602
601
|
try {
|
|
603
|
-
const content = (await (0, import_promises2.readFile)(absolutePath, "utf8")).replace(/\r\n/g, "\n");
|
|
604
|
-
|
|
605
|
-
|
|
602
|
+
const content = (await (0, import_promises2.readFile)(absolutePath, "utf8")).replace(/\r\n/g, "\n").trim();
|
|
603
|
+
guidelineParts.push({
|
|
604
|
+
content,
|
|
605
|
+
isFile: true,
|
|
606
|
+
displayPath: import_node_path2.default.basename(absolutePath)
|
|
607
|
+
});
|
|
606
608
|
} catch (error) {
|
|
607
609
|
logWarning(`Could not read guideline file ${absolutePath}: ${error.message}`);
|
|
608
610
|
}
|
|
609
611
|
}
|
|
610
|
-
const guidelines =
|
|
612
|
+
const guidelines = formatFileContents(guidelineParts);
|
|
611
613
|
const segmentsByMessage = [];
|
|
612
614
|
const fileContentsByPath = /* @__PURE__ */ new Map();
|
|
613
615
|
for (const segment of testCase.input_segments) {
|
|
@@ -809,6 +811,20 @@ function cloneJsonValue(value) {
|
|
|
809
811
|
}
|
|
810
812
|
return cloneJsonObject(value);
|
|
811
813
|
}
|
|
814
|
+
function formatFileContents(parts) {
|
|
815
|
+
const fileCount = parts.filter((p) => p.isFile).length;
|
|
816
|
+
if (fileCount > 0) {
|
|
817
|
+
return parts.map((part) => {
|
|
818
|
+
if (part.isFile && part.displayPath) {
|
|
819
|
+
return `<file path="${part.displayPath}">
|
|
820
|
+
${part.content}
|
|
821
|
+
</file>`;
|
|
822
|
+
}
|
|
823
|
+
return part.content;
|
|
824
|
+
}).join("\n\n");
|
|
825
|
+
}
|
|
826
|
+
return parts.map((p) => p.content).join(" ");
|
|
827
|
+
}
|
|
812
828
|
async function resolveAssistantContent(content, searchRoots, verbose) {
|
|
813
829
|
if (typeof content === "string") {
|
|
814
830
|
return content;
|
|
@@ -819,7 +835,7 @@ async function resolveAssistantContent(content, searchRoots, verbose) {
|
|
|
819
835
|
const parts = [];
|
|
820
836
|
for (const entry of content) {
|
|
821
837
|
if (typeof entry === "string") {
|
|
822
|
-
parts.push(entry);
|
|
838
|
+
parts.push({ content: entry, isFile: false });
|
|
823
839
|
continue;
|
|
824
840
|
}
|
|
825
841
|
if (!isJsonObject(entry)) {
|
|
@@ -841,8 +857,8 @@ async function resolveAssistantContent(content, searchRoots, verbose) {
|
|
|
841
857
|
continue;
|
|
842
858
|
}
|
|
843
859
|
try {
|
|
844
|
-
const fileContent = (await (0, import_promises2.readFile)(resolvedPath, "utf8")).replace(/\r\n/g, "\n");
|
|
845
|
-
parts.push(fileContent);
|
|
860
|
+
const fileContent = (await (0, import_promises2.readFile)(resolvedPath, "utf8")).replace(/\r\n/g, "\n").trim();
|
|
861
|
+
parts.push({ content: fileContent, isFile: true, displayPath });
|
|
846
862
|
if (verbose) {
|
|
847
863
|
console.log(` [Expected Assistant File] Found: ${displayPath}`);
|
|
848
864
|
console.log(` Resolved to: ${resolvedPath}`);
|
|
@@ -854,17 +870,17 @@ async function resolveAssistantContent(content, searchRoots, verbose) {
|
|
|
854
870
|
}
|
|
855
871
|
const textValue = asString(entry.text);
|
|
856
872
|
if (typeof textValue === "string") {
|
|
857
|
-
parts.push(textValue);
|
|
873
|
+
parts.push({ content: textValue, isFile: false });
|
|
858
874
|
continue;
|
|
859
875
|
}
|
|
860
876
|
const valueValue = asString(entry.value);
|
|
861
877
|
if (typeof valueValue === "string") {
|
|
862
|
-
parts.push(valueValue);
|
|
878
|
+
parts.push({ content: valueValue, isFile: false });
|
|
863
879
|
continue;
|
|
864
880
|
}
|
|
865
|
-
parts.push(JSON.stringify(entry));
|
|
881
|
+
parts.push({ content: JSON.stringify(entry), isFile: false });
|
|
866
882
|
}
|
|
867
|
-
return parts
|
|
883
|
+
return formatFileContents(parts);
|
|
868
884
|
}
|
|
869
885
|
async function parseEvaluators(rawEvalCase, globalExecution, searchRoots, evalId) {
|
|
870
886
|
const execution = rawEvalCase.execution;
|