@aliou/pi-guardrails 0.13.2 → 0.13.3
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.
|
@@ -198,8 +198,14 @@ export const COMMAND_EXAMPLES: Array<{
|
|
|
198
198
|
},
|
|
199
199
|
{
|
|
200
200
|
label: "git push --force",
|
|
201
|
-
description:
|
|
202
|
-
|
|
201
|
+
description:
|
|
202
|
+
"Prompts before force-pushing Git history. Uses regex so the flag is caught regardless of its position in the command (e.g. `git push origin main --force` or `-f` at the end).",
|
|
203
|
+
pattern: {
|
|
204
|
+
pattern: "git push .*(-f\\b|--force(?!-with-lease)|--force-with-lease)",
|
|
205
|
+
regex: true,
|
|
206
|
+
description:
|
|
207
|
+
"Git force push (any variant: --force, --force-with-lease, -f)",
|
|
208
|
+
},
|
|
203
209
|
},
|
|
204
210
|
{
|
|
205
211
|
label: "npm publish",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aliou/pi-guardrails",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -56,14 +56,6 @@
|
|
|
56
56
|
"typescript": "^5.9.3",
|
|
57
57
|
"vitest": "^4.1.4"
|
|
58
58
|
},
|
|
59
|
-
"peerDependenciesMeta": {
|
|
60
|
-
"@earendil-works/pi-coding-agent": {
|
|
61
|
-
"optional": true
|
|
62
|
-
},
|
|
63
|
-
"@earendil-works/pi-tui": {
|
|
64
|
-
"optional": true
|
|
65
|
-
}
|
|
66
|
-
},
|
|
67
59
|
"scripts": {
|
|
68
60
|
"typecheck": "tsc --noEmit",
|
|
69
61
|
"gen:schema": "ts-json-schema-generator --path src/shared/config/types.ts --type GuardrailsConfig --no-type-check -o schema.json",
|
|
@@ -73,8 +65,18 @@
|
|
|
73
65
|
"lint": "biome check",
|
|
74
66
|
"format": "biome check --write",
|
|
75
67
|
"check:lockfile": "pnpm install --frozen-lockfile --ignore-scripts",
|
|
68
|
+
"prepare": "[ -d .git ] && husky || true",
|
|
76
69
|
"changeset": "changeset",
|
|
77
70
|
"version": "changeset version",
|
|
78
71
|
"release": "pnpm changeset publish"
|
|
72
|
+
},
|
|
73
|
+
"packageManager": "pnpm@10.26.1",
|
|
74
|
+
"peerDependenciesMeta": {
|
|
75
|
+
"@earendil-works/pi-coding-agent": {
|
|
76
|
+
"optional": true
|
|
77
|
+
},
|
|
78
|
+
"@earendil-works/pi-tui": {
|
|
79
|
+
"optional": true
|
|
80
|
+
}
|
|
79
81
|
}
|
|
80
|
-
}
|
|
82
|
+
}
|
|
@@ -1,13 +1,31 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
buildSchemaUrl,
|
|
3
|
+
ConfigLoader,
|
|
4
|
+
type Scope,
|
|
5
|
+
} from "@aliou/pi-utils-settings";
|
|
2
6
|
import pkg from "../../../package.json" with { type: "json" };
|
|
3
7
|
import { DEFAULT_CONFIG } from "./defaults";
|
|
4
8
|
import { migrations } from "./migration";
|
|
5
9
|
import type { GuardrailsConfig, PolicyRule, ResolvedConfig } from "./types";
|
|
6
10
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
class GuardrailsConfigLoader extends ConfigLoader<
|
|
12
|
+
GuardrailsConfig,
|
|
13
|
+
ResolvedConfig
|
|
14
|
+
> {
|
|
15
|
+
override async save(scope: Scope, config: GuardrailsConfig): Promise<void> {
|
|
16
|
+
await super.save(scope, ensureConfigVersion(config));
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function ensureConfigVersion(config: GuardrailsConfig): GuardrailsConfig {
|
|
21
|
+
if (typeof config.version === "string" && config.version.trim()) {
|
|
22
|
+
return config;
|
|
23
|
+
}
|
|
24
|
+
return { ...config, version: DEFAULT_CONFIG.version };
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function createGuardrailsConfigLoader(): GuardrailsConfigLoader {
|
|
28
|
+
return new GuardrailsConfigLoader("guardrails", DEFAULT_CONFIG, {
|
|
11
29
|
scopes: ["global", "local", "memory"],
|
|
12
30
|
migrations,
|
|
13
31
|
schemaUrl: buildSchemaUrl(pkg.name, pkg.version),
|
|
@@ -60,5 +78,7 @@ export const configLoader = new ConfigLoader<GuardrailsConfig, ResolvedConfig>(
|
|
|
60
78
|
|
|
61
79
|
return resolved;
|
|
62
80
|
},
|
|
63
|
-
}
|
|
64
|
-
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export const configLoader = createGuardrailsConfigLoader();
|