@mcgrapeng/ccg 3.1.0 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,220 +1,717 @@
1
- # ccg — Code Divergence Detector
1
+ # CCG — Code Change Guardian
2
2
 
3
- > A Claude Code slash command. Install once, type `/ccg` on a diff.
3
+ [![License](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
4
+ [![Bash](https://img.shields.io/badge/Shell-Bash%203.2%2B-green.svg)]()
5
+ [![Models](https://img.shields.io/badge/Models-25%2B-purple.svg)]()
4
6
 
5
- [![Tests](https://img.shields.io/badge/tests-99%20passing-brightgreen.svg)]()
6
- [![npm](https://img.shields.io/npm/v/@mcgrapeng/ccg.svg)](https://www.npmjs.com/package/@mcgrapeng/ccg)
7
- [![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
7
+ > **CCG (Code Change Guardian)** is a multi-model code review and Git workflow automation system.
8
+ > Two independent AI model families guard every change across **Review · Commit · Merge · Push** —
9
+ > divergence-aware review, risk-aware model routing, AI merge-conflict resolution, and a pre-push gate,
10
+ > from the working tree to the remote.
8
11
 
9
- **English** [简体中文](README.zh-CN.md) [日本語](README.ja.md) [한국어](README.ko.md) · [Architecture →](docs/ARCHITECTURE.md)
12
+ CCG runs two independent models in parallel on each diff and lets Claude synthesize their findings. When they **agree**, signal is low; when they **diverge**, that's where humans should focus. Beyond review it adds a zero-LLM commit gate, AI-powered merge-conflict resolution, and a graphical pre-push scorecard — with a JSONL ledger that makes every review reusable.
13
+
14
+ **Other languages**: [简体中文](docs/README.zh-CN.md) · [日本語](docs/README.ja.md) · [한국어](docs/README.ko.md)
10
15
 
11
16
  ---
12
17
 
13
- ## What is ccg
18
+ ## Table of Contents
14
19
 
15
- You're about to merge a change to `auth/login.go`. You want a sanity check. Today you have three options, all of them flawed:
20
+ - [Why CCG](#why-ccg)
21
+ - [Installation](#installation)
22
+ - [Quick Start](#quick-start)
23
+ - [The 4 Stages](#the-4-stages)
24
+ - [Model Strategy](#model-strategy)
25
+ - [Configuration](#configuration)
26
+ - [Architecture](#architecture)
27
+ - [Documentation](#documentation)
16
28
 
17
- - **Single-model review** (Copilot, Cursor `/review`, Aider) gives you **one perspective**. If Claude misses a timing attack, you miss it too.
18
- - **Multi-model gateways** (zen-mcp-server etc.) **average opinions**, hiding exactly the places where smart models disagreed — which is the only place you actually needed help.
19
- - **Manual cross-checking** is what you'd do if you had unlimited time. You don't.
29
+ ---
20
30
 
21
- ccg is a `/ccg` slash command for Claude Code that fixes all three. On any diff, it:
31
+ ## Why CCG
22
32
 
23
- 1. Sends the same prompt to **Codex (OpenAI)** and **Gemini (Google)** in parallel
24
- 2. Has **Claude** read both reports and surface **specifically where they disagree** — that's where human judgment is needed
25
- 3. Tracks cost, picks the cheapest model good enough for the risk level, and remembers past reviews
33
+ CCG guards the entire path from working tree to remote not just the review step. Each stage targets a specific pain point:
26
34
 
27
- **Think of it like:** asking two senior engineers from different teams to review the same PR, then having a tech lead synthesize: "they agree on these issues, they disagree on this one — you decide, and here's my read."
35
+ | Problem | CCG's Answer |
36
+ |---|---|
37
+ | Single-model review has blind spots | Two independent model families review in parallel — surface where they **disagree** |
38
+ | One-size-fits-all model wastes money / quality | Risk-aware auto-routing: cheap for low-risk, premium for critical |
39
+ | Merge conflicts are tedious and error-prone | **AI conflict resolution with Bailian as primary** — multiple safety guards, never silently drops code |
40
+ | Push decisions lack context | Stage 4 produces a **graphical quality scorecard** before push |
41
+ | Reviews aren't reusable | JSONL ledger captures every review, queryable by path |
28
42
 
29
- ## When to use ccg
43
+ ---
30
44
 
31
- The trigger isn't a *domain* — it's a *feeling*. Use ccg when, looking at your own diff, you catch yourself thinking:
45
+ ## Installation
32
46
 
33
- | Inner monologue | Use ccg? |
34
- |---|---|
35
- | "If I get this wrong, I'll get paged at 3am." | ✅ Yes |
36
- | "This is a judgment call — no obviously right answer." | ✅ Yes |
37
- | "I wish someone else would look at this first." | ✅ Yes |
38
- | "I just renamed a variable." | ❌ No |
39
- | "Docs-only change." | ❌ No |
40
- | "I want streaming chat with one model." | ❌ No (use the CLI directly) |
47
+ ### npm 安装(推荐)
41
48
 
42
- **Examples across domains** — none of these are auth/crypto, all of them are real "two senior engineers would disagree" moments:
49
+ ```bash
50
+ npm install -g @mcgrapeng/ccg
51
+ ```
43
52
 
44
- - **Social platforms** — re-ranking the feed with a new engagement signal · comment-thread fan-out strategy · A/B test bucketing logic · anti-abuse rate-limit policy · graph-DB schema for follow relationships
45
- - **Data / AI infra** — switching embedding model (do you re-index?) · changing chunking strategy · RAG retrieval scoring · prompt-injection defense layering
46
- - **Frontend** — SSR vs ISR vs RSC for a new page · cache invalidation strategy · state-management refactor · accessibility trade-offs
47
- - **API design** — cursor vs offset pagination · error response model · versioning approach · idempotency-key handling
48
- - **Distributed systems** — timeout/retry policy · cache TTL vs event-driven invalidation · partition tolerance trade-off · leader-election semantics
49
- - **Database** — multi-step migration sequencing · index choice on a hot path · transaction isolation level · soft-delete vs hard-delete
50
- - **Security** — yes, auth / crypto / payments too — but just one of many domains
53
+ ### 从源码安装
51
54
 
52
- **The pattern:** any change where a reasonable engineer might pick option A and another reasonable engineer might pick option B. That's when divergence detection earns its $0.04.
55
+ ```bash
56
+ git clone https://github.com/mcgrapeng/ccg.git
57
+ cd ccg
58
+ npm link
59
+ ```
60
+
61
+ ### 验证安装
53
62
 
54
- ## Why ccg (vs everything else)
63
+ ```bash
64
+ ccg --version
65
+ ccg doctor # 检查环境配置
66
+ ccg config # 显示当前配置
67
+ ccg models # 列出所有可用模型
68
+ ```
69
+
70
+ **环境要求:**
71
+ - `bash 3.2+`, `git`, `curl`, `jq`
72
+ - Node.js >= 16
73
+
74
+ **配置 API 密钥(至少一个):**
75
+ ```bash
76
+ # 阿里云百炼(国内推荐)
77
+ export BAILIAN_API_KEY="sk-xxxx"
55
78
 
56
- **1. Disagreement is the signal, not the noise.**
57
- When Codex says "use `subtle.ConstantTimeCompare`" and Gemini says "bcrypt is already constant-time, that's cargo-cult", *that* is where you need to think. Other tools blend these into a vague "consider timing attacks". ccg shows you the conflict verbatim.
79
+ # Anthropic Claude
80
+ export ANTHROPIC_API_KEY="sk-ant-xxxx"
58
81
 
59
- **2. Cost telemetry built in.**
60
- Codex/Gemini CLIs don't tell you what you spent. ccg logs every call, picks the cheapest sufficient model automatically (risk-aware routing), and caches identical prompts for 24h. `ccg_usage --this-month` answers "how much have I spent so far?".
82
+ # Google Gemini
83
+ export GEMINI_API_KEY="AIzaSy-xxxx"
84
+ ```
61
85
 
62
- **3. A review history that survives across sessions.**
63
- "What did the model say about `src/auth.ts` two weeks ago?" ccg's append-only ledger answers that. No stateless tool can.
86
+ **自定义 API 端点(支持第三方代理):**
87
+ - `CCG_CODEX_BASE_URL` / `OPENAI_BASE_URL` — Codex / OpenAI 代理
88
+ - `CCG_CLAUDE_BASE_URL` / `ANTHROPIC_BASE_URL` — Claude / Anthropic 代理
89
+ - `CCG_GEMINI_BASE_URL` / `GEMINI_BASE_URL` — Gemini 代理
90
+ - `CCG_BAILIAN_BASE_URL` — 百炼代理
64
91
 
65
- ## Install
92
+ ---
66
93
 
67
- Pick one:
94
+ ## Quick Start
68
95
 
69
96
  ```bash
70
- # npm (recommended)
71
- npx @mcgrapeng/ccg install
97
+ # 1. Review your current changes
98
+ ccg review
99
+
100
+ # 2. Auto-commit if review gate passes
101
+ ccg commit "feat: add user auth"
102
+
103
+ # 3. Merge with AI conflict resolution
104
+ ccg merge main
72
105
 
73
- # or curl one-liner, no Node
74
- curl -fsSL https://raw.githubusercontent.com/mcgrapeng/ccg/main/scripts/curl-install.sh | bash
106
+ # 4. Pre-push graphical analysis & decision
107
+ ccg push origin main
108
+
109
+ # Helper commands
110
+ ccg config # Show current configuration
111
+ ccg models # List all available models
75
112
  ```
76
113
 
77
- Then install the AI CLIs once:
114
+ ### Skip Review Mode
115
+
116
+ For trivial changes (docs, typos) you can disable Stage 1 entirely:
78
117
 
79
118
  ```bash
80
- npm i -g @openai/codex @google/gemini-cli
81
- echo 'export GEMINI_API_KEY="<your-key>"' >> ~/.zshenv
119
+ # Skip review commit becomes the first stage
120
+ export CCG_REVIEW=off
121
+
122
+ ccg commit "docs: fix typo" # Auto git add + commits (no LLM)
123
+ ccg push origin main # Push still works
124
+
125
+ # Re-enable later
126
+ unset CCG_REVIEW # or: export CCG_REVIEW=on
127
+ ```
128
+
129
+ The `CCG_REVIEW` switch accepts: `on` (default) / `off` / `0` / `false` / `disabled`.
130
+
131
+ ---
132
+
133
+ ## Complete Workflow
134
+
135
+ ### Default Flow (Review enabled)
136
+
82
137
  ```
138
+ ┌───────────────────────────────────────────────────────────────────────┐
139
+ │ Stage 1: ccg review 【3 LLM calls】 │
140
+ │ ───────────────────── │
141
+ │ 1. ccg_init → mktemp workdir + paths │
142
+ │ 2. ccg_diff_capture → 4-level fallback (worktree / staged / ...) │
143
+ │ 3. ccg_risk_score → Bailian LLM (fallback: rule engine) │
144
+ │ 4. Auto-pick CCG_MODE (cost/balanced/quality) by risk │
145
+ │ 5. Run any 2 providers in parallel (codex/gemini/bailian) │
146
+ │ 6. ccg_synthesize → Claude meta-review │
147
+ │ → CLASSIFICATION: AGREEMENT / DIVERGENCE / BLINDSPOT │
148
+ │ → VERDICT: merge / fix-required / discuss │
149
+ │ 7. Persist state to <repo>/.git/ccg/last-review.json │
150
+ └───────────────────────────────────────────────────────────────────────┘
151
+
152
+ ┌───────────────────────────────────────────────────────────────────────┐
153
+ │ Stage 2: ccg commit "msg" 【0 LLM calls】 │
154
+ │ ───────────────────────── │
155
+ │ 1. git add -A (auto-stage worktree; opt out via │
156
+ │ CCG_NO_AUTO_ADD=1) │
157
+ │ 2. Read last-review.json (refuses if missing) │
158
+ │ 3. Compare staged diff hash with reviewed hash │
159
+ │ → mismatch? refuse and ask user to re-run 'ccg review' │
160
+ │ 4. Apply verdict: │
161
+ │ • merge → ✅ commit │
162
+ │ • discuss → ⚠️ commit (or block if CCG_GATE_DISCUSS=block) │
163
+ │ • fix-required → ❌ block │
164
+ │ 5. git commit -m "msg" │
165
+ │ 6. Delete state file (one-shot) │
166
+ └───────────────────────────────────────────────────────────────────────┘
167
+
168
+ ┌───────────────────────────────────────────────────────────────────────┐
169
+ │ Stage 3: ccg merge <target> 【on-demand LLM】 │
170
+ │ ─────────────────────────── │
171
+ │ 1. Safety checks: clean tree, no detached HEAD, no mid-op │
172
+ │ 2. git fetch + sync local target with origin │
173
+ │ 3. Create backup branch (ccg-backup/<target>-<ts>-<pid>-<rand>) │
174
+ │ 4. git checkout target + git merge --no-commit feature │
175
+ │ 5. For each conflict file: │
176
+ │ a. classify (content / binary / submodule / symlink / ...) │
177
+ │ b. parse <<<<<<< >>>>>>> blocks │
178
+ │ c. AI resolution (Bailian → Claude → Codex+Gemini) │
179
+ │ d. validate (no markdown fences, no conflict markers, non-empty) │
180
+ │ e. atomic file rewrite (mktemp + mv, preserve perms) │
181
+ │ f. git add (only if resolved cleanly) │
182
+ │ 6. git commit (if all clean) OR leave uncommitted (if needs-human) │
183
+ │ 7. Real-time progress: [3/12] src/auth.js ... ✅ resolved │
184
+ └───────────────────────────────────────────────────────────────────────┘
185
+
186
+ ┌───────────────────────────────────────────────────────────────────────┐
187
+ │ Stage 4: ccg push <remote> <branch> 【1 LLM call】 │
188
+ │ ────────────────────────────────── │
189
+ │ 1. Detect upstream + remote URL │
190
+ │ 2. Compute commits ahead / behind │
191
+ │ 3. List commits with quality markers (✓ conventional / ⚠ WIP) │
192
+ │ 4. Categorize files (💻 code / 🧪 tests / 📖 docs / ⚙️ config) │
193
+ │ 5. Detect sensitive files (.env / *.pem / credentials / ...) │
194
+ │ 6. ccg_risk_score on the push diff (Bailian LLM) │
195
+ │ 7. Quality Scorecard (5 checks): │
196
+ │ • conventional commit messages │
197
+ │ • tests updated alongside code │
198
+ │ • no sensitive files │
199
+ │ • up to date with remote │
200
+ │ • risk level acceptable │
201
+ │ 8. Recommendation: 🟢 READY / 🟡 CAUTION / 🔴 NOT RECOMMENDED │
202
+ │ 9. Decision prompt: y/n/d (diff)/l (log) │
203
+ │ 10. git push (if y) │
204
+ └───────────────────────────────────────────────────────────────────────┘
205
+ ```
206
+
207
+ ### Skip-Review Flow (`CCG_REVIEW=off`)
208
+
209
+ ```
210
+ ┌───────────────────────────────────────────────────────────────────────┐
211
+ │ Stage 1: ccg review 【0 LLM calls】│
212
+ │ → ℹ️ Review stage is DISABLED — no-op │
213
+ └───────────────────────────────────────────────────────────────────────┘
214
+
215
+ ┌───────────────────────────────────────────────────────────────────────┐
216
+ │ Stage 2: ccg commit "msg" 【0 LLM calls】│
217
+ │ → 1. git add -A │
218
+ │ → 2. ⚠️ Review stage DISABLED — committing without review │
219
+ │ → 3. git commit -m "msg" │
220
+ └───────────────────────────────────────────────────────────────────────┘
221
+
222
+ (Stage 3 / Stage 4 unchanged from default flow)
223
+ ```
224
+
225
+ ---
83
226
 
84
- Verify:
227
+ ---
85
228
 
229
+ ## The 4 Stages
230
+
231
+ CCG is built around four stages. Each has a specific purpose, model strategy, and safety guarantees.
232
+
233
+ ### Stage 1 — Code Review (`ccg review`)
234
+
235
+ **Purpose**: Identify bugs, security issues, and quality problems in your diff.
236
+
237
+ **Model strategy**:
238
+ - Runs **any 2 models in parallel** from different vendors
239
+ - **Default depends on mode**:
240
+ - `cost`/`balanced`: two different-vendor Bailian models (e.g., `qwen-3.5-haiku` + `deepseek-v4-lite`)
241
+ - `quality`: `codex + gemini` (CLI-based, independent)
242
+ - **🚫 Claude is STRICTLY FORBIDDEN in Stage 1** — it is reserved exclusively for the Synthesis step where it serves as the meta-reviewer with an independent perspective
243
+ - Models are selected by current `CCG_MODE` (see [Model Strategy](#model-strategy))
244
+
245
+ **`CCG_PROVIDERS` syntax** (Stage 1 only — max 2 parallel):
86
246
  ```bash
87
- npx @mcgrapeng/ccg doctor # check Codex / Gemini / API key
88
- npx @mcgrapeng/ccg about # 7-layer capability probe + runtime state
247
+ # quality mode default codex + gemini (CLI-based, independent)
248
+ CCG_PROVIDERS="codex gemini"
249
+
250
+ # Same provider, two different models — e.g., 2 Bailian models in parallel
251
+ CCG_PROVIDERS="bailian:qwen-3.7 bailian:deepseek-v4"
252
+
253
+ # Mix providers with explicit model overrides (quality mode only)
254
+ CCG_MODE=quality CCG_PROVIDERS="codex:gpt-5.5 gemini:gemini-3.5-flash"
255
+
256
+ # Cost optimization — all domestic models
257
+ CCG_PROVIDERS="bailian:kimi-k2.6 bailian:glm-5.1"
258
+
259
+ # ❌ DO NOT do this — claude is rejected and ccg review will return error
260
+ # CCG_PROVIDERS="claude codex"
261
+ ```
262
+
263
+ **Output**: Synthesis classified as one of:
264
+ - `AGREEMENT` — both reviewers flag same issues (high confidence)
265
+ - `DIVERGENCE` — reviewers contradict (needs human judgment)
266
+ - `BLINDSPOT` — one missed issues the other caught (highest signal)
267
+
268
+ **Pipeline**:
269
+ ```
270
+ git diff → risk scoring → mode selection
271
+ → parallel: [Codex review + Bailian review]
272
+ → synthesize → AGREEMENT | DIVERGENCE | BLINDSPOT
89
273
  ```
90
274
 
91
- ## Try it — a walkthrough
275
+ **Safety guarantees**:
276
+ - Prompt injection defense (untrusted-content markers, per-call nonce)
277
+ - Diff size warning (>200KB may exceed context)
278
+ - Cleanup trap (Ctrl+C kills child processes)
279
+ - Partial-failure handling (1/2 success → continue with warning)
92
280
 
93
- Say you just edited `auth/login.go`:
281
+ ---
94
282
 
95
- ```go
96
- // before // after
97
- func Login(user, pw string) bool { func Login(user, pw string) bool {
98
- u := lookupUser(user) u := lookupUser(user)
99
- - return u.Hash == sha256.Sum256([]byte(pw)) hashed, err := bcrypt.GenerateFromPassword([]byte(pw), 12)
100
- + if err != nil { return false }
101
- + return subtle.ConstantTimeCompare(u.Hash, hashed) == 1
283
+ ### Stage 2 — Auto Commit (`ccg commit`)
284
+
285
+ **Purpose**: Enforce that only reviewed code reaches git history **without any extra LLM calls**.
286
+
287
+ **Model strategy**: 🚫 **No LLM calls in Stage 2**. Reuses Stage 1's synthesis verdict.
288
+
289
+ **How it works**:
290
+ 1. **Auto-stage worktree** with `git add -A` (opt out via `CCG_NO_AUTO_ADD=1`)
291
+ 2. Read state file from `<repo>/.git/ccg/last-review.json` (written by Stage 1)
292
+ 3. Verify the staged diff hash matches the reviewed hash
293
+ 4. Apply the recorded verdict (`merge` / `fix-required` / `discuss`)
294
+ 5. `git commit -m "msg"`
295
+ 6. Delete the state file (one-shot — next commit needs a fresh review)
296
+
297
+ **State file contents**:
298
+ ```json
299
+ {
300
+ "ts": "2026-05-29T11:30:00Z",
301
+ "diff_hash": "acb9adaab6516b3e7fc66fed10dd8a8d",
302
+ "diff_source": "worktree",
303
+ "verdict": "merge",
304
+ "classification": "AGREEMENT",
305
+ "mode": "balanced"
102
306
  }
103
307
  ```
104
308
 
105
- You open Claude Code and type:
309
+ **Verdicts**:
310
+ | Verdict | Action |
311
+ |---|---|
312
+ | `merge` | ✅ Commit allowed |
313
+ | `discuss` | ⚠️ Allowed by default (set `CCG_GATE_DISCUSS=block` to enforce) |
314
+ | `fix-required` | ❌ Commit blocked |
315
+
316
+ **Failure modes**:
317
+ | Scenario | Result |
318
+ |---|---|
319
+ | No prior review | ❌ Error: "Run 'ccg review' first" (or set `CCG_REVIEW=off` to skip) |
320
+ | Diff changed since review | ❌ Hash mismatch — re-run review |
321
+ | Bypass diff check | `CCG_COMMIT_FORCE=1 ccg commit ...` |
322
+ | Auto-stage disabled | `CCG_NO_AUTO_ADD=1 ccg commit ...` — caller must `git add` first |
323
+ | Review disabled | `CCG_REVIEW=off ccg commit ...` — skips state check entirely |
324
+
325
+ **Why no LLM in Stage 2?**
326
+
327
+ The original design ran 2 parallel models here for adversarial robustness — but `ccg review` already does that (2 models + Claude synthesis). Repeating it on commit doubles cost and latency without adding signal. Reusing Stage 1's verdict is faster, cheaper, and equally safe.
328
+
329
+ ---
330
+
331
+ ### Stage 3 — AI Merge (`ccg merge <target>`) ⭐ **Core Competitive Advantage**
106
332
 
333
+ **Purpose**: Resolve merge conflicts professionally and reliably.
334
+
335
+ **Model strategy** (3-tier fallback):
336
+ 1. **Bailian** (primary) — Aliyun-hosted models (most reliable for code)
337
+ 2. **Claude** (secondary) — direct Anthropic API
338
+ 3. **Codex + Gemini** (tertiary) — parallel race
339
+ 4. `NEEDS_HUMAN_DECISION` if all fail
340
+
341
+ **Conflict classification** (only `content` goes to AI):
342
+ | Kind | Handling |
343
+ |---|---|
344
+ | `content` | AI resolution |
345
+ | `binary` | NEEDS HUMAN |
346
+ | `submodule` | NEEDS HUMAN |
347
+ | `symlink` | NEEDS HUMAN |
348
+ | `delete_modify` | NEEDS HUMAN |
349
+ | `both_deleted` | NEEDS HUMAN |
350
+ | `added_one_side` | NEEDS HUMAN |
351
+ | `both_added` | NEEDS HUMAN |
352
+
353
+ **Pipeline**:
107
354
  ```
108
- /ccg
355
+ checkout target → backup branch → git merge --no-commit
356
+ ↓ (for each conflict file)
357
+ classify → parse <<<<<<< blocks
358
+ → Bailian resolution
359
+ ↓ (if failed)
360
+ Codex + Gemini parallel
361
+ ↓ (if both failed)
362
+ NEEDS_HUMAN_DECISION
363
+ → validate (no markdown fences, no conflict markers, non-empty)
364
+ → atomic file rewrite (mktemp + mv, preserve permissions)
365
+ → git add (if resolved)
366
+
367
+ commit (if all clean) | leave uncommitted (if any needs-human)
109
368
  ```
110
369
 
111
- After ~30 seconds you see something like this — **real output**, not a placeholder:
370
+ **Safety guarantees**:
371
+ - Backup branch created BEFORE merge (`ccg-backup/<target>-<timestamp>-<pid>-<rand>`)
372
+ - Aborts if working tree is dirty, detached HEAD, or mid-operation
373
+ - Rejects diverged remote
374
+ - Per-conflict nonce prevents OURS/THEIRS injection
375
+ - Validates resolved content (no markdown fences, no conflict markers, non-empty)
376
+ - Atomic file replacement (`mktemp` + `mv`)
377
+ - Preserves file permissions and refuses to write through symlinks
378
+ - **Never silently drops code** — fails to NEEDS_HUMAN
379
+ - Real-time progress: `[3/12] src/auth.js ... ✅ resolved`
380
+ - Limits max conflicts (default 50, override via `CCG_MERGE_MAX_CONFLICTS`)
381
+
382
+ ---
383
+
384
+ ### Stage 4 — Pre-Push Analysis (`ccg push <remote> <branch>`)
385
+
386
+ **Purpose**: Show a comprehensive, graphical report before pushing — let user decide informed.
387
+
388
+ **Model strategy**: Bailian LLM for risk scoring (falls back to deterministic rules).
112
389
 
390
+ **Report sections**:
113
391
  ```
114
- 📍 Scope: worktree · 1 file · +4 -1 lines
115
- 🎯 Mode: quality (risk=65 · auth+35 size>0+5 crypto-mention+25)
116
- 🩺 Both reviewers OK: Codex ✓ · Gemini ✓
117
- 💰 Cost: $0.041
392
+ ╔══════════════════════════════════════════════════════════╗
393
+ ║ 🚀 CCG Pre-Push Analysis Report 🚀 ║
394
+ ╚══════════════════════════════════════════════════════════╝
118
395
 
119
- ═══ AGREEMENT (2) both flagged, low signal ═══
120
- • auth/login.go:3 — sha256 wasn't a password hash; bcrypt is correct
121
- • auth/login.go:5 — handle the bcrypt error explicitly (you do)
396
+ 📍 Branch / Remote / HEAD / Author / Time
122
397
 
123
- ═══ DIVERGENCE (1) — the models disagreed ★ you decide ═══
398
+ ┌─ Commit Summary ─────────────────────────────────────┐
399
+ │ Ahead: N commit(s) / Behind: M commit(s)
400
+ └──────────────────────────────────────────────────────┘
124
401
 
125
- auth/login.go:6 how to compare bcrypt hashes
126
- 🔵 Codex: "Wrap with subtle.ConstantTimeCompare to prevent timing attacks
127
- even with bcrypt."
128
- 🟢 Gemini: "bcrypt.CompareHashAndPassword is already constant-time. Wrapping
129
- it is cargo-cult and can mask bugs (length mismatch panics)."
130
- ⚖️ Claude: Gemini is correct. bcrypt.CompareHashAndPassword is the canonical
131
- comparison; ConstantTimeCompare on its raw output is a category
132
- error — you'd be comparing the freshly-hashed `pw` against the
133
- stored hash, but bcrypt salts each hash uniquely so direct
134
- comparison ALWAYS returns false.
135
- ➡️ Action: Replace the ConstantTimeCompare line with:
136
- `err := bcrypt.CompareHashAndPassword(u.Hash, []byte(pw))`
137
- `return err == nil`
402
+ 📝 Commits with quality markers (✓ conventional / ⚠ WIP)
138
403
 
139
- ═══ BLINDSPOT (1) — neither saw, Claude suspects ═══
140
- Error path: returning `false` on bcrypt error is correct for the caller but
141
- silently swallows infrastructure errors (e.g. bcrypt OOM). Log the error.
404
+ ┌─ Code Changes ───────────────────────────────────────┐
405
+ │ Files / Lines added / Lines removed + visual bar
406
+ └──────────────────────────────────────────────────────┘
142
407
 
143
- ═══ VERDICT: fix-required ═══
144
- The comparison logic as written will always reject valid passwords. Apply
145
- the DIVERGENCE action, add error logging, and you're good to merge.
146
- ```
408
+ 📂 File Categories: 💻 Code / 🧪 Tests / 📖 Docs / ⚙️ Config
147
409
 
148
- ### How to read this output
410
+ 🚨 SENSITIVE FILES DETECTED (.env, *.pem, credentials, ...)
149
411
 
150
- | Section | What it means | What to do |
151
- |---|---|---|
152
- | **AGREEMENT** | Both Codex and Gemini flagged the same thing. Your single-source Claude likely catches these too — **low new information**. | Skim, fix if not already done. |
153
- | **DIVERGENCE** ★ | The two models disagreed. **This is the whole reason ccg exists.** Claude's "Action" line gives you a recommendation, but you're the final decider. | Read carefully. Apply Claude's call or override it. |
154
- | **BLINDSPOT** | Neither model raised it, but Claude noticed something while synthesizing. **Use sparingly** — limit 2 per run. | Treat as a hint, not gospel. |
155
- | **VERDICT** | `merge` / `fix-required` / `discuss`. One-line summary. | Use as merge gate. |
412
+ ┌─ Risk Assessment ────────────────────────────────────┐
413
+ │ Score: 🔴 CRITICAL (85) — auth + payment
414
+ │ [████████████████████████████████████████████]
415
+ └──────────────────────────────────────────────────────┘
156
416
 
157
- After the review, `ccg_ledger_record` writes one JSONL line to your ledger. Two weeks from now you can:
417
+ 📊 Push Quality Scorecard:
418
+ ✅ Conventional commit messages
419
+ ✅ Code changes accompanied by tests
420
+ ❌ Sensitive files in changeset
421
+ ✅ Up to date with remote
422
+ ⚠️ High risk score — review carefully
158
423
 
159
- ```bash
160
- source ~/.claude/commands/ccg.sh
161
- ccg_ledger_query "auth/login.go"
162
- # → "auth/login.go: 3 reviews · last 2026-05-23 (fix-required) · 2026-05-09 (merge) · 2026-04-28 (discuss)"
424
+ ┌─ Recommendation ─────────────────────────────────────┐
425
+ │ 🔴 NOT RECOMMENDED (3/5 checks passed)
426
+ └──────────────────────────────────────────────────────┘
427
+
428
+ ┌─ Decision ───────────────────────────────────────────┐
429
+ │ y — push | n — cancel | d — view diff | l — view log
430
+ └──────────────────────────────────────────────────────┘
163
431
  ```
164
432
 
165
- ## Configure (defaults are usually fine)
433
+ **Quality checks**:
434
+ 1. Conventional commit messages (`feat|fix|chore|...:`)
435
+ 2. Test files updated alongside code
436
+ 3. No sensitive files (`.env`, `*.pem`, `credentials`, etc.)
437
+ 4. Up to date with remote (not behind)
438
+ 5. Risk level acceptable (<80)
439
+
440
+ ---
441
+
442
+ ### One-Click Ship (`ccg ship [target] [msg]`)
166
443
 
167
- Mode and model picks are automatic. Override only when needed:
444
+ **Purpose**: Combine review commit merge in a single command.
168
445
 
446
+ **Pipeline**:
447
+ 1. `ccg review` — run full Stage 1 review
448
+ 2. `ccg commit` — commit with review gate (only if verdict is `merge`)
449
+ 3. `ccg merge <target>` — merge into target branch
450
+
451
+ **Usage**:
169
452
  ```bash
170
- CCG_MODE=quality /ccg # force quality models on any diff
171
- CCG_CODEX_MODEL=o3 /ccg # override one model
172
- CCG_NO_CACHE=1 /ccg # skip 24h cache for this call
453
+ # Ship to main with auto-detected target
454
+ ccg ship
455
+
456
+ # Ship to specific branch
457
+ ccg ship main
458
+
459
+ # Ship with custom commit message
460
+ ccg ship main "feat: add user auth"
173
461
  ```
174
462
 
175
- Common knobs (full list in [Architecture → §5](docs/ARCHITECTURE.md#5-extension-points)):
463
+ **When to use**: For rapid iteration when you want the full review-commit-merge pipeline in one command.
176
464
 
177
- | Variable | Default | Purpose |
178
- |---|---|---|
179
- | `CCG_MODE` | `auto` | `auto` / `cost` / `balanced` / `quality` |
180
- | `CCG_CACHE_TTL_HOURS` | `24` | Cache TTL |
181
- | `CCG_MAX_PROMPT_KB` | `100` | Per-call prompt size cap |
465
+ ---
466
+
467
+ ## Model Strategy
182
468
 
183
- Cost reference (USD per call, after cache):
469
+ ### Four Independent Providers
184
470
 
185
- | Mode | Codex | Gemini | Typical cost |
471
+ | Provider | API Path | Required Env | Custom Endpoint |
186
472
  |---|---|---|---|
187
- | `cost` | gpt-5-nano | gemini-2.5-flash-lite | ~$0.0007 |
188
- | `balanced` | gpt-5-mini | gemini-2.5-flash | ~$0.0046 |
189
- | `quality` | gpt-5 | gemini-2.5-pro | ~$0.0440 |
473
+ | `codex` | Codex CLI (calls OpenAI) | `codex` binary | `CCG_CODEX_BASE_URL` / `OPENAI_BASE_URL` |
474
+ | `claude` | Direct Anthropic API | `ANTHROPIC_API_KEY` or `CLAUDE_API_KEY` | `CCG_CLAUDE_BASE_URL` / `ANTHROPIC_BASE_URL` |
475
+ | `gemini` | Gemini CLI (calls Google) | `gemini` binary + `GEMINI_API_KEY` | `CCG_GEMINI_BASE_URL` / `GEMINI_BASE_URL` |
476
+ | `bailian` | Direct Aliyun Bailian API | `BAILIAN_API_KEY` | `CCG_BAILIAN_BASE_URL` |
190
477
 
191
- See accumulated spend any time:
478
+ ### Three Modes
192
479
 
193
- ```bash
194
- source ~/.claude/commands/ccg.sh
195
- ccg_usage --this-month
196
- ```
480
+ CCG auto-selects mode based on risk score, or you can force it via `CCG_MODE`.
197
481
 
198
- ## Not for
482
+ | Risk Score | Auto Mode | Strategy |
483
+ |---|---|---|
484
+ | `< 30` | `cost` | Use cheap Bailian models everywhere |
485
+ | `30 – 70` | `balanced` | Mix of mid-tier models per provider |
486
+ | `> 70` | `quality` | Top-tier models per provider |
487
+
488
+ ### Model Per Mode
199
489
 
200
- - IDEs other than Claude Code (try [zen-mcp-server](https://github.com/BeehiveInnovations/zen-mcp-server))
201
- - Replacing static analysis (pair with Semgrep / CodeQL)
202
- - Auto-running on every PR (ccg is a triage tool, not a bot)
203
- - Streaming or multi-turn conversation
490
+ | Mode | codex | claude | gemini | bailian |
491
+ |---|---|---|---|---|
492
+ | **`cost`** | `gpt-5-mini` | `claude-haiku-4-5` | `gemini-2.5-flash-lite` | `qwen-3.5-haiku` |
493
+ | **`balanced`** | `gpt-5.4` | `claude-sonnet-4-6` | `gemini-2.5-flash` | `qwen-3.6` |
494
+ | **`quality`** | `gpt-5.5` | `claude-opus-4-7` | `gemini-3.5-flash` | `qwen-3.7` |
204
495
 
205
- ## Architecture & contributing
496
+ ### Per-Stage Model Usage
206
497
 
207
- ccg is **7 layers**, only the top one is "divergence detection". The other six (cache, ledger, usage, risk routing, smart diff, safe CLI scheduling) each independently solve a real problem. Read [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md) before changing anything in `ccg.sh`.
498
+ | Stage | Uses Models? | Which Models |
499
+ |---|---|---|
500
+ | **Diff Capture** | ❌ | Pure git ops |
501
+ | **Risk Score** | ✅ Bailian LLM | Falls back to rule engine |
502
+ | **Stage 1: Review** | ✅ **any 2 slots in parallel** | Default: codex + gemini. Same provider can run twice with different models (e.g., `bailian:qwen-3.7 bailian:deepseek-v4`) |
503
+ | **Synthesize** | ✅ 1 model | **Claude preferred** (reserved meta-reviewer) → fallback: codex → bailian → gemini |
504
+ | **Stage 2: Commit Gate** | ❌ **NO LLM** | Reuses Stage 1 synthesis verdict (zero extra cost) |
505
+ | **Stage 3: Merge Conflicts** | ✅ **3-tier fallback** | Bailian → Claude → Codex+Gemini |
506
+ | **Stage 4: Push Check** | ✅ Bailian LLM | Risk scoring only |
507
+
508
+ ### Available Bailian Models
509
+
510
+ | Model | Tier | Input ¥/1M | Output ¥/1M | Notes |
511
+ |---|---|---|---|---|
512
+ | `qwen-3.7` | quality | 0.30 | 0.90 | Latest Qwen |
513
+ | `deepseek-v4` | quality | 0.35 | 1.05 | Top reasoning |
514
+ | `kimi-k2.6` | quality | 0.32 | 0.96 | Long context |
515
+ | `glm-5.1` | quality | 0.28 | 0.84 | Multimodal |
516
+ | `qwen-3.6` | balanced | 0.25 | 0.75 | |
517
+ | `mimo-v2.5-pro` | balanced | 0.22 | 0.66 | |
518
+ | `qwen-3.6-plus` | balanced | 0.20 | 0.60 | |
519
+ | `qwen-3.5-sonnet` | balanced | 0.15 | 0.45 | |
520
+ | `deepseek-v4-lite` | balanced | 0.18 | 0.54 | |
521
+ | `kimi-k2.6-lite` | balanced | 0.16 | 0.48 | |
522
+ | `glm-5.1-lite` | balanced | 0.14 | 0.42 | |
523
+ | `mimo-v2.5` | cost | 0.11 | 0.33 | |
524
+ | `qwen-3.5-haiku` | cost | 0.05 | 0.15 | Cheapest |
208
525
 
209
- Tests:
526
+ ---
527
+
528
+ ## Configuration
529
+
530
+ ### Environment Variables
531
+
532
+ | Variable | Default | Description |
533
+ |---|---|---|
534
+ | **Switches / Mode** | | |
535
+ | `CCG_MODE` | auto | `cost` / `balanced` / `quality` |
536
+ | `CCG_REVIEW` | `on` | Master switch: `on` / `off` (when off, `ccg review` is a no-op and `ccg commit` skips state check) |
537
+ | `CCG_PROVIDERS` | auto (depends on mode) | Providers for Stage 1 (max 2 parallel). quality: codex+gemini, cost/balanced: bailian pair. Claude is reserved for Synthesis by default. |
538
+ | **Provider models** | | |
539
+ | `CCG_CODEX_MODEL` | by mode | Override Codex model |
540
+ | `CCG_CLAUDE_MODEL` | by mode | Override Claude model |
541
+ | `CCG_GEMINI_MODEL` | by mode | Override Gemini model |
542
+ | `CCG_BAILIAN_MODEL` | by mode | Override Bailian model |
543
+ | `CCG_DEEPSEEK_MODEL` | by mode | Override DeepSeek model |
544
+ | `CCG_KIMI_MODEL` | by mode | Override Kimi model |
545
+ | `CCG_GLM_MODEL` | by mode | Override GLM model |
546
+ | `CCG_MINIMAX_MODEL` | by mode | Override MiniMax model |
547
+ | `CCG_MIMO_MODEL` | by mode | Override Mimo model |
548
+ | **API keys** | | |
549
+ | `BAILIAN_API_KEY` | — | Bailian (Aliyun) API key |
550
+ | `ANTHROPIC_API_KEY` / `CLAUDE_API_KEY` | — | Anthropic API key |
551
+ | `GEMINI_API_KEY` | — | Google Gemini API key |
552
+ | `DEEPSEEK_API_KEY` | — | DeepSeek official API key |
553
+ | `KIMI_API_KEY` | — | Kimi (Moonshot) official API key |
554
+ | `GLM_API_KEY` | — | GLM (Zhipu) official API key |
555
+ | `MINIMAX_API_KEY` | — | MiniMax official API key |
556
+ | `MIMO_API_KEY` | — | Mimo official API key |
557
+ | **Custom endpoints (proxies)** | | |
558
+ | `CCG_CODEX_BASE_URL` / `OPENAI_BASE_URL` | OpenAI | Codex / OpenAI proxy URL |
559
+ | `CCG_CLAUDE_BASE_URL` / `ANTHROPIC_BASE_URL` | api.anthropic.com | Claude proxy URL |
560
+ | `CCG_GEMINI_BASE_URL` / `GEMINI_BASE_URL` | Google | Gemini proxy URL |
561
+ | `CCG_BAILIAN_BASE_URL` | dashscope.aliyuncs.com | Bailian proxy URL |
562
+ | `CCG_DEEPSEEK_BASE_URL` | api.deepseek.com/v1 | DeepSeek official API URL |
563
+ | `CCG_KIMI_BASE_URL` | api.moonshot.cn/v1 | Kimi official API URL |
564
+ | `CCG_GLM_BASE_URL` | open.bigmodel.cn/api/paas/v4 | GLM official API URL |
565
+ | `CCG_MINIMAX_BASE_URL` | api.minimax.chat/v1 | MiniMax official API URL |
566
+ | `CCG_MIMO_BASE_URL` | — | Mimo official API URL (required) |
567
+ | **Timeouts / Parameters** | | |
568
+ | `CCG_CODEX_TIMEOUT` | 240 | Codex timeout (seconds) |
569
+ | `CCG_GEMINI_TIMEOUT` | 120 | Gemini timeout (seconds) |
570
+ | `CCG_BAILIAN_TIMEOUT` | 120 | Bailian timeout (seconds) |
571
+ | `CCG_CLAUDE_TIMEOUT` | 120 | Claude timeout (seconds) |
572
+ | `CCG_DEEPSEEK_TIMEOUT` | 120 | DeepSeek timeout (seconds) |
573
+ | `CCG_KIMI_TIMEOUT` | 120 | Kimi timeout (seconds) |
574
+ | `CCG_GLM_TIMEOUT` | 120 | GLM timeout (seconds) |
575
+ | `CCG_MINIMAX_TIMEOUT` | 120 | MiniMax timeout (seconds) |
576
+ | `CCG_MIMO_TIMEOUT` | 120 | Mimo timeout (seconds) |
577
+ | `CCG_BAILIAN_TEMP` | 0.7 | Bailian temperature |
578
+ | `CCG_BAILIAN_MAX_TOKENS` | 4096 | Bailian max tokens |
579
+ | `CCG_BAILIAN_RETRIES` | 3 | Bailian retry count |
580
+ | `CCG_CLAUDE_RETRIES` | 3 | Claude retry count |
581
+ | **Gate / Commit** | | |
582
+ | `CCG_GATE_OFFLINE` | 0 | Set to 1 to skip Stage 2 review (legacy gate) |
583
+ | `CCG_GATE_DISCUSS` | allow | Set to `block` to block discuss verdict |
584
+ | `CCG_NO_AUTO_ADD` | 0 | Stage 2: skip auto `git add -A`, use only what's already staged |
585
+ | `CCG_COMMIT_FORCE` | 0 | Stage 2: bypass diff-hash check (force commit even if diff changed) |
586
+ | `CCG_AUTOCOMMIT_ALL` | 0 | Auto-commit all changes (including untracked) |
587
+ | `CCG_AUTOCOMMIT_DRY_RUN` | 0 | Dry run mode for autocommit |
588
+ | `CCG_DIFF_CACHED_ONLY` | 0 | Only use cached diff |
589
+ | **Merge** | | |
590
+ | `CCG_MERGE_DRY_RUN` | 0 | Stage 3: resolve but don't commit |
591
+ | `CCG_MERGE_NO_AI` | 0 | Stage 3: skip AI resolution |
592
+ | `CCG_MERGE_NO_FETCH` | 0 | Stage 3: skip remote fetch |
593
+ | `CCG_MERGE_MAX_CONFLICTS` | 50 | Stage 3: max conflict files |
594
+ | `CCG_MERGE_KEEP_BACKUP` | 0 | Stage 3: keep backup branch after success |
595
+ | **Cache / Ledger / Reports** | | |
596
+ | `CCG_NO_CACHE` | 0 | Disable prompt cache |
597
+ | `CCG_CACHE_TTL_HOURS` | 24 | Prompt cache TTL |
598
+ | `CCG_CACHE_DIR` | XDG default | Custom cache directory |
599
+ | `CCG_MAX_PROMPT_KB` | 100 | Max prompt size in KB |
600
+ | `CCG_USAGE_LOG` | XDG default | Custom usage log path |
601
+ | `CCG_LEDGER_LOG` | XDG default | Custom ledger log path |
602
+ | `CCG_LEDGER_MAX_LINES` | 10000 | Max ledger lines before rotation |
603
+ | `CCG_NO_HISTORY` | 0 | Disable review history injection |
604
+ | `CCG_HISTORY_MAX` | 3 | Max historical reviews to inject |
605
+ | `CCG_NO_REPORT` | 0 | Disable report persistence |
606
+ | `CCG_REPORT_DIR` | .ccg/reports | Custom report directory |
607
+ | `CCG_KEEP_ARTIFACTS` | 0 | Keep workdir for debugging |
608
+ | **Other** | | |
609
+ | `CCG_ALLOW_SAME_VENDOR` | 0 | Allow same vendor in Stage 1 slots |
610
+ | `CCG_SYNTH_PROVIDER` | auto | Override synthesizer provider |
611
+ | `CCG_RISK_LLM` | 0 | Enable LLM-based risk scoring |
612
+
613
+ ### Usage Examples
210
614
 
211
615
  ```bash
212
- bash tests/test_ccg.sh # 99 regression tests, ~31s
213
- REAL_CLI=1 bash tests/test_ccg.sh # +2 live API tests (incurs cost)
616
+ # Force quality mode for a critical review
617
+ CCG_MODE=quality ccg review
618
+
619
+ # Use only Bailian (offline-friendly for China)
620
+ CCG_PROVIDERS="bailian" ccg review
621
+
622
+ # Mix providers — codex + claude (requires quality mode)
623
+ CCG_MODE=quality CCG_PROVIDERS="codex claude" ccg review
624
+
625
+ # Specific Bailian model
626
+ CCG_BAILIAN_MODEL=deepseek-v4 ccg review
627
+
628
+ # Use DeepSeek official API
629
+ DEEPSEEK_API_KEY="sk-xxx" CCG_PROVIDERS="deepseek" ccg review
630
+
631
+ # Use Kimi (Moonshot) official API
632
+ KIMI_API_KEY="sk-xxx" CCG_PROVIDERS="kimi" ccg review
633
+
634
+ # Use GLM (Zhipu) official API
635
+ GLM_API_KEY="xxx.xxx" CCG_PROVIDERS="glm" ccg review
636
+
637
+ # Use MiniMax official API
638
+ MINIMAX_API_KEY="xxx" CCG_PROVIDERS="minimax" ccg review
639
+
640
+ # Use Mimo official API (requires custom base URL)
641
+ MIMO_API_KEY="sk-xxx" CCG_MIMO_BASE_URL="https://api.mimo.com/v1" CCG_PROVIDERS="mimo" ccg review
642
+
643
+ # Mix independent providers (different vendors)
644
+ DEEPSEEK_API_KEY="sk-xxx" KIMI_API_KEY="sk-xxx" CCG_PROVIDERS="deepseek kimi" ccg review
645
+
646
+ # Use OpenAI through proxy (e.g., for China)
647
+ CCG_CODEX_BASE_URL="https://your-proxy.com/v1" ccg review
648
+
649
+ # Use Claude through proxy (e.g., third-party gateway)
650
+ CCG_CLAUDE_BASE_URL="https://tokensolo.com" ccg review
651
+
652
+ # Dry-run merge (resolve but don't commit)
653
+ CCG_MERGE_DRY_RUN=1 ccg merge main
654
+
655
+ # Skip AI merge resolution (just detect conflicts)
656
+ CCG_MERGE_NO_AI=1 ccg merge main
214
657
  ```
215
658
 
216
- ## License & credits
659
+ ---
660
+
661
+ ## Architecture
662
+
663
+ ```
664
+ ccg/
665
+ ├── ccg # Entry point (4-line delegator)
666
+ ├── ccg.sh # Core engine (~3000 lines)
667
+ │ ├── _ccg_xdg_* / _ccg_vcs_* # XDG paths + git abstraction
668
+ │ ├── ccg_init / ccg_preflight # Workdir setup
669
+ │ ├── ccg_diff_capture # 4-level diff fallback
670
+ │ ├── ccg_risk_score # Bailian LLM + rule engine
671
+ │ ├── ccg_codex / ccg_gemini # Provider runners (with custom endpoint support)
672
+ │ ├── ccg_claude / _ccg_claude_retry # Direct Anthropic API (with custom endpoint)
673
+ │ ├── _ccg_bailian_retry # Bailian with retry/backoff
674
+ │ ├── ccg_synthesize # AGREEMENT/DIVERGENCE/BLINDSPOT
675
+ │ ├── ccg_precommit_gate # Stage 2 commit gate
676
+ │ └── ccg_merge # Stage 3 AI merge (Bailian → Claude → Codex+Gemini)
677
+ │ ├── _ccg_classify_conflict # content/binary/submodule/...
678
+ │ ├── _ccg_parse_conflicts # extract <<<<<<<>>>>>>> blocks
679
+ │ ├── _ccg_resolve_one_conflict # 3-tier AI resolution
680
+ │ └── _ccg_apply_resolutions # atomic file rewrite
681
+ ├── ccg-bailian-models.sh # 15-model Bailian registry
682
+ ├── ccg-bailian-integration.sh # Bailian API call helpers
683
+ ├── ccg-multi-provider.sh # 4-provider orchestration
684
+ ├── ccg-workflow.sh # 4-stage workflow entry points
685
+ └── ccg.md # Claude Code slash command spec
686
+
687
+ docs/
688
+ ├── README.zh-CN.md / .ja.md / .ko.md # Translations
689
+ ├── ARCHITECTURE.md (+ 3 translations) # Deep architecture
690
+ └── CHANGELOG.md # Version history
691
+ ```
692
+
693
+ ### Storage (XDG-compliant)
694
+
695
+ | Path | Content |
696
+ |---|---|
697
+ | `$XDG_DATA_HOME/ccg/usage.log` | Token usage + cost log |
698
+ | `$XDG_DATA_HOME/ccg/ledger.jsonl` | Per-review JSONL ledger |
699
+ | `$XDG_CACHE_HOME/ccg/cache/` | Prompt hash → result cache (24h TTL) |
700
+ | `$XDG_CONFIG_HOME/ccg/` | User config |
701
+
702
+ Legacy `~/.ccg/*` auto-migrated on first run.
703
+
704
+ ---
705
+
706
+ ## Documentation
707
+
708
+ - [Architecture deep-dive](docs/ARCHITECTURE.md) ([中文](docs/ARCHITECTURE.zh-CN.md) · [日本語](docs/ARCHITECTURE.ja.md) · [한국어](docs/ARCHITECTURE.ko.md))
709
+ - [Capabilities reference](docs/CAPABILITIES.md) — full feature inventory grounded in the source (中文)
710
+ - [Changelog](docs/CHANGELOG.md)
711
+ - [Slash command spec](ccg.md) — Claude Code `/ccg` command
712
+
713
+ ---
217
714
 
218
- MIT — see [LICENSE](LICENSE).
715
+ ## License
219
716
 
220
- Built on [oh-my-claudecode](https://github.com/Yeachan-Heo/oh-my-claudecode)'s original `/ccg` concept · Claude Code · OpenAI Codex CLI · Google Gemini CLI.
717
+ MIT