your-cto-jev 0.20.0 → 0.22.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 +8 -6
- package/dist/brief.js +4 -1
- package/dist/docs.js +86 -16
- package/dist/flow.js +14 -4
- package/dist/hooks.js +7 -2
- package/dist/i18n.js +24 -0
- package/dist/setup.js +3 -1
- package/dist/setupui.js +2 -3
- package/dist/skill.js +15 -11
- package/dist/tests.js +1 -1
- package/dist/turn.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -139,7 +139,7 @@ cto brief # what an agent should know before it s
|
|
|
139
139
|
cto check # preview the commit checks on your current changes
|
|
140
140
|
cto log # recent decisions with scores; cto report [n] flags a wrong one
|
|
141
141
|
cto index # regenerate docs/cto_jev/INDEX.md (brief does this too)
|
|
142
|
-
cto docs # suggest what to do with old planning markdown; changes nothing
|
|
142
|
+
cto docs # suggest what to do with old planning markdown, and check docs/cto_jev/ for alignment; changes nothing
|
|
143
143
|
cto tests # Jev screens test files against their SPEC and for repeats; changes nothing
|
|
144
144
|
```
|
|
145
145
|
|
|
@@ -268,7 +268,7 @@ The skill gives the agent seven named jobs, so they cannot be confused with anot
|
|
|
268
268
|
| `cto-jev work` | dispatches Ready tasks to sub-agents with the narrowest brief, runs each acceptance command itself before ticking (only the wave's own tasks and the `e2e/<slug>/` tests of the features it touches; the whole suites run once per feature cleanup and at release; until a repo's e2e tests are split into `e2e/<slug>/`, each wave runs the whole e2e suite; `cto brief` flags tests outside every feature folder (the `e2e/` root or a flat `e2e/tests/`) and the final report asks whether to split them, `"e2e_folders": false` in `.cto.json` keeps them flat), never opens a question menu mid-run, has a zero-context reviewer read the diff **before every commit**: P1 findings are fixed first, then the whole change reviewed again by `cto-reviewer` (at most three rounds in all; P1s left after that go to you), P2 findings become tasks that wait until the feature has nothing else Ready and then run as one cleanup wave with one review (what that review finds below P1 is written into REVIEW.md and listed for you, not filed as tasks, so findings never chain), a finding is contested only with evidence the reviewer could read; a review with no P1 left is committed with no code change in between, a fix made in conversation is reviewed and committed before new work, and no new wave starts while code waits for review; sub-agents and the reviewer never run a whole test suite; 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 |
|
|
269
269
|
| `cto-jev work all` | for a new project or a big batch: the same run on a `work-all` branch, every wave reviewed by a zero-context `cto-reviewer` before its commit, then hands over to `cto-jev release`, never merges. Never releases |
|
|
270
270
|
| `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, audits the tests (`cto tests` screens with Jev, an agent proposes keep, merge, delete or lighter for the flagged and slowest files, you decide), then prepares the merge, PR or tag for you to perform |
|
|
271
|
-
| `cto-jev docs` | runs `cto docs` and brings you the list; acts only on what you decide |
|
|
271
|
+
| `cto-jev docs` | runs `cto docs` and brings you the old-plan list; acts only on what you decide. It also runs the alignment checks on `docs/cto_jev/` (five rules), has a reviewer look for duplicated rules, contradictions, docs that disagree with the code and SPEC behavior with no test, and fixes the findings: P1 now, P2 and P3 as tasks |
|
|
272
272
|
|
|
273
273
|
"Release" adapts to the branches you have. A solo repo with only `main`: the wave review before each commit is the gate, and a release is a tag. `main` plus feature branches: the PR is the release. `main` plus `review`/`develop`/`staging`: merging the integration branch into `main`. `staging` and `live`: promoting one to the other. In every case the branch that reaches users takes nothing without a release review, and that is the branch to put in `protected_branches`. Changes inside an existing feature only add tasks; only a new module gets a new folder. The first time it runs it scans the repo, fills PRODUCT.md and ARCHITECTURE.md with what it can prove, asks you the rest a few questions at a time, and walks you through the result until you say it is complete. `unknown` is an allowed answer.
|
|
274
274
|
|
|
@@ -285,7 +285,7 @@ What `cto` adds on top, all without a model call unless noted:
|
|
|
285
285
|
| `architecture_violation` judged against the feature's `## Constraints` and PRODUCT's non-goals instead of a one-line goal | `git commit` (Jev) | Warns |
|
|
286
286
|
| An architecture change with no new decision record | `git commit` (Jev) | Warns |
|
|
287
287
|
| INDEX.md older than the TASKS it is built from; an `(after:)` id nobody defines; a SPEC's `## Interface` changed | `git commit` | Warns, naming dependants |
|
|
288
|
-
| Missing feature files,
|
|
288
|
+
| Missing feature files, `src/` directories owned by no feature, missing headings | `cto brief`, `cto doctor` | Listed |
|
|
289
289
|
|
|
290
290
|
### Sign-off
|
|
291
291
|
|
|
@@ -298,7 +298,7 @@ Might be missing: what the agent is unsure of, pointing to the `Assumed:` lines
|
|
|
298
298
|
Data: which tables or stores change, whether old data migrates; "none" if nothing
|
|
299
299
|
```
|
|
300
300
|
|
|
301
|
-
- **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
|
|
301
|
+
- **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 a free-text reply that agrees to only some files signs nothing; to sign some, name them (next line). A reply that opens with a yes to all and then turns to something unrelated ("ok all, also CI is red") still signs; when Jev turns down a reply that opens with a yes, cto says it signed nothing and how to sign. 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.
|
|
302
302
|
- **Claude Code, by name:** a reply that is only names from the `Review:` line plus a yes signs just those, without asking Jev: "imports ok", "imports、catalog 好". A feature is named by its slug, PRODUCT and ARCHITECTURE by their own names. "ok all" or "全部 ok" signs every listed draft; a bare "都可以" goes to Jev, since it may answer another question. The rest stay on the `Review:` line for later.
|
|
303
303
|
- **Claude Code, from a menu:** whenever the agent stops for you, the skill has it put everything waiting on you in one menu (`/cto-jev decide` lists it all at once): docs to sign, decisions, parked tasks, `manual` checks. Each item has a short summary and 2–3 options with pros and cons, the recommended one first, plus "之後再選" (later). A sign-off question covers one doc and its summary lists every `Assumed:` line and data change; picking `Approve` signs that doc at once (a `PostToolUse` hook on `AskUserQuestion`, no Jev call). Anything typed under "Other" is a follow-up question and signs nothing. cto blocks a sign-off menu the agent prefilled with answers, and ignores menus from sub-agents.
|
|
304
304
|
- **Codex, Cursor, Gemini CLI:** edit the `Status:` line yourself.
|
|
@@ -309,6 +309,8 @@ Agreeing covers what is written, `Assumed:` lines included. A signed-off CONCEPT
|
|
|
309
309
|
|
|
310
310
|
`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.
|
|
311
311
|
|
|
312
|
+
`cto docs` also checks `docs/cto_jev/` against itself: five rules that need no judgment (a task's `(files:)` path that never existed, a task checked by a command that cannot fail, a parent not ticked over ticked children, a parent that carries its own acceptance, SPEC sections out of order). Each finding shows file:line, the rule and the fix. The agent handles them without asking you: a finding is P2 unless the doc it sits in would make an agent do wrong work (P1, fixed now); a P2 or P3 becomes a task, and REVIEW.md lists them. A reviewer then looks for what needs reading (the same rule written twice, contradicting docs, docs that disagree with the code, SPEC behavior with no test).
|
|
313
|
+
|
|
312
314
|
If a docs site generator is configured (`mkdocs.yml`, `docusaurus.config.*`, `_config.yml`, ...), setup reminds you to keep `docs/cto_jev/` out of it: PRODUCT.md holds your pricing and business rules.
|
|
313
315
|
|
|
314
316
|
## Supported agents
|
|
@@ -390,14 +392,14 @@ Nothing else is uploaded, and nothing is logged unless you set `CTO_DEBUG=1`. Th
|
|
|
390
392
|
}
|
|
391
393
|
```
|
|
392
394
|
|
|
393
|
-
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.
|
|
395
|
+
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, `signoff_approved` 0.8 (a floor: `.cto.json` can only raise it), `review_unresolved` and `review_prompt` 0.7 (a ceiling: `.cto.json` can only lower them; not calibrated yet).
|
|
394
396
|
|
|
395
397
|
- **`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.
|
|
396
398
|
- **`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.
|
|
397
399
|
- **`test_command`**: what `cto brief` tells the agent to verify with, for example `"pnpm test"`. Detected from the project when empty.
|
|
398
400
|
- **`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.
|
|
399
401
|
- **`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.
|
|
400
|
-
- **`stage`**: `"prototype"` or `"build"`; a file without it is `build`, and `cto setup` writes `prototype` for a new project (the flow on and no test file tracked yet). In prototype, `cto brief` shows `Stage prototype` and the flow gets the main path running for you to try first: acceptance is the lightest command that shows a task works (a build, a smoke test) or a `manual` check, no end-to-end harness is built, test-setup trouble waits for build, and the reviewer does not ask for missing tests. When you can walk the main path, the run's report asks whether to switch to `build
|
|
402
|
+
- **`stage`**: `"prototype"` or `"build"`; a file without it is `build`, and `cto setup` writes `prototype` for a new project (the flow on and no test file tracked yet). In prototype, `cto brief` shows `Stage prototype` and the flow gets the main path running for you to try first: acceptance is the lightest command that shows a task works (a build, a smoke test) or a `manual` check, no end-to-end harness is built, test-setup trouble waits for build, and the reviewer does not ask for missing tests. Review findings below P1 (except in the review before you sign a CONCEPT) are noted in REVIEW.md under "Left for the user (prototype)" instead of becoming tasks, no cleanup waves run, and the whole test suites run only at release. When you can walk the main path, the run's report asks whether to switch to `build`; switching turns the noted findings that still hold into tasks.
|
|
401
403
|
- **`e2e_folders`**: `true` by default. `false` means you chose to keep e2e tests flat in `e2e/`: `cto brief` stops asking to split them into `e2e/<slug>/`, and every wave runs the whole e2e suite.
|
|
402
404
|
- **Thresholds**: Jev returns a probability from 0 to 1. `code_complexity` is the exception: it is a score from 0 (clean) to 4 (unmaintainable).
|
|
403
405
|
- **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.
|
package/dist/brief.js
CHANGED
|
@@ -5,6 +5,9 @@ import { freshErrors, loadBrain, loadConfig } from './brain.js';
|
|
|
5
5
|
import { FEATURE_FILES, FLOW_DIR, featureIndex, listFeatures, loadTasks, openTasks, parallelTasks, writeIndex } from './flow.js';
|
|
6
6
|
import { loadLessons, packageManager, rankLessons } from './lessons.js';
|
|
7
7
|
import { BOX, isManualAccept } from './turn.js';
|
|
8
|
+
/** Terminal columns: CJK and full-width characters take two. Lives here, not in setupui.ts, so the hook path never loads clack. */
|
|
9
|
+
const WIDE = /[\u1100-\u115f\u2e80-\ua4cf\uac00-\ud7a3\uf900-\ufaff\ufe30-\ufe4f\uff00-\uff60\uffe0-\uffe6]/;
|
|
10
|
+
export const displayWidth = (s) => [...s].reduce((w, ch) => w + (WIDE.test(ch) ? 2 : 1), 0);
|
|
8
11
|
// `cto brief`: what an agent should know before it starts working in this repo. Read by agents (Claude Code gets it
|
|
9
12
|
// at SessionStart), so it is English only and fits on one screen.
|
|
10
13
|
const git = (cwd, ...args) => {
|
|
@@ -235,7 +238,7 @@ export function brief(root, now = Date.now()) {
|
|
|
235
238
|
const test = cfg.test_command.trim() || detectTestCommand(root);
|
|
236
239
|
L.push(`Verify with ${test || '(unknown: set test_command in .cto.json)'}${test && !cfg.test_command.trim() ? ' (detected; pin it as test_command in .cto.json)' : ''}`);
|
|
237
240
|
if (cfg.stage === 'prototype')
|
|
238
|
-
L.push('Stage prototype: get the main path running for the user; tests stay light (see Stage in the cto-jev skill)');
|
|
241
|
+
L.push('Stage prototype: get the main path running for the user; tests stay light; P2/P3 review findings wait for build, even when listed Ready (see Stage in the cto-jev skill)');
|
|
239
242
|
L.push(...flowLines(root));
|
|
240
243
|
const plans = openPlanItems(root);
|
|
241
244
|
if (plans.length) {
|
package/dist/docs.js
CHANGED
|
@@ -1,39 +1,49 @@
|
|
|
1
1
|
import { execFileSync } from 'node:child_process';
|
|
2
|
-
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
3
3
|
import { join } from 'node:path';
|
|
4
|
+
import { detectTestCommand } from './brief.js';
|
|
4
5
|
import { evaluate } from './api.js';
|
|
5
|
-
import { loadBrain, saveKeeping } from './brain.js';
|
|
6
|
+
import { loadBrain, loadConfig, saveKeeping } from './brain.js';
|
|
6
7
|
import { estimateTokens } from './diff.js';
|
|
7
|
-
import { featureIndex, renderIndex } from './flow.js';
|
|
8
|
+
import { FLOW_DIR, featureIndex, listFeatures, loadTasks, renderIndex } from './flow.js';
|
|
8
9
|
import { t } from './i18n.js';
|
|
9
10
|
import { maskSensitiveState } from './masker.js';
|
|
10
|
-
import { BOX } from './turn.js';
|
|
11
|
+
import { BOX, isDropped } from './turn.js';
|
|
11
12
|
const PLANNING_MIN = 0.6;
|
|
12
13
|
const FINISHED_MIN = 0.6;
|
|
13
14
|
const CONFLICTS_MIN = 0.6;
|
|
14
15
|
const STATE_TOKENS = 6000;
|
|
15
16
|
const UNAVAILABLE = 'Jev unavailable; decide by hand';
|
|
16
|
-
|
|
17
|
+
/** Output of a git command; undefined when git failed (no git, not a repo). '' means it ran and printed nothing. */
|
|
18
|
+
const gitOut = (cwd, ...args) => {
|
|
17
19
|
try {
|
|
18
20
|
return execFileSync('git', args, { cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).trim();
|
|
19
21
|
}
|
|
20
22
|
catch {
|
|
21
|
-
return
|
|
23
|
+
return undefined;
|
|
22
24
|
}
|
|
23
25
|
};
|
|
26
|
+
const git = (cwd, ...args) => gitOut(cwd, ...args) ?? '';
|
|
24
27
|
const EXCLUDED = /^(README|CONTRIBUTING|CHANGELOG|SECURITY)\.md$|^LICENSE/i;
|
|
25
28
|
const TOOL_DIR = /(^|\/)(\.planning|specs|\.kiro)\//;
|
|
26
29
|
const TOOL_FILE = /^(PLAN|TODO|NOTES)\.md$|-plan\.md$/i;
|
|
27
30
|
const STALE_DAYS = 30;
|
|
28
|
-
/**
|
|
29
|
-
function
|
|
30
|
-
let fenced = false
|
|
31
|
-
|
|
31
|
+
/** Lines outside ``` and ~~~ fences, with their 1-based line numbers. */
|
|
32
|
+
function unfenced(text) {
|
|
33
|
+
let fenced = false;
|
|
34
|
+
return text.split(/\r?\n/).flatMap((l, i) => {
|
|
32
35
|
if (/^\s*(```|~~~)/.test(l)) {
|
|
33
36
|
fenced = !fenced;
|
|
34
|
-
|
|
37
|
+
return [];
|
|
35
38
|
}
|
|
36
|
-
|
|
39
|
+
return fenced ? [] : [{ l, n: i + 1 }];
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
/** Checkbox counts, ignoring boxes inside fences exactly like openPlanItems. */
|
|
43
|
+
function countBoxes(text) {
|
|
44
|
+
let open = 0, done = 0;
|
|
45
|
+
for (const { l } of unfenced(text)) {
|
|
46
|
+
const m = BOX.exec(l);
|
|
37
47
|
if (m)
|
|
38
48
|
m[2] === ' ' ? open++ : done++;
|
|
39
49
|
}
|
|
@@ -120,7 +130,62 @@ export async function judgeDocs(root, candidates, ctx) {
|
|
|
120
130
|
}
|
|
121
131
|
/** The whole `cto docs` report: rules, then Jev on what the rules left open. No network call when nothing is `ask`. */
|
|
122
132
|
export async function docsReport(root, ctx) {
|
|
123
|
-
return renderDocs(await judgeDocs(root, docCandidates(root), ctx), ctx.lang);
|
|
133
|
+
return renderDocs(await judgeDocs(root, docCandidates(root), ctx), ctx.lang, renderAlignment(alignmentIssues(root), ctx.lang));
|
|
134
|
+
}
|
|
135
|
+
const SPEC_ORDER = ['Interface', 'Constraints', 'Acceptance', 'Internals'];
|
|
136
|
+
const SPEC_HEAD = /^## (Interface|Constraints|Acceptance|Internals)\s*$/;
|
|
137
|
+
const tickedTask = (t) => t.done || isDropped(t);
|
|
138
|
+
export function alignmentIssues(root) {
|
|
139
|
+
const tasks = loadTasks(root);
|
|
140
|
+
const byId = new Map(tasks.map((t) => [t.id, t]));
|
|
141
|
+
const verify = loadConfig(root).test_command.trim() || detectTestCommand(root);
|
|
142
|
+
// Fail open: a shallow clone (or no git) cannot tell a path that never existed from one whose history was cut off.
|
|
143
|
+
const history = gitOut(root, 'rev-parse', '--is-shallow-repository') === 'false';
|
|
144
|
+
const out = [];
|
|
145
|
+
const add = (t, rule) => out.push({ file: t.file, line: t.line, rule });
|
|
146
|
+
for (const t of tasks) {
|
|
147
|
+
const kids = t.children.map((id) => byId.get(id)).filter((k) => !!k);
|
|
148
|
+
if (t.done && !isDropped(t) && history) {
|
|
149
|
+
const gone = t.files.some((f) => {
|
|
150
|
+
const p = f.replace(/\/$/, '');
|
|
151
|
+
return !f.includes('*') && !existsSync(join(root, p)) && gitOut(root, 'log', '--all', '--format=%H', '-n', '1', '--', p) === '';
|
|
152
|
+
});
|
|
153
|
+
if (gone)
|
|
154
|
+
add(t, 'never_existed');
|
|
155
|
+
}
|
|
156
|
+
if (!t.done && verify && t.files.length && t.files.every((f) => f.endsWith('.md')) && t.accept === verify)
|
|
157
|
+
add(t, 'acceptance');
|
|
158
|
+
if (!t.done && kids.length && kids.every(tickedTask))
|
|
159
|
+
add(t, 'parent_unticked');
|
|
160
|
+
if (!t.done && kids.length && (t.files.length || t.accept))
|
|
161
|
+
add(t, 'parent_acceptance');
|
|
162
|
+
}
|
|
163
|
+
for (const slug of listFeatures(root)) {
|
|
164
|
+
const rel = `${FLOW_DIR}/features/${slug}/SPEC.md`;
|
|
165
|
+
let text = '';
|
|
166
|
+
try {
|
|
167
|
+
text = readFileSync(join(root, rel), 'utf8');
|
|
168
|
+
}
|
|
169
|
+
catch {
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
const heads = unfenced(text).flatMap(({ l, n }) => {
|
|
173
|
+
const m = SPEC_HEAD.exec(l);
|
|
174
|
+
return m ? [{ rank: SPEC_ORDER.indexOf(m[1]), line: n }] : [];
|
|
175
|
+
});
|
|
176
|
+
const bad = heads.find((h, i) => heads.slice(0, i).some((p) => p.rank > h.rank));
|
|
177
|
+
if (bad)
|
|
178
|
+
out.push({ file: rel, line: bad.line, rule: 'spec_order' });
|
|
179
|
+
}
|
|
180
|
+
return out;
|
|
181
|
+
}
|
|
182
|
+
export function renderAlignment(issues, lang = 'en') {
|
|
183
|
+
if (!issues.length)
|
|
184
|
+
return [];
|
|
185
|
+
return [
|
|
186
|
+
t(lang, 'docs_align_title'),
|
|
187
|
+
...issues.map((i) => ` ${i.file}:${i.line} ${t(lang, `align_${i.rule}`)} — ${t(lang, `align_fix_${i.rule}`)}`),
|
|
188
|
+
];
|
|
124
189
|
}
|
|
125
190
|
/** `cto docs`: the report, then the brain saved with what other hooks wrote during the Jev calls (saveKeeping). */
|
|
126
191
|
export async function runDocs(root, lang) {
|
|
@@ -130,10 +195,10 @@ export async function runDocs(root, lang) {
|
|
|
130
195
|
return lines;
|
|
131
196
|
}
|
|
132
197
|
const GROUPS = ['delete', 'merge', 'archive', 'ask'];
|
|
133
|
-
export function renderDocs(c, lang = 'en') {
|
|
134
|
-
if (!c.length)
|
|
198
|
+
export function renderDocs(c, lang = 'en', align = []) {
|
|
199
|
+
if (!c.length && !align.length)
|
|
135
200
|
return [t(lang, 'docs_none')];
|
|
136
|
-
const L = [];
|
|
201
|
+
const L = c.length ? [] : [t(lang, 'docs_none')];
|
|
137
202
|
for (const verdict of GROUPS) {
|
|
138
203
|
const rows = c.filter((d) => d.verdict === verdict);
|
|
139
204
|
if (!rows.length)
|
|
@@ -146,6 +211,11 @@ export function renderDocs(c, lang = 'en') {
|
|
|
146
211
|
L.push(` ${d.file} ${d.open} open · ${d.done} done · ${age} — ${d.reason}`);
|
|
147
212
|
}
|
|
148
213
|
}
|
|
214
|
+
if (align.length) {
|
|
215
|
+
if (L.length)
|
|
216
|
+
L.push('');
|
|
217
|
+
L.push(...align);
|
|
218
|
+
}
|
|
149
219
|
L.push('', t(lang, 'docs_footer'));
|
|
150
220
|
return L;
|
|
151
221
|
}
|
package/dist/flow.js
CHANGED
|
@@ -6,7 +6,8 @@ import { ACCEPT, acceptValue, BOX } from './turn.js';
|
|
|
6
6
|
export const FLOW_DIR = 'docs/cto_jev';
|
|
7
7
|
export const FEATURE_FILES = ['CONCEPT.md', 'SPEC.md', 'TASKS.md', 'REVIEW.md'];
|
|
8
8
|
const ID = /^([A-Z][A-Z0-9]*-\d+(?:\.\d+)*)\b\s*/;
|
|
9
|
-
|
|
9
|
+
// A code span is matched first so a tag quoted in one is left alone; a tag value may hold one level of parens (`(tabs)`) and backticked paths.
|
|
10
|
+
const CODE_OR_TAG = /(`[^`]*`)|\s*\((after|files):\s*((?:[^()`]|`[^`]*`|`(?![^`]*`)|\([^()]*\))*)\)/g; // a lone backtick only when no closing one follows: otherwise `a` could match two ways and backtrack exponentially
|
|
10
11
|
const PRIORITY = /\s*\((P[123])\)/;
|
|
11
12
|
const SEQ = /\s*\(seq\)/;
|
|
12
13
|
const list = (s) => s.split(/[,,]/).map((x) => x.trim()).filter(Boolean);
|
|
@@ -53,14 +54,23 @@ export function parseTasks(text, feature, file) {
|
|
|
53
54
|
let priority;
|
|
54
55
|
let seq = false;
|
|
55
56
|
const text = m[3].slice(idm[0].length)
|
|
56
|
-
.replace(
|
|
57
|
+
.replace(CODE_OR_TAG, (s, code, kind, v) => {
|
|
58
|
+
if (code)
|
|
59
|
+
return code;
|
|
60
|
+
(kind === 'after' ? after : files).push(...list(v.replace(/`([^`]*)`/g, '$1'))); // a lone backtick stays a character
|
|
61
|
+
return '';
|
|
62
|
+
})
|
|
63
|
+
// Odd parts of the split are inline code: a tag quoted there ("quotes `(seq)`") is text, not a tag.
|
|
64
|
+
.split(/(`[^`]*`)/)
|
|
65
|
+
.map((s, k) => (k % 2 ? s : s
|
|
57
66
|
.replace(PRIORITY, (_, p) => { priority = p; return ''; })
|
|
58
|
-
.replace(SEQ, () => { seq = true; return ''; })
|
|
67
|
+
.replace(SEQ, () => { seq = true; return ''; })))
|
|
68
|
+
.join('')
|
|
59
69
|
.trim();
|
|
60
70
|
while (stack.length && stack[stack.length - 1].indent >= indent)
|
|
61
71
|
stack.pop();
|
|
62
72
|
const parent = stack[stack.length - 1]?.id;
|
|
63
|
-
const t = { id: idm[1], text, done: m[2] !== ' ', feature, file, line: i + 1, parent, children: [], after, files, ...(priority ? { priority } : {}), ...(seq ? { seq } : {}) };
|
|
73
|
+
const t = { id: idm[1], text, done: m[2] !== ' ', feature, file, line: i + 1, parent, children: [], after, files: files.filter((f) => f !== '-'), ...(priority ? { priority } : {}), ...(seq ? { seq } : {}) };
|
|
64
74
|
if (parent)
|
|
65
75
|
tasks.find((p) => p.id === parent)?.children.push(t.id);
|
|
66
76
|
tasks.push(t);
|
package/dist/hooks.js
CHANGED
|
@@ -94,7 +94,9 @@ export const Q = {
|
|
|
94
94
|
'Does the user\'s reply agree to all of the listed documents, without asking for any change and without agreeing to only some of them? ' +
|
|
95
95
|
'Agreement: a plain yes such as 好, 可以, ok, lgtm, 👍, "go ahead", "可以開始", including typos that still mean yes. ' +
|
|
96
96
|
'Not agreement: a question, a change request (even with a yes, like "好,但 X 改一下"), agreeing to only some documents, ' +
|
|
97
|
-
'asking for something else first, or talking about something unrelated.'
|
|
97
|
+
'asking for something else first, or talking about something unrelated. ' +
|
|
98
|
+
'Exception: a reply that opens with a plain yes to all ("ok all", "好,簽") and then moves to a separate topic that names nothing in the listed documents ' +
|
|
99
|
+
'(another repo, CI, a complaint about something else) is agreement: the rest is a new request, not a condition on these documents.',
|
|
98
100
|
criteria: {
|
|
99
101
|
true: 'The user clearly approves every listed document as written',
|
|
100
102
|
false: 'The user asks, requests changes, agrees only in part, or says something else',
|
|
@@ -1556,6 +1558,8 @@ function revertSelfSigned(root, sessionId) {
|
|
|
1556
1558
|
const YES = String.raw `(?:ok(?:ay)?|好(?:的|啊)?|可以|同意|沒問題|簽(?:核)?|lgtm|yes|👍|go ahead)`;
|
|
1557
1559
|
const END = String.raw `[\s!!.。~]*`;
|
|
1558
1560
|
const SHORT_YES = new RegExp(`^${YES}${END}$`, 'iu');
|
|
1561
|
+
// The yes word must end at a separator: "好像少了一個欄位" opens with 好 but is no yes.
|
|
1562
|
+
const LEADING_YES = new RegExp(`^${YES}(?=[\\s,,、.。!!~;;::]|$)`, 'iu');
|
|
1559
1563
|
const NAMED_YES = [new RegExp(`^(.+?)[\\s,,、]*${YES}${END}$`, 'iu'), new RegExp(`^${YES}[\\s,,、]+(.+?)${END}$`, 'iu')];
|
|
1560
1564
|
const docName = (f) => (f.endsWith('/CONCEPT.md') ? f.split('/').at(-2) : f.split('/').at(-1).replace(/\.md$/, '')).toLowerCase();
|
|
1561
1565
|
// Alone, "all" and "全部" mean every listed draft ("ok all"). "都" is only filler next to names ("imports 跟 catalog 都 ok"):
|
|
@@ -1614,8 +1618,9 @@ async function signoffReply(input, { root, lang, now }) {
|
|
|
1614
1618
|
saveKeeping(root, brain);
|
|
1615
1619
|
if (!r.ok)
|
|
1616
1620
|
return promptOutput(undefined, t(lang, r.reason === 'no_keys' ? 'signoff_no_keys' : r.reason === 'cooldown' ? 'signoff_paused' : 'signoff_unavailable'));
|
|
1621
|
+
// A reply that opens with a yes and goes on looks signed to the user: say it was not, rather than stay silent.
|
|
1617
1622
|
if (exceeded(r.answers, 'signoff_approved', cfg) === undefined)
|
|
1618
|
-
return SILENT;
|
|
1623
|
+
return LEADING_YES.test(input.prompt.trim()) && !SHORT_YES.test(input.prompt.trim()) ? promptOutput(undefined, t(lang, 'signoff_declined_user')) : SILENT;
|
|
1619
1624
|
return signDocs(root, lang, files).out;
|
|
1620
1625
|
}
|
|
1621
1626
|
/** Sets every file to approved, or none when one is no longer a draft; the output in the given hook event's shape. */
|
package/dist/i18n.js
CHANGED
|
@@ -73,6 +73,7 @@ const messages = {
|
|
|
73
73
|
local_flow_duplicate_id: (v) => `[cto] ${v.detail}:這個任務 ID 在 TASKS.md 裡出現不只一次,after: 會指錯。改成唯一的 ID;這次不擋。`,
|
|
74
74
|
signoff_done: (v) => `[cto] 已簽核:${v.detail}`,
|
|
75
75
|
signoff_unavailable: () => '[cto] 沒有簽核:判斷服務連不上,可以手改 Status',
|
|
76
|
+
signoff_declined_user: () => '[cto] 沒有簽核:這則回覆不只是同意(有條件、提問或部分同意)。要簽就單獨回「ok all」,或文件名加 ok',
|
|
76
77
|
signoff_no_keys: () => '[cto] 沒有簽核:還沒設判斷服務的 API key(跑 cto setup),可以手改 Status',
|
|
77
78
|
signoff_paused: () => '[cto] 沒有簽核:判斷服務剛才失敗,暫停中,稍後再回一次或手改 Status',
|
|
78
79
|
signoff_partial: (v) => `[cto] 簽核寫到一半失敗。已簽核:${v.signed};沒簽:${v.unsigned},可以手改 Status`,
|
|
@@ -125,6 +126,17 @@ const messages = {
|
|
|
125
126
|
docs_group_archive: () => '封存到 docs/cto_jev/archive/',
|
|
126
127
|
docs_group_ask: () => '要看一下',
|
|
127
128
|
docs_footer: () => 'cto 只給建議:沒有移動或刪除任何檔案。',
|
|
129
|
+
docs_align_title: () => 'docs/cto_jev/ 對齊檢查(只用規則)',
|
|
130
|
+
align_never_existed: () => '路徑從沒存在過',
|
|
131
|
+
align_fix_never_existed: () => '改成真正改到的路徑',
|
|
132
|
+
align_acceptance: () => '驗收不會失敗',
|
|
133
|
+
align_fix_acceptance: () => '改成會因內容錯而失敗的指令,例如 grep -q \'<新寫的那句>\' <檔>',
|
|
134
|
+
align_parent_unticked: () => '上層漏勾',
|
|
135
|
+
align_fix_parent_unticked: () => '勾上層',
|
|
136
|
+
align_parent_acceptance: () => '上層自帶驗收',
|
|
137
|
+
align_fix_parent_acceptance: () => '移到一個子項',
|
|
138
|
+
align_spec_order: () => 'SPEC 段落順序',
|
|
139
|
+
align_fix_spec_order: () => '照順序排',
|
|
128
140
|
local_flow_interface: (v) => `[cto] ${v.detail}:SPEC 的 Interface 改了。依賴它的 feature 要重看自己的 task;這次不擋。`,
|
|
129
141
|
setup_not_git: () => '[cto] 這裡不是 git repository,setup 中止。',
|
|
130
142
|
setup_bad_json: (v) => `[cto] ${v.path} 不是合法 JSON 或 hooks 格式不符,未修改任何檔案。請先修正該檔。`,
|
|
@@ -355,6 +367,7 @@ const messages = {
|
|
|
355
367
|
local_flow_duplicate_id: (v) => `[cto] ${v.detail}: this task id appears more than once in TASKS.md, so after: may point at the wrong one. Make it unique; not blocking.`,
|
|
356
368
|
signoff_done: (v) => `[cto] Signed off: ${v.detail}`,
|
|
357
369
|
signoff_unavailable: () => '[cto] Not signed off: the judging service is unreachable. You can edit the Status line by hand',
|
|
370
|
+
signoff_declined_user: () => '[cto] Not signed off: this reply is more than a yes (a condition, a question or a partial yes). To sign, reply "ok all" alone, or names plus ok',
|
|
358
371
|
signoff_no_keys: () => '[cto] Not signed off: no API key for the judging service yet (run cto setup). You can edit the Status line by hand',
|
|
359
372
|
signoff_paused: () => '[cto] Not signed off: the judging service failed a moment ago and is paused. Reply again later or edit the Status line by hand',
|
|
360
373
|
signoff_partial: (v) => `[cto] Sign-off failed partway. Signed off: ${v.signed}; not signed: ${v.unsigned}. You can edit the Status line by hand`,
|
|
@@ -407,6 +420,17 @@ const messages = {
|
|
|
407
420
|
docs_group_archive: () => 'Archive to docs/cto_jev/archive/',
|
|
408
421
|
docs_group_ask: () => 'Needs a look',
|
|
409
422
|
docs_footer: () => 'cto only suggests: nothing was moved or deleted.',
|
|
423
|
+
docs_align_title: () => 'Alignment checks for docs/cto_jev/ (rules only)',
|
|
424
|
+
align_never_existed: () => 'path never existed',
|
|
425
|
+
align_fix_never_existed: () => 'change it to the path actually changed',
|
|
426
|
+
align_acceptance: () => 'acceptance cannot fail',
|
|
427
|
+
align_fix_acceptance: () => 'use a check that fails on wrong content, e.g. grep -q \'<new sentence>\' <file>',
|
|
428
|
+
align_parent_unticked: () => 'parent unticked',
|
|
429
|
+
align_fix_parent_unticked: () => 'tick the parent',
|
|
430
|
+
align_parent_acceptance: () => 'parent with own acceptance',
|
|
431
|
+
align_fix_parent_acceptance: () => 'move it to a child',
|
|
432
|
+
align_spec_order: () => 'SPEC section order',
|
|
433
|
+
align_fix_spec_order: () => 'reorder to match',
|
|
410
434
|
local_flow_interface: (v) => `[cto] ${v.detail}: the SPEC's Interface changed. Dependent features must re-check their tasks; not blocking.`,
|
|
411
435
|
setup_not_git: () => '[cto] Not a git repository, setup aborted.',
|
|
412
436
|
setup_bad_json: (v) => `[cto] ${v.path} is not valid JSON or has an unexpected hooks shape. Nothing was changed. Fix it first.`,
|
package/dist/setup.js
CHANGED
|
@@ -42,6 +42,8 @@ export function appendBlock(content, body) {
|
|
|
42
42
|
export function hasEarlyExit(content) {
|
|
43
43
|
return /^\s*exit\s+0\b/m.test(removeBlock(content));
|
|
44
44
|
}
|
|
45
|
+
// Test file names outside JS/TS, so a mature Python, Go, Ruby, JVM, .NET or Rust repo is not taken for a new project.
|
|
46
|
+
const ANY_LANG_TEST = /(^|\/)(test_[^/]*\.py|[^/]*_test\.(py|go)|[^/]*_spec\.rb|[^/]*Tests?\.(java|kt|cs)|tests\/[^/]*\.rs)$/;
|
|
45
47
|
const git = (cwd, ...args) => execFileSync('git', args, { cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).trim();
|
|
46
48
|
/**
|
|
47
49
|
* IGNORE_BODY entries the repo's own .gitignore does not already cover outside our block: an exact line, or any rule there
|
|
@@ -513,7 +515,7 @@ export function setup(cwd, lang, opts = {}) {
|
|
|
513
515
|
tracked = git(root, 'ls-files', '-z').split('\0');
|
|
514
516
|
}
|
|
515
517
|
catch { /* not a git repo yet: nothing tracked */ }
|
|
516
|
-
const fresh = flow && !tracked.some((f) => TEST_FILE.test(f));
|
|
518
|
+
const fresh = flow && !tracked.some((f) => TEST_FILE.test(f) || ANY_LANG_TEST.test(f));
|
|
517
519
|
writeFileSync(cfgPath, JSON.stringify({ sprint_goal: '', ...(fresh ? { stage: 'prototype' } : {}), thresholds: {} }, null, 2) + '\n');
|
|
518
520
|
lines.push(t(lang, 'setup_config'));
|
|
519
521
|
}
|
package/dist/setupui.js
CHANGED
|
@@ -4,15 +4,14 @@ import { styleText } from 'node:util';
|
|
|
4
4
|
import { agentNames, agents } from './agents.js';
|
|
5
5
|
import { DEFAULT_ORDER, probeProvider, providers } from './api.js';
|
|
6
6
|
import { DEFAULT_MODELS } from './brain.js';
|
|
7
|
+
import { displayWidth } from './brief.js';
|
|
7
8
|
import { t } from './i18n.js';
|
|
8
9
|
import { MEMORY_FILES } from './skill.js';
|
|
9
10
|
const BACK = Symbol('back');
|
|
10
11
|
const PROVIDER_ORDER = DEFAULT_ORDER;
|
|
11
12
|
const dim = (s) => styleText('dim', s);
|
|
12
13
|
const tail = (v) => `…${v.slice(-4)}`;
|
|
13
|
-
|
|
14
|
-
const WIDE = /[\u1100-\u115f\u2e80-\ua4cf\uac00-\ud7a3\uf900-\ufaff\ufe30-\ufe4f\uff00-\uff60\uffe0-\uffe6]/;
|
|
15
|
-
export const displayWidth = (s) => [...s].reduce((w, ch) => w + (WIDE.test(ch) ? 2 : 1), 0);
|
|
14
|
+
export { displayWidth };
|
|
16
15
|
const pad = (s, w) => s + ' '.repeat(Math.max(0, w - displayWidth(s)));
|
|
17
16
|
/**
|
|
18
17
|
* Interactive setup. First run walks agents -> providers -> keys -> flow (Esc goes back one step), then
|
package/dist/skill.js
CHANGED
|
@@ -34,7 +34,7 @@ ${SKILL_HEAD}
|
|
|
34
34
|
You review changes you have never seen, with no context beyond the repository and the request. Do not trust the author's intent or the request's claims; check the code.
|
|
35
35
|
|
|
36
36
|
1. Run \`git status\` and \`git diff HEAD\` to see what changed, then read the changed files and the code that calls them.
|
|
37
|
-
2. Look for wrong logic, missed edge cases, broken callers, security holes, data loss, and tests that were skipped, deleted or loosened. A new test that repeats what an existing test already checks, a new test file where the existing test file for that code would do, or a test heavier than it needs (a real database or server where a unit test would check the same thing) is a P2. If the prompt says \`stage: prototype\`, a missing or thin test is no finding at all; the rest of this rule still applies.
|
|
37
|
+
2. Look for wrong logic, missed edge cases, broken callers, security holes, data loss, and tests that were skipped, deleted or loosened. A new test that repeats what an existing test already checks, a new test file where the existing test file for that code would do, or a test heavier than it needs (a real database or server where a unit test would check the same thing) is a P2. If the prompt says \`stage: prototype\`, a missing or thin test is no finding at all; the rest of this rule still applies, and so does the question every acceptance test answers (would it fail if its scenario were broken): a test that is there must not pass on broken behavior.
|
|
38
38
|
3. Never edit, write or delete anything. Use Bash only for read-only commands (git diff, git log, git show, running a single test file of the changed code). Never run a whole test suite: the author already ran the acceptance commands, and a whole suite run beside another one can share its test database and break both.
|
|
39
39
|
|
|
40
40
|
Output one finding per line, each starting with P1 (must fix: a bug, a security hole, data loss), P2 (should fix) or P3 (minor), then \`file:line\` and the problem in one sentence. A P1 or P2 about behaviour names the input or state that produces the wrong result; a behaviour concern you cannot tie to one is not reported. A test that was skipped, deleted or loosened, a broken Constraint or Interface, and code that does something the CONCEPT does not say need no such input: report them as they are. Nothing else before or after. No findings: write \`No findings.\`
|
|
@@ -147,13 +147,13 @@ turns it into a calibration case; you do not run that yourself.
|
|
|
147
147
|
- \`cto check\`: preview the commit checks on your current changes.
|
|
148
148
|
- \`cto doctor\`: show whether cto is working here (keys, hooks, recent checks).
|
|
149
149
|
- \`cto index\`: regenerate \`docs/cto_jev/INDEX.md\` (only in a repo that uses the development flow).
|
|
150
|
-
- \`cto docs\`: list stale planning markdown outside \`docs/cto_jev/\` with a suggestion per file; changes nothing.
|
|
150
|
+
- \`cto docs\`: list stale planning markdown outside \`docs/cto_jev/\` with a suggestion per file, and the alignment checks of \`docs/cto_jev/\` itself; changes nothing.
|
|
151
151
|
`;
|
|
152
152
|
// The flow skill: how the host agent plans, dispatches and accepts work under docs/cto_jev/. Written only when
|
|
153
153
|
// `cto setup` chose the flow.
|
|
154
154
|
export const FLOW_SKILL_TEXT = `---
|
|
155
155
|
name: cto-jev
|
|
156
|
-
description: The development flow of this repo, kept in docs/cto_jev/. Invoked by saying the job's name (in Claude Code: /cto-jev <job>; in Codex: $cto-jev). Its jobs are named so they cannot be confused with another skill's steps - "cto-jev init" (first-time setup, also "set up PRODUCT.md and ARCHITECTURE.md"), "cto-jev feature" (a request bigger than one edit), "cto-jev tasks" (break a signed-off concept down), "cto-jev work" (dispatch, accept, review and commit every wave, without stopping in between), "cto-jev work all" (the same on a branch, every wave reviewed, then the hand-over to release), "cto-jev release" (review everything unreleased, then merge to main), "cto-jev docs" (clean up old documents), "cto-jev decision" (record an architecture decision), "cto-jev decide" (put everything waiting on the user in one menu). Load it when the user names one of them, and whenever you are about to plan, dispatch, tick a task or commit.
|
|
156
|
+
description: The development flow of this repo, kept in docs/cto_jev/. Invoked by saying the job's name (in Claude Code: /cto-jev <job>; in Codex: $cto-jev). Its jobs are named so they cannot be confused with another skill's steps - "cto-jev init" (first-time setup, also "set up PRODUCT.md and ARCHITECTURE.md"), "cto-jev feature" (a request bigger than one edit), "cto-jev tasks" (break a signed-off concept down), "cto-jev work" (dispatch, accept, review and commit every wave, without stopping in between), "cto-jev work all" (the same on a branch, every wave reviewed, then the hand-over to release), "cto-jev release" (review everything unreleased, then merge to main), "cto-jev docs" (clean up old documents, and check that docs/cto_jev/ agrees with itself, the code and the tests), "cto-jev decision" (record an architecture decision), "cto-jev decide" (put everything waiting on the user in one menu). Load it when the user names one of them, and whenever you are about to plan, dispatch, tick a task or commit.
|
|
157
157
|
---
|
|
158
158
|
${SKILL_HEAD}
|
|
159
159
|
|
|
@@ -282,7 +282,9 @@ Two more tags, on any task:
|
|
|
282
282
|
- A task's acceptance is the lightest command that shows it works (a build, a smoke test that the app starts and answers), or \`manual: <what to try> @ <where>\` for what the user sees. Write no end-to-end harness, and no unit or database test beyond what that acceptance needs.
|
|
283
283
|
- Trouble with the test setup itself (a flaky harness, a test database that crashes) becomes a \`platform\` task for the build stage, not work now.
|
|
284
284
|
- Every \`cto-reviewer\` dispatch prompt says \`stage: prototype\`. Wrong behavior, security holes, secrets and data loss are still P1.
|
|
285
|
-
-
|
|
285
|
+
- Below P1, nothing is cleaned up yet. In a wave review, a \`cto-jev docs\` review and the release review, P1s are fixed as usual, but P2s and P3s become no task: write them under \`Left for the user (prototype):\` in that review's REVIEW.md entry. The pre-sign-off docs review of \`cto-jev init\` and \`feature\` is not one of these: it still fixes P1 and P2 in the docs. There are no cleanup waves: never dispatch a finding task (as defined under "Review findings") marked \`(P2)\` or \`(P3)\`; count them as waiting on the user, not as Ready work.
|
|
286
|
+
- The whole unit and end-to-end suites run only in the release. This overrides step 4 of \`cto-jev work\`: a wave that changes a \`platform\` or shared file, touches a feature without \`e2e/<slug>/\`, or runs with \`"e2e_folders": false\` still runs only its own tasks' acceptance commands and the \`e2e/<slug>/\` tests that exist for the features it touches.
|
|
287
|
+
- When the user can walk the main path, put "switch to build?" in the run's final report. The user decides; only then set \`"stage": "build"\`, turn the \`Left for the user (prototype):\` items in each feature's REVIEW.md that still hold into finding tasks (other \`Left for the user:\` items stay as they are), and plan the tests the main path needs.
|
|
286
288
|
|
|
287
289
|
## cto-jev work
|
|
288
290
|
|
|
@@ -322,14 +324,14 @@ Without sub-agents: do the Ready tasks yourself in brief's order, one at a time,
|
|
|
322
324
|
|
|
323
325
|
## Review findings
|
|
324
326
|
|
|
325
|
-
Every review (docs, wave, release) ends here. You wrote what was reviewed, so wanting to disagree is not evidence.
|
|
327
|
+
Every review (docs, alignment, wave, release) ends here. You wrote what was reviewed, so wanting to disagree is not evidence.
|
|
326
328
|
|
|
327
329
|
- **Contest** a finding only by citing something the reviewer could read: a file and symbol, or a decision written in the docs. "It was intentional" is not evidence.
|
|
328
330
|
- **Escalate** to the user when the evidence is outside anything the reviewer could read (a verbal decision, a team convention). Do not dismiss it yourself; if the user confirms, write the fact into the docs.
|
|
329
331
|
- A reviewer who could not follow the docs found missing context. Never contest that.
|
|
330
332
|
- Never change a severity yourself. A P1 that looks like a P2 is contested like any finding, with evidence, and the user decides.
|
|
331
|
-
- An escalated finding, or a contest the user has not decided, does not stop a run: leave that finding unfixed, write it into the REVIEW.md entry, go on, and list it in your final report and the release report. In
|
|
332
|
-
- After fixing P1s, a new \`cto-reviewer\` (no model parameter, none of your context) re-reviews the whole current change, never the fix alone: the commit gate matches a review to the exact working tree, so a review of the fix alone does not cover what is committed. Run the formatter again before every re-dispatch. At most three rounds per review: the first plus up to two whole-change re-reviews. If P1s remain after round three, stop fixing: write each one into the REVIEW.md entry marked as escalated to the user (the commit gate accepts that), leave it unfixed, and hand it to the user. Anything below P1 becomes a task with its severity, except in a cleanup review (next rule) (in
|
|
333
|
+
- An escalated finding, or a contest the user has not decided, does not stop a run: leave that finding unfixed, write it into the REVIEW.md entry, go on, and list it in your final report and the release report. In the pre-sign-off docs review of \`cto-jev init\` and \`feature\` (not the alignment review of \`cto-jev docs\`) it goes into the handoff's "might be missing" instead, since that job stops for sign-off anyway. Before escalating, read the CONCEPT: what it decides is not the user's to decide again.
|
|
334
|
+
- After fixing P1s, a new \`cto-reviewer\` (no model parameter, none of your context) re-reviews the whole current change, never the fix alone: the commit gate matches a review to the exact working tree, so a review of the fix alone does not cover what is committed. Run the formatter again before every re-dispatch. At most three rounds per review: the first plus up to two whole-change re-reviews. If P1s remain after round three, stop fixing: write each one into the REVIEW.md entry marked as escalated to the user (the commit gate accepts that), leave it unfixed, and hand it to the user. Anything below P1 becomes a task with its severity, except in a cleanup review (next rule) (in the pre-sign-off docs review, where no tasks may exist yet: fixed in the docs or put in the handoff's "might be missing").
|
|
333
335
|
- **Findings below P1 are batched, not chained.** A finding task is one whose text starts \`Review finding (\`, or, for one filed before that marker existed, whose text says it came from a review in any wording. Finding tasks wait while their feature has any other Ready task you would dispatch; parked tasks, finding tasks and tasks blocked on a finding task do not count. Then all of the feature's Ready finding tasks run as one cleanup wave: dispatched as usual (\`(seq)\` and overlapping \`(files:)\` still run one after another), each accepted, then one review over the whole cleanup and one commit. A finding task's test is a unit or database test, unless the finding is an Acceptance scenario that is broken for the user; then it is that scenario's end-to-end test. What that cleanup review finds below P1 does not become a task: write it into the cleanup's REVIEW.md entry under \`Left for the user:\` and list it in the final report and the release report. It becomes a task only when the user asks for it.
|
|
334
336
|
- Without sub-agents every review here, the re-review included, is your own: say \`self-review\` in its REVIEW.md entry. Where Claude Code is wired and the review gate is on, that self-review cannot pass the commit gate: keep its tasks ticked, leave the tree uncommitted, stop the run, and say in the final report that it is waiting for a cto-reviewer review in a Claude Code session.
|
|
335
337
|
|
|
@@ -356,15 +358,17 @@ Whatever the row, one rule holds: the branch that reaches users receives nothing
|
|
|
356
358
|
|
|
357
359
|
**Stop:** before the merge, with the P1/P2/P3 lists in front of the user.
|
|
358
360
|
|
|
359
|
-
**After the user merges:** \`git fetch --prune\`, then delete
|
|
361
|
+
**After the user merges:** if the tree has uncommitted changes, skip this and say so in your report; never stash or discard them for it. Otherwise \`git checkout <release branch>\` and \`git pull\` (a merge on the host leaves the local copy behind, and the branch you stand on cannot be deleted), \`git fetch --prune\`, then delete the local branches whose work is merged, never the release branch, the integration branch or the deploy branches. On GitHub these are the head branches of merged PRs (\`gh pr list --state merged --json headRefName,headRefOid\`) whose local tip is still that \`headRefOid\`, deleted with \`git branch -D\`: a squash or rebase merge leaves commits \`git branch -d\` does not recognise. Elsewhere, delete only the branch this release merged, with \`git branch -d\`. A branch with no merged PR (one just created and not yet committed to) stays. On the remote, delete the merged feature or \`work-all\` branch only if the host did not already (on GitHub, the repo setting "Automatically delete head branches" does it; if it is off, put "turn it on?" in your report).
|
|
360
362
|
|
|
361
363
|
## cto-jev docs
|
|
362
364
|
|
|
363
365
|
**When:** the user says "cto-jev docs", before opening a feature, or when the user asks to tidy the repo.
|
|
364
366
|
|
|
365
|
-
1. \`cto docs\`. It lists markdown outside \`docs/cto_jev/\` that looks like an old plan, grouped as Delete / Merge into a feature / Archive / Needs a look.
|
|
366
|
-
2. Show the list to the user with one line per file; they decide.
|
|
367
|
-
3. Then act: merge = fold the still-open items into the right TASKS.md or SPEC.md and delete the file; archive = move to \`docs/cto_jev/archive/<YYYYMM>-<name>/\`; delete = \`git rm\`. Never act before the user answers.
|
|
367
|
+
1. \`cto docs\`. It lists two things and changes nothing. First, markdown outside \`docs/cto_jev/\` that looks like an old plan, grouped as Delete / Merge into a feature / Archive / Needs a look. Second, the alignment checks on \`docs/cto_jev/\` itself: five rule-based checks, each finding with file:line, the rule and how to fix it (a \`(files:)\` path that never existed, a task verified only by a command that cannot fail, a parent not ticked over ticked children, a parent that carries its own acceptance, SPEC sections out of order).
|
|
368
|
+
2. Show the old-plan list to the user with one line per file; they decide.
|
|
369
|
+
3. Then act on that list: merge = fold the still-open items into the right TASKS.md or SPEC.md and delete the file; archive = move to \`docs/cto_jev/archive/<YYYYMM>-<name>/\`; delete = \`git rm\`. Never act before the user answers.
|
|
370
|
+
4. Alignment: handle every item \`cto docs\` listed, without waiting for the user (step 5 says how each one is handled). Then dispatch \`subagent_type: "cto-reviewer"\` with no model parameter and none of your context, over \`docs/cto_jev/\`, README.md and the test files. It answers four questions: the same rule written in two docs (name the doc that owns it), docs that contradict each other, docs that disagree with the code, and SPEC behavior with no test. Also run \`cto tests\` and add the files it flags to that list.
|
|
371
|
+
5. Findings follow "Review findings", except where this step says otherwise. Severity of a \`cto docs\` rule finding: P2 by default, P1 when the doc it sits in tells an agent something false that would lead it to wrong work. None of the five rules is P1 by itself, so judge each case on what the doc says. A reviewer's finding keeps the severity the reviewer gave. P1 is fixed now. Every P2 and P3 becomes a task whose text starts \`Review finding (docs):\`, in the feature whose doc holds the problem, or in \`platform\` when the finding spans features or sits in PRODUCT, ARCHITECTURE, INDEX or README. Write one REVIEW.md entry in each feature that got a fix or a task, listing them. An alignment fix does not wait for the user, except an edit to a sign-off doc (CONCEPT, PRODUCT or ARCHITECTURE): that goes through draft and sign-off as usual, with \`Status: draft\` set by the Edit tool first.
|
|
368
372
|
|
|
369
373
|
## cto-jev decision
|
|
370
374
|
|
package/dist/tests.js
CHANGED
|
@@ -51,7 +51,7 @@ const terms = (s) => new Set([
|
|
|
51
51
|
...[...s.matchAll(/(?=([ -鿿]{2}))/g)].map((m) => m[1]),
|
|
52
52
|
]);
|
|
53
53
|
/**
|
|
54
|
-
* The SPEC sections a test should trace to. A big SPEC (
|
|
54
|
+
* The SPEC sections a test should trace to. A big SPEC (22k tokens seen in practice) does not fit beside the test, and a
|
|
55
55
|
* clipped one hides the lines the test traces to, so then only the lines sharing a word or a CJK pair with the test go,
|
|
56
56
|
* the most shared first, kept in SPEC order.
|
|
57
57
|
*/
|
package/dist/turn.js
CHANGED
|
@@ -228,8 +228,8 @@ const MANUAL = /^manual(?![\w./-])/i;
|
|
|
228
228
|
export const isManualAccept = (accept) => MANUAL.test(squash(accept ?? ''));
|
|
229
229
|
const TASK_ID = /^[A-Z][A-Z0-9]*-\d+(?:\.\d+)*\b/;
|
|
230
230
|
const DROPPED = /[((]dropped[::]\s*[^))\s][^))]*[))]/i;
|
|
231
|
-
/** A task closed without doing it: `(dropped: reason)` on its line, then ticked. */
|
|
232
|
-
export const isDropped = (t) => DROPPED.test(t.text);
|
|
231
|
+
/** A task closed without doing it: `(dropped: reason)` on its line, then ticked. A marker quoted in inline code is text. */
|
|
232
|
+
export const isDropped = (t) => DROPPED.test(t.text.replace(/`[^`]*`/g, ''));
|
|
233
233
|
/** The task's id, or its first words when it has none: how messages name it. */
|
|
234
234
|
export const taskName = (t) => TASK_ID.exec(t.text)?.[0] ?? squash(t.text.replace(DROPPED, '')).slice(0, 30);
|
|
235
235
|
const esc = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "your-cto-jev",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.0",
|
|
4
4
|
"description": "A sharp-tongued CTO gatekeeper for AI coding agents: blocks leaked secrets in git commits and destructive shell commands in Claude Code, Cursor, Gemini CLI and Codex, using TypeSafe Jev.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"claude-code",
|