your-cto-jev 0.21.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 CHANGED
@@ -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, dead `(files:)` paths, `src/` directories owned by no feature, missing headings | `cto brief`, `cto doctor` | Listed |
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 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.
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.
@@ -392,14 +392,14 @@ Nothing else is uploaded, and nothing is logged unless you set `CTO_DEBUG=1`. Th
392
392
  }
393
393
  ```
394
394
 
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.
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).
396
396
 
397
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.
398
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.
399
399
  - **`test_command`**: what `cto brief` tells the agent to verify with, for example `"pnpm test"`. Detected from the project when empty.
400
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.
401
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.
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. 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.
403
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.
404
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).
405
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/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`,
@@ -366,6 +367,7 @@ const messages = {
366
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.`,
367
368
  signoff_done: (v) => `[cto] Signed off: ${v.detail}`,
368
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',
369
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',
370
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',
371
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`,
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
- /** Terminal columns: CJK and full-width characters take two. */
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
@@ -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
- - 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.
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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "your-cto-jev",
3
- "version": "0.21.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",