@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
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
5
5
|
import { describe, expect, it, vi } from "vitest";
|
|
6
6
|
|
|
7
|
-
import { PermissionGateHandler } from "
|
|
8
|
-
import type { PermissionDecisionEvent } from "
|
|
9
|
-
import { PERMISSIONS_DECISION_CHANNEL } from "
|
|
10
|
-
import type { PermissionSession } from "
|
|
11
|
-
import type { ToolRegistry } from "
|
|
12
|
-
import type { PermissionState } from "
|
|
7
|
+
import { PermissionGateHandler } from "#src/handlers/permission-gate-handler";
|
|
8
|
+
import type { PermissionDecisionEvent } from "#src/permission-events";
|
|
9
|
+
import { PERMISSIONS_DECISION_CHANNEL } from "#src/permission-events";
|
|
10
|
+
import type { PermissionSession } from "#src/permission-session";
|
|
11
|
+
import type { ToolRegistry } from "#src/tool-registry";
|
|
12
|
+
import type { PermissionState } from "#src/types";
|
|
13
13
|
|
|
14
14
|
// ── helpers ────────────────────────────────────────────────────────────────
|
|
15
15
|
|
|
@@ -4,10 +4,10 @@ import { describe, expect, it, vi } from "vitest";
|
|
|
4
4
|
import {
|
|
5
5
|
extractSkillNameFromInput,
|
|
6
6
|
PermissionGateHandler,
|
|
7
|
-
} from "
|
|
8
|
-
import type { PermissionSession } from "
|
|
9
|
-
import type { ToolRegistry } from "
|
|
10
|
-
import type { PermissionState } from "
|
|
7
|
+
} from "#src/handlers/permission-gate-handler";
|
|
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
|
// ── helpers ────────────────────────────────────────────────────────────────
|
|
13
13
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
import { describe, expect, it, vi } from "vitest";
|
|
3
|
-
import { SessionLifecycleHandler } from "
|
|
4
|
-
import type { PermissionSession } from "
|
|
3
|
+
import { SessionLifecycleHandler } from "#src/handlers/lifecycle";
|
|
4
|
+
import type { PermissionSession } from "#src/permission-session";
|
|
5
5
|
|
|
6
6
|
// ── status stub ────────────────────────────────────────────────────────────
|
|
7
7
|
vi.mock("../../src/status", () => ({
|
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
6
6
|
import { describe, expect, it, vi } from "vitest";
|
|
7
7
|
|
|
8
|
-
import { PermissionGateHandler } from "
|
|
9
|
-
import type { PermissionDecisionEvent } from "
|
|
10
|
-
import { PERMISSIONS_DECISION_CHANNEL } from "
|
|
11
|
-
import type { PermissionSession } from "
|
|
12
|
-
import type { ToolRegistry } from "
|
|
13
|
-
import type { PermissionCheckResult, PermissionState } from "
|
|
8
|
+
import { PermissionGateHandler } from "#src/handlers/permission-gate-handler";
|
|
9
|
+
import type { PermissionDecisionEvent } from "#src/permission-events";
|
|
10
|
+
import { PERMISSIONS_DECISION_CHANNEL } from "#src/permission-events";
|
|
11
|
+
import type { PermissionSession } from "#src/permission-session";
|
|
12
|
+
import type { ToolRegistry } from "#src/tool-registry";
|
|
13
|
+
import type { PermissionCheckResult, PermissionState } from "#src/types";
|
|
14
14
|
|
|
15
15
|
// ── helpers ────────────────────────────────────────────────────────────────
|
|
16
16
|
|
|
@@ -4,10 +4,10 @@ import { describe, expect, it, vi } from "vitest";
|
|
|
4
4
|
import {
|
|
5
5
|
getEventInput,
|
|
6
6
|
PermissionGateHandler,
|
|
7
|
-
} from "
|
|
8
|
-
import type { PermissionSession } from "
|
|
9
|
-
import type { ToolRegistry } from "
|
|
10
|
-
import type { PermissionCheckResult, PermissionState } from "
|
|
7
|
+
} from "#src/handlers/permission-gate-handler";
|
|
8
|
+
import type { PermissionSession } from "#src/permission-session";
|
|
9
|
+
import type { ToolRegistry } from "#src/tool-registry";
|
|
10
|
+
import type { PermissionCheckResult, PermissionState } from "#src/types";
|
|
11
11
|
|
|
12
12
|
// ── SDK stubs ──────────────────────────────────────────────────────────────
|
|
13
13
|
vi.mock("@earendil-works/pi-coding-agent", async (importOriginal) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { normalizeInput } from "
|
|
3
|
-
import { createMcpPermissionTargets } from "
|
|
2
|
+
import { normalizeInput } from "#src/input-normalizer";
|
|
3
|
+
import { createMcpPermissionTargets } from "#src/mcp-targets";
|
|
4
4
|
|
|
5
5
|
describe("normalizeInput — non-MCP surfaces", () => {
|
|
6
6
|
describe("special / path", () => {
|
|
@@ -2,7 +2,7 @@ import { describe, expect, it } from "vitest";
|
|
|
2
2
|
import {
|
|
3
3
|
createMcpPermissionTargets,
|
|
4
4
|
parseQualifiedMcpToolName,
|
|
5
|
-
} from "
|
|
5
|
+
} from "#src/mcp-targets";
|
|
6
6
|
|
|
7
7
|
describe("parseQualifiedMcpToolName", () => {
|
|
8
8
|
it("returns server and tool for a valid qualified name", () => {
|
|
@@ -18,7 +18,7 @@ vi.mock("node:fs", () => ({
|
|
|
18
18
|
default: { existsSync: mockExistsSync },
|
|
19
19
|
}));
|
|
20
20
|
|
|
21
|
-
import { discoverGlobalNodeModulesRoot } from "
|
|
21
|
+
import { discoverGlobalNodeModulesRoot } from "#src/node-modules-discovery";
|
|
22
22
|
|
|
23
23
|
describe("discoverGlobalNodeModulesRoot", () => {
|
|
24
24
|
beforeEach(() => {
|
|
@@ -3,16 +3,16 @@ import { describe, expect, it, vi } from "vitest";
|
|
|
3
3
|
import {
|
|
4
4
|
type PermissionRpcDeps,
|
|
5
5
|
registerPermissionRpcHandlers,
|
|
6
|
-
} from "
|
|
6
|
+
} from "#src/permission-event-rpc";
|
|
7
7
|
import type {
|
|
8
8
|
PermissionsCheckReplyData,
|
|
9
9
|
PermissionsRpcReply,
|
|
10
|
-
} from "
|
|
10
|
+
} from "#src/permission-events";
|
|
11
11
|
import {
|
|
12
12
|
PERMISSIONS_PROTOCOL_VERSION,
|
|
13
13
|
PERMISSIONS_RPC_CHECK_CHANNEL,
|
|
14
14
|
PERMISSIONS_RPC_PROMPT_CHANNEL,
|
|
15
|
-
} from "
|
|
15
|
+
} from "#src/permission-events";
|
|
16
16
|
|
|
17
17
|
// ── Helpers ────────────────────────────────────────────────────────────────
|
|
18
18
|
|
|
@@ -3,8 +3,8 @@ import { tmpdir } from "node:os";
|
|
|
3
3
|
import { dirname, join } from "node:path";
|
|
4
4
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
5
5
|
|
|
6
|
-
import { getGlobalConfigPath } from "
|
|
7
|
-
import piPermissionSystemExtension from "
|
|
6
|
+
import { getGlobalConfigPath } from "#src/config-paths";
|
|
7
|
+
import piPermissionSystemExtension from "#src/index";
|
|
8
8
|
import type {
|
|
9
9
|
PermissionDecisionEvent,
|
|
10
10
|
PermissionsCheckReplyData,
|
|
@@ -13,7 +13,7 @@ import type {
|
|
|
13
13
|
PermissionsPromptRequest,
|
|
14
14
|
PermissionsReadyEvent,
|
|
15
15
|
PermissionsRpcReply,
|
|
16
|
-
} from "
|
|
16
|
+
} from "#src/permission-events";
|
|
17
17
|
import {
|
|
18
18
|
emitDecisionEvent,
|
|
19
19
|
emitReadyEvent,
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
PERMISSIONS_READY_CHANNEL,
|
|
23
23
|
PERMISSIONS_RPC_CHECK_CHANNEL,
|
|
24
24
|
PERMISSIONS_RPC_PROMPT_CHANNEL,
|
|
25
|
-
} from "
|
|
25
|
+
} from "#src/permission-events";
|
|
26
26
|
|
|
27
27
|
// ── Minimal EventBus stub ──────────────────────────────────────────────────
|
|
28
28
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { describe, expect, it, vi } from "vitest";
|
|
2
|
-
import type { PermissionPromptDecision } from "
|
|
2
|
+
import type { PermissionPromptDecision } from "#src/permission-dialog";
|
|
3
3
|
import {
|
|
4
4
|
applyPermissionGate,
|
|
5
5
|
type PermissionGateParams,
|
|
6
|
-
} from "
|
|
6
|
+
} from "#src/permission-gate";
|
|
7
7
|
|
|
8
8
|
function makeParams(
|
|
9
9
|
overrides: Partial<PermissionGateParams> = {},
|
|
@@ -8,8 +8,8 @@ import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
|
8
8
|
import { homedir, tmpdir } from "node:os";
|
|
9
9
|
import { join } from "node:path";
|
|
10
10
|
import { describe, expect, it } from "vitest";
|
|
11
|
-
import { PermissionManager } from "
|
|
12
|
-
import type { Rule, Ruleset } from "
|
|
11
|
+
import { PermissionManager } from "#src/permission-manager";
|
|
12
|
+
import type { Rule, Ruleset } from "#src/rule";
|
|
13
13
|
|
|
14
14
|
// ---------------------------------------------------------------------------
|
|
15
15
|
// Helpers
|
|
@@ -666,9 +666,9 @@ describe("checkPermission — rule origin provenance", () => {
|
|
|
666
666
|
// In-memory PolicyLoader stub tests — no filesystem required
|
|
667
667
|
// ---------------------------------------------------------------------------
|
|
668
668
|
|
|
669
|
-
import type { PolicyLoader } from "
|
|
670
|
-
import type { ResolvedPolicyPaths } from "
|
|
671
|
-
import type { ScopeConfig } from "
|
|
669
|
+
import type { PolicyLoader } from "#src/permission-manager";
|
|
670
|
+
import type { ResolvedPolicyPaths } from "#src/policy-loader";
|
|
671
|
+
import type { ScopeConfig } from "#src/types";
|
|
672
672
|
|
|
673
673
|
/**
|
|
674
674
|
* Minimal in-memory PolicyLoader for testing merge + evaluation logic
|
|
@@ -14,13 +14,13 @@ vi.mock("../src/forwarded-permissions/polling", () => ({
|
|
|
14
14
|
// ── Imports (after mocks) ───────────────────────────────────────────────────
|
|
15
15
|
|
|
16
16
|
import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
17
|
-
import { DEFAULT_EXTENSION_CONFIG } from "
|
|
18
|
-
import type { PermissionPromptDecision } from "
|
|
19
|
-
import type { PromptPermissionDetails } from "
|
|
17
|
+
import { DEFAULT_EXTENSION_CONFIG } from "#src/extension-config";
|
|
18
|
+
import type { PermissionPromptDecision } from "#src/permission-dialog";
|
|
19
|
+
import type { PromptPermissionDetails } from "#src/permission-prompter";
|
|
20
20
|
import {
|
|
21
21
|
PermissionPrompter,
|
|
22
22
|
type PermissionPrompterDeps,
|
|
23
|
-
} from "
|
|
23
|
+
} from "#src/permission-prompter";
|
|
24
24
|
|
|
25
25
|
// ── Helpers ─────────────────────────────────────────────────────────────────
|
|
26
26
|
|
|
@@ -11,10 +11,10 @@ import {
|
|
|
11
11
|
formatSkillAskPrompt,
|
|
12
12
|
formatSkillPathAskPrompt,
|
|
13
13
|
formatUnknownToolReason,
|
|
14
|
-
} from "
|
|
15
|
-
import type { SkillPromptEntry } from "
|
|
16
|
-
import { formatToolInputForPrompt } from "
|
|
17
|
-
import type { PermissionCheckResult } from "
|
|
14
|
+
} from "#src/permission-prompts";
|
|
15
|
+
import type { SkillPromptEntry } from "#src/skill-prompt-sanitizer";
|
|
16
|
+
import { formatToolInputForPrompt } from "#src/tool-input-preview";
|
|
17
|
+
import type { PermissionCheckResult } from "#src/types";
|
|
18
18
|
|
|
19
19
|
const mockedFormatToolInput = vi.mocked(formatToolInputForPrompt);
|
|
20
20
|
|
|
@@ -29,16 +29,16 @@ vi.mock("../src/runtime", async (importOriginal) => {
|
|
|
29
29
|
|
|
30
30
|
// ── Test helpers ───────────────────────────────────────────────────────────
|
|
31
31
|
|
|
32
|
-
import type { ExtensionPaths } from "
|
|
33
|
-
import type { ForwardingController } from "
|
|
34
|
-
import type { PermissionManager } from "
|
|
32
|
+
import type { ExtensionPaths } from "#src/extension-paths";
|
|
33
|
+
import type { ForwardingController } from "#src/forwarding-manager";
|
|
34
|
+
import type { PermissionManager } from "#src/permission-manager";
|
|
35
35
|
import {
|
|
36
36
|
PermissionSession,
|
|
37
37
|
type PermissionSessionRuntimeDeps,
|
|
38
|
-
} from "
|
|
39
|
-
import type { SessionLogger } from "
|
|
40
|
-
import type { SkillPromptEntry } from "
|
|
41
|
-
import type { PermissionCheckResult } from "
|
|
38
|
+
} from "#src/permission-session";
|
|
39
|
+
import type { SessionLogger } from "#src/session-logger";
|
|
40
|
+
import type { SkillPromptEntry } from "#src/skill-prompt-sanitizer";
|
|
41
|
+
import type { PermissionCheckResult } from "#src/types";
|
|
42
42
|
|
|
43
43
|
function makeSkillEntry(
|
|
44
44
|
name: string,
|
|
@@ -14,39 +14,39 @@ import {
|
|
|
14
14
|
createActiveToolsCacheKey,
|
|
15
15
|
createBeforeAgentStartPromptStateKey,
|
|
16
16
|
shouldApplyCachedAgentStartState,
|
|
17
|
-
} from "
|
|
18
|
-
import { getGlobalConfigPath } from "
|
|
19
|
-
import { DEFAULT_EXTENSION_CONFIG } from "
|
|
20
|
-
import piPermissionSystemExtension from "
|
|
21
|
-
import { createPermissionSystemLogger } from "
|
|
17
|
+
} from "#src/before-agent-start-cache";
|
|
18
|
+
import { getGlobalConfigPath } from "#src/config-paths";
|
|
19
|
+
import { DEFAULT_EXTENSION_CONFIG } from "#src/extension-config";
|
|
20
|
+
import piPermissionSystemExtension from "#src/index";
|
|
21
|
+
import { createPermissionSystemLogger } from "#src/logging";
|
|
22
22
|
import {
|
|
23
23
|
createPermissionForwardingLocation,
|
|
24
24
|
isForwardedPermissionRequestForSession,
|
|
25
25
|
resolvePermissionForwardingTargetSessionId,
|
|
26
26
|
SUBAGENT_ENV_HINT_KEYS,
|
|
27
27
|
SUBAGENT_PARENT_SESSION_ENV_KEY,
|
|
28
|
-
} from "
|
|
29
|
-
import { PermissionManager } from "
|
|
28
|
+
} from "#src/permission-forwarding";
|
|
29
|
+
import { PermissionManager } from "#src/permission-manager";
|
|
30
30
|
import {
|
|
31
31
|
findSkillPathMatch,
|
|
32
32
|
parseAllSkillPromptSections,
|
|
33
33
|
resolveSkillPromptEntries,
|
|
34
|
-
} from "
|
|
35
|
-
import { getPermissionSystemStatus } from "
|
|
36
|
-
import { sanitizeAvailableToolsSection } from "
|
|
34
|
+
} from "#src/skill-prompt-sanitizer";
|
|
35
|
+
import { getPermissionSystemStatus } from "#src/status";
|
|
36
|
+
import { sanitizeAvailableToolsSection } from "#src/system-prompt-sanitizer";
|
|
37
37
|
import {
|
|
38
38
|
checkRequestedToolRegistration,
|
|
39
39
|
getToolNameFromValue,
|
|
40
|
-
} from "
|
|
40
|
+
} from "#src/tool-registry";
|
|
41
41
|
import type {
|
|
42
42
|
PermissionCheckResult,
|
|
43
43
|
PermissionState,
|
|
44
44
|
ScopeConfig,
|
|
45
|
-
} from "
|
|
45
|
+
} from "#src/types";
|
|
46
46
|
import {
|
|
47
47
|
canResolveAskPermissionRequest,
|
|
48
48
|
shouldAutoApprovePermissionState,
|
|
49
|
-
} from "
|
|
49
|
+
} from "#src/yolo-mode";
|
|
50
50
|
|
|
51
51
|
type CreateManagerOptions = {
|
|
52
52
|
mcpServerNames?: readonly string[];
|
|
@@ -15,8 +15,8 @@ vi.mock("node:child_process", () => ({
|
|
|
15
15
|
default: { spawnSync: mockSpawnSync },
|
|
16
16
|
}));
|
|
17
17
|
|
|
18
|
-
import { discoverGlobalNodeModulesRoot } from "
|
|
19
|
-
import { isPiInfrastructureRead } from "
|
|
18
|
+
import { discoverGlobalNodeModulesRoot } from "#src/node-modules-discovery";
|
|
19
|
+
import { isPiInfrastructureRead } from "#src/path-utils";
|
|
20
20
|
|
|
21
21
|
// ── discoverGlobalNodeModulesRoot ──────────────────────────────────────────
|
|
22
22
|
|
|
@@ -2,7 +2,7 @@ import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
|
2
2
|
import { tmpdir } from "node:os";
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import { describe, expect, it } from "vitest";
|
|
5
|
-
import { FilePolicyLoader } from "
|
|
5
|
+
import { FilePolicyLoader } from "#src/policy-loader";
|
|
6
6
|
|
|
7
7
|
// ---------------------------------------------------------------------------
|
|
8
8
|
// Helpers
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { describe, expect, test } from "vitest";
|
|
2
|
-
import type { Rule, RuleOrigin, Ruleset } from "
|
|
3
|
-
import { evaluate, evaluateFirst, evaluateMostRestrictive } from "
|
|
2
|
+
import type { Rule, RuleOrigin, Ruleset } from "#src/rule";
|
|
3
|
+
import { evaluate, evaluateFirst, evaluateMostRestrictive } from "#src/rule";
|
|
4
4
|
|
|
5
5
|
describe("evaluate", () => {
|
|
6
6
|
const allowBashGit: Rule = {
|
|
@@ -71,15 +71,15 @@ import {
|
|
|
71
71
|
getGlobalConfigPath,
|
|
72
72
|
getGlobalLogsDir,
|
|
73
73
|
getProjectConfigPath,
|
|
74
|
-
} from "
|
|
75
|
-
import { DEFAULT_EXTENSION_CONFIG } from "
|
|
76
|
-
import { PermissionManager } from "
|
|
74
|
+
} from "#src/config-paths";
|
|
75
|
+
import { DEFAULT_EXTENSION_CONFIG } from "#src/extension-config";
|
|
76
|
+
import { PermissionManager } from "#src/permission-manager";
|
|
77
77
|
import {
|
|
78
78
|
createExtensionRuntime,
|
|
79
79
|
createPermissionManagerForCwd,
|
|
80
80
|
derivePiProjectPaths,
|
|
81
81
|
refreshExtensionConfig,
|
|
82
|
-
} from "
|
|
82
|
+
} from "#src/runtime";
|
|
83
83
|
|
|
84
84
|
// ── test suite ─────────────────────────────────────────────────────────────
|
|
85
85
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
2
|
-
import { buildInputForSurface } from "
|
|
3
|
-
import type { PermissionsService } from "
|
|
2
|
+
import { buildInputForSurface } from "#src/input-normalizer";
|
|
3
|
+
import type { PermissionsService } from "#src/service";
|
|
4
4
|
import {
|
|
5
5
|
getPermissionsService,
|
|
6
6
|
publishPermissionsService,
|
|
7
7
|
unpublishPermissionsService,
|
|
8
|
-
} from "
|
|
9
|
-
import type { PermissionCheckResult } from "
|
|
8
|
+
} from "#src/service";
|
|
9
|
+
import type { PermissionCheckResult } from "#src/types";
|
|
10
10
|
|
|
11
11
|
// ── helpers ────────────────────────────────────────────────────────────────
|
|
12
12
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { describe, expect, it, vi } from "vitest";
|
|
2
|
-
import type { ExtensionRuntime } from "
|
|
3
|
-
import { createSessionLogger } from "
|
|
2
|
+
import type { ExtensionRuntime } from "#src/runtime";
|
|
3
|
+
import { createSessionLogger } from "#src/session-logger";
|
|
4
4
|
|
|
5
5
|
// ── helpers ────────────────────────────────────────────────────────────────
|
|
6
6
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { describe, expect, it } from "vitest";
|
|
2
2
|
|
|
3
|
-
import { evaluate } from "
|
|
4
|
-
import { deriveApprovalPattern, SessionRules } from "
|
|
3
|
+
import { evaluate } from "#src/rule";
|
|
4
|
+
import { deriveApprovalPattern, SessionRules } from "#src/session-rules";
|
|
5
5
|
|
|
6
6
|
// ── SessionRules ───────────────────────────────────────────────────────────
|
|
7
7
|
|
|
@@ -2,10 +2,10 @@ import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
|
2
2
|
import { tmpdir } from "node:os";
|
|
3
3
|
import { dirname, join } from "node:path";
|
|
4
4
|
import { afterEach, beforeEach, describe, expect, test } from "vitest";
|
|
5
|
-
import { getGlobalConfigPath } from "
|
|
6
|
-
import { DEFAULT_EXTENSION_CONFIG } from "
|
|
7
|
-
import piPermissionSystemExtension from "
|
|
8
|
-
import type { ScopeConfig } from "
|
|
5
|
+
import { getGlobalConfigPath } from "#src/config-paths";
|
|
6
|
+
import { DEFAULT_EXTENSION_CONFIG } from "#src/extension-config";
|
|
7
|
+
import piPermissionSystemExtension from "#src/index";
|
|
8
|
+
import type { ScopeConfig } from "#src/types";
|
|
9
9
|
|
|
10
10
|
type MockHandler = (
|
|
11
11
|
event: Record<string, unknown>,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { afterEach, describe, expect, test, vi } from "vitest";
|
|
2
|
-
import type { PermissionManager } from "
|
|
2
|
+
import type { PermissionManager } from "#src/permission-manager";
|
|
3
3
|
import {
|
|
4
4
|
findSkillPathMatch,
|
|
5
5
|
resolveSkillPromptEntries,
|
|
6
|
-
} from "
|
|
7
|
-
import type { PermissionCheckResult } from "
|
|
6
|
+
} from "#src/skill-prompt-sanitizer";
|
|
7
|
+
import type { PermissionCheckResult } from "#src/types";
|
|
8
8
|
|
|
9
9
|
afterEach(() => {
|
|
10
10
|
vi.restoreAllMocks();
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
import { afterEach, describe, expect, test, vi } from "vitest";
|
|
3
|
-
import { SUBAGENT_ENV_HINT_KEYS } from "
|
|
3
|
+
import { SUBAGENT_ENV_HINT_KEYS } from "#src/permission-forwarding";
|
|
4
4
|
import {
|
|
5
5
|
isSubagentExecutionContext,
|
|
6
6
|
normalizeFilesystemPath,
|
|
7
|
-
} from "
|
|
7
|
+
} from "#src/subagent-context";
|
|
8
8
|
|
|
9
9
|
afterEach(() => {
|
|
10
10
|
vi.unstubAllEnvs();
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { describe, expect, test } from "vitest";
|
|
2
|
-
import type { RuleOrigin } from "
|
|
3
|
-
import { evaluate } from "
|
|
2
|
+
import type { RuleOrigin } from "#src/rule";
|
|
3
|
+
import { evaluate } from "#src/rule";
|
|
4
4
|
import {
|
|
5
5
|
composeRuleset,
|
|
6
6
|
synthesizeBaseline,
|
|
7
7
|
synthesizeDefaults,
|
|
8
|
-
} from "
|
|
8
|
+
} from "#src/synthesize";
|
|
9
9
|
|
|
10
10
|
// ── synthesizeDefaults ─────────────────────────────────────────────────────
|
|
11
11
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { afterEach, describe, expect, test, vi } from "vitest";
|
|
2
2
|
|
|
3
|
-
import { sanitizeAvailableToolsSection } from "
|
|
3
|
+
import { sanitizeAvailableToolsSection } from "#src/system-prompt-sanitizer";
|
|
4
4
|
|
|
5
5
|
afterEach(() => {
|
|
6
6
|
vi.restoreAllMocks();
|
|
@@ -5,7 +5,7 @@ vi.mock("../src/logging.js", () => ({
|
|
|
5
5
|
safeJsonStringify: vi.fn((value: unknown) => JSON.stringify(value)),
|
|
6
6
|
}));
|
|
7
7
|
|
|
8
|
-
import { safeJsonStringify } from "
|
|
8
|
+
import { safeJsonStringify } from "#src/logging";
|
|
9
9
|
import {
|
|
10
10
|
countTextLines,
|
|
11
11
|
formatCount,
|
|
@@ -24,8 +24,8 @@ import {
|
|
|
24
24
|
TOOL_INPUT_PREVIEW_MAX_LENGTH,
|
|
25
25
|
TOOL_TEXT_SUMMARY_MAX_LENGTH,
|
|
26
26
|
truncateInlineText,
|
|
27
|
-
} from "
|
|
28
|
-
import type { PermissionCheckResult } from "
|
|
27
|
+
} from "#src/tool-input-preview";
|
|
28
|
+
import type { PermissionCheckResult } from "#src/types";
|
|
29
29
|
|
|
30
30
|
const mockedStringify = vi.mocked(safeJsonStringify);
|
|
31
31
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { afterEach, describe, expect, test, vi } from "vitest";
|
|
2
|
-
import type { PermissionSystemExtensionConfig } from "
|
|
2
|
+
import type { PermissionSystemExtensionConfig } from "#src/extension-config";
|
|
3
3
|
import {
|
|
4
4
|
canResolveAskPermissionRequest,
|
|
5
5
|
shouldAutoApprovePermissionState,
|
|
6
|
-
} from "
|
|
6
|
+
} from "#src/yolo-mode";
|
|
7
7
|
|
|
8
8
|
afterEach(() => {
|
|
9
9
|
vi.restoreAllMocks();
|