@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
@@ -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.