# https://github.com/chenhg5/cc-connect 项目说明书

生成时间：2026-05-15 11:55:32 UTC

## 目录

- [Introduction to cc-connect](#page-introduction)
- [Quick Start Guide](#page-quickstart)
- [System Architecture](#page-architecture)
- [Core Components](#page-core-components)
- [Agent Integrations](#page-agent-integrations)
- [Platform Integrations](#page-platform-integrations)
- [Configuration Guide](#page-configuration)
- [Session Management](#page-session-management)
- [Web UI Administration](#page-web-ui)
- [Deployment and Operations](#page-deployment)

<a id='page-introduction'></a>

## Introduction to cc-connect

### 相关页面

相关主题：[System Architecture](#page-architecture), [Quick Start Guide](#page-quickstart)

<details>
<summary>相关源码文件</summary>

以下源码文件用于生成本页说明：

- [npm/README.md](https://github.com/chenhg5/cc-connect/blob/main/npm/README.md)
- [INSTALL.md](https://github.com/chenhg5/cc-connect/blob/main/INSTALL.md)
- [web/src/api/client.ts](https://github.com/chenhg5/cc-connect/blob/main/web/src/api/client.ts)
- [web/src/pages/Projects/ProjectList.tsx](https://github.com/chenhg5/cc-connect/blob/main/web/src/pages/Projects/ProjectList.tsx)
- [web/src/pages/Providers/ProviderList.tsx](https://github.com/chenhg5/cc-connect/blob/main/web/src/pages/Providers/ProviderList.tsx)
- [core/i18n.go](https://github.com/chenhg5/cc-connect/blob/main/core/i18n.go)
</details>

# Introduction to cc-connect

cc-connect is a bridge service that connects local AI coding agents to messaging platforms, enabling developers to interact with their AI development assistants from anywhere through popular chat applications.

## Overview

cc-connect acts as a middleware layer between AI coding agents and messaging platforms. It allows developers to leverage the power of AI coding tools like Claude Code, Cursor, Codex, Gemini CLI, and iFlow from messaging applications such as Feishu/Lark, DingTalk, Slack, Telegram, Discord, LINE, and WeChat Work.

资料来源：[npm/README.md:1-12]()

## Architecture

cc-connect consists of three main components:

| Component | Description | Technology |
|-----------|-------------|------------|
| Backend Service | Core bridge service that manages connections and message routing | Go |
| Web Admin UI | Browser-based dashboard for configuration and monitoring | React/TypeScript |
| NPM Package | CLI tool for installation and management | Node.js |

The backend service runs as a daemon process and maintains persistent connections to both the local AI coding agent and the configured messaging platforms.

资料来源：[INSTALL.md:1-50]()

## Supported AI Agents

cc-connect integrates with multiple AI coding agents through a unified agent interface:

| Agent | Type Identifier | Description |
|-------|-----------------|-------------|
| Claude Code | `claudecode` | Anthropic's CLI tool for Claude |
| Codex | `codex` | OpenAI's coding agent |
| Cursor | `cursor` | Cursor AI editor |
| Gemini CLI | `gemini` | Google's Gemini CLI |
| iFlow | `iflow` | iFlow AI platform |
| Qoder | `qoder` | Qoder coding assistant |
| OpenCode | `opencode` | Open code editing agent |

资料来源：[INSTALL.md:60-75]()

## Supported Messaging Platforms

The service supports integration with multiple enterprise and consumer messaging platforms:

- **Feishu/Lark** - ByteDance's enterprise communication platform
- **DingTalk** - Alibaba's enterprise messaging tool
- **Slack** - Popular team collaboration platform
- **Telegram** - Cloud-based instant messaging
- **Discord** - Community and gaming communication
- **LINE** - Japanese messaging application
- **WeChat Work** - Tencent's enterprise WeChat variant

资料来源：[npm/README.md:3]()

## Project Management

cc-connect organizes work through projects, where each project links a code folder to one or more messaging platforms.

```toml
[[projects]]
name = "my-project"

[projects.agent]
type = "claudecode"  # or "codex", "cursor", "gemini", "qoder", "opencode", "iflow"

[projects.agent.options]
work_dir = "/absolute/path/to/your/project"
mode = "default"
```

资料来源：[INSTALL.md:30-45]()

## Configuration

### Configuration File Locations

cc-connect searches for configuration in this order:

| Priority | Location | Notes |
|----------|----------|-------|
| 1 | `-config <path>` flag | Explicit path specification |
| 2 | `./config.toml` | Current directory |
| 3 | `~/.cc-connect/config.toml` | Global user directory (recommended) |

If no config file exists, running `cc-connect` will auto-create a starter template at `~/.cc-connect/config.toml`.

资料来源：[INSTALL.md:8-18]()

### Global Settings

| Setting | Values | Default | Description |
|---------|--------|---------|-------------|
| `language` | `"en"`, `"zh"`, `""` | `""` (auto-detect) | UI and message language |
| `log.level` | `"debug"`, `"info"`, `"warn"`, `"error"` | `"info"` | Logging verbosity |

## Web Interface

The web admin interface provides a graphical dashboard for managing all cc-connect functionality:

### Sessions Management

The sessions feature displays active chat sessions with real-time status indicators:

- Live session badges showing active connections
- Last message preview with role indicators
- Session switching and creation capabilities

资料来源：[web/src/pages/Sessions/SessionList.tsx:10-30]()

### Bridge Status Monitoring

The interface displays connection status between cc-connect and the configured messaging platforms:

| Status | Indicator | Description |
|--------|-----------|-------------|
| Connected | Green indicator | Bridge active and operational |
| Connecting | Spinner animation | Connection in progress |
| Disconnected | Warning icon | Bridge connection lost |

资料来源：[web/src/pages/Chat/ChatView.tsx:1-25]()

### Provider Management

Providers define the messaging platform connections. Each provider can have multiple models and agent types associated with it.

资料来源：[web/src/pages/Providers/ProviderList.tsx:1-30]()

## API Client

The web interface communicates with the backend through a RESTful API client:

```typescript
get<T>(path: string, params?: Record<string, string>)
post<T>(path: string, body?: any)
put<T>(path: string, body?: any)
patch<T>(path: string, body?: any)
delete<T>(path: string)
async raw(path: string): Promise<string>
```

The client supports JWT Bearer token authentication and handles unauthorized access with automatic callback notification.

资料来源：[web/src/api/client.ts:1-50]()

## Internationalization

cc-connect supports multiple languages for its user interface and messages:

| Language | Code | Status |
|----------|------|--------|
| English | `en` | Primary |
| Chinese (Simplified) | `zh` | Supported |
| Chinese (Traditional) | `zh-TW` | Supported |
| Japanese | `ja` | Supported |
| Spanish | `es` | Supported |

资料来源：[core/i18n.go:1-50]()

## Installation Methods

### Package Managers

| Platform | Command |
|----------|---------|
| macOS (Homebrew) | `brew install cc-connect` |
| npm | `npm install -g cc-connect` |

### Manual Installation

1. Download the binary from GitHub Releases
2. Make it executable: `chmod +x cc-connect`
3. Move to PATH: `sudo mv cc-connect /usr/local/bin/`

### Build from Source

Requires Go 1.22+:

```bash
git clone https://github.com/chenhg5/cc-connect.git
cd cc-connect
make build
```

资料来源：[INSTALL.md:80-110]()

## Daemon Management

cc-connect can run as a background service managed by the operating system:

| Command | Description |
|---------|-------------|
| `cc-connect daemon install` | Install as system service |
| `cc-connect daemon start` | Start the service |
| `cc-connect daemon stop` | Stop the service |
| `cc-connect daemon restart` | Restart the service |
| `cc-connect daemon status` | Check service status |
| `cc-connect daemon logs` | View service logs |

On Linux, this uses systemd user services. On macOS, it uses launchd LaunchAgents. On Windows, it creates a Task Scheduler task.

资料来源：[INSTALL.md:150-175]()

## Workflow Diagram

```mermaid
graph TD
    A[User on Messaging Platform] -->|Sends Message| B[Messaging Platform API]
    B -->|Routes Message| C[cc-connect Bridge]
    C -->|Processes & Formats| D[Local AI Agent]
    D -->|AI Response| C
    C -->|Formats Response| B
    B -->|Delivers Message| A
    
    E[Web Admin UI] -->|Configuration| C
    F[config.toml] -->|Settings| C
```

## Skills System

cc-connect supports an extensible skills system that allows AI agents to gain additional capabilities:

- **Recommended Skills** - Curated skill presets that can be downloaded
- **Custom Skills** - User-defined skills for specific workflows
- **Skill Presets** - Pre-configured skill collections with metadata

Skills include metadata such as:
- Display name and description
- Version information
- Pricing model
- Author attribution
- Source URL and provider information

资料来源：[web/src/pages/Skills/SkillList.tsx:1-100]()

## Summary

cc-connect provides a unified bridge between local AI coding agents and enterprise messaging platforms, enabling developers to:

- Access AI coding assistance from any messaging platform
- Manage multiple projects with different AI agents
- Configure flexible provider settings
- Monitor connections through a web-based dashboard
- Extend capabilities through a skills system

The architecture prioritizes reliability with automatic reconnection, comprehensive logging, and daemon-based operation for continuous availability.

---

<a id='page-quickstart'></a>

## Quick Start Guide

### 相关页面

相关主题：[Introduction to cc-connect](#page-introduction), [Configuration Guide](#page-configuration), [Deployment and Operations](#page-deployment)

<details>
<summary>相关源码文件</summary>

以下源码文件用于生成本页说明：

- [INSTALL.md](https://github.com/chenhg5/cc-connect/blob/main/INSTALL.md)
- [config.example.toml](https://github.com/chenhg5/cc-connect/blob/main/config.example.toml)
- [cmd/cc-connect/main.go](https://github.com/chenhg5/cc-connect/blob/main/cmd/cc-connect/main.go)
- [cmd/cc-connect/cron.go](https://github.com/chenhg5/cc-connect/blob/main/cmd/cc-connect/cron.go)
- [AGENTS.md](https://github.com/chenhg5/cc-connect/blob/main/AGENTS.md)
</details>

# Quick Start Guide

cc-connect is a bridge service that connects local AI coding agents (Claude Code, Codex, Cursor, Gemini CLI, etc.) with messaging platforms (Feishu, Telegram, Discord, Slack, etc.). This enables natural language interaction with AI coding agents through familiar chat interfaces.

## Prerequisites

Before installing cc-connect, ensure your environment meets these requirements:

| Requirement | Version/Details |
|-------------|-----------------|
| Go (for source build) | 1.22+ |
| Node.js (for Claude Code agent) | Latest stable |
| npm | Latest stable |
| Supported OS | Linux, macOS, Windows |
| Network | Outbound access to messaging platform APIs |

You must also install at least one supported AI coding agent:

```bash
# Claude Code
npm install -g @anthropic-ai/claude-code

# Codex
npm install -g @openai/codex

# Gemini CLI
npm install -g @google/gemini-cli

# iFlow CLI
npm install -g @iflow-ai/if
```

## Installation Methods

### Option A: Homebrew (macOS/Linux)

```bash
brew tap chenhg5/tap
brew install cc-connect
```

### Option B: Download Binary

Download pre-built binaries from [GitHub Releases](https://github.com/chenhg5/cc-connect/releases):

| Platform | Artifact Pattern |
|----------|------------------|
| Linux amd64 | `cc-connect-<version>-linux-amd64` |
| macOS amd64 | `cc-connect-<version>-darwin-amd64` |
| macOS ARM64 | `cc-connect-<version>-darwin-arm64` |
| Windows | `cc-connect-<version>-windows-amd64.exe` |

```bash
curl -L -o cc-connect https://github.com/chenhg5/cc-connect/releases/latest/download/cc-connect-linux-amd64
chmod +x cc-connect
sudo mv cc-connect /usr/local/bin/
```

On macOS, remove the quarantine attribute:
```bash
xattr -d com.apple.quarantine cc-connect
```

### Option C: Build from Source

```bash
git clone https://github.com/chenhg5/cc-connect.git
cd cc-connect
make build
```

资料来源：[INSTALL.md:1-80]()

## Configuration

### Config File Location

cc-connect searches for configuration in this order:

1. `-config <path>` flag (explicit path)
2. `./config.toml` (current directory)
3. `~/.cc-connect/config.toml` (global, recommended)

资料来源：[INSTALL.md:10-15]()

### Create Starter Config

The easiest method is to let cc-connect auto-generate a starter config:

```bash
# Run once - creates ~/.cc-connect/config.toml automatically
cc-connect
```

Or manually create from the example:

```bash
mkdir -p ~/.cc-connect
cp config.example.toml ~/.cc-connect/config.toml
```

### Configuration Structure

```toml
# Optional global settings
# language = "en"  # "en", "zh", or "" (auto-detect)

[log]
level = "info"  # debug, info, warn, error

# Each [[projects]] entry connects one code folder to one or more messaging platforms
[[projects]]
name = "my-project"

[projects.agent]
type = "claudecode"  # or "codex", "cursor", "gemini", "qoder", "opencode", "iflow"

[projects.agent.options]
work_dir = "/absolute/path/to/your/project"
mode = "default"  # "default", "acceptEdits", "plan", "yolo"

[[projects.platforms]]
type = "feishu"  # or "telegram", "discord", "slack", "dingtalk", etc.

[projects.platforms.options]
app_id = "cli_xxx"
app_secret = "xxx"
```

资料来源：[INSTALL.md:30-60]()

### Agent Permission Modes

| Mode | Behavior |
|------|----------|
| `default` | Standard permission model - agent asks before actions |
| `acceptEdits` | Accepts all edit suggestions automatically |
| `plan` | Only plans, does not execute |
| `bypassPermissions` | Bypasses all permission checks (yolo mode) |
| `dontAsk` | Never prompts for confirmation |

资料来源：[web/src/pages/Projects/ProjectDetail.tsx:1-30]()

## Running the Application

### Basic Startup

```bash
# Run with config.toml in current directory
cc-connect

# Or specify config path
cc-connect -config /path/to/config.toml

# Check version
cc-connect --version
```

Expected output:
```
level=INFO msg="platform started" project=my-project platform=feishu
level=INFO msg="engine started" project=my-project agent=claudecode platforms=1
level=INFO msg="cc-connect is running" projects=1
```

### Claude Code Session Note

If running inside a Claude Code session, you must unset the `CLAUDECODE` environment variable before starting:

```bash
unset CLAUDECODE && cc-connect
```

Alternatively, open a separate terminal to run cc-connect.

资料来源：[INSTALL.md:75-90]()

## Chat Commands

Once running, use these slash commands on your configured messaging platform:

| Command | Description |
|---------|-------------|
| `/new [name]` | Start a new session |
| `/list` | List agent sessions |
| `/switch <id>` | Resume an existing session |
| `/current` | Show current active session |
| `/history [n]` | Show last n messages (default 10) |
| `/reasoning [level]` | View/switch reasoning effort (Codex) |
| `/mode [name]` | View/switch permission mode |
| `/quiet` | Toggle thinking/tool progress messages |
| `/allow <tool>` | Pre-allow a tool (next session) |

资料来源：[INSTALL.md:95-110]()

## Scheduled Tasks (Cron)

Create automated tasks that run through the agent or execute shell commands directly.

### Add a Scheduled Task

```bash
cc-connect cron add --cron "<min> <hour> <day> <month> <weekday>" --prompt "<task description>" --desc "<short label>"
```

### Cron Expression Format

| Field | Allowed Values |
|-------|----------------|
| Minute | 0-59 or * |
| Hour | 0-23 or * |
| Day | 1-31 or * |
| Month | 1-12 or * |
| Weekday | 0-6 (0=Sunday) or * |

### Examples

```bash
# Run every day at 6am through the agent
cc-connect cron add --cron "0 6 * * *" --prompt "Collect GitHub trending repos and send a summary" --desc "Daily GitHub Trending"

# Run every Monday at 9am
cc-connect cron add --cron "0 9 * * 1" --prompt "Generate a weekly project status report" --desc "Weekly Report"

# Run every 30 minutes with direct shell command
cc-connect cron add --cron "*/30 * * * *" --exec "df -h" --desc "Disk usage check"
```

### Additional Cron Options

| Option | Description | Default |
|--------|-------------|---------|
| `--project <name>` | Target project | Auto-detected from CC_PROJECT env |
| `--session-key <key>` | Target session | Auto-detected from CC_SESSION_KEY env |
| `--session-mode <mode>` | `reuse` (default) or `new-per-run` | reuse |
| `--timeout-mins <n>` | Max minutes per run (0=no limit) | 30 |
| `--data-dir <path>` | Data directory | ~/.cc-connect |

资料来源：[cmd/cc-connect/cron.go:1-50]()

## Multi-Project Setup

A single cc-connect process can manage multiple projects, each with its own agent, work directory, and platforms:

```toml
[[projects]]
name = "backend"
[projects.agent]
type = "claudecode"
[projects.agent.options]
work_dir = "/path/to/backend"
mode = "default"
[[projects.platforms]]
type = "feishu"
[projects.platforms.options]
app_id = "cli_xxx"
app_secret = "xxx"

[[projects]]
name = "frontend"
[projects.agent]
type = "codex"
[projects.agent.options]
work_dir = "/path/to/frontend"
mode = "full-auto"
[[projects.platforms]]
type = "telegram"
[projects.platforms.options]
token = "xxx"

[[projects]]
name = "design-system"
[projects.agent]
type = "cursor"
[projects.agent.options]
work_dir = "/path/to/design-system"
mode = "force"
[[projects.platforms]]
type = "discord"
[projects.platforms.options]
token = "xxx"
```

资料来源：[INSTALL.md:150-180]()

## Running as a Background Service

### Install the Daemon

```bash
cc-connect daemon install --config ~/.cc-connect/config.toml
```

Or specify the work directory containing `config.toml`:

```bash
cc-connect daemon install --work-dir ~/.cc-connect
```

### Service Control Commands

```bash
cc-connect daemon start
cc-connect daemon stop
cc-connect daemon restart
cc-connect daemon status
```

### View Logs

```bash
cc-connect daemon logs           # tail current log
cc-connect daemon logs -f         # follow (like tail -f)
cc-connect daemon logs -n 100     # last 100 lines
cc-connect daemon logs --log-file /path/to/log  # custom log file
```

Logs auto-rotate at the configured max size and keep one backup.

On Windows, this creates a Task Scheduler task that runs at user logon.

资料来源：[INSTALL.md:190-220]()

## Agent Integration

### Claude Code

Claude Code handles cc-connect integration automatically via `--append-system-prompt` - no extra setup needed.

### Other Agents

For Codex, Cursor Agent, Qoder CLI, Gemini CLI, OpenCode, or iFlow CLI, add instructions to the agent's project-level instruction file:

| Agent | File Location |
|-------|---------------|
| Codex | `AGENTS.md` |
| Cursor Agent | `.cursorrules` |
| Qoder CLI | `AGENTS.md` |
| Gemini CLI | `GEMINI.md` |
| OpenCode | `OPENCODE.md` |
| iFlow CLI | `IFLOW.md` |

Create/edit the file in your project's `work_dir` with cc-connect integration instructions. The agent will automatically use `cc-connect cron add` commands when scheduling tasks.

> **Tip:** Add these files to `.gitignore` if you don't want cc-connect instructions committed to version control.

资料来源：[AGENTS.md:1-30]()

## Web UI

The cc-connect web interface provides a visual dashboard for managing projects. Access it at:

```
http://localhost:18792
```

The web UI allows you to:
- View and manage projects
- Configure platforms
- Manage provider settings
- View and manage agent sessions
- Configure and monitor skills

资料来源：[web/index.html:1-15]()

## Upgrade Instructions

### Package Manager Users

```bash
brew upgrade cc-connect
```

### Binary Users

```bash
# Download new binary
curl -L -o cc-connect https://github.com/chenhg5/cc-connect/releases/latest/download/cc-connect-linux-amd64
chmod +x cc-connect
sudo mv cc-connect /usr/local/bin/
```

### Source Users

```bash
cd cc-connect
git pull
make build
```

After upgrading, restart the running cc-connect process.

资料来源：[INSTALL.md:85-100]()

## Verification Checklist

Before going to production, verify:

- [ ] Build passes: `go build ./...`
- [ ] Tests pass: `go test ./...`
- [ ] Configuration file is valid TOML
- [ ] Agent is installed and accessible from PATH
- [ ] Platform credentials are configured correctly
- [ ] Network connectivity to platform APIs works
- [ ] Web UI is accessible
- [ ] Basic chat commands work (`/new`, `/list`, `/history`)

资料来源：[AGENTS.md:1-10]()

---

<a id='page-architecture'></a>

## System Architecture

### 相关页面

相关主题：[Core Components](#page-core-components), [Agent Integrations](#page-agent-integrations), [Platform Integrations](#page-platform-integrations)

<details>
<summary>相关源码文件</summary>

以下源码文件用于生成本页说明：

- [core/bridge.go](https://github.com/chenhg5/cc-connect/blob/main/core/bridge.go)
- [core/engine.go](https://github.com/chenhg5/cc-connect/blob/main/core/engine.go)
- [core/relay.go](https://github.com/chenhg5/cc-connect/blob/main/core/relay.go)
- [web/src/api/client.ts](https://github.com/chenhg5/cc-connect/blob/main/web/src/api/client.ts)
- [web/src/pages/Chat/ChatView.tsx](https://github.com/chenhg5/cc-connect/blob/main/web/src/pages/Chat/ChatView.tsx)
- [web/src/pages/Sessions/SessionChat.tsx](https://github.com/chenhg5/cc-connect/blob/main/web/src/pages/Sessions/SessionChat.tsx)
- [INSTALL.md](https://github.com/chenhg5/cc-connect/blob/main/INSTALL.md)
- [AGENTS.md](https://github.com/chenhg5/cc-connect/blob/main/AGENTS.md)
</details>

# System Architecture

## Overview

cc-connect is a bridge service that connects AI coding agents (such as Claude Code, Codex, Cursor, Gemini, Qoder, OpenCode, and iFlow) with messaging platforms (Feishu, WeChat Work, Telegram, Discord, Slack, DingTalk, WeCom, WeChat, QQ, Line, Weibo). The system acts as a bidirectional relay, translating messages between agent sessions and chat platforms in real-time.

## High-Level Architecture

```mermaid
graph TD
    subgraph "Messaging Platforms"
        FEISHU[Feishu]
        WECHAT[WeChat Work]
        TELEGRAM[Telegram]
        DISCORD[Discord]
        SLACK[Slack]
        DINGTALK[DingTalk]
        WECOM[WeCom]
        WEIXIN[WeChat]
        QQ[QQ]
    end

    subgraph "cc-connect Core"
        BRIDGE[Bridge Manager]
        ENGINE[Engine]
        RELAY[Relay Handler]
        SESSION[Session Manager]
    end

    subgraph "AI Agents"
        CLAUDE[Claude Code]
        CODEX[Codex]
        CURSOR[Cursor]
        GEMINI[Gemini]
        QODER[Qoder]
        OPENCODE[OpenCode]
        IFLOW[iFlow]
    end

    FEISHU <--> BRIDGE
    WECHAT <--> BRIDGE
    TELEGRAM <--> BRIDGE
    DISCORD <--> BRIDGE
    SLACK <--> BRIDGE
    DINGTALK <--> BRIDGE
    WECOM <--> BRIDGE
    WEIXIN <--> BRIDGE
    QQ <--> BRIDGE

    BRIDGE <--> ENGINE
    ENGINE <--> RELAY
    ENGINE <--> SESSION
    RELAY <--> CLAUDE
    RELAY <--> CODEX
    RELAY <--> CURSOR
    RELAY <--> GEMINI
    RELAY <--> QODER
    RELAY <--> OPENCODE
    RELAY <--> IFLOW
```

## Core Components

### Bridge Manager

The Bridge Manager (`core/bridge.go`) is the central coordinator that maintains WebSocket connections to all configured messaging platforms. It handles:

- Connection lifecycle management (connect, reconnect, disconnect)
- Message routing between platforms and the engine
- Bridge status monitoring for the web UI

| Property | Type | Description |
|----------|------|-------------|
| `Status` | `string` | Connection state: `connected`, `connecting`, `disconnected`, `error` |
| `Platform` | `string` | Platform identifier (e.g., `feishu`, `telegram`) |
| `SessionKey` | `string` | Associated session identifier |

The web UI displays bridge status using icons and text:

```tsx
// Connected state - ChatView.tsx:45
bridgeStatus === 'error' ? (
  <div className="flex items-center gap-2 text-amber-600">
    <WifiOff size={14} />
    <span>{t('sessions.bridgeDisconnected')}</span>
  </div>
) : (
  <div className="flex items-center gap-2 text-gray-400">
    <Loader2 size={14} className="animate-spin" />
    <span>{t('sessions.bridgeConnecting')}</span>
  </div>
)
```

### Engine

The Engine (`core/engine.go`) serves as the central processing unit that:

- Manages project configurations and agent assignments
- Coordinates message processing and response handling
- Maintains session state across multiple concurrent conversations

### Relay Handler

The Relay Handler (`core/relay.go`) acts as the message translation layer between platforms and agents:

- Converts incoming platform messages to agent-readable format
- Translates agent responses back to platform-specific formats
- Handles multi-turn conversations and context preservation

## Session Management

Each project can have multiple sessions, allowing concurrent conversations. The system supports:

```mermaid
graph LR
    subgraph "Project: my-project"
        S1[Session: session-1]
        S2[Session: session-2]
        S3[Session: session-3]
    end

    S1 <--> A1[Claude Code]
    S2 <--> A2[Claude Code]
    S3 <--> A3[Claude Code]
```

Sessions are accessible via the UI drawer component:

```tsx
// ProjectList.tsx:120
<SessionDrawer
  open={drawerOpen}
  onClose={() => setDrawerOpen(false)}
  sessions={sessions}
  currentSessionId={currentSession?.id || ''}
  onSelect={switchToSession}
  onNewSession={handleNewSession}
/>
```

## Agent System

### Supported Agents

| Agent | Type Key | Mode Options |
|-------|----------|--------------|
| Claude Code | `claudecode` | `default`, `acceptEdits`, `plan`, `bypassPermissions`, `dontAsk` |
| Codex | `codex` | Default settings with optional wire API |
| Cursor | `cursor` | Default mode |
| Gemini | `gemini` | Default mode |
| Qoder | `qoder` | Default mode |
| OpenCode | `opencode` | Default mode |
| iFlow | `iflow` | Default mode |

### Agent Configuration

Agents are configured per project in `config.toml`:

```toml
[[projects]]
name = "my-project"

[projects.agent]
type = "claudecode"

[projects.agent.options]
work_dir = "/absolute/path/to/your/project"
mode = "default"
```

资料来源：[INSTALL.md](https://github.com/chenhg5/cc-connect/blob/main/INSTALL.md)

### Adding New Agents

The architecture follows a plugin pattern for extensibility. To add a new agent:

1. Create `agent/newagent/newagent.go`
2. Implement `core.Agent` and `core.AgentSession` interfaces
3. Register in `init()`: `core.RegisterAgent("newagent", factory)`
4. Create `cmd/cc-connect/plugin_agent_newagent.go` with `//go:build` tag

资料来源：[AGENTS.md](https://github.com/chenhg5/cc-connect/blob/main/AGENTS.md)

## Platform System

### Supported Platforms

| Platform | Key | Configuration Method |
|----------|-----|---------------------|
| Feishu | `feishu` | QR code setup or manual credentials |
| WeChat Work | `wecom` | Manual credentials |
| Telegram | `telegram` | Manual credentials |
| Discord | `discord` | Manual credentials |
| Slack | `slack` | Manual credentials |
| DingTalk | `dingtalk` | Manual credentials |
| WeChat | `weixin` | QR code setup |
| QQ | `qq` | Manual credentials |

### Platform Setup Flow

```mermaid
graph TD
    A[Add Platform] --> B{Is QR Platform?}
    B -->|Yes| C[Show QR Code]
    B -->|No| D{Has Manual Form?}
    D -->|Yes| E[Platform Manual Form]
    D -->|No| F[Manual Config Hint]
    C --> G[Complete]
    E --> G
    G --> H[Restart Required Modal]
    H --> I[Restart Service]
```

Platform setup is handled dynamically in the UI:

```tsx
// ProjectDetail.tsx:85
(addPlatType) ? (
  <PlatformSetupQR
    platformType={addPlatType as 'feishu' | 'weixin'}
    projectName={name!}
    onComplete={() => {
      setShowAddPlatform(false);
      setShowRestartModal(true);
    }}
    onCancel={() => setAddPlatType('')}
  />
) : platformMeta[addPlatType] ? (
  <PlatformManualForm
    platformType={addPlatType}
    projectName={name!}
    onComplete={() => {
      setShowAddPlatform(false);
      setShowRestartModal(true);
    }}
    onCancel={() => setAddPlatType('')}
  />
) : (
  <div>
    <p>{t('setup.manualHint', 'For {{platform}}, please configure credentials in config.toml')}</p>
  </div>
)
```

### Adding New Platforms

New platforms follow the same plugin architecture:

1. Create `platform/newplatform/newplatform.go`
2. Implement `core.Platform` interface
3. Register in `init()`: `core.RegisterPlatform("newplatform", factory)`
4. Add `//go:build !no_newplatform` tag in plugin file
5. Add platform to `ALL_PLATFORMS` in Makefile

资料来源：[AGENTS.md](https://github.com/chenhg5/cc-connect/blob/main/AGENTS.md)

## Web API Client

The frontend communicates with the backend via a typed API client:

```typescript
// client.ts:25
export class ApiClient {
  async request<T>(method: string, path: string, body?: any, params?: Record<string, string>): Promise<T> {
    const h: HeadersInit = {};
    if (this.token) h['Authorization'] = `Bearer ${this.token}`;
    const res = await fetch(`${API_BASE}${path}`, { method, headers: h, body, params });
    // ...
  }

  get<T>(path: string, params?: Record<string, string>) { return this.request<T>('GET', path, undefined, params); }
  post<T>(path: string, body?: any) { return this.request<T>('POST', path, body); }
  put<T>(path: string, body?: any) { return this.request<T>('PUT', path, body); }
  delete<T>(path: string) { return this.request<T>('DELETE', path); }
}
```

资料来源：[web/src/api/client.ts](https://github.com/chenhg5/cc-connect/blob/main/web/src/api/client.ts)

## Provider System

Global providers allow centralized API key management for multiple projects:

```mermaid
graph TD
    subgraph "Global Providers"
        P1[Provider: anthropic]
        P2[Provider: openai]
        P3[Provider: google]
    end

    subgraph "Projects"
        PRJ1[my-project]
        PRJ2[work-project]
        PRJ3[test-project]
    end

    P1 --> PRJ1
    P1 --> PRJ2
    P2 --> PRJ2
    P2 --> PRJ3
    P3 --> PRJ3
```

Provider configurations include base URL, default model, model lists, and thinking settings:

```tsx
// ProviderList.tsx:150
{
  label: t('globalProviders.form.thinking'),
  type: 'select',
  value: form.thinking || '',
  options: [
    { value: '', label: t('globalProviders.form.thinkingDefault') },
    { value: 'enabled', label: 'enabled' },
    { value: 'disabled', label: 'disabled' },
  ]
}
```

## Cron Scheduling

The system supports scheduled tasks for automated workflows:

```bash
cc-connect cron add --cron "0 6 * * *" --prompt "Collect GitHub trending data" --desc "Daily Trending"
cc-connect cron add --cron "*/30 * * * *" --exec "df -h" --desc "Disk usage check"
```

Available cron options:

| Option | Description |
|--------|-------------|
| `-p, --project` | Target project name |
| `-s, --session-key` | Target session key |
| `-c, --cron` | Cron expression |
| `--prompt` | Task prompt (runs through agent) |
| `--exec` | Shell command (runs directly) |
| `--desc` | Short description |
| `--session-mode` | `reuse` (default) or `new-per-run` |
| `--timeout-mins` | Max minutes per run (default: 30) |

资料来源：[cmd/cc-connect/cron.go](https://github.com/chenhg5/cc-connect/blob/main/cmd/cc-connect/cron.go)

## Configuration Structure

The system uses TOML configuration with the following precedence:

1. `-config <path>` flag (explicit)
2. `./config.toml` (current directory)
3. `~/.cc-connect/config.toml` (global, recommended)

```toml
# Optional global settings
# language = "en"  # "en", "zh", or "" (auto-detect)

[log]
level = "info"  # debug, info, warn, error

[[projects]]
name = "my-project"

[projects.agent]
type = "claudecode"

[projects.agent.options]
work_dir = "/absolute/path/to/your/project"
mode = "default"
```

资料来源：[INSTALL.md](https://github.com/chenhg5/cc-connect/blob/main/INSTALL.md)

## Data Flow

```mermaid
sequenceDiagram
    participant User
    participant Platform as Messaging Platform
    participant Bridge as Bridge Manager
    participant Engine as Engine
    participant Relay as Relay Handler
    participant Agent as AI Agent

    User->>Platform: Send message
    Platform->>Bridge: WebSocket event
    Bridge->>Engine: Process message
    Engine->>Relay: Route to agent
    Relay->>Agent: Format & forward
    Agent->>Relay: Generate response
    Relay->>Engine: Process response
    Engine->>Bridge: Route response
    Bridge->>Platform: Send reply
    Platform->>User: Display message
```

## Extension Points

### Disabling Features

Build tags allow excluding specific platforms or agents:

```
no_gemini, no_iflow, no_opencode, no_qoder, no_feishu, no_telegram,
no_discord, no_slack, no_dingtalk, no_wecom, no_weixin, no_qq, no_line, no_weibo
```

资料来源：[AGENTS.md](https://github.com/chenhg5/cc-connect/blob/main/AGENTS.md)

### Build Requirements

The pre-commit checklist ensures code quality:

1. **Build passes**: `go build ./...`
2. **Tests pass**: `go test ./...`
3. **No new hardcoded platform/agent names in core**
4. **i18n complete**: all new user-facing strings have translations
5. **No secrets in code**: no API keys in source files

---

<a id='page-core-components'></a>

## Core Components

### 相关页面

相关主题：[System Architecture](#page-architecture), [Configuration Guide](#page-configuration)

<details>
<summary>相关源码文件</summary>

以下源码文件用于生成本页说明：

- [core/i18n.go](https://github.com/chenhg5/cc-connect/blob/main/core/i18n.go)
- [cmd/cc-connect/cron.go](https://github.com/chenhg5/cc-connect/blob/main/cmd/cc-connect/cron.go)
- [web/src/api/client.ts](https://github.com/chenhg5/cc-connect/blob/main/web/src/api/client.ts)
- [AGENTS.md](https://github.com/chenhg5/cc-connect/blob/main/AGENTS.md)
- [web/src/pages/Providers/ProviderList.tsx](https://github.com/chenhg5/cc-connect/blob/main/web/src/pages/Providers/ProviderList.tsx)
</details>

# Core Components

The cc-connect project is structured around a layered architecture consisting of a Go-based core backend and a React-based web interface. The core components provide the essential infrastructure for agent management, message handling, internationalization, and scheduled task execution.

## Architecture Overview

The system follows a modular plugin-based architecture where core interfaces define contracts for platforms and agents.

```mermaid
graph TD
    A[User/CLI] --> B[Web UI or CLI]
    B --> C[Core Backend API]
    C --> D[Agent Plugins]
    C --> E[Platform Plugins]
    F[Config File] --> C
    G[i18n] --> B
```

## Internationalization System

The internationalization (i18n) subsystem in `core/i18n.go` provides multi-language support for all user-facing messages.

### Supported Languages

| Language Code | Description |
|---------------|-------------|
| `LangEnglish` | English (default) |
| `LangChinese` | Simplified Chinese |
| `LangTraditionalChinese` | Traditional Chinese |
| `LangJapanese` | Japanese |
| `LangSpanish` | Spanish |

资料来源：[core/i18n.go](https://github.com/chenhg5/cc-connect/blob/main/core/i18n.go)

### Message Structure

Messages are defined using a `MessageMap` type that maps language codes to translated strings:

```go
MsgProviderSwitchHint: {
    LangEnglish:            "`/provider switch <name>` to switch | `/provider clear` to reset",
    LangChinese:            "`/provider switch <名称>` 切换 | `/provider clear` 清除",
    LangTraditionalChinese: "`/provider switch <名稱>` 切換 | `/provider clear` 清除",
    LangJapanese:           "`/provider switch <名前>` で切り替え | `/provider clear` でリセット",
    LangSpanish:            "`/provider switch <nombre>` para cambiar | `/provider clear` para restablecer",
},
```

The system includes messages for:
- Provider management (switching, listing, errors)
- Session management
- Command execution feedback
- Error handling

资料来源：[core/i18n.go](https://github.com/chenhg5/cc-connect/blob/main/core/i18n.go)

## API Client

The web interface communicates with the backend through `web/src/api/client.ts`, which provides a typed REST client.

### ApiClient Methods

| Method | Description |
|--------|-------------|
| `get<T>(path, params?)` | GET request with optional query parameters |
| `post<T>(path, body?)` | POST request with JSON body |
| `put<T>(path, body?)` | PUT request |
| `patch<T>(path, body?)` | PATCH request |
| `delete<T>(path)` | DELETE request |
| `raw(path)` | Fetch raw text (non-JSON) response |

资料来源：[web/src/api/client.ts](https://github.com/chenhg5/cc-connect/blob/main/web/src/api/client.ts)

### Error Handling

```typescript
export class ApiError extends Error {
  constructor(message: string, public status: number) {
    super(message);
    this.name = 'ApiError';
  }
}
```

The client handles:
- JSON response parsing
- 401 Unauthorized with callback notification
- Generic HTTP error propagation

## Agent Architecture

Agents are implemented as plugins following a defined interface. The `AGENTS.md` documentation outlines the agent system design.

### Adding a New Agent

1. Create `agent/newagent/newagent.go`
2. Implement `core.Agent` and `core.AgentSession` interfaces
3. Register in `init()`: `core.RegisterAgent("newagent", factory)`
4. Create plugin file with `//go:build !no_newagent` tag
5. Add to `ALL_AGATFORMS` in `Makefile`
6. Add unit tests

资料来源：[AGENTS.md](https://github.com/chenhg5/cc-connect/blob/main/AGENTS.md)

### Supported Agent Types

Based on the configuration structure, the following agent types are supported:

| Agent Type | Description |
|------------|-------------|
| `claudecode` | Claude Code agent |
| `codex` | OpenAI Codex |
| `cursor` | Cursor AI |
| `gemini` | Google Gemini |
| `qoder` | Qoder agent |
| `opencode` | OpenCode |
| `iflow` | IFlow agent |

### Agent Modes

| Mode | Purpose |
|------|---------|
| `default` | Standard operation with user prompts |
| `acceptEdits` | Accept edits automatically |
| `plan` | Plan-only mode |
| `bypassPermissions` | Bypass permission checks (yolo mode) |
| `dontAsk` | No confirmation prompts |

资料来源：[web/src/pages/Projects/ProjectDetail.tsx](https://github.com/chenhg5/cc-connect/blob/main/web/src/pages/Projects/ProjectDetail.tsx)

## Provider System

Providers manage API credentials and configuration for LLM services. The provider system is managed through the web interface in `web/src/pages/Providers/ProviderList.tsx`.

### Provider Configuration

Providers include:
- **Name**: Unique identifier
- **Base URL**: API endpoint
- **Model**: Default model
- **Models**: Available models array
- **Thinking**: Thinking mode (`enabled`, `disabled`, or default)
- **Agent Types**: Supported agent types

```typescript
interface GlobalProvider {
  name: string;
  base_url?: string;
  model?: string;
  models?: string[];
  thinking?: string;
  agent_types?: string[];
}
```

### Thinking Configuration

The thinking setting can be configured per-provider:

| Value | Behavior |
|-------|----------|
| `""` (empty) | Use default thinking behavior |
| `enabled` | Force thinking enabled |
| `disabled` | Force thinking disabled |

资料来源：[web/src/pages/Providers/ProviderList.tsx](https://github.com/chenhg5/cc-connect/blob/main/web/src/pages/Providers/ProviderList.tsx)

## Scheduled Tasks (Cron)

The cron subsystem in `cmd/cc-connect/cron.go` enables scheduled task execution.

### Cron Command Options

| Option | Description |
|--------|-------------|
| `-p, --project` | Target project name |
| `-s, --session-key` | Target session key |
| `-c, --cron` | Cron expression (e.g., "0 6 * * *") |
| `--prompt` | Task prompt (runs through agent) |
| `--exec` | Shell command (runs directly) |
| `--desc` | Short description |
| `--session-mode` | `reuse` (default) or `new-per-run` |
| `--timeout-mins` | Max minutes per run (0 = no limit, default 30) |
| `--data-dir` | Data directory (default: ~/.cc-connect) |

### Cron Expression Format

Standard 5-field cron format:
```
<min> <hour> <day> <month> <weekday>
```

### Session Modes

| Mode | Behavior |
|------|----------|
| `reuse` | Reuse the same agent session across runs (default) |
| `new-per-run` | Create fresh agent session for each run |

### Examples

```bash
# Daily task at 6 AM
cc-connect cron add --cron "0 6 * * *" --prompt "Collect GitHub trending data" --desc "Daily Trending"

# Every 30 minutes
cc-connect cron add --cron "*/30 * * * *" --exec "df -h" --desc "Disk usage check"
```

资料来源：[cmd/cc-connect/cron.go](https://github.com/chenhg5/cc-connect/blob/main/cmd/cc-connect/cron.go)

## Project Management

Projects connect code folders to messaging platforms. Each project configuration includes:

```toml
[[projects]]
name = "my-project"

[projects.agent]
type = "claudecode"  # or "codex", "cursor", "gemini", etc.

[projects.agent.options]
work_dir = "/absolute/path/to/your/project"
mode = "default"
```

### Project Features

| Feature | Description |
|---------|-------------|
| Sessions | Multiple concurrent conversation sessions |
| Heartbeat | Periodic health checks |
| Platform Bridge | Connection to messaging platforms |
| Skills | Attached skill configurations |

资料来源：[web/src/pages/Projects/ProjectList.tsx](https://github.com/chenhg5/cc-connect/blob/main/web/src/pages/Projects/ProjectList.tsx)

## Skill System

Skills extend agent capabilities through a plugin-like configuration system.

### Skill Types

- **Local Skills**: Project-specific skills defined in local directories
- **Recommended Skills**: Preset skill configurations

### Skill Configuration

Each skill includes:
- `name`: Skill identifier
- `display_name`: Human-readable name
- `description`: Skill purpose
- `source`: Skill origin/path

### Scan Directories

Projects can define scan directories for discovering skills:

```typescript
interface ProjectSkills {
  project: string;
  agent_type: string;
  skills?: Skill[];
  dirs?: string[];  // Scan directories
}
```

资料来源：[web/src/pages/Skills/SkillList.tsx](https://github.com/chenhg5/cc-connect/blob/main/web/src/pages/Skills/SkillList.tsx)

## Configuration

The system uses TOML configuration files, searching in this order:

1. `-config <path>` flag (explicit path)
2. `./config.toml` (current directory)
3. `~/.cc-connect/config.toml` (global, recommended)

If no config exists, `cc-connect` auto-creates a starter template at `~/.cc-connect/config.toml`.

资料来源：[INSTALL.md](https://github.com/chenhg5/cc-connect/blob/main/INSTALL.md)

## Web Interface Structure

The React web interface is organized by functional areas:

| Path | Component | Purpose |
|------|-----------|---------|
| `/pages/Chat/ChatView.tsx` | ChatView | Main chat interface |
| `/pages/Sessions/SessionList.tsx` | SessionList | Session management |
| `/pages/Sessions/SessionChat.tsx` | SessionChat | Individual session view |
| `/pages/Projects/ProjectList.tsx` | ProjectList | Project management |
| `/pages/Projects/ProjectDetail.tsx` | ProjectDetail | Project configuration |
| `/pages/Providers/ProviderList.tsx` | ProviderList | Provider management |
| `/pages/Skills/SkillList.tsx` | SkillList | Skill management |

### Bridge Connection Status

The UI displays connection status indicators:

| Status | UI Treatment |
|--------|--------------|
| `error` | Amber warning with WifiOff icon |
| `connecting` | Gray loading spinner with "Connecting..." |
| `connected` | Hidden (normal operation) |

资料来源：[web/src/pages/Chat/ChatView.tsx](https://github.com/chenhg5/cc-connect/blob/main/web/src/pages/Chat/ChatView.tsx)

---

<a id='page-agent-integrations'></a>

## Agent Integrations

### 相关页面

相关主题：[System Architecture](#page-architecture), [Platform Integrations](#page-platform-integrations)

<details>
<summary>相关源码文件</summary>

以下源码文件用于生成本页说明：

- [agent/claudecode/claudecode.go](https://github.com/chenhg5/cc-connect/blob/main/agent/claudecode/claudecode.go)
- [agent/codex/codex.go](https://github.com/chenhg5/cc-connect/blob/main/agent/codex/codex.go)
- [agent/cursor/cursor.go](https://github.com/chenhg5/cc-connect/blob/main/agent/cursor/cursor.go)
- [agent/gemini/gemini.go](https://github.com/chenhg5/cc-connect/blob/main/agent/gemini/gemini.go)
- [agent/kimi/kimi.go](https://github.com/chenhg5/cc-connect/blob/main/agent/kimi/kimi.go)
- [agent/acp/agent.go](https://github.com/chenhg5/cc-connect/blob/main/agent/acp/agent.go)
- [core/interfaces.go](https://github.com/chenhg5/cc-connect/blob/main/core/interfaces.go)
- [web/src/pages/Providers/ProviderList.tsx](https://github.com/chenhg5/cc-connect/blob/main/web/src/pages/Providers/ProviderList.tsx)
- [web/src/pages/Projects/ProjectDetail.tsx](https://github.com/chenhg5/cc-connect/blob/main/web/src/pages/Projects/ProjectDetail.tsx)
</details>

# Agent Integrations

## Overview

Agent Integrations in CC-Connect provide a unified abstraction layer for connecting to various AI agent backends. The system supports multiple agent providers including Claude Code, OpenAI Codex, Cursor, Gemini, and Kimi, allowing projects to utilize different AI capabilities through a consistent interface.

## Architecture

The agent integration system follows a plugin-style architecture where each agent implementation conforms to a common interface defined in `core/interfaces.go`. This design enables runtime provider switching and consistent interaction patterns across all supported agents.

```mermaid
graph TD
    A[User/Project] --> B[CC-Connect Core]
    B --> C[Agent Interface]
    C --> D[Claude Code Agent]
    C --> E[Codex Agent]
    C --> F[Cursor Agent]
    C --> G[Gemini Agent]
    C --> H[Kimi Agent]
    C --> I[ACP Agent]
    
    J[Provider Config] --> B
    K[Platform Integration] --> B
```

## Supported Agent Types

The system currently supports the following agent backends:

| Agent Type | Source File | Description |
|------------|-------------|-------------|
| claude | `agent/claudecode/claudecode.go` | Anthropic Claude Code integration |
| codex | `agent/codex/codex.go` | OpenAI Codex integration |
| cursor | `agent/cursor/cursor.go` | Cursor AI agent |
| gemini | `agent/gemini/gemini.go` | Google Gemini agent |
| kimi | `agent/kimi/kimi.go` | Kimi AI agent |
| acp | `agent/acp/agent.go` | Custom ACP agent protocol |

## Core Interface Definition

Each agent must implement the `Agent` interface defined in `core/interfaces.go`. The interface specifies the contract for agent lifecycle management, message handling, and capability reporting.

资料来源：[core/interfaces.go](https://github.com/chenhg5/cc-connect/blob/main/core/interfaces.go)

## Agent Configuration

### Agent Type Selection

Projects specify their agent type through the `agent_type` field. This selection determines which agent backend will be used for processing requests.

```tsx
<select
  value={selectedAgentType}
  onChange={(e) => setSelectedAgentType(e.target.value)}
>
  {agentTypes.map(a => <option key={a} value={a}>{a}</option>)}
</select>
```

资料来源：[web/src/pages/Projects/ProjectDetail.tsx](https://github.com/chenhg5/cc-connect/blob/main/web/src/pages/Projects/ProjectDetail.tsx)

### Thinking Mode

Agents support a configurable thinking mode that controls how the AI processes requests:

| Mode | Description |
|------|-------------|
| `enabled` | Full thinking/reasoning enabled |
| `disabled` | Thinking disabled |
| Default (empty) | Uses provider-level or system default |

```tsx
<select value={form.thinking || ''} onChange={e => set('thinking', e.target.value)}>
  <option value="">{t('globalProviders.form.thinkingDefault')}</option>
  <option value="enabled">enabled</option>
  <option value="disabled">disabled</option>
</select>
```

资料来源：[web/src/pages/Providers/ProviderList.tsx](https://github.com/chenhg5/cc-connect/blob/main/web/src/pages/Providers/ProviderList.tsx)

### Permission Modes

The system supports granular permission control for agent operations:

| Mode | Behavior |
|------|----------|
| `default` | Standard permission checks |
| `acceptEdits` | Automatically accept code edits |
| `plan` | Only generate execution plans |
| `bypassPermissions` | Skip all permission checks |
| `dontAsk` | Never prompt for confirmation |

```tsx
<select value={agentMode}>
  <option value="default">default</option>
  <option value="acceptEdits">acceptEdits (edit)</option>
  <option value="plan">plan</option>
  <option value="bypassPermissions">bypassPermissions (yolo)</option>
  <option value="dontAsk">dontAsk</option>
</select>
```

资料来源：[web/src/pages/Projects/ProjectDetail.tsx](https://github.com/chenhg5/cc-connect/blob/main/web/src/pages/Projects/ProjectDetail.tsx)

## Provider-Agent Relationship

Providers define which agent types they support through the `agent_types` configuration array:

```tsx
{p.agent_types && p.agent_types.length > 0 && (
  <div className="mt-2 flex flex-wrap gap-1">
    {p.agent_types.map(a => (
      <Badge key={a} variant="info" className="text-xs">{a}</Badge>
    ))}
  </div>
)}
```

资料来源：[web/src/pages/Providers/ProviderList.tsx](https://github.com/chenhg5/cc-connect/blob/main/web/src/pages/Providers/ProviderList.tsx)

## Project Agent Assignment

Each project is associated with a specific agent type and can be configured with custom agent settings:

```tsx
<div>
  <label>{t('projects.agentType', 'Agent type')}</label>
  <select value={selectedAgentType} onChange={(e) => setSelectedAgentType(e.target.value)}>
    {agentTypes.map(a => <option key={a} value={a}>{a}</option>)}
    {selectedAgentType && !agentTypes.includes(selectedAgentType) && (
      <option value={selectedAgentType}>{selectedAgentType}</option>
    )}
  </select>
  {selectedAgentType !== project.agent_type && (
    <p className="text-[11px] text-amber-500">
      {t('projects.agentTypeChangeHint', 'Changing agent type requires restart. Incompatible providers will be removed.')}
    </p>
  )}
</div>
```

资料来源：[web/src/pages/Projects/ProjectDetail.tsx](https://github.com/chenhg5/cc-connect/blob/main/web/src/pages/Projects/ProjectDetail.tsx)

## Workflow: Agent Selection and Switching

```mermaid
sequenceDiagram
    participant User
    participant UI as Web Interface
    participant Core as CC-Connect Core
    participant Provider as Provider Manager
    participant Agent as Agent Backend
    
    User->>UI: Select Project
    UI->>Core: Fetch Project Config
    Core->>UI: Return Project with agent_type
    User->>UI: Change Agent Type
    UI->>Core: Update Project agent_type
    Core->>Provider: Validate Provider Compatibility
    Provider-->>Core: Return Compatible Providers
    Core-->>UI: Confirm Configuration
```

## Data Flow

When a message is processed through an agent integration:

1. **Input**: User message received via platform (WeChat, Slack, etc.)
2. **Routing**: Message routed to appropriate project based on session
3. **Agent Selection**: Project's `agent_type` determines agent backend
4. **Provider Selection**: Associated provider configuration loaded
5. **Processing**: Agent backend processes request with provider credentials
6. **Response**: Agent response returned through platform integration

## Session Management

Sessions track the active agent context:

```tsx
<div className="flex items-center gap-1.5 min-w-0">
  <MessageSquare size={14} className={s.live ? 'text-accent shrink-0' : 'text-gray-400 shrink-0'} />
  <span className="text-sm font-medium truncate">
    {s.name || s.user_name || s.id.slice(0, 8)}
  </span>
  {s.live && <Circle size={5} className="fill-emerald-500 text-emerald-500 shrink-0" />}
</div>
```

资料来源：[web/src/pages/Sessions/SessionList.tsx](https://github.com/chenhg5/cc-connect/blob/main/web/src/pages/Sessions/SessionList.tsx)

## Configuration File Structure

Agent integrations are configured through `config.toml` or via the admin interface:

```toml
[[agents]]
name = "my-project"
agent_type = "claude"
thinking = "enabled"

[[providers]]
name = "anthropic"
base_url = "https://api.anthropic.com"
models = ["claude-sonnet-4-20250514"]
```

## Best Practices

1. **Provider Compatibility**: When changing agent types, verify the new type is supported by your configured provider
2. **Permission Mode**: Use `bypassPermissions` only in controlled environments
3. **Thinking Mode**: Enable thinking for complex reasoning tasks; disable for simple operations to reduce latency
4. **Session Persistence**: Active sessions maintain agent context across multiple interactions

---

<a id='page-platform-integrations'></a>

## Platform Integrations

### 相关页面

相关主题：[System Architecture](#page-architecture), [Agent Integrations](#page-agent-integrations)

<details>
<summary>Relevant Source Files</summary>

以下源码文件用于生成本页说明：

- [AGENTS.md](https://github.com/chenhg5/cc-connect/blob/main/AGENTS.md)
- [INSTALL.md](https://github.com/chenhg5/cc-connect/blob/main/INSTALL.md)
- [core/i18n.go](https://github.com/chenhg5/cc-connect/blob/main/core/i18n.go)
- [core/markdown_html_test.go](https://github.com/chenhg5/cc-connect/blob/main/core/markdown_html_test.go)
- [web/src/pages/Projects/ProjectDetail.tsx](https://github.com/chenhg5/cc-connect/blob/main/web/src/pages/Projects/ProjectDetail.tsx)
- [web/src/pages/Providers/ProviderList.tsx](https://github.com/chenhg5/cc-connect/blob/main/web/src/pages/Providers/ProviderList.tsx)
- [web/src/pages/Skills/SkillList.tsx](https://github.com/chenhg5/cc-connect/blob/main/web/src/pages/Skills/SkillList.tsx)
- [web/src/pages/Sessions/SessionList.tsx](https://github.com/chenhg5/cc-connect/blob/main/web/src/pages/Sessions/SessionList.tsx)
- [web/src/pages/Projects/ProjectList.tsx](https://github.com/chenhg5/cc-connect/blob/main/web/src/pages/Projects/ProjectList.tsx)
</details>

# Platform Integrations

## Overview

Platform Integrations in cc-connect enable AI agents to connect and communicate across multiple messaging and collaboration platforms. The system acts as a unified bridge, allowing a single AI agent to serve users on different platforms simultaneously without requiring separate deployments.

## Architecture Overview

The platform integration system follows a plugin-based architecture where each messaging platform is implemented as a separate module conforming to a common `Platform` interface.

```mermaid
graph TD
    A[User] -->|Message| B[Platform Adapter]
    B --> C[Core Agent]
    C -->|Response| B
    B -->|Deliver| A
    
    D[Telegram] --> B
    E[Slack] --> B
    F[Discord] --> B
    G[DingTalk] --> B
    H[WeChat] --> B
    I[Feishu] --> B
    J[WeCom] --> B
    K[QQ] --> B
    L[LINE] --> B
    M[Weibo] --> B
```

## Supported Platforms

cc-connect supports the following messaging platforms:

| Platform | Connection Type | Public IP Required | Build Tag |
|----------|----------------|-------------------|-----------|
| Telegram | Long Polling | No | `no_telegram` |
| Slack | Socket Mode (WebSocket) | No | `no_slack` |
| Discord | Webhook/Long Polling | No | `no_discord` |
| DingTalk | Webhook | Yes | `no_dingtalk` |
| WeChat (Weixin) | Various | Varies | `no_weixin` |
| Feishu (Lark) | Webhook | Yes | `no_feishu` |
| WeCom | Webhook | Yes | `no_wecom` |
| QQ | Bot Protocol | No | `no_qq` |
| LINE | Webhook | Yes | `no_line` |
| Weibo | Webhook | Yes | `no_weibo` |

资料来源：[AGENTS.md:1]()

## Platform Configuration

### Configuration Structure

Each platform is configured within the `[[projects.platforms]]` section of `config.toml`:

```toml
[[projects.platforms]]
type = "telegram"  # Platform type identifier

[projects.platforms.options]
token = "1234567890:ABCdefGHIjklMNOpqrsTUVwxyz"
```

### Project-Level Platform Assignment

Projects can specify which platforms they utilize through the `platforms` field:

```typescript
interface Project {
  name: string;
  agent_type: string;
  platforms?: string[];  // e.g., ["telegram", "slack"]
  heartbeat_enabled?: boolean;
  sessions_count?: number;
}
```

资料来源：[web/src/pages/Projects/ProjectList.tsx:1-15]()

## Adding a New Platform

The platform integration system is designed for extensibility. New platforms can be added by following this checklist:

1. **Create Platform Module**: Create `platform/newplatform/newplatform.go`
2. **Implement Interface**: Implement the `core.Platform` interface (and optional interfaces as needed)
3. **Register Platform**: Register in `init()`: `core.RegisterPlatform("newplatform", factory)`
4. **Create Build Plugin**: Create `cmd/cc-connect/plugin_platform_newplatform.go` with `//go:build !no_newplatform` tag
5. **Update Build System**: Add `newplatform` to `ALL_PLATFORMS` in `Makefile`
6. **Document Configuration**: Add config example in `config.example.toml`
7. **Add Tests**: Add unit tests for the platform module

资料来源：[AGENTS.md:15-23]()

## Connection Methods

### Long Polling

Some platforms (like Telegram) use long polling, where the client repeatedly requests new messages from the platform's API:

```mermaid
sequenceDiagram
    Client->>Platform API: GET /updates (long poll)
    Platform API-->>Client: Messages (or timeout)
    Client->>Platform API: GET /updates (long poll)
```

### Webhook

Other platforms require a publicly accessible webhook endpoint:

```mermaid
sequenceDiagram
    Platform->>CC-Connect: POST /webhook/{platform}
    CC-Connect->>Platform: 200 OK
    CC-Connect->>Core: Process Message
    Core-->>Platform: Response
```

## Platform-Specific Features

### Telegram

Telegram uses long polling, eliminating the need for a public IP address. Setup requires:

1. Create a bot via @BotFather
2. Obtain the bot token
3. Configure in `config.toml`

资料来源：[INSTALL.md:1-30]()

### Slack

Slack uses Socket Mode (WebSocket) for receiving events, which does not require a public IP:

1. Enable Socket Mode in app settings
2. Generate App-Level Token (`xapp-...`)
3. Subscribe to bot events: `message.im`, `app_mention`
4. Configure required Bot Token Scopes

资料来源：[INSTALL.md:40-55]()

## Build Tags and Platform Exclusion

Platform integrations can be excluded at compile time using build tags:

| Tag | Platform Excluded |
|-----|------------------|
| `no_telegram` | Telegram |
| `no_slack` | Slack |
| `no_discord` | Discord |
| `no_dingtalk` | DingTalk |
| `no_weixin` | WeChat/Weixin |
| `no_feishu` | Feishu/Lark |
| `no_wecom` | WeCom |
| `no_qq` | QQ |
| `no_line` | LINE |
| `no_weibo` | Weibo |

Build tags are listed in `AGENTS.md`:

> `no_gemini`, `no_iflow`, `no_opencode`, `no_qoder`, `no_feishu`, `no_telegram`, `no_discord`, `no_slack`, `no_dingtalk`, `no_wecom`, `no_weixin`, `no_qq`, `no_qqbot`, `no_line`, `no_weibo`.

资料来源：[AGENTS.md:1-3]()

## Pre-Commit Checklist

When adding platform integrations, ensure compliance with:

1. **Build passes**: `go build ./...`
2. **Tests pass**: `go test ./...`
3. **No new hardcoded platform/agent names in core**: `grep` for platform names in `core/*.go`
4. **i18n complete**: All new user-facing strings have translations for all languages
5. **No secrets in code**: No API keys, tokens, or credentials in source files

资料来源：[AGENTS.md:5-11]()

## Web Interface Management

The cc-connect admin web interface (CC-Connect Admin) provides UI components for managing platform-related settings:

### Project Platform Assignment

Projects can be assigned multiple platforms through the web UI:

```tsx
<div className="flex flex-wrap gap-1.5 mb-3">
  <Badge variant="info">{p.agent_type}</Badge>
  {p.platforms?.slice(0, 3).map((pl) => <Badge key={pl}>{pl}</Badge>)}
  {(p.platforms?.length ?? 0) > 3 && (
    <Badge>+{p.platforms!.length - 3}</Badge>
  )}
</div>
```

资料来源：[web/src/pages/Projects/ProjectList.tsx:1-10]()

### Provider Thinking Configuration

Platform providers can have thinking modes configured per-agent:

```tsx
{p.thinking && (
  <p className="mt-1.5 text-xs text-amber-600 dark:text-amber-400">
    thinking: {p.thinking}
  </p>
)}
```

Supported thinking modes:
- `enabled` - Thinking explicitly enabled
- `disabled` - Thinking explicitly disabled
- `""` (empty) - Use default setting

资料来源：[web/src/pages/Providers/ProviderList.tsx:1-10]()

## Message Processing Flow

```mermaid
graph LR
    A[Incoming Message] --> B[Platform Adapter]
    B --> C{Message Type?}
    C -->|Text| D[Parse Intent]
    C -->|Command| E[Handle Command]
    C -->|Media| F[Process Attachment]
    D --> G[Agent Processing]
    E --> G
    F --> G
    G --> H[Response Generation]
    H --> I[Markdown Rendering]
    I --> J[HTML Sanitization]
    J --> K[Platform Delivery]
    K --> L[End User]
```

## Internationalization

All platform-related user-facing messages support multiple languages:

| Language | Code |
|----------|------|
| English | `en` |
| Chinese (Simplified) | `zh` |
| Chinese (Traditional) | `zh-TW` |
| Japanese | `ja` |
| Spanish | `es` |

Provider-related messages include:

- `MsgProviderSwitchHint`: Command hints for switching providers
- `MsgProviderNotFound`: Error when provider doesn't exist
- `MsgProviderSwitched`: Confirmation when provider changes

资料来源：[core/i18n.go:1-30]()

## Session Management

Sessions are tracked per-platform with metadata:

```typescript
interface Session {
  id: string;
  name?: string;
  user_name?: string;
  live?: boolean;
  updated_at?: string;
  created_at?: string;
  last_message?: {
    role: 'user' | 'bot';
    content: string;
  };
}
```

资料来源：[web/src/pages/Sessions/SessionList.tsx:1-20]()

## Markdown to HTML Rendering

Platform integrations utilize the `MarkdownToSimpleHTML` function for rendering agent responses:

```go
func MarkdownToSimpleHTML(md string) string
```

Features supported:
- Code blocks with language syntax (`<pre><code class="language-go">`)
- Links (`<a href="...">`)
- Headings converted to bold (`<b>`)
- Blockquotes (`<blockquote>`)
- HTML escaping for special characters (`&lt;`, `&gt;`, `&amp;`)

资料来源：[core/markdown_html_test.go:1-40]()

## Summary

Platform Integrations in cc-connect provide a unified, extensible system for connecting AI agents to multiple messaging platforms. The architecture emphasizes:

- **Modularity**: Each platform is a separate plugin
- **Flexibility**: Multiple connection methods (webhook, long polling, WebSocket)
- **Security**: Build tags allow excluding platforms
- **Internationalization**: Full multi-language support
- **Web Management**: Admin UI for platform configuration

---

<a id='page-configuration'></a>

## Configuration Guide

### 相关页面

相关主题：[Session Management](#page-session-management), [Web UI Administration](#page-web-ui)

<details>
<summary>相关源码文件</summary>

以下源码文件用于生成本页说明：

- [config/config.go](https://github.com/chenhg5/cc-connect/blob/main/config/config.go)
- [config.example.toml](https://github.com/chenhg5/cc-connect/blob/main/config.example.toml)
- [core/provider_presets.go](https://github.com/chenhg5/cc-connect/blob/main/core/provider_presets.go)
- [core/skill_presets.go](https://github.com/chenhg5/cc-connect/blob/main/core/skill_presets.go)
- [web/src/pages/Projects/ProjectDetail.tsx](https://github.com/chenhg5/cc-connect/blob/main/web/src/pages/Projects/ProjectDetail.tsx)
- [web/src/pages/Providers/ProviderList.tsx](https://github.com/chenhg5/cc-connect/blob/main/web/src/pages/Providers/ProviderList.tsx)
- [core/i18n.go](https://github.com/chenhg5/cc-connect/blob/main/core/i18n.go)
</details>

# Configuration Guide

## Overview

The cc-connect configuration system provides a flexible, multi-layered approach to managing AI provider settings, project configurations, and skill definitions. This guide covers all configuration aspects including global providers, project-specific settings, and skill presets.

## Configuration Architecture

The system uses a hierarchical configuration model with three primary layers:

```mermaid
graph TD
    A[config.toml - Global Config] --> B[Project-level Settings]
    B --> C[Provider Configuration]
    C --> D[Model & API Settings]
    
    E[Skill Presets] -.-> B
    F[Provider Presets] -.-> C
```

## Global Configuration

Global settings are managed through `config.toml` located in the application root directory. This file contains default providers and system-wide settings that apply across all projects.

### Provider Configuration

Providers define the API endpoints and models used by agents. Each provider can be configured with multiple models and supports various agent types.

| Parameter | Type | Description | Required |
|-----------|------|-------------|----------|
| `name` | string | Unique provider identifier | Yes |
| `base_url` | string | API endpoint URL | Yes |
| `model` | string | Default model name | Yes |
| `models` | array | List of available models | No |
| `thinking` | string | Thinking mode: `enabled`, `disabled`, or empty for default | No |
| `agent_type` | string | Associated agent type (e.g., `codex`, `claude`) | No |

资料来源：[web/src/pages/Providers/ProviderList.tsx:1-50]()

### Agent Types

The system supports multiple agent types with different capability profiles:

| Agent Type | Description |
|------------|-------------|
| `codex` | Code-focused agent with extended capabilities |
| `claude` | Anthropic Claude-based agent |
| `default` | Standard agent configuration |

资料来源：[web/src/pages/Projects/ProjectDetail.tsx:1-30]()

### Permission Modes

Agents can operate in different permission modes controlling their operational boundaries:

| Mode | Description |
|------|-------------|
| `default` | Standard permission level |
| `acceptEdits` | Agent can directly edit files |
| `plan` | Agent only plans, does not execute |
| `bypassPermissions` | YOLO mode - skips permission checks |
| `dontAsk` | No confirmation prompts |

资料来源：[web/src/pages/Projects/ProjectDetail.tsx:30-60]()

## Provider Presets

Provider presets provide pre-configured settings for common AI providers, sorted by pricing tier.

### Tier System

Presets are organized into tiers reflecting cost and capability levels:

```mermaid
graph LR
    A[Tier 1 - Premium] --> B[Tier 2 - Standard]
    B --> C[Tier 3 - Budget]
    C --> D[Tier 4 - Free/Local]
```

| Tier | Description | Example Providers |
|------|-------------|-------------------|
| 1 | Premium APIs | Claude, GPT-4 |
| 2 | Standard APIs | GPT-3.5, Gemini Pro |
| 3 | Budget APIs | Various open-source models |
| 4 | Free/Local | Local deployments, free tiers |

资料来源：[web/src/pages/Providers/ProviderList.tsx:80-120]()

### Adding Providers from Presets

```typescript
interface ProviderPreset {
  name: string;
  tier: number;
  agent_types: string[];
  models: string[];
  thinking?: string;
}
```

The preset grid displays available presets sorted by tier. Existing provider names are filtered out using `Set<string>` to prevent duplicates.

资料来源：[web/src/pages/Providers/ProviderList.tsx:100-150]()

## Project Configuration

Each project maintains its own configuration including agent type, working directory, and platform-specific settings.

### Project Settings Structure

| Setting | Type | Description |
|---------|------|-------------|
| `name` | string | Project identifier (alphanumeric, `-`, `_`) |
| `agent_type` | string | Agent type for this project |
| `work_dir` | string | Working directory path |
| `platforms` | array | Enabled platforms |
| `heartbeat_enabled` | boolean | Heartbeat monitoring status |
| `show_ctx_indicator` | boolean | Context usage indicator |

资料来源：[web/src/pages/Projects/ProjectList.tsx:1-50]()

### Heartbeat Configuration

Projects can enable heartbeat monitoring with the following settings:

| Parameter | Description |
|-----------|-------------|
| `interval_mins` | Monitoring interval in minutes |
| `paused` | Whether heartbeat is paused |
| `run_count` | Total heartbeat executions |
| `error_count` | Number of errors encountered |

资料来源：[web/src/pages/Projects/ProjectDetail.tsx:200-250]()

## Skill Presets

Skill presets define collections of skills organized by project type and agent capability.

### Skill Preset Structure

```typescript
interface SkillPreset {
  project: string;        // Project type identifier
  agent_type: string;      // Required agent type
  dirs?: string[];         // Scan directories for skills
  skills?: Skill[];       // Associated skills
}
```

| Field | Description |
|-------|-------------|
| `project` | Project category or type name |
| `agent_type` | Compatible agent type |
| `dirs` | Directories to scan for skill definitions |
| `skills` | Pre-configured skill list |

资料来源：[web/src/pages/Skills/SkillList.tsx:50-100]()

### Skill Structure

```typescript
interface Skill {
  name: string;           // Skill identifier
  display_name?: string;  // User-friendly name
  description?: string;  // Skill description
  source: {
    url?: string;         // Source URL
    name?: string;         // Provider name
    provider?: string;     // Provider identifier
  };
  author?: string;        // Skill author
  url?: string;           // Download URL
}
```

资料来源：[web/src/pages/Skills/SkillList.tsx:100-150]()

## CLI Configuration Commands

The command-line interface provides provider management commands:

| Command | Description |
|---------|-------------|
| `/provider list` | List all configured providers |
| `/provider switch <name>` | Switch active provider |
| `/provider clear` | Reset provider selection |
| `cc-connect provider add` | Add new provider via CLI |

资料来源：[core/i18n.go:1-100]()

### Provider Switching

When switching providers, the system validates provider existence and updates the active configuration:

```mermaid
sequenceDiagram
    User->>CLI: /provider switch <name>
    CLI->>Config: Validate provider exists
    Config-->>CLI: Provider found
    CLI->>Config: Update active provider
    Config-->>User: Provider switched to <name>
```

资料来源：[core/i18n.go:100-150]()

## Configuration File Example

```toml
# Global Providers Section
[providers.openai]
base_url = "https://api.openai.com/v1"
model = "gpt-4"
models = ["gpt-4", "gpt-3.5-turbo"]

[providers.claude]
base_url = "https://api.anthropic.com"
model = "claude-3-sonnet-20240229"
thinking = "enabled"

# Project-specific Configuration
[project.my-project]
agent_type = "claude"
work_dir = "/path/to/project"
platforms = ["github"]

# Heartbeat Configuration
[heartbeat.my-project]
interval_mins = 5
```

## Platform-Specific Settings

Different platforms may require specific configuration:

| Platform | Required Settings |
|----------|------------------|
| `github` | Repository access, authentication token |
| `feishu` | App ID, App Secret, verification token |
| `telegram` | Bot token, webhook URL |
| `discord` | Bot token, guild ID |
| `slack` | Bot token, signing secret |

资料来源：[AGENTS.md:1-50]()

## Build Tags for Platform Support

Platform support is controlled via Go build tags:

```makefile
ALL_PLATFORMS = gemini iflow opencode qoder feishu telegram discord slack dingtalk wecom weixin qq qqbot line weibo
```

To exclude specific platforms:

```bash
go build -tags "no_gemini,no_iflow"
```

资料来源：[AGENTS.md:50-100]()

## Best Practices

1. **Provider Organization**: Use provider presets as templates and customize as needed
2. **Project Isolation**: Each project should have its own working directory
3. **Permission Mode**: Use `plan` mode for testing, `bypassPermissions` only when necessary
4. **Heartbeat**: Enable for long-running projects to monitor agent health
5. **i18n**: All user-facing strings should have translations for all supported languages

## Summary

The cc-connect configuration system provides a comprehensive framework for managing AI providers, projects, and skills. By understanding the hierarchical relationship between global settings, project configurations, and skill presets, administrators can effectively customize the system for various use cases and platform requirements.

---

<a id='page-session-management'></a>

## Session Management

### 相关页面

相关主题：[Configuration Guide](#page-configuration), [Core Components](#page-core-components)

<details>
<summary>相关源码文件</summary>

以下源码文件用于生成本页说明：

- [core/session.go](https://github.com/chenhg5/cc-connect/blob/main/core/session.go)
- [core/projectstate.go](https://github.com/chenhg5/cc-connect/blob/main/core/projectstate.go)
- [core/dir_history.go](https://github.com/chenhg5/cc-connect/blob/main/core/dir_history.go)
- [core/cron.go](https://github.com/chenhg5/cc-connect/blob/main/core/cron.go)
- [core/command.go](https://github.com/chenhg5/cc-connect/blob/main/core/command.go)
- [cmd/cc-connect/sessions.go](https://github.com/chenhg5/cc-connect/blob/main/cmd/cc-connect/sessions.go)
</details>

# Session Management

## Overview

Session Management is the core system responsible for maintaining conversational state between users and AI agents in cc-connect. Each session represents a single conversation context, preserving message history, working directory state, and agent configuration across interactions. The system enables users to switch between multiple concurrent conversations while maintaining isolation of context and state per session.

Sessions serve as the fundamental unit of work in cc-connect, allowing agents to maintain context across multiple requests, store conversation history, and provide seamless user experience through features like session switching, history retrieval, and live session indicators.

## Architecture Overview

```mermaid
graph TD
    User[User] -->|Chat/CLI| WebUI[Web UI / CLI]
    WebUI -->|Bridge| Bridge[Session Bridge]
    Bridge -->|Manage| SessionMgr[Session Manager]
    SessionMgr -->|Persist| Store[Session Store]
    SessionMgr -->|Agent Comm| Agent[Agent Session]
    Agent -->|Execute| CodeAgent[Claude Code / Codex / etc]
    
    SessionMgr -->|State| ProjectState[Project State]
    SessionMgr -->|History| DirHistory[Directory History]
    SessionMgr -->|Schedule| Cron[Cron Jobs]
    
    subgraph Per-Session
        S1[Session 1]
        S2[Session 2]
        SN[Session N]
    end
    
    SessionMgr -.->|Created| S1
    SessionMgr -.->|Created| S2
    SessionMgr -.->|Created| SN
```

## Session Data Model

### Core Session Structure

```go
type Session struct {
    ID              string           // Unique session identifier
    ProjectName     string           // Associated project
    Name            string           // Display name
    UserName        string           // Creator identifier
    ActiveSessionKeys []string       // Active session references
    Live            bool             // Currently active/in-use
    CreatedAt       time.Time        // Creation timestamp
    UpdatedAt       time.Time        // Last modification
    LastMessage     *HistoryEntry    // Most recent message
    Messages        []HistoryEntry   // Full message history
}
```

| Field | Type | Description |
|-------|------|-------------|
| `id` | string | Unique session identifier (UUID) |
| `project_name` | string | Name of associated project |
| `name` | string | Human-readable session name |
| `user_name` | string | Creator's identifier |
| `live` | bool | Whether session is currently active |
| `created_at` | timestamp | Session creation time |
| `updated_at` | timestamp | Last activity time |
| `last_message` | HistoryEntry | Most recent message object |
| `messages_count` | int | Total message count |

### History Entry Structure

Each message in a session is stored as a `HistoryEntry`:

| Field | Type | Description |
|-------|------|-------------|
| `role` | string | "user" or "assistant" |
| `content` | string | Message content |
| `timestamp` | time.Time | Message timestamp |
| `thinking` | string | Optional reasoning content (Codex) |

## Session Lifecycle

### Lifecycle States

```mermaid
stateDiagram-v2
    [*] --> Created: /new-session
    Created --> Active: First Message
    Active --> Active: Send Message
    Active --> Paused: /history or Switch
    Paused --> Active: Resume Session
    Active --> Closed: /close or Timeout
    Closed --> [*]: Cleanup
    
    Created --> Deleted: /delete
    Active --> Deleted: /delete
    Paused --> Deleted: /delete
    Deleted --> [*]
```

### Session Creation

Sessions are created in multiple scenarios:

1. **Explicit Creation**: Via `/new-session` command or CLI `cc-connect sessions new`
2. **Automatic on First Project Use**: When a project has no existing sessions
3. **Cron Job Sessions**: Fresh sessions created per cron run (when `session-mode: new-per-run`)

### Session Persistence

Sessions are persisted to storage with the following behavior:

- **Active Session Tracking**: `ActiveSessionKeys` array tracks currently active sessions per project
- **Last Message Cache**: The `LastMessage` field is updated after each exchange for quick retrieval
- **History Truncation**: When `limit > 0`, only the most recent N entries are retained (configurable per request)

## Project State Management

Sessions are scoped to projects. The `ProjectState` interface manages this relationship:

```go
type ProjectState interface {
    GetActiveSessionKey(project string) string
    SetActiveSessionKey(project, sessionKey string)
    AddSession(project string, session Session) error
    ListSessions(project string) ([]Session, error)
    GetSession(project, sessionKey string) (*Session, error)
}
```

### Project-Session Relationship

| Project Setting | Session Behavior |
|----------------|------------------|
| `sessions_count` | Number of sessions for project |
| `active_session_keys` | Currently active session references |
| Per-project agent | Each session uses project's configured agent |

## Session History

### History Entry Format

Sessions store a chronological list of `HistoryEntry` objects:

```go
type HistoryEntry struct {
    Role      string    `json:"role"`
    Content   string    `json:"content"`
    Timestamp time.Time `json:"timestamp"`
    Thinking  string    `json:"thinking,omitempty"` // Codex reasoning
}
```

### History Retrieval Commands

| Command | Description | Source |
|---------|-------------|--------|
| `/history [n]` | Show last n messages (default 10) | `core/command.go` |
| `/reasoning [level]` | View/switch reasoning effort | `core/command.go` |
| SessionDrawer | UI component for browsing history | `SessionList.tsx` |

### History Display

In the web UI, session history is displayed with:

- **Role Indicators**: User messages show `User` icon, assistant messages show `Bot` icon
- **Timestamp**: Relative time display using `timeAgo()` function
- **Message Preview**: Last 100 characters of content, newlines replaced with spaces
- **Line Clamping**: Messages limited to 2 lines in list view

## Session Switching

### Switch Session Methods

```mermaid
graph LR
    A[User] -->|/session| B[Switch Command]
    A -->|UI Click| C[SessionDrawer]
    B -->|Validate| D{Valid Session?}
    D -->|Yes| E[Set Active Session]
    D -->|No| F[Error: Not Found]
    E --> G[Update ProjectState]
    G --> H[Load Session Context]
    
    C -->|Select| I[switchToSession]
    I --> G
```

### Active Session Management

The system maintains a single active session per project:

```go
// ProjectState maintains active session key
func (ps *projectState) GetActiveSessionKey(project string) string
func (ps *projectState) SetActiveSessionKey(project, sessionKey string)
```

### Session Drawer Component

The `SessionDrawer` component in `web/src/pages/Sessions/SessionList.tsx` provides:

| Feature | Description |
|---------|-------------|
| Session List | All sessions for current project |
| Live Indicator | Green dot for currently active session |
| Quick Switch | Click to switch active session |
| New Session | Button to create fresh session |
| Message Preview | Shows last message in each session |

## Directory History Integration

Sessions track working directory changes via `DirHistory`:

```go
type DirHistory struct {
    SessionID string   // Associated session
    Paths     []string // Ordered list of visited directories
    Index     int      // Current position in history
}
```

### Directory Commands

| Command | Description |
|---------|-------------|
| `/dir <path>` | Change to specified directory |
| `/dir reset` | Return to project's default directory |
| `/history` | Show directory visit history |

This allows agents to maintain working context across sessions when the same session is resumed.

## Scheduled Tasks (Cron) Integration

Sessions interact with the cron system through the `--session-mode` flag:

### Session Modes

| Mode | Behavior | Use Case |
|------|----------|----------|
| `reuse` (default) | Reuse same session across runs | Ongoing conversations |
| `new-per-run` | Fresh agent session each run | Isolated task execution |

```bash
# Example: Daily task with reused session
cc-connect cron add --cron "0 6 * * *" --prompt "Summarize emails" --desc "Morning Summary"

# Example: Task requiring fresh context each run
cc-connect cron add --cron "*/30 * * * *" --exec "df -h" --session-mode new-per-run
```

### Cron Session Configuration

| Parameter | Description |
|-----------|-------------|
| `--timeout-mins <n>` | Max minutes per run (0 = no limit, default 30) |
| `--session-mode` | `reuse` or `new-per-run` |

## CLI Session Commands

### Available Commands

```bash
# List sessions for current project
cc-connect sessions list

# Create new session
cc-connect sessions new

# Switch to session
cc-connect sessions switch <session-id>

# Show session history
cc-connect sessions history <session-id> [limit]

# Delete session
cc-connect sessions delete <session-id>
```

### Session Options (from `cmd/cc-connect/sessions.go`)

| Option | Description |
|--------|-------------|
| `-p, --project <name>` | Target project (auto-detected from CC_PROJECT) |
| `-s, --session-key <key>` | Target session (auto-detected from CC_SESSION_KEY) |

## Bridge Communication

The web UI communicates with sessions via a bridge protocol:

```mermaid
sequenceDiagram
    participant UI as ChatView
    participant Bridge as Session Bridge
    participant Session as Session Manager
    
    UI->>Bridge: connect(project, sessionId)
    Bridge->>Session: Register connection
    Session-->>Bridge: session state
    Bridge-->>UI: bridge status: connected
    
    UI->>Bridge: send(message)
    Bridge->>Session: Process message
    Session->>Session: Update history
    Session-->>Bridge: response
    Bridge-->>UI: stream events
    
    Note over Bridge: status: "connected" | "connecting" | "error" | "disconnected"
```

### Bridge Status States

| Status | Description | UI Display |
|--------|-------------|------------|
| `connected` | Active connection | Hidden |
| `connecting` | Establishing connection | Spinner + "Connecting..." |
| `error` | Connection failed | Warning icon + "Disconnected" |
| `disconnected` | No active bridge | Warning icon + "Disconnected" |

## Session Storage

### Storage Location

- **Default Directory**: `~/.cc-connect`
- **Session Data**: Stored in project-specific storage
- **Session Key Environment Variable**: `CC_SESSION_KEY`

### Storage Schema

```
~/.cc-connect/
├── projects/
│   └── <project-name>/
│       └── sessions/
│           └── <session-id>/
│               ├── meta.json       # Session metadata
│               ├── messages.jsonl  # Message history
│               └── context/        # Agent context files
```

## Agent-Specific Session Handling

### Codex Agent

The Codex agent includes special session handling (`agent/codex/session.go`):

```go
func patchSessionSource(sessionID, codexHome string) {
    // Rewrites session_meta line in Codex JSONL transcript
    // Sets source="cli" and originator="codex_cli_rs"
    // Makes session visible in interactive codex terminal
}
```

### Session Context Loading

Codex sessions retry context loading with:

| Parameter | Value | Purpose |
|-----------|-------|---------|
| `codexContextUsageRetryCount` | 5 | Maximum retry attempts |
| `codexContextUsageRetryDelay` | 1 second | Delay between retries |
| `codexSessionCloseTimeout` | 5 seconds | Grace period for cleanup |

## Best Practices

1. **Session Naming**: Use descriptive names for easy identification
2. **History Cleanup**: Periodically delete old sessions to maintain performance
3. **Project Isolation**: Keep sessions scoped to their project for proper context
4. **Timeout Configuration**: Set appropriate `--timeout-mins` for long-running tasks
5. **Session Mode Selection**: Use `new-per-run` for isolated tasks, `reuse` for conversational agents

## Related Commands Reference

| Slash Command | Description |
|---------------|-------------|
| `/new-session` | Create a new session |
| `/sessions` | List/manage sessions |
| `/history [n]` | View message history |
| `/session <id>` | Switch to specific session |
| `/dir <path>` | Change working directory (session-scoped) |

---

<a id='page-web-ui'></a>

## Web UI Administration

### 相关页面

相关主题：[Configuration Guide](#page-configuration), [Deployment and Operations](#page-deployment)

<details>
<summary>相关源码文件</summary>

以下源码文件用于生成本页说明：

- [web/src/App.tsx](https://github.com/chenhg5/cc-connect/blob/main/web/src/App.tsx)
- [web/src/pages/Dashboard.tsx](https://github.com/chenhg5/cc-connect/blob/main/web/src/pages/Dashboard.tsx)
- [web/src/api/index.ts](https://github.com/chenhg5/cc-connect/blob/main/web/src/api/index.ts)
- [cmd/cc-connect/web.go](https://github.com/chenhg5/cc-connect/blob/main/cmd/cc-connect/web.go)
- [core/web_manager.go](https://github.com/chenhg5/cc-connect/blob/main/core/web_manager.go)
</details>

# Web UI Administration

The Web UI Administration module in cc-connect provides a comprehensive, single-page administrative interface for managing the entire platform. Built with React and TypeScript, the web interface serves as the primary control center for administrators to configure projects, manage agent providers, monitor sessions, and administer scheduled cron jobs—all without requiring command-line interaction.

## Architecture Overview

The web administration system follows a client-server architecture where the React frontend communicates with the Go backend through a RESTful API. The backend serves both static assets and dynamic API endpoints, while the frontend manages routing, state, and user interactions.

```mermaid
graph TD
    A[Browser Client] --> B[React SPA Frontend]
    B --> C[API Client Layer]
    C --> D[Go Backend API]
    D --> E[(SQLite Database)]
    D --> F[Platform Connectors<br/>Feishu/WeChat]
    D --> G[Agent Providers<br/>Claude/Codex/Gemini]
    
    B --> H[Dashboard]
    B --> I[Projects]
    B --> J[Sessions]
    B --> K[Providers]
    B --> L[Skills]
    B --> M[Cron Jobs]
```

## Frontend Application Structure

### App Entry Point and Routing

The main application entry point (`web/src/App.tsx`) initializes the React application with routing capabilities. The application uses client-side routing to navigate between different administrative sections.

**资料来源：** [web/src/App.tsx:1-50]()

### Page Modules

The web interface is organized into several distinct page modules, each handling a specific domain of administrative functionality:

| Module | File Path | Purpose |
|--------|-----------|---------|
| Dashboard | `web/src/pages/Dashboard.tsx` | System overview, status metrics, quick links |
| Projects | `web/src/pages/Projects/ProjectList.tsx` | Project creation and management |
| Project Detail | `web/src/pages/Projects/ProjectDetail.tsx` | Per-project settings and configuration |
| Sessions | `web/src/pages/Sessions/SessionList.tsx` | Chat session history and management |
| Providers | `web/src/pages/Providers/ProviderList.tsx` | Agent provider configuration |
| Skills | `web/src/pages/Skills/SkillList.tsx` | Skill preset management |
| Cron Jobs | `web/src/pages/Cron/CronList.tsx` | Scheduled task administration |

**资料来源：** [web/src/pages/Dashboard.tsx:1-30]()

## Core Features

### Dashboard

The Dashboard provides an at-a-glance view of the system status. It displays key metrics including version information, uptime statistics, connected platform count, and total project count.

```typescript
// Key dashboard metrics displayed
<StatCard label={t('dashboard.version')} value={status?.version || '-'} accent />
<StatCard label={t('dashboard.uptime')} value={status ? formatUptime(status.uptime_seconds) : '-'} />
<StatCard label={t('dashboard.platforms')} value={status?.connected_platforms?.length ?? 0} />
<StatCard label={t('dashboard.projects')} value={status?.projects_count ?? 0} />
```

The dashboard also includes a projects section with quick navigation links to the full projects list.

**资料来源：** [web/src/pages/Dashboard.tsx:20-45]()

### Project Management

Projects are the central organizational unit in cc-connect. The project management interface allows administrators to:

- Create new projects with the Add Project Wizard
- Configure platform integrations (Feishu, WeChat)
- Set up agent types and working directories
- View session counts and heartbeat status

#### Project List View

The project list displays all configured projects with key metadata including agent type, supported platforms, session count, and heartbeat status indicators.

```typescript
// Project card displays key information
<Badge variant="info">{p.agent_type}</Badge>
{p.platforms?.slice(0, 3).map((pl) => <Badge key={pl}>{pl}</Badge>)}
<span>{p.sessions_count} {t('nav.sessions').toLowerCase()}</span>
{p.heartbeat_enabled && (
  <span className="flex items-center gap-1 text-emerald-500">
    <Heart size={12} /> {t('heartbeat.title')}
  </span>
)}
```

**资料来源：** [web/src/pages/Projects/ProjectList.tsx:1-80]()

#### Project Detail Settings

Individual project pages expose granular configuration options:

| Setting | Description | Type |
|---------|-------------|------|
| Context Indicator | Show `[ctx: ~N%]` suffix on replies | Toggle |
| Reply Footer | Append model/usage metadata to replies | Toggle |
| Scan Directories | Directories scanned for skills | List |
| Provider Links | Connected agent providers | Reference |

**资料来源：** [web/src/pages/Projects/ProjectDetail.tsx:1-50]()

#### Add Project Wizard

The wizard guides users through a multi-step setup process:

1. **Name Step** - Enter project name (alphanumeric, hyphen, underscore only)
2. **Platform Step** - Select integration platform (Feishu, WeChat, or manual setup)
3. **QR Step** - Generate QR code for mobile platform authentication
4. **Form Step** - Manual configuration form for advanced settings

```typescript
// Project name validation
value={newProjName}
onChange={(e) => setNewProjName(e.target.value.replace(/[^a-zA-Z0-9_-]/g, ''))}
```

**资料来源：** [web/src/pages/Projects/ProjectList.tsx:80-120]()

### Session Management

The Session List view provides a chronological view of all chat sessions across projects. Each session entry shows:

- Session name or ID
- Live status indicator
- Last activity timestamp
- Message preview (first 100 characters)
- Associated project and platform badges
- Message count

```typescript
// Session display with live indicator
<MessageSquare size={14} className={s.live ? 'text-accent shrink-0' : 'text-gray-400 shrink-0'} />
<span className="text-sm font-medium text-gray-900 dark:text-white truncate">
  {s.name || s.user_name || s.id.slice(0, 8)}
</span>
{s.live && <Circle size={5} className="fill-emerald-500 text-emerald-500 shrink-0" />}
```

**资料来源：** [web/src/pages/Sessions/SessionList.tsx:1-60]()

### Provider Administration

The Provider Management interface allows configuration of LLM agent providers with support for both global and per-project provider assignments.

#### Provider Features

- **Model Selection** - Configure base URL and model identifiers
- **Multi-Model Support** - Define model lists with default selection
- **Thinking Control** - Enable or disable extended thinking per provider
- **Agent Type Filtering** - Restrict providers to specific agent types

#### Provider Form Configuration

| Field | Description | Required |
|-------|-------------|----------|
| Name | Provider identifier | Yes |
| API Key | Authentication key | Yes |
| Base URL | Endpoint URL | No |
| Model | Default model name | No |
| Models | Additional model list | No |
| Thinking | Extended thinking mode | No |
| Agent Types | Applicable agent types | No |

**资料来源：** [web/src/pages/Providers/ProviderList.tsx:1-100]()

#### CC-Switch Import

The interface supports importing provider configurations from CC-Switch, enabling migration of existing setups.

### Skills Management

The Skills interface manages skill presets that can be assigned to projects. Skills define capabilities and behaviors for agents, with support for:

- Display name and description (with localization)
- Source tracking (URL, provider, author)
- Version information
- Pricing metadata
- Tag-based categorization

#### Recommended Skills

A preset grid displays available skill templates that administrators can add to their projects.

### Cron Job Scheduling

The Cron List view administers scheduled tasks that execute prompts on projects at configured intervals.

```typescript
// Cron job display includes mode, project, and timing
<Badge variant="outline" className="text-[10px] px-1.5 py-0">{job.mode || t('cron.modeDefault')}</Badge>
<span className="font-medium w-12 shrink-0 text-gray-400">{t('cron.project')}</span>
<span className="truncate">{job.project}</span>
<span className="font-medium w-12 shrink-0 text-gray-400">{t('cron.lastRun')}</span>
<span>{formatTime(job.last_run)}</span>
```

**资料来源：** [web/src/pages/Cron/CronList.tsx:1-50]()

## API Client Layer

The frontend communicates with the backend through an API client module (`web/src/api/index.ts`). This layer abstracts HTTP communication and provides typed interfaces for all administrative operations.

### Key API Operations

| Category | Operations |
|----------|------------|
| Projects | list, create, update, delete, get |
| Sessions | list, get, delete, clear history |
| Providers | list, create, update, delete |
| Skills | list presets, add to project |
| Cron | list, create, update, delete, trigger |
| System | status, restart, shutdown |

**资料来源：** [web/src/api/index.ts:1-100]()

## Backend Server

### Web Server Initialization

The Go backend initializes the web server with static file serving and API routing.

**资料来源：** [cmd/cc-connect/web.go:1-50]()

### Web Manager

The core web manager handles the lifecycle of the web interface, including configuration, middleware setup, and request routing.

```go
// Web server configuration structure
type WebConfig struct {
    Host     string
    Port     int
    TLS      bool
    CertFile string
    KeyFile  string
}
```

**资料来源：** [core/web_manager.go:1-80]()

## Internationalization

The web interface supports multiple languages through an internationalization system defined in `core/i18n.go`. Supported languages include:

- English
- Simplified Chinese (简体中文)
- Traditional Chinese (繁體中文)
- Japanese (日本語)
- Spanish (Español)

The UI automatically detects the browser language and falls back to English when translations are unavailable.

## User Interface Components

### Common UI Elements

The interface uses a consistent component library including:

- **Card** - Container for grouped content
- **Badge** - Status indicators and labels
- **Button** - Action triggers with variants (primary, secondary, ghost)
- **Modal** - Dialog overlays for forms and confirmations
- **Input** - Form field components with validation
- **Badge variants** - default, outline, info, success for semantic coloring

### Dark Mode Support

All components support dark mode theming through CSS custom properties and Tailwind dark variants:

```typescript
// Example dark mode styling pattern
className="text-gray-900 dark:text-white bg-white dark:bg-white/[0.02]"
className="border-gray-200 dark:border-white/[0.06]"
```

## Configuration and State Management

The frontend uses React hooks for state management with several key patterns:

1. **Server State** - Data fetched from the API (projects, sessions, providers)
2. **UI State** - Local component state (modals, forms, selections)
3. **Preferences** - User settings like language and theme

### Key State Hooks

| Hook | Purpose |
|------|---------|
| `useProjects` | Fetch and cache project list |
| `useProviders` | Manage provider configurations |
| `useSessions` | Session listing and filtering |
| `useStatus` | System status polling |

## Security Considerations

The web interface handles sensitive operations including:

- API key management for provider configurations
- Project authentication credentials
- Session data access

All sensitive fields use password input types with visibility toggles:

```typescript
<Input
  type={showKey ? 'text' : 'password'}
  value={form.api_key || ''}
  placeholder="sk-..."
/>
<button onClick={() => setShowKey(!showKey)}>
  {showKey ? <EyeOff size={16} /> : <Eye size={16} />}
</button>
```

**资料来源：** [web/src/pages/Providers/ProviderList.tsx:150-180]()

## Data Flow Diagram

```mermaid
sequenceDiagram
    participant User
    participant ReactApp
    participant API
    participant GoBackend
    participant Database

    User->>ReactApp: Navigate to Projects
    ReactApp->>API: GET /api/projects
    API->>GoBackend: HTTP Request
    GoBackend->>Database: Query projects
    Database->>GoBackend: Project records
    GoBackend->>API: JSON response
    API->>ReactApp: Project list data
    ReactApp->>User: Render ProjectList
```

## Conclusion

The Web UI Administration module provides a complete, production-ready administrative interface for cc-connect. Its modular design separates concerns across page components, while the typed API client ensures reliable communication with the backend. The support for dark mode, internationalization, and responsive design makes it suitable for deployment in varied operational environments.

---

<a id='page-deployment'></a>

## Deployment and Operations

### 相关页面

相关主题：[Quick Start Guide](#page-quickstart)

<details>
<summary>相关源码文件</summary>

以下源码文件用于生成本页说明：

- [cmd/cc-connect/update.go](https://github.com/chenhg5/cc-connect/blob/main/cmd/cc-connect/update.go)
- [cmd/cc-connect/daemon.go](https://github.com/chenhg5/cc-connect/blob/main/cmd/cc-connect/daemon.go)
- [daemon/manager.go](https://github.com/chenhg5/cc-connect/blob/main/daemon/manager.go)
- [daemon/systemd.go](https://github.com/chenhg5/cc-connect/blob/main/daemon/systemd.go)
- [core/runas.go](https://github.com/chenhg5/cc-connect/blob/main/core/runas.go)
- [core/updater.go](https://github.com/chenhg5/cc-connect/blob/main/core/updater.go)
</details>

# Deployment and Operations

This page covers the operational aspects of cc-connect, including installation, daemon management, service configuration, and system-level integration.

## Overview

cc-connect is a bridge application that connects local AI coding agents to messaging platforms. It supports multiple deployment scenarios ranging from manual binary execution to automated system service management across Linux (systemd), macOS (launchd), and Windows (Task Scheduler).

资料来源：[INSTALL.md](https://github.com/chenhg5/cc-connect/blob/main/INSTALL.md)

## Installation Methods

cc-connect offers four primary installation approaches depending on your environment and requirements.

### Package Manager Installation

**macOS (Homebrew):**
```bash
brew install cc-connect
```

**Linux (Homebrew):**
```bash
brew install cc-connect
```

资料来源：[INSTALL.md](https://github.com/chenhg5/cc-connect/blob/main/INSTALL.md)

### Pre-built Binary Download

Download platform-specific binaries from the [GitHub Releases](https://github.com/chenhg5/cc-connect/releases) page.

| Platform | Architecture | Artifact Pattern |
|----------|-------------|------------------|
| Linux | amd64 | `cc-connect-<version>-linux-amd64` |
| macOS | amd64 | `cc-connect-<version>-darwin-amd64` |
| macOS | ARM64 | `cc-connect-<version>-darwin-arm64` |
| Windows | amd64 | `cc-connect-<version>-windows-amd64.exe` |

**Installation Example (Linux):**
```bash
curl -L -o cc-connect https://github.com/chenhg5/cc-connect/releases/latest/download/cc-connect-linux-amd64
chmod +x cc-connect
sudo mv cc-connect /usr/local/bin/
```

**macOS Quarantine Removal:**
```bash
xattr -d com.apple.quarantine cc-connect
```

资料来源：[INSTALL.md](https://github.com/chenhg5/cc-connect/blob/main/INSTALL.md)

### Build from Source

Building from source requires Go 1.22 or later.

```bash
git clone https://github.com/chenhg5/cc-connect.git
cd cc-connect
make build
# Binary output: ./cc-connect
```

资料来源：[INSTALL.md](https://github.com/chenhg5/cc-connect/blob/main/INSTALL.md)

## Configuration File Management

cc-connect searches for configuration files in the following order:

1. `-config <path>` flag (explicit path)
2. `./config.toml` (current directory)
3. `~/.cc-connect/config.toml` (global, recommended)

If no configuration file exists, running `cc-connect` will automatically create a starter template at `~/.cc-connect/config.toml`.

### Manual Configuration Setup

```bash
mkdir -p ~/.cc-connect
# Option 1: Copy example from cloned repo
cp config.example.toml ~/.cc-connect/config.toml
# Option 2: Run cc-connect once to auto-generate
cc-connect
```

资料来源：[INSTALL.md](https://github.com/chenhg5/cc-connect/blob/main/INSTALL.md)

## Daemon Management

The daemon subsystem provides persistent background operation with automatic startup on system boot.

### Installing the Daemon

**Basic Installation:**
```bash
cc-connect daemon install --config ~/.cc-connect/config.toml
```

**Using Work Directory:**
```bash
cc-connect daemon install --work-dir ~/.cc-connect
```

**Installation Options:**

| Flag | Description | Default |
|------|-------------|---------|
| `--config PATH` | Path to config file | `~/.cc-connect/config.toml` |
| `--log-file PATH` | Custom log file location | Auto-generated |
| `--log-max-size N` | Max log size in MB | Configured value |
| `--work-dir DIR` | Directory containing config.toml | `~/.cc-connect` |
| `--force` | Overwrite existing unit | false |

资料来源：[cmd/cc-connect/daemon.go](https://github.com/chenhg5/cc-connect/blob/main/cmd/cc-connect/daemon.go)

### Daemon Lifecycle Commands

```bash
cc-connect daemon start      # Start the service
cc-connect daemon stop       # Stop the service
cc-connect daemon restart    # Restart the service
cc-connect daemon status      # Check current status
```

### Platform-Specific Implementation

The daemon manager delegates to platform-specific implementations:

- **Linux:** Creates a systemd user service 资料来源：[daemon/systemd.go](https://github.com/chenhg5/cc-connect/blob/main/daemon/systemd.go)
- **macOS:** Creates a LaunchAgent plist
- **Windows:** Creates a Task Scheduler task named `cc-connect`

```mermaid
graph TD
    A[cc-connect daemon install] --> B{Platform Detection}
    B -->|Linux| C[systemd User Service]
    B -->|macOS| D[LaunchAgent Plist]
    B -->|Windows| E[Task Scheduler Task]
    C --> F[Auto-start on login]
    D --> F
    E --> G[Run at user logon]
```

资料来源：[daemon/manager.go](https://github.com/chenhg5/cc-connect/blob/main/daemon/manager.go)

## Log Management

### Viewing Logs

```bash
cc-connect daemon logs              # Display current log
cc-connect daemon logs -f           # Follow mode (tail -f equivalent)
cc-connect daemon logs -n 100       # Show last 100 lines
cc-connect daemon logs --log-file /path/to/log  # Custom log file
```

### Log Rotation

Logs automatically rotate when they reach the configured maximum size. The system maintains one backup of the previous log file.

资料来源：[INSTALL.md](https://github.com/chenhg5/cc-connect/blob/main/INSTALL.md)

## Update Management

### Update Command

The update subsystem handles binary updates with signature verification.

```bash
cc-connect update [options]
```

**Update Options:**

| Flag | Description |
|------|-------------|
| `--channel <name>` | Update channel (stable/beta) |
| `--file <path>` | Install from local file |
| `--data-dir <path>` | Data directory for update metadata |

### Update Process Flow

```mermaid
graph TD
    A[cc-connect update] --> B[Check Update Channel]
    B --> C{Fetch Latest Version}
    C -->|Version Available| D[Download Binary]
    C -->|Up to Date| E[Exit: Already current]
    D --> F{Verify Signature}
    F -->|Valid| G[Replace Binary]
    F -->|Invalid| H[Abort Update]
    G --> I[Restart Service]
```

资料来源：[cmd/cc-connect/update.go](https://github.com/chenhg5/cc-connect/blob/main/cmd/cc-connect/update.go)

### Manual Update for Package Managers

**Homebrew:**
```bash
brew upgrade cc-connect
```

**Source Users:**
```bash
cd cc-connect
git pull
make build
```

After upgrading, restart the running cc-connect process to apply changes.

资料来源：[INSTALL.md](https://github.com/chenhg5/cc-connect/blob/main/INSTALL.md)

## Process Execution Model

### Privilege Escalation

The `runas` module handles process execution with appropriate privileges:

```mermaid
graph LR
    A[Main Process] -->|Non-elevated| B[User Context]
    A -->|Elevated tasks| C[runas Module]
    C -->|sudo/elevation| D[Privileged Execution]
```

The module supports:
- Running commands with elevated privileges when required
- Managing user context for different operation modes

资料来源：[core/runas.go](https://github.com/chenhg5/cc-connect/blob/main/core/runas.go)

## Operational Best Practices

### Recommended Setup

1. **Use Global Config Location:** Store configuration at `~/.cc-connect/config.toml` for consistent access across terminal sessions.

2. **Install as System Service:** Use `daemon install` for production deployments to ensure automatic restart on system reboot.

3. **Configure Log Rotation:** Set appropriate `--log-max-size` value based on expected message volume.

4. **Monitor Log Output:** Regularly check `cc-connect daemon logs` for operational insights and error tracking.

### Configuration Structure

A typical multi-project production configuration:

```toml
[log]
level = "info"

[[projects]]
name = "backend"
[projects.agent]
type = "claudecode"
[projects.agent.options]
work_dir = "/path/to/backend"
mode = "default"

[[projects.platforms]]
type = "feishu"
[projects.platforms.options]
app_id = "cli_xxx"
app_secret = "xxx"
```

### Health Monitoring

The daemon status command provides current service state:

```bash
cc-connect daemon status
```

This reports whether the service is running, and if applicable, the uptime and last activity timestamp.

## Windows-Specific Considerations

On Windows, `daemon install` creates a Task Scheduler task that:
- Runs at user logon
- Starts immediately after installation
- Is named `cc-connect` in the Task Scheduler

资料来源：[INSTALL.md](https://github.com/chenhg5/cc-connect/blob/main/INSTALL.md)

---

---

## Doramagic 踩坑日志

项目：chenhg5/cc-connect

摘要：发现 39 个潜在踩坑项，其中 12 个为 high/blocking；最高优先级：安装坑 - 来源证据：[Bug]。

## 1. 安装坑 · 来源证据：[Bug]

- 严重度：high
- 证据强度：source_linked
- 发现：GitHub 社区证据显示该项目存在一个安装相关的待验证问题：[Bug]
- 对用户的影响：可能增加新用户试用和生产接入成本。
- 建议检查：来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。
- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。
- 证据：community_evidence:github | cevd_c85c0f8f48ac44c7a855066b2bfc3939 | https://github.com/chenhg5/cc-connect/issues/933 | 来源讨论提到 npm 相关条件，需在安装/试用前复核。

## 2. 安装坑 · 来源证据：[Bug] cc-connect web服务商管理从 CC-Switch 导入服务商重名问题

- 严重度：high
- 证据强度：source_linked
- 发现：GitHub 社区证据显示该项目存在一个安装相关的待验证问题：[Bug] cc-connect web服务商管理从 CC-Switch 导入服务商重名问题
- 对用户的影响：可能增加新用户试用和生产接入成本。
- 建议检查：来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。
- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。
- 证据：community_evidence:github | cevd_bbbf45839e1043e2afdedf3f1d87b55b | https://github.com/chenhg5/cc-connect/issues/1058 | 来源讨论提到 npm 相关条件，需在安装/试用前复核。

## 3. 安装坑 · 来源证据：[Feature] Preserve full interactive card schema on inbound

- 严重度：high
- 证据强度：source_linked
- 发现：GitHub 社区证据显示该项目存在一个安装相关的待验证问题：[Feature] Preserve full interactive card schema on inbound
- 对用户的影响：可能影响升级、迁移或版本选择。
- 建议检查：来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。
- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。
- 证据：community_evidence:github | cevd_f50380a7aef54548ac053b1127a2916e | https://github.com/chenhg5/cc-connect/issues/936 | 来源类型 github_issue 暴露的待验证使用条件。

## 4. 安装坑 · 来源证据：cc-connect 因 SSH 断开被 systemd 停止：需要文档化 `loginctl enable-linger`

- 严重度：high
- 证据强度：source_linked
- 发现：GitHub 社区证据显示该项目存在一个安装相关的待验证问题：cc-connect 因 SSH 断开被 systemd 停止：需要文档化 `loginctl enable-linger`
- 对用户的影响：可能增加新用户试用和生产接入成本。
- 建议检查：来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。
- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。
- 证据：community_evidence:github | cevd_3a818efa6ddf479aae0f026d1f06d491 | https://github.com/chenhg5/cc-connect/issues/960 | 来源讨论提到 npm 相关条件，需在安装/试用前复核。

## 5. 配置坑 · 来源证据：Feishu: all messages permanently ignored as 'old message after restart' after every daemon restart (v1.3.3-beta.2)

- 严重度：high
- 证据强度：source_linked
- 发现：GitHub 社区证据显示该项目存在一个配置相关的待验证问题：Feishu: all messages permanently ignored as 'old message after restart' after every daemon restart (v1.3.3-beta.2)
- 对用户的影响：可能增加新用户试用和生产接入成本。
- 建议检查：来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。
- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。
- 证据：community_evidence:github | cevd_7b001c45ac3449abaee3dd365bc4cc74 | https://github.com/chenhg5/cc-connect/issues/972 | 来源讨论提到 linux 相关条件，需在安装/试用前复核。

## 6. 配置坑 · 来源证据：WeChat ilink (weixin): image content is empty, not passed to agent

- 严重度：high
- 证据强度：source_linked
- 发现：GitHub 社区证据显示该项目存在一个配置相关的待验证问题：WeChat ilink (weixin): image content is empty, not passed to agent
- 对用户的影响：可能增加新用户试用和生产接入成本。
- 建议检查：来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。
- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。
- 证据：community_evidence:github | cevd_17d4c5f39a5745c5bdfbc88cdac32056 | https://github.com/chenhg5/cc-connect/issues/1057 | 来源讨论提到 windows 相关条件，需在安装/试用前复核。

## 7. 配置坑 · 来源证据：[Bug] cc-connect send uses default socket path in custom data_dir agent sessions

- 严重度：high
- 证据强度：source_linked
- 发现：GitHub 社区证据显示该项目存在一个配置相关的待验证问题：[Bug] cc-connect send uses default socket path in custom data_dir agent sessions
- 对用户的影响：可能增加新用户试用和生产接入成本。
- 建议检查：来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。
- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。
- 证据：community_evidence:github | cevd_6136e384578b499ca63299322032211a | https://github.com/chenhg5/cc-connect/issues/966 | 来源类型 github_issue 暴露的待验证使用条件。

## 8. 安全/权限坑 · 失败模式：security_permissions: [Bug] cc-connect send uses default socket path in custom data_dir agent sessions

- 严重度：high
- 证据强度：source_linked
- 发现：Developers should check this security_permissions risk before relying on the project: [Bug] cc-connect send uses default socket path in custom data_dir agent sessions
- 对用户的影响：Developers may expose sensitive permissions or credentials: [Bug] cc-connect send uses default socket path in custom data_dir agent sessions
- 建议检查：Before packaging this project, run the relevant install/config/quickstart check for: [Bug] cc-connect send uses default socket path in custom data_dir agent sessions. Context: Observed during installation or first-run setup.
- 防护动作：Do not recommend enabling privileged or credential-bearing paths until the source-backed risk is reviewed: https://github.com/chenhg5/cc-connect/issues/966
- 证据：failure_mode_cluster:github_issue | fmev_d8aeb38642d53571d47292761cca7247 | https://github.com/chenhg5/cc-connect/issues/966 | [Bug] cc-connect send uses default socket path in custom data_dir agent sessions, failure_mode_cluster:github_issue | fmev_105e57f4097e09e9e5c522a568ff4991 | https://github.com/chenhg5/cc-connect/issues/966 | [Bug] cc-connect send uses default socket path in custom data_dir agent sessions

## 9. 安全/权限坑 · 失败模式：security_permissions: [Bug] cc-connect 启动 Claude Code 时使用了 --dangerously-skip-permissions，但 最新版Claude Code 不允许 root...

- 严重度：high
- 证据强度：source_linked
- 发现：Developers should check this security_permissions risk before relying on the project: [Bug] cc-connect 启动 Claude Code 时使用了 --dangerously-skip-permissions，但 最新版Claude Code 不允许 root 用户使用这个标志
- 对用户的影响：Developers may expose sensitive permissions or credentials: [Bug] cc-connect 启动 Claude Code 时使用了 --dangerously-skip-permissions，但 最新版Claude Code 不允许 root 用户使用这个标志
- 建议检查：Before packaging this project, run the relevant install/config/quickstart check for: [Bug] cc-connect 启动 Claude Code 时使用了 --dangerously-skip-permissions，但 最新版Claude Code 不允许 root 用户使用这个标志. Context: Observed when using linux
- 防护动作：Do not recommend enabling privileged or credential-bearing paths until the source-backed risk is reviewed: https://github.com/chenhg5/cc-connect/issues/1054
- 证据：failure_mode_cluster:github_issue | fmev_9f56ecf6ad99707575ffe84fc2c10e1b | https://github.com/chenhg5/cc-connect/issues/1054 | [Bug] cc-connect 启动 Claude Code 时使用了 --dangerously-skip-permissions，但 最新版Claude Code 不允许 root 用户使用这个标志

## 10. 安全/权限坑 · 来源证据：Feature Request: 终端与 IM 双通道统一会话管理

- 严重度：high
- 证据强度：source_linked
- 发现：GitHub 社区证据显示该项目存在一个安全/权限相关的待验证问题：Feature Request: 终端与 IM 双通道统一会话管理
- 对用户的影响：可能影响授权、密钥配置或安全边界。
- 建议检查：来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。
- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。
- 证据：community_evidence:github | cevd_befa8b4f1c7f4ef483d6d8b38ba06ba4 | https://github.com/chenhg5/cc-connect/issues/968 | 来源讨论提到 windows 相关条件，需在安装/试用前复核。

## 11. 安全/权限坑 · 来源证据：[Bug] cc-connect 启动 Claude Code 时使用了 --dangerously-skip-permissions，但 最新版Claude Code 不允许 root 用户使用这个标志

- 严重度：high
- 证据强度：source_linked
- 发现：GitHub 社区证据显示该项目存在一个安全/权限相关的待验证问题：[Bug] cc-connect 启动 Claude Code 时使用了 --dangerously-skip-permissions，但 最新版Claude Code 不允许 root 用户使用这个标志
- 对用户的影响：可能影响授权、密钥配置或安全边界。
- 建议检查：来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。
- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。
- 证据：community_evidence:github | cevd_c632e470b2d04852abae801be4d2aba2 | https://github.com/chenhg5/cc-connect/issues/1054 | 来源讨论提到 linux 相关条件，需在安装/试用前复核。

## 12. 安全/权限坑 · 来源证据：[Bug] codex mode修改YOLO模式无效

- 严重度：high
- 证据强度：source_linked
- 发现：GitHub 社区证据显示该项目存在一个安全/权限相关的待验证问题：[Bug] codex mode修改YOLO模式无效
- 对用户的影响：可能影响授权、密钥配置或安全边界。
- 建议检查：来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。
- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。
- 证据：community_evidence:github | cevd_ce58ad66fc4e4d2ea6f0bb4a43527cd0 | https://github.com/chenhg5/cc-connect/issues/233 | 来源讨论提到 macos 相关条件，需在安装/试用前复核。

## 13. 安装坑 · 失败模式：installation: [Bug]

- 严重度：medium
- 证据强度：source_linked
- 发现：Developers should check this installation risk before relying on the project: [Bug]
- 对用户的影响：Developers may fail before the first successful local run: [Bug]
- 建议检查：Before packaging this project, run the relevant install/config/quickstart check for: [Bug]. Context: Observed when using node, windows
- 防护动作：State this as source-backed community evidence, not as Doramagic reproduction.
- 证据：failure_mode_cluster:github_issue | fmev_555d98ac56e7850b1c49e5892d2b6c48 | https://github.com/chenhg5/cc-connect/issues/933 | [Bug]

## 14. 安装坑 · 失败模式：installation: [Bug] codex mode修改YOLO模式无效

- 严重度：medium
- 证据强度：source_linked
- 发现：Developers should check this installation risk before relying on the project: [Bug] codex mode修改YOLO模式无效
- 对用户的影响：Developers may fail before the first successful local run: [Bug] codex mode修改YOLO模式无效
- 建议检查：Before packaging this project, run the relevant install/config/quickstart check for: [Bug] codex mode修改YOLO模式无效. Context: Observed when using macos
- 防护动作：State this as source-backed community evidence, not as Doramagic reproduction.
- 证据：failure_mode_cluster:github_issue | fmev_59a6433bec9f3dcf0981efd11a046df3 | https://github.com/chenhg5/cc-connect/issues/233 | [Bug] codex mode修改YOLO模式无效

## 15. 安装坑 · 失败模式：installation: [Bug] cursorSession error: unknown option '--trust

- 严重度：medium
- 证据强度：source_linked
- 发现：Developers should check this installation risk before relying on the project: [Bug] cursorSession error: unknown option '--trust
- 对用户的影响：Developers may fail before the first successful local run: [Bug] cursorSession error: unknown option '--trust
- 建议检查：Before packaging this project, run the relevant install/config/quickstart check for: [Bug] cursorSession error: unknown option '--trust. Context: Observed when using node, macos
- 防护动作：State this as source-backed community evidence, not as Doramagic reproduction.
- 证据：failure_mode_cluster:github_issue | fmev_279592e262a8c9114ffed9bcd68ca683 | https://github.com/chenhg5/cc-connect/issues/923 | [Bug] cursorSession error: unknown option '--trust

## 16. 安装坑 · 失败模式：installation: cc-connect 因 SSH 断开被 systemd 停止：需要文档化 `loginctl enable-linger`

- 严重度：medium
- 证据强度：source_linked
- 发现：Developers should check this installation risk before relying on the project: cc-connect 因 SSH 断开被 systemd 停止：需要文档化 `loginctl enable-linger`
- 对用户的影响：Developers may fail before the first successful local run: cc-connect 因 SSH 断开被 systemd 停止：需要文档化 `loginctl enable-linger`
- 建议检查：Before packaging this project, run the relevant install/config/quickstart check for: cc-connect 因 SSH 断开被 systemd 停止：需要文档化 `loginctl enable-linger`. Context: Observed when using node, linux
- 防护动作：State this as source-backed community evidence, not as Doramagic reproduction.
- 证据：failure_mode_cluster:github_issue | fmev_2ab77150cf90931385fb7741956a1f53 | https://github.com/chenhg5/cc-connect/issues/960 | cc-connect 因 SSH 断开被 systemd 停止：需要文档化 `loginctl enable-linger`, failure_mode_cluster:github_issue | fmev_5c45b25a78af1b25aea75c4cad91e50a | https://github.com/chenhg5/cc-connect/issues/960 | cc-connect 因 SSH 断开被 systemd 停止：需要文档化 `loginctl enable-linger`

## 17. 安装坑 · 失败模式：installation: v1.3.0

- 严重度：medium
- 证据强度：source_linked
- 发现：Developers should check this installation risk before relying on the project: v1.3.0
- 对用户的影响：Upgrade or migration may change expected behavior: v1.3.0
- 建议检查：Before packaging this project, run the relevant install/config/quickstart check for: v1.3.0. Context: Observed when using node, windows
- 防护动作：State this as source-backed community evidence, not as Doramagic reproduction.
- 证据：failure_mode_cluster:github_release | fmev_a2ead0f4920aaffbc2c58e566c82e8e8 | https://github.com/chenhg5/cc-connect/releases/tag/v1.3.0 | v1.3.0

## 18. 安装坑 · 失败模式：installation: v1.3.3-beta.1

- 严重度：medium
- 证据强度：source_linked
- 发现：Developers should check this installation risk before relying on the project: v1.3.3-beta.1
- 对用户的影响：Upgrade or migration may change expected behavior: v1.3.3-beta.1
- 建议检查：Before packaging this project, run the relevant install/config/quickstart check for: v1.3.3-beta.1. Context: Observed when using node
- 防护动作：State this as source-backed community evidence, not as Doramagic reproduction.
- 证据：failure_mode_cluster:github_release | fmev_2967bcebc65cc66231ca2bcd62e03f6f | https://github.com/chenhg5/cc-connect/releases/tag/v1.3.3-beta.1 | v1.3.3-beta.1

## 19. 安装坑 · 失败模式：installation: 生图 app-icon 请求未稳定转发到 generate-image，且 cc-connect 存在部署漂移风险

- 严重度：medium
- 证据强度：source_linked
- 发现：Developers should check this installation risk before relying on the project: 生图 app-icon 请求未稳定转发到 generate-image，且 cc-connect 存在部署漂移风险
- 对用户的影响：Developers may fail before the first successful local run: 生图 app-icon 请求未稳定转发到 generate-image，且 cc-connect 存在部署漂移风险
- 建议检查：Before packaging this project, run the relevant install/config/quickstart check for: 生图 app-icon 请求未稳定转发到 generate-image，且 cc-connect 存在部署漂移风险. Context: Observed during installation or first-run setup.
- 防护动作：State this as source-backed community evidence, not as Doramagic reproduction.
- 证据：failure_mode_cluster:github_issue | fmev_f2c109d868a32136d97c513f8ac192bb | https://github.com/chenhg5/cc-connect/issues/967 | 生图 app-icon 请求未稳定转发到 generate-image，且 cc-connect 存在部署漂移风险

## 20. 安装坑 · 来源证据：v1.3.3-beta.1

- 严重度：medium
- 证据强度：source_linked
- 发现：GitHub 社区证据显示该项目存在一个安装相关的待验证问题：v1.3.3-beta.1
- 对用户的影响：可能影响升级、迁移或版本选择。
- 建议检查：来源显示可能已有修复、规避或版本变化，说明书中必须标注适用版本。
- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。
- 证据：community_evidence:github | cevd_5eb39ef63cf14e56aff580db738dcd9f | https://github.com/chenhg5/cc-connect/releases/tag/v1.3.3-beta.1 | 来源讨论提到 npm 相关条件，需在安装/试用前复核。

## 21. 安装坑 · 来源证据：生图 app-icon 请求未稳定转发到 generate-image，且 cc-connect 存在部署漂移风险

- 严重度：medium
- 证据强度：source_linked
- 发现：GitHub 社区证据显示该项目存在一个安装相关的待验证问题：生图 app-icon 请求未稳定转发到 generate-image，且 cc-connect 存在部署漂移风险
- 对用户的影响：可能增加新用户试用和生产接入成本。
- 建议检查：来源显示可能已有修复、规避或版本变化，说明书中必须标注适用版本。
- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。
- 证据：community_evidence:github | cevd_574cca97359b4bc1a8a8fa968ab758cb | https://github.com/chenhg5/cc-connect/issues/967 | 来源讨论提到 node 相关条件，需在安装/试用前复核。

## 22. 配置坑 · 可能修改宿主 AI 配置

- 严重度：medium
- 证据强度：source_linked
- 发现：项目面向 Claude/Cursor/Codex/Gemini/OpenCode 等宿主，或安装命令涉及用户配置目录。
- 对用户的影响：安装可能改变本机 AI 工具行为，用户需要知道写入位置和回滚方法。
- 建议检查：列出会写入的配置文件、目录和卸载/回滚步骤。
- 防护动作：涉及宿主配置目录时必须给回滚路径，不能只给安装命令。
- 证据：capability.host_targets | github_repo:1168978399 | https://github.com/chenhg5/cc-connect | host_targets=claude, claude_code, cursor

## 23. 配置坑 · 失败模式：configuration: Feature Request: 终端与 IM 双通道统一会话管理

- 严重度：medium
- 证据强度：source_linked
- 发现：Developers should check this configuration risk before relying on the project: Feature Request: 终端与 IM 双通道统一会话管理
- 对用户的影响：Developers may misconfigure credentials, environment, or host setup: Feature Request: 终端与 IM 双通道统一会话管理
- 建议检查：Before packaging this project, run the relevant install/config/quickstart check for: Feature Request: 终端与 IM 双通道统一会话管理. Context: Observed when using windows
- 防护动作：State this as source-backed community evidence, not as Doramagic reproduction.
- 证据：failure_mode_cluster:github_issue | fmev_eb8a9f26e9a7250936e6075aa04d1f9f | https://github.com/chenhg5/cc-connect/issues/968 | Feature Request: 终端与 IM 双通道统一会话管理

## 24. 配置坑 · 失败模式：configuration: Feishu: all messages permanently ignored as 'old message after restart' after every daemon re...

- 严重度：medium
- 证据强度：source_linked
- 发现：Developers should check this configuration risk before relying on the project: Feishu: all messages permanently ignored as 'old message after restart' after every daemon restart (v1.3.3-beta.2)
- 对用户的影响：Developers may misconfigure credentials, environment, or host setup: Feishu: all messages permanently ignored as 'old message after restart' after every daemon restart (v1.3.3-beta.2)
- 建议检查：Before packaging this project, run the relevant install/config/quickstart check for: Feishu: all messages permanently ignored as 'old message after restart' after every daemon restart (v1.3.3-beta.2). Context: Observed when using linux
- 防护动作：State this as source-backed community evidence, not as Doramagic reproduction.
- 证据：failure_mode_cluster:github_issue | fmev_d77b163febfec4d4e69e2e4e32f620a1 | https://github.com/chenhg5/cc-connect/issues/972 | Feishu: all messages permanently ignored as 'old message after restart' after every daemon restart (v1.3.3-beta.2)

## 25. 配置坑 · 失败模式：configuration: [Feature] Preserve full interactive card schema on inbound

- 严重度：medium
- 证据强度：source_linked
- 发现：Developers should check this configuration risk before relying on the project: [Feature] Preserve full interactive card schema on inbound
- 对用户的影响：Developers may misconfigure credentials, environment, or host setup: [Feature] Preserve full interactive card schema on inbound
- 建议检查：Before packaging this project, run the relevant install/config/quickstart check for: [Feature] Preserve full interactive card schema on inbound. Context: Observed when using python
- 防护动作：State this as source-backed community evidence, not as Doramagic reproduction.
- 证据：failure_mode_cluster:github_issue | fmev_bc874b9a16a67215d86b2e2342c2ce30 | https://github.com/chenhg5/cc-connect/issues/936 | [Feature] Preserve full interactive card schema on inbound

## 26. 配置坑 · 失败模式：configuration: v1.3.0-rc.5

- 严重度：medium
- 证据强度：source_linked
- 发现：Developers should check this configuration risk before relying on the project: v1.3.0-rc.5
- 对用户的影响：Upgrade or migration may change expected behavior: v1.3.0-rc.5
- 建议检查：Before packaging this project, run the relevant install/config/quickstart check for: v1.3.0-rc.5. Context: Source discussion did not expose a precise runtime context.
- 防护动作：State this as source-backed community evidence, not as Doramagic reproduction.
- 证据：failure_mode_cluster:github_release | fmev_742c16dbbbfed9286198088ba0f05c07 | https://github.com/chenhg5/cc-connect/releases/tag/v1.3.0-rc.5 | v1.3.0-rc.5

## 27. 配置坑 · 失败模式：configuration: v1.3.1

- 严重度：medium
- 证据强度：source_linked
- 发现：Developers should check this configuration risk before relying on the project: v1.3.1
- 对用户的影响：Upgrade or migration may change expected behavior: v1.3.1
- 建议检查：Before packaging this project, run the relevant install/config/quickstart check for: v1.3.1. Context: Observed during version upgrade or migration.
- 防护动作：State this as source-backed community evidence, not as Doramagic reproduction.
- 证据：failure_mode_cluster:github_release | fmev_af9571ceb2092a140a16c2cfbe490ca1 | https://github.com/chenhg5/cc-connect/releases/tag/v1.3.1 | v1.3.1

## 28. 配置坑 · 失败模式：configuration: v1.3.2

- 严重度：medium
- 证据强度：source_linked
- 发现：Developers should check this configuration risk before relying on the project: v1.3.2
- 对用户的影响：Upgrade or migration may change expected behavior: v1.3.2
- 建议检查：Before packaging this project, run the relevant install/config/quickstart check for: v1.3.2. Context: Source discussion did not expose a precise runtime context.
- 防护动作：State this as source-backed community evidence, not as Doramagic reproduction.
- 证据：failure_mode_cluster:github_release | fmev_a2bd7f299418ec4b6c3fe49f42c6e933 | https://github.com/chenhg5/cc-connect/releases/tag/v1.3.2 | v1.3.2

## 29. 配置坑 · 失败模式：configuration: v1.3.3-beta.2

- 严重度：medium
- 证据强度：source_linked
- 发现：Developers should check this configuration risk before relying on the project: v1.3.3-beta.2
- 对用户的影响：Upgrade or migration may change expected behavior: v1.3.3-beta.2
- 建议检查：Before packaging this project, run the relevant install/config/quickstart check for: v1.3.3-beta.2. Context: Source discussion did not expose a precise runtime context.
- 防护动作：State this as source-backed community evidence, not as Doramagic reproduction.
- 证据：failure_mode_cluster:github_release | fmev_6d397fcba273f6fa44d3976dd8c91a69 | https://github.com/chenhg5/cc-connect/releases/tag/v1.3.3-beta.2 | v1.3.3-beta.2

## 30. 能力坑 · 能力判断依赖假设

- 严重度：medium
- 证据强度：source_linked
- 发现：README/documentation is current enough for a first validation pass.
- 对用户的影响：假设不成立时，用户拿不到承诺的能力。
- 建议检查：将假设转成下游验证清单。
- 防护动作：假设必须转成验证项；没有验证结果前不能写成事实。
- 证据：capability.assumptions | github_repo:1168978399 | https://github.com/chenhg5/cc-connect | README/documentation is current enough for a first validation pass.

## 31. 运行坑 · 来源证据：出现网络波动后，一直显示这个retrying，只能手动重启吗？

- 严重度：medium
- 证据强度：source_linked
- 发现：GitHub 社区证据显示该项目存在一个运行相关的待验证问题：出现网络波动后，一直显示这个retrying，只能手动重启吗？
- 对用户的影响：可能增加新用户试用和生产接入成本。
- 建议检查：来源显示可能已有修复、规避或版本变化，说明书中必须标注适用版本。
- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。
- 证据：community_evidence:github | cevd_8d8f7103758f4f46bffd9b411c81bbf6 | https://github.com/chenhg5/cc-connect/issues/102 | 来源类型 github_issue 暴露的待验证使用条件。

## 32. 维护坑 · 维护活跃度未知

- 严重度：medium
- 证据强度：source_linked
- 发现：未记录 last_activity_observed。
- 对用户的影响：新项目、停更项目和活跃项目会被混在一起，推荐信任度下降。
- 建议检查：补 GitHub 最近 commit、release、issue/PR 响应信号。
- 防护动作：维护活跃度未知时，推荐强度不能标为高信任。
- 证据：evidence.maintainer_signals | github_repo:1168978399 | https://github.com/chenhg5/cc-connect | last_activity_observed missing

## 33. 安全/权限坑 · 下游验证发现风险项

- 严重度：medium
- 证据强度：source_linked
- 发现：no_demo
- 对用户的影响：下游已经要求复核，不能在页面中弱化。
- 建议检查：进入安全/权限治理复核队列。
- 防护动作：下游风险存在时必须保持 review/recommendation 降级。
- 证据：downstream_validation.risk_items | github_repo:1168978399 | https://github.com/chenhg5/cc-connect | no_demo; severity=medium

## 34. 安全/权限坑 · 存在评分风险

- 严重度：medium
- 证据强度：source_linked
- 发现：no_demo
- 对用户的影响：风险会影响是否适合普通用户安装。
- 建议检查：把风险写入边界卡，并确认是否需要人工复核。
- 防护动作：评分风险必须进入边界卡，不能只作为内部分数。
- 证据：risks.scoring_risks | github_repo:1168978399 | https://github.com/chenhg5/cc-connect | no_demo; severity=medium

## 35. 安全/权限坑 · 来源证据：[Bug] cursorSession error: unknown option '--trust

- 严重度：medium
- 证据强度：source_linked
- 发现：GitHub 社区证据显示该项目存在一个安全/权限相关的待验证问题：[Bug] cursorSession error: unknown option '--trust
- 对用户的影响：可能影响授权、密钥配置或安全边界。
- 建议检查：来源显示可能已有修复、规避或版本变化，说明书中必须标注适用版本。
- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。
- 证据：community_evidence:github | cevd_d9323b9200ff491e8c6f408880565e86 | https://github.com/chenhg5/cc-connect/issues/923 | 来源讨论提到 npm 相关条件，需在安装/试用前复核。

## 36. 安全/权限坑 · 来源证据：v1.3.2

- 严重度：medium
- 证据强度：source_linked
- 发现：GitHub 社区证据显示该项目存在一个安全/权限相关的待验证问题：v1.3.2
- 对用户的影响：可能影响授权、密钥配置或安全边界。
- 建议检查：来源显示可能已有修复、规避或版本变化，说明书中必须标注适用版本。
- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。
- 证据：community_evidence:github | cevd_2245b50ba3e94323b2228f6ed5b2b73e | https://github.com/chenhg5/cc-connect/releases/tag/v1.3.2 | 来源类型 github_release 暴露的待验证使用条件。

## 37. 安全/权限坑 · 来源证据：v1.3.3-beta.2

- 严重度：medium
- 证据强度：source_linked
- 发现：GitHub 社区证据显示该项目存在一个安全/权限相关的待验证问题：v1.3.3-beta.2
- 对用户的影响：可能影响授权、密钥配置或安全边界。
- 建议检查：来源显示可能已有修复、规避或版本变化，说明书中必须标注适用版本。
- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。
- 证据：community_evidence:github | cevd_4665651336a6450db47e6262a8926c7b | https://github.com/chenhg5/cc-connect/releases/tag/v1.3.3-beta.2 | 来源类型 github_release 暴露的待验证使用条件。

## 38. 维护坑 · issue/PR 响应质量未知

- 严重度：low
- 证据强度：source_linked
- 发现：issue_or_pr_quality=unknown。
- 对用户的影响：用户无法判断遇到问题后是否有人维护。
- 建议检查：抽样最近 issue/PR，判断是否长期无人处理。
- 防护动作：issue/PR 响应未知时，必须提示维护风险。
- 证据：evidence.maintainer_signals | github_repo:1168978399 | https://github.com/chenhg5/cc-connect | issue_or_pr_quality=unknown

## 39. 维护坑 · 发布节奏不明确

- 严重度：low
- 证据强度：source_linked
- 发现：release_recency=unknown。
- 对用户的影响：安装命令和文档可能落后于代码，用户踩坑概率升高。
- 建议检查：确认最近 release/tag 和 README 安装命令是否一致。
- 防护动作：发布节奏未知或过期时，安装说明必须标注可能漂移。
- 证据：evidence.maintainer_signals | github_repo:1168978399 | https://github.com/chenhg5/cc-connect | release_recency=unknown

<!-- canonical_name: chenhg5/cc-connect; human_manual_source: deepwiki_human_wiki -->
