# weixin-cc-channel **Repository Path**: Darchrow-Mu/weixin-cc-channel ## Basic Information - **Project Name**: weixin-cc-channel - **Description**: 使用微信Bot机器人和电脑上的 claude code沟通,发送指令。 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-05-25 - **Last Updated**: 2026-05-25 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # weixin-cc-channel 微信与 Claude Code 的桥接服务,让你可以通过微信与本地运行的 Claude Code Agent 进行交互。 ## 功能特性 - **微信登录**:通过扫码登录微信 Bot API - **会话管理**:自动发现本地 Claude Code 会话,支持切换、创建、终止 - **消息路由**:微信消息实时转发给 Agent,Agent 响应自动推送到微信 - **状态持久化**:重启服务后自动恢复用户与会话的绑定关系 - **后台运行**:支持 daemon 模式后台运行服务 - **自然语言**:支持自然语言指令(如"列出全部项目"、"切换到第一个") ## 安装 ### 前置要求 - Node.js >= 18 - [Claude Code CLI](https://github.com/anthropics/claude-code) 已安装并配置 ### 安装步骤 ```bash # 克隆仓库 git clone https://gitee.com/Darchrow-Mu/weixin-cc-channel.git cd weixin-cc-channel # 安装依赖 npm install # 构建 npm run build # 全局安装(可选) npm link ``` ## 使用方法 ### 启动服务 ```bash # 一键启动(自动检查登录状态,后台运行) weixin-cc-channel # 或使用 npm npm start # 前台运行(用于调试) weixin-cc-channel run --foreground weixin-cc-channel start -f ``` ### 登录微信 首次运行时会自动提示扫码登录,也可以手动登录: ```bash weixin-cc-channel login ``` 启动后会显示二维码,使用微信扫码授权即可。 ### 查看状态 ```bash weixin-cc-channel status ``` 显示登录状态和服务运行状态。 ### 停止服务 ```bash weixin-cc-channel stop ``` ### 登出 ```bash weixin-cc-channel logout ``` ## 微信端指令 在微信中向 Bot 发送以下指令: ### 会话管理 | 指令 | 说明 | |------|------| | `/list` 或 `列出全部项目` | 列出所有活跃的 Claude Code 会话 | | `/p <数字>` | 切换到指定序号的会话(如 `/p 1`) | | `/create <项目路径>` | 在指定路径创建新会话 | | `/status` | 查看当前会话状态 | | `/terminate` | 终止当前会话 | | `/help` | 显示帮助信息 | ### 与 Agent 对话 直接发送消息即可与当前会话的 Agent 对话,Agent 的响应会自动推送到微信。 ### 权限确认 当 Agent 需要执行敏感操作时会请求权限,回复以下指令: - `Y` - 允许 - `N` - 拒绝 ## 配置 配置文件位于 `~/.weixin-cc-channel/config.json`: ```json { "weixin": { "baseUrl": "https://ilinkai.weixin.qq.com", "longPollTimeoutMs": 30000 }, "agents": { "claude-code": { "sessionsDir": "~/.claude/projects" } } } ``` ## 目录结构 ``` ~/.weixin-cc-channel/ ├── config.json # 配置文件 ├── auth.json # 登录凭证(加密存储) ├── sync-buf.json # 消息同步缓冲 ├── user-*.json # 用户上下文持久化 ├── weixin-cc-channel.pid # PID 文件 └── logs/ └── app.log # 运行日志 ``` ## 项目结构 ``` src/ ├── agent/ # Agent 适配器 │ ├── adapters/ # Claude Code 适配器实现 │ └── types.ts # Agent 相关类型定义 ├── command/ # 指令处理 │ ├── handlers/ # 各指令处理器 │ ├── parser.ts # 指令解析器 │ ├── router.ts # 指令路由 │ └── types.ts # 指令相关类型 ├── config/ # 配置管理 ├── sanitizer/ # 输出清洗(路径脱敏等) ├── session/ # 会话管理 │ ├── manager.ts # 会话管理器 │ └── user-context.ts # 用户上下文持久化 ├── storage/ # 存储层 ├── utils/ # 工具函数 ├── weixin/ # 微信相关 │ ├── api.ts # 微信 Bot API 封装 │ ├── gateway.ts # 消息网关 │ ├── login.ts # 登录流程 │ └── types.ts # 微信相关类型 ├── daemon.ts # 后台进程管理 ├── index.ts # CLI 入口 └── server.ts # 服务入口 ``` ## 开发 ```bash # 开发模式(监听文件变化) npm run build -- --watch # 运行测试 npm test # 代码检查 npm run lint ``` ## 参考 - [Claude Code](https://github.com/anthropics/claude-code) - Anthropic 官方 CLI 工具 - [微信 Bot API](https://ilinkai.weixin.qq.com) - 微信机器人 API 服务 ## License MIT