Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions packages/loopover-mcp/lib/local-branch.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
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";

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;
Expand Down Expand Up @@ -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";
Expand Down
13 changes: 11 additions & 2 deletions test/unit/local-scorer-adapter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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),
Expand Down