codex: support store-path skill sources
Handle per-skill values that come through as store-path strings, such as fetcher outputs with subdirectories appended. This restores the previously working pattern for packaged skill directories and adds a regression test for both directory and file sources. Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
This commit is contained in:
parent
5068d0b03e
commit
b8cb89f2c4
3 changed files with 41 additions and 2 deletions
|
|
@ -150,9 +150,13 @@ in
|
|||
# TODO: Remove this workaround once Codex supports symlinked SKILL.md
|
||||
# files again. Upstream only supports symlinking the containing skill
|
||||
# directory today: https://github.com/openai/codex/issues/10470
|
||||
isStorePathString = content: builtins.isString content && lib.hasPrefix builtins.storeDir content;
|
||||
isPathLikeContent = content: lib.isPath content || isStorePathString content;
|
||||
mkSkillDir =
|
||||
content:
|
||||
pkgs.writeTextDir "SKILL.md" (if lib.isPath content then builtins.readFile content else content);
|
||||
pkgs.writeTextDir "SKILL.md" (
|
||||
if isPathLikeContent content then builtins.readFile content else content
|
||||
);
|
||||
skillSources =
|
||||
if builtins.isAttrs cfg.skills then
|
||||
cfg.skills
|
||||
|
|
@ -162,7 +166,7 @@ in
|
|||
{ };
|
||||
mkSkillEntry =
|
||||
name: content:
|
||||
if lib.isPath content && lib.pathIsDirectory content then
|
||||
if isPathLikeContent content && lib.pathIsDirectory content then
|
||||
lib.nameValuePair "${skillsDir}/${name}" {
|
||||
source = content;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,5 +9,6 @@
|
|||
codex-skills-inline-null-package = ./skills-inline-null-package.nix;
|
||||
codex-skills-inline-legacy-path = ./skills-inline-legacy-path.nix;
|
||||
codex-skills-dir = ./skills-dir.nix;
|
||||
codex-skills-store-path = ./skills-store-path.nix;
|
||||
codex-skills-path-not-directory = ./skills-path-not-directory.nix;
|
||||
}
|
||||
|
|
|
|||
34
tests/modules/programs/codex/skills-store-path.nix
Normal file
34
tests/modules/programs/codex/skills-store-path.nix
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
{ pkgs, ... }:
|
||||
let
|
||||
src = pkgs.writeTextDir "skills/external-skill/SKILL.md" ''
|
||||
---
|
||||
name: external-skill
|
||||
description: Store path skill fixture.
|
||||
---
|
||||
|
||||
# External Skill
|
||||
|
||||
This content simulates a skill living inside a package source.
|
||||
'';
|
||||
in
|
||||
{
|
||||
programs.codex = {
|
||||
enable = true;
|
||||
skills = {
|
||||
dir-skill = "${src}/skills/external-skill";
|
||||
file-skill = "${src}/skills/external-skill/SKILL.md";
|
||||
};
|
||||
};
|
||||
|
||||
nmt.script = ''
|
||||
assertLinkExists home-files/.agents/skills/dir-skill
|
||||
assertFileExists home-files/.agents/skills/dir-skill/SKILL.md
|
||||
assertFileContent home-files/.agents/skills/dir-skill/SKILL.md \
|
||||
"${src}/skills/external-skill/SKILL.md"
|
||||
|
||||
assertLinkExists home-files/.agents/skills/file-skill
|
||||
assertFileExists home-files/.agents/skills/file-skill/SKILL.md
|
||||
assertFileContent home-files/.agents/skills/file-skill/SKILL.md \
|
||||
"${src}/skills/external-skill/SKILL.md"
|
||||
'';
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue