@sassywares/skills 0.17.1 → 0.17.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,128 @@
1
+ # generated_by: sassy-setup@0.17.2
2
+ # lib/common.sh — topology and config helpers, the suite roster predicate, and
3
+ # the functions that resolve the paths the proposal and the check read.
4
+ # Sourced by detect.sh. Never sets shell options; ROOT, CONFIG, and START are
5
+ # the entry point's to set, and this file only reads them.
6
+
7
+ is_suite_skill() {
8
+ if [[ -n "$SUITE_ROSTER" ]]; then
9
+ case ",$SUITE_ROSTER," in *",$1,"*) return 0 ;; *) return 1 ;; esac
10
+ fi
11
+ [[ "$1" == sassy-* ]]
12
+ }
13
+
14
+ config_value() {
15
+ local key="$1" file="${2:-$CONFIG}"
16
+ [[ -f "$file" ]] || return 1
17
+ sed -n "s/^[[:space:]]*${key}:[[:space:]]*//p" "$file" \
18
+ | head -n 1 \
19
+ | sed -E 's/[[:space:]]+#.*$//; s/^["'\'']//; s/["'\'']$//' \
20
+ | grep -v '^$' || return 1
21
+ }
22
+
23
+ block_value() { # $1 block name, $2 key — value only, comments stripped
24
+ sed -n "/^$1:/,/^[a-z]/p" "$CONFIG" \
25
+ | sed -n "s/^[[:space:]]\{1,\}$2:[[:space:]]*//p" \
26
+ | head -n 1 \
27
+ | sed -E 's/[[:space:]]+#.*$//; s/[[:space:]]+$//'
28
+ }
29
+
30
+ hook_skill_path() { # $1 hook skill name — nearest .agents/skills/<name>/SKILL.md
31
+ local name="$1" dir="$ROOT"
32
+ while :; do
33
+ if [[ -f "$dir/.agents/skills/$name/SKILL.md" ]]; then
34
+ printf '%s' "$dir/.agents/skills/$name/SKILL.md"
35
+ return 0
36
+ fi
37
+ [[ "$dir" == "/" ]] && return 1
38
+ dir="$(dirname "$dir")"
39
+ done
40
+ }
41
+
42
+ # The flattened-config reader (lib/yaml.sh) joins paths with a unit
43
+ # separator, so a key can never be confused for part of its parent.
44
+ US=$'\037'
45
+
46
+ # Base branch for one repo. Empty output means unknown — never guessed.
47
+ detect_base() {
48
+ local dir="$1" b
49
+ b="$(git -C "$dir" symbolic-ref --short refs/remotes/origin/HEAD 2>/dev/null | sed 's|^origin/||' || true)"
50
+ if [[ -n "$b" ]]; then printf '%s' "$b"; return 0; fi
51
+ if command -v gh >/dev/null 2>&1; then
52
+ b="$(cd "$dir" && gh repo view --json defaultBranchRef -q .defaultBranchRef.name 2>/dev/null || true)"
53
+ if [[ -n "$b" ]]; then printf '%s' "$b"; return 0; fi
54
+ fi
55
+ return 0
56
+ }
57
+
58
+ remote_name() {
59
+ local dir="$1" remotes
60
+ remotes="$(git -C "$dir" remote 2>/dev/null)"
61
+ if printf '%s\n' "$remotes" | grep -qx origin; then printf 'origin'; return 0; fi
62
+ printf '%s\n' "$remotes" | head -n 1
63
+ }
64
+
65
+ # An unmatched glob stays literal when nullglob is off, which the -d guard
66
+ # already skips, so the loop needs no shell option of its own.
67
+ nested_repos() {
68
+ local child
69
+ for child in "$ROOT"/*/; do
70
+ [[ -d "$child/.git" ]] || continue
71
+ printf '%s\n' "$(basename "$child")"
72
+ done
73
+ }
74
+
75
+ path_exists() { [[ -e "$ROOT/$1" ]]; }
76
+
77
+ # A configured path that leaves the project is a document written somewhere the
78
+ # project does not own, so it fails closed rather than being created.
79
+ escapes_root() {
80
+ local p="${1#./}"
81
+ case "$p" in
82
+ ..|../*|*/..|*/../*|*"/../"*) return 0 ;;
83
+ esac
84
+ return 1
85
+ }
86
+
87
+ pick_artifact() {
88
+ local candidate="$1" fallback="$2"
89
+ if path_exists "$candidate"; then printf '%s' "$candidate"; else printf '%s' "$fallback"; fi
90
+ }
91
+
92
+ # The glossary moved under docs/. Prefer the new home, and fall back to a legacy
93
+ # root file only when that file already exists — an existing config is never
94
+ # migrated, and a project with neither file gets the new default.
95
+ pick_concepts() {
96
+ pick_artifact docs/concepts.md "$(pick_artifact CONCEPTS.md docs/concepts.md)"
97
+ }
98
+
99
+ resolve_artifacts() {
100
+ PLANS="$(pick_artifact docs/plans docs/plans)"
101
+ SOLUTIONS="$(pick_artifact docs/solutions docs/solutions)"
102
+ HANDBOOKS="$(pick_artifact docs/handbooks docs/handbooks)"
103
+ CONCEPTS="$(pick_concepts)"
104
+ STRATEGY="$(pick_artifact docs/strategy.md docs/strategy.md)"
105
+ }
106
+
107
+ # The git defaults the proposal and the check read. Probed once, before either
108
+ # caller runs: a check or sync reads the base from the config, so only the
109
+ # default print and --branch pay for the network call.
110
+ resolve_git_defaults() {
111
+ MIRROR_REMOTE=""
112
+ MIRROR_BRANCH="main"
113
+ REPO_NAME=""
114
+ DEFAULT_BRANCH=""
115
+
116
+ case "$TOPOLOGY" in
117
+ repo)
118
+ REPO_NAME="$(remote_name "$ROOT")"
119
+ REPO_NAME="${REPO_NAME:-origin}"
120
+ (( CHECK || SYNC )) || DEFAULT_BRANCH="$(detect_base "$ROOT")"
121
+ ;;
122
+ workspace)
123
+ MIRROR_REMOTE="$(config_value remote 2>/dev/null || true)"
124
+ MIRROR_BRANCH="$(config_value mirror_branch 2>/dev/null || true)"
125
+ MIRROR_BRANCH="${MIRROR_BRANCH:-main}"
126
+ ;;
127
+ esac
128
+ }
@@ -0,0 +1,221 @@
1
+ # generated_by: sassy-setup@0.17.2
2
+ # lib/proposal.sh — the proposed config, printed by the default mode and merged
3
+ # onto by --check and --sync.
4
+ # Sourced by detect.sh. Never sets shell options; reads the paths it set.
5
+
6
+ # --- Emit a proposal -------------------------------------------------------
7
+ # One function, two callers: the default mode prints it, and --sync/--check
8
+ # merge onto it. Everything it reads (PLANS, REPO_NAME, TOPOLOGY, DEFAULT_BRANCH,
9
+ # MIRROR_*) is computed above, before either caller runs.
10
+
11
+ emit_proposal() {
12
+ # Every key carries its meaning and its allowed values. The file is the
13
+ # documentation a teammate reads, so the comments are part of the output, not
14
+ # decoration to be stripped.
15
+
16
+ # kv KEY VALUE WIDTH COMMENT [INDENT] — prints "key: value" padded so comments
17
+ # align. WIDTH 0 means no padding.
18
+ kv() {
19
+ local indent="${5:- }" line
20
+ line="$indent$1: $2"
21
+ if [[ -n "${4:-}" && "${3:-0}" != "0" ]]; then
22
+ printf '%-*s%s\n' "$3" "$line" "$4"
23
+ elif [[ -n "${4:-}" ]]; then
24
+ printf '%s %s\n' "$line" "$4"
25
+ else
26
+ printf '%s\n' "$line"
27
+ fi
28
+ }
29
+
30
+ cat <<EOF
31
+ # Sassy Skills project config — written by sassy-setup.
32
+ # Every key is optional: delete a line to fall back to the documented default.
33
+ # Guide: https://github.com/sassywares/sassy-skills/blob/main/skills/sassy-setup/references/config.md
34
+
35
+ # --- Artifacts ------------------------------------------------------------
36
+ # Where sassy writes its documents. Paths are relative to this file's folder.
37
+ artifacts:
38
+ EOF
39
+ kv plans "$PLANS" 34 '# sassy-plan writes plans here'
40
+ kv solutions "$SOLUTIONS" 34 '# sassy-compound writes learnings here'
41
+ kv handbooks "$HANDBOOKS" 34 '# sassy-docs writes handbooks here'
42
+ kv concepts "$CONCEPTS" 34 '# the glossary sassy-compound maintains (a file)'
43
+ kv strategy "$STRATEGY" 34 '# the direction sassy-strategy writes (a file)'
44
+ cat <<EOF
45
+
46
+ # --- Knowledge ------------------------------------------------------------
47
+ # read: folders and files searched for prior learnings before planning or
48
+ # debugging. Any paths; one that does not exist is skipped, not fatal.
49
+ # write: true | false — false means this project takes no learnings.
50
+ knowledge:
51
+ EOF
52
+ kv read "[$SOLUTIONS, $CONCEPTS]" 0
53
+ kv write true 34 '# true | false'
54
+
55
+ case "$TOPOLOGY" in
56
+ repo)
57
+ cat <<EOF
58
+
59
+ # --- Git ------------------------------------------------------------------
60
+ # repo: a remote name (this folder is the repo) | workspace (repos live below,
61
+ # this folder is not a repo) | none (no git anywhere here).
62
+ # base_map: the base for a HEAD branch, so a PR targets the right rung.
63
+ # "*" is ordinary work; add a rung for a branch that releases elsewhere.
64
+ git:
65
+ EOF
66
+ kv repo "$REPO_NAME" 0
67
+ printf ' base_map:\n'
68
+ if [[ -n "$DEFAULT_BRANCH" ]]; then
69
+ printf ' "*": %s # probed — confirm this is where ordinary work branches from\n' "$DEFAULT_BRANCH"
70
+ else
71
+ printf ' "*": %s # base for ordinary work; never guessed\n' "<confirm by hand>"
72
+ fi
73
+ printf ' # staging: main # uncomment when a branch releases somewhere else\n'
74
+ printf ' # release/*: main # a family of heads, longest prefix wins\n'
75
+ cat <<'EOF'
76
+ # remote: owner/backup # workspace only: the snapshot mirror
77
+ # mirror_branch: main # workspace only: the mirror's branch
78
+
79
+ # workspace only: each nested repo folder -> the base its PRs target
80
+ # repos:
81
+ # fe: dev
82
+ EOF
83
+ ;;
84
+ workspace)
85
+ cat <<EOF
86
+
87
+ # --- Git ------------------------------------------------------------------
88
+ # repo: workspace means repos live below and this folder is not a repo.
89
+ # remote: the snapshot mirror (GitHub owner/name or URL), required here.
90
+ # mirror_branch: the branch the mirror pushes to. Not a PR base — nested repos
91
+ # carry their own, and a workspace has no branches of its own.
92
+ git:
93
+ EOF
94
+ kv repo workspace 0
95
+ kv remote "${MIRROR_REMOTE:-<set the snapshot mirror, owner/name or URL>}" 0
96
+ kv mirror_branch "$MIRROR_BRANCH" 0
97
+ cat <<'EOF'
98
+
99
+ # --- Repos ----------------------------------------------------------------
100
+ # Every nested repo -> the base its PRs target. A touched repo missing here is
101
+ # a question, never a default.
102
+ repos:
103
+ EOF
104
+ any=0
105
+ while IFS= read -r name; do
106
+ [[ -n "$name" ]] || continue
107
+ base="$(detect_base "$ROOT/$name")"
108
+ if [[ -n "$base" ]]; then
109
+ kv "$name" "$base" 34 '# probed — confirm the PR base'
110
+ else
111
+ kv "$name" "<confirm>" 34 '# base unknown; confirm by hand'
112
+ fi
113
+ any=1
114
+ done < <(nested_repos)
115
+ (( any )) || printf ' # no nested repos found\n'
116
+ ;;
117
+ *)
118
+ cat <<EOF
119
+
120
+ # --- Git ------------------------------------------------------------------
121
+ # repo: none means this folder is deliberately outside git: commit, PR, and
122
+ # babysit refuse here, and work still leaves its changes on disk.
123
+ git:
124
+ EOF
125
+ kv repo none 0
126
+ ;;
127
+ esac
128
+
129
+ cat <<'EOF'
130
+
131
+ # --- Commit ---------------------------------------------------------------
132
+ # current: commit on the checked-out branch, even on a base branch, then push
133
+ # it to its upstream. No PR: pr.* and hooks.pr are ignored; hooks.push runs.
134
+ # new: never commit on a base branch — sassy-work and sassy-debug
135
+ # cut a branch at the start of the run and stay on it.
136
+ commit:
137
+ EOF
138
+ kv branch new 34 '# current | new'
139
+ cat <<'EOF'
140
+
141
+ # --- Pull requests --------------------------------------------------------
142
+ pr:
143
+ EOF
144
+ kv babysit true 24 '# true | false — babysit the PR this run opened'
145
+ kv merge false 24 '# true = merge every babysat PR here'
146
+ kv delete_branch false 24 '# true | false — delete the head branch once merged'
147
+ cat <<'EOF'
148
+
149
+ # --- Hooks ----------------------------------------------------------------
150
+ # Project steps injected into the PR pipeline, after a push under
151
+ # commit.branch: current, across a worktree's life, or around a goal. Keyed by
152
+ # the branch — the branch the PR comes from, never the one it targets — or by the
153
+ # goal slug for hooks.goal. `"*"` is the default; a name overrides per point, and
154
+ # `release/*` matches a family. Each entry is `<skill> <args…>`, resolved at
155
+ # .agents/skills/<name>/SKILL.md; args are passed to the skill verbatim. Declared
156
+ # order, one worker each, missing skill fails closed.
157
+ hooks:
158
+ pr:
159
+ "*":
160
+ EOF
161
+ kv before_create '[]' 30 '# after the commit, before the PR opens' ' '
162
+ kv after_create '[]' 30 '# the PR was just created' ' '
163
+ kv before_merge '[]' 30 '# this run is about to merge' ' '
164
+ kv after_merge '[]' 30 '# this run observed the merge' ' '
165
+ cat <<'EOF'
166
+ # staging: # per-point override for one head branch
167
+ # before_create: []
168
+ # release/*: # a family of heads
169
+ # after_merge: [notify mode:auto]
170
+ goal: # keyed by the goal slug (the folder under artifacts.plans)
171
+ "*":
172
+ EOF
173
+ kv before_slice '[]' 30 '# sassy-goal mode:next: after the previous slice merges' ' '
174
+ kv after_close '[]' 30 '# sassy-goal mode:close: after the status is persisted' ' '
175
+ cat <<'EOF'
176
+ # migration-v2: # one goal, by slug
177
+ # before_slice: [db-migrate mode:auto]
178
+ # push: # commit.branch: current only; keyed by the pushed branch
179
+ # "*":
180
+ # after_push: []
181
+ EOF
182
+ cat <<'EOF'
183
+
184
+ # --- Worktrees ------------------------------------------------------------
185
+ # Parallel work in one repo: a checkout per branch, each with its own derived
186
+ # namespace, so two runs never fight over one working tree. enabled: true lets a
187
+ # run offer one instead of working here — the run asks, and stays here unless the
188
+ # answer is yes. It needs commit.branch: new, because `current` never cuts a
189
+ # branch. The built-in scripts in .sassywares/worktree/ own the git mechanics;
190
+ # create: and remove: name this project's own scripts, which wrap them for
191
+ # whatever a checkout needs and are what a run executes. Nothing else reads
192
+ # these values.
193
+ #
194
+ # Repo topology only: a workspace root has no repo to cut a checkout from, and a
195
+ # `none` folder has no git at all. A checkout is addressed by the project's own
196
+ # stack, not by the suite: a port is the project's business, and this block
197
+ # carries no range.
198
+ worktrees:
199
+ EOF
200
+ kv enabled false 34 '# true = a run may offer its own checkout'
201
+ kv dir '~/.sassywares/worktrees' 34 '# parent of the per-repo folder; ~ is allowed'
202
+ cat <<'EOF'
203
+ # create: scripts/worktrees/create # this project's own; runs before and after git
204
+ # remove: scripts/worktrees/remove # this project's own; stop, then dispose
205
+ EOF
206
+ cat <<'EOF'
207
+
208
+ # --- Dogfood --------------------------------------------------------------
209
+ # Agent QA: a stored procedure that proves a change works in the running
210
+ # product. This block only points at it — commands live in the recipe, because
211
+ # a copy here would duplicate the manifest and could not express step order.
212
+ # The recipe ends each section in a `Prove it:` step whose exit code is the
213
+ # verdict. enabled: true lets a plan write Mode: Auto QA rows, but only for a
214
+ # section that actually has one.
215
+ dogfood:
216
+ EOF
217
+ kv enabled false 42 '# true = plan writes Auto QA rows; false = all Manual'
218
+ kv recipe .sassywares/dogfood/recipe.md 42 '# the procedure; sassy-dogfood writes it'
219
+ kv reports .sassywares/dogfood/reports 42 '# run output; must stay gitignored'
220
+ kv timeout 900 42 '# seconds for the whole procedure'
221
+ }
@@ -0,0 +1,43 @@
1
+ # generated_by: sassy-setup@0.17.2
2
+ # lib/sync.sh — the --sync mode: merge the config and the AGENTS.md block.
3
+ # Sourced by detect.sh. Never sets shell options; reads the paths it set.
4
+
5
+ # --- Template sync ---------------------------------------------------------
6
+ # The one mode that writes. It computes the same proposal the default mode
7
+ # prints, merges the current file onto it (see --sync at the top), and either
8
+ # prints the result (dry run, the default) or writes it with --write. The file is
9
+ # left untouched when the merge is identical, so a second run is a no-op that
10
+ # says so.
11
+ mode_sync() {
12
+ [[ -n "$CONFIG" ]] || { echo "no .sassywares/config.yaml found — run sassy-setup" >&2; exit 1; }
13
+ # --agents scopes the run to AGENTS.md: the config merge is skipped, not printed.
14
+ if (( ! AGENTS_ONLY )); then
15
+ merged="$(merged_config)"
16
+ current="$(cat "$CONFIG")"
17
+ if [[ "$merged" == "$current" ]]; then
18
+ (( SINGLE )) || printf '%s\n' "$merged"
19
+ echo "sync: $CONFIG is already current" >&2
20
+ else
21
+ before="$(mktemp "${TMPDIR:-/tmp}/sassy-sync-before.XXXXXX")"
22
+ after="$(mktemp "${TMPDIR:-/tmp}/sassy-sync-after.XXXXXX")"
23
+ printf '%s\n' "$current" > "$before"
24
+ printf '%s\n' "$merged" > "$after"
25
+ changed="$(diff -u "$before" "$after" 2>/dev/null | awk '/^\+[^+]|^-[^-]/{n++} END{print n+0}' || true)"
26
+ rm -f "$before" "$after"
27
+ if (( SINGLE )); then
28
+ printf '%s\n' "$merged" > "$CONFIG"
29
+ echo "sync: wrote $CONFIG ($changed line(s) changed)" >&2
30
+ else
31
+ printf '%s\n' "$merged"
32
+ echo "sync: $CONFIG would change ($changed line(s)) — nothing written; rerun with --sync --write" >&2
33
+ fi
34
+ fi
35
+ fi
36
+ # AGENTS.md is the second thing --sync owns. Its block is independent of the
37
+ # config merge, so a run whose config is already current still refreshes it,
38
+ # and an untouched project is a no-op that says so.
39
+ if (( NO_AGENTS )); then
40
+ echo "sync: AGENTS.md untouched (--no-agents)" >&2
41
+ elif (( SINGLE )); then agents_md_sync 0; else agents_md_sync 1; fi
42
+ exit $?
43
+ }
@@ -0,0 +1,57 @@
1
+ # generated_by: sassy-setup@0.17.2
2
+ # lib/worktree.sh — the --worktree-script mode and its value predicate.
3
+ # Sourced by detect.sh. Never sets shell options; reads the paths it set.
4
+
5
+ # wt_script_reason VALUE — succeeds with the reason when a `worktrees.create|remove`
6
+ # value has the wrong shape, fails when it is usable. One path, relative to the
7
+ # project, no arguments: the script is the lifecycle, so a command line here would
8
+ # define a second place it lives. `--check` and `--worktree-script` share this one
9
+ # predicate, so a value cannot pass one mode and fail the other over the same
10
+ # question.
11
+ wt_script_reason() {
12
+ local v="$1"
13
+ case "$v" in
14
+ *[[:space:]]*) printf 'takes one path, no arguments — move the arguments into the script'; return 0 ;;
15
+ /*|~*) printf 'is not a path relative to the project root'; return 0 ;;
16
+ esac
17
+ escapes_root "$v" && { printf 'walks outside the project'; return 0; }
18
+ return 1
19
+ }
20
+
21
+ # --- Worktree script path --------------------------------------------------
22
+ # One question, one answer: which absolute path does a run execute for
23
+ # `worktrees.create` or `worktrees.remove`? A declared path that is gone is a
24
+ # degradation, not an error (D3): warn on stderr naming the key and the missing
25
+ # file, then hand back the built-in. Never writes, never creates a directory, and
26
+ # answers even when the built-in folder has not been installed yet.
27
+ mode_worktree_script() {
28
+ case "$WT_SCRIPT" in
29
+ create|remove) ;;
30
+ *) echo "unknown --worktree-script: $WT_SCRIPT (expected create or remove)" >&2; exit 2 ;;
31
+ esac
32
+ [[ -n "$CONFIG" ]] || { echo "no .sassywares/config.yaml found — run sassy-setup" >&2; exit 1; }
33
+ # The config's folder is the project root, not the .sassywares folder holding
34
+ # the file: declared paths are relative to the project, like every other key.
35
+ builtin="$ROOT/.sassywares/worktree/$WT_SCRIPT"
36
+ declared="$(yflat "worktrees${US}${WT_SCRIPT}" 2>/dev/null || true)"
37
+ if [[ -z "$declared" ]]; then
38
+ printf '%s\n' "$builtin"
39
+ exit 0
40
+ fi
41
+ # A wrong shape is the same degradation as a missing file: warn with the reason
42
+ # `--check` gives, then hand back the built-in.
43
+ if reason="$(wt_script_reason "$declared")"; then
44
+ echo "warning: worktrees.$WT_SCRIPT: '$declared' $reason — using the built-in .sassywares/worktree/$WT_SCRIPT" >&2
45
+ printf '%s\n' "$builtin"
46
+ exit 0
47
+ fi
48
+ declared_path="$ROOT/${declared#./}"
49
+ if [[ -f "$declared_path" && -x "$declared_path" ]]; then
50
+ # Physical path, so the identity a run inherits never disagrees over /tmp.
51
+ printf '%s\n' "$(cd "$(dirname "$declared_path")" && pwd -P)/$(basename "$declared_path")"
52
+ exit 0
53
+ fi
54
+ echo "warning: worktrees.$WT_SCRIPT names '$declared' but $declared_path is missing or not executable — using the built-in .sassywares/worktree/$WT_SCRIPT" >&2
55
+ printf '%s\n' "$builtin"
56
+ exit 0
57
+ }
@@ -0,0 +1,199 @@
1
+ # generated_by: sassy-setup@0.17.2
2
+ # lib/yaml.sh — the flattened-config readers and the map match both nested
3
+ # maps share (git.base_map, hooks.<kind>).
4
+ # Sourced by detect.sh. Never sets shell options; reads CONFIG.
5
+
6
+ # --- config readers -------------------------------------------------------
7
+ # The file is flattened to `path<TAB>value` with paths joined by unit separators,
8
+ # which is enough to read the two nested maps we own (git.base_map, hooks.pr.*).
9
+ # The US constant itself is lib/common.sh's.
10
+
11
+ yaml_flat() {
12
+ awk -v us="$US" '
13
+ function ind(s, m) { m = match(s, /^ */); return m ? RLENGTH : 0 }
14
+ {
15
+ line = $0; sub(/#.*$/, "", line)
16
+ if (line ~ /^[[:space:]]*$/) next
17
+ d = ind(line)
18
+ body = line; sub(/^[[:space:]]*/, "", body); sub(/[[:space:]]+$/, "", body)
19
+ if (body ~ /:$/) {
20
+ key = body; sub(/:$/, "", key); gsub(/"/, "", key)
21
+ while (sp > 0 && sd[sp] >= d) sp--
22
+ sd[++sp] = d; sk[sp] = key
23
+ next
24
+ }
25
+ if (body !~ /:/) next
26
+ key = body; sub(/:.*/, "", key); gsub(/"/, "", key)
27
+ val = body; sub(/^[^:]*:[[:space:]]*/, "", val); gsub(/^"|"$/, "", val)
28
+ path = ""
29
+ for (i = 1; i <= sp; i++) if (sd[i] < d) path = path (path == "" ? "" : us) sk[i]
30
+ print path (path == "" ? "" : us) key "\t" val
31
+ }' "${1:-$CONFIG}"
32
+ }
33
+
34
+ yflat() { yaml_flat "$CONFIG" | awk -F'\t' -v p="$1" '$1 == p { print $2; exit }'; }
35
+
36
+ # yflat_in FILE PATH — the same reader against another config file.
37
+ yflat_in() { yaml_flat "$1" | awk -F'\t' -v p="$2" '$1 == p { print $2; exit }'; }
38
+
39
+ list_items() {
40
+ printf '%s' "$1" | sed -e 's/^\[//' -e 's/\]$//' | tr ',' '\n' \
41
+ | sed -E 's/^[[:space:]]+//; s/[[:space:]]+$//; s/^"//; s/"$//' | grep -v '^$' || true
42
+ }
43
+
44
+ # recipe_lint FILE — structural lint for a dogfood procedure. Prints one message
45
+ # per breach; the caller turns each into a drift line. Nothing is executed: a
46
+ # check run validates the shape of a procedure, it never runs the product.
47
+ recipe_lint() {
48
+ awk '
49
+ function inventory(rest, kind, n, parts, i, name) {
50
+ n = split(rest, parts, ",")
51
+ for (i = 1; i <= n; i++) {
52
+ name = parts[i]
53
+ sub(/^[[:space:]]+/, "", name)
54
+ sub(/[[:space:]\(].*$/, "", name)
55
+ if (name == "") continue
56
+ if (kind == "unc") unc[++nunc] = name
57
+ else oos[++noos] = name
58
+ }
59
+ }
60
+ BEGIN { pending = 0; sec = ""; sname = ""; prove = 0; step = ""; incomment = 0; nunc = 0; noos = 0 }
61
+ index($0, "<!--") { incomment = 1 }
62
+ incomment {
63
+ if (index($0, "-->")) incomment = 0
64
+ next
65
+ }
66
+ # The two inventories are file level: names of surfaces, not a surface. Inside a
67
+ # section they are a mistake — a section states its own answer with **Prove it:**.
68
+ index($0, "**Uncovered:**") || index($0, "**Out of scope:**") {
69
+ if (sec != "") {
70
+ printf "\"**Uncovered:**\" and \"**Out of scope:**\" are file level only — section \"%s\" states its own answer with **Prove it:** none\n", sname
71
+ next
72
+ }
73
+ line = $0
74
+ if (index($0, "**Uncovered:**")) { sub(/^\*\*Uncovered:\*\*[[:space:]]*/, "", line); inventory(line, "unc") }
75
+ else { sub(/^\*\*Out of scope:\*\*[[:space:]]*/, "", line); inventory(line, "oos") }
76
+ next
77
+ }
78
+ index($0, "**Prove it:**") {
79
+ prove = 1
80
+ val = $0; sub(/^.*\*\*Prove it:\*\*[[:space:]]*/, "", val)
81
+ low = tolower(val)
82
+ if (sname != "") pval[sname] = low
83
+ if (low !~ /^none/ && low !~ /^step[[:space:]]+[0-9]/)
84
+ printf "a **Prove it:** line must name a step (`step 3`) or say `none` — got \"%s\"\n", val
85
+ next
86
+ }
87
+ /^## / {
88
+ if (sec != "" && !prove)
89
+ printf "section \"%s\" has no **Prove it:** line — it has no verdict\n", sname
90
+ if (pending)
91
+ printf "step %s-%s has no **Expect** line — an unstated check is a suggestion\n", sname, step
92
+ pending = 0; prove = 0
93
+ sec = $0; sub(/^## +/, "", sec)
94
+ split(sec, parts, /[ \t]+/); sname = parts[1]
95
+ insection[sname] = 1
96
+ next
97
+ }
98
+ /^[0-9]+\. / && index($0, "**Do**") {
99
+ if (pending)
100
+ printf "step %s-%s has no **Expect** line — an unstated check is a suggestion\n", sname, step
101
+ step = $0; sub(/\..*$/, "", step)
102
+ pending = 1; next
103
+ }
104
+ index($0, "**Expect**") { pending = 0; next }
105
+ END {
106
+ if (pending)
107
+ printf "step %s-%s has no **Expect** line — an unstated check is a suggestion\n", sname, step
108
+ if (sec != "" && !prove)
109
+ printf "section \"%s\" has no **Prove it:** line — it has no verdict\n", sname
110
+ if (sec == "")
111
+ printf "has no \"## <section>\" heading — there is nothing to prove\n"
112
+ # The inventory and the sections must agree, or the gap list lies.
113
+ for (i = 1; i <= nunc; i++) {
114
+ n = unc[i]
115
+ if (!(n in insection))
116
+ printf "**Uncovered:** names \"%s\" but there is no \"## %s\" section — an uncovered surface gets a section saying **Prove it:** none\n", n, n
117
+ else if (pval[n] !~ /^none/)
118
+ printf "**Uncovered:** names \"%s\" but its section has a verdict — uncovered means **Prove it:** none\n", n
119
+ }
120
+ for (i = 1; i <= noos; i++) {
121
+ n = oos[i]
122
+ if (n in insection)
123
+ printf "\"%s\" is listed **Out of scope:** but gets a \"## %s\" section — out of scope means no section\n", n, n
124
+ }
125
+ }
126
+ ' "$1"
127
+ }
128
+
129
+ # map_match SECTION HEAD — exact key, then the longest matching family, then "*".
130
+ # base_map uses it, and hooks use the same rule, so "which pattern applies" has
131
+ # exactly one answer in the whole config.
132
+ map_match() {
133
+ local section="$1" head="$2" pat stem best="" bestlen=0 v
134
+ v="$(yflat "git${US}${section}${US}${head}")"
135
+ [[ -n "$v" ]] && { printf '%s' "$v"; return; }
136
+ while IFS= read -r pat; do
137
+ case "$pat" in *"*") ;; *) continue ;; esac
138
+ [[ "$pat" == "*" ]] && continue
139
+ stem="${pat%\*}"
140
+ if [[ "$head" == "$stem"* ]] && (( ${#stem} > bestlen )); then
141
+ best="$pat"; bestlen=${#stem}
142
+ fi
143
+ done < <(yaml_flat "$CONFIG" | awk -F'\t' -v us="$US" -v sec="$section" \
144
+ '{n=split($1,a,us); if (n==3 && a[1]=="git" && a[2]==sec) print a[3]}' | sort -u)
145
+ if [[ -n "$best" ]]; then
146
+ v="$(yflat "git${US}${section}${US}${best}")"
147
+ [[ -n "$v" ]] && { printf '%s' "$v"; return; }
148
+ fi
149
+ yflat "git${US}${section}${US}*"
150
+ }
151
+
152
+ base_for_head() { map_match base_map "$1"; }
153
+
154
+ # hook_patterns [KIND] — the keys declared under hooks.<kind> (pr by default): a
155
+ # head branch, or a goal slug for hooks.goal.
156
+ hook_patterns() {
157
+ yaml_flat | awk -F'\t' -v us="$US" -v k="${1:-pr}" '{n=split($1,a,us); if (n==4 && a[1]=="hooks" && a[2]==k) print a[3]}' | sort -u
158
+ }
159
+
160
+ # hook_points KIND — the single source of point names; empty for an unknown kind.
161
+ hook_points() {
162
+ case "$1" in
163
+ pr) printf '%s' "before_create after_create before_merge after_merge" ;;
164
+ push) printf '%s' "after_push" ;;
165
+ goal) printf '%s' "before_slice after_close" ;;
166
+ esac
167
+ }
168
+
169
+ # hooks_declared KIND — succeeds when hooks.<kind> names at least one skill.
170
+ hooks_declared() {
171
+ local kind="$1" pat point
172
+ while IFS= read -r pat; do
173
+ for point in $(hook_points "$kind"); do
174
+ [[ -n "$(list_items "$(yflat "hooks${US}${kind}${US}${pat}${US}${point}")")" ]] && return 0
175
+ done
176
+ done < <(hook_patterns "$kind")
177
+ return 1
178
+ }
179
+
180
+ # hooks_for_head_point HEAD POINT [KIND] — exact head, then the longest matching
181
+ # family, then "*". A pattern that declares no entry for this point inherits.
182
+ hooks_for_head_point() {
183
+ local head="$1" point="$2" kind="${3:-pr}" pat stem best="" bestlen=0 v
184
+ v="$(yflat "hooks${US}${kind}${US}${head}${US}${point}")"
185
+ [[ -n "$v" ]] && { printf '%s' "$v"; return; }
186
+ while IFS= read -r pat; do
187
+ case "$pat" in *"*") ;; *) continue ;; esac
188
+ [[ "$pat" == "*" ]] && continue
189
+ stem="${pat%\*}"
190
+ if [[ "$head" == "$stem"* ]] && (( ${#stem} > bestlen )); then
191
+ best="$pat"; bestlen=${#stem}
192
+ fi
193
+ done < <(hook_patterns "$kind")
194
+ if [[ -n "$best" ]]; then
195
+ v="$(yflat "hooks${US}${kind}${US}${best}${US}${point}")"
196
+ [[ -n "$v" ]] && { printf '%s' "$v"; return; }
197
+ fi
198
+ printf '%s' "$(yflat "hooks${US}${kind}${US}*${US}${point}")"
199
+ }
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- // generated_by: sassy-setup@0.17.0
2
+ // generated_by: sassy-setup@0.17.2
3
3
  // Verify the vendored suite skill folders against skills-lock.json.
4
4
  //
5
5
  // The suite installs in one of two scopes, like the agents: the project
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- // generated_by: sassy-setup@0.17.0
2
+ // generated_by: sassy-setup@0.17.2
3
3
  // Verify an installed `.sassywares/worktree/` set against the copy this skill
4
4
  // ships.
5
5
  //