@gotgenes/pi-permission-system 5.11.0 → 5.14.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.
Files changed (41) hide show
  1. package/CHANGELOG.md +78 -0
  2. package/package.json +7 -7
  3. package/src/active-agent.ts +1 -1
  4. package/src/config-modal.ts +2 -2
  5. package/src/extension-config.ts +2 -139
  6. package/src/forwarded-permissions/polling.ts +1 -1
  7. package/src/forwarding-manager.ts +1 -1
  8. package/src/handlers/before-agent-start.ts +1 -1
  9. package/src/handlers/lifecycle.ts +1 -1
  10. package/src/handlers/permission-gate-handler.ts +1 -1
  11. package/src/index.ts +1 -1
  12. package/src/logging.ts +4 -12
  13. package/src/permission-event-rpc.ts +1 -1
  14. package/src/permission-prompter.ts +1 -1
  15. package/src/permission-session.ts +1 -1
  16. package/src/policy-loader.ts +1 -1
  17. package/src/runtime.ts +1 -1
  18. package/src/status.ts +1 -1
  19. package/src/subagent-context.ts +1 -1
  20. package/src/wildcard-matcher.ts +11 -3
  21. package/tests/active-agent.test.ts +1 -1
  22. package/tests/config-modal.test.ts +22 -12
  23. package/tests/config-reporter.test.ts +2 -0
  24. package/tests/extension-config.test.ts +1 -60
  25. package/tests/forwarding-manager.test.ts +1 -1
  26. package/tests/handlers/before-agent-start.test.ts +3 -3
  27. package/tests/handlers/external-directory-integration.test.ts +609 -0
  28. package/tests/handlers/external-directory-session-dedup.test.ts +367 -0
  29. package/tests/handlers/gates/skill-read.test.ts +2 -2
  30. package/tests/handlers/input-events.test.ts +1 -1
  31. package/tests/handlers/input.test.ts +1 -1
  32. package/tests/handlers/lifecycle.test.ts +1 -1
  33. package/tests/handlers/tool-call-events.test.ts +1 -1
  34. package/tests/handlers/tool-call.test.ts +3 -3
  35. package/tests/permission-event-rpc.test.ts +1 -1
  36. package/tests/permission-prompter.test.ts +1 -1
  37. package/tests/permission-session.test.ts +1 -1
  38. package/tests/permission-system.test.ts +1 -122
  39. package/tests/runtime.test.ts +1 -1
  40. package/tests/subagent-context.test.ts +1 -1
  41. package/tests/wildcard-matcher.test.ts +91 -0
@@ -243,6 +243,97 @@ describe("wildcardMatch", () => {
243
243
  expect(wildcardMatch("tool.name", "tool.name")).toBe(true);
244
244
  expect(wildcardMatch("tool.name", "toolXname")).toBe(false);
245
245
  });
246
+
247
+ describe("trailing wildcard optionality", () => {
248
+ test("'git *' matches bare 'git' (trailing space+wildcard is optional)", () => {
249
+ expect(wildcardMatch("git *", "git")).toBe(true);
250
+ });
251
+
252
+ test("'git *' still matches 'git status' (existing behaviour preserved)", () => {
253
+ expect(wildcardMatch("git *", "git status")).toBe(true);
254
+ });
255
+
256
+ test("'git *' still matches 'git status --short'", () => {
257
+ expect(wildcardMatch("git *", "git status --short")).toBe(true);
258
+ });
259
+
260
+ test("'git *' does not match an unrelated command", () => {
261
+ expect(wildcardMatch("git *", "npm install")).toBe(false);
262
+ });
263
+
264
+ test("'git status *' matches bare 'git status'", () => {
265
+ expect(wildcardMatch("git status *", "git status")).toBe(true);
266
+ });
267
+
268
+ test("'git status *' matches 'git status --short'", () => {
269
+ expect(wildcardMatch("git status *", "git status --short")).toBe(true);
270
+ });
271
+
272
+ test("non-trailing '*' is unaffected: 'g*t' does not match 'g' or 't'", () => {
273
+ expect(wildcardMatch("g*t", "g")).toBe(false);
274
+ expect(wildcardMatch("g*t", "t")).toBe(false);
275
+ });
276
+
277
+ test("non-trailing '*' still matches when content is present: 'g*t' matches 'git'", () => {
278
+ expect(wildcardMatch("g*t", "git")).toBe(true);
279
+ });
280
+
281
+ test("'git*' (no space) still matches bare 'git' — unchanged behaviour", () => {
282
+ expect(wildcardMatch("git*", "git")).toBe(true);
283
+ });
284
+
285
+ test("'*' alone still matches everything", () => {
286
+ expect(wildcardMatch("*", "git")).toBe(true);
287
+ expect(wildcardMatch("*", "")).toBe(true);
288
+ });
289
+ });
290
+ });
291
+
292
+ describe("? single-character wildcard", () => {
293
+ test("'?' matches exactly one character", () => {
294
+ expect(wildcardMatch("?", "a")).toBe(true);
295
+ expect(wildcardMatch("?", "Z")).toBe(true);
296
+ expect(wildcardMatch("?", "5")).toBe(true);
297
+ });
298
+
299
+ test("'?' does not match zero characters", () => {
300
+ expect(wildcardMatch("?", "")).toBe(false);
301
+ expect(wildcardMatch("a?", "a")).toBe(false);
302
+ });
303
+
304
+ test("'?' does not match two or more characters", () => {
305
+ expect(wildcardMatch("?", "ab")).toBe(false);
306
+ expect(wildcardMatch("?", "abc")).toBe(false);
307
+ });
308
+
309
+ test("multiple '?' match exactly that many characters", () => {
310
+ expect(wildcardMatch("f??", "foo")).toBe(true);
311
+ expect(wildcardMatch("f??", "fo")).toBe(false);
312
+ expect(wildcardMatch("f??", "fooo")).toBe(false);
313
+ });
314
+
315
+ test("'?' combined with '*'", () => {
316
+ // git + one char + anything
317
+ expect(wildcardMatch("git?*", "git status")).toBe(true);
318
+ // git + zero chars — '?' requires one
319
+ expect(wildcardMatch("git?*", "git")).toBe(false);
320
+ });
321
+
322
+ test("'?' matches path separators and special characters", () => {
323
+ expect(wildcardMatch("a?b", "a/b")).toBe(true);
324
+ expect(wildcardMatch("a?b", "a.b")).toBe(true);
325
+ expect(wildcardMatch("a?b", "a\nb")).toBe(true);
326
+ });
327
+
328
+ test("'?' in pattern matches literal '?' in value", () => {
329
+ expect(wildcardMatch("a?c", "a?c")).toBe(true);
330
+ });
331
+
332
+ test("'?' in bash-style patterns", () => {
333
+ expect(wildcardMatch("git statu?", "git status")).toBe(true);
334
+ expect(wildcardMatch("git statu?", "git statux")).toBe(true);
335
+ expect(wildcardMatch("git statu?", "git statu")).toBe(false);
336
+ });
246
337
  });
247
338
 
248
339
  describe("home path expansion in patterns", () => {