@sassywares/skills 0.17.1 → 0.17.3
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.
- package/README.md +28 -6
- package/package.json +1 -1
- package/skills/sassy-babysit/SKILL.md +2 -2
- package/skills/sassy-dogfood/SKILL.md +11 -8
- package/skills/sassy-dogfood/references/check.md +5 -3
- package/skills/sassy-dogfood/references/discover.md +23 -12
- package/skills/sassy-dogfood/references/run.md +91 -17
- package/skills/sassy-setup/SKILL.md +5 -5
- package/skills/sassy-setup/assets/dogfood-recipe.md +19 -5
- package/skills/sassy-setup/references/anchors.md +1 -1
- package/skills/sassy-setup/references/branching.md +1 -1
- package/skills/sassy-setup/references/check.md +1 -1
- package/skills/sassy-setup/references/config.md +66 -14
- package/skills/sassy-setup/references/dogfood.md +181 -40
- package/skills/sassy-setup/references/harness.md +1 -1
- package/skills/sassy-setup/references/init.md +6 -4
- package/skills/sassy-setup/references/plan-resolution.md +1 -1
- package/skills/sassy-setup/references/scaffold-header.md +9 -2
- package/skills/sassy-setup/references/workspace.md +63 -1
- package/skills/sassy-setup/references/worktree.md +1 -1
- package/skills/sassy-setup/scripts/detect.sh +49 -1982
- package/skills/sassy-setup/scripts/hash-skill.mjs +1 -1
- package/skills/sassy-setup/scripts/lib/agents-md.sh +513 -0
- package/skills/sassy-setup/scripts/lib/branch.sh +200 -0
- package/skills/sassy-setup/scripts/lib/check.sh +940 -0
- package/skills/sassy-setup/scripts/lib/common.sh +128 -0
- package/skills/sassy-setup/scripts/lib/proposal.sh +248 -0
- package/skills/sassy-setup/scripts/lib/sync.sh +43 -0
- package/skills/sassy-setup/scripts/lib/worktree.sh +57 -0
- package/skills/sassy-setup/scripts/lib/yaml.sh +273 -0
- package/skills/sassy-setup/scripts/lockcheck.mjs +1 -1
- package/skills/sassy-setup/scripts/worktree-check.mjs +1 -1
- package/skills/sassy-ship/SKILL.md +4 -4
- package/skills/sassy-ship/references/brief.md +1 -1
- package/skills/sassy-ship/references/plan.md +1 -1
- package/skills/sassy-ship/references/slice.md +1 -1
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# generated_by: sassy-setup@0.17.3
|
|
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,248 @@
|
|
|
1
|
+
# generated_by: sassy-setup@0.17.3
|
|
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
|
+
if [[ "$TOPOLOGY" == "workspace" ]]; then
|
|
219
|
+
# A workspace declares one recipe per repo, keyed by `repos:` — the single
|
|
220
|
+
# `recipe:` key is a repo-topology form and is drift here. The map is shown as
|
|
221
|
+
# a commented example rather than a guessed entry: a path nobody wrote would
|
|
222
|
+
# be a note today and drift the moment dogfood is turned on.
|
|
223
|
+
printf ' # recipes: # workspace only: one recipe per repo; false = deliberately not dogfooded\n'
|
|
224
|
+
# Propose the keys `--check` validates: `repos:` when the config has one, and
|
|
225
|
+
# the disk only when it does not (a fresh setup). A key from a folder the
|
|
226
|
+
# config never lists would be drift the moment it is uncommented.
|
|
227
|
+
dg_any=0
|
|
228
|
+
if [[ -n "$CONFIG" && -f "$CONFIG" ]] && [[ -n "$(repo_names)" ]]; then
|
|
229
|
+
while IFS= read -r name; do
|
|
230
|
+
[[ -n "$name" ]] || continue
|
|
231
|
+
printf ' # %s: docs/dogfood/%s.md\n' "$name" "$name"
|
|
232
|
+
dg_any=1
|
|
233
|
+
done < <(repo_names)
|
|
234
|
+
else
|
|
235
|
+
while IFS= read -r name; do
|
|
236
|
+
[[ -n "$name" ]] || continue
|
|
237
|
+
printf ' # %s: docs/dogfood/%s.md\n' "$name" "$name"
|
|
238
|
+
dg_any=1
|
|
239
|
+
done < <(nested_repos)
|
|
240
|
+
fi
|
|
241
|
+
(( dg_any )) || printf ' # <repo>: docs/dogfood/<repo>.md\n'
|
|
242
|
+
else
|
|
243
|
+
kv recipe docs/dogfood.md 42 '# the procedure; sassy-dogfood writes it'
|
|
244
|
+
fi
|
|
245
|
+
kv reports .sassywares/dogfood/reports 42 '# run output; must stay gitignored'
|
|
246
|
+
kv timeout 900 42 '# seconds for the whole procedure'
|
|
247
|
+
kv keep 10 42 '# runs kept per repo; a green run prunes the oldest'
|
|
248
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# generated_by: sassy-setup@0.17.3
|
|
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.3
|
|
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
|
+
}
|