chore: update flake, agents lib, and clean up tracked dotfiles
Some checks failed
Update Nix Packages with nix-update / nix-update (push) Failing after 3m59s
Some checks failed
Update Nix Packages with nix-update / nix-update (push) Failing after 3m59s
- Remove .pi* and .td-root files from git index (now in .gitignore) - Update flake.lock and flake.nix - Add shells/coding.nix, remove shells/opencode.nix - Update lib/agents.nix, lib/coding-rules.nix - Update modules/home-manager/coding/agents/pi.nix - Update tests for agents and coding-rules - Update .gitignore
This commit is contained in:
@@ -20,7 +20,67 @@ let
|
||||
result = agentsLib.loadCanonical {agentsInput = fakeInput;};
|
||||
in
|
||||
assert result == {test = {description = "test";};}; {result = "pass";};
|
||||
|
||||
# Test 3: renderForPi accepts codingRules parameter without error (null case)
|
||||
# Verifies that passing codingRules = null produces the same result as omitting it.
|
||||
# Uses a minimal fake canonical set instead of a real agents repo.
|
||||
testPiNullCodingRules = let
|
||||
pkgs = import <nixpkgs> {};
|
||||
canonical = {
|
||||
chiron = {
|
||||
mode = "primary";
|
||||
description = "Test primary agent";
|
||||
display_name = "Chiron";
|
||||
systemPrompt = "You are a test agent.";
|
||||
permissions = {};
|
||||
};
|
||||
};
|
||||
result = agentsLib.renderForPi {
|
||||
inherit pkgs canonical;
|
||||
codingRules = null;
|
||||
};
|
||||
agentsMd = builtins.readFile "${result}/AGENTS.md";
|
||||
hasMarkers = builtins.match ".*CODING-RULES:START.*" agentsMd != null;
|
||||
in
|
||||
assert hasMarkers == false; {result = "pass";};
|
||||
|
||||
# Test 4: renderForPi with codingRules includes rules in AGENTS.md
|
||||
# Uses the real AGENTS repo to read rule files (requires --impure or local path)
|
||||
testPiWithCodingRules = let
|
||||
agentsPath = /home/sascha.koenig/p/AI/AGENTS;
|
||||
pkgs = import <nixpkgs> {};
|
||||
canonical = {
|
||||
chiron = {
|
||||
mode = "primary";
|
||||
description = "Test primary agent";
|
||||
display_name = "Chiron";
|
||||
systemPrompt = "You are a test agent.";
|
||||
permissions = {};
|
||||
};
|
||||
};
|
||||
result = agentsLib.renderForPi {
|
||||
inherit pkgs canonical;
|
||||
codingRules = {
|
||||
agents = agentsPath;
|
||||
concerns = ["coding-style"];
|
||||
languages = [];
|
||||
frameworks = [];
|
||||
};
|
||||
};
|
||||
agentsMd = builtins.readFile "${result}/AGENTS.md";
|
||||
hasStartMarker = builtins.match ".*CODING-RULES:START.*" agentsMd != null;
|
||||
hasEndMarker = builtins.match ".*CODING-RULES:END.*" agentsMd != null;
|
||||
hasCodingStyle = builtins.match ".*Coding Style.*" agentsMd != null;
|
||||
# Also verify agent descriptions are still present
|
||||
hasAgentInstructions = builtins.match ".*Agent Instructions.*" agentsMd != null;
|
||||
in
|
||||
assert hasStartMarker == true;
|
||||
assert hasEndMarker == true;
|
||||
assert hasCodingStyle == true;
|
||||
assert hasAgentInstructions == true; {result = "pass";};
|
||||
in {
|
||||
unknown-tool-throws = testUnknownTool;
|
||||
load-canonical = testLoadCanonical;
|
||||
pi-null-coding-rules = testPiNullCodingRules;
|
||||
pi-with-coding-rules = testPiWithCodingRules;
|
||||
}
|
||||
|
||||
@@ -37,8 +37,74 @@ let
|
||||
in
|
||||
assert hasSymlink;
|
||||
assert hasConfigGen; {result = "pass";};
|
||||
|
||||
# Test 4: forPi=false does not include AGENTS.md logic in shellHook
|
||||
testForPiDisabled = let
|
||||
rules = codingRulesLib.mkCodingRules {
|
||||
agents = "/tmp/fake-agents";
|
||||
forPi = false;
|
||||
};
|
||||
hook = rules.shellHook;
|
||||
hasPiBlock = builtins.match ".*CODING-RULES:START.*" hook != null;
|
||||
in
|
||||
assert hasPiBlock == false; {result = "pass";};
|
||||
|
||||
# Test 5: forPi=true adds CODING-RULES markers to shellHook (when agents path has rules)
|
||||
# Note: This test uses the real AGENTS repo at /home/sascha.koenig/p/AI/AGENTS
|
||||
# It is only run when the path exists.
|
||||
testForPiEnabled = let
|
||||
agentsPath = /home/sascha.koenig/p/AI/AGENTS;
|
||||
rules = codingRulesLib.mkCodingRules {
|
||||
agents = agentsPath;
|
||||
forPi = true;
|
||||
concerns = ["coding-style"];
|
||||
languages = [];
|
||||
frameworks = [];
|
||||
};
|
||||
hook = rules.shellHook;
|
||||
hasPiBlock = builtins.match ".*CODING-RULES:START.*" hook != null;
|
||||
hasCodingStyle = builtins.match ".*Coding Style.*" hook != null;
|
||||
in
|
||||
assert hasPiBlock == true;
|
||||
assert hasCodingStyle == true; {result = "pass";};
|
||||
|
||||
# Test 6: concatRulesMd produces concatenated markdown (with real agents path)
|
||||
testConcatRulesMd = let
|
||||
agentsPath = /home/sascha.koenig/p/AI/AGENTS;
|
||||
md = codingRulesLib.concatRulesMd {
|
||||
agents = agentsPath;
|
||||
concerns = ["coding-style"];
|
||||
languages = [];
|
||||
frameworks = [];
|
||||
};
|
||||
hasHeader = builtins.match ".*Coding Style.*" md != null;
|
||||
hasCritical = builtins.match ".*Critical Rules.*" md != null;
|
||||
in
|
||||
assert hasHeader == true;
|
||||
assert hasCritical == true; {result = "pass";};
|
||||
|
||||
# Test 7: mkRulesMdSection wraps content with markers
|
||||
testRulesMdSection = let
|
||||
agentsPath = /home/sascha.koenig/p/AI/AGENTS;
|
||||
section = codingRulesLib.mkRulesMdSection {
|
||||
agents = agentsPath;
|
||||
concerns = ["coding-style"];
|
||||
languages = [];
|
||||
frameworks = [];
|
||||
};
|
||||
hasStartMarker = builtins.match ".*CODING-RULES:START.*" section != null;
|
||||
hasEndMarker = builtins.match ".*CODING-RULES:END.*" section != null;
|
||||
hasHeader = builtins.match ".*# Coding Rules.*" section != null;
|
||||
in
|
||||
assert hasStartMarker == true;
|
||||
assert hasEndMarker == true;
|
||||
assert hasHeader == true; {result = "pass";};
|
||||
in {
|
||||
instructions-correct = testInstructions;
|
||||
default-rules-dir = testDefaultRulesDir;
|
||||
shell-hook = testShellHook;
|
||||
forpi-disabled = testForPiDisabled;
|
||||
forpi-enabled = testForPiEnabled;
|
||||
concat-rules-md = testConcatRulesMd;
|
||||
rules-md-section = testRulesMdSection;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user