@staff0rd/assist 0.1100.1 → 0.1101.0
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/dist/built-version +1 -1
- package/dist/commands/extension/extension/content.js +39 -39
- package/dist/commands/sessions/web/bundle.js +444 -444
- package/dist/index.js +1454 -1128
- package/package.json +1 -1
- package/pi/permission-gate.ts +17 -9
package/package.json
CHANGED
package/pi/permission-gate.ts
CHANGED
|
@@ -3,10 +3,20 @@ import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
|
3
3
|
|
|
4
4
|
type Decision = { decision: "allow" | "deny" | "gate"; reason?: string };
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
const POLICED_TOOLS = new Set([
|
|
7
|
+
"bash",
|
|
8
|
+
"read",
|
|
9
|
+
"write",
|
|
10
|
+
"edit",
|
|
11
|
+
"grep",
|
|
12
|
+
"find",
|
|
13
|
+
"ls",
|
|
14
|
+
]);
|
|
15
|
+
|
|
16
|
+
function classify(toolName: string, input: unknown): Decision {
|
|
7
17
|
try {
|
|
8
18
|
const result = spawnSync("assist", ["pi-hook"], {
|
|
9
|
-
input: JSON.stringify({ toolName
|
|
19
|
+
input: JSON.stringify({ toolName, input }),
|
|
10
20
|
encoding: "utf8",
|
|
11
21
|
});
|
|
12
22
|
const out = result.stdout?.trim();
|
|
@@ -19,13 +29,9 @@ function classify(command: string): Decision {
|
|
|
19
29
|
|
|
20
30
|
export default function (pi: ExtensionAPI) {
|
|
21
31
|
pi.on("tool_call", async (event, ctx) => {
|
|
22
|
-
if (event.toolName
|
|
32
|
+
if (!POLICED_TOOLS.has(event.toolName)) return undefined;
|
|
23
33
|
|
|
24
|
-
const
|
|
25
|
-
typeof event.input.command === "string" ? event.input.command.trim() : "";
|
|
26
|
-
if (!command) return undefined;
|
|
27
|
-
|
|
28
|
-
const { decision, reason } = classify(command);
|
|
34
|
+
const { decision, reason } = classify(event.toolName, event.input);
|
|
29
35
|
|
|
30
36
|
if (decision === "allow") return undefined;
|
|
31
37
|
if (decision === "deny")
|
|
@@ -34,7 +40,9 @@ export default function (pi: ExtensionAPI) {
|
|
|
34
40
|
reason: reason ?? "Denied by the assist allowlist",
|
|
35
41
|
};
|
|
36
42
|
|
|
37
|
-
|
|
43
|
+
const command =
|
|
44
|
+
typeof event.input.command === "string" ? event.input.command.trim() : "";
|
|
45
|
+
if (!ctx.hasUI || event.toolName !== "bash" || !command) return undefined;
|
|
38
46
|
|
|
39
47
|
const choice = await ctx.ui.select(
|
|
40
48
|
"Command not in the assist allowlist:\n\n " + command + "\n\nRun it?",
|