mirror of
https://bitbucket.org/siakitem/my-pi.git
synced 2026-08-28 08:35:57 +00:00
feat: add lsp and auto-permissions stack
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import autoPermissionsExtension from "../node_modules/@ogulcancelik/pi-auto-permissions/index.ts";
|
||||
import { getAgentDir, type ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
||||
import { mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
||||
import { dirname, join } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const BUNDLE_CONFIG_PATH = fileURLToPath(new URL("../config/pi-auto-permissions.json", import.meta.url));
|
||||
|
||||
function deployBundleAutoPermissionsConfig(): void {
|
||||
const targetPath = join(getAgentDir(), "pi-auto-permissions", "config.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.
|
||||
}
|
||||
|
||||
mkdirSync(dirname(targetPath), { recursive: true });
|
||||
const temporaryPath = `${targetPath}.my-pi.tmp`;
|
||||
writeFileSync(temporaryPath, bundledConfig, "utf8");
|
||||
renameSync(temporaryPath, targetPath);
|
||||
}
|
||||
|
||||
/** Deploy contextual Bash review policy before registering auto-permissions. */
|
||||
export default function bundledAutoPermissionsExtension(pi: ExtensionAPI): void {
|
||||
deployBundleAutoPermissionsConfig();
|
||||
autoPermissionsExtension(pi);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
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";
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/** Deploy the bundle-owned LSP config before registering pi-lsp. */
|
||||
export default function bundledLspExtension(pi: ExtensionAPI): void {
|
||||
deployBundleLspConfig();
|
||||
lspExtension(pi);
|
||||
}
|
||||
Reference in New Issue
Block a user