your-cto-jev 0.10.1 → 0.11.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 +14 -8
- package/dist/brain.js +1 -0
- package/dist/check.js +2 -1
- package/dist/flow.js +5 -1
- package/dist/hooks.js +49 -6
- package/dist/i18n.js +8 -2
- package/dist/signoff.js +1 -1
- package/dist/skill.js +20 -16
- package/dist/turn.js +31 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -37,11 +37,12 @@ Jev judges meaning and answers with probabilities, not prose. It costs about $0.
|
|
|
37
37
|
| `done_unverified` | an agent ending a turn that edited code or checked off plan items | **Sends it back to work** until the change is verified or the gap is disclosed |
|
|
38
38
|
| `architecture_violation` | `git commit`, once you set a sprint goal, or when the [development flow](#the-development-flow-optional) maps the commit to a feature's SPEC | Warns only |
|
|
39
39
|
| `architecture_undocumented` | `git commit` under the development flow, when code changes and no decision record is added | Warns only |
|
|
40
|
+
| `manual_measurable` | `git commit` under the development flow, when it adds a task accepted `manual` that a script could check instead | Warns only |
|
|
40
41
|
| `code_complexity` | every `git commit` | Warns only |
|
|
41
42
|
|
|
42
43
|
`test_tampering` catches the classic agent shortcut: making a red test green by skipping it, deleting its assertions, loosening the expectation, or lowering the coverage bar, instead of fixing the code. It lets through real fixes, new or tighter tests, refactors, and tests removed together with their feature.
|
|
43
44
|
|
|
44
|
-
`done_unverified` catches the other classic shortcut: "Done, all tests pass!" when nothing ran after the last edit, the last run failed, or the claim is not backed by anything the agent actually did. It lets through turns that ran a passing check after the last edit, turns that changed only docs or CI config, and turns where the agent honestly says what it could not verify. Checked-off items count even when the agent committed them in the same turn. For a task with an acceptance line (`accept:` or `驗收:`), cto itself works out whether that exact command ran and passed after the last edit and tells Jev, and a `manual` task ticked without the final message saying the user accepted it is sent back without asking Jev at all. It blocks at most once per stop, so it cannot loop.
|
|
45
|
+
`done_unverified` catches the other classic shortcut: "Done, all tests pass!" when nothing ran after the last edit, the last run failed, or the claim is not backed by anything the agent actually did. It lets through turns that ran a passing check after the last edit, turns that changed only docs or CI config, and turns where the agent honestly says what it could not verify. Checked-off items count even when the agent committed them in the same turn. For a task with an acceptance line (`accept:` or `驗收:`), cto itself works out whether that exact command ran and passed after the last edit and tells Jev, and a `manual` task ticked without the final message saying the user accepted it (or a `(dropped: ...)` task the final message does not report as dropped) is sent back without asking Jev at all. It blocks at most once per stop, so it cannot loop.
|
|
45
46
|
|
|
46
47
|
Checking off a plan item is the same claim. Whatever planning tool you use (spec-kit, GSD, Kiro, specOS, a hand-written `TODO.md`), plans end up as markdown checklists, so `cto` reads the uncommitted `- [ ]` to `- [x]` changes in tracked `.md` files and asks whether the turn backs them up. A phase or parent item counts as backed when everything nested under it is checked, or when the turn ran a passing check that covers it. Each tick is judged once. A turn that only ticks boxes, without doing the work, is checked too.
|
|
47
48
|
|
|
@@ -168,6 +169,7 @@ The rules also tell the agent to run `cto check` before committing, and never to
|
|
|
168
169
|
test_tampering 0.03 blocks above 0.8 ok
|
|
169
170
|
architecture_violation not checked: no sprint_goal in .cto.json and no feature Constraints for these files
|
|
170
171
|
architecture_undocumented not checked: no docs/cto_jev/ flow, or this commit adds a decision record
|
|
172
|
+
manual_measurable not checked: this commit adds no task accepted manually
|
|
171
173
|
code_complexity 2.02 warns above 2 would warn
|
|
172
174
|
[cto] Good to commit.
|
|
173
175
|
```
|
|
@@ -217,7 +219,7 @@ docs/cto_jev/
|
|
|
217
219
|
decisions/NNNN-<slug>.md decision records, append-only
|
|
218
220
|
features/<slug>/
|
|
219
221
|
CONCEPT.md why: purpose, business rules, non-goals
|
|
220
|
-
SPEC.md how: ## Interface (what other features may use), ## Constraints, ## Internals
|
|
222
|
+
SPEC.md how: ## Interface (what other features may use), ## Constraints, ## Acceptance, ## Internals
|
|
221
223
|
TASKS.md the only state: a checklist with ids, dependencies and an acceptance command
|
|
222
224
|
REVIEW.md what a zero-context reviewer found, and which tasks it became
|
|
223
225
|
```
|
|
@@ -228,22 +230,26 @@ A task is one checklist line, and everything else is computed from it:
|
|
|
228
230
|
- [ ] CUST-1 Customer list
|
|
229
231
|
- [x] CUST-1.1 List API, filtered by role (after: PERM-2) (files: src/customers/api/)
|
|
230
232
|
accept: npm test -- customers/api
|
|
231
|
-
- [ ] CUST-1.2 List UI (after: CUST-1.1) (files: src/customers/ui/)
|
|
233
|
+
- [ ] CUST-1.2 List UI (after: CUST-1.1) (files: src/customers/ui/, e2e/customers.spec.ts)
|
|
234
|
+
accept: npx playwright test e2e/customers.spec.ts
|
|
235
|
+
- [ ] CUST-1.3 List matches the brand (look) (after: CUST-1.2) (files: src/customers/ui/)
|
|
232
236
|
accept: manual
|
|
233
237
|
```
|
|
234
238
|
|
|
239
|
+
You confirm what is expected, not what was built. A SPEC's `## Acceptance` lists each scenario as steps and a result a script can compare ("at 375px wide: no horizontal scroll"), and it is signed with the SPEC, so the agent cannot quietly change it. A task you would see is accepted by the end-to-end test written from those lines before the code; if the agent thinks an expectation is wrong, it asks you and changes the SPEC, not the test. `manual` is left for taste (does it look right, does it match the brand), and the agent shows you screenshots at each width before you say yes. A task that will not be done is closed with `(dropped: <reason>)` on its line, and the agent must say "<id> dropped" in its final message.
|
|
240
|
+
|
|
235
241
|
`(after:)` says what must be ticked first, across features too; `(files:)` says what the task changes. Two optional tags: `(P1)`/`(P2)`/`(P3)` for priority (P1 first and nothing releases while one is open; no tag means P2; P3 last) and `(seq)` for a task that must run alone (migrations, shared types). From that, `cto brief` lists what is ready in priority order, what can run at the same time (no overlapping files, not `(seq)`), what is blocked and on whom:
|
|
236
242
|
|
|
237
243
|
```text
|
|
238
244
|
Features · 2 · 1 active · 1 planned · sign-off pending: billing (spec draft)
|
|
239
245
|
|
|
240
246
|
Ready · 3 (run together: CUST-1.2, PERM-3)
|
|
241
|
-
CUST-1.2 P1 List UI files src/customers/ui/ accept:
|
|
247
|
+
CUST-1.2 P1 List UI files src/customers/ui/, e2e/customers.spec.ts accept: npx playwright test e2e/customers.spec.ts
|
|
242
248
|
PERM-3 Role cache files src/auth/cache/ accept: npm test -- auth
|
|
243
|
-
CUST-2 Export files src/customers/ accept:
|
|
249
|
+
CUST-2 Export files src/customers/ accept: npm test -- export (overlaps CUST-1.2: run after)
|
|
244
250
|
|
|
245
251
|
Blocked · 1
|
|
246
|
-
CUST-1.
|
|
252
|
+
CUST-1.4 Shared types waiting on PERM-9 (missing), CUST-1.2
|
|
247
253
|
```
|
|
248
254
|
|
|
249
255
|
The skill gives the agent seven named jobs, so they cannot be confused with another skill's steps. In Claude Code type `/cto-jev <job>` (for example `/cto-jev init`); bare `/cto-jev` runs `cto brief` and names the job to run next. In other agents say the name, for example "cto-jev init" (Codex also takes `$cto-jev`):
|
|
@@ -251,7 +257,7 @@ The skill gives the agent seven named jobs, so they cannot be confused with anot
|
|
|
251
257
|
| Say | The agent |
|
|
252
258
|
|---|---|
|
|
253
259
|
| `cto-jev init` | scans the repo, fills PRODUCT.md and ARCHITECTURE.md, asks you the rest a few questions at a time, walks you through the result until you say it is complete |
|
|
254
|
-
| `cto-jev feature` | talks the request through first (who it is for, business rules, what is out of scope, the simpler option it rejected, data migration and rollback, what other features may call, how a production failure gets noticed,
|
|
260
|
+
| `cto-jev feature` | talks the request through first (who it is for, business rules, what is out of scope, the simpler option it rejected, data migration and rollback, what other features may call, how a production failure gets noticed, the acceptance scenarios you will confirm), writes CONCEPT and SPEC, has a zero-context reviewer check that a newcomer could build from them without making design decisions, that nothing unneeded or already in the code gets built and that every acceptance scenario has a result a script can check, walks you through them, hands them over with a [Review handoff](#sign-off) and stops for your sign-off |
|
|
255
261
|
| `cto-jev tasks` | breaks an approved SPEC into parent/child tasks with files, dependencies and an acceptance command each |
|
|
256
262
|
| `cto-jev work` | dispatches Ready tasks to sub-agents with the narrowest brief, runs each acceptance command itself before ticking, has a zero-context reviewer read the diff **before every commit**: P1 findings are fixed first (and only the fixes reviewed again, at most three rounds in all; P1s left after that go to you), P2 findings become tasks, a finding is contested only with evidence the reviewer could read, then it commits that one wave to the review branch and stops |
|
|
257
263
|
| `cto-jev work all` | for a new project or a big batch: runs every wave in one go, fixes failing acceptance along the way, parks (does not stop for) tasks that need you, then one zero-context review of everything it did with P1s fixed; ends with one report of what is done and every question for you. Never releases |
|
|
@@ -375,7 +381,7 @@ Nothing else is uploaded, and nothing is logged unless you set `CTO_DEBUG=1`. Th
|
|
|
375
381
|
}
|
|
376
382
|
```
|
|
377
383
|
|
|
378
|
-
Defaults: `credential_leak` 0.5, `destructive_command` 0.7, `infinite_loop` 0.6, `test_tampering` 0.8, `done_unverified` 0.6, `architecture_violation` 0.85, `architecture_undocumented` 0.85, `code_complexity` 2.
|
|
384
|
+
Defaults: `credential_leak` 0.5, `destructive_command` 0.7, `infinite_loop` 0.6, `test_tampering` 0.8, `done_unverified` 0.6, `architecture_violation` 0.85, `architecture_undocumented` 0.85, `manual_measurable` 0.85 (not calibrated yet), `code_complexity` 2.
|
|
379
385
|
|
|
380
386
|
- **`sprint_goal`**: fill it in to enable the architecture check, for example `"Ship Stripe billing, no new services"`. Under the development flow a commit that falls inside a feature's code scope is judged against that feature's SPEC instead; the goal is the fallback.
|
|
381
387
|
- **`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.
|
package/dist/brain.js
CHANGED
|
@@ -17,6 +17,7 @@ export const DEFAULT_CONFIG = {
|
|
|
17
17
|
infinite_loop: 0.6,
|
|
18
18
|
architecture_violation: 0.85,
|
|
19
19
|
architecture_undocumented: 0.85,
|
|
20
|
+
manual_measurable: 0.85, // not calibrated yet; warns only
|
|
20
21
|
test_tampering: 0.8,
|
|
21
22
|
done_unverified: 0.6,
|
|
22
23
|
signoff_approved: SIGNOFF_FLOOR,
|
package/dist/check.js
CHANGED
|
@@ -52,7 +52,8 @@ export async function runCheck(root, lang, base) {
|
|
|
52
52
|
const v = review.scores[s];
|
|
53
53
|
const name = s.padEnd(width);
|
|
54
54
|
if (v === undefined) {
|
|
55
|
-
|
|
55
|
+
// Asked but unanswered means the request failed, not that the question did not apply.
|
|
56
|
+
const why = review.asked.has(s) ? 'check_why_failed' : s === 'test_tampering' ? 'check_why_tests' : s === 'architecture_violation' ? 'check_why_goal' : s === 'architecture_undocumented' ? 'check_why_adr' : s === 'manual_measurable' ? 'check_why_manual' : s === 'code_complexity' && base ? 'check_why_release' : 'check_why_failed';
|
|
56
57
|
lines.push(` ${name} ${t(lang, why)}`);
|
|
57
58
|
continue;
|
|
58
59
|
}
|
package/dist/flow.js
CHANGED
|
@@ -126,7 +126,11 @@ catch {
|
|
|
126
126
|
return undefined;
|
|
127
127
|
} };
|
|
128
128
|
/** A sign-off doc's state: the first `Status: draft|approved` line (any case); no such line is 'missing'. */
|
|
129
|
-
|
|
129
|
+
// Blanks on a Status line: space, tab, or the no-break space some editors and IMEs type; never a line break.
|
|
130
|
+
const SP = '[ \\t\\u00a0]';
|
|
131
|
+
export const docStatus = (text) => new RegExp(`^Status:${SP}*(draft|approved)${SP}*\\r?$`, 'im').exec(text)?.[1]?.toLowerCase() ?? 'missing';
|
|
132
|
+
/** `text` with its first `Status: <from>` line set to `to`, keeping the blanks and line ending. */
|
|
133
|
+
export const setStatus = (text, from, to) => text.replace(new RegExp(`^(Status:${SP}*)${from}(?=${SP}*\\r?$)`, 'im'), `$1${to}`);
|
|
130
134
|
const signoff = (path) => docStatus(readOr(path) ?? '');
|
|
131
135
|
function purpose(concept) {
|
|
132
136
|
const lines = concept.split(/\r?\n/);
|
package/dist/hooks.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { execFileSync } from 'node:child_process';
|
|
2
2
|
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
3
3
|
import { join } from 'node:path';
|
|
4
|
-
import { FLOW_DIR, docStatus, featureIndex, listFeatures } from './flow.js';
|
|
4
|
+
import { FLOW_DIR, docStatus, featureIndex, listFeatures, setStatus } from './flow.js';
|
|
5
5
|
import { styleText } from 'node:util';
|
|
6
6
|
import { checkUpdate, currentVersion } from './update.js';
|
|
7
7
|
import { promptOutput } from './agents.js';
|
|
8
|
-
import { isCodeFile, manualUnconfirmed, reviewMessage, tickedItems, tickedKey, turnActions, turnState } from './turn.js';
|
|
8
|
+
import { ACCEPT, BOX, isCodeFile, isDropped, manualUnconfirmed, taskName, reviewMessage, tickedItems, tickedKey, turnActions, turnState } from './turn.js';
|
|
9
9
|
import { shellWrites } from './shellwrites.js';
|
|
10
10
|
import { afterEdit, guardVerdict, powershellHitsSignoffDoc, reviewPaths, shellWritesSignoffDoc, signoffDoc, signoffState } from './signoff.js';
|
|
11
11
|
import { evaluate, providerOrder, providers } from './api.js';
|
|
@@ -190,6 +190,46 @@ export function adrQuestion(root, paths) {
|
|
|
190
190
|
criteria: { true: 'Changes the architecture or breaks a listed principle; a decision record is missing', false: 'Ordinary feature, fix, library import or version bump within the existing architecture' },
|
|
191
191
|
};
|
|
192
192
|
}
|
|
193
|
+
/**
|
|
194
|
+
* New `manual` tasks in a flow TASKS.md: an added task line followed by an added `驗收: manual` line. Manual is for
|
|
195
|
+
* what only taste can judge; ask whether a script could accept any of them instead. Undefined when none were added.
|
|
196
|
+
*/
|
|
197
|
+
export function manualQuestion(files) {
|
|
198
|
+
const tasks = [];
|
|
199
|
+
for (const f of files) {
|
|
200
|
+
if (!/^diff --git a\/.+? b\/docs\/cto_jev\/features\/[^/]+\/TASKS\.md$/m.test(f))
|
|
201
|
+
continue;
|
|
202
|
+
// The task above an added `manual` line, whether the task line itself is added or unchanged context: switching an
|
|
203
|
+
// existing task from a command to manual is the change worth asking about.
|
|
204
|
+
let last = '';
|
|
205
|
+
for (const line of f.split(/\r?\n/)) {
|
|
206
|
+
if (line.startsWith('+++') || line.startsWith('---') || line.startsWith('@@')) {
|
|
207
|
+
last = '';
|
|
208
|
+
continue;
|
|
209
|
+
}
|
|
210
|
+
const box = BOX.exec(line.slice(1));
|
|
211
|
+
if (box) {
|
|
212
|
+
last = line[0] === '-' ? '' : box[3].trim();
|
|
213
|
+
continue;
|
|
214
|
+
}
|
|
215
|
+
const acc = line[0] === '+' ? ACCEPT.exec(line.slice(1)) : null;
|
|
216
|
+
if (acc && last && /^manual\b/i.test(acc[1])) {
|
|
217
|
+
tasks.push(last);
|
|
218
|
+
last = '';
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
if (!tasks.length)
|
|
223
|
+
return undefined;
|
|
224
|
+
return {
|
|
225
|
+
type: 'noul',
|
|
226
|
+
instructions: `These new plan tasks are accepted manually, by a human looking at the result:\n${tasks.slice(0, 15).map((x) => `- ${x.slice(0, 200)}`).join('\n')}\n\n` +
|
|
227
|
+
'Manual acceptance is meant only for what taste must judge: whether it looks good, feels right or matches the brand. ' +
|
|
228
|
+
'Behaviour, text, sizes, layout at given screen widths, overflow and error messages can be checked by a script (an end-to-end or unit test). ' +
|
|
229
|
+
'Could at least one of these tasks be accepted by such a script instead?',
|
|
230
|
+
criteria: { true: 'At least one task describes something a script could check', false: 'Every task needs human taste to judge' },
|
|
231
|
+
};
|
|
232
|
+
}
|
|
193
233
|
const diffPaths = (files) => files.map((f) => /^diff --git a\/.+? b\/(.+)$/m.exec(f)?.[1]).filter((p) => !!p);
|
|
194
234
|
const value = (a) => (a?.type === 'noul' ? a.noul : a?.type === 'score' ? a.score : undefined);
|
|
195
235
|
function exceeded(answers, signal, cfg) {
|
|
@@ -262,6 +302,9 @@ export async function reviewDiff(rawDiff, cfg, brain, lang, now, hook = 'commit'
|
|
|
262
302
|
const adr = root ? adrQuestion(root, paths) : undefined;
|
|
263
303
|
if (adr)
|
|
264
304
|
soft.architecture_undocumented = adr;
|
|
305
|
+
const manual = root ? manualQuestion(files) : undefined;
|
|
306
|
+
if (manual)
|
|
307
|
+
soft.manual_measurable = manual;
|
|
265
308
|
const notices = new Set();
|
|
266
309
|
const asked = new Set();
|
|
267
310
|
const ctx = { brain, lang, timeoutMs: 5000, notices, now };
|
|
@@ -299,7 +342,7 @@ export async function reviewDiff(rawDiff, cfg, brain, lang, now, hook = 'commit'
|
|
|
299
342
|
return { files: files.length, scores, asked, failed: results.some((r) => !r.ok), noKeys, notices };
|
|
300
343
|
}
|
|
301
344
|
export const BLOCKING_COMMIT = ['credential_leak', 'test_tampering'];
|
|
302
|
-
export const WARNING_COMMIT = ['architecture_violation', 'architecture_undocumented', 'code_complexity'];
|
|
345
|
+
export const WARNING_COMMIT = ['architecture_violation', 'architecture_undocumented', 'manual_measurable', 'code_complexity'];
|
|
303
346
|
const over = (v, s, cfg) => v !== undefined && v > cfg.thresholds[s];
|
|
304
347
|
export const localLines = (lang, findings) => findings.map((f) => t(lang, `local_${f.kind}`, { detail: f.detail }));
|
|
305
348
|
export async function gitCommit(rawDiff, { root, lang, now }) {
|
|
@@ -441,7 +484,7 @@ export async function agentPre(agent, input, { root, lang, now }) {
|
|
|
441
484
|
// ---------- sign-off (Claude Code only) ----------
|
|
442
485
|
const SILENT = { code: 0, stderr: [] };
|
|
443
486
|
// Only the value of the first Status line changes; its line ending and everything else stay byte for byte.
|
|
444
|
-
const approve = (text) => text
|
|
487
|
+
const approve = (text) => setStatus(text, 'draft', 'approved');
|
|
445
488
|
/**
|
|
446
489
|
* The user's reply to a Review handoff: when Jev is sure it agrees to every listed draft doc, flip their Status to
|
|
447
490
|
* approved. Fails closed (no sign-off) on anything uncertain; never blocks the prompt.
|
|
@@ -474,7 +517,7 @@ function revertSelfSigned(root, sessionId) {
|
|
|
474
517
|
const reverted = [];
|
|
475
518
|
for (const f of approvedDocs(root).filter((f) => !baseline.includes(f))) {
|
|
476
519
|
try {
|
|
477
|
-
writeFileSync(join(root, f), readOr(join(root, f))
|
|
520
|
+
writeFileSync(join(root, f), setStatus(readOr(join(root, f)), 'approved', 'draft'));
|
|
478
521
|
reverted.push(f);
|
|
479
522
|
}
|
|
480
523
|
catch { /* fail open: the pre-commit check still requires sign-off */ }
|
|
@@ -600,7 +643,7 @@ export async function agentStop(agent, input, { root, lang, now }) {
|
|
|
600
643
|
// A manual task ticked without the user's confirmation is a text fact, not a judgement: cto blocks it itself. Jev
|
|
601
644
|
// still judges everything else in the turn, since this stop's block is the only one it gets.
|
|
602
645
|
const manual = manualUnconfirmed(ticked, lastMessage);
|
|
603
|
-
const manualLines = manual.slice(0, 5).map((m) => t(lang, 'done_manual', { detail: m.text.slice(0, 80) }));
|
|
646
|
+
const manualLines = manual.slice(0, 5).map((m) => t(lang, isDropped(m) ? 'done_dropped' : 'done_manual', { detail: m.text.slice(0, 80), id: taskName(m) }));
|
|
604
647
|
const rest = ticked.filter((x) => !manual.includes(x));
|
|
605
648
|
if (!rest.length && !actions.some((a) => a.kind === 'edit' && isCodeFile(a.file))) {
|
|
606
649
|
brain.blocked_attempts++;
|
package/dist/i18n.js
CHANGED
|
@@ -20,6 +20,7 @@ export const personaDict = {
|
|
|
20
20
|
infinite_loop: '同樣的錯誤又來了,你們在鬼打牆燒 Token。這次工具呼叫我擋下了,先去看邏輯。',
|
|
21
21
|
architecture_violation: '這次變更偏離了 Sprint 目標。我放你過,但這筆帳記著。',
|
|
22
22
|
architecture_undocumented: '這看起來改了架構,卻沒有決策紀錄。放你過,但去寫 docs/cto_jev/decisions/NNNN-<slug>.md。',
|
|
23
|
+
manual_measurable: '新加的 manual task 裡有能用腳本驗的東西(行為、文字、尺寸、版面)。放你過,但改成 e2e 測試當驗收指令,manual 只留給美感。',
|
|
23
24
|
test_tampering: '程式沒修好,倒先把測試改弱了?Commit 已攔下。去修程式,不是修測試。',
|
|
24
25
|
done_unverified: '說做完了?證據呢?最後一次改程式之後,我沒看到通過的測試或建置,或是你打勾的計畫項目沒有證據。先跑相關的檢查,看到通過再收工;真的跑不了,就老實告訴使用者哪些還沒驗證。',
|
|
25
26
|
signoff_approved: '使用者點頭了。Review 列的文件我替他簽核,之後要改受保護的內容,先改回 draft 再重發 Review。',
|
|
@@ -31,6 +32,7 @@ export const personaDict = {
|
|
|
31
32
|
infinite_loop: 'Same error again. You are looping and burning tokens. This tool call is BLOCKED. Fix the logic first.',
|
|
32
33
|
architecture_violation: 'This change drifts from the sprint goal. Letting it through, but I noticed.',
|
|
33
34
|
architecture_undocumented: 'This looks like an architecture change with no decision record. Letting it through, but write docs/cto_jev/decisions/NNNN-<slug>.md.',
|
|
35
|
+
manual_measurable: 'A new manual task describes something a script could check (behaviour, text, sizes, layout). Letting it through, but accept it with an end-to-end test; keep manual for taste.',
|
|
34
36
|
test_tampering: 'Weakening the tests instead of fixing the code? Commit BLOCKED. Fix the code, not the tests.',
|
|
35
37
|
done_unverified: 'Done, you say? Show me. Nothing passing ran after your last code change, or the plan items you checked off have no evidence. Run the relevant tests or build and see them pass before you stop; if you really cannot, tell the user plainly what is still unverified.',
|
|
36
38
|
signoff_approved: 'The user said yes. I signed off the docs on the Review line; to change protected content later, set them back to draft and resend Review.',
|
|
@@ -73,7 +75,8 @@ const messages = {
|
|
|
73
75
|
signoff_guard: () => '[cto] 簽核由使用者決定。要改已簽核的內容,先用 Edit 把 Status 改成 draft,改完用「請你看」格式交給使用者;shell 不能寫簽核文件,請用 Read/Edit/Write',
|
|
74
76
|
signoff_reverted: (v) => `[cto] 這一輪有簽核文件被改成 approved,但不是使用者簽的,已經改回 draft:${v.files}。只有使用者能簽核:用「請你看」格式(Review: 行)交給使用者`,
|
|
75
77
|
signoff_self_approve: () => '[cto] 簽核由使用者決定,只有使用者能把 Status 設成 approved。用「請你看」格式(Review: 行)交給使用者,等他回覆',
|
|
76
|
-
done_manual: (v) => `[cto] ${v.detail}:這是要使用者驗收的 task(manual
|
|
78
|
+
done_manual: (v) => `[cto] ${v.detail}:這是要使用者驗收的 task(manual),但你的最後訊息沒說使用者已經確認。先請使用者確認,確認後寫「${v.id} accepted manually」再打勾;還沒確認就取消打勾,列給使用者。`,
|
|
79
|
+
done_dropped: (v) => `[cto] ${v.detail}:這個 task 標了 dropped,但你的最後訊息沒寫「${v.id} dropped」。在最後訊息寫出放棄了哪個 task、為什麼,讓使用者看得到。`,
|
|
77
80
|
docs_none: () => 'docs/cto_jev/ 以外沒有過期的規劃文件。',
|
|
78
81
|
docs_group_delete: () => '刪除',
|
|
79
82
|
docs_group_merge: () => '併入某個 feature',
|
|
@@ -163,6 +166,7 @@ const messages = {
|
|
|
163
166
|
check_why_tests: () => '未檢查:沒有改到測試相關檔案',
|
|
164
167
|
check_why_goal: () => '未檢查:.cto.json 沒有 sprint_goal,這些檔案也沒對到任何 feature 的 Constraints',
|
|
165
168
|
check_why_adr: () => '未檢查:沒有 docs/cto_jev/ 流程、沒改到程式碼,或這次 commit 已新增決策紀錄',
|
|
169
|
+
check_why_manual: () => '未檢查:這次 commit 沒有新增 manual 驗收的 task',
|
|
166
170
|
check_why_release: () => '未檢查:整條分支不算複雜度,每次 commit 時已經看過',
|
|
167
171
|
check_why_failed: () => '未檢查:請求失敗',
|
|
168
172
|
check_limit_block: (v) => `超過 ${v.limit} 會擋下`,
|
|
@@ -267,7 +271,8 @@ const messages = {
|
|
|
267
271
|
signoff_guard: () => '[cto] Sign-off is the user\'s call. To change signed-off content, first use Edit to set Status to draft, then hand it to the user with a Review handoff. Shell commands cannot write sign-off docs: use Read, Edit or Write',
|
|
268
272
|
signoff_reverted: (v) => `[cto] A sign-off doc was set to approved this turn, but not by the user; it is back to draft: ${v.files}. Only the user signs off: hand it over with a Review handoff`,
|
|
269
273
|
signoff_self_approve: () => '[cto] Sign-off is the user\'s call: only the user can set Status to approved. Hand it to the user with a Review handoff and wait for their reply',
|
|
270
|
-
done_manual: (v) => `[cto] ${v.detail}: this task is accepted by the user (manual), but your final message does not say the user confirmed it. Ask the user; once they confirm, say "accepted manually" and tick it. Until then untick it and list it for them.`,
|
|
274
|
+
done_manual: (v) => `[cto] ${v.detail}: this task is accepted by the user (manual), but your final message does not say the user confirmed it. Ask the user; once they confirm, say "${v.id} accepted manually" and tick it. Until then untick it and list it for them.`,
|
|
275
|
+
done_dropped: (v) => `[cto] ${v.detail}: this task is marked dropped, but your final message does not say "${v.id} dropped". Say which task you dropped and why in your final message, so the user sees it.`,
|
|
271
276
|
docs_none: () => 'No stale planning documents outside docs/cto_jev/.',
|
|
272
277
|
docs_group_delete: () => 'Delete',
|
|
273
278
|
docs_group_merge: () => 'Merge into a feature',
|
|
@@ -357,6 +362,7 @@ const messages = {
|
|
|
357
362
|
check_why_tests: () => 'not checked: no test files changed',
|
|
358
363
|
check_why_goal: () => 'not checked: no sprint_goal in .cto.json and no feature Constraints for these files',
|
|
359
364
|
check_why_adr: () => 'not checked: no docs/cto_jev/ flow, no code changed, or this commit adds a decision record',
|
|
365
|
+
check_why_manual: () => 'not checked: this commit adds no task accepted manually',
|
|
360
366
|
check_why_release: () => 'not checked: a whole branch is not scored for complexity; each commit was',
|
|
361
367
|
check_why_failed: () => 'not checked: request failed',
|
|
362
368
|
check_limit_block: (v) => `blocks above ${v.limit}`,
|
package/dist/signoff.js
CHANGED
|
@@ -90,7 +90,7 @@ export function afterEdit(before, toolName, input) {
|
|
|
90
90
|
}
|
|
91
91
|
// CONCEPT/PRODUCT/ARCHITECTURE: everything but the Status line. SPEC: `## Interface` up to `## Internals`.
|
|
92
92
|
function protectedText(file, text) {
|
|
93
|
-
let lines = text.replace(/\r\n/g, '\n').split('\n').filter((l) =>
|
|
93
|
+
let lines = text.replace(/\r\n/g, '\n').split('\n').filter((l) => docStatus(l) === 'missing');
|
|
94
94
|
if (/(^|\/)spec\.md$/i.test(file.replace(/\\/g, '/'))) {
|
|
95
95
|
const start = lines.findIndex((l) => /^##\s+Interface\b/.test(l));
|
|
96
96
|
const end = lines.findIndex((l) => /^##\s+Internals\b/.test(l));
|
package/dist/skill.js
CHANGED
|
@@ -136,7 +136,7 @@ Data: which tables or stores change, whether old data migrates; "none" if nothin
|
|
|
136
136
|
- Only with another agent, after cto says it did not sign, or when the user asks how to approve: give this command with the real paths, for the user to type while you are not working (never run it yourself):
|
|
137
137
|
\`! sed -i 's/^Status: draft/Status: approved/' docs/cto_jev/features/<slug>/CONCEPT.md docs/cto_jev/features/<slug>/SPEC.md\`
|
|
138
138
|
- Approval covers what is written, \`Assumed:\` lines included. Partial agreement signs nothing: fix and resend \`Review:\`, or resend it with only the agreed files.
|
|
139
|
-
- You never set approved (in Claude Code cto blocks it). To change approved CONCEPT, PRODUCT or ARCHITECTURE content, or a SPEC's \`## Interface\` or \`##
|
|
139
|
+
- You never set approved (in Claude Code cto blocks it). To change approved CONCEPT, PRODUCT or ARCHITECTURE content, or a SPEC's \`## Interface\`, \`## Constraints\` or \`## Acceptance\`, first set \`Status: draft\` with the Edit tool, then make the change and resend \`Review:\`. A SPEC's \`## Internals\` stays editable after sign-off.
|
|
140
140
|
- Shell commands may not write CONCEPT, SPEC, PRODUCT or ARCHITECTURE under \`docs/cto_jev/\` (no \`cp\`, \`mv\`, \`sed -i\` or redirects); use the Read, Edit and Write tools.
|
|
141
141
|
|
|
142
142
|
## cto-jev init
|
|
@@ -155,7 +155,7 @@ This is a conversation, not a form. The files are done when the user says so, no
|
|
|
155
155
|
|
|
156
156
|
PRODUCT.md headings: \`## 一句話\`, \`## 使用者角色\`, \`## 怎麼賺錢\`, \`## 方案與限制\`, \`## 不做的事\`, \`## 設計約束\`.
|
|
157
157
|
ARCHITECTURE.md headings: \`## 技術棧\`, \`## 目錄地圖\`, \`## 外部服務與資料\`, \`## 驗證指令\`, \`## 不變的原則\`.
|
|
158
|
-
Short bullets or a table per heading. \`## 不做的事\` and \`## 不變的原則\` feed the drift checks: one rule per line.
|
|
158
|
+
Short bullets or a table per heading. \`## 不做的事\` and \`## 不變的原則\` feed the drift checks: one rule per line. In a repo with a UI, \`## 驗證指令\` names the end-to-end test command (Playwright or similar) that Acceptance scenarios run under, or says there is none yet; ask before adding one.
|
|
159
159
|
|
|
160
160
|
## cto-jev feature
|
|
161
161
|
|
|
@@ -164,21 +164,21 @@ Short bullets or a table per heading. \`## 不做的事\` and \`## 不變的原
|
|
|
164
164
|
1. Run \`cto-jev docs\` first when it has not run this session; bring its suggestions to the user before opening a feature.
|
|
165
165
|
2. Read \`docs/cto_jev/INDEX.md\` and classify:
|
|
166
166
|
- Inside an existing feature, within its Constraints: add tasks to its TASKS.md (\`cto-jev tasks\`). No new docs.
|
|
167
|
-
- Changes a feature's \`## Constraints\` or \`##
|
|
167
|
+
- Changes a feature's \`## Constraints\`, \`## Interface\` or \`## Acceptance\`: edit its SPEC.md, set \`Status: draft\`, run the docs review (step 5), stop for sign-off.
|
|
168
168
|
- A new module: \`features/<slug>/\` with the four files below.
|
|
169
|
-
- An existing module with no feature folder yet: create its folder describing what exists today (short CONCEPT, SPEC with the
|
|
169
|
+
- An existing module with no feature folder yet: create its folder describing what exists today (short CONCEPT, SPEC with its sections; Acceptance lists what the code does today), \`Status: draft\`, before any task on it.
|
|
170
170
|
- Infrastructure (CI, build, deploy, dependency upgrades): a task under \`features/platform/\`.
|
|
171
171
|
3. Talk before you write. Restate the request in two sentences and ask until every question below has an answer or an explicit "not relevant". At most five questions per message, each with your best guess; an installed interview skill may run the rounds, the questions below are what must be answered. Do not write CONCEPT.md until the first group is settled, nor SPEC.md until the second.
|
|
172
172
|
- For CONCEPT: who uses this and what changes for them; which business rules apply, including what happens on failure, limits, roles and paid tiers; what is explicitly out of scope; which existing features it touches; which simpler option was considered and why it was rejected (goes under \`## 動機\`).
|
|
173
|
-
- For SPEC: which data and tables change, and whether existing data must migrate and how it rolls back; what other features may call (the Interface) and what stays private; the error cases and what the user sees; how a failure in production gets noticed (migration, rollback and that go under \`## Internals\`); the hard rules the code must never break (the Constraints); how each part will be verified.
|
|
174
|
-
4. Write CONCEPT.md, then SPEC.md. Constraints are testable rules ("a refund always writes an audit row"), not aspirations. Interface is only what other features may call.
|
|
175
|
-
5. **Review the docs before the user does.** Dispatch a reviewer with none of your context, which may read and search the code. It reads CONCEPT.md and SPEC.md and answers
|
|
173
|
+
- For SPEC: which data and tables change, and whether existing data must migrate and how it rolls back; what other features may call (the Interface) and what stays private; the error cases and what the user sees; how a failure in production gets noticed (migration, rollback and that go under \`## Internals\`); the hard rules the code must never break (the Constraints); how each part will be verified, and for what the user sees, the acceptance scenarios (the Acceptance): the steps, the expected result a script can compare, and the screen widths. The user confirms what is expected here, so a check you write later compares against their answer, not your guess.
|
|
174
|
+
4. Write CONCEPT.md, then SPEC.md. Constraints are testable rules ("a refund always writes an audit row"), not aspirations. Interface is only what other features may call. Acceptance is one line per scenario, step → expected result, measurable ("at 375px wide: no horizontal scroll, Save visible without scrolling"; "empty email: 'Email required' under the field, nothing sent"), never "looks right". What only taste can judge (is it pleasing, does it match the brand) is one line marked \`(look)\`; that line becomes a \`manual\` task.
|
|
175
|
+
5. **Review the docs before the user does.** Dispatch a reviewer with none of your context, which may read and search the code. It reads CONCEPT.md and SPEC.md and answers four questions: could an engineer new to this repo build it from these two files without making a design decision; does it build something not needed now, or something the code already has; which business rules, error cases, roles/permissions or data cases are missing; and does every Acceptance scenario have an expected result a script can check (a vague one, or a \`(look)\` line that could be measured, is a finding). Findings are P1 or P2; handle them as under "Review findings" below, fixing both P1 and P2 in the docs now (the docs are cheap to change). A finding only the user can settle goes into the docs as \`Assumed: ...\` and into the handoff's "might be missing". Append one REVIEW.md entry: date, "docs", counts, what was contested or escalated.
|
|
176
176
|
6. Walk the user through both files section by section, including what the review changed, and ask what is wrong or missing. Edit, walk through again, until they have nothing to add.
|
|
177
177
|
|
|
178
178
|
**Stop:** when the user says the docs are complete: send a review handoff (see "Sign-off") for CONCEPT.md and SPEC.md. Never write TASKS.md before both CONCEPT and SPEC are approved; cto blocks the commit anyway.
|
|
179
179
|
|
|
180
180
|
CONCEPT.md: \`Status:\` line, then \`## 目的\` (one sentence), \`## 動機\`, \`## 商業規則\`, \`## 不做的事\`.
|
|
181
|
-
SPEC.md: \`Status:\` line, then \`## Interface\`, \`## Constraints\`, \`## Internals
|
|
181
|
+
SPEC.md: \`Status:\` line, then \`## Interface\`, \`## Constraints\`, \`## Acceptance\`, \`## Internals\`, in this order; keep Acceptance above Internals.
|
|
182
182
|
REVIEW.md: created empty with one line saying it is pending.
|
|
183
183
|
|
|
184
184
|
## cto-jev tasks
|
|
@@ -186,7 +186,7 @@ REVIEW.md: created empty with one line saying it is pending.
|
|
|
186
186
|
**When:** the user says "cto-jev tasks", or CONCEPT.md and SPEC.md are both \`Status: approved\` and TASKS.md is empty or the request adds work.
|
|
187
187
|
|
|
188
188
|
1. One parent per deliverable, children small enough for one sub-agent and one acceptance command.
|
|
189
|
-
2. Every child gets \`(files:)\` (the directories it changes, never bare \`src/\`), \`(after:)\` for anything that must be ticked first (across features too), and an acceptance line: a runnable command,
|
|
189
|
+
2. Every child gets \`(files:)\` (the directories it changes, never bare \`src/\`), \`(after:)\` for anything that must be ticked first (across features too), and an acceptance line: a runnable command. A task the user sees is accepted by the end-to-end test of the SPEC's Acceptance scenarios it covers (named in the task line), e.g. \`npx playwright test e2e/customers.spec.ts\`; driving a browser by hand is how you write that test, never how you accept. If ARCHITECTURE.md \`## 驗證指令\` names no end-to-end command, ask the user, and plan the harness as a \`(seq)\` task under \`features/platform/\` that the UI tasks wait on. \`manual\` only for a \`(look)\` line: what taste must judge, not sizes or behaviour a script can measure.
|
|
190
190
|
3. Shared files (route tables, shared types, migrations, a single test file, the CLI entry point) get their own sequential task; take them out of the other tasks' \`(files:)\`.
|
|
191
191
|
4. Run \`cto index\` and read \`cto brief\`: Ready should list the first wave; nothing should be Blocked on a missing id.
|
|
192
192
|
|
|
@@ -194,7 +194,9 @@ REVIEW.md: created empty with one line saying it is pending.
|
|
|
194
194
|
- [ ] CUST-1 Customer list
|
|
195
195
|
- [ ] CUST-1.1 List API, filtered by role (after: PERM-2) (files: src/customers/api/)
|
|
196
196
|
驗收: npm test -- customers/api
|
|
197
|
-
- [ ] CUST-1.2 List UI (after: CUST-1.1) (files: src/customers/ui/)
|
|
197
|
+
- [ ] CUST-1.2 List UI: Acceptance "filter by role", "375px no horizontal scroll" (after: CUST-1.1) (files: src/customers/ui/, e2e/customers.spec.ts)
|
|
198
|
+
驗收: npx playwright test e2e/customers.spec.ts
|
|
199
|
+
- [ ] CUST-1.3 List matches the brand (look) (after: CUST-1.2) (files: src/customers/ui/)
|
|
198
200
|
驗收: manual
|
|
199
201
|
\`\`\`
|
|
200
202
|
|
|
@@ -207,8 +209,8 @@ Two more tags, on any task:
|
|
|
207
209
|
\`\`\`md
|
|
208
210
|
- [ ] CUST-3 Add customer_tier column (P1) (seq) (files: db/migrations/)
|
|
209
211
|
驗收: npm run migrate:test
|
|
210
|
-
- [ ] CUST-4 Tier badge in the list (P3) (after: CUST-3) (files: src/customers/ui/)
|
|
211
|
-
驗收:
|
|
212
|
+
- [ ] CUST-4 Tier badge in the list (P3) (after: CUST-3) (files: src/customers/ui/, e2e/tier.spec.ts)
|
|
213
|
+
驗收: npx playwright test e2e/tier.spec.ts
|
|
212
214
|
\`\`\`
|
|
213
215
|
|
|
214
216
|
## cto-jev work
|
|
@@ -218,9 +220,9 @@ Two more tags, on any task:
|
|
|
218
220
|
Branches: work on an integration branch (\`review\`, or whatever the repo calls it; see the table under \`cto-jev release\`). The release branch only receives \`cto-jev release\`. Never commit to it directly; ask the user to add it to \`protected_branches\` in \`.cto.json\` if it is not there. The one exception is a repo with only \`main\` and one developer (the first row of that table): there you commit each reviewed wave to \`main\` (\`cto-jev work all\` uses a branch instead, below), and \`main\` stays out of \`protected_branches\`, or every commit would be blocked.
|
|
219
221
|
|
|
220
222
|
1. \`cto brief\`. Dispatch only Ready tasks; the "run together" set is safe to run at once. P1 tasks go first. Before dispatching, list what will run (the tasks, the files each changes, how each is accepted, the order) and wait for the user to say go.
|
|
221
|
-
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; report what you changed and what you found ambiguous". Each sub-agent writes its own new test file; nobody appends to a shared one.
|
|
223
|
+
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; 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.
|
|
222
224
|
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.
|
|
223
|
-
4. Accept by running the task's acceptance command yourself; never trust the report. Tick only on a pass. \`manual\` waits for the user to confirm in the conversation; say "accepted manually" when you tick it. Tick the parent when its last child is ticked.
|
|
225
|
+
4. Accept by running the task's acceptance command yourself; never trust the report. Tick only on a pass. A failing end-to-end test means the code is wrong; if you think the expectation is, that is the user's call: say so, and change it only in the SPEC's Acceptance (draft, \`Review:\`), then the test. \`manual\` waits for the user to confirm in the conversation: show them screenshots at each width the Acceptance names, so they judge from the picture; say "accepted manually" when you tick it. A task that will not be done (the user decided, or what it checks is gone): add \`(dropped: <reason>)\` to its line, tick it, and say "<id> dropped" in your final message. Never drop a task to get past a block or an unconfirmed \`manual\`. 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.
|
|
224
226
|
5. **Review before you commit.** Dispatch a reviewer with none of your context: it reads the feature's CONCEPT.md and SPEC.md and the uncommitted diff, and returns findings each marked P1 (wrong, unsafe, breaks a Constraint or the Interface) or P2 (should improve, can wait). Handle them as under "Review findings": fix every P1 now and re-run acceptance; write every P2 as a \`(P2)\` task in TASKS.md. 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.
|
|
225
227
|
6. \`cto check\`, then commit the wave to the review branch.
|
|
226
228
|
|
|
@@ -237,8 +239,10 @@ Without sub-agents: do the Ready tasks yourself in brief's order, one at a time,
|
|
|
237
239
|
2. Loop until no task is left to run: re-read \`cto brief\` and the TASKS.md files each round, then run steps 1 to 4 and step 6 of \`cto-jev work\` (dispatch, integrate, accept, commit) for the Ready tasks, skipping tasks you parked (below) and every task of a feature whose CONCEPT or SPEC is not \`Status: approved\` (cto blocks those commits; list the feature instead). There is no per-wave review: each wave's REVIEW.md entry says "work all, reviewed at the end". \`cto check\` and the git hooks still run on every commit. Without sub-agents, do the tasks yourself in brief's order; the end review is then a \`self-review\`.
|
|
238
240
|
3. Fix along the way: a failing acceptance or a broken test is yours to fix before moving on. The same failure twice means a different approach, not a third try.
|
|
239
241
|
4. Never stop for the user mid-run: park the task instead. Parked means unticked, never dispatched again in this run, and its dependants wait too (they are not Ready while it is unticked). The parked ids live only in this conversation; the final report lists them, and the next run starts without them. Park a task when:
|
|
240
|
-
- it needs a decision that would change a SPEC's \`## Interface\` or \`##
|
|
241
|
-
- it is \`manual\`: build it, run what can be run, and list it for the user to accept (do not tick it);
|
|
242
|
+
- it needs a decision that would change a SPEC's \`## Interface\`, \`## Constraints\` or \`## Acceptance\`. Do not edit those sections or the \`Status:\` line. A gap that only touches \`## Internals\` you decide yourself: add it under \`## Internals\` as \`Assumed: ...\` and leave \`Status:\` as it is;
|
|
243
|
+
- it is \`manual\`: build it, run what can be run, and list it for the user to accept with screenshots (do not tick it);
|
|
244
|
+
- its end-to-end test fails and you believe the expectation, not the code, is wrong;
|
|
245
|
+
- you think it should be dropped (never drop in this run; the user decides);
|
|
242
246
|
- it needs credentials, money, an outside account, or anything irreversible;
|
|
243
247
|
- it still fails after a second approach.
|
|
244
248
|
5. When no task is left to run, the review: a reviewer with none of your context reads \`git diff <start>..HEAD\` and the SPECs of every feature touched, findings P1/P2/P3, handled as under "Review findings" except that escalations and undecided contests go to the final report instead of stopping the run (a contested finding stays unfixed until the user decides). Fix every P1 (with re-reviews of the fixes, at most three rounds in all), write P2 and P3 as tasks, commit, and append one REVIEW.md entry: date, "work all", the task ids, counts.
|
package/dist/turn.js
CHANGED
|
@@ -182,13 +182,35 @@ function acceptOf(text, item) {
|
|
|
182
182
|
const squash = (s) => s.replace(/\s+/g, ' ').trim();
|
|
183
183
|
const MANUAL = /^manual\b/i;
|
|
184
184
|
const TASK_ID = /^[A-Z][A-Z0-9]*-\d+(?:\.\d+)*\b/;
|
|
185
|
-
|
|
185
|
+
const DROPPED = /[((]dropped[::]\s*[^))\s][^))]*[))]/i;
|
|
186
|
+
/** A task closed without doing it: `(dropped: reason)` on its line, then ticked. */
|
|
187
|
+
export const isDropped = (t) => DROPPED.test(t.text);
|
|
188
|
+
/** The task's id, or its first words when it has none: how messages name it. */
|
|
189
|
+
export const taskName = (t) => TASK_ID.exec(t.text)?.[0] ?? squash(t.text.replace(DROPPED, '')).slice(0, 30);
|
|
190
|
+
const esc = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
191
|
+
const ANY_ID = '[A-Z][A-Z0-9]*-\\d+(?:\\.\\d+)*';
|
|
192
|
+
// What may sit between a task's name and the phrase: other ids, list punctuation, markdown, and a few verbs. A "not",
|
|
193
|
+
// "never" or "n't" is none of these, so a negated report does not count, nor does one about the next task.
|
|
194
|
+
const JOIN = `(?:[ \\t,,、::*\`()()]|\\band\\b|和|與|${ANY_ID})*(?:\\b(?:was|were|is|are|has been|have been|both|now)\\s+)*`;
|
|
195
|
+
const LIST = `(?:[\\s,,、*\`()()-]|\\band\\b|${ANY_ID})*`;
|
|
196
|
+
/**
|
|
197
|
+
* The final message reports how this task closed: "accepted manually", or "dropped" for a dropped task. Either the
|
|
198
|
+
* task's name then the phrase ("A-1, A-2 accepted manually"), or the phrase then a list naming it ("Accepted
|
|
199
|
+
* manually:\n- A-1"). Reported in the message so the user sees every drop.
|
|
200
|
+
*/
|
|
186
201
|
function acceptedManually(t, lastMessage) {
|
|
187
202
|
const id = TASK_ID.exec(t.text)?.[0];
|
|
188
|
-
|
|
203
|
+
const word = isDropped(t) ? 'dropped' : 'accepted manually';
|
|
204
|
+
// The id as a whole token: "A-12" or "A-1.2" does not name A-1, while "A-1." at a sentence end does.
|
|
205
|
+
const me = id ? `(?<![\\w.-])${esc(id)}(?![\\w]|\\.\\d)` : esc(taskName(t));
|
|
206
|
+
return new RegExp(`${me}${JOIN}${word}`, 'i').test(lastMessage)
|
|
207
|
+
|| new RegExp(`(?<!\\bnot\\s|\\bnever\\s|n't\\s)${word}\\s*[::]${LIST}${me}`, 'i').test(lastMessage);
|
|
189
208
|
}
|
|
190
|
-
/**
|
|
191
|
-
|
|
209
|
+
/**
|
|
210
|
+
* Ticked `manual` tasks the final message does not report as accepted by the user, and dropped tasks it does not
|
|
211
|
+
* report as dropped: a text check, so no model judges it.
|
|
212
|
+
*/
|
|
213
|
+
export const manualUnconfirmed = (ticked, lastMessage) => ticked.filter((t) => (isDropped(t) || MANUAL.test(squash(t.accept ?? ''))) && !acceptedManually(t, lastMessage));
|
|
192
214
|
/** `cmd` run as a command of its own: at a command boundary, and not with its failure swallowed (`|| true`). */
|
|
193
215
|
const runsCommand = (command, cmd) => {
|
|
194
216
|
const esc = cmd.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
@@ -202,6 +224,11 @@ function acceptFacts(ticked, actions, lastEdit, lastMessage) {
|
|
|
202
224
|
const lines = ticked.filter((t) => t.accept).slice(0, 20).map((t) => {
|
|
203
225
|
const name = oneLine(t.text, 60);
|
|
204
226
|
const cmd = squash(t.accept);
|
|
227
|
+
if (isDropped(t)) {
|
|
228
|
+
return acceptedManually(t, lastMessage)
|
|
229
|
+
? `"${name}" is dropped (closed without doing it), and the final message reports it as dropped: nothing to accept.`
|
|
230
|
+
: `"${name}" is dropped (closed without doing it), but the final message does not report it as dropped.`;
|
|
231
|
+
}
|
|
205
232
|
if (MANUAL.test(cmd)) {
|
|
206
233
|
return acceptedManually(t, lastMessage)
|
|
207
234
|
? `"${name}" is accepted by the user (manual), and the final message says it was accepted manually.`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "your-cto-jev",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.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",
|