Add skill command env patching
This commit was merged in pull request #21.
This commit is contained in:
@@ -11,6 +11,30 @@ let
|
||||
discovered = discoverSkills ./fixtures/valid;
|
||||
built = map (skill: mkSkill { inherit pkgs; inherit (skill) name src; }) discovered;
|
||||
|
||||
commandSrc = pkgs.runCommandLocal "command-skill-src" { } ''
|
||||
mkdir -p "$out"
|
||||
printf '%s\n' '---' 'name: command-skill' 'description: Fixture skill with a command.' '---' \
|
||||
> "$out/SKILL.md"
|
||||
cat > "$out/run-command" <<'EOF'
|
||||
#!/usr/bin/env sh
|
||||
: "''${TOOL:=tool}" # mkSkill:TOOL
|
||||
exec "$TOOL" "$@"
|
||||
EOF
|
||||
chmod +x "$out/run-command"
|
||||
'';
|
||||
|
||||
commandSkill = mkSkill {
|
||||
inherit pkgs;
|
||||
name = "command-skill";
|
||||
src = commandSrc;
|
||||
commands = [
|
||||
{
|
||||
path = "run-command";
|
||||
env.TOOL = "${pkgs.coreutils}/bin/printf";
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
collision = builtins.tryEval (discoverSkills ./fixtures/collision);
|
||||
|
||||
discoveredNames = lib.sort (a: b: a < b) (map (skill: skill.name) discovered);
|
||||
@@ -24,6 +48,7 @@ pkgs.runCommandLocal "skill-build-check"
|
||||
pairs = lib.concatStringsSep " " (map (skill: "${skill.skillName}=${skill}") built);
|
||||
collisionSucceeded = if collision.success then "yes" else "no";
|
||||
expectedNames = lib.concatStringsSep " " discoveredNames;
|
||||
inherit commandSkill;
|
||||
}
|
||||
''
|
||||
fail() { echo "FAIL: $1" >&2; exit 1; }
|
||||
@@ -52,5 +77,11 @@ pkgs.runCommandLocal "skill-build-check"
|
||||
test -f "$beta_path/tools/SKILL.md" \
|
||||
|| fail "beta's asset subfolder did not ride along into \$out"
|
||||
|
||||
echo "command tier: declared command env defaults are patched"
|
||||
test -x "$commandSkill/run-command" \
|
||||
|| fail "declared command is not executable"
|
||||
grep -qx ': "''${TOOL:=${pkgs.coreutils}/bin/printf}" # mkSkill:TOOL' "$commandSkill/run-command" \
|
||||
|| fail "declared command env default was not patched"
|
||||
|
||||
touch "$out"
|
||||
''
|
||||
|
||||
Reference in New Issue
Block a user