@muggleai/works 4.3.0 → 4.5.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/README.md +31 -13
- package/dist/{chunk-23NOSJFH.js → chunk-MNCBJEPQ.js} +588 -36
- package/dist/cli.js +1 -1
- package/dist/index.js +1 -1
- package/dist/plugin/.claude-plugin/plugin.json +1 -1
- package/dist/plugin/.cursor-plugin/plugin.json +1 -1
- package/dist/plugin/README.md +1 -0
- package/dist/plugin/skills/do/open-prs.md +32 -65
- package/dist/plugin/skills/muggle/SKILL.md +15 -15
- package/dist/plugin/skills/muggle-pr-visual-walkthrough/SKILL.md +181 -0
- package/dist/plugin/skills/muggle-test/SKILL.md +97 -137
- package/dist/plugin/skills/muggle-test-feature-local/SKILL.md +94 -27
- package/dist/plugin/skills/muggle-test-import/SKILL.md +135 -40
- package/dist/plugin/skills/muggle-test-regenerate-missing/SKILL.md +196 -0
- package/dist/plugin/skills/muggle-test-regenerate-missing/evals/evals.json +58 -0
- package/dist/plugin/skills/muggle-test-regenerate-missing/evals/trigger-eval.json +22 -0
- package/dist/release-manifest.json +7 -0
- package/package.json +7 -7
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/.cursor-plugin/plugin.json +1 -1
- package/plugin/README.md +1 -0
- package/plugin/skills/do/open-prs.md +32 -65
- package/plugin/skills/muggle/SKILL.md +15 -15
- package/plugin/skills/muggle-pr-visual-walkthrough/SKILL.md +181 -0
- package/plugin/skills/muggle-test/SKILL.md +97 -137
- package/plugin/skills/muggle-test-feature-local/SKILL.md +94 -27
- package/plugin/skills/muggle-test-import/SKILL.md +135 -40
- package/plugin/skills/muggle-test-regenerate-missing/SKILL.md +196 -0
- package/plugin/skills/muggle-test-regenerate-missing/evals/evals.json +58 -0
- package/plugin/skills/muggle-test-regenerate-missing/evals/trigger-eval.json +22 -0
package/dist/cli.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { src_exports2 as commands, createChildLogger, createUnifiedMcpServer, e2e_exports as e2e, getConfig, getLocalQaTools, getLogger, getQaTools, local_exports as localQa, mcp_exports as mcp, e2e_exports as qa, server_exports as server, src_exports as shared } from './chunk-
|
|
1
|
+
export { src_exports2 as commands, createChildLogger, createUnifiedMcpServer, e2e_exports as e2e, getConfig, getLocalQaTools, getLogger, getQaTools, local_exports as localQa, mcp_exports as mcp, e2e_exports as qa, server_exports as server, src_exports as shared } from './chunk-MNCBJEPQ.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "muggle",
|
|
3
3
|
"description": "Run real-browser end-to-end (E2E) acceptance tests on your web app from any AI coding agent. Generate test scripts from plain English, replay them on localhost, capture screenshots, and validate user flows like signup, checkout, and dashboards. Works across Claude Code, Cursor, Codex, and Windsurf.",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.5.0",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Muggle AI",
|
|
7
7
|
"email": "support@muggle-ai.com"
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "muggle",
|
|
3
3
|
"displayName": "Muggle AI",
|
|
4
4
|
"description": "Ship quality products with AI-powered end-to-end (E2E) acceptance testing that validates your web app like a real user — from Claude Code and Cursor to PR.",
|
|
5
|
-
"version": "4.
|
|
5
|
+
"version": "4.5.0",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Muggle AI",
|
|
8
8
|
"email": "support@muggle-ai.com"
|
package/dist/plugin/README.md
CHANGED
|
@@ -28,6 +28,7 @@ Type `muggle` to discover the full command family.
|
|
|
28
28
|
| `/muggle:muggle-test` | Change-driven E2E acceptance router: detects code changes, maps to use cases, runs test generation locally or remotely, publishes to dashboard, opens in browser, posts E2E acceptance results to PR. |
|
|
29
29
|
| `/muggle:muggle-test-feature-local` | Test a feature on localhost with AI-driven browser automation. Offers publish to cloud after each run. |
|
|
30
30
|
| `/muggle:muggle-test-import` | Import existing tests into Muggle Test — from Playwright/Cypress specs, PRDs, Gherkin feature files, test plan docs, or any test artifact. |
|
|
31
|
+
| `/muggle:muggle-test-regenerate-missing` | Bulk-regenerate test scripts for every test case in a project that doesn't currently have an active script. Scans DRAFT + GENERATION_PENDING, confirms the list with the user, and dispatches remote generation workflows for each. |
|
|
31
32
|
| `/muggle:muggle-status` | Health check for Electron browser test runner, MCP server, and authentication. |
|
|
32
33
|
| `/muggle:muggle-repair` | Diagnose and fix broken installation automatically. |
|
|
33
34
|
| `/muggle:muggle-upgrade` | Update Electron browser test runner and MCP server to latest version. |
|
|
@@ -23,94 +23,61 @@ For each repo with changes:
|
|
|
23
23
|
- If E2E acceptance tests have failures: `[E2E FAILING] <goal>`
|
|
24
24
|
- Otherwise: `<goal>`
|
|
25
25
|
- Keep under 70 characters
|
|
26
|
-
3. **
|
|
26
|
+
3. **Render the E2E acceptance block** by invoking the shared `muggle-pr-visual-walkthrough` skill in **Mode B** (render-only for embedding). See "Rendering the E2E acceptance block via the shared skill" below. You receive `{body, comment}` where `body` is the E2E markdown block and `comment` is a non-null overflow comment only when the content exceeds the CLI's byte budget.
|
|
27
|
+
4. **Build the PR body** by concatenating, in order:
|
|
27
28
|
- `## Goal` — the requirements goal
|
|
28
29
|
- `## Acceptance Criteria` — bulleted list (omit section if empty)
|
|
29
30
|
- `## Changes` — summary of what changed in this repo
|
|
30
|
-
- `## E2E Acceptance Results` —
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
- The `body` field from the skill output (already contains its own `## E2E Acceptance Results` header — do not add another)
|
|
32
|
+
5. **Create the PR** using `gh pr create --title "..." --body "..." --head <branch>` in the repo directory.
|
|
33
|
+
6. **Capture the PR URL** and extract the PR number.
|
|
34
|
+
7. **Post the overflow `comment` only if it is non-null.** In the common case, `comment` is `null` and nothing is posted. Never post speculatively.
|
|
34
35
|
|
|
35
|
-
|
|
36
|
+
```bash
|
|
37
|
+
gh pr comment <PR#> --body "$(cat <<'EOF'
|
|
38
|
+
<comment field contents>
|
|
39
|
+
EOF
|
|
40
|
+
)"
|
|
41
|
+
```
|
|
36
42
|
|
|
37
|
-
|
|
38
|
-
## E2E Acceptance Results
|
|
43
|
+
## Rendering the E2E acceptance block via the shared skill
|
|
39
44
|
|
|
40
|
-
**
|
|
45
|
+
**Do not hand-write the `## E2E Acceptance Results` markdown, and do not call `muggle build-pr-section` directly from this stage.** The rendering workflow is owned by the shared **`muggle-pr-visual-walkthrough`** skill (see `plugin/skills/muggle-pr-visual-walkthrough/SKILL.md`), which wraps the CLI and enforces the `E2eReport` input contract with a Zod schema.
|
|
41
46
|
|
|
42
|
-
|
|
43
|
-
|-----------|--------|---------|
|
|
44
|
-
| [Name]({viewUrl}) | ✅ PASSED | — |
|
|
45
|
-
| [Name]({viewUrl}) | ❌ FAILED | {error} |
|
|
46
|
-
```
|
|
47
|
+
### Input — the `E2eReport` JSON
|
|
47
48
|
|
|
48
|
-
|
|
49
|
+
The `e2e-acceptance.md` stage already produces an `E2eReport` with the exact shape the skill expects (`projectId` + `tests[]` with per-test `name`, `testCaseId`, `testScriptId`, `runId`, `viewUrl`, `status`, and `steps[]` of `{stepIndex, action, screenshotUrl}`; failed tests additionally have `failureStepIndex`, `error`, and optionally `artifactsDir`). Pass it through unchanged — do not reshape it. The full schema is documented in the shared skill.
|
|
49
50
|
|
|
50
|
-
|
|
51
|
+
### Invocation — Mode B (render-only)
|
|
51
52
|
|
|
52
|
-
|
|
53
|
-
gh pr comment <PR#> --body "$(cat <<'EOF'
|
|
54
|
-
## 🧪 E2E acceptance evidence
|
|
53
|
+
Invoke `muggle-pr-visual-walkthrough` via the `Skill` tool with the `E2eReport` already in context. The skill will:
|
|
55
54
|
|
|
56
|
-
|
|
55
|
+
1. Validate the `E2eReport` and call `muggle build-pr-section` (piping the JSON to stdin).
|
|
56
|
+
2. Parse the CLI's `{body, comment}` stdout.
|
|
57
|
+
3. **Return `{body, comment}` to this stage's conversation** without posting anything — because Mode B is render-only. `body` is the E2E markdown block; `comment` is a non-null overflow follow-up comment only when content exceeds the byte budget, otherwise `null`.
|
|
57
58
|
|
|
58
|
-
|
|
59
|
-
|-----------|--------|---------|
|
|
60
|
-
| [Login Flow]({viewUrl}) | ✅ PASSED | <a href="{lastStepScreenshotUrl}"><img src="{lastStepScreenshotUrl}" width="120"></a> |
|
|
61
|
-
| [Checkout]({viewUrl}) | ❌ FAILED | <a href="{failureStepScreenshotUrl}"><img src="{failureStepScreenshotUrl}" width="120"></a> |
|
|
59
|
+
Mode A (where the skill itself finds an existing PR and posts a `gh pr comment`) is **not used by `muggle-do`** — it's for interactive callers like `muggle-test` that are mid-development with a PR already open. `muggle-do` always creates new PRs, so it always uses Mode B.
|
|
62
60
|
|
|
63
|
-
|
|
64
|
-
<summary>📸 <strong>Login Flow</strong> — 5 steps</summary>
|
|
61
|
+
### After rendering
|
|
65
62
|
|
|
66
|
-
|
|
67
|
-
|---|--------|------------|
|
|
68
|
-
| 1 | Navigate to `/login` | <a href="{screenshotUrl}"><img src="{screenshotUrl}" width="200"></a> |
|
|
69
|
-
| 2 | Enter username | <a href="{screenshotUrl}"><img src="{screenshotUrl}" width="200"></a> |
|
|
70
|
-
| 3 | Click "Sign In" | <a href="{screenshotUrl}"><img src="{screenshotUrl}" width="200"></a> |
|
|
63
|
+
Back in this stage:
|
|
71
64
|
|
|
72
|
-
|
|
65
|
+
- Embed `body` in the `gh pr create --body` body (see step 4 above).
|
|
66
|
+
- Post the overflow `comment` as a follow-up **only when it is non-null** (see step 7 above).
|
|
67
|
+
- If the CLI exited non-zero, the skill surfaces the stderr error — do not swallow it, surface it to the user.
|
|
73
68
|
|
|
74
|
-
|
|
75
|
-
<summary>📸 <strong>Checkout</strong> — 4 steps (failed at step 3)</summary>
|
|
69
|
+
### Notes on fit vs. overflow
|
|
76
70
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
| 2 | View cart | <a href="{screenshotUrl}"><img src="{screenshotUrl}" width="200"></a> |
|
|
81
|
-
| 3 ⚠️ | Click confirm — **Element not found** | <a href="{screenshotUrl}"><img src="{screenshotUrl}" width="200"></a> |
|
|
82
|
-
|
|
83
|
-
</details>
|
|
84
|
-
EOF
|
|
85
|
-
)"
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
### Comment Building Rules
|
|
89
|
-
|
|
90
|
-
1. **Summary table:**
|
|
91
|
-
- Show thumbnail (120px) of **last step** for passed tests
|
|
92
|
-
- Show thumbnail of **failure step** for failed tests
|
|
93
|
-
- Thumbnail links to full-size image
|
|
94
|
-
|
|
95
|
-
2. **Collapsible details per test case:**
|
|
96
|
-
- Show all steps with 200px thumbnails
|
|
97
|
-
- Mark failure step with ⚠️ and inline error message
|
|
98
|
-
- Include step count in summary line
|
|
99
|
-
|
|
100
|
-
3. **HTML for thumbnails:**
|
|
101
|
-
- Use `<a href="{url}"><img src="{url}" width="N"></a>` for clickable thumbnails
|
|
102
|
-
- 120px width in summary table, 200px in details
|
|
103
|
-
|
|
104
|
-
4. **All tests get screenshots:**
|
|
105
|
-
- Passing tests show proof of success
|
|
106
|
-
- Failing tests highlight the failure point
|
|
71
|
+
- **Common case (fit):** the full evidence (summary, per-test rows, collapsible failure details) lives in the PR description, `comment` is `null`, no follow-up comment is posted.
|
|
72
|
+
- **Overflow case:** the CLI detects the full body would exceed its byte budget; `body` contains the summary, per-test rows, and a pointer line; `comment` contains the overflow details. Post both.
|
|
73
|
+
- You do not make the fit-vs-overflow decision — the CLI does. Never post the comment when it is `null`.
|
|
107
74
|
|
|
108
75
|
## Output
|
|
109
76
|
|
|
110
77
|
**PRs Created:**
|
|
111
78
|
- (repo name): (PR URL)
|
|
112
79
|
|
|
113
|
-
**E2E acceptance
|
|
80
|
+
**E2E acceptance overflow comments posted:** (only include repos where an overflow comment was actually posted)
|
|
114
81
|
- (repo name): comment posted to PR #(number)
|
|
115
82
|
|
|
116
83
|
**Errors:** (any repos where PR creation or comment posting failed, with the error message)
|
|
@@ -9,24 +9,24 @@ Use this as the top-level Muggle command router.
|
|
|
9
9
|
|
|
10
10
|
## Menu
|
|
11
11
|
|
|
12
|
-
When user asks for "muggle" with no specific subcommand,
|
|
12
|
+
When user asks for "muggle" with no specific subcommand, use `AskQuestion` to present the command set as clickable options:
|
|
13
13
|
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
14
|
+
- "Test my changes — change-driven E2E acceptance testing (local or remote)" → `muggle-test`
|
|
15
|
+
- "Test a feature on localhost — run a single E2E test locally" → `muggle-test-feature-local`
|
|
16
|
+
- "Autonomous dev pipeline — requirements to PR" → `muggle-do`
|
|
17
|
+
- "Health check — verify installation status" → `muggle-status`
|
|
18
|
+
- "Repair — fix broken installation" → `muggle-repair`
|
|
19
|
+
- "Upgrade — update to latest version" → `muggle-upgrade`
|
|
20
20
|
|
|
21
21
|
## Routing
|
|
22
22
|
|
|
23
|
-
If the user intent clearly matches one command, route
|
|
23
|
+
If the user intent clearly matches one command, route directly — no menu needed:
|
|
24
24
|
|
|
25
|
-
- status/health/check
|
|
26
|
-
- repair/fix/install broken
|
|
27
|
-
- upgrade/update latest
|
|
28
|
-
- test my changes/acceptance test my work/test before push/post E2E acceptance results to PR/test on staging/test on preview
|
|
29
|
-
- test localhost/validate single feature
|
|
30
|
-
- build/implement from request
|
|
25
|
+
- status/health/check → `muggle-status`
|
|
26
|
+
- repair/fix/install broken → `muggle-repair`
|
|
27
|
+
- upgrade/update latest → `muggle-upgrade`
|
|
28
|
+
- test my changes/acceptance test my work/test before push/post E2E acceptance results to PR/test on staging/test on preview → `muggle-test`
|
|
29
|
+
- test localhost/validate single feature → `muggle-test-feature-local`
|
|
30
|
+
- build/implement from request → `muggle-do`
|
|
31
31
|
|
|
32
|
-
If intent is ambiguous,
|
|
32
|
+
If intent is ambiguous, use `AskQuestion` with the most likely options rather than asking the user to type a clarification.
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: muggle-pr-visual-walkthrough
|
|
3
|
+
description: Renders and posts a visual walkthrough of Muggle AI E2E acceptance test results to a PR — per-test-case dashboard links, step-by-step screenshots, and pass/fail summary — using the `muggle build-pr-section` CLI for deterministic formatting with automatic fit-vs-overflow. Use at the end of any Muggle test run (local or remote) to give PR reviewers clickable visual evidence that user flows work. Triggers on 'post results to PR', 'attach walkthrough to PR', 'share E2E screenshots on the PR', 'add visual walkthrough to PR'.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Muggle PR Visual Walkthrough
|
|
7
|
+
|
|
8
|
+
Renders a visual walkthrough of Muggle AI E2E acceptance test results and posts it to a PR. Each test case is linked to its detail page on the Muggle AI dashboard, so PR reviewers can click through to see step-by-step screenshots and action scripts — not just a pass/fail flag.
|
|
9
|
+
|
|
10
|
+
This is the **canonical PR-walkthrough workflow** shared across every Muggle entry point:
|
|
11
|
+
|
|
12
|
+
| Caller | Mode | When to invoke |
|
|
13
|
+
| :--- | :--- | :--- |
|
|
14
|
+
| `muggle-test` | **Mode A** (post to existing PR) | After publishing results, user opts in via `AskQuestion` |
|
|
15
|
+
| `muggle-test-feature-local` | **Mode A** (post to existing PR) | After publishing the run, user opts in via `AskQuestion` |
|
|
16
|
+
| `muggle-do` / `open-prs.md` | **Mode B** (render-only for embedding) | During PR creation — caller embeds `body` in `gh pr create` and posts `comment` as follow-up |
|
|
17
|
+
|
|
18
|
+
Rendering is always done by `muggle build-pr-section`, a battle-tested CLI that handles deterministic markdown layout, per-step screenshots, and automatic fit-vs-overflow (oversized content spills into a follow-up comment). Never hand-write the walkthrough markdown.
|
|
19
|
+
|
|
20
|
+
## Input contract: the `E2eReport` JSON
|
|
21
|
+
|
|
22
|
+
Every caller must build an `E2eReport` JSON object and have it in conversation context before invoking this skill. The schema is defined in `src/cli/pr-section/types.ts` (`E2eReportSchema`) and enforced by the CLI with Zod — malformed input exits non-zero with a descriptive stderr message.
|
|
23
|
+
|
|
24
|
+
```json
|
|
25
|
+
{
|
|
26
|
+
"projectId": "<UUID>",
|
|
27
|
+
"tests": [
|
|
28
|
+
{
|
|
29
|
+
"name": "<test case name>",
|
|
30
|
+
"testCaseId": "<UUID>",
|
|
31
|
+
"testScriptId": "<UUID>",
|
|
32
|
+
"runId": "<UUID>",
|
|
33
|
+
"viewUrl": "https://www.muggle-ai.com/...",
|
|
34
|
+
"status": "passed",
|
|
35
|
+
"steps": [
|
|
36
|
+
{ "stepIndex": 0, "action": "Click login button", "screenshotUrl": "https://..." },
|
|
37
|
+
{ "stepIndex": 1, "action": "Type email", "screenshotUrl": "https://..." }
|
|
38
|
+
]
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"name": "Checkout flow",
|
|
42
|
+
"testCaseId": "<UUID>",
|
|
43
|
+
"testScriptId": "<UUID>",
|
|
44
|
+
"runId": "<UUID>",
|
|
45
|
+
"viewUrl": "https://www.muggle-ai.com/...",
|
|
46
|
+
"status": "failed",
|
|
47
|
+
"steps": [
|
|
48
|
+
{ "stepIndex": 0, "action": "Open cart", "screenshotUrl": "https://..." }
|
|
49
|
+
],
|
|
50
|
+
"failureStepIndex": 2,
|
|
51
|
+
"error": "Element not found: Click checkout button",
|
|
52
|
+
"artifactsDir": "/Users/.../~/.muggle-ai/sessions/<runId>"
|
|
53
|
+
}
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Required fields per test: `name`, `testCaseId`, `runId`, `viewUrl`, `status`, `steps[]` with `{stepIndex, action, screenshotUrl}`. Failed tests additionally require `failureStepIndex` and `error`. `testScriptId` and `artifactsDir` are optional.
|
|
59
|
+
|
|
60
|
+
If any required field is missing, stop and tell the caller exactly what's missing. Never fabricate data.
|
|
61
|
+
|
|
62
|
+
## Step 1: Gather the `E2eReport`
|
|
63
|
+
|
|
64
|
+
How to assemble the JSON depends on which caller you are:
|
|
65
|
+
|
|
66
|
+
### From `muggle-test` / `muggle-test-feature-local` (local mode)
|
|
67
|
+
|
|
68
|
+
After `muggle-local-publish-test-script` returns `{testScriptId, viewUrl, ...}` for each run:
|
|
69
|
+
|
|
70
|
+
1. Call `muggle-remote-test-script-get` with `testScriptId` to fetch the published script.
|
|
71
|
+
2. Extract `steps[]` — for each step, build `{stepIndex: <index>, action: operation.action, screenshotUrl: operation.screenshotUrl}`.
|
|
72
|
+
3. Determine `status` from the local run result (`muggle-local-run-result-get`).
|
|
73
|
+
4. For failures, read `failureStepIndex`, `error`, and `artifactsDir` from the run result.
|
|
74
|
+
5. Assemble the `E2eReport` with `projectId` from the test run.
|
|
75
|
+
|
|
76
|
+
### From `muggle-do` (`open-prs.md`)
|
|
77
|
+
|
|
78
|
+
The `e2e-acceptance.md` stage already produces an `E2eReport` with the exact shape above — that is the report's native output format. Pass it through unchanged.
|
|
79
|
+
|
|
80
|
+
### Direct invocation (user asked to post existing results)
|
|
81
|
+
|
|
82
|
+
The caller must have already executed tests and published them. If the `E2eReport` is not in context, stop and tell the user to run `muggle-test` or `muggle-test-feature-local` first.
|
|
83
|
+
|
|
84
|
+
## Step 2: Render via `muggle build-pr-section`
|
|
85
|
+
|
|
86
|
+
Pipe the `E2eReport` JSON to the CLI. It writes `{"body": "...", "comment": "..." | null}` to stdout — the `body` is the E2E markdown block, and `comment` is a non-null overflow comment only when the full body exceeds the byte budget (default 60 KB).
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
echo "$REPORT_JSON" | muggle build-pr-section > /tmp/muggle-pr-section.json
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
- Exit **non-zero** → the CLI wrote a descriptive error to stderr. Surface it to the user; do not swallow it.
|
|
93
|
+
- `comment` is **`null`** (fit case) → everything is inline in `body`. Post `body` only.
|
|
94
|
+
- `comment` is a **non-null string** (overflow case) → `body` contains the summary + a pointer; `comment` contains the full per-step details. Post both, in order.
|
|
95
|
+
|
|
96
|
+
Never hand-write the walkthrough markdown. Never modify the CLI's output before posting. The CLI owns the format.
|
|
97
|
+
|
|
98
|
+
## Step 3 — Mode A: Post to an existing PR
|
|
99
|
+
|
|
100
|
+
Used by `muggle-test` and `muggle-test-feature-local`, where the user is mid-development and a PR already exists on the current branch.
|
|
101
|
+
|
|
102
|
+
### 3A.1: Find the PR
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
gh pr view --json number,url,title 2>/dev/null
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
- **PR exists** → continue to 3A.2
|
|
109
|
+
- **No PR exists** → use `AskQuestion`:
|
|
110
|
+
- "Create a new PR with the visual walkthrough in the body"
|
|
111
|
+
- "Skip posting"
|
|
112
|
+
- If the user chooses to create a new PR, switch to Mode B and return the rendered `body`/`comment` to the caller for embedding in `gh pr create`. Do not create the PR directly from this skill unless the caller has no better way to do it.
|
|
113
|
+
- **`gh` not installed or not authenticated** → tell the user, suggest `gh auth login`, stop.
|
|
114
|
+
|
|
115
|
+
### 3A.2: Post the body as a PR comment
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
gh pr comment <pr-number> --body "$(cat <<'EOF'
|
|
119
|
+
<contents of body field from CLI output>
|
|
120
|
+
EOF
|
|
121
|
+
)"
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### 3A.3: Post the overflow comment only if the CLI emitted one
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
gh pr comment <pr-number> --body "$(cat <<'EOF'
|
|
128
|
+
<contents of comment field from CLI output>
|
|
129
|
+
EOF
|
|
130
|
+
)"
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
**Skip this step entirely if `comment` is `null`** — do not post a placeholder. The CLI decides fit-vs-overflow; never post the overflow comment speculatively.
|
|
134
|
+
|
|
135
|
+
### 3A.4: Confirm to the user
|
|
136
|
+
|
|
137
|
+
> "Visual walkthrough posted to PR #<number>. Reviewers can click any test case link to see the step-by-step screenshots on the Muggle AI dashboard."
|
|
138
|
+
|
|
139
|
+
Include the PR URL in the confirmation.
|
|
140
|
+
|
|
141
|
+
## Step 3 — Mode B: Return rendered block for embedding in a new PR
|
|
142
|
+
|
|
143
|
+
Used by `muggle-do`'s `open-prs.md`, where the PR does not exist yet and the caller is assembling the PR body from multiple sections (`## Goal`, `## Acceptance Criteria`, `## Changes`, plus this walkthrough).
|
|
144
|
+
|
|
145
|
+
Instead of posting, **return** the CLI output to the caller's context so they can:
|
|
146
|
+
|
|
147
|
+
1. **Embed `body`** in their PR body, concatenated after `## Changes`. `body` already includes its own `## E2E Acceptance Results` header — do not add another.
|
|
148
|
+
2. **Create the PR** with `gh pr create --title "..." --body "..."` using the concatenated body.
|
|
149
|
+
3. **Post `comment` as a follow-up only if the CLI emitted one:**
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
gh pr comment <new-pr-number> --body "$(cat <<'EOF'
|
|
153
|
+
<contents of comment field>
|
|
154
|
+
EOF
|
|
155
|
+
)"
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
Skip if `comment` is `null`.
|
|
159
|
+
|
|
160
|
+
In Mode B, this skill does not call `gh pr comment` or `gh pr create` itself — the caller owns PR creation because it also owns branch pushing, title building (including `[E2E FAILING]` prefix on failures), and multi-repo orchestration.
|
|
161
|
+
|
|
162
|
+
## Tool Reference
|
|
163
|
+
|
|
164
|
+
| Phase | Tool |
|
|
165
|
+
|:------|:-----|
|
|
166
|
+
| Gather per-step data (muggle-test, muggle-test-feature-local) | `muggle-remote-test-script-get` |
|
|
167
|
+
| Render the walkthrough markdown | `muggle build-pr-section` (shell) |
|
|
168
|
+
| Find existing PR (Mode A) | `gh pr view` |
|
|
169
|
+
| Post comment(s) (Mode A) | `gh pr comment` |
|
|
170
|
+
| Create new PR (Mode B, caller handles) | `gh pr create` |
|
|
171
|
+
| User confirmation (Mode A no-PR branch) | `AskQuestion` |
|
|
172
|
+
|
|
173
|
+
## Guardrails
|
|
174
|
+
|
|
175
|
+
- **Never hand-write the walkthrough markdown** — always call `muggle build-pr-section`. The CLI is the single source of truth for formatting.
|
|
176
|
+
- **Never modify the CLI's output** — post `body` and (if present) `comment` verbatim. Any reformatting defeats the fit-vs-overflow budget math.
|
|
177
|
+
- **Never invent report fields** — if `projectId`, a per-test `viewUrl`, or per-step `screenshotUrl` is missing, stop and report what's missing. Do not fabricate URLs or fill in placeholders.
|
|
178
|
+
- **Never post the overflow comment when `comment` is `null`** — the CLI decides fit-vs-overflow.
|
|
179
|
+
- **Never create a PR without confirmation in Mode A** — if no PR exists, ask the user or switch to Mode B and hand back to the caller.
|
|
180
|
+
- **Don't run tests** — this skill only renders and posts existing results. If the `E2eReport` is not in context, redirect the caller to `muggle-test`, `muggle-test-feature-local`, or `muggle-do`.
|
|
181
|
+
- **Mode A vs Mode B is chosen by the caller, not the user** — `muggle-test` always uses Mode A; `muggle-do` always uses Mode B. Don't ask the user which mode to use.
|