add-coder 0.1.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.
- package/README.md +50 -0
- package/bin/add-coder.js +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +576 -0
- package/package.json +64 -0
- package/templates/adapters/claude/hooks/doc-format-guard.sh +17 -0
- package/templates/adapters/claude/hooks/notification.sh +9 -0
- package/templates/adapters/claude/hooks/permission-gate.sh +18 -0
- package/templates/adapters/claude/hooks/post-tool-failure.sh +10 -0
- package/templates/adapters/claude/hooks/post-tool-use.sh +18 -0
- package/templates/adapters/claude/hooks/pre-compact.sh +14 -0
- package/templates/adapters/claude/hooks/pre-tool-use.sh +28 -0
- package/templates/adapters/claude/hooks/prompt-submit.sh +16 -0
- package/templates/adapters/claude/hooks/review-checklist.sh +10 -0
- package/templates/adapters/claude/hooks/session-start.sh +23 -0
- package/templates/adapters/claude/hooks/stop-check.sh +10 -0
- package/templates/adapters/claude/hooks/subagent-guard.sh +15 -0
- package/templates/adapters/claude/mcp.json +13 -0
- package/templates/adapters/claude/settings.json +125 -0
- package/templates/adapters/qoder/hooks/doc-format-guard.sh +164 -0
- package/templates/adapters/qoder/hooks/lib/context-inject.sh +96 -0
- package/templates/adapters/qoder/hooks/lib/state-detect.sh +104 -0
- package/templates/adapters/qoder/hooks/lib/vocabulary.sh +49 -0
- package/templates/adapters/qoder/hooks/notification.sh +22 -0
- package/templates/adapters/qoder/hooks/permission-gate.sh +8 -0
- package/templates/adapters/qoder/hooks/post-tool-failure.sh +8 -0
- package/templates/adapters/qoder/hooks/post-tool-use.sh +20 -0
- package/templates/adapters/qoder/hooks/pre-compact.sh +12 -0
- package/templates/adapters/qoder/hooks/pre-tool-use.sh +77 -0
- package/templates/adapters/qoder/hooks/prompt-submit.sh +72 -0
- package/templates/adapters/qoder/hooks/review-checklist.sh +157 -0
- package/templates/adapters/qoder/hooks/session-start.sh +16 -0
- package/templates/adapters/qoder/hooks/stop-check.sh +71 -0
- package/templates/adapters/qoder/hooks/subagent-guard.sh +11 -0
- package/templates/adapters/qoder/mcp.json +13 -0
- package/templates/adapters/qoder/settings.json +125 -0
- package/templates/adapters/qoder/sync-policy.json +18 -0
- package/templates/adapters/vscode/extensions.json +5 -0
- package/templates/adapters/vscode/launch.json +16 -0
- package/templates/adapters/vscode/settings.json +16 -0
- package/templates/adapters/vscode/tasks.json +38 -0
- package/templates/core/agents/add-flow-guardian.md +276 -0
- package/templates/core/agents/add-orchestrator.md +217 -0
- package/templates/core/plans/2026-07/08/farm-agent-add-coder-npm-package-add-route-v1.md +323 -0
- package/templates/core/plans/2026-07/08/farm-agent-add-coder-npm-package-handoff-v1.md +678 -0
- package/templates/core/plans/2026-07/08/farm-agent-add-coder-npm-package-plan-v1.md +785 -0
- package/templates/core/prisma/add.prisma +34 -0
- package/templates/core/reports/REPORT-WORKFLOW.md +250 -0
- package/templates/core/reports/boundary-runtime-report.md +134 -0
- package/templates/core/reports/code-review-combined-report.md +227 -0
- package/templates/core/reports/code-review-fix-verification-report.md +505 -0
- package/templates/core/reports/code-review-suggestions.md +66 -0
- package/templates/core/reports/index.md +57 -0
- package/templates/core/reports/runtime-report/gateway.md +741 -0
- package/templates/core/rules/project_rules.md +905 -0
- package/templates/core/rules/theory-practice-map.toml +105 -0
- package/templates/core/scripts/mcp-server.ts +3492 -0
- package/templates/core/skills/add-paradigm/SKILL.md +1086 -0
- package/templates/core/skills/session-init/SKILL.md +215 -0
- package/templates/core/specs/farm-agent-add-coder-npm-package/checklist.md +125 -0
- package/templates/core/specs/farm-agent-add-coder-npm-package/spec.md +343 -0
- package/templates/core/specs/farm-agent-add-coder-npm-package/tasks.md +203 -0
- package/templates/core/templates/01-/346/236/266/346/236/204//343/200/212ADD/345/274/200/345/217/221/345/267/245/344/275/234/350/267/257/345/276/204/344/270/216/346/226/207/346/241/243/345/215/217/345/220/214/350/247/204/350/214/203/343/200/213.md +386 -0
- package/templates/core/templates/TERMINOLOGY.md +81 -0
- package/templates/core/templates/add-route-template-heavyweight.md +288 -0
- package/templates/core/templates/add-route-template.md +242 -0
- package/templates/core/templates/add-route-template.schema.json +35 -0
- package/templates/core/templates/checklist-template.md +72 -0
- package/templates/core/templates/checklist-template.schema.json +20 -0
- package/templates/core/templates/fix-verification-template.md +132 -0
- package/templates/core/templates/fix-verification-template.schema.json +54 -0
- package/templates/core/templates/handoff-multi-round-template.md +295 -0
- package/templates/core/templates/handoff-multi-round.schema.json +48 -0
- package/templates/core/templates/handoff-single-round-template.md +145 -0
- package/templates/core/templates/handoff-single-round.schema.json +92 -0
- package/templates/core/templates/index.md +60 -0
- package/templates/core/templates/report-template.md +126 -0
- package/templates/core/templates/report-template.schema.json +69 -0
- package/templates/core/templates/review-implementation-template.md +66 -0
- package/templates/core/templates/review-implementation-template.schema.json +58 -0
- package/templates/core/templates/review-runtime-template.md +73 -0
- package/templates/core/templates/review-runtime-template.schema.json +47 -0
- package/templates/core/templates/review-template.md +37 -0
- package/templates/core/templates/review-template.schema.json +42 -0
- package/templates/core/templates/runtime-report-template.md +73 -0
- package/templates/core/templates/runtime-report-template.schema.json +48 -0
- package/templates/core/templates/simple-plan-template.md +166 -0
- package/templates/core/templates/simple-plan-template.schema.json +109 -0
- package/templates/core/templates/spec-template.md +22 -0
- package/templates/core/templates/spec-template.schema.json +41 -0
- package/templates/core/templates/standard-plan-template.md +96 -0
- package/templates/core/templates/standard-plan-template.schema.json +73 -0
- package/templates/core/templates/tasks-template.md +54 -0
- package/templates/core/templates/tasks-template.schema.json +43 -0
- package/templates/core/tools/README.md +361 -0
- package/templates/core/vocabulary/add-governance-vocabulary.md +370 -0
- package/templates/shared/hooks-lib/common.sh +22 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// add.prisma — ADD 治理模型(npm 包写入,不修改用户业务文件)
|
|
2
|
+
// 前置条件:用户项目必须已有 User 模型(id: String),否则 prisma migrate 失败
|
|
3
|
+
|
|
4
|
+
model DevOperation {
|
|
5
|
+
id String @id @default(cuid())
|
|
6
|
+
userId String
|
|
7
|
+
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
8
|
+
planKeyword String
|
|
9
|
+
action String
|
|
10
|
+
targetType String
|
|
11
|
+
targetId String
|
|
12
|
+
beforeState Json?
|
|
13
|
+
afterState Json?
|
|
14
|
+
reason String?
|
|
15
|
+
createdAt DateTime @default(now())
|
|
16
|
+
|
|
17
|
+
@@index([planKeyword])
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
model AuditLog {
|
|
21
|
+
id String @id @default(cuid())
|
|
22
|
+
userId String
|
|
23
|
+
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
24
|
+
action String
|
|
25
|
+
targetType String
|
|
26
|
+
targetId String
|
|
27
|
+
traceId String?
|
|
28
|
+
beforeState Json?
|
|
29
|
+
afterState Json?
|
|
30
|
+
reason String?
|
|
31
|
+
createdAt DateTime @default(now())
|
|
32
|
+
|
|
33
|
+
@@index([traceId])
|
|
34
|
+
}
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
# Report 工作流
|
|
2
|
+
|
|
3
|
+
> Reports 目录的生成、消费、归档规范。遵循 [Runtime Reports ↔ 静态 Reports 边界划分](./boundary-runtime-report.md)。
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 目录结构
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
.qoder/reports/
|
|
11
|
+
├── REPORT-WORKFLOW.md ← 本文件
|
|
12
|
+
├── boundary-runtime-report.md ← Runtime Report ↔ 静态 Report 边界划分
|
|
13
|
+
├── index.md ← Issue 注册表(由 gen-report-index.sh 每天自动生成,勿手动编辑)
|
|
14
|
+
├── combined-report.md ← 当前活跃的综合报告(模板: templates/report-template.md)
|
|
15
|
+
├── {{projectName}}-runtime-report/ ← 运行时报告目录(按子系统分类)
|
|
16
|
+
│ ├── gateway.md ← Gateway 边界合约断裂(appendRuntimeFinding 自动写入)
|
|
17
|
+
│ ├── rag.md ← RAG 检索异常(未来)
|
|
18
|
+
│ └── agent.md ← Agent Node 执行异常(未来)
|
|
19
|
+
├── runtime-issue-{id}.md ← Runtime Report 子系统自动生成的 Issue 草稿(人工 triage 后合并删除)
|
|
20
|
+
├── suggestions.md ← 临时审查建议(合并后删除,内容已归入 combined-report.md)
|
|
21
|
+
└── archive/ ← 历史报告归档
|
|
22
|
+
└── combined-report-{YYYY-MM-DD}.md
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Report 生命周期
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
┌─────────────────┐
|
|
31
|
+
│ 触发方式 │
|
|
32
|
+
└───────┬─────────┘
|
|
33
|
+
│
|
|
34
|
+
┌───────────────────┼───────────────────┐
|
|
35
|
+
▼ ▼ ▼
|
|
36
|
+
全量代码扫描 增量审查 运行时异常
|
|
37
|
+
(定期/按需) (合并前/发布前) (Runtime Report 子系统自动)
|
|
38
|
+
│ │ │
|
|
39
|
+
▼ ▼ ▼
|
|
40
|
+
新建 combined- 追加 Issue 生成 runtime-issue-{id}.md
|
|
41
|
+
report.md 到已有报告 (草稿,待人工 triage)
|
|
42
|
+
│ │ │
|
|
43
|
+
└───────────────────┼───────────────────┘
|
|
44
|
+
│
|
|
45
|
+
▼
|
|
46
|
+
┌───────────────┐
|
|
47
|
+
│ 人工 Triage │
|
|
48
|
+
│ (协同同事) │
|
|
49
|
+
└───────┬───────┘
|
|
50
|
+
│
|
|
51
|
+
┌───────────┼───────────┐
|
|
52
|
+
▼ ▼ ▼
|
|
53
|
+
确认为 Bug 环境问题 已知问题
|
|
54
|
+
│ │ │
|
|
55
|
+
▼ ▼ ▼
|
|
56
|
+
分配优先级 关闭草稿 合并到已有
|
|
57
|
+
补充根因 (标注原因) Issue
|
|
58
|
+
│
|
|
59
|
+
▼
|
|
60
|
+
┌───────────────┐
|
|
61
|
+
│ 进入 Plan 流程 │
|
|
62
|
+
│ (ADD 范式) │
|
|
63
|
+
└───────┬───────┘
|
|
64
|
+
│
|
|
65
|
+
▼
|
|
66
|
+
┌───────────────┐
|
|
67
|
+
│ 修复 + 验证 │
|
|
68
|
+
└───────┬───────┘
|
|
69
|
+
│
|
|
70
|
+
┌───────┴───────┐
|
|
71
|
+
▼ ▼
|
|
72
|
+
标记 ✅ Runtime Report 运行时验证
|
|
73
|
+
(人工确认) (自动: 请求路径跑通 → verified_at)
|
|
74
|
+
│ │
|
|
75
|
+
└───────┬───────┘
|
|
76
|
+
│
|
|
77
|
+
▼
|
|
78
|
+
┌───────────────┐
|
|
79
|
+
│ 归档 │
|
|
80
|
+
│ 阶段性完成后 │
|
|
81
|
+
│ 移动到 archive/│
|
|
82
|
+
└───────────────┘
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## 何时创建新 Report
|
|
88
|
+
|
|
89
|
+
| 场景 | 操作 | 说明 |
|
|
90
|
+
|------|------|------|
|
|
91
|
+
| 首次代码审查 | 新建 `combined-report.md` | 使用 [report-template.md](../templates/report-template.md) |
|
|
92
|
+
| 定期全量扫描 | 旧报告 → `archive/`,新建 | 同上 |
|
|
93
|
+
| 增量审查(合入前) | 追加 Issue 到已有报告 | 不新建,更新状态列 |
|
|
94
|
+
| Runtime Report 新异常 | 生成 `runtime-issue-{id}.md` | 草稿,等待 triage |
|
|
95
|
+
| 新建运行时报告子系统 | 新建 `{{projectName}}-runtime-report/{subsystem}.md` | 使用 [runtime-report-template.md](../templates/runtime-report-template.md) |
|
|
96
|
+
| 发布前验证 | 基于已有报告生成 `fix-verification-report.md` | 使用 [fix-verification-template.md](../templates/fix-verification-template.md) |
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## Issue 编号规范
|
|
101
|
+
|
|
102
|
+
```
|
|
103
|
+
RPT-{YYYYMMDD}-{seq}
|
|
104
|
+
│ │ │
|
|
105
|
+
│ │ └── 当日序号,从 01 开始
|
|
106
|
+
│ └─────────── 生成日期
|
|
107
|
+
└────────────────── 固定前缀 (Report)
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
示例:`RPT-20260701-03` = 2026年7月1日第3个 Issue
|
|
111
|
+
|
|
112
|
+
Runtime Report 草稿使用 `RUNTIME-{YYYYMMDD}-{seq}` 前缀,合并后改为 `RPT-` 前缀。
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## Triage → Plan 流程
|
|
117
|
+
|
|
118
|
+
> Runtime Report 草稿经人工 triage 后,转入 ADD 范式 Plan 管线。
|
|
119
|
+
|
|
120
|
+
```
|
|
121
|
+
runtime-issue-{date}-{seq}.md
|
|
122
|
+
│
|
|
123
|
+
▼ (人工 triage)
|
|
124
|
+
┌───┴───┐
|
|
125
|
+
▼ ▼
|
|
126
|
+
真实 Bug 环境/测试
|
|
127
|
+
│ │
|
|
128
|
+
│ └── 删除草稿,标注关闭原因
|
|
129
|
+
│
|
|
130
|
+
▼
|
|
131
|
+
创建 runtime-fix-plan-v1.md
|
|
132
|
+
│ 命名: {子系统}-runtime-fix-{关键词}-plan-v1.md
|
|
133
|
+
│ 位置: .qoder/plans/{YYYY-MM}/{DD}/
|
|
134
|
+
│ 模板: plan-template.md
|
|
135
|
+
│
|
|
136
|
+
▼
|
|
137
|
+
进入 ADD 范式(Step 0-9)
|
|
138
|
+
│
|
|
139
|
+
├── Step 0: 方案设计
|
|
140
|
+
├── Step 1-3: Spec + Checklist
|
|
141
|
+
├── Step 4-7: 实施
|
|
142
|
+
├── Step 8: 验收 → handoff + devlog
|
|
143
|
+
├── Step 9: Report Closure(runtime-fix plan)→ gateway.md 追 `- [x]`
|
|
144
|
+
│
|
|
145
|
+
▼
|
|
146
|
+
修复完成后 → combined-report.md 标记 ✅
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### Triage 判定标准
|
|
150
|
+
|
|
151
|
+
| 判定 | 条件 | 操作 |
|
|
152
|
+
|------|------|------|
|
|
153
|
+
| **Plan 修复** | 真实 Bug,影响生产或有复发风险 | 创建 runtime-fix-plan → ADD 范式 |
|
|
154
|
+
| **关闭** | 环境问题(已修复)、测试触发、不复现 | 删除 runtime-issue 草稿,gateway.md 中标注关闭原因 |
|
|
155
|
+
| **合并** | 与已有 Report Issue 重复 | 合并到已有 RPT-{id},删除草稿 |
|
|
156
|
+
|
|
157
|
+
### 草稿关闭标记
|
|
158
|
+
|
|
159
|
+
决定关闭的 runtime-issue 草稿,在 gateway.md 对应发现条目体末尾追加 checklist 标记(`check-boundary-report.ts` L58-60 通过解析 `- [x]` 行判断关闭状态):
|
|
160
|
+
|
|
161
|
+
```markdown
|
|
162
|
+
- [x] Triage 结果: 已关闭 — {原因}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
> **格式说明**:使用 `- [x]` checklist 格式而非 `**Triage 结果**` 粗体格式。
|
|
166
|
+
> 完整 handoff 集成流程见 [report-handoff-template](../templates/report-handoff-template.md)。
|
|
167
|
+
> runtime-fix plan 的 Step 9 Report Closure 负责统一关闭。
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
## 协作协议
|
|
172
|
+
|
|
173
|
+
### 单人工作
|
|
174
|
+
|
|
175
|
+
1. 新建 Report → 填充 Issue → 修代码 → 更新状态 → 归档
|
|
176
|
+
|
|
177
|
+
### 多人协同
|
|
178
|
+
|
|
179
|
+
1. **生成方**(扫描 / Runtime Report 子系统): 创建 Report 或 Issue 草稿
|
|
180
|
+
2. **Triage 方**(协同同事): 阅读草稿,确认/关闭,分配优先级
|
|
181
|
+
3. **修复方**(开发者): 按优先级修复,更新 Issue 状态
|
|
182
|
+
4. **验证方**(Runtime Report 子系统 / 人工): 运行时验证或 E2E 验证,写回结果
|
|
183
|
+
|
|
184
|
+
**冲突避免**:
|
|
185
|
+
- 同一 Report 不要两人同时编辑
|
|
186
|
+
- 用 Git 管理:`git pull` → 编辑 → `git commit` → `git push`
|
|
187
|
+
- 或者拆分为独立 Issue 文件(`issues/RPT-{id}.md`),避免合并冲突
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
## 运行时反馈流程(Runtime Report → Reports)
|
|
192
|
+
|
|
193
|
+
```
|
|
194
|
+
1. Runtime Report 子系统捕获异常
|
|
195
|
+
│
|
|
196
|
+
2. appendRuntimeFinding() 去重检查
|
|
197
|
+
├── 已记录 → count++ → 不生成新草稿
|
|
198
|
+
└── 新异常 → 生成 runtime-issue-{id}.md
|
|
199
|
+
│
|
|
200
|
+
3. 协同同事定期扫描 runtime-issue-*.md
|
|
201
|
+
│
|
|
202
|
+
4. Triage:
|
|
203
|
+
├── 真实 Bug → 分配 RPT-{id}, 转入 combined-report.md
|
|
204
|
+
├── 环境问题 → 标注原因, 删除草稿
|
|
205
|
+
└── 已知问题 → 合并到已有 Issue, 更新 count
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
---
|
|
209
|
+
|
|
210
|
+
## 验证反馈流程(Reports → Runtime Report)
|
|
211
|
+
|
|
212
|
+
```
|
|
213
|
+
1. combined-report.md 中 Issue 标记 ✅
|
|
214
|
+
│
|
|
215
|
+
2. 验证方在 {{projectName}}-runtime-report/gateway.md 中增加验证条目:
|
|
216
|
+
```
|
|
217
|
+
### 验证: RPT-{id}
|
|
218
|
+
- 修复版本: commit {hash}
|
|
219
|
+
- 验证路径: {method} {pathname}
|
|
220
|
+
- 预期: {期望行为}
|
|
221
|
+
```
|
|
222
|
+
│
|
|
223
|
+
3. Runtime Report 子系统下次请求经过该路径:
|
|
224
|
+
├── 成功 → {{projectName}}-runtime-report/gateway.md 追加 verified_at
|
|
225
|
+
└── 失败 → {{projectName}}-runtime-report/gateway.md 追加 regression_at → Issue 回退为 ❌
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
230
|
+
## 归档规则
|
|
231
|
+
|
|
232
|
+
| 条件 | 操作 |
|
|
233
|
+
|------|------|
|
|
234
|
+
| Report 中所有 Issue 标记 ✅ 或关闭 | 移动到 `archive/combined-report-{YYYY-MM-DD}.md` |
|
|
235
|
+
| 新 Report 生成时 | 旧 Report 移动到 `archive/` |
|
|
236
|
+
| 单次增量审查完成 | 不归档,持续追加到活跃 Report |
|
|
237
|
+
| runtime-issue 草稿已 triage | 合并后删除草稿 |
|
|
238
|
+
|
|
239
|
+
---
|
|
240
|
+
|
|
241
|
+
## 关联文档
|
|
242
|
+
|
|
243
|
+
| 文档 | 路径 | 用途 |
|
|
244
|
+
|------|------|------|
|
|
245
|
+
| 边界划分 | [boundary-runtime-report.md](./boundary-runtime-report.md) | Runtime Report ↔ 静态 Report 职责边界 |
|
|
246
|
+
| Report 模板 | [report-template.md](../templates/report-template.md) | 综合审查报告模板 |
|
|
247
|
+
| 运行时报告模板 | [runtime-report-template.md](../templates/runtime-report-template.md) | 子系统运行时报告模板 |
|
|
248
|
+
| 修复验证模板 | [fix-verification-template.md](../templates/fix-verification-template.md) | 修复验证对照报告模板 |
|
|
249
|
+
| 索引脚本 | [gen-report-index.sh](../../scripts/gen-report-index.sh) | 每日 2:10 AM 自动生成 index.md(cron: [crontab.report.txt](../../scripts/crontab.report.txt)) |
|
|
250
|
+
| Plan 索引 | [index.md](../plans/index.md) | Plan 索引(Issue → Plan 关联) |
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# Runtime Reports ↔ 静态 Reports 边界划分
|
|
2
|
+
|
|
3
|
+
> 定义 `{{projectName}}-runtime-report/`(运行时报告,按子系统分类写入)与 `reports/`(协同手工生成)的职责边界、数据流向和互操作协议。
|
|
4
|
+
>
|
|
5
|
+
> Runtime Report 包含多个业务域:gateway(边界合约断裂)、rag(检索异常)、agent(Node 执行)等。
|
|
6
|
+
> 本文以 **gateway 子系统** 为示例说明边界划分逻辑,规则适用于全部 Runtime Report 子系统。
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## 两条产线
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
┌─────────────────────────────────┐ ┌─────────────────────────────────┐
|
|
14
|
+
│ Runtime Report(gateway 示例) │ │ Reports 静态分析 │
|
|
15
|
+
│ ({{projectName}}-runtime-report/gateway.md) │ │ (reports/*.md) │
|
|
16
|
+
├─────────────────────────────────┤ ├─────────────────────────────────┤
|
|
17
|
+
│ 触发: 运行时异常 / 合约断裂 │ │ 触发: 代码扫描 / 人工 review │
|
|
18
|
+
│ 作者: appendRuntimeFinding() │ │ 作者: 协同同事 │
|
|
19
|
+
│ 格式: 自动追加 Markdown │ │ 格式: 结构化 Issue 列表 │
|
|
20
|
+
│ 去重: ❌ 无 │ │ 去重: ✅ 合并去重 │
|
|
21
|
+
│ 优先级: ❌ 无 │ │ 优先级: ✅ P0-P3 │
|
|
22
|
+
│ 关闭/修复: ❌ 无 │ │ 关闭/修复: ✅ ✅⚠️❌ 逐条跟踪 │
|
|
23
|
+
└─────────────────────────────────┘ └─────────────────────────────────┘
|
|
24
|
+
│ │
|
|
25
|
+
└──────────── 双向联动 ─────────────────┘
|
|
26
|
+
Runtime Finding ⇄ Report Issue
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## 职责边界
|
|
32
|
+
|
|
33
|
+
### Runtime Report 子系统(以 gateway 为例)的职责
|
|
34
|
+
|
|
35
|
+
| 职责 | 说明 | 不去做的事 |
|
|
36
|
+
|------|------|-----------|
|
|
37
|
+
| 捕获运行时异常 | 合约断裂、未处理错误、环境缺失 | 不做静态代码扫描 |
|
|
38
|
+
| 去重聚合 | 同一 `source + path + errorMsg` 合并为一条 + 发生次数 | 不做优先级分类 |
|
|
39
|
+
| 生成 Issue 草稿 | 首次出现的异常 → 在 `reports/` 下生成 `runtime-issue-{id}.md` | 不人工评估严重度 |
|
|
40
|
+
| 验证修复状态 | Reports 标记 ✅ 后,下次请求路径跑通 → 自动写回 `verified_at` | 不自行关闭 Issue |
|
|
41
|
+
|
|
42
|
+
### Reports 的职责(只做这些)
|
|
43
|
+
|
|
44
|
+
| 职责 | 说明 | 不去做的事 |
|
|
45
|
+
|------|------|-----------|
|
|
46
|
+
| 静态代码审查 | 安全漏洞、死代码、架构重复、类型问题 | 不捕获运行时异常 |
|
|
47
|
+
| 优先级分类 | P0(立即)/ P1(尽快)/ P2(计划)/ P3(债务) | 不自动生成 Issue |
|
|
48
|
+
| 补充根因分析 | Runtime Report 子系统的草稿只含堆栈,Reports 补充业务影响和修复方案 | 不修改 Runtime Report 子系统写入的原始数据 |
|
|
49
|
+
| 跟踪修复进度 | ✅ 已修复 / ⚠️ 部分修复 / ❌ 仍存在 | 不做运行时验证 |
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## 数据流向
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
运行时异常发生
|
|
57
|
+
│
|
|
58
|
+
▼
|
|
59
|
+
appendRuntimeFinding() ─────────────────────────────┐
|
|
60
|
+
│ │
|
|
61
|
+
├── 1. 写入 AuditLog (RUNTIME_ERROR) │
|
|
62
|
+
│ │
|
|
63
|
+
├── 2. 写入 {{projectName}}-runtime-report/gateway.md │
|
|
64
|
+
│ └── 去重检查: 同 source+path+errorMsg │
|
|
65
|
+
│ ├── 已存在 → count++ │
|
|
66
|
+
│ └── 新发现 → 追加 + 生成草稿 │
|
|
67
|
+
│ │
|
|
68
|
+
└── 3. 生成 reports/runtime-issue-{id}.md ────┘
|
|
69
|
+
│
|
|
70
|
+
▼ (协同同事接手)
|
|
71
|
+
Reports 人工 triage
|
|
72
|
+
│
|
|
73
|
+
├── 补充优先级、分类、修复建议
|
|
74
|
+
├── 合并到 combined-report.md
|
|
75
|
+
└── 标记为 P1/P2 后 → Plan 流程
|
|
76
|
+
│
|
|
77
|
+
▼ (修复完成后)
|
|
78
|
+
Reports 标记 ✅
|
|
79
|
+
│
|
|
80
|
+
▼ (Runtime Report 运行时验证)
|
|
81
|
+
下次请求跑通同一路径
|
|
82
|
+
→ {{projectName}}-runtime-report/gateway.md 写回 verified_at
|
|
83
|
+
→ Issue 自动标记为 "已验证"
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## 互操作协议
|
|
89
|
+
|
|
90
|
+
### 1. Runtime Report → Reports: Issue 草稿
|
|
91
|
+
|
|
92
|
+
Runtime Report 子系统发现新异常时,在 `reports/` 下生成最小草稿:
|
|
93
|
+
|
|
94
|
+
```markdown
|
|
95
|
+
# RUNTIME-{YYYYMMDD}-{seq}
|
|
96
|
+
|
|
97
|
+
- **来源**: Gateway 运行时 (`{{projectName}}-runtime-report/gateway.md`)
|
|
98
|
+
- **首次发生**: {timestamp}
|
|
99
|
+
- **发生次数**: 1
|
|
100
|
+
- **错误**: {errorMsg}
|
|
101
|
+
- **路径**: {method} {pathname}
|
|
102
|
+
- **堆栈**: (见 {{projectName}}-runtime-report/gateway.md 对应条目)
|
|
103
|
+
|
|
104
|
+
> 此草稿由 Gateway 自动生成,待人工 triage 后合并到 combined-report.md。
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Reports 侧接收后:
|
|
108
|
+
- 确认是否为真实 Bug(排除环境问题)
|
|
109
|
+
- 分配优先级和分类
|
|
110
|
+
- 补充业务影响描述
|
|
111
|
+
- 合并入 `combined-report.md`,原草稿可删除
|
|
112
|
+
|
|
113
|
+
### 2. Reports → Runtime Report: 验证请求
|
|
114
|
+
|
|
115
|
+
Reports 中标记为 ✅ 的 Issue,Runtime Report 子系统在下次对应路径的请求中:
|
|
116
|
+
- 请求成功 → 写入 `verified_at: {timestamp}` → Issue 自动标记 "已验证"
|
|
117
|
+
- 请求仍失败 → 写入 `regression_at: {timestamp}` → Issue 自动回退为 ❌
|
|
118
|
+
|
|
119
|
+
### 3. 双向引用格式
|
|
120
|
+
|
|
121
|
+
- `{{projectName}}-runtime-report/gateway.md` 中每条发现增加 `report-issue: RUNTIME-{id}` 引用
|
|
122
|
+
- `reports/combined-report.md` 中每条 Issue 增加 `runtime-finding: {{projectName}}-runtime-report/gateway.md#L{line}` 引用
|
|
123
|
+
- 确保可双向追溯
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
## 现有问题
|
|
128
|
+
|
|
129
|
+
| 问题 | 表现 | 修复方向 |
|
|
130
|
+
|------|------|---------|
|
|
131
|
+
| Runtime Report 无去重 | `{{projectName}}-runtime-report/gateway.md` 452 行,90% 是重复条目 | `appendRuntimeFinding()` 增加去重逻辑 |
|
|
132
|
+
| Reports 三份文件重叠 | `suggestions.md` ⊆ `combined-report.md`,`fix-verification.md` 跟踪同一批 Issue | 合并为单一 Issue 注册表 + 每条 Issue 独立文件 |
|
|
133
|
+
| 无双向引用 | 两份产物互不知晓对方存在 | 增加 `report-issue` / `runtime-finding` 交叉引用 |
|
|
134
|
+
| Runtime Report 不感知 Reports 修复状态 | Reports 标记 ✅ 后 Runtime Report 不知道需要验证 | 增加验证请求协议 |
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
# {{projectName}} 项目代码审查综合报告
|
|
2
|
+
|
|
3
|
+
> 生成时间:2026-06-29
|
|
4
|
+
> 来源:`code-review-suggestions.md`(历史审查)+ 本次全量代码审查
|
|
5
|
+
> 格式:合并去重,逐条验证当前代码状态
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 问题总览
|
|
10
|
+
|
|
11
|
+
| 分类 | 数量 |
|
|
12
|
+
|------|------|
|
|
13
|
+
| 安全风险 | 2 |
|
|
14
|
+
| 代码重复 / 架构问题 | 7 |
|
|
15
|
+
| 健壮性 / 边界条件 | 5 |
|
|
16
|
+
| 代码整洁 | 7 |
|
|
17
|
+
| 基础设施 / 运维 | 3 |
|
|
18
|
+
| **总计** | **24** |
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## 一、安全风险
|
|
23
|
+
|
|
24
|
+
### 1. JWT 硬编码默认密钥
|
|
25
|
+
|
|
26
|
+
- **文件**: [src/lib/auth.ts:3](file://{{projectRoot}}/src/lib/auth.ts#L3)
|
|
27
|
+
- **状态**: 仍存在
|
|
28
|
+
- **描述**: `JWT_SECRET = process.env.JWT_SECRET || "dev-secret-key"`,生产环境若漏配环境变量将使用可预测的弱密钥
|
|
29
|
+
- **建议**: 生产环境强制要求配置,缺失时直接拒绝启动(`throw new Error`)
|
|
30
|
+
|
|
31
|
+
### 2. QWeather JWT 签名是占位符
|
|
32
|
+
|
|
33
|
+
- **文件**: [src/lib/farm-server-client.ts:74-76](file://{{projectRoot}}/src/lib/farm-server-client.ts#L74-L76)
|
|
34
|
+
- **状态**: 仍存在
|
|
35
|
+
- **描述**: `createQWeatherJwt()` 中 EdDSA 签名写死为 `"PLACEHOLDER_SIGNATURE"`,注释说"实际迁移 co-agent 天气工具时会携带完整的 JWT 签名实现",生产环境会导致认证失败
|
|
36
|
+
- **建议**: 完成 JWT 签名实现,或在使用处增加强校验拦截
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## 二、代码重复 / 架构问题
|
|
41
|
+
|
|
42
|
+
### 3. LLM 模块重复(`llm.ts` vs `llm/index.ts`)
|
|
43
|
+
|
|
44
|
+
- **文件**: [src/lib/llm.ts](file://{{projectRoot}}/src/lib/llm.ts) / [src/lib/llm/index.ts](file://{{projectRoot}}/src/lib/llm/index.ts)
|
|
45
|
+
- **状态**: 仍存在
|
|
46
|
+
- **描述**: 旧版 `llm.ts` 使用 `globalForLLM` 模式 + IIFE,新版 `index.ts` 使用 `AuditedLLM` 包装类。`agents/index.ts` 实际引用 `@/lib/llm/index`,旧文件成死代码。两个文件还各自定义了 `MultimodalContent` / `MultimodalMessage` 类型
|
|
47
|
+
- **建议**: 删除 `src/lib/llm.ts`,统一使用 `src/lib/llm/index.ts`
|
|
48
|
+
|
|
49
|
+
### 4. Chroma 客户端重复(`chroma.ts` vs `chroma-client.ts`)
|
|
50
|
+
|
|
51
|
+
- **文件**: [src/lib/chroma.ts](file://{{projectRoot}}/src/lib/chroma.ts) / [src/lib/chroma-client.ts](file://{{projectRoot}}/src/lib/chroma-client.ts)
|
|
52
|
+
- **状态**: 仍存在
|
|
53
|
+
- **描述**: 两个 ChromaDB 客户端实现,一个用 `chromadb` npm 包,一个用原生 HTTP fetch,功能重叠
|
|
54
|
+
- **建议**: 统一为一个客户端模块
|
|
55
|
+
|
|
56
|
+
### 5. `extractTokenFromRequest` 重复定义
|
|
57
|
+
|
|
58
|
+
- **文件**: [src/lib/auth.ts:27](file://{{projectRoot}}/src/lib/auth.ts#L27) / [src/caijuehub/strategies/auth-gateway.ts:59](file://{{projectRoot}}/src/caijuehub/strategies/auth-gateway.ts#L59)
|
|
59
|
+
- **状态**: 仍存在
|
|
60
|
+
- **描述**: 同一函数在 `auth.ts` 和 `auth-gateway.ts` 中各定义一次,注释说"避免循环依赖",造成维护负担
|
|
61
|
+
- **建议**: 提取到独立工具模块,或从 `auth.ts` 导出后由 `auth-gateway.ts` 引用
|
|
62
|
+
|
|
63
|
+
### 6. 8+ 个日志模块共享相同代码模式
|
|
64
|
+
|
|
65
|
+
- **文件**: `chat-persistence-logger.ts`、`stream-bus-logger.ts`、`audit-logger.ts`、`stream-chat-logger.ts`、`agent-gateway-dev-logger.ts` 等
|
|
66
|
+
- **状态**: 仍存在
|
|
67
|
+
- **描述**: 每个日志模块都有几乎相同的 `ensureLogDir()` / `writeToFile()` / `formatMessage()` 实现,大量重复代码
|
|
68
|
+
- **建议**: 提取公共日志基础设施模块
|
|
69
|
+
|
|
70
|
+
### 7. `agent-gateway-dev-logger.ts` 与 `agent-gateway-audit.ts` 行为不一致
|
|
71
|
+
|
|
72
|
+
- **文件**: [src/lib/agent-gateway-dev-logger.ts:12](file://{{projectRoot}}/src/lib/agent-gateway-dev-logger.ts#L12) / [src/lib/agent-gateway-audit.ts](file://{{projectRoot}}/src/lib/agent-gateway-audit.ts)
|
|
73
|
+
- **状态**: 仍存在
|
|
74
|
+
- **描述**: `agent-gateway-dev-logger.ts` 仅在 `IS_DEV` 时输出日志,`agent-gateway-audit.ts` 始终输出。两个模块功能重叠但行为不一致
|
|
75
|
+
- **建议**: 统一为一个网关审计模块
|
|
76
|
+
|
|
77
|
+
### 8. `audit-log.ts` 内存存储审计日志
|
|
78
|
+
|
|
79
|
+
- **文件**: [src/services/audit-log.ts:30](file://{{projectRoot}}/src/services/audit-log.ts#L30)
|
|
80
|
+
- **状态**: 仍存在
|
|
81
|
+
- **描述**: `auditLogs` 数组只存内存,进程重启全部丢失。与 `agent-audit-logger.ts` 的 DB 持久化方案不一致
|
|
82
|
+
- **建议**: 统一使用 DB 持久化,或明确标注为仅开发环境使用
|
|
83
|
+
|
|
84
|
+
### 9. `agents/index.ts` 职责过大(468 行)
|
|
85
|
+
|
|
86
|
+
- **文件**: [src/agents/index.ts](file://{{projectRoot}}/src/agents/index.ts)
|
|
87
|
+
- **状态**: 仍存在
|
|
88
|
+
- **描述**: 同时包含 StateGraph 定义、ToolNode 包装器、审计包装器、`runAgent`/`streamAgent` 入口、Tracer 管理、`buildPartialState`
|
|
89
|
+
- **建议**: 拆分为 `graph.ts`、`tool-node-wrapper.ts`、`audit-wrapper.ts`、`agent-runner.ts`
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## 三、健壮性 / 边界条件
|
|
94
|
+
|
|
95
|
+
### 10. LLM 单例竞态条件
|
|
96
|
+
|
|
97
|
+
- **文件**: [src/lib/llm/index.ts:215-248](file://{{projectRoot}}/src/lib/llm/index.ts#L215-L248)
|
|
98
|
+
- **状态**: 仍存在
|
|
99
|
+
- **描述**: `setLLMConfig()` 会调用 `resetLLM()` 将 `llmInstance` 置为 `null`,并发请求携带不同 `modelConfig` 时,A 请求的重置可能影响 B 请求正在使用的实例
|
|
100
|
+
- **建议**: 改为按请求/线程隔离的 LLM 实例,或使用请求级缓存
|
|
101
|
+
|
|
102
|
+
### 11. `activeTracers` Map 潜在内存泄漏
|
|
103
|
+
|
|
104
|
+
- **文件**: [src/agents/index.ts:239](file://{{projectRoot}}/src/agents/index.ts#L239)
|
|
105
|
+
- **状态**: 仍存在
|
|
106
|
+
- **描述**: 清理依赖 `endChainTrace()` 被调用。如果流式请求异常中断(客户端断开),`endChainTrace` 可能不会被调用,Map 持续增长
|
|
107
|
+
- **建议**: 增加 TTL 过期机制或定期清理
|
|
108
|
+
|
|
109
|
+
### 12. 审计日志静默吞错
|
|
110
|
+
|
|
111
|
+
- **文件**: [src/lib/agent-audit-logger.ts:175-180](file://{{projectRoot}}/src/lib/agent-audit-logger.ts#L175-L180)
|
|
112
|
+
- **状态**: 仍存在
|
|
113
|
+
- **描述**: `writeAuditLog()` 的 catch 块只做 `console.error`,`ensureLogDir()` 的 catch 完全忽略。DB 不可用时所有审计记录静默丢失
|
|
114
|
+
- **建议**: 增加失败计数器或 metric 上报
|
|
115
|
+
|
|
116
|
+
### 13. 缺少请求体运行时校验
|
|
117
|
+
|
|
118
|
+
- **文件**: [src/app/api/agent/chat/route.ts:17](file://{{projectRoot}}/src/app/api/agent/chat/route.ts#L17)
|
|
119
|
+
- **状态**: 仍存在
|
|
120
|
+
- **描述**: 直接 `await request.json()` 后做类型断言,没有用 Zod 或类似库做运行时校验。格式错误的请求体会在深层抛出不友好的异常
|
|
121
|
+
- **建议**: 引入 Zod schema 进行请求体校验
|
|
122
|
+
|
|
123
|
+
### 14. Model config 使用 `require()` 动态加载
|
|
124
|
+
|
|
125
|
+
- **文件**: [src/lib/llm/index.ts:246-247](file://{{projectRoot}}/src/lib/llm/index.ts#L246-L247)
|
|
126
|
+
- **状态**: 仍存在
|
|
127
|
+
- **描述**: `require("@/lib/model-config-logger")` 动态加载,ESM 环境下可能不稳定。注释 `// Logger unavailable in server context` 说明有已知问题
|
|
128
|
+
- **建议**: 改为静态 import 或明确的依赖注入
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## 四、代码整洁
|
|
133
|
+
|
|
134
|
+
### 15. 大量 `as any` / `as unknown as` 类型断言
|
|
135
|
+
|
|
136
|
+
- **文件**: [src/agents/index.ts](file://{{projectRoot}}/src/agents/index.ts) 等多处
|
|
137
|
+
- **状态**: 仍存在(约 119 处 `any` 使用)
|
|
138
|
+
- **描述**: 消息类型转换、toolResults 赋值等大量绕过 TypeScript 类型检查
|
|
139
|
+
- **建议**: 逐步用类型守卫或 zod schema 替代
|
|
140
|
+
|
|
141
|
+
### 16. `knowledge-indexer.ts` 遗留调试日志
|
|
142
|
+
|
|
143
|
+
- **文件**: [src/services/knowledge-indexer.ts:568-586](file://{{projectRoot}}/src/services/knowledge-indexer.ts#L568-L586)
|
|
144
|
+
- **状态**: 仍存在
|
|
145
|
+
- **描述**: `[RAG-DEBUG]` 前缀的 `console.log` 在生产环境也会输出,应改为条件日志
|
|
146
|
+
- **建议**: 改为仅在 `NODE_ENV=development` 时输出
|
|
147
|
+
|
|
148
|
+
### 17. 未完成的 TODO
|
|
149
|
+
|
|
150
|
+
- **文件**: [src/agents/policy-update-loop.ts:149](file://{{projectRoot}}/src/agents/policy-update-loop.ts#L149)
|
|
151
|
+
- **状态**: 仍存在
|
|
152
|
+
- **描述**: `// TODO: 根据 pathMetrics 定制提示语——第 7 轮设计 reserve 但未实现`
|
|
153
|
+
- **建议**: 完成实现或移除 TODO
|
|
154
|
+
|
|
155
|
+
### 18. `AgentAuditPhase` 类型过于庞大(80+ 联合成员)
|
|
156
|
+
|
|
157
|
+
- **文件**: [src/lib/agent-audit-logger.ts:15-143](file://{{projectRoot}}/src/lib/agent-audit-logger.ts#L15-L143)
|
|
158
|
+
- **状态**: 仍存在
|
|
159
|
+
- **描述**: 80+ 个联合成员,维护困难且容易拼写错误
|
|
160
|
+
- **建议**: 按域拆分为多个子类型,或改为 `string` 类型 + 常量枚举
|
|
161
|
+
|
|
162
|
+
### 19. 脚本目录过于庞大(60+ 文件)
|
|
163
|
+
|
|
164
|
+
- **文件**: `scripts/` 目录
|
|
165
|
+
- **状态**: 仍存在(实际 60+ 文件)
|
|
166
|
+
- **描述**: 包含一次性迁移脚本(`backfill-projectId.ts`、`fix-knowledge-data.js`、`restore-from-dump.js`)、Windows `.bat` 和 Unix `.sh` 双份
|
|
167
|
+
- **建议**: 将一次性脚本归档到单独目录
|
|
168
|
+
|
|
169
|
+
### 20. Prisma 多文件 Schema 注释与实际路径不一致
|
|
170
|
+
|
|
171
|
+
- **文件**: [prisma/schema.prisma:12-14](file://{{projectRoot}}/prisma/schema.prisma#L12-L14)
|
|
172
|
+
- **状态**: 仍存在
|
|
173
|
+
- **描述**: 注释说子文件在 `prisma/schema/` 目录下,但实际 `main.prisma` 和 `nongqing.prisma` 在 `prisma/` 根目录。且 `prisma/dev.db`(SQLite 文件)存在,说明开发环境可能混用了 SQLite 和 PostgreSQL
|
|
174
|
+
- **建议**: 修正注释或移动文件,清理 `dev.db`
|
|
175
|
+
|
|
176
|
+
### 21. 项目中大量 `console.log`(842+ 处)
|
|
177
|
+
|
|
178
|
+
- **文件**: 全局
|
|
179
|
+
- **状态**: 仍存在
|
|
180
|
+
- **描述**: 大量 `console.log/warn/error` 散落在 100+ 个文件中,部分本应使用专用日志模块
|
|
181
|
+
- **建议**: 逐步替换为结构化日志模块
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
## 五、基础设施 / 运维
|
|
186
|
+
|
|
187
|
+
### 22. Chroma 端口未绑定 localhost
|
|
188
|
+
|
|
189
|
+
- **文件**: [docker-compose.yml:50](file://{{projectRoot}}/docker-compose.yml#L50)
|
|
190
|
+
- **状态**: 仍存在
|
|
191
|
+
- **描述**: Chroma 端口映射为 `"8000:8000"`,没有绑定到 `127.0.0.1`,而 PostgreSQL 是 `"127.0.0.1:5433:5432"`。公网部署时 Chroma 8000 端口暴露在外
|
|
192
|
+
- **建议**: 改为 `"127.0.0.1:8000:8000"`
|
|
193
|
+
|
|
194
|
+
### 23. Docker Compose 资源限制被注释
|
|
195
|
+
|
|
196
|
+
- **文件**: [docker-compose.yml:30-36](file://{{projectRoot}}/docker-compose.yml#L30-L36) / [docker-compose.yml:60-67](file://{{projectRoot}}/docker-compose.yml#L60-L67)
|
|
197
|
+
- **状态**: 仍存在
|
|
198
|
+
- **描述**: PostgreSQL 和 Chroma 的 `deploy.resources` 全部被注释,生产环境无资源限制
|
|
199
|
+
- **建议**: 根据实际负载启用 resource limits
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
## 六、本次审查新增发现
|
|
204
|
+
|
|
205
|
+
以下为本次审查独立发现、`code-review-suggestions.md` 未覆盖的问题:
|
|
206
|
+
|
|
207
|
+
| # | 问题 | 文件 | 严重度 |
|
|
208
|
+
|---|------|------|--------|
|
|
209
|
+
| 25 | `extractTokenFromRequest` 重复定义 | [auth.ts](file://{{projectRoot}}/src/lib/auth.ts#L27) / [auth-gateway.ts](file://{{projectRoot}}/src/caijuehub/strategies/auth-gateway.ts#L59) | 中 |
|
|
210
|
+
| 26 | Chroma 客户端双实现 | [chroma.ts](file://{{projectRoot}}/src/lib/chroma.ts) / [chroma-client.ts](file://{{projectRoot}}/src/lib/chroma-client.ts) | 中 |
|
|
211
|
+
| 27 | 日志模块行为不一致 | [agent-gateway-dev-logger.ts](file://{{projectRoot}}/src/lib/agent-gateway-dev-logger.ts) vs [agent-gateway-audit.ts](file://{{projectRoot}}/src/lib/agent-gateway-audit.ts) | 中 |
|
|
212
|
+
| 28 | 审计日志内存存储 vs DB 持久化不一致 | [audit-log.ts](file://{{projectRoot}}/src/services/audit-log.ts) | 中 |
|
|
213
|
+
| 29 | `AgentAuditPhase` 类型 80+ 联合成员 | [agent-audit-logger.ts](file://{{projectRoot}}/src/lib/agent-audit-logger.ts) | 低 |
|
|
214
|
+
| 30 | `knowledge-indexer.ts` RAG-DEBUG 日志遗留 | [knowledge-indexer.ts](file://{{projectRoot}}/src/services/knowledge-indexer.ts) | 低 |
|
|
215
|
+
| 31 | 未完成 TODO | [policy-update-loop.ts](file://{{projectRoot}}/src/agents/policy-update-loop.ts) | 低 |
|
|
216
|
+
| 32 | 大量 `console.log` 散落 | 全局 100+ 文件 | 低 |
|
|
217
|
+
|
|
218
|
+
---
|
|
219
|
+
|
|
220
|
+
## 修复优先级建议
|
|
221
|
+
|
|
222
|
+
| 优先级 | 问题编号 | 说明 |
|
|
223
|
+
|--------|---------|------|
|
|
224
|
+
| P0 立即修复 | #1, #2 | 安全风险:JWT 弱密钥 + QWeather 占位签名 |
|
|
225
|
+
| P1 尽快修复 | #10, #11, #12 | 健壮性:竞态条件、内存泄漏、审计静默吞错 |
|
|
226
|
+
| P2 计划修复 | #3, #4, #5, #6, #7, #8, #9, #13, #14, #15 | 代码重复、架构问题、缺少校验 |
|
|
227
|
+
| P3 技术债务 | #16, #17, #18, #19, #20, #21, #22, #23 | 代码整洁、基础设施 |
|