From 285fe994613f0dfc2d1865e6fd12f01e97513395 Mon Sep 17 00:00:00 2001 From: Evan Reichard Date: Thu, 28 May 2026 17:16:42 -0400 Subject: [PATCH] feat: create skill variable helper --- .../pi/config/skills/create-skill/SKILL.md | 1 + .../skills/create-skill/assets/variable.sh | 60 +++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100755 modules/home/programs/terminal/pi/config/skills/create-skill/assets/variable.sh 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..0a81757 --- /dev/null +++ b/modules/home/programs/terminal/pi/config/skills/create-skill/assets/variable.sh @@ -0,0 +1,60 @@ +#!/usr/bin/env bash +# Skill-local variable store. Values live in /.vars/. +# +# Usage: +# variable.sh --get NAME # prints value to stdout, exits 0 +# # or prints a self-explaining hint to +# # stderr and exits 2 if unset. +# variable.sh --set NAME VALUE # writes value, exits 0. +# +# Callers should treat a non-zero exit as fatal; the stderr message tells +# the caller (agent or user) exactly how to populate the missing 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 + cat "$file" + ;; + --set) + [[ $# -eq 3 ]] || usage + name="$2"; value="$3" + [[ "$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" + ;; + *) + usage + ;; +esac