(path: string)
| 80 | |
| 81 | /** Maps a file path to a coarse language bucket (mirrors the backend mapping). */ |
| 82 | export function languageForPath(path: string): string { |
| 83 | const dot = path.lastIndexOf("."); |
| 84 | if (dot < 0) return "unknown"; |
| 85 | const ext = path.slice(dot + 1).toLowerCase(); |
| 86 | const table: Record<string, string> = { |
| 87 | rs: "rust", |
| 88 | ts: "typescript", tsx: "typescript", |
| 89 | js: "javascript", jsx: "javascript", mjs: "javascript", cjs: "javascript", |
| 90 | py: "python", go: "go", java: "java", scala: "scala", sc: "scala", |
| 91 | c: "c", h: "c", |
| 92 | cc: "cpp", cpp: "cpp", cxx: "cpp", hpp: "cpp", hh: "cpp", hxx: "cpp", |
| 93 | kt: "kotlin", kts: "kotlin", cs: "csharp", swift: "swift", rb: "ruby", |
| 94 | php: "php", lua: "lua", zig: "zig", |
| 95 | sh: "shell", bash: "shell", zsh: "shell", |
| 96 | md: "markdown", mdx: "markdown", |
| 97 | json: "json", toml: "toml", yaml: "yaml", yml: "yaml", sql: "sql", |
| 98 | html: "web", css: "web", |
| 99 | }; |
| 100 | return table[ext] || "other"; |
| 101 | } |
| 102 | |
| 103 | /** Buckets the many backend node kinds into a small set of visual families. */ |
| 104 | export function kindFamily(kind: string): string { |
no outgoing calls
no test coverage detected