import { Type } from "@sinclair/typebox"; import type { ExtensionAPI } from "../_shared/pi-api.js"; import { errorResult } from "../_shared/pi-api.js"; import { validateParams } from "../_shared/validation.js"; const LspParams = Type.Object({ action: Type.Union([ Type.Literal("diagnostics"), Type.Literal("definition"), Type.Literal("references"), Type.Literal("hover"), Type.Literal("symbols"), Type.Literal("implementation"), Type.Literal("type_definition"), Type.Literal("rename"), Type.Literal("rename_file"), Type.Literal("code_actions"), Type.Literal("status"), Type.Literal("reload"), Type.Literal("capabilities"), Type.Literal("request"), ], { description: "OMP LSP action" }), file: Type.Optional(Type.String({ description: "File path" })), line: Type.Optional(Type.Integer({ minimum: 1, description: "Line number" })), symbol: Type.Optional(Type.String({ description: "Symbol substring" })), query: Type.Optional(Type.String({ description: "Query/filter" })), new_name: Type.Optional(Type.String({ description: "New symbol or destination path" })), apply: Type.Optional(Type.Boolean({ description: "Apply edits" })), timeout: Type.Optional(Type.Integer({ minimum: 1, description: "Request timeout seconds" })), payload: Type.Optional(Type.String({ description: "JSON-encoded raw request params" })), }); export default function lspTool(pi: ExtensionAPI): void { pi.registerTool({ name: "lsp", description: "OMP-shaped LSP contract shell; disabled until the real OMP LSP backend is ported.", parameters: LspParams, async execute(_toolCallId, params, _signal, _update, ctx) { const valid = validateParams(LspParams, params); if (!valid.ok) return valid.result; return errorResult( [ "OMP LSP backend is not ported into miloc-pi yet.", "The previous regex/file-scan implementation was removed because it was not a real language-server surface.", "Port OMP LSP client/config/diagnostics/rename/code_actions behavior before enabling this tool.", ].join("\n"), { owner: "omp-lsp", ported: false, requestedAction: valid.value.action, projectRoot: ctx.session?.projectRoot ?? ctx.cwd, supportsActions: [ "diagnostics", "definition", "references", "hover", "symbols", "implementation", "type_definition", "rename", "rename_file", "code_actions", "status", "reload", "capabilities", "request", ], }, ); }, }); }