@aliou/pi-guardrails 0.7.5 → 0.7.7
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 +13 -3
- package/src/config.ts +2 -1
- package/src/index.ts +7 -0
- package/src/utils/matching.ts +7 -2
- package/src/utils/migration.ts +2 -1
- package/src/utils/warnings.ts +7 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aliou/pi-guardrails",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.7",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -33,22 +33,32 @@
|
|
|
33
33
|
"@aliou/sh": "^0.1.0"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"@mariozechner/pi-coding-agent": ">=0.51.0"
|
|
36
|
+
"@mariozechner/pi-coding-agent": ">=0.51.0",
|
|
37
|
+
"@mariozechner/pi-tui": ">=0.51.0"
|
|
37
38
|
},
|
|
38
39
|
"devDependencies": {
|
|
40
|
+
"@aliou/biome-plugins": "^0.3.2",
|
|
39
41
|
"@biomejs/biome": "^2.3.13",
|
|
40
42
|
"@changesets/cli": "^2.27.11",
|
|
41
43
|
"@mariozechner/pi-coding-agent": "0.52.7",
|
|
42
|
-
"@mariozechner/pi-tui": "0.52.7",
|
|
43
44
|
"@sinclair/typebox": "^0.34.48",
|
|
44
45
|
"@types/node": "^25.0.10",
|
|
45
46
|
"husky": "^9.1.7",
|
|
46
47
|
"typescript": "^5.9.3"
|
|
47
48
|
},
|
|
49
|
+
"peerDependenciesMeta": {
|
|
50
|
+
"@mariozechner/pi-coding-agent": {
|
|
51
|
+
"optional": true
|
|
52
|
+
},
|
|
53
|
+
"@mariozechner/pi-tui": {
|
|
54
|
+
"optional": true
|
|
55
|
+
}
|
|
56
|
+
},
|
|
48
57
|
"scripts": {
|
|
49
58
|
"typecheck": "tsc --noEmit",
|
|
50
59
|
"lint": "biome check",
|
|
51
60
|
"format": "biome check --write",
|
|
61
|
+
"check:lockfile": "pnpm install --frozen-lockfile --ignore-scripts",
|
|
52
62
|
"changeset": "changeset",
|
|
53
63
|
"version": "changeset version",
|
|
54
64
|
"release": "pnpm changeset publish"
|
package/src/config.ts
CHANGED
|
@@ -82,6 +82,7 @@ import {
|
|
|
82
82
|
migrateV0,
|
|
83
83
|
needsMigration,
|
|
84
84
|
} from "./utils/migration";
|
|
85
|
+
import { pendingWarnings } from "./utils/warnings";
|
|
85
86
|
|
|
86
87
|
/**
|
|
87
88
|
* Config fields removed in the toolchain extraction.
|
|
@@ -136,7 +137,7 @@ const migrations: Migration<GuardrailsConfig>[] = [
|
|
|
136
137
|
| string
|
|
137
138
|
| undefined;
|
|
138
139
|
if (!version || version < TOOLCHAIN_MIGRATION_VERSION) {
|
|
139
|
-
|
|
140
|
+
pendingWarnings.push(
|
|
140
141
|
"[guardrails] preventBrew, preventPython, enforcePackageManager, and packageManager " +
|
|
141
142
|
"have been removed from guardrails and moved to @aliou/pi-toolchain. " +
|
|
142
143
|
"These fields will be stripped from your config.",
|
package/src/index.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
|
2
2
|
import { registerGuardrailsSettings } from "./commands/settings-command";
|
|
3
3
|
import { configLoader } from "./config";
|
|
4
4
|
import { setupGuardrailsHooks } from "./hooks";
|
|
5
|
+
import { pendingWarnings } from "./utils/warnings";
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Guardrails Extension
|
|
@@ -27,4 +28,10 @@ export default async function (pi: ExtensionAPI) {
|
|
|
27
28
|
|
|
28
29
|
setupGuardrailsHooks(pi, config);
|
|
29
30
|
registerGuardrailsSettings(pi);
|
|
31
|
+
|
|
32
|
+
pi.on("session_start", (_event, ctx) => {
|
|
33
|
+
for (const warning of pendingWarnings.splice(0)) {
|
|
34
|
+
ctx.ui.notify(warning, "warning");
|
|
35
|
+
}
|
|
36
|
+
});
|
|
30
37
|
}
|
package/src/utils/matching.ts
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import type { PatternConfig } from "../config";
|
|
12
|
+
import { pendingWarnings } from "./warnings";
|
|
12
13
|
|
|
13
14
|
export interface CompiledPattern {
|
|
14
15
|
test: (input: string) => boolean;
|
|
@@ -62,7 +63,9 @@ export function compileFilePattern(config: PatternConfig): CompiledPattern {
|
|
|
62
63
|
const re = new RegExp(config.pattern, "i");
|
|
63
64
|
return { test: (input) => re.test(input), source: config };
|
|
64
65
|
} catch {
|
|
65
|
-
|
|
66
|
+
pendingWarnings.push(
|
|
67
|
+
`Invalid regex in guardrails config: ${config.pattern}`,
|
|
68
|
+
);
|
|
66
69
|
return { test: () => false, source: config };
|
|
67
70
|
}
|
|
68
71
|
}
|
|
@@ -89,7 +92,9 @@ export function compileCommandPattern(config: PatternConfig): CompiledPattern {
|
|
|
89
92
|
const re = new RegExp(config.pattern);
|
|
90
93
|
return { test: (input) => re.test(input), source: config };
|
|
91
94
|
} catch {
|
|
92
|
-
|
|
95
|
+
pendingWarnings.push(
|
|
96
|
+
`Invalid regex in guardrails config: ${config.pattern}`,
|
|
97
|
+
);
|
|
93
98
|
return { test: () => false, source: config };
|
|
94
99
|
}
|
|
95
100
|
}
|
package/src/utils/migration.ts
CHANGED
|
@@ -13,6 +13,7 @@ import type {
|
|
|
13
13
|
GuardrailsConfig,
|
|
14
14
|
PatternConfig,
|
|
15
15
|
} from "../config";
|
|
16
|
+
import { pendingWarnings } from "./warnings";
|
|
16
17
|
|
|
17
18
|
export const CURRENT_VERSION = "0.6.0-20260204";
|
|
18
19
|
|
|
@@ -129,7 +130,7 @@ export async function backupConfig(configPath: string): Promise<void> {
|
|
|
129
130
|
try {
|
|
130
131
|
await copyFile(configPath, backupPath);
|
|
131
132
|
} catch (err) {
|
|
132
|
-
|
|
133
|
+
pendingWarnings.push(`guardrails: could not back up config: ${err}`);
|
|
133
134
|
}
|
|
134
135
|
}
|
|
135
136
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Module-level warnings queue for messages that arise before any session
|
|
3
|
+
* context is available (config loading, migration, pattern compilation).
|
|
4
|
+
*
|
|
5
|
+
* Drained and reported via ctx.ui.notify in the session_start handler.
|
|
6
|
+
*/
|
|
7
|
+
export const pendingWarnings: string[] = [];
|