feat(aia): Complete AIA V2.0 with universal streaming capabilities
Major Changes: - Add StreamingService with OpenAI Compatible format - Upgrade Chat component V2 with Ant Design X integration - Implement AIA module with 12 intelligent agents - Update API routes to unified /api/v1 prefix - Update system documentation Backend (~1300 lines): - common/streaming: OpenAI Compatible adapter - modules/aia: 12 agents, conversation service, streaming integration - Update route versions (RVW, PKB to v1) Frontend (~3500 lines): - modules/aia: AgentHub + ChatWorkspace (100% prototype restoration) - shared/Chat: AIStreamChat, ThinkingBlock, useAIStream Hook - Update API endpoints to v1 Documentation: - AIA module status guide - Universal capabilities catalog - System overview updates - All module documentation sync Tested: Stream response verified, authentication working Status: AIA V2.0 core completed (85%)
This commit is contained in:
@@ -2,47 +2,47 @@
|
||||
|
||||
## 馃搶 鑳屾櫙
|
||||
|
||||
在任务19(后端代码分层)执行过程中,由于 PowerShell 批量操作导致了中文编码问题,引发了多个文件的字符串未闭合、注释代码合并等严重错误,导致服务器无法启动。
|
||||
鍦ㄤ换鍔?9锛堝悗绔<E68297>唬鐮佸垎灞傦級鎵ц<E98EB5>杩囩▼涓<E296BC>紝鐢变簬 PowerShell 鎵归噺鎿嶄綔瀵艰嚧浜嗕腑鏂囩紪鐮侀棶棰橈紝寮曞彂浜嗗<E6B59C>涓<EFBFBD>枃浠剁殑瀛楃<E7809B>涓叉湭闂<E6B9AD>悎銆佹敞閲婁唬鐮佸悎骞剁瓑涓ラ噸閿欒<E996BF>锛屽<E9949B>鑷存湇鍔″櫒鏃犳硶鍚<E7A1B6>姩銆?
|
||||
|
||||
## 🔍 乱码产生的根本原因
|
||||
## 馃攳 涔辩爜浜х敓鐨勬牴鏈<E789B4>師鍥?
|
||||
|
||||
### 1. PowerShell 批量操作的陷阱
|
||||
### 1. PowerShell 鎵归噺鎿嶄綔鐨勯櫡闃?
|
||||
|
||||
```powershell
|
||||
# ❌ 错误示例(会导致乱码)
|
||||
# 鉂?閿欒<E996BF>绀轰緥锛堜細瀵艰嚧涔辩爜锛?
|
||||
Get-Content file.ts -Raw -Encoding UTF8 |
|
||||
Set-Content file.ts -NoNewline -Encoding UTF8
|
||||
```
|
||||
|
||||
**问题:**
|
||||
**闂<EFBFBD><EFBFBD>锛?*
|
||||
- `-NoNewline` 浼氬<E6B5BC>鑷磋<E991B7>鍚堝苟
|
||||
- Windows PowerShell 的 UTF-8 处理不完善
|
||||
- 可能引入或移除 BOM (Byte Order Mark)
|
||||
- Windows PowerShell 鐨?UTF-8 澶勭悊涓嶅畬鍠?
|
||||
- 鍙<EFBFBD>兘寮曞叆鎴栫Щ闄?BOM (Byte Order Mark)
|
||||
|
||||
### 2. 编码不一致
|
||||
### 2. 缂栫爜涓嶄竴鑷?
|
||||
|
||||
- UTF-8 with BOM vs UTF-8 without BOM
|
||||
- Windows (CRLF) vs Unix (LF) 行尾符
|
||||
- Windows (CRLF) vs Unix (LF) 琛屽熬绗?
|
||||
- 涓嶅悓缂栬緫鍣ㄧ殑榛樿<E6A69B>缂栫爜璁剧疆
|
||||
|
||||
## ✅ 解决方案
|
||||
## 鉁?瑙e喅鏂规<E98F82>
|
||||
|
||||
### 方案一:项目配置文件
|
||||
### 鏂规<EFBFBD>涓€锛氶」鐩<EFBFBD>厤缃<EFBFBD>枃浠?
|
||||
|
||||
#### 1. `.editorconfig`(已创建)
|
||||
#### 1. `.editorconfig`锛堝凡鍒涘缓锛?
|
||||
|
||||
确保所有编辑器统一使用:
|
||||
纭<EFBFBD>繚鎵€鏈夌紪杈戝櫒缁熶竴浣跨敤锛?
|
||||
- 缂栫爜锛歎TF-8 without BOM
|
||||
- 琛屽熬绗︼細LF
|
||||
- 缩进:2空格
|
||||
- 缂╄繘锛?绌烘牸
|
||||
|
||||
#### 2. `.gitattributes`(已创建)
|
||||
#### 2. `.gitattributes`锛堝凡鍒涘缓锛?
|
||||
|
||||
防止 Git 自动转换行尾符导致的问题。
|
||||
闃叉<EFBFBD> Git 鑷<EFBFBD>姩杞<EFBFBD>崲琛屽熬绗﹀<EFBFBD>鑷寸殑闂<EFBFBD><EFBFBD>銆?
|
||||
|
||||
### 方案二:VSCode 工作区设置
|
||||
### 鏂规<EFBFBD>浜岋細VSCode 宸ヤ綔鍖鸿<EFBFBD>缃?
|
||||
|
||||
在项目根目录创建 `.vscode/settings.json`:
|
||||
鍦ㄩ」鐩<EFBFBD>牴鐩<EFBFBD>綍鍒涘缓 `.vscode/settings.json`锛?
|
||||
|
||||
```json
|
||||
{
|
||||
@@ -56,23 +56,23 @@ Get-Content file.ts -Raw -Encoding UTF8 |
|
||||
|
||||
### 鏂规<E98F82>涓夛細鍥㈤槦瑙勮寖
|
||||
|
||||
#### 强制规则:
|
||||
#### 寮哄埗瑙勫垯锛?
|
||||
|
||||
1. **绂佹<E7BB82>浣跨敤 PowerShell 鎵归噺淇<E599BA>敼浠g爜鏂囦欢**
|
||||
- 鏀圭敤 Node.js 鑴氭湰
|
||||
- 使用 IDE 的重构功能
|
||||
- 浣跨敤 IDE 鐨勯噸鏋勫姛鑳?
|
||||
|
||||
2. **鎵€鏈変唬鐮佹枃浠跺繀椤伙細**
|
||||
- UTF-8 without BOM
|
||||
- LF 行尾符
|
||||
- 文件末尾有空行
|
||||
- LF 琛屽熬绗?
|
||||
- 鏂囦欢鏈<EFBFBD>熬鏈夌┖琛?
|
||||
|
||||
3. **鎵归噺鎿嶄綔鍓嶅繀椤伙細**
|
||||
- Git 提交当前状态
|
||||
- 在独立分支操作
|
||||
- 逐步验证,而非一次性全部修改
|
||||
- Git 鎻愪氦褰撳墠鐘舵€?
|
||||
- 鍦ㄧ嫭绔嬪垎鏀<EFBFBD>搷浣?
|
||||
- 閫愭<EFBFBD>楠岃瘉锛岃€岄潪涓€娆℃€у叏閮ㄤ慨鏀?
|
||||
|
||||
## 🛠️ 安全的批量修改方案
|
||||
## 馃洜锔?瀹夊叏鐨勬壒閲忎慨鏀规柟妗?
|
||||
|
||||
### 浣跨敤 Node.js 鑴氭湰锛堟帹鑽愶級
|
||||
|
||||
@@ -85,7 +85,7 @@ function safeReplace(filePath, searchValue, replaceValue) {
|
||||
// 浣跨敤 UTF-8 璇诲彇
|
||||
let content = fs.readFileSync(filePath, 'utf8');
|
||||
|
||||
// 确认需要修改
|
||||
// 纭<EFBFBD><EFBFBD>闇€瑕佷慨鏀?
|
||||
if (!content.includes(searchValue)) {
|
||||
return false;
|
||||
}
|
||||
@@ -96,19 +96,19 @@ function safeReplace(filePath, searchValue, replaceValue) {
|
||||
replaceValue
|
||||
);
|
||||
|
||||
// 写回(保持原有行尾符)
|
||||
// 鍐欏洖锛堜繚鎸佸師鏈夎<EFBFBD>灏剧<EFBFBD>锛?
|
||||
fs.writeFileSync(filePath, newContent, 'utf8');
|
||||
|
||||
console.log(`✅ 修改成功: ${path.basename(filePath)}`);
|
||||
console.log(`鉁?淇<>敼鎴愬姛: ${path.basename(filePath)}`);
|
||||
return true;
|
||||
} catch (error) {
|
||||
console.error(`❌ 修改失败: ${filePath}`, error.message);
|
||||
console.error(`鉂?淇<>敼澶辫触: ${filePath}`, error.message);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 使用 TypeScript 编辑器 API(最安全)
|
||||
### 浣跨敤 TypeScript 缂栬緫鍣?API锛堟渶瀹夊叏锛?
|
||||
|
||||
```typescript
|
||||
// 浣跨敤 ts-morph 搴撹繘琛屽畨鍏ㄧ殑浠g爜閲嶆瀯
|
||||
@@ -150,29 +150,29 @@ git restore . # 或从手动备份恢复
|
||||
|
||||
### 4. 楠岃瘉
|
||||
```bash
|
||||
# 编译检查
|
||||
# 缂栬瘧妫€鏌?
|
||||
npm run build
|
||||
|
||||
# 鍚<>姩娴嬭瘯
|
||||
npm run dev
|
||||
```
|
||||
|
||||
## 📝 检查清单
|
||||
## 馃摑 妫€鏌ユ竻鍗?
|
||||
|
||||
鍦ㄦ彁浜や唬鐮佸墠锛岀‘淇濓細
|
||||
|
||||
- [ ] 所有 `.ts` 文件编码为 UTF-8
|
||||
- [ ] 鎵€鏈?`.ts` 鏂囦欢缂栫爜涓?UTF-8
|
||||
- [ ] 娌℃湁 BOM 鏍囪<E98F8D>
|
||||
- [ ] 使用 LF 行尾符
|
||||
- [ ] 没有乱码字符(<EFBFBD>)
|
||||
- [ ] 浣跨敤 LF 琛屽熬绗?
|
||||
- [ ] 娌℃湁涔辩爜瀛楃<EFBFBD>锛堬拷锛?
|
||||
- [ ] 瀛楃<E7809B>涓查兘姝g‘闂<E28098>悎
|
||||
- [ ] 娉ㄩ噴娌℃湁鍜屼唬鐮佽<E990AE>鍚堝苟
|
||||
- [ ] 编译通过(`npm run build`)
|
||||
- [ ] 服务器可以启动(`npm run dev`)
|
||||
- [ ] 缂栬瘧閫氳繃锛坄npm run build`锛?
|
||||
- [ ] 鏈嶅姟鍣ㄥ彲浠ュ惎鍔<EFBFBD>紙`npm run dev`锛?
|
||||
|
||||
## 馃敡 瀹炵敤宸ュ叿鍛戒护
|
||||
|
||||
### 检测文件编码
|
||||
### 妫€娴嬫枃浠剁紪鐮?
|
||||
```bash
|
||||
file -bi <filename> # Linux/Mac
|
||||
```
|
||||
@@ -182,11 +182,11 @@ file -bi <filename> # Linux/Mac
|
||||
iconv -f GBK -t UTF-8 file.txt > file_utf8.txt
|
||||
```
|
||||
|
||||
### 检查 BOM
|
||||
### 妫€鏌?BOM
|
||||
```bash
|
||||
# Linux/Mac
|
||||
head -c 3 file.txt | od -A n -t x1
|
||||
# 如果输出 ef bb bf,则有 BOM
|
||||
# 濡傛灉杈撳嚭 ef bb bf锛屽垯鏈?BOM
|
||||
```
|
||||
|
||||
### 绉婚櫎 BOM
|
||||
@@ -197,16 +197,16 @@ sed -i '1s/^\xEF\xBB\xBF//' file.txt
|
||||
|
||||
## 馃挕 缁忛獙鏁欒<E98F81>
|
||||
|
||||
1. **架构优先,工具其次**
|
||||
- 正确的架构设计可以减少批量修改的需求
|
||||
1. **鏋舵瀯浼樺厛锛屽伐鍏峰叾娆?*
|
||||
- 姝g‘鐨勬灦鏋勮<EFBFBD>璁″彲浠ュ噺灏戞壒閲忎慨鏀圭殑闇€姹?
|
||||
|
||||
2. **小步快跑,频繁验证**
|
||||
- 每修改一个文件就测试一次
|
||||
- 不要一次性修改所有文件
|
||||
2. **灏忔<EFBFBD>蹇<EFBFBD>窇锛岄<EFBFBD>绻侀獙璇?*
|
||||
- 姣忎慨鏀逛竴涓<EFBFBD>枃浠跺氨娴嬭瘯涓€娆?
|
||||
- 涓嶈<EFBFBD>涓€娆℃€т慨鏀规墍鏈夋枃浠?
|
||||
|
||||
3. **自动化测试是最后防线**
|
||||
- 编译检查
|
||||
- Linter 检查
|
||||
3. **鑷<EFBFBD>姩鍖栨祴璇曟槸鏈€鍚庨槻绾?*
|
||||
- 缂栬瘧妫€鏌?
|
||||
- Linter 妫€鏌?
|
||||
- 鍗曞厓娴嬭瘯
|
||||
|
||||
4. **澶囦唤鏄<E594A4>畨鍏ㄧ殑淇濋殰**
|
||||
@@ -214,7 +214,7 @@ sed -i '1s/^\xEF\xBB\xBF//' file.txt
|
||||
- 鎵嬪姩澶囦唤鍏抽敭鐩<E695AD>綍
|
||||
- 浜戠<E6B59C>鍚屾<E98D9A>
|
||||
|
||||
## 📚 参考资料
|
||||
## 馃摎 鍙傝€冭祫鏂?
|
||||
|
||||
- [EditorConfig 瀹樻柟鏂囨。](https://editorconfig.org/)
|
||||
- [Git Attributes 鏂囨。](https://git-scm.com/docs/gitattributes)
|
||||
@@ -223,10 +223,10 @@ sed -i '1s/^\xEF\xBB\xBF//' file.txt
|
||||
|
||||
---
|
||||
|
||||
**文档版本:** 1.0
|
||||
**创建日期:** 2025-11-14
|
||||
**鏂囨。鐗堟湰锛?* 1.0
|
||||
**鍒涘缓鏃ユ湡锛?* 2025-11-14
|
||||
**鏈€鍚庢洿鏂帮細** 2025-11-14
|
||||
**维护人员:** AI Assistant
|
||||
**缁存姢浜哄憳锛?* AI Assistant
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user