From fdd0a96747790a9509725492fdb67c4fb5a08c0b Mon Sep 17 00:00:00 2001 From: galuis116 Date: Thu, 16 Jul 2026 02:36:59 -0400 Subject: [PATCH] chore(mcp): remove dead referenceScorePreviewCommand export in local-branch.js Its only real caller was test/unit/local-scorer-adapter.test.ts, which uses it to exercise the actual bundled scorer script end to end. Production guidance text always uses the sibling referenceScorePreviewExample instead -- and that's intentional, not a bug: an existing test explicitly asserts the guidance text stays generic/path-redacted (never leaks the real local filesystem path), so wiring in the absolute-path version would have been a regression, not a fix. Moved the packaged-scorer path resolution into the test file itself (the same join(process.cwd(), ...) pattern already used by its neighboring fixtureCommand() helper) since the test is genuinely its only caller. packageRoot and its now-unused dirname import are removed from local-branch.js along with the export. Closes #6259 --- packages/loopover-mcp/lib/local-branch.js | 10 +--------- test/unit/local-scorer-adapter.test.ts | 13 +++++++++++-- 2 files changed, 12 insertions(+), 11 deletions(-) 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),