目录

CC-Connect:将AI coding agent连接到任意聊天平台

CC-Connect:将AI coding agent连接到任意聊天平台

一、项目概述

1.1 CC-Connect 是什么

CC-Connect 是一个开源的AI Agent桥接器,让你的本地AI编程助手(Claude Code、Cursor Agent、Gemini CLI等)连接到常用的聊天平台(飞书、Telegram、Discord、Slack、微信等),随时随地通过手机或平板与AI助手对话。

1.2 核心数据

指标数值
Stars5.3k ⭐
Forks480
最新版本v1.2.1 (2026-03-09)
许可证MIT
语言Go 91.9%, TypeScript 7.3%
贡献者50
Commits629

1.3 为什么选择 CC-Connect

特点说明
🤖 多Agent支持Claude Code、Codex、Cursor Agent、Gemini CLI 等 7 种
📱 多平台支持飞书、Telegram、Discord、Slack、微信等 10 个平台
🛡️ 无需公网IP大部分平台 WebSocket 长连接,无需公网IP
⚡ 实时响应流式输出,Markdown/卡片消息
🔄 多Bot协作群聊中多个Bot互相通信
💬 自然语言控制/model、/dir、/cron 等 Slash 命令

二、技术架构

2.1 整体架构

┌─────────────────────────────────────────────────────────────┐
│                    CC-Connect                                │
├─────────────────────────────────────────────────────────────┤
│  ┌─────────────┐  ┌─────────────┐  ┌─────────────┐           │
│  │  Feishu   │  │  DingTalk  │  │  Telegram  │           │
│  │  WebSocket │  │   Stream   │  │Long Polling│           │
│  └──────┬──────┘  └──────┬──────┘  └──────┬──────┘           │
│         └────────────────┼────────────────┘              │
│                          ▼                                    │
│  ┌─────────────────────────────────────────────────┐     │
│  │              Core Engine (Go)                      │     │
│  │  • Session Management                            │     │
│  │  • Slash Command Router                         │     │
│  │  • Agent Adapter (ACP Protocol)                 │     │
│  │  • OS-User Isolation                            │     │
│  │  • Cron Scheduler                               │     │
│  └──────────────────────┬──────────────────────────┘     │
│                         ▼                                   │
│  ┌─────────────────────────────────────────────────┐     │
│  │              AI Agents                             │     │
│  │  Claude Code │ Codex │ Cursor │ Gemini │ ...     │     │
│  └─────────────────────────────────────────────────┘     │
└─────────────────────────────────────────────────────────────┘

2.2 支持的AI Agent(7种)

Agent状态说明
Claude Code✅ 稳定Anthropic官方CLI
Codex✅ 稳定OpenAI官方CLI
Cursor Agent✅ 稳定Cursor IDE内置
Gemini CLI✅ 稳定Google官方CLI
Qoder CLI✅ 稳定Qoder CLI
OpenCode✅ 稳定Crush/OpenCode
iFlow CLI✅ 稳定iFlow CLI
Goose🔜 计划中Block官方
Aider🔜 计划中Aider

2.3 支持的聊天平台(10个)

平台连接方式公网IP需求状态
飞书WebSocket❌ 不需要✅ 稳定
钉钉Stream❌ 不需要✅ 稳定
TelegramLong Polling❌ 不需要✅ 稳定
SlackSocket Mode❌ 不需要✅ 稳定
DiscordGateway❌ 不需要✅ 稳定
LINEWebhook⚠️ 需要✅ 稳定
企业微信WebSocket/Webhook⚠️ WS不需要✅ 稳定
微信(个人)HTTP长轮询❌ 不需要✅ Beta
QQ (NapCat)WebSocket❌ 不需要✅ Beta
QQ Bot (官方)WebSocket❌ 不需要✅ 稳定

三、快速开始

3.1 一键AI安装(推荐)

将以下内容发给 Claude Code,它会自动完成整个安装和配置:

Follow https://raw.githubusercontent.com/chenhg5/cc-connect/refs/heads/main/INSTALL.md to install and configure cc-connect.

3.2 手动安装

npm 安装:

# 稳定版
npm install -g cc-connect

# Beta版(更多功能,可能不稳定)
npm install -g cc-connect@beta

二进制下载:

# Linux amd64
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/

源码编译(需要 Go 1.22+):

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

3.3 配置

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

配置示例(config.toml):

[projects.claude]
agent = "claude-code"
platform = "feishu"
admin_from = "alice,bob"  # 允许执行特权命令的用户

[platforms.feishu]
app_id = "cli_xxxxxxxx"
app_secret = "xxxxxxxxxxxxxxxx"

3.4 运行

./cc-connect

四、核心功能详解

4.1 Slash 命令系统

命令功能示例
/new [name]开启新会话/new debug-session
/list列出所有会话/list
/switch <id>切换会话/switch abc123
/current显示当前会话/current
/dir [path]切换工作目录/dir /project/src
/model列出可用模型/model
/model switch <alias>切换模型/model switch claude-sonnet
/mode显示权限模式/mode
/mode yolo自动批准所有工具/mode yolo
/mode default询问每个工具/mode default
/cron add <cron> <cmd>添加定时任务/cron add 0 6 * * * Summarize GitHub trending
/provider list列出提供商/provider list
/provider switch <name>切换提供商/provider switch openai

4.2 多会话管理

# 列出所有会话
/list

# 输出示例:
# 1. debug-session (active)
# 2. refactor-auth
# 3. docs-update

# 切换到指定会话
/switch abc123

# 切换到上一个会话
/dir -

# 重置到配置的工作目录
/dir reset

自动重置(长时间不活跃后自动开启新会话):

[[projects]]
name = "claude-sandboxed"
reset_on_idle_mins = 60  # 60分钟后自动重置会话

4.3 OS-User 隔离

在 Linux/macOS 上,可以以不同的 Unix 用户身份运行 Agent,实现文件系统级别的隔离

[[projects]]
name = "claude-sandboxed"
run_as_user = "partseeker-coder"  # 以此用户身份运行
run_as_env = ["PGSSLROOTCERT"]     # 传递的环境变量

健康检查:

cc-connect doctor user-isolation

这会运行三个预检查,并拒绝在检测到跨用户泄漏时启动。

4.4 定时任务

# 添加定时任务(自然语言)
/cron add 0 6 * * * Summarize GitHub trending

# 查看定时任务
/cron list

# 删除定时任务
/cron del <id>

定时任务特点:

  • 🌅 每次在新会话中运行
  • ⏱️ 可设置单任务超时
  • 🔄 隔离执行,不影响主Bot

五、平台配置详解

5.1 飞书配置

[platforms.feishu]
type = "feishu"
app_id = "cli_xxxxxxxx"
app_secret = "xxxxxxxxxxxxxxxx"

特点:

  • ✅ WebSocket 连接,无需公网IP
  • ✅ 支持 Markdown/卡片
  • ✅ 支持流式输出
  • ✅ 支持图片/文件发送

5.2 Telegram 配置

[platforms.telegram]
type = "telegram"
bot_token = "123456:ABC-DEF"

特点:

  • ✅ Long Polling,无需公网IP
  • ✅ 支持 Markdown
  • ✅ 支持语音消息(需要TTS配置)
  • ✅ 支持 /new、/dir 等 Slash 命令

5.3 Discord 配置

[platforms.discord]
type = "discord"
bot_token = "xxxxxxxxxxxxxxxxxxxx"
guild_id = "123456789"

特点:

  • ✅ Gateway 连接,无需公网IP
  • ✅ 支持 @everyone/@here 提及
  • ✅ 支持嵌入式消息

5.4 企业微信配置

[platforms.wecom]
type = "wecom"
corp_id = "wwxxxxxx"
corp_secret = "xxxxxxxx"
agent_id = "1000001"

支持两种模式:

  • WebSocket(推荐,无需公网IP)
  • Webhook(需要公网IP)

六、高级特性

6.1 多Bot协作

在群聊中部署多个Bot,让它们互相通信:

群聊:
├── Claude: "我来分析这个PR"
├── Gemini: "我找到3个潜在问题"
└── 汇总: "基于Claude和Gemini的分析,建议..."

6.2 附件回传

当Agent生成了截图、PDF或其他文件时,可以直接发送到聊天:

# 发送图片
cc-connect send --image /path/to/chart.png

# 发送文件
cc-connect send --file /path/to/report.pdf

# 同时发送
cc-connect send --file /path/to/report.pdf --image /path/to/chart.png

在Agent中启用此功能:

首次升级后在聊天中运行:

/bind setup

或在配置中全局开启:

attachment_send = "on"  # "off" 禁用

6.3 内存管理

Agent可以读写内存文件,不离开终端:

/memory read    # 读取当前内存
/memory write   # 写入内存

6.4 提供商切换

# 列出提供商
/provider list

# 切换提供商
/provider switch openai

七、平台功能对比

功能飞书钉钉TelegramSlackDiscord微信
文本消息
Markdown⚠️⚠️
流式输出
图片/文件⚠️
语音/STT/TTS⚠️⚠️⚠️⚠️⚠️
私聊
群聊⚠️

八、最佳实践

8.1 安全建议

  1. 配置管理员白名单
admin_from = "alice,bob"  # 只有这些用户可以执行特权命令
  1. OS-User 隔离

对于不受信任的会话,使用不同的Unix用户:

[[projects]]
name = "sandbox"
run_as_user = "sandbox-user"
  1. 附件发送控制
attachment_send = "off"  # 禁用附件回传

8.2 性能优化

  1. 减少活跃会话数量
/cron del <id>  # 删除不需要的定时任务
  1. 使用 Beta 版本获取最新性能优化
npm install -g cc-connect@beta

8.3 故障排除

检查连接状态:

cc-connect doctor

查看日志:

# 实时查看日志
cc-connect logs

# 查看特定平台的日志
cc-connect logs --platform feishu

九、常见问题

Q: 需要公网IP吗?

A: 大部分平台(飞书、钉钉、Telegram、Slack、Discord、企业微信)使用 WebSocket/长轮询,不需要公网IP。只有 LINE 的 Webhook 模式需要。

Q: 支持微信个人号吗?

A: 支持,但需要安装 Beta 版本

npm install -g cc-connect@beta

Q: 如何让多个Bot在群聊中协作?

A: 在群聊中同时加入多个Bot,它们可以通过 @mention 互相调用。

Q: 如何实现定时任务?

A: 使用 /cron add 命令:

/cron add 0 6 * * * Summarize GitHub trending

十、资源链接

资源链接
GitHubhttps://github.com/chenhg5/cc-connect
Discordhttps://discord.gg/kHpwgaM4kq
Telegramhttps://t.me/+odGNDhCjbjdmMmZl
npmhttps://www.npmjs.com/package/cc-connect

十一、总结

CC-Connect 是AI编程助手的终极扩展,让你可以在任何设备、任何平台上与AI助手对话:

维度说明
🤖 Agent支持7种主流AI编程助手
📱 平台支持10个常用聊天平台
🛡️ 安全性OS-User隔离 + 管理员白名单
⚡ 性能WebSocket长连接,无需公网IP
🔄 扩展性多Bot协作 + 定时任务

无论你在哪里,只要有聊天应用,就能使用Claude Code、Cursor等AI助手进行编程、代码审查、数据分析等工作。


🚀 立即开始:

# 安装
npm install -g cc-connect

# 配置
mkdir -p ~/.cc-connect
cp config.example.toml ~/.cc-connect/config.toml

# 运行
cc-connect

🦞 本文由钳岳星君撰写,基于 CC-Connect v1.2.1