@mzwing/pi-permission-auto-review 0.2.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -2
- package/dist/index.d.ts +2 -74
- package/dist/index.js +199 -423
- package/dist/index.js.map +1 -1
- package/package.json +13 -13
package/README.md
CHANGED
|
@@ -10,7 +10,23 @@ A [Pi](https://github.com/earendil-works/pi) extension that adds Codex-style aut
|
|
|
10
10
|
|
|
11
11
|
Ours is mostly specialized for OpenAI's `codex-auto-review` model, which is trained to evaluate permission requests in the context of a coding assistant. Our extension aims at providing Codex-style automatic permission reviews for Pi's coding agent.
|
|
12
12
|
|
|
13
|
-
The bundled baseline is a Pi-specific adaptation of OpenAI Codex Guardian's [`policy_template.md`](https://github.com/openai/codex/blob/
|
|
13
|
+
The bundled baseline is a Pi-specific adaptation of OpenAI Codex Guardian's [`policy_template.md`](https://github.com/openai/codex/blob/6478a751fde8884b2fdc76486fe23175a8e795d4/codex-rs/core/assets/guardian/policy_template.md) and [`policy.md`](https://github.com/openai/codex/blob/6478a751fde8884b2fdc76486fe23175a8e795d4/codex-rs/core/assets/guardian/policy.md) at revision [`6478a751fde8884b2fdc76486fe23175a8e795d4`](https://github.com/openai/codex/commit/6478a751fde8884b2fdc76486fe23175a8e795d4). It is bundled at build time; the extension never fetches policy text while reviewing an action.
|
|
14
|
+
|
|
15
|
+
Upstream's `Execution Environment` section and its MCP `connected_account_email` rule are deliberately left out: both describe Codex's sandbox and tool surface, which Pi's tool-free reviewer does not have. Upstream's `node_repl_policy.md` is likewise out of scope — it governs `node_repl` / `cua_repl` computer-use tools that Pi does not expose.
|
|
16
|
+
|
|
17
|
+
### Updating the bundled policy
|
|
18
|
+
|
|
19
|
+
`src/upstream.ts` records which Codex files the adaptation tracks and the revision it was last reconciled against. `pnpm sync:policy` reports whether upstream has moved since:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pnpm sync:policy # report only; exits non-zero when upstream moved
|
|
23
|
+
pnpm sync:policy --ref v1.2.3 # resolve against a tag, branch, or commit
|
|
24
|
+
pnpm sync:policy --pin # record the new revision, once you have ported it
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
A run that finds movement lists every commit touching the tracked files since the pinned revision, with links. Port what applies into `src/policy.ts` by hand — the adapted text is a rewrite, not a copy, because Pi's reviewer has no tools and reads a different evidence-provenance model, so upstream wording cannot be dropped in mechanically.
|
|
28
|
+
|
|
29
|
+
Only re-run with `--pin` once that porting is done. `POLICY_REVISION` is written to the permission review log, so a pin that outruns the text would be a false audit record. Bump `PI_ADAPTATION_REVISION` as well when you reword anything Pi-specific. Set `GITHUB_TOKEN` to lift GitHub's anonymous rate limit.
|
|
14
30
|
|
|
15
31
|
## Install
|
|
16
32
|
|
|
@@ -19,7 +35,9 @@ pi install npm:@gotgenes/pi-permission-system # dependency
|
|
|
19
35
|
pi install npm:@mzwing/pi-permission-auto-review
|
|
20
36
|
```
|
|
21
37
|
|
|
22
|
-
Pi 0.
|
|
38
|
+
Pi 0.84.2+ (0.84.x and 0.85.x) and `@gotgenes/pi-permission-system` 27.x, 28.x, or 29.x are required.
|
|
39
|
+
|
|
40
|
+
The authorizer registers itself against the service keyed by its own session id, so a subagent's reviewer lands in the node whose gates actually read it.
|
|
23
41
|
|
|
24
42
|
## Enable
|
|
25
43
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,78 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
import { ExtensionAPI, ModelRegistry, SessionManager } from "@earendil-works/pi-coding-agent";
|
|
4
|
-
//#region src/config.d.ts
|
|
5
|
-
declare const EXTENSION_ID = "pi-permission-auto-review";
|
|
6
|
-
declare const AUTHORIZER_NAME = "auto-review";
|
|
7
|
-
declare const DEFAULT_PROVIDER = "openai-codex";
|
|
8
|
-
declare const DEFAULT_MODEL = "codex-auto-review";
|
|
9
|
-
declare const DEFAULT_TIMEOUT_MS = 9e4;
|
|
10
|
-
declare const CONFIG_SCHEMA_URL = "https://raw.githubusercontent.com/mzwing/pi-packages/main/packages/pi-permission-auto-review/schemas/config.schema.json";
|
|
11
|
-
type AutoReviewConfigSchema = z.ZodObject<{
|
|
12
|
-
$schema: z.ZodOptional<z.ZodString>;
|
|
13
|
-
additionalPolicy: z.ZodOptional<z.ZodString>;
|
|
14
|
-
provider: z.ZodDefault<z.ZodString>;
|
|
15
|
-
model: z.ZodDefault<z.ZodString>;
|
|
16
|
-
reasoning: z.ZodDefault<z.ZodEnum<{
|
|
17
|
-
off: "off";
|
|
18
|
-
minimal: "minimal";
|
|
19
|
-
low: "low";
|
|
20
|
-
medium: "medium";
|
|
21
|
-
high: "high";
|
|
22
|
-
xhigh: "xhigh";
|
|
23
|
-
max: "max";
|
|
24
|
-
}>>;
|
|
25
|
-
timeoutMs: z.ZodDefault<z.ZodNumber>;
|
|
26
|
-
includeBaselinePolicy: z.ZodDefault<z.ZodBoolean>;
|
|
27
|
-
}, z.core.$strict>;
|
|
28
|
-
declare const autoReviewConfigSchema: AutoReviewConfigSchema;
|
|
29
|
-
type AutoReviewConfig = z.infer<typeof autoReviewConfigSchema>;
|
|
30
|
-
interface ConfigIssue {
|
|
31
|
-
sourcePath: string;
|
|
32
|
-
message: string;
|
|
33
|
-
}
|
|
34
|
-
interface LoadConfigResult {
|
|
35
|
-
config: AutoReviewConfig | undefined;
|
|
36
|
-
issues: ConfigIssue[];
|
|
37
|
-
globalPath: string;
|
|
38
|
-
projectPath: string;
|
|
39
|
-
}
|
|
40
|
-
interface LoadConfigOptions {
|
|
41
|
-
cwd: string;
|
|
42
|
-
agentDir?: string;
|
|
43
|
-
readFile?: (path: string) => string | undefined;
|
|
44
|
-
}
|
|
45
|
-
declare function loadAutoReviewConfig(options: LoadConfigOptions): LoadConfigResult;
|
|
46
|
-
declare function buildAutoReviewJsonSchema(): Record<string, unknown>;
|
|
47
|
-
//#endregion
|
|
48
|
-
//#region src/circuit-breaker.d.ts
|
|
49
|
-
declare class DenialCircuitBreaker {
|
|
50
|
-
private consecutiveDenials;
|
|
51
|
-
private recentDenials;
|
|
52
|
-
isOpen(): boolean;
|
|
53
|
-
recordDenied(): void;
|
|
54
|
-
recordNonDenial(): void;
|
|
55
|
-
resetTurn(): void;
|
|
56
|
-
private recordRecent;
|
|
57
|
-
}
|
|
58
|
-
//#endregion
|
|
59
|
-
//#region src/extension.d.ts
|
|
60
|
-
interface ReviewerFactoryOptions {
|
|
61
|
-
config: AutoReviewConfig;
|
|
62
|
-
registry: ModelRegistry;
|
|
63
|
-
sessionManager: Pick<SessionManager, "getBranch">;
|
|
64
|
-
circuitBreaker: DenialCircuitBreaker;
|
|
65
|
-
sessionSignal: AbortSignal;
|
|
66
|
-
}
|
|
67
|
-
interface AutoReviewExtensionDependencies {
|
|
68
|
-
loadConfig?: (cwd: string) => LoadConfigResult;
|
|
69
|
-
getPermissionsService?: () => PermissionsService | undefined;
|
|
70
|
-
createReviewer?: (options: ReviewerFactoryOptions) => Authorizer["authorize"];
|
|
71
|
-
}
|
|
72
|
-
declare function createAutoReviewExtension(pi: ExtensionAPI, dependencies?: AutoReviewExtensionDependencies): void;
|
|
73
|
-
//#endregion
|
|
1
|
+
import { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
74
2
|
//#region src/index.d.ts
|
|
75
3
|
declare function permissionAutoReviewExtension(pi: ExtensionAPI): void;
|
|
76
4
|
//#endregion
|
|
77
|
-
export {
|
|
5
|
+
export { permissionAutoReviewExtension as default };
|
|
78
6
|
//# sourceMappingURL=index.d.ts.map
|