diff --git a/packages/loopover-mcp/lib/local-branch.js b/packages/loopover-mcp/lib/local-branch.js index 1faa522417..58bf125b4f 100644 --- a/packages/loopover-mcp/lib/local-branch.js +++ b/packages/loopover-mcp/lib/local-branch.js @@ -1,6 +1,6 @@ import { execFileSync } from "node:child_process"; import { realpathSync } from "node:fs"; -import { dirname, isAbsolute, join, relative, resolve } from "node:path"; +import { isAbsolute, join, relative, resolve } from "node:path"; import { fileURLToPath } from "node:url"; import { isCodeFile, isTestPath as isTestFile } from "@loopover/engine/signals/test-evidence"; import { redactLocalPath } from "./redact-local-path.js"; @@ -8,8 +8,6 @@ import { redactLocalPath } from "./redact-local-path.js"; export { isCodeFile, isTestFile }; export { redactLocalPath }; -const packageRoot = join(dirname(fileURLToPath(import.meta.url)), ".."); - function stripTrailingSlashes(value) { let end = value.length; while (end > 0 && value.charCodeAt(end - 1) === 47) end -= 1; @@ -201,12 +199,6 @@ export function resolveScorePreviewCommand(input = {}) { return undefined; } -export function referenceScorePreviewCommand(kind = "metadata") { - const script = kind === "gittensor" ? "gittensor-score-preview.py" : "gittensor-score-preview.mjs"; - const interpreter = kind === "gittensor" ? "python3" : "node"; - return `${interpreter} ${join(packageRoot, "scripts", script)}`; -} - export function referenceScorePreviewExample(kind = "metadata") { const script = kind === "gittensor" ? "gittensor-score-preview.py" : "gittensor-score-preview.mjs"; const interpreter = kind === "gittensor" ? "python3" : "node"; diff --git a/test/unit/local-scorer-adapter.test.ts b/test/unit/local-scorer-adapter.test.ts index 4a74f40fc3..58ea8ccd61 100644 --- a/test/unit/local-scorer-adapter.test.ts +++ b/test/unit/local-scorer-adapter.test.ts @@ -5,6 +5,15 @@ function fixtureCommand(name: string) { return `node ${join(process.cwd(), "test/fixtures/local-scorer", name)}`; } +// Points at the real bundled scorer script the package ships, so this test exercises it end to end. +// Lives here (not exported from lib/local-branch.js) since this test is its only real caller (#6259) -- +// production guidance text always uses the intentionally generic, path-redacted referenceScorePreviewExample. +function packagedScorerCommand(kind: "metadata" | "gittensor" = "metadata") { + const script = kind === "gittensor" ? "gittensor-score-preview.py" : "gittensor-score-preview.mjs"; + const interpreter = kind === "gittensor" ? "python3" : "node"; + return `${interpreter} ${join(process.cwd(), "packages/loopover-mcp/scripts", script)}`; +} + describe("local scorer adapter", () => { const metadata = { repoFullName: "entrius/allways-ui", @@ -96,8 +105,8 @@ describe("local scorer adapter", () => { it("runs the packaged reference scorer against metadata only", async () => { // @ts-expect-error package helper is plain JS because the local wrapper ships as a Node bin package. - const { referenceScorePreviewCommand, runExternalScorePreview } = await import("../../packages/loopover-mcp/lib/local-branch.js"); - const result = runExternalScorePreview(metadata, referenceScorePreviewCommand("metadata")); + const { runExternalScorePreview } = await import("../../packages/loopover-mcp/lib/local-branch.js"); + const result = runExternalScorePreview(metadata, packagedScorerCommand("metadata")); expect(result.ok).toBe(true); expect(result.payload).toMatchObject({ sourceTokenScore: expect.any(Number),