diff --git a/modules/home/programs/terminal/pi/config/skills/create-skill/SKILL.md b/modules/home/programs/terminal/pi/config/skills/create-skill/SKILL.md index 4fbc288..7c7770a 100644 --- a/modules/home/programs/terminal/pi/config/skills/create-skill/SKILL.md +++ b/modules/home/programs/terminal/pi/config/skills/create-skill/SKILL.md @@ -45,6 +45,7 @@ description: "//` directory (e.g. `mappings/`, `references/`) with one sub-doc per category and an index `README.md`. Keep `SKILL.md` focused on the hot path — workflow, hard rules, and a short table pointing at the sub-docs. Include a brief style guide in the index README covering (a) defer to authoritative sources (stubs, schemas, generated docs) whenever possible, (b) row/entry formatting conventions, (c) when to create a new sub-doc vs. extend an existing one. diff --git a/modules/home/programs/terminal/pi/config/skills/create-skill/assets/variable.sh b/modules/home/programs/terminal/pi/config/skills/create-skill/assets/variable.sh new file mode 100755 index 0000000..af8fda8 --- /dev/null +++ b/modules/home/programs/terminal/pi/config/skills/create-skill/assets/variable.sh @@ -0,0 +1,86 @@ +#!/usr/bin/env bash +# Skill-local variable store. Values live in /.vars/. +# +# Usage: +# variable.sh --get NAME [--require-exec RELPATH] +# Prints value to stdout, exits 0. +# --require-exec asserts that VALUE/RELPATH +# exists and is executable; if not, prints +# the fix instructions to stderr and exits 2. +# variable.sh --set NAME VALUE Writes value, exits 0. +# +# Callers should treat any non-zero exit as fatal; the stderr message tells +# the caller (agent or user) exactly how to populate or correct the value. + +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +SKILL_DIR="$(dirname "$SCRIPT_DIR")" +STORE="$SKILL_DIR/.vars" +SELF="$0" + +usage() { + cat >&2 <&2 < +EOF + exit 2 + fi + val="$(cat "$file")" + if [[ -n "$require_exec" && ! -x "$val/$require_exec" ]]; then + cat >&2 < +EOF + exit 2 + fi + printf '%s' "$val" + ;; + set) + [[ -n "$value" ]] || usage + [[ "$name" =~ ^[A-Z][A-Z0-9_]*$ ]] || { + echo >&2 "$SELF: invalid name '$name' (must match [A-Z][A-Z0-9_]*)" + exit 2 + } + mkdir -p "$STORE" + # Self-ignore the store so values never get committed, even if the + # skill root lacks a .gitignore entry for .vars/. + [[ -f "$STORE/.gitignore" ]] || printf '*\n' > "$STORE/.gitignore" + printf '%s' "$value" > "$STORE/$name" + ;; +esac