@sassywares/skills 0.11.7 → 0.11.8
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/package.json +1 -1
- package/skills/sassy-setup/assets/worktree/_lib.sh +31 -1
- package/skills/sassy-setup/assets/worktree/list +6 -7
- package/skills/sassy-setup/assets/worktree/prune +2 -5
- package/skills/sassy-setup/assets/worktree/remove +7 -9
- package/skills/sassy-setup/assets/worktree/stop +6 -6
- package/skills/sassy-setup/references/worktree.md +9 -4
- package/skills/sassy-worktree/SKILL.md +2 -2
package/package.json
CHANGED
|
@@ -339,7 +339,15 @@ wt_preview() {
|
|
|
339
339
|
recipe="${recipe:-.sassywares/dogfood/recipe.md}"
|
|
340
340
|
case "$recipe" in /*) ;; *) recipe="$MAIN/$recipe" ;; esac
|
|
341
341
|
[ -f "$recipe" ] || return 0
|
|
342
|
-
line
|
|
342
|
+
# The block is the line after `**Preview:**` plus its continuation lines, up to
|
|
343
|
+
# a blank line or the next `**Header:**` — a wrapped sentence is still one answer.
|
|
344
|
+
line="$(awk '
|
|
345
|
+
/^\*\*Preview:\*\*/ { sub(/^\*\*Preview:\*\*[[:space:]]*/, ""); buf = $0; inb = 1; next }
|
|
346
|
+
inb && /^[[:space:]]*$/ { inb = 0; next }
|
|
347
|
+
inb && /^\*\*/ { inb = 0; next }
|
|
348
|
+
inb { buf = buf " " $0 }
|
|
349
|
+
END { print buf }
|
|
350
|
+
' "$recipe" 2>/dev/null | sed -E 's/[[:space:]]+/ /g; s/[[:space:]]+$//')"
|
|
343
351
|
[ -n "$line" ] || return 0
|
|
344
352
|
port=""
|
|
345
353
|
if wt_has_ports; then
|
|
@@ -354,6 +362,28 @@ wt_preview() {
|
|
|
354
362
|
printf '%s' "$line"
|
|
355
363
|
}
|
|
356
364
|
|
|
365
|
+
# wt_preview_port SLUG — the port the preview line advertises, if it names one.
|
|
366
|
+
# A project with no `worktrees.ports` still has an address; this is how the tools
|
|
367
|
+
# find it without assuming a browser or a claim.
|
|
368
|
+
wt_preview_port() {
|
|
369
|
+
local line
|
|
370
|
+
line="$(wt_preview "$1")"
|
|
371
|
+
[ -n "$line" ] || return 0
|
|
372
|
+
printf '%s' "$line" \
|
|
373
|
+
| grep -oE '(localhost|127\.0\.0\.1):[0-9]+' | head -n 1 | grep -oE '[0-9]+$'
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
# wt_live_port SLUG — where to probe this checkout: its claim if it has one, else
|
|
377
|
+
# the port its preview advertises. Empty means "nothing to probe here".
|
|
378
|
+
wt_live_port() {
|
|
379
|
+
local slug="$1" p
|
|
380
|
+
if wt_has_ports; then
|
|
381
|
+
p="$(wt_port_for "$slug")"
|
|
382
|
+
[ -n "$p" ] && { printf '%s' "$p"; return 0; }
|
|
383
|
+
fi
|
|
384
|
+
wt_preview_port "$slug"
|
|
385
|
+
}
|
|
386
|
+
|
|
357
387
|
# Newest dogfood verdict for a checkout, as `status class` — or empty.
|
|
358
388
|
wt_verdict() {
|
|
359
389
|
local dir="$1/.sassywares/dogfood/reports" newest s c
|
|
@@ -46,8 +46,9 @@ one() { # $1 path, $2 branch
|
|
|
46
46
|
case "$kind" in
|
|
47
47
|
path) printf '%s\n' "$p" ;;
|
|
48
48
|
address)
|
|
49
|
-
|
|
50
|
-
port="$(
|
|
49
|
+
# A claimed port, or the one the recipe's preview line advertises.
|
|
50
|
+
port="$(wt_live_port "$slug")"
|
|
51
|
+
[ -n "$port" ] || die "no address here — worktrees.ports is unset and the preview line names no port; try --preview"
|
|
51
52
|
printf 'http://localhost:%s\n' "$port"
|
|
52
53
|
;;
|
|
53
54
|
preview)
|
|
@@ -82,11 +83,9 @@ while IFS=$'\t' read -r p b; do
|
|
|
82
83
|
fi
|
|
83
84
|
# The address is whatever the project says it is: a URL, a simulator, a window.
|
|
84
85
|
line="$(wt_preview "$slug")"
|
|
85
|
-
port=""
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
[ -n "$line" ] || line="http://localhost:$port"
|
|
89
|
-
fi
|
|
86
|
+
port="$(wt_live_port "$slug")"
|
|
87
|
+
[ -n "$line" ] || line=""
|
|
88
|
+
if [ -z "$line" ] && [ -n "$port" ]; then line="http://localhost:$port"; fi
|
|
90
89
|
if [ -n "$port" ]; then
|
|
91
90
|
if tcp_up "$port"; then live="up"; else live="down"; fi
|
|
92
91
|
else
|
|
@@ -48,12 +48,9 @@ while IFS=$'\t' read -r p b; do
|
|
|
48
48
|
state="$(wt_upstream_state "$p")"
|
|
49
49
|
if wt_dirty "$p"; then dirty="yes"; else dirty="no"; fi
|
|
50
50
|
unpushed="$(wt_unpushed "$p")"
|
|
51
|
-
port=""
|
|
51
|
+
port="$(wt_live_port "$slug")"
|
|
52
52
|
live="no"
|
|
53
|
-
|
|
54
|
-
port="$(wt_port_for "$slug")"
|
|
55
|
-
tcp_up "$port" && live="yes"
|
|
56
|
-
fi
|
|
53
|
+
[ -n "$port" ] && tcp_up "$port" && live="yes"
|
|
57
54
|
|
|
58
55
|
action=""
|
|
59
56
|
if [ "$state" = "unmerged" ]; then
|
|
@@ -60,12 +60,9 @@ if [ -n "$hooks" ] && [ "$hook_ok" -eq 0 ]; then
|
|
|
60
60
|
exit 3
|
|
61
61
|
fi
|
|
62
62
|
|
|
63
|
-
port=""
|
|
64
|
-
if
|
|
65
|
-
|
|
66
|
-
if tcp_up "$port"; then
|
|
67
|
-
die "something is still listening on :$port — stop <$slug> first"
|
|
68
|
-
fi
|
|
63
|
+
port="$(wt_live_port "$slug")"
|
|
64
|
+
if [ -n "$port" ] && tcp_up "$port"; then
|
|
65
|
+
die "something is still listening on :$port — stop <$slug> first"
|
|
69
66
|
fi
|
|
70
67
|
|
|
71
68
|
if [ "$force" -eq 0 ]; then
|
|
@@ -83,7 +80,8 @@ if [ "$force" -eq 1 ]; then
|
|
|
83
80
|
else
|
|
84
81
|
git worktree remove "$path"
|
|
85
82
|
fi
|
|
86
|
-
[ -n "$port" ] &&
|
|
87
|
-
|
|
88
|
-
|
|
83
|
+
if [ -n "$port" ] && [ "$(wt_owner "$port")" = "$slug" ]; then
|
|
84
|
+
wt_release "$port" "$slug"
|
|
85
|
+
ok released ":$port"
|
|
86
|
+
fi
|
|
89
87
|
ok removed "$path"
|
|
@@ -15,10 +15,10 @@ usage() {
|
|
|
15
15
|
cat <<'EOF'
|
|
16
16
|
Usage: .sassywares/worktree/stop <slug|branch>
|
|
17
17
|
|
|
18
|
-
Kill the processes listening on
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
Kill the processes listening on the address this checkout advertises — its claimed
|
|
19
|
+
port if it has one, otherwise the port its recipe's preview line names. Nothing
|
|
20
|
+
listening is a success with a note, so stopping twice is safe. A preview that names
|
|
21
|
+
no port at all (a simulator, a window) is the project's to stop.
|
|
22
22
|
EOF
|
|
23
23
|
}
|
|
24
24
|
|
|
@@ -36,8 +36,8 @@ slug="$(wt_slug "$branch")"
|
|
|
36
36
|
|
|
37
37
|
wt_is_main "$path" && die "the main checkout is not a worktree — nothing to stop"
|
|
38
38
|
wt_managed "$path" || die "'$1' is not managed here — it is outside the worktree home, or it was cut before the wiring"
|
|
39
|
-
|
|
40
|
-
port
|
|
39
|
+
port="$(wt_live_port "$slug")"
|
|
40
|
+
[ -n "$port" ] || die "no address to stop — worktrees.ports is unset and the preview line names no port"
|
|
41
41
|
|
|
42
42
|
if ! tcp_up "$port"; then
|
|
43
43
|
ok status "nothing listening on :$port"
|
|
@@ -110,9 +110,14 @@ to the config for this — it is procedure, not identity.
|
|
|
110
110
|
When a range *is* configured: the slug hashes into it, the claim is taken with an
|
|
111
111
|
atomic `mkdir`, and a collision probes forward one port at a time. A claim
|
|
112
112
|
belongs to a slug, so a restarted app returns to the same port and two slugs that
|
|
113
|
-
hash alike do not fight.
|
|
114
|
-
|
|
115
|
-
|
|
113
|
+
hash alike do not fight.
|
|
114
|
+
|
|
115
|
+
**Liveness and stopping follow the address, not the claim.** `list` probes the port
|
|
116
|
+
the checkout advertises — its claim if it has one, otherwise the port its recipe's
|
|
117
|
+
`**Preview:**` line names — and never trusts a recorded pid. `stop` kills by that
|
|
118
|
+
same address, and `remove` refuses to delete a checkout while it answers. A preview
|
|
119
|
+
that names no port at all (a simulator, a desktop window) has nothing to probe, so
|
|
120
|
+
`LIVE` reads `—` and stopping it is the project's job.
|
|
116
121
|
|
|
117
122
|
## Hooks
|
|
118
123
|
|
|
@@ -172,7 +177,7 @@ writing down once in the recipe rather than rediscovering it.
|
|
|
172
177
|
| It is the main checkout | the repo itself |
|
|
173
178
|
| Dirty tree | uncommitted work |
|
|
174
179
|
| Commits on no remote | nothing to recover from |
|
|
175
|
-
| Something listening on its
|
|
180
|
+
| Something listening on its advertised address | stop the app first |
|
|
176
181
|
| A `before_remove` hook not yet run | the project has cleanup to do |
|
|
177
182
|
|
|
178
183
|
`remove` deletes the checkout, the port claim, and nothing else. **The branch
|
|
@@ -42,7 +42,7 @@ argument-hint: "[slug] [mode:create|list|preview|remove|prune] [section:<name>]"
|
|
|
42
42
|
|
|
43
43
|
Paths in the table are shortened to `~`; `--path <slug>` prints the real absolute path, which is what you hand a user who wants to open the checkout in an editor.
|
|
44
44
|
|
|
45
|
-
Run `.sassywares/worktree/list` and present it as it prints — branch, worktree, how to see it, live, last verdict. `--preview <slug>` prints how to see one checkout, `--path <slug>` its path, and `--address <slug>` its URL
|
|
45
|
+
Run `.sassywares/worktree/list` and present it as it prints — branch, worktree, how to see it, live, last verdict. `--preview <slug>` prints how to see one checkout, `--path <slug>` its path, and `--address <slug>` its URL — from its claimed port, or the one its preview line names. Never summarise the table away: how to see it is the point.
|
|
46
46
|
|
|
47
47
|
## `preview`
|
|
48
48
|
|
|
@@ -51,7 +51,7 @@ Run `.sassywares/worktree/list` and present it as it prints — branch, worktree
|
|
|
51
51
|
3. **Preflight the session.** If the recipe's *Working in a second checkout* or *Set up once* names a session artifact and `.sassywares/session/` in **that checkout** is empty, that is `class: env`: report it with the line that fixes it and stop. Never open a logged-out app and call it a preview — the human will read the login screen as a broken build.
|
|
52
52
|
4. **Run the bring-up.** In `WT_PATH`: the recipe's *Set up once* when the checkout is cold (no `.env`, no installed deps), then the section's steps in order **up to but not including** its `Prove it:` step. Judge each step by its `Expect`. A failure stops the preview and is reported with the step id and its output tail — a preview that half-started is not a preview.
|
|
53
53
|
5. **Leave it running and report how to see it.** `list --preview <slug>` prints the recipe's `**Preview:**` line with the namespace substituted — the *result*, a URL or a simulator name or a window, never the command that started it. Print exactly that; never build an address yourself, and never assume one is a URL. When the project has ports and the preview answers on one, say it is up; when it does not, say it is running and that stopping it is the project's job.
|
|
54
|
-
6. **To stop it,** run `.sassywares/worktree/stop <slug>`. It kills
|
|
54
|
+
6. **To stop it,** run `.sassywares/worktree/stop <slug>`. It kills whatever answers on the address this checkout advertises — its claimed port, or the port its preview line names — so it works for a project with no port resource too. A preview that names no port at all is the project's to stop, and it says so.
|
|
55
55
|
|
|
56
56
|
Preview never judges the work, never writes a report, never commits, and never returns a verdict. If the user wants to know whether it *works*, that is `sassy-dogfood mode:run`.
|
|
57
57
|
|