@gotgenes/pi-permission-system 31.1.0 → 31.1.1

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 (138) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/public.d.ts +15 -15
  3. package/docs/configuration.md +1 -1
  4. package/docs/cross-extension-api.md +1 -1
  5. package/docs/session-approvals.md +2 -2
  6. package/package.json +1 -1
  7. package/src/access-intent/access-intent.ts +1 -1
  8. package/src/access-intent/bash/bash-path-resolver.ts +11 -14
  9. package/src/access-intent/bash/command-enumeration.ts +6 -12
  10. package/src/access-intent/bash/msys-bash-tokens.ts +1 -1
  11. package/src/access-intent/bash/nested-execution.ts +1 -1
  12. package/src/access-intent/bash/node-text.ts +2 -2
  13. package/src/access-intent/bash/parser.ts +1 -1
  14. package/src/access-intent/bash/program.ts +4 -7
  15. package/src/access-intent/bash/redirect-analysis.ts +2 -2
  16. package/src/access-intent/bash/shell-variable-expansion.ts +1 -1
  17. package/src/access-intent/bash/sync-commands.ts +2 -5
  18. package/src/access-intent/bash/token-collection.ts +6 -9
  19. package/src/access-intent/bash/wrapper-analysis.ts +1 -1
  20. package/src/access-intent/input-normalizer.ts +2 -2
  21. package/src/access-intent/path-normalization.ts +1 -1
  22. package/src/access-intent/path-surfaces.ts +1 -1
  23. package/src/access-intent/tool-input-path.ts +1 -1
  24. package/src/access-intent/tool-kind.ts +1 -1
  25. package/src/authority/approval-escalator.ts +13 -13
  26. package/src/authority/authorizer-chain.ts +1 -1
  27. package/src/authority/authorizer-registry.ts +1 -1
  28. package/src/authority/authorizer-selection.ts +1 -1
  29. package/src/authority/authorizer.ts +9 -9
  30. package/src/authority/decision-resolution.ts +2 -5
  31. package/src/authority/denying-authorizer.ts +1 -1
  32. package/src/authority/forwarded-request-server.ts +21 -24
  33. package/src/authority/forwarder-context.ts +2 -2
  34. package/src/authority/forwarding-io.ts +14 -12
  35. package/src/authority/forwarding-liveness.ts +5 -8
  36. package/src/authority/forwarding-manager.ts +1 -1
  37. package/src/authority/inherited-registrations.ts +2 -2
  38. package/src/authority/local-user-authorizer.ts +13 -13
  39. package/src/authority/permission-dialog.ts +2 -2
  40. package/src/authority/permission-forwarding.ts +6 -3
  41. package/src/authority/permission-prompt-component.ts +12 -15
  42. package/src/authority/permission-prompt-decision.ts +2 -2
  43. package/src/authority/permission-prompter.ts +8 -8
  44. package/src/authority/subagent-context.ts +3 -3
  45. package/src/authority/subagent-detection.ts +3 -3
  46. package/src/{config-loader.ts → config/config-loader.ts} +3 -3
  47. package/src/{config-modal.ts → config/config-modal.ts} +1 -2
  48. package/src/{config-reporter.ts → config/config-reporter.ts} +1 -1
  49. package/src/{config-store.ts → config/config-store.ts} +1 -2
  50. package/src/{extension-config.ts → config/extension-config.ts} +4 -4
  51. package/src/{extension-paths.ts → config/extension-paths.ts} +1 -1
  52. package/src/{policy-loader.ts → config/policy-loader.ts} +2 -2
  53. package/src/{skill-prompt-sanitizer.ts → exposure/skill-prompt-sanitizer.ts} +2 -2
  54. package/src/{tool-registry.ts → exposure/tool-registry.ts} +1 -1
  55. package/src/handlers/before-agent-start.ts +11 -8
  56. package/src/handlers/gates/bash-command.ts +2 -2
  57. package/src/handlers/gates/bash-external-directory.ts +3 -3
  58. package/src/handlers/gates/bash-path-extractor.ts +1 -1
  59. package/src/handlers/gates/bash-path.ts +4 -4
  60. package/src/handlers/gates/descriptor.ts +2 -2
  61. package/src/handlers/gates/external-directory-policy.ts +2 -2
  62. package/src/handlers/gates/external-directory.ts +4 -4
  63. package/src/handlers/gates/helpers.ts +1 -1
  64. package/src/handlers/gates/path.ts +4 -4
  65. package/src/handlers/gates/runner.ts +4 -4
  66. package/src/handlers/gates/skill-read.ts +3 -3
  67. package/src/handlers/gates/tool-call-gate-pipeline.ts +7 -7
  68. package/src/handlers/gates/tool.ts +3 -3
  69. package/src/handlers/lifecycle.ts +6 -7
  70. package/src/handlers/permission-gate-handler.ts +11 -11
  71. package/src/handlers/session-turn-prep.ts +1 -1
  72. package/src/handlers/tool-call-boundary.ts +3 -3
  73. package/src/index.ts +39 -39
  74. package/src/{decision-reporter.ts → logging/decision-reporter.ts} +1 -1
  75. package/src/{logging.ts → logging/logging.ts} +1 -1
  76. package/src/{session-logger.ts → logging/session-logger.ts} +5 -2
  77. package/src/path/approval-pattern.ts +1 -1
  78. package/src/path/canonicalize-path.ts +1 -1
  79. package/src/path/path-containment.ts +2 -2
  80. package/src/path/path-flavor.ts +1 -1
  81. package/src/{path-normalizer.ts → path/path-normalizer.ts} +6 -8
  82. package/src/path/pi-infrastructure-read.ts +3 -3
  83. package/src/{normalize.ts → policy/normalize.ts} +2 -2
  84. package/src/{permission-gate.ts → policy/permission-gate.ts} +1 -1
  85. package/src/{permission-manager.ts → policy/permission-manager.ts} +21 -15
  86. package/src/{permission-merge.ts → policy/permission-merge.ts} +1 -1
  87. package/src/{permission-resolver.ts → policy/permission-resolver.ts} +5 -5
  88. package/src/{rule.ts → policy/rule.ts} +3 -4
  89. package/src/{scope-merge.ts → policy/scope-merge.ts} +3 -3
  90. package/src/{synthesize.ts → policy/synthesize.ts} +1 -1
  91. package/src/{wildcard-matcher.ts → policy/wildcard-matcher.ts} +1 -1
  92. package/src/presentation/agent-renderer.ts +5 -5
  93. package/src/presentation/dialog-renderer.ts +3 -3
  94. package/src/presentation/fact-vocabulary.ts +1 -4
  95. package/src/presentation/forwarded-ask-payload.ts +1 -4
  96. package/src/presentation/path-ask-payload.ts +2 -5
  97. package/src/{pattern-suggest.ts → presentation/pattern-suggest.ts} +6 -3
  98. package/src/{permission-prompts.ts → presentation/permission-prompts.ts} +1 -1
  99. package/src/presentation/review-log-renderer.ts +1 -1
  100. package/src/presentation/skill-ask-payload.ts +3 -3
  101. package/src/presentation/tool-ask-payload.ts +3 -6
  102. package/src/{bash-advisory-check.ts → service/bash-advisory-check.ts} +1 -1
  103. package/src/{permissions-service.ts → service/permissions-service.ts} +10 -10
  104. package/src/{service-lifecycle.ts → service/service-lifecycle.ts} +5 -5
  105. package/src/service.ts +18 -18
  106. package/src/{permission-session.ts → session/permission-session.ts} +19 -20
  107. package/src/{session-approval.ts → session/session-approval.ts} +2 -2
  108. package/src/{session-rules.ts → session/session-rules.ts} +1 -1
  109. package/src/{builtin-tool-input-formatters.ts → tool-input/builtin-tool-input-formatters.ts} +1 -1
  110. package/src/{tool-input-preview.ts → tool-input/tool-input-preview.ts} +2 -2
  111. package/src/{tool-input-prompt-formatters.ts → tool-input/tool-input-prompt-formatters.ts} +1 -1
  112. package/src/{tool-preview-formatter.ts → tool-input/tool-preview-formatter.ts} +3 -3
  113. package/src/types.ts +2 -2
  114. /package/src/{async-cache.ts → access-intent/bash/async-cache.ts} +0 -0
  115. /package/src/{bash-arity.ts → access-intent/bash/bash-arity.ts} +0 -0
  116. /package/src/{config-paths.ts → config/config-paths.ts} +0 -0
  117. /package/src/{config-schema.ts → config/config-schema.ts} +0 -0
  118. /package/src/{status.ts → config/status.ts} +0 -0
  119. /package/src/{yaml-frontmatter.ts → config/yaml-frontmatter.ts} +0 -0
  120. /package/src/{system-prompt-sanitizer.ts → exposure/system-prompt-sanitizer.ts} +0 -0
  121. /package/src/{tool-surface-baseline.ts → exposure/tool-surface-baseline.ts} +0 -0
  122. /package/src/{decision-audit.ts → logging/decision-audit.ts} +0 -0
  123. /package/src/{json-safe-stringify.ts → logging/json-safe-stringify.ts} +0 -0
  124. /package/src/{log-field-cap.ts → logging/log-field-cap.ts} +0 -0
  125. /package/src/{log-file-permissions.ts → logging/log-file-permissions.ts} +0 -0
  126. /package/src/{log-redaction.ts → logging/log-redaction.ts} +0 -0
  127. /package/src/{expand-home.ts → path/expand-home.ts} +0 -0
  128. /package/src/{node-modules-discovery.ts → path/node-modules-discovery.ts} +0 -0
  129. /package/src/{safe-system-paths.ts → path/safe-system-paths.ts} +0 -0
  130. /package/src/{restrictiveness.ts → policy/restrictiveness.ts} +0 -0
  131. /package/src/{permission-events.ts → service/permission-events.ts} +0 -0
  132. /package/src/{permission-ui-prompt.ts → service/permission-ui-prompt.ts} +0 -0
  133. /package/src/{active-agent.ts → session/active-agent.ts} +0 -0
  134. /package/src/{approval-grant.ts → session/approval-grant.ts} +0 -0
  135. /package/src/{session-approval-recorder.ts → session/session-approval-recorder.ts} +0 -0
  136. /package/src/{session-identity.ts → session/session-identity.ts} +0 -0
  137. /package/src/{tool-access-extractor-registry.ts → tool-input/tool-access-extractor-registry.ts} +0 -0
  138. /package/src/{tool-input-formatter-registry.ts → tool-input/tool-input-formatter-registry.ts} +0 -0
@@ -1,30 +1,29 @@
1
1
  import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
2
+ import type { AuthorizerSelectionLifecycle } from "#src/authority/authorizer-selection";
2
3
  import type { ForwardingController } from "#src/authority/forwarding-manager";
4
+ import type { ShellToolsConfig } from "#src/config/config-schema";
5
+ import type { SessionConfigStore } from "#src/config/config-store";
6
+ import type { PermissionSystemExtensionConfig } from "#src/config/extension-config";
7
+ import type { ExtensionPaths } from "#src/config/extension-paths";
8
+ import type { SkillPromptEntry } from "#src/exposure/skill-prompt-sanitizer";
3
9
  import {
4
- getActiveAgentName,
5
- getActiveAgentNameFromSystemPrompt,
6
- } from "./active-agent";
7
- import type { AuthorizerSelectionLifecycle } from "./authority/authorizer-selection";
8
- import type { ShellToolsConfig } from "./config-schema";
9
- import type { SessionConfigStore } from "./config-store";
10
- import type { PermissionSystemExtensionConfig } from "./extension-config";
11
- import type { ExtensionPaths } from "./extension-paths";
12
- import type { ToolCallGateInputs } from "./handlers/gates/tool-call-gate-pipeline";
13
- import type { PathFlavor } from "./path/path-flavor";
14
- import { PathNormalizer } from "./path-normalizer";
15
- import type { ScopedPermissionManager } from "./permission-manager";
16
-
17
- import type { SessionRules } from "./session-rules";
18
- import type { SkillPromptEntry } from "./skill-prompt-sanitizer";
10
+ ToolSurfaceBaseline,
11
+ type ToolSurfaceObservation,
12
+ type ToolSurfaceResolution,
13
+ } from "#src/exposure/tool-surface-baseline";
14
+ import type { ToolCallGateInputs } from "#src/handlers/gates/tool-call-gate-pipeline";
15
+ import type { PathFlavor } from "#src/path/path-flavor";
16
+ import { PathNormalizer } from "#src/path/path-normalizer";
17
+ import type { ScopedPermissionManager } from "#src/policy/permission-manager";
19
18
  import {
20
19
  resolveToolPreviewLimits,
21
20
  type ToolPreviewFormatterOptions,
22
- } from "./tool-preview-formatter";
21
+ } from "#src/tool-input/tool-preview-formatter";
23
22
  import {
24
- ToolSurfaceBaseline,
25
- type ToolSurfaceObservation,
26
- type ToolSurfaceResolution,
27
- } from "./tool-surface-baseline";
23
+ getActiveAgentName,
24
+ getActiveAgentNameFromSystemPrompt,
25
+ } from "./active-agent";
26
+ import type { SessionRules } from "./session-rules";
28
27
 
29
28
  /**
30
29
  * Encapsulates all mutable session state and exposes operations instead of
@@ -1,9 +1,9 @@
1
+ import type { ForwardedSessionApproval } from "#src/authority/permission-forwarding";
1
2
  import {
2
3
  type ApprovalGrant,
3
4
  type SessionGrantWidth,
4
5
  widenGrant,
5
- } from "#src/approval-grant";
6
- import type { ForwardedSessionApproval } from "#src/authority/permission-forwarding";
6
+ } from "./approval-grant";
7
7
 
8
8
  /**
9
9
  * Value object for a session-scoped approval: one or more
@@ -1,5 +1,5 @@
1
1
  import { surfaceFamilyMembers } from "#src/access-intent/path-surfaces";
2
- import type { Ruleset } from "./rule";
2
+ import type { Ruleset } from "#src/policy/rule";
3
3
  import type { SessionApproval } from "./session-approval";
4
4
  import type { SessionApprovalRecorder } from "./session-approval-recorder";
5
5
 
@@ -5,12 +5,12 @@
5
5
  * through exactly the same path a third-party extension would use.
6
6
  */
7
7
 
8
+ import { toRecord } from "#src/value-guards";
8
9
  import type {
9
10
  ToolInputFormatter,
10
11
  ToolInputFormatterRegistry,
11
12
  } from "./tool-input-formatter-registry";
12
13
  import { truncateInlineText } from "./tool-input-preview";
13
- import { toRecord } from "./value-guards";
14
14
 
15
15
  /** Maximum total length of the generated argument summary (before "with " prefix). */
16
16
  const MCP_ARGS_SUMMARY_MAX_LENGTH = 160;
@@ -1,5 +1,5 @@
1
- import { safeJsonStringify } from "./json-safe-stringify";
2
- import { redactedJsonStringify } from "./log-redaction";
1
+ import { safeJsonStringify } from "#src/logging/json-safe-stringify";
2
+ import { redactedJsonStringify } from "#src/logging/log-redaction";
3
3
 
4
4
  export const TOOL_INPUT_PREVIEW_MAX_LENGTH = 200;
5
5
  export const TOOL_TEXT_SUMMARY_MAX_LENGTH = 80;
@@ -1,5 +1,5 @@
1
+ import { getNonEmptyString, toRecord } from "#src/value-guards";
1
2
  import { countTextLines, formatCount } from "./tool-input-preview";
2
- import { getNonEmptyString, toRecord } from "./value-guards";
3
3
 
4
4
  export function getPromptPath(input: Record<string, unknown>): string | null {
5
5
  return getNonEmptyString(input.path) ?? getNonEmptyString(input.file_path);
@@ -1,4 +1,6 @@
1
- import { classifyToolKind, isMcpCheck } from "./access-intent/tool-kind";
1
+ import { classifyToolKind, isMcpCheck } from "#src/access-intent/tool-kind";
2
+ import type { PermissionCheckResult } from "#src/types";
3
+ import { getNonEmptyString, toRecord } from "#src/value-guards";
2
4
  import type { ToolInputFormatterLookup } from "./tool-input-formatter-registry";
3
5
  import {
4
6
  serializeRedactedToolInputPreview,
@@ -13,8 +15,6 @@ import {
13
15
  formatWriteInputForPrompt,
14
16
  getPromptPath,
15
17
  } from "./tool-input-prompt-formatters";
16
- import type { PermissionCheckResult } from "./types";
17
- import { getNonEmptyString, toRecord } from "./value-guards";
18
18
 
19
19
  export interface ToolPreviewFormatterOptions {
20
20
  toolInputPreviewMaxLength: number;
package/src/types.ts CHANGED
@@ -3,8 +3,8 @@ import type {
3
3
  FlatPermissionConfig,
4
4
  PatternValue,
5
5
  PermissionState,
6
- } from "./config-schema";
7
- import type { RuleOrigin } from "./rule";
6
+ } from "#src/config/config-schema";
7
+ import type { RuleOrigin } from "#src/policy/rule";
8
8
 
9
9
  // The config-file shape types are derived from the zod schema
10
10
  // (config-schema.ts) — the single source of truth — and re-exported here so
File without changes
File without changes
File without changes