diff --git a/src/index.ts b/src/index.ts index 31be0e0..6b1fa1e 100755 --- a/src/index.ts +++ b/src/index.ts @@ -53,7 +53,7 @@ program .description("Initialize dora in the current repository") .option( "-l, --language ", - "Project language (typescript, javascript, python, rust, go, java)", + "Project language (typescript, javascript, python, rust, go, java, scala, kotlin, dart, ruby, c, cpp, php, csharp, visualbasic)", ) .action( wrapCommand(async (options) => { diff --git a/src/mcp/metadata.ts b/src/mcp/metadata.ts index 3c32dbc..138bd3d 100644 --- a/src/mcp/metadata.ts +++ b/src/mcp/metadata.ts @@ -25,7 +25,7 @@ export const toolsMetadata: ToolMetadata[] = [ name: "language", type: "string", description: - "Project language (typescript, javascript, python, rust, go, java)", + "Project language (typescript, javascript, python, rust, go, java, scala, kotlin, dart, ruby, c, cpp, php, csharp, visualbasic)", required: false, }, ], diff --git a/src/utils/config.ts b/src/utils/config.ts index ad9e88f..e935536 100644 --- a/src/utils/config.ts +++ b/src/utils/config.ts @@ -2,7 +2,7 @@ import { existsSync, readFileSync } from "fs"; import { join } from "path"; -import { ZodError, z } from "zod"; +import { z } from "zod"; import { CtxError } from "./errors.ts"; import { findRepoRoot, @@ -29,8 +29,19 @@ export const LanguageSchema = z.enum([ "rust", "go", "java", + "scala", + "kotlin", + "dart", + "ruby", + "c", + "cpp", + "php", + "csharp", + "visualbasic", ]); +export type Language = z.infer; + const ConfigSchema = z.object({ root: z.string().min(1), scip: z.string().min(1), @@ -110,7 +121,9 @@ export function validateConfig(data: unknown): Config { } const field = firstError.path.join("."); throw new CtxError( - `Invalid config: ${field ? `field '${field}' ` : ""}${firstError.message}`, + `Invalid config: ${field ? `field '${field}' ` : ""}${ + firstError.message + }`, ); } @@ -196,7 +209,21 @@ function detectIndexerCommand(params: { case "go": return "scip-go --output .dora/index.scip"; case "java": + case "scala": + case "kotlin": return "scip-java index --output .dora/index.scip"; + case "dart": + return "scip-dart index --output .dora/index.scip"; + case "ruby": + return "scip-ruby index --output .dora/index.scip"; + case "c": + case "cpp": + return "scip-clang index --output .dora/index.scip"; + case "php": + return "scip-php index --output .dora/index.scip"; + case "csharp": + case "visualbasic": + return "scip-csharp index --output .dora/index.scip"; default: return "scip-typescript index --output .dora/index.scip"; } @@ -273,14 +300,7 @@ export function createDefaultConfig(params: { root: params.root, scip: ".dora/index.scip", db: ".dora/dora.db", - language: params.language as - | "typescript" - | "javascript" - | "python" - | "rust" - | "go" - | "java" - | undefined, + language: params.language as Language | undefined, commands: { index: indexCommand, }, diff --git a/test/utils/config.test.ts b/test/utils/config.test.ts index 0756952..ed775e8 100644 --- a/test/utils/config.test.ts +++ b/test/utils/config.test.ts @@ -288,6 +288,114 @@ describe("Config Management", () => { ); }); + test("should use csharp indexer when language is csharp", async () => { + const config = createDefaultConfig({ + root: tempDir, + language: "csharp", + }); + + expect(config.language).toBe("csharp"); + expect(config.commands?.index).toBe( + "scip-csharp index --output .dora/index.scip", + ); + }); + + test("should use csharp indexer when language is visualbasic", async () => { + const config = createDefaultConfig({ + root: tempDir, + language: "visualbasic", + }); + + expect(config.language).toBe("visualbasic"); + expect(config.commands?.index).toBe( + "scip-csharp index --output .dora/index.scip", + ); + }); + + test("should use java indexer when language is java", async () => { + const config = createDefaultConfig({ + root: tempDir, + language: "java", + }); + + expect(config.language).toBe("java"); + expect(config.commands?.index).toBe( + "scip-java index --output .dora/index.scip", + ); + }); + + test("should use java indexer when language is kotlin", async () => { + const config = createDefaultConfig({ + root: tempDir, + language: "kotlin", + }); + + expect(config.language).toBe("kotlin"); + expect(config.commands?.index).toBe( + "scip-java index --output .dora/index.scip", + ); + }); + + test("should use java indexer when language is scala", async () => { + const config = createDefaultConfig({ + root: tempDir, + language: "scala", + }); + + expect(config.language).toBe("scala"); + expect(config.commands?.index).toBe( + "scip-java index --output .dora/index.scip", + ); + }); + + test("should use ruby indexer when language is ruby", async () => { + const config = createDefaultConfig({ + root: tempDir, + language: "ruby", + }); + + expect(config.language).toBe("ruby"); + expect(config.commands?.index).toBe( + "scip-ruby index --output .dora/index.scip", + ); + }); + + test("should use dart indexer when language is dart", async () => { + const config = createDefaultConfig({ + root: tempDir, + language: "dart", + }); + + expect(config.language).toBe("dart"); + expect(config.commands?.index).toBe( + "scip-dart index --output .dora/index.scip", + ); + }); + + test("should use clang indexer when language is c", async () => { + const config = createDefaultConfig({ + root: tempDir, + language: "c", + }); + + expect(config.language).toBe("c"); + expect(config.commands?.index).toBe( + "scip-clang index --output .dora/index.scip", + ); + }); + + test("should use clang indexer when language is cpp", async () => { + const config = createDefaultConfig({ + root: tempDir, + language: "cpp", + }); + + expect(config.language).toBe("cpp"); + expect(config.commands?.index).toBe( + "scip-clang index --output .dora/index.scip", + ); + }); + test("should use go indexer when language is go", async () => { const config = createDefaultConfig({ root: tempDir,