codex: unify skills option and tests

This commit is contained in:
Hauke Schnau 2026-01-13 10:18:07 +01:00 committed by Austin Horstman
parent 34a9ab0fae
commit f1b5f20210
7 changed files with 57 additions and 44 deletions

View file

@ -8,5 +8,5 @@
codex-empty-custom-instructions = ./empty-custom-instructions.nix;
codex-skills-inline = ./skills-inline.nix;
codex-skills-dir = ./skills-dir.nix;
codex-skills-conflict = ./skills-conflict.nix;
codex-skills-path-not-directory = ./skills-path-not-directory.nix;
}

View file

@ -0,0 +1,8 @@
---
name: file-skill
description: File skill for tests.
---
# File Skill
Test fixture content.

View file

@ -1,13 +0,0 @@
{
programs.codex = {
enable = true;
skills = {
inline-skill = "Test";
};
skillsDir = ./skills-dir;
};
test.asserts.assertions.expected = [
"Cannot specify both `programs.codex.skills` and `programs.codex.skillsDir`"
];
}

View file

@ -1,11 +1,12 @@
{
programs.codex = {
enable = true;
skillsDir = ./skills-dir;
skills = ./skills-dir;
};
nmt.script = ''
assertFileExists home-files/.codex/skills/skill-one/SKILL.md
assertFileRegex home-files/.codex/skills/skill-one/SKILL.md "Skill One"
assertFileContent home-files/.codex/skills/skill-one/SKILL.md \
${./skills-dir/skill-one/SKILL.md}
'';
}

View file

@ -1,22 +1,30 @@
let
inlineSkill = ''
---
name: inline-skill
description: Inline skill for tests.
---
# Inline Skill
Test fixture content.
'';
in
{
programs.codex = {
enable = true;
skills = {
inline-skill = ''
---
name: inline-skill
description: Inline skill for tests.
---
# Inline Skill
Test fixture content.
'';
inline-skill = inlineSkill;
file-skill = ./skill-file.md;
};
};
nmt.script = ''
assertFileExists home-files/.codex/skills/inline-skill/SKILL.md
assertFileRegex home-files/.codex/skills/inline-skill/SKILL.md "Inline Skill"
assertFileContent home-files/.codex/skills/inline-skill/SKILL.md \
${builtins.toFile "expected-inline-skill.md" inlineSkill}
assertFileExists home-files/.codex/skills/file-skill/SKILL.md
assertFileContent home-files/.codex/skills/file-skill/SKILL.md \
${./skill-file.md}
'';
}

View file

@ -0,0 +1,10 @@
{
programs.codex = {
enable = true;
skills = ./skill-file.md;
};
test.asserts.assertions.expected = [
"`programs.codex.skills` must be a directory when set to a path"
];
}