@sassywares/skills 0.12.1 → 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 (29) hide show
  1. package/CONCEPTS.md +28 -15
  2. package/README.md +41 -34
  3. package/package.json +1 -1
  4. package/skills/sassy-overview/SKILL.md +2 -2
  5. package/skills/sassy-overview/references/identify.md +1 -1
  6. package/skills/sassy-setup/SKILL.md +6 -6
  7. package/skills/sassy-setup/assets/templates/worktrees-create +52 -0
  8. package/skills/sassy-setup/assets/templates/worktrees-remove +51 -0
  9. package/skills/sassy-setup/assets/worktree/_lib.sh +22 -55
  10. package/skills/sassy-setup/assets/worktree/create +21 -28
  11. package/skills/sassy-setup/assets/worktree/list +52 -11
  12. package/skills/sassy-setup/assets/worktree/remove +10 -83
  13. package/skills/sassy-setup/references/branching.md +2 -2
  14. package/skills/sassy-setup/references/check.md +23 -0
  15. package/skills/sassy-setup/references/config.md +62 -100
  16. package/skills/sassy-setup/references/dogfood.md +3 -3
  17. package/skills/sassy-setup/references/init.md +18 -16
  18. package/skills/sassy-setup/references/scaffold-header.md +63 -0
  19. package/skills/sassy-setup/references/worktree.md +135 -86
  20. package/skills/sassy-setup/scripts/detect.sh +127 -51
  21. package/skills/sassy-setup/scripts/worktree-check.mjs +32 -1
  22. package/skills/sassy-worktree/SKILL.md +9 -12
  23. package/skills/sassy-worktree/references/create.md +10 -3
  24. package/skills/sassy-worktree/references/list.md +4 -2
  25. package/skills/sassy-worktree/references/remove.md +30 -6
  26. package/skills/sassy-setup/assets/lifecycle/down +0 -29
  27. package/skills/sassy-setup/assets/lifecycle/up +0 -34
  28. package/skills/sassy-setup/assets/worktree/prune +0 -93
  29. package/skills/sassy-worktree/references/prune.md +0 -13
@@ -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. |
@@ -0,0 +1,63 @@
1
+ # The scaffold header
2
+
3
+ One header, one owner. Every project-owned file the suite plants **outside**
4
+ `.sassywares/` — today the worktree `create`/`remove` pair, and any future script
5
+ or config setup writes — carries the line below. Files inside `.sassywares/` are
6
+ either suite-owned assets or carry their own H1.
7
+
8
+ A file the project already had never gets one. The worktree toolbox under
9
+ `.sassywares/worktree/` is copied, not scaffolded: it is suite-owned and carries
10
+ its own `worktree-version` line instead.
11
+
12
+ ## The bytes
13
+
14
+ ```text
15
+ # sassywares:scaffold v1 skill=<name> version=<version> date=<YYYY-MM-DD>
16
+ ```
17
+
18
+ `skill` is the suite skill that wrote it (`sassy-setup`), `date` is the day it was
19
+ written. After that line come a blank comment line and the prose block: the
20
+ file's contract — what it is called as, what it must exit with, what it must
21
+ print — and the statement that future setup runs leave it alone. The header is
22
+ part of the file; never move it below the contract.
23
+
24
+ ## What `version` means
25
+
26
+ The suite release that wrote the file **at write time**. Provenance, never a pin:
27
+
28
+ - never updated when the suite moves;
29
+ - never compared, by `--check` or by anything else;
30
+ - never drift, and never a reason to report the file as edited or stale.
31
+
32
+ The suite-owned toolbox is proven by a content hash; a scaffolded project file
33
+ has no hash at all, so an old version number there says nothing about its current
34
+ contents.
35
+
36
+ ## Resolving `<version>`
37
+
38
+ At write time, in this order:
39
+
40
+ 1. The suite's own release, when the install carries one — `version` in the
41
+ `@sassywares/skills` `package.json` beside the skill, or
42
+ `git describe --tags --abbrev=0` in a sassy-skills checkout.
43
+ 2. Otherwise the literal word `unknown`. Never guess a number and never leave the
44
+ field empty.
45
+
46
+ `skills-lock.json` cannot supply one. Its `version` is the lock format's era
47
+ (`1`, `2`, `3`) and each entry's `computedHash` is content, not a release, so a
48
+ project pinned that way still has no suite version to write down.
49
+
50
+ ## Upgrading a scaffold
51
+
52
+ Never rewrite it. A later setup run may **offer** to migrate a scaffold whose
53
+ template version has moved: show the header, the current template, and what the
54
+ project added. The answer is the user's, and migrating is editing their file with
55
+ their approval — not setup installing over it. Setup installs new files only, so a
56
+ scaffold the project deleted stays deleted until the user asks for it again.
57
+
58
+ ## Never on YAML frontmatter
59
+
60
+ A document that already starts with YAML frontmatter — a plan, a goal, a
61
+ solution, a handbook — never takes this header. The frontmatter is its metadata
62
+ and the first bytes belong to it; provenance there is `created`/`updated`, not a
63
+ comment.
@@ -16,16 +16,35 @@ cut a branch, or when the user asks to run two agents in one project.
16
16
  checkout — or takes one on a `worktree:on` token — and stays in the main one
17
17
  otherwise: two runs only collide when they are actually parallel, and one taken
18
18
  unasked moves the work to another directory, leaves the uncommitted tree behind,
19
- and spends the `after_create` setup on a checkout nobody needed. `branching.md`
20
- owns that ask. `sassy-worktree` runs after the answer is yes, or when a human
21
- asks for a checkout outright; an existing managed checkout for the branch is
22
- reused rather than a second one cut.
19
+ and spends the setup step on a checkout nobody needed. `branching.md` owns that
20
+ ask. `sassy-worktree` runs after the answer is yes, or when a human asks for a
21
+ checkout outright; an existing managed checkout for the branch is reused rather
22
+ than a second one cut.
23
+
24
+ ## The project's scripts are the entry point; the toolbox is git only
25
+
26
+ The suite ships four small scripts that create, list, and remove a checkout — the
27
+ git mechanics, project-agnostic and suite-owned. Everything a *particular*
28
+ project needs around that (installing dependencies, deriving an `.env`, seeding a
29
+ database, stopping a stack) belongs to that project's own pair:
30
+ `<home>/worktrees/create` and `<home>/worktrees/remove`, scaffolded by setup from
31
+ `assets/templates/`. `sassy-worktree` runs the project's scripts; those call the
32
+ toolbox when they need git. Neither the toolbox nor the suite knows how a project
33
+ starts or stops its stack.
34
+
35
+ The pair carries the scaffold header — write-time provenance and the statement
36
+ that the file belongs to the project — described once in
37
+ [`scaffold-header.md`](scaffold-header.md). Setup installs them new-files-only and
38
+ never rewrites them; an untouched pair behaves exactly like calling the toolbox
39
+ directly.
23
40
 
24
41
  ## Install
25
42
 
26
43
  Setup copies `assets/worktree/*` flat into `.sassywares/worktree/`, makes the
27
- four scripts executable, and stops. They are tracked: a worktree is a checkout of
28
- the repo, so every worktree carries the tooling.
44
+ three scripts executable, and stops. They are tracked: a worktree is a checkout of
45
+ the repo, so every worktree carries the tooling. Setup also scaffolds the
46
+ project's pair under `<home>/worktrees/`, probes `<home>`, and records both paths
47
+ as `worktrees.create` and `worktrees.remove` — [`init.md`](init.md) step 6.
29
48
 
30
49
  **No command runner is required and no manifest is created.** Every caller — the
31
50
  suite included — runs them by path, `.sassywares/worktree/create <branch>`. Setup
@@ -35,21 +54,25 @@ nothing else.
35
54
 
36
55
  | Script | Does | Ends with |
37
56
  |---|---|---|
38
- | `create <branch> [--from <ref>] [--env]` | cuts the branch untracked | the `WT_*` block (`--env`), the upstream it found, and the `after_create` hooks to dispatch |
39
- | `list [--path <slug>]` | the table: branch, path, dirty, upstream | what it prints; a flag prints one value for scripting |
40
- | `remove <slug\|branch> [--hook-ok] [--force]` | the refusals below, then deletes the checkout | a surviving branch |
41
- | `prune [--yes]` | merged-or-gone, clean, fully pushed — and no `down:` or `before_remove` hook it cannot run | the removals, and why each skipped row was skipped |
42
-
43
- `_lib.sh` is shared helpers — it reads `worktrees:` and carries the version; it is
44
- sourced, never run. Every script takes `--version` (prints `worktree-version`) and
45
- `--help` (its own usage). Exit codes: `0` success, `1` a refusal with the reason,
46
- `2` bad usage, and `3` from `remove` when an obligation is left that a shell
47
- cannot dispatch — a declared `before_remove` hook, or a `down:` that names a
48
- skill — and `--hook-ok` is missing. `--hook-ok` is the caller saying the hook
49
- and the `down:` skill have been dispatched, so that exit is the handshake, not an
50
- error to route around.
51
-
52
- Nothing else lives there. No state, no registry, no pid file.
57
+ | `create <branch> [--from <ref>]` | cuts the branch untracked (or shows an existing checkout) | the four `WT_*` lines on stdout |
58
+ | `list [--path <slug>] [--env <slug\|branch>]` | the table: branch, path, dirty, upstream, state | what it prints; a flag prints one value for scripting |
59
+ | `remove <slug\|branch> [--force]` | the refusals below, then deletes the checkout | a surviving branch |
60
+ | `_lib.sh` | shared helpers: config, slug, namespace, identity, upstream state | sourced, never run |
61
+
62
+ **Streams are a contract.** `create` puts only the four `WT_*` identity lines on
63
+ stdout, once, at the end of a successful run; every human line (progress, the
64
+ upstream it found, a warning) goes to stderr. `list --env` prints the same four
65
+ lines and nothing else. `remove` writes every human line to stderr and nothing to
66
+ stdout — nothing consumes its stdout. A caller can `eval` stdout while a person
67
+ still reads the narration, and `create` and `list --env` are interchangeable for
68
+ that.
69
+
70
+ **Exit codes.** `0` success, `1` a refusal with the reason, `2` bad usage with the
71
+ usage on stderr — a usage error touches nothing. A removal either happened or was
72
+ refused before touching anything.
73
+
74
+ Nothing else lives there. No state, no registry, no pid file. Every script takes
75
+ `--version` (prints `WT_VERSION`) and `--help` (its own usage).
53
76
 
54
77
  **Aliases are a convenience, never a requirement.** When the project already has a
55
78
  file at the root that carries named commands — `package.json` `scripts`,
@@ -59,11 +82,28 @@ setup offers to add one `worktree:<script>` entry per script, append-only, by
59
82
  such a file to hold them: a path works in every shell, hook, and delegation brief
60
83
  with no runner in between.
61
84
 
62
- The installed set is suite-owned and read-only: nothing under `.sassywares/`
63
- but `config.yaml` is the project's to edit. `--check` hashes the installed
85
+ The installed toolbox is suite-owned and read-only: nothing under
86
+ `.sassywares/worktree/` is the project's to edit. `--check` hashes the installed
64
87
  files the way `skills-lock.json` hashes a skill folder, so a differing byte is
65
88
  drift and the file is named. Setup overwrites the set without asking, because
66
- there is no legitimate project edit to preserve.
89
+ there is no legitimate project edit to preserve. The project's scripts under
90
+ `<home>/worktrees/` are the opposite: wholly the project's, never rewritten.
91
+
92
+ **The missing-script degrade.** `scripts/detect.sh --worktree-script create|remove`
93
+ answers which path a run executes. A declared path is relative to the project
94
+ root. An absent key falls back to the built-in silently — a project that deleted
95
+ the pair means it. A declared value that is unusable — a missing or non-executable
96
+ file, whitespace or arguments, an absolute or `~/` path, `..`, a list, or a block —
97
+ warns on stderr naming the key and the file, then falls back to the built-in. The
98
+ rule and its warning live in [`config.md`](config.md)'s Lifecycle.
99
+
100
+ **Upgrading the toolbox: version 12 → 13.** `# worktree-version:` in `_lib.sh` and
101
+ `WT_VERSION` move together. 13 deletes `prune`: what it classified is now a state
102
+ column on `list`, and `remove` keeps the branch, so "merged" was never a data-safety
103
+ gate. `--check` treats a 12 header as an upgrade rather than tampering; the fix is
104
+ a setup re-run, which overwrites the set. Then delete a stale
105
+ `.sassywares/worktree/prune` if one is still there — nothing reads it. An install
106
+ at version 8 or lower may also carry `<worktree home>/ports/`; inert, delete it.
67
107
 
68
108
  ## Where things live
69
109
 
@@ -78,10 +118,6 @@ there is no legitimate project edit to preserve.
78
118
  one path in the config that may be absolute or start with `~/` — it names
79
119
  machine-local state, not something a teammate clones.
80
120
 
81
- **An install at `worktree-version` 8 or lower also has `<worktree home>/ports/`**
82
- — a folder of claim directories. Nothing reads it any more: it is inert and can be
83
- deleted.
84
-
85
121
  The folder is named after the repo. When another **live** clone of the same name
86
122
  already owns it, this one takes `<repo>-<hash>` instead; a home whose recorded
87
123
  owner no longer exists is reclaimed, so a finished project does not squat the name
@@ -93,7 +129,7 @@ is undocumented and breaks where `.git` is a file (linked worktrees, submodules,
93
129
  and crawled by every scanner that does not read `.gitignore` (`tsc`, Docker).
94
130
 
95
131
  **Never `rm -rf` the worktree home.** It is full of checkouts with uncommitted
96
- work; `remove` and `prune` are the only safe exits.
132
+ work; `remove` is the only safe exit.
97
133
 
98
134
  ## The branch
99
135
 
@@ -107,11 +143,12 @@ work; `remove` and `prune` are the only safe exits.
107
143
  `upstream` line; one that is not the branch's own name is called out with what
108
144
  a plain push would hit. That is the state a branch cut by hand arrives in.
109
145
  - **`create` never resolves a base.** The base is `references/branching.md`'s
110
- decision, and a push names its remote.
146
+ decision, and a push names its remote. A caller that has already resolved the
147
+ base passes `--from`; the script never guesses.
111
148
 
112
149
  ## The namespace
113
150
 
114
- `create` derives and prints, for the caller and the hook:
151
+ `create` derives and prints the identity a caller inherits:
115
152
 
116
153
  | Variable | Example | Use |
117
154
  |---|---|---|
@@ -120,7 +157,10 @@ work; `remove` and `prune` are the only safe exits.
120
157
  | `WT_SLUG` | `feat-catalog` | the directory name; the handle `list` and `remove` take |
121
158
  | `WT_NAMESPACE` | `shop-feat-catalog` | database schema, compose project, simulator name |
122
159
 
123
- The same names expand inside a hook's brief.
160
+ The same names are what a project's `create` and `remove` slots expand. Derived,
161
+ never invented downstream: a script that needs a database name uses
162
+ `$WT_NAMESPACE` rather than building its own, so two worktrees cannot collide by
163
+ accident. `create` mints an identity; `remove` receives one.
124
164
 
125
165
  **Finding a checkout.** `list` prints paths with `$HOME` shortened to `~`, which
126
166
  reads well and does **not** paste into anything:
@@ -129,77 +169,86 @@ reads well and does **not** paste into anything:
129
169
  cd "$(.sassywares/worktree/list --path feat-catalog)" # the real absolute path
130
170
  ```
131
171
 
132
- `create --env` prints `WT_PATH=` and the rest for scripts, and a slug is just the
133
- branch with `/` flattened.
172
+ `list --env <slug|branch>` prints the four assignments. A slug that matches two
173
+ branches (`feat/x` and `feat-x`) is an error naming every match, never a first
174
+ pick.
134
175
 
135
- Derived, never invented downstream: a hook that needs a database name uses
136
- `$WT_NAMESPACE` rather than building its own, so two worktrees cannot collide by
137
- accident.
176
+ ```bash
177
+ eval "$(.sassywares/worktree/list --env feat/catalog)"
178
+ ```
179
+
180
+ ## The state column, and removing several checkouts
181
+
182
+ `list` adds a state per managed checkout, from the branch's upstream:
138
183
 
139
- **Addressing a checkout is the project's own business**: how it is looked at, and
140
- what brings it up, are the project's `up:` and `down:` pair — see
141
- [`config.md`](config.md), Lifecycle. Two checkouts running the same app collide
142
- only if that `up:` lets them.
184
+ | State | Means |
185
+ |---|---|
186
+ | `merged` | HEAD is an ancestor of the tracked upstream — the work is on a remote |
187
+ | `gone` | the branch tracks nothing, so "merged" is unknowable |
188
+ | `unmerged` | there are commits the upstream does not have |
189
+
190
+ `remove <slug>` refuses a dirty tree, unpushed commits, or the main checkout, and
191
+ removes one checkout. There is no bulk `prune`: a user who says "remove the merged
192
+ ones" gets the list, a confirmation, and a sequential walk over each `merged` row —
193
+ one `remove <slug>` at a time, reporting each refusal and continuing, so one
194
+ blocked checkout does not hide the rest. Slower by design, and every row is
195
+ visible before it goes.
143
196
 
144
- **Liveness and stopping are the project's.** `list` reports branches, paths, dirty
145
- state, and upstreams, and nothing else: the suite keeps no registry, no pid file,
146
- and nothing to go stale. `remove` refuses a dirty tree, unpushed commits, or the
147
- main checkout, and a configured `down:` is the project's own stop step.
197
+ `remove` deletes the checkout and nothing else. **The branch survives** — git keeps
198
+ it, so the work is still reachable after the worktree is gone. Deleting it is the
199
+ user's call, or `pr.delete_branch`'s after a merge. `--force` skips the dirty and
200
+ unpushed checks and nothing else; it is never implied. When git removes the
201
+ registration but not the folder, the script says so and exits `1` rather than
202
+ claiming success.
148
203
 
149
- ## Hooks
204
+ ## A project's `remove` runs four steps in order
150
205
 
151
- Two points, keyed by head branch like the PR hooks:
206
+ The scaffold's slots exist because the order is the point:
152
207
 
153
- ```yaml
154
- hooks:
155
- worktree:
156
- "*":
157
- after_create: [shop-worktree]
158
- before_remove: [shop-worktree]
208
+ ```text
209
+ identity -> stop -> delete -> dispose
210
+ list --env project toolbox project
211
+ (files (git) ($WT_NAMESPACE
212
+ exist) still set)
159
213
  ```
160
214
 
161
- `after_create` runs **after** the checkout exists — that is when a project
162
- installs dependencies, derives `.env` from `$WT_NAMESPACE`, seeds a database or
163
- creates a simulator, and copies the session. `before_remove` runs **before** the
164
- files go, and is where the derived database or device is dropped.
215
+ 1. **Identity** — `list --env` gives `WT_PATH`, `WT_BRANCH`, `WT_SLUG`,
216
+ `WT_NAMESPACE`. Asking the toolbox means the names are the ones `create`
217
+ minted; `remove` never rebuilds a slug.
218
+ 2. **Stop, while the checkout still exists** — the project stops whatever it
219
+ started for this checkout. A process holding the tree is what makes a removal
220
+ half-fail.
221
+ 3. **Delete** — the toolbox's `remove` runs its guards and deletes the tree.
222
+ 4. **Dispose, after the tree is gone** — `$WT_NAMESPACE` is still set, so the
223
+ project drops what it derived: a database, a preview deployment, a simulator.
165
224
 
166
- A shell script cannot dispatch a skill, so `remove` fails closed: with a hook
167
- declared and `--hook-ok` missing, it prints `require-hook <name>` and exits `3`.
225
+ There is no hook handshake, no `--hook-ok`, and no exit `3`: a shell script cannot
226
+ dispatch a skill, so anything needing one is the agent's job before it calls the
227
+ script. The scaffold's slots are labelled comments — a comment is where a project
228
+ writes a step, and setup writes none of them as code.
168
229
 
169
- **Never write a hook skill yourself** — the same rule as every other hook. Setup
170
- records the name; the project writes the body.
230
+ ## The suite carries no stack, no port, and no registry
171
231
 
172
- **Sessions and third-party origins.** A worktree gets a fresh, empty
173
- `.sassywares/session/`. Most providers register one callback URL, so a worktree
174
- usually cannot log in on its own, and the `after_create` hook is where a project
175
- solves it — copying or linking the main checkout's session is the common answer.
176
- A cookie is host-scoped; a `localStorage` session is origin-scoped and has to be
177
- injected per origin. That difference is worth writing down once rather than
178
- rediscovering it.
232
+ Two checkouts running the same app collide only if the project's own scripts let
233
+ them. The suite carries no address and no port range and never derives one; a
234
+ port belongs in the project's `create`, derived from `$WT_SLUG` (a hash, because
235
+ nothing here tracks claims, so a collision is possible and the script is where it
236
+ surfaces).
179
237
 
180
- ## Refusals
238
+ `list` reports branches, paths, dirty state, upstreams, and the state column, and
239
+ nothing else: the suite keeps no registry, no pid file, and nothing to go stale.
181
240
 
182
- `remove` refuses, and `prune` skips rows it cannot prove safe:
241
+ ## Refusals
183
242
 
184
243
  | Condition | Why |
185
244
  |---|---|
186
245
  | It is the main checkout | the repo itself |
187
- | Dirty tree | uncommitted work |
246
+ | A dirty tree | uncommitted work |
188
247
  | Commits on no remote | nothing to recover from |
189
- | A `before_remove` hook not yet run | the project has cleanup to do |
190
- | A `down:` or `before_remove` hook `prune` cannot run | it runs neither, so `--yes` sends the row to `remove` |
191
-
192
- `prune --yes` removes nothing on a project with a `down:` configured — real or the
193
- generated stub — or a `before_remove` hook: it can run neither, so every
194
- otherwise-removable checkout is listed for `remove <slug>` to handle instead. That
195
- is by design, not a bug.
196
-
197
- `remove` deletes the checkout and nothing else. **The branch
198
- survives** — git keeps it, so the work is still reachable after the worktree is
199
- gone. Deleting it is the user's call, or `pr.delete_branch`'s after a merge.
248
+ | A checkout outside the worktree home, or without `.sassywares/config.yaml` | it is not managed here — another tool's, or cut before the wiring |
249
+ | A branch already checked out elsewhere | git's own refusal; `create` reports it as such |
200
250
 
201
- `--force` skips the dirty and unpushed checks and nothing else. It is never
202
- implied.
251
+ `--force` skips the dirty and unpushed checks only.
203
252
 
204
253
  ## Concurrency rules
205
254
 
@@ -218,8 +267,8 @@ implied.
218
267
  - **Never `git checkout` a branch in two places.** Git refuses it — that refusal
219
268
  is a feature, and `create` reports it as such.
220
269
  - **Do not copy `node_modules`.** Hardlink copies share inodes, so a rewrite
221
- through one checkout corrupts the other. Let the package manager's store do
222
- the deduplicating.
270
+ through one checkout corrupts the other. Let the package manager's store do the
271
+ deduplicating.
223
272
  - **`worktrees.enabled` needs `commit.branch: new`.** Under `current` a run
224
273
  commits where it stands and never cuts a branch, so no run would ever offer a
225
274
  worktree; `--check` notes the combination.