feihong-code 0.6.1 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,292 @@
1
+ # Feihong Code v7.0.0 Technical Specification
2
+
3
+ **Version**: 7.0.0
4
+ **Date**: August 24, 2026
5
+ **R&D Team**: Feihongzhi Technology Enterprise Management Co., Ltd. · Feiyang Qiyuan R&D Center
6
+
7
+ ---
8
+
9
+ ## 1. Product Overview
10
+
11
+ Feihong Code (feihong-code) is a terminal AI coding agent, benchmarked against Muse Code / Cursor CLI, supporting multi-model routing, enterprise-grade RBAC auditing, fully automated SWE Agent, and offline private deployment.
12
+
13
+ ### 1.1 Core Capabilities
14
+
15
+ - Natural Language to Code Changes: Transform user requirements into real, verifiable code repository changes
16
+ - Multi-model Routing: Support DeepSeek, Tongyi Qianwen, Ollama, OpenAI, and other models
17
+ - Fully Automated SWE Agent: Autonomous planning, execution, verification, and fixing
18
+ - Enterprise-grade Security: RBAC permissions, audit logs, workspace isolation
19
+ - Full Platform Support: Web console, Electron desktop, CLI command line
20
+
21
+ ### 1.2 Tech Stack
22
+
23
+ | Layer | Technology | Version |
24
+ |-------|-----------|---------|
25
+ | Runtime | Node.js | 18+ |
26
+ | Language | TypeScript | 5.x |
27
+ | Web Framework | Express | 4.x |
28
+ | Data Validation | Zod | 3.x |
29
+ | Frontend | Native HTML/CSS/JS | - |
30
+ | Desktop | Electron | 41.x |
31
+ | Packaging | electron-builder | 26.x |
32
+ | Build | tsc | 5.x |
33
+
34
+ ---
35
+
36
+ ## 2. System Architecture
37
+
38
+ ### 2.1 Overall Architecture
39
+
40
+ ```
41
+ ┌─────────────────────────────────────────────────┐
42
+ │ User Interface Layer │
43
+ │ ┌──────────┐ ┌──────────┐ ┌──────────────┐ │
44
+ │ │Web Console│ │ Desktop │ │ CLI │ │
45
+ │ └────┬─────┘ └────┬─────┘ └──────┬───────┘ │
46
+ └───────┼─────────────┼───────────────┼──────────┘
47
+ │ │ │
48
+ └─────────────┼───────────────┘
49
+
50
+ ┌───────▼───────┐
51
+ │ Express API │
52
+ │ Service Layer│
53
+ └───────┬───────┘
54
+
55
+ ┌─────────────┼─────────────┐
56
+ │ │ │
57
+ ┌─────▼─────┐ ┌─────▼─────┐ ┌─────▼─────┐
58
+ │Task Queue │ │Model Router│ │Audit │
59
+ │TaskQueue │ │Router │ │Security │
60
+ └─────┬─────┘ └─────┬─────┘ └───────────┘
61
+ │ │
62
+ ┌─────▼─────────────▼─────┐
63
+ │ SWE Agent Layer │
64
+ │ Orchestrator │
65
+ └─────┬───────────────────┘
66
+
67
+ ┌─────▼───────────────────┐
68
+ │ Tool Execution Layer │
69
+ │ File Ops / Shell / Browser│
70
+ └─────────────────────────┘
71
+ ```
72
+
73
+ ### 2.2 Core Modules
74
+
75
+ #### 2.2.1 Agent Layer (src/agent/)
76
+
77
+ - **orchestrator.ts**: Core orchestrator, manages conversation loop, tool calls, error recovery
78
+ - **prompts.ts**: System prompts, defines AI behavior boundaries and capability requirements
79
+ - **self-heal.ts**: Self-healing module, error classification, fix suggestion generation
80
+ - **code-writer.ts**: Code generation module
81
+ - **swe-agent.ts**: SWE Agent implementation
82
+ - **experience.ts**: Experience retrieval and reuse
83
+
84
+ #### 2.2.2 Web Service Layer (src/web/)
85
+
86
+ - **server.ts**: Express service, API routes, static file serving
87
+ - **task-queue.ts**: Task queue, concurrency control, task persistence, state management
88
+ - **public/**: Frontend static assets (HTML/CSS/JS)
89
+
90
+ #### 2.2.3 CLI Layer (src/cli/)
91
+
92
+ - **index.ts**: CLI entry, command parsing
93
+ - **commands.ts**: Command implementation (serve/run/init etc.)
94
+ - **version.ts**: Centralized version definition
95
+ - **repl.ts**: Interactive REPL
96
+
97
+ #### 2.2.4 Desktop (electron/)
98
+
99
+ - **main.js**: Electron main process, window management, server startup, IPC communication
100
+ - **preload.js**: Preload script, safely exposes API to renderer process
101
+
102
+ #### 2.2.5 Local Speech Recognition (funasr-server/)
103
+
104
+ - **app.py**: FastAPI service, based on faster-whisper
105
+ - **requirements.txt**: Python dependencies
106
+ - **启动语音识别服务.bat**: Windows one-click startup
107
+
108
+ ---
109
+
110
+ ## 3. Core Mechanisms
111
+
112
+ ### 3.1 Task Execution Flow
113
+
114
+ 1. **Task Submission**: User submits task via Web/Desktop/CLI
115
+ 2. **Task Enqueue**: TaskQueue receives task, sets status to queued
116
+ 3. **Task Execution**: Picks up task under concurrency control, calls Orchestrator
117
+ 4. **Orchestration Loop**: Orchestrator manages model calls, tool execution, result verification
118
+ 5. **Error Recovery**: Continuous errors trigger self-heal, generate fix suggestions and retry
119
+ 6. **Task Completion**: Result persisted, triggers webhook/notification
120
+
121
+ ### 3.2 Conversation Flow Rendering
122
+
123
+ - **conversation**: Complete conversation history, limit 300 messages
124
+ - **steps**: Thinking chain steps, limit 500
125
+ - **Real-time Polling**: Frontend polls task status every 1 second
126
+ - **Pure Text Output**: Frontend stripMarkdown hard defense, strips all formatting symbols
127
+ - **Thinking Process Display**: Extract model.response content from steps for real-time display
128
+
129
+ ### 3.3 Self-healing Mechanism
130
+
131
+ - **Error Classification**: 11 categories including compile-error / runtime-error / build-error / timeout
132
+ - **Continuous Error Detection**: Traverse all continuous error messages for classification recording
133
+ - **Fix Suggestion Generation**: Generate specific troubleshooting steps based on error type
134
+ - **Max Retries**: Default 3, configurable
135
+ - **Structured Report**: Error type + last error + fix suggestion + next step
136
+
137
+ ### 3.4 Permissions and Security
138
+
139
+ - **RBAC Permissions**: Read scope, write permission, Shell permission, network permission, browser permission
140
+ - **Workspace Isolation**: File operations limited to workspace scope
141
+ - **Audit Logs**: All operations recorded to event-log
142
+ - **Security Approval**: Dangerous operations require user confirmation
143
+
144
+ ---
145
+
146
+ ## 4. API Interfaces
147
+
148
+ ### 4.1 Core APIs
149
+
150
+ | Method | Path | Description |
151
+ |--------|------|-------------|
152
+ | GET | /api/health | Health check |
153
+ | POST | /api/auth/login | Login |
154
+ | GET | /api/tasks | Task list |
155
+ | POST | /api/tasks | Create task |
156
+ | GET | /api/tasks/:id | Task detail |
157
+ | POST | /api/tasks/:id/cancel | Cancel task |
158
+ | DELETE | /api/tasks/:id | Delete task |
159
+ | POST | /api/tasks/:id/continue | Continue task |
160
+ | GET | /api/models | Available model list |
161
+ | POST | /api/computer/screenshot | Computer screenshot |
162
+ | POST | /api/computer/mouse/move | Mouse move |
163
+ | POST | /api/computer/mouse/click | Mouse click |
164
+ | POST | /api/computer/keyboard/type | Keyboard type |
165
+ | POST | /api/computer/keyboard/press | Key press |
166
+
167
+ ### 4.2 Local Speech Recognition API
168
+
169
+ | Method | Path | Description |
170
+ |--------|------|-------------|
171
+ | GET | /health | Health check |
172
+ | POST | /api/recognize | Speech recognition (file upload) |
173
+ | POST | /api/recognize-bytes | Speech recognition (byte stream) |
174
+
175
+ ---
176
+
177
+ ## 5. Deployment
178
+
179
+ ### 5.1 npm Global Install
180
+
181
+ ```bash
182
+ npm install -g feihong-code
183
+ fhcode serve
184
+ ```
185
+
186
+ ### 5.2 Source Deployment
187
+
188
+ ```bash
189
+ git clone https://github.com/wch887292/feihong-code.git
190
+ cd feihong-code
191
+ npm install
192
+ npm run build
193
+ node dist/cli/index.js serve
194
+ ```
195
+
196
+ ### 5.3 Desktop Version
197
+
198
+ ```bash
199
+ # One-click startup
200
+ Double-click 一键启动桌面版.bat
201
+
202
+ # Or manual
203
+ npm run build
204
+ npm run electron
205
+ ```
206
+
207
+ ### 5.4 Local Speech Recognition Service
208
+
209
+ ```bash
210
+ cd funasr-server
211
+ Double-click 启动语音识别服务.bat
212
+ # Service URL: http://localhost:8082
213
+ ```
214
+
215
+ ---
216
+
217
+ ## 6. Configuration
218
+
219
+ ### 6.1 Environment Variables
220
+
221
+ | Variable | Description | Default |
222
+ |----------|-------------|---------|
223
+ | FH_WEB_PORT | Web service port | 8080 |
224
+ | FH_WEB_TOKEN | Access token | Auto-generated |
225
+ | FH_HOME | Data directory | ~/.feihong-code |
226
+ | FH_TASK_CONCURRENCY | Task concurrency | 2 |
227
+ | FH_TASK_PERSIST_DIR | Task persistence dir | FH_HOME/tasks |
228
+ | FH_TASK_WEBHOOK_URL | Task webhook | - |
229
+
230
+ ### 6.2 Model Configuration
231
+
232
+ Supports multi-model routing, configurable in Web console:
233
+ - DeepSeek (deepseek-chat / deepseek-coder)
234
+ - Tongyi Qianwen (qwen-turbo / qwen-max)
235
+ - Ollama (local models)
236
+ - OpenAI compatible interfaces
237
+
238
+ ---
239
+
240
+ ## 7. Extension Development
241
+
242
+ ### 7.1 Add New Tool
243
+
244
+ Add tool definition under `src/agent/tools/`, following Zod schema specification.
245
+
246
+ ### 7.2 Add New Skill
247
+
248
+ Create skill directory under workspace `.feihong/skills/`, containing SKILL.md and scripts.
249
+
250
+ ### 7.3 Plugin System
251
+
252
+ Template library supports custom sources, connects to external plugin systems through nodes.
253
+
254
+ ---
255
+
256
+ ## 8. Performance Metrics
257
+
258
+ | Metric | Value |
259
+ |--------|-------|
260
+ | Startup Time | < 3 seconds |
261
+ | Task Concurrency | Default 2, configurable |
262
+ | Conversation History | 300 messages |
263
+ | Thinking Steps | 500 |
264
+ | Frontend Poll Interval | 1 second |
265
+ | Build Time | < 10 seconds |
266
+ | Desktop Memory | ~200MB |
267
+
268
+ ---
269
+
270
+ ## 9. Directory Structure
271
+
272
+ ```
273
+ feihong-code/
274
+ ├── src/ # Source code
275
+ │ ├── agent/ # Agent core
276
+ │ ├── cli/ # CLI
277
+ │ ├── models/ # Model abstraction
278
+ │ ├── runtime/ # Runtime
279
+ │ ├── shared/ # Shared utilities
280
+ │ └── web/ # Web service
281
+ ├── electron/ # Electron desktop
282
+ ├── funasr-server/ # Local speech recognition
283
+ ├── docs/ # Documentation
284
+ ├── dist/ # Build output
285
+ ├── package.json
286
+ ├── tool-schema.json
287
+ └── README.md
288
+ ```
289
+
290
+ ---
291
+
292
+ *Feihongzhi Technology Enterprise Management Co., Ltd. · Feiyang Qiyuan R&D Center*
@@ -0,0 +1,292 @@
1
+ # 飞虹 Code v7.0.0 技术说明书
2
+
3
+ **版本**:7.0.0
4
+ **日期**:2026年8月24日
5
+ **研发团队**:晋江市飞虹智科技企业管理有限公司 · 飞扬企源研发中心
6
+
7
+ ---
8
+
9
+ ## 1. 产品概述
10
+
11
+ 飞虹 Code(feihong-code)是一款终端 AI 编程智能体,对标 Muse Code / Cursor CLI,支持多模型路由、企业级 RBAC 审计、全自动 SWE Agent,支持离线私有化部署。
12
+
13
+ ### 1.1 核心能力
14
+
15
+ - 自然语言到代码变更:将用户需求转化为真实、可验证的代码仓库变更
16
+ - 多模型路由:支持 DeepSeek、通义千问、Ollama、OpenAI 等多种模型
17
+ - 全自动 SWE Agent:自主规划、执行、验证、修复
18
+ - 企业级安全:RBAC 权限、审计日志、工作区隔离
19
+ - 全平台支持:Web 控制台、Electron 桌面版、CLI 命令行
20
+
21
+ ### 1.2 技术栈
22
+
23
+ | 层级 | 技术 | 版本 |
24
+ |------|------|------|
25
+ | 运行时 | Node.js | 18+ |
26
+ | 语言 | TypeScript | 5.x |
27
+ | Web 框架 | Express | 4.x |
28
+ | 数据校验 | Zod | 3.x |
29
+ | 前端 | 原生 HTML/CSS/JS | - |
30
+ | 桌面端 | Electron | 41.x |
31
+ | 打包 | electron-builder | 26.x |
32
+ | 构建 | tsc | 5.x |
33
+
34
+ ---
35
+
36
+ ## 2. 系统架构
37
+
38
+ ### 2.1 整体架构
39
+
40
+ ```
41
+ ┌─────────────────────────────────────────────────┐
42
+ │ 用户界面层 │
43
+ │ ┌──────────┐ ┌──────────┐ ┌──────────────┐ │
44
+ │ │ Web 控制台 │ │ 桌面版 │ │ CLI 命令行 │ │
45
+ │ └────┬─────┘ └────┬─────┘ └──────┬───────┘ │
46
+ └───────┼─────────────┼───────────────┼──────────┘
47
+ │ │ │
48
+ └─────────────┼───────────────┘
49
+
50
+ ┌───────▼───────┐
51
+ │ Express API │
52
+ │ 服务层 │
53
+ └───────┬───────┘
54
+
55
+ ┌─────────────┼─────────────┐
56
+ │ │ │
57
+ ┌─────▼─────┐ ┌─────▼─────┐ ┌─────▼─────┐
58
+ │ 任务队列 │ │ 模型路由 │ │ 权限审计 │
59
+ │ TaskQueue │ │ Router │ │ Security │
60
+ └─────┬─────┘ └─────┬─────┘ └───────────┘
61
+ │ │
62
+ ┌─────▼─────────────▼─────┐
63
+ │ SWE Agent 编排层 │
64
+ │ Orchestrator │
65
+ └─────┬───────────────────┘
66
+
67
+ ┌─────▼───────────────────┐
68
+ │ 工具执行层 │
69
+ │ 文件操作 / Shell / 浏览器│
70
+ └─────────────────────────┘
71
+ ```
72
+
73
+ ### 2.2 核心模块
74
+
75
+ #### 2.2.1 Agent 编排层(src/agent/)
76
+
77
+ - **orchestrator.ts**:核心编排器,管理对话循环、工具调用、错误恢复
78
+ - **prompts.ts**:系统提示词,定义 AI 行为边界和能力要求
79
+ - **self-heal.ts**:自我修复模块,错误分类、修复建议生成
80
+ - **code-writer.ts**:代码生成模块
81
+ - **swe-agent.ts**:SWE Agent 实现
82
+ - **experience.ts**:经验检索与复用
83
+
84
+ #### 2.2.2 Web 服务层(src/web/)
85
+
86
+ - **server.ts**:Express 服务,API 路由、静态文件服务
87
+ - **task-queue.ts**:任务队列,并发控制、任务持久化、状态管理
88
+ - **public/**:前端静态资源(HTML/CSS/JS)
89
+
90
+ #### 2.2.3 CLI 层(src/cli/)
91
+
92
+ - **index.ts**:CLI 入口,命令解析
93
+ - **commands.ts**:命令实现(serve/run/init 等)
94
+ - **version.ts**:版本号集中定义
95
+ - **repl.ts**:交互式 REPL
96
+
97
+ #### 2.2.4 桌面端(electron/)
98
+
99
+ - **main.js**:Electron 主进程,窗口管理、服务器启动、IPC 通信
100
+ - **preload.js**:预加载脚本,安全暴露 API 给渲染进程
101
+
102
+ #### 2.2.5 本地语音识别(funasr-server/)
103
+
104
+ - **app.py**:FastAPI 服务,基于 faster-whisper
105
+ - **requirements.txt**:Python 依赖
106
+ - **启动语音识别服务.bat**:Windows 一键启动
107
+
108
+ ---
109
+
110
+ ## 3. 核心机制
111
+
112
+ ### 3.1 任务执行流程
113
+
114
+ 1. **任务提交**:用户通过 Web/桌面/CLI 提交任务
115
+ 2. **任务入队**:TaskQueue 接收任务,设置状态为 queued
116
+ 3. **任务执行**:并发控制下取出任务,调用 Orchestrator
117
+ 4. **编排循环**:Orchestrator 管理模型调用、工具执行、结果验证
118
+ 5. **错误恢复**:连续错误触发 self-heal,生成修复建议并重试
119
+ 6. **任务完成**:结果持久化,触发 webhook/通知
120
+
121
+ ### 3.2 对话流渲染机制
122
+
123
+ - **conversation**:完整对话历史,上限 300 条
124
+ - **steps**:思维链路步骤,上限 500 条
125
+ - **实时轮询**:前端每 1 秒轮询任务状态
126
+ - **纯文本输出**:前端 stripMarkdown 硬防线,剥离所有格式符号
127
+ - **思考过程展示**:从 steps 中提取 model.response 内容实时显示
128
+
129
+ ### 3.3 自我修复机制
130
+
131
+ - **错误分类**:compile-error / runtime-error / build-error / timeout 等 11 类
132
+ - **连续错误检测**:遍历所有连续错误消息分类记录
133
+ - **修复建议生成**:基于错误类型生成具体排查步骤
134
+ - **最大重试次数**:默认 3 次,可配置
135
+ - **结构化报告**:错误类型 + 最后错误 + 修复建议 + 下一步操作
136
+
137
+ ### 3.4 权限与安全
138
+
139
+ - **RBAC 权限**:读范围、写权限、Shell 权限、网络权限、浏览器权限
140
+ - **工作区隔离**:文件操作限制在工作区范围内
141
+ - **审计日志**:所有操作记录到 event-log
142
+ - **安全审批**:危险操作需要用户确认
143
+
144
+ ---
145
+
146
+ ## 4. API 接口
147
+
148
+ ### 4.1 核心 API
149
+
150
+ | 方法 | 路径 | 说明 |
151
+ |------|------|------|
152
+ | GET | /api/health | 健康检查 |
153
+ | POST | /api/auth/login | 登录 |
154
+ | GET | /api/tasks | 任务列表 |
155
+ | POST | /api/tasks | 创建任务 |
156
+ | GET | /api/tasks/:id | 任务详情 |
157
+ | POST | /api/tasks/:id/cancel | 取消任务 |
158
+ | DELETE | /api/tasks/:id | 删除任务 |
159
+ | POST | /api/tasks/:id/continue | 继续任务 |
160
+ | GET | /api/models | 可用模型列表 |
161
+ | POST | /api/computer/screenshot | 电脑截图 |
162
+ | POST | /api/computer/mouse/move | 鼠标移动 |
163
+ | POST | /api/computer/mouse/click | 鼠标点击 |
164
+ | POST | /api/computer/keyboard/type | 键盘输入 |
165
+ | POST | /api/computer/keyboard/press | 按键 |
166
+
167
+ ### 4.2 本地语音识别 API
168
+
169
+ | 方法 | 路径 | 说明 |
170
+ |------|------|------|
171
+ | GET | /health | 健康检查 |
172
+ | POST | /api/recognize | 语音识别(文件上传) |
173
+ | POST | /api/recognize-bytes | 语音识别(字节流) |
174
+
175
+ ---
176
+
177
+ ## 5. 部署方式
178
+
179
+ ### 5.1 npm 全局安装
180
+
181
+ ```bash
182
+ npm install -g feihong-code
183
+ fhcode serve
184
+ ```
185
+
186
+ ### 5.2 源码部署
187
+
188
+ ```bash
189
+ git clone https://github.com/wch887292/feihong-code.git
190
+ cd feihong-code
191
+ npm install
192
+ npm run build
193
+ node dist/cli/index.js serve
194
+ ```
195
+
196
+ ### 5.3 桌面版
197
+
198
+ ```bash
199
+ # 一键启动
200
+ 双击 一键启动桌面版.bat
201
+
202
+ # 或手动
203
+ npm run build
204
+ npm run electron
205
+ ```
206
+
207
+ ### 5.4 本地语音识别服务
208
+
209
+ ```bash
210
+ cd funasr-server
211
+ 双击 启动语音识别服务.bat
212
+ # 服务地址:http://localhost:8082
213
+ ```
214
+
215
+ ---
216
+
217
+ ## 6. 配置说明
218
+
219
+ ### 6.1 环境变量
220
+
221
+ | 变量 | 说明 | 默认值 |
222
+ |------|------|--------|
223
+ | FH_WEB_PORT | Web 服务端口 | 8080 |
224
+ | FH_WEB_TOKEN | 访问令牌 | 自动生成 |
225
+ | FH_HOME | 数据目录 | ~/.feihong-code |
226
+ | FH_TASK_CONCURRENCY | 任务并发数 | 2 |
227
+ | FH_TASK_PERSIST_DIR | 任务持久化目录 | FH_HOME/tasks |
228
+ | FH_TASK_WEBHOOK_URL | 任务 Webhook | - |
229
+
230
+ ### 6.2 模型配置
231
+
232
+ 支持多模型路由,可在 Web 控制台配置:
233
+ - DeepSeek(deepseek-chat / deepseek-coder)
234
+ - 通义千问(qwen-turbo / qwen-max)
235
+ - Ollama(本地模型)
236
+ - OpenAI 兼容接口
237
+
238
+ ---
239
+
240
+ ## 7. 扩展开发
241
+
242
+ ### 7.1 新增工具
243
+
244
+ 在 `src/agent/tools/` 下新增工具定义,遵循 Zod schema 规范。
245
+
246
+ ### 7.2 新增技能
247
+
248
+ 在工作区 `.feihong/skills/` 下创建技能目录,包含 SKILL.md 和脚本。
249
+
250
+ ### 7.3 插件系统
251
+
252
+ 模板库支持自定义来源,通过节点连接外部插件系统。
253
+
254
+ ---
255
+
256
+ ## 8. 性能指标
257
+
258
+ | 指标 | 数值 |
259
+ |------|------|
260
+ | 启动时间 | < 3 秒 |
261
+ | 任务并发 | 默认 2,可配置 |
262
+ | 对话历史 | 300 条 |
263
+ | 思维步骤 | 500 条 |
264
+ | 前端轮询间隔 | 1 秒 |
265
+ | 构建时间 | < 10 秒 |
266
+ | 桌面版内存 | ~200MB |
267
+
268
+ ---
269
+
270
+ ## 9. 目录结构
271
+
272
+ ```
273
+ feihong-code/
274
+ ├── src/ # 源码
275
+ │ ├── agent/ # Agent 核心
276
+ │ ├── cli/ # CLI 命令行
277
+ │ ├── models/ # 模型抽象
278
+ │ ├── runtime/ # 运行时
279
+ │ ├── shared/ # 共享工具
280
+ │ └── web/ # Web 服务
281
+ ├── electron/ # Electron 桌面端
282
+ ├── funasr-server/ # 本地语音识别服务
283
+ ├── docs/ # 文档
284
+ ├── dist/ # 构建输出
285
+ ├── package.json
286
+ ├── tool-schema.json
287
+ └── README.md
288
+ ```
289
+
290
+ ---
291
+
292
+ *晋江市飞虹智科技企业管理有限公司 · 飞扬企源研发中心*