your-cto-jev 0.5.0 → 0.6.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 +26 -20
- package/dist/agents.js +11 -0
- package/dist/api.js +4 -1
- package/dist/doctor.js +25 -8
- package/dist/hooks.js +2 -2
- package/dist/i18n.js +6 -0
- package/dist/index.js +4 -4
- package/dist/setup.js +20 -1
- package/dist/setupui.js +2 -2
- package/dist/skill.js +7 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
**A sharp-tongued CTO that reviews what your AI coding agent is about to do, and says no.**
|
|
4
4
|
|
|
5
|
-
`cto` hooks into `git commit` and into
|
|
5
|
+
`cto` hooks into `git commit` and into Claude Code, Cursor, Gemini CLI and Codex. Before a commit lands, before an agent runs a shell command, and when Claude Code says it is done, it asks [TypeSafe Jev](https://developers.cloudflare.com/ai/models/typesafe/jev/), a typed decision model, a few yes/no questions. Then it blocks, warns, or stays completely silent.
|
|
6
6
|
|
|
7
7
|
```text
|
|
8
8
|
$ git commit -m "add payments"
|
|
@@ -15,7 +15,7 @@ $ git commit -m "add payments"
|
|
|
15
15
|
|
|
16
16
|
# Same build fails twice, agent tries the exact same thing again
|
|
17
17
|
[cto] Same error again. You are looping and burning tokens. This tool call is BLOCKED. Fix the logic first.
|
|
18
|
-
infinite_loop = 0.95 (threshold > 0.
|
|
18
|
+
infinite_loop = 0.95 (threshold > 0.6)
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
Messages come in English or 繁體中文, picked from your locale.
|
|
@@ -50,18 +50,20 @@ When nothing crosses a threshold, `cto` prints nothing at all.
|
|
|
50
50
|
|
|
51
51
|
```mermaid
|
|
52
52
|
flowchart TD
|
|
53
|
-
A["git commit"] --> B["Staged diff<br/>minus lock files
|
|
54
|
-
C["Agent shell command<br/>Claude Code · Cursor · Gemini CLI · Codex"] --> D["Command + failures from the last 15 min"]
|
|
55
|
-
E["Agent command failed"] --> F[("
|
|
53
|
+
A["git commit<br/>or cto check"] --> B["Staged diff (cto check: working tree<br/>when nothing is staged), minus lock files,<br/>minified files, maps, binaries · ~24k-token chunks"]
|
|
54
|
+
C["Agent shell command<br/>Claude Code · Cursor · Gemini CLI · Codex"] --> D["Command + failures from the last 15 min<br/>marked when code was edited since"]
|
|
55
|
+
E["Agent command failed"] --> F[("Failure log, kept locally<br/>edits mark entries · no API call")]
|
|
56
|
+
G["Agent edited a code file"] --> F
|
|
56
57
|
F -.-> D
|
|
58
|
+
H["Claude Code ends a turn<br/>that edited code"] --> I["Final message + this turn's actions<br/>+ what ran after the last edit"]
|
|
57
59
|
B --> M["Mask secrets<br/>keys, tokens, .env values"]
|
|
58
60
|
D --> M
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
P1 -- "
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
J -- "secret, weakened tests,<br/>destructive or
|
|
61
|
+
I --> M
|
|
62
|
+
M --> P1{"Providers in your order<br/>default: OpenRouter, TypeSafe, Cloudflare"}
|
|
63
|
+
P1 -- "answers" --> J{"Jev scores vs<br/>thresholds"}
|
|
64
|
+
P1 -- "error, cooling down or no key:<br/>next provider" --> P1
|
|
65
|
+
P1 -- "none left" --> O["Fail open<br/>let it through"]
|
|
66
|
+
J -- "secret, weakened tests,<br/>destructive, loop, or unverified done" --> X["BLOCK<br/>commit exit 1 · tool call or stop exit 2"]
|
|
65
67
|
J -- "complex or off the sprint goal" --> W["Warn, then allow"]
|
|
66
68
|
J -- "nothing crosses" --> S["Allow silently"]
|
|
67
69
|
```
|
|
@@ -106,7 +108,8 @@ Other forms:
|
|
|
106
108
|
|
|
107
109
|
```sh
|
|
108
110
|
cto setup --agents claude,cursor --yes # non-interactive (scripts, CI); only adds, never removes
|
|
109
|
-
cto setup --
|
|
111
|
+
cto setup --refresh # re-write hooks and rules for the agents already set up
|
|
112
|
+
cto setup --uninstall # remove every cto hook, rules block and skill again
|
|
110
113
|
cto doctor # is it actually working?
|
|
111
114
|
cto check # preview the commit checks on your current changes
|
|
112
115
|
```
|
|
@@ -146,12 +149,12 @@ The rules also tell the agent to run `cto check` before committing, and never to
|
|
|
146
149
|
|
|
147
150
|
The git pre-commit check is always installed. It protects every agent and every human who commits from that repo.
|
|
148
151
|
|
|
149
|
-
| Agent | Config written | Command gate | Loop detection |
|
|
150
|
-
|
|
151
|
-
| Claude Code | `.claude/settings.local.json` | yes | yes |
|
|
152
|
-
| Cursor | `.cursor/hooks.json` | yes | yes |
|
|
153
|
-
| Gemini CLI | `.gemini/settings.json` | yes | yes |
|
|
154
|
-
| Codex CLI | `.codex/hooks.json` | yes | limited: Codex has no failure event |
|
|
152
|
+
| Agent | Config written | Command gate | Loop detection | Knows about edits | Done check |
|
|
153
|
+
|---|---|---|---|---|---|
|
|
154
|
+
| Claude Code | `.claude/settings.local.json` | yes | yes | yes | yes |
|
|
155
|
+
| Cursor | `.cursor/hooks.json` | yes | yes | yes (`afterFileEdit`) | not yet |
|
|
156
|
+
| Gemini CLI | `.gemini/settings.json` | yes | yes | yes (`write_file`, `replace`) | not yet |
|
|
157
|
+
| Codex CLI | `.codex/hooks.json` | yes | limited: Codex has no failure event | yes (`apply_patch`) | not yet |
|
|
155
158
|
|
|
156
159
|
Claude Code is tested end to end inside the agent. The Cursor, Gemini CLI and Codex adapters follow each agent's official hook docs and are tested with their documented payloads, but have not been run inside those agents yet. Reports welcome.
|
|
157
160
|
|
|
@@ -167,7 +170,7 @@ You need at least one provider. `cto setup` lets you pick which ones to use and
|
|
|
167
170
|
| [TypeSafe](https://docs.typesafe.ai/introduction/quickstart) | `TYPESAFE_API_KEY` | Direct from the makers of Jev. Get a key at console.typesafe.ai/keys. Pinned to `jev-1.13.0`, the version the thresholds were calibrated on. Not yet tested with a live key |
|
|
168
171
|
| [Cloudflare Workers AI](https://developers.cloudflare.com/ai/models/typesafe/jev/) | `CLOUDFLARE_API_TOKEN`, `CLOUDFLARE_ACCOUNT_ID` | Token needs Account > Workers AI > Read. Your account's default AI Gateway must have **Authenticated Gateway** on and Unified Billing credits |
|
|
169
172
|
|
|
170
|
-
If the first provider fails, `cto` switches to the next one in your order and tells you once. It retries the first provider later. A missing key, a timeout or an outage never blocks you: `cto` fails open and lets the action through. It only blocks when Jev answers and the answer crosses a threshold.
|
|
173
|
+
Without a picked order, the fastest measured provider goes first: OpenRouter, then TypeSafe, then Cloudflare. If the first provider fails, `cto` switches to the next one in your order and tells you once. It retries the first provider later. A missing key, a timeout or an outage never blocks you: `cto` fails open and lets the action through. It only blocks when Jev answers and the answer crosses a threshold.
|
|
171
174
|
|
|
172
175
|
**Where keys live.** Environment variables win. Otherwise `cto` reads a per-user file that `setup` writes:
|
|
173
176
|
|
|
@@ -182,6 +185,8 @@ Every check sends text to your chosen provider. `cto` masks it first:
|
|
|
182
185
|
|
|
183
186
|
- **For commits:** the staged diff, with lock files, minified files, source maps and binaries removed.
|
|
184
187
|
- **For agent commands:** the command, plus up to five failures from the last 15 minutes when checking for loops.
|
|
188
|
+
- **When Claude Code ends a turn that edited code:** the agent's final message and a log of that turn: names of edited files, the shell commands it ran, whether each succeeded, and the last 200 characters of each output.
|
|
189
|
+
- **For `cto check`:** the same as a commit; when nothing is staged, all working-tree changes, including the full content of new files git does not track yet.
|
|
185
190
|
- **Always masked:** private key blocks, Stripe, OpenAI, AWS, GitHub and npm tokens, and any `NAME=value` whose name ends in `PASSWORD`, `SECRET`, `TOKEN` or `KEY`. Every value in a `.env` file is masked as well.
|
|
186
191
|
|
|
187
192
|
Masking only controls what goes out. Jev still sees labels such as `[REDACTED: STRIPE_KEY]`, which is how it knows a real secret was there.
|
|
@@ -206,13 +211,14 @@ Defaults: `credential_leak` 0.5, `destructive_command` 0.7, `infinite_loop` 0.6,
|
|
|
206
211
|
- **`sprint_goal`**: fill it in to enable the architecture check, for example `"Ship Stripe billing, no new services"`.
|
|
207
212
|
- **Thresholds**: Jev returns a probability from 0 to 1. `code_complexity` is the exception: it is a score from 0 (clean) to 4 (unmaintainable).
|
|
208
213
|
- **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.
|
|
214
|
+
- `done_unverified` (0.6) and `infinite_loop` (0.6) were calibrated the same way; the measurements are in the design spec.
|
|
209
215
|
- In the same way, `git push --force` scored about 0.50 for `destructive_command`, so the default lets it through. Lower that threshold to about 0.45 if you want force pushes blocked.
|
|
210
216
|
|
|
211
217
|
`.cto-brain.json` holds personal runtime state and is gitignored.
|
|
212
218
|
|
|
213
219
|
| Env var | Purpose |
|
|
214
220
|
|---|---|
|
|
215
|
-
| `CTO_PROVIDER` | Use only `
|
|
221
|
+
| `CTO_PROVIDER` | Use only one provider: `openrouter`, `typesafe` or `cloudflare` |
|
|
216
222
|
| `CTO_FAILOVER=0` | Never switch providers |
|
|
217
223
|
| `CTO_LANG` | `en` or `zh-TW` (default: your locale) |
|
|
218
224
|
| `CTO_DEBUG=1` | Write masked hook input to `debug_stdin.json` |
|
package/dist/agents.js
CHANGED
|
@@ -28,6 +28,7 @@ export const agents = {
|
|
|
28
28
|
post: { event: 'PostToolUseFailure', matcher: 'Bash' },
|
|
29
29
|
stop: { event: 'Stop' },
|
|
30
30
|
edit: { event: 'PostToolUse', matcher: 'Edit|Write|MultiEdit|NotebookEdit' },
|
|
31
|
+
parseEdit: (i) => { const p = str(i?.tool_input?.file_path) ?? str(i?.tool_input?.notebook_path); return p ? [p] : undefined; },
|
|
31
32
|
parseStop: (i) => ({
|
|
32
33
|
sessionId: str(i?.session_id),
|
|
33
34
|
cwd: str(i?.cwd),
|
|
@@ -47,6 +48,8 @@ export const agents = {
|
|
|
47
48
|
style: 'cursor',
|
|
48
49
|
pre: { event: 'beforeShellExecution' },
|
|
49
50
|
post: { event: 'postToolUseFailure' },
|
|
51
|
+
edit: { event: 'afterFileEdit' },
|
|
52
|
+
parseEdit: (i) => { const p = str(i?.file_path); return p ? [p] : undefined; },
|
|
50
53
|
parsePre: (i) => ({ command: str(i?.command), sessionId: str(i?.conversation_id), cwd: str(i?.cwd) ?? str(i?.workspace_roots?.[0]) }),
|
|
51
54
|
parsePost: (i) => i?.tool_name !== 'Shell' || i?.is_interrupt || !str(i?.error_message)
|
|
52
55
|
? null
|
|
@@ -66,6 +69,8 @@ export const agents = {
|
|
|
66
69
|
style: 'nested',
|
|
67
70
|
pre: { event: 'BeforeTool', matcher: 'run_shell_command' },
|
|
68
71
|
post: { event: 'AfterTool', matcher: 'run_shell_command' },
|
|
72
|
+
edit: { event: 'AfterTool', matcher: 'write_file|replace' },
|
|
73
|
+
parseEdit: (i) => { const p = str(i?.tool_input?.file_path); return p ? [p] : undefined; },
|
|
69
74
|
parsePre: nestedPre,
|
|
70
75
|
parsePost: (i) => {
|
|
71
76
|
if (i?.tool_name !== 'run_shell_command')
|
|
@@ -85,6 +90,12 @@ export const agents = {
|
|
|
85
90
|
pre: { event: 'PreToolUse', matcher: 'Bash' },
|
|
86
91
|
// Codex has no failure event; PostToolUse is recorded only when its output shows a non-zero exit.
|
|
87
92
|
post: { event: 'PostToolUse', matcher: 'Bash' },
|
|
93
|
+
// Codex edits through apply_patch; the patch text names each file ("*** Update File: src/a.ts").
|
|
94
|
+
edit: { event: 'PostToolUse', matcher: 'apply_patch' },
|
|
95
|
+
parseEdit: (i) => {
|
|
96
|
+
const files = [...String(i?.tool_input?.command ?? '').matchAll(/^\*\*\* (?:Add|Update|Delete) File: (.+)$/gm)].map((m) => m[1].trim());
|
|
97
|
+
return files.length ? files : undefined;
|
|
98
|
+
},
|
|
88
99
|
note: 'note_codex_trust',
|
|
89
100
|
parsePre: nestedPre,
|
|
90
101
|
parsePost: (i) => {
|
package/dist/api.js
CHANGED
|
@@ -34,6 +34,9 @@ export const providers = {
|
|
|
34
34
|
body: ({ session_id: _, ...req }) => ({ model: 'jev-1.13.0', ...req }),
|
|
35
35
|
},
|
|
36
36
|
};
|
|
37
|
+
// Default order when nothing was ever picked: fastest measured first (OpenRouter p95 ~0.33 s; Cloudflare p50 ~0.9 s
|
|
38
|
+
// with spikes past 3 s, 2026-10-02/05). TypeSafe direct sits in between until it has been measured.
|
|
39
|
+
export const DEFAULT_ORDER = ['openrouter', 'typesafe', 'cloudflare'];
|
|
37
40
|
/**
|
|
38
41
|
* Providers to try, in order: CTO_PROVIDER > the order picked in setup (only those; an empty pick means none) > every
|
|
39
42
|
* provider with a key when nothing was ever picked.
|
|
@@ -41,7 +44,7 @@ export const providers = {
|
|
|
41
44
|
*/
|
|
42
45
|
export function providerOrder() {
|
|
43
46
|
const picked = loadPrefs().provider_order;
|
|
44
|
-
const order = env.CTO_PROVIDER ? [env.CTO_PROVIDER] : picked !== undefined ? picked :
|
|
47
|
+
const order = env.CTO_PROVIDER ? [env.CTO_PROVIDER] : picked !== undefined ? picked : DEFAULT_ORDER;
|
|
45
48
|
return order.filter((n) => providers[n]?.enabled());
|
|
46
49
|
}
|
|
47
50
|
async function callOnce(name, req, timeoutMs) {
|
package/dist/doctor.js
CHANGED
|
@@ -2,12 +2,12 @@ import { execFileSync } from 'node:child_process';
|
|
|
2
2
|
import { existsSync, readFileSync } from 'node:fs';
|
|
3
3
|
import { join } from 'node:path';
|
|
4
4
|
import { agents } from './agents.js';
|
|
5
|
-
import { probeProvider, providers } from './api.js';
|
|
5
|
+
import { probeProvider, providerOrder, providers } from './api.js';
|
|
6
6
|
import { loadBrain, loadConfig, loadCredentials } from './brain.js';
|
|
7
7
|
import { AGENT_TIMEOUT_MS } from './hooks.js';
|
|
8
8
|
import { t } from './i18n.js';
|
|
9
|
-
import { missingHooks, wiredAgents } from './setup.js';
|
|
10
|
-
import { staleGuidance } from './skill.js';
|
|
9
|
+
import { ignoredByGit, missingHooks, wiredAgents } from './setup.js';
|
|
10
|
+
import { guidancePaths, staleGuidance } from './skill.js';
|
|
11
11
|
import { checkUpdate, currentVersion } from './update.js';
|
|
12
12
|
function hint(provider, status) {
|
|
13
13
|
if (status === '401')
|
|
@@ -20,8 +20,17 @@ function hint(provider, status) {
|
|
|
20
20
|
return 'doc_hint_network';
|
|
21
21
|
return 'doc_hint_other';
|
|
22
22
|
}
|
|
23
|
+
const isTracked = (root, p) => {
|
|
24
|
+
try {
|
|
25
|
+
execFileSync('git', ['ls-files', '--error-unmatch', p], { cwd: root, stdio: 'ignore' });
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
23
32
|
/** One screen answering "is cto actually working here?". Exit 1 when it is not. */
|
|
24
|
-
export async function doctor(cwd, lang) {
|
|
33
|
+
export async function doctor(cwd, lang, slowMs = AGENT_TIMEOUT_MS) {
|
|
25
34
|
const L = [];
|
|
26
35
|
const problems = [];
|
|
27
36
|
const latest = await checkUpdate();
|
|
@@ -30,6 +39,7 @@ export async function doctor(cwd, lang) {
|
|
|
30
39
|
L.push('', t(lang, 'doc_keys'));
|
|
31
40
|
const file = loadCredentials();
|
|
32
41
|
let working = 0;
|
|
42
|
+
const primary = providerOrder()[0];
|
|
33
43
|
for (const name of Object.keys(providers)) {
|
|
34
44
|
const label = providers[name].label;
|
|
35
45
|
const missing = providers[name].keys.filter((k) => !process.env[k]);
|
|
@@ -44,10 +54,13 @@ export async function doctor(cwd, lang) {
|
|
|
44
54
|
const ms = Math.round(performance.now() - start);
|
|
45
55
|
if (r.ok) {
|
|
46
56
|
working++;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
57
|
+
// Only the provider tried first decides whether checks finish in time; a slow backup is worth a note, not a failure.
|
|
58
|
+
const slow = ms > slowMs;
|
|
59
|
+
const mark = !slow ? 'OK' : name === primary ? '!!' : '--';
|
|
60
|
+
const note = !slow ? '' : ' ' + t(lang, name === primary ? 'doc_slow' : 'doc_slow_backup', { limit: slowMs / 1000 });
|
|
61
|
+
L.push(` ${mark} ${label} (${source}): ${t(lang, 'doc_ok', { ms })}${note}`);
|
|
62
|
+
if (slow && name === primary)
|
|
63
|
+
problems.push(t(lang, 'doc_slow', { limit: slowMs / 1000 }));
|
|
51
64
|
}
|
|
52
65
|
else {
|
|
53
66
|
L.push(` !! ${label} (${source}): ${t(lang, 'doc_fail', { status: r.status })} ${r.message ?? ''}`.trimEnd());
|
|
@@ -79,6 +92,10 @@ export async function doctor(cwd, lang) {
|
|
|
79
92
|
}
|
|
80
93
|
const wired = wiredAgents(root);
|
|
81
94
|
L.push(` ${wired.length ? 'OK' : '--'} ${t(lang, 'doc_agents', { list: wired.map((n) => agents[n].label).join(', ') || t(lang, 'doc_none') })}`);
|
|
95
|
+
// Only files git ignores AND does not track yet: once added with -f they are tracked and fine.
|
|
96
|
+
const hidden = ignoredByGit(root, guidancePaths(wired)).filter((p) => !isTracked(root, p));
|
|
97
|
+
if (hidden.length)
|
|
98
|
+
L.push(` -- ${t(lang, 'doc_ignored', { list: hidden.join(', '), cmd: `git add -f ${hidden.join(' ')}` })}`);
|
|
82
99
|
const stale = [...missingHooks(root), ...staleGuidance(root, wired)];
|
|
83
100
|
if (stale.length) {
|
|
84
101
|
L.push(` !! ${t(lang, 'doc_stale', { list: stale.join(', ') })}`);
|
package/dist/hooks.js
CHANGED
|
@@ -282,8 +282,8 @@ export async function agentStop(input, { root, lang, now }) {
|
|
|
282
282
|
* re-run after a fix is a new attempt, but the same error coming back across repeated fixes is still a loop, and only
|
|
283
283
|
* the history shows that. Local only: no Jev call, no network. Docs/YAML edits do not count.
|
|
284
284
|
*/
|
|
285
|
-
export function agentEdit(
|
|
286
|
-
if (
|
|
285
|
+
export function agentEdit(files, { root }) {
|
|
286
|
+
if (files && !files.some(isCodeFile))
|
|
287
287
|
return { code: 0, stderr: [] };
|
|
288
288
|
const brain = loadBrain(root);
|
|
289
289
|
if (brain.recent_errors.some((e) => !e.edited_after)) {
|
package/dist/i18n.js
CHANGED
|
@@ -123,6 +123,9 @@ const messages = {
|
|
|
123
123
|
check_result_block: () => '[cto] 現在 commit 會被擋下,先修正上面標示的問題。',
|
|
124
124
|
setup_skill: (v) => `[cto] cto 開發規矩已寫入 ${v.path}`,
|
|
125
125
|
refresh_none: () => '[cto] 這個 repo 還沒設定 cto,請先執行 cto setup。',
|
|
126
|
+
setup_ignored: (v) => `[cto] 注意:${v.list} 被 .gitignore 排除,commit 時不會帶上,隊友的 agent 讀不到。要分享就執行:${v.cmd}`,
|
|
127
|
+
doc_ignored: (v) => `${v.list} 被 .gitignore 排除且尚未加入 git,只存在這台電腦。要分享給隊友就執行:${v.cmd}`,
|
|
128
|
+
doc_slow_backup: (v) => `備援 provider 這次超過 ${v.limit} 秒;主要 provider 正常時不影響檢查`,
|
|
126
129
|
refresh_after_update: () => '[cto] 正在用新版更新目前 repo 的 hook 與規矩…',
|
|
127
130
|
doc_stale: (v) => `這個 repo 的 cto 設定比目前版本舊(${v.list}),執行 cto setup --refresh`,
|
|
128
131
|
uninstall_skill: (v) => `[cto] 已移除 cto 開發規矩:${v.path}`,
|
|
@@ -252,6 +255,9 @@ const messages = {
|
|
|
252
255
|
check_result_block: () => '[cto] A commit now would be blocked. Fix what is flagged above first.',
|
|
253
256
|
setup_skill: (v) => `[cto] cto rules written to ${v.path}`,
|
|
254
257
|
refresh_none: () => '[cto] cto is not set up in this repo yet. Run cto setup first.',
|
|
258
|
+
setup_ignored: (v) => `[cto] Note: ${v.list} is ignored by .gitignore, so it will not be committed and teammates' agents will not see it. To share it, run: ${v.cmd}`,
|
|
259
|
+
doc_ignored: (v) => `${v.list} is ignored by .gitignore and not tracked, so it exists only on this machine. To share it with teammates, run: ${v.cmd}`,
|
|
260
|
+
doc_slow_backup: (v) => `this backup provider took longer than ${v.limit} s; checks are unaffected while the primary is healthy`,
|
|
255
261
|
refresh_after_update: () => '[cto] Refreshing hooks and rules in this repo with the new version…',
|
|
256
262
|
doc_stale: (v) => `cto in this repo is older than this version (${v.list}). Run cto setup --refresh`,
|
|
257
263
|
uninstall_skill: (v) => `[cto] Removed cto rules: ${v.path}`,
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { writeFileSync } from 'node:fs';
|
|
|
4
4
|
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
|
-
import { providerOrder, providers } from './api.js';
|
|
7
|
+
import { DEFAULT_ORDER, providerOrder, providers } from './api.js';
|
|
8
8
|
import { agentEdit, agentPost, agentPre, agentStop, gitCommit, stagedDiff } from './hooks.js';
|
|
9
9
|
import { checkUpdate, currentVersion, runUpdate } from './update.js';
|
|
10
10
|
import { doctor } from './doctor.js';
|
|
@@ -52,8 +52,8 @@ async function runHook(name) {
|
|
|
52
52
|
}
|
|
53
53
|
catch { /* fail-open below */ }
|
|
54
54
|
if (m[2] === 'edit') {
|
|
55
|
-
const
|
|
56
|
-
return agentEdit(
|
|
55
|
+
const cwd = typeof input?.cwd === 'string' ? input.cwd : typeof input?.workspace_roots?.[0] === 'string' ? input.workspace_roots[0] : process.cwd();
|
|
56
|
+
return agentEdit(agent.parseEdit?.(input), { root: findRoot(cwd), lang });
|
|
57
57
|
}
|
|
58
58
|
if (m[2] === 'stop') {
|
|
59
59
|
if (!agent.parseStop)
|
|
@@ -115,7 +115,7 @@ else if (args[0] === 'setup') {
|
|
|
115
115
|
const wired = wiredAgents(root);
|
|
116
116
|
const initial = {
|
|
117
117
|
agents: wired.length ? wired : detectAgents(),
|
|
118
|
-
providers: prefs.provider_order ??
|
|
118
|
+
providers: prefs.provider_order ?? DEFAULT_ORDER.filter((p) => providers[p].enabled()),
|
|
119
119
|
keys: fileKeys,
|
|
120
120
|
lang: prefs.lang,
|
|
121
121
|
goal: loadConfig(root).sprint_goal,
|
package/dist/setup.js
CHANGED
|
@@ -4,7 +4,7 @@ import { homedir } from 'node:os';
|
|
|
4
4
|
import { basename, dirname, join, relative } from 'node:path';
|
|
5
5
|
import { agentNames, agents, hookCommand } from './agents.js';
|
|
6
6
|
import { t } from './i18n.js';
|
|
7
|
-
import { syncGuidance } from './skill.js';
|
|
7
|
+
import { guidancePaths, syncGuidance } from './skill.js';
|
|
8
8
|
const START = '# >>> YOUR CTO JEV START >>>';
|
|
9
9
|
const END = '# <<< YOUR CTO JEV END <<<';
|
|
10
10
|
// Keep the block minimal: all logic (including the git diff call) lives in the package, so npm update upgrades every repo.
|
|
@@ -209,6 +209,10 @@ export function setup(cwd, lang, opts = {}) {
|
|
|
209
209
|
const skills = syncGuidance(root, chosen, !!opts.exact);
|
|
210
210
|
for (const p of skills.written)
|
|
211
211
|
lines.push(t(lang, 'setup_skill', { path: p }));
|
|
212
|
+
const hidden = ignoredByGit(root, guidancePaths(chosen));
|
|
213
|
+
// Advise git add -f: a .gitignore negation cannot re-include a file whose parent folder is excluded (git rule).
|
|
214
|
+
if (hidden.length)
|
|
215
|
+
lines.push(t(lang, 'setup_ignored', { list: hidden.join(', '), cmd: `git add -f ${hidden.join(' ')}` }));
|
|
212
216
|
for (const p of skills.removed)
|
|
213
217
|
lines.push(t(lang, 'uninstall_skill', { path: p }));
|
|
214
218
|
// 3. .gitignore block.
|
|
@@ -245,6 +249,21 @@ export function missingHooks(root) {
|
|
|
245
249
|
}
|
|
246
250
|
return missing;
|
|
247
251
|
}
|
|
252
|
+
/**
|
|
253
|
+
* Paths git would ignore. cto's rules are meant to be committed so every teammate's agent follows them; a repo
|
|
254
|
+
* .gitignore that excludes them (often a broad rule like .agents/skills/) silently keeps them on one machine.
|
|
255
|
+
*/
|
|
256
|
+
export function ignoredByGit(root, paths) {
|
|
257
|
+
return paths.filter((p) => {
|
|
258
|
+
try {
|
|
259
|
+
execFileSync('git', ['check-ignore', '-q', p], { cwd: root, stdio: 'ignore' });
|
|
260
|
+
return true;
|
|
261
|
+
}
|
|
262
|
+
catch {
|
|
263
|
+
return false;
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
}
|
|
248
267
|
/** Agents whose config in this repo currently calls cto. */
|
|
249
268
|
export function wiredAgents(root) {
|
|
250
269
|
return agentNames.filter((n) => {
|
package/dist/setupui.js
CHANGED
|
@@ -2,10 +2,10 @@ import { MultiSelectPrompt } from '@clack/core';
|
|
|
2
2
|
import { S_BAR, S_BAR_END, S_STEP_ACTIVE, S_STEP_CANCEL, S_STEP_SUBMIT, intro, isCancel, log, multiselect, outro, password, select, spinner, text } from '@clack/prompts';
|
|
3
3
|
import { styleText } from 'node:util';
|
|
4
4
|
import { agentNames, agents } from './agents.js';
|
|
5
|
-
import { probeProvider, providers } from './api.js';
|
|
5
|
+
import { DEFAULT_ORDER, probeProvider, providers } from './api.js';
|
|
6
6
|
import { t } from './i18n.js';
|
|
7
7
|
const BACK = Symbol('back');
|
|
8
|
-
const PROVIDER_ORDER =
|
|
8
|
+
const PROVIDER_ORDER = DEFAULT_ORDER;
|
|
9
9
|
const dim = (s) => styleText('dim', s);
|
|
10
10
|
const tail = (v) => `…${v.slice(-4)}`;
|
|
11
11
|
/** Terminal columns: CJK and full-width characters take two. */
|
package/dist/skill.js
CHANGED
|
@@ -134,6 +134,13 @@ export function syncGuidance(root, chosen, removeOthers) {
|
|
|
134
134
|
removeFileAndEmptyDirs(root, legacy);
|
|
135
135
|
return { written, removed };
|
|
136
136
|
}
|
|
137
|
+
/** The guidance files the given agents use (what should be committed for them). */
|
|
138
|
+
export function guidancePaths(agentsInUse) {
|
|
139
|
+
const set = new Set(agentsInUse);
|
|
140
|
+
if (!set.size)
|
|
141
|
+
return [];
|
|
142
|
+
return [...MEMORY_FILES.filter((m) => m.agents.some((a) => set.has(a))).map((m) => m.path), SKILL_PATH];
|
|
143
|
+
}
|
|
137
144
|
/** Guidance files that are missing or differ from what this version would write, for the given agents. */
|
|
138
145
|
export function staleGuidance(root, agentsInUse) {
|
|
139
146
|
if (!agentsInUse.length)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "your-cto-jev",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.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",
|