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
2 changes: 1 addition & 1 deletion packages/gittensory-mcp/lib/local-branch.js
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ export function isTestFile(file) {
}

export function isCodeFile(file) {
return /\.(ts|tsx|mts|cts|js|jsx|mjs|cjs|py|rb|rs|kt|scala|java|go|sql|cs|swift|groovy|php|cpp|cc|c|h|hpp|m|vue|svelte|astro)$/i.test(file) && !isTestFile(file);
return /\.(ts|tsx|mts|cts|js|jsx|mjs|cjs|py|rb|rs|kt|scala|java|go|sql|cs|swift|groovy|php|cpp|cc|c|h|hpp|m|vue|svelte|astro|dart)$/i.test(file) && !isTestFile(file);
}

function numberValue(value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function isTestFile(file) {
}

function isCodeFile(file) {
return /\.(ts|tsx|mts|cts|js|jsx|mjs|cjs|py|rb|rs|kt|scala|java|go|sql|cs|swift|groovy|php|cpp|cc|c|h|hpp|m|vue|svelte|astro)$/i.test(file) && !isTestFile(file);
return /\.(ts|tsx|mts|cts|js|jsx|mjs|cjs|py|rb|rs|kt|scala|java|go|sql|cs|swift|groovy|php|cpp|cc|c|h|hpp|m|vue|svelte|astro|dart)$/i.test(file) && !isTestFile(file);
}

function lineCount(file) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def metadata_fallback(metadata: dict) -> dict:
lines = max(int(entry.get("additions") or 0) + int(entry.get("deletions") or 0), 0)
if is_test_file(path):
tests += lines
elif lower_path.endswith((".ts", ".tsx", ".mts", ".cts", ".js", ".jsx", ".mjs", ".cjs", ".py", ".rb", ".rs", ".go", ".java", ".kt", ".scala", ".sql", ".cs", ".swift", ".groovy", ".php", ".cpp", ".cc", ".c", ".h", ".hpp", ".m", ".vue", ".svelte", ".astro")):
elif lower_path.endswith((".ts", ".tsx", ".mts", ".cts", ".js", ".jsx", ".mjs", ".cjs", ".py", ".rb", ".rs", ".go", ".java", ".kt", ".scala", ".sql", ".cs", ".swift", ".groovy", ".php", ".cpp", ".cc", ".c", ".h", ".hpp", ".m", ".vue", ".svelte", ".astro", ".dart")):
source += lines
else:
non_code += lines
Expand Down
2 changes: 1 addition & 1 deletion src/rules/advisory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ function severityToAnnotationLevel(severity: AdvisorySeverity): CheckRunAnnotati
}

function isCodePath(path: string): boolean {
return /\.(ts|tsx|js|jsx|py|go|rs|java|rb|php|cs|cpp|cc|c|h|hpp|swift|kt|m|sql|yaml|yml|json|toml|md|vue|svelte|astro)$/i.test(path);
return /\.(ts|tsx|js|jsx|py|go|rs|java|rb|php|cs|cpp|cc|c|h|hpp|swift|kt|m|sql|yaml|yml|json|toml|md|vue|svelte|astro|dart)$/i.test(path);
}

function collisionClustersForPull(collisions: CollisionReport, pullNumber: number): CollisionCluster[] {
Expand Down
5 changes: 3 additions & 2 deletions src/signals/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5539,9 +5539,10 @@ function isCodeFile(file: string): boolean {
// Mirrors isCodeFile in local-branch.ts — kept in sync (cs/swift/groovy/php and C/C++/Objective-C added
// so native/C#/Swift/Groovy/PHP source counts as code, matching the test conventions
// isTestPath already recognizes; vue/svelte/astro match rag.ts, visual paths, and isCodePath;
// cc/hpp complete the C++ extension set alongside cpp/c/h).
// cc/hpp complete the C++ extension set alongside cpp/c/h; dart matches rag.ts and
// test-evidence's *_test.dart test convention).
return (
/\.(ts|tsx|mts|cts|js|jsx|mjs|cjs|py|rb|rs|kt|scala|java|go|sql|cs|swift|groovy|php|cpp|cc|c|h|hpp|m|vue|svelte|astro)$/i.test(
/\.(ts|tsx|mts|cts|js|jsx|mjs|cjs|py|rb|rs|kt|scala|java|go|sql|cs|swift|groovy|php|cpp|cc|c|h|hpp|m|vue|svelte|astro|dart)$/i.test(
file,
) && !isTestFile(file)
);
Expand Down
4 changes: 3 additions & 1 deletion src/signals/local-branch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1273,8 +1273,10 @@ export function isCodeFile(file: string): boolean {
// nor code in the local scorer. vue/svelte/astro align with review/rag.ts CODE_EXT_RE,
// review/visual/paths.ts, and rules/advisory.ts isCodePath so every classifier agrees.
// cc/hpp round out the C++ set alongside cpp/c/h (rag.ts already indexes all four).
// dart aligns with rag.ts and test-evidence's *_test.dart convention (hand-authored
// .dart is source; generated .g.dart/.freezed.dart stay non-code via isGeneratedFile).
return (
/\.(ts|tsx|mts|cts|js|jsx|mjs|cjs|py|rb|rs|kt|scala|java|go|sql|cs|swift|groovy|php|cpp|cc|c|h|hpp|m|vue|svelte|astro)$/i.test(
/\.(ts|tsx|mts|cts|js|jsx|mjs|cjs|py|rb|rs|kt|scala|java|go|sql|cs|swift|groovy|php|cpp|cc|c|h|hpp|m|vue|svelte|astro|dart)$/i.test(
file,
) && !isTestFile(file)
);
Expand Down
5 changes: 5 additions & 0 deletions test/unit/local-branch-file-classifiers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ describe("isCodeFile", () => {
"src/App.vue",
"src/Widget.svelte",
"src/pages/index.astro",
// Dart/Flutter hand-authored source — rag.ts indexes .dart; *_test.dart stays test.
"lib/models/user.dart",
"lib/widgets/card.dart",
]) {
expect(isCodeFile(path)).toBe(true);
}
Expand All @@ -160,6 +163,8 @@ describe("isCodeFile", () => {
"AppTests/LoginTests.swift",
// PHP class-suffix test file (PHPUnit) — code extension, but a test, not code.
"app/Service/PaymentTest.php",
// Dart co-located *_test.dart is test evidence, not source.
"lib/models/user_test.dart",
]) {
expect(isCodeFile(path)).toBe(false);
}
Expand Down
4 changes: 4 additions & 0 deletions test/unit/local-branch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1784,6 +1784,10 @@ describe("local MCP git metadata collection", () => {
expect(isTestFile(file)).toBe(false);
expect(isCodeFile(file)).toBe(true);
}
// Dart/Flutter hand-authored source; *_test.dart remains test-only.
expect(isCodeFile("lib/models/user.dart")).toBe(true);
expect(isTestFile("lib/models/user_test.dart")).toBe(true);
expect(isCodeFile("lib/models/user_test.dart")).toBe(false);
});

it("extracts linked issues only from standalone closing keywords, not keyword substrings", async () => {
Expand Down
21 changes: 21 additions & 0 deletions test/unit/rules.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,27 @@ describe("advisory rules", () => {
}
});

it("flags Missing test evidence for Dart source via isCodePath + isCodeFile parity", () => {
const advisory = buildPullRequestAdvisory(repo, {
repoFullName: repo.fullName, number: 25, title: "Add Dart widget without tests", state: "open",
authorLogin: "contributor", authorAssociation: "NONE", labels: [], linkedIssues: [],
});
const sourcePaths = ["lib/models/user.dart", "lib/widgets/card.dart"];
const files: PullRequestFileRecord[] = sourcePaths.map((path) => ({
repoFullName: repo.fullName, pullNumber: 25, path, additions: 10, deletions: 0, changes: 10, payload: {},
}));
const collisions: CollisionReport = {
repoFullName: repo.fullName, generatedAt: "2026-06-10T00:00:00.000Z",
summary: { clusterCount: 0, highRiskCount: 0, itemsReviewed: 0 }, clusters: [],
};

const { annotations } = buildCheckRunAnnotations(advisory, { files, collisions, pullNumber: 25 }, "standard");

for (const path of sourcePaths) {
expect(annotations.some((entry) => entry.title === "Missing test evidence" && entry.path === path)).toBe(true);
}
});

it("buildCheckRunAnnotations uses notice level for medium-risk collisions and critical public finding text", () => {
const advisory = {
...buildPullRequestAdvisory(repo, null),
Expand Down
14 changes: 7 additions & 7 deletions test/unit/score-preview-script.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,17 +114,17 @@ describe("gittensor-score-preview.mjs classifier parity with the server", () =>
expect(py.nonCodeTokenScore).toBe(0);
});

it("classifies Dart/Flutter *_test.dart as a test in both .mjs and .py previews", () => {
it("classifies Dart/Flutter source and *_test.dart tests in both .mjs and .py previews", () => {
// Parity with src/signals/test-evidence.ts: co-located `foo_test.dart` must count as test evidence,
// not source/non-code, in every mirrored classifier.
// while hand-authored `.dart` source counts as code (rag.ts already indexes .dart).
const files = [
{ path: "lib/models/user_test.dart", additions: 8, deletions: 0 },
{ path: "lib/models/user.dart", additions: 3, deletions: 0 }, // non-code (dart not in isCodeFile)
{ path: "lib/models/user.dart", additions: 3, deletions: 0 },
];
const mjs = runPreview(files);
expect(mjs.testTokenScore).toBe(8);
expect(mjs.sourceTokenScore).toBe(0);
expect(mjs.nonCodeTokenScore).toBe(3);
expect(mjs.sourceTokenScore).toBe(3);
expect(mjs.nonCodeTokenScore).toBe(0);

const python = findPython();
if (!python) return;
Expand All @@ -134,8 +134,8 @@ describe("gittensor-score-preview.mjs classifier parity with the server", () =>
expect(res.status, res.stderr).toBe(0);
const py = JSON.parse(res.stdout);
expect(py.testTokenScore).toBe(8);
expect(py.sourceTokenScore).toBe(0);
expect(py.nonCodeTokenScore).toBe(3);
expect(py.sourceTokenScore).toBe(3);
expect(py.nonCodeTokenScore).toBe(0);
});

it("classifies Vue/Svelte/Astro source as code in both .mjs and .py previews", () => {
Expand Down
Loading