mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-03-30 22:03:58 +00:00
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com> Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com> Co-authored-by: rekram1-node <rekram1-node@users.noreply.github.com>
27 lines
891 B
TypeScript
27 lines
891 B
TypeScript
import z from "zod"
|
|
import { Tool } from "./tool"
|
|
import path from "path"
|
|
import { LSP } from "../lsp"
|
|
import DESCRIPTION from "./lsp-diagnostics.txt"
|
|
import { Instance } from "../project/instance"
|
|
|
|
export const LspDiagnosticTool = Tool.define("lsp_diagnostics", {
|
|
description: DESCRIPTION,
|
|
parameters: z.object({
|
|
path: z.string().describe("The path to the file to get diagnostics."),
|
|
}),
|
|
execute: async (args) => {
|
|
const normalized = path.isAbsolute(args.path) ? args.path : path.join(Instance.directory, args.path)
|
|
await LSP.touchFile(normalized, true)
|
|
const diagnostics = await LSP.diagnostics()
|
|
const file = diagnostics[normalized]
|
|
return {
|
|
title: path.relative(Instance.worktree, normalized),
|
|
metadata: {
|
|
diagnostics,
|
|
},
|
|
output: file?.length ? file.map(LSP.Diagnostic.pretty).join("\n") : "No errors found",
|
|
}
|
|
},
|
|
})
|