refactor(permission-system): simplify policy and autoreview flow

This commit is contained in:
云服务部-叶林立
2026-09-03 02:01:06 +08:00
parent 180da95ab7
commit 6e7effa792
112 changed files with 911 additions and 10346 deletions
+5 -14
View File
@@ -1,5 +1,5 @@
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
import { getAgentDir, getPackageDir } from "@earendil-works/pi-coding-agent";
import { getAgentDir } from "@earendil-works/pi-coding-agent";
import { warmBashParser } from "./access-intent/bash/parser";
import { buildResolvedIntentFromMatchValues } from "./access-intent/input-normalizer";
import { AuthorizerRegistry } from "./authority/authorizer-registry";
@@ -57,9 +57,7 @@ import { ToolInputFormatterRegistry } from "./tool-input-formatter-registry";
export default function piPermissionSystemExtension(pi: ExtensionAPI): void {
const agentDir = getAgentDir();
// getPackageDir() is Pi's own install dir; auto-allow it for read-only tools
// so the agent can read Pi's bundled docs/examples regardless of layout.
const paths = computeExtensionPaths(agentDir, getPackageDir());
const paths = computeExtensionPaths(agentDir);
// The single process.platform read for the whole extension, resolved once
// into the path-language flavor that every consumer shares (the session's
// PathNormalizer, rule evaluation, and subagent detection). Interior modules
@@ -273,8 +271,6 @@ export default function piPermissionSystemExtension(pi: ExtensionAPI): void {
const toolRegistry = {
getAll: () => pi.getAllTools(),
getActive: () => pi.getActiveTools(),
setActive: (names: string[]) => pi.setActiveTools(names),
};
const audit = new DecisionAudit();
@@ -285,14 +281,9 @@ export default function piPermissionSystemExtension(pi: ExtensionAPI): void {
logger,
audit,
);
const agentPrep = new AgentPrepHandler(
session,
resolver,
toolRegistry,
() => {
void warmBashParser();
},
);
const agentPrep = new AgentPrepHandler(session, resolver, () => {
void warmBashParser();
});
const reporter = new GateDecisionReporter(logger, pi.events);
const gateRunner = new GateRunner(