feat(lsp): add directory support to lsp_diagnostics via extension param

- Add isDirectoryPath helper to lsp-client-wrapper.ts
- Create directory-diagnostics.ts with aggregateDiagnosticsForDirectory
- Update diagnostics-tool.ts with extension parameter for directory paths
- Update Atlas agent prompts to use extension param for directory diagnostics
- Add unit tests for isDirectoryPath and aggregateDiagnosticsForDirectory

Fixes #2362
This commit is contained in:
acamq
2026-03-07 13:05:58 -07:00
parent fd9642a6ab
commit 7379e10dd6
9 changed files with 268 additions and 31 deletions
+16 -1
View File
@@ -1,6 +1,6 @@
import { extname, resolve } from "path"
import { fileURLToPath } from "node:url"
import { existsSync } from "fs"
import { existsSync, statSync } from "fs"
import { LSPClient, lspManager } from "./client"
import { findServerForExtension } from "./config"
@@ -33,6 +33,13 @@ export function uriToPath(uri: string): string {
return fileURLToPath(uri)
}
export function isDirectoryPath(filePath: string): boolean {
if (!existsSync(filePath)) {
return false
}
return statSync(filePath).isDirectory()
}
export function formatServerLookupError(result: Exclude<ServerLookupResult, { status: "found" }>): string {
if (result.status === "not_installed") {
const { server, installHint } = result
@@ -70,6 +77,14 @@ export function formatServerLookupError(result: Exclude<ServerLookupResult, { st
export async function withLspClient<T>(filePath: string, fn: (client: LSPClient) => Promise<T>): Promise<T> {
const absPath = resolve(filePath)
if (isDirectoryPath(absPath)) {
throw new Error(
`Directory paths are not supported by this LSP tool. ` +
`Use lsp_diagnostics with the 'extension' parameter for directory diagnostics.`
)
}
const ext = extname(absPath)
const result = findServerForExtension(ext)