your-cto-jev 0.10.1 → 0.12.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 +35 -21
- package/dist/agents.js +3 -1
- package/dist/brain.js +7 -0
- package/dist/brief.js +1 -2
- package/dist/check.js +2 -1
- package/dist/flow.js +25 -7
- package/dist/hooks.js +166 -33
- package/dist/i18n.js +18 -6
- package/dist/local.js +9 -5
- package/dist/setup.js +5 -3
- package/dist/signoff.js +20 -22
- package/dist/skill.js +60 -43
- package/dist/turn.js +83 -14
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -37,11 +37,12 @@ Jev judges meaning and answers with probabilities, not prose. It costs about $0.
|
|
|
37
37
|
| `done_unverified` | an agent ending a turn that edited code or checked off plan items | **Sends it back to work** until the change is verified or the gap is disclosed |
|
|
38
38
|
| `architecture_violation` | `git commit`, once you set a sprint goal, or when the [development flow](#the-development-flow-optional) maps the commit to a feature's SPEC | Warns only |
|
|
39
39
|
| `architecture_undocumented` | `git commit` under the development flow, when code changes and no decision record is added | Warns only |
|
|
40
|
+
| `manual_measurable` | `git commit` under the development flow, when it adds a task accepted `manual` that a script could check instead | Warns only |
|
|
40
41
|
| `code_complexity` | every `git commit` | Warns only |
|
|
41
42
|
|
|
42
43
|
`test_tampering` catches the classic agent shortcut: making a red test green by skipping it, deleting its assertions, loosening the expectation, or lowering the coverage bar, instead of fixing the code. It lets through real fixes, new or tighter tests, refactors, and tests removed together with their feature.
|
|
43
44
|
|
|
44
|
-
`done_unverified` catches the other classic shortcut: "Done, all tests pass!" when nothing ran after the last edit, the last run failed, or the claim is not backed by anything the agent actually did. It lets through turns that ran a passing check after the last edit, turns that changed only docs or CI config, and turns where the agent honestly says what it could not verify. Checked-off items count even when the agent committed them in the same turn. For a task with an acceptance line (`accept:` or `驗收:`), cto itself works out whether that exact command ran and passed after the last edit and tells Jev, and a `
|
|
45
|
+
`done_unverified` catches the other classic shortcut: "Done, all tests pass!" when nothing ran after the last edit, the last run failed, or the claim is not backed by anything the agent actually did. It lets through turns that ran a passing check after the last edit, turns that changed only docs or CI config, and turns where the agent honestly says what it could not verify. Checked-off items count even when the agent committed them in the same turn. For a task with an acceptance line (`accept:` or `驗收:`), cto itself works out whether that exact command ran and passed after the last edit and tells Jev, and a `(dropped: ...)` task the final message does not report as dropped is sent back without asking Jev at all. A ticked `manual` task never blocks: cto shows you what to look at. A task whose acceptance was a command and is switched to `manual` in the turn it is ticked is judged against that old command (when cto recorded where the turn started; otherwise against the last commit). It blocks at most once per stop, so it cannot loop.
|
|
45
46
|
|
|
46
47
|
Checking off a plan item is the same claim. Whatever planning tool you use (spec-kit, GSD, Kiro, specOS, a hand-written `TODO.md`), plans end up as markdown checklists, so `cto` reads the uncommitted `- [ ]` to `- [x]` changes in tracked `.md` files and asks whether the turn backs them up. A phase or parent item counts as backed when everything nested under it is checked, or when the turn ran a passing check that covers it. Each tick is judged once. A turn that only ticks boxes, without doing the work, is checked too.
|
|
47
48
|
|
|
@@ -55,13 +56,15 @@ Some checks need no model at all. They run first, before anything is sent anywhe
|
|
|
55
56
|
| A `.env` file with values (not `.env.example`) | `git commit` | **Blocks** |
|
|
56
57
|
| A file over 5 MB | `git commit` | Warns |
|
|
57
58
|
| `package.json` dependencies changed, lock file not | `git commit` | Warns |
|
|
58
|
-
| Development flow: a feature with tasks whose CONCEPT
|
|
59
|
+
| Development flow: a feature with tasks whose CONCEPT is not `Status: approved` | `git commit` touching that feature | **Blocks** |
|
|
59
60
|
| Development flow: INDEX.md older than its inputs, an `(after:)` id nobody defines, a SPEC `## Interface` changed | `git commit` | Warns |
|
|
60
61
|
|
|
61
62
|
`protected_branches` is empty by default; set it in `.cto.json` (`["main"]`) and the whole team's agents stop committing to main by accident. A commit a local check blocks never reaches Jev.
|
|
62
63
|
|
|
63
64
|
Architecture and complexity only warn on purpose. They are subjective, and a gate that blocks too often teaches people to use `git commit --no-verify`, which switches off the secret check too.
|
|
64
65
|
|
|
66
|
+
A turn that runs long gets one reminder, never a block. When a turn passes 20 minutes, 150 tool calls or 4 sub-agents since your last message, the agent's next shell command carries `[cto] This turn has run 21 min, 160 tool calls, 2 sub-agents. Stop and tell the user where you are, what is stuck, and what you plan next, before going on.`, and you see `[cto] This turn has run 21 min, 160 tool calls, 2 sub-agents; the agent has been asked to stop and report.` A background agent finishing does not start a new turn. Set the limits in `turn_limits` in `.cto.json`.
|
|
67
|
+
|
|
65
68
|
When nothing crosses a threshold, `cto` prints nothing at all.
|
|
66
69
|
|
|
67
70
|
## How it works
|
|
@@ -168,6 +171,7 @@ The rules also tell the agent to run `cto check` before committing, and never to
|
|
|
168
171
|
test_tampering 0.03 blocks above 0.8 ok
|
|
169
172
|
architecture_violation not checked: no sprint_goal in .cto.json and no feature Constraints for these files
|
|
170
173
|
architecture_undocumented not checked: no docs/cto_jev/ flow, or this commit adds a decision record
|
|
174
|
+
manual_measurable not checked: this commit adds no task accepted manually
|
|
171
175
|
code_complexity 2.02 warns above 2 would warn
|
|
172
176
|
[cto] Good to commit.
|
|
173
177
|
```
|
|
@@ -217,7 +221,7 @@ docs/cto_jev/
|
|
|
217
221
|
decisions/NNNN-<slug>.md decision records, append-only
|
|
218
222
|
features/<slug>/
|
|
219
223
|
CONCEPT.md why: purpose, business rules, non-goals
|
|
220
|
-
SPEC.md how: ## Interface (what other features may use), ## Constraints, ## Internals
|
|
224
|
+
SPEC.md how: ## Interface (what other features may use), ## Constraints, ## Acceptance, ## Internals
|
|
221
225
|
TASKS.md the only state: a checklist with ids, dependencies and an acceptance command
|
|
222
226
|
REVIEW.md what a zero-context reviewer found, and which tasks it became
|
|
223
227
|
```
|
|
@@ -228,22 +232,28 @@ A task is one checklist line, and everything else is computed from it:
|
|
|
228
232
|
- [ ] CUST-1 Customer list
|
|
229
233
|
- [x] CUST-1.1 List API, filtered by role (after: PERM-2) (files: src/customers/api/)
|
|
230
234
|
accept: npm test -- customers/api
|
|
231
|
-
- [ ] CUST-1.2 List UI (after: CUST-1.1) (files: src/customers/ui/)
|
|
232
|
-
accept:
|
|
235
|
+
- [ ] CUST-1.2 List UI (after: CUST-1.1) (files: src/customers/ui/, e2e/customers.spec.ts)
|
|
236
|
+
accept: npx playwright test e2e/customers.spec.ts
|
|
237
|
+
- [ ] CUST-1.3 List matches the brand (look) (after: CUST-1.2) (files: src/customers/ui/)
|
|
238
|
+
accept: manual: list page against the brand sheet, at 375px and 1280px @ http://localhost:3000/customers
|
|
233
239
|
```
|
|
234
240
|
|
|
241
|
+
You sign one document per feature, the CONCEPT: what it is for, the business rules, what the user sees when it works, what is out of scope. Until you sign it the agent talks with you (the CONCEPT questions); after that it waits for you in one place only: before the merge in `cto-jev release`. The SPEC is the agent's technical document, derived from the CONCEPT; nobody signs it and the agent may change it. Its `## Acceptance` lists each scenario as steps and a result a script can compare ("at 375px wide: no horizontal scroll"), each from a rule in the CONCEPT. A task you would see is accepted by the end-to-end test written from those lines before the code; if the agent thinks an expectation is wrong, the CONCEPT decides, and the Acceptance line changes before the test does. What the CONCEPT leaves open the agent decides and writes down as `Assumed:`; you read those in the release report. `manual` is left for taste (does it look right, does it match the brand) and blocks nothing: its line says what to look at and where (`manual: list page against the brand sheet @ http://localhost:3000/customers`), cto shows you that text when the turn ends, and the release report lists them all. A task that will not be done is closed with `(dropped: <reason>)` on its line, and the agent must say "<id> dropped" in its final message.
|
|
242
|
+
|
|
243
|
+
The trade: fewer stops, later discovery. A SPEC that drifted from what you meant shows up in the release review, not at a mid-way approval, and the agent writes both the code and its tests. The zero-context review before every commit is what stands in for you there: it checks the diff against the CONCEPT and asks of each acceptance test whether it would fail if its scenario broke.
|
|
244
|
+
|
|
235
245
|
`(after:)` says what must be ticked first, across features too; `(files:)` says what the task changes. Two optional tags: `(P1)`/`(P2)`/`(P3)` for priority (P1 first and nothing releases while one is open; no tag means P2; P3 last) and `(seq)` for a task that must run alone (migrations, shared types). From that, `cto brief` lists what is ready in priority order, what can run at the same time (no overlapping files, not `(seq)`), what is blocked and on whom:
|
|
236
246
|
|
|
237
247
|
```text
|
|
238
|
-
Features · 2 · 1 active · 1 planned · sign-off pending: billing (
|
|
248
|
+
Features · 2 · 1 active · 1 planned · sign-off pending: billing (concept draft)
|
|
239
249
|
|
|
240
250
|
Ready · 3 (run together: CUST-1.2, PERM-3)
|
|
241
|
-
CUST-1.2 P1 List UI files src/customers/ui/ accept:
|
|
251
|
+
CUST-1.2 P1 List UI files src/customers/ui/, e2e/customers.spec.ts accept: npx playwright test e2e/customers.spec.ts
|
|
242
252
|
PERM-3 Role cache files src/auth/cache/ accept: npm test -- auth
|
|
243
|
-
CUST-2 Export files src/customers/ accept:
|
|
253
|
+
CUST-2 Export files src/customers/ accept: npm test -- export (overlaps CUST-1.2: run after)
|
|
244
254
|
|
|
245
255
|
Blocked · 1
|
|
246
|
-
CUST-1.
|
|
256
|
+
CUST-1.4 Shared types waiting on PERM-9 (missing), CUST-1.2
|
|
247
257
|
```
|
|
248
258
|
|
|
249
259
|
The skill gives the agent seven named jobs, so they cannot be confused with another skill's steps. In Claude Code type `/cto-jev <job>` (for example `/cto-jev init`); bare `/cto-jev` runs `cto brief` and names the job to run next. In other agents say the name, for example "cto-jev init" (Codex also takes `$cto-jev`):
|
|
@@ -251,10 +261,10 @@ The skill gives the agent seven named jobs, so they cannot be confused with anot
|
|
|
251
261
|
| Say | The agent |
|
|
252
262
|
|---|---|
|
|
253
263
|
| `cto-jev init` | scans the repo, fills PRODUCT.md and ARCHITECTURE.md, asks you the rest a few questions at a time, walks you through the result until you say it is complete |
|
|
254
|
-
| `cto-jev feature` | talks the
|
|
255
|
-
| `cto-jev tasks` | breaks
|
|
256
|
-
| `cto-jev work` | dispatches Ready tasks to sub-agents with the narrowest brief, runs each acceptance command itself before ticking, has a zero-context reviewer read the diff **before every commit**: P1 findings are fixed first (and only the fixes reviewed again, at most three rounds in all; P1s left after that go to you), P2 findings become tasks, a finding is contested only with evidence the reviewer could read, then it commits
|
|
257
|
-
| `cto-jev work all` | for a new project or a big batch:
|
|
264
|
+
| `cto-jev feature` | talks the CONCEPT through first (who it is for, business rules, what the user sees when it works, what is out of scope, the simpler option it rejected), writes CONCEPT, then writes the SPEC itself (data migration and rollback, what other features may call, how a production failure gets noticed, the acceptance scenarios), has a zero-context reviewer check that a newcomer could build from them without making design decisions, that nothing unneeded or already in the code gets built and that every acceptance scenario has a result a script can check and a CONCEPT rule behind it, walks you through the CONCEPT, hands it over with a [Review handoff](#sign-off) and stops for your sign-off |
|
|
265
|
+
| `cto-jev tasks` | breaks a feature with a signed-off CONCEPT into parent/child tasks with files, dependencies and an acceptance command each |
|
|
266
|
+
| `cto-jev work` | dispatches Ready tasks to sub-agents with the narrowest brief, runs each acceptance command itself before ticking, has a zero-context reviewer read the diff **before every commit**: P1 findings are fixed first (and only the fixes reviewed again, at most three rounds in all; P1s left after that go to you), P2 findings become tasks, a finding is contested only with evidence the reviewer could read, then it commits the wave to the review branch and starts the next one, without asking, until nothing is Ready; tasks that need you (credentials, money, anything irreversible, a drop) are parked, not waited on; ends with one report of what is done and everything for you to look at. Never releases |
|
|
267
|
+
| `cto-jev work all` | for a new project or a big batch: the same run on a `work-all` branch with one zero-context review of everything at the end instead of one per wave. Never releases |
|
|
258
268
|
| `cto-jev release` | reviews the whole unreleased diff against the SPECs (looking hardest at waves marked `self-review`), files P1/P2/P3 tasks under the same findings rules, requires every P1 ticked and `cto check --base <release branch>` green, then prepares the merge, PR or tag for you to perform |
|
|
259
269
|
| `cto-jev docs` | runs `cto docs` and brings you the list; acts only on what you decide |
|
|
260
270
|
| `cto-jev decision` | writes an append-only decision record under `decisions/` |
|
|
@@ -265,9 +275,11 @@ What `cto` adds on top, all without a model call unless noted:
|
|
|
265
275
|
|
|
266
276
|
| Check | Where | What happens |
|
|
267
277
|
|---|---|---|
|
|
268
|
-
| A feature has tasks but its CONCEPT
|
|
278
|
+
| A feature has tasks but its CONCEPT is not approved | `git commit` touching that feature | **Blocks** |
|
|
269
279
|
| The agent sets `Status: approved` itself, or changes signed-off content without going back to draft | Claude Code edit tools and PowerShell | **Blocks** ([sign-off](#sign-off)) |
|
|
270
|
-
| A shell command writes CONCEPT,
|
|
280
|
+
| A shell command writes CONCEPT, PRODUCT or ARCHITECTURE under `docs/cto_jev/` | every agent's shell command | **Blocks** |
|
|
281
|
+
| A `manual` task is ticked | every agent, when the turn ends (Cursor may not display it) | **Tells you** what to look at and where, from the task's acceptance line; never blocks |
|
|
282
|
+
| An open task's acceptance line says only `manual` | `git commit` touching that TASKS.md | Warns: say what to look at |
|
|
271
283
|
| A sign-off doc became `approved` during the turn without your reply (however it was written) | Claude Code, when the turn ends | **Reverts** it to `draft` and tells the agent |
|
|
272
284
|
| `architecture_violation` judged against the feature's `## Constraints` and PRODUCT's non-goals instead of a one-line goal | `git commit` (Jev) | Warns |
|
|
273
285
|
| An architecture change with no new decision record | `git commit` (Jev) | Warns |
|
|
@@ -276,10 +288,10 @@ What `cto` adds on top, all without a model call unless noted:
|
|
|
276
288
|
|
|
277
289
|
### Sign-off
|
|
278
290
|
|
|
279
|
-
CONCEPT,
|
|
291
|
+
CONCEPT, PRODUCT and ARCHITECTURE are signed off when their `Status:` line says `approved`, and only you decide that. SPEC is not signed. Each time the agent wants you to read them it ends with a Review handoff:
|
|
280
292
|
|
|
281
293
|
```text
|
|
282
|
-
Review: docs/cto_jev/features/<slug>/CONCEPT.md
|
|
294
|
+
Review: docs/cto_jev/features/<slug>/CONCEPT.md
|
|
283
295
|
Key points: at most three lines
|
|
284
296
|
Might be missing: what the agent is unsure of, pointing to the `Assumed:` lines in the docs
|
|
285
297
|
Data: which tables or stores change, whether old data migrates; "none" if nothing
|
|
@@ -288,9 +300,9 @@ Data: which tables or stores change, whether old data migrates; "none" if nothin
|
|
|
288
300
|
- **Claude Code:** just agree in the chat. cto's `UserPromptSubmit` hook asks Jev whether your reply agrees to every listed file and, if so, sets the listed drafts to `Status: approved` and tells you which files it signed. "OK, but change X", a question or agreeing to only some files signs nothing. When Jev cannot sign, it signs nothing and says why: no API key yet (run `cto setup`), the service failed a moment ago and is paused (reply again later), or it is unreachable. In each case you can also edit the line yourself.
|
|
289
301
|
- **Codex, Cursor, Gemini CLI:** edit the `Status:` line yourself.
|
|
290
302
|
|
|
291
|
-
Agreeing covers what is written, `Assumed:` lines included. A signed-off CONCEPT, PRODUCT or ARCHITECTURE
|
|
303
|
+
Agreeing covers what is written, `Assumed:` lines included. A signed-off CONCEPT, PRODUCT or ARCHITECTURE can only change after going back to `Status: draft` and a new Review. In Claude Code cto blocks the agent from setting `approved` itself or skipping that step (Edit, Write, MultiEdit; PowerShell may not touch those files at all). For every agent, shell commands may not write them. As a backstop in Claude Code, when a turn ends cto puts any sign-off doc that became `approved` during the turn without your reply back to `draft` and tells the agent, however it was written (a glob, a variable, a script). Codex, Cursor and Gemini edit tools are not guarded yet; there only the skill's rules hold.
|
|
292
304
|
|
|
293
|
-
**Upgrading.** `cto update` refreshes the repo you run it from and adds the new Claude Code sign-off hooks; elsewhere run `cto setup --refresh` (`cto doctor` reports missing hooks).
|
|
305
|
+
**Upgrading.** `cto update` refreshes the repo you run it from and adds the new Claude Code sign-off hooks; elsewhere run `cto setup --refresh` (`cto doctor` reports missing hooks). From 0.12 only the CONCEPT is signed: a `Status:` line left in an old SPEC is ignored, the commit check reads CONCEPT alone, and INDEX.md's sign-off column holds one value (the first commit after upgrading asks for `cto index`). `manual` tasks no longer need "accepted manually" in the agent's message.
|
|
294
306
|
|
|
295
307
|
`cto docs` deals with the rest of the repo: it finds markdown outside `docs/cto_jev/` that looks like an old plan (tool output under `.planning/`, `specs/`, `.kiro/`, fully ticked `TODO.md`s, checklists untouched for a month), asks Jev about the ambiguous ones, and prints merge / archive / delete suggestions. It changes nothing; the agent acts only after you decide.
|
|
296
308
|
|
|
@@ -375,12 +387,13 @@ Nothing else is uploaded, and nothing is logged unless you set `CTO_DEBUG=1`. Th
|
|
|
375
387
|
}
|
|
376
388
|
```
|
|
377
389
|
|
|
378
|
-
Defaults: `credential_leak` 0.5, `destructive_command` 0.7, `infinite_loop` 0.6, `test_tampering` 0.8, `done_unverified` 0.6, `architecture_violation` 0.85, `architecture_undocumented` 0.85, `code_complexity` 2.
|
|
390
|
+
Defaults: `credential_leak` 0.5, `destructive_command` 0.7, `infinite_loop` 0.6, `test_tampering` 0.8, `done_unverified` 0.6, `architecture_violation` 0.85, `architecture_undocumented` 0.85, `manual_measurable` 0.85 (not calibrated yet), `code_complexity` 2.
|
|
379
391
|
|
|
380
392
|
- **`sprint_goal`**: fill it in to enable the architecture check, for example `"Ship Stripe billing, no new services"`. Under the development flow a commit that falls inside a feature's code scope is judged against that feature's SPEC instead; the goal is the fallback.
|
|
381
393
|
- **`flow`**: `true` turns on the [development flow](#the-development-flow-optional). `cto setup --flow` / `--no-flow` set it; `cto setup --refresh` follows the saved value. `--no-flow` removes the cto-jev skill, `/cto-jev` and its rule but keeps `docs/cto_jev/`; while `docs/cto_jev/features/` exists, the sign-off, index and drift checks keep running. Delete or archive that folder to stop them.
|
|
382
394
|
- **`test_command`**: what `cto brief` tells the agent to verify with, for example `"pnpm test"`. Detected from the project when empty.
|
|
383
395
|
- **`protected_branches`**: for example `["main", "release"]`. Commits on them and pushes that delete or rewrite them are blocked locally, no key needed. Empty by default.
|
|
396
|
+
- **`turn_limits`**: `{ "minutes": 20, "tool_calls": 150, "agents": 4 }` by default; a turn past any one of them gets one reminder to stop and report. `0` turns that limit off; a key you leave out keeps its default.
|
|
384
397
|
- **Thresholds**: Jev returns a probability from 0 to 1. `code_complexity` is the exception: it is a score from 0 (clean) to 4 (unmaintainable).
|
|
385
398
|
- **Calibration**: on 32 hand-written diffs, every one scoring above 0.8 for `test_tampering` really weakened the tests, and no legitimate change scored above 0.37. The 0.8 default caught 13 of 16 weakening diffs; the misses were subtle ones such as a meaningless float tolerance or a skip hidden behind an env var. Lower it to 0.5 to catch 15 of 16, at a higher risk of blocking honest commits.
|
|
386
399
|
- `done_unverified` (0.6) and `infinite_loop` (0.6) were calibrated the same way; the cases are in `calibration/`.
|
|
@@ -405,7 +418,8 @@ Defaults: `credential_leak` 0.5, `destructive_command` 0.7, `infinite_loop` 0.6,
|
|
|
405
418
|
- **A lesson's fix is the edit between a failure and the next pass of a command with the same first two words.** A fix that was verified by a different command (`npm test` fails, `npx vitest run` passes) is not recorded, and a turn that edits files for other reasons in between credits them to the fix as well.
|
|
406
419
|
- **Loop detection knows about edits, but only through the agent's edit tools.** A first re-run after a code edit is a new attempt, while the same error coming back across repeated fixes still counts as a loop; each loop is blocked once, so the agent can still verify its next fix. A file changed only through a shell command is not seen as an edit, and failures expire after 15 minutes.
|
|
407
420
|
- **The development flow reads exact headings and prefixes.** `## Interface`, `## Constraints`, `Status: approved` and the PRODUCT/ARCHITECTURE field headings must match the skeleton as written; a reworded heading is "missing" in `cto brief` and silently skipped by the checks. A commit maps to a feature by `(files:)` prefix, so a task written as `src/` claims everything and `./src/x/` claims nothing. The two Jev questions look at the first diff chunk only.
|
|
408
|
-
- **The sign-off guard has gaps.** Shell writes it cannot resolve (paths in variables, scripts such as `node -e`, `git checkout --`, `git apply`) are not blocked up front; in Claude Code a self-approval made that way is put back to `draft` when the turn ends,
|
|
421
|
+
- **The sign-off guard has gaps.** Shell writes it cannot resolve (paths in variables, scripts such as `node -e`, `git checkout --`, `git apply`) are not blocked up front; in Claude Code a self-approval made that way is put back to `draft` when the turn ends, and so is a signed doc whose content changed during the turn (set to draft, edited, approved again). All of this catches an agent that takes a shortcut or makes a mistake. It is not a security boundary against one set on cheating: anything the agent can run can also rewrite the record that check keeps in `.cto-brain.json`, and the commit check reads only the Status line. Codex, Cursor and Gemini edit tools are not guarded. If you flip a Status to `approved` by hand while the agent is mid-turn, that end-of-turn check reverts it too; flip it again afterwards. The hook signs only the reply right after a Review handoff, and keeps no record: a hook sign-off and a hand edit look the same in git.
|
|
422
|
+
- **The long-turn reminder is checked only when the agent runs a shell command.** A turn that only reads and edits files is not reminded until its next command. It works in Claude Code only: the other agents have no hook that marks where a turn starts.
|
|
409
423
|
- **Each agent shell command waits for one Jev request.** OpenRouter answered in about 0.3 s in our tests, Cloudflare in about 0.9 s with occasional spikes past 3 s. Agent checks wait up to 5 s before failing open.
|
|
410
424
|
|
|
411
425
|
## Development
|
package/dist/agents.js
CHANGED
|
@@ -7,7 +7,7 @@ const cmdOf = (i) => String(i?.tool_input?.command ?? i?.command ?? '');
|
|
|
7
7
|
// For their stop events exit 2 also means "keep working", with stderr as the reason fed back to the agent.
|
|
8
8
|
const exit2Block = (lines) => ({ code: 2, stderr: lines });
|
|
9
9
|
const systemMessage = (msgs) => ({ code: 0, stdout: JSON.stringify({ systemMessage: msgs.join('\n') }), stderr: [] });
|
|
10
|
-
const nestedPre = (i) => ({ command: str(i?.tool_input?.command), sessionId: str(i?.session_id), cwd: str(i?.cwd) });
|
|
10
|
+
const nestedPre = (i) => ({ command: str(i?.tool_input?.command), sessionId: str(i?.session_id), cwd: str(i?.cwd), transcriptPath: str(i?.transcript_path), subagent: !!str(i?.agent_id) });
|
|
11
11
|
const sessionId = (i) => str(i?.session_id);
|
|
12
12
|
/** UserPromptSubmit reply: context reaches Claude, user reaches the user; nothing at all when both are absent. */
|
|
13
13
|
export function promptOutput(context, user) {
|
|
@@ -59,6 +59,8 @@ export const agents = {
|
|
|
59
59
|
block: exit2Block,
|
|
60
60
|
stopBlock: exit2Block,
|
|
61
61
|
notice: systemMessage,
|
|
62
|
+
// additionalContext reaches Claude next to the tool result; systemMessage reaches the user only.
|
|
63
|
+
preContext: (forAgent, forUser) => ({ code: 0, stdout: JSON.stringify({ systemMessage: forUser.join('\n'), hookSpecificOutput: { hookEventName: 'PreToolUse', additionalContext: forAgent } }), stderr: [] }),
|
|
62
64
|
},
|
|
63
65
|
cursor: {
|
|
64
66
|
label: 'Cursor',
|
package/dist/brain.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, readFileSync, renameSync, unlinkSync, writeFileSync } from 'node:fs';
|
|
2
2
|
import { homedir } from 'node:os';
|
|
3
3
|
import { dirname, join } from 'node:path';
|
|
4
|
+
const turnLimits = (raw) => {
|
|
5
|
+
const n = (k) => (typeof raw?.[k] === 'number' && raw[k] >= 0 ? raw[k] : DEFAULT_CONFIG.turn_limits[k]);
|
|
6
|
+
return { minutes: n('minutes'), tool_calls: n('tool_calls'), agents: n('agents') };
|
|
7
|
+
};
|
|
4
8
|
export const DECISIONS_KEPT = 30;
|
|
5
9
|
export const DECISION_STATE_CHARS = 12_000;
|
|
6
10
|
/** Sign-off writes approved for the user, so an agent editing .cto.json may raise this bar but never lower it. */
|
|
@@ -17,11 +21,13 @@ export const DEFAULT_CONFIG = {
|
|
|
17
21
|
infinite_loop: 0.6,
|
|
18
22
|
architecture_violation: 0.85,
|
|
19
23
|
architecture_undocumented: 0.85,
|
|
24
|
+
manual_measurable: 0.85, // not calibrated yet; warns only
|
|
20
25
|
test_tampering: 0.8,
|
|
21
26
|
done_unverified: 0.6,
|
|
22
27
|
signoff_approved: SIGNOFF_FLOOR,
|
|
23
28
|
code_complexity: 2,
|
|
24
29
|
},
|
|
30
|
+
turn_limits: { minutes: 20, tool_calls: 150, agents: 4 },
|
|
25
31
|
};
|
|
26
32
|
const emptyBrain = () => ({
|
|
27
33
|
recent_errors: [],
|
|
@@ -61,6 +67,7 @@ export function loadConfig(root) {
|
|
|
61
67
|
protected_branches: Array.isArray(raw.protected_branches) ? raw.protected_branches.filter((b) => typeof b === 'string') : [],
|
|
62
68
|
flow: raw.flow === true,
|
|
63
69
|
thresholds,
|
|
70
|
+
turn_limits: turnLimits(raw.turn_limits),
|
|
64
71
|
};
|
|
65
72
|
}
|
|
66
73
|
/** Corrupt or missing state rebuilds as empty: the gate must never crash on its own bookkeeping. */
|
package/dist/brief.js
CHANGED
|
@@ -153,8 +153,7 @@ export function flowLines(root) {
|
|
|
153
153
|
// Nothing truncated: the text and the acceptance command are what the agent dispatches and runs.
|
|
154
154
|
const line = (t, rest) => ` ${t.id.padEnd(idW)} ${(t.priority ? `${t.priority} ` : '') + t.text} ${rest}`;
|
|
155
155
|
const counts = ['active', 'planned', 'done'].filter((s) => rows.some((r) => r.status === s)).map((s) => `${rows.filter((r) => r.status === s).length} ${s}`);
|
|
156
|
-
const pending = rows.filter((r) => r.signoff
|
|
157
|
-
.map((r) => `${r.slug} (${['concept', 'spec'].filter((k) => r.signoff[k] !== 'approved').map((k) => `${k} ${r.signoff[k]}`).join(', ')})`);
|
|
156
|
+
const pending = rows.filter((r) => r.signoff !== 'approved').map((r) => `${r.slug} (concept ${r.signoff})`);
|
|
158
157
|
const L = ['', ['Features', String(rows.length), ...counts, ...(pending.length ? [`sign-off pending: ${pending.join(', ')}`] : [])].join(' · ')];
|
|
159
158
|
L.push('', ready.length
|
|
160
159
|
? `Ready · ${ready.length}${together.length > 1 ? ` (run together: ${together.map((t) => t.id).join(', ')})` : ''}`
|
package/dist/check.js
CHANGED
|
@@ -52,7 +52,8 @@ export async function runCheck(root, lang, base) {
|
|
|
52
52
|
const v = review.scores[s];
|
|
53
53
|
const name = s.padEnd(width);
|
|
54
54
|
if (v === undefined) {
|
|
55
|
-
|
|
55
|
+
// Asked but unanswered means the request failed, not that the question did not apply.
|
|
56
|
+
const why = review.asked.has(s) ? 'check_why_failed' : s === 'test_tampering' ? 'check_why_tests' : s === 'architecture_violation' ? 'check_why_goal' : s === 'architecture_undocumented' ? 'check_why_adr' : s === 'manual_measurable' ? 'check_why_manual' : s === 'code_complexity' && base ? 'check_why_release' : 'check_why_failed';
|
|
56
57
|
lines.push(` ${name} ${t(lang, why)}`);
|
|
57
58
|
continue;
|
|
58
59
|
}
|
package/dist/flow.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { existsSync, readdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
|
-
import { ACCEPT, BOX } from './turn.js';
|
|
3
|
+
import { ACCEPT, acceptValue, BOX } from './turn.js';
|
|
4
4
|
// docs/cto_jev/features/<slug>/TASKS.md: the one place the development flow keeps state. Everything else (INDEX,
|
|
5
5
|
// ready list, feature dependencies, code ownership) is computed from it. Format: FLOW_SKILL_TEXT in skill.ts.
|
|
6
6
|
export const FLOW_DIR = 'docs/cto_jev';
|
|
@@ -15,9 +15,14 @@ export function parseTasks(text, feature, file) {
|
|
|
15
15
|
const tasks = [];
|
|
16
16
|
const stack = [];
|
|
17
17
|
let fenced = false;
|
|
18
|
+
// The task whose acceptance line may still follow; the same boundaries as the stop check (turn.ts acceptOf): only the
|
|
19
|
+
// first acceptance line indented under the item, before the next item or anything at its depth or lower.
|
|
20
|
+
let open;
|
|
18
21
|
const lines = text.split(/\r?\n/);
|
|
19
22
|
lines.forEach((raw, i) => {
|
|
20
23
|
if (/^\s*(```|~~~)/.test(raw)) {
|
|
24
|
+
if (open && raw.length - raw.trimStart().length <= open.indent)
|
|
25
|
+
open = undefined; // a fence at the item's depth ends it, as any line does
|
|
21
26
|
fenced = !fenced;
|
|
22
27
|
return;
|
|
23
28
|
}
|
|
@@ -25,12 +30,20 @@ export function parseTasks(text, feature, file) {
|
|
|
25
30
|
return;
|
|
26
31
|
const m = BOX.exec(raw);
|
|
27
32
|
if (!m) {
|
|
33
|
+
if (!open || !raw.trim())
|
|
34
|
+
return;
|
|
35
|
+
if (raw.length - raw.trimStart().length <= open.indent) {
|
|
36
|
+
open = undefined;
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
28
39
|
const a = ACCEPT.exec(raw);
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
40
|
+
if (a) {
|
|
41
|
+
open.task.accept = acceptValue(a[1]);
|
|
42
|
+
open = undefined;
|
|
43
|
+
}
|
|
32
44
|
return;
|
|
33
45
|
}
|
|
46
|
+
open = undefined;
|
|
34
47
|
const indent = m[1].length;
|
|
35
48
|
const idm = ID.exec(m[3]);
|
|
36
49
|
if (!idm)
|
|
@@ -51,6 +64,7 @@ export function parseTasks(text, feature, file) {
|
|
|
51
64
|
if (parent)
|
|
52
65
|
tasks.find((p) => p.id === parent)?.children.push(t.id);
|
|
53
66
|
tasks.push(t);
|
|
67
|
+
open = { task: t, indent };
|
|
54
68
|
stack.push({ indent, id: t.id });
|
|
55
69
|
});
|
|
56
70
|
return tasks;
|
|
@@ -126,7 +140,11 @@ catch {
|
|
|
126
140
|
return undefined;
|
|
127
141
|
} };
|
|
128
142
|
/** A sign-off doc's state: the first `Status: draft|approved` line (any case); no such line is 'missing'. */
|
|
129
|
-
|
|
143
|
+
// Blanks on a Status line: space, tab, or the no-break space some editors and IMEs type; never a line break.
|
|
144
|
+
const SP = '[ \\t\\u00a0]';
|
|
145
|
+
export const docStatus = (text) => new RegExp(`^Status:${SP}*(draft|approved)${SP}*\\r?$`, 'im').exec(text)?.[1]?.toLowerCase() ?? 'missing';
|
|
146
|
+
/** `text` with its first `Status: <from>` line set to `to`, keeping the blanks and line ending. */
|
|
147
|
+
export const setStatus = (text, from, to) => text.replace(new RegExp(`^(Status:${SP}*)${from}(?=${SP}*\\r?$)`, 'im'), `$1${to}`);
|
|
130
148
|
const signoff = (path) => docStatus(readOr(path) ?? '');
|
|
131
149
|
function purpose(concept) {
|
|
132
150
|
const lines = concept.split(/\r?\n/);
|
|
@@ -149,13 +167,13 @@ export function featureIndex(root) {
|
|
|
149
167
|
status: !mine.length ? 'planned' : leaves.every((t) => t.done) ? 'done' : 'active',
|
|
150
168
|
code: files.filter((f) => !files.some((o) => o !== f && f.startsWith(o))),
|
|
151
169
|
dependsOn: uniqSorted(mine.flatMap((t) => t.after).map((id) => featureOf.get(id)).filter((f) => !!f && f !== slug)),
|
|
152
|
-
signoff:
|
|
170
|
+
signoff: signoff(join(dir, 'CONCEPT.md')),
|
|
153
171
|
};
|
|
154
172
|
});
|
|
155
173
|
}
|
|
156
174
|
export function renderIndex(rows) {
|
|
157
175
|
const cell = (s) => s.replace(/\|/g, '\\|');
|
|
158
|
-
const line = (r) => `| ${r.slug} | ${r.status} | ${cell(r.purpose)} | ${r.code.join(', ')} | ${r.dependsOn.join(', ')} | ${r.signoff
|
|
176
|
+
const line = (r) => `| ${r.slug} | ${r.status} | ${cell(r.purpose)} | ${r.code.join(', ')} | ${r.dependsOn.join(', ')} | ${r.signoff} |`;
|
|
159
177
|
return [
|
|
160
178
|
'# INDEX',
|
|
161
179
|
'',
|