Turbocharge Claude Code, Cursor, Codex, Gemini & every coding agent: faster, cheaper, with contextual understanding specific to your codebase.
TypeScript ai-agentsanthropicclaude-codeclicode-graphcodexcontext-engineeringcursordeveloper-toolsgeminiknowledge-graphllmmcpmcp-serveropen-sourceopenaitree-sitter
test(lsp): registry selection + graceful no-op when no server
Shrish Dwivedi341fab916b58
diff --git a/test/lsp-enrich.test.ts b/test/lsp-enrich.test.tsnew file mode 100644index 00000000..8e87d1c2--- /dev/null+++ b/test/lsp-enrich.test.ts@@ -0,0 +1,44 @@+/**+ * LSP enrichment tier: registry selection + graceful degradation. These run+ * without any language server installed — they assert the OPT-IN promise that+ * `graft build --lsp` is a safe no-op when no server applies (never a crash,+ * never a mutated graph), which is the contract the build relies on.+ */+import { test } from "node:test";+import assert from "node:assert/strict";+import { pickServer, LSP_SERVERS } from "../src/graph/lsp/registry.js";+import { enrichWithLsp } from "../src/graph/lsp/enrich.js";+import type { GraphV1 } from "../src/graph/types.js";++test("pickServer: no languages present → no server", () => {+ assert.equal(pickServer(new Set()), null);+});++test("pickServer: a language no registered server covers → null", () => {+ assert.equal(pickServer(new Set(["cobol", "fortran"])), null);+});++test("registry rows are well-formed (languages, command, languageId)", () => {+ for (const s of LSP_SERVERS) {+ assert.ok(s.languages.length > 0 && s.command && s.languageId, `${s.command} row shape`);+ assert.ok(Array.isArray(s.args), `${s.command} args is an array`);+ }+});++test("enrichWithLsp is a no-op when no server matches the repo's languages", async () => {+ // A graph whose only file is an unsupported language → no server is picked →+ // no process spawned, graph returned unchanged.+ const graph: GraphV1 = {+ meta: { version: 1, nodeCount: 1, edgeCount: 0, languages: ["text"], scopes: [] },+ nodes: [+ { id: "notes.txt", name: "notes.txt", kind: "file", path: "notes.txt", span: "L1-L1",+ signature: null, exported: true, origin: "ast", body_hash: "x", summary_state: "pending", summary: null, crux: null },+ ],+ edges: [],+ };+ const before = graph.edges.length;+ const r = await enrichWithLsp(graph, "/tmp/does-not-matter");+ assert.equal(r.server, null, "no server selected for an unsupported language");+ assert.equal(r.added, 0);+ assert.equal(graph.edges.length, before, "graph edges untouched");+});