feat: add hashline editing and TypeScript LSP

This commit is contained in:
云服务部-叶林立
2026-08-19 10:24:03 +08:00
parent 3d431a353d
commit bf8bb42a09
14 changed files with 438 additions and 36 deletions
+8 -19
View File
@@ -1,28 +1,17 @@
import lspExtension from "../node_modules/pi-lsp/extensions/pi-lsp/index.ts";
import { getAgentDir, type ExtensionAPI } from "@earendil-works/pi-coding-agent";
import { readFileSync, renameSync, writeFileSync } from "node:fs";
import { join } from "node:path";
import { fileURLToPath } from "node:url";
import { deployBundleLspConfig } from "./lsp-config.ts";
const BUNDLE_CONFIG_PATH = fileURLToPath(new URL("../config/lsp.json", import.meta.url));
function deployBundleLspConfig(): void {
const targetPath = join(getAgentDir(), "lsp.json");
const bundledConfig = readFileSync(BUNDLE_CONFIG_PATH, "utf8");
try {
if (readFileSync(targetPath, "utf8") === bundledConfig) return;
} catch {
// Missing or unreadable target: replace it with the bundle-owned baseline.
}
const temporaryPath = `${targetPath}.my-pi.tmp`;
writeFileSync(temporaryPath, bundledConfig, "utf8");
renameSync(temporaryPath, targetPath);
}
const TYPESCRIPT_LANGUAGE_SERVER_CLI = fileURLToPath(
new URL("../node_modules/typescript-language-server/lib/cli.mjs", import.meta.url),
);
/** Deploy the bundle-owned LSP config before registering pi-lsp. */
export default function bundledLspExtension(pi: ExtensionAPI): void {
deployBundleLspConfig();
deployBundleLspConfig(getAgentDir(), {
nodeBinary: process.execPath,
serverCliPath: TYPESCRIPT_LANGUAGE_SERVER_CLI,
});
lspExtension(pi);
}