Skip to content

Commit 9aec1d0

Browse files
refactor(evals): drop the node:path suppression in the grader
The grader's paths are absolute POSIX paths, so a short segment resolver replaces path.posix.normalize and its file-wide diagnostic suppression. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 88818d8 commit 9aec1d0

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

‎evals/mcp-tool-use/file-link-grading.ts‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// @effect-diagnostics nodeBuiltinImport:off
2-
import * as NodePath from "node:path";
31
import * as Schema from "effect/Schema";
42
import { splitFilePathPosition } from "@t3tools/shared/fileLinks";
53
import {
@@ -21,6 +19,16 @@ export const FileLinksExpect = Schema.Struct({
2119
minWorking: Schema.Number,
2220
});
2321

22+
/** Resolves `.` and `..` segments, which the file system resolves when the client opens the path. */
23+
const normalizeAbsolutePath = (path: string) => {
24+
const segments: Array<string> = [];
25+
for (const segment of path.split("/")) {
26+
if (segment === "..") segments.pop();
27+
else if (segment !== "" && segment !== ".") segments.push(segment);
28+
}
29+
return `/${segments.join("/")}`;
30+
};
31+
2432
/** The client opens an exact basename match, or a case-insensitive one when only one exists. */
2533
const uniqueBasename = (name: string, entries: ReadonlyArray<{ readonly path: string }>) => {
2634
const basenames = entries.map((entry) => entry.path.split("/").at(-1) ?? "");
@@ -62,7 +70,7 @@ export const fileLinkPills = (
6270
return [...new Set(sources)].flatMap((source) => {
6371
const target = resolveMarkdownFileLinkTarget(source, cwd);
6472
if (target === null) return [];
65-
const path = NodePath.posix.normalize(splitFilePathPosition(target).path).replace(/\/+$/, "");
73+
const path = normalizeAbsolutePath(splitFilePathPosition(target).path);
6674
// System paths such as /usr/bin/node are not what these cases test.
6775
if (!/^\/(?:home|Users)\//.test(path)) return [];
6876
const relative = parseMarkdownFileLink(source)?.path ?? path;

0 commit comments

Comments
 (0)