@muggleai/works 5.24.0 → 5.25.0-staging.185
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/.claude-plugin/marketplace.json +1 -1
- package/README.md +1 -0
- package/dist/{chunk-GLTZIZVT.js → chunk-53MCWNVE.js} +56 -32
- package/dist/{chunk-FEHTWWVH.js → chunk-C6OEDLIP.js} +273 -5
- package/dist/cli.js +2 -2
- package/dist/index.js +2 -2
- package/dist/plugin/.claude-plugin/plugin.json +1 -1
- package/dist/plugin/.codex-mcp.json +1 -1
- package/dist/plugin/.codex-plugin/plugin.json +1 -1
- package/dist/plugin/.cursor-plugin/plugin.json +1 -1
- package/dist/plugin/.mcp.json +1 -1
- package/dist/plugin/agents/test-prepare-runner.md +3 -3
- package/dist/plugin/skills/_shared/dev-loop/run.md +4 -1
- package/dist/plugin/skills/_shared/post-merge-cleanup.md +7 -6
- package/dist/plugin/skills/_shared/pr-branch-worktree.md +7 -6
- package/dist/plugin/skills/_shared/sync-branch-with-base.md +39 -4
- package/dist/plugin/skills/_shared/use-worktrees.md +12 -6
- package/dist/plugin/skills/do/e2e-acceptance.md +1 -1
- package/dist/plugin/skills/do/pre-flight.md +1 -1
- package/dist/plugin/skills/do/wave-e2e.md +2 -2
- package/dist/plugin/skills/muggle-preferences/preference-gates/autoRebase.md +3 -3
- package/dist/plugin/skills/muggle-test/execute-local.md +2 -2
- package/dist/plugin/skills/muggle-test-feature-local/SKILL.md +3 -8
- package/dist/plugin/skills/muggle-test-prepare/SKILL.md +42 -29
- package/dist/plugin/skills/muggle-test-prepare/steps/check-running.md +25 -10
- package/dist/plugin/skills/muggle-test-prepare/steps/e2e-instructions.md +1 -1
- package/dist/plugin/skills/muggle-test-prepare/steps/env-file.md +8 -5
- package/dist/plugin/skills/muggle-test-prepare/steps/readiness-report.md +22 -18
- package/dist/plugin/skills/muggle-test-prepare/steps/rebase-check.md +13 -1
- package/dist/plugin/skills/muggle-test-prepare/steps/replay-or-learn.md +2 -2
- package/dist/plugin/skills/muggle-test-prepare/steps/resolve-sources.md +39 -0
- package/dist/plugin/skills/muggle-test-prepare/steps/reuse-plan.md +7 -5
- package/dist/plugin/skills/muggle-test-prepare/steps/smoke-test.md +2 -2
- package/dist/plugin/skills/muggle-test-prepare/steps/start-services.md +4 -4
- package/dist/release-manifest.json +3 -3
- package/dist/src-V7DVV6KO.js +1 -0
- package/package.json +2 -2
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/.codex-mcp.json +1 -1
- package/plugin/.codex-plugin/plugin.json +1 -1
- package/plugin/.cursor-plugin/plugin.json +1 -1
- package/plugin/.mcp.json +1 -1
- package/plugin/agents/test-prepare-runner.md +3 -3
- package/plugin/skills/_shared/dev-loop/run.md +4 -1
- package/plugin/skills/_shared/post-merge-cleanup.md +7 -6
- package/plugin/skills/_shared/pr-branch-worktree.md +7 -6
- package/plugin/skills/_shared/sync-branch-with-base.md +39 -4
- package/plugin/skills/_shared/use-worktrees.md +12 -6
- package/plugin/skills/do/e2e-acceptance.md +1 -1
- package/plugin/skills/do/pre-flight.md +1 -1
- package/plugin/skills/do/wave-e2e.md +2 -2
- package/plugin/skills/muggle-preferences/preference-gates/autoRebase.md +3 -3
- package/plugin/skills/muggle-test/execute-local.md +2 -2
- package/plugin/skills/muggle-test-feature-local/SKILL.md +3 -8
- package/plugin/skills/muggle-test-prepare/SKILL.md +42 -29
- package/plugin/skills/muggle-test-prepare/steps/check-running.md +25 -10
- package/plugin/skills/muggle-test-prepare/steps/e2e-instructions.md +1 -1
- package/plugin/skills/muggle-test-prepare/steps/env-file.md +8 -5
- package/plugin/skills/muggle-test-prepare/steps/readiness-report.md +22 -18
- package/plugin/skills/muggle-test-prepare/steps/rebase-check.md +13 -1
- package/plugin/skills/muggle-test-prepare/steps/replay-or-learn.md +2 -2
- package/plugin/skills/muggle-test-prepare/steps/resolve-sources.md +39 -0
- package/plugin/skills/muggle-test-prepare/steps/reuse-plan.md +7 -5
- package/plugin/skills/muggle-test-prepare/steps/smoke-test.md +2 -2
- package/plugin/skills/muggle-test-prepare/steps/start-services.md +4 -4
- package/dist/src-3MQ2UWSP.js +0 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "muggle",
|
|
3
3
|
"displayName": "Muggle AI",
|
|
4
4
|
"description": "Real-browser E2E acceptance for your coding agent: test the flows you changed and open the PR with screenshots. Built for flows other tools can't reach: managed test identities with live inboxes (magic links, email OTP and 2FA, verification mail, password resets), an encrypted secret store for login and test credentials, and a test graph that runs prerequisite flows first. Plain-English tests become replayable scripts on localhost or preview URLs.",
|
|
5
|
-
"version": "5.
|
|
5
|
+
"version": "5.25.0-staging.185",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Muggle AI",
|
|
8
8
|
"email": "support@muggle-ai.com"
|
package/dist/plugin/.mcp.json
CHANGED
|
@@ -12,10 +12,10 @@ You bring a local dev stack to verified readiness for E2E testing: detect what's
|
|
|
12
12
|
|
|
13
13
|
The dispatch prompt carries the resolved prepare plan:
|
|
14
14
|
|
|
15
|
-
- `services[]` — name, dir, start command, expected port, `external` flag, approval already granted.
|
|
15
|
+
- `services[]` — name, dir, start command, expected port, `external` flag, approval already granted. `dir` is the run directory the skill's resolve-sources stage chose this run — the change's own checkout, or a base checkout on the latest default branch; start and judge each service from it, never from anywhere else.
|
|
16
16
|
- `testingScope` and `excludedServices[]` (with reasons).
|
|
17
17
|
- The recorded dev-server URL (from the `autoSelectLocalHost` resolution) — never invent or default a host/port; a framework default like `:3000` is not a fallback.
|
|
18
|
-
- Resolved gate values the stages read (`autoRebase` outcome already applied
|
|
18
|
+
- Resolved gate values the stages read (`autoRebase` outcome already applied upstream, with the checkout synced onto its base).
|
|
19
19
|
- The E2E run instructions — startup order, manual steps, local gotchas — already captured from the user. Honour the recorded startup order when starting services, and write the instructions out per the readiness-report stage. Absent means the skill had nothing to record; never invent them.
|
|
20
20
|
|
|
21
21
|
## Stages
|
|
@@ -34,7 +34,7 @@ Where a stage file offers the user a choice, take the branch the plan resolved;
|
|
|
34
34
|
|
|
35
35
|
## PID tracking
|
|
36
36
|
|
|
37
|
-
Track every launched process in
|
|
37
|
+
Track every launched process in the tracking file of the checkout it runs from, exactly per the skill's [PID Tracking](../skills/muggle-test-prepare/SKILL.md#pid-tracking) schema (`services[]` with pid/port/headSha/log). Never write into, or kill a process recorded in, another checkout's file — that is a parallel session's server. Processes the user started independently stay `external: true` and are never killed. Prune dead PIDs silently.
|
|
38
38
|
|
|
39
39
|
## Output contract
|
|
40
40
|
|
|
@@ -10,7 +10,8 @@ The caller resolves these before the loop and supplies them per test case:
|
|
|
10
10
|
|
|
11
11
|
- `mode` — `replay` or `regen`, already chosen (by the user, or by [`../failure-mode-handling.md`](../failure-mode-handling.md) for change-driven callers).
|
|
12
12
|
- `localUrl` — local execution target. Local-only; never changes the cloud project or test definitions.
|
|
13
|
-
- `cwd` — absolute path of the active working tree (PR-branch worktree if one exists, else repo root). Drives the cross-worktree single-flight lock so concurrent runs serialize.
|
|
13
|
+
- `cwd` — absolute path of the active working tree (PR-branch worktree if one exists, else repo root). Drives the cross-worktree single-flight lock so concurrent runs serialize, and names the checkout the execute tools check for freshness.
|
|
14
|
+
- `baseBranch` — the change's base, only when it is not the remote default (a stacked change, a PR into a release branch). Omitted, the tools check `cwd` against the remote default.
|
|
14
15
|
- `testCase` / `cloudTestCaseId` — the cloud test case and its id.
|
|
15
16
|
- `showUi` — from the caller's `showElectronBrowser` resolution: omit for visible, `false` for headless.
|
|
16
17
|
|
|
@@ -32,3 +33,5 @@ Per test case, branch on `mode`:
|
|
|
32
33
|
2. `muggle-local-execute-test-generation` with `testCase`, `localUrl`, `cwd`, `showUi`, `freshSession` (omit it so the stored flag decides; pass it only to override for this run, per [`fresh-session.md`](fresh-session.md)), `timeoutMs`.
|
|
33
34
|
|
|
34
35
|
Store the returned `runId`, tagged with its `mode`. If a run fails, log it and continue the batch — never abort. Read the result per [`failures.md`](failures.md), then [`publish.md`](publish.md).
|
|
36
|
+
|
|
37
|
+
**A refused run is not a failure.** A result headed `Run refused — checkout is not on the latest …` launched nothing and has no `runId`: the `cwd` checkout lacks its base's latest commit (`BEHIND_BASE`) or carries another branch's commits (`FOREIGN_BASE`). Sync it per [`../sync-branch-with-base.md`](../sync-branch-with-base.md), re-invoke [`muggle-test-prepare`](../../muggle-test-prepare/SKILL.md) so the dev server serves the synced code, and run the case again. Never route it through failure handling or count it as a result.
|
|
@@ -37,11 +37,12 @@ A worktree's dependency dir (`node_modules`, and nested workspace copies) is oft
|
|
|
37
37
|
`git worktree remove` refuses for two unrelated reasons, and **both texts lead to the same forbidden flag** — one because it is the obvious fix, the other because git prints it as the suggestion. Clear each cause at its source; neither is a reason to reconsider the flag.
|
|
38
38
|
|
|
39
39
|
1. **Never `--force`.** It is the one flag that follows links.
|
|
40
|
-
2.
|
|
40
|
+
2. Stop the services environment prep started from this worktree (step 6 names their tracker) — a running dev server holds files open, and on Windows the removal then fails.
|
|
41
|
+
3. Clear the dependency and build dirs first, nested workspace ones included (`packages/*/node_modules`, `dist`). A plain `git worktree remove` fails with `Directory not empty` while they remain, and the obvious fix for that error is exactly the forbidden flag.
|
|
41
42
|
- A **link** → unlink it first with the host OS's unlink, removing the link only and never its target.
|
|
42
43
|
- A **real directory** → delete it in place.
|
|
43
44
|
Check which it is before deleting; the two are indistinguishable from a listing but not from a `rm -r`.
|
|
44
|
-
|
|
45
|
+
4. Clear the worktree's own dirty state — what the merge already landed, and nothing else. While anything remains, removal fails with `contains modified or untracked files, use --force to delete it`, an error that prescribes the forbidden flag in its own text.
|
|
45
46
|
|
|
46
47
|
Expect this on any cycle that pushed through a server-side signed commit: that mutation writes to the remote only, so the worktree keeps the edits as modifications of a commit it never made locally. The dirt is this cycle's own landed work, not something the user left behind.
|
|
47
48
|
|
|
@@ -50,8 +51,8 @@ A worktree's dependency dir (`node_modules`, and nested workspace copies) is oft
|
|
|
50
51
|
- **Untracked files** — never on the base, so no diff can clear them. Delete only the paths this procedure itself created: the dependency and build dirs cleared above. Anything else stops the sequence and is reported by name; an untracked file is the one thing in the worktree with no copy anywhere.
|
|
51
52
|
|
|
52
53
|
**Never `git clean -x`.** `-x` is what reaches the ignored dependency dir, and clean recurses through a link exactly as a forced remove does — it undoes the unlink above under a different name.
|
|
53
|
-
|
|
54
|
-
|
|
54
|
+
5. Then plain `git worktree remove {worktreePath}`.
|
|
55
|
+
6. `git worktree prune` to drop the administrative entry when the directory went away out from under git.
|
|
55
56
|
|
|
56
57
|
**Verify:** the path is gone, it no longer appears in `git worktree list`, the removal ran without `--force`, **and** the shared dependency tree the links pointed at still exists. That last check is the one that catches a link-follow.
|
|
57
58
|
|
|
@@ -87,9 +88,9 @@ Clear it only when `prs.json` records a terminal state. A slot for a still-open
|
|
|
87
88
|
|
|
88
89
|
## 6. Clear this run's prepare artifacts
|
|
89
90
|
|
|
90
|
-
The
|
|
91
|
+
The services environment prep started from the merged change's worktree, with their tracker and logs — that worktree's tracking file and log directory, per [`muggle-test-prepare`'s PID Tracking](../muggle-test-prepare/SKILL.md#pid-tracking). Stop any tracked PID still alive (step 2 normally already has), then delete both.
|
|
91
92
|
|
|
92
|
-
**Only this run's.**
|
|
93
|
+
**Only this run's worktree.** Another checkout's tracker belongs to another session, which may be mid-prepare with services running; a base checkout's services are shared by every session. Neither is yours to stop or delete.
|
|
93
94
|
|
|
94
95
|
Cloud results always stay.
|
|
95
96
|
|
|
@@ -8,10 +8,10 @@ A skill receives a GitHub PR URL of the form `github.com/<org>/<repo>/pull/<n>`
|
|
|
8
8
|
|
|
9
9
|
## Steps
|
|
10
10
|
|
|
11
|
-
1. **Resolve the PR's head
|
|
12
|
-
`gh pr view <n> --repo <org>/<repo> --json headRefName
|
|
11
|
+
1. **Resolve the PR's head and base branches:**
|
|
12
|
+
`gh pr view <n> --repo <org>/<repo> --json headRefName,baseRefName`
|
|
13
13
|
2. **Sanitize the branch name** for filesystem use — replace `/` and other path separators with `-`. Example: `claude/regen-test-replay-flow-ZSScQ` → `claude-regen-test-replay-flow-ZSScQ`.
|
|
14
|
-
3. **Build the target worktree path:** `<repo>/.claude/worktrees/<sanitized-branch
|
|
14
|
+
3. **Build the target worktree path:** `<repo>/.claude/worktrees/<sanitized-branch>`, where `<repo>` is the clone's main working tree (the first `worktree` line of `git worktree list --porcelain`) even when the session stands in another worktree.
|
|
15
15
|
4. **Materialize the worktree:**
|
|
16
16
|
- If the target path does NOT exist:
|
|
17
17
|
- `git -C <repo> fetch origin <branch>`
|
|
@@ -19,10 +19,11 @@ A skill receives a GitHub PR URL of the form `github.com/<org>/<repo>/pull/<n>`
|
|
|
19
19
|
- If the target path EXISTS (reused from a prior run):
|
|
20
20
|
- `git -C <target-path> fetch`
|
|
21
21
|
- `git -C <target-path> reset --hard origin/<branch>` — picks up new pushes, drops any local cruft.
|
|
22
|
-
5. **
|
|
23
|
-
|
|
22
|
+
5. **Bring it onto the latest base.** A PR branch opened days ago lacks everything merged since; testing it as-is tests code that will never ship. Sync the worktree onto `origin/<baseRefName>` per [`sync-branch-with-base.md`](sync-branch-with-base.md), passing `baseRefName` as the base. This rebase is local and test-only — **never push it**; the next run's `reset --hard` discards it. A rebase that conflicts means the PR cannot merge as it stands: report the conflicted files and stop rather than testing either side alone.
|
|
23
|
+
6. **Use the worktree path as the working directory** for the rest of the run, including:
|
|
24
|
+
- Passing it as the **`cwd` parameter** to `muggle-local-execute-test-generation` and `muggle-local-execute-replay`. This is required, not optional — see `_shared/failure-mode-handling.md` and the lock identity discussion in those tools' MCP source. When `baseRefName` is not the remote default, pass it as `baseBranch` too: the tools refuse a loopback run whose `cwd` lacks its base's latest commit.
|
|
24
25
|
- Resolving any `npm install` / dev-server start commands inside the worktree (it has its own `node_modules/` and `.env*` files).
|
|
25
|
-
|
|
26
|
+
7. **Tell the user** where the worktree lives so they can clean it up later with `git -C <repo> worktree remove <target-path>`.
|
|
26
27
|
|
|
27
28
|
## Invariants
|
|
28
29
|
|
|
@@ -6,15 +6,27 @@ Bring the working branch up to date with the branch it merges into — before a
|
|
|
6
6
|
|
|
7
7
|
`base` is the branch the work merges into, which is not automatically the remote default — pre-flight lets the user target a different branch, and once a change exists its `baseRefName` is authoritative. A caller holding a base passes it in; fall back to the remote default only when no target was chosen.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
## Checking freshness
|
|
10
|
+
|
|
11
|
+
`muggle checkout-freshness` fetches the base and returns one verdict. Run it in the checkout:
|
|
10
12
|
|
|
11
13
|
```bash
|
|
12
|
-
git fetch origin
|
|
13
14
|
base="${base:-$(git symbolic-ref refs/remotes/origin/HEAD --short | sed 's|origin/||')}"
|
|
14
|
-
|
|
15
|
+
muggle checkout-freshness --base "${base}" --json
|
|
15
16
|
```
|
|
16
17
|
|
|
17
|
-
|
|
18
|
+
| Verdict | Meaning | Action |
|
|
19
|
+
| :------ | :------ | :----- |
|
|
20
|
+
| `FRESH` | HEAD contains `origin/${base}` | None |
|
|
21
|
+
| `NOT_APPLICABLE` | Not a git checkout, no `origin`, or no such base | None — nothing to check |
|
|
22
|
+
| `BEHIND_BASE` | HEAD lacks `behindBy` commits of `origin/${base}` | [Rebase](#rebasing) |
|
|
23
|
+
| `FOREIGN_BASE` | The branch was cut from another branch's unmerged commits (`inheritedCommits`) | [Stop](#foreign-base) |
|
|
24
|
+
|
|
25
|
+
Pass `{behind}` (the report's `behindBy`) and `{base}` to the picker prompts. A report with `hasFetchFailed: true` judged against the last fetched base — say so in one line and act on the verdict.
|
|
26
|
+
|
|
27
|
+
## Rebasing
|
|
28
|
+
|
|
29
|
+
On `always`:
|
|
18
30
|
|
|
19
31
|
1. Capture the rollback point: `pre_rebase_sha=$(git rev-parse HEAD)`.
|
|
20
32
|
2. `git rebase origin/${base}`.
|
|
@@ -22,6 +34,29 @@ Pass `{behind}` and `{base}` to the picker prompts. On `always`:
|
|
|
22
34
|
- `never` → `git rebase --abort`; stop and report, naming the conflicted files. Never auto-resolve.
|
|
23
35
|
- `always` → hand off to [`resolve-rebase-conflicts.md`](resolve-rebase-conflicts.md) with `pre_rebase_sha` to resolve the conflicts, then run the [`verify-or-rollback-gate.md`](verify-or-rollback-gate.md) with `pre_rebase_sha`; it either proceeds or restores `pre_rebase_sha` and escalates.
|
|
24
36
|
|
|
37
|
+
A dev server already running from this checkout still serves the pre-rebase code: restart it before testing.
|
|
38
|
+
|
|
39
|
+
## Before a dev server or E2E run
|
|
40
|
+
|
|
41
|
+
The code under test always contains the latest `origin/${base}`. `autoRebase` decides only whether the rebase happens without asking, never whether stale code runs:
|
|
42
|
+
|
|
43
|
+
- `always` → rebase.
|
|
44
|
+
- `ask` → Picker 1. `Rebase first` rebases; `Don't rebase` stops the run.
|
|
45
|
+
- `never` → stop the run.
|
|
46
|
+
|
|
47
|
+
A stop names the checkout, the verdict and `behindBy`, and starts nothing. There is no run-as-is: a stale tree produces false failures and false greens, and the local execute tools refuse a stale loopback run regardless, so running as-is only moves the failure later.
|
|
48
|
+
|
|
49
|
+
## Foreign base
|
|
50
|
+
|
|
51
|
+
`FOREIGN_BASE` stops the run or push whatever `autoRebase` says — a rebase would carry the inherited commits along. Report the branch they came from and `inheritedCommits`. The fix is a decision about someone else's work, so it is the user's:
|
|
52
|
+
|
|
53
|
+
- Recreate the branch with `origin/${base}` as its explicit start point and carry over only the change's own commits.
|
|
54
|
+
- Or, when the change deliberately stacks on that branch, name it as the base and re-check.
|
|
55
|
+
|
|
56
|
+
## Before a push
|
|
57
|
+
|
|
58
|
+
`BEHIND_BASE` → rebase per `autoRebase`; on `never` the push goes ahead as-is, and the remote's merge checks own that decision. `FOREIGN_BASE` → [stop](#foreign-base).
|
|
59
|
+
|
|
25
60
|
## Branches already on the remote
|
|
26
61
|
|
|
27
62
|
The rebase rewrites history, so a branch the remote already has needs a force-push to land it. Never force-push from here. A caller in that position hands the sync to its own rebase mode, which owns the per-SHA attempt budget and the verify-or-rollback gate wrapped around the force-push.
|
|
@@ -10,13 +10,18 @@ Use this for feature development, local validation, and PR iteration.
|
|
|
10
10
|
|
|
11
11
|
## Start new change work
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
Every new branch starts at the latest `origin/<base>` — never at HEAD, never at a local branch. The directory a session stands in may be a detached main checkout months old, or a sibling worktree on someone else's feature branch; a branch created without a start point silently inherits that code. A local `<base>` branch is no better: it is often checked out, stale, in another worktree.
|
|
14
|
+
|
|
15
|
+
1. Resolve `<main-root>` — the clone's main working tree, the first `worktree` line of `git worktree list --porcelain` — and `<base>` (the change's target branch; the remote default when none was chosen).
|
|
16
|
+
2. Fetch and create from the remote-tracking ref:
|
|
15
17
|
```bash
|
|
16
|
-
git
|
|
18
|
+
git -C <main-root> fetch --no-tags origin "+refs/heads/<base>:refs/remotes/origin/<base>"
|
|
19
|
+
git -C <main-root> worktree add <main-root>/.claude/worktrees/<sanitized-branch> -b <branch> origin/<base>
|
|
17
20
|
```
|
|
18
|
-
|
|
19
|
-
|
|
21
|
+
Under `<main-root>` even when the session stands in another worktree, so worktrees never nest.
|
|
22
|
+
3. Confirm with `muggle checkout-freshness --cwd <worktree>` — it must report `FRESH`.
|
|
23
|
+
4. Install dependencies and run setup in that worktree.
|
|
24
|
+
5. Keep all edits and commits for the change in that same worktree.
|
|
20
25
|
|
|
21
26
|
## Test in the worktree
|
|
22
27
|
|
|
@@ -27,7 +32,7 @@ Use this for feature development, local validation, and PR iteration.
|
|
|
27
32
|
|
|
28
33
|
## E2E + worktree checklist
|
|
29
34
|
|
|
30
|
-
1. Confirm command cwd, checked-out branch, and server source are the same worktree.
|
|
35
|
+
1. Confirm command cwd, checked-out branch, and server source are the same worktree, and that the worktree is still on the latest base per [`sync-branch-with-base.md`](sync-branch-with-base.md).
|
|
31
36
|
2. Start the app from that worktree and verify readiness first (see [`dev-server-readiness.md`](dev-server-readiness.md)).
|
|
32
37
|
3. Run local E2E acceptance checks in that same session.
|
|
33
38
|
4. Isolate test data across parallel branches (separate users/accounts/orgs or resettable fixtures).
|
|
@@ -39,6 +44,7 @@ Use this for feature development, local validation, and PR iteration.
|
|
|
39
44
|
- **Port collision:** Multiple branches share a dev-server port.
|
|
40
45
|
- **Shared mutable state:** Parallel runs mutate the same account or fixtures.
|
|
41
46
|
- **Stale server:** Old process still serves previous branch code.
|
|
47
|
+
- **Inherited base:** A branch created from whatever HEAD the session stood on carries that checkout's age or another branch's commits.
|
|
42
48
|
|
|
43
49
|
## Pull request workflow
|
|
44
50
|
|
|
@@ -69,7 +69,7 @@ For a `local-e2e` block, use `localUrl`, `projectId`, and the working-tree path
|
|
|
69
69
|
|
|
70
70
|
A `local-e2e` cycle runs these before any `muggle-local-execute-*` call, every cycle — even when pre-flight already reported the app ready, since a server can die while stages 2–5 run and a healthy one fast-exits:
|
|
71
71
|
|
|
72
|
-
1. **Dev-server + backend readiness** — invoke [`muggle-test-prepare`](../muggle-test-prepare/SKILL.md), the readiness/service-start owner (idempotent fast-exit when healthy; probes via `dev-server-readiness.md` and starts what is down). Still not ready after its start attempts → the readiness halt below.
|
|
72
|
+
1. **Dev-server + backend readiness** — invoke [`muggle-test-prepare`](../muggle-test-prepare/SKILL.md) from the cycle's worktree, passing the PR target as `base` — the readiness/service-start owner (idempotent fast-exit when healthy; probes via `dev-server-readiness.md` and starts what is down). It syncs the worktree onto the latest base before starting anything, and serves every other repo from its latest default branch. Its readiness table must show the cycle's worktree as the `Source` of the changed repo's services, at the worktree's current HEAD; any other source is not ready. Still not ready after its start attempts → the readiness halt below.
|
|
73
73
|
2. **Auth** — `muggle-remote-auth-status` must be `authenticated`; else escalate.
|
|
74
74
|
3. **Identity tenant/domain match** — if test credentials were marked `existing`, confirm the repo's configured identity tenant/domain matches the recorded tenant/domain. Mismatch → halt.
|
|
75
75
|
|
|
@@ -34,7 +34,7 @@ Before asking anything, gather every fact you can resolve without the user:
|
|
|
34
34
|
8. **Auth0 tenant in use for local dev.** Grep the repo's env file for `*AUTH0_DOMAIN*`; record the tenant. This tells the user whether the staging-tenant test user will work or not.
|
|
35
35
|
9. **Branch hygiene signals** for the `autoUseWorktree` and `autoRebase` gates (see [`../_shared/use-worktrees.md`](../_shared/use-worktrees.md), [`../_shared/sync-branch-with-base.md`](../_shared/sync-branch-with-base.md)):
|
|
36
36
|
- Is the current checkout already a worktree? `git -C <repo> rev-parse --is-inside-work-tree` plus `git -C <repo> worktree list`.
|
|
37
|
-
-
|
|
37
|
+
- Is the current checkout on the latest base? `muggle checkout-freshness --cwd <repo> --json` fetches and reports the verdict and `behindBy`. However stale or foreign the current checkout, a new worktree starts from `origin/<base>`, never from it.
|
|
38
38
|
10. **`autoE2ETest` preference.** Read the session-context preferences line. Unset → treat as `always` (this gate's default — opposite of the system-wide `ask` default). `ask` → surface in Q13. `always` → no question; stage 6 runs.
|
|
39
39
|
11. **Wave candidate?** Two or more candidate repos, one PR each, and validation leaning `local-e2e` → the cycle is a wave per [`wave-e2e.md`](wave-e2e.md): the repos' services start together from their branches and one E2E run covers every PR. Record each repo's worktree path for the `Wave members` block. Not a wave → note why.
|
|
40
40
|
12. **CI check present?** For each GitHub repo, whether `.github/workflows/muggle-walkthrough.yml` exists on its default branch. Missing and [`autoInstallCiWorkflow`](../muggle-preferences/preference-gates/autoInstallCiWorkflow.md) resolves to `ask` → surface in Q14.
|
|
@@ -34,8 +34,8 @@ The worktree path is where that repo's wave branch is checked out — the path i
|
|
|
34
34
|
|
|
35
35
|
Run [`e2e-acceptance.md`](e2e-acceptance.md) **once**, not once per repo, with these changes:
|
|
36
36
|
|
|
37
|
-
1. **Start the wave stack.** Invoke [`muggle-test-prepare`](../muggle-test-prepare/SKILL.md) with the wave members as `directoryOverrides` (repo → worktree path): every service whose repo is a wave member starts from that member's worktree path, not from the repo's usual checkout. Services from repos outside the wave start
|
|
38
|
-
2. **Confirm each wave service runs the wave branch.** A port that answers is not enough — the process on it may be a dev server the user left running from the default checkout. Check the readiness table: every wave service must report its member's worktree as its
|
|
37
|
+
1. **Start the wave stack.** Invoke [`muggle-test-prepare`](../muggle-test-prepare/SKILL.md) with the wave members as `directoryOverrides` (repo → worktree path): every service whose repo is a wave member starts from that member's worktree path, synced onto its base first, not from the repo's usual checkout. Services from repos outside the wave start from that repo's base checkout on its latest default branch.
|
|
38
|
+
2. **Confirm each wave service runs the wave branch.** A port that answers is not enough — the process on it may be a dev server the user left running from the default checkout. Check the readiness table: every wave service must report its member's worktree as its `Source`, at that worktree's current HEAD. A service that doesn't → halt and escalate with the table; never test a wave against a service running another branch.
|
|
39
39
|
3. **Merge every member's scope.** Steps 1.5–3 read impact analysis for every wave repo, and the run's scope is the union of each member's `e2eScope`: a test case several members scope runs once, and a new case two members plan for the same criterion is created once. `EMPTY_DIFF` applies only when every member's diff is empty.
|
|
40
40
|
4. **Run each selected test case once** against the combined stack. Do not repeat a case per repo.
|
|
41
41
|
5. **Attribute failures.** For each Failed entry, name the member whose change the failing step implicates (`implicatedRepo: <owner/repo>`), or `unknown` when the evidence does not point at one. Stage 7.5 repairs in that repo.
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# `autoRebase`
|
|
2
2
|
|
|
3
|
-
Sync onto `origin/{base}` before dev servers / E2E and before a push, or run
|
|
3
|
+
Sync onto `origin/{base}` before dev servers / E2E and before a push, without asking. Stale code is never tested: before a dev server or E2E run, not rebasing stops the run. Substitute `{behind}` and `{base}`.
|
|
4
4
|
|
|
5
5
|
**Picker 1** — header `Rebase first`, question `"Branch is {behind} commits behind origin/{base} — rebase first?"`
|
|
6
6
|
- `Rebase first` — `Pull in the base branch's changes so the run reflects the merged main line.` → `always`
|
|
7
|
-
- `
|
|
7
|
+
- `Don't rebase` — `Leave the branch as it is. A dev server or E2E run stops instead of testing stale code; a push goes ahead.` → `never`
|
|
8
8
|
|
|
9
9
|
**Silent action**
|
|
10
10
|
- `always` → `Rebasing onto origin/{base} ({behind} behind)`
|
|
11
|
-
- `never` → `
|
|
11
|
+
- `never` → `Not rebasing ({behind} behind origin/{base}) — a dev server or E2E run stops here`
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
## Local environment readiness
|
|
12
12
|
|
|
13
|
-
Before anything else, invoke [`muggle-test-prepare`](../muggle-test-prepare/SKILL.md) — the readiness/service-start owner (idempotent; halt on what it surfaces). The URL gate below only *selects* the target; prepare is what guarantees
|
|
13
|
+
Before anything else, invoke [`muggle-test-prepare`](../muggle-test-prepare/SKILL.md) from `cwd` — the readiness/service-start owner (idempotent; halt on what it surfaces). It syncs `cwd` onto the latest base before starting anything, and serves every other repo from its latest default branch. The URL gate below only *selects* the target; prepare is what guarantees the right code is listening and compiled. Confirm its readiness table shows `cwd` as the `Source` of this repo's services, at `cwd`'s current HEAD — a different source means the run would test someone else's code; halt.
|
|
14
14
|
|
|
15
15
|
Then read `~/.muggle-ai/e2e-instructions/<key>.md` when it exists — this stack's recorded startup order, manual steps, and local gotchas. Use it to interpret what you see: a gotcha listed there explains a symptom that would otherwise read as a failure. Absent is normal.
|
|
16
16
|
|
|
@@ -40,7 +40,7 @@ Execute each test case via the shared loop in [`../_shared/dev-loop/run.md`](../
|
|
|
40
40
|
|
|
41
41
|
Caller glue:
|
|
42
42
|
- `mode` per test case is the input from the router; `localUrl` from the pre-flight question; `showUi` from the `showElectronBrowser` resolution.
|
|
43
|
-
- `cwd` is the input from the router — it drives the cross-worktree single-flight lock so concurrent muggle-test runs from different branches serialize.
|
|
43
|
+
- `cwd` is the input from the router — it drives the cross-worktree single-flight lock so concurrent muggle-test runs from different branches serialize, and the execute tools refuse it when it is not on the latest base. For a PR whose base is not the remote default, pass its `baseRefName` as `baseBranch`.
|
|
44
44
|
- On a failed run, continue the batch; the router routes failures through the debug path after this path returns.
|
|
45
45
|
|
|
46
46
|
## Collect results
|
|
@@ -26,12 +26,12 @@ The local URL only changes where the browser opens; it does not change the remot
|
|
|
26
26
|
Three gates apply, each per the standard procedure in [`preference-gates/README.md`](../muggle-preferences/preference-gates/README.md):
|
|
27
27
|
|
|
28
28
|
- `autoUseWorktree` at pre-flight (see [`_shared/use-worktrees.md`](../_shared/use-worktrees.md)).
|
|
29
|
-
- `autoRebase` before Step 7 (Execute) when
|
|
29
|
+
- `autoRebase` before any service starts — `muggle-test-prepare` syncs the checkout first — and again before Step 7 (Execute) when the base moved meanwhile, re-invoking `muggle-test-prepare` after that rebase so the dev server serves it. Stale code is never tested (see [`_shared/sync-branch-with-base.md`](../_shared/sync-branch-with-base.md)).
|
|
30
30
|
- `autoCleanup` after the PR is merged (see [`_shared/post-merge-cleanup.md`](../_shared/post-merge-cleanup.md)).
|
|
31
31
|
|
|
32
32
|
## Local environment prerequisites
|
|
33
33
|
|
|
34
|
-
Before any workflow step, invoke [`muggle-test-prepare`](../muggle-test-prepare/SKILL.md). Halt on what it surfaces.
|
|
34
|
+
Before any workflow step, invoke [`muggle-test-prepare`](../muggle-test-prepare/SKILL.md) from the checkout under test. Halt on what it surfaces — a checkout it cannot bring onto the latest base included.
|
|
35
35
|
|
|
36
36
|
Then read `~/.muggle-ai/e2e-instructions/<key>.md` when it exists — this stack's recorded startup order, manual steps, and local gotchas. A gotcha listed there explains a symptom that would otherwise read as a failure. Absent is normal.
|
|
37
37
|
|
|
@@ -112,12 +112,7 @@ Prompt for projects: "Pick the project to group this test into:"
|
|
|
112
112
|
|
|
113
113
|
### 3. Ensure Local Services Are Ready
|
|
114
114
|
|
|
115
|
-
Before detecting the local URL,
|
|
116
|
-
|
|
117
|
-
1. Check if `/tmp/muggle-test-prepare.json` exists.
|
|
118
|
-
2. If it exists, verify tracked PIDs are alive with `kill -0`.
|
|
119
|
-
3. If all live → services are ready, proceed to Step 4 (Local URL).
|
|
120
|
-
4. If the file is missing or has stale PIDs → invoke the `muggle:muggle-test-prepare` skill via the `Skill` tool to get services started. Once it completes, proceed to Step 4.
|
|
115
|
+
Before detecting the local URL, invoke the `muggle:muggle-test-prepare` skill via the `Skill` tool from the checkout under test — every run, even when services look up. Live PIDs prove nothing about which code they serve: prepare syncs this checkout onto the latest base, starts sibling services from base checkouts on the latest default branch, and keeps a running service only when it still serves the right commit. It fast-exits when everything is proven. Once it reports ready, check its readiness table: this checkout's services must show this checkout as their `Source` at its current HEAD. Then proceed to Step 4.
|
|
121
116
|
|
|
122
117
|
This step is especially important when the user's app depends on sibling services (a backend API, an auth service, etc.) that may not be running yet. The prepare skill handles discovery, startup, and cleanup so this skill doesn't have to.
|
|
123
118
|
|
|
@@ -26,42 +26,46 @@ This skill touches the user's local machine — processes, ports, directories ou
|
|
|
26
26
|
|
|
27
27
|
## PID Tracking
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
Every launched process is tracked by the **checkout it runs from**, one file per checkout, so parallel sessions never share — or tear down — each other's state:
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
~/.muggle-ai/prepare/running/<source-key>.json services started from that checkout
|
|
33
|
+
~/.muggle-ai/prepare/logs/<source-key>/<name>.log their logs
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
`<source-key>` is the checkout root's absolute path, made filename-safe exactly as the E2E instructions key is ([e2e-instructions](./steps/e2e-instructions.md#resolve-the-saved-file)).
|
|
30
37
|
|
|
31
38
|
```json
|
|
32
39
|
{
|
|
33
|
-
"
|
|
34
|
-
"testing_scope": "frontend",
|
|
35
|
-
"excluded_services": [
|
|
36
|
-
{"name": "payment-gateway", "reason": "Needs production certificates"}
|
|
37
|
-
],
|
|
40
|
+
"source": "/Users/user/Github/app/.claude/worktrees/feat-x",
|
|
38
41
|
"services": [
|
|
39
42
|
{
|
|
40
|
-
"name": "
|
|
41
|
-
"dir": "/Users/user/Github/
|
|
43
|
+
"name": "frontend",
|
|
44
|
+
"dir": "/Users/user/Github/app/.claude/worktrees/feat-x/web",
|
|
42
45
|
"command": "npm run dev",
|
|
43
46
|
"pid": 12345,
|
|
44
|
-
"port":
|
|
45
|
-
"
|
|
47
|
+
"port": 3999,
|
|
48
|
+
"headSha": "9f8e7d6c5b4a39281706f5e4d3c2b1a098f7e6d5",
|
|
49
|
+
"startedAt": "2026-10-22T10:30:00Z",
|
|
50
|
+
"log": "/Users/user/.muggle-ai/prepare/logs/-Users-user-Github-app-.claude-worktrees-feat-x/frontend.log"
|
|
46
51
|
}
|
|
47
52
|
]
|
|
48
53
|
}
|
|
49
54
|
```
|
|
50
55
|
|
|
51
|
-
`
|
|
56
|
+
`headSha` is the commit the checkout had out when the service started — what [check-running](./steps/check-running.md) compares against before trusting a listener. These files are machine-wide and readable by every session: they are how one session learns that a port belongs to another.
|
|
52
57
|
|
|
53
|
-
This
|
|
58
|
+
This is **ephemeral runtime state**, not the saved recipe. The durable plan lives in `~/.muggle-ai/prepare-plans.json`, under the entry keyed on this stack, and is consulted in [reuse-plan](./steps/reuse-plan.md) before any other stage. The two never merge. The `test-prepare-runner` agent writes the tracking files during execution; Cleanup reads them.
|
|
54
59
|
|
|
55
60
|
The prose companion to the plan is `~/.muggle-ai/e2e-instructions/<key>.md`, written by [e2e-instructions](./steps/e2e-instructions.md), holding startup order, manual steps, and local gotchas. The plan remains the single source of truth for each service's start command; the markdown never restates one.
|
|
56
61
|
|
|
57
62
|
**Everything this skill saves is machine-local, user-level data and lives under the Muggle home directory — never inside the user's project.** A project directory is shared, versioned, and cloned onto machines set up differently; a local run recipe is none of those things. Both files are keyed on the same stack identity, so they stay in lockstep.
|
|
58
63
|
|
|
59
|
-
**On every invocation**,
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
- Option 3: "Add more services to the running set"
|
|
64
|
+
**On every invocation**, prune dead PIDs from the tracking files silently (verify with `kill -0`). Whether a live service is kept is never asked: [check-running](./steps/check-running.md) keeps one still serving its checkout's current HEAD and restarts one serving older code.
|
|
65
|
+
|
|
66
|
+
## Code freshness
|
|
63
67
|
|
|
64
|
-
|
|
68
|
+
Every service runs code built on the latest base: the caller's own checkout, synced onto `origin/<base>`, for the repo under test; a base checkout pinned to the latest `origin/<default>` for every other repo. [rebase-check](./steps/rebase-check.md) and [resolve-sources](./steps/resolve-sources.md) run on **every** invocation, replays included — a saved recipe makes the start commands reusable, never the code they start.
|
|
65
69
|
|
|
66
70
|
## Preferences
|
|
67
71
|
|
|
@@ -69,7 +73,7 @@ Gates run per [`preference-gates/README.md`](../muggle-preferences/preference-ga
|
|
|
69
73
|
|
|
70
74
|
| Preference | Gates |
|
|
71
75
|
|------------|-------|
|
|
72
|
-
| `autoRebase` | [rebase-check](./steps/rebase-check.md) — rebase onto `origin/<
|
|
76
|
+
| `autoRebase` | [rebase-check](./steps/rebase-check.md) — rebase onto `origin/<base>` without asking before starting dev servers; not rebasing stops the run |
|
|
73
77
|
| `reusePreparePlan` | [reuse-plan](./steps/reuse-plan.md) — reuse the saved prepare plan for this stack, or rediscover; also [e2e-instructions](./steps/e2e-instructions.md), which goes stale for the same reason |
|
|
74
78
|
| `autoSelectLocalHost` | [check-running](./steps/check-running.md) — reuse the recorded dev-server URL silently, or confirm it each run |
|
|
75
79
|
|
|
@@ -85,13 +89,16 @@ Decide stages, in order; read each detail file when you reach it:
|
|
|
85
89
|
|:------|:--------|
|
|
86
90
|
| [replay-or-learn](./steps/replay-or-learn.md) | Replay the saved recipe, or learn a new one |
|
|
87
91
|
| [derive-service-graph](./steps/derive-service-graph.md) | Derive services from workspace manifests |
|
|
88
|
-
| [rebase-check](./steps/rebase-check.md) |
|
|
92
|
+
| [rebase-check](./steps/rebase-check.md) | Sync every checkout under test onto the latest base — replays too |
|
|
93
|
+
| [resolve-sources](./steps/resolve-sources.md) | Pick the checkout each service runs from — replays too |
|
|
89
94
|
| [scope](./steps/scope.md) | Frontend / backend / full stack |
|
|
90
95
|
| [viability-check](./steps/viability-check.md) | Exclude services that can't run locally |
|
|
91
96
|
| [identify-services](./steps/identify-services.md) | Confirm the derived graph; fill the gaps |
|
|
92
97
|
| [e2e-instructions](./steps/e2e-instructions.md) | Startup order, manual steps, local gotchas |
|
|
93
98
|
|
|
94
|
-
The Decide phase's output is the **resolved prepare plan**: `services[]` (name,
|
|
99
|
+
The Decide phase's output is the **resolved prepare plan**: `services[]` (name, run directory from [resolve-sources](./steps/resolve-sources.md), start command, expected port, `external` flag, approval granted), `testingScope`, `excludedServices[]`, the recorded dev-server URL, the E2E run instructions, and resolved gate outcomes.
|
|
100
|
+
|
|
101
|
+
A replay runs [rebase-check](./steps/rebase-check.md) and [resolve-sources](./steps/resolve-sources.md) before dispatching — they ask nothing unless a checkout cannot be brought up to date.
|
|
95
102
|
|
|
96
103
|
**Execute (agent).** Dispatch the `test-prepare-runner` agent (subagent type `muggle:test-prepare-runner`; bare `test-prepare-runner` where the plugin namespace is absent), synchronously, passing the resolved plan; it returns `READY` / `DEGRADED` plus the readiness table. The agent's own definition lists its stage files; in a harness with no agent/subagent facility, run the execute-phase stages ([check-running](./steps/check-running.md) through [readiness-report](./steps/readiness-report.md)) inline instead.
|
|
97
104
|
|
|
@@ -103,13 +110,14 @@ The agent also returns the problems it hit and what cleared them. On a learning
|
|
|
103
110
|
|
|
104
111
|
Triggered when the user says "stop services", "tear down", "clean up", "I'm done testing", another skill signals run complete, or this skill is re-invoked with "tear down and start fresh". Runs in-session, not in the agent.
|
|
105
112
|
|
|
106
|
-
|
|
113
|
+
Cleanup stops only what runs from the caller's own checkout. Another checkout's services may be mid-run in a peer session, and base-checkout services are shared — they stay up unless the user explicitly asks to stop everything.
|
|
114
|
+
|
|
115
|
+
1. Read the caller's checkout's tracking file (see [PID Tracking](#pid-tracking))
|
|
107
116
|
2. Skip services marked `external: true`
|
|
108
117
|
3. For each managed service: `kill <pid>` (SIGTERM)
|
|
109
118
|
4. Wait ~2 s, verify with `kill -0`
|
|
110
119
|
5. If still alive: `kill -9 <pid>`
|
|
111
|
-
6.
|
|
112
|
-
7. `rm -f /tmp/muggle-test-prepare.json`
|
|
120
|
+
6. Delete that checkout's log directory and tracking file
|
|
113
121
|
|
|
114
122
|
Report:
|
|
115
123
|
|
|
@@ -126,12 +134,15 @@ Stopped 3 services:
|
|
|
126
134
|
|
|
127
135
|
After a test run, the caller can re-invoke for cleanup or leave services running for the next run.
|
|
128
136
|
|
|
129
|
-
**
|
|
137
|
+
**The caller's checkout.** Invoke from the checkout under test — the worktree the change lives in. Its repo is the repo under test, and its services start from that checkout; every other repo's services start from that repo's base checkout ([resolve-sources](./steps/resolve-sources.md)). Pass `base` when the change targets a branch other than the remote default.
|
|
130
138
|
|
|
131
|
-
|
|
132
|
-
|
|
139
|
+
**Directory overrides.** A caller testing changes that span several repos at once may pass `directoryOverrides`: a map from a service's repo (its usual directory, or `owner/repo`) to the checkout that service must start from this run — typically a worktree on a feature branch. Each override makes its repo a repo under test, exactly like the caller's own checkout:
|
|
140
|
+
|
|
141
|
+
- An overridden service starts from the override directory, with its recorded start command. Its install and env-file steps run there too, and [rebase-check](./steps/rebase-check.md) syncs the override first.
|
|
142
|
+
- An overridden service already listening counts as running only when [check-running](./steps/check-running.md) proves it serves the override's current HEAD. Otherwise it is the wrong checkout: it is never tested against, and is restarted from the override under the same approval rules as any restart.
|
|
133
143
|
- Overrides are per-run. They never enter the saved recipe — a worktree path is not this stack's durable layout.
|
|
134
|
-
|
|
144
|
+
|
|
145
|
+
The readiness table names the directory and commit each service runs from, so the caller can confirm its own code is the code being served.
|
|
135
146
|
|
|
136
147
|
## Guardrails
|
|
137
148
|
|
|
@@ -142,11 +153,13 @@ After a test run, the caller can re-invoke for cleanup or leave services running
|
|
|
142
153
|
- **Never start a process the user didn't approve** — approvals are granted in Decide and travel in the plan; the agent starts nothing outside it.
|
|
143
154
|
- **Never read file contents outside confirmed directories** — folder names are discoverable; file contents require explicit user selection.
|
|
144
155
|
- **Never write a credential into the E2E run instructions** — plaintext notes are not a secret store, and this is the file a user pastes when asking why their stack won't start. Record the env-var or secret name, never its value.
|
|
145
|
-
- **Never leave orphan processes untracked** — every background PID goes into
|
|
156
|
+
- **Never leave orphan processes untracked** — every background PID goes into its checkout's tracking file.
|
|
146
157
|
- **Never kill a process the user started independently** — `external: true` survives cleanup.
|
|
158
|
+
- **Never kill or test against another checkout's service** — a listener tracked under a different checkout belongs to a peer session; see [check-running](./steps/check-running.md).
|
|
159
|
+
- **Never start code that is not on the latest base** — no replay, preference, or approval skips [rebase-check](./steps/rebase-check.md) or [resolve-sources](./steps/resolve-sources.md).
|
|
147
160
|
- **Never assume start commands** — verify via indicator file; confirm with user.
|
|
148
161
|
- **Bail early on non-viable services** — don't start what can't run locally.
|
|
149
|
-
- **Idempotent** —
|
|
162
|
+
- **Idempotent** — a tracked, alive service still serving its checkout's current HEAD is kept; [smoke-test](./steps/smoke-test.md) still runs against it.
|
|
150
163
|
- **Port-listening is never enough** — smoke-test (HTTP + body sniff + log tail) is mandatory before the final report.
|
|
151
164
|
- **Clean Restart is the recommended fix** — first option in the smoke-test diagnose-and-fix loop; lint/build/missing-deps issues need nuke-and-reinstall.
|
|
152
165
|
- **Fresh install is automatic** — [fresh-install](./steps/fresh-install.md) notifies, doesn't ask.
|
|
@@ -13,29 +13,44 @@ The resolved host fixes the **expected** dev-server port for the detection below
|
|
|
13
13
|
|
|
14
14
|
## Detect listening services
|
|
15
15
|
|
|
16
|
-
Run port detection and (when an app declares a backend URL) backend-health probe per [`../../_shared/dev-server-readiness.md`](../../_shared/dev-server-readiness.md).
|
|
16
|
+
Run port detection and (when an app declares a backend URL) backend-health probe per [`../../_shared/dev-server-readiness.md`](../../_shared/dev-server-readiness.md).
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
## Prove what each listener serves
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
A port that answers proves nothing about which code answers it — a peer session's dev server, or last week's, answers just as well. Judge every listener on a service's port against the tracking files ([PID Tracking](../SKILL.md#pid-tracking)) and the service's run directory and commit from [resolve-sources](./resolve-sources.md):
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
-
|
|
22
|
+
| Listener | Verdict |
|
|
23
|
+
| :------- | :------ |
|
|
24
|
+
| A tracking entry with this port, a live PID, `dir` = the run directory and `headSha` = the commit it must serve | **Proven** — keep it. A base-checkout service a peer started is proven the same way, and shared |
|
|
25
|
+
| The plan marks the service `external: true` | **Vouched** — the user confirmed in Decide that they run it from this checkout; keep it, never kill it |
|
|
26
|
+
| Tracked under the run directory's checkout at an older `headSha` | **Stale** — restart it per [start-services](./start-services.md) |
|
|
27
|
+
| Tracked under a different checkout, PID alive | **A peer's** — never test against it, never kill it; [Port already held](#port-already-held) |
|
|
28
|
+
| Untracked | **Unknown code** — when the plan approves a restart for this service, treat it as stale: Clean Restart it through [smoke-test](./smoke-test.md)'s loop (kill → [fresh-install](./fresh-install.md) → [start-services](./start-services.md) → re-test). Otherwise [Port already held](#port-already-held) |
|
|
25
29
|
|
|
26
|
-
|
|
30
|
+
An approved restart settles whose port it is. When the restart cannot free or claim the port — the old process survives the kill, or the port keeps answering with code this run did not start — the service is broken, not contested: it stays in the smoke-test loop and ends `DEGRADED` with that diagnosis, never `needs-input`. `DEGRADED` already stops the caller from testing, so nothing foreign is ever reported `READY`. [Port already held](#port-already-held) is only for a peer's service, or for unknown code the plan gives no restart approval for.
|
|
31
|
+
|
|
32
|
+
> "**backend-api** on port 3001 (PID 54321) serves `api/.claude/worktrees/base-main` @ `a1b2c3d` — proven."
|
|
33
|
+
|
|
34
|
+
If **all** required services are proven or vouched, skip straight to [smoke-test](./smoke-test.md) — don't trust port-listening alone.
|
|
35
|
+
|
|
36
|
+
Otherwise continue to [start-commands](./start-commands.md) only for the services still missing. **Exception:** when this stage is entered via the [reuse-plan](./reuse-plan.md) short-circuit, the missing entries already carry their `command` from the reused plan — skip `start-commands` and go straight to [env-file](./env-file.md).
|
|
27
37
|
|
|
28
38
|
## Port already held
|
|
29
39
|
|
|
30
|
-
When the
|
|
40
|
+
When a port the run needs is held by a process this run may not touch — a peer's service, or unknown code with no restart approved:
|
|
41
|
+
|
|
42
|
+
The held process is likely something the user — or a parallel session — is still using. Don't auto-decide. In the agent, return `needs-input:` naming the port, the PID, and the checkout its tracking entry names (or "untracked"); the skill asks:
|
|
31
43
|
|
|
32
44
|
The held process is likely something the user is still using — a current test or dev server they value more than this prepare run. Don't auto-decide; leave the kill-vs-pause call to them.
|
|
33
45
|
|
|
34
|
-
> "Port 3999 is held by PID 87421
|
|
46
|
+
> "Port 3999 is held by PID 87421, serving `app/.claude/worktrees/feat-y` — not this change's code. How do you want to proceed?"
|
|
35
47
|
|
|
36
48
|
- Option 1: "Use the next available port" (recommended — non-destructive, leaves the existing process running)
|
|
37
|
-
- Option 2: "Force-kill PID 87421 and claim port 3999" (kill-switch — only if
|
|
49
|
+
- Option 2: "Force-kill PID 87421 and claim port 3999" (kill-switch — only if nobody needs that process)
|
|
38
50
|
- Option 3: "Pause — leave it running, I'll finish up and re-run prepare later"
|
|
51
|
+
- Option 4: "It's mine — I started it from `<run directory>`" (untracked listeners only) → mark the service `external: true` in the plan and record the listener in the run directory's tracking file at its current HEAD
|
|
52
|
+
|
|
53
|
+
Testing against a listener nobody can tie to this change's checkout is never an option: its results describe someone else's code.
|
|
39
54
|
|
|
40
55
|
**Option 1**: probe `3999 + N` for `N = 1, 2, …` until nothing listens. Record the new port and any env file edit (`PORT=` in `.env.local` etc.). Dev server may need restart to pick up.
|
|
41
56
|
|
|
@@ -24,7 +24,7 @@ One file per stack:
|
|
|
24
24
|
~/.muggle-ai/e2e-instructions/<key>.md
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
-
`<key>` is the
|
|
27
|
+
`<key>` is the stack key from [reuse-plan](./reuse-plan.md) — the same stack identity the global prepare plan keys its entries on — reduced to a filename-safe token by replacing every path separator, and any drive-letter colon, with `-`. A file saved under an older key is adopted and renamed the same way the plan entry is. Derive it from the resolved absolute path rather than assuming a separator character; they differ per platform.
|
|
28
28
|
|
|
29
29
|
Missing → no saved instructions; run the capture below.
|
|
30
30
|
|