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|c|h|m)$/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|c|h|m|vue|svelte|astro)$/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|c|h|m)$/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|c|h|m|vue|svelte|astro)$/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", ".c", ".h", ".m")):
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", ".c", ".h", ".m", ".vue", ".svelte", ".astro")):
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|c|h|swift|kt|m|sql|yaml|yml|json|toml|md)$/i.test(path);
return /\.(ts|tsx|js|jsx|py|go|rs|java|rb|php|cs|cpp|c|h|swift|kt|m|sql|yaml|yml|json|toml|md|vue|svelte|astro)$/i.test(path);
}

function collisionClustersForPull(collisions: CollisionReport, pullNumber: number): CollisionCluster[] {
Expand Down
7 changes: 4 additions & 3 deletions src/signals/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5538,10 +5538,11 @@ function sanitizeOutcomeDimensionKey(key: string): string {
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).
// isTestPath already recognizes; vue/svelte/astro match rag.ts, visual paths, and isCodePath).
return (
/\.(ts|tsx|mts|cts|js|jsx|mjs|cjs|py|rb|rs|kt|scala|java|go|sql|cs|swift|groovy|php|cpp|c|h|m)$/i.test(file) &&
!isTestFile(file)
/\.(ts|tsx|mts|cts|js|jsx|mjs|cjs|py|rb|rs|kt|scala|java|go|sql|cs|swift|groovy|php|cpp|c|h|m|vue|svelte|astro)$/i.test(
file,
) && !isTestFile(file)
);
}

Expand Down
8 changes: 5 additions & 3 deletions src/signals/local-branch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1270,10 +1270,12 @@ export function isCodeFile(file: string): boolean {
// cs/swift/groovy/php plus C/C++/Objective-C round out the native/JVM/.NET/Swift/PHP set: isTestPath already
// recognizes their `SomethingTest(s)`/`Spec` test files, so their source must
// count as code too — otherwise a C#/Swift/Groovy/PHP/native source file is neither test
// nor code in the local scorer.
// 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.
return (
/\.(ts|tsx|mts|cts|js|jsx|mjs|cjs|py|rb|rs|kt|scala|java|go|sql|cs|swift|groovy|php|cpp|c|h|m)$/i.test(file) &&
!isTestFile(file)
/\.(ts|tsx|mts|cts|js|jsx|mjs|cjs|py|rb|rs|kt|scala|java|go|sql|cs|swift|groovy|php|cpp|c|h|m|vue|svelte|astro)$/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 @@ -131,6 +131,11 @@ describe("isCodeFile", () => {
"src/native/add.cpp",
"include/native/add.h",
"src/objc/View.m",
// Front-end framework source — already indexed as code by rag.ts and flagged
// as visual paths, but must count as code for slop/missing-tests signals.
"src/App.vue",
"src/Widget.svelte",
"src/pages/index.astro",
]) {
expect(isCodeFile(path)).toBe(true);
}
Expand Down
5 changes: 5 additions & 0 deletions test/unit/local-branch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1774,6 +1774,11 @@ describe("local MCP git metadata collection", () => {
expect(isTestFile(file)).toBe(false);
expect(isCodeFile(file)).toBe(true);
}
// Front-end framework source mirrors review/rag.ts and visual-path classifiers.
for (const file of ["src/App.vue", "src/Widget.svelte", "src/pages/index.astro"]) {
expect(isTestFile(file)).toBe(false);
expect(isCodeFile(file)).toBe(true);
}
});

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

it("flags Missing test evidence for Vue/Svelte/Astro source via isCodePath + isCodeFile parity", () => {
// Regression: isCodeFile was updated but advisory.ts isCodePath still excluded .vue/.svelte/.astro,
// so buildCheckRunAnnotations filtered those files out of annotatableFiles before missing_tests ran.
const advisory = buildPullRequestAdvisory(repo, {
repoFullName: repo.fullName, number: 23, title: "Add Svelte component without tests", state: "open",
authorLogin: "contributor", authorAssociation: "NONE", labels: [], linkedIssues: [],
});
const sourcePaths = ["src/App.vue", "src/Widget.svelte", "src/pages/index.astro"];
const files: PullRequestFileRecord[] = sourcePaths.map((path) => ({
repoFullName: repo.fullName, pullNumber: 23, path, additions: 12, deletions: 0, changes: 12, 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: 23 }, "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
26 changes: 26 additions & 0 deletions test/unit/score-preview-script.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,32 @@ describe("gittensor-score-preview.mjs classifier parity with the server", () =>
expect(py.nonCodeTokenScore).toBe(3);
});

it("classifies Vue/Svelte/Astro source as code in both .mjs and .py previews", () => {
// Parity with review/rag.ts CODE_EXT_RE and review/visual/paths.ts: front-end framework
// source must count as code, not non-code, in every mirrored classifier.
const files = [
{ path: "src/App.vue", additions: 6, deletions: 0 },
{ path: "src/Widget.svelte", additions: 4, deletions: 0 },
{ path: "src/pages/index.astro", additions: 5, deletions: 0 },
{ path: "README.md", additions: 2, deletions: 0 }, // non-code control
];
const mjs = runPreview(files);
expect(mjs.sourceTokenScore).toBe(15);
expect(mjs.testTokenScore).toBe(0);
expect(mjs.nonCodeTokenScore).toBe(2);

const python = findPython();
if (!python) return;
const env = { ...process.env };
delete env.GITTENSOR_ROOT;
const res = spawnSync(python, [scriptPy], { input: JSON.stringify({ changedFiles: files }), encoding: "utf8", env });
expect(res.status, res.stderr).toBe(0);
const py = JSON.parse(res.stdout);
expect(py.sourceTokenScore).toBe(15);
expect(py.testTokenScore).toBe(0);
expect(py.nonCodeTokenScore).toBe(2);
});

it("classifies PascalCase PHP test files as tests in both .mjs and .py previews", () => {
// Parity with src/signals/test-evidence.ts: PHPUnit/PHPSpec class-suffix files must not be counted as
// PHP source simply because they live outside a conventional tests/ directory.
Expand Down
Loading