mirror of
https://bitbucket.org/siakitem/my-pi.git
synced 2026-10-26 10:45:22 +00:00
refactor(permission-system): simplify policy and autoreview flow
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -47,16 +47,6 @@ describe("normalizeInput — non-MCP surfaces", () => {
|
||||
expect(result.resultExtras).toEqual({});
|
||||
});
|
||||
|
||||
it("external_directory surface ignores input.path and returns ['*']", () => {
|
||||
const result = normalizeInput(
|
||||
"external_directory",
|
||||
{ path: "/other/project" },
|
||||
[],
|
||||
);
|
||||
expect(result.surface).toBe("external_directory");
|
||||
expect(result.values).toEqual(["*"]);
|
||||
expect(result.resultExtras).toEqual({});
|
||||
});
|
||||
|
||||
it("read surface ignores input.path and returns ['*']", () => {
|
||||
const result = normalizeInput("read", { path: ".env" }, []);
|
||||
@@ -68,7 +58,6 @@ describe("normalizeInput — non-MCP surfaces", () => {
|
||||
it("missing path also returns ['*'] (unchanged fallback)", () => {
|
||||
for (const surface of [
|
||||
"path",
|
||||
"external_directory",
|
||||
"read",
|
||||
"write",
|
||||
"edit",
|
||||
@@ -249,19 +238,6 @@ describe("buildAccessIntentForSurface", () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("emits an access-path intent for the external_directory surface", () => {
|
||||
const intent = buildAccessIntentForSurface(
|
||||
"external_directory",
|
||||
"/outside/dir",
|
||||
normalizer,
|
||||
undefined,
|
||||
);
|
||||
expect(intent.kind).toBe("access-path");
|
||||
if (intent.kind === "access-path") {
|
||||
expect(intent.surface).toBe("external_directory");
|
||||
expect(intent.path.value()).toBe("/outside/dir");
|
||||
}
|
||||
});
|
||||
|
||||
it("emits an access-path intent for a path-bearing tool surface (read)", () => {
|
||||
const intent = buildAccessIntentForSurface(
|
||||
@@ -315,15 +291,6 @@ describe("buildAccessIntentForSurface", () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("falls back to a tool intent for a whitespace-only path value", () => {
|
||||
const intent = buildAccessIntentForSurface(
|
||||
"external_directory",
|
||||
" ",
|
||||
normalizer,
|
||||
undefined,
|
||||
);
|
||||
expect(intent.kind).toBe("tool");
|
||||
});
|
||||
});
|
||||
|
||||
describe("buildResolvedIntentFromMatchValues", () => {
|
||||
@@ -348,19 +315,6 @@ describe("buildResolvedIntentFromMatchValues", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("emits a path-values intent for the external_directory surface", () => {
|
||||
const intent = buildResolvedIntentFromMatchValues(
|
||||
"external_directory",
|
||||
["/tmp/x", "/real/tmp/x"],
|
||||
"Explore",
|
||||
);
|
||||
expect(intent).toEqual({
|
||||
kind: "path-values",
|
||||
surface: "external_directory",
|
||||
values: ["/tmp/x", "/real/tmp/x"],
|
||||
agentName: "Explore",
|
||||
});
|
||||
});
|
||||
|
||||
it("emits a tool intent from the single portable value for a non-path surface (bash)", () => {
|
||||
const intent = buildResolvedIntentFromMatchValues(
|
||||
|
||||
@@ -3,7 +3,6 @@ import { describe, expect, test } from "vitest";
|
||||
import {
|
||||
PATH_BEARING_TOOLS,
|
||||
PATH_SURFACES,
|
||||
READ_ONLY_PATH_BEARING_TOOLS,
|
||||
} from "#src/access-intent/path-surfaces";
|
||||
|
||||
describe("PATH_BEARING_TOOLS", () => {
|
||||
@@ -19,21 +18,9 @@ describe("PATH_BEARING_TOOLS", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("READ_ONLY_PATH_BEARING_TOOLS", () => {
|
||||
test("contains read, find, grep, ls", () => {
|
||||
for (const tool of ["read", "find", "grep", "ls"]) {
|
||||
expect(READ_ONLY_PATH_BEARING_TOOLS.has(tool)).toBe(true);
|
||||
}
|
||||
});
|
||||
|
||||
test("does not contain write or edit", () => {
|
||||
expect(READ_ONLY_PATH_BEARING_TOOLS.has("write")).toBe(false);
|
||||
expect(READ_ONLY_PATH_BEARING_TOOLS.has("edit")).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("PATH_SURFACES", () => {
|
||||
test("contains the path-bearing tools plus the cross-cutting gates", () => {
|
||||
test("contains the path-bearing tools plus the path gate", () => {
|
||||
for (const surface of [
|
||||
"read",
|
||||
"write",
|
||||
@@ -41,7 +28,6 @@ describe("PATH_SURFACES", () => {
|
||||
"find",
|
||||
"grep",
|
||||
"ls",
|
||||
"external_directory",
|
||||
"path",
|
||||
]) {
|
||||
expect(PATH_SURFACES.has(surface)).toBe(true);
|
||||
|
||||
Reference in New Issue
Block a user