your-cto-jev 0.7.0 → 0.8.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 +71 -2
- package/dist/agents.js +2 -1
- package/dist/brain.js +6 -0
- package/dist/brief.js +108 -0
- package/dist/check.js +17 -11
- package/dist/conflicts.js +93 -0
- package/dist/diff.js +2 -1
- package/dist/doctor.js +11 -8
- package/dist/hooks.js +52 -9
- package/dist/i18n.js +46 -10
- package/dist/index.js +34 -4
- package/dist/lessons.js +123 -0
- package/dist/local.js +69 -0
- package/dist/report.js +36 -0
- package/dist/setup.js +48 -24
- package/dist/skill.js +11 -1
- package/dist/turn.js +1 -1
- package/package.json +5 -5
package/dist/i18n.js
CHANGED
|
@@ -52,9 +52,14 @@ const messages = {
|
|
|
52
52
|
bad_request: (v) => `[cto] Jev 拒絕請求 (400),這次直接放行:${v.msg}`,
|
|
53
53
|
no_keys: () => '[cto] 未設定 Jev API key,全部放行。請設定 CLOUDFLARE_API_TOKEN + CLOUDFLARE_ACCOUNT_ID 或 OPENROUTER_API_KEY',
|
|
54
54
|
detail: (v) => `${v.signal} = ${v.value}(門檻 > ${v.threshold})`,
|
|
55
|
+
local_protected_branch: (v) => `[cto] ${v.detail} 是受保護的分支,不准直接動。開一個 branch 再來。(protected_branches)`,
|
|
56
|
+
local_conflict_marker: (v) => `[cto] ${v.detail} 裡還有 merge 衝突標記,你打算把 <<<<<<< 一起 commit 進去?先解完衝突。`,
|
|
57
|
+
local_env_file: (v) => `[cto] 你正要把 ${v.detail} 連同值一起 commit。.env 不進 git,放進 .gitignore,要分享用 .env.example。`,
|
|
58
|
+
local_big_file: (v) => `[cto] ${v.detail} 太大了,確定是要進 git 的東西?不擋,但想清楚。`,
|
|
59
|
+
local_lock_drift: (v) => `[cto] package.json 改了相依套件,但 ${v.detail} 沒跟著改。先跑一次 install,不然隊友裝的會跟你不一樣。`,
|
|
55
60
|
setup_not_git: () => '[cto] 這裡不是 git repository,setup 中止。',
|
|
56
61
|
setup_bad_json: (v) => `[cto] ${v.path} 不是合法 JSON 或 hooks 格式不符,未修改任何檔案。請先修正該檔。`,
|
|
57
|
-
setup_hook: (v) => `[cto]
|
|
62
|
+
setup_hook: (v) => `[cto] ${v.name} 區塊已寫入 ${v.path}`,
|
|
58
63
|
setup_hook_exit: (v) => `[cto] 警告:${v.path} 在 cto 區塊之前有 exit 0,cto 檢查不會執行。請調整該 hook。`,
|
|
59
64
|
setup_gitignore: () => '[cto] .gitignore 已加入 .cto-brain.json 與 debug_stdin.json',
|
|
60
65
|
setup_config: () => '[cto] 已建立 .cto.json(請 commit 給團隊共用)',
|
|
@@ -110,6 +115,7 @@ const messages = {
|
|
|
110
115
|
check_nothing: () => '[cto] 沒有可檢查的改動。',
|
|
111
116
|
check_head_staged: (v) => `[cto] 檢查 staged 的改動(${v.files} 個檔案),跟 commit 時的檢查相同:`,
|
|
112
117
|
check_head_working: (v) => `[cto] 沒有 staged 的改動,改為檢查工作目錄(${v.files} 個檔案,含尚未加入 git 的新檔):`,
|
|
118
|
+
check_head_base: (v) => `[cto] 檢查這個分支相對於 ${v.base} 的改動(${v.files} 個檔案):`,
|
|
113
119
|
check_unchecked: () => '[cto] 無法檢查:沒有可用的 Jev provider。執行 cto doctor 看原因。',
|
|
114
120
|
check_why_tests: () => '未檢查:沒有改到測試相關檔案',
|
|
115
121
|
check_why_goal: () => '未檢查:.cto.json 沒有設定 sprint_goal',
|
|
@@ -147,15 +153,27 @@ const messages = {
|
|
|
147
153
|
doc_hint_401: () => 'key 無效或已撤銷,請重新產生後執行 cto setup',
|
|
148
154
|
doc_hint_402: () => '額度不足,請到 provider 後台儲值',
|
|
149
155
|
doc_hint_network: () => '連不上或太慢,檢查網路或稍後再試',
|
|
150
|
-
doc_hint_other: () => '非預期的回應,請回報到 github.com/
|
|
156
|
+
doc_hint_other: () => '非預期的回應,請回報到 github.com/hierichhsu/your-cto-jev/issues',
|
|
151
157
|
doc_repo: (v) => `目前的 repo:${v.root}`,
|
|
152
158
|
doc_no_repo: () => '目前不在 git repo 裡,略過專案檢查。',
|
|
153
|
-
doc_hook_ok: (v) => `git
|
|
154
|
-
doc_hook_missing: () =>
|
|
159
|
+
doc_hook_ok: (v) => `git ${v.name} 已安裝(${v.path})`,
|
|
160
|
+
doc_hook_missing: (v) => `git ${v.name} 沒有 cto 區塊,請在此 repo 執行 cto setup`,
|
|
155
161
|
doc_agents: (v) => `已接上的 agent:${v.list}`,
|
|
156
162
|
doc_none: () => '無',
|
|
157
163
|
doc_goal_set: () => 'sprint_goal 已設定,架構對齊檢查啟用中',
|
|
158
164
|
doc_goal_empty: () => 'sprint_goal 未設定,架構對齊檢查關閉(可在 .cto.json 填入)',
|
|
165
|
+
log_empty: () => '[cto] 這個 repo 還沒有 Jev 回答過的檢查。',
|
|
166
|
+
log_head: () => '[cto] 最近的判斷(最舊在上):',
|
|
167
|
+
log_crossed: () => '超過門檻',
|
|
168
|
+
log_hint: () => '[cto] 哪一筆判斷錯了?cto report <編號>(不給編號就是最後一筆)會把它存成校正案例。',
|
|
169
|
+
report_bad_n: (v) => `[cto] 沒有這個編號,cto log 只有 1 到 ${v.max}。`,
|
|
170
|
+
report_wrong: (v) => `[cto] 記下了:${v.signal} 給 ${v.value} 是誤擋,正確答案應該是「否」。`,
|
|
171
|
+
report_missed: (v) => `[cto] 記下了:${v.signal} 給 ${v.value} 是漏判,正確答案應該是「是」。`,
|
|
172
|
+
report_written: (v) => `[cto] 已寫入 ${v.path}(只在這台電腦,已遮罩)。要幫 cto 校正:把那行貼進 your-cto-jev 的 calibration/candidates/${v.signal}.jsonl 開 PR,或貼進 issue。`,
|
|
173
|
+
conflicts_head: () => '[cto] 其他也在管 agent 的東西(請確認沒有跟 cto 打架):',
|
|
174
|
+
conflict_hook: (v) => `cto 的事件上還有別的 hook:${v.where} → ${v.detail}。先擋的那個 cto 看不到;cto 擋了之後,後面的不會跑。`,
|
|
175
|
+
conflict_guidance: (v) => `${v.where} 這行看起來在教 agent 做 cto 會擋的事:「${v.detail}」`,
|
|
176
|
+
conflict_dup_skill: (v) => `skill「${v.where}」在 ${v.detail} 各裝了一份,agent 會看到兩個版本。`,
|
|
159
177
|
doc_stats: (v) => `累計:擋下 ${v.blocked} 次,因無法檢查而放行 ${v.skipped} 次`,
|
|
160
178
|
doc_cooldown: (v) => `${v.name} 冷卻中,原因 ${v.status},到 ${v.until} 才會重試`,
|
|
161
179
|
doc_p_no_provider: () => '沒有任何可用的 provider:現在所有檢查都會直接放行',
|
|
@@ -164,7 +182,7 @@ const messages = {
|
|
|
164
182
|
doc_bad: () => '[cto] 有問題需要處理:',
|
|
165
183
|
update_available: (v) => `[cto] 有新版 ${v.latest}(目前 ${v.current}),執行 cto update 更新`,
|
|
166
184
|
update_done: () => '[cto] 已更新。已設定過的專案不用重跑 cto setup。',
|
|
167
|
-
usage: () => '用法:cto check | cto doctor | cto update | cto --version | cto setup [--refresh] [--agents claude,cursor,gemini,codex] [--yes] [--uninstall] | cto --hook <git-commit|AGENT-pre|AGENT-post>',
|
|
185
|
+
usage: () => '用法:cto brief | cto check [--base origin/main] | cto log | cto report [n] | cto doctor | cto update | cto --version | cto setup [--refresh] [--agents claude,cursor,gemini,codex] [--yes] [--uninstall] | cto --hook <git-commit|AGENT-pre|AGENT-post>',
|
|
168
186
|
},
|
|
169
187
|
en: {
|
|
170
188
|
reason_402: () => 'out of credits',
|
|
@@ -184,9 +202,14 @@ const messages = {
|
|
|
184
202
|
bad_request: (v) => `[cto] Jev rejected the request (400), letting this one through: ${v.msg}`,
|
|
185
203
|
no_keys: () => '[cto] No Jev API key set, everything passes. Set CLOUDFLARE_API_TOKEN + CLOUDFLARE_ACCOUNT_ID or OPENROUTER_API_KEY',
|
|
186
204
|
detail: (v) => `${v.signal} = ${v.value} (threshold > ${v.threshold})`,
|
|
205
|
+
local_protected_branch: (v) => `[cto] ${v.detail} is a protected branch. Not on my watch: make a branch. (protected_branches)`,
|
|
206
|
+
local_conflict_marker: (v) => `[cto] ${v.detail} still has merge conflict markers. Committing <<<<<<< is not a strategy. Resolve it first.`,
|
|
207
|
+
local_env_file: (v) => `[cto] You are about to commit ${v.detail} with real values. .env files stay out of git: add it to .gitignore and share a .env.example.`,
|
|
208
|
+
local_big_file: (v) => `[cto] ${v.detail} is huge. Sure that belongs in git? Not blocking, but think.`,
|
|
209
|
+
local_lock_drift: (v) => `[cto] package.json changed dependencies but ${v.detail} did not. Run install first, or your teammates get a different tree.`,
|
|
187
210
|
setup_not_git: () => '[cto] Not a git repository, setup aborted.',
|
|
188
211
|
setup_bad_json: (v) => `[cto] ${v.path} is not valid JSON or has an unexpected hooks shape. Nothing was changed. Fix it first.`,
|
|
189
|
-
setup_hook: (v) => `[cto]
|
|
212
|
+
setup_hook: (v) => `[cto] ${v.name} block written to ${v.path}`,
|
|
190
213
|
setup_hook_exit: (v) => `[cto] Warning: ${v.path} has an exit 0 before the cto block, so cto will never run. Adjust that hook.`,
|
|
191
214
|
setup_gitignore: () => '[cto] Added .cto-brain.json and debug_stdin.json to .gitignore',
|
|
192
215
|
setup_config: () => '[cto] Created .cto.json (commit it for the team)',
|
|
@@ -242,6 +265,7 @@ const messages = {
|
|
|
242
265
|
check_nothing: () => '[cto] Nothing to check.',
|
|
243
266
|
check_head_staged: (v) => `[cto] Checking staged changes (${v.files} files), same checks as a commit:`,
|
|
244
267
|
check_head_working: (v) => `[cto] Nothing staged, checking the working tree instead (${v.files} files, including new untracked files):`,
|
|
268
|
+
check_head_base: (v) => `[cto] Checking what this branch adds on top of ${v.base} (${v.files} files):`,
|
|
245
269
|
check_unchecked: () => '[cto] Could not check: no working Jev provider. Run cto doctor to see why.',
|
|
246
270
|
check_why_tests: () => 'not checked: no test files changed',
|
|
247
271
|
check_why_goal: () => 'not checked: sprint_goal is empty in .cto.json',
|
|
@@ -279,15 +303,27 @@ const messages = {
|
|
|
279
303
|
doc_hint_401: () => 'Key invalid or revoked. Create a new one and run cto setup',
|
|
280
304
|
doc_hint_402: () => 'Out of credits. Top up in the provider dashboard',
|
|
281
305
|
doc_hint_network: () => 'Unreachable or too slow. Check your network or try again later',
|
|
282
|
-
doc_hint_other: () => 'Unexpected response. Please report it at github.com/
|
|
306
|
+
doc_hint_other: () => 'Unexpected response. Please report it at github.com/hierichhsu/your-cto-jev/issues',
|
|
283
307
|
doc_repo: (v) => `Current repo: ${v.root}`,
|
|
284
308
|
doc_no_repo: () => 'Not inside a git repo, skipping project checks.',
|
|
285
|
-
doc_hook_ok: (v) => `git
|
|
286
|
-
doc_hook_missing: () =>
|
|
309
|
+
doc_hook_ok: (v) => `git ${v.name} installed (${v.path})`,
|
|
310
|
+
doc_hook_missing: (v) => `git ${v.name} has no cto block. Run cto setup in this repo`,
|
|
287
311
|
doc_agents: (v) => `Agents wired up: ${v.list}`,
|
|
288
312
|
doc_none: () => 'none',
|
|
289
313
|
doc_goal_set: () => 'sprint_goal set, architecture check on',
|
|
290
314
|
doc_goal_empty: () => 'sprint_goal empty, architecture check off (set it in .cto.json)',
|
|
315
|
+
log_empty: () => '[cto] No check answered by Jev in this repo yet.',
|
|
316
|
+
log_head: () => '[cto] Recent decisions (oldest first):',
|
|
317
|
+
log_crossed: () => 'CROSSED',
|
|
318
|
+
log_hint: () => '[cto] One of these was wrong? cto report <n> (the last one when n is omitted) saves it as a calibration case.',
|
|
319
|
+
report_bad_n: (v) => `[cto] No such entry; cto log has 1 to ${v.max}.`,
|
|
320
|
+
report_wrong: (v) => `[cto] Noted: ${v.signal} at ${v.value} was a false alarm, the right answer is "no".`,
|
|
321
|
+
report_missed: (v) => `[cto] Noted: ${v.signal} at ${v.value} was a miss, the right answer is "yes".`,
|
|
322
|
+
report_written: (v) => `[cto] Written to ${v.path} (this machine only, masked). To help calibrate cto, paste that line into calibration/candidates/${v.signal}.jsonl of your-cto-jev in a PR, or into an issue.`,
|
|
323
|
+
conflicts_head: () => '[cto] Other things steering the agents here (make sure they do not fight cto):',
|
|
324
|
+
conflict_hook: (v) => `another hook on cto's events: ${v.where} -> ${v.detail}. Whichever blocks first hides the call from the rest.`,
|
|
325
|
+
conflict_guidance: (v) => `${v.where} looks like it tells the agent to do what cto blocks: "${v.detail}"`,
|
|
326
|
+
conflict_dup_skill: (v) => `skill "${v.where}" is installed in both ${v.detail}; the agent sees two versions.`,
|
|
291
327
|
doc_stats: (v) => `So far: blocked ${v.blocked}, let through unchecked ${v.skipped}`,
|
|
292
328
|
doc_cooldown: (v) => `${v.name} is cooling down after ${v.status}, retried after ${v.until}`,
|
|
293
329
|
doc_p_no_provider: () => 'No working provider: every check is currently let through',
|
|
@@ -296,7 +332,7 @@ const messages = {
|
|
|
296
332
|
doc_bad: () => '[cto] Needs attention:',
|
|
297
333
|
update_available: (v) => `[cto] Version ${v.latest} is available (you have ${v.current}). Run cto update`,
|
|
298
334
|
update_done: () => '[cto] Updated. Projects already set up do not need cto setup again.',
|
|
299
|
-
usage: () => 'Usage: cto check | cto doctor | cto update | cto --version | cto setup [--refresh] [--agents claude,cursor,gemini,codex] [--yes] [--uninstall] | cto --hook <git-commit|AGENT-pre|AGENT-post>',
|
|
335
|
+
usage: () => 'Usage: cto brief | cto check [--base origin/main] | cto log | cto report [n] | cto doctor | cto update | cto --version | cto setup [--refresh] [--agents claude,cursor,gemini,codex] [--yes] [--uninstall] | cto --hook <git-commit|AGENT-pre|AGENT-post>',
|
|
300
336
|
},
|
|
301
337
|
};
|
|
302
338
|
export function t(lang, key, vars = {}) {
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import { join } from 'node:path';
|
|
|
5
5
|
import { agentNames, agents } from './agents.js';
|
|
6
6
|
import { applyCredentials, findRoot, loadConfig, loadCredentials, loadPrefs, saveCredentials, savePrefs } from './brain.js';
|
|
7
7
|
import { DEFAULT_ORDER, providerOrder, providers } from './api.js';
|
|
8
|
-
import { agentEdit, agentPost, agentPre, agentReply, agentStop, gitCommit, stagedDiff } from './hooks.js';
|
|
8
|
+
import { agentEdit, agentPost, agentPre, agentReply, agentStop, gitCommit, gitPush, stagedDiff } from './hooks.js';
|
|
9
9
|
import { checkUpdate, currentVersion, runUpdate } from './update.js';
|
|
10
10
|
import { doctor } from './doctor.js';
|
|
11
11
|
import { detectLang, t } from './i18n.js';
|
|
@@ -42,7 +42,9 @@ async function runHook(name) {
|
|
|
42
42
|
return gitCommit(diff, { root, lang });
|
|
43
43
|
}
|
|
44
44
|
const raw = await readStdin();
|
|
45
|
-
|
|
45
|
+
if (name === 'git-push')
|
|
46
|
+
return gitPush(raw, { root: findRoot(), lang });
|
|
47
|
+
const m = /^(claude|cursor|gemini|codex)-(pre|post|stop|edit|reply|start)$/.exec(name);
|
|
46
48
|
if (!m)
|
|
47
49
|
return { code: 0, stderr: [] };
|
|
48
50
|
const agent = agents[m[1]];
|
|
@@ -51,6 +53,10 @@ async function runHook(name) {
|
|
|
51
53
|
input = JSON.parse(raw);
|
|
52
54
|
}
|
|
53
55
|
catch { /* fail-open below */ }
|
|
56
|
+
if (m[2] === 'start') {
|
|
57
|
+
const { brief } = await import('./brief.js');
|
|
58
|
+
return { code: 0, stdout: brief(findRoot(typeof input?.cwd === 'string' ? input.cwd : process.cwd())).join('\n'), stderr: [] };
|
|
59
|
+
}
|
|
54
60
|
if (m[2] === 'edit') {
|
|
55
61
|
const cwd = typeof input?.cwd === 'string' ? input.cwd : typeof input?.workspace_roots?.[0] === 'string' ? input.workspace_roots[0] : process.cwd();
|
|
56
62
|
return agentEdit(agent.parseEdit?.(input), { root: findRoot(cwd), lang }, agent.transcriptTurns ? undefined : agent.session(input));
|
|
@@ -78,7 +84,7 @@ async function runHook(name) {
|
|
|
78
84
|
const post = agent.parsePost(input);
|
|
79
85
|
const root = findRoot(post?.cwd ?? input?.cwd ?? process.cwd());
|
|
80
86
|
debug(root, maskSensitiveState(raw));
|
|
81
|
-
return agentPost(post, { root, lang });
|
|
87
|
+
return agentPost(post, { root, lang }, m[1]);
|
|
82
88
|
}
|
|
83
89
|
const args = process.argv.slice(2);
|
|
84
90
|
const lang = detectLang();
|
|
@@ -169,11 +175,35 @@ else if (args[0] === 'check') {
|
|
|
169
175
|
}
|
|
170
176
|
else {
|
|
171
177
|
const { runCheck } = await import('./check.js');
|
|
172
|
-
const r = await runCheck(root, lang);
|
|
178
|
+
const r = await runCheck(root, lang, flag('--base'));
|
|
173
179
|
console.log(r.lines.join('\n'));
|
|
174
180
|
process.exitCode = r.code;
|
|
175
181
|
}
|
|
176
182
|
}
|
|
183
|
+
else if (args[0] === 'log' || args[0] === 'report') {
|
|
184
|
+
const root = gitRoot(process.cwd());
|
|
185
|
+
if (!root) {
|
|
186
|
+
process.stderr.write(t(lang, 'setup_not_git') + '\n');
|
|
187
|
+
process.exitCode = 1;
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
const { showLog, report } = await import('./report.js');
|
|
191
|
+
const r = args[0] === 'log' ? showLog(root, lang) : report(root, lang, args[1]);
|
|
192
|
+
(r.code ? process.stderr : process.stdout).write(r.lines.join('\n') + '\n');
|
|
193
|
+
process.exitCode = r.code;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
else if (args[0] === 'brief') {
|
|
197
|
+
const root = gitRoot(process.cwd());
|
|
198
|
+
if (!root) {
|
|
199
|
+
process.stderr.write(t(lang, 'setup_not_git') + '\n');
|
|
200
|
+
process.exitCode = 1;
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
const { brief } = await import('./brief.js');
|
|
204
|
+
console.log(brief(root).join('\n'));
|
|
205
|
+
}
|
|
206
|
+
}
|
|
177
207
|
else if (args[0] === 'doctor') {
|
|
178
208
|
const r = await doctor(process.cwd(), lang);
|
|
179
209
|
console.log(r.lines.join('\n'));
|
package/dist/lessons.js
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { existsSync, readFileSync, renameSync, unlinkSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { maskSensitiveState } from './masker.js';
|
|
4
|
+
// Lessons: every failed agent command, fingerprinted, with the edit that made the same command pass afterwards.
|
|
5
|
+
// Kept per repo in .cto-lessons.jsonl (meant to be committed, so every teammate's agent learns from it). One line
|
|
6
|
+
// per lesson, append-style, so two people adding lessons never conflict in git. No Jev call anywhere in here.
|
|
7
|
+
export const LESSONS_FILE = '.cto-lessons.jsonl';
|
|
8
|
+
const MAX_LESSONS = 200;
|
|
9
|
+
/** The first two words of a command: the tool and its verb ("npm test", "npx tsc", "git push"). Flags are not a verb. */
|
|
10
|
+
export function commandHead(command) {
|
|
11
|
+
const words = command.trim().replace(/^(?:\w+=\S*\s+)+/, '').split(/\s+/);
|
|
12
|
+
return words.slice(0, words[1] && !words[1].startsWith('-') ? 2 : 1).join(' ');
|
|
13
|
+
}
|
|
14
|
+
// Numbers, hashes, quoted names and absolute paths vary between runs of the same mistake.
|
|
15
|
+
const normalise = (s) => s.replace(/(['"`])[^'"`]*\1/g, "'*'").replace(/\b[0-9a-f]{6,}\b/gi, '*').replace(/\d+/g, '*')
|
|
16
|
+
.replace(/(?:[A-Za-z]:)?[\\/](?:[\w.-]+[\\/])+[\w.-]*/g, '*').replace(/\s+/g, ' ').trim();
|
|
17
|
+
const TELLING = /\b(error|err|exception|fail|failed|cannot|not found|denied|invalid|unexpected|missing|ENOENT|TS\d{4}|panic|traceback)\b/i;
|
|
18
|
+
/** The lines of a failure worth keeping: the first telling line and the two after it. */
|
|
19
|
+
export function errorLines(output, root) {
|
|
20
|
+
const lines = output.split(/\r?\n/).map((l) => l.trim()).filter(Boolean);
|
|
21
|
+
const at = Math.max(0, lines.findIndex((l) => TELLING.test(l)));
|
|
22
|
+
return lines.slice(at, at + 3).map((l) => relativise(maskSensitiveState(l), root).slice(0, 200));
|
|
23
|
+
}
|
|
24
|
+
// Absolute paths under the repo become ./..., with forward slashes, so the same lesson reads the same on every machine.
|
|
25
|
+
const relativise = (s, root) => root ? s.split(root).join('.').split(root.replace(/\\/g, '/')).join('.').replace(/\\/g, '/') : s;
|
|
26
|
+
export const fingerprint = (command, error) => `${commandHead(command)} | ${normalise(error[0] ?? '')}`;
|
|
27
|
+
const idOf = (fp) => {
|
|
28
|
+
let h = 0;
|
|
29
|
+
for (const c of fp)
|
|
30
|
+
h = (h * 31 + c.charCodeAt(0)) | 0;
|
|
31
|
+
return 'l_' + (h >>> 0).toString(16).padStart(8, '0');
|
|
32
|
+
};
|
|
33
|
+
export function loadLessons(root) {
|
|
34
|
+
try {
|
|
35
|
+
return readFileSync(join(root, LESSONS_FILE), 'utf8').split('\n').flatMap((l) => {
|
|
36
|
+
try {
|
|
37
|
+
const j = l && JSON.parse(l);
|
|
38
|
+
return j && typeof j.fingerprint === 'string' ? [j] : [];
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return [];
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
return [];
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/** Same tmp + rename as saveBrain; never throws, so bookkeeping can never turn into a fail-open pass. */
|
|
50
|
+
export function saveLessons(root, lessons) {
|
|
51
|
+
const path = join(root, LESSONS_FILE);
|
|
52
|
+
const kept = lessons.length > MAX_LESSONS ? [...lessons].sort((a, b) => b.last_at.localeCompare(a.last_at)).slice(0, MAX_LESSONS) : lessons;
|
|
53
|
+
if (!kept.length && !existsSync(path))
|
|
54
|
+
return;
|
|
55
|
+
const tmp = `${path}.${process.pid}.tmp`;
|
|
56
|
+
try {
|
|
57
|
+
writeFileSync(tmp, kept.map((l) => JSON.stringify(l)).join('\n') + (kept.length ? '\n' : ''));
|
|
58
|
+
renameSync(tmp, path);
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
try {
|
|
62
|
+
unlinkSync(tmp);
|
|
63
|
+
}
|
|
64
|
+
catch { /* nothing to clean */ }
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
export function packageManager(root) {
|
|
68
|
+
return existsSync(join(root, 'pnpm-lock.yaml')) ? 'pnpm' : existsSync(join(root, 'yarn.lock')) ? 'yarn'
|
|
69
|
+
: existsSync(join(root, 'bun.lockb')) || existsSync(join(root, 'bun.lock')) ? 'bun' : 'npm';
|
|
70
|
+
}
|
|
71
|
+
/** A command failed: count it, and forget any earlier fix since it evidently did not hold. Called once per failure. */
|
|
72
|
+
export function recordFailure(lessons, command, error, root, agent, now = new Date()) {
|
|
73
|
+
const lines = errorLines(error, root);
|
|
74
|
+
const fp = fingerprint(command, lines);
|
|
75
|
+
const at = now.toISOString();
|
|
76
|
+
let l = lessons.find((x) => x.fingerprint === fp);
|
|
77
|
+
if (l) {
|
|
78
|
+
l.seen++;
|
|
79
|
+
l.last_at = at;
|
|
80
|
+
l.error = lines;
|
|
81
|
+
delete l.fix;
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
l = {
|
|
85
|
+
id: idOf(fp), fingerprint: fp, command: relativise(maskSensitiveState(command), root).slice(0, 200), error: lines,
|
|
86
|
+
env: { os: process.platform, node: process.version, pm: packageManager(root), agent }, seen: 1, first_at: at, last_at: at,
|
|
87
|
+
};
|
|
88
|
+
lessons.push(l);
|
|
89
|
+
}
|
|
90
|
+
return l;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Resolve lessons from a turn: a failed run, then code edits, then the same command (by head) passing marks the fix.
|
|
94
|
+
* Idempotent, so a turn that is read again at a second stop sets the same fix twice. Failures are not counted here.
|
|
95
|
+
*/
|
|
96
|
+
export function resolveFromTurn(lessons, actions, root, now = new Date()) {
|
|
97
|
+
const pending = new Map();
|
|
98
|
+
const fixed = [];
|
|
99
|
+
for (const a of actions) {
|
|
100
|
+
if (a.kind === 'edit') {
|
|
101
|
+
for (const p of pending.values())
|
|
102
|
+
p.files.add(a.file);
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
const head = commandHead(a.command);
|
|
106
|
+
if (!a.ok) {
|
|
107
|
+
const fp = fingerprint(a.command, errorLines(a.tail, root));
|
|
108
|
+
const lesson = lessons.find((l) => l.fingerprint === fp) ?? lessons.find((l) => commandHead(l.command) === head && !l.fix);
|
|
109
|
+
if (lesson)
|
|
110
|
+
pending.set(head, { lesson, files: new Set() });
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
const p = pending.get(head);
|
|
114
|
+
if (!p || !p.files.size)
|
|
115
|
+
continue;
|
|
116
|
+
p.lesson.fix = { files: [...p.files], verified_by: maskSensitiveState(a.command).slice(0, 200), at: now.toISOString() };
|
|
117
|
+
fixed.push(p.lesson);
|
|
118
|
+
pending.delete(head);
|
|
119
|
+
}
|
|
120
|
+
return fixed;
|
|
121
|
+
}
|
|
122
|
+
/** Unresolved first, then the most often seen, then the most recent. */
|
|
123
|
+
export const rankLessons = (lessons) => [...lessons].sort((a, b) => Number(!!a.fix) - Number(!!b.fix) || b.seen - a.seen || b.last_at.localeCompare(a.last_at));
|
package/dist/local.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { execFileSync } from 'node:child_process';
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { splitFiles } from './diff.js';
|
|
5
|
+
const BIG_BYTES = 5 * 1024 * 1024;
|
|
6
|
+
const ENV_FILE = /(^|\/)\.env(\.(?!example$|sample$|template$)[^/]*)?$/;
|
|
7
|
+
const LOCKS = ['package-lock.json', 'pnpm-lock.yaml', 'yarn.lock', 'bun.lock', 'bun.lockb'];
|
|
8
|
+
// A dependency line's value is a version range or a spec prefix; author, url and script lines are not.
|
|
9
|
+
const DEP_LINE = /^[+-]\s*"[^"]+":\s*"(?:[\d~^>=<*][^"]*|latest|(?:workspace|npm|file|link):[^"]*)"\s*,?$/m;
|
|
10
|
+
const git = (cwd, ...args) => {
|
|
11
|
+
try {
|
|
12
|
+
return execFileSync('git', args, { cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).trim();
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
return '';
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
export const currentBranch = (root) => git(root, 'rev-parse', '--abbrev-ref', 'HEAD');
|
|
19
|
+
/** Local findings for a diff about to be committed on `branch`. The raw diff: lock files are part of the question here. */
|
|
20
|
+
export function localCommitChecks(rawDiff, cfg, root, branch = currentBranch(root)) {
|
|
21
|
+
const out = [];
|
|
22
|
+
if (branch && cfg.protected_branches.includes(branch))
|
|
23
|
+
out.push({ kind: 'protected_branch', block: true, detail: branch });
|
|
24
|
+
const touched = new Set();
|
|
25
|
+
for (const section of splitFiles(rawDiff)) {
|
|
26
|
+
const file = /^diff --git a\/.+? b\/(.+)$/m.exec(section)?.[1];
|
|
27
|
+
if (!file)
|
|
28
|
+
continue;
|
|
29
|
+
touched.add(file);
|
|
30
|
+
if (/^\+(<{7} |={7}$|>{7} )/m.test(section))
|
|
31
|
+
out.push({ kind: 'conflict_marker', block: true, detail: file });
|
|
32
|
+
if (ENV_FILE.test(file) && /^\+\s*(?:export\s+)?[A-Za-z_][\w.]*\s*=\s*\S/m.test(section))
|
|
33
|
+
out.push({ kind: 'env_file', block: true, detail: file });
|
|
34
|
+
if (section.length > BIG_BYTES)
|
|
35
|
+
out.push({ kind: 'big_file', block: false, detail: `${file} (${Math.round(section.length / 1024 / 1024)} MB)` });
|
|
36
|
+
}
|
|
37
|
+
const pkgs = [...touched].filter((f) => /(^|\/)package\.json$/.test(f));
|
|
38
|
+
const lockInRepo = LOCKS.find((l) => existsSync(join(root, l)));
|
|
39
|
+
if (pkgs.length && lockInRepo && ![...touched].some((f) => LOCKS.some((l) => f.endsWith(l)))) {
|
|
40
|
+
const depChange = splitFiles(rawDiff).some((s) => pkgs.some((p) => s.includes(` b/${p}\n`)) && DEP_LINE.test(s));
|
|
41
|
+
if (depChange)
|
|
42
|
+
out.push({ kind: 'lock_drift', block: false, detail: lockInRepo });
|
|
43
|
+
}
|
|
44
|
+
return out;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* pre-push: stdin lines "<local ref> <local sha> <remote ref> <remote sha>". A protected branch is blocked when the
|
|
48
|
+
* push deletes it or rewrites its history (the remote commit is not an ancestor of what is pushed).
|
|
49
|
+
*/
|
|
50
|
+
export function localPushChecks(stdin, cfg, root) {
|
|
51
|
+
const out = [];
|
|
52
|
+
for (const line of stdin.split('\n')) {
|
|
53
|
+
const [, localSha, remoteRef, remoteSha] = line.trim().split(/\s+/);
|
|
54
|
+
const branch = remoteRef?.replace(/^refs\/heads\//, '');
|
|
55
|
+
if (!branch || !cfg.protected_branches.includes(branch) || !remoteSha || /^0+$/.test(remoteSha))
|
|
56
|
+
continue;
|
|
57
|
+
if (/^0+$/.test(localSha)) {
|
|
58
|
+
out.push({ kind: 'protected_branch', block: true, detail: `${branch} (delete)` });
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
try {
|
|
62
|
+
execFileSync('git', ['merge-base', '--is-ancestor', remoteSha, localSha], { cwd: root, stdio: 'ignore' });
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
out.push({ kind: 'protected_branch', block: true, detail: `${branch} (force push)` });
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return out;
|
|
69
|
+
}
|
package/dist/report.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { appendFileSync, mkdirSync } from 'node:fs';
|
|
2
|
+
import { dirname, join } from 'node:path';
|
|
3
|
+
import { credentialsPath, loadBrain } from './brain.js';
|
|
4
|
+
import { t } from './i18n.js';
|
|
5
|
+
// `cto log`: the last answered questions with their scores. `cto report [n]`: "that call was wrong", which writes
|
|
6
|
+
// the exact masked state as a calibration case to a per-user file, ready to paste into calibration/candidates/.
|
|
7
|
+
const stamp = (iso) => iso.slice(0, 16).replace('T', ' ');
|
|
8
|
+
export function showLog(root, lang) {
|
|
9
|
+
const d = loadBrain(root).decisions ?? [];
|
|
10
|
+
if (!d.length)
|
|
11
|
+
return { code: 0, lines: [t(lang, 'log_empty')] };
|
|
12
|
+
const lines = [t(lang, 'log_head')];
|
|
13
|
+
d.forEach((x, i) => {
|
|
14
|
+
const crossed = x.value > x.threshold;
|
|
15
|
+
lines.push(` ${String(i + 1).padStart(2)} ${stamp(x.at)} ${x.hook.padEnd(7)} ${x.signal.padEnd(22)} ${String(x.value).padEnd(5)} ${crossed ? '>' : '<'} ${x.threshold} ${crossed ? t(lang, 'log_crossed') : 'ok'}`);
|
|
16
|
+
});
|
|
17
|
+
lines.push(t(lang, 'log_hint'));
|
|
18
|
+
return { code: 0, lines };
|
|
19
|
+
}
|
|
20
|
+
export const reportsPath = (signal) => join(dirname(credentialsPath()), 'reports', `${signal}.jsonl`);
|
|
21
|
+
/** A reported decision becomes a case whose expected answer is the opposite of what Jev said. */
|
|
22
|
+
export function report(root, lang, which) {
|
|
23
|
+
const d = loadBrain(root).decisions ?? [];
|
|
24
|
+
if (!d.length)
|
|
25
|
+
return { code: 1, lines: [t(lang, 'log_empty')] };
|
|
26
|
+
const n = which ? Number(which) : d.length;
|
|
27
|
+
const x = d[n - 1];
|
|
28
|
+
if (!x)
|
|
29
|
+
return { code: 1, lines: [t(lang, 'report_bad_n', { max: d.length })] };
|
|
30
|
+
const crossed = x.value > x.threshold;
|
|
31
|
+
const entry = { id: `report-${x.at.replace(/\D/g, '').slice(0, 14)}`, set: 'holdout', expect: !crossed, source: `cto report ${stamp(x.at)} ${x.hook} value ${x.value}`, state: x.state };
|
|
32
|
+
const path = reportsPath(x.signal);
|
|
33
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
34
|
+
appendFileSync(path, JSON.stringify(entry) + '\n', { mode: 0o600 });
|
|
35
|
+
return { code: 0, lines: [t(lang, crossed ? 'report_wrong' : 'report_missed', { signal: x.signal, value: x.value }), t(lang, 'report_written', { path, signal: x.signal })] };
|
|
36
|
+
}
|
package/dist/setup.js
CHANGED
|
@@ -5,10 +5,14 @@ import { basename, dirname, join, relative } from 'node:path';
|
|
|
5
5
|
import { PHASES, agentNames, agents, hookCommand } from './agents.js';
|
|
6
6
|
import { t } from './i18n.js';
|
|
7
7
|
import { guidancePaths, syncGuidance } from './skill.js';
|
|
8
|
+
import { findConflicts } from './conflicts.js';
|
|
8
9
|
const START = '# >>> YOUR CTO JEV START >>>';
|
|
9
10
|
const END = '# <<< YOUR CTO JEV END <<<';
|
|
10
11
|
// Keep the block minimal: all logic (including the git diff call) lives in the package, so npm update upgrades every repo.
|
|
11
12
|
const HOOK_BODY = 'if command -v cto >/dev/null 2>&1; then\n cto --hook git-commit || exit 1\nfi\n';
|
|
13
|
+
// pre-push gets git's ref lines on stdin; they are passed straight through.
|
|
14
|
+
const PUSH_BODY = 'if command -v cto >/dev/null 2>&1; then\n cto --hook git-push || exit 1\nfi\n';
|
|
15
|
+
export const GIT_HOOKS = [['pre-commit', HOOK_BODY], ['pre-push', PUSH_BODY]];
|
|
12
16
|
const IGNORE_BODY = '.cto-brain.json\n.cto-brain.json.*tmp\ndebug_stdin.json\n';
|
|
13
17
|
const OURS = (cmd) => typeof cmd === 'string' && cmd.startsWith('cto --hook ');
|
|
14
18
|
const block = (body) => `${START}\n${body}${END}\n`;
|
|
@@ -139,19 +143,22 @@ export function setup(cwd, lang, opts = {}) {
|
|
|
139
143
|
return { code: 1, lines: [t(lang, 'setup_bad_json', { path: rel(path) })] };
|
|
140
144
|
settings.set(name, { path, json });
|
|
141
145
|
}
|
|
142
|
-
const
|
|
146
|
+
const dir = hooksDir(root);
|
|
143
147
|
const ignorePath = join(root, '.gitignore');
|
|
144
148
|
if (opts.uninstall) {
|
|
145
|
-
|
|
149
|
+
for (const [name] of GIT_HOOKS) {
|
|
150
|
+
const hookPath = join(dir, name);
|
|
151
|
+
if (!existsSync(hookPath))
|
|
152
|
+
continue;
|
|
146
153
|
const c = readFileSync(hookPath, 'utf8');
|
|
147
|
-
if (blockRe.test(c))
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
}
|
|
154
|
+
if (!blockRe.test(c))
|
|
155
|
+
continue;
|
|
156
|
+
const rest = removeBlock(c);
|
|
157
|
+
if (!rest.trim() || rest.trim() === '#!/bin/sh')
|
|
158
|
+
unlinkSync(hookPath);
|
|
159
|
+
else
|
|
160
|
+
writeFileSync(hookPath, rest);
|
|
161
|
+
lines.push(t(lang, 'uninstall_hook', { path: rel(hookPath) }));
|
|
155
162
|
}
|
|
156
163
|
for (const [name, { path, json }] of settings) {
|
|
157
164
|
if (!existsSync(path) || !uninstallHooks(json))
|
|
@@ -175,19 +182,22 @@ export function setup(cwd, lang, opts = {}) {
|
|
|
175
182
|
lines.push(t(lang, 'uninstall_done'));
|
|
176
183
|
return { code: 0, lines };
|
|
177
184
|
}
|
|
178
|
-
// 1. git pre-commit:
|
|
179
|
-
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
185
|
+
// 1. git pre-commit and pre-push: cover every agent and humans alike. Append a marked block, never overwrite.
|
|
186
|
+
for (const [name, body] of GIT_HOOKS) {
|
|
187
|
+
const hookPath = join(dir, name);
|
|
188
|
+
if (existsSync(hookPath)) {
|
|
189
|
+
const c = readFileSync(hookPath, 'utf8');
|
|
190
|
+
writeFileSync(hookPath, appendBlock(c, body));
|
|
191
|
+
if (hasEarlyExit(c))
|
|
192
|
+
lines.push(t(lang, 'setup_hook_exit', { path: rel(hookPath) }));
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
mkdirSync(dirname(hookPath), { recursive: true });
|
|
196
|
+
writeFileSync(hookPath, '#!/bin/sh\n' + block(body));
|
|
197
|
+
}
|
|
198
|
+
chmodSync(hookPath, 0o755);
|
|
199
|
+
lines.push(t(lang, 'setup_hook', { name, path: rel(hookPath) }));
|
|
188
200
|
}
|
|
189
|
-
chmodSync(hookPath, 0o755);
|
|
190
|
-
lines.push(t(lang, 'setup_hook', { path: rel(hookPath) }));
|
|
191
201
|
// 2. Agent hooks: merge, keep everything else. Agents not chosen lose their cto hooks only.
|
|
192
202
|
for (const [name, { path, json }] of settings) {
|
|
193
203
|
if (!chosen.has(name)) {
|
|
@@ -216,8 +226,14 @@ export function setup(cwd, lang, opts = {}) {
|
|
|
216
226
|
for (const p of skills.removed)
|
|
217
227
|
lines.push(t(lang, 'uninstall_skill', { path: p }));
|
|
218
228
|
// 3. .gitignore block.
|
|
219
|
-
|
|
220
|
-
|
|
229
|
+
// Only the entries the file lacks outside our block; a repo that already ignores them all gets no block.
|
|
230
|
+
const ignoreText = existsSync(ignorePath) ? readFileSync(ignorePath, 'utf8') : '';
|
|
231
|
+
const have = new Set(removeBlock(ignoreText).split(/\r?\n/).map((l) => l.trim()));
|
|
232
|
+
const missing = IGNORE_BODY.split('\n').filter((l) => l && !have.has(l));
|
|
233
|
+
if (missing.length) {
|
|
234
|
+
writeFileSync(ignorePath, appendBlock(ignoreText, missing.join('\n') + '\n'));
|
|
235
|
+
lines.push(t(lang, 'setup_gitignore'));
|
|
236
|
+
}
|
|
221
237
|
// 4. Shared config, created once and never removed.
|
|
222
238
|
const cfgPath = join(root, '.cto.json');
|
|
223
239
|
let goal = '';
|
|
@@ -234,9 +250,17 @@ export function setup(cwd, lang, opts = {}) {
|
|
|
234
250
|
}
|
|
235
251
|
if (!String(goal).trim())
|
|
236
252
|
lines.push(t(lang, 'setup_sprint'));
|
|
253
|
+
lines.push(...conflictLines(root, [...chosen], lang));
|
|
237
254
|
lines.push(t(lang, 'setup_done'));
|
|
238
255
|
return { code: 0, lines };
|
|
239
256
|
}
|
|
257
|
+
/** Notes about other hooks, contrary guidance and duplicate skills; empty when there is nothing to say. */
|
|
258
|
+
export function conflictLines(root, wired, lang, home) {
|
|
259
|
+
const found = findConflicts(root, wired, home);
|
|
260
|
+
if (!found.length)
|
|
261
|
+
return [];
|
|
262
|
+
return [t(lang, 'conflicts_head'), ...found.map((c) => ` -- ${t(lang, `conflict_${c.kind}`, { where: c.where, detail: c.detail })}`)];
|
|
263
|
+
}
|
|
240
264
|
/** Hook phases a wired agent should have but its config lacks (installed by an older version). */
|
|
241
265
|
export function missingHooks(root) {
|
|
242
266
|
const missing = [];
|
package/dist/skill.js
CHANGED
|
@@ -22,6 +22,7 @@ export const RULES_BLOCK = `${MD_START}
|
|
|
22
22
|
|
|
23
23
|
This repo is guarded by cto: every rule below is checked automatically, and breaking one gets you blocked.
|
|
24
24
|
|
|
25
|
+
- **Start with \`cto brief\`.** It shows the sprint goal, the command that verifies this repo, open plan items, and how commands failed here before and what fixed them. Skip it only if cto is not installed.
|
|
25
26
|
- **Secrets stay out of code.** Use environment variables, never literal keys, tokens or passwords. (\`credential_leak\` blocks the commit)
|
|
26
27
|
- **Fix the code, not the tests.** Never skip, delete or loosen a test, rewrite an expectation to match wrong output, or lower coverage. (\`test_tampering\` blocks the commit)
|
|
27
28
|
- **Done means verified.** After your last code change, run the relevant tests or build and see them pass before saying done or checking off a plan item; otherwise say what is unverified. (\`done_unverified\` sends you back)
|
|
@@ -54,6 +55,13 @@ Each rule below has a check behind it. Following the rules is faster than being
|
|
|
54
55
|
| **Stay on the sprint goal.** If \`.cto.json\` sets a \`sprint_goal\`, keep changes inside it and point out anything unrelated. | \`architecture_violation\` warns |
|
|
55
56
|
| **Keep it simple.** Prefer the smallest change that solves the problem. | \`code_complexity\` warns |
|
|
56
57
|
|
|
58
|
+
## Before you start
|
|
59
|
+
|
|
60
|
+
Run \`cto brief\`. It prints the sprint goal, the command that verifies this repo, the open plan items, and the lessons
|
|
61
|
+
of this repo: commands that failed before, how often, and the edit that made them pass. When a command you are about
|
|
62
|
+
to run is listed there, read its lesson first. Lessons are collected automatically from every failed command and kept
|
|
63
|
+
in \`.cto-lessons.jsonl\`; add a note to one with care, since the file is shared with the team.
|
|
64
|
+
|
|
57
65
|
## Before you commit
|
|
58
66
|
|
|
59
67
|
Run \`cto check\`. It runs the same commit checks on your staged changes (or, if nothing is staged, on all working-tree
|
|
@@ -64,10 +72,12 @@ then commit. If \`cto\` is not installed on this machine, skip this step.
|
|
|
64
72
|
|
|
65
73
|
Read the message, fix the cause, and try again. Never bypass a block: no \`git commit --no-verify\`, no disabling or
|
|
66
74
|
editing hooks, no changing \`.cto.json\` thresholds to get through. If you believe a block is wrong, stop and tell the
|
|
67
|
-
user what was blocked and why you disagree; the user decides.
|
|
75
|
+
user what was blocked and why you disagree; the user decides. The user can record a wrong call with \`cto report\`, which
|
|
76
|
+
turns it into a calibration case; you do not run that yourself.
|
|
68
77
|
|
|
69
78
|
## Commands
|
|
70
79
|
|
|
80
|
+
- \`cto brief\`: sprint goal, verify command, open plan items, and this repo's lessons. Run it before you start.
|
|
71
81
|
- \`cto check\`: preview the commit checks on your current changes.
|
|
72
82
|
- \`cto doctor\`: show whether cto is working here (keys, hooks, recent checks).
|
|
73
83
|
`;
|
package/dist/turn.js
CHANGED
|
@@ -83,7 +83,7 @@ export function turnActions(transcriptPath, cwd) {
|
|
|
83
83
|
}
|
|
84
84
|
return actions;
|
|
85
85
|
}
|
|
86
|
-
const BOX = /^(\s*)[-*+] \[([ xX])\]\s+(.*)$/;
|
|
86
|
+
export const BOX = /^(\s*)[-*+] \[([ xX])\]\s+(.*)$/;
|
|
87
87
|
const itemKey = (file, text) => `${file}:${text.replace(/\s+/g, ' ').trim().toLowerCase().slice(0, 60)}`;
|
|
88
88
|
/**
|
|
89
89
|
* Checklist items a unified diff of markdown files marks done: every added "[x]" line, except ones that were already
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "your-cto-jev",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.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",
|
|
@@ -14,15 +14,15 @@
|
|
|
14
14
|
"guardrails",
|
|
15
15
|
"jev"
|
|
16
16
|
],
|
|
17
|
-
"author": "
|
|
17
|
+
"author": "hierichhsu",
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"repository": {
|
|
20
20
|
"type": "git",
|
|
21
|
-
"url": "git+https://github.com/
|
|
21
|
+
"url": "git+https://github.com/hierichhsu/your-cto-jev.git"
|
|
22
22
|
},
|
|
23
|
-
"homepage": "https://github.com/
|
|
23
|
+
"homepage": "https://github.com/hierichhsu/your-cto-jev#readme",
|
|
24
24
|
"bugs": {
|
|
25
|
-
"url": "https://github.com/
|
|
25
|
+
"url": "https://github.com/hierichhsu/your-cto-jev/issues"
|
|
26
26
|
},
|
|
27
27
|
"type": "module",
|
|
28
28
|
"bin": {
|