feihong-code 7.0.0 → 7.5.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.
Files changed (149) hide show
  1. package/.github/workflows/ci.yml +180 -140
  2. package/.github/workflows/release.yml +200 -0
  3. package/CHANGELOG.md +94 -65
  4. package/README.md +609 -586
  5. package/dist/agent/browser-agent.js +354 -0
  6. package/dist/agent/browser-agent.js.map +1 -0
  7. package/dist/agent/change-manager.js +433 -0
  8. package/dist/agent/change-manager.js.map +1 -0
  9. package/dist/agent/code-rag.js +293 -0
  10. package/dist/agent/code-rag.js.map +1 -0
  11. package/dist/agent/code-writer.js +13 -1
  12. package/dist/agent/code-writer.js.map +1 -1
  13. package/dist/agent/completion-engine.js +553 -0
  14. package/dist/agent/completion-engine.js.map +1 -0
  15. package/dist/agent/completion-postprocess.js +109 -0
  16. package/dist/agent/completion-postprocess.js.map +1 -0
  17. package/dist/agent/context-budget.js +121 -0
  18. package/dist/agent/context-budget.js.map +1 -0
  19. package/dist/agent/context-compactor.js +235 -10
  20. package/dist/agent/context-compactor.js.map +1 -1
  21. package/dist/agent/custom-agent.js +368 -0
  22. package/dist/agent/custom-agent.js.map +1 -0
  23. package/dist/agent/design-to-code.js +218 -0
  24. package/dist/agent/design-to-code.js.map +1 -0
  25. package/dist/agent/event-driven-agent.js +359 -0
  26. package/dist/agent/event-driven-agent.js.map +1 -0
  27. package/dist/agent/git-integration.js +324 -0
  28. package/dist/agent/git-integration.js.map +1 -0
  29. package/dist/agent/layered-memory.js +329 -0
  30. package/dist/agent/layered-memory.js.map +1 -0
  31. package/dist/agent/lint.js +121 -0
  32. package/dist/agent/lint.js.map +1 -0
  33. package/dist/agent/multi-agent.js +359 -0
  34. package/dist/agent/multi-agent.js.map +1 -0
  35. package/dist/agent/orchestrator.js +136 -25
  36. package/dist/agent/orchestrator.js.map +1 -1
  37. package/dist/agent/prompts.js +54 -54
  38. package/dist/agent/quality-gate.js +139 -0
  39. package/dist/agent/quality-gate.js.map +1 -1
  40. package/dist/agent/self-correction.js +274 -0
  41. package/dist/agent/self-correction.js.map +1 -0
  42. package/dist/agent/self-heal.js +47 -17
  43. package/dist/agent/self-heal.js.map +1 -1
  44. package/dist/agent/solo-agent.js +321 -0
  45. package/dist/agent/solo-agent.js.map +1 -0
  46. package/dist/agent/symbol-index.js +258 -28
  47. package/dist/agent/symbol-index.js.map +1 -1
  48. package/dist/agent/team-collaboration.js +252 -0
  49. package/dist/agent/team-collaboration.js.map +1 -0
  50. package/dist/agent/type-checker.js +229 -0
  51. package/dist/agent/type-checker.js.map +1 -0
  52. package/dist/cli/commands.js +9 -0
  53. package/dist/cli/commands.js.map +1 -1
  54. package/dist/cli/index.js +9 -0
  55. package/dist/cli/index.js.map +1 -1
  56. package/dist/cli/multi-pane-tui.js +217 -0
  57. package/dist/cli/multi-pane-tui.js.map +1 -0
  58. package/dist/cli/run.js +130 -40
  59. package/dist/cli/run.js.map +1 -1
  60. package/dist/cli/tui-run.js +79 -0
  61. package/dist/cli/tui-run.js.map +1 -0
  62. package/dist/cli/tui.js.map +1 -1
  63. package/dist/cli/version.js +1 -1
  64. package/dist/integrations/collaboration.js +219 -0
  65. package/dist/integrations/collaboration.js.map +1 -0
  66. package/dist/integrations/figma.js +307 -0
  67. package/dist/integrations/figma.js.map +1 -0
  68. package/dist/integrations/sso.js +327 -0
  69. package/dist/integrations/sso.js.map +1 -0
  70. package/dist/knowledge/library.js +301 -0
  71. package/dist/knowledge/library.js.map +1 -0
  72. package/dist/lsp/lsp-client.js +183 -0
  73. package/dist/lsp/lsp-client.js.map +1 -0
  74. package/dist/lsp/lsp-service.js +159 -0
  75. package/dist/lsp/lsp-service.js.map +1 -0
  76. package/dist/plugins/manager.js +380 -0
  77. package/dist/plugins/manager.js.map +1 -0
  78. package/dist/runtime/event-log.js.map +1 -1
  79. package/dist/shared/i18n.js +108 -100
  80. package/dist/shared/i18n.js.map +1 -1
  81. package/dist/tools/browser/browser.tool.js +217 -0
  82. package/dist/tools/browser/browser.tool.js.map +1 -0
  83. package/dist/tools/generator/code-generator.js +40 -40
  84. package/dist/tools/generator/test-generator.js +9 -9
  85. package/dist/tools/index.js +2 -0
  86. package/dist/tools/index.js.map +1 -1
  87. package/dist/tools/shell/exec.js +73 -11
  88. package/dist/tools/shell/exec.js.map +1 -1
  89. package/dist/tools/shell/run-shell.tool.js +8 -2
  90. package/dist/tools/shell/run-shell.tool.js.map +1 -1
  91. package/dist/training/completion-evaluator.js +213 -0
  92. package/dist/training/completion-evaluator.js.map +1 -0
  93. package/dist/training/fim-data.js +248 -0
  94. package/dist/training/fim-data.js.map +1 -0
  95. package/dist/voice/voice-programming.js +223 -0
  96. package/dist/voice/voice-programming.js.map +1 -0
  97. package/dist/web/extra-apis.js +440 -0
  98. package/dist/web/extra-apis.js.map +1 -0
  99. package/dist/web/public/css/style.css +1729 -1671
  100. package/dist/web/public/index.html +1242 -990
  101. package/dist/web/public/js/api.js +555 -382
  102. package/dist/web/public/js/app.js +2210 -2210
  103. package/dist/web/public/js/mock-api.js +234 -0
  104. package/dist/web/public/js/monaco-editor.js +363 -0
  105. package/dist/web/public/js/ui.js +2251 -1059
  106. package/dist/web/public/js/utils.js +214 -214
  107. package/dist/web/public/manifest.json +59 -0
  108. package/dist/web/public/service-worker.js +173 -0
  109. package/dist/web/server.js +1116 -45
  110. package/dist/web/server.js.map +1 -1
  111. package/dist/web/task-queue.js +22 -2
  112. package/dist/web/task-queue.js.map +1 -1
  113. package/docs/BENCHMARK_REPORT_en.md +386 -329
  114. package/docs/BENCHMARK_REPORT_zh.md +386 -329
  115. package/docs/DPA.md +63 -0
  116. package/docs/DPA/346/225/260/346/215/256/345/244/204/347/220/206/345/215/217/350/256/256/346/250/241/346/235/277_v1.0.md +67 -0
  117. package/docs/SECURITY_WHITEPAPER.md +74 -0
  118. package/docs/SWE_BENCH_REPORT.md +55 -0
  119. package/docs/TECHNICAL_SPEC_en.md +292 -292
  120. package/docs/TECHNICAL_SPEC_zh.md +292 -292
  121. package/docs/UPDATE_NOTES_en.md +159 -159
  122. package/docs/UPDATE_NOTES_zh.md +159 -159
  123. package/docs/UPGRADE_7.2.0.md +309 -0
  124. package/docs/UPGRADE_GUIDE_7_5.md +86 -0
  125. package/docs/geo-feihong-code.html +391 -0
  126. package/docs//345/205/250/351/235/242/345/244/215/347/233/230_50/350/275/256/346/267/261/345/272/246/345/256/241/350/256/241_v7.2.0.md +208 -0
  127. package/docs//345/205/250/351/235/242/345/244/215/347/233/230_6/351/241/271/351/207/215/347/202/271/346/240/270/346/237/245_v7.2.0.md +152 -0
  128. package/docs//345/205/250/351/235/242/345/244/215/347/233/230_/350/277/220/350/241/214/346/227/266/345/256/236/346/265/213/347/211/210_v7.2.0.md +271 -0
  129. package/docs//345/220/210/350/247/204/350/256/244/350/257/201/345/207/206/345/244/207/346/270/205/345/215/225_v7.2.0.md +59 -0
  130. package/docs//345/256/211/345/205/250/347/231/275/347/232/256/344/271/246_v7.2.0.md +82 -0
  131. package/electron/main.js +404 -404
  132. package/package.json +175 -167
  133. package/templates/skills/api-design/SKILL.md +27 -0
  134. package/templates/skills/code-review/SKILL.md +35 -0
  135. package/templates/skills/dependency-upgrade/SKILL.md +29 -0
  136. package/templates/skills/doc-gen/SKILL.md +29 -0
  137. package/templates/skills/git-flow/SKILL.md +26 -0
  138. package/templates/skills/onboarding/SKILL.md +27 -0
  139. package/templates/skills/performance/SKILL.md +29 -0
  140. package/templates/skills/refactor/SKILL.md +28 -0
  141. package/templates/skills/security-audit/SKILL.md +28 -0
  142. package/templates/skills/test-gen/SKILL.md +30 -0
  143. package/tool-schema.json +197 -197
  144. package/dist/hello.js +0 -14
  145. package/dist/hello.js.map +0 -1
  146. package/dist/self-evolve/hook.ts +0 -80
  147. package/dist/self-evolve/manager.d.ts +0 -8
  148. package/dist/web/web-config.js +0 -143
  149. package/dist/web/web-config.js.map +0 -1
@@ -1,292 +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*
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*