@gotgenes/pi-permission-system 7.1.2 → 7.1.4
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 +14 -0
- package/package.json +6 -2
- package/src/handlers/gates/bash-external-directory.ts +4 -4
- package/src/handlers/gates/bash-path-extractor.ts +1 -1
- package/src/handlers/gates/bash-path.ts +4 -4
- package/src/handlers/gates/descriptor.ts +6 -6
- package/src/handlers/gates/external-directory.ts +2 -2
- package/src/handlers/gates/helpers.ts +2 -2
- package/src/handlers/gates/path.ts +4 -4
- package/src/handlers/gates/runner.ts +4 -4
- package/src/handlers/gates/skill-read.ts +5 -5
- package/src/handlers/gates/tool.ts +5 -5
- package/src/wildcard-matcher.ts +2 -2
- package/{tests → test}/active-agent.test.ts +1 -1
- package/{tests → test}/bash-arity.test.ts +4 -4
- package/{tests → test}/bash-external-directory.test.ts +3 -3
- package/{tests → test}/common.test.ts +1 -1
- package/{tests → test}/config-loader.test.ts +1 -1
- package/{tests → test}/config-modal.test.ts +3 -3
- package/{tests → test}/config-paths.test.ts +1 -1
- package/{tests → test}/config-reporter.test.ts +4 -4
- package/{tests → test}/denial-messages.test.ts +2 -2
- package/{tests → test}/expand-home.test.ts +1 -1
- package/{tests → test}/extension-config.test.ts +1 -1
- package/{tests → test}/extension-paths.test.ts +2 -2
- package/{tests → test}/forwarded-permissions/io.test.ts +2 -2
- package/{tests → test}/forwarding-manager.test.ts +1 -1
- package/{tests → test}/handlers/before-agent-start.test.ts +4 -4
- package/{tests → test}/handlers/external-directory-integration.test.ts +7 -7
- package/{tests → test}/handlers/external-directory-session-dedup.test.ts +6 -6
- package/{tests → test}/handlers/gates/bash-external-directory.test.ts +5 -8
- package/{tests → test}/handlers/gates/bash-path.test.ts +6 -9
- package/{tests → test}/handlers/gates/external-directory-messages.test.ts +1 -1
- package/{tests → test}/handlers/gates/external-directory.test.ts +4 -7
- package/{tests → test}/handlers/gates/helpers.test.ts +1 -1
- package/{tests → test}/handlers/gates/path.test.ts +6 -6
- package/{tests → test}/handlers/gates/runner.test.ts +5 -5
- package/{tests → test}/handlers/gates/skill-read.test.ts +4 -4
- package/{tests → test}/handlers/gates/tool.test.ts +3 -3
- package/{tests → test}/handlers/input-events.test.ts +6 -6
- package/{tests → test}/handlers/input.test.ts +4 -4
- package/{tests → test}/handlers/lifecycle.test.ts +2 -2
- package/{tests → test}/handlers/tool-call-events.test.ts +6 -6
- package/{tests → test}/handlers/tool-call.test.ts +4 -4
- package/{tests → test}/input-normalizer.test.ts +2 -2
- package/{tests → test}/mcp-targets.test.ts +1 -1
- package/{tests → test}/node-modules-discovery.test.ts +1 -1
- package/{tests → test}/normalize.test.ts +1 -1
- package/{tests → test}/path-utils.test.ts +1 -1
- package/{tests → test}/pattern-suggest.test.ts +1 -1
- package/{tests → test}/permission-dialog.test.ts +1 -1
- package/{tests → test}/permission-event-rpc.test.ts +3 -3
- package/{tests → test}/permission-events.test.ts +4 -4
- package/{tests → test}/permission-forwarding.test.ts +1 -1
- package/{tests → test}/permission-gate.test.ts +2 -2
- package/{tests → test}/permission-manager-unified.test.ts +5 -5
- package/{tests → test}/permission-merge.test.ts +1 -1
- package/{tests → test}/permission-prompter.test.ts +4 -4
- package/{tests → test}/permission-prompts.test.ts +4 -4
- package/{tests → test}/permission-session.test.ts +7 -7
- package/{tests → test}/permission-system.test.ts +13 -13
- package/{tests → test}/pi-infrastructure-read.test.ts +2 -2
- package/{tests → test}/policy-loader.test.ts +1 -1
- package/{tests → test}/rule.test.ts +2 -2
- package/{tests → test}/runtime.test.ts +4 -4
- package/{tests → test}/service.test.ts +4 -4
- package/{tests → test}/session-logger.test.ts +2 -2
- package/{tests → test}/session-rules.test.ts +2 -2
- package/{tests → test}/session-start.test.ts +4 -4
- package/{tests → test}/skill-prompt-sanitizer.test.ts +3 -3
- package/{tests → test}/subagent-context.test.ts +2 -2
- package/{tests → test}/synthesize.test.ts +3 -3
- package/{tests → test}/system-prompt-sanitizer.test.ts +1 -1
- package/{tests → test}/tool-input-preview.test.ts +3 -3
- package/{tests → test}/tool-registry.test.ts +1 -1
- package/{tests → test}/wildcard-matcher.test.ts +1 -1
- package/{tests → test}/yolo-mode.test.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,20 @@ 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
|
+
## [7.1.4](https://github.com/gotgenes/pi-packages/compare/pi-permission-system-v7.1.3...pi-permission-system-v7.1.4) (2026-05-23)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* add package.json imports field for #src/#test path aliases ([#157](https://github.com/gotgenes/pi-packages/issues/157)) ([75b4598](https://github.com/gotgenes/pi-packages/commit/75b45980810583452f7741678359c004900c8bd0))
|
|
14
|
+
|
|
15
|
+
## [7.1.3](https://github.com/gotgenes/pi-packages/compare/pi-permission-system-v7.1.2...pi-permission-system-v7.1.3) (2026-05-23)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Documentation
|
|
19
|
+
|
|
20
|
+
* **retro:** add retro notes for issue [#155](https://github.com/gotgenes/pi-packages/issues/155) ([4aa3250](https://github.com/gotgenes/pi-packages/commit/4aa3250471198013dfeb1f3d3ebe6752abfb65d5))
|
|
21
|
+
|
|
8
22
|
## [7.1.2](https://github.com/gotgenes/pi-packages/compare/pi-permission-system-v7.1.1...pi-permission-system-v7.1.2) (2026-05-23)
|
|
9
23
|
|
|
10
24
|
|
package/package.json
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gotgenes/pi-permission-system",
|
|
3
|
-
"version": "7.1.
|
|
3
|
+
"version": "7.1.4",
|
|
4
4
|
"description": "Permission enforcement extension for the Pi coding agent.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": "./src/service.ts"
|
|
8
8
|
},
|
|
9
|
+
"imports": {
|
|
10
|
+
"#src/*": "./src/*",
|
|
11
|
+
"#test/*": "./test/*"
|
|
12
|
+
},
|
|
9
13
|
"files": [
|
|
10
14
|
"src",
|
|
11
|
-
"
|
|
15
|
+
"test",
|
|
12
16
|
"config/config.example.json",
|
|
13
17
|
"schemas/permissions.schema.json",
|
|
14
18
|
"README.md",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { getNonEmptyString, toRecord } from "
|
|
2
|
-
import type { Rule } from "
|
|
3
|
-
import { deriveApprovalPattern } from "
|
|
4
|
-
import type { PermissionCheckResult } from "
|
|
1
|
+
import { getNonEmptyString, toRecord } from "#src/common";
|
|
2
|
+
import type { Rule } from "#src/rule";
|
|
3
|
+
import { deriveApprovalPattern } from "#src/session-rules";
|
|
4
|
+
import type { PermissionCheckResult } from "#src/types";
|
|
5
5
|
import { extractExternalPathsFromBashCommand } from "./bash-path-extractor";
|
|
6
6
|
import type { GateResult } from "./descriptor";
|
|
7
7
|
import { formatBashExternalDirectoryAskPrompt } from "./external-directory-messages";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { getNonEmptyString, toRecord } from "
|
|
2
|
-
import type { Rule } from "
|
|
3
|
-
import { deriveApprovalPattern } from "
|
|
4
|
-
import type { PermissionCheckResult } from "
|
|
1
|
+
import { getNonEmptyString, toRecord } from "#src/common";
|
|
2
|
+
import type { Rule } from "#src/rule";
|
|
3
|
+
import { deriveApprovalPattern } from "#src/session-rules";
|
|
4
|
+
import type { PermissionCheckResult } from "#src/types";
|
|
5
5
|
import { extractTokensForPathRules } from "./bash-path-extractor";
|
|
6
6
|
import type { GateResult } from "./descriptor";
|
|
7
7
|
import { formatPathAskPrompt } from "./path";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { DenialContext } from "
|
|
2
|
-
import type { PermissionPromptDecision } from "
|
|
3
|
-
import type { PermissionDecisionEvent } from "
|
|
4
|
-
import type { PromptPermissionDetails } from "
|
|
5
|
-
import type { Rule } from "
|
|
6
|
-
import type { PermissionCheckResult, PermissionState } from "
|
|
1
|
+
import type { DenialContext } from "#src/denial-messages";
|
|
2
|
+
import type { PermissionPromptDecision } from "#src/permission-dialog";
|
|
3
|
+
import type { PermissionDecisionEvent } from "#src/permission-events";
|
|
4
|
+
import type { PromptPermissionDetails } from "#src/permission-prompter";
|
|
5
|
+
import type { Rule } from "#src/rule";
|
|
6
|
+
import type { PermissionCheckResult, PermissionState } from "#src/types";
|
|
7
7
|
|
|
8
8
|
// ── Descriptor types ───────────────────────────────────────────────────────
|
|
9
9
|
|
|
@@ -3,8 +3,8 @@ import {
|
|
|
3
3
|
isPathOutsideWorkingDirectory,
|
|
4
4
|
isPiInfrastructureRead,
|
|
5
5
|
normalizePathForComparison,
|
|
6
|
-
} from "
|
|
7
|
-
import { deriveApprovalPattern } from "
|
|
6
|
+
} from "#src/path-utils";
|
|
7
|
+
import { deriveApprovalPattern } from "#src/session-rules";
|
|
8
8
|
import type { GateResult } from "./descriptor";
|
|
9
9
|
import { formatExternalDirectoryAskPrompt } from "./external-directory-messages";
|
|
10
10
|
import type { ToolCallContext } from "./types";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { PermissionDecisionResolution } from "
|
|
2
|
-
import type { PermissionCheckResult } from "
|
|
1
|
+
import type { PermissionDecisionResolution } from "#src/permission-events";
|
|
2
|
+
import type { PermissionCheckResult } from "#src/types";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Derive the human-readable value for a decision event from a check result.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { getPathBearingToolPath } from "
|
|
2
|
-
import type { Rule } from "
|
|
3
|
-
import { deriveApprovalPattern } from "
|
|
4
|
-
import type { PermissionCheckResult } from "
|
|
1
|
+
import { getPathBearingToolPath } from "#src/path-utils";
|
|
2
|
+
import type { Rule } from "#src/rule";
|
|
3
|
+
import { deriveApprovalPattern } from "#src/session-rules";
|
|
4
|
+
import type { PermissionCheckResult } from "#src/types";
|
|
5
5
|
import type { GateDescriptor, GateResult } from "./descriptor";
|
|
6
6
|
import type { ToolCallContext } from "./types";
|
|
7
7
|
|
|
@@ -2,10 +2,10 @@ import {
|
|
|
2
2
|
formatDenyReason,
|
|
3
3
|
formatUnavailableReason,
|
|
4
4
|
formatUserDeniedReason,
|
|
5
|
-
} from "
|
|
6
|
-
import type { PermissionPromptDecision } from "
|
|
7
|
-
import { applyPermissionGate } from "
|
|
8
|
-
import type { PermissionCheckResult } from "
|
|
5
|
+
} from "#src/denial-messages";
|
|
6
|
+
import type { PermissionPromptDecision } from "#src/permission-dialog";
|
|
7
|
+
import { applyPermissionGate } from "#src/permission-gate";
|
|
8
|
+
import type { PermissionCheckResult } from "#src/types";
|
|
9
9
|
import type { GateDescriptor, GateRunnerDeps } from "./descriptor";
|
|
10
10
|
import { deriveResolution } from "./helpers";
|
|
11
11
|
import type { GateOutcome } from "./types";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { toRecord } from "
|
|
2
|
-
import { normalizePathForComparison } from "
|
|
3
|
-
import { formatSkillPathAskPrompt } from "
|
|
4
|
-
import type { SkillPromptEntry } from "
|
|
5
|
-
import { findSkillPathMatch } from "
|
|
1
|
+
import { toRecord } from "#src/common";
|
|
2
|
+
import { normalizePathForComparison } from "#src/path-utils";
|
|
3
|
+
import { formatSkillPathAskPrompt } from "#src/permission-prompts";
|
|
4
|
+
import type { SkillPromptEntry } from "#src/skill-prompt-sanitizer";
|
|
5
|
+
import { findSkillPathMatch } from "#src/skill-prompt-sanitizer";
|
|
6
6
|
import type { GateDescriptor } from "./descriptor";
|
|
7
7
|
import type { ToolCallContext } from "./types";
|
|
8
8
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { getPathBearingToolPath, PATH_BEARING_TOOLS } from "
|
|
2
|
-
import { suggestSessionPattern } from "
|
|
3
|
-
import { formatAskPrompt } from "
|
|
4
|
-
import { getPermissionLogContext } from "
|
|
5
|
-
import type { PermissionCheckResult } from "
|
|
1
|
+
import { getPathBearingToolPath, PATH_BEARING_TOOLS } from "#src/path-utils";
|
|
2
|
+
import { suggestSessionPattern } from "#src/pattern-suggest";
|
|
3
|
+
import { formatAskPrompt } from "#src/permission-prompts";
|
|
4
|
+
import { getPermissionLogContext } from "#src/tool-input-preview";
|
|
5
|
+
import type { PermissionCheckResult } from "#src/types";
|
|
6
6
|
import type { GateDescriptor } from "./descriptor";
|
|
7
7
|
import { deriveDecisionValue } from "./helpers";
|
|
8
8
|
import type { ToolCallContext } from "./types";
|
package/src/wildcard-matcher.ts
CHANGED
|
@@ -30,7 +30,7 @@ export function compileWildcardPattern<TState>(
|
|
|
30
30
|
// space-and-arguments portion optional so that e.g. "git *" matches both
|
|
31
31
|
// "git status" and bare "git". Mirrors OpenCode wildcard semantics.
|
|
32
32
|
if (escaped.endsWith(" .*")) {
|
|
33
|
-
escaped = escaped.slice(0, -3)
|
|
33
|
+
escaped = `${escaped.slice(0, -3)}( .*)?`;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
return {
|
|
@@ -48,7 +48,7 @@ export function compileWildcardPatternEntries<TState>(
|
|
|
48
48
|
);
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
function
|
|
51
|
+
function _compileWildcardPatterns<TState>(
|
|
52
52
|
patterns: Record<string, TState>,
|
|
53
53
|
): CompiledWildcardPattern<TState>[] {
|
|
54
54
|
return compileWildcardPatternEntries(Object.entries(patterns));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { ARITY, prefix } from "
|
|
2
|
+
import { ARITY, prefix } from "#src/bash-arity";
|
|
3
3
|
|
|
4
4
|
describe("ARITY dictionary", () => {
|
|
5
5
|
it("is exported as a plain object", () => {
|
|
@@ -7,7 +7,7 @@ describe("ARITY dictionary", () => {
|
|
|
7
7
|
});
|
|
8
8
|
|
|
9
9
|
it("maps 'git' to arity 2", () => {
|
|
10
|
-
expect(ARITY
|
|
10
|
+
expect(ARITY.git).toBe(2);
|
|
11
11
|
});
|
|
12
12
|
|
|
13
13
|
it("maps 'npm run' to arity 3", () => {
|
|
@@ -15,7 +15,7 @@ describe("ARITY dictionary", () => {
|
|
|
15
15
|
});
|
|
16
16
|
|
|
17
17
|
it("maps 'npm' to arity 2 (fallback when 'npm run' does not match)", () => {
|
|
18
|
-
expect(ARITY
|
|
18
|
+
expect(ARITY.npm).toBe(2);
|
|
19
19
|
});
|
|
20
20
|
|
|
21
21
|
it("maps 'docker compose' to arity 3", () => {
|
|
@@ -23,7 +23,7 @@ describe("ARITY dictionary", () => {
|
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
it("maps 'docker' to arity 2 (fallback)", () => {
|
|
26
|
-
expect(ARITY
|
|
26
|
+
expect(ARITY.docker).toBe(2);
|
|
27
27
|
});
|
|
28
28
|
});
|
|
29
29
|
|
|
@@ -9,12 +9,12 @@ vi.mock("node:os", () => {
|
|
|
9
9
|
};
|
|
10
10
|
});
|
|
11
11
|
|
|
12
|
-
import { formatDenyReason } from "
|
|
12
|
+
import { formatDenyReason } from "#src/denial-messages";
|
|
13
13
|
import {
|
|
14
14
|
extractExternalPathsFromBashCommand,
|
|
15
15
|
extractTokensForPathRules,
|
|
16
|
-
} from "
|
|
17
|
-
import { formatBashExternalDirectoryAskPrompt } from "
|
|
16
|
+
} from "#src/handlers/gates/bash-path-extractor";
|
|
17
|
+
import { formatBashExternalDirectoryAskPrompt } from "#src/handlers/gates/external-directory-messages";
|
|
18
18
|
|
|
19
19
|
afterEach(() => {
|
|
20
20
|
vi.restoreAllMocks();
|
|
@@ -2,13 +2,13 @@ import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
|
2
2
|
import { tmpdir } from "node:os";
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import { expect, test, vi } from "vitest";
|
|
5
|
-
import { registerPermissionSystemCommand } from "
|
|
5
|
+
import { registerPermissionSystemCommand } from "#src/config-modal";
|
|
6
6
|
import {
|
|
7
7
|
DEFAULT_EXTENSION_CONFIG,
|
|
8
8
|
normalizePermissionSystemConfig,
|
|
9
9
|
type PermissionSystemExtensionConfig,
|
|
10
|
-
} from "
|
|
11
|
-
import type { Rule } from "
|
|
10
|
+
} from "#src/extension-config";
|
|
11
|
+
import type { Rule } from "#src/rule";
|
|
12
12
|
|
|
13
13
|
vi.mock("@earendil-works/pi-coding-agent", () => ({
|
|
14
14
|
getSettingsListTheme: () => ({}),
|
|
@@ -8,10 +8,10 @@ import {
|
|
|
8
8
|
import { tmpdir } from "node:os";
|
|
9
9
|
import { join } from "node:path";
|
|
10
10
|
import { expect, test } from "vitest";
|
|
11
|
-
import { buildResolvedConfigLogEntry } from "
|
|
12
|
-
import { createPermissionSystemLogger } from "
|
|
13
|
-
import type { ResolvedPolicyPaths } from "
|
|
14
|
-
import { PermissionManager } from "
|
|
11
|
+
import { buildResolvedConfigLogEntry } from "#src/config-reporter";
|
|
12
|
+
import { createPermissionSystemLogger } from "#src/logging";
|
|
13
|
+
import type { ResolvedPolicyPaths } from "#src/permission-manager";
|
|
14
|
+
import { PermissionManager } from "#src/permission-manager";
|
|
15
15
|
|
|
16
16
|
test("buildResolvedConfigLogEntry includes policy paths and legacy detection flags", () => {
|
|
17
17
|
const policyPaths: ResolvedPolicyPaths = {
|
|
@@ -6,8 +6,8 @@ import {
|
|
|
6
6
|
formatDenyReason,
|
|
7
7
|
formatUnavailableReason,
|
|
8
8
|
formatUserDeniedReason,
|
|
9
|
-
} from "
|
|
10
|
-
import type { PermissionCheckResult } from "
|
|
9
|
+
} from "#src/denial-messages";
|
|
10
|
+
import type { PermissionCheckResult } from "#src/types";
|
|
11
11
|
|
|
12
12
|
// ── Helpers ────────────────────────────────────────────────────────────────
|
|
13
13
|
|
|
@@ -3,7 +3,7 @@ import { describe, expect, it } from "vitest";
|
|
|
3
3
|
import {
|
|
4
4
|
detectMisplacedPermissionKeys,
|
|
5
5
|
normalizePermissionSystemConfig,
|
|
6
|
-
} from "
|
|
6
|
+
} from "#src/extension-config";
|
|
7
7
|
|
|
8
8
|
describe("detectMisplacedPermissionKeys", () => {
|
|
9
9
|
it("returns an empty array for a record with only valid extension keys", () => {
|
|
@@ -9,8 +9,8 @@ vi.mock("../src/node-modules-discovery", () => ({
|
|
|
9
9
|
discoverGlobalNodeModulesRoot: mockDiscoverGlobalNodeModulesRoot,
|
|
10
10
|
}));
|
|
11
11
|
|
|
12
|
-
import { getGlobalLogsDir } from "
|
|
13
|
-
import { computeExtensionPaths } from "
|
|
12
|
+
import { getGlobalLogsDir } from "#src/config-paths";
|
|
13
|
+
import { computeExtensionPaths } from "#src/extension-paths";
|
|
14
14
|
|
|
15
15
|
describe("computeExtensionPaths", () => {
|
|
16
16
|
beforeEach(() => {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { describe, expect, it, vi } from "vitest";
|
|
2
2
|
|
|
3
|
-
import type { ForwardedPermissionLogger } from "
|
|
3
|
+
import type { ForwardedPermissionLogger } from "#src/forwarded-permissions/io";
|
|
4
4
|
import {
|
|
5
5
|
formatUnknownErrorMessage,
|
|
6
6
|
isErrnoCode,
|
|
7
7
|
logPermissionForwardingError,
|
|
8
8
|
logPermissionForwardingWarning,
|
|
9
|
-
} from "
|
|
9
|
+
} from "#src/forwarded-permissions/io";
|
|
10
10
|
|
|
11
11
|
// ── helpers ────────────────────────────────────────────────────────────────
|
|
12
12
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
2
2
|
|
|
3
|
-
import { ForwardingManager } from "
|
|
3
|
+
import { ForwardingManager } from "#src/forwarding-manager";
|
|
4
4
|
|
|
5
5
|
// ── Mocks ─────────────────────────────────────────────────────────────────
|
|
6
6
|
|
|
@@ -4,10 +4,10 @@ import { describe, expect, it, vi } from "vitest";
|
|
|
4
4
|
import {
|
|
5
5
|
AgentPrepHandler,
|
|
6
6
|
shouldExposeTool,
|
|
7
|
-
} from "
|
|
8
|
-
import type { PermissionSession } from "
|
|
9
|
-
import type { ToolRegistry } from "
|
|
10
|
-
import type { PermissionState } from "
|
|
7
|
+
} from "#src/handlers/before-agent-start";
|
|
8
|
+
import type { PermissionSession } from "#src/permission-session";
|
|
9
|
+
import type { ToolRegistry } from "#src/tool-registry";
|
|
10
|
+
import type { PermissionState } from "#src/types";
|
|
11
11
|
|
|
12
12
|
// ── SDK stubs ──────────────────────────────────────────────────────────────
|
|
13
13
|
vi.mock("@earendil-works/pi-coding-agent", async (importOriginal) => {
|
|
@@ -11,16 +11,16 @@
|
|
|
11
11
|
import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
12
12
|
import { describe, expect, it, vi } from "vitest";
|
|
13
13
|
|
|
14
|
-
import { EXTENSION_TAG } from "
|
|
15
|
-
import { formatExternalDirectoryAskPrompt } from "
|
|
16
|
-
import { PermissionGateHandler } from "
|
|
14
|
+
import { EXTENSION_TAG } from "#src/denial-messages";
|
|
15
|
+
import { formatExternalDirectoryAskPrompt } from "#src/handlers/gates/external-directory-messages";
|
|
16
|
+
import { PermissionGateHandler } from "#src/handlers/permission-gate-handler";
|
|
17
17
|
import {
|
|
18
18
|
PERMISSIONS_DECISION_CHANNEL,
|
|
19
19
|
type PermissionDecisionEvent,
|
|
20
|
-
} from "
|
|
21
|
-
import type { PermissionSession } from "
|
|
22
|
-
import type { ToolRegistry } from "
|
|
23
|
-
import type { PermissionCheckResult, PermissionState } from "
|
|
20
|
+
} from "#src/permission-events";
|
|
21
|
+
import type { PermissionSession } from "#src/permission-session";
|
|
22
|
+
import type { ToolRegistry } from "#src/tool-registry";
|
|
23
|
+
import type { PermissionCheckResult, PermissionState } from "#src/types";
|
|
24
24
|
|
|
25
25
|
// ── SDK stubs ──────────────────────────────────────────────────────────────
|
|
26
26
|
vi.mock("@earendil-works/pi-coding-agent", async (importOriginal) => {
|
|
@@ -11,12 +11,12 @@
|
|
|
11
11
|
import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
12
12
|
import { describe, expect, it, vi } from "vitest";
|
|
13
13
|
|
|
14
|
-
import { PermissionGateHandler } from "
|
|
15
|
-
import type { PermissionSession } from "
|
|
16
|
-
import type { Rule } from "
|
|
17
|
-
import type { ToolRegistry } from "
|
|
18
|
-
import type { PermissionCheckResult } from "
|
|
19
|
-
import { wildcardMatch } from "
|
|
14
|
+
import { PermissionGateHandler } from "#src/handlers/permission-gate-handler";
|
|
15
|
+
import type { PermissionSession } from "#src/permission-session";
|
|
16
|
+
import type { Rule } from "#src/rule";
|
|
17
|
+
import type { ToolRegistry } from "#src/tool-registry";
|
|
18
|
+
import type { PermissionCheckResult } from "#src/types";
|
|
19
|
+
import { wildcardMatch } from "#src/wildcard-matcher";
|
|
20
20
|
|
|
21
21
|
// ── SDK stub ───────────────────────────────────────────────────────────────
|
|
22
22
|
vi.mock("@earendil-works/pi-coding-agent", async (importOriginal) => {
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import { describe, expect, it, vi } from "vitest";
|
|
2
|
-
import { describeBashExternalDirectoryGate } from "
|
|
2
|
+
import { describeBashExternalDirectoryGate } from "#src/handlers/gates/bash-external-directory";
|
|
3
3
|
import type {
|
|
4
4
|
GateBypass,
|
|
5
5
|
GateDescriptor,
|
|
6
|
-
} from "
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
} from "../../../src/handlers/gates/descriptor";
|
|
11
|
-
import type { ToolCallContext } from "../../../src/handlers/gates/types";
|
|
12
|
-
import type { PermissionCheckResult } from "../../../src/types";
|
|
6
|
+
} from "#src/handlers/gates/descriptor";
|
|
7
|
+
import { isGateBypass, isGateDescriptor } from "#src/handlers/gates/descriptor";
|
|
8
|
+
import type { ToolCallContext } from "#src/handlers/gates/types";
|
|
9
|
+
import type { PermissionCheckResult } from "#src/types";
|
|
13
10
|
|
|
14
11
|
// ── helpers ────────────────────────────────────────────────────────────────
|
|
15
12
|
|
|
@@ -9,18 +9,15 @@ vi.mock("node:os", () => {
|
|
|
9
9
|
};
|
|
10
10
|
});
|
|
11
11
|
|
|
12
|
-
import { describeBashPathGate } from "
|
|
12
|
+
import { describeBashPathGate } from "#src/handlers/gates/bash-path";
|
|
13
13
|
import type {
|
|
14
14
|
GateBypass,
|
|
15
15
|
GateDescriptor,
|
|
16
|
-
} from "
|
|
17
|
-
import {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
} from "
|
|
21
|
-
import type { ToolCallContext } from "../../../src/handlers/gates/types";
|
|
22
|
-
import type { Rule } from "../../../src/rule";
|
|
23
|
-
import type { PermissionCheckResult } from "../../../src/types";
|
|
16
|
+
} from "#src/handlers/gates/descriptor";
|
|
17
|
+
import { isGateBypass, isGateDescriptor } from "#src/handlers/gates/descriptor";
|
|
18
|
+
import type { ToolCallContext } from "#src/handlers/gates/types";
|
|
19
|
+
import type { Rule } from "#src/rule";
|
|
20
|
+
import type { PermissionCheckResult } from "#src/types";
|
|
24
21
|
|
|
25
22
|
afterEach(() => {
|
|
26
23
|
vi.restoreAllMocks();
|
|
@@ -3,7 +3,7 @@ import { describe, expect, test } from "vitest";
|
|
|
3
3
|
import {
|
|
4
4
|
formatBashExternalDirectoryAskPrompt,
|
|
5
5
|
formatExternalDirectoryAskPrompt,
|
|
6
|
-
} from "
|
|
6
|
+
} from "#src/handlers/gates/external-directory-messages";
|
|
7
7
|
|
|
8
8
|
// Denial message functions (formatExternalDirectoryDenyReason,
|
|
9
9
|
// formatExternalDirectoryUserDeniedReason, formatExternalDirectoryHardStopHint,
|
|
@@ -3,13 +3,10 @@ import { describe, expect, it } from "vitest";
|
|
|
3
3
|
import type {
|
|
4
4
|
GateBypass,
|
|
5
5
|
GateDescriptor,
|
|
6
|
-
} from "
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
} from "../../../src/handlers/gates/descriptor";
|
|
11
|
-
import { describeExternalDirectoryGate } from "../../../src/handlers/gates/external-directory";
|
|
12
|
-
import type { ToolCallContext } from "../../../src/handlers/gates/types";
|
|
6
|
+
} from "#src/handlers/gates/descriptor";
|
|
7
|
+
import { isGateBypass, isGateDescriptor } from "#src/handlers/gates/descriptor";
|
|
8
|
+
import { describeExternalDirectoryGate } from "#src/handlers/gates/external-directory";
|
|
9
|
+
import type { ToolCallContext } from "#src/handlers/gates/types";
|
|
13
10
|
|
|
14
11
|
// ── helpers ───────────────────────────��────────────────────────────��───────
|
|
15
12
|
|
|
@@ -3,7 +3,7 @@ import { describe, expect, it } from "vitest";
|
|
|
3
3
|
import {
|
|
4
4
|
deriveDecisionValue,
|
|
5
5
|
deriveResolution,
|
|
6
|
-
} from "
|
|
6
|
+
} from "#src/handlers/gates/helpers";
|
|
7
7
|
|
|
8
8
|
describe("deriveDecisionValue", () => {
|
|
9
9
|
it("returns command for bash", () => {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { describe, expect, it, vi } from "vitest";
|
|
2
2
|
|
|
3
|
-
import type { GateDescriptor } from "
|
|
4
|
-
import { isGateDescriptor } from "
|
|
5
|
-
import { describePathGate } from "
|
|
6
|
-
import type { ToolCallContext } from "
|
|
7
|
-
import type { Rule } from "
|
|
8
|
-
import type { PermissionCheckResult } from "
|
|
3
|
+
import type { GateDescriptor } from "#src/handlers/gates/descriptor";
|
|
4
|
+
import { isGateDescriptor } from "#src/handlers/gates/descriptor";
|
|
5
|
+
import { describePathGate } from "#src/handlers/gates/path";
|
|
6
|
+
import type { ToolCallContext } from "#src/handlers/gates/types";
|
|
7
|
+
import type { Rule } from "#src/rule";
|
|
8
|
+
import type { PermissionCheckResult } from "#src/types";
|
|
9
9
|
|
|
10
10
|
// ── helpers ────────────────────────────────────────────────────────────────
|
|
11
11
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { describe, expect, it, vi } from "vitest";
|
|
2
2
|
|
|
3
|
-
import type { DenialContext } from "
|
|
4
|
-
import { EXTENSION_TAG } from "
|
|
3
|
+
import type { DenialContext } from "#src/denial-messages";
|
|
4
|
+
import { EXTENSION_TAG } from "#src/denial-messages";
|
|
5
5
|
import type {
|
|
6
6
|
GateDescriptor,
|
|
7
7
|
GateRunnerDeps,
|
|
8
|
-
} from "
|
|
9
|
-
import { runGateCheck } from "
|
|
10
|
-
import type { PermissionCheckResult } from "
|
|
8
|
+
} from "#src/handlers/gates/descriptor";
|
|
9
|
+
import { runGateCheck } from "#src/handlers/gates/runner";
|
|
10
|
+
import type { PermissionCheckResult } from "#src/types";
|
|
11
11
|
|
|
12
12
|
// ── helpers ────────────────────────────────────────────────────────────────
|
|
13
13
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { describe, expect, it, vi } from "vitest";
|
|
2
2
|
|
|
3
|
-
import type { GateDescriptor } from "
|
|
4
|
-
import { describeSkillReadGate } from "
|
|
5
|
-
import type { ToolCallContext } from "
|
|
6
|
-
import type { SkillPromptEntry } from "
|
|
3
|
+
import type { GateDescriptor } from "#src/handlers/gates/descriptor";
|
|
4
|
+
import { describeSkillReadGate } from "#src/handlers/gates/skill-read";
|
|
5
|
+
import type { ToolCallContext } from "#src/handlers/gates/types";
|
|
6
|
+
import type { SkillPromptEntry } from "#src/skill-prompt-sanitizer";
|
|
7
7
|
|
|
8
8
|
// ── SDK stubs ──────────────────────────────────────────────────────────────
|
|
9
9
|
vi.mock("@earendil-works/pi-coding-agent", async (importOriginal) => {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { describe, expect, it } from "vitest";
|
|
2
2
|
|
|
3
|
-
import { describeToolGate } from "
|
|
4
|
-
import type { ToolCallContext } from "
|
|
5
|
-
import type { PermissionCheckResult } from "
|
|
3
|
+
import { describeToolGate } from "#src/handlers/gates/tool";
|
|
4
|
+
import type { ToolCallContext } from "#src/handlers/gates/types";
|
|
5
|
+
import type { PermissionCheckResult } from "#src/types";
|
|
6
6
|
|
|
7
7
|
// ── helpers ────────────────────────────────────────────────────────────────
|
|
8
8
|
|