@gotgenes/pi-permission-system 10.5.0 → 10.5.2

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 (40) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/package.json +1 -1
  3. package/src/handlers/before-agent-start.ts +11 -6
  4. package/src/handlers/lifecycle.ts +7 -4
  5. package/src/handlers/permission-gate-handler.ts +3 -3
  6. package/src/index.ts +8 -3
  7. package/src/input-normalizer.ts +20 -8
  8. package/src/path-utils.ts +1 -10
  9. package/src/permission-resolver.ts +0 -3
  10. package/src/permission-session.ts +8 -52
  11. package/src/session-rules.ts +3 -2
  12. package/src/skill-prompt-sanitizer.ts +1 -1
  13. package/test/before-agent-start-cache.test.ts +89 -0
  14. package/test/handlers/before-agent-start.test.ts +56 -86
  15. package/test/handlers/external-directory-session-dedup.test.ts +175 -159
  16. package/test/handlers/gates/bash-path.test.ts +57 -0
  17. package/test/handlers/gates/path.test.ts +58 -0
  18. package/test/handlers/input.test.ts +5 -4
  19. package/test/handlers/lifecycle.test.ts +79 -85
  20. package/test/handlers/tool-call.test.ts +106 -2
  21. package/test/helpers/handler-fixtures.ts +99 -102
  22. package/test/helpers/manager-harness.ts +61 -0
  23. package/test/helpers/session-fixtures.ts +192 -0
  24. package/test/input-normalizer.test.ts +77 -1
  25. package/test/logging.test.ts +51 -0
  26. package/test/path-utils.test.ts +10 -0
  27. package/test/permission-forwarding.test.ts +73 -0
  28. package/test/permission-manager-unified.test.ts +1577 -3
  29. package/test/permission-resolver.test.ts +3 -1
  30. package/test/permission-session.test.ts +14 -198
  31. package/test/session-rules.test.ts +13 -5
  32. package/test/skill-prompt-sanitizer.test.ts +130 -0
  33. package/test/status.test.ts +10 -0
  34. package/test/system-prompt-sanitizer.test.ts +68 -0
  35. package/test/tool-registry.test.ts +42 -0
  36. package/test/yolo-mode.test.ts +78 -0
  37. package/src/agent-prep-session.ts +0 -28
  38. package/src/gate-handler-session.ts +0 -13
  39. package/src/session-lifecycle-session.ts +0 -24
  40. package/test/permission-system.test.ts +0 -2785
@@ -1,28 +0,0 @@
1
- import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
2
-
3
- import type { GateHandlerSession } from "./gate-handler-session";
4
- import type {
5
- SkillPermissionChecker,
6
- SkillPromptEntry,
7
- } from "./skill-prompt-sanitizer";
8
- import type { PermissionState } from "./types";
9
-
10
- /**
11
- * The session surface `AgentPrepHandler` invokes during `before_agent_start`:
12
- * bind context + identify the agent (via {@link GateHandlerSession}), check
13
- * skill permissions for prompt sanitization (via {@link SkillPermissionChecker}),
14
- * refresh config, decide tool exposure, manage the active-tools / prompt-state
15
- * cache keys, and store the resolved skill entries.
16
- */
17
- export interface AgentPrepSession
18
- extends GateHandlerSession,
19
- SkillPermissionChecker {
20
- refreshConfig(ctx?: ExtensionContext): void;
21
- getToolPermission(toolName: string, agentName?: string): PermissionState;
22
- shouldUpdateActiveTools(cacheKey: string): boolean;
23
- commitActiveToolsCacheKey(cacheKey: string): void;
24
- getPolicyCacheStamp(agentName?: string): string;
25
- shouldUpdatePromptState(cacheKey: string): boolean;
26
- commitPromptStateCacheKey(cacheKey: string): void;
27
- setActiveSkillEntries(entries: SkillPromptEntry[]): void;
28
- }
@@ -1,13 +0,0 @@
1
- import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
2
-
3
- /**
4
- * The session surface `PermissionGateHandler` invokes directly: bind the
5
- * per-event context and identify the agent.
6
- *
7
- * This is the two-method context role both entry points share after [#329]
8
- * extracted `SkillInputGatePipeline` to own the skill-input gate assembly.
9
- */
10
- export interface GateHandlerSession {
11
- activate(ctx: ExtensionContext): void;
12
- resolveAgentName(ctx: ExtensionContext, systemPrompt?: string): string | null;
13
- }
@@ -1,24 +0,0 @@
1
- import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
2
-
3
- import type { SessionLogger } from "./session-logger";
4
-
5
- /**
6
- * The session surface `SessionLifecycleHandler` invokes across
7
- * `session_start`, `resources_discover`, and `session_shutdown`: refresh and
8
- * report config, reset / reload / shut down session state, resolve the agent
9
- * name, surface config issues, read the runtime context, and log.
10
- *
11
- * `activate` is intentionally absent — the lifecycle handler never calls it
12
- * directly (ISP: do not depend on methods you do not use).
13
- */
14
- export interface SessionLifecycleSession {
15
- refreshConfig(ctx?: ExtensionContext): void;
16
- resetForNewSession(ctx: ExtensionContext): void;
17
- logResolvedConfigPaths(): void;
18
- resolveAgentName(ctx: ExtensionContext, systemPrompt?: string): string | null;
19
- getConfigIssues(agentName?: string): string[];
20
- reload(): void;
21
- getRuntimeContext(): ExtensionContext | null;
22
- shutdown(): void;
23
- readonly logger: SessionLogger;
24
- }