Artifact fb17260e4bc3a235f99f84cdbc9e69bb5c45045c54f94b5b2eb80bd9c48f927e:
- File
test/pic/skills.sh
— part of check-in
[376fd483ed]
at
2026-11-20 00:29:28
on branch cache
— Prompt caching on every provider, as Pi's
Anthropic: cache_control on the system block, the last tool and the last block of the final user message; 5 minutes by default, ttl 1h with cacheRetention=long, none with cacheRetention=none (setting in pic.sqlite, PI_CACHE_RETENTION as fallback). Anthropic models through OpenRouter get the same markers. OpenAI Responses and Chat Completions send prompt_cache_key (the conversation id) and 24h retention when long, as Pi does. The system prompt and tools stay byte-identical across turns, and 1-hour cache writes are kept in the stored usage. (user: dmestas, size: 4565) [annotate] [blame] [check-ins using] [more...]
#!/bin/sh # Skills through the command line: skill folders symlinked into ~/.pic/skills # are listed in the system prompt the server receives, the workspace's only # once it is trusted, /skill:name expands in pic ask and pic chat, a skill # that vanished (a dangling symlink) is not listed, and pic skills lists them. set -eu PIC=${PIC:?set PIC to the pic binary} SERVER=${SERVER:?set SERVER to the fake_server binary} S=$(cd "$(dirname "$0")/streams" && pwd) T=$(mktemp -d "${TMPDIR:-/tmp}/pic-skills.XXXXXX") spid= cleanup() { [ -n "$spid" ] && kill "$spid" 2>/dev/null; rm -rf -- "$T"; } trap cleanup EXIT HUP INT TERM fail() { printf 'FAIL: %s\n' "$*" >&2; exit 1; } export HOME="$T/home" ANTHROPIC_API_KEY=pic-skills-test-key PIC_PI_EXPORT=0 PIC_MODEL_CATALOG=offline mkdir -p "$T/ws/.pic/skills" "$T/log" "$HOME/.pic/skills" "$T/store/alpha" "$T/store/beta" "$T/store/proj" # Exact request shapes below: prompt caching (provider.sh) is off here. "$PIC" settings cacheRetention none > /dev/null "$SERVER" "$T/port" "$T/log" 120 "sse:$S/text.sse" "sse:$S/text.sse" "sse:$S/text.sse" "sse:$S/text.sse" \ "sse:$S/text.sse" "sse:$S/text.sse" "sse:$S/text.sse" & spid=$! i=0 while [ ! -s "$T/port" ]; do i=$((i + 1)); [ "$i" -lt 100 ] || fail "server"; sleep 0.05; done printf '{"providers":{"fake":{"baseUrl":"http://127.0.0.1:%s","api":"anthropic-messages","apiKey":"$ANTHROPIC_API_KEY","models":[{"id":"m"}]}}}' \ "$(cat "$T/port")" > "$T/models.json" export PIC_MODELS_FILE="$T/models.json" pic() { "$PIC" --db "$T/j" --workspace "$T/ws" --model fake/m "$@"; } has() { grep -qF -- "$2" "$T/log/$1.req" || fail "request $1 lacks: $2 ($(cut -c1-300 "$T/log/$1.req"))"; } lacks() { ! grep -qF -- "$2" "$T/log/$1.req" || fail "request $1 has: $2"; } printf -- '---\nname: alpha\ndescription: Alpha does <things> & more\n---\n\n# Alpha\nDo alpha steps.\n' > "$T/store/alpha/SKILL.md" printf -- '---\ndescription: Beta is command only\ndisable-model-invocation: true\n---\nBeta steps\n' > "$T/store/beta/SKILL.md" printf -- '---\ndescription: Project skill\n---\nProject steps\n' > "$T/store/proj/SKILL.md" ln -s "$T/store/alpha" "$HOME/.pic/skills/alpha" ln -s "$T/store/beta" "$HOME/.pic/skills/beta" ln -s "$T/store/proj" "$T/ws/.pic/skills/proj" pic ask 'hello' > /dev/null 2>&1 || fail "ask hello" has 1 'The following skills provide specialized instructions for specific tasks.\nUse the read tool to load' has 1 '<available_skills>\n <skill>\n <name>alpha</name>\n <description>Alpha does <things> & more</description>\n <location>' has 1 "$HOME/.pic/skills/alpha/SKILL.md</location>" lacks 1 '<name>beta</name>' lacks 1 '<name>proj</name>' printf 'PASS: symlinked user skills are listed in the system prompt, a hidden one is not\n' pic ask 'hello again' > /dev/null 2>&1 || fail "ask untrusted" lacks 2 '<name>proj</name>' pic trust yes > /dev/null pic ask 'hello once more' > /dev/null 2>&1 || fail "ask trusted" has 3 '<name>proj</name>' printf 'PASS: a project skill is listed only once the workspace is trusted\n' pic ask '/skill:alpha fix the bug' > /dev/null 2>&1 || fail "ask skill" has 4 "<skill name=\\\"alpha\\\" location=\\\"$HOME/.pic/skills/alpha/SKILL.md\\\">\\nReferences are relative to $HOME/.pic/skills/alpha.\\n\\n# Alpha\\nDo alpha steps.\\n</skill>\\n\\nfix the bug" lacks 4 'description: Alpha' printf 'PASS: /skill:name expands in pic ask, frontmatter stripped, arguments after\n' printf '/skill:beta\n' | pic chat > "$T/chat.out" 2>&1 || fail "chat: $(cat "$T/chat.out")" has 5 '<skill name=\"beta\"' has 5 'Beta steps\n</skill>' printf 'PASS: pic chat expands a hidden skill\n' pic skills > "$T/list" 2>&1 || fail "skills" [ "$(wc -l < "$T/list" | tr -d ' ')" = 3 ] || fail "skills list: $(cat "$T/list")" grep -q "^alpha user Alpha does <things> & more $HOME/.pic/skills/alpha/SKILL.md\$" "$T/list" || fail "skills row: $(cat "$T/list")" grep -q '^proj project Project skill ' "$T/list" || fail "skills project row" pic skills --json | grep -q '"name":"beta","scope":"user","description":"Beta is command only","path":".*","disableModelInvocation":true' \ || fail "skills --json" printf 'PASS: pic skills lists name, scope, description, path\n' rm -rf "$T/store/alpha" pic skills > "$T/list" 2>&1 || fail "skills after vanish" ! grep -q '^alpha' "$T/list" || fail "a vanished skill is listed" pic ask '/skill:alpha later' > /dev/null 2>&1 || fail "ask vanished" has 6 '/skill:alpha later' lacks 6 '<name>alpha</name>' printf 'PASS: a vanished skill is skipped, and its command passes through\n'