ccg
Safety scan
A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.
Check it deeper on your machine
Its scripts were only partly scanned.
As a Claude Code plugin, install it and then ask Claude Code:
/plugin marketplace add keithmackay/mackayi/plugin install scanskillsafety@mackayiDo a deep scan of https://github.com/fengshao1227/ccg-workflow with scanskillsafety
Or from a terminal, clone it and run it:
git clone https://github.com/keithmackay/scanskillsafety-skill ~/.claude/skills/scanskillsafetynode ~/.claude/skills/scanskillsafety/cli.cjs --deep 'https://github.com/fengshao1227/ccg-workflow'
It checks the exact commit: every file, its packages against OSV (api.osv.dev), how it compares with this page's scan (findsafeskills.com receives the repository's address), and, if you agree, Claude reading every file with your own Claude subscription. It never runs the code.
Badge for your README
Markdown
[](/listings/fengshao1227--ccg-workflow)HTML
<a href="/listings/fengshao1227--ccg-workflow"><img src="/api/listings/fengshao1227--ccg-workflow/badge.svg" alt="findsafeskills safety rating" /></a>Install
Install instructions from the README
As written by the repo's author. findsafeskills has not verified these steps.
**Option A — full install (multi-model orchestration + commands + hooks + binary, recommended)**
# Install (interactive 4-step wizard) npx ccg-workflow # Or non-interactive with defaults npx ccg-workflow init --skip-prompt
Requires **Node.js 20+** and **Claude Code CLI**. Codex CLI, Grok CLI, Kimi Code CLI, and Antigravity are optional (enable multi-model features).
**Option B — native plugin (skills only, zero dependencies, v3.5.1+)**
Want just the skills (web-ops toolkit, quality gates, frontend-design, domain knowledge) without the multi-model orchestration?
claude plugin marketplace add fengshao1227/ccg-workflow claude plugin install ccg@ccg
Skills are invoked as `/ccg:<skill>`. No npx, no binary. The multi-model commands ship only through Option A (their templates carry install-time placeholders that a native plugin can't resolve).
What was scanned
The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.
.claude-plugin/marketplace.json · Manifest · 27 lines
View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)
- {
- "name": "ccg",
- "owner": {
- "name": "fengshao1227",
- "url": "https://github.com/fengshao1227"
- },
- "metadata": {
- "description": "CCG multi-model collaboration system — install the skills natively via Claude Code plugins, or the full workflow (commands + hooks + binary) via `npx ccg-workflow`.",
- "version": "3.7.4"
- },
- "plugins": [
- {
- "name": "ccg",
- "source": ".",
- "description": "All CCG skills in one install: bt-panel / seo-page-builder / adsense-site-auditor / scrapling, the verify-* quality gates + gen-docs, the Impeccable-fused frontend-design skill, and 60+ domain-knowledge references. Invoked as /ccg:<skill>.",
- "version": "3.7.4",
- "category": "workflow",
- "keywords": [
- "skills",
- "deployment",
- "seo",
- "frontend-design",
- "code-review"
- ]
- }
- ]
- }
README.md · README · 384 lines
View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)
- # CCG - Claude + Codex + Gemini Multi-Model Collaboration
- <div align="center">
- <img src="assets/logo/ccg-logo-cropped.png" alt="CCG Workflow" width="400">
- [](https://github.com/fengshao1227/ccg-workflow)
- [](https://www.npmjs.com/package/ccg-workflow)
- [](https://www.npmjs.com/package/ccg-workflow)
- [](https://opensource.org/licenses/MIT)
- [](https://github.com/fengshao1227/ccg-workflow/actions/workflows/ci.yml)
- [](https://codecov.io/gh/fengshao1227/ccg-workflow)
- [](https://claude.ai/code)
- [](https://nodejs.org/)
- [](https://x.com/CCG_Workflow)
- 
- [](https://ccg.fengshao1227.com/)
- [](https://deepwiki.com/fengshao1227/ccg-workflow)
- [简体中文](./README.zh-CN.md) | English | [**Documentation**](https://ccg.fengshao1227.com/)
- </div>
- ## ♥️ Sponsor
- [](https://www.packyapi.ai/register?aff=m21P)
- Thanks to [PackyCode](https://www.packyapi.ai/register?aff=m21P) for sponsoring this project! PackyCode is a stable, high-throughput API gateway for leading models — one domain, one key, automatic failover, 97% availability. Dedicated high-speed routes for Codex and Claude Code. Pay in RMB 1:1 with no FX markup or top-up fees; new users get a first-charge discount plus $1 in free credits, and eligible groups start from 20% of list price. [Sign up here](https://www.packyapi.ai/register?aff=m21P) to get started.
- > 💡 PackyCode also exposes an Anthropic-compatible endpoint, so it can serve as your API provider for Claude Code itself — run `npx ccg-workflow`, pick PackyCode at Step 1, and paste your key.
- ---
- [](https://go.apimart.ai/gh-ccg-workflow)
- Thanks to [APIMart](https://go.apimart.ai/gh-ccg-workflow) for sponsoring this project! APIMart is a low-cost API platform for AI image & video generation — GPT-Image-2 from $0.006/image, 160+ images per dollar. One async API covers both image and video: submit a task, get an ID, fetch results via polling or callback. Batch tens of thousands of images without timeouts, switch models without changing code. Pay-as-you-go with no monthly fee — [sign up here](https://go.apimart.ai/gh-ccg-workflow) to get started.
- > 💡 APIMart also exposes an Anthropic-compatible endpoint, so it can serve as your API provider for Claude Code itself — run `npx ccg-workflow`, pick APIMart at Step 1, and paste your key.
- ---
- [](https://x6.ai)
- [x6.ai](https://x6.ai): One API key for every major model. Official-key and proxy channels, up to 90% off, free credits on sign-up. Pay with Alipay, Google Pay, Apple Pay, Visa or Mastercard.
- > 💡 x6.ai also exposes an Anthropic-compatible endpoint, so it can serve as your API provider for Claude Code itself — run `npx ccg-workflow`, pick x6.ai at Step 1, and paste your key.
- ---
- ## Choose the skills you use (v3.7.0)
- Install native skills independently, or select them during the CCG setup wizard. Each selected skill gets a `ccg-` entry; its scripts and references live in a versioned source cache.
- ```bash
- npx ccg-workflow skills catalog
- npx ccg-workflow skills install verify-quality seo-page-builder
- npx ccg-workflow skills list --installed --json
- npx ccg-workflow skills update
- npx ccg-workflow skills remove seo-page-builder
- # Codex native skills
- npx ccg-workflow skills install verify-quality --target codex
- # Configure the framework with a saved selection
- npx ccg-workflow init --skills verify-quality,verify-security
- npx ccg-workflow doctor --json
- ```
- Claude Code uses `/ccg-verify-quality`; Codex uses `$ccg-verify-quality`. The manager exposes only selected entries, keeps supporting resources together, refuses ownership conflicts and preserves edited caches. The menu has **S. Manage Skills** and **V. Doctor**. Reinstalling retains the latest selection; `--skills all` selects the catalog and `--skills none` selects none. Existing full installations remain available as compatibility mode.
- `doctor --json` returns a versioned report with check IDs, status, remediation, and failure/warning counts. It detects the actual Claude/Codex/Skills-only mode, validates the selected backends (including review routes), Hook registrations and managed skills. Failures exit with code 1. Version and filesystem checks establish configuration health; they do not call a model or prove vendor API access.
- Standalone Codex mode checks its own CLI, configuration and installed files. Missing shared Claude routing is optional; missing external delegation tools are reported as warnings with setup instructions.
- Model-action Hooks now follow the configured routes and concrete model IDs, avoid duplicate calls to one backend, and use native Agents for pure Claude setups. Native mode uses on-demand skill discovery; legacy knowledge excerpts have a fixed size limit.
- ### Use an OpenCode worker, including DeepSeek
- Configure your provider in OpenCode with `/connect`, then query `opencode models` (or `opencode models deepseek`) for its actual model IDs. In CCG's model menu choose **OpenCode** and enter that `provider/model`. Keep Claude Code as the coordinator; the worker runs through the existing wrapper. CCG preserves the chosen model when changing routing, reinstalling or updating, and does not manage the provider credentials.
- ## 🐳 CCG on DeepSeek Harness — `dsh-ccg`
- The same role matrix, running natively inside [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness). It ships **inside this package** — no second install, no second version to track.
- ```bash
- npx ccg-workflow dsh install # every profile found; --profile <name> for one
- npx ccg-workflow dsh list # which profiles have it
- ```
- Or pick **`D. DeepSeek Harness`** from `npx ccg-workflow`.
- Requires dsh `0.2.0-rc.2` or `0.2.1-alpha.2`. After updating CCG, run `npx ccg-workflow@latest dsh install` again and restart dsh. Configuration now belongs to each profile's `cordis.patch.yml`; the CCG card is in Settings › Built-in plugins.
- Seven role-pinned delegation tools, each on its own model with its own expert persona — and two things the Claude Code side cannot do as cleanly:
- - **Model panels.** Give one role several models and they all answer the same brief independently, rendered **side by side in the conversation**. Nothing votes, nothing is averaged — disagreement is the finding.
- - **Live teammates.** `ccg_team` hires a role as a colleague that stays alive across turns, owns its own files (a colliding hire is *refused*, not warned about), and reports back on its own. Every hire asks you to approve it first.
- No external CLI, no binary bridge, no cold-start tax — every hop is a provider API request. Source lives in [`dsh-ccg/`](./dsh-ccg); [full README →](./dsh-ccg/README.md)
- ## 🧩 Also by the author
- **[DSH Marketplace](https://dshmarketplace.dev/)** — a directory of [DeepSeek Harness plugins](https://dshmarketplace.dev/plugins). 2,500+ indexed across 14 categories, bilingual EN / 中文.
- Not a sponsor — same author as CCG, built out of a plain annoyance: DSH plugins are multiplying fast, but figuring out what one does, whether it still installs, and what the command actually is meant opening one GitHub README after another. So the install commands here are put through a throwaway container first. **A plugin only gets a check mark if it really installs — and if it can't, the listing says why** (buried in a monorepo subdirectory, never published to npm, and so on). A verified index, not another awesome list.
- ```bash
- dsh plugin --profile web add dshmarketplace-plugin # browse the store from inside DSH
- npx dshmarketplace-cli add owner/repo # install any plugin from your shell
- ```
- There is also a [Python SDK](https://github.com/DshMarketPlace/dshmarketplace-py) and a [public API](https://dshmarketplace.dev/api-docs). Early days — bug reports and plugin submissions are very welcome on [GitHub](https://github.com/DshMarketPlace).
- ---
- ## What is CCG?
- **CCG is a workflow engine for Claude Code.** It turns Claude into a multi-model orchestrator — Claude stays in control while dispatching specialized work to Codex (OpenAI), Grok (xAI), Kimi Code (Moonshot), and Antigravity through a Go binary bridge.
- One command. Describe what you want. The engine handles the rest.
- ```bash
- npx ccg-workflow # Install in 60 seconds
- ```
- ## Architecture
- <div align="center">
- <img src="assets/readme/architecture.png" alt="CCG Architecture" width="800">
- </div>
- **Claude Code** is the lead orchestrator. It analyzes your intent, selects a strategy, and manages the entire workflow. The **Hook Engine** injects state every turn so Claude never loses context — even after compaction. The **codeagent-wrapper** (a compiled Go binary) bridges Claude to external models for parallel analysis and review.
- ## How It Works
- ```
- You: /ccg:go add JWT authentication to this API
- CCG Engine:
- 1. Reads project context (git status, tech stack, file structure)
- 2. Classifies: feature / L complexity / backend / high risk
- 3. Selects strategy: full-collaborate
- 4. Creates .ccg/tasks/add-jwt-auth/task.json
- 5. Launches dual-model analysis (Codex + Gemini in parallel)
- 6. Produces plan → HARD STOP for your approval
- 7. Spawns Agent Teams Builders for parallel implementation
- 8. Runs quality gates + dual-model cross-review
- 9. Reports results
- Every turn, a hook injects:
- <ccg-state>
- Task: add-jwt-auth (in_progress)
- Strategy: full-collaborate
- Phase: 4-implementation
- </ccg-state>
- ```
- ## 10 Built-in Strategies
- The engine auto-selects the right strategy based on task type and complexity:
- | Strategy | When | External Models | Agent Teams |
- |----------|------|:---:|:---:|
- | `direct-fix` | Simple bug, single file | — | — |
- | `quick-implement` | Small feature, clear scope | — | — |
- | `guided-develop` | Medium feature, needs planning | Single | — |
- | `full-collaborate` | Complex feature, multi-module | Dual parallel | ✓ |
- | `debug-investigate` | Complex bug, unknown cause | Dual diagnosis | — |
- | `refactor-safely` | Code restructuring | Dual review | — |
- | `deep-research` | Technical research | Dual exploration | — |
- | `optimize-measure` | Performance optimization | Optional | — |
- | `review-audit` | Code review | Dual cross-review | — |
- | `git-action` | commit, rollback, branches | — | — |
- Simple tasks run fast with zero overhead. Complex tasks get the full engine.
- ## Core Features
- ### Hook Engine — Never Lose Context
- 4 JavaScript hooks inject state into every Claude Code session:
- | Hook | Event | What it does |
- |------|-------|-------------|
- | `workflow-state.js` | Every turn | Injects current task state as breadcrumb |
- | `session-start.js` | Session start/compact | Re-injects full project context |
- | `subagent-context.js` | Agent/Bash spawn | Injects spec directly into subagent prompts |
- | `skill-router.js` | Every turn | Auto-injects domain knowledge by keyword |
- Context survives compaction. Sub-agents born with spec in their prompt. Zero state loss.
- ### Task System — Persistent Lifecycle
- Medium+ complexity tasks get a persistent directory:
- ```
- .ccg/tasks/add-jwt-auth/
- ├── task.json # Status, strategy, phase, gate
- ├── requirements.md # Enhanced requirements
- ├── plan.md # Approved implementation plan
- ├── context.jsonl # Spec files for sub-agent injection
- ├── review.md # Review results
- └── research/ # Persisted research findings
- ```
- ### Quality Gates — Built-in Security & Quality
- | Gate | Trigger |
- |------|---------|
- | `/ccg:verify-security` | New modules, security changes |
- | `/ccg:verify-quality` | Changes > 30 lines |
- | `/ccg:verify-change` | Doc sync check |
- | `/ccg:verify-module` | Module structure check |
- | `/ccg:gen-docs` | Auto-generate README + DESIGN |
- ### 100+ Domain Knowledge Files
- When your message mentions security, caching, RAG, Kubernetes, etc., the relevant knowledge file is auto-injected. 10 domains, 61 files:
- `Security` · `Architecture` · `DevOps` · `AI/MLOps` · `Development` · `Frontend Design` · `Infrastructure` · `Mobile` · `Data Engineering` · `Orchestration`
- ### Standalone Skills — battle-tested website workflows (v3.5.1)
- Self-contained skills, each usable on its own or auto-triggered by intent. Drawn from real site-building work and shipped with their scripts:
- | Skill | What it does |
- |-------|-------------|
- | `/ccg:bt-panel` | Drive a **BaoTa / aaPanel** server over its HTTP API — deploy a build, update a live site, read/write files, run shell, run MySQL. No SSH or rsync; just a panel URL + API key. Ships `bt_client.py` + one-shot `bt_deploy.py`. |
- | `/ccg:seo-page-builder` | Build, audit, or optimize **SEO tool pages** (AI generator / remover / enhancer / converter / editor). SERP-intent driven, with a runnable `onpage-audit.py` keyword-density meter. |
- | `/ccg:adsense-site-auditor` | Audit a site for **Google AdSense** readiness against the full official checklist — eligibility, ownership, content quality, ads.txt, privacy, Publisher Policies — before you apply or after a rejection. |
- > `bt-panel` reads credentials only from env vars / a git-ignored `sites.json`; nothing is hardcoded. `seo-page-builder` is adapted from yuzeiki's skill of the same name (see its SKILL.md).
- ## Commands
- ### Core (v3.0 default: 13 commands)
- | Command | Description |
- |---------|-------------|
- | `/ccg:go` | **Smart entry** — describe what you want, engine handles the rest |
- | `/ccg:commit` | Smart conventional commit |
- | `/ccg:rollback` | Interactive rollback |
- | `/ccg:clean-branches` | Clean merged branches |
- | `/ccg:worktree` | Worktree management |
- | `/ccg:init` | Initialize project CLAUDE.md |
- | `/ccg:context` | Project context management |
- ### OpenSpec Integration
- | Command | Description |
- |---------|-------------|
- | `/ccg:spec-init` | Initialize OPSX environment |
- | `/ccg:spec-research` | Requirements → constraints |
- | `/ccg:spec-plan` | Constraints → zero-decision plan |
- | `/ccg:spec-impl` | Execute plan + archive |
- | `/ccg:spec-review` | Dual-model cross-review |
- ### Legacy Mode (18 additional commands)
- Includes `/ccg:workflow`, `/ccg:plan`, `/ccg:execute`, `/ccg:frontend`, `/ccg:backend`, `/ccg:analyze`, `/ccg:debug`, `/ccg:optimize`, `/ccg:test`, `/ccg:review`, `/ccg:team`, and more.
- ## Quick Start
- **Option A — full install (multi-model orchestration + commands + hooks + binary, recommended)**
- ```bash
- # Install (interactive 4-step wizard)
- npx ccg-workflow
- # Or non-interactive with defaults
- npx ccg-workflow init --skip-prompt
- ```
- Requires **Node.js 20+** and **Claude Code CLI**. Codex CLI, Grok CLI, Kimi Code CLI, and Antigravity are optional (enable multi-model features).
- **Option B — native plugin (skills only, zero dependencies, v3.5.1+)**
- Want just the skills (web-ops toolkit, quality gates, frontend-design, domain knowledge) without the multi-model orchestration?
- ```bash
- claude plugin marketplace add fengshao1227/ccg-workflow
- claude plugin install ccg@ccg
- ```
- Skills are invoked as `/ccg:<skill>`. No npx, no binary. The multi-model commands ship only through Option A (their templates carry install-time placeholders that a native plugin can't resolve).
- ## CLI Commands
- ```bash
- npx ccg-workflow # Interactive menu
- npx ccg-workflow init # 4-step install wizard
- npx ccg-workflow doctor # Environment health check
- npx ccg-workflow doctor --json # Machine-readable health report
- npx ccg-workflow skills list # Catalog and native selection
- npx ccg-workflow status # Installation overview
- npx ccg-workflow codex-mode install # Install Codex-Led mode
- npx ccg-workflow codex-mode uninstall # Uninstall Codex-Led mode
- npx ccg-workflow dsh install # Install CCG into DeepSeek Harness
- npx ccg-workflow dsh list # Which dsh profiles have it
- npx ccg-workflow dsh uninstall # Remove it from every profile
- npx ccg-workflow uninstall # Uninstall CCG
- npx ccg-workflow config mcp # Configure MCP tokens
- npx ccg-workflow diagnose-mcp # Diagnose MCP issues
- ```
- ## Configuration
- ```
- ~/.claude/
- ├── commands/ccg/ # Slash commands
- ├── hooks/ccg/ # Hook scripts (5 files)
- ├── skills/ccg/ # Legacy bundled skills
- ├── skills/ccg-<slug> # Selected native skill entries
- ├── .ccg-skills/ # Native selection manifest and resource cache
- ├── rules/ # Auto-trigger rules
- ├── .ccg/
- │ ├── config.toml # Model routing, MCP, performance
- │ ├── engine/ # 10 strategy files + model router
- │ └── prompts/ # Expert prompts (codex/gemini/claude)
- └── bin/codeagent-wrapper # Multi-model bridge (Go binary)
- ```
- ### Environment Variables
- Set in `~/.claude/settings.json` under `"env"`:
- | Variable | Default | Description |
- |----------|---------|-------------|
- | `CODEX_TIMEOUT` | `7200` | Wrapper timeout (seconds) |
- | `CODEAGENT_POST_MESSAGE_DELAY` | `5` | Post-completion delay |
- | `CODEAGENT_BROWSER` | `default` | Set to `builtin` to stop opening the system browser for the Web UI |
- | `CODEAGENT_AGY_SETTINGS` | - | Settings file passed to agy as `--settings` (needs an agy that has the flag) |
- | `CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS` | unset | Set `1` for parallel Agent Teams |
- ## Update / Uninstall
- ```bash
- npx ccg-workflow@latest # Update to latest
- npx ccg-workflow doctor # Check health after update
- npx ccg-workflow uninstall # Clean uninstall
- ```
- ## Credits
- - [stellarlinkco/myclaude](https://github.com/stellarlinkco/myclaude) — codeagent-wrapper inspiration
- - [UfoMiao/zcf](https://github.com/UfoMiao/zcf) — Git tools reference
- - [mindfold-ai/Trellis](https://github.com/mindfold-ai/Trellis) — Hook-based workflow state patterns
- - [ace-tool](https://linux.do/t/topic/1344562) — MCP code retrieval
- ## Contributors
- <!-- readme: contributors -start -->
- <table>
- <tr>
- <td align="center"><a href="https://github.com/fengshao1227"><img src="https://avatars.githubusercontent.com/fengshao1227?v=4&s=100" width="100;" alt="fengshao1227"/><br /><sub><b>fengshao1227</b></sub></a></td>
- <td align="center"><a href="https://github.com/SXP-Simon"><img src="https://avatars.githubusercontent.com/SXP-Simon?v=4&s=100" width="100;" alt="SXP-Simon"/><br /><sub><b>SXP-Simon</b></sub></a></td>
- <td align="center"><a href="https://github.com/RebornQ"><img src="https://avatars.githubusercontent.com/RebornQ?v=4&s=100" width="100;" alt="RebornQ"/><br /><sub><b>RebornQ</b></sub></a></td>
- <td align="center"><a href="https://github.com/Sakuranda"><img src="https://avatars.githubusercontent.com/Sakuranda?v=4&s=100" width="100;" alt="Sakuranda"/><br /><sub><b>Sakuranda</b></sub></a></td>
- <td align="center"><a href="https://github.com/Mriris"><img src="https://avatars.githubusercontent.com/Mriris?v=4&s=100" width="100;" alt="Mriris"/><br /><sub><b>Mriris</b></sub></a></td>
- <td align="center"><a href="https://github.com/23q3"><img src="https://avatars.githubusercontent.com/23q3?v=4&s=100" width="100;" alt="23q3"/><br /><sub><b>23q3</b></sub></a></td>
- <td align="center"><a href="https://github.com/MrNine-666"><img src="https://avatars.githubusercontent.com/MrNine-666?v=4&s=100" width="100;" alt="MrNine-666"/><br /><sub><b>MrNine-666</b></sub></a></td>
- </tr>
- <tr>
- <td align="center"><a href="https://github.com/GGzili"><img src="https://avatars.githubusercontent.com/GGzili?v=4&s=100" width="100;" alt="GGzili"/><br /><sub><b>GGzili</b></sub></a></td>
- </tr>
- </table>
- <!-- readme: contributors -end -->
- ## Contact
- - **X (Twitter)**: [@CCG_Workflow](https://x.com/CCG_Workflow)
- - **Email**: [fengshao1227@gmail.com](mailto:fengshao1227@gmail.com)
- - **Issues**: [GitHub Issues](https://github.com/fengshao1227/ccg-workflow/issues)
- - **Community**: [Linux.do](https://linux.do)
- ## Star History
- [](https://www.star-history.com/#fengshao1227/ccg-workflow&type=timeline&legend=top-left)
- ## License
- MIT
- ---
- v3.7.4 | [Issues](https://github.com/fengshao1227/ccg-workflow/issues) | [Contributing](./CONTRIBUTING.md)
src/commands/menu.ts · Bundled script · 1,274 lines · 1 finding marked
- import ansis from 'ansis'
- import inquirer from 'inquirer'
- import ora from 'ora'
- import { exec, spawn } from 'node:child_process'
- import { promisify } from 'node:util'
- import { homedir } from 'node:os'
- import { fileURLToPath } from 'node:url'
- import { dirname, join } from 'pathe'
- import fs from 'fs-extra'
- import { parse as parseTOML } from 'smol-toml'
- import { version } from '../../package.json'
- import { configMcp } from './config-mcp'
- import { i18n } from '../i18n'
- import { configureGeminiCliApi, getSponsor, installCodexMode, promptSponsorMenuKey, removeGeminiCliApi, sponsorInquirerChoices, uninstallCodexMode, uninstallWorkflows } from '../utils/installer'
- import { findDshProfiles, installDshPlugin, uninstallDshPlugin } from '../utils/installer-dsh'
- import { readCcgConfig, writeCcgConfig } from '../utils/config'
- import { init } from './init'
- import { update } from './update'
- import { manageSkillsMenu } from './skills'
- import { doctor } from './doctor'
- import { promptOpencodeModel } from '../utils/model-selection'
- import { isWindows } from '../utils/platform'
- const execAsync = promisify(exec)
- // ═══════════════════════════════════════════════════════
- // UI Helpers
- // ═══════════════════════════════════════════════════════
- /**
- * Get visual display width of a string (CJK = 2, ASCII = 1)
- */
- function visWidth(s: string): number {
- const stripped = s.replace(/\x1B\[[0-9;]*m/g, '')
- let w = 0
- for (const ch of stripped) {
- const code = ch.codePointAt(0) || 0
- // CJK Unified Ideographs + common fullwidth ranges
- if (
- (code >= 0x2E80 && code <= 0x9FFF)
- || (code >= 0xF900 && code <= 0xFAFF)
- || (code >= 0xFE30 && code <= 0xFE4F)
- || (code >= 0xFF00 && code <= 0xFF60)
- || (code >= 0xFFE0 && code <= 0xFFE6)
- || (code >= 0x1F300 && code <= 0x1F9FF) // Emojis
- || (code >= 0x20000 && code <= 0x2FA1F) // CJK Extension B+
- ) {
- w += 2
- }
- else {
- w += 1
- }
- }
- return w
- }
- /**
- * Pad a string to a fixed visible width (ANSI + CJK aware)
- */
- function pad(s: string, w: number): string {
- const diff = w - visWidth(s)
- return diff > 0 ? s + ' '.repeat(diff) : s
- }
- const INNER_W = 60
- /**
- * Center a string (with ANSI) inside a fixed-width area
- */
- function centerLine(s: string, w: number): string {
- const vis = visWidth(s)
- const left = Math.max(0, Math.floor((w - vis) / 2))
- const right = Math.max(0, w - vis - left)
- return ' '.repeat(left) + s + ' '.repeat(right)
- }
- /**
- * Draw a boxed row: ║ <content padded to INNER_W> ║
- */
- function boxRow(content: string): string {
- const vis = visWidth(content)
- const gap = Math.max(0, INNER_W - vis)
- return ansis.cyan('║') + content + ' '.repeat(gap) + ansis.cyan('║')
- }
- function drawHeader(statusParts: string[]): void {
- const top = ansis.cyan('╔' + '═'.repeat(INNER_W) + '╗')
- const bot = ansis.cyan('╚' + '═'.repeat(INNER_W) + '╝')
- const empty = boxRow(' '.repeat(INNER_W))
- // ASCII Art Logo
- const logo = [
- ' ██████╗ ██████╗ ██████╗ ',
- ' ██╔════╝ ██╔════╝ ██╔════╝ ',
- ' ██║ ██║ ██║ ███╗',
- ' ██║ ██║ ██║ ██║',
- ' ╚██████╗ ╚██████╗ ╚██████╔╝',
- ' ╚═════╝ ╚═════╝ ╚═════╝ ',
- ]
- console.log()
- console.log(top)
- console.log(empty)
- for (const line of logo) {
- console.log(boxRow(centerLine(ansis.bold.white(line), INNER_W)))
- }
- console.log(empty)
- console.log(boxRow(centerLine(ansis.gray('Claude + Codex + Gemini'), INNER_W)))
- console.log(boxRow(centerLine(ansis.gray('Multi-Model Collaboration'), INNER_W)))
- console.log(empty)
- if (statusParts.length > 0) {
- const statusLine = statusParts.join(ansis.gray(' | '))
- console.log(boxRow(centerLine(statusLine, INNER_W)))
- console.log(empty)
- }
- console.log(bot)
- console.log()
- }
- function groupSep(label: string): InstanceType<typeof inquirer.Separator> {
- const w = 42
- const labelW = visWidth(label)
- const remaining = Math.max(0, w - labelW - 2)
- const left = Math.floor(remaining / 2)
- const right = remaining - left
- return new inquirer.Separator(ansis.gray(`${'─'.repeat(left)} ${label} ${'─'.repeat(right)}`))
- }
- // ═══════════════════════════════════════════════════════
- // Main Menu
- // ═══════════════════════════════════════════════════════
- export async function showMainMenu(): Promise<void> {
- while (true) {
- // Read config for status display
- const config = await readCcgConfig()
- const cmdCount = config?.workflows?.installed?.length || 0
- const lang = config?.general?.language || 'zh-CN'
- const mcpProvider = config?.mcp?.provider || '—'
- // Build status parts
- const statusParts = [
- ansis.green(`v${version}`),
- ansis.white(`${cmdCount} commands`),
- ansis.yellow(lang),
- ]
- if (mcpProvider && mcpProvider !== '—' && mcpProvider !== 'skip') {
- statusParts.push(ansis.magenta(mcpProvider))
- }
- drawHeader(statusParts)
- const isZh = lang === 'zh-CN'
- // Build menu item helper: " N. Label - description"
- const item = (key: string, label: string, desc: string) => ({
- name: ` ${ansis.green(key + '.')} ${pad(label, 20)} ${ansis.gray('- ' + desc)}`,
- value: key,
- })
- const { action } = await inquirer.prompt([{
- type: 'list',
- name: 'action',
- message: i18n.t('menu:title'),
- pageSize: 20,
- choices: [
- groupSep(isZh ? 'Claude Code' : 'Claude Code'),
- item('1', i18n.t('menu:options.init'), isZh ? '安装 CCG 工作流' : 'Install CCG workflows'),
- item('2', i18n.t('menu:options.update'), isZh ? '更新到最新版本' : 'Update to latest version'),
- item('3', i18n.t('menu:options.configMcp'), isZh ? '代码检索 MCP 工具' : 'Code retrieval MCP tool'),
- item('4', i18n.t('menu:options.configApi'), isZh ? '自定义 API 端点' : 'Custom API endpoint'),
- item('5', i18n.t('menu:options.configStyle'), isZh ? '选择输出人格' : 'Choose output personality'),
- item('6', i18n.t('menu:options.configModel'), isZh ? '前端/后端模型切换' : 'Switch frontend/backend models'),
- groupSep(isZh ? '其他工具' : 'Tools'),
- item('X', isZh ? 'Codex 模式' : 'Codex Mode', isZh ? '安装 Codex 主导的多模型编排' : 'Install Codex-led multi-model orchestration'),
- item('D', isZh ? 'DeepSeek Harness' : 'DeepSeek Harness', isZh ? '把 CCG 角色矩阵装进 dsh' : 'Install the CCG role matrix into dsh'),
- item('T', i18n.t('menu:options.tools'), 'ccusage, CCometixLine'),
- item('C', i18n.t('menu:options.installClaude'), isZh ? '安装/重装 CLI' : 'Install/reinstall CLI'),
- groupSep('CCG'),
- item('S', isZh ? 'Skills 管理' : 'Manage Skills', isZh ? '按需安装、更新与移除技能' : 'Select, update and remove skills'),
- item('V', isZh ? '环境诊断' : 'Doctor', isZh ? '检查安装模式、模型路由与技能' : 'Check modes, routing and skills'),
- item('H', i18n.t('menu:options.help'), isZh ? '查看全部斜杠命令' : 'View all slash commands'),
- item('-', i18n.t('menu:options.uninstall'), isZh ? '移除 CCG 配置' : 'Remove CCG config'),
- new inquirer.Separator(ansis.gray('─'.repeat(42))),
- { name: ` ${ansis.red('Q.')} ${i18n.t('menu:options.exit')}`, value: 'Q' },
- ],
- }])
- switch (action) {
- case '1':
- await init()
- break
- case '2':
- await update()
- break
- case '3':
- await configMcp()
- break
- case '4':
- await configApi()
- break
- case '5':
- await configOutputStyle()
- break
- case '6':
- await configModelRouting()
- break
- case 'X':
- await handleCodexMode()
- break
- case 'D':
- await handleDshPlugin()
- break
- case 'T':
- await handleTools()
- break
- case 'C':
- await handleInstallClaude()
- break
- case '-':
- await uninstall()
- break
- case 'H':
- showHelp()
- break
- case 'S':
- await manageSkillsMenu()
- break
- case 'V':
- await doctor()
- break
- case 'Q':
- console.log()
- console.log(ansis.gray(` ${i18n.t('common:goodbye')}`))
- console.log()
- return
- }
- // Pause after action so user can see results
- console.log()
- await inquirer.prompt([{
- type: 'input',
- name: 'continue',
- message: ansis.gray(i18n.t('common:pressEnterToReturn')),
- }])
- }
- }
- // (visWidth and pad are defined in UI Helpers section above)
- // ═══════════════════════════════════════════════════════
- // Help
- // ═══════════════════════════════════════════════════════
- function showHelp(): void {
- const config = readCcgConfigSync()
- const isZh = (config?.general?.language || 'zh-CN') === 'zh-CN'
- console.log()
- console.log(ansis.cyan.bold(` ${i18n.t('menu:help.title')}`))
- console.log()
- const col1 = 22 // command column width
- const section = (title: string) => console.log(ansis.yellow.bold(` ${title}`))
- const cmd = (name: string, desc: string) => console.log(` ${ansis.green(name.padEnd(col1))} ${ansis.gray(desc)}`)
- // Core Engine
- section(i18n.t('menu:help.sections.engine'))
- cmd('/ccg:go', i18n.t('menu:help.descriptions.go'))
- console.log()
- // OpenSpec Workflows
- section(i18n.t('menu:help.sections.opsx'))
- cmd('/ccg:spec-init', i18n.t('menu:help.descriptions.specInit'))
- cmd('/ccg:spec-research', i18n.t('menu:help.descriptions.specResearch'))
- cmd('/ccg:spec-plan', i18n.t('menu:help.descriptions.specPlan'))
- cmd('/ccg:spec-impl', i18n.t('menu:help.descriptions.specImpl'))
- cmd('/ccg:spec-review', i18n.t('menu:help.descriptions.specReview'))
- console.log()
- // Git Tools
- section(i18n.t('menu:help.sections.gitTools'))
- cmd('/ccg:commit', i18n.t('menu:help.descriptions.commit'))
- cmd('/ccg:rollback', i18n.t('menu:help.descriptions.rollback'))
- cmd('/ccg:clean-branches', i18n.t('menu:help.descriptions.cleanBranches'))
- cmd('/ccg:worktree', i18n.t('menu:help.descriptions.worktree'))
- console.log()
- // Project Management
- section(i18n.t('menu:help.sections.projectMgmt'))
- cmd('/ccg:init', i18n.t('menu:help.descriptions.init'))
- cmd('/ccg:context', i18n.t('menu:help.descriptions.context'))
- console.log()
- // Quality Gates
- section(i18n.t('menu:help.sections.qualityGates'))
- cmd('/ccg:verify-security', i18n.t('menu:help.descriptions.verifySecurity'))
- cmd('/ccg:verify-quality', i18n.t('menu:help.descriptions.verifyQuality'))
- cmd('/ccg:verify-change', i18n.t('menu:help.descriptions.verifyChange'))
- cmd('/ccg:verify-module', i18n.t('menu:help.descriptions.verifyModule'))
- console.log()
- console.log(ansis.gray(` ${i18n.t('menu:help.hint')}`))
- console.log()
- }
- /**
- * Synchronous config read for non-async contexts (help display)
- */
- function readCcgConfigSync(): any {
- try {
- const configPath = join(homedir(), '.claude', '.ccg', 'config.toml')
- if (fs.pathExistsSync(configPath)) {
- return parseTOML(fs.readFileSync(configPath, 'utf-8'))
- }
- }
- catch { /* ignore */ }
- return null
- }
- // ═══════════════════════════════════════════════════════
- // API Configuration
- // ═══════════════════════════════════════════════════════
- async function configApi(): Promise<void> {
- console.log()
- console.log(ansis.cyan.bold(` ${i18n.t('menu:api.title')}`))
- console.log()
- const settingsPath = join(homedir(), '.claude', 'settings.json')
- let settings: Record<string, any> = {}
- if (await fs.pathExists(settingsPath)) {
- settings = await fs.readJson(settingsPath)
- }
- // Show current config
- const currentUrl = settings.env?.ANTHROPIC_BASE_URL
- const currentKey = settings.env?.ANTHROPIC_AUTH_TOKEN || settings.env?.ANTHROPIC_API_KEY
- if (currentUrl || currentKey) {
- console.log(ansis.gray(` ${i18n.t('menu:api.currentConfig')}`))
- if (currentUrl)
- console.log(ansis.gray(` URL: ${currentUrl}`))
- if (currentKey)
- console.log(ansis.gray(` Key: ${currentKey.slice(0, 8)}...${currentKey.slice(-4)}`))
- console.log()
- }
- const { apiProvider } = await inquirer.prompt([{
- type: 'list',
- name: 'apiProvider',
- message: i18n.t('menu:api.providerPrompt'),
- choices: [
- { name: `${ansis.green('●')} ${i18n.t('menu:api.officialOption')}`, value: 'official' },
- { name: `${ansis.cyan('●')} ${i18n.t('menu:api.thirdPartyOption')}`, value: 'thirdparty' },
- ...sponsorInquirerChoices(),
- { name: `${ansis.magenta('●')} ${i18n.t('init:api.geminiCliOption')}`, value: 'gemini-cli' },
- ],
- }])
- // Gemini CLI gateway lives in ~/.gemini/.env, not Claude Code's
- // settings.json — handle it as its own flow and return early so the
- // ANTHROPIC_* writing below never runs for this choice.
- if (apiProvider === 'gemini-cli') {
- const { action } = await inquirer.prompt([{
- type: 'list',
- name: 'action',
- message: i18n.t('init:api.geminiCliActionPrompt'),
- choices: [
- { name: `${ansis.green('●')} ${i18n.t('init:api.geminiCliConfigureOption')}`, value: 'configure' },
- { name: `${ansis.gray('○')} ${i18n.t('init:api.geminiCliRemoveOption')}`, value: 'remove' },
- ],
- }])
- if (action === 'remove') {
- const removed = await removeGeminiCliApi()
- console.log()
- console.log(removed.success
- ? ansis.green(` ✓ ${i18n.t('init:api.geminiCliRemoved')}`)
- : ansis.yellow(` ! ${removed.message}`))
- return
- }
- console.log(` ${ansis.yellow('!')} ${i18n.t('init:api.geminiCliProtocolHint')}`)
- const answers = await inquirer.prompt([
- {
- type: 'input',
- name: 'url',
- message: `${i18n.t('init:api.geminiCliUrlPrompt')} ${ansis.gray(`(${i18n.t('menu:api.urlRequired')})`)}`,
- validate: (v: string) => v.trim() !== '' || i18n.t('menu:api.enterUrl'),
- },
- {
- type: 'password',
- name: 'key',
- message: `Gemini API Key ${ansis.gray(`(${i18n.t('menu:api.keyRequired')})`)}`,
- mask: '*',
- validate: (v: string) => v.trim() !== '' || i18n.t('menu:api.enterKey'),
- },
- {
- type: 'input',
- name: 'model',
- message: i18n.t('init:api.geminiCliModelPrompt'),
- },
- ])
- const result = await configureGeminiCliApi({
- baseUrl: answers.url.trim(),
- apiKey: answers.key.trim(),
- model: answers.model?.trim() || undefined,
- })
- console.log()
- if (result.success) {
- console.log(ansis.green(` ✓ ${i18n.t('init:api.geminiCliSaved')}`))
- if (result.rcPath)
- console.log(ansis.gray(` ${i18n.t('common:configFile')}: ${result.rcPath}`))
- if (result.needsReload)
- console.log(ansis.gray(` ${i18n.t('init:api.geminiCliReloadHint')}`))
- }
- else {
- console.log(ansis.yellow(` ! ${result.message}`))
- }
- return
- }
- const sponsor = getSponsor(apiProvider)
- if (apiProvider === 'official') {
- // Clear third-party config, let Claude Code use official auth
- if (!settings.env)
- settings.env = {}
- delete settings.env.ANTHROPIC_BASE_URL
- delete settings.env.ANTHROPIC_AUTH_TOKEN
- delete settings.env.ANTHROPIC_API_KEY
- }
- else if (sponsor) {
- const key = await promptSponsorMenuKey(sponsor)
- if (!settings.env)
- settings.env = {}
- // No /v1 suffix: Claude Code appends /v1/messages to ANTHROPIC_BASE_URL itself.
- settings.env.ANTHROPIC_BASE_URL = sponsor.anthropicBaseUrl
- settings.env.ANTHROPIC_AUTH_TOKEN = key
- delete settings.env.ANTHROPIC_API_KEY
- }
- else {
- const answers = await inquirer.prompt([
- {
- type: 'input',
- name: 'url',
- message: `API URL ${ansis.gray(`(${i18n.t('menu:api.urlRequired')})`)}`,
- default: currentUrl || '',
- validate: (v: string) => v.trim() !== '' || i18n.t('menu:api.enterUrl'),
- },
- {
- type: 'password',
- name: 'key',
- message: `API Key ${ansis.gray(`(${i18n.t('menu:api.keyRequired')})`)}`,
- mask: '*',
- validate: (v: string) => v.trim() !== '' || i18n.t('menu:api.enterKey'),
- },
- ])
- if (!settings.env)
- settings.env = {}
- settings.env.ANTHROPIC_BASE_URL = answers.url.trim()
- settings.env.ANTHROPIC_AUTH_TOKEN = answers.key.trim()
- delete settings.env.ANTHROPIC_API_KEY
- }
- // Default optimization config
- settings.env.DISABLE_TELEMETRY = '1'
- settings.env.DISABLE_ERROR_REPORTING = '1'
- settings.env.CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC = '1'
- settings.env.CLAUDE_CODE_ATTRIBUTION_HEADER = '0'
- settings.env.MCP_TIMEOUT = '60000'
- // codeagent-wrapper permission allowlist
- if (!settings.permissions)
- settings.permissions = {}
- if (!settings.permissions.allow)
- settings.permissions.allow = []
- const wrapperPerms = [
- 'Bash(~/.claude/bin/codeagent-wrapper*)',
- 'Bash(*codeagent-wrapper*)',
- ]
- for (const perm of wrapperPerms) {
- if (!settings.permissions.allow.includes(perm))
- settings.permissions.allow.push(perm)
- }
- await fs.ensureDir(join(homedir(), '.claude'))
- await fs.writeJson(settingsPath, settings, { spaces: 2 })
- console.log()
- console.log(ansis.green(` ✓ ${i18n.t('menu:api.saved')}`))
- console.log(ansis.gray(` ${i18n.t('common:configFile')}: ${settingsPath}`))
- }
- // ═══════════════════════════════════════════════════════
- // Output Style Configuration
- // ═══════════════════════════════════════════════════════
- const OUTPUT_STYLES = [
- { id: 'default', nameKey: 'menu:style.default', descKey: 'menu:style.defaultDesc' },
- { id: 'engineer-professional', nameKey: 'menu:style.engineerPro', descKey: 'menu:style.engineerProDesc' },
- { id: 'nekomata-engineer', nameKey: 'menu:style.nekomata', descKey: 'menu:style.nekomataDesc' },
- { id: 'laowang-engineer', nameKey: 'menu:style.laowang', descKey: 'menu:style.laowangDesc' },
- { id: 'ojousama-engineer', nameKey: 'menu:style.ojousama', descKey: 'menu:style.ojousamaDesc' },
- { id: 'abyss-cultivator', nameKey: 'menu:style.abyss', descKey: 'menu:style.abyssDesc' },
- { id: 'abyss-concise', nameKey: 'menu:style.abyssConcise', descKey: 'menu:style.abyssConciseDesc' },
- { id: 'abyss-command', nameKey: 'menu:style.abyssCommand', descKey: 'menu:style.abyssCommandDesc' },
- { id: 'abyss-ritual', nameKey: 'menu:style.abyssRitual', descKey: 'menu:style.abyssRitualDesc' },
- ]
- // ═══════════════════════════════════════════════════════
- // Model Routing Configuration
- // ═══════════════════════════════════════════════════════
- async function configModelRouting(): Promise<void> {
- const config = await readCcgConfig()
- const isZh = (config?.general?.language || 'zh-CN') === 'zh-CN'
- if (!config) {
- console.log(isZh ? '请先运行 ccg init 初始化配置。' : 'Run ccg init before changing routing.')
- return
- }
- console.log()
- console.log(ansis.cyan.bold(` ${i18n.t('init:model.title')}`))
- console.log()
- // Show current routing
- const currentFrontend = config?.routing?.frontend?.primary || 'antigravity'
- const currentBackend = config?.routing?.backend?.primary || 'codex'
- const currentGeminiModel = config?.routing?.geminiModel || 'gemini-3.1-pro-preview'
- const currentGrokModel = config?.routing?.grokModel || 'grok-4.5'
- const currentKimiModel = config?.routing?.kimiModel || ''
- const currentOpencodeModel = config?.routing?.opencodeModel || ''
- console.log(ansis.gray(` ${i18n.t('init:model.currentRouting')}:`))
- console.log(` ${ansis.cyan('Frontend:')} ${ansis.green(currentFrontend)}`)
- console.log(` ${ansis.cyan('Backend:')} ${ansis.blue(currentBackend)}`)
- if (currentFrontend === 'gemini' || currentBackend === 'gemini') {
- console.log(` ${ansis.cyan('Gemini:')} ${ansis.gray(currentGeminiModel)}`)
- }
- if (currentFrontend === 'grok' || currentBackend === 'grok') {
- console.log(` ${ansis.cyan('Grok:')} ${ansis.gray(currentGrokModel)}`)
- }
- console.log()
- // Frontend model selection
- const { selectedFrontend } = await inquirer.prompt([{
- type: 'list',
- name: 'selectedFrontend',
- message: i18n.t('init:model.selectFrontend'),
- choices: [
- { name: `Antigravity ${ansis.green(`(${i18n.t('init:model.recommended')})`)}`, value: 'antigravity' },
- { name: 'Grok', value: 'grok' },
- { name: 'Kimi', value: 'kimi' },
- { name: 'Codex', value: 'codex' },
- { name: 'OpenCode', value: 'opencode' },
- { name: `Claude Code ${ansis.cyan(`(${i18n.t('init:model.agentTeams')})`)}`, value: 'claude' },
- { name: `Gemini ${ansis.gray(`(${i18n.t('init:model.deprecated')})`)}`, value: 'gemini' },
- ],
- default: currentFrontend,
- }])
- // Backend model selection
- const { selectedBackend } = await inquirer.prompt([{
- type: 'list',
- name: 'selectedBackend',
- message: i18n.t('init:model.selectBackend'),
- choices: [
- { name: `Codex ${ansis.green(`(${i18n.t('init:model.recommended')})`)}`, value: 'codex' },
- { name: 'Grok', value: 'grok' },
- { name: 'Kimi', value: 'kimi' },
- { name: 'Antigravity', value: 'antigravity' },
- { name: 'OpenCode', value: 'opencode' },
- { name: `Claude Code ${ansis.cyan(`(${i18n.t('init:model.agentTeams')})`)}`, value: 'claude' },
- { name: `Gemini ${ansis.gray(`(${i18n.t('init:model.deprecated')})`)}`, value: 'gemini' },
- ],
- default: currentBackend,
- }])
- // Gemini model name (if gemini is selected for any role)
- let geminiModel = currentGeminiModel
- if (selectedFrontend === 'gemini' || selectedBackend === 'gemini') {
- const { selectedGeminiModel } = await inquirer.prompt([{
- type: 'list',
- name: 'selectedGeminiModel',
- message: i18n.t('init:model.selectGeminiModel'),
- choices: [
- { name: `gemini-3.1-pro-preview ${ansis.green(`(${i18n.t('init:model.recommended')})`)}`, value: 'gemini-3.1-pro-preview' },
- { name: 'gemini-2.5-flash', value: 'gemini-2.5-flash' },
- { name: `${i18n.t('init:model.custom')}`, value: 'custom' },
- ],
- default: currentGeminiModel,
- }])
- if (selectedGeminiModel === 'custom') {
- const { customModel } = await inquirer.prompt([{
- type: 'input',
- name: 'customModel',
- message: i18n.t('init:model.enterCustomModel'),
- validate: (v: string) => v.trim() !== '' || i18n.t('init:model.enterCustomModel'),
- }])
- geminiModel = customModel.trim()
- }
- else {
- geminiModel = selectedGeminiModel
- }
- }
- // Grok model name (if grok is selected for any role)
- let grokModel = currentGrokModel
- if (selectedFrontend === 'grok' || selectedBackend === 'grok') {
- const { selectedGrokModel } = await inquirer.prompt([{
- type: 'list',
- name: 'selectedGrokModel',
- message: i18n.t('init:model.selectGrokModel'),
- choices: [
- { name: `grok-4.5 ${ansis.green(`(${i18n.t('init:model.recommended')})`)}`, value: 'grok-4.5' },
- { name: 'grok-composer-2.5-fast', value: 'grok-composer-2.5-fast' },
- { name: `${i18n.t('init:model.custom')}`, value: 'custom' },
- ],
- default: currentGrokModel,
- }])
- if (selectedGrokModel === 'custom') {
- const { customModel } = await inquirer.prompt([{
- type: 'input',
- name: 'customModel',
- message: i18n.t('init:model.enterCustomModel'),
- validate: (v: string) => v.trim() !== '' || i18n.t('init:model.enterCustomModel'),
- }])
- grokModel = customModel.trim()
- }
- else {
- grokModel = selectedGrokModel
- }
- }
- // Check if anything changed
- let opencodeModel = currentOpencodeModel
- if (selectedFrontend === 'opencode' || selectedBackend === 'opencode') {
- opencodeModel = await promptOpencodeModel(currentOpencodeModel, isZh)
- }
- if (selectedFrontend === currentFrontend && selectedBackend === currentBackend && geminiModel === currentGeminiModel && grokModel === currentGrokModel && opencodeModel === currentOpencodeModel) {
- console.log(ansis.gray(` ${i18n.t('common:configNotModified')}`))
- return
- }
- // Update config.toml
- if (config) {
- config.routing.frontend = {
- models: [selectedFrontend as any],
- primary: selectedFrontend as any,
- strategy: 'fallback',
- }
- config.routing.backend = {
- models: [selectedBackend as any],
- primary: selectedBackend as any,
- strategy: 'fallback',
- }
- config.routing.review = {
- models: [...new Set([selectedFrontend, selectedBackend])] as any,
- strategy: 'parallel',
- }
- config.routing.geminiModel = geminiModel
- config.routing.grokModel = grokModel
- config.routing.kimiModel = currentKimiModel
- config.routing.opencodeModel = opencodeModel
- await writeCcgConfig(config)
- }
- console.log()
- console.log(ansis.green(` ✓ ${i18n.t('init:model.routingUpdated')}`))
- // Reinstall templates with new config
- const spinner = ora(i18n.t('init:model.reinstalling')).start()
- const previousExitCode = process.exitCode
- try {
- process.exitCode = 0
- await init({ force: true, skipPrompt: true, skipMcp: true })
- if (process.exitCode) {
- spinner.fail(i18n.t('init:model.reinstallFailed'))
- return
- }
- process.exitCode = previousExitCode
- spinner.succeed(i18n.t('init:model.reinstallDone'))
- }
- catch {
- process.exitCode = 1
- spinner.fail(i18n.t('init:model.reinstallFailed'))
- return
- }
- console.log(ansis.gray(` ${i18n.t('common:restartToApply')}`))
- }
- async function configOutputStyle(): Promise<void> {
- console.log()
- console.log(ansis.cyan.bold(` ${i18n.t('menu:style.title')}`))
- console.log()
- const settingsPath = join(homedir(), '.claude', 'settings.json')
- let settings: Record<string, any> = {}
- if (await fs.pathExists(settingsPath)) {
- settings = await fs.readJson(settingsPath)
- }
- const currentStyle = settings.outputStyle || 'default'
- console.log(ansis.gray(` ${i18n.t('menu:style.currentStyle')}: ${currentStyle}`))
- console.log()
- const { style } = await inquirer.prompt([{
- type: 'list',
- name: 'style',
- message: i18n.t('menu:style.selectStyle'),
- choices: OUTPUT_STYLES.map(s => ({
- name: `${i18n.t(s.nameKey)} ${ansis.gray(`- ${i18n.t(s.descKey)}`)}`,
- value: s.id,
- })),
- default: currentStyle,
- }])
- if (style === currentStyle) {
- console.log(ansis.gray(i18n.t('menu:style.notChanged')))
- return
- }
- // Copy style file if not default
- if (style !== 'default') {
- const outputStylesDir = join(homedir(), '.claude', 'output-styles')
- await fs.ensureDir(outputStylesDir)
- const __filename = fileURLToPath(import.meta.url)
- const __dirname = dirname(__filename)
- let pkgRoot = dirname(dirname(__dirname))
- if (!await fs.pathExists(join(pkgRoot, 'templates'))) {
- pkgRoot = dirname(pkgRoot)
- }
- const templatePath = join(pkgRoot, 'templates', 'output-styles', `${style}.md`)
- const destPath = join(outputStylesDir, `${style}.md`)
- if (await fs.pathExists(templatePath)) {
- await fs.copy(templatePath, destPath)
- console.log(ansis.green(` ✓ ${i18n.t('menu:style.installed', { style })}`))
- }
- }
- // Update settings.json
- if (style === 'default') {
- delete settings.outputStyle
- }
- else {
- settings.outputStyle = style
- }
- await fs.writeJson(settingsPath, settings, { spaces: 2 })
- console.log()
- console.log(ansis.green(` ✓ ${i18n.t('menu:style.set', { style })}`))
- console.log(ansis.gray(` ${i18n.t('common:restartToApply')}`))
- }
- // ═══════════════════════════════════════════════════════
- // Install Claude Code
- // ═══════════════════════════════════════════════════════
- /**
- * Install the CCG role matrix into a DeepSeek Harness profile.
- *
- * The plugin ships inside this package, so there is nothing to download and no
- * second version number: whatever CCG you ran is the plugin you get.
- */
- async function handleDshPlugin(): Promise<void> {
- const isZh = i18n.language === 'zh-CN'
- console.log()
- console.log(ansis.cyan.bold(isZh ? ' CCG for DeepSeek Harness' : ' CCG for DeepSeek Harness'))
- console.log()
- console.log(isZh
- ? ' 七个角色委派工具,各跑各的模型;任一角色可挂多个模型并排作答,\n 也能被雇成有自己文件的常驻队友。不依赖任何外部 CLI。'
- : ' Seven role-pinned delegation tools, each on its own model. Any role can\n answer as a panel of models, or be hired as a live teammate with its own\n files. No external CLI.')
- console.log()
- const profiles = await findDshProfiles()
- if (profiles.length === 0) {
- console.log(ansis.yellow(isZh
- ? ' 没有找到 DeepSeek Harness 配置档(~/.dsh/profiles/)。'
- : ' No DeepSeek Harness profile found (~/.dsh/profiles/).'))
- console.log(ansis.gray(isZh
- ? ' 先跑一次 `dsh web` 生成配置档,再回来安装。'
- : ' Run `dsh web` once to create one, then come back.'))
- console.log()
- return
- }
- for (const profile of profiles) {
- const mark = profile.installed ? ansis.green('✓') : ansis.gray('○')
- const note = profile.installed ? ansis.gray(isZh ? '已安装' : 'installed') : ''
- console.log(` ${mark} ${profile.name} ${note}`)
- }
- console.log()
- const { action } = await inquirer.prompt([{
- type: 'list',
- name: 'action',
- message: isZh ? '选择操作' : 'Select action',
- choices: [
- { name: isZh ? '安装 / 更新到全部配置档' : 'Install / update in every profile', value: 'install' },
- { name: isZh ? '选择配置档安装' : 'Pick which profiles', value: 'pick' },
- { name: isZh ? '卸载(从全部配置档移除)' : 'Uninstall (remove from every profile)', value: 'uninstall' },
- { name: isZh ? '返回' : 'Back', value: 'back' },
- ],
- }])
- if (action === 'back') return
- let chosen: string[] | undefined
- if (action === 'pick') {
- const { picked } = await inquirer.prompt([{
- type: 'checkbox',
- name: 'picked',
- message: isZh ? '装到哪些配置档' : 'Install into which profiles',
- choices: profiles.map(profile => ({ name: profile.name, value: profile.name, checked: profile.installed })),
- }])
- if (!picked || picked.length === 0) return
- chosen = picked
- }
- const uninstalling = action === 'uninstall'
- const spinner = ora(uninstalling
- ? (isZh ? '移除 dsh-ccg...' : 'Removing dsh-ccg...')
- : (isZh ? '安装 dsh-ccg...' : 'Installing dsh-ccg...')).start()
- const result = uninstalling
- ? await uninstallDshPlugin()
- : await installDshPlugin({ profiles: chosen })
- if (result.success) {
- spinner.succeed(uninstalling
- ? (isZh ? `已移除:${result.profiles.join(', ') || '(没有配置档装过)'}` : `Removed from: ${result.profiles.join(', ') || '(no profile had it)'}`)
- : (isZh ? `已安装到:${result.profiles.join(', ')}` : `Installed into: ${result.profiles.join(', ')}`))
- if (!uninstalling) {
- console.log()
- console.log(ansis.gray(isZh
- ? ' 重启 dsh 生效,然后在 设置 › 内置插件 › CCG 角色矩阵 里设好两个模型档位。'
- : ' Restart dsh to load it, then set the two model tiers in Settings › Built-in plugins › CCG.'))
- }
- }
- else {
- spinner.fail(isZh ? '失败' : 'Failed')
- if (result.message) console.log(ansis.red(` ${result.message}`))
- }
- for (const warning of result.warnings) console.log(ansis.yellow(` ! ${warning}`))
- console.log()
- }
- async function handleCodexMode(): Promise<void> {
- const isZh = i18n.language === 'zh-CN'
- console.log()
- console.log(ansis.cyan.bold(isZh ? ' Codex 多模型编排模式' : ' Codex Multi-Model Orchestration Mode'))
- console.log()
- const { action } = await inquirer.prompt([{
- type: 'list',
- name: 'action',
- message: isZh ? '选择操作' : 'Select action',
- choices: [
- { name: isZh ? '安装 / 更新 Codex 模式' : 'Install / Update Codex Mode', value: 'install' },
- { name: isZh ? '卸载 Codex 模式(只删 CCG 文件,保留用户配置)' : 'Uninstall Codex Mode (CCG files only, preserves user config)', value: 'uninstall' },
- { name: isZh ? '返回' : 'Back', value: 'back' },
- ],
- }])
- if (action === 'back') return
- if (action === 'uninstall') {
- const spinner = ora(isZh ? '卸载 Codex 模式...' : 'Uninstalling Codex mode...').start()
- const result = await uninstallCodexMode()
- if (result.success) {
- spinner.succeed(isZh ? 'Codex 模式已卸载' : 'Codex mode uninstalled')
- if (result.removed.length > 0) {
- console.log()
- for (const f of result.removed) {
- console.log(` ${ansis.red('✗')} ${f}`)
- }
- }
- if (result.skipped.length > 0) {
- console.log()
- for (const f of result.skipped) {
- console.log(` ${ansis.gray('○')} ${f}`)
- }
- }
- }
- else {
- spinner.fail(isZh ? '卸载失败' : 'Uninstall failed')
- }
- return
- }
- // Install
- console.log(isZh
- ? ' 安装 CCG Codex 模式到 ~/.codex/,让 Codex CLI 作为主导者编排多模型。'
- : ' Install CCG Codex mode to ~/.codex/, enabling Codex CLI as lead orchestrator.',
- )
- console.log()
- console.log(isZh ? ' 将安装:' : ' Will install:')
- console.log(' ~/.codex/AGENTS.md — orchestration instructions')
- console.log(' ~/.codex/config.toml — multi-agent + timeout config')
- console.log(' ~/.codex/hooks.json + hooks/ — adaptive guardrail hook')
- console.log(' ~/.codex/agents/ccg-*.toml — sub-agent definitions')
- console.log()
- const { confirm } = await inquirer.prompt([{
- type: 'confirm',
- name: 'confirm',
- message: isZh ? '确认安装?' : 'Confirm install?',
- default: true,
- }])
- if (!confirm) return
- const spinner = ora(isZh ? '安装 Codex 模式...' : 'Installing Codex mode...').start()
- const result = await installCodexMode()
- if (result.success) {
- spinner.succeed(isZh ? 'Codex 模式安装完成' : 'Codex mode installed')
- console.log()
- console.log(ansis.green(result.message))
- console.log()
- console.log(ansis.yellow(isZh
- ? ' 使用方法: 在项目目录运行 codex,AGENTS.md 会自动生效'
- : ' Usage: run codex in your project directory, AGENTS.md takes effect automatically',
- ))
- }
- else {
- spinner.fail(result.message)
- }
- }
- // ═══════════════════════════════════════════════════════
- async function handleInstallClaude(): Promise<void> {
- console.log()
- console.log(ansis.cyan.bold(` ${i18n.t('menu:claude.title')}`))
- console.log()
- // Check if already installed
- let isInstalled = false
- try {
- await execAsync('claude --version', { timeout: 5000 })
- isInstalled = true
- }
- catch {
- isInstalled = false
- }
- if (isInstalled) {
- console.log(ansis.yellow(` ⚠ ${i18n.t('menu:claude.alreadyInstalled')}`))
- const { confirm } = await inquirer.prompt([{
- type: 'confirm',
- name: 'confirm',
- message: i18n.t('menu:claude.reinstallPrompt'),
- default: false,
- }])
- if (!confirm) {
- console.log(ansis.gray(` ${i18n.t('common:cancelled')}`))
- return
- }
- // Uninstall
- console.log()
- console.log(ansis.yellow(` ⏳ ${i18n.t('menu:claude.uninstalling')}`))
- try {
- const uninstallCmd = isWindows() ? 'npm uninstall -g @anthropic-ai/claude-code' : 'sudo npm uninstall -g @anthropic-ai/claude-code'
- await execAsync(uninstallCmd, { timeout: 60000 })
- console.log(ansis.green(` ✓ ${i18n.t('menu:claude.uninstallSuccess')}`))
- }
- catch (e) {
- console.log(ansis.red(` ✗ ${i18n.t('menu:claude.uninstallFailed', { error: String(e) })}`))
- return
- }
- }
- // Select installation method
- const isMac = process.platform === 'darwin'
- const isLinux = process.platform === 'linux'
- const { method } = await inquirer.prompt([{
- type: 'list',
- name: 'method',
- message: i18n.t('menu:claude.selectMethod'),
- choices: [
- { name: `npm ${ansis.green('(⭐)')} ${ansis.gray('- npm install -g')}`, value: 'npm' },
- ...((isMac || isLinux) ? [{ name: `homebrew ${ansis.gray('- brew install')}`, value: 'homebrew' }] : []),
- ...((isMac || isLinux) ? [{ name: `curl ${ansis.gray('- official script')}`, value: 'curl' }] : []),
- ...(isWindows() ? [
- { name: `powershell ${ansis.gray('- Windows official')}`, value: 'powershell' },
- { name: `cmd ${ansis.gray('- Command Prompt')}`, value: 'cmd' },
- ] : []),
- new inquirer.Separator(),
- { name: `${ansis.gray(i18n.t('common:cancel'))}`, value: 'cancel' },
- ],
- }])
- if (method === 'cancel')
- return
- console.log()
- console.log(ansis.yellow(` ⏳ ${i18n.t('menu:claude.installing')}`))
- try {
- if (method === 'npm') {
- const installCmd = isWindows() ? 'npm install -g @anthropic-ai/claude-code' : 'sudo npm install -g @anthropic-ai/claude-code'
- await execAsync(installCmd, { timeout: 300000 })
- }
- else if (method === 'homebrew') {
- await execAsync('brew install --cask claude-code', { timeout: 300000 })
- }
- else if (method === 'curl') {
- await execAsync('curl -fsSL https://claude.ai/install.sh | bash', { timeout: 300000 })
- }
- else if (method === 'powershell') {
- await execAsync('powershell -Command "irm https://claude.ai/install.ps1 | iex"', { timeout: 300000 })
- }
- else if (method === 'cmd') {
- await execAsync('cmd /c "curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd"', { timeout: 300000 })
- Dismissed after review: Links to a Windows program from code, which is how droppers fetch their payload
- Line 1,029 on GitHub
- }
- console.log(ansis.green(` ✓ ${i18n.t('menu:claude.installSuccess')}`))
- console.log()
- console.log(ansis.cyan(` 💡 ${i18n.t('menu:claude.runHint')}`))
- }
- catch (e) {
- console.log(ansis.red(` ✗ ${i18n.t('menu:claude.installFailed', { error: String(e) })}`))
- }
- }
- // ═══════════════════════════════════════════════════════
- // Uninstall
- // ═══════════════════════════════════════════════════════
- /**
- * Check if CCG is installed globally via npm
- */
- async function checkIfGlobalInstall(): Promise<boolean> {
- try {
- const { stdout } = await execAsync('npm list -g ccg-workflow --depth=0', { timeout: 5000 })
- return stdout.includes('ccg-workflow@')
- }
- catch {
- return false
- }
- }
- async function uninstall(): Promise<void> {
- console.log()
- // Check if installed globally via npm
- const isGlobalInstall = await checkIfGlobalInstall()
- if (isGlobalInstall) {
- console.log(ansis.yellow(` ⚠️ ${i18n.t('menu:uninstall.globalDetected')}`))
- console.log()
- console.log(` ${i18n.t('menu:uninstall.twoSteps')}`)
- console.log(` ${ansis.cyan(`1. ${i18n.t('menu:uninstall.step1')}`)} ${ansis.gray(`(${i18n.t('menu:uninstall.step1Hint')})`)}`)
- console.log(` ${ansis.cyan(`2. ${i18n.t('menu:uninstall.step2')}`)} ${ansis.gray(`(${i18n.t('menu:uninstall.step2Hint')})`)}`)
- console.log()
- }
- // Confirm uninstall
- const { confirm } = await inquirer.prompt([{
- type: 'confirm',
- name: 'confirm',
- message: isGlobalInstall ? i18n.t('menu:uninstall.continuePrompt') : i18n.t('menu:uninstall.confirm'),
- default: false,
- }])
- if (!confirm) {
- console.log(ansis.gray(` ${i18n.t('menu:uninstall.cancelled')}`))
- return
- }
- console.log()
- console.log(ansis.yellow(` ${i18n.t('menu:uninstall.uninstalling')}`))
- // Uninstall workflows
- const installDir = join(homedir(), '.claude')
- const result = await uninstallWorkflows(installDir)
- if (result.success) {
- console.log(ansis.green(` ✅ ${i18n.t('menu:uninstall.success')}`))
- if (result.removedCommands.length > 0) {
- console.log()
- console.log(ansis.cyan(` ${i18n.t('menu:uninstall.removedCommands')}`))
- for (const cmd of result.removedCommands) {
- console.log(` ${ansis.gray('•')} /ccg:${cmd}`)
- }
- }
- if (result.removedAgents.length > 0) {
- console.log()
- console.log(ansis.cyan(` ${i18n.t('menu:uninstall.removedAgents')}`))
- for (const agent of result.removedAgents) {
- console.log(` ${ansis.gray('•')} ${agent}`)
- }
- }
- if (result.removedSkills.length > 0) {
- console.log()
- console.log(ansis.cyan(` ${i18n.t('menu:uninstall.removedSkills')}`))
- console.log(` ${ansis.gray('•')} multi-model-collaboration`)
- }
- if (result.removedBin) {
- console.log()
- console.log(ansis.cyan(` ${i18n.t('menu:uninstall.removedBin')}`))
- console.log(` ${ansis.gray('•')} codeagent-wrapper`)
- }
- // If globally installed, show instructions to uninstall npm package
- if (isGlobalInstall) {
- console.log()
- console.log(ansis.yellow.bold(` 🔸 ${i18n.t('menu:uninstall.lastStep')}`))
- console.log()
- console.log(` ${i18n.t('menu:uninstall.runInNewTerminal')}`)
- console.log()
- console.log(ansis.cyan.bold(' npm uninstall -g ccg-workflow'))
- console.log()
- console.log(ansis.gray(` (${i18n.t('menu:uninstall.afterDone')})`))
- }
- }
- else {
- console.log(ansis.red(` ${i18n.t('menu:uninstall.failed')}`))
- for (const error of result.errors) {
- console.log(ansis.red(` ${error}`))
- }
- }
- console.log()
- }
- // ═══════════════════════════════════════════════════════
- // Tools
- // ═══════════════════════════════════════════════════════
- async function handleTools(): Promise<void> {
- console.log()
- const { tool } = await inquirer.prompt([{
- type: 'list',
- name: 'tool',
- message: i18n.t('menu:tools.title'),
- choices: [
- { name: `${ansis.green('📊')} ccusage ${ansis.gray(`${i18n.t('menu:tools.ccusage')}`)}`, value: 'ccusage' },
- { name: `${ansis.blue('📟')} CCometixLine ${ansis.gray(`${i18n.t('menu:tools.ccline')}`)}`, value: 'ccline' },
- new inquirer.Separator(),
- { name: `${ansis.gray(`← ${i18n.t('common:back')}`)}`, value: 'cancel' },
- ],
- }])
- if (tool === 'cancel')
- return
- if (tool === 'ccusage') {
- await runCcusage()
- }
- else if (tool === 'ccline') {
- await handleCCometixLine()
- }
- }
- async function runCcusage(): Promise<void> {
- console.log()
- console.log(ansis.cyan(` 📊 ${i18n.t('menu:tools.runningCcusage')}`))
- console.log(ansis.gray(' $ npx ccusage@latest'))
- console.log()
- return new Promise((resolve) => {
- const child = spawn('npx', ['ccusage@latest'], {
- stdio: 'inherit',
- shell: true,
- })
- child.on('close', () => resolve())
- child.on('error', () => resolve())
- })
- }
- async function handleCCometixLine(): Promise<void> {
- console.log()
- const { action } = await inquirer.prompt([{
- type: 'list',
- name: 'action',
- message: i18n.t('menu:tools.cclineAction'),
- choices: [
- { name: `${ansis.green('➜')} ${i18n.t('menu:tools.cclineInstall')}`, value: 'install' },
- { name: `${ansis.red('✕')} ${i18n.t('menu:tools.cclineUninstall')}`, value: 'uninstall' },
- new inquirer.Separator(),
- { name: `${ansis.gray(`← ${i18n.t('common:back')}`)}`, value: 'cancel' },
- ],
- }])
- if (action === 'cancel')
- return
- if (action === 'install') {
- await installCCometixLine()
- }
- else if (action === 'uninstall') {
- await uninstallCCometixLine()
- }
- }
- async function installCCometixLine(): Promise<void> {
- console.log()
- console.log(ansis.yellow(` ⏳ ${i18n.t('menu:tools.cclineInstalling')}`))
- try {
- const installCmd = isWindows() ? 'npm install -g @cometix/ccline' : 'sudo npm install -g @cometix/ccline'
- await execAsync(installCmd, { timeout: 120000 })
- console.log(ansis.green(` ✓ ${i18n.t('menu:tools.cclineInstallSuccess')}`))
- const settingsPath = join(homedir(), '.claude', 'settings.json')
- let settings: Record<string, any> = {}
- if (await fs.pathExists(settingsPath)) {
- settings = await fs.readJson(settingsPath)
- }
- settings.statusLine = {
- type: 'command',
- command: isWindows()
- ? '~/.claude/ccline/ccline.exe'
- : '~/.claude/ccline/ccline',
- padding: 0,
- }
- await fs.ensureDir(join(homedir(), '.claude'))
- await fs.writeJson(settingsPath, settings, { spaces: 2 })
- console.log(ansis.green(` ✓ ${i18n.t('menu:tools.cclineConfigured')}`))
- console.log()
- console.log(ansis.cyan(` 💡 ${i18n.t('common:restartToApply')}`))
- }
- catch (error) {
- console.log(ansis.red(` ✗ ${i18n.t('menu:tools.cclineInstallFailed', { error: String(error) })}`))
- }
- }
- async function uninstallCCometixLine(): Promise<void> {
- console.log()
- console.log(ansis.yellow(` ⏳ ${i18n.t('menu:tools.cclineUninstalling')}`))
- try {
- const settingsPath = join(homedir(), '.claude', 'settings.json')
- if (await fs.pathExists(settingsPath)) {
- const settings = await fs.readJson(settingsPath)
- delete settings.statusLine
- await fs.writeJson(settingsPath, settings, { spaces: 2 })
- console.log(ansis.green(` ✓ ${i18n.t('menu:tools.cclineConfigRemoved')}`))
- }
- const uninstallCmd = isWindows() ? 'npm uninstall -g @cometix/ccline' : 'sudo npm uninstall -g @cometix/ccline'
- await execAsync(uninstallCmd, { timeout: 60000 })
- console.log(ansis.green(` ✓ ${i18n.t('menu:tools.cclineUninstalled')}`))
- }
- catch (error) {
- console.log(ansis.red(` ✗ ${i18n.t('menu:tools.cclineUninstallFailed', { error: String(error) })}`))
- }
- }
Ratings and comments
Sign in to rate this skill.
Sign inFree to use. If it’s helped, pass it on.