@gotgenes/pi-permission-system 6.0.2 → 7.0.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.
@@ -9,14 +9,12 @@ vi.mock("node:os", () => {
9
9
  };
10
10
  });
11
11
 
12
+ import { formatDenyReason } from "../src/denial-messages";
12
13
  import {
13
14
  extractExternalPathsFromBashCommand,
14
15
  extractTokensForPathRules,
15
16
  } from "../src/handlers/gates/bash-path-extractor";
16
- import {
17
- formatBashExternalDirectoryAskPrompt,
18
- formatBashExternalDirectoryDenyReason,
19
- } from "../src/handlers/gates/external-directory-messages";
17
+ import { formatBashExternalDirectoryAskPrompt } from "../src/handlers/gates/external-directory-messages";
20
18
 
21
19
  afterEach(() => {
22
20
  vi.restoreAllMocks();
@@ -859,35 +857,19 @@ describe("formatBashExternalDirectoryAskPrompt", () => {
859
857
  });
860
858
  });
861
859
 
862
- describe("formatBashExternalDirectoryDenyReason", () => {
863
- test("includes command, external paths, and CWD", () => {
864
- const result = formatBashExternalDirectoryDenyReason(
865
- "cat /etc/hosts",
866
- ["/etc/hosts"],
867
- "/projects/my-app",
868
- );
860
+ describe("bash external-directory denial messages (centralized)", () => {
861
+ test("denial message includes command, paths, and extension tag", () => {
862
+ const result = formatDenyReason({
863
+ kind: "bash_external_directory",
864
+ command: "cat /etc/hosts",
865
+ externalPaths: ["/etc/hosts"],
866
+ cwd: "/projects/my-app",
867
+ });
869
868
  expect(result).toContain("cat /etc/hosts");
870
869
  expect(result).toContain("/etc/hosts");
871
870
  expect(result).toContain("/projects/my-app");
872
- });
873
-
874
- test("includes hard stop hint", () => {
875
- const result = formatBashExternalDirectoryDenyReason(
876
- "cat /etc/hosts",
877
- ["/etc/hosts"],
878
- "/projects/my-app",
879
- );
880
- expect(result).toContain("Hard stop");
881
- });
882
-
883
- test("includes agent name when provided", () => {
884
- const result = formatBashExternalDirectoryDenyReason(
885
- "cat /etc/hosts",
886
- ["/etc/hosts"],
887
- "/projects/my-app",
888
- "my-agent",
889
- );
890
- expect(result).toContain("my-agent");
871
+ expect(result).toContain("[pi-permission-system]");
872
+ expect(result).not.toContain("Hard stop");
891
873
  });
892
874
  });
893
875
 
@@ -0,0 +1,517 @@
1
+ import { describe, expect, test } from "vitest";
2
+
3
+ import {
4
+ type DenialContext,
5
+ EXTENSION_TAG,
6
+ formatDenyReason,
7
+ formatUnavailableReason,
8
+ formatUserDeniedReason,
9
+ } from "../src/denial-messages";
10
+ import type { PermissionCheckResult } from "../src/types";
11
+
12
+ // ── Helpers ────────────────────────────────────────────────────────────────
13
+
14
+ function toolCheck(
15
+ toolName: string,
16
+ overrides: Partial<PermissionCheckResult> = {},
17
+ ): PermissionCheckResult {
18
+ return {
19
+ toolName,
20
+ state: "deny",
21
+ source: "tool",
22
+ origin: "builtin",
23
+ ...overrides,
24
+ };
25
+ }
26
+
27
+ function mcpCheck(
28
+ target: string,
29
+ overrides: Partial<PermissionCheckResult> = {},
30
+ ): PermissionCheckResult {
31
+ return {
32
+ toolName: "mcp",
33
+ target,
34
+ state: "deny",
35
+ source: "mcp",
36
+ origin: "builtin",
37
+ ...overrides,
38
+ };
39
+ }
40
+
41
+ function toolCtx(
42
+ check: PermissionCheckResult,
43
+ agentName?: string,
44
+ ): Extract<DenialContext, { kind: "tool" }> {
45
+ return { kind: "tool", check, agentName };
46
+ }
47
+
48
+ // ── EXTENSION_TAG ──────────────────────────────────────────────────────────
49
+
50
+ describe("EXTENSION_TAG", () => {
51
+ test("is [pi-permission-system]", () => {
52
+ expect(EXTENSION_TAG).toBe("[pi-permission-system]");
53
+ });
54
+ });
55
+
56
+ // ── formatDenyReason ───────────────────────────────────────────────────────
57
+
58
+ describe("formatDenyReason", () => {
59
+ describe("tool context", () => {
60
+ test("generic tool without agent", () => {
61
+ expect(formatDenyReason(toolCtx(toolCheck("write")))).toBe(
62
+ "[pi-permission-system] is not permitted to run 'write'.",
63
+ );
64
+ });
65
+
66
+ test("generic tool with agent", () => {
67
+ expect(formatDenyReason(toolCtx(toolCheck("write"), "my-agent"))).toBe(
68
+ "[pi-permission-system] Agent 'my-agent' is not permitted to run 'write'.",
69
+ );
70
+ });
71
+
72
+ test("MCP target", () => {
73
+ expect(formatDenyReason(toolCtx(mcpCheck("server:do-thing")))).toBe(
74
+ "[pi-permission-system] is not permitted to run MCP target 'server:do-thing'.",
75
+ );
76
+ });
77
+
78
+ test("bash with command", () => {
79
+ expect(
80
+ formatDenyReason(toolCtx(toolCheck("bash", { command: "rm -rf /" }))),
81
+ ).toBe(
82
+ "[pi-permission-system] is not permitted to run 'bash' command 'rm -rf /'.",
83
+ );
84
+ });
85
+
86
+ test("bash with command and matched pattern", () => {
87
+ expect(
88
+ formatDenyReason(
89
+ toolCtx(
90
+ toolCheck("bash", {
91
+ command: "rm -rf /",
92
+ matchedPattern: "rm *",
93
+ }),
94
+ ),
95
+ ),
96
+ ).toBe(
97
+ "[pi-permission-system] is not permitted to run 'bash' command 'rm -rf /' (matched 'rm *').",
98
+ );
99
+ });
100
+
101
+ test("MCP source with target on non-mcp toolName", () => {
102
+ expect(
103
+ formatDenyReason(
104
+ toolCtx(
105
+ toolCheck("anything", { source: "mcp", target: "server:tool" }),
106
+ ),
107
+ ),
108
+ ).toBe(
109
+ "[pi-permission-system] is not permitted to run MCP target 'server:tool'.",
110
+ );
111
+ });
112
+ });
113
+
114
+ describe("path context", () => {
115
+ test("without agent", () => {
116
+ expect(
117
+ formatDenyReason({
118
+ kind: "path",
119
+ toolName: "read",
120
+ pathValue: "/etc/passwd",
121
+ }),
122
+ ).toBe(
123
+ "[pi-permission-system] Current agent is not permitted to access path '/etc/passwd' via tool 'read'.",
124
+ );
125
+ });
126
+
127
+ test("with agent", () => {
128
+ expect(
129
+ formatDenyReason({
130
+ kind: "path",
131
+ toolName: "read",
132
+ pathValue: "/etc/passwd",
133
+ agentName: "sec-agent",
134
+ }),
135
+ ).toBe(
136
+ "[pi-permission-system] Agent 'sec-agent' is not permitted to access path '/etc/passwd' via tool 'read'.",
137
+ );
138
+ });
139
+ });
140
+
141
+ describe("external_directory context", () => {
142
+ test("without agent", () => {
143
+ expect(
144
+ formatDenyReason({
145
+ kind: "external_directory",
146
+ toolName: "read",
147
+ pathValue: "/etc/passwd",
148
+ cwd: "/project",
149
+ }),
150
+ ).toBe(
151
+ "[pi-permission-system] Current agent is not permitted to run tool 'read' for path '/etc/passwd' outside working directory '/project'.",
152
+ );
153
+ });
154
+
155
+ test("with agent", () => {
156
+ expect(
157
+ formatDenyReason({
158
+ kind: "external_directory",
159
+ toolName: "read",
160
+ pathValue: "/etc/passwd",
161
+ cwd: "/project",
162
+ agentName: "sec-agent",
163
+ }),
164
+ ).toBe(
165
+ "[pi-permission-system] Agent 'sec-agent' is not permitted to run tool 'read' for path '/etc/passwd' outside working directory '/project'.",
166
+ );
167
+ });
168
+ });
169
+
170
+ describe("bash_external_directory context", () => {
171
+ test("single path without agent", () => {
172
+ expect(
173
+ formatDenyReason({
174
+ kind: "bash_external_directory",
175
+ command: "cat /etc/hosts",
176
+ externalPaths: ["/etc/hosts"],
177
+ cwd: "/project",
178
+ }),
179
+ ).toBe(
180
+ "[pi-permission-system] Current agent is not permitted to run bash command 'cat /etc/hosts' which references path(s) outside working directory '/project': /etc/hosts.",
181
+ );
182
+ });
183
+
184
+ test("multiple paths with agent", () => {
185
+ expect(
186
+ formatDenyReason({
187
+ kind: "bash_external_directory",
188
+ command: "cp /etc/hosts /tmp/out",
189
+ externalPaths: ["/etc/hosts", "/tmp/out"],
190
+ cwd: "/project",
191
+ agentName: "my-agent",
192
+ }),
193
+ ).toBe(
194
+ "[pi-permission-system] Agent 'my-agent' is not permitted to run bash command 'cp /etc/hosts /tmp/out' which references path(s) outside working directory '/project': /etc/hosts, /tmp/out.",
195
+ );
196
+ });
197
+ });
198
+
199
+ describe("bash_path context", () => {
200
+ test("without agent", () => {
201
+ expect(
202
+ formatDenyReason({
203
+ kind: "bash_path",
204
+ command: "cat /etc/passwd",
205
+ pathValue: "/etc/passwd",
206
+ }),
207
+ ).toBe(
208
+ "[pi-permission-system] Current agent is not permitted to access path '/etc/passwd' via tool 'bash'.",
209
+ );
210
+ });
211
+
212
+ test("with agent", () => {
213
+ expect(
214
+ formatDenyReason({
215
+ kind: "bash_path",
216
+ command: "cat /etc/passwd",
217
+ pathValue: "/etc/passwd",
218
+ agentName: "my-agent",
219
+ }),
220
+ ).toBe(
221
+ "[pi-permission-system] Agent 'my-agent' is not permitted to access path '/etc/passwd' via tool 'bash'.",
222
+ );
223
+ });
224
+ });
225
+
226
+ describe("skill_read context", () => {
227
+ test("without agent", () => {
228
+ expect(
229
+ formatDenyReason({
230
+ kind: "skill_read",
231
+ skillName: "librarian",
232
+ readPath: "/skills/librarian/SKILL.md",
233
+ }),
234
+ ).toBe(
235
+ "[pi-permission-system] Current agent is not permitted to access skill 'librarian' via '/skills/librarian/SKILL.md'.",
236
+ );
237
+ });
238
+
239
+ test("with agent", () => {
240
+ expect(
241
+ formatDenyReason({
242
+ kind: "skill_read",
243
+ skillName: "librarian",
244
+ readPath: "/skills/librarian/SKILL.md",
245
+ agentName: "my-agent",
246
+ }),
247
+ ).toBe(
248
+ "[pi-permission-system] Agent 'my-agent' is not permitted to access skill 'librarian' via '/skills/librarian/SKILL.md'.",
249
+ );
250
+ });
251
+ });
252
+ });
253
+
254
+ // ── formatUnavailableReason ────────────────────────────────────────────────
255
+
256
+ describe("formatUnavailableReason", () => {
257
+ test("generic tool", () => {
258
+ expect(formatUnavailableReason(toolCtx(toolCheck("write")))).toBe(
259
+ "[pi-permission-system] Using tool 'write' requires approval, but no interactive UI is available.",
260
+ );
261
+ });
262
+
263
+ test("bash with command", () => {
264
+ expect(
265
+ formatUnavailableReason(
266
+ toolCtx(toolCheck("bash", { command: "git push" })),
267
+ ),
268
+ ).toBe(
269
+ "[pi-permission-system] Running bash command 'git push' requires approval, but no interactive UI is available.",
270
+ );
271
+ });
272
+
273
+ test("mcp", () => {
274
+ expect(formatUnavailableReason(toolCtx(mcpCheck("server:tool")))).toBe(
275
+ "[pi-permission-system] Using tool 'mcp' requires approval, but no interactive UI is available.",
276
+ );
277
+ });
278
+
279
+ test("path", () => {
280
+ expect(
281
+ formatUnavailableReason({
282
+ kind: "path",
283
+ toolName: "read",
284
+ pathValue: "/etc/passwd",
285
+ }),
286
+ ).toBe(
287
+ "[pi-permission-system] Accessing '/etc/passwd' requires approval, but no interactive UI is available.",
288
+ );
289
+ });
290
+
291
+ test("external_directory", () => {
292
+ expect(
293
+ formatUnavailableReason({
294
+ kind: "external_directory",
295
+ toolName: "read",
296
+ pathValue: "/etc/passwd",
297
+ cwd: "/project",
298
+ }),
299
+ ).toBe(
300
+ "[pi-permission-system] Accessing '/etc/passwd' outside the working directory requires approval, but no interactive UI is available.",
301
+ );
302
+ });
303
+
304
+ test("bash_external_directory", () => {
305
+ expect(
306
+ formatUnavailableReason({
307
+ kind: "bash_external_directory",
308
+ command: "cat /etc/hosts",
309
+ externalPaths: ["/etc/hosts"],
310
+ cwd: "/project",
311
+ }),
312
+ ).toBe(
313
+ "[pi-permission-system] Bash command 'cat /etc/hosts' references path(s) outside the working directory and requires approval, but no interactive UI is available.",
314
+ );
315
+ });
316
+
317
+ test("bash_path", () => {
318
+ expect(
319
+ formatUnavailableReason({
320
+ kind: "bash_path",
321
+ command: "cat /etc/passwd",
322
+ pathValue: "/etc/passwd",
323
+ }),
324
+ ).toBe(
325
+ "[pi-permission-system] Bash command 'cat /etc/passwd' accesses path '/etc/passwd' which requires approval, but no interactive UI is available.",
326
+ );
327
+ });
328
+
329
+ test("skill_read", () => {
330
+ expect(
331
+ formatUnavailableReason({
332
+ kind: "skill_read",
333
+ skillName: "librarian",
334
+ readPath: "/skills/librarian/SKILL.md",
335
+ }),
336
+ ).toBe(
337
+ "[pi-permission-system] Accessing skill 'librarian' requires approval, but no interactive UI is available.",
338
+ );
339
+ });
340
+ });
341
+
342
+ // ── formatUserDeniedReason ─────────────────────────────────────────────────
343
+
344
+ describe("formatUserDeniedReason", () => {
345
+ describe("tool context", () => {
346
+ test("generic tool without reason", () => {
347
+ expect(formatUserDeniedReason(toolCtx(toolCheck("write")))).toBe(
348
+ "[pi-permission-system] User denied tool 'write'.",
349
+ );
350
+ });
351
+
352
+ test("generic tool with reason", () => {
353
+ expect(
354
+ formatUserDeniedReason(toolCtx(toolCheck("write")), "too risky"),
355
+ ).toBe(
356
+ "[pi-permission-system] User denied tool 'write'. Reason: too risky.",
357
+ );
358
+ });
359
+
360
+ test("bash with command", () => {
361
+ expect(
362
+ formatUserDeniedReason(
363
+ toolCtx(toolCheck("bash", { command: "ls -la" })),
364
+ ),
365
+ ).toBe("[pi-permission-system] User denied bash command 'ls -la'.");
366
+ });
367
+
368
+ test("MCP target", () => {
369
+ expect(formatUserDeniedReason(toolCtx(mcpCheck("server:query")))).toBe(
370
+ "[pi-permission-system] User denied MCP target 'server:query'.",
371
+ );
372
+ });
373
+ });
374
+
375
+ describe("path context", () => {
376
+ test("without reason", () => {
377
+ expect(
378
+ formatUserDeniedReason({
379
+ kind: "path",
380
+ toolName: "read",
381
+ pathValue: "/etc/passwd",
382
+ }),
383
+ ).toBe(
384
+ "[pi-permission-system] User denied access to path '/etc/passwd'.",
385
+ );
386
+ });
387
+
388
+ test("with reason", () => {
389
+ expect(
390
+ formatUserDeniedReason(
391
+ { kind: "path", toolName: "read", pathValue: "/etc/passwd" },
392
+ "sensitive",
393
+ ),
394
+ ).toBe(
395
+ "[pi-permission-system] User denied access to path '/etc/passwd'. Reason: sensitive.",
396
+ );
397
+ });
398
+ });
399
+
400
+ describe("external_directory context", () => {
401
+ test("without reason", () => {
402
+ expect(
403
+ formatUserDeniedReason({
404
+ kind: "external_directory",
405
+ toolName: "edit",
406
+ pathValue: "/etc/hosts",
407
+ cwd: "/project",
408
+ }),
409
+ ).toBe(
410
+ "[pi-permission-system] User denied external directory access for tool 'edit' path '/etc/hosts'.",
411
+ );
412
+ });
413
+
414
+ test("with reason", () => {
415
+ expect(
416
+ formatUserDeniedReason(
417
+ {
418
+ kind: "external_directory",
419
+ toolName: "edit",
420
+ pathValue: "/etc/hosts",
421
+ cwd: "/project",
422
+ },
423
+ "too risky",
424
+ ),
425
+ ).toBe(
426
+ "[pi-permission-system] User denied external directory access for tool 'edit' path '/etc/hosts'. Reason: too risky.",
427
+ );
428
+ });
429
+ });
430
+
431
+ describe("bash_external_directory context", () => {
432
+ test("without reason", () => {
433
+ expect(
434
+ formatUserDeniedReason({
435
+ kind: "bash_external_directory",
436
+ command: "rm /etc/hosts",
437
+ externalPaths: ["/etc/hosts"],
438
+ cwd: "/project",
439
+ }),
440
+ ).toBe(
441
+ "[pi-permission-system] User denied external directory access for bash command 'rm /etc/hosts'.",
442
+ );
443
+ });
444
+
445
+ test("with reason", () => {
446
+ expect(
447
+ formatUserDeniedReason(
448
+ {
449
+ kind: "bash_external_directory",
450
+ command: "rm /etc/hosts",
451
+ externalPaths: ["/etc/hosts"],
452
+ cwd: "/project",
453
+ },
454
+ "dangerous",
455
+ ),
456
+ ).toBe(
457
+ "[pi-permission-system] User denied external directory access for bash command 'rm /etc/hosts'. Reason: dangerous.",
458
+ );
459
+ });
460
+ });
461
+
462
+ describe("bash_path context", () => {
463
+ test("without reason", () => {
464
+ expect(
465
+ formatUserDeniedReason({
466
+ kind: "bash_path",
467
+ command: "cat /etc/passwd",
468
+ pathValue: "/etc/passwd",
469
+ }),
470
+ ).toBe(
471
+ "[pi-permission-system] User denied path access for bash command 'cat /etc/passwd' (path '/etc/passwd').",
472
+ );
473
+ });
474
+
475
+ test("with reason", () => {
476
+ expect(
477
+ formatUserDeniedReason(
478
+ {
479
+ kind: "bash_path",
480
+ command: "cat /etc/passwd",
481
+ pathValue: "/etc/passwd",
482
+ },
483
+ "sensitive",
484
+ ),
485
+ ).toBe(
486
+ "[pi-permission-system] User denied path access for bash command 'cat /etc/passwd' (path '/etc/passwd'). Reason: sensitive.",
487
+ );
488
+ });
489
+ });
490
+
491
+ describe("skill_read context", () => {
492
+ test("without reason", () => {
493
+ expect(
494
+ formatUserDeniedReason({
495
+ kind: "skill_read",
496
+ skillName: "librarian",
497
+ readPath: "/skills/librarian/SKILL.md",
498
+ }),
499
+ ).toBe("[pi-permission-system] User denied access to skill 'librarian'.");
500
+ });
501
+
502
+ test("with reason", () => {
503
+ expect(
504
+ formatUserDeniedReason(
505
+ {
506
+ kind: "skill_read",
507
+ skillName: "librarian",
508
+ readPath: "/skills/librarian/SKILL.md",
509
+ },
510
+ "not needed",
511
+ ),
512
+ ).toBe(
513
+ "[pi-permission-system] User denied access to skill 'librarian'. Reason: not needed.",
514
+ );
515
+ });
516
+ });
517
+ });
@@ -11,12 +11,8 @@
11
11
  import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
12
12
  import { describe, expect, it, vi } from "vitest";
13
13
 
14
- import {
15
- formatExternalDirectoryAskPrompt,
16
- formatExternalDirectoryDenyReason,
17
- formatExternalDirectoryHardStopHint,
18
- formatExternalDirectoryUserDeniedReason,
19
- } from "../../src/handlers/gates/external-directory-messages";
14
+ import { EXTENSION_TAG } from "../../src/denial-messages";
15
+ import { formatExternalDirectoryAskPrompt } from "../../src/handlers/gates/external-directory-messages";
20
16
  import { PermissionGateHandler } from "../../src/handlers/permission-gate-handler";
21
17
  import {
22
18
  PERMISSIONS_DECISION_CHANNEL,
@@ -177,11 +173,6 @@ function getDecisionEvents(
177
173
  // ── Regression guard: helper presence ──────────────────────────────────────
178
174
 
179
175
  describe("external_directory helper regression guard", () => {
180
- it("formatExternalDirectoryHardStopHint is a callable function", () => {
181
- expect(typeof formatExternalDirectoryHardStopHint).toBe("function");
182
- expect(formatExternalDirectoryHardStopHint()).toContain("Hard stop");
183
- });
184
-
185
176
  it("formatExternalDirectoryAskPrompt is a callable function", () => {
186
177
  expect(typeof formatExternalDirectoryAskPrompt).toBe("function");
187
178
  expect(
@@ -189,19 +180,13 @@ describe("external_directory helper regression guard", () => {
189
180
  ).toContain("/outside/file");
190
181
  });
191
182
 
192
- it("formatExternalDirectoryDenyReason is a callable function", () => {
193
- expect(typeof formatExternalDirectoryDenyReason).toBe("function");
194
- expect(
195
- formatExternalDirectoryDenyReason("read", "/outside/file", "/project"),
196
- ).toContain("Hard stop");
183
+ it("EXTENSION_TAG is the expected value", () => {
184
+ expect(EXTENSION_TAG).toBe("[pi-permission-system]");
197
185
  });
198
186
 
199
- it("formatExternalDirectoryUserDeniedReason is a callable function", () => {
200
- expect(typeof formatExternalDirectoryUserDeniedReason).toBe("function");
201
- expect(
202
- formatExternalDirectoryUserDeniedReason("read", "/outside/file"),
203
- ).toContain("User denied");
204
- });
187
+ // formatExternalDirectoryDenyReason, formatExternalDirectoryUserDeniedReason,
188
+ // and formatExternalDirectoryHardStopHint have moved to denial-messages.ts.
189
+ // Their behavior is tested in denial-messages.test.ts.
205
190
  });
206
191
 
207
192
  // ── Path scope: gate applicability ────────────────────────────────────────
@@ -386,13 +371,14 @@ describe("external_directory policy state — deny", () => {
386
371
  expect(result.reason).toContain(EXTERNAL_PATH);
387
372
  });
388
373
 
389
- it("block reason contains the hard-stop hint", async () => {
374
+ it("block reason contains extension attribution", async () => {
390
375
  const { handler } = makeHandler({
391
376
  session: { checkPermission: makeCheckPermission("deny") },
392
377
  });
393
378
  const event = makeToolCallEvent("read", { path: EXTERNAL_PATH });
394
379
  const result = await handler.handleToolCall(event, makeCtx());
395
- expect(result.reason).toContain("Hard stop");
380
+ expect(result.reason).toContain("[pi-permission-system]");
381
+ expect(result.reason).not.toContain("Hard stop");
396
382
  });
397
383
 
398
384
  it("writes review-log entry with resolution policy_denied", async () => {
@@ -142,15 +142,18 @@ describe("describeBashExternalDirectoryGate", () => {
142
142
  expect(desc.decision.surface).toBe("external_directory");
143
143
  });
144
144
 
145
- it("messages contain the command", async () => {
145
+ it("denialContext contains the command and external paths", async () => {
146
146
  const result = await describeBashExternalDirectoryGate(
147
147
  makeTcc({ input: { command: "cat /outside/file.ts" } }),
148
148
  vi.fn().mockReturnValue(makeCheckResult("ask")),
149
149
  vi.fn().mockReturnValue([]),
150
150
  );
151
151
  const desc = result as GateDescriptor;
152
- expect(desc.messages.denyReason).toContain("cat /outside/file.ts");
153
- expect(desc.messages.unavailableReason).toContain("cat /outside/file.ts");
152
+ expect(desc.denialContext).toMatchObject({
153
+ kind: "bash_external_directory",
154
+ command: "cat /outside/file.ts",
155
+ cwd: "/test/project",
156
+ });
154
157
  });
155
158
 
156
159
  it("promptDetails includes command and tool_call source", async () => {
@@ -144,7 +144,11 @@ describe("describeBashPathGate", () => {
144
144
  checkPermission,
145
145
  getSessionRuleset,
146
146
  )) as GateDescriptor;
147
- expect(result.messages.denyReason).toContain(".env");
147
+ expect(result.denialContext).toMatchObject({
148
+ kind: "bash_path",
149
+ command: "cat .env",
150
+ pathValue: ".env",
151
+ });
148
152
  expect(result.promptDetails.message).toContain(".env");
149
153
  });
150
154