@xynogen/pix-gate 0.1.9 → 0.1.12
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/package.json +2 -2
- package/src/gate.test.ts +3 -2
- package/src/index.ts +7 -1
- package/src/lib.ts +1 -2
- package/src/prompt.ts +9 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xynogen/pix-gate",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.12",
|
|
4
4
|
"description": "Pi extension — permission gate for dangerous bash commands (confirm/block with TUI dialog)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.ts",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"access": "public"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@xynogen/pix-pretty": "
|
|
45
|
+
"@xynogen/pix-pretty": "^1.7.9"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"@earendil-works/pi-coding-agent": "*",
|
package/src/gate.test.ts
CHANGED
|
@@ -131,8 +131,9 @@ describe("buildRules", () => {
|
|
|
131
131
|
|
|
132
132
|
test("autoApprove strings compile to regexes", () => {
|
|
133
133
|
const { autoApprove } = buildRules({ autoApprove: ["^npm publish"] });
|
|
134
|
-
|
|
135
|
-
expect(
|
|
134
|
+
const rule0 = autoApprove[0] as RegExp;
|
|
135
|
+
expect(rule0.test("npm publish --access public")).toBe(true);
|
|
136
|
+
expect(rule0.test("yarn publish")).toBe(false);
|
|
136
137
|
});
|
|
137
138
|
|
|
138
139
|
test("defaults included when disableDefaults absent", () => {
|
package/src/index.ts
CHANGED
|
@@ -88,7 +88,13 @@ export default function (pi: ExtensionAPI): void {
|
|
|
88
88
|
});
|
|
89
89
|
|
|
90
90
|
// ── Unified bash gate (path + command concerns in ONE dialog) ───────────
|
|
91
|
-
const SEVERITY_TIER:
|
|
91
|
+
const SEVERITY_TIER: {
|
|
92
|
+
critical: number;
|
|
93
|
+
block: number;
|
|
94
|
+
dangerous: number;
|
|
95
|
+
warn: number;
|
|
96
|
+
risky: number;
|
|
97
|
+
} = {
|
|
92
98
|
critical: 5,
|
|
93
99
|
block: 4,
|
|
94
100
|
dangerous: 3,
|
package/src/lib.ts
CHANGED
|
@@ -276,8 +276,7 @@ export function extractPathsFromBash(cmd: string): string[] {
|
|
|
276
276
|
const out: string[] = [];
|
|
277
277
|
const re =
|
|
278
278
|
/(?:^|[\s=><|;&"'`(])((?:\.\.\/|\/|~\/|\.)[^\s"'`<>|;&)]+|\.env(?:\.[A-Za-z0-9_-]+)?|[A-Za-z0-9_./-]+\.(?:pem|key|p12|pfx|crt|cer|env|envrc|netrc))/g;
|
|
279
|
-
|
|
280
|
-
while ((m = re.exec(cmd)) !== null) out.push(m[1]);
|
|
279
|
+
for (const m of cmd.matchAll(re)) out.push(m[1] ?? "");
|
|
281
280
|
return out;
|
|
282
281
|
}
|
|
283
282
|
|
package/src/prompt.ts
CHANGED
|
@@ -126,7 +126,13 @@ export async function promptPathDecision(
|
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
/** Tier for dialog behavior — higher = more restrictive (deny-first, shorter timeout). */
|
|
129
|
-
const SEVERITY_TIER:
|
|
129
|
+
const SEVERITY_TIER: {
|
|
130
|
+
critical: number;
|
|
131
|
+
block: number;
|
|
132
|
+
dangerous: number;
|
|
133
|
+
warn: number;
|
|
134
|
+
risky: number;
|
|
135
|
+
} = {
|
|
130
136
|
critical: 5,
|
|
131
137
|
block: 4,
|
|
132
138
|
dangerous: 3,
|
|
@@ -146,6 +152,8 @@ export async function promptMergedGateDecision(
|
|
|
146
152
|
// Sort by tier desc so the highest-severity concern drives dialog behavior.
|
|
147
153
|
const sorted = [...concerns].sort((a, b) => b.tier - a.tier);
|
|
148
154
|
const highest = sorted[0];
|
|
155
|
+
if (!highest)
|
|
156
|
+
throw new Error("promptMergedGateDecision requires at least one concern");
|
|
149
157
|
const isRestrictive = highest.tier >= SEVERITY_TIER.block; // block or critical
|
|
150
158
|
|
|
151
159
|
// Title: unique severity types, joined with " + "
|