@sassywares/skills 0.12.0 → 0.13.0

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.
Files changed (39) hide show
  1. package/CONCEPTS.md +32 -19
  2. package/README.md +50 -43
  3. package/package.json +1 -1
  4. package/skills/sassy-goal/SKILL.md +5 -5
  5. package/skills/sassy-goal/references/close.md +4 -4
  6. package/skills/sassy-goal/references/goal-format.md +27 -4
  7. package/skills/sassy-goal/references/next.md +2 -1
  8. package/skills/sassy-goal/references/write.md +2 -2
  9. package/skills/sassy-lfg/SKILL.md +1 -1
  10. package/skills/sassy-overview/SKILL.md +2 -2
  11. package/skills/sassy-overview/references/identify.md +1 -1
  12. package/skills/sassy-plan/SKILL.md +5 -5
  13. package/skills/sassy-plan/references/plan-format.md +34 -6
  14. package/skills/sassy-setup/SKILL.md +6 -6
  15. package/skills/sassy-setup/assets/templates/worktrees-create +52 -0
  16. package/skills/sassy-setup/assets/templates/worktrees-remove +51 -0
  17. package/skills/sassy-setup/assets/worktree/_lib.sh +22 -55
  18. package/skills/sassy-setup/assets/worktree/create +21 -28
  19. package/skills/sassy-setup/assets/worktree/list +52 -11
  20. package/skills/sassy-setup/assets/worktree/remove +10 -83
  21. package/skills/sassy-setup/references/branching.md +9 -5
  22. package/skills/sassy-setup/references/check.md +23 -0
  23. package/skills/sassy-setup/references/config.md +68 -107
  24. package/skills/sassy-setup/references/dogfood.md +3 -3
  25. package/skills/sassy-setup/references/init.md +18 -16
  26. package/skills/sassy-setup/references/scaffold-header.md +63 -0
  27. package/skills/sassy-setup/references/worktree.md +135 -86
  28. package/skills/sassy-setup/scripts/detect.sh +127 -51
  29. package/skills/sassy-setup/scripts/worktree-check.mjs +32 -1
  30. package/skills/sassy-ship/SKILL.md +1 -1
  31. package/skills/sassy-work/SKILL.md +1 -1
  32. package/skills/sassy-worktree/SKILL.md +9 -12
  33. package/skills/sassy-worktree/references/create.md +10 -3
  34. package/skills/sassy-worktree/references/list.md +4 -2
  35. package/skills/sassy-worktree/references/remove.md +30 -6
  36. package/skills/sassy-setup/assets/lifecycle/down +0 -29
  37. package/skills/sassy-setup/assets/lifecycle/up +0 -34
  38. package/skills/sassy-setup/assets/worktree/prune +0 -93
  39. package/skills/sassy-worktree/references/prune.md +0 -13
@@ -2,12 +2,9 @@
2
2
  # Remove a worktree, after proving nothing would be lost.
3
3
  #
4
4
  # Refuses: the main checkout, a dirty tree, and commits that are on no remote.
5
- # A configured top-level `down:` runs before the folder goes and before any hook is
6
- # dispatched; a declared `hooks.worktree.before_remove` needs the caller to dispatch
7
- # it first — the script cannot dispatch a skill, so it fails closed until the caller
8
- # says the hook has been dispatched.
5
+ # Only the checkout goes — the branch survives, so the work stays reachable.
9
6
  #
10
- # Usage: .sassywares/worktree/remove <slug|branch> [--hook-ok] [--force]
7
+ # Usage: .sassywares/worktree/remove <slug|branch> [--force]
11
8
  # .sassywares/worktree/remove --version
12
9
  set -euo pipefail
13
10
 
@@ -17,27 +14,22 @@ source "$SCRIPT_DIR/_lib.sh"
17
14
 
18
15
  usage() {
19
16
  cat <<'EOF'
20
- Usage: .sassywares/worktree/remove <slug|branch> [--hook-ok] [--force]
17
+ Usage: .sassywares/worktree/remove <slug|branch> [--force]
21
18
 
22
- --hook-ok the project's hooks.worktree.before_remove — or a `down:` that names
23
- a skill — has already been dispatched; required when one is declared
24
- (exit 3 otherwise)
25
19
  --force skip the dirty-tree and unpushed-commit refusals. Never skips the
26
- main checkout or the hook handshake.
20
+ main checkout.
27
21
  EOF
28
22
  }
29
23
 
30
24
  target=""
31
- hook_ok=0
32
25
  force=0
33
26
  while [ $# -gt 0 ]; do
34
27
  case "$1" in
35
28
  -h|--help) usage; exit 0 ;;
36
29
  --version) printf '%s\n' "$WT_VERSION"; exit 0 ;;
37
- --hook-ok) hook_ok=1 ;;
38
30
  --force) force=1 ;;
39
- -*) die "unknown flag: $1 (try --help)" ;;
40
- *) [ -z "$target" ] || die "one worktree at a time"; target="$1" ;;
31
+ -*) usage >&2; exit 2 ;;
32
+ *) [ -z "$target" ] || { usage >&2; exit 2; }; target="$1" ;;
41
33
  esac
42
34
  shift
43
35
  done
@@ -47,13 +39,12 @@ need_git
47
39
  rec="$(wt_require "$target")" || exit 1
48
40
  path="${rec%%$'\t'*}"
49
41
  branch="${rec##*$'\t'}"
50
- slug="$(wt_slug "$branch")"
51
42
 
52
43
  wt_is_main "$path" && die "that is the main checkout — it cannot be removed"
53
44
  wt_managed "$path" || die "'$target' is not managed here — it is outside the worktree home, or it was cut before the wiring"
54
45
 
55
- # Refuse before tearing anything down: a checkout we would not delete should not
56
- # have had its stack stopped on the way to that refusal.
46
+ # Refuse before touching anything: a checkout we would not delete should not be
47
+ # half-removed on the way to that refusal.
57
48
  if [ "$force" -eq 0 ]; then
58
49
  wt_dirty "$path" && die "not clean — $(git -C "$path" status --porcelain | wc -l | tr -d ' ') path(s) modified. Commit, discard, or --force."
59
50
  n="$(wt_unpushed "$path")"
@@ -64,70 +55,6 @@ if [ "$force" -eq 0 ]; then
64
55
  esac
65
56
  fi
66
57
 
67
- # The project's own stop step, resolved first and run before anything is
68
- # dispatched: a `before_remove` drops the environment, so the app has to be
69
- # stopped while that environment still exists, and a failing `down` aborts before
70
- # the teardown starts. A value naming a script or a command runs here; anything
71
- # else is a skill, which a shell script cannot dispatch, so it joins the exit-3
72
- # handshake below. `wt_resolve` is the one reader for both halves of the pair.
73
- down="$(wt_down)"
74
- IFS=$'\t' read -r how dcmd dargs <<<"$(wt_resolve "$down" "$path")"
75
-
76
- case "$how" in
77
- none) ;;
78
- missing)
79
- die "down: '$down' is path-shaped but not executable in $path — fix the down: key, or make that file executable" ;;
80
- run)
81
- # On the --hook-ok re-run this is the continuation of the same removal, and a
82
- # successful first run already stopped the stack: do not run it twice.
83
- if [ "$hook_ok" -eq 0 ]; then
84
- ok down "$down"
85
- # Its arguments are command words, not patterns: disable globbing so
86
- # `down: ./bin/stop tmp/*.pid` stops the pid file the project meant instead of
87
- # every match in the checkout.
88
- set -f
89
- if ( cd "$path" && WT_PATH="$path" WT_BRANCH="$branch" WT_SLUG="$slug" WT_NAMESPACE="$(wt_namespace "$slug")" $dcmd $dargs ); then
90
- :
91
- else
92
- status=$?
93
- if [ "$status" -eq 78 ]; then
94
- warn unimplemented "down: $down is the generated stub (exit 78) — implement it, or delete the down: key if nothing needs stopping; removing anyway"
95
- else
96
- set +f
97
- die "down failed: $down"
98
- fi
99
- fi
100
- set +f
101
- fi
102
- down="" # it ran (or is skipped as already run): no obligation remains
103
- ;;
104
- skill) ;;
105
- esac
106
-
107
- # One handshake lists everything still owed — a `down:` naming a skill, and/or
108
- # every declared `before_remove` hook — so the caller dispatches once and re-runs
109
- # once instead of discovering a second obligation after the first.
110
- hooks="$(wt_hook before_remove "$branch")"
111
- if [ "$hook_ok" -eq 0 ]; then
112
- action=""
113
- if [ -n "$down" ]; then
114
- log "require-hook $down"
115
- action="run down ($down)"
116
- fi
117
- if [ -n "$hooks" ]; then
118
- while IFS= read -r n; do
119
- [ -n "$n" ] || continue
120
- log "require-hook $n"
121
- done <<<"$hooks"
122
- action="${action:+$action and }dispatch it"
123
- fi
124
- [ -z "$action" ] || require_dispatch "$action, then re-run with --hook-ok"
125
- fi
126
-
127
- if [ -n "$down" ]; then
128
- ok down "$down (dispatched)"
129
- fi
130
-
131
58
  if [ "$force" -eq 1 ]; then
132
59
  removed_ok=0
133
60
  git worktree remove --force "$path" && removed_ok=1
@@ -141,5 +68,5 @@ if [ "$removed_ok" -eq 0 ]; then
141
68
  printf ' %s\n' "(\`git worktree prune\` only matters if \`git worktree list\` still names it)" >&2
142
69
  exit 1
143
70
  fi
144
- ok removed "$path"
145
- ok branch "$branch — the branch stays, so the work is still reachable"
71
+ ok removed "$path" >&2
72
+ ok branch "$branch — the branch stays, so the work is still reachable" >&2
@@ -69,9 +69,13 @@ ask at step 6, never a token of its own. There is no `worktree:ask`.
69
69
  exactly that. Name the count, the branch, and the choice.
70
70
  3. Name it `<type>/<slug>` from the plan path or the topic, deterministically,
71
71
  so a retried run converges on the same name instead of forking `-2`. The slug
72
- is the plan's path relative to `artifacts.plans`, without `.md`: a standalone
73
- plan stays `feat/<slug>`, and a goal slice nests as `<type>/<goal>/<NN-slice>`
74
- (`feat/powersync/02-offline-reads`). A `feat/*`-style `base_map` or
72
+ is the plan's path relative to `artifacts.plans`, without `.md`, and without a
73
+ standalone plan's `<type>-` filename prefix: `feat-worktree-cut.md` names
74
+ `feat/worktree-cut`. A goal slice nests as `<type>/<goal>/<NN-slice>`, where
75
+ `<goal>` is the goal's folder minus its `<type>-` prefix (`feat-powersync/`
76
+ names `feat/powersync/02-offline-reads`), and `<type>` comes from the slice
77
+ plan's frontmatter because its `NN-<slice-slug>.md` filename carries none. A
78
+ `feat/*`-style `base_map` or
75
79
  `hooks.pr` family still matches the nested name by prefix.
76
80
  4. Re-run with `--name <name>` and take `pr-base` from that answer: a name like
77
81
  `release/1.2` or `hotfix/x` matches a `base_map` family and retargets the PR,
@@ -83,8 +87,8 @@ ask at step 6, never a token of its own. There is no `worktree:ask`.
83
87
  `worktrees.enabled: true` (per `worktree.md`) means this project *allows* a
84
88
  checkout. It is permission, not a default: two runs only collide when they are
85
89
  actually parallel, so guessing wrong moves the work to another directory,
86
- leaves the uncommitted tree behind, and spends the `after_create` setup on a
87
- checkout nobody needed. Ask once, here, with the branch named — *this
90
+ leaves the uncommitted tree behind, and spends the project's create-script setup
91
+ on a checkout nobody needed. Ask once, here, with the branch named — *this
88
92
  checkout, or a worktree of its own?* — and take the answer, **unless the
89
93
  caller forwarded a `worktree:` token**, which is the user answering before
90
94
  being asked. Silence is not a yes, and never ask when the answer cannot
@@ -13,3 +13,26 @@ A check run never edits the config, never installs a skill or an agent, never re
13
13
  |------|-------------|
14
14
  | Check reports, init repairs | Every finding is reported with `mode:init` as its fix. Nothing is corrected in place, approved or not. |
15
15
  | No detection | A check compares the file to the tree; it never re-derives the config from the tree and calls the difference drift. |
16
+
17
+ ## What a worktree finding means
18
+
19
+ `worktrees.create` and `worktrees.remove` are the project's own files, so a check
20
+ never hashes them and never treats them as suite-owned. Five outcomes:
21
+
22
+ - **Declared and executable** — a note naming the path. Nothing to do.
23
+ - **Declared but missing or not executable** — a note, never drift:
24
+ `worktrees.create 'scripts/worktrees/create' is missing or not executable — the built-in .sassywares/worktree/create is used instead`. Report it so the user can restore the file or drop the key.
25
+ - **A wrong shape** — whitespace, an absolute or `~/` path, `..`, a list, or a
26
+ block — is drift: `--check` names the key and the value, and the fix is one
27
+ relative path with no arguments.
28
+ - **No `sassywares:scaffold` header** — a note naming the file: it carries no
29
+ header, so the run cannot tell whether it prints the `WT_*` block. Provenance,
30
+ never drift.
31
+ - **A legacy key** — `up:`, `down:`, or `hooks.worktree` — a `drift:` line that
32
+ names the key, says the lifecycle moved into the project's create/remove
33
+ scripts, and gives the exact edit (delete the `up:`/`down:` line, or the
34
+ `worktree:` block under `hooks`). The fix is `mode:init` and only when the user
35
+ asks for it; a check never deletes the key itself.
36
+
37
+ A scaffold header's `version=` is provenance, not a pin, so an old scaffold
38
+ version is never drift — [`scaffold-header.md`](scaffold-header.md).
@@ -85,26 +85,21 @@ hooks:
85
85
  push:
86
86
  "*":
87
87
  after_push: [] # commit.branch: current only
88
- # worktree: # worktrees only; keyed by the checkout's branch
89
- # "*":
90
- # after_create: [] # derive .env, seed, copy the session
91
- # before_remove: [] # drop the database, shut the device
92
88
  worktrees:
93
89
  enabled: false # true = a run may offer its own checkout
94
90
  dir: ~/.sassywares/worktrees # parent of the per-repo folder; ~ is allowed here
91
+ create: scripts/worktrees/create # this project's prepare step; absent = built-in
92
+ remove: scripts/worktrees/remove # this project's teardown; absent = built-in
95
93
  dogfood:
96
94
  enabled: false # true = sassy-plan writes Mode: Auto QA rows
97
95
  recipe: .sassywares/dogfood/recipe.md # the procedure
98
96
  reports: .sassywares/dogfood/reports # run output, never committed
99
97
  timeout: 900 # whole procedure, seconds
100
- # top level, not under worktrees: how this project's stack starts and stops
101
- up: just dev # <script> <args…> | <skill> <args…>; absent = no lifecycle
102
- down: just down
103
98
  ```
104
99
 
105
100
  | Key | Default | Meaning |
106
101
  |-----|---------|---------|
107
- | `artifacts.plans` | `docs/plans` | Where `sassy-plan` writes plans, and where `sassy-goal` keeps goal folders (`<slug>/goal.md` plus slice plans) |
102
+ | `artifacts.plans` | `docs/plans` | Where `sassy-plan` writes plans, and where `sassy-goal` keeps goal folders (`<type>-<slug>/goal.md` plus slice plans) |
108
103
  | `artifacts.solutions` | `docs/solutions` | Where `sassy-compound` writes learnings |
109
104
  | `artifacts.handbooks` | `docs/handbooks` | Where `sassy-handbook` writes handbooks |
110
105
  | `artifacts.concepts` | `CONCEPTS.md` | The glossary file compound maintains |
@@ -123,17 +118,16 @@ down: just down
123
118
  | `hooks.goal.<slug>.before_slice` | `[]` | Project steps as `sassy-goal mode:next` picks a slice, keyed by goal slug (see Goal hooks) |
124
119
  | `hooks.goal.<slug>.after_close` | `[]` | Project steps as `sassy-goal mode:close` persists the status, keyed by goal slug |
125
120
  | `hooks.push.<pattern>.after_push` | `[]` | Project steps after a push, keyed by the pushed branch (see Hooks) |
126
- | `hooks.worktree.<pattern>.<point>` | `[]` | Project steps across a checkout's life, keyed by the head branch it holds |
127
121
  | `dogfood.enabled` | `false` | `true` lets a plan write automated QA rows. Absent means `false` — manual QA, today's behavior |
128
122
  | `dogfood.recipe` | `.sassywares/dogfood/recipe.md` | The stored procedure `sassy-dogfood` executes. Its `Prove it:` step is the verdict |
129
123
  | `dogfood.reports` | `.sassywares/dogfood/reports` | Where a run writes its summary, step logs, and artifacts. Must be gitignored |
130
124
  | `dogfood.timeout` | `900` | Wall-clock for one run. A timeout is a failure, never a hang |
131
125
  | `worktrees.enabled` | `false` | `true` lets a run *offer* its own checkout; it asks, or takes one on a `worktree:on` token, and works in this checkout on `worktree:off`. Needs `commit.branch: new` |
132
126
  | `worktrees.dir` | `~/.sassywares/worktrees` | Parent of the per-repo worktree folder. The one path here that may be absolute or `~/` |
133
- | `up` | absent | How this project's stack starts: one `<script> <args…>` or `<skill> <args…>`, run in the foreground from inside a checkout. Absent means no lifecycle |
134
- | `down` | absent | How it stops: the same form. `remove` runs it before deleting a checkout. Absent means nothing to stop |
127
+ | `worktrees.create` | absent | The project's own prepare step: one executable path, no arguments. Absent uses the built-in `.sassywares/worktree/create` silently; a declared file that is missing or not executable falls back to it with a warning naming the key and the file |
128
+ | `worktrees.remove` | absent | The project's own teardown step: one executable path, no arguments. Same silent built-in for an absent key, same warning for a declared file that is missing or not executable |
135
129
 
136
- Paths are relative to the config's own directory, never to the cwd. Two exceptions: `worktrees.dir` may be absolute or start with `~/`, and a relative `up`/`down` path resolves against the checkout being started or stopped, not this file's directory.
130
+ Paths are relative to the project root — the folder holding `.sassywares/` — never to the cwd. `worktrees.dir` is the one exception: it may be absolute or start with `~/`, because it names machine-local state, not something a teammate clones. `worktrees.create` and `worktrees.remove` are relative paths and must name executable files.
137
131
 
138
132
  ## `git.repo` — the three topologies
139
133
 
@@ -332,15 +326,10 @@ targets. `hooks.pr.staging` means *PRs whose source is staging*. The exception i
332
326
  | `before_merge` | `sassy-babysit` | the PR looks ready **and** this run will merge it |
333
327
  | `after_merge` | `sassy-babysit` | this run observed the PR merged |
334
328
  | `hooks.push.after_push` | `sassy-ship` | right after a successful push under `commit.branch: current` |
335
- | `hooks.worktree.after_create` | `sassy-worktree` | just after a checkout exists, before anyone works in it |
336
- | `hooks.worktree.before_remove` | `sassy-worktree` | before the checkout is deleted — drop its database, shut its device |
337
329
  | `hooks.goal.before_slice` | `sassy-goal` | mode:next, once the slice is picked and the previous one's merge is confirmed, before the base check |
338
330
  | `hooks.goal.after_close` | `sassy-goal` | mode:close, once the goal status is persisted |
339
331
 
340
- `hooks.worktree` has the same shape and resolution as the other two kinds, keyed
341
- by the head branch the checkout holds. It needs `worktrees.enabled`; a shell
342
- script cannot dispatch a skill, so `.sassywares/worktree/remove` fails closed (exit `3`,
343
- `require-hook <name>`) until the caller has run it.
332
+ **The worktree points are gone.** `hooks.worktree` is a named error in `--check`: what a checkout prepares and disposes now lives in `worktrees.create`/`worktrees.remove` (see Lifecycle), so a shell script no longer dispatches a skill and there is no handshake to solve. Move an `after_create` step into the create script's after-the-checkout slot and a `before_remove` step into the remove script's stop slot.
344
333
 
345
334
  `hooks.push` has the same shape and resolution as `hooks.pr`, but its key is the
346
335
  pushed head branch and its only point is `after_push`. It runs only under
@@ -394,10 +383,9 @@ in review, and commented when it is deliberate.
394
383
 
395
384
  ### Goal hooks
396
385
 
397
- `hooks.goal` keys on the **goal slug** — the goal's folder under
398
- `artifacts.plans` — and resolves exactly like `hooks.pr`: exact slug, the
399
- longest matching family, then `"*"`. Its two points are in the table above;
400
- `sassy-goal` owns both.
386
+ `hooks.goal` keys on the **goal folder's name**, the `<type>-<slug>` folder under `artifacts.plans`, prefix included (`hooks.goal.feat-powersync`; the slug alone is the part after the `<type>-`), and resolves exactly like `hooks.pr`: exact slug, the longest matching family, then `"*"`. Its two points are in the table above; `sassy-goal` owns both.
387
+
388
+ A goal folder renamed to the `<type>-<slug>/` shape takes its `hooks.goal` keys with it: existing folders keep working under their old key until renamed.
401
389
 
402
390
  - **Early stop**: neither fires when that mode stops early — an unmerged PR,
403
391
  nothing eligible, or a failed persist. A stale base does not stop
@@ -412,8 +400,8 @@ longest matching family, then `"*"`. Its two points are in the table above;
412
400
  unpushed on a base is a stop, not a slice's starting point. Entries must be
413
401
  idempotent: a resumed `mode:next` re-fires `before_slice`, and a close-out
414
402
  can be re-run.
415
- - **Both outcomes**: `after_close` fires for `**Status:** Done` and for a goal
416
- left `Active` because a gap went to a new slice. The brief carries
403
+ - **Both outcomes**: `after_close` fires for `status: done` and for a goal
404
+ left `active` because a gap went to a new slice. The brief carries
417
405
  `goal_status` so the hook can tell them apart.
418
406
  - **Not PR-keyed**: `commit.branch: current` does not suppress these, so the
419
407
  `pr.*`, babysit, and merge rules that ignore `hooks.pr` under `current` do not
@@ -453,81 +441,51 @@ partial failures explicitly. Never collapse it into one status.
453
441
  fan-out means one `sassy-babysit` run per PR; merging a fan-out needs an explicit
454
442
  per-PR say-so, because one switch would merge N PRs nobody re-read.
455
443
 
456
- ## Lifecycle — `up` and `down`
444
+ ## Lifecycle — `worktrees.create` and `worktrees.remove`
457
445
 
458
- How this project's stack starts and stops. Two **top-level** keys, each naming
459
- exactly one thing:
446
+ The project owns what a checkout needs beyond git. Two keys point at two scripts
447
+ the project writes once:
460
448
 
461
449
  ```yaml
462
- up: just dev
450
+ worktrees:
451
+ create: scripts/worktrees/create
452
+ remove: scripts/worktrees/remove
463
453
  ```
464
454
 
465
- That is the whole declaration: `up` is the command word `just` and the argument
466
- `dev`. A value is split on whitespace, one argument per word, with no quote
467
- processing — `down: ./bin/down "two words"` arrives as three arguments, quotes
468
- included. The first word is the script or the skill; the rest are that thing's
469
- own arguments. A script is a relative path, an absolute path, or a word on
470
- `PATH`.
471
-
472
- **Absent means no lifecycle.** Nothing is inferred and nothing is invented:
473
- with no `up`, no run starts anything; with no `down`, `remove` deletes the
474
- checkout and says nothing was stopped. There is no default command, and no
475
- falling back to a `Makefile` target or a `package.json` script — a project that
476
- has one and wants it used says so in the key.
477
-
478
- **`up` runs in the foreground.** It owns the terminal until it is stopped with
479
- SIGTERM, and it must reap its children before it exits. A detached or daemonizing
480
- `up` is wrong here: the app outlives the call, nobody can ask it to stop, and the
481
- process holds the checkout — which is exactly what `down` then cannot kill.
482
- `down` must terminate whatever `up` started and exit once it has.
483
-
484
- **`down` runs before the checkout goes.** `remove` resolves the key after its
485
- guards pass and before deleting anything, so a failing `down` aborts the removal
486
- and a dirty checkout is never stopped on the way to a refusal. The `--hook-ok`
487
- re-run does not run `down` again: it continues the same removal, and a successful
488
- first run already stopped the stack.
489
-
490
- **A generated stub exits `78`.** That status means unimplemented, not a failure:
491
- `remove` warns loudly, names the `down:` key, and removes the checkout anyway,
492
- because a stub cannot be holding anything. Any other non-zero status still aborts
493
- the removal. A bare word that is not path-shaped may name a skill; a path-shaped
494
- value with no executable behind it is a mistake, and `remove` refuses with the
495
- value and the checkout in the message.
496
-
497
- **A skill is a value too, and a shell script cannot dispatch it.** When `down:`
498
- names a skill rather than a script, `remove` prints `require-hook <name>` and
499
- exits `3`; the agent runs that skill and re-runs with `--hook-ok`. That is the
500
- same handshake `hooks.worktree` uses — one mechanism, not two. Args after a skill
501
- name are the skill's own vocabulary, exactly like a hook entry.
502
-
503
- **The `WT_*` block is the checkout's identity.** Whoever runs the pair exports
504
- `WT_PATH`, `WT_BRANCH`, `WT_SLUG`, and `WT_NAMESPACE`; `remove` does it for
505
- `down`, and a caller that starts a stack does it for `up`. `create --env` prints
506
- the four assignments, which need exporting to reach a child process:
507
-
508
- ```bash
509
- set -a; eval "$(.sassywares/worktree/create <branch> --env)"; set +a
510
- bin/up
455
+ **One path, no arguments.** A value is relative to the project root — the folder
456
+ holding `.sassywares/` — must name an executable file, and is run bare: anything
457
+ it needs comes from its own arguments (`<branch> [--from <ref>]` for create,
458
+ `<slug|branch> [--force]` for remove) or from the checkout itself. A command line in the key would define a
459
+ second place the lifecycle lives, so `--check` fails a value with whitespace, an
460
+ absolute path, a path that walks outside the project, a list, or a block — one
461
+ path is the whole shape.
462
+
463
+ **Absent falls back silently; a declared value that is unusable warns.** With no
464
+ `create:`/`remove:` key, a run executes the built-in
465
+ `.sassywares/worktree/create|remove` and says nothing — a project that deleted the
466
+ pair means it. A key that declares a file that is missing or not executable, or a
467
+ value with whitespace or arguments, an absolute or `~/` path, `..`, a list, or a
468
+ block, falls back to the same built-in and warns on stderr naming the key and the
469
+ file:
470
+
471
+ ```text
472
+ warning: worktrees.create names 'scripts/worktrees/create' but /…/scripts/worktrees/create is missing or not executable — using the built-in .sassywares/worktree/create
511
473
  ```
512
474
 
513
- `WT_SLUG` is the branch made filesystem-safe and `WT_NAMESPACE` is the derived
514
- name for a database, a compose project, or a device — derive from them, never
515
- build a name by hand.
475
+ That is the git-only baseline: the checkout is cut or deleted and nothing is
476
+ prepared or disposed. A declared-but-unusable key is never a silent success — the
477
+ warning is the point — and a create that exits 0 without the `WT_*` lines is
478
+ reported as "checkout is real but unprepared".
516
479
 
517
- **Ports are the project's business.** The suite carries no port range and never
518
- derives one, so two checkouts running the same app will collide on the same
519
- fixed port unless the project's own `up` keeps them apart. Derive it there from
520
- the slug — a hash, because nothing here tracks claims, so a collision is possible
521
- and the script is where it surfaces:
480
+ **The scripts are the entry point.** `sassy-worktree` runs the project's pair; the
481
+ contract, the slots, and the scaffold are [`worktree.md`](worktree.md)'s and
482
+ [`scaffold-header.md`](scaffold-header.md)'s.
522
483
 
523
- ```bash
524
- PORT=$(( 3000 + $(printf '%s' "$WT_SLUG" | cksum | cut -d' ' -f1) % 100 ))
525
- ```
484
+ **Order is the script's.** Identity → stop → delete → dispose, and the slot that
485
+ holds each step, are in [`worktree.md`](worktree.md).
526
486
 
527
- Setup initializes the pair once and never touches it again: it points the keys at
528
- the command the project already declares, or writes the two stubs that exit `78`
529
- (see [`init.md`](init.md)). After that the keys and the scripts behind them are
530
- the project's.
487
+ **Legacy keys.** [`check.md`](check.md) reports them, and [`init.md`](init.md)
488
+ migrates them only when the user asks.
531
489
 
532
490
  ## Worktrees
533
491
 
@@ -538,23 +496,26 @@ namespace, so two runs never fight over a working tree.
538
496
  worktrees:
539
497
  enabled: true
540
498
  dir: ~/.sassywares/worktrees
499
+ create: scripts/worktrees/create
500
+ remove: scripts/worktrees/remove
541
501
  ```
542
502
 
543
- Two keys, no commands. The scripts in `.sassywares/worktree/` own the
544
- mechanics and `sassy-worktree` orchestrates them.
503
+ The scripts in `.sassywares/worktree/` own the git mechanics, the project's pair
504
+ owns everything else, and `sassy-worktree` runs the pair (see Lifecycle).
545
505
 
546
506
  **`enabled: true` is permission, not a default.** It makes a checkout available;
547
507
  `branching.md` still asks before a run takes one, unless the caller forwarded
548
508
  `worktree:`, and the run works in the main checkout until the answer is yes.
549
509
  Two runs only collide when they are actually parallel, and an unasked checkout
550
- relocates the work, leaves the uncommitted tree behind, and pays the setup hooks
510
+ relocates the work, leaves the uncommitted tree behind, and pays the setup step
551
511
  for a checkout nobody needed.
552
512
 
553
513
  **Putting a stack in a checkout is the project's business.** The suite carries no
554
- address and no port range, so the `up:`/`down:` pair is where a project
555
- decides how its stack comes up and, if it needs one, which port. `dir` is the one
556
- path in this file that may be absolute or start with `~/` — it names machine-local
557
- state, not something a teammate clones.
514
+ addresses, no ports, and no stack commands: how a checkout comes up, what it
515
+ installs, and what it disposes live in `create`/`remove`, and the scaffolding
516
+ slots are where a project writes them. `dir` is the one path in this file that may
517
+ be absolute or start with `~/` — it names machine-local state, not something a
518
+ teammate clones.
558
519
 
559
520
  **Two conditions.**
560
521
 
@@ -564,8 +525,9 @@ state, not something a teammate clones.
564
525
  - It needs the `repo` topology. A `workspace` root and a `none` folder have no
565
526
  git to cut a checkout from.
566
527
 
567
- The namespace, the two hooks, and every refusal are in
568
- [`worktree.md`](worktree.md).
528
+ The namespace, the four toolbox scripts, and every refusal are in
529
+ [`worktree.md`](worktree.md). The scaffold header both scripts carry is
530
+ [`scaffold-header.md`](scaffold-header.md).
569
531
 
570
532
  ## Dogfood
571
533
 
@@ -614,15 +576,14 @@ report layout, the verdict classes, and the lint are in
614
576
  - `git.remote` is required when `git.repo: workspace`; forbidden otherwise.
615
577
  `git.mirror_branch` and `repos` are workspace-only too.
616
578
  - `hooks` is allowed only with the four points under `hooks.pr`, `after_push`
617
- under `hooks.push`, `after_create`/`before_remove` under `hooks.worktree`, and
618
- `before_slice`/`after_close` under `hooks.goal`, each a list of skill names
619
- that resolve to `.agents/skills/<name>/SKILL.md`.
620
- - `up` and `down` are top-level single-line strings, each `<script> <args…>` or
621
- `<skill> <args…>`, naming exactly one thing. Never a block, a list, or a
622
- command chain (`&&`, `;`): the shell word after `down:` is resolved as one
623
- command, so a chain would be run as arguments to the first word. The value is
624
- split on whitespace, one argument per word, with no quote processing; quotes
625
- are passed through as ordinary characters.
579
+ under `hooks.push`, and `before_slice`/`after_close` under `hooks.goal`, each
580
+ a list of skill names that resolve to `.agents/skills/<name>/SKILL.md`.
581
+ `hooks.worktree` is gone and is reported as an error, never ignored.
582
+ - `worktrees.create` and `worktrees.remove` are one path each, relative to the
583
+ project root and naming an executable file. The drift and note outcomes are in
584
+ [`check.md`](check.md).
585
+ - `up`, `down`, and `hooks.worktree` are gone. `--check` reports each with the
586
+ exact line to delete, and the lifecycle now lives in the two script keys.
626
587
  - `worktrees.enabled` is `true` or `false`. A checkout must resolve outside the
627
588
  working tree and must not hold a branch `base_map` names as a base. An
628
589
  `enabled: true` with no tooling installed, or with the wrong tooling version,
@@ -152,7 +152,7 @@ value it needs has to resolve in both places.
152
152
  | Project | Preview line |
153
153
  |---|---|
154
154
  | Web | `the page the app serves — open it in a browser` |
155
- | Mobile | `simulator "$WT_NAMESPACE"` — booted by the `after_create` hook |
155
+ | Mobile | `simulator "$WT_NAMESPACE"` — booted by the project's `create` script |
156
156
  | Desktop | `the app window is already open` |
157
157
  | CLI | *(none — there is nothing to look at)* |
158
158
 
@@ -216,8 +216,8 @@ configured. Two things follow, and they are all this file says about it:
216
216
 
217
217
  A worktree gets a fresh, empty `session/`. When a project's provider registers a
218
218
  single callback URL, a second checkout usually cannot log in on its own, so the
219
- usual answer is to copy or link the main checkout's session in the
220
- `after_create` hook. Worth writing down, because a **cookie** is host-scoped and
219
+ usual answer is to copy or link the main checkout's session in the create script's
220
+ after-the-checkout slot. Worth writing down, because a **cookie** is host-scoped and
221
221
  crosses ports freely while a **`localStorage`** session is origin-scoped, port
222
222
  included, and has to be injected per origin — the difference looks like a broken
223
223
  transplant when it is only the wrong mechanism.
@@ -10,7 +10,7 @@ The path argument, else the working directory. `init` is the default mode; the m
10
10
 
11
11
  Run `scripts/detect.sh --root <path>`. It prints a proposed config: topology (`repo`, `workspace`, `none`), the remote name, a probed base branch, and nested repos with their bases.
12
12
 
13
- **A config that already exists is the proposal.** When `.sassywares/config.yaml` is found — an explicit `init` on a project that is already wired — the detector's output is only the starting point: take every value it **probes** (`git.repo`, `base_map`'s `"*"`, `repos`), and take every value it **emits as a default** from the existing file instead — the other `base_map` rungs, `hooks.*`, `worktrees.*`, `dogfood.*`, `pr.*`, `commit.branch`, `knowledge.*`, `artifacts.*`, and the top-level `up`/`down` pair. A default is not an answer: writing the blank slate here would retarget `"*"` away from the integration branch the project actually uses and delete its hooks. Present the result as a **diff against the file, key by key**, and ask before writing.
13
+ **A config that already exists is the proposal.** When `.sassywares/config.yaml` is found — an explicit `init` on a project that is already wired — the detector's output is only the starting point: take every value it **probes** (`git.repo`, `base_map`'s `"*"`, `repos`), and take every value it **emits as a default** from the existing file instead — the other `base_map` rungs, `hooks.*`, `worktrees.*`, `dogfood.*`, `pr.*`, `commit.branch`, `knowledge.*`, and `artifacts.*`. A default is not an answer: writing the blank slate here would retarget `"*"` away from the integration branch the project actually uses and delete its hooks. Present the result as a **diff against the file, key by key**, and ask before writing.
14
14
 
15
15
  ## 3. Ask only what detection cannot answer
16
16
 
@@ -24,25 +24,15 @@ Never re-ask what the tree already said.
24
24
  - **`commit.branch`** — default `new`: the run cuts a branch before the first change and never commits on a base branch. Offer `current` for a repo that genuinely wants work committed where it stands, and say plainly that `current` lets a run commit onto its base branch and push it, with no PR (`pr.*` and `hooks.pr` are ignored; `hooks.push` runs), and that a later `sassy-ship` run in `mode:auto` will then push to that base with no gate.
25
25
  - **`pr.*`** — default `babysit: true`, `merge: false`, `delete_branch: false`. Say plainly that `merge: true` authorizes merging every babysat PR in this project without asking.
26
26
  - **Hooks** — offer, do not impose. Ask whether the project wants steps injected at `before_create`, `after_create`, `before_merge`, or `after_merge` (or `hooks.push` `after_push`, for `commit.branch: current` only), and under which head branch (`"*"` for all). Also offer goal hooks — `before_slice` and `after_close` under `hooks.goal`, keyed by the goal slug — as base refresh, environment preparation, and boundary announcements that never touch the goal itself and leave every base level with its remote. Entries may carry args (`<skill> <args…>`); a hook skill's args are its own vocabulary. Leave them `[]` when there is nothing to add. **Never write a hook skill yourself** — hooks are project skills, and copying one of ours into that role is the fork this mechanism exists to prevent.
27
- - **Worktrees** — ask whether the project wants parallel work in this repo: a checkout per branch, each with its own derived namespace, so two runs never fight over one working tree. Say plainly what it costs and what it needs. `false` — the run works here, which is today's behaviour. `true` — a run may *offer* a checkout and takes one only on your yes, or outright when the run carries a `worktree:on` token, and `sassy-worktree` gains `create`, `list`, `remove`, and `prune`. It needs `commit.branch: new`: under `current` nothing ever cuts a branch, so the switch would do nothing — say so and leave it `false` rather than writing a setting that cannot fire. In `workspace` or `none` topology, say it is not available and write `false`. Read `references/worktree.md`. **Say what a checkout will need for this project** — install, `.env` derivation, a per-namespace database, a simulator, the session — and offer to create the hook with `sassy-skill`; **never write its body yourself**. With no hook, say plainly that every new checkout starts empty.
27
+ - **Worktrees** — ask whether the project wants parallel work in this repo: a checkout per branch, each with its own derived namespace, so two runs never fight over one working tree. Say plainly what it costs and what it needs. `false` — the run works here, which is today's behaviour. `true` — a run may *offer* a checkout and takes one only on your yes, or outright when the run carries a `worktree:on` token, and `sassy-worktree` gains `create`, `list`, and `remove`. It needs `commit.branch: new`: under `current` nothing ever cuts a branch, so the switch would do nothing — say so and leave it `false` rather than writing a setting that cannot fire. In `workspace` or `none` topology, say it is not available and write `false`. Read `references/worktree.md`. **Ask what a checkout will need for this project** and carry each confirmed need into step 6's interview, which owns the pattern menu and writes it as a labelled comment in the project's own scripts. Never a hook skill, and never a body setup writes.
28
28
  - **Dogfood** — ask whether the project wants agent QA: a stored procedure that proves a change works in the running product, which then lets `sassy-plan` write `Mode: Auto` QA rows instead of manual ones. Say plainly what each answer means. `false` — every QA row stays a human's, which is today's behavior. `true` — a plan may write Auto rows, but only for a recipe section that carries a `Prove it:` step, so the switch alone never makes a gate prove something. Write the answer explicitly either way; never leave it to inference. On yes, scaffold per step 4 and offer to run the first `sassy-dogfood mode:discover` before this run ends: yes means do it now (it is the only step that knows how to bring this app up), no means hand over the command and say the recipe stays a skeleton until it runs. Read `references/dogfood.md` and **never** write a command into the block or author the procedure: the recipe is the project's, and its first real content comes from a `sassy-dogfood mode:discover` run.
29
- - **Lifecycle** — how this project's stack starts and stops: the top-level `up:` and `down:` keys. Probe before asking — run `bash <sassy-overview skill>/scripts/identify.sh --root <path> up down` and read its `key<TAB>value<TAB>source` lines; exit `0` means the project already declares both, exit `3` means at least one is `unknown`. Two outcomes, each an offer, never an imposition:
30
- - **It answers** — a `dev`/`start`/`up`/`serve` target in a `Makefile` or `justfile`, or a compose file. When identify reports both `unknown` but an executable `dev` exists at the probed path (`bin/`, then `tool/`, then `scripts/`), that is an answer too: `up: bin/dev`. Offer each key on its own, pointing at **exactly** what was found — `up: just dev`, `down: just down`, `up: bin/dev` — naming the source identify reported or the script you found. On yes, write the keys and **write no file**: the command exists, and a copy in a downloaded script would drift from it. A key with no answer stays absent rather than becoming a guess.
31
- - **It does not** — identify left the key `unknown` and nothing else declares it, so there is nothing to point at. Offer the stubs for whichever keys are still unanswered: the two files from `assets/lifecycle/`, copied to the first of `bin/`, `tool/`, `scripts/` that exists (or a new `bin/` when none does), and set `up: <dir>/up`, `down: <dir>/down`.
32
-
33
- Declining both leaves the keys absent, which is **no lifecycle** — say it plainly and never invent a command. A file already sitting at either stub path is shown and asked about, never overwritten.
34
-
35
29
  ## 4. Write the config
36
30
 
37
31
  Build the file from the proposal plus the answers. It is written **fully commented**: every key keeps a description and its allowed values, exactly as the detector emits them. Never strip those comments to save lines — for a teammate opening the file, the comments are the documentation. If a config already exists, show what changes and ask before writing — never silently overwrite. Keep every key; an unset key falls back to its documented default, so a short file is legal when nothing deviates.
38
32
 
39
33
  **The dogfood scaffold, only when the answer was yes.** Create `.sassywares/dogfood/` holding `recipe.md` copied verbatim from `assets/dogfood-recipe.md`, and `.sassywares/.gitignore` with two lines — `/session/` and `/dogfood/reports/` — adding them to a `.gitignore` that already exists rather than replacing it. Never overwrite an existing recipe — show it and ask. The skeleton is deliberately incomplete: it carries the shape and the rules and fills in nothing, because `sassy-dogfood mode:discover` writes the procedure from what actually worked. Say so in the report — `enabled: true` is a permission, not a promise that a check exists.
40
34
 
41
- **The lifecycle pair, when step 3 accepted one.** Write `up:` and `down:` as two top-level keys, each naming one thing: the project's own declared command (`up: just dev`), or the two stub paths. They sit at the top level, never under `worktrees:`. The shape and the contract are `references/config.md`'s Lifecycle section.
42
-
43
- When there was no answer and the user accepted the stubs, copy `assets/lifecycle/up` and `assets/lifecycle/down` to `<dir>/up` and `<dir>/down` and make them executable; do not write a longer body. Their headers carry the contract, and both exit `78` while unimplemented — `remove` treats that as a warning and removes anyway, while any other non-zero status aborts.
44
-
45
- **From then on they are the project's.** Setup writes the pair once; no later run edits the keys or the stub bodies, and `check` reports an absent pair as **no lifecycle** instead of proposing one. Say in the report which two values the keys name, or that the project declares no lifecycle.
35
+ **The worktree keys and scripts are written in step 6**, once the pair exists. Nothing here writes them.
46
36
 
47
37
  ## 5. Wire the skills and the agents
48
38
 
@@ -80,9 +70,21 @@ Both install the same way: report the scope if the pieces are present, otherwise
80
70
 
81
71
  Two independent sets, each only when its answer was yes.
82
72
 
83
- - **Worktrees, `repo` topology and `worktrees.enabled: true`.** Copy every file in `assets/worktree/` flat into `.sassywares/worktree/` and make the four scripts executable. **That is the install.** They are run by path, so do not require a command runner and do not create or extend one to hold aliases: a `package.json` written into a Go, Python, or Dart project so four aliases have a home is a file the project did not ask for. When a file that already carries named commands exists (`package.json` `scripts`, `deno.json` `tasks`, `composer.json` `scripts`, a make/just target), **offer** the `worktree:<script>` aliases per `references/workspace.md`'s merge rules — append-only, proven to parse with that file's own tool, `git diff` added-lines only, restored from `HEAD` if not. Declining is a complete install. Name the scripts' path in the report either way — no version header: `--check` hashes the installed files against the copy this skill ships, not a version line. **Overwrite them without asking** when they already exist — the set is suite-owned and read-only, so a differing byte is drift for a re-run to replace, not a project edit to preserve. Read `references/worktree.md`. Do not create a worktree, and do not run a script: installing is the whole job, and the first `create` belongs to the user — a run asks, or takes one on `worktree:on`.
73
+ - **Worktrees, `repo` topology and `worktrees.enabled: true`.** Three jobs in order: the toolbox, the project's pair, and the keys that point at the pair.
74
+
75
+ **Probe `<home>`.** Take the first existing of `scripts/`, `bin/`, `tool/`, `tools/`; with none, use `tool/` for a dart/flutter stack and `scripts/` otherwise (`sassy-overview`'s `stack` breaks that tie — it is a tiebreak, not a new question). Show the choice and ask the user to confirm it: first match wins, and a wrong default is one edit.
76
+
77
+ **Install the toolbox.** Copy every file in `assets/worktree/` flat into `.sassywares/worktree/` and make the three scripts executable. **That is the install.** They are run by path, so do not require a command runner and do not create or extend one to hold aliases: a `package.json` written into a Go, Python, or Dart project so three aliases have a home is a file the project did not ask for. When a file that already carries named commands exists (`package.json` `scripts`, `deno.json` `tasks`, `composer.json` `scripts`, a make/just target), **offer** the `worktree:<script>` aliases per `references/workspace.md`'s merge rules — append-only, proven to parse with that file's own tool, `git diff` added-lines only, restored from `HEAD` if not. Declining is a complete install. Name the scripts' path in the report either way — no version header: `--check` hashes the installed files against the copy this skill ships, not a version line. **Overwrite them without asking** when they already exist — the set is suite-owned and read-only, so a differing byte is drift for a re-run to replace, not a project edit to preserve. Read `references/worktree.md`.
78
+
79
+ **Scaffold the project's pair — new files only.** Copy `assets/templates/worktrees-create` and `assets/templates/worktrees-remove` to `<home>/worktrees/create` and `<home>/worktrees/remove`, make both executable, and replace the header's `<version>` and `<YYYY-MM-DD>` with the write-time release and today's date, resolved as [`scaffold-header.md`](scaffold-header.md) says. An existing file is **never** overwritten, and a file the project deleted stays deleted: setting the keys again is the user's call, not a re-run's. The templates take exactly the toolbox's arguments and, untouched, behave exactly like calling the toolbox directly.
80
+
81
+ **Interview, then write inert stubs.** Ask what this project needs per worktree, and offer the patterns the overview/identify facts make plausible: a preview deployment, a per-worktree database, a compose namespace, a device or simulator, a derived `.env`. For each confirmed need, write one labelled comment in the right slot of the pair — pre-cut preparation in `create`'s before-the-checkout slot, post-cut preparation in its after-the-checkout slot, stopping in `remove`'s stop slot, disposal in its dispose slot. **A comment, never working code**: setup cannot verify a command it invents, so the body stays the suite call. Name the need specifically enough to act on ("drop the postgres database `$WT_NAMESPACE` created in create"), and change nothing else.
82
+
83
+ **Write the keys.** Set `worktrees.create: <home>/worktrees/create` and `worktrees.remove: <home>/worktrees/remove`, single paths relative to the project root — the folder holding `.sassywares/` — with no arguments.
84
+
85
+ Do not create a worktree, do not run either script, and do not start or stop anything: installing and scaffolding are the whole job, and the first `create` belongs to the user — a run asks, or takes one on `worktree:on`.
84
86
 
85
- What a life cycle does and does not do here: `create` runs a checkout's `hooks.worktree.after_create` and **never** `up`, because provisioning has to terminate and a running stack does not; `remove` runs the configured `down:` before it deletes, after its guards pass. Nothing in the suite starts a stack — that is the project's or the user's, run from the checkout with the `WT_*` block.
87
+ **Legacy keys, on request only.** `up:`, `down:`, and `hooks.worktree` were removed with the old lifecycle, and `--check` hard-errors on each with the exact edit. Never migrate on your own: a `mode:init` run the user asks for performs it — delete those keys, write the two new paths, and scaffold the pair as above.
86
88
  - **Workspace, `workspace` topology only.** The snapshot plus the `branches` / `pull` / `checkout-bases` git helpers, run by path. Aliases are an offer into a command file the root already has — never a `package.json` created for them. Read `references/workspace.md` and follow it.
87
89
 
88
90
  Then return to `SKILL.md` for steps 7–9.
@@ -99,4 +101,4 @@ Then return to `SKILL.md` for steps 7–9.
99
101
  | Dogfood is a pointer | The block names a recipe, a reports path, a timeout, and whether Auto rows are allowed — four keys. Never a command and never a tool: a copied command duplicates the manifest and cannot express step order. |
100
102
  | The recipe is the project's | Setup scaffolds the skeleton and stops. Authoring or "fixing" a procedure is `sassy-dogfood mode:discover`'s job, and a run may never edit the recipe to make its own failure pass. |
101
103
  | Worktrees need `new` | `worktrees.enabled: true` with `commit.branch: current` is refused, not written: nothing cuts a branch there, so the switch could never fire. |
102
- | The lifecycle is written once | `up`/`down` are initialized and then left alone: no re-run edits the keys or the stub bodies, and an absent pair is reported as **no lifecycle** rather than invented. |
104
+ | Stubs are inert | The interview writes labelled comments in the scaffolding slots, never executable code: an untouched pair behaves exactly like the git-only baseline. |