@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@staff0rd/assist",
3
- "version": "0.1100.1",
3
+ "version": "0.1101.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -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
- function classify(command: string): Decision {
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: "bash", command }),
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 !== "bash") return undefined;
32
+ if (!POLICED_TOOLS.has(event.toolName)) return undefined;
23
33
 
24
- const command =
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
- if (!ctx.hasUI) return undefined;
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?",