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 src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ program
.description("Initialize dora in the current repository")
.option(
"-l, --language <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) => {
Expand Down
2 changes: 1 addition & 1 deletion src/mcp/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
],
Expand Down
40 changes: 30 additions & 10 deletions src/utils/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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<typeof LanguageSchema>;

const ConfigSchema = z.object({
root: z.string().min(1),
scip: z.string().min(1),
Expand Down Expand Up @@ -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
}`,
);
}

Expand Down Expand Up @@ -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";
}
Expand Down Expand Up @@ -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,
},
Expand Down
108 changes: 108 additions & 0 deletions test/utils/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down