mirror of
https://bitbucket.org/siakitem/my-pi.git
synced 2026-08-28 08:35:57 +00:00
chore: initialize my-pi extension bundle
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
||||
import fffExtension from "../node_modules/@ff-labs/pi-fff/src/index.ts";
|
||||
|
||||
/** Load FFF as the bundle's canonical `find` and `grep` implementation. */
|
||||
export default function fffOverrideExtension(pi: ExtensionAPI): void {
|
||||
process.env.PI_FFF_MODE = "override";
|
||||
fffExtension(pi);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
import permissionSystemExtension from "../node_modules/@gotgenes/pi-permission-system/src/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-permission-system.json", import.meta.url));
|
||||
|
||||
function deployBundlePermissionConfig(): void {
|
||||
const targetPath = join(getAgentDir(), "extensions", "pi-permission-system", "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 the bundle-owned policy before registering permission hooks. */
|
||||
export default function bundledPermissionSystemExtension(pi: ExtensionAPI): void {
|
||||
deployBundlePermissionConfig();
|
||||
permissionSystemExtension(pi);
|
||||
}
|
||||
Reference in New Issue
Block a user