levi-gear 0.5.0 → 0.7.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 +21 -14
- package/agents/designer.md +1 -0
- package/agents/developer.md +2 -1
- package/agents/pm.md +2 -1
- package/agents/qa.md +2 -1
- package/agents/teamlead.md +1 -0
- package/docs/README.md +39 -0
- package/docs/authoring-usecases.md +124 -0
- package/docs/cli.md +99 -0
- package/docs/codex.md +35 -0
- package/docs/configuration.md +84 -0
- package/docs/contributing.md +46 -0
- package/docs/customization.md +45 -0
- package/docs/installation.md +82 -0
- package/docs/introduction.md +49 -0
- package/docs/team.md +143 -0
- package/docs/troubleshooting.md +63 -0
- package/docs/unattended-runs.md +51 -0
- package/docs/updating.md +109 -0
- package/docs/usage.md +62 -0
- package/docs/usecases.md +471 -0
- package/package.json +4 -3
- package/src/cli.js +2 -2
- package/src/commands/init.js +20 -10
- package/src/commands/list.js +1 -1
- package/src/commands/update.js +2 -2
- package/src/lib/agents.js +6 -1
- package/src/lib/desired-state.js +65 -5
- package/src/lib/sync.js +1 -1
- package/src/lib/tools.js +4 -3
- package/src/runtime/codex-checkpoint.mjs +48 -0
- package/usecases/_run-rules.md +10 -1
- package/usecases/create-feature/SKILL.md +20 -15
- package/usecases/create-feature/scripts/lock-tests.mjs +21 -8
- package/usecases/create-feature/workflow.js +49 -29
- package/usecases/design/SKILL.md +18 -3
- package/usecases/fix-bug/SKILL.md +16 -13
- package/usecases/fix-bug/workflow.js +47 -28
- package/usecases/generate-test-scenarios/SKILL.md +4 -4
- package/usecases/generate-test-scenarios/references/test-case-guide.md +1 -1
package/usecases/design/SKILL.md
CHANGED
|
@@ -22,6 +22,20 @@ A design is built from what the user gave: the text, the images, the frames of t
|
|
|
22
22
|
| Video or GIF | Cannot be read by the designer. You extract key frames to image files first (step 3) |
|
|
23
23
|
| Spec in `docs/specs/` | Context only: the user stories and rules the design must serve. Read-only |
|
|
24
24
|
|
|
25
|
+
## Model and effort of the designer
|
|
26
|
+
|
|
27
|
+
The default model and effort of `levi-designer` (set in its agent file) are enough when the design only has to follow something the user already approved. Without one, the designer has to invent the layout, and it is called with model `opus` and effort `high`.
|
|
28
|
+
|
|
29
|
+
An **approved basis** is one of:
|
|
30
|
+
|
|
31
|
+
- an image, a cover or key image, a mockup, a sketch or a video frame that the user attached or pointed to in this request, to be recreated (what the user hands over to be recreated is approved by that act);
|
|
32
|
+
- an HTML preview that the user attached or pointed to (a path or a link);
|
|
33
|
+
- an existing design in `docs/designs/` that the request names or clearly means, or that the user picked in the opening round.
|
|
34
|
+
|
|
35
|
+
These are **not** an approved basis: a text description alone; a reference taken only for its style (colors, type, radii); the spec alone; a design in `docs/designs/` that was found only by matching and that nobody confirmed; anything a designer drew earlier in this same run.
|
|
36
|
+
|
|
37
|
+
Steps 4 and 6 use this rule: with an approved basis, call the designer without overriding model or effort; without one, call it with model `opus` and effort `high`. Decide it once, in step 2, and use the same setting in both steps. When you cannot tell whether a reference or an existing design is approved, do not guess: ask in the opening round (step 2), together with the other questions, never in a round of its own.
|
|
38
|
+
|
|
25
39
|
## Files
|
|
26
40
|
|
|
27
41
|
| File | Owner | Purpose |
|
|
@@ -37,8 +51,9 @@ A design is built from what the user gave: the text, the images, the frames of t
|
|
|
37
51
|
|
|
38
52
|
1. **Intake.** The request is the text plus the attachments. If there is neither text nor an attachment, ask what to design and stop. Derive the slug. List every image and video with its file path. Note the user's intent for each: recreate it, take its style, or extract its flow.
|
|
39
53
|
2. **Find the context.**
|
|
40
|
-
- *Existing design.* List `docs/designs/` and match folders against the subject. One clear match is an update: the designer revises those files and leaves the rest as they are. Two or more equally plausible: ask the user which one (or "new design"). None: a new folder `docs/designs/<slug>/`.
|
|
54
|
+
- *Existing design.* List `docs/designs/` and match folders against the subject. One clear match is an update: the designer revises those files and leaves the rest as they are. Two or more equally plausible: ask the user which one (or "new design"). None: a new folder `docs/designs/<slug>/`. A match that the request does not name or clearly mean is not yet approved: ask whether it is the approved design to draw from.
|
|
41
55
|
- *Spec.* List `docs/specs/` and match files by name and title. Use a clear match as context and say which in one line; with no clear match, go on without one. Never create or edit anything under `docs/specs/`.
|
|
56
|
+
- *Model and effort.* Decide whether the designer has an approved basis (see above). Put every question this step leaves open (which design, whether a reference or a match is approved, anything unclear in the request) into one opening round.
|
|
42
57
|
3. **Prepare the references.** The designer works only from files, never from the conversation.
|
|
43
58
|
- *Images with a file path:* pass the path.
|
|
44
59
|
- *Images that exist only in the conversation* (pasted or attached with no path): write `docs/levi/<slug>/references.md` with one section per image, a plain description of what is visible and nothing else: the layout region by region, every text exactly as written, colors as hex values, sizes and spacing you can read, icons, states, and what you cannot make out. No design opinions, no additions. Name the section `Image N` and tell the designer that the description is its only view of that image.
|
|
@@ -49,14 +64,14 @@ A design is built from what the user gave: the text, the images, the frames of t
|
|
|
49
64
|
```
|
|
50
65
|
|
|
51
66
|
If that gives fewer than 3 frames, take one frame every few seconds instead (`-vf "fps=1/3,scale=1280:-2"`). Look at the frames, keep one per distinct screen or state and delete near-duplicates, and write `frames/index.md` listing each frame with its timestamp or order. If ffmpeg is not installed, do not guess what the video shows: tell the user and ask for screenshots of the key screens (or for ffmpeg to be installed), then continue with what you have.
|
|
52
|
-
4. **Designer draws.** Call `levi-designer` with: the request as the user wrote it, the intent for each reference, every reference path (images, `frames/`, `references.md`), the spec path if any, the existing design folder if updating, the output folder `docs/designs/<slug>/`, and the path of `references/svg-guide.md` in this skill's folder (the SVG rules). It must:
|
|
67
|
+
4. **Designer draws.** Call `levi-designer`, with model `opus` and effort `high` unless it has an approved basis, with: the request as the user wrote it, the intent for each reference, every reference path (images, `frames/`, `references.md`), the spec path if any, the existing design folder if updating, the output folder `docs/designs/<slug>/`, and the path of `references/svg-guide.md` in this skill's folder (the SVG rules). It must:
|
|
53
68
|
- decide the list of files before drawing, and keep tokens and components the same across all of them;
|
|
54
69
|
- write only SVG files in the output folder, no notes or other files (variants it did not pick go in `alternatives/` inside it);
|
|
55
70
|
- when the request leaves a choice open (logo options, layout variants, palettes), draw the variants it needs, pick the best one for the design and say so: do not ask. Record the pick in `docs/levi/<slug>/choices/designer-<topic>.md`, as the run rules say;
|
|
56
71
|
- follow a recreate reference closely (layout, proportions, texts, colors, icons, states) and be honest about what it could not reproduce; follow a style reference for colors, type, radii and density only;
|
|
57
72
|
- return in its report the file list with one line per file, the assumptions it made, what it could not reproduce, and its questions.
|
|
58
73
|
5. **Check the files.** Run the checker over the output folder: `python3 <this skill's folder>/scripts/check-svg.py docs/designs/<slug>/` (or `xmllint --noout` on each file if there is no Python). Then, if a renderer exists (`rsvg-convert`, `inkscape`, or headless Chrome/Chromium), render every SVG to `docs/levi/<slug>/render/<name>.png` and look at the renders. Check that nothing is cut off, overlapping or unreadable, that the texts are the right ones, and, for recreate references, that the design matches the reference. If there is no renderer, say so in the report and rely on the checker.
|
|
59
|
-
6. **Fix, once.** When the checker or the render check found problems, call `levi-designer` once more with the exact problems (file, what is wrong, where) and the paths of the renders and references. It fixes only those, and you run step 5 again. Do not start a third pass: report what is still wrong.
|
|
74
|
+
6. **Fix, once.** When the checker or the render check found problems, call `levi-designer` once more, with the same model and effort as in step 4, with the exact problems (file, what is wrong, where) and the paths of the renders and references. It fixes only those, and you run step 5 again. Do not start a third pass: report what is still wrong.
|
|
60
75
|
7. **Settle its questions.** The designer cannot ask. Take the questions from its reports. A choice between layouts or variants is already picked (see step 4); so is missing content that a placeholder can hold. A question left over (an unclear reference that changes the whole design, a fact only the user knows) is parked as the run rules say, and goes with the report; the design carries the assumption meanwhile. Ask nothing now. Skip this step when there are no questions.
|
|
61
76
|
8. **Clean up.** Read `choices/` for the report, then delete it with `frames/`, `references.md` and `render/` from `docs/levi/<slug>/`, then remove the folder if empty, and `docs/levi` if that is empty. Delete only those, only after the designs are final. Keep the SVG files, the user's uploads and the spec.
|
|
62
77
|
9. **Report.** Tell the user the folder, the files with one line each (what screen or state it shows), whether it is new or an update, the spec used (if any), the assumptions, what could not be reproduced from the references (photos become labeled placeholders, fonts fall back to the stack), what the checks found and fixed, and whether the render check ran. Offer the next step in one line only when it is obvious, such as the missing states or breakpoints.
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: levi-fix-bug
|
|
3
|
-
description: Fix a bug in code that is already merged into the base branch. The developer lists what is unclear in the report and the user confirms it; then, as a Workflow of independent subagents, the developer investigates and fixes it test first (writing unit and feature tests only when the existing ones do not cover the bug) while QA writes the bug's test cases; the teamlead reviews every fix once the tests pass, and
|
|
3
|
+
description: Fix a bug in code that is already merged into the base branch. The developer lists what is unclear in the report and the user confirms it; then, as a Workflow of independent subagents, the developer investigates and fixes it test first (writing unit and feature tests only when the existing ones do not cover the bug) while QA writes the bug's test cases; the teamlead reviews every fix once the tests pass, and, when the user opts in, QA then runs the test cases end to end in a headless browser after the approval and sends the failing ones back to the developer (browser tests are slow, so the user is asked once at the start, the recommended answer is to skip them, and the test cases are written to be run later). Tests and test cases are never changed to make them pass. A problem in work that is not merged yet is a revision of that work, not a bug. Fits requests such as "fix this bug", "X is broken", "X shows the wrong value", "sửa bug X", "lỗi X".
|
|
4
4
|
argument-hint: "<what goes wrong, how to reproduce it, and screenshots or logs if you have them>"
|
|
5
5
|
requires: create-feature, code-review, generate-test-scenarios
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
# Fix a bug
|
|
9
9
|
|
|
10
|
-
Fix a bug with the team: `levi-developer` clarifies, investigates and fixes, `levi-teamlead` reviews, `levi-qa` writes the scenarios and tests the fix end to end. You run them, relay their questions to the user, and never investigate, fix, review or test yourself.
|
|
10
|
+
Fix a bug with the team: `levi-developer` clarifies, investigates and fixes, `levi-teamlead` reviews, `levi-qa` writes the scenarios and, when the user chose browser tests, tests the fix end to end. You run them, relay their questions to the user, and never investigate, fix, review or test yourself.
|
|
11
11
|
|
|
12
12
|
**What counts as a bug.** A bug is a defect in feature code that is already merged into the base branch. When the code at fault is still on a branch that is not merged, or not committed (for example the output of `create-feature` the user is checking), a request to change it is a revision of that work, not a bug. This usecase does not handle revisions: it says so and stops.
|
|
13
13
|
|
|
@@ -18,7 +18,7 @@ The work has two halves:
|
|
|
18
18
|
|
|
19
19
|
## The rules that never bend
|
|
20
20
|
|
|
21
|
-
- **Test first.** Before the fix, there are unit and feature tests that fail because of the bug: existing ones when they already cover it, otherwise new ones the developer writes. The fix is done when they pass, together with the whole suite.
|
|
21
|
+
- **Test first.** Before the fix, there are unit and feature tests that fail because of the bug: existing ones when they already cover it, otherwise new ones the developer writes. The fix is done when they pass, together with the whole suite. Unless browser tests are on, neither these tests nor that suite open a browser.
|
|
22
22
|
- **Tests are locked, test cases are QA's.** The tests that cover the bug are locked before the fix: nobody may edit, delete, skip or weaken them afterwards, and when one fails, the code is fixed. The lock is the `lock-tests.mjs` script of `create-feature`: it hashes the files, checks them after every round and restores any that changed. The test cases belong to QA: QA writes, changes and runs them with the test case guide of `generate-test-scenarios`, and a change by anyone else is undone with the same script before QA runs them. QA never changes an expected result to match what the code does.
|
|
23
23
|
- **No guessing.** The expected behavior comes from the spec, the designs and the points the user confirmed. What none of them settles is asked, not assumed.
|
|
24
24
|
- **Nothing is committed.** The changes stay in the working tree for the user to review.
|
|
@@ -29,7 +29,7 @@ The work has two halves:
|
|
|
29
29
|
|---|---|---|
|
|
30
30
|
| `docs/specs/<spec>.md`, `docs/designs/<design>/` | PM, Designer | The spec and designs of the feature, when there are. Read-only |
|
|
31
31
|
| Unit and feature tests, in the framework's folders | Developer | **Deliverable.** The tests that cover the bug. Locked before the fix |
|
|
32
|
-
| `docs/tests/bugs/<slug>.md`, `docs/tests/bugs/<slug>.xlsx` | QA | **Deliverable.** The test cases of the bug with
|
|
32
|
+
| `docs/tests/bugs/<slug>.md`, `docs/tests/bugs/<slug>.xlsx` | QA | **Deliverable.** The test cases of the bug with the PASS or FAIL result of each case that was run, in the format of `generate-test-scenarios`. Only QA changes them |
|
|
33
33
|
| Application code | Developer | **Deliverable.** The fix |
|
|
34
34
|
| `docs/levi/<slug>/report.md` | Workflow | Scratch: the bug report as the user gave it. Deleted at the end |
|
|
35
35
|
| `docs/levi/<slug>/confirmed.md` | Workflow | Scratch: the developer's questions and the user's answers, word for word. Deleted at the end |
|
|
@@ -46,12 +46,12 @@ The work has two halves:
|
|
|
46
46
|
2. **Merge check.** Find the base branch: the target of `git symbolic-ref --short refs/remotes/origin/HEAD` when it exists, otherwise `main` or `master`; use `origin/<branch>` when that ref exists, else the local branch. All code is merged when `git status --porcelain` lists nothing and `git merge-base --is-ancestor HEAD <base>` exits 0. Otherwise the workflow checks the lines at the root cause once the developer has found it.
|
|
47
47
|
- If the user clearly points at work that is not merged (a change still on its branch, the output of a usecase they are reviewing), tell them it is a revision of that work, not a bug, and stop.
|
|
48
48
|
3. **Write down the report.** Write `docs/levi/<slug>/report.md`: the report exactly as the user wrote it, the path of every attachment, and for an image that exists only in the conversation, a plain description of what it shows (texts exactly, values, states), without opinions. For a video, extract key frames into `docs/levi/<slug>/frames/` as step 3 of `levi-design/SKILL.md` describes, and list them.
|
|
49
|
-
4. **Spec and designs.** List `docs/specs/` and `docs/designs/` and match them against the feature where the bug happens, or use what the user pointed to. One clear match is used; two or more plausible ones, ask the user which (or "none"). With none, the expected behavior comes from the report and the confirmed points alone.
|
|
49
|
+
4. **Spec and designs.** List `docs/specs/` and `docs/designs/` and match them against the feature where the bug happens, or use what the user pointed to. One clear match is used; two or more plausible ones, ask the user which (or "none"). With none, the expected behavior comes from the report and the confirmed points alone. Those questions, if there are any, are the opening round: put the browser-tests question in it ("Browser tests are optional, asked once" in the run rules below).
|
|
50
50
|
5. **Clarify with the developer.** Call `levi-developer` with `report.md`, the spec, the designs and `confirmed.md` (when it exists). It reads them and the project, changes nothing, and returns:
|
|
51
51
|
- every point that is unclear and would change the fix or its tests: the expected behavior, the steps, the data, the environment, the scope (which cases are part of the bug). Each comes with two to four options, the most likely first;
|
|
52
52
|
- whether it looks like a bug: the behavior differs from what the spec, the designs and the report expect, or the code does exactly what the spec says.
|
|
53
53
|
|
|
54
|
-
Ask the user all the points in one round (use the tool's structured question feature if it has one). Append the questions and answers to `confirmed.md`, word for word. Do not answer for the user, and do not take an option as the answer unless the user picks it. Then call `levi-developer` again, fresh, with the updated `confirmed.md`. Stop when it has no more points; at most three rounds. If it then says the code works as the spec states, tell the user, quoting the spec: changing that behavior is a change to the feature, not a bug fix. Stop there.
|
|
54
|
+
Ask the user all the points in one round (use the tool's structured question feature if it has one). **If step 4 asked no question, this is the opening round, so add the browser-tests question to it, and ask it alone when the developer has no points.** The question is asked once, in the first round of the run, never twice. Append the developer's questions and the answers to `confirmed.md`, word for word, and write the browser-tests answer to `docs/levi/<slug>/choices/user-browser-tests.md`, as the run rules say (not into `confirmed.md`: the agents read that file as input). Do not answer for the user, and do not take an option as the answer unless the user picks it. Then call `levi-developer` again, fresh, with the updated `confirmed.md`. Stop when it has no more points; at most three rounds. If it then says the code works as the spec states, tell the user, quoting the spec: changing that behavior is a change to the feature, not a bug fix. Stop there.
|
|
55
55
|
6. **Fix.** Delete `docs/levi/<slug>/locked/` if an earlier run left it.
|
|
56
56
|
- *With a Workflow tool (Claude Code):* call it with `scriptPath` set to `workflow.js` in this skill's folder, and `args`:
|
|
57
57
|
|
|
@@ -62,21 +62,23 @@ The work has two halves:
|
|
|
62
62
|
"designs": "docs/designs/<design>/ (omit when there is none)",
|
|
63
63
|
"base": "<base branch ref from step 2>",
|
|
64
64
|
"allMerged": true,
|
|
65
|
+
"browserTests": <true or false>,
|
|
66
|
+
"browserScope": "<the user's words, only when they limited which cases to run>",
|
|
65
67
|
"skillDir": "<this skill's folder, relative to the project root>"
|
|
66
68
|
}
|
|
67
69
|
```
|
|
68
70
|
|
|
69
|
-
Set `allMerged` to false when step 2 found unmerged work.
|
|
71
|
+
Set `allMerged` to false when step 2 found unmerged work. `browserTests` is the user's answer to the opening question: `false` when they chose not to run browser tests (also the value when the answer is missing). Omit `browserScope` unless the user limited the run.
|
|
70
72
|
- *Without a Workflow tool:* run the steps under [Workflow](#workflow) below yourself, in order, each agent call as a new subagent call that gets only the paths and instructions written there.
|
|
71
73
|
7. **Act on the result.**
|
|
72
|
-
- `done`: go to step 8.
|
|
74
|
+
- `done`: go to step 8. When `browserTests` was off, the result lists the test cases that were not run (`notRun`).
|
|
73
75
|
- `questions`: an agent found a point that is still open. Ask the user, append the answers to `confirmed.md`, and run step 6 again.
|
|
74
76
|
- `not_a_bug`: the developer found that the code does what the spec and the confirmed points expect. Tell the user why, clean up (step 8) and stop.
|
|
75
77
|
- `unmerged`: the root cause is in code that is not merged into the base branch. Tell the user it is a revision of unmerged work, not a bug, with the root cause and its locations. Clean up and stop. The code was not changed.
|
|
76
78
|
- `blocked`: something outside the code stops the work (the app cannot start, a service or credential is missing, no test could be made to fail on the bug). Tell the user the stage, the detail and what they need to provide. Keep `docs/levi/<slug>/` and run step 6 again when they say to.
|
|
77
79
|
- `stalled`: the rounds ran out (10 by default) and something still fails. Tell the user what failed last. Continue in the same session with `resumeFromRunId` and a higher `maxRounds`. Tests and test cases still do not change.
|
|
78
80
|
8. **Clean up.** Delete `docs/levi/<slug>/`, then `docs/levi` if it is empty. Keep everything else.
|
|
79
|
-
9. **Report.** Tell the user: the root cause and where it was; the tests that cover the bug (written now, or existing ones) and the command that runs them; the test case files with their result (for example `4/4 PASS`); how many rounds it took; the review outcome and the suggestions left open; the files changed (from `git status`); and that nothing was committed.
|
|
81
|
+
9. **Report.** Tell the user: the root cause and where it was; the tests that cover the bug (written now, or existing ones) and the command that runs them; the test case files with their result (for example `4/4 PASS`); how many rounds it took; the review outcome and the suggestions left open; the files changed (from `git status`); and that nothing was committed. When browser tests did not run (all or part), add the line "Browser tests: not run (the user chose this)", or the partly-run variant, and list every test case that was not run with its ID and title (read the titles from the test case file).
|
|
80
82
|
|
|
81
83
|
## Workflow
|
|
82
84
|
|
|
@@ -84,13 +86,14 @@ The steps `workflow.js` runs, and the ones you run when there is no Workflow too
|
|
|
84
86
|
|
|
85
87
|
1. **Baseline.** Record `git rev-parse HEAD` and the files `git status --porcelain` lists, so the review sees only this run's changes.
|
|
86
88
|
2. **Two tracks at the same time**, neither reading the other's work:
|
|
87
|
-
- *QA.* `levi-qa` writes the test cases from the report, the confirmed points, the spec and the designs, without reading code, following `levi-generate-test-scenarios/references/test-case-guide.md`, with the cases file `docs/levi/<slug>/test-cases.json` and the output base `docs/tests/bugs/<slug>`: case 1 follows the steps of the report, the next ones cover nearby cases the same bug could break. The files are snapshotted at once (`lock-tests.mjs lock docs/levi/<slug>/locked/scenarios ...`). QA then waits for the review to approve.
|
|
89
|
+
- *QA.* `levi-qa`, called with model `opus` and effort `high`, writes the test cases from the report, the confirmed points, the spec and the designs, without reading code, following `levi-generate-test-scenarios/references/test-case-guide.md`, with the cases file `docs/levi/<slug>/test-cases.json` and the output base `docs/tests/bugs/<slug>`: case 1 follows the steps of the report, the next ones cover nearby cases the same bug could break. The files are snapshotted at once (`lock-tests.mjs lock docs/levi/<slug>/locked/scenarios ...`). QA then waits for the review to approve (browser tests on) or is done (off).
|
|
88
90
|
- *Developer, test first.* `levi-developer` finds the root cause (file, line range, other places with the same cause) and writes `investigation.md`. If existing unit and feature tests already cover the bug and fail because of it, it uses them; otherwise it writes the missing ones, from the spec and the confirmed points. The tests are run: some must fail on the current code. If none fails, the developer tries again (at most 3 times). If the code turns out to do what is expected, stop with `not_a_bug`.
|
|
89
91
|
3. **Merge check**, unless all code is merged: for each root-cause location, `git blame --porcelain -L <from>,<to> -- <file>`, then `git merge-base --is-ancestor <commit> <base>` for each commit. An uncommitted line (all-zero commit), an untracked file or a commit that is not an ancestor of the base means the code is not merged: stop with `unmerged`.
|
|
90
92
|
4. **Lock** the tests that cover the bug (`lock-tests.mjs lock docs/levi/<slug>/locked/tests ...`).
|
|
91
93
|
5. **Rounds** (at most 10 unless raised), each starting with a fresh `levi-developer` call:
|
|
92
94
|
1. *Fix.* The developer fixes the code: first as planned in `investigation.md`, later what the last round sent back. It fixes the cause, not the symptom.
|
|
93
|
-
2. *Tests.* `lock-tests.mjs verify` on the tests (any changed test is restored and the developer is told), then the bug's tests, then the whole suite. A failure goes back to the developer.
|
|
95
|
+
2. *Tests.* `lock-tests.mjs verify` on the tests (any changed test is restored and the developer is told), then the bug's tests, then the whole suite (without the tests that open a browser, unless browser tests are on). A failure goes back to the developer.
|
|
94
96
|
3. *Review.* Once the tests pass, a fresh `levi-teamlead` call reviews the change since the baseline: the root cause fixed everywhere, what the spec, designs and confirmed points expect, nothing else broken, security, performance, fit, following `levi-code-review/references/review-guide.md` and its checklists. It writes `review.md`. A change of more than 100 reviewable files is reviewed in slices by several fresh `levi-teamlead` calls and merged by a lead call, as `levi-code-review/references/large-changes.md` says. Critical or warning findings go back to the developer.
|
|
95
|
-
4. *E2E
|
|
96
|
-
|
|
97
|
+
4. *E2E*, only when browser tests are on. Once the review approves, `lock-tests.mjs verify` on the test cases undoes any change made outside QA. Then `levi-qa`, with its default model and effort, runs every case in a headless browser (the project's E2E runner such as Playwright, or a browser tool; through the API or CLI when there is no UI) and records PASS or FAIL as its test case guide says; the snapshot is then taken again. Failing cases go back to the developer, and the next round runs tests, review and E2E again. When the user limited the run, only the cases they chose are run; the others are reported as not run and do not count against the result.
|
|
98
|
+
*Browser tests off:* skip this step. Once the review approves, run `lock-tests.mjs verify` on the test cases once more, so that they stay as QA wrote them, and the run is done.
|
|
99
|
+
5. The run is done when the review approves and, when browser tests are on, every case passes.
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
export const meta = {
|
|
2
2
|
name: 'levi-fix-bug',
|
|
3
|
-
description: 'Fix a bug with TDD: the developer investigates and fixes it while QA writes the scenarios; the teamlead reviews every fix, then QA runs the scenarios end to end until they all pass',
|
|
3
|
+
description: 'Fix a bug with TDD: the developer investigates and fixes it while QA writes the scenarios; the teamlead reviews every fix, then, when browser tests are on, QA runs the scenarios end to end until they all pass',
|
|
4
4
|
whenToUse: 'Started by the levi-fix-bug skill once the open points of the bug report are confirmed with the user',
|
|
5
5
|
phases: [
|
|
6
6
|
{ title: 'Investigate', detail: 'the developer finds the root cause and makes tests fail on the bug; QA writes the scenarios at the same time' },
|
|
7
|
-
{ title: 'Fix', detail: 'fix, unit and feature tests, teamlead review, E2E; repeat until the review approves and every scenario passes' },
|
|
7
|
+
{ title: 'Fix', detail: 'fix, unit and feature tests, teamlead review, E2E when browser tests are on; repeat until the review approves and, with browser tests on, every scenario passes' },
|
|
8
8
|
],
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
// args: { slug, spec?, designs?, base, allMerged?, featureId?, testBase?, skillDir, maxRounds? } — see the skill's SKILL.md.
|
|
11
|
+
// args: { slug, spec?, designs?, base, allMerged?, featureId?, testBase?, browserTests?, browserScope?, skillDir, maxRounds? } — see the skill's SKILL.md.
|
|
12
12
|
const A = args || {}
|
|
13
13
|
const absent = ['slug', 'base', 'skillDir'].filter((k) => !A[k])
|
|
14
14
|
if (absent.length) return { status: 'error', message: `missing args: ${absent.join(', ')}` }
|
|
@@ -32,6 +32,13 @@ const LOCK_TESTS = `${WORK}/locked/tests`
|
|
|
32
32
|
const LOCK_SCENARIOS = `${WORK}/locked/scenarios`
|
|
33
33
|
const MAX_RED = 3
|
|
34
34
|
const MAX_ROUNDS = A.maxRounds || 10
|
|
35
|
+
// Browser tests (the E2E run) are slow and optional: the user chooses at the start, and a missing value means no.
|
|
36
|
+
const BROWSER = A.browserTests === true
|
|
37
|
+
const BROWSER_SCOPE = BROWSER && A.browserScope ? String(A.browserScope) : ''
|
|
38
|
+
// QA writes and changes test cases with the strongest setting; running them keeps the agent's default.
|
|
39
|
+
const QA_WRITE = { model: 'opus', effort: 'high' }
|
|
40
|
+
// With browser tests off, nothing in the run may open a browser: not the new tests, and not the suite the gate runs.
|
|
41
|
+
const NO_BROWSER = BROWSER ? '' : '\n\nBrowser tests are off for this run: write or rely on no test that opens a browser (an E2E runner, Playwright, a browser project of Vitest), and make every test command you return (testCommand and suiteCommand) leave out the tests that do.'
|
|
35
42
|
|
|
36
43
|
const CONTEXT = [
|
|
37
44
|
`Bug report, as the user gave it: ${REPORT}`,
|
|
@@ -88,6 +95,7 @@ const E2E = obj({
|
|
|
88
95
|
status: STATUS,
|
|
89
96
|
summary: { type: 'string' },
|
|
90
97
|
results: { type: 'array', items: obj({ id: { type: 'string' }, result: { type: 'string', enum: ['PASS', 'FAIL'] }, evidence: { type: 'string' } }) },
|
|
98
|
+
skipped: { ...STRINGS, description: 'IDs of the cases left out on purpose because of the scope the user set. Empty when no scope was set' },
|
|
91
99
|
})
|
|
92
100
|
|
|
93
101
|
// ---- helpers ----
|
|
@@ -125,7 +133,7 @@ On top of the guide:
|
|
|
125
133
|
- Do not record results: you record them later, when you run the cases.
|
|
126
134
|
|
|
127
135
|
Return the number of cases as scenarioCount.`,
|
|
128
|
-
{ label: 'qa:scenarios', phase: 'Investigate', agentType: 'levi-qa', schema: WRITTEN },
|
|
136
|
+
{ label: 'qa:scenarios', phase: 'Investigate', agentType: 'levi-qa', schema: WRITTEN, ...QA_WRITE },
|
|
129
137
|
)
|
|
130
138
|
if (!written || written.status === 'BLOCKED') return { stop: 'blocked', detail: written ? written.summary : 'QA did not write the scenarios' }
|
|
131
139
|
if (questionsOf(written).length) return { stop: 'questions', questions: written.questions }
|
|
@@ -147,7 +155,7 @@ Investigate this bug, test first. Do not fix it yet.
|
|
|
147
155
|
3. Run them: they must fail now, because of the bug, not because of a typo or a wrong setup.
|
|
148
156
|
|
|
149
157
|
Write ${INVESTIGATION}: expected against actual, the root cause with its locations, other places with the same cause, the tests that cover the bug, and how you will fix it.
|
|
150
|
-
Return also the command that runs the tests covering the bug, the command for the whole suite, and how to start the app for end-to-end tests. After this step the tests that cover the bug are locked: the fix must pass them and nobody may change them
|
|
158
|
+
Return also the command that runs the tests covering the bug, the command for the whole suite, and how to start the app for end-to-end tests${BROWSER ? '' : ' (browser tests will not run, so leave app.start, app.url and app.notes empty)'}. After this step the tests that cover the bug are locked: the fix must pass them and nobody may change them.${NO_BROWSER}`,
|
|
151
159
|
{ label: 'developer:investigate', phase: 'Investigate', agentType: 'levi-developer', schema: INVESTIGATE },
|
|
152
160
|
)
|
|
153
161
|
for (let i = 1; ; i++) {
|
|
@@ -159,7 +167,7 @@ Return also the command that runs the tests covering the bug, the command for th
|
|
|
159
167
|
if (red && red.exitCode !== 0) return { ...found, red: red.summary }
|
|
160
168
|
if (i >= MAX_RED) return { stop: 'blocked', detail: `after ${MAX_RED} tries, no test fails on the buggy code` }
|
|
161
169
|
found = await agent(
|
|
162
|
-
`${CONTEXT}\n\nThe tests you named (${found.bugTests.join(', ')}) all pass with \`${found.testCommand}\` on the buggy code, so they do not catch the bug. Write or correct the tests so that they fail because of this bug, then return your investigation again, updating ${INVESTIGATION}. Do not fix the bug yet
|
|
170
|
+
`${CONTEXT}\n\nThe tests you named (${found.bugTests.join(', ')}) all pass with \`${found.testCommand}\` on the buggy code, so they do not catch the bug. Write or correct the tests so that they fail because of this bug, then return your investigation again, updating ${INVESTIGATION}. Do not fix the bug yet.${NO_BROWSER}`,
|
|
163
171
|
{ label: `developer:red-${i}`, phase: 'Investigate', agentType: 'levi-developer', schema: INVESTIGATE },
|
|
164
172
|
)
|
|
165
173
|
}
|
|
@@ -288,7 +296,7 @@ ${output}`,
|
|
|
288
296
|
)
|
|
289
297
|
}
|
|
290
298
|
|
|
291
|
-
// ---- Fix: fix, tests, review, E2E, until the review approves and every scenario passes ----
|
|
299
|
+
// ---- Fix: fix, tests, review, E2E when browser tests are on, until the review approves and every scenario passes ----
|
|
292
300
|
|
|
293
301
|
phase('Fix')
|
|
294
302
|
const gate = () =>
|
|
@@ -343,48 +351,59 @@ Check that the fix removes the root cause rather than the symptom, everywhere it
|
|
|
343
351
|
continue
|
|
344
352
|
}
|
|
345
353
|
|
|
346
|
-
// The review approved
|
|
354
|
+
// The review approved. QA must have finished the test cases, with browser tests on or off.
|
|
347
355
|
if (!scenarios) {
|
|
348
356
|
scenarios = await scenariosReady
|
|
349
357
|
if (!scenarios) return { status: 'blocked', stage: 'scenarios', detail: 'QA did not finish the scenarios' }
|
|
350
358
|
if (scenarios.stop === 'questions') return { status: 'questions', stage: 'scenarios', questions: scenarios.questions }
|
|
351
359
|
if (scenarios.stop) return { status: 'blocked', stage: 'scenarios', detail: scenarios.detail }
|
|
352
360
|
}
|
|
361
|
+
const caseIds = Array.from({ length: scenarios.scenarioCount }, (_, n) => `TC-${FEATURE_ID}-${String(n + 1).padStart(3, '0')}`)
|
|
362
|
+
const finish = (notRun) => ({
|
|
363
|
+
status: 'done',
|
|
364
|
+
rounds: round,
|
|
365
|
+
rootCause: inv.rootCause,
|
|
366
|
+
tests: inv.bugTests,
|
|
367
|
+
wroteTests: inv.wroteTests,
|
|
368
|
+
testCommand: inv.testCommand,
|
|
369
|
+
scenarios: { files: SCENARIO_FILES, count: scenarios.scenarioCount },
|
|
370
|
+
browserTests: BROWSER,
|
|
371
|
+
browserScope: BROWSER_SCOPE || undefined,
|
|
372
|
+
notRun,
|
|
373
|
+
review: review.summary,
|
|
374
|
+
suggestions: review.findings.filter((f) => f.severity === 'suggestion'),
|
|
375
|
+
})
|
|
376
|
+
// Changes to the test cases by anyone but QA are undone before they are used; QA's own results are kept after.
|
|
377
|
+
const restored = await restoreScenarios()
|
|
378
|
+
if (restored && restored.exitCode !== 0) log('the test cases had been changed outside QA and were restored')
|
|
379
|
+
if (!BROWSER) return finish(caseIds)
|
|
380
|
+
|
|
381
|
+
// Browser tests on: QA runs its scenarios end to end.
|
|
353
382
|
const e2e = (note) =>
|
|
354
383
|
agent(
|
|
355
384
|
`${CONTEXT}
|
|
356
385
|
|
|
357
|
-
The fix of this bug was approved in review. Run
|
|
386
|
+
The fix of this bug was approved in review. Run ${
|
|
387
|
+
BROWSER_SCOPE
|
|
388
|
+
? `only the test cases in ${SCENARIOS} that the user chose with these words: "${BROWSER_SCOPE}". List the IDs of the others in skipped and do not run them`
|
|
389
|
+
: `every test case in ${SCENARIOS} (there are ${scenarios.scenarioCount})`
|
|
390
|
+
} against the running app and record the results, following your test case guide, ${TEST_GUIDE} ("Recording results"), with the cases file ${CASES} and the output base ${TEST_BASE}. Run them ${
|
|
358
391
|
inv.hasUi ? "in a headless browser: the project's E2E runner (such as Playwright) or a browser tool you have" : 'through its API or CLI'
|
|
359
392
|
}. Start the app with \`${inv.app.start}\` (${inv.app.url}; ${inv.app.notes}) and stop it when you are done.
|
|
360
|
-
Change no application code. Return the result of every case, by its ID.${note ? `\n\n${note}` : ''}`,
|
|
393
|
+
Change no application code. Return the result of every case you ran, by its ID.${note ? `\n\n${note}` : ''}`,
|
|
361
394
|
{ label: `qa:e2e-${round}`, phase: 'Fix', agentType: 'levi-qa', schema: E2E },
|
|
362
395
|
)
|
|
363
|
-
// Changes to the test cases by anyone but QA are undone before QA runs them; QA's own results are kept after.
|
|
364
|
-
const restored = await restoreScenarios()
|
|
365
|
-
if (restored && restored.exitCode !== 0) log('the test cases had been changed outside QA and were restored')
|
|
366
396
|
const run = await e2e()
|
|
367
397
|
if (!run) return { status: 'blocked', stage: 'e2e', detail: 'the E2E run did not complete' }
|
|
368
398
|
await snapshotScenarios()
|
|
399
|
+
const skipped = new Set(BROWSER_SCOPE ? (run.skipped || []).filter((id) => caseIds.includes(id)) : [])
|
|
369
400
|
const failing = []
|
|
370
|
-
for (
|
|
371
|
-
|
|
401
|
+
for (const id of caseIds) {
|
|
402
|
+
if (skipped.has(id)) continue
|
|
372
403
|
const r = run.results.find((x) => x.id === id)
|
|
373
404
|
if (!r || r.result !== 'PASS') failing.push(`${id}: ${r ? r.evidence : 'not run'}`)
|
|
374
405
|
}
|
|
375
|
-
if (!failing.length)
|
|
376
|
-
return {
|
|
377
|
-
status: 'done',
|
|
378
|
-
rounds: round,
|
|
379
|
-
rootCause: inv.rootCause,
|
|
380
|
-
tests: inv.bugTests,
|
|
381
|
-
wroteTests: inv.wroteTests,
|
|
382
|
-
testCommand: inv.testCommand,
|
|
383
|
-
scenarios: { files: SCENARIO_FILES, count: scenarios.scenarioCount },
|
|
384
|
-
review: review.summary,
|
|
385
|
-
suggestions: review.findings.filter((f) => f.severity === 'suggestion'),
|
|
386
|
-
}
|
|
387
|
-
}
|
|
406
|
+
if (!failing.length) return finish([...skipped])
|
|
388
407
|
last = { stage: 'e2e', failing }
|
|
389
408
|
todo = `QA ran the test cases in ${SCENARIOS} end to end after the review, and these failed. Fix the code so that they pass:\n${failing.join('\n')}`
|
|
390
409
|
}
|
|
@@ -55,7 +55,7 @@ A feature is one spec file, or one folder of spec files, under `docs/specs/` (se
|
|
|
55
55
|
- *`docs/tests/<base>.md` or `.xlsx` already exists:* replace it, or write a new version with a date suffix, `<base>-YYYYMMDD` (today's date; if that exists too, add `-2`, `-3`, ...).
|
|
56
56
|
|
|
57
57
|
In the same message, before the questions, tell the user every missing spec. If no feature is left to generate, say so and stop. Skip the questions when none applies.
|
|
58
|
-
4. **Analyze.** Call `levi-qa` once per feature (in parallel when the tool allows), with this prompt filled in:
|
|
58
|
+
4. **Analyze.** Call `levi-qa`, with model `opus` and effort `high`, once per feature (in parallel when the tool allows), with this prompt filled in:
|
|
59
59
|
|
|
60
60
|
```text
|
|
61
61
|
Analysis pass for feature <FeatureID>: <feature name or slug>.
|
|
@@ -69,7 +69,7 @@ A feature is one spec file, or one folder of spec files, under `docs/specs/` (se
|
|
|
69
69
|
```
|
|
70
70
|
|
|
71
71
|
5. **Report what is missing, up front.** Before any case is written, tell the user in one message, per feature: `Generate: no` with what the spec lacks (that feature is skipped), and for the others the Missing line and the number of ambiguities found. Then go on; this is information, not a question. If every feature is `Generate: no`, delete the scratch folder and stop.
|
|
72
|
-
6. **Generate.** For every feature with `Generate: yes`, call `levi-qa` (in parallel when the tool allows):
|
|
72
|
+
6. **Generate.** For every feature with `Generate: yes`, call `levi-qa`, with model `opus` and effort `high` (in parallel when the tool allows):
|
|
73
73
|
|
|
74
74
|
```text
|
|
75
75
|
Generation pass for feature <FeatureID>: <feature name or slug>.
|
|
@@ -85,7 +85,7 @@ A feature is one spec file, or one folder of spec files, under `docs/specs/` (se
|
|
|
85
85
|
Report the case count and every ambiguity that remains.
|
|
86
86
|
```
|
|
87
87
|
|
|
88
|
-
7. **Verify.** For each feature, run `node <this skill's folder>/scripts/render-test-cases.mjs check docs/levi/test-cases/<FeatureID>.json` and check that `docs/tests/<base>.md` and `docs/tests/<base>.xlsx` exist. If the check fails or a file is missing, send QA the errors once to fix and render again. If it still fails, report the feature as not done, with the errors.
|
|
88
|
+
7. **Verify.** For each feature, run `node <this skill's folder>/scripts/render-test-cases.mjs check docs/levi/test-cases/<FeatureID>.json` and check that `docs/tests/<base>.md` and `docs/tests/<base>.xlsx` exist. If the check fails or a file is missing, send QA the errors once to fix and render again (again with model `opus` and effort `high`). If it still fails, report the feature as not done, with the errors.
|
|
89
89
|
8. **Clean up.** Delete `docs/levi/test-cases/`, and `docs/levi` if that is empty. Delete only after step 7.
|
|
90
90
|
9. **Report.** A short summary, in the language of the request:
|
|
91
91
|
- per feature: the number of cases (by priority), the two file paths, and the spec it came from;
|
|
@@ -94,4 +94,4 @@ A feature is one spec file, or one folder of spec files, under `docs/specs/` (se
|
|
|
94
94
|
|
|
95
95
|
If QA was BLOCKED or needed context, say what it needs.
|
|
96
96
|
|
|
97
|
-
Without a parallel subagent feature, run the QA calls of steps 4 and 6 one after another; the steps are the same.
|
|
97
|
+
Every call to `levi-qa` here writes or changes test cases, so all of them use model `opus` and effort `high`. Without a parallel subagent feature, run the QA calls of steps 4 and 6 one after another; the steps are the same.
|
|
@@ -164,7 +164,7 @@ Never change an expected result to match what the product does. When you think t
|
|
|
164
164
|
|
|
165
165
|
## Recording results
|
|
166
166
|
|
|
167
|
-
|
|
167
|
+
Run the cases only when the prompt asks you to: browser tests are optional, and when the user turned them off the cases stay without a result. When you run them (end to end, in a headless browser through the project's E2E runner or a browser tool, or through the API or CLI when there is no UI):
|
|
168
168
|
|
|
169
169
|
1. Follow each case's preconditions and steps as written, and compare with its expected result.
|
|
170
170
|
2. In the cases file, give each case you ran `"status": "PASS"` or `"status": "FAIL"`, and `"evidence"`: what you observed (for FAIL, the actual result against the expected one, and the error). A case you could not run is FAIL, with the reason: untested is not passed.
|