Skip to content

Commit f961aff

Browse files
Fix project type detection using scanned file extensions
- Run extension fallback for both Unknown and generic types - Skip non-code extensions (svg, png, etc.) when finding dominant type - Add HTML/CSS, TypeScript, JavaScript to extension type map Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 2a4cbe6 commit f961aff

File tree

2 files changed

+19
-15
lines changed

2 files changed

+19
-15
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "codeep",
3-
"version": "1.2.129",
3+
"version": "1.2.130",
44
"description": "AI-powered coding assistant built for the terminal. Multiple LLM providers, project-aware context, and a seamless development workflow.",
55
"type": "module",
66
"main": "dist/index.js",

src/utils/project.ts

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -449,23 +449,27 @@ export function getProjectContext(dir: string = process.cwd()): ProjectContext |
449449
try {
450450
const files = scanDirectory(dir, 3);
451451
const isProject = isProjectDirectory(dir);
452-
let projectType = isProject ? getProjectType(dir) : 'generic';
453-
// If still Unknown, use scanned file extensions to detect type
454-
if (projectType === 'Unknown') {
452+
let projectType = isProject ? getProjectType(dir) : 'Unknown';
453+
// Fallback: detect type from scanned file extensions
454+
if (projectType === 'Unknown' || projectType === 'generic') {
455455
const extCounts: Record<string, number> = {};
456456
files.filter(f => !f.isDirectory).forEach(f => {
457-
const ext = f.path.split('.').pop()?.toLowerCase() || '';
458-
if (ext) extCounts[ext] = (extCounts[ext] || 0) + 1;
457+
const ext = (f.path.split('.').pop() || '').toLowerCase();
458+
if (ext && ext.length <= 6) extCounts[ext] = (extCounts[ext] || 0) + 1;
459459
});
460-
const dominant = Object.entries(extCounts).sort((a, b) => b[1] - a[1])[0];
461-
if (dominant) {
462-
const extTypeMap: Record<string, string> = {
463-
php: 'PHP', py: 'Python', rb: 'Ruby', java: 'Java',
464-
kt: 'Kotlin', swift: 'Swift', cs: 'C#', cpp: 'C++',
465-
c: 'C/C++', ex: 'Elixir', exs: 'Elixir', dart: 'Dart/Flutter',
466-
};
467-
projectType = extTypeMap[dominant[0]] || 'Unknown';
468-
}
460+
const extTypeMap: Record<string, string> = {
461+
php: 'PHP', py: 'Python', rb: 'Ruby', java: 'Java',
462+
kt: 'Kotlin', swift: 'Swift', cs: 'C#', cpp: 'C++',
463+
c: 'C/C++', ex: 'Elixir', exs: 'Elixir', dart: 'Dart/Flutter',
464+
html: 'HTML/CSS', htm: 'HTML/CSS', css: 'HTML/CSS',
465+
ts: 'TypeScript', js: 'JavaScript',
466+
};
467+
// Skip non-code extensions when finding dominant type
468+
const skipExt = new Set(['svg', 'png', 'jpg', 'jpeg', 'gif', 'ico', 'ttf', 'woff', 'woff2', 'eot', 'map', 'lock', 'md', 'txt', 'json', 'xml', 'yml', 'yaml', 'env', 'z', 'sql']);
469+
const codeDominant = Object.entries(extCounts)
470+
.filter(([ext]) => !skipExt.has(ext) && extTypeMap[ext])
471+
.sort((a, b) => b[1] - a[1])[0];
472+
if (codeDominant) projectType = extTypeMap[codeDominant[0]];
469473
}
470474
const structure = generateTreeStructure(files, 25);
471475

0 commit comments

Comments
 (0)