levi-gear 0.4.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -35
- package/docs/README.md +39 -0
- package/docs/authoring-usecases.md +123 -0
- package/docs/cli.md +99 -0
- package/docs/codex.md +23 -0
- package/docs/configuration.md +81 -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 +49 -0
- package/docs/updating.md +109 -0
- package/docs/usage.md +62 -0
- package/docs/usecases.md +460 -0
- package/package.json +4 -3
- package/src/cli.js +3 -3
- package/src/commands/init.js +20 -25
- package/src/commands/list.js +3 -5
- package/src/commands/status.js +1 -1
- package/src/commands/update.js +4 -4
- package/src/lib/agents.js +1 -1
- package/src/lib/desired-state.js +62 -31
- package/src/lib/sync.js +3 -3
- package/src/lib/tools.js +10 -81
- package/src/runtime/codex-checkpoint.mjs +48 -0
- package/src/runtime/quota-check.mjs +21 -142
- package/usecases/_run-rules.md +13 -20
- package/usecases/brainstorming/SKILL.md +0 -4
- package/usecases/code-review/SKILL.md +0 -4
- package/usecases/create-feature/SKILL.md +3 -4
- package/usecases/create-feature/scripts/lock-tests.mjs +21 -8
- package/usecases/design/SKILL.md +0 -4
- package/usecases/fix-bug/SKILL.md +3 -4
- package/usecases/generate-test-scenarios/SKILL.md +0 -5
- package/usecases/spec-writing/SKILL.md +0 -4
- package/src/runtime/codex-run-state.mjs +0 -156
- package/usecases/brainstorming/references/codex-runner.md +0 -28
- package/usecases/code-review/references/codex-runner.md +0 -5
- package/usecases/create-feature/references/codex-runner.md +0 -57
- package/usecases/design/references/codex-runner.md +0 -27
- package/usecases/fix-bug/references/codex-runner.md +0 -32
- package/usecases/generate-test-scenarios/references/codex-runner.md +0 -32
- package/usecases/spec-writing/references/codex-runner.md +0 -25
|
@@ -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. Claude Code runs `workflow.js
|
|
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`.
|
|
16
16
|
|
|
17
17
|
## The rules that never bend
|
|
18
18
|
|
|
@@ -68,13 +68,12 @@ The work has two halves:
|
|
|
68
68
|
```
|
|
69
69
|
|
|
70
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.
|
|
71
|
-
- *
|
|
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.
|
|
71
|
+
- *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.
|
|
73
72
|
7. **Act on the result.**
|
|
74
73
|
- `done`: go to step 8.
|
|
75
74
|
- `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.
|
|
76
75
|
- `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.
|
|
77
|
-
- `stalled`: the build rounds ran out (10 by default) and something still fails. Tell the user what failed last.
|
|
76
|
+
- `stalled`: the build 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
77
|
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.
|
|
79
78
|
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.
|
|
80
79
|
|
|
@@ -14,9 +14,11 @@ import crypto from 'node:crypto';
|
|
|
14
14
|
|
|
15
15
|
const RESULT_LINE = /^\s*- \*\*(Status|Evidence):\*\*.*$/gm;
|
|
16
16
|
|
|
17
|
-
function hash(file) {
|
|
18
|
-
|
|
19
|
-
if (
|
|
17
|
+
function hash(file, legacy = false, logicalPath = file) {
|
|
18
|
+
const bytes = fs.readFileSync(file);
|
|
19
|
+
if (!legacy && !logicalPath.endsWith('.md')) return crypto.createHash('sha256').update(bytes).digest('hex');
|
|
20
|
+
let text = bytes.toString('utf8').replace(/\r\n/g, '\n');
|
|
21
|
+
if (logicalPath.endsWith('.md')) text = text.replace(RESULT_LINE, '');
|
|
20
22
|
return crypto.createHash('sha256').update(text).digest('hex');
|
|
21
23
|
}
|
|
22
24
|
|
|
@@ -30,22 +32,33 @@ function lock(dir, paths) {
|
|
|
30
32
|
if (!paths.length) throw new Error('nothing to lock');
|
|
31
33
|
const files = {};
|
|
32
34
|
for (const file of [...new Set(paths.flatMap(walk))].map((f) => path.normalize(f))) {
|
|
33
|
-
|
|
35
|
+
// Keep snapshots out of test discovery (for example Node's **/*.test.js).
|
|
36
|
+
const copy = path.join(dir, 'files', `${file}.levi-snapshot`);
|
|
34
37
|
fs.mkdirSync(path.dirname(copy), { recursive: true });
|
|
35
38
|
fs.copyFileSync(file, copy);
|
|
36
39
|
files[file] = hash(file);
|
|
37
40
|
}
|
|
38
|
-
fs.writeFileSync(path.join(dir, 'manifest.json'), JSON.stringify({ files }, null, 2) + '\n');
|
|
41
|
+
fs.writeFileSync(path.join(dir, 'manifest.json'), JSON.stringify({ version: 2, files }, null, 2) + '\n');
|
|
39
42
|
console.log(JSON.stringify({ locked: Object.keys(files) }, null, 2));
|
|
40
43
|
}
|
|
41
44
|
|
|
42
45
|
function verify(dir) {
|
|
43
|
-
const { files } = JSON.parse(fs.readFileSync(path.join(dir, 'manifest.json'), 'utf8'));
|
|
46
|
+
const { files, version } = JSON.parse(fs.readFileSync(path.join(dir, 'manifest.json'), 'utf8'));
|
|
44
47
|
const restored = [];
|
|
45
48
|
for (const [file, expected] of Object.entries(files)) {
|
|
46
|
-
|
|
49
|
+
const snapshot = path.join(dir, 'files', `${file}.levi-snapshot`);
|
|
50
|
+
const legacy = path.join(dir, 'files', file);
|
|
51
|
+
// Move old snapshots out of test discovery even when the original is intact.
|
|
52
|
+
if (!fs.existsSync(snapshot) && fs.existsSync(legacy) && fs.statSync(legacy).isFile()) fs.renameSync(legacy, snapshot);
|
|
53
|
+
if (!fs.existsSync(snapshot)) throw new Error(`snapshot missing: ${file}`);
|
|
54
|
+
const currentSnapshotHash = hash(snapshot, false, file);
|
|
55
|
+
const oldHash = version !== 2 && currentSnapshotHash !== expected;
|
|
56
|
+
if (currentSnapshotHash !== expected && (!oldHash || hash(snapshot, true, file) !== expected)) {
|
|
57
|
+
throw new Error(`snapshot corrupted: ${file}`);
|
|
58
|
+
}
|
|
59
|
+
if (fs.existsSync(file) && hash(file, oldHash) === expected) continue;
|
|
47
60
|
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
48
|
-
fs.copyFileSync(
|
|
61
|
+
fs.copyFileSync(snapshot, file);
|
|
49
62
|
restored.push(file);
|
|
50
63
|
}
|
|
51
64
|
console.log(JSON.stringify({ intact: restored.length === 0, restored, checked: Object.keys(files).length }, null, 2));
|
package/usecases/design/SKILL.md
CHANGED
|
@@ -33,10 +33,6 @@ 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
|
-
|
|
40
36
|
## Steps
|
|
41
37
|
|
|
42
38
|
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.
|
|
@@ -14,7 +14,7 @@ Fix a bug with the team: `levi-developer` clarifies, investigates and fixes, `le
|
|
|
14
14
|
The work has two halves:
|
|
15
15
|
|
|
16
16
|
- **Clarify** (steps 1 to 5), here in the conversation, because it needs the user. The developer lists what is unclear and the user confirms it.
|
|
17
|
-
- **Fix** (step 6), without the user. Claude Code runs `workflow.js
|
|
17
|
+
- **Fix** (step 6), without the user. Claude Code runs `workflow.js`. Every agent call is a fresh subagent that sees only the files it is given, and the developer and QA work at the same time without reading each other's work.
|
|
18
18
|
|
|
19
19
|
## The rules that never bend
|
|
20
20
|
|
|
@@ -67,15 +67,14 @@ The work has two halves:
|
|
|
67
67
|
```
|
|
68
68
|
|
|
69
69
|
Set `allMerged` to false when step 2 found unmerged work.
|
|
70
|
-
- *
|
|
71
|
-
- *Other tools 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.
|
|
70
|
+
- *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.
|
|
72
71
|
7. **Act on the result.**
|
|
73
72
|
- `done`: go to step 8.
|
|
74
73
|
- `questions`: an agent found a point that is still open. Ask the user, append the answers to `confirmed.md`, and run step 6 again.
|
|
75
74
|
- `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.
|
|
76
75
|
- `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.
|
|
77
76
|
- `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.
|
|
78
|
-
- `stalled`: the rounds ran out (10 by default) and something still fails. Tell the user what failed last.
|
|
77
|
+
- `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.
|
|
79
78
|
8. **Clean up.** Delete `docs/levi/<slug>/`, then `docs/levi` if it is empty. Keep everything else.
|
|
80
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
80
|
|
|
@@ -26,7 +26,6 @@ skill-guide: references/test-case-guide.md
|
|
|
26
26
|
| `docs/tests/<base>.xlsx` | QA | **Deliverable**: one sheet, one row per case, columns `ID, Title, Category, Priority, Preconditions, Steps, Expected Result, Notes` |
|
|
27
27
|
| `docs/levi/test-cases/<FeatureID>-analysis.md` | QA | Scratch: spec items, coverage plan, ambiguities, readiness |
|
|
28
28
|
| `docs/levi/test-cases/<FeatureID>.json` | QA | Scratch: the cases the two deliverables are rendered from |
|
|
29
|
-
| `docs/levi/test-cases/selection.md` | Workflow | Scratch: the confirmed feature list, output bases and overwrite choices for a resumable Codex run |
|
|
30
29
|
| `references/test-case-guide.md` | - | How QA analyzes the spec and writes the cases |
|
|
31
30
|
| `scripts/render-test-cases.mjs` | - | Checks the cases and renders both deliverables from them, so they always agree. The cases are also embedded in the `.md`, so QA can change them later |
|
|
32
31
|
|
|
@@ -41,10 +40,6 @@ A feature is one spec file, or one folder of spec files, under `docs/specs/` (se
|
|
|
41
40
|
| Output `<base>` | `<FeatureID>-<slug>` when the spec has a code (`F001-login`); `<slug>-test-cases` when it has none (`export-orders-csv-test-cases`) |
|
|
42
41
|
| Case ID | `TC-<FeatureID>-<3 digits>`, for example `TC-F001-001` |
|
|
43
42
|
|
|
44
|
-
## Codex runner
|
|
45
|
-
|
|
46
|
-
On Codex, use [`references/codex-runner.md`](references/codex-runner.md). It checkpoints selection, per-feature QA work and verification in `docs/levi/test-cases/run.json` so a stopped run does not silently regenerate finished outputs.
|
|
47
|
-
|
|
48
43
|
## Steps
|
|
49
44
|
|
|
50
45
|
1. **Intake.** From the request, take the feature codes (`F001`, `F002`, ...) and the spec files or folders it names. Anything else in it (a focus such as "only permissions") is passed to QA as written.
|
|
@@ -22,10 +22,6 @@ A spec is a promise to the rest of the team: **a line goes into the spec only wh
|
|
|
22
22
|
|
|
23
23
|
`<slug>` is a short kebab-case name for the subject, in English (for example `export-orders-csv`). Create folders as needed. Pass the PM the exact paths it should read and write. Only the PM touches either file.
|
|
24
24
|
|
|
25
|
-
## Codex runner
|
|
26
|
-
|
|
27
|
-
On Codex, use [`references/codex-runner.md`](references/codex-runner.md). It persists question rounds and the selected output in `docs/levi/<slug>/run.json`, allowing the run to continue after an interruption.
|
|
28
|
-
|
|
29
25
|
## Steps
|
|
30
26
|
|
|
31
27
|
1. **Intake.** The request is the subject. If it is empty, ask what the spec is about and stop. Derive the slug. Note every file or link the user mentioned: they are sources.
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// Durable, tool-neutral checkpoint helper installed with every Codex levi skill.
|
|
3
|
-
// It deliberately does not run agents: the Codex skill remains responsible for
|
|
4
|
-
// dispatching the right role, while this file makes a stopped run resumable.
|
|
5
|
-
|
|
6
|
-
import fs from 'node:fs';
|
|
7
|
-
import path from 'node:path';
|
|
8
|
-
|
|
9
|
-
const [command, workDir, ...args] = process.argv.slice(2);
|
|
10
|
-
const stateFile = workDir && path.join(workDir, 'run.json');
|
|
11
|
-
|
|
12
|
-
function die(message) {
|
|
13
|
-
console.error(message);
|
|
14
|
-
process.exitCode = 2;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function read() {
|
|
18
|
-
if (!stateFile || !fs.existsSync(stateFile)) throw new Error(`no run state at ${stateFile || '<workdir>'}`);
|
|
19
|
-
return JSON.parse(fs.readFileSync(stateFile, 'utf8'));
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function write(state) {
|
|
23
|
-
fs.mkdirSync(workDir, { recursive: true });
|
|
24
|
-
state.updatedAt = new Date().toISOString();
|
|
25
|
-
const temporary = `${stateFile}.${process.pid}.tmp`;
|
|
26
|
-
fs.writeFileSync(temporary, JSON.stringify(state, null, 2) + '\n');
|
|
27
|
-
try {
|
|
28
|
-
fs.renameSync(temporary, stateFile);
|
|
29
|
-
} catch (error) {
|
|
30
|
-
// Some Windows filesystems do not replace an existing destination on rename.
|
|
31
|
-
// The completed temporary file is still safer than writing JSON in place.
|
|
32
|
-
if (!['EEXIST', 'EPERM'].includes(error.code)) throw error;
|
|
33
|
-
fs.copyFileSync(temporary, stateFile);
|
|
34
|
-
fs.unlinkSync(temporary);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function print(value) {
|
|
39
|
-
console.log(JSON.stringify(value, null, 2));
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function stage(state, name) {
|
|
43
|
-
const found = state.stages.find((item) => item.name === name);
|
|
44
|
-
if (!found) throw new Error(`unknown stage "${name}"; expected one of: ${state.stages.map((item) => item.name).join(', ')}`);
|
|
45
|
-
return found;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function previousStagesComplete(state, current) {
|
|
49
|
-
const index = state.stages.indexOf(current);
|
|
50
|
-
return state.stages.slice(0, index).every((item) => item.status === 'complete');
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function record(state, type, details = {}) {
|
|
54
|
-
state.history.push({ at: new Date().toISOString(), type, ...details });
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function update(commandName, callback) {
|
|
58
|
-
const state = read();
|
|
59
|
-
callback(state);
|
|
60
|
-
write(state);
|
|
61
|
-
print({ command: commandName, state: state.status, currentStage: state.currentStage, file: stateFile });
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
try {
|
|
65
|
-
if (command === 'init') {
|
|
66
|
-
const [usecase, slug, ...stageNames] = args;
|
|
67
|
-
if (!usecase || !slug || !stageNames.length) throw new Error('usage: init <workdir> <usecase> <slug> <stage>...');
|
|
68
|
-
if (new Set(stageNames).size !== stageNames.length) throw new Error('stage names must be unique');
|
|
69
|
-
if (fs.existsSync(stateFile)) throw new Error(`run state already exists at ${stateFile}; use status or resume instead`);
|
|
70
|
-
const now = new Date().toISOString();
|
|
71
|
-
const state = {
|
|
72
|
-
version: 1,
|
|
73
|
-
runtime: 'codex',
|
|
74
|
-
usecase,
|
|
75
|
-
slug,
|
|
76
|
-
status: 'running',
|
|
77
|
-
currentStage: stageNames[0],
|
|
78
|
-
createdAt: now,
|
|
79
|
-
updatedAt: now,
|
|
80
|
-
stages: stageNames.map((name) => ({ name, status: 'pending', attempts: 0, artifacts: [] })),
|
|
81
|
-
history: [{ at: now, type: 'initialized' }],
|
|
82
|
-
};
|
|
83
|
-
write(state);
|
|
84
|
-
print({ command: 'init', state: state.status, currentStage: state.currentStage, file: stateFile });
|
|
85
|
-
} else if (command === 'status') {
|
|
86
|
-
const state = read();
|
|
87
|
-
print({ state: state.status, currentStage: state.currentStage, stages: state.stages, history: state.history, file: stateFile });
|
|
88
|
-
} else if (command === 'begin') {
|
|
89
|
-
const [name] = args;
|
|
90
|
-
update(command, (state) => {
|
|
91
|
-
if (state.status !== 'running') throw new Error(`cannot begin while run is ${state.status}; use resume first`);
|
|
92
|
-
const current = stage(state, name);
|
|
93
|
-
if (state.currentStage !== name) throw new Error(`cannot begin ${name}; current stage is ${state.currentStage}`);
|
|
94
|
-
if (!previousStagesComplete(state, current)) throw new Error(`cannot begin ${name}; an earlier stage is incomplete`);
|
|
95
|
-
if (current.status === 'complete') throw new Error(`${name} is already complete`);
|
|
96
|
-
current.status = 'active';
|
|
97
|
-
current.attempts += 1;
|
|
98
|
-
record(state, 'began', { stage: name, attempt: current.attempts });
|
|
99
|
-
});
|
|
100
|
-
} else if (command === 'complete') {
|
|
101
|
-
const [name, ...artifacts] = args;
|
|
102
|
-
update(command, (state) => {
|
|
103
|
-
if (state.status !== 'running') throw new Error(`cannot complete while run is ${state.status}`);
|
|
104
|
-
const current = stage(state, name);
|
|
105
|
-
if (state.currentStage !== name) throw new Error(`cannot complete ${name}; current stage is ${state.currentStage}`);
|
|
106
|
-
if (!['active', 'pending'].includes(current.status)) throw new Error(`${name} is ${current.status}, not active`);
|
|
107
|
-
const missing = artifacts.filter((artifact) => !fs.existsSync(artifact));
|
|
108
|
-
if (missing.length) throw new Error(`cannot complete ${name}; missing artifact(s): ${missing.join(', ')}`);
|
|
109
|
-
current.status = 'complete';
|
|
110
|
-
current.completedAt = new Date().toISOString();
|
|
111
|
-
current.artifacts = [...new Set([...current.artifacts, ...artifacts])];
|
|
112
|
-
const next = state.stages[state.stages.indexOf(current) + 1];
|
|
113
|
-
state.currentStage = next ? next.name : null;
|
|
114
|
-
state.status = next ? 'running' : 'done';
|
|
115
|
-
record(state, 'completed', { stage: name, artifacts });
|
|
116
|
-
});
|
|
117
|
-
} else if (command === 'finish') {
|
|
118
|
-
const [name, ...artifacts] = args;
|
|
119
|
-
update(command, (state) => {
|
|
120
|
-
const current = stage(state, name);
|
|
121
|
-
if (state.currentStage !== name) throw new Error(`cannot finish at ${name}; current stage is ${state.currentStage}`);
|
|
122
|
-
const missing = artifacts.filter((artifact) => !fs.existsSync(artifact));
|
|
123
|
-
if (missing.length) throw new Error(`cannot finish at ${name}; missing artifact(s): ${missing.join(', ')}`);
|
|
124
|
-
current.status = 'complete';
|
|
125
|
-
current.completedAt = new Date().toISOString();
|
|
126
|
-
current.artifacts = [...new Set([...current.artifacts, ...artifacts])];
|
|
127
|
-
for (const later of state.stages.slice(state.stages.indexOf(current) + 1)) later.status = 'skipped';
|
|
128
|
-
state.currentStage = null;
|
|
129
|
-
state.status = 'done';
|
|
130
|
-
record(state, 'finished', { stage: name, artifacts });
|
|
131
|
-
});
|
|
132
|
-
} else if (command === 'wait' || command === 'block') {
|
|
133
|
-
const [name, ...message] = args;
|
|
134
|
-
update(command, (state) => {
|
|
135
|
-
const current = stage(state, name);
|
|
136
|
-
if (state.currentStage !== name) throw new Error(`cannot mark ${name}; current stage is ${state.currentStage}`);
|
|
137
|
-
current.status = command === 'wait' ? 'waiting_user' : 'blocked';
|
|
138
|
-
current.message = message.join(' ').trim();
|
|
139
|
-
state.status = current.status;
|
|
140
|
-
record(state, command, { stage: name, message: current.message });
|
|
141
|
-
});
|
|
142
|
-
} else if (command === 'resume') {
|
|
143
|
-
update(command, (state) => {
|
|
144
|
-
if (!['waiting_user', 'blocked'].includes(state.status)) throw new Error(`cannot resume while run is ${state.status}`);
|
|
145
|
-
const current = stage(state, state.currentStage);
|
|
146
|
-
current.status = 'active';
|
|
147
|
-
delete current.message;
|
|
148
|
-
state.status = 'running';
|
|
149
|
-
record(state, 'resumed', { stage: current.name });
|
|
150
|
-
});
|
|
151
|
-
} else {
|
|
152
|
-
die('usage: codex-run-state.mjs <init|status|begin|complete|finish|wait|block|resume> <workdir> ...');
|
|
153
|
-
}
|
|
154
|
-
} catch (error) {
|
|
155
|
-
die(error.message);
|
|
156
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
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,5 +0,0 @@
|
|
|
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.
|
|
@@ -1,57 +0,0 @@
|
|
|
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.
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
# Codex runner
|
|
2
|
-
|
|
3
|
-
Run from the project root and persist the workflow after intake derives the slug:
|
|
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> design <slug> context references draw decide check finalize
|
|
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
|
-
Read `status` first after an interruption. Begin the active stage, complete it only after the listed output is present, and use `wait`, `block`, and `resume` for user decisions and external prerequisites. Do not redo a completed stage or rewrite a user upload.
|
|
19
|
-
|
|
20
|
-
- `context`: select the target design folder and optional read-only spec.
|
|
21
|
-
- `references`: make only the permitted reference descriptions and video frames. If ffmpeg is missing, mark this stage `block` with the request for screenshots or ffmpeg; do not guess the video.
|
|
22
|
-
- `draw`: dispatch `levi-designer` with exact input/output paths. Complete only when the output folder contains its SVG files.
|
|
23
|
-
- `decide`: run the initial checker/render needed to make an informed decision, then preserve the designer's material questions with `wait`. After an answer, `resume` and make the permitted final design change; otherwise complete with the recorded assumptions. Do not mark final verification complete here.
|
|
24
|
-
- `check`: run the final SVG checker and, when available, render the final files. If a repair is needed, keep this stage active while the designer gets the exact findings once, then check again. Record the render/check artifacts.
|
|
25
|
-
- `finalize`: report verified SVG files, then remove frames, reference descriptions, renders and `run.json`. Never delete uploads or the read-only spec.
|
|
26
|
-
|
|
27
|
-
Only `levi-designer` writes SVG files. The coordinator runs checks and advances state.
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
# Codex runner
|
|
2
|
-
|
|
3
|
-
Use this durable runner on Codex instead of the Claude-only `workflow.js`. Run every command below from the project root. After clarification is complete, first inspect `docs/levi/<slug>/run.json`. If absent, initialize it:
|
|
4
|
-
|
|
5
|
-
```bash
|
|
6
|
-
node <this skill folder>/scripts/codex-run-state.mjs init docs/levi/<slug> fix-bug <slug> baseline tests merge-check lock build
|
|
7
|
-
```
|
|
8
|
-
|
|
9
|
-
For each current stage, call `begin` before dispatching the named Levi agent and `complete` only after its artifacts exist. `status` is the source of truth after an interruption; completed stages are never repeated. Use `wait` for questions that need the user, `block` for an external dependency, and `resume` after it is resolved. Do not use the Claude-only `resumeFromRunId`.
|
|
10
|
-
|
|
11
|
-
```bash
|
|
12
|
-
node <this skill folder>/scripts/codex-run-state.mjs begin docs/levi/<slug> <stage>
|
|
13
|
-
node <this skill folder>/scripts/codex-run-state.mjs complete docs/levi/<slug> <stage> <artifact>...
|
|
14
|
-
node <this skill folder>/scripts/codex-run-state.mjs wait docs/levi/<slug> <stage> "<questions>"
|
|
15
|
-
node <this skill folder>/scripts/codex-run-state.mjs block docs/levi/<slug> <stage> "<blocker>"
|
|
16
|
-
node <this skill folder>/scripts/codex-run-state.mjs resume docs/levi/<slug>
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
For a valid terminal result that does not build a fix, use `finish` before cleanup:
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
node <this skill folder>/scripts/codex-run-state.mjs finish docs/levi/<slug> tests
|
|
23
|
-
node <this skill folder>/scripts/codex-run-state.mjs finish docs/levi/<slug> merge-check
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
- `baseline`: record the baseline commit and dirty paths for the later review.
|
|
27
|
-
- `tests`: QA writes and PM-approved scenarios while the developer investigates and produces a failing test. Both tracks are separate; complete only with `investigation.md`, `test-cases.json`, and the rendered scenario files. When the code already does what is expected, use `finish` at this stage and report `not_a_bug`; do not build a change.
|
|
28
|
-
- `merge-check`: run the existing blame/ancestor check when the initial check did not prove all code merged. For unmerged root-cause code, use `finish` at this stage, report `unmerged`, and do not fix it.
|
|
29
|
-
- `lock`: lock the developer tests and QA cases with the existing lock script. Require both lock manifests.
|
|
30
|
-
- `build`: run the existing code → test gate → teamlead review → QA E2E loop (a review of more than 100 reviewable files follows `levi-code-review/references/large-changes.md`: split, parallel slice reviews, one merge). Keep the stage active across all rounds. Complete only after approved review and all cases PASS.
|
|
31
|
-
|
|
32
|
-
Use installed named roles for every subagent call. The coordinator owns the checkpoint and stages; subagents only read/write their assigned artifacts. Keep dependent work sequential and use parallel calls only for the independent QA and investigation tracks.
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
# Codex runner
|
|
2
|
-
|
|
3
|
-
Run from the project root with one durable state per invocation:
|
|
4
|
-
|
|
5
|
-
```bash
|
|
6
|
-
node <this skill folder>/scripts/codex-run-state.mjs status docs/levi/test-cases
|
|
7
|
-
node <this skill folder>/scripts/codex-run-state.mjs init docs/levi/test-cases generate-test-scenarios test-cases select analyze report generate verify
|
|
8
|
-
```
|
|
9
|
-
|
|
10
|
-
```bash
|
|
11
|
-
node <this skill folder>/scripts/codex-run-state.mjs begin docs/levi/test-cases <stage>
|
|
12
|
-
node <this skill folder>/scripts/codex-run-state.mjs complete docs/levi/test-cases <stage> <artifact>...
|
|
13
|
-
node <this skill folder>/scripts/codex-run-state.mjs wait docs/levi/test-cases <stage> "<questions>"
|
|
14
|
-
node <this skill folder>/scripts/codex-run-state.mjs block docs/levi/test-cases <stage> "<blocker>"
|
|
15
|
-
node <this skill folder>/scripts/codex-run-state.mjs resume docs/levi/test-cases
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
When a valid branch ends before the last stage, use `finish` rather than pretending later stages completed:
|
|
19
|
-
|
|
20
|
-
```bash
|
|
21
|
-
node <this skill folder>/scripts/codex-run-state.mjs finish docs/levi/test-cases report
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
Use `status` before continuing a stopped run. Begin the current stage, complete it only after its outputs exist, and use `wait`, `block`, and `resume` for user choices and dependencies. Record the selected feature list and output bases in `docs/levi/test-cases/selection.md`, then pass that file to `complete` for `select`. Do not regenerate a feature whose verify stage completed.
|
|
25
|
-
|
|
26
|
-
- `select`: find requested specs, report missing ones, and preserve required choices (all features, ambiguous codes, overwrite/versioned output) with `wait`. Complete when exact features and output bases are fixed in `selection.md`.
|
|
27
|
-
- `analyze`: dispatch one `levi-qa` agent per selected feature only. They may run in parallel because each owns `docs/levi/test-cases/<FeatureID>-analysis.md`. Complete only when every selected analysis exists.
|
|
28
|
-
- `report`: report `Generate: no` and ambiguities before any writing. If every selected feature is skipped, use `finish docs/levi/test-cases report` and clean up; otherwise continue.
|
|
29
|
-
- `generate`: dispatch QA only for features marked `Generate: yes`. Complete only when each `json` case source and both requested output files exist.
|
|
30
|
-
- `verify`: run `render-test-cases.mjs check` for every generated feature. QA may repair each failing feature once; a remaining failure marks this stage `block` with its errors. Complete only after all selected outputs validate, then cleanup removes the scratch state.
|
|
31
|
-
|
|
32
|
-
Only `levi-qa` writes analysis, case sources and deliverables. The coordinator does not edit those files.
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# Codex runner
|
|
2
|
-
|
|
3
|
-
Run this workflow from the project root with a durable checkpoint. Initialize it immediately after intake:
|
|
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> spec-writing <slug> discover decide write 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
|
-
On a resumed run, `status` is authoritative. Begin the current stage, complete it only after the stated artifact exists, and never repeat a completed stage. Use `wait` to preserve unanswered user questions, `block` for an external dependency, and `resume` after it is resolved.
|
|
19
|
-
|
|
20
|
-
- `discover`: select update/new mode and dispatch `levi-pm` to write `ledger.md`. Complete with that ledger.
|
|
21
|
-
- `decide`: run the up-to-three user-answer rounds. Before each question round use `wait`; after the answer use `resume` and have the PM update `ledger.md`. Complete when it is ready to write, when the user explicitly asks to write with remaining questions, or mark `block` when the goal/users/core scope cannot be confirmed.
|
|
22
|
-
- `write`: dispatch `levi-pm` once with the ledger and selected spec path. Complete only when `docs/specs/<slug>.md` exists.
|
|
23
|
-
- `verify`: confirm the PM-owned spec is the requested new/update output and report its status. Cleanup can remove the state and ledger only after this stage completes.
|
|
24
|
-
|
|
25
|
-
The coordinator never edits the ledger or spec. Only `levi-pm` writes them.
|