levi-gear 0.2.0 → 0.4.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 +13 -3
- package/agents/_team-protocol.md +3 -1
- package/package.json +5 -2
- package/src/lib/desired-state.js +15 -4
- package/src/lib/usecases.js +4 -1
- package/src/runtime/codex-run-state.mjs +156 -0
- package/src/runtime/quota-check.mjs +195 -0
- package/usecases/_run-rules.md +49 -0
- package/usecases/brainstorming/SKILL.md +55 -13
- package/usecases/brainstorming/references/codex-runner.md +28 -0
- package/usecases/code-review/SKILL.md +14 -7
- package/usecases/code-review/references/codex-runner.md +5 -0
- package/usecases/code-review/references/large-changes.md +37 -0
- package/usecases/code-review/references/review-guide.md +3 -1
- package/usecases/create-feature/SKILL.md +10 -7
- package/usecases/create-feature/references/codex-runner.md +57 -0
- package/usecases/create-feature/workflow.js +100 -8
- package/usecases/design/SKILL.md +8 -3
- package/usecases/design/references/codex-runner.md +27 -0
- package/usecases/fix-bug/SKILL.md +5 -4
- package/usecases/fix-bug/references/codex-runner.md +32 -0
- package/usecases/fix-bug/workflow.js +100 -6
- package/usecases/generate-test-scenarios/SKILL.md +5 -0
- package/usecases/generate-test-scenarios/references/codex-runner.md +32 -0
- package/usecases/spec-writing/SKILL.md +5 -1
- package/usecases/spec-writing/references/codex-runner.md +25 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: levi-brainstorming
|
|
3
|
-
description: Brainstorm any problem or idea with the PM and Teamlead and turn it into an execution plan - a list of small tasks, each with the team agent that owns it and an estimate in hours. Uses the project's spec in docs/specs/ as a basis when one exists; never creates or edits specs. Fits requests such as "brainstorm X", "how should we approach X", "break X into tasks and estimate it".
|
|
3
|
+
description: Brainstorm any problem or idea with the PM and Teamlead and turn it into an execution plan - a list of small tasks, each with the team agent that owns it and an estimate in hours. A problem with several features is planned in phases: an MVP first, then one feature completed per phase, each phase a release that runs on its own. Uses the project's spec in docs/specs/ as a basis when one exists; never creates or edits specs. Fits requests such as "brainstorm X", "how should we approach X", "break X into tasks and estimate it".
|
|
4
4
|
argument-hint: "<problem or idea to brainstorm>"
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -10,6 +10,8 @@ Turn a problem into an execution plan. `levi-pm` frames the problem and owns the
|
|
|
10
10
|
|
|
11
11
|
The problem can be anything the team could work on: a feature, a refactor, a migration, a process change.
|
|
12
12
|
|
|
13
|
+
**A problem with several features is planned in phases.** Phase 1 is the MVP: the basic version of what the product needs to work end to end. Every later phase completes one feature. The plan is cut so that each phase is a release that runs on its own and never needs a later phase, which also keeps each stretch of development small. A problem with one feature, or with no sensible cut, gets a flat plan.
|
|
14
|
+
|
|
13
15
|
This usecase plans; it does not write specs. Never create or edit anything under `docs/specs/`. An existing spec is read-only input. If the user wants a spec written or changed, they will ask for it separately.
|
|
14
16
|
|
|
15
17
|
## Files
|
|
@@ -18,12 +20,17 @@ This usecase plans; it does not write specs. Never create or edit anything under
|
|
|
18
20
|
|---|---|---|
|
|
19
21
|
| `docs/brainstorming/<slug>.md` | PM | **The deliverable**: the plan |
|
|
20
22
|
| `docs/levi/<slug>/brief.md` | PM | Scratch: the problem framed in a few lines. Written only when there is no spec. Deleted at the end |
|
|
23
|
+
| `docs/levi/<slug>/phases.md` | PM | Scratch: the features, the MVP cut and the order of the later phases. Written only when the problem holds several features. Deleted at the end |
|
|
21
24
|
| `docs/levi/<slug>/architecture.md` | Teamlead | Scratch: approaches considered and the one chosen. Deleted at the end |
|
|
22
25
|
| `docs/levi/<slug>/tasks.md` | Teamlead | Scratch: task breakdown with suggested roles and estimates. Deleted at the end |
|
|
23
26
|
| `docs/levi/<slug>/status.md` | PM | Scratch: task assignments. Deleted at the end |
|
|
24
27
|
|
|
25
28
|
`<slug>` is a short kebab-case name for the problem, in English (for example `export-orders-csv`). Create folders as needed. Pass each agent the exact paths it should read and write. When the run finishes, only the plan is left behind (and the spec, untouched, if the project had one).
|
|
26
29
|
|
|
30
|
+
## Codex runner
|
|
31
|
+
|
|
32
|
+
On Codex, use [`references/codex-runner.md`](references/codex-runner.md). It records the planning stage in `docs/levi/<slug>/run.json`, so a stopped run resumes from its artifact checkpoint rather than from conversation memory.
|
|
33
|
+
|
|
27
34
|
## Steps
|
|
28
35
|
|
|
29
36
|
1. **Intake.** The request is the problem. If it is empty, ask what to brainstorm and stop. Derive the slug and a plain-language problem name.
|
|
@@ -37,26 +44,26 @@ This usecase plans; it does not write specs. Never create or edit anything under
|
|
|
37
44
|
|
|
38
45
|
From here on, "the basis" means the spec when there is one, otherwise `brief.md`.
|
|
39
46
|
4. **Teamlead explores.** Call `levi-teamlead` with the problem and the basis path. It reads the basis and the project, then writes `architecture.md`: two or three genuinely different approaches with their trade-offs, a recommendation, and the forks only the user can decide. It does not break the work down yet.
|
|
40
|
-
5. **Ask the user once.** Merge the questions from steps 3 and 4, drop duplicates, and ask them all in a single round (use the tool's structured question feature if it has one). Give each question two to four options with the recommended one first. Add one more question if `docs/brainstorming/<slug>.md` already exists: replace it, or write the new plan under another name. Skip this step when there are no questions. An unanswered question takes its recommended option, recorded as an assumption. After this step the user's part is done; do not ask again unless an agent is BLOCKED.
|
|
41
|
-
6. **Finalize the inputs.** Run these
|
|
42
|
-
- `levi-pm
|
|
43
|
-
- `levi-teamlead`: update `architecture.md` with the chosen approach, then write `tasks.md`. Every task is small (split anything over about 8 hours) and has: ID, goal, files or areas touched, done criteria, dependencies, the suggested role (`levi-pm`, `levi-teamlead`, `levi-developer`, `levi-designer` or `levi-qa`) and an estimate in hours. Include design, review, QA and acceptance tasks, not only implementation. Name the riskiest task.
|
|
47
|
+
5. **Ask the user once.** Merge the questions from steps 3 and 4, drop duplicates, and ask them all in a single round (use the tool's structured question feature if it has one). Give each question two to four options with the recommended one first. Ask what only the user can settle (facts, scope, priorities, a fork that decides the approach); a choice that is cheap to change, such as a name or the order of two equal tasks, is picked and recorded as the run rules say. Add one more question if `docs/brainstorming/<slug>.md` already exists: replace it, or write the new plan under another name. Skip this step when there are no questions. An unanswered question takes its recommended option, recorded as an assumption. After this step the user's part is done; do not ask again unless an agent is BLOCKED.
|
|
48
|
+
6. **Finalize the inputs.** Run these with the user's answers as input. When the problem holds several features, run the PM first (it writes `phases.md`) and then the teamlead; otherwise run them in parallel when the tool allows.
|
|
49
|
+
- `levi-pm`: when it wrote `brief.md`, fold the answers into it and clear the open questions that were answered. When the problem holds more than one feature, also write `phases.md`: the list of features; **Phase 1, the MVP**, the smallest set that works end to end for the core purpose, holding the basic version of every feature the core flow needs and nothing optional, with what a user can do with that release; then **one later phase per feature**, each completing that feature (bringing it from the MVP's basic version to complete, or adding it whole when the MVP has none of it), ordered by value and then risk, with the reason for the order; and for each phase a release check, a way to tell that the release works on its own. No phase may need anything from a later phase, and a later phase extends the earlier ones instead of reworking them. Say so and write no phases when there is one feature or no sensible cut.
|
|
50
|
+
- `levi-teamlead`: update `architecture.md` with the chosen approach, then write `tasks.md`. Every task is small (split anything over about 8 hours) and has: ID, goal, files or areas touched, done criteria, dependencies, the suggested role (`levi-pm`, `levi-teamlead`, `levi-developer`, `levi-designer` or `levi-qa`) and an estimate in hours. Include design, review, QA and acceptance tasks, not only implementation. Name the riskiest task. With `phases.md`, each task also has its phase; the shared foundation goes in Phase 1; every phase has its own QA and release-check tasks, so its release is really verified; a task depends only on tasks of its own or an earlier phase; and nothing for a later phase is built early.
|
|
44
51
|
- **Keep tasks independent.** The breakdown exists so that many agents can work at the same time, so cut the work along seams that leave as few dependencies as possible. Each task should be doable and checkable on its own, with its own inputs and done criteria, without waiting for or touching the output of another task. Prefer vertical slices over layers, and tasks that own separate files or areas.
|
|
45
52
|
- **Pull shared work out first.** When several tasks truly need the same thing (a data model, an interface or contract, a shared component, a config), do not let them depend on one another. Make one foundation task that delivers only that shared part, as small as it can be, and let the other tasks depend on it alone. After the foundation task, the remaining tasks must be able to run in parallel.
|
|
46
53
|
- **Dependencies are the exception.** Keep a dependency only when it cannot be removed, such as a task that needs a decision, an interface, or a result that does not exist yet. Prefer a dependency on a foundation task over a chain of tasks. Avoid long chains; a task that waits on a task that waits on another is a sign the cut is wrong.
|
|
47
|
-
7. **PM writes the plan.** Call `levi-pm` with the basis, `architecture.md` and `tasks.md`. It checks that every goal and done-criterion in the basis is covered by a task, decides the owner of each task (the Teamlead's suggestion unless it has a reason to change it), records the assignments in `status.md`, and writes `docs/brainstorming/<slug>.md` in the format below. The scratch files are deleted later, so the plan's Notes must carry the chosen approach, what was rejected and why, and the riskiest task.
|
|
54
|
+
7. **PM writes the plan.** Call `levi-pm` with the basis, `architecture.md` and `tasks.md`. It checks that every goal and done-criterion in the basis is covered by a task (in some phase, when there are phases), decides the owner of each task (the Teamlead's suggestion unless it has a reason to change it), records the assignments in `status.md`, and writes `docs/brainstorming/<slug>.md` in the format below (the phased format when `phases.md` exists). The scratch files are deleted later, so the plan's Notes must carry the chosen approach, what was rejected and why, and the riskiest task.
|
|
48
55
|
- If the PM reports uncovered criteria, send them to `levi-teamlead` to add tasks, then call the PM once more. The PM must settle any criterion that is still uncovered by itself: add the missing task and assign it, or rule the criterion out of scope with a one-line note in the plan's Notes. It never edits the spec, and it does not leave a gap open.
|
|
49
|
-
8. **Review a hard plan.** Count the rows of the task
|
|
56
|
+
8. **Review a hard plan.** Count the rows of the task tables (all phases together). With 10 tasks or fewer, skip to step 9. With more than 10, run an independent review, once:
|
|
50
57
|
- Use fresh agent calls that get only the paths of the basis and the plan (plus `review.md` for the PM's call), never the conversation, the other scratch files or your own opinion of the plan. A new call starts with no memory of the earlier steps, which is what makes the review independent.
|
|
51
|
-
- First call `levi-teamlead` to review the plan: task size, independence (remove dependencies that are not needed, move work shared by several tasks into one foundation task), dependencies and order, estimates, missing or redundant tasks, technical risk. The plan belongs to the PM, so the teamlead does not edit it: it writes its decisions to `docs/levi/<slug>/review.md` as a list of concrete changes (task, what changes, why). It decides: it may change tasks, estimates and even the chosen approach, and its calls override the first round.
|
|
52
|
-
- Then call `levi-pm` as a second fresh call, with the basis, the plan and `review.md`. The PM applies the teamlead's changes to `docs/brainstorming/<slug>.md`, then reviews the result against the basis: coverage of every goal and done-criterion, owner of each task, the total and the agent list. It decides on scope, coverage and ownership, and writes the final version over the old one. The teamlead's calls bind on technical matters (task size, estimates, approach, dependencies); the PM's calls override on scope, coverage and ownership. Its reply lists what changed in the review.
|
|
58
|
+
- First call `levi-teamlead` to review the plan: task size, independence (remove dependencies that are not needed, move work shared by several tasks into one foundation task), dependencies and order, estimates, missing or redundant tasks, technical risk, and for a phased plan that no task depends on a later phase and that each phase's release works on its own. The plan belongs to the PM, so the teamlead does not edit it: it writes its decisions to `docs/levi/<slug>/review.md` as a list of concrete changes (task, what changes, why). It decides: it may change tasks, estimates and even the chosen approach, and its calls override the first round.
|
|
59
|
+
- Then call `levi-pm` as a second fresh call, with the basis, the plan and `review.md`. The PM applies the teamlead's changes to `docs/brainstorming/<slug>.md`, then reviews the result against the basis: coverage of every goal and done-criterion, owner of each task, the total and the agent list, and for a phased plan that the MVP is the smallest working release and that each later phase completes one feature. It decides on scope, coverage and ownership, and writes the final version over the old one. The teamlead's calls bind on technical matters (task size, estimates, approach, dependencies); the PM's calls override on scope, coverage and ownership. Its reply lists what changed in the review.
|
|
53
60
|
- The reviewers settle every point themselves, with their best judgment; they do not defer a point, hand it back as a question, or park it in Notes. Notes only add information to a decision already made, such as a changed approach and why, or an assumption behind it. Update the Notes to match the final plan. Do not start a second round.
|
|
54
|
-
9. **Clean up.** Delete `architecture.md`, `tasks.md`, `status.md`, `brief.md` and `review.md` (the last
|
|
55
|
-
10. **Check and report.** Open the plan and confirm that the total equals the sum of the task estimates and that the agent list equals the agents in the task
|
|
61
|
+
9. **Clean up.** Delete `architecture.md`, `tasks.md`, `status.md`, `brief.md`, `phases.md` and `review.md` (the last three if they exist) and `choices/` (read it first for the report) from `docs/levi/<slug>/`, then remove the folder if it is now empty. Remove `docs/levi` too if that is empty. Delete only those files, and only after the plan is final. Keep the plan, and never touch the spec.
|
|
62
|
+
10. **Check and report.** Open the plan and confirm that the total equals the sum of the task estimates (the phase estimates too, for a phased plan) and that the agent list equals the agents in the task tables; fix it if not. Tell the user the plan path, the spec used (if any), the total hours, the agents involved, whether the plan was reviewed (and what the review changed), and any assumption taken in place of an unanswered question.
|
|
56
63
|
|
|
57
64
|
## Plan format
|
|
58
65
|
|
|
59
|
-
`docs/brainstorming/<slug>.md`, written in the language of the request:
|
|
66
|
+
`docs/brainstorming/<slug>.md`, written in the language of the request. A problem with one feature, or with no sensible cut, gets the flat plan:
|
|
60
67
|
|
|
61
68
|
```markdown
|
|
62
69
|
# <Problem name>
|
|
@@ -78,7 +85,42 @@ risks (the riskiest task), work that needs a human. Notes supplement the plan an
|
|
|
78
85
|
undecided point. Omit this whole section otherwise.>
|
|
79
86
|
```
|
|
80
87
|
|
|
81
|
-
|
|
88
|
+
A problem with several features gets the phased plan. The tasks sit in one table per phase:
|
|
89
|
+
|
|
90
|
+
```markdown
|
|
91
|
+
# <Problem name>
|
|
92
|
+
|
|
93
|
+
- **Total estimate:** <N> hours
|
|
94
|
+
- **Agents:** levi-pm, levi-teamlead, levi-developer
|
|
95
|
+
|
|
96
|
+
## Phases
|
|
97
|
+
|
|
98
|
+
| Phase | Release | Estimate (h) |
|
|
99
|
+
|---|---|---|
|
|
100
|
+
| 1. MVP | <what a user can do with this release> | 20 |
|
|
101
|
+
| 2. <Feature> | <what this release adds> | 8 |
|
|
102
|
+
|
|
103
|
+
## Phase 1: MVP
|
|
104
|
+
|
|
105
|
+
**Release check:** <how to tell that this release works on its own>
|
|
106
|
+
|
|
107
|
+
| # | Task | Agent | Estimate (h) | Depends on |
|
|
108
|
+
|---|---|---|---|---|
|
|
109
|
+
| 1 | <small, concrete task> | levi-teamlead | 2 | - |
|
|
110
|
+
|
|
111
|
+
## Phase 2: <Feature>
|
|
112
|
+
|
|
113
|
+
**Release check:** <how to tell that this release works on its own>
|
|
114
|
+
|
|
115
|
+
| # | Task | Agent | Estimate (h) | Depends on |
|
|
116
|
+
|---|---|---|---|---|
|
|
117
|
+
| 2 | <small, concrete task> | levi-developer | 4 | 1 |
|
|
118
|
+
|
|
119
|
+
## Notes
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
- The total is the sum of the task estimates. It is agent working time, not the calendar duration, so tasks that can run in parallel are still added up. In a phased plan each phase's estimate is the sum of its tasks.
|
|
82
123
|
- An estimate is the hours the assigned agent needs for that task, including checking its own work, in steps of 0.5 hours. It does not include waiting for the user.
|
|
83
124
|
- The agent list contains each agent that owns at least one task, once.
|
|
84
125
|
- `Depends on` lists only dependencies that cannot be removed. Most tasks should have `-` or point at a foundation task, so that as many tasks as possible can run in parallel.
|
|
126
|
+
- Task numbers run across the phases. In a phased plan a task depends only on tasks of its own phase or an earlier one, never a later one. Phase 1 is the MVP and holds the foundation; each later phase completes one feature; every phase ends with its own QA and release-check tasks, so each release can ship and run on its own.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Codex runner
|
|
2
|
+
|
|
3
|
+
Run this workflow from the project root with a durable checkpoint. Do not reconstruct a stopped planning run from chat history.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
node <this skill folder>/scripts/codex-run-state.mjs status docs/levi/<slug>
|
|
7
|
+
node <this skill folder>/scripts/codex-run-state.mjs init docs/levi/<slug> brainstorming <slug> frame explore decide finalize plan review verify
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
node <this skill folder>/scripts/codex-run-state.mjs begin docs/levi/<slug> <stage>
|
|
12
|
+
node <this skill folder>/scripts/codex-run-state.mjs complete docs/levi/<slug> <stage> <artifact>...
|
|
13
|
+
node <this skill folder>/scripts/codex-run-state.mjs wait docs/levi/<slug> <stage> "<questions>"
|
|
14
|
+
node <this skill folder>/scripts/codex-run-state.mjs block docs/levi/<slug> <stage> "<blocker>"
|
|
15
|
+
node <this skill folder>/scripts/codex-run-state.mjs resume docs/levi/<slug>
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Create the state after intake has derived the slug. On every new or resumed turn, read `status` first. Call `begin` for the current stage and `complete` only when its required artifact exists. Use `wait` for the single consolidated user-question round, `block` for a dependency outside the project, and `resume` once resolved. Completed stages are never repeated.
|
|
19
|
+
|
|
20
|
+
- `frame`: find the optional read-only spec and have `levi-pm` write `brief.md` when no spec exists.
|
|
21
|
+
- `explore`: `levi-teamlead` writes `architecture.md` from the basis.
|
|
22
|
+
- `decide`: collect the PM/teamlead questions and the overwrite choice. Mark this stage `wait` before asking the user; after the answer, `resume` and complete it. Do not ask later unless blocked.
|
|
23
|
+
- `finalize`: dispatch the PM and teamlead with the confirmed choices; when the problem holds several features, the PM writes `phases.md` first and the teamlead plans from it. Complete only when `tasks.md` exists (and `phases.md`, for several features) and, when no spec was available, `brief.md` has been updated.
|
|
24
|
+
- `plan`: `levi-pm` writes `docs/brainstorming/<slug>.md`; if it finds a coverage gap, return only the missing tasks to the teamlead and keep this stage active.
|
|
25
|
+
- `review`: when the plan has more than ten tasks, run the independent teamlead then PM review exactly once. Complete with the final plan; otherwise complete the skipped stage without an artifact.
|
|
26
|
+
- `verify`: check totals and agents in the final plan, then complete with that plan. Only after this stage is complete may cleanup remove the checkpoint and scratch files.
|
|
27
|
+
|
|
28
|
+
Use the named Levi role agents; the coordinator alone changes `run.json`. The final plan is the only deliverable after cleanup.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: levi-code-review
|
|
3
|
-
description: Have the teamlead review code and suggest a fix for every problem it finds, without changing anything. It checks security against the OWASP Top 10 (injection, broken authentication, sensitive data exposure, XXE, broken access control, security misconfiguration, XSS, insecure deserialization, SSRF and more) and performance and correctness (N+1 queries, race conditions, memory leaks, inefficient algorithms, missing indexes, wrong error handling, breaking API changes). The target is a pull request link, a branch, a commit range, files or folders, or the uncommitted changes. The findings are given in the conversation, graded critical / warning / suggestion. Other usecases (create-feature, fix-bug) use the same review criteria for their teamlead review. Fits requests such as "review this PR", "review my changes", "check this code for security issues", "review PR này", "review code giúp tôi", "kiểm tra bảo mật đoạn code này".
|
|
3
|
+
description: Have the teamlead review code and suggest a fix for every problem it finds, without changing anything. It checks security against the OWASP Top 10 (injection, broken authentication, sensitive data exposure, XXE, broken access control, security misconfiguration, XSS, insecure deserialization, SSRF and more) and performance and correctness (N+1 queries, race conditions, memory leaks, inefficient algorithms, missing indexes, wrong error handling, breaking API changes). The target is a pull request link, a branch, a commit range, files or folders, or the uncommitted changes. The findings are given in the conversation, graded critical / warning / suggestion. A change of more than 100 files is split into slices that several teamlead reviewers read at the same time, and one lead teamlead merges their findings into a single review, so the author gets everything in one round. Other usecases (create-feature, fix-bug) use the same review criteria for their teamlead review. Fits requests such as "review this PR", "review my changes", "check this code for security issues", "review PR này", "review code giúp tôi", "kiểm tra bảo mật đoạn code này".
|
|
4
4
|
argument-hint: "<pull request link, branch, commit range or path; empty for the uncommitted changes>"
|
|
5
5
|
skill-for: teamlead
|
|
6
6
|
skill-when: you review code
|
|
@@ -9,14 +9,14 @@ skill-guide: references/review-guide.md
|
|
|
9
9
|
|
|
10
10
|
# Code review
|
|
11
11
|
|
|
12
|
-
`levi-teamlead` reviews the code; reviewing code is its job, and no other team member does it. You work out what to review, call the teamlead, and pass
|
|
12
|
+
`levi-teamlead` reviews the code; reviewing code is its job, and no other team member does it. You work out what to review, call the teamlead (or, for a large change, several), and pass the review on to the user. You never review the code yourself, and nothing is changed: not the code, not the working tree, not the pull request.
|
|
13
13
|
|
|
14
14
|
## The rules that never bend
|
|
15
15
|
|
|
16
16
|
- **Suggest, never change.** The review returns findings and fixes. Nobody edits, commits, checks out, pushes or comments on anything.
|
|
17
17
|
- **Every finding has a fix.** Each problem comes with a concrete change to make, in the project's own language and idiom.
|
|
18
18
|
- **Evidence, not guesses.** Each finding points to a file and line and says how it fails. What depends on code or config the teamlead could not see is marked as an assumption.
|
|
19
|
-
- **Relay, do not edit.** You pass the findings on as the teamlead gave them. Do not add, drop, merge or soften any.
|
|
19
|
+
- **Relay, do not edit.** You pass the findings on as the teamlead gave them. Do not add, drop, merge or soften any. (For a large change the lead teamlead merges the slices' findings; you relay its merged review.)
|
|
20
20
|
|
|
21
21
|
## Files
|
|
22
22
|
|
|
@@ -25,9 +25,14 @@ skill-guide: references/review-guide.md
|
|
|
25
25
|
| `references/review-guide.md` | How the teamlead reviews: scope, severities, finding format, verdict |
|
|
26
26
|
| `references/security.md` | Security checklist, by OWASP Top 10 category |
|
|
27
27
|
| `references/performance-and-correctness.md` | Performance and correctness checklist |
|
|
28
|
+
| `references/large-changes.md` | How a change of more than 100 files is split among teamlead reviewers and merged into one review |
|
|
28
29
|
|
|
29
30
|
Nothing is written into the project. The review is given in the conversation.
|
|
30
31
|
|
|
32
|
+
## Codex runner
|
|
33
|
+
|
|
34
|
+
On Codex, use [`references/codex-runner.md`](references/codex-runner.md). This workflow is deliberately stateless: its single read-only review dispatch is safe to restart after an interruption.
|
|
35
|
+
|
|
31
36
|
## Steps
|
|
32
37
|
|
|
33
38
|
1. **Target.** Work out what to review from the request:
|
|
@@ -42,7 +47,8 @@ Nothing is written into the project. The review is given in the conversation.
|
|
|
42
47
|
|
|
43
48
|
The base branch is the target of `git symbolic-ref --short refs/remotes/origin/HEAD` when it exists, otherwise `main` or `master`. If the target is still empty (no changes, an empty branch, a path that does not exist), tell the user and stop. When the request asks for one area only (for example "only security"), pass that on as the focus; otherwise the focus is everything.
|
|
44
49
|
2. **Pull request access.** For a pull request, check that `gh` works (`gh auth status`) and that the pull request exists (`gh pr view <link> --json number`). If either fails, tell the user what is missing and stop.
|
|
45
|
-
3. **
|
|
50
|
+
3. **Size the change.** Count the reviewable files of the target as `references/large-changes.md` says. With more than 100, review it as that file says (its split, slice and merge steps replace the single call below, with the same prompt for every teamlead call), and go to step 4 with the merged review. With 100 or fewer, continue.
|
|
51
|
+
4. **Review.** Call `levi-teamlead` once, with this prompt filled in:
|
|
46
52
|
|
|
47
53
|
```text
|
|
48
54
|
Review this code as the gate before merge. Change nothing.
|
|
@@ -60,13 +66,13 @@ Nothing is written into the project. The review is given in the conversation.
|
|
|
60
66
|
|
|
61
67
|
| Target | How to read it |
|
|
62
68
|
|---|---|
|
|
63
|
-
| Pull request | `gh pr view <link> --json title,body,baseRefName,headRefOid,files,url` and `gh pr diff <link>`. Full files: if it belongs to this repository, `git fetch origin pull/<number>/head`, then `git show <headRefOid>:<path>`; otherwise `gh api "repos/<owner>/<repo>/contents/<path>?ref=<headRefOid>" -H "Accept: application/vnd.github.raw"` |
|
|
69
|
+
| Pull request | `gh pr view <link> --json title,body,baseRefName,headRefOid,changedFiles,files,url` and `gh pr diff <link>`. Full files: if it belongs to this repository, `git fetch origin pull/<number>/head`, then `git show <headRefOid>:<path>`; otherwise `gh api "repos/<owner>/<repo>/contents/<path>?ref=<headRefOid>" -H "Accept: application/vnd.github.raw"` |
|
|
64
70
|
| Branch | `git diff <base>...<branch>`, and `git show <branch>:<path>` for full files |
|
|
65
71
|
| Commits | `git show <commit>` or `git diff <a>..<b>` |
|
|
66
72
|
| Files or folders | The files themselves |
|
|
67
73
|
| Uncommitted changes | `git diff HEAD` and the untracked files `git status --porcelain` lists |
|
|
68
74
|
|
|
69
|
-
|
|
75
|
+
5. **Relay.** Give the user the teamlead's review: the verdict, then the findings from critical to suggestion, each with its location, the problem, how it fails and the suggested fix. Then the checks it could not make, and its questions. If the teamlead was BLOCKED or needed context, tell the user what it needs.
|
|
70
76
|
|
|
71
77
|
## When another usecase reviews code
|
|
72
78
|
|
|
@@ -74,6 +80,7 @@ A usecase that has the teamlead review code (for example `create-feature` and `f
|
|
|
74
80
|
|
|
75
81
|
- names the change to review (for example "everything that differs from commit `<sha>`") and the context it is judged against (spec, plan, designs);
|
|
76
82
|
- tells the teamlead to follow `levi-code-review/references/review-guide.md` and its checklists (in the folder next to its own skill folder);
|
|
77
|
-
- says where the findings go (for example `review.md` and the workflow's schema) and which ones block
|
|
83
|
+
- says where the findings go (for example `review.md` and the workflow's schema) and which ones block;
|
|
84
|
+
- counts the reviewable files of the change, and when there are more than 100 reviews it in slices and merges the findings, as `references/large-changes.md` says. Only the lead's merge writes the review file; the slice reviewers write nothing.
|
|
78
85
|
|
|
79
86
|
The calling usecase's own rules come first: where the review is written, what blocks, and what may not be changed (for example locked tests). This usecase's rule of writing nothing applies only when it runs by itself.
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# Codex runner
|
|
2
|
+
|
|
3
|
+
This is the one Codex usecase that deliberately has no `run.json`: every dispatch is read-only and creates no project artifacts. Resolve the target and pull-request access checks first, size the change, then dispatch the installed named teamlead agent: once with the exact review prompt in `SKILL.md` for 100 or fewer reviewable files, or as `large-changes.md` says (a split, the slice reviews at the same time, then a merge) for more.
|
|
4
|
+
|
|
5
|
+
If the turn is interrupted before the review is returned, rerun the same read-only target check, sizing and dispatches. Do not write a checkpoint, comment on the pull request, or modify the working tree. Once the review is returned, relay it unchanged.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Reviewing large changes
|
|
2
|
+
|
|
3
|
+
One reviewer reading hundreds of files skims, and a skimmed review finds a few problems per round, so the author fixes, resubmits and meets the next few. A large change is therefore reviewed in slices by several teamlead calls at the same time, and one lead teamlead merges their findings into a single review. The author then gets everything in one go.
|
|
4
|
+
|
|
5
|
+
Every usecase that has the teamlead review code follows this file, whatever else it says about where the review goes and what blocks. It applies to every review round, not only the first.
|
|
6
|
+
|
|
7
|
+
Team members never call each other, so the **usecase that runs the review** (the workflow or the skill you are following) does the calling and the counting. The teamlead calls below are fresh and independent: each sees only its prompt.
|
|
8
|
+
|
|
9
|
+
## When it applies
|
|
10
|
+
|
|
11
|
+
Count the **reviewable files** of the change: the changed files, leaving out generated files, lock files, vendored code and build output (the review guide's list).
|
|
12
|
+
|
|
13
|
+
| Reviewable files | Review |
|
|
14
|
+
|---|---|
|
|
15
|
+
| 100 or fewer | One teamlead call, as the usecase says |
|
|
16
|
+
| More than 100 | Slices, as below |
|
|
17
|
+
|
|
18
|
+
Count from the whole change, never from a listing that may be cut off. For a pull request use `gh pr view <link> --json changedFiles` for the number and `gh api --paginate "repos/<owner>/<repo>/pulls/<number>/files" --jq '.[].filename'` for the names (`gh pr view --json files` stops at 100 files, and `gh pr diff` fails on very large diffs: read a pull request from this repository locally, with `git fetch origin pull/<number>/head` and a diff against the merge base).
|
|
19
|
+
|
|
20
|
+
## Steps
|
|
21
|
+
|
|
22
|
+
1. **Split.** One `levi-teamlead` call (the lead) gets the target, the file list with the changed lines of each file, and the rule below. It returns the slices: a title, the files, and one line on what the slice shares with the others (an interface, a schema, a config).
|
|
23
|
+
- At most 100 files per slice, and as few slices as that allows.
|
|
24
|
+
- Group by what belongs together: a module or feature with its tests, callers, schema and migrations; one layer of a cross-cutting change. Never by alphabet or by chunks of 100.
|
|
25
|
+
- Every reviewable file is in exactly one slice. Check this yourself before going on; send an incomplete or oversized split back to the lead once, and if it is still wrong, cut the list by directory order into slices of at most 100 files.
|
|
26
|
+
2. **Review the slices**, one fresh `levi-teamlead` call per slice, all at the same time (in batches when the tool limits how many run at once). Each gets: the same prompt a single review would get (target, how to read it, focus, context, the guide and checklists), its own files, the title and shared-interface line of every other slice, and these rules:
|
|
27
|
+
- Review every file of your slice in full and walk both checklists. Read outside the slice whenever you need context.
|
|
28
|
+
- **Report everything you find, in one pass, whatever the severity.** Nothing is kept back for a later round: the author will fix the whole list at once.
|
|
29
|
+
- Report on your slice's files. When a change in your slice breaks, or relies on, code in another slice, report it on your file and name the other location. A concern that only the other slice's reviewer can settle goes under "Cross-slice".
|
|
30
|
+
- Change nothing and write no file: your reply is the only output. The review guide's finding format applies; give no verdict for the whole change.
|
|
31
|
+
3. **Merge**, one fresh `levi-teamlead` call (the lead) gets every slice report and the split. It writes the one review the usecase asks for, in the guide's format, with one verdict:
|
|
32
|
+
- Join findings that have one cause (list every location), and give equal problems equal severity across slices.
|
|
33
|
+
- Settle each cross-slice item by reading the code on both sides; keep it as a finding, or drop it with a reason.
|
|
34
|
+
- Re-read the location of every critical finding before keeping it.
|
|
35
|
+
- Keep every valid finding. Add nothing new except what the cross-slice items turn up.
|
|
36
|
+
- A slice that returned nothing usable is called again once. If it still fails, the review is incomplete: the slice goes under "Not checked" and the verdict cannot be Approve (a workflow stops as blocked instead of continuing).
|
|
37
|
+
4. **Hand over** the merged review to whoever acts on it (the developer, or the user for `code-review`), as one list.
|
|
@@ -15,7 +15,8 @@ Read the two checklists in this folder before you start:
|
|
|
15
15
|
4. **Follow the data.** Trace every input that crosses a trust boundary (request, file, message, header, environment, third-party response) to where it is used: a query, a shell command, a template, a file path, a URL, a deserializer, a log. Most security findings sit on that path.
|
|
16
16
|
5. **Walk both checklists.** Go through every item that applies to the code. Skip the ones that cannot apply (no XML parsing means no XXE), and do not report items as passed one by one.
|
|
17
17
|
6. **Try to break it.** For each finding, write the concrete case that fails: the input, the timing, the data size or the caller that triggers it. If you cannot make one, it is not a finding.
|
|
18
|
-
7. **
|
|
18
|
+
7. **Report it all in one pass.** The author fixes everything you list, then resubmits. A finding you hold back, or a lower-severity one you skip, costs another round. List every finding you can make a case for, of every severity, before you return.
|
|
19
|
+
8. **Write the fix.** Give the change to make, where, in the project's language, framework and conventions. Prefer the framework's built-in protection (parameterized queries, the ORM's eager loading, the template engine's escaping, the framework's CSRF and auth middleware) over hand-written code.
|
|
19
20
|
|
|
20
21
|
## Scope
|
|
21
22
|
|
|
@@ -23,6 +24,7 @@ Read the two checklists in this folder before you start:
|
|
|
23
24
|
- A problem that was already there in code the change did not touch is out of scope, unless the change makes it worse or it is a critical security hole. Then report it and mark it **pre-existing**.
|
|
24
25
|
- Leave formatting and naming to the linter, unless they break a convention the project documents.
|
|
25
26
|
- Do not report a problem twice. When one cause shows in several places, report it once and list every location.
|
|
27
|
+
- A change of more than 100 reviewable files is not read by one reviewer: [large-changes.md](large-changes.md) says how it is split and merged. When you review a slice, these rules apply to your slice's files, and the lead's merge produces the one verdict.
|
|
26
28
|
|
|
27
29
|
## Severities
|
|
28
30
|
|
|
@@ -12,7 +12,7 @@ Build a feature the spec-driven way: **the spec decides, the tests and scenarios
|
|
|
12
12
|
The work has two halves:
|
|
13
13
|
|
|
14
14
|
- **Prepare** (steps 1 to 5), here in the conversation, because it needs the user: the spec, the brainstorming plan and the designs. It reuses the `spec-writing`, `brainstorming` and `design` usecases.
|
|
15
|
-
- **Implement** (step 6), without the user: tests, scenarios, code, end-to-end runs and code review. Every agent call is a fresh, independent subagent that sees only the files it is given, never the conversation or another agent's reasoning.
|
|
15
|
+
- **Implement** (step 6), without the user: tests, scenarios, code, end-to-end runs and code review. Every agent call is a fresh, independent subagent that sees only the files it is given, never the conversation or another agent's reasoning. Claude Code runs `workflow.js`; Codex uses the durable runner in [`references/codex-runner.md`](references/codex-runner.md).
|
|
16
16
|
|
|
17
17
|
## The rules that never bend
|
|
18
18
|
|
|
@@ -41,13 +41,15 @@ The work has two halves:
|
|
|
41
41
|
## Steps
|
|
42
42
|
|
|
43
43
|
1. **Intake.** The request is the feature. If it is empty, ask what to build and stop. Derive the slug. Note any spec the user attached or pointed to (a path, a link, "the spec in ...").
|
|
44
|
+
|
|
45
|
+
**Opening round.** Before any flow starts, list the candidates for the spec (`docs/specs/`), the plan (`docs/brainstorming/`) and, when the feature has a user interface, the designs (`docs/designs/`), and ask every confirmation below in one round together with anything else unclear in the request, as the run rules say. Steps 2 to 4 then use these answers instead of asking one at a time. The flows they run ask only what they cannot know before they start (the PM's open questions about the spec); after this and those rounds the run goes on alone.
|
|
44
46
|
2. **Spec.**
|
|
45
47
|
- *The user gave one:* use it.
|
|
46
|
-
- *Otherwise:* list `docs/specs/` and match files against the feature by name, title and goal. When one or more look like the spec for this feature, ask the user to confirm, in one question: each candidate (path and title) as an option, the most likely first, plus "None of these: write a new spec". Never use a candidate the user did not confirm.
|
|
48
|
+
- *Otherwise:* list `docs/specs/` and match files against the feature by name, title and goal. When one or more look like the spec for this feature, ask the user to confirm (in the opening round), in one question: each candidate (path and title) as an option, the most likely first, plus "None of these: write a new spec". Never use a candidate the user did not confirm.
|
|
47
49
|
- *Confirmed:* use it. *Rejected, or no candidate:* run the `spec-writing` flow with the feature as subject, to write a new spec in `docs/specs/`, then use that.
|
|
48
50
|
- **The spec must be Ready.** If its Status is Draft, its open questions would have to be guessed, so do not implement yet. Ask the user to settle them, and run the `spec-writing` flow in update mode with the answers. If the user prefers to leave a point out, that is an answer too: the PM moves it to Out of scope. Continue only when the Status is Ready.
|
|
49
|
-
3. **Brainstorming plan.** List `docs/brainstorming/` and match plans against the feature and the spec. One clear match: use it, and say which in one line. Two or more equally plausible: ask the user which one (or "none"). None: run the `brainstorming` flow, with the feature and the spec, and use the plan it writes.
|
|
50
|
-
4. **Designs.** Decide from the spec whether the feature has a user interface (screens, pages, forms, components, visible states). If it has none, skip this step. If it has, list `docs/designs/` and match folders against the feature: one clear match is used; two or more plausible ones, ask the user; none: run the `design` flow with the feature as subject and the spec as context, and use the folder it writes.
|
|
51
|
+
3. **Brainstorming plan.** List `docs/brainstorming/` and match plans against the feature and the spec. One clear match: use it, and say which in one line. Two or more equally plausible: ask the user which one (or "none") in the opening round. None: run the `brainstorming` flow, with the feature and the spec, and use the plan it writes.
|
|
52
|
+
4. **Designs.** Decide from the spec whether the feature has a user interface (screens, pages, forms, components, visible states). If it has none, skip this step. If it has, list `docs/designs/` and match folders against the feature: one clear match is used; two or more plausible ones, ask the user in the opening round; none: run the `design` flow with the feature as subject and the spec as context, and use the folder it writes.
|
|
51
53
|
5. **Get ready.** Delete `docs/levi/<slug>/locked/` and `qa-snapshot/` if an earlier run left them. Work out the feature ID and the output base `<base>` of the test cases from the spec, as the "Features, IDs and file names" table of `levi-generate-test-scenarios/SKILL.md` says. Say in a few lines what will be used (spec, plan, designs) and that implementation starts now.
|
|
52
54
|
6. **Implement.**
|
|
53
55
|
- *With a Workflow tool (Claude Code):* call it with `scriptPath` set to `workflow.js` in this skill's folder, and `args`:
|
|
@@ -66,12 +68,13 @@ The work has two halves:
|
|
|
66
68
|
```
|
|
67
69
|
|
|
68
70
|
The script runs the steps under [Implementation](#implementation) below and returns a result with a `status`. Follow its progress with the user only when they ask.
|
|
69
|
-
- *
|
|
71
|
+
- *On Codex:* follow [`references/codex-runner.md`](references/codex-runner.md). It persists the stage in `docs/levi/<slug>/run.json`, so a stopped run resumes from the recorded stage rather than restarting. Run the steps under [Implementation](#implementation) through that runner, each agent call as a new named subagent call that gets only the paths and instructions written there.
|
|
72
|
+
- *Other tools without a Workflow tool:* run the steps under [Implementation](#implementation) yourself, in order, each agent call as a new subagent call that gets only the paths and instructions written there.
|
|
70
73
|
7. **Act on the result.**
|
|
71
74
|
- `done`: go to step 8.
|
|
72
75
|
- `spec_questions`: the spec is silent or unclear on a point the tests depend on. Ask the user the questions in one round, run the `spec-writing` flow in update mode with the answers, then run step 6 again from the start.
|
|
73
76
|
- `blocked`: something outside the code stops the work (the app cannot start, a service or a credential is missing, an agent could not finish). Tell the user the stage and the detail, and what they need to provide. Keep `docs/levi/<slug>/`. Run step 6 again when they say to.
|
|
74
|
-
- `stalled`: the build rounds ran out (10 by default) and something still fails. Tell the user what failed last.
|
|
77
|
+
- `stalled`: the build rounds ran out (10 by default) and something still fails. Tell the user what failed last. On Claude Code, continue in the same session with `resumeFromRunId` and a higher `maxRounds`; on Codex, keep `run.json` and resume its active `build` stage after the user asks to continue. Tests and test cases still do not change.
|
|
75
78
|
8. **Clean up.** Delete `docs/levi/<slug>/` (`tasks.md`, `review.md`, `locked/`), then `docs/levi` if it is empty. Keep everything else: spec, plan, designs, tests, test cases with their results, code.
|
|
76
79
|
9. **Report.** Tell the user: the spec, plan and designs used (and which were created in this run); the test files and the command that runs them; the test case files with their result (for example `12/12 PASS`); how many build rounds it took; the review outcome and the suggestions left open; the files changed (from `git status`); and that nothing was committed.
|
|
77
80
|
|
|
@@ -89,6 +92,6 @@ The steps the Workflow runs, and the ones you run when there is no Workflow tool
|
|
|
89
92
|
6. **Build**, in rounds (at most 10 unless raised), until the teamlead approves and every scenario passes:
|
|
90
93
|
1. *Code.* First round: each batch in order, the tasks of a batch in parallel, each by its owner (`levi-developer`, or `levi-teamlead` for schema, migrations and CI/CD). Later rounds: the owners fix exactly what the last round found.
|
|
91
94
|
2. *Gate.* Run `lock-tests.mjs verify docs/levi/<slug>/locked` (it restores any locked file that was changed), then the new tests, then the whole suite. Any restored file, failing test or regression sends the round back to the developer with the failures.
|
|
92
|
-
3. *Review* — once the tests pass, a fresh `levi-teamlead` call reviews the change since the baseline against the spec, `tasks.md` and the designs (correctness, security, performance, fit), following `levi-code-review/references/review-guide.md` and its checklists, writes `review.md` and approves only when no critical or warning finding is left. Findings go back to their owners, and the round starts again.
|
|
95
|
+
3. *Review* — once the tests pass, a fresh `levi-teamlead` call reviews the change since the baseline against the spec, `tasks.md` and the designs (correctness, security, performance, fit), following `levi-code-review/references/review-guide.md` and its checklists, writes `review.md` and approves only when no critical or warning finding is left. A change of more than 100 reviewable files is not read by one teamlead: it is split into slices of at most 100 files, reviewed by several fresh `levi-teamlead` calls at the same time, and a lead `levi-teamlead` call merges their reports into the one `review.md`, as `levi-code-review/references/large-changes.md` says. Findings go back to their owners, and the round starts again.
|
|
93
96
|
4. *E2E* — only after the review approves. First `lock-tests.mjs verify docs/levi/<slug>/qa-snapshot`, which undoes any change to the test cases made outside QA. Then `levi-qa` starts the app, 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), records PASS or FAIL and the evidence as its test case guide says, and stops the app; the snapshot is then taken again. Any case that is not PASS goes back to the developer with the evidence, and the next round runs code, gate, review and E2E again.
|
|
94
97
|
5. The run is done when the review approves and every case passes.
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Codex runner
|
|
2
|
+
|
|
3
|
+
This file is the durable runner for Codex. It replaces the Claude-only `workflow.js`; do not try to execute that file with Node or translate its state from chat history.
|
|
4
|
+
|
|
5
|
+
## Start or continue
|
|
6
|
+
|
|
7
|
+
After preparation has selected a Ready spec, a plan and any required designs, use the state helper installed in this skill folder. Run every command below from the project root:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
node <this skill folder>/scripts/codex-run-state.mjs status docs/levi/<slug>
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
If there is no state file, start one:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
node <this skill folder>/scripts/codex-run-state.mjs init docs/levi/<slug> create-feature <slug> plan tests lock build
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Never create a second state file for the same run. On a resumed run, read `status`; its `currentStage`, stage `status`, artifacts and history decide the next action. Do not repeat a completed stage.
|
|
20
|
+
|
|
21
|
+
Before starting or retrying the current stage, call `begin`. It is valid to call `begin` again on an active stage; that records a new attempt. A successful stage is recorded only after its required artifact exists:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
node <this skill folder>/scripts/codex-run-state.mjs begin docs/levi/<slug> <stage>
|
|
25
|
+
node <this skill folder>/scripts/codex-run-state.mjs complete docs/levi/<slug> <stage> <artifact>...
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
For a question only the user can settle, or an external blocker, preserve the exact reason before returning it:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
node <this skill folder>/scripts/codex-run-state.mjs wait docs/levi/<slug> <stage> "<questions for the user>"
|
|
32
|
+
node <this skill folder>/scripts/codex-run-state.mjs block docs/levi/<slug> <stage> "<external blocker>"
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
When the user answers or supplies the missing dependency, run `resume` and continue the same stage. Do not use `resumeFromRunId`: that is a Claude Workflow capability, not a Codex recovery mechanism.
|
|
36
|
+
|
|
37
|
+
## Stages
|
|
38
|
+
|
|
39
|
+
### `plan`
|
|
40
|
+
|
|
41
|
+
Dispatch `levi-teamlead` with only the spec, plan, designs, project and work-folder paths. It writes `tasks.md`. Check that every acceptance criterion has a test group, then complete this stage with `tasks.md`.
|
|
42
|
+
|
|
43
|
+
### `tests`
|
|
44
|
+
|
|
45
|
+
Run the developer test groups and the QA scenario track as separate named Codex subagents. They may run in parallel only when their output paths do not overlap. The developer tests and QA cases are then independently reviewed and repaired until approved, up to the existing five-review limit. Do not advance until both tracks are approved and `test-cases.json`, `<testBase>.md` and `<testBase>.xlsx` exist. If a reviewer finds a spec ambiguity, mark this stage `wait`; do not guess.
|
|
46
|
+
|
|
47
|
+
### `lock`
|
|
48
|
+
|
|
49
|
+
Run the existing `lock-tests.mjs` commands for the approved test files and QA deliverables. Complete only after both manifests exist: `locked/manifest.json` and `qa-snapshot/manifest.json`.
|
|
50
|
+
|
|
51
|
+
### `build`
|
|
52
|
+
|
|
53
|
+
Keep this stage active through all build rounds. In each round, dispatch only the owner of the pending implementation, test, review or E2E finding. Then run the lock verification, feature tests and whole suite. Run the teamlead review only after the test gate passes; for more than 100 reviewable files follow `levi-code-review/references/large-changes.md` (a teamlead split, parallel teamlead slice reviews that write no file, then one teamlead merge that writes `review.md`). Run QA E2E only after that review approves. Record every real failure in the next Codex subagent prompt. Complete `build` only after the review approves and every QA case is PASS; pass `review.md`, `<testBase>.md` and `<testBase>.xlsx` as artifacts.
|
|
54
|
+
|
|
55
|
+
## Dispatch contract
|
|
56
|
+
|
|
57
|
+
Use the installed named agents (`levi-teamlead`, `levi-developer`, `levi-qa`, `levi-pm`) rather than asking a general agent to impersonate a role. Each prompt must name the allowed input paths, output paths, acceptance criteria, and whether the agent may edit. The coordinator alone advances the state. Keep dependent operations in the coordinator; reserve parallel subagents for independent test groups or implementation batches that the plan says do not overlap.
|
|
@@ -315,6 +315,101 @@ const snapped = await snapshotScenarios()
|
|
|
315
315
|
if (!snapped || snapped.exitCode !== 0) return { status: 'blocked', stage: 'lock', detail: snapped ? snapped.summary : 'the test cases could not be snapshotted' }
|
|
316
316
|
log(`locked ${tests.files.length} test file(s); ${scenarios.scenarioCount} test case(s) kept as QA wrote them`)
|
|
317
317
|
|
|
318
|
+
const REVIEW_PHASE = 'Build'
|
|
319
|
+
// ---- review of the change: one teamlead, or slices merged by a lead when the change is large ----
|
|
320
|
+
// levi-code-review/references/large-changes.md explains why: one reviewer skims a big change and finds problems a few at a time.
|
|
321
|
+
|
|
322
|
+
const LARGE_CHANGE = 100 // reviewable files; more than this is reviewed in slices
|
|
323
|
+
const LARGE_GUIDE = `${A.skillDir}/../levi-code-review/references/large-changes.md`
|
|
324
|
+
const FINDING = CODE_REVIEW.properties.findings.items
|
|
325
|
+
const CHANGED = obj({ files: { type: 'array', items: obj({ path: { type: 'string' }, lines: { type: 'integer' } }) } })
|
|
326
|
+
const SLICES = obj({ slices: { type: 'array', items: obj({ title: { type: 'string' }, files: STRINGS, shares: { type: 'string' } }) } })
|
|
327
|
+
const SLICE_REVIEW = obj({ summary: { type: 'string' }, findings: { type: 'array', items: FINDING }, crossSlice: STRINGS, notChecked: STRINGS })
|
|
328
|
+
|
|
329
|
+
// What is wrong with a split: a slice over the limit, a file in no slice, a file in two slices or not in the change.
|
|
330
|
+
const splitProblems = (slices, paths) => {
|
|
331
|
+
const placed = slices.flatMap((s) => s.files)
|
|
332
|
+
return [
|
|
333
|
+
...slices.filter((s) => s.files.length > LARGE_CHANGE).map((s) => `slice "${s.title}" has ${s.files.length} files, more than ${LARGE_CHANGE}`),
|
|
334
|
+
...paths.filter((p) => !placed.includes(p)).map((p) => `${p} is in no slice`),
|
|
335
|
+
...placed.filter((p, i) => placed.indexOf(p) !== i || !paths.includes(p)).map((p) => `${p} is in two slices or not part of the change`),
|
|
336
|
+
]
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
async function splitChange(round, files) {
|
|
340
|
+
const paths = files.map((f) => f.path)
|
|
341
|
+
const ask = (note) =>
|
|
342
|
+
agent(
|
|
343
|
+
`${CONTEXT}
|
|
344
|
+
|
|
345
|
+
This change is too large for one reviewer (${paths.length} reviewable files). Split it into slices that are reviewed at the same time, as the "Steps" of ${LARGE_GUIDE} say: at most ${LARGE_CHANGE} files per slice and as few slices as that allows, grouped by what belongs together (a module or feature with its tests, callers, schema and migrations; never by alphabet), every file in exactly one slice. For each slice return a title, its files, and one line on what it shares with the other slices (an interface, a schema, a config). Change nothing and write no file.
|
|
346
|
+
The files, with their changed lines:
|
|
347
|
+
${files.map((f) => `${f.path} (${f.lines})`).join('\n')}${note}`,
|
|
348
|
+
{ label: `teamlead:split-${round}`, phase: REVIEW_PHASE, agentType: 'levi-teamlead', schema: SLICES },
|
|
349
|
+
)
|
|
350
|
+
let split = await ask('')
|
|
351
|
+
let problems = split ? splitProblems(split.slices, paths) : ['no split was returned']
|
|
352
|
+
if (problems.length) {
|
|
353
|
+
split = await ask(`\n\nYour previous split was not valid: ${problems.slice(0, 20).join('; ')}. Return the whole corrected split.`)
|
|
354
|
+
problems = split ? splitProblems(split.slices, paths) : ['no split was returned']
|
|
355
|
+
}
|
|
356
|
+
if (!problems.length) return split.slices
|
|
357
|
+
log(`the lead's split was not usable (${problems[0]}); cutting the file list by path`)
|
|
358
|
+
const sorted = [...paths].sort()
|
|
359
|
+
return Array.from({ length: Math.ceil(sorted.length / LARGE_CHANGE) }, (_, i) => ({
|
|
360
|
+
title: `Files ${i * LARGE_CHANGE + 1}-${Math.min((i + 1) * LARGE_CHANGE, sorted.length)} by path`,
|
|
361
|
+
files: sorted.slice(i * LARGE_CHANGE, (i + 1) * LARGE_CHANGE),
|
|
362
|
+
shares: 'unknown: read the other slices as needed',
|
|
363
|
+
}))
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
// `brief` says what the review is for and what to check; `output` says where the review goes and what blocks.
|
|
367
|
+
async function reviewChange(round, brief, output) {
|
|
368
|
+
const changed = await guard(
|
|
369
|
+
`changed-files-${round}`,
|
|
370
|
+
`List the reviewable files of the change: every file that differs from commit ${base.head} (git diff --name-only ${base.head}) and every untracked file (git status --porcelain), leaving out files that were already modified before the run (${base.dirty.join(', ') || 'none'}), generated files, lock files, vendored code and build output. Give each path with its number of changed lines (git diff --numstat ${base.head}; the line count for an untracked file).`,
|
|
371
|
+
CHANGED,
|
|
372
|
+
)
|
|
373
|
+
if (!changed) return null
|
|
374
|
+
const prompt = `${CONTEXT}\n\n${brief}\nFollow ${REVIEW_GUIDE} and the two checklists next to it (security by OWASP Top 10, performance and correctness), but write the findings where and how this prompt says.`
|
|
375
|
+
if (changed.files.length <= LARGE_CHANGE) {
|
|
376
|
+
return agent(`${prompt}\n${output}`, { label: `teamlead:review-${round}`, phase: REVIEW_PHASE, agentType: 'levi-teamlead', schema: CODE_REVIEW })
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
log(`round ${round}: ${changed.files.length} reviewable files, so the review is split into slices (${LARGE_GUIDE})`)
|
|
380
|
+
const slices = await splitChange(round, changed.files)
|
|
381
|
+
const others = (i) => slices.map((s, j) => (j === i ? null : `- ${s.title} (${s.files.length} files): shares ${s.shares}`)).filter(Boolean).join('\n')
|
|
382
|
+
const reviewSlice = (s, i) =>
|
|
383
|
+
agent(
|
|
384
|
+
`${prompt}
|
|
385
|
+
|
|
386
|
+
This change is large (${changed.files.length} reviewable files), so ${slices.length} reviewers each review one slice at the same time, and a lead merges their reports. You review slice ${i + 1}: ${s.title}. It shares: ${s.shares}.
|
|
387
|
+
Your files, to review in full:
|
|
388
|
+
${s.files.join('\n')}
|
|
389
|
+
The other slices:
|
|
390
|
+
${others(i)}
|
|
391
|
+
Report every finding you can make a case for in your files, in one pass, whatever the severity: nothing is held for a later round, because the author fixes the whole list at once. When a change in your files breaks or relies on code in another slice, report it on your file and name the other location; what only another slice's reviewer can settle goes in crossSlice. Do not write ${REVIEW} or any other file and change nothing: your reply is the review of this slice. Give no verdict for the whole change. Findings carry the same fields as in a full review.`,
|
|
392
|
+
{ label: `teamlead:review-${round}-slice-${i + 1}`, phase: REVIEW_PHASE, agentType: 'levi-teamlead', schema: SLICE_REVIEW },
|
|
393
|
+
)
|
|
394
|
+
const reports = [...(await parallel(slices.map((s, i) => () => reviewSlice(s, i))))]
|
|
395
|
+
const failed = slices.map((_, i) => i).filter((i) => !reports[i])
|
|
396
|
+
if (failed.length) {
|
|
397
|
+
const again = await parallel(failed.map((i) => () => reviewSlice(slices[i], i)))
|
|
398
|
+
failed.forEach((i, k) => (reports[i] = again[k]))
|
|
399
|
+
}
|
|
400
|
+
if (reports.some((r) => !r)) return null
|
|
401
|
+
|
|
402
|
+
return agent(
|
|
403
|
+
`${prompt}
|
|
404
|
+
|
|
405
|
+
You are the lead teamlead. ${slices.length} reviewers reviewed this large change in slices; ${LARGE_GUIDE} ("Steps", the merge) says how to combine them. Their reports:
|
|
406
|
+
${JSON.stringify(slices.map((s, i) => ({ slice: s.title, files: s.files.length, report: reports[i] })))}
|
|
407
|
+
Merge them into the one review: join findings that have one cause (list every location), give equal problems equal severity, settle each crossSlice item by reading the code on both sides, re-read the location of every critical finding before you keep it, keep every valid finding and add nothing else. Do not approve while any slice lists something in notChecked that matters to the verdict.
|
|
408
|
+
${output}`,
|
|
409
|
+
{ label: `teamlead:review-${round}-merge`, phase: REVIEW_PHASE, agentType: 'levi-teamlead', schema: CODE_REVIEW },
|
|
410
|
+
)
|
|
411
|
+
}
|
|
412
|
+
|
|
318
413
|
// ---- 4. Build: implement, tests, review, then E2E, until the review approves and every scenario passes ----
|
|
319
414
|
|
|
320
415
|
const RULES = LOCKED_RULES(tests.files)
|
|
@@ -390,15 +485,12 @@ for (let round = 1; round <= MAX_BUILD_ROUNDS; round++) {
|
|
|
390
485
|
continue
|
|
391
486
|
}
|
|
392
487
|
|
|
393
|
-
const review = await
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
Review the code change of this feature as the gate before merge. The change is everything that differs from commit ${base.head} (git diff and untracked files), leaving out files that were already modified before the run: ${base.dirty.join(', ') || 'none'}.
|
|
488
|
+
const review = await reviewChange(
|
|
489
|
+
round,
|
|
490
|
+
`Review the code change of this feature as the gate before merge. The change is everything that differs from commit ${base.head} (git diff and untracked files), leaving out files that were already modified before the run: ${base.dirty.join(', ') || 'none'}.
|
|
397
491
|
All unit and feature tests pass. The tests are locked and the test cases are QA's; both are correct by definition: do not propose changing them.
|
|
398
|
-
Check the change against the spec, ${TASKS} and the designs: correctness, security (input validation, authorization, secrets), performance, fit with the architecture and conventions, missing pieces
|
|
399
|
-
|
|
400
|
-
Write ${REVIEW}: findings graded critical / warning / suggestion, each with the file, the problem, a concrete fix and its owner (levi-teamlead for schema, migrations and CI/CD, levi-developer for the rest). Approve only when no critical or warning finding remains; suggestions alone do not block.`,
|
|
401
|
-
{ label: `teamlead:review-${round}`, phase: 'Build', agentType: 'levi-teamlead', schema: CODE_REVIEW },
|
|
492
|
+
Check the change against the spec, ${TASKS} and the designs: correctness, security (input validation, authorization, secrets), performance, fit with the architecture and conventions, missing pieces.`,
|
|
493
|
+
`Write ${REVIEW}: findings graded critical / warning / suggestion, each with the file, the problem, a concrete fix and its owner (levi-teamlead for schema, migrations and CI/CD, levi-developer for the rest). Approve only when no critical or warning finding remains; suggestions alone do not block.`,
|
|
402
494
|
)
|
|
403
495
|
if (!review) return { status: 'blocked', stage: 'review', detail: 'the code review did not complete' }
|
|
404
496
|
const blocking = review.findings.filter((f) => f.severity !== 'suggestion')
|
package/usecases/design/SKILL.md
CHANGED
|
@@ -33,6 +33,10 @@ A design is built from what the user gave: the text, the images, the frames of t
|
|
|
33
33
|
|
|
34
34
|
`<slug>` is a short kebab-case name for what is designed, in English (for example `login-screen`). Create folders as needed. Pass the designer the exact paths it should read and write. The files the user uploaded are the user's: never move, edit or delete them.
|
|
35
35
|
|
|
36
|
+
## Codex runner
|
|
37
|
+
|
|
38
|
+
On Codex, use [`references/codex-runner.md`](references/codex-runner.md). It checkpoints reference preparation, drawing and validation in `docs/levi/<slug>/run.json` so a stopped run resumes safely.
|
|
39
|
+
|
|
36
40
|
## Steps
|
|
37
41
|
|
|
38
42
|
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.
|
|
@@ -51,11 +55,12 @@ A design is built from what the user gave: the text, the images, the frames of t
|
|
|
51
55
|
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
56
|
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:
|
|
53
57
|
- decide the list of files before drawing, and keep tokens and components the same across all of them;
|
|
54
|
-
- write only SVG files in the output folder, no notes or other files;
|
|
58
|
+
- write only SVG files in the output folder, no notes or other files (variants it did not pick go in `alternatives/` inside it);
|
|
59
|
+
- 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;
|
|
55
60
|
- 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;
|
|
56
61
|
- return in its report the file list with one line per file, the assumptions it made, what it could not reproduce, and its questions.
|
|
57
62
|
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.
|
|
58
63
|
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.
|
|
59
|
-
7. **
|
|
60
|
-
8. **Clean up.**
|
|
64
|
+
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.
|
|
65
|
+
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.
|
|
61
66
|
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.
|