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
6 changes: 3 additions & 3 deletions packages/gittensory-mcp/lib/local-branch.js
Original file line number Diff line number Diff line change
Expand Up @@ -598,14 +598,14 @@ export function isTestFile(file) {
/(^|\/)src\/test\//i.test(file) ||
/(^|\/)[^/]+_test\.(go|py|rb)$/i.test(file) ||
/(^|\/)[^/]+_spec\.rb$/i.test(file) ||
/\.(test|spec)\.(ts|tsx|js|jsx|py|rb|rs)$/i.test(file) ||
/(^|\/)[^/]+\.(cy|e2e)\.(ts|tsx|js|jsx)$/i.test(file) ||
/\.(test|spec)\.(ts|tsx|mts|cts|js|jsx|mjs|cjs|py|rb|rs)$/i.test(file) ||
/(^|\/)[^/]+\.(cy|e2e)\.(ts|tsx|mts|cts|js|jsx|mjs|cjs)$/i.test(file) ||
/(^|\/)__snapshots__\//i.test(file)
);
}

export function isCodeFile(file) {
return /\.(ts|tsx|js|jsx|py|rb|rs|kt|scala|java|go|sql)$/i.test(file) && !isTestFile(file);
return /\.(ts|tsx|mts|cts|js|jsx|mjs|cjs|py|rb|rs|kt|scala|java|go|sql)$/i.test(file) && !isTestFile(file);
}

function numberValue(value) {
Expand Down
14 changes: 5 additions & 9 deletions src/signals/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import type { GittensorContributorSnapshot } from "../gittensor/api";
import { nowIso } from "../utils/json";
import { sanitizePublicComment } from "../queue-intelligence";
import { labelMatchesPattern, projectLinkedIssueMultiplierForPlannedSolve, type LinkedIssueMultiplierStatus } from "../scoring/preview";
import { hasLocalTestEvidence } from "./test-evidence";
import { hasLocalTestEvidence, isTestPath } from "./test-evidence";
import { isFailingCheckSummary } from "./local-branch";
import { isDuplicateClusterWinnerByClaim } from "./duplicate-winner";
import { PREFLIGHT_LIMITS } from "./preflight-limits";
Expand Down Expand Up @@ -5500,17 +5500,13 @@ function sanitizeOutcomeDimensionKey(key: string): string {
}

function isCodeFile(file: string): boolean {
return /\.(ts|tsx|js|jsx|py|rb|rs|kt|scala|java|go|sql)$/i.test(file) && !isTestFile(file);
return /\.(ts|tsx|mts|cts|js|jsx|mjs|cjs|py|rb|rs|kt|scala|java|go|sql)$/i.test(file) && !isTestFile(file);
}

function isTestFile(file: string): boolean {
return (
/(^|\/)(test|tests|spec|__tests__)\//i.test(file) ||
/(^|\/)src\/test\//i.test(file) ||
/(^|\/)[^/]+_test\.(go|py|rb)$/i.test(file) ||
/(^|\/)[^/]+_spec\.rb$/i.test(file) ||
/\.(test|spec)\.(ts|tsx|js|jsx|py|rb|rs)$/i.test(file)
);
// Single-sourced with the canonical matcher (test-evidence.ts isTestPath), mirroring local-branch.ts's
// isTestFile — so cy/e2e, __snapshots__, and module extensions stay in sync and can't drift.
return isTestPath(file);
}

function riskRank(risk: CollisionCluster["risk"]): number {
Expand Down
2 changes: 1 addition & 1 deletion src/signals/local-branch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1267,7 +1267,7 @@ export function isTestFile(file: string): boolean {
}

export function isCodeFile(file: string): boolean {
return /\.(ts|tsx|js|jsx|py|rb|rs|kt|scala|java|go|sql)$/i.test(file) && !isTestFile(file);
return /\.(ts|tsx|mts|cts|js|jsx|mjs|cjs|py|rb|rs|kt|scala|java|go|sql)$/i.test(file) && !isTestFile(file);
}

function sameRepo(left: string, right: string): boolean {
Expand Down
4 changes: 2 additions & 2 deletions src/signals/test-evidence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ export function isTestPath(file: string): boolean {
/(^|\/)src\/test\//i.test(file) ||
/(^|\/)[^/]+_test\.(go|py|rb)$/i.test(file) ||
/(^|\/)[^/]+_spec\.rb$/i.test(file) ||
/\.(test|spec)\.(ts|tsx|js|jsx|py|rb|rs)$/i.test(file) ||
/(^|\/)[^/]+\.(cy|e2e)\.(ts|tsx|js|jsx)$/i.test(file) ||
/\.(test|spec)\.(ts|tsx|mts|cts|js|jsx|mjs|cjs|py|rb|rs)$/i.test(file) ||
/(^|\/)[^/]+\.(cy|e2e)\.(ts|tsx|mts|cts|js|jsx|mjs|cjs)$/i.test(file) ||
/(^|\/)__snapshots__\//i.test(file)
);
}
Expand Down
13 changes: 13 additions & 0 deletions test/unit/local-branch-file-classifiers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ describe("isTestFile", () => {
"calc.test.py",
"user.spec.rb",
"engine.test.rs",
// .mts/.cts/.mjs/.cjs test files must count as tests (else a .test.mts is misclassified as source).
"loader.test.mts",
"config.spec.cts",
"widget.test.mjs",
"legacy.spec.cjs",
"Engine.Test.TS",
]) {
expect(isTestFile(path)).toBe(true);
Expand Down Expand Up @@ -106,6 +111,11 @@ describe("isCodeFile", () => {
"server/Main.java",
"cmd/server/main.go",
"migrations/0001_init.sql",
// Node/TypeScript ESM + CommonJS module files are code (rag.ts's JS_TS_RE already recognizes .mjs/.cjs).
"src/loader.mjs",
"src/legacy.cjs",
"src/config.mts",
"src/setup.cts",
"helper_test.ts",
]) {
expect(isCodeFile(path)).toBe(true);
Expand All @@ -120,6 +130,9 @@ describe("isCodeFile", () => {
"service_test.py",
"models/account_test.rb",
"__tests__/component.jsx",
// module-extension e2e tests must not count as code
"e2e/checkout.cy.mts",
"e2e/flow.e2e.mjs",
]) {
expect(isCodeFile(path)).toBe(false);
}
Expand Down
11 changes: 10 additions & 1 deletion test/unit/local-branch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1746,13 +1746,22 @@ describe("local MCP git metadata collection", () => {
}
// Regression: Cypress/e2e and snapshot files must count as tests; before this they fell through to
// isCodeFile and were wrongly counted as source in the local packet.
for (const file of ["components/Button.cy.ts", "e2e/login.e2e.tsx", "src/__snapshots__/Button.snap.ts"]) {
for (const file of ["components/Button.cy.ts", "e2e/login.e2e.tsx", "src/__snapshots__/Button.snap.ts", "e2e/checkout.cy.mts", "e2e/flow.e2e.mjs"]) {
expect(isTestFile(file)).toBe(true);
expect(isCodeFile(file)).toBe(false);
}
// Plain source stays source.
expect(isTestFile("src/app.ts")).toBe(false);
expect(isCodeFile("src/app.ts")).toBe(true);
// Node/TypeScript ESM + CommonJS module files are code; their .test/.spec variants are tests.
for (const file of ["src/loader.mjs", "src/legacy.cjs", "src/config.mts", "src/setup.cts"]) {
expect(isCodeFile(file)).toBe(true);
expect(isTestFile(file)).toBe(false);
}
for (const file of ["src/loader.test.mts", "src/legacy.spec.cjs"]) {
expect(isTestFile(file)).toBe(true);
expect(isCodeFile(file)).toBe(false);
}
});

it("extracts linked issues only from standalone closing keywords, not keyword substrings", async () => {
Expand Down
8 changes: 8 additions & 0 deletions test/unit/test-evidence.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,15 @@ describe("test evidence helpers", () => {
expect(isTestPath("integration/api_flow.cy.ts")).toBe(true);
expect(isTestPath("playwright/smoke.spec.ts")).toBe(true);
expect(isTestPath("cypress/e2e/checkout.cy.js")).toBe(true);
// Cypress/Playwright e2e tests in Node/TS module extensions.
expect(isTestPath("cypress/e2e/checkout.cy.mts")).toBe(true);
expect(isTestPath("e2e/flow.e2e.mjs")).toBe(true);
expect(isTestPath("components/__snapshots__/Card.tsx.snap")).toBe(true);
// .test/.spec files in Node/TS ESM + CommonJS module extensions.
expect(isTestPath("src/loader.test.mts")).toBe(true);
expect(isTestPath("src/legacy.spec.cjs")).toBe(true);
expect(isTestPath("src/config.test.cts")).toBe(true);
expect(isTestPath("src/widget.spec.mjs")).toBe(true);
expect(isTestPath("src/state.snap")).toBe(false);
expect(isTestPath("src/widget.rs")).toBe(false);
});
Expand Down
Loading