your-cto-jev 0.19.0 → 0.20.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 +1 -0
- package/dist/brain.js +2 -0
- package/dist/brief.js +2 -0
- package/dist/setup.js +9 -1
- package/dist/skill.js +13 -2
- package/dist/tests.js +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -397,6 +397,7 @@ Defaults: `credential_leak` 0.5, `destructive_command` 0.7, `infinite_loop` 0.6,
|
|
|
397
397
|
- **`test_command`**: what `cto brief` tells the agent to verify with, for example `"pnpm test"`. Detected from the project when empty.
|
|
398
398
|
- **`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
399
|
- **`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`.
|
|
400
401
|
- **`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.
|
|
401
402
|
- **Thresholds**: Jev returns a probability from 0 to 1. `code_complexity` is the exception: it is a score from 0 (clean) to 4 (unmaintainable).
|
|
402
403
|
- **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/brain.js
CHANGED
|
@@ -34,6 +34,7 @@ export const DEFAULT_CONFIG = {
|
|
|
34
34
|
review_gate: true,
|
|
35
35
|
turn_limits: { minutes: 20, tool_calls: 150, agents: 4 },
|
|
36
36
|
e2e_folders: true,
|
|
37
|
+
stage: 'build',
|
|
37
38
|
};
|
|
38
39
|
const emptyBrain = () => ({
|
|
39
40
|
recent_errors: [],
|
|
@@ -81,6 +82,7 @@ export function loadConfig(root) {
|
|
|
81
82
|
review_gate: raw.review_gate !== false,
|
|
82
83
|
turn_limits: turnLimits(raw.turn_limits),
|
|
83
84
|
e2e_folders: raw.e2e_folders !== false,
|
|
85
|
+
stage: raw.stage === 'prototype' ? 'prototype' : 'build',
|
|
84
86
|
};
|
|
85
87
|
}
|
|
86
88
|
/** Corrupt or missing state rebuilds as empty: the gate must never crash on its own bookkeeping. */
|
package/dist/brief.js
CHANGED
|
@@ -234,6 +234,8 @@ export function brief(root, now = Date.now()) {
|
|
|
234
234
|
L.push(`Sprint goal ${cfg.sprint_goal.trim() || '(none set in .cto.json)'}`);
|
|
235
235
|
const test = cfg.test_command.trim() || detectTestCommand(root);
|
|
236
236
|
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
|
+
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)');
|
|
237
239
|
L.push(...flowLines(root));
|
|
238
240
|
const plans = openPlanItems(root);
|
|
239
241
|
if (plans.length) {
|
package/dist/setup.js
CHANGED
|
@@ -9,6 +9,7 @@ import { MODEL_KEYS, MSG, advisorOf, agentsDir, applyModels, clearScope, driftCh
|
|
|
9
9
|
import { AGENT_FILES, FLOW_COMMAND_PATH, FLOW_SKILL_PATH, SKILL_MARK, guidancePaths, syncFlowSkill, syncGuidance } from './skill.js';
|
|
10
10
|
import { findConflicts } from './conflicts.js';
|
|
11
11
|
import { FLOW_DIR } from './flow.js';
|
|
12
|
+
import { TEST_FILE } from './tests.js';
|
|
12
13
|
const START = '# >>> YOUR CTO JEV START >>>';
|
|
13
14
|
const END = '# <<< YOUR CTO JEV END <<<';
|
|
14
15
|
// Keep the block minimal: all logic (including the git diff call) lives in the package, so npm update upgrades every repo.
|
|
@@ -506,7 +507,14 @@ export function setup(cwd, lang, opts = {}) {
|
|
|
506
507
|
let goal = '';
|
|
507
508
|
if (!existsSync(cfgPath)) {
|
|
508
509
|
// Thresholds are left out on purpose: the package defaults apply and improve with each release. Add only overrides.
|
|
509
|
-
|
|
510
|
+
// A new project starts as a prototype (CONCEPT: 專案分兩個階段). New = flow on and no tracked test file yet.
|
|
511
|
+
let tracked = [];
|
|
512
|
+
try {
|
|
513
|
+
tracked = git(root, 'ls-files', '-z').split('\0');
|
|
514
|
+
}
|
|
515
|
+
catch { /* not a git repo yet: nothing tracked */ }
|
|
516
|
+
const fresh = flow && !tracked.some((f) => TEST_FILE.test(f));
|
|
517
|
+
writeFileSync(cfgPath, JSON.stringify({ sprint_goal: '', ...(fresh ? { stage: 'prototype' } : {}), thresholds: {} }, null, 2) + '\n');
|
|
510
518
|
lines.push(t(lang, 'setup_config'));
|
|
511
519
|
}
|
|
512
520
|
else {
|
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.
|
|
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.
|
|
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.\`
|
|
@@ -275,6 +275,15 @@ Two more tags, on any task:
|
|
|
275
275
|
驗收: npx playwright test e2e/customers/tier.spec.ts
|
|
276
276
|
\`\`\`
|
|
277
277
|
|
|
278
|
+
## Stage
|
|
279
|
+
|
|
280
|
+
\`cto brief\` shows \`Stage prototype\` when \`.cto.json\` has \`"stage": "prototype"\` (\`cto setup\` writes it for a new project); without it the stage is \`build\`. In prototype, these rules take precedence over the rest of this skill:
|
|
281
|
+
- The goal is an app the user can try. Plan and run the main path first, from the first screen to the result the product promises, before anything else is hardened.
|
|
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
|
+
- 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
|
+
- Every \`cto-reviewer\` dispatch prompt says \`stage: prototype\`. Wrong behavior, security holes, secrets and data loss are still P1.
|
|
285
|
+
- 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"\` and plan the tests the main path needs.
|
|
286
|
+
|
|
278
287
|
## cto-jev work
|
|
279
288
|
|
|
280
289
|
**When:** the user says "cto-jev work" or "continue", or \`cto brief\` shows Ready tasks.
|
|
@@ -287,7 +296,7 @@ Every wave, one after another, until nothing is Ready. Do not ask before a wave
|
|
|
287
296
|
2. One sub-agent per task. Give it only: the task line, the feature's SPEC.md, the \`## Interface\` of each feature it depends on, the list of files it may touch, and "do not edit anything else, write nothing outside this repo (no notes, no lesson logs), no git commands, run only your task's acceptance command and the test file you wrote, never a whole test suite (other agents run tests at the same time, and whole suites can share one test database); report what you changed and what you found ambiguous". Each sub-agent writes its own new test file; nobody appends to a shared one. A task accepted by an end-to-end test also gets the Acceptance lines it covers: the test is written from them first and seen failing, then the code.
|
|
288
297
|
3. When they return: \`git status\`; revert anything outside the union of their \`(files:)\`. Integrate the shared files yourself. Fix any existing test their change broke. A sub-agent's "the SPEC does not say" goes into the SPEC now, not into the code's comments.
|
|
289
298
|
4. Accept by running the task's acceptance command yourself; never trust the report. Tick only on a pass. A wave runs only its own tasks' acceptance commands plus the end-to-end tests of the features it touches (\`e2e/<slug>/\`); when it changes a \`platform\` file or a shared file you integrated (step 3), run the whole end-to-end suite instead. The whole unit and end-to-end suites run once in a feature's cleanup wave and once in the release, never in every wave. Like a wave that changes a \`platform\` or shared file, a wave that touches a feature whose end-to-end tests are not yet in \`e2e/<slug>/\` runs the whole end-to-end suite. When \`cto brief\` lists test files outside every feature folder (in the \`e2e/\` root or a flat folder such as \`e2e/tests/\`), do not move them on your own: put "split the end-to-end tests into feature folders?" in the run's final report menu, with how many files and how long the whole suite takes. If the user says yes, add a \`platform\` task for the split whose text starts exactly \`Split the end-to-end tests into feature folders\`, in English whatever language the rest of TASKS.md uses (brief knows it by that text and stops asking while it is open), tagged \`(seq)\`, whose \`(files:)\` hold \`e2e/\` plus each file that holds the test runner's file pattern (\`playwright.config.ts\`, \`package.json\`); it runs as a wave of its own, reviewed and committed alone. The split goes test by test, not file by file: a test goes into the folder of the feature whose task ids or Acceptance scenario it tests; a test that walks through several features goes to the feature whose SPEC holds its scenario; a check of the whole app (smoke, error page, layout of every page, the test harness) goes to \`e2e/platform/\`; shared helpers stay in the root. Update imports, the test runner's file pattern (a root-only glob such as \`e2e/*.test.ts\` finds nothing in subfolders) and open tasks' acceptance paths; the whole end-to-end suite must pass with as many tests as before. If the user says no, set \`"e2e_folders": false\` in \`.cto.json\`: brief stops listing them, and every wave keeps running the whole end-to-end suite. A failing end-to-end test means the code is wrong. If you think the expectation is wrong instead, the CONCEPT decides: where it backs the scenario, the code is wrong after all; where it says otherwise, fix the SPEC's Acceptance first, then the test, and note it in the wave's REVIEW.md entry; where it is silent, do the same and add an \`Assumed: ...\` line. Never change a test to match the code without changing the Acceptance line it came from. \`manual\` does not wait for the user: build it, run what can be run, take screenshots at each width the Acceptance names, and tick it. cto reminds the user with the text on its acceptance line, and your final report lists every manual task of the run with that text and the screenshot paths. A task the user decided not to do: add \`(dropped: <reason>)\` to its line, tick it, and say "<id> dropped" in your final message. Dropping is the user's call: a task you think is no longer needed (what it checks is gone) is parked and listed in your report with that reason, never dropped by you; never drop a task to get past a block. A dropped task counts as closed, so the tasks that wait on it (\`(after:)\`) become Ready: drop or re-plan them first. Tick the parent when its last child is ticked.
|
|
290
|
-
5. **Review before you commit.** Before dispatching, run the project's formatter, if any, so the review sees the final tree. Then dispatch \`subagent_type: "cto-reviewer"\` with no model parameter (it runs on Opus), with none of your context: it reads the feature's CONCEPT.md and SPEC.md and the whole uncommitted change of the wave, and returns findings each marked P1 (wrong, unsafe, breaks a Constraint or the Interface, does something the CONCEPT does not say or contradicts, or an acceptance test that would still pass with its scenario broken), P2 (should improve, can wait) or P3 (minor). You wrote both the code and its tests, so the reviewer answers one question per acceptance test: if the scenario were not met, would this test fail. Handle them as under "Review findings": fix every P1 now and re-run acceptance; write every P2 and P3 as a task with its severity (\`(P2)\`, \`(P3)\`) in TASKS.md whose text starts with exactly \`Review finding (wave <ids>):\`, in English whatever language the rest of TASKS.md uses. A cleanup wave's review is the exception: its P2s and P3s become no task and go under \`Left for the user:\` instead (see "Review findings"). Append one entry to REVIEW.md: date, scope (the task ids of the wave), how many P1/P2, which task ids they became, what was contested or escalated. The dispatch prompt names the wave's task ids, every changed path, and the acceptance commands you ran with their results (the reviewer runs no whole suite, so it is never asked to run the verify command from \`cto brief\`); it never dictates the verdict and never drops a changed path. After fixing P1s, run the formatter again before every re-dispatch; then dispatch again on the whole change, never on the fix alone. Where Claude Code is wired and the review gate is on, only a Claude Code session can satisfy the gate, so other agents (with or without sub-agents) hand the wave over as below.
|
|
299
|
+
5. **Review before you commit.** Before dispatching, run the project's formatter, if any, so the review sees the final tree. Then dispatch \`subagent_type: "cto-reviewer"\` with no model parameter (it runs on Opus), with none of your context: it reads the feature's CONCEPT.md and SPEC.md and the whole uncommitted change of the wave, and returns findings each marked P1 (wrong, unsafe, breaks a Constraint or the Interface, does something the CONCEPT does not say or contradicts, or an acceptance test that would still pass with its scenario broken), P2 (should improve, can wait) or P3 (minor). You wrote both the code and its tests, so the reviewer answers one question per acceptance test: if the scenario were not met, would this test fail. Handle them as under "Review findings": fix every P1 now and re-run acceptance; write every P2 and P3 as a task with its severity (\`(P2)\`, \`(P3)\`) in TASKS.md whose text starts with exactly \`Review finding (wave <ids>):\`, in English whatever language the rest of TASKS.md uses. A cleanup wave's review is the exception: its P2s and P3s become no task and go under \`Left for the user:\` instead (see "Review findings"). Append one entry to REVIEW.md: date, scope (the task ids of the wave), how many P1/P2, which task ids they became, what was contested or escalated. The dispatch prompt names the wave's task ids, \`stage: prototype\` when brief shows it, every changed path, and the acceptance commands you ran with their results (the reviewer runs no whole suite, so it is never asked to run the verify command from \`cto brief\`); it never dictates the verdict and never drops a changed path. After fixing P1s, run the formatter again before every re-dispatch; then dispatch again on the whole change, never on the fix alone. Where Claude Code is wired and the review gate is on, only a Claude Code session can satisfy the gate, so other agents (with or without sub-agents) hand the wave over as below.
|
|
291
300
|
6. \`cto check\`, then commit the wave to the review branch. A review with no P1 left to fix (none found, or every one contested or escalated in REVIEW.md) is committed as it stands: change no code between it and the commit (REVIEW.md and TASKS.md are not code), since a change to any file the gate counts as code makes it ask for another whole review. A P2 or P3 is a task (in a cleanup wave, a line under \`Left for the user:\`), never a fix made now. Only when \`cto check\` or a git hook blocks the commit and its fix changes code is the whole change reviewed again; that review counts toward the three rounds under "Review findings". The same holds for fixes made in conversation (the user reports a bug and you fix it on the spot): give them a task line with an acceptance command as in step 1, then review and commit them before the user moves on to other work, not at the next run.
|
|
292
301
|
|
|
293
302
|
Without sub-agents: do the Ready tasks yourself in brief's order, one at a time, accepting each before the next; review your own diff against the SPEC before each commit. That is not a review by a fresh reader: write \`self-review\` in its REVIEW.md entry, so the release review looks harder at those waves. Where Claude Code is wired and the review gate is on, a self-review cannot pass the commit gate (the gate needs a cto-reviewer review of the exact tree): keep the wave's tasks ticked, leave the tree uncommitted, stop the run, and say in the final report that the wave is waiting for a cto-reviewer review in a Claude Code session.
|
|
@@ -347,6 +356,8 @@ Whatever the row, one rule holds: the branch that reaches users receives nothing
|
|
|
347
356
|
|
|
348
357
|
**Stop:** before the merge, with the P1/P2/P3 lists in front of the user.
|
|
349
358
|
|
|
359
|
+
**After the user merges:** \`git fetch --prune\`, then delete every local branch that \`git branch --merged <release branch>\` lists, except the release branch, the integration branch and the deploy branches (\`git branch -d\`, which refuses an unmerged one). 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
|
+
|
|
350
361
|
## cto-jev docs
|
|
351
362
|
|
|
352
363
|
**When:** the user says "cto-jev docs", before opening a feature, or when the user asks to tidy the repo.
|
package/dist/tests.js
CHANGED
|
@@ -13,7 +13,7 @@ const UNTRACED_MIN = 0.6;
|
|
|
13
13
|
const REPEATS_MIN = 0.6;
|
|
14
14
|
const PART_TOKENS = 7000; // a test file; two of them for a pair
|
|
15
15
|
const SPEC_TOKENS = 12000; // with a test file, inside Jev's 24k chunk
|
|
16
|
-
const TEST_FILE = /\.(test|spec|cy)\.[cm]?[jt]sx?$/;
|
|
16
|
+
export const TEST_FILE = /\.(test|spec|cy)\.[cm]?[jt]sx?$/;
|
|
17
17
|
const UNTRACED = {
|
|
18
18
|
untraced: { type: 'noul', instructions: 'Do several tests in this test file check behaviour that no line of this SPEC (Interface, Constraints, Acceptance) asks for?' },
|
|
19
19
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "your-cto-jev",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.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",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"access": "public"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@clack/core": "1.
|
|
53
|
-
"@clack/prompts": "1.
|
|
52
|
+
"@clack/core": "1.6.0",
|
|
53
|
+
"@clack/prompts": "1.9.0"
|
|
54
54
|
}
|
|
55
55
|
}
|