@xynogen/pix-gate 0.1.16 → 0.2.1

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xynogen/pix-gate",
3
- "version": "0.1.16",
3
+ "version": "0.2.1",
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",
@@ -44,7 +44,7 @@
44
44
  "dependencies": {
45
45
  "@xynogen/pix-pretty": "^1.7.9",
46
46
  "@xynogen/pix-data": "^0.4.0",
47
- "@xynogen/pix-runtime": "^0.2.0"
47
+ "@xynogen/pix-runtime": "^0.4.0"
48
48
  },
49
49
  "peerDependencies": {
50
50
  "@earendil-works/pi-coding-agent": "*",
package/src/gate.test.ts CHANGED
@@ -105,14 +105,14 @@ describe("classify", () => {
105
105
  // ── buildRules ────────────────────────────────────────────────────────────────
106
106
 
107
107
  describe("buildRules", () => {
108
- test("disableDefaults removes all built-in rules", () => {
109
- const { rules } = buildRules({ disableDefaults: true });
108
+ test("guardrails off removes all built-in rules", () => {
109
+ const { rules } = buildRules({ guardrails: "off" });
110
110
  expect(rules).toHaveLength(0);
111
111
  });
112
112
 
113
- test("extraRules are appended", () => {
113
+ test("extraRules are appended when guardrails are off", () => {
114
114
  const { rules } = buildRules({
115
- disableDefaults: true,
115
+ guardrails: "off",
116
116
  extraRules: [{ pattern: "foo", severity: "risky", reason: "test" }],
117
117
  });
118
118
  expect(rules).toHaveLength(1);
@@ -126,7 +126,7 @@ describe("buildRules", () => {
126
126
  expect(rule0.test("yarn publish")).toBe(false);
127
127
  });
128
128
 
129
- test("defaults included when disableDefaults absent", () => {
129
+ test("defaults included when guardrails is absent", () => {
130
130
  const { rules } = buildRules({});
131
131
  expect(rules.length).toBe(DEFAULT_RULES.length);
132
132
  });
package/src/index.ts CHANGED
@@ -11,8 +11,8 @@
11
11
  * sudo — hard block, must use sudo_run tool instead (no bypass)
12
12
  * No-UI fallback: critical/dangerous auto-block (can't show dialog)
13
13
  *
14
- * Config: ~/.pi/agent/pix-gate.json
15
- * disableDefaults: true — replace built-in rules entirely
14
+ * Config: ~/.pi/agent/pix.json (the `gate` section)
15
+ * guardrails: "off" — disable built-in rules entirely
16
16
  * extraRules: [{ pattern, flags?, severity?, reason? }] — append extra rules
17
17
  * autoApprove: ["regex"] — bypass gate for matching commands
18
18
  */
package/src/lib.ts CHANGED
@@ -20,7 +20,8 @@ export interface UserConfig {
20
20
  severity?: Severity;
21
21
  reason?: string;
22
22
  }[];
23
- disableDefaults?: boolean;
23
+ /** Whether Pix's built-in command protections are active. Defaults to "on". */
24
+ guardrails?: "on" | "off";
24
25
  /** Regex strings — commands matching any are passed through without prompting. */
25
26
  autoApprove?: string[];
26
27
  }
@@ -133,7 +134,7 @@ export function loadUserConfig(): UserConfig {
133
134
  // Read from ~/.pi/agent/pix.json gate section
134
135
  const pix = config(gateSection);
135
136
  return {
136
- disableDefaults: pix.disableDefaults || undefined,
137
+ guardrails: pix.guardrails,
137
138
  autoApprove: pix.autoApprove.length > 0 ? pix.autoApprove : undefined,
138
139
  extraRules:
139
140
  pix.extraRules.length > 0
@@ -152,7 +153,7 @@ export function buildRules(cfg: UserConfig): {
152
153
  autoApprove: RegExp[];
153
154
  pathRules: PathRule[];
154
155
  } {
155
- const base = cfg.disableDefaults ? [] : DEFAULT_RULES.slice();
156
+ const base = cfg.guardrails === "off" ? [] : DEFAULT_RULES.slice();
156
157
  const extra = (cfg.extraRules ?? []).map((r) => ({
157
158
  pattern: new RegExp(r.pattern, r.flags ?? "i"),
158
159
  severity: (r.severity ?? "dangerous") as Severity,
@@ -160,7 +161,7 @@ export function buildRules(cfg: UserConfig): {
160
161
  }));
161
162
  const autoApprove = (cfg.autoApprove ?? []).map((s) => new RegExp(s));
162
163
  // ponytail: path rule config extension skipped for now — add extraPathRules/disablePathDefaults to UserConfig when needed
163
- const pathRules = cfg.disableDefaults ? [] : DEFAULT_PATH_RULES.slice();
164
+ const pathRules = cfg.guardrails === "off" ? [] : DEFAULT_PATH_RULES.slice();
164
165
  return { rules: [...base, ...extra], autoApprove, pathRules };
165
166
  }
166
167