Compare commits
6 Commits
f7f0c4072e
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9b423315b3 | ||
|
|
14d906ef93 | ||
|
|
e7393d6fa4 | ||
| 1da8c96447 | |||
| 6a8cb62903 | |||
| a3e247e5af |
12
flake.lock
generated
12
flake.lock
generated
@@ -55,11 +55,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs-master": {
|
"nixpkgs-master": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1777470666,
|
"lastModified": 1777598070,
|
||||||
"narHash": "sha256-uAi+pTjKLturTz3XqTwnsU0fJnqf8xx8orfPpRbdaKQ=",
|
"narHash": "sha256-XhR4i1U3Sk5s55IeSmep+RuR5OonlUqwbP0xJMrQqhQ=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "053b9fa5f0fbdac0bd9d248cea58a11223eb495d",
|
"rev": "fada675d5d2b7fcec9c7fbced7c912325f511dee",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -76,11 +76,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1776788052,
|
"lastModified": 1777556999,
|
||||||
"narHash": "sha256-L4LBHVVtgMhSJm+IzZSYOR0UXPbvIRg4xiEV5urYxdI=",
|
"narHash": "sha256-HfFlRwR8IMjudRttN4T8L3DJKnNlpWfeNzQPly/HaRY=",
|
||||||
"owner": "Fission-AI",
|
"owner": "Fission-AI",
|
||||||
"repo": "OpenSpec",
|
"repo": "OpenSpec",
|
||||||
"rev": "3c7a05c5dc88b2397c478805890b55ed392b19e8",
|
"rev": "347f0277e3be3549cd85cdea364fbd7710f1922b",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|||||||
@@ -202,6 +202,38 @@
|
|||||||
See pi docs/settings.md for all options.
|
See pi docs/settings.md for all options.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# ── Pi Guardrails ─────────────────────────────────────────────
|
||||||
|
guardrails = mkOption {
|
||||||
|
type = types.nullOr (types.submodule {
|
||||||
|
options = {
|
||||||
|
enable =
|
||||||
|
mkEnableOption
|
||||||
|
("Generate ~/.pi/agent/extensions/guardrails.json for pi-guardrails. "
|
||||||
|
+ "Adds @aliou/pi-guardrails to packages automatically.");
|
||||||
|
|
||||||
|
config = mkOption {
|
||||||
|
type = types.attrsOf types.anything;
|
||||||
|
default = {};
|
||||||
|
description = ''
|
||||||
|
Guardrails configuration written to ~/.pi/agent/extensions/guardrails.json.
|
||||||
|
See https://github.com/aliou/pi-guardrails for config schema.
|
||||||
|
|
||||||
|
IMPORTANT: Path access checks are lexical (not symlink-safe).
|
||||||
|
Local project .pi/extensions/guardrails.json can override same rule IDs
|
||||||
|
(memory > local > global > defaults). For immutable global policies,
|
||||||
|
consider a wrapper or upstream patch.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
});
|
||||||
|
default = null;
|
||||||
|
description = ''
|
||||||
|
Pi Guardrails security configuration.
|
||||||
|
Generates ~/.pi/agent/extensions/guardrails.json when enabled.
|
||||||
|
The @aliou/pi-guardrails package is added to settings.packages automatically.
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = with lib; let
|
config = with lib; let
|
||||||
@@ -224,8 +256,37 @@
|
|||||||
attrs
|
attrs
|
||||||
);
|
);
|
||||||
|
|
||||||
|
# Base settings (already filtered)
|
||||||
piSettings = filterNulls cfg.settings;
|
piSettings = filterNulls cfg.settings;
|
||||||
|
|
||||||
|
# Guardrails package to inject when guardrails is enabled
|
||||||
|
guardrailsPackage = "npm:@aliou/pi-guardrails@0.11.1";
|
||||||
|
|
||||||
|
# Guardrails config (only when guardrails is enabled)
|
||||||
|
guardrailsJson =
|
||||||
|
if (cfg.guardrails != null && cfg.guardrails.enable)
|
||||||
|
then builtins.toJSON cfg.guardrails.config
|
||||||
|
else null;
|
||||||
|
|
||||||
|
# Merge guardrails package into settings.packages when guardrails is enabled
|
||||||
|
piSettingsWithGuardrails = let
|
||||||
|
baseSettings = cfg.settings;
|
||||||
|
basePackages = baseSettings.packages or [];
|
||||||
|
hasGuardrailsPackage =
|
||||||
|
lib.any
|
||||||
|
(p:
|
||||||
|
lib.hasPrefix "npm:@aliou/pi-guardrails" p
|
||||||
|
|| (lib.hasPrefix "git:" p && lib.hasSuffix "/pi-guardrails" p))
|
||||||
|
basePackages;
|
||||||
|
packagesWithGuardrails =
|
||||||
|
if (cfg.guardrails != null && cfg.guardrails.enable && !hasGuardrailsPackage)
|
||||||
|
then basePackages ++ [guardrailsPackage]
|
||||||
|
else basePackages;
|
||||||
|
in
|
||||||
|
if packagesWithGuardrails != basePackages
|
||||||
|
then filterNulls (baseSettings // {packages = packagesWithGuardrails;})
|
||||||
|
else piSettings;
|
||||||
|
|
||||||
# Coding rules config for renderForPi (only when both agentsInput and codingRules are set)
|
# Coding rules config for renderForPi (only when both agentsInput and codingRules are set)
|
||||||
piCodingRules =
|
piCodingRules =
|
||||||
if cfg.agentsInput != null && cfg.codingRules != null
|
if cfg.agentsInput != null && cfg.codingRules != null
|
||||||
@@ -269,10 +330,16 @@
|
|||||||
|
|
||||||
# ── ~/.pi/agent/settings.json ──────────────────────────────────
|
# ── ~/.pi/agent/settings.json ──────────────────────────────────
|
||||||
{
|
{
|
||||||
".pi/agent/settings.json".text = builtins.toJSON piSettings;
|
".pi/agent/settings.json".text = builtins.toJSON piSettingsWithGuardrails;
|
||||||
".pi/agent/settings.json".force = true;
|
".pi/agent/settings.json".force = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# ── pi-guardrails config ─────────────────────────────────────
|
||||||
|
(mkIf (guardrailsJson != null) {
|
||||||
|
".pi/agent/extensions/guardrails.json".text = guardrailsJson;
|
||||||
|
".pi/agent/extensions/guardrails.json".force = true;
|
||||||
|
})
|
||||||
|
|
||||||
# ── AGENTS.md — agent descriptions and specialist listing ──────
|
# ── AGENTS.md — agent descriptions and specialist listing ──────
|
||||||
(mkIf (cfg.agentsInput != null) {
|
(mkIf (cfg.agentsInput != null) {
|
||||||
".pi/agent/AGENTS.md".source = "${rendered}/AGENTS.md";
|
".pi/agent/AGENTS.md".source = "${rendered}/AGENTS.md";
|
||||||
|
|||||||
Reference in New Issue
Block a user