@sassywares/skills 0.11.22 → 0.12.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.
- package/CONCEPTS.md +32 -18
- package/README.md +33 -24
- package/package.json +1 -1
- package/skills/sassy-lfg/SKILL.md +1 -1
- package/skills/sassy-overview/SKILL.md +52 -0
- package/skills/sassy-overview/references/identify.md +82 -0
- package/skills/sassy-overview/scripts/identify.sh +83 -0
- package/skills/sassy-overview/scripts/lib.sh +334 -0
- package/skills/sassy-setup/SKILL.md +8 -8
- package/skills/sassy-setup/assets/dogfood-recipe.md +1 -1
- package/skills/sassy-setup/assets/lifecycle/down +29 -0
- package/skills/sassy-setup/assets/lifecycle/up +34 -0
- package/skills/sassy-setup/assets/roster +1 -0
- package/skills/sassy-setup/assets/sassywares-readme.md +5 -4
- package/skills/sassy-setup/assets/worktree/_lib.sh +52 -213
- package/skills/sassy-setup/assets/worktree/create +18 -33
- package/skills/sassy-setup/assets/worktree/list +20 -54
- package/skills/sassy-setup/assets/worktree/prune +13 -9
- package/skills/sassy-setup/assets/worktree/remove +83 -26
- package/skills/sassy-setup/references/config.md +99 -17
- package/skills/sassy-setup/references/dogfood.md +11 -17
- package/skills/sassy-setup/references/init.md +18 -4
- package/skills/sassy-setup/references/workspace.md +27 -34
- package/skills/sassy-setup/references/worktree.md +66 -75
- package/skills/sassy-setup/scripts/detect.sh +112 -103
- package/skills/sassy-setup/scripts/hash-skill.mjs +31 -18
- package/skills/sassy-setup/scripts/worktree-check.mjs +89 -0
- package/skills/sassy-work/SKILL.md +1 -1
- package/skills/sassy-worktree/SKILL.md +17 -21
- package/skills/sassy-worktree/references/create.md +3 -3
- package/skills/sassy-worktree/references/list.md +2 -2
- package/skills/sassy-worktree/references/prune.md +4 -4
- package/skills/sassy-worktree/references/remove.md +8 -6
- package/skills/sassy-setup/assets/worktree/stop +0 -65
- package/skills/sassy-worktree/references/preview.md +0 -17
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Verify an installed `.sassywares/worktree/` set against the copy this skill
|
|
3
|
+
// ships.
|
|
4
|
+
//
|
|
5
|
+
// A `worktree-version` header cannot prove the tree is untouched: it is
|
|
6
|
+
// hand-maintained, so an edited byte and an asset change without a bump both
|
|
7
|
+
// still read as current. Instead hash both folders with the `skills` CLI's own
|
|
8
|
+
// definition (./hash-skill.mjs — the one skills-lock.json uses), and when the
|
|
9
|
+
// hashes differ, name every file that differs. The expected hash is the shipped
|
|
10
|
+
// asset folder's: setup installs it by copying that folder flat, so no separate
|
|
11
|
+
// state file records it and no second hash definition exists.
|
|
12
|
+
//
|
|
13
|
+
// Usage: worktree-check.mjs --installed DIR --shipped DIR
|
|
14
|
+
// Prints "<drift|note>\t<message>" per finding and always exits 0: the caller
|
|
15
|
+
// owns the verdict and the formatting. Read-only, offline.
|
|
16
|
+
|
|
17
|
+
import { existsSync } from "node:fs";
|
|
18
|
+
|
|
19
|
+
import { hashFiles, skillFiles } from "./hash-skill.mjs";
|
|
20
|
+
|
|
21
|
+
let installed = "";
|
|
22
|
+
let shipped = "";
|
|
23
|
+
|
|
24
|
+
const argv = process.argv.slice(2);
|
|
25
|
+
for (let i = 0; i < argv.length; i += 1) {
|
|
26
|
+
if (argv[i] === "--installed") {
|
|
27
|
+
installed = argv[i + 1] ?? "";
|
|
28
|
+
i += 1;
|
|
29
|
+
} else if (argv[i] === "--shipped") {
|
|
30
|
+
shipped = argv[i + 1] ?? "";
|
|
31
|
+
i += 1;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const lines = [];
|
|
36
|
+
const drift = (message) => lines.push(`drift\t${message}`);
|
|
37
|
+
const note = (message) => lines.push(`note\t${message}`);
|
|
38
|
+
|
|
39
|
+
if (!installed || !shipped) {
|
|
40
|
+
drift("usage: worktree-check.mjs --installed DIR --shipped DIR");
|
|
41
|
+
console.log(lines.join("\n"));
|
|
42
|
+
process.exit(0);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// A missing installed set is the caller's "re-run setup" finding, not an empty
|
|
46
|
+
// folder that happens to hash differently.
|
|
47
|
+
if (!existsSync(installed)) {
|
|
48
|
+
drift("missing .sassywares/worktree — re-run setup");
|
|
49
|
+
console.log(lines.join("\n"));
|
|
50
|
+
process.exit(0);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Walk each side once: the hash is the verdict and the same arrays name which
|
|
54
|
+
// bytes moved, so the per-file report cannot contradict the folder hash.
|
|
55
|
+
const [installedFiles, shippedFiles] = await Promise.all([
|
|
56
|
+
skillFiles(installed),
|
|
57
|
+
skillFiles(shipped),
|
|
58
|
+
]);
|
|
59
|
+
|
|
60
|
+
const got = hashFiles(installedFiles);
|
|
61
|
+
const want = hashFiles(shippedFiles);
|
|
62
|
+
|
|
63
|
+
if (got === want) {
|
|
64
|
+
note(`worktree tooling matches the shipped set (hash ${got.slice(0, 12)})`);
|
|
65
|
+
console.log(lines.join("\n"));
|
|
66
|
+
process.exit(0);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const byPath = (files) => new Map(files.map((file) => [file.path, file.body]));
|
|
70
|
+
const installedByPath = byPath(installedFiles);
|
|
71
|
+
const shippedByPath = byPath(shippedFiles);
|
|
72
|
+
|
|
73
|
+
for (const [path, body] of shippedByPath) {
|
|
74
|
+
if (!installedByPath.has(path)) {
|
|
75
|
+
drift(`.sassywares/worktree/${path} is missing from the installed set — re-run setup`);
|
|
76
|
+
} else if (!installedByPath.get(path).equals(body)) {
|
|
77
|
+
drift(`.sassywares/worktree/${path} differs from the shipped copy — re-run setup`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
for (const path of installedByPath.keys()) {
|
|
81
|
+
if (!shippedByPath.has(path)) {
|
|
82
|
+
drift(`.sassywares/worktree/${path} is not shipped by this skill — remove it, or re-run setup`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Always say the hashes disagreed, even when only a mode or a file the walk
|
|
87
|
+
// cannot see moved: the failure is the hash, and the lines above are the detail.
|
|
88
|
+
drift(`.sassywares/worktree hash ${got} != the shipped ${want} — re-run setup`);
|
|
89
|
+
console.log(lines.join("\n"));
|
|
@@ -61,7 +61,7 @@ Always gate before committing. The cycle has already fixed its findings in one w
|
|
|
61
61
|
- review tier = this run's `review:` token when present, else the phase's `**Review:**` line
|
|
62
62
|
4. **Evaluate the phase.** On `Status: done`, the code is ready for the gate, but leave the phase `In progress` — both gates must pass before it closes. On `Status: blocked`, set it `Blocked` in the Phase tracking table and stop; a blocked phase is a real outcome and needs no approval.
|
|
63
63
|
|
|
64
|
-
**Then prove the `Auto` rows.** If the phase has any, run the `sassy-dogfood` skill in `mode:run` with each row's section named, before the gate and never after it. When the decision took a checkout, the report runs against the checkout's own
|
|
64
|
+
**Then prove the `Auto` rows.** If the phase has any, run the `sassy-dogfood` skill in `mode:run` with each row's section named, before the gate and never after it. When the decision took a checkout, the report runs against the checkout's own path and namespace — `WT_PATH` and `WT_NAMESPACE` — since proof run against the main checkout's app proves the wrong app. Record what each report said. A `failed` verdict is a finding, so the phase goes back through step 3's cycle with the failing step and the report's log tail as its findings, and this step runs again; a `class: env` verdict is not a finding — report that the toolchain is broken, leave the phase `In progress`, and stop. An `Auto` row with no report is `Pending`, never `Done`.
|
|
65
65
|
5. **Present the phase gate.** Report the phase, what changed, findings raised and what the single fix pass did with each (self-reported; the cycle does not re-review), the simplifications applied or skipped, the validator grade (or that it did not run), the reviewer summary, and the reviewer's suggestions as options the user may pick. Then give the QA checklist verbatim: each row's ID, check, `Mode`, and — for `Manual` — how to run it and what passing looks like, and for `Auto` — the dogfood verdict and run id, with unreported rows `Pending`. Ask for both decisions — code approval (or the changes wanted, including any suggestions picked) and the result per `Manual` row. Wait.
|
|
66
66
|
6. **Resolve the gate.** Four outcomes, nothing in between:
|
|
67
67
|
- **Code approved and every QA row passes** → go to step 7.
|
|
@@ -2,21 +2,19 @@
|
|
|
2
2
|
name: sassy-worktree
|
|
3
3
|
description: >-
|
|
4
4
|
Run more than one agent, or more than one line of work, in the same repo: a
|
|
5
|
-
worktree per branch, each with its own derived namespace
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
the user accepts.
|
|
10
|
-
argument-hint: "[slug] [mode:create|list|preview|remove|prune] [section:<name>]"
|
|
5
|
+
worktree per branch, each with its own derived namespace, created and torn down
|
|
6
|
+
safely. Use when asked for parallel work, a second checkout, or to see what a
|
|
7
|
+
worktree looks like, and when a run offers one and the user accepts.
|
|
8
|
+
argument-hint: "[slug] [mode:create|list|remove|prune]"
|
|
11
9
|
---
|
|
12
10
|
|
|
13
11
|
# Sassy Worktree
|
|
14
12
|
|
|
15
|
-
**Outcome:** a checkout per branch that a run or a human can use without touching the main one — created
|
|
13
|
+
**Outcome:** a checkout per branch that a run or a human can use without touching the main one — created and removed without losing work — or a table saying what exists and what is safe to delete.
|
|
16
14
|
|
|
17
|
-
**Config.** Resolve `.sassywares/config.yaml` (nearest, walking up) per the `sassy-setup` skill's `references/config.md`. `worktrees.enabled` decides whether a checkout is available at all — permission, never an instruction to take one; `dir`
|
|
15
|
+
**Config.** Resolve `.sassywares/config.yaml` (nearest, walking up) per the `sassy-setup` skill's `references/config.md`. `worktrees.enabled` decides whether a checkout is available at all — permission, never an instruction to take one; `dir` is read by the scripts, not by you. Precedence: explicit token > session instruction > config > skill default. Read the `sassy-setup` skill's `references/worktree.md` before the first mode: it owns the directory, refusal, and hook rules the scripts implement.
|
|
18
16
|
|
|
19
|
-
**The scripts do the git.** `.sassywares/worktree/{create,list,
|
|
17
|
+
**The scripts do the git.** `.sassywares/worktree/{create,list,remove,prune}` are installed by `sassy-setup` and own the mechanics: `git worktree`, the identity, the refusals. This skill never runs `git worktree` itself and never deletes a directory.
|
|
20
18
|
|
|
21
19
|
**Harness.** Loading another skill, dispatching an agent, and any command you hand the user follow the `sassy-setup` skill's `references/harness.md`. Read it once per run, before the first of those.
|
|
22
20
|
|
|
@@ -25,31 +23,29 @@ argument-hint: "[slug] [mode:create|list|preview|remove|prune] [section:<name>]"
|
|
|
25
23
|
| Mode | Load | It ends with |
|
|
26
24
|
|---|---|---|
|
|
27
25
|
| `list` (default) | `references/list.md` | the table of managed checkouts, as it prints |
|
|
28
|
-
| `create` | `references/create.md` | a ready checkout
|
|
29
|
-
| `
|
|
30
|
-
| `remove` | `references/remove.md` | a deleted checkout, a released port, a surviving branch |
|
|
26
|
+
| `create` | `references/create.md` | a ready checkout and its hooks |
|
|
27
|
+
| `remove` | `references/remove.md` | a deleted checkout, a surviving branch |
|
|
31
28
|
| `prune` | `references/prune.md` | the removed checkouts, and why each skipped row was skipped |
|
|
32
29
|
|
|
33
|
-
Resolve the mode: an explicit `mode:` token wins. With none, it is `list` — the only mode that changes nothing; a request to add a checkout is `create`, to
|
|
30
|
+
Resolve the mode: an explicit `mode:` token wins. With none, it is `list` — the only mode that changes nothing; a request to add a checkout is `create`, to delete one is `remove`, and to sweep the safe ones is `prune`. Read the one reference for that mode **and only that one**.
|
|
34
31
|
|
|
35
32
|
## Hard rules — every mode
|
|
36
33
|
|
|
37
34
|
| Rule | Requirement |
|
|
38
35
|
|------|-------------|
|
|
39
|
-
| The scripts do the git | Never run `git worktree`, never
|
|
36
|
+
| The scripts do the git | Never run `git worktree`, never delete a checkout by hand. `.sassywares/worktree/*` owns all of it. |
|
|
40
37
|
| Repo topology only | `git.repo: workspace` or `none` means no worktrees at all. Say so in one line and stop — never create a checkout inside a nested repo to work around it. |
|
|
41
38
|
| Enabled is permission | `worktrees.enabled: true` lets a run *offer* a checkout. `create` runs on the user's yes, or on a human asking outright — never because the config allowed it. |
|
|
42
|
-
| Ours only | A checkout is managed when it sits under `worktrees.dir` **and** carries `.sassywares/config.yaml`. Never list, prune,
|
|
43
|
-
| Names come from the script | `WT_NAMESPACE` is derived once
|
|
44
|
-
| Hooks are dispatched, not skipped | A declared `after_create` or `before_remove` runs. `remove` exits `3` rather than skipping it, and that is deliberate. |
|
|
39
|
+
| Ours only | A checkout is managed when it sits under `worktrees.dir` **and** carries `.sassywares/config.yaml`. Never list, prune, or remove one that is not — another tool made it, or it was cut before the wiring. `create` says so when that happens. |
|
|
40
|
+
| Names come from the script | `WT_NAMESPACE` is derived once. Never build a database name, a compose project, or a device name by hand. |
|
|
41
|
+
| Hooks are dispatched, not skipped | A declared `after_create` or `before_remove` runs, or a `down:` that names a skill. `remove` exits `3` rather than skipping it, and that is deliberate. |
|
|
45
42
|
| Never force on your behalf | `--force` skips the dirty and unpushed checks. Only the user's explicit instruction passes it. |
|
|
46
|
-
| No
|
|
47
|
-
| No state of its own |
|
|
48
|
-
| Never production | A preview serves the local or staging app. A recipe step pointing at production is refused and reported. |
|
|
43
|
+
| No judgement | This skill says what exists and what is safe to delete. Whether the work is correct is a different question, and not one it answers. |
|
|
44
|
+
| No state of its own | The scripts keep no registry and no pid file. What exists is what `git worktree list` prints. |
|
|
49
45
|
| The main checkout is read-only here | Read config from it, list from it, never work in it on a run's behalf. |
|
|
50
46
|
|
|
51
47
|
## What worktree is not
|
|
52
48
|
|
|
53
49
|
Not a second clone: the checkouts share one object store and one branch lock, so two worktrees can never hold the same branch — which is the property that makes this safe and a `git clone` per agent unsafe.
|
|
54
50
|
|
|
55
|
-
Not a
|
|
51
|
+
Not a runner. How the stack starts and stops belongs to the project, and this skill neither owns it nor guesses at it.
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
Read the shared sections in `SKILL.md` first. This file is the create path only.
|
|
4
4
|
|
|
5
5
|
1. **Resolve the branch and its start point first**, through the `sassy-setup` skill's `references/branching.md`, exactly as `sassy-work` does. A run that reaches here has already decided; the branch is not created twice. When a human asks for one by hand with no branch named, ask for the branch name — never derive one.
|
|
6
|
-
2. **Run `.sassywares/worktree/create <branch> --from <start-point>`** with the resolved start point. It is idempotent: an existing worktree for that branch is
|
|
7
|
-
3. **Dispatch the declared hooks.** The script prints one line per `hooks.worktree.after_create` entry; it cannot dispatch a skill, so you do. One `worker` each, in declared order: *load the project skill at `.agents/skills/<name>/SKILL.md` and follow it*, briefed with the `WT_*` block and the fact that the checkout now exists. A missing skill or a `blocked` result stops here — the checkout is real but unprepared, and saying so is the
|
|
8
|
-
4. **
|
|
6
|
+
2. **Run `.sassywares/worktree/create <branch> --from <start-point>`** with the resolved start point. It is idempotent: an existing worktree for that branch is shown, a branch held by the main checkout is refused, and the same checkout comes back either way. On `--env` it prints the `WT_*` block alone.
|
|
7
|
+
3. **Dispatch the declared hooks.** The script prints one line per `hooks.worktree.after_create` entry; it cannot dispatch a skill, so you do. One `worker` each, in declared order: *load the project skill at `.agents/skills/<name>/SKILL.md` and follow it*, briefed with the `WT_*` block and the fact that the checkout now exists. A missing skill or a `blocked` result stops here — the checkout is real but unprepared, and saying so is the answer.
|
|
8
|
+
4. **Say** the path, branch, the namespace, the upstream it printed (`none` is normal), and the hooks that ran or that none are declared. If the caller is a run, tell it to work in `WT_PATH` from now on.
|
|
9
9
|
|
|
10
10
|
| Rule | Requirement |
|
|
11
11
|
|------|-------------|
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Read the shared sections in `SKILL.md` first. This file is the list path only. `list` is the default because it is the only mode that changes nothing.
|
|
4
4
|
|
|
5
|
-
1. Run `.sassywares/worktree/list` and present it as it prints — branch, worktree,
|
|
5
|
+
1. Run `.sassywares/worktree/list` and present it as it prints — branch, worktree, dirty, upstream. Never summarise the table away: the columns are the answer.
|
|
6
6
|
2. Paths in the table are shortened to `~`. `--path <slug>` prints the real absolute path, which is what you hand a user who wants to open the checkout in an editor.
|
|
7
|
-
3.
|
|
7
|
+
3. A row's upstream is what the branch tracks, or `—` when nothing. An empty upstream is normal for a branch cut here; an upstream that is not the branch's own name is worth pointing at.
|
|
8
8
|
4. Only managed checkouts appear. Anything else found under the worktrees directory is counted in a footer, never listed as if it were ours.
|
|
9
9
|
|
|
10
10
|
| Rule | Requirement |
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
Read the shared sections in `SKILL.md` first. This file is the prune path only.
|
|
4
4
|
|
|
5
5
|
1. Run `.sassywares/worktree/prune` with no flag and show the table.
|
|
6
|
-
2. Ask before removing. `--yes` removes only rows marked `removable`: merged into their upstream or whose upstream is gone, clean, fully pushed,
|
|
7
|
-
3. Rows with a declared hook are
|
|
8
|
-
4.
|
|
6
|
+
2. Ask before removing. `--yes` removes only rows marked `removable`: merged into their upstream or whose upstream is gone, clean, fully pushed, and no `before_remove` hook or `down:` life cycle it would skip.
|
|
7
|
+
3. Rows with a declared hook or a `down:` are shown so the user can run `remove <slug>` instead and get the cleanup. Prune never skips either silently.
|
|
8
|
+
4. Give the counts — removed, left, and why each skipped row was skipped.
|
|
9
9
|
|
|
10
10
|
| Rule | Requirement |
|
|
11
11
|
|------|-------------|
|
|
12
12
|
| Only `removable` rows | The script's marking is the safety proof. Never extend `--yes` to a row it left out, and never prune by hand. |
|
|
13
|
-
| A skipped row says why | `
|
|
13
|
+
| A skipped row says why | `unmerged`, `dirty`, `unpushed`, `hook`, or `down`: name it. A bare count leaves the user unable to tell a safe sweep from a stuck one. |
|
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
Read the shared sections in `SKILL.md` first. This file is the remove path only.
|
|
4
4
|
|
|
5
|
-
1. **
|
|
6
|
-
2. **
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
1. **Run `.sassywares/worktree/remove <slug>`.** It refuses first — dirty, unpushed, the main checkout — before it stops anything.
|
|
6
|
+
2. **Then, in this order:** a top-level `down:` naming a script is run by the script itself, in the checkout; a `down:` naming a skill is not, so it joins the hooks in the exit-3 handshake. That exit is the handshake, not an error to route around: it lists every obligation still owed in one round — that `down`, and every declared `hooks.worktree.before_remove` — so dispatch them all, one `worker` per hook briefed with the `WT_*` block and that the checkout is about to go (drop the derived database, shut the simulator), then re-run once with `--hook-ok`. That re-run skips a script `down` that already ran: it continues the same removal, so nothing is stopped twice. A `down:` whose value is path-shaped but has no executable in the checkout is a mistake, not a skill, and `remove` refuses naming both the value and the checkout.
|
|
7
|
+
|
|
8
|
+
A generated stub exits `78` to mean **unimplemented**. `remove` warns loudly, names the `down:` key, and removes anyway; any other non-zero status aborts before the handshake. Drop the key if nothing needs stopping, or implement the stub.
|
|
9
|
+
3. **Say what survives.** `remove` deletes the checkout; the **branch stays**, so the work is still reachable. Naming that stops someone assuming the deletion took their commits with it.
|
|
10
|
+
4. **Give a refusal verbatim and stop.** Dirty tree, unpushed commits, the main checkout: each is a real reason, and `--force` is the user's call, never yours. On success say which path went.
|
|
9
11
|
|
|
10
12
|
| Rule | Requirement |
|
|
11
13
|
|------|-------------|
|
|
12
|
-
| The branch outlives the checkout |
|
|
13
|
-
| A refusal is information |
|
|
14
|
+
| The branch outlives the checkout | Say that the branch survived. A removal the user reads as a data loss is a removal that gets skipped next time. |
|
|
15
|
+
| A refusal is information | Give dirty, unpushed, or main-checkout verbatim. Never route around `--hook-ok`, and never clear the objection yourself. |
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# Stop whatever is listening on a worktree's port.
|
|
3
|
-
#
|
|
4
|
-
# By port, not by pid file: a preview that already died leaves nothing to
|
|
5
|
-
# believe, and a port that answers is the only proof that something is running.
|
|
6
|
-
#
|
|
7
|
-
# Usage: .sassywares/worktree/stop <slug|branch> [--version]
|
|
8
|
-
set -euo pipefail
|
|
9
|
-
|
|
10
|
-
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
11
|
-
# shellcheck source=./_lib.sh
|
|
12
|
-
source "$SCRIPT_DIR/_lib.sh"
|
|
13
|
-
|
|
14
|
-
usage() {
|
|
15
|
-
cat <<'EOF'
|
|
16
|
-
Usage: .sassywares/worktree/stop <slug|branch>
|
|
17
|
-
|
|
18
|
-
Kill the processes listening on the address this checkout advertises — its claimed
|
|
19
|
-
port if it has one, otherwise the port its recipe's preview line names. Nothing
|
|
20
|
-
listening is a success with a note, so stopping twice is safe. A preview that names
|
|
21
|
-
no port at all (a simulator, a window) is the project's to stop.
|
|
22
|
-
EOF
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
case "${1:-}" in
|
|
26
|
-
-h|--help) usage; exit 0 ;;
|
|
27
|
-
--version) printf '%s\n' "$WT_VERSION"; exit 0 ;;
|
|
28
|
-
"") usage >&2; exit 2 ;;
|
|
29
|
-
esac
|
|
30
|
-
|
|
31
|
-
need_git
|
|
32
|
-
rec="$(wt_require "$1")" || exit 1
|
|
33
|
-
path="${rec%%$'\t'*}"
|
|
34
|
-
branch="${rec##*$'\t'}"
|
|
35
|
-
slug="$(wt_slug "$branch")"
|
|
36
|
-
|
|
37
|
-
wt_is_main "$path" && die "the main checkout is not a worktree — nothing to stop"
|
|
38
|
-
wt_managed "$path" || die "'$1' is not managed here — it is outside the worktree home, or it was cut before the wiring"
|
|
39
|
-
port="$(wt_live_port "$slug")"
|
|
40
|
-
[ -n "$port" ] || die "no address to stop — worktrees.ports is unset and the preview line names no port"
|
|
41
|
-
|
|
42
|
-
if ! tcp_up "$port"; then
|
|
43
|
-
ok status "nothing listening on :$port"
|
|
44
|
-
exit 0
|
|
45
|
-
fi
|
|
46
|
-
|
|
47
|
-
command -v lsof >/dev/null 2>&1 || die "lsof not found — stop the process on :$port yourself"
|
|
48
|
-
|
|
49
|
-
pids="$(lsof -ti "tcp:$port" 2>/dev/null | tr '\n' ' ' || true)"
|
|
50
|
-
[ -n "$pids" ] || die "something answers on :$port but lsof cannot name it — is it yours?"
|
|
51
|
-
|
|
52
|
-
n="$(printf '%s' "$pids" | wc -w | tr -d ' ')"
|
|
53
|
-
kill -TERM $pids 2>/dev/null || true
|
|
54
|
-
for _ in 1 2 3 4 5; do
|
|
55
|
-
sleep 1
|
|
56
|
-
tcp_up "$port" || break
|
|
57
|
-
done
|
|
58
|
-
if tcp_up "$port"; then
|
|
59
|
-
kill -KILL $pids 2>/dev/null || true
|
|
60
|
-
sleep 1
|
|
61
|
-
tcp_up "$port" && die ":$port still answers after SIGKILL (pids: $pids)"
|
|
62
|
-
ok stopped "$n process(es) on :$port (SIGKILL)"
|
|
63
|
-
else
|
|
64
|
-
ok stopped "$n process(es) on :$port"
|
|
65
|
-
fi
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
# Mode: preview — bring a checkout up, and leave it up
|
|
2
|
-
|
|
3
|
-
Read the shared sections in `SKILL.md` first. This file is the preview path only. Preview has no script of its own: it runs the recipe. `stop` is the script that reaps it.
|
|
4
|
-
|
|
5
|
-
1. **Resolve the target and the section.** `preview <slug>` uses that checkout; with none, ask which. `section:<name>` names a dogfood recipe section; with none, use the first.
|
|
6
|
-
2. **Read the recipe** at `dogfood.recipe`. Two things stop the run, and both are reported rather than worked around: no recipe (the project has no stored procedure — say to run `sassy-dogfood mode:discover`), or the section has no `Prove it:` step (nothing marks where bringing-up ends).
|
|
7
|
-
3. **Preflight the session.** If the recipe's *Working in a second checkout* or *Set up once* names a session artifact and `.sassywares/session/` in **that checkout** is empty, that is `class: env`: report it with the line that fixes it and stop. Never open a logged-out app and call it a preview — the human will read the login screen as a broken build.
|
|
8
|
-
4. **Run the bring-up.** In `WT_PATH`: the recipe's *Set up once* when the checkout is cold (no `.env`, no installed deps), then the section's steps in order **up to but not including** its `Prove it:` step. Judge each step by its `Expect`. A failure stops the preview and is reported with the step id and its output tail — a preview that half-started is not a preview.
|
|
9
|
-
5. **Leave it running and report how to see it.** `list --preview <slug>` prints the recipe's `**Preview:**` line with the namespace substituted — the *result*, a URL or a simulator name or a window, never the command that started it. Print exactly that; never build an address yourself, and never assume one is a URL. When the project has ports and the preview answers on one, say it is up; when it does not, say it is running and that stopping it is the project's job.
|
|
10
|
-
6. **To stop it,** run `.sassywares/worktree/stop <slug>`. It kills whatever answers on the address this checkout advertises — its claimed port, or the port its preview line names — so it works for a project with no port resource too. A preview that names no port at all is the project's to stop, and it says so.
|
|
11
|
-
|
|
12
|
-
Preview never judges the work, never writes a report, never commits, and never returns a verdict. If the user wants to know whether it *works*, that is `sassy-dogfood mode:run`.
|
|
13
|
-
|
|
14
|
-
| Rule | Requirement |
|
|
15
|
-
|------|-------------|
|
|
16
|
-
| A preview is not a URL | How to see a checkout is the recipe's preview line. A port is one resource among several; a mobile app's preview is a simulator, and this skill must not invent a URL for it. |
|
|
17
|
-
| Preview is a promise | Report a URL only when something answers on it. A half-started app is a failure with a step id, not a preview — and an app without a port gets its preview line, not a fabricated address. |
|