@gotgenes/pi-permission-system 10.8.0 → 10.9.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/CHANGELOG.md CHANGED
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [10.9.0](https://github.com/gotgenes/pi-packages/compare/pi-permission-system-v10.8.0...pi-permission-system-v10.9.0) (2026-06-10)
9
+
10
+
11
+ ### Features
12
+
13
+ * add ToolInputFormatterRegistrar write-side interface ([#366](https://github.com/gotgenes/pi-packages/issues/366)) ([e000eb0](https://github.com/gotgenes/pi-packages/commit/e000eb02a507c06e241b5a35cac5334e06dca1e2))
14
+
8
15
  ## [10.8.0](https://github.com/gotgenes/pi-packages/compare/pi-permission-system-v10.7.2...pi-permission-system-v10.8.0) (2026-06-10)
9
16
 
10
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gotgenes/pi-permission-system",
3
- "version": "10.8.0",
3
+ "version": "10.9.0",
4
4
  "description": "Permission enforcement extension for the Pi coding agent.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -1,10 +1,10 @@
1
1
  import { buildInputForSurface } from "./input-normalizer";
2
- import type { PermissionManager } from "./permission-manager";
2
+ import type { ScopedPermissionManager } from "./permission-manager";
3
3
  import type { PermissionsService } from "./service";
4
4
  import type { SessionRules } from "./session-rules";
5
5
  import type {
6
6
  ToolInputFormatter,
7
- ToolInputFormatterRegistry,
7
+ ToolInputFormatterRegistrar,
8
8
  } from "./tool-input-formatter-registry";
9
9
 
10
10
  /**
@@ -16,9 +16,9 @@ import type {
16
16
  */
17
17
  export class LocalPermissionsService implements PermissionsService {
18
18
  constructor(
19
- private readonly permissionManager: PermissionManager,
20
- private readonly sessionRules: SessionRules,
21
- private readonly formatterRegistry: ToolInputFormatterRegistry,
19
+ private readonly permissionManager: ScopedPermissionManager,
20
+ private readonly sessionRules: Pick<SessionRules, "getRuleset">,
21
+ private readonly formatterRegistry: ToolInputFormatterRegistrar,
22
22
  ) {}
23
23
 
24
24
  checkPermission(
@@ -19,6 +19,14 @@ export interface ToolInputFormatterLookup {
19
19
  get(toolName: string): ToolInputFormatter | undefined;
20
20
  }
21
21
 
22
+ /**
23
+ * Registration side of the formatter registry (ISP — exposes only the
24
+ * write surface, mirroring the read-only {@link ToolInputFormatterLookup}).
25
+ */
26
+ export interface ToolInputFormatterRegistrar {
27
+ register(toolName: string, formatter: ToolInputFormatter): () => void;
28
+ }
29
+
22
30
  /**
23
31
  * Persistent registry mapping tool names to custom preview formatters.
24
32
  *
@@ -26,7 +34,9 @@ export interface ToolInputFormatterLookup {
26
34
  * per-tool-call `ToolPreviewFormatter` construction cycle.
27
35
  * Exposed to sibling extensions via `PermissionsService.registerToolInputFormatter`.
28
36
  */
29
- export class ToolInputFormatterRegistry implements ToolInputFormatterLookup {
37
+ export class ToolInputFormatterRegistry
38
+ implements ToolInputFormatterLookup, ToolInputFormatterRegistrar
39
+ {
30
40
  private readonly formatters = new Map<string, ToolInputFormatter>();
31
41
 
32
42
  /**
@@ -1,14 +1,15 @@
1
1
  import { beforeEach, describe, expect, it, vi } from "vitest";
2
- import type { PermissionManager } from "#src/permission-manager";
2
+ import type { ScopedPermissionManager } from "#src/permission-manager";
3
3
  import { LocalPermissionsService } from "#src/permissions-service";
4
4
  import type { Ruleset } from "#src/rule";
5
5
  import type { SessionRules } from "#src/session-rules";
6
6
  import type {
7
7
  ToolInputFormatter,
8
- ToolInputFormatterRegistry,
8
+ ToolInputFormatterRegistrar,
9
9
  } from "#src/tool-input-formatter-registry";
10
10
 
11
11
  import { makeCheckResult } from "#test/helpers/handler-fixtures";
12
+ import { makeFakePermissionManager } from "#test/helpers/session-fixtures";
12
13
 
13
14
  // ── input-normalizer stub ──────────────────────────────────────────────────
14
15
 
@@ -22,38 +23,29 @@ vi.mock("#src/input-normalizer", () => ({
22
23
 
23
24
  // ── helpers ────────────────────────────────────────────────────────────────
24
25
 
25
- function makePermissionManager(): PermissionManager {
26
- return {
27
- checkPermission: vi
28
- .fn<PermissionManager["checkPermission"]>()
29
- .mockReturnValue(makeCheckResult()),
30
- getToolPermission: vi
31
- .fn<PermissionManager["getToolPermission"]>()
32
- .mockReturnValue("allow"),
33
- } as unknown as PermissionManager;
34
- }
35
-
36
- function makeSessionRules(rules: Ruleset = []): SessionRules {
26
+ function makeSessionRules(
27
+ rules: Ruleset = [],
28
+ ): Pick<SessionRules, "getRuleset"> {
37
29
  return {
38
30
  getRuleset: vi.fn<SessionRules["getRuleset"]>().mockReturnValue(rules),
39
- } as unknown as SessionRules;
31
+ };
40
32
  }
41
33
 
42
- function makeFormatterRegistry(): ToolInputFormatterRegistry {
34
+ function makeFormatterRegistry(): ToolInputFormatterRegistrar {
43
35
  return {
44
36
  register: vi
45
- .fn<ToolInputFormatterRegistry["register"]>()
37
+ .fn<ToolInputFormatterRegistrar["register"]>()
46
38
  .mockReturnValue(vi.fn()),
47
- } as unknown as ToolInputFormatterRegistry;
39
+ };
48
40
  }
49
41
 
50
42
  function makeService(overrides?: {
51
- permissionManager?: PermissionManager;
52
- sessionRules?: SessionRules;
53
- formatterRegistry?: ToolInputFormatterRegistry;
43
+ permissionManager?: ScopedPermissionManager;
44
+ sessionRules?: Pick<SessionRules, "getRuleset">;
45
+ formatterRegistry?: ToolInputFormatterRegistrar;
54
46
  }) {
55
47
  const permissionManager =
56
- overrides?.permissionManager ?? makePermissionManager();
48
+ overrides?.permissionManager ?? makeFakePermissionManager();
57
49
  const sessionRules = overrides?.sessionRules ?? makeSessionRules();
58
50
  const formatterRegistry =
59
51
  overrides?.formatterRegistry ?? makeFormatterRegistry();