@gotgenes/pi-permission-system 18.1.1 → 18.1.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.
- package/CHANGELOG.md +16 -0
- package/docs/configuration.md +11 -0
- package/package.json +1 -2
- package/src/access-intent/access-path.ts +29 -4
- package/src/access-intent/bash/bash-path-resolver.ts +39 -18
- package/src/access-intent/bash/msys-bash-tokens.ts +64 -0
- package/src/path-normalizer.ts +105 -2
- package/test/access-intent/access-path.test.ts +0 -277
- package/test/access-intent/bash/node-text.test.ts +0 -148
- package/test/access-intent/bash/parser.test.ts +0 -19
- package/test/access-intent/bash/program.test.ts +0 -673
- package/test/access-intent/bash/token-classification.test.ts +0 -363
- package/test/access-intent/bash/token-collection.test.ts +0 -300
- package/test/active-agent.test.ts +0 -155
- package/test/async-cache.test.ts +0 -48
- package/test/bash-arity.test.ts +0 -144
- package/test/bash-external-directory.test.ts +0 -1022
- package/test/builtin-tool-input-formatters.test.ts +0 -109
- package/test/canonicalize-path.test.ts +0 -119
- package/test/composition-root.test.ts +0 -698
- package/test/config-loader.test.ts +0 -740
- package/test/config-modal.test.ts +0 -320
- package/test/config-paths.test.ts +0 -83
- package/test/config-pipeline.test.ts +0 -90
- package/test/config-reporter.test.ts +0 -147
- package/test/config-store.test.ts +0 -466
- package/test/decision-audit.test.ts +0 -72
- package/test/decision-reporter.test.ts +0 -112
- package/test/denial-messages.test.ts +0 -714
- package/test/detect-permissive-bash-fallback.test.ts +0 -56
- package/test/expand-home.test.ts +0 -93
- package/test/extension-config.test.ts +0 -129
- package/test/extension-paths.test.ts +0 -108
- package/test/forwarded-permissions/io.test.ts +0 -251
- package/test/forwarding-manager.test.ts +0 -200
- package/test/handlers/before-agent-start.test.ts +0 -314
- package/test/handlers/external-directory-integration.test.ts +0 -515
- package/test/handlers/external-directory-session-dedup.test.ts +0 -175
- package/test/handlers/external-directory-symlink-acceptance.test.ts +0 -167
- package/test/handlers/gates/bash-command-metamorphic.test.ts +0 -88
- package/test/handlers/gates/bash-command.test.ts +0 -257
- package/test/handlers/gates/bash-external-directory.test.ts +0 -268
- package/test/handlers/gates/bash-path.test.ts +0 -346
- package/test/handlers/gates/candidate-check.test.ts +0 -52
- package/test/handlers/gates/external-directory-messages.test.ts +0 -85
- package/test/handlers/gates/external-directory-policy.test.ts +0 -134
- package/test/handlers/gates/external-directory.test.ts +0 -267
- package/test/handlers/gates/helpers.test.ts +0 -165
- package/test/handlers/gates/path.test.ts +0 -369
- package/test/handlers/gates/runner.test.ts +0 -408
- package/test/handlers/gates/skill-input-gate-pipeline.test.ts +0 -176
- package/test/handlers/gates/skill-input.test.ts +0 -128
- package/test/handlers/gates/skill-read.test.ts +0 -161
- package/test/handlers/gates/tool-call-gate-pipeline.test.ts +0 -356
- package/test/handlers/gates/tool.test.ts +0 -244
- package/test/handlers/input-events.test.ts +0 -168
- package/test/handlers/input.test.ts +0 -199
- package/test/handlers/lifecycle.test.ts +0 -221
- package/test/handlers/tool-call-boundary.test.ts +0 -145
- package/test/handlers/tool-call-events.test.ts +0 -277
- package/test/handlers/tool-call.test.ts +0 -395
- package/test/handlers/validate-requested-tool.test.ts +0 -92
- package/test/helpers/external-directory-fixtures.ts +0 -269
- package/test/helpers/gate-fixtures.ts +0 -316
- package/test/helpers/handler-fixtures.ts +0 -335
- package/test/helpers/make-fake-pi.ts +0 -100
- package/test/helpers/manager-harness.ts +0 -112
- package/test/helpers/session-fixtures.ts +0 -199
- package/test/input-normalizer.test.ts +0 -325
- package/test/logging.test.ts +0 -51
- package/test/mcp-targets.test.ts +0 -233
- package/test/node-modules-discovery.test.ts +0 -97
- package/test/normalize.test.ts +0 -247
- package/test/path-containment.test.ts +0 -161
- package/test/path-normalization.test.ts +0 -233
- package/test/path-normalizer.test.ts +0 -196
- package/test/path-surfaces.test.ts +0 -55
- package/test/pattern-suggest.test.ts +0 -248
- package/test/permission-dialog.test.ts +0 -205
- package/test/permission-event-rpc.test.ts +0 -560
- package/test/permission-events.test.ts +0 -400
- package/test/permission-forwarder.test.ts +0 -370
- package/test/permission-forwarding.test.ts +0 -315
- package/test/permission-gate.test.ts +0 -269
- package/test/permission-manager-unified.test.ts +0 -3714
- package/test/permission-merge.test.ts +0 -61
- package/test/permission-prompter.test.ts +0 -518
- package/test/permission-prompts.test.ts +0 -363
- package/test/permission-resolver.test.ts +0 -277
- package/test/permission-session.test.ts +0 -404
- package/test/permission-ui-prompt.test.ts +0 -146
- package/test/permissions-service.test.ts +0 -192
- package/test/pi-infrastructure-read.test.ts +0 -432
- package/test/policy-loader.test.ts +0 -561
- package/test/prompting-gateway.test.ts +0 -231
- package/test/rule.test.ts +0 -650
- package/test/safe-system-paths.test.ts +0 -46
- package/test/scope-merge.test.ts +0 -116
- package/test/service-lifecycle.test.ts +0 -163
- package/test/service.test.ts +0 -261
- package/test/session-approval.test.ts +0 -75
- package/test/session-logger.test.ts +0 -200
- package/test/session-rules.test.ts +0 -321
- package/test/session-start.test.ts +0 -112
- package/test/skill-prompt-sanitizer.test.ts +0 -418
- package/test/status.test.ts +0 -10
- package/test/subagent-context.test.ts +0 -372
- package/test/subagent-lifecycle-events.test.ts +0 -132
- package/test/subagent-registry.test.ts +0 -145
- package/test/synthesize.test.ts +0 -302
- package/test/system-prompt-sanitizer.test.ts +0 -382
- package/test/tool-access-extractor-registry.test.ts +0 -77
- package/test/tool-input-formatter-registry.test.ts +0 -75
- package/test/tool-input-path.test.ts +0 -84
- package/test/tool-input-preview.test.ts +0 -129
- package/test/tool-input-prompt-formatters.test.ts +0 -115
- package/test/tool-preview-formatter.test.ts +0 -458
- package/test/tool-registry.test.ts +0 -197
- package/test/value-guards.test.ts +0 -193
- package/test/wildcard-matcher.test.ts +0 -424
- package/test/yaml-frontmatter.test.ts +0 -91
- package/test/yolo-mode.test.ts +0 -188
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import {
|
|
3
|
-
resolveNodeText,
|
|
4
|
-
SKIP_SUBTREE_TYPES,
|
|
5
|
-
} from "#src/access-intent/bash/node-text";
|
|
6
|
-
import type { TSNode } from "#src/access-intent/bash/parser";
|
|
7
|
-
|
|
8
|
-
// Minimal fake TSNode builder — only fills the fields resolveNodeText reads.
|
|
9
|
-
function makeNode(type: string, text: string, children: TSNode[] = []): TSNode {
|
|
10
|
-
return {
|
|
11
|
-
type,
|
|
12
|
-
text,
|
|
13
|
-
startIndex: 0,
|
|
14
|
-
childCount: children.length,
|
|
15
|
-
isNamed: true,
|
|
16
|
-
child: (i) => children[i] ?? null,
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
describe("SKIP_SUBTREE_TYPES", () => {
|
|
21
|
-
it("contains the three node types that must not be descended", () => {
|
|
22
|
-
expect(SKIP_SUBTREE_TYPES.has("heredoc_body")).toBe(true);
|
|
23
|
-
expect(SKIP_SUBTREE_TYPES.has("heredoc_end")).toBe(true);
|
|
24
|
-
expect(SKIP_SUBTREE_TYPES.has("comment")).toBe(true);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it("does not contain common argument node types", () => {
|
|
28
|
-
expect(SKIP_SUBTREE_TYPES.has("word")).toBe(false);
|
|
29
|
-
expect(SKIP_SUBTREE_TYPES.has("string")).toBe(false);
|
|
30
|
-
expect(SKIP_SUBTREE_TYPES.has("raw_string")).toBe(false);
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
describe("resolveNodeText", () => {
|
|
35
|
-
describe("word nodes", () => {
|
|
36
|
-
it("returns the node text unchanged", () => {
|
|
37
|
-
expect(resolveNodeText(makeNode("word", "hello"))).toBe("hello");
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
describe("raw_string nodes (single-quoted)", () => {
|
|
42
|
-
it("strips surrounding single quotes", () => {
|
|
43
|
-
expect(resolveNodeText(makeNode("raw_string", "'content'"))).toBe(
|
|
44
|
-
"content",
|
|
45
|
-
);
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it("strips single quotes around a path", () => {
|
|
49
|
-
expect(resolveNodeText(makeNode("raw_string", "'/etc/hosts'"))).toBe(
|
|
50
|
-
"/etc/hosts",
|
|
51
|
-
);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it("returns text as-is when not fully single-quoted", () => {
|
|
55
|
-
// A raw_string node without enclosing quotes (defensive fallback)
|
|
56
|
-
expect(resolveNodeText(makeNode("raw_string", "noquotes"))).toBe(
|
|
57
|
-
"noquotes",
|
|
58
|
-
);
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
describe("string nodes (double-quoted)", () => {
|
|
63
|
-
it("concatenates inner word children, skipping quote delimiters", () => {
|
|
64
|
-
const quoteOpen = makeNode('"', '"');
|
|
65
|
-
const content = makeNode("string_content", "hello world");
|
|
66
|
-
const quoteClose = makeNode('"', '"');
|
|
67
|
-
const node = makeNode("string", '"hello world"', [
|
|
68
|
-
quoteOpen,
|
|
69
|
-
content,
|
|
70
|
-
quoteClose,
|
|
71
|
-
]);
|
|
72
|
-
expect(resolveNodeText(node)).toBe("hello world");
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it("concatenates multiple inner children", () => {
|
|
76
|
-
const quoteOpen = makeNode('"', '"');
|
|
77
|
-
const part1 = makeNode("string_content", "foo");
|
|
78
|
-
const part2 = makeNode("simple_expansion", "$BAR");
|
|
79
|
-
const quoteClose = makeNode('"', '"');
|
|
80
|
-
const node = makeNode("string", '"foo$BAR"', [
|
|
81
|
-
quoteOpen,
|
|
82
|
-
part1,
|
|
83
|
-
part2,
|
|
84
|
-
quoteClose,
|
|
85
|
-
]);
|
|
86
|
-
expect(resolveNodeText(node)).toBe("foo$BAR");
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it("returns empty string for an empty double-quoted string", () => {
|
|
90
|
-
const quoteOpen = makeNode('"', '"');
|
|
91
|
-
const quoteClose = makeNode('"', '"');
|
|
92
|
-
const node = makeNode("string", '""', [quoteOpen, quoteClose]);
|
|
93
|
-
expect(resolveNodeText(node)).toBe("");
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
describe("string_content, simple_expansion, and expansion nodes", () => {
|
|
98
|
-
it("returns text as-is for string_content", () => {
|
|
99
|
-
expect(resolveNodeText(makeNode("string_content", "plain text"))).toBe(
|
|
100
|
-
"plain text",
|
|
101
|
-
);
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
it("returns text as-is for simple_expansion (e.g. $HOME)", () => {
|
|
105
|
-
// retro 0350: $HOME returns the literal text of a simple_expansion node
|
|
106
|
-
expect(resolveNodeText(makeNode("simple_expansion", "$HOME"))).toBe(
|
|
107
|
-
"$HOME",
|
|
108
|
-
);
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
it("returns text as-is for expansion", () => {
|
|
112
|
-
// biome-ignore lint/suspicious/noTemplateCurlyInString: intentional literal — testing that expansion node text is returned verbatim
|
|
113
|
-
expect(resolveNodeText(makeNode("expansion", "${VAR}"))).toBe("${VAR}");
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
describe("concatenation nodes", () => {
|
|
118
|
-
it("concatenates resolved children", () => {
|
|
119
|
-
const word = makeNode("word", "/etc/");
|
|
120
|
-
const expansion = makeNode("simple_expansion", "$FILE");
|
|
121
|
-
const node = makeNode("concatenation", "/etc/$FILE", [word, expansion]);
|
|
122
|
-
expect(resolveNodeText(node)).toBe("/etc/$FILE");
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
it("handles nested concatenation-of-string", () => {
|
|
126
|
-
// A concatenation whose child is a double-quoted string
|
|
127
|
-
const quoteOpen = makeNode('"', '"');
|
|
128
|
-
const content = makeNode("string_content", "bar");
|
|
129
|
-
const quoteClose = makeNode('"', '"');
|
|
130
|
-
const inner = makeNode("string", '"bar"', [
|
|
131
|
-
quoteOpen,
|
|
132
|
-
content,
|
|
133
|
-
quoteClose,
|
|
134
|
-
]);
|
|
135
|
-
const prefix = makeNode("word", "foo");
|
|
136
|
-
const node = makeNode("concatenation", 'foo"bar"', [prefix, inner]);
|
|
137
|
-
expect(resolveNodeText(node)).toBe("foobar");
|
|
138
|
-
});
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
describe("default fallback", () => {
|
|
142
|
-
it("returns the raw text for unknown node types", () => {
|
|
143
|
-
expect(resolveNodeText(makeNode("unknown_type", "rawtext"))).toBe(
|
|
144
|
-
"rawtext",
|
|
145
|
-
);
|
|
146
|
-
});
|
|
147
|
-
});
|
|
148
|
-
});
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { getParser } from "#src/access-intent/bash/parser";
|
|
3
|
-
|
|
4
|
-
describe("getParser", () => {
|
|
5
|
-
it("parses a simple bash command and returns a non-null root node", async () => {
|
|
6
|
-
const parser = await getParser();
|
|
7
|
-
const tree = parser.parse("echo hi");
|
|
8
|
-
expect(tree).not.toBeNull();
|
|
9
|
-
expect(tree?.rootNode).toBeDefined();
|
|
10
|
-
expect(tree?.rootNode.type).toBe("program");
|
|
11
|
-
tree?.delete();
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it("returns the same memoized parser instance on repeated calls", async () => {
|
|
15
|
-
const first = await getParser();
|
|
16
|
-
const second = await getParser();
|
|
17
|
-
expect(first).toBe(second);
|
|
18
|
-
});
|
|
19
|
-
});
|