@sassywares/skills 0.11.7 → 0.11.9

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sassywares/skills",
3
- "version": "0.11.7",
3
+ "version": "0.11.9",
4
4
  "description": "Lean, explicit-invocation Agent Skills for shipping fast: plan, work, review, validate, ship.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -10,11 +10,11 @@
10
10
  # 3. Everything resolves against the MAIN checkout, so running any of these
11
11
  # from inside a worktree behaves identically.
12
12
  #
13
- # worktree-version: 2
13
+ # worktree-version: 3
14
14
 
15
15
  set -euo pipefail
16
16
 
17
- WT_VERSION="2"
17
+ WT_VERSION="3"
18
18
  WT_LIB_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
19
19
 
20
20
  log() { printf '%s\n' "$*"; }
@@ -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="$(sed -n 's/^\*\*Preview:\*\*[[:space:]]*//p' "$recipe" 2>/dev/null | head -n 1)"
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
- wt_has_ports || die "no port resource here — worktrees.ports is unset; try --preview"
50
- port="$(wt_port_for "$slug")"
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,18 +83,16 @@ 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
- if wt_has_ports; then
87
- port="$(wt_port_for "$slug")"
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
93
92
  live="—"
94
93
  fi
95
94
  last="$(wt_verdict "$p")"
96
- printf ' %-34s %-50s %-40s %-5s %s\n' "$b" "$shown" "${line:-—}" "$live" "${last:-—}"
95
+ printf ' %-34s %-50s %-40.40s %-5s %s\n' "$b" "$shown" "${line:-—}" "$live" "${last:-—}"
97
96
  done < <(wt_all)
98
97
 
99
98
  [ "$count" -gt 0 ] || log " no checkouts found — is this a git repository?"
@@ -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
- if wt_has_ports; then
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 wt_has_ports; then
65
- port="$(wt_port_for "$slug")"
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
@@ -78,12 +75,13 @@ if [ "$force" -eq 0 ]; then
78
75
  esac
79
76
  fi
80
77
 
81
- if [ "$force" -eq 1 ]; then
82
- git worktree remove --force "$path"
83
- else
84
- git worktree remove "$path"
78
+ if ! { [ "$force" -eq 1 ] && git worktree remove --force "$path" || [ "$force" -eq 0 ] && git worktree remove "$path"; }; then
79
+ printf ' %-9s %s\n' "→" "a half-removed checkout is not a removal: if it is gone from 'git worktree list'" >&2
80
+ printf ' %-9s %s\n' "" "but the folder remains, delete the folder and run: git worktree prune" >&2
81
+ exit 1
82
+ fi
83
+ if [ -n "$port" ] && [ "$(wt_owner "$port")" = "$slug" ]; then
84
+ wt_release "$port" "$slug"
85
+ ok released ":$port"
85
86
  fi
86
- [ -n "$port" ] && wt_release "$port" "$slug"
87
-
88
- [ -n "$port" ] && ok released ":$port"
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 that worktree's port. Nothing listening is a
19
- success with a note, so stopping twice is safe. Only a project that configured
20
- `worktrees.ports` has something here to stop — for a simulator or a desktop app,
21
- stopping belongs to the project.
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
- wt_has_ports || die "no port resource here — stopping this preview is the project's job (its before_remove hook or the recipe)"
40
- port="$(wt_port_for "$slug")"
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. `list` probes for liveness and never trusts a recorded
114
- pid. Without a port there is nothing to probe, so `LIVE` reads `—` and stopping
115
- the preview is the project's job — its `before_remove` hook, or the recipe.
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 port | stop the app first (only when `ports:` is set) |
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
@@ -758,6 +758,12 @@ if (( CHECK )); then
758
758
  else
759
759
  note " worktree tooling v${installed_wt}"
760
760
  fi
761
+ # The version is hand-maintained, so a shipped change that forgot to bump
762
+ # it would look current. Say so when the bytes differ but the numbers do not.
763
+ if [[ -n "$installed_wt" && "$installed_wt" == "$asset_wt" ]] \
764
+ && ! cmp -s "$wt_lib" "$ASSET_WORKTREE/_lib.sh"; then
765
+ note " .sassywares/worktree/_lib.sh matches v${installed_wt} but differs from the shipped copy — extended here, or the assets changed without a bump"
766
+ fi
761
767
  for helper in create list stop remove prune; do
762
768
  [[ -x "$ROOT/.sassywares/worktree/$helper" ]] \
763
769
  || bad "missing or not executable: .sassywares/worktree/$helper"
@@ -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 when the project configured ports. Never summarise the table away: how to see it is the point.
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 by port, so it works only for a project that configured `worktrees.ports`; for a simulator or a window it says so instead of pretending.
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