Skip to content
Closed
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
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).
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 and
// review/visual/paths.ts so front-end framework source is not misclassified as "other".
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
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