256 Commits

Author SHA1 Message Date
wangdl
55221116b7 debug: rag-chat 日志增加 kbId
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 42s
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-06 14:12:44 +08:00
wangdl
07f2786ab9 fix: 移除 rag-chat 调试日志中的 rawText 引用 (GatewayResponse 无此字段)
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 41s
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-06 14:04:17 +08:00
wangdl
ce43256690 debug: rag-chat sendMessage 添加详细日志定位 AI Gateway 调用失败原因
Some checks failed
Deploy API Server / build-and-deploy (push) Failing after 21s
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-06 13:56:28 +08:00
wangdl
d8877f926f fix: 注册 rag-chat prompt template,修复 AI 对话始终返回 fallback
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 44s
根因:PromptTemplateService 未注册 rag-chat 的 prompt,
sendMessage 中 promptTemplate.get('rag-chat') 抛异常被 catch,
永远走 fallbackReply("AI 服务暂时不可用")。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-06 13:48:17 +08:00
wangdl
78e21c4c4c fix: RagChatModule 导入 AiModule,修复 AiGatewayService 未注入
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 43s
AiGatewayService 使用了 @Optional() 导致不报错但始终为 null,
sendMessage 永远走 fallbackReply。现在导入 AiModule 正确注入。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-06 13:40:03 +08:00
wangdl
a784ee3bc3 fix: MiniMax 已到期,切换 primary tier 到 DeepSeek V4 Pro
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 40s
- model-router: primary 层 preferred 从 minimax-m2.7 改为 deepseek-v4-pro
- cost-calculator: 移除 minimax 零成本豁免
- billing: MiniMax 标注已到期

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-06 12:23:35 +08:00
wangdl
11a38a68c1 fix: admin-billing 不再硬编码 API key,改为从 ConfigService 读取
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 47s
DeepSeek 和硅基流动的 API key 改为从环境变量读取,不再硬编码在源码中。
旧 DeepSeek key(公司采购)已全局替换为个人账号 key sk-cb34244304914c77943dfaf6522a7c9a。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-06 12:17:17 +08:00
wangdl
28c68a8c3b fix: code review — 6 medium issues in KnowledgeItem/LearningActivity
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 43s
1. enrichItem: add Logger.warn on COS errors instead of silent catch
2. getTrend: add 15s timeout fallback for AI analysis
3. buildDailySeries: use local date strings to avoid UTC timezone shift
4. detectSourceType: use lazy regex .+? to prevent ReDoS on long texts
5. sortBy: validate against whitelist, reject invalid values
6. PaginationDto visibility/ownerType: already handled via @Query params

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-06 12:07:40 +08:00
wangdl
4b21c98835 fix: code review — 4 critical bugs in KnowledgeItem/KB modules
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 42s
1. enrichItem: remove MIME type → sourceType mapping (contentType is text/markdown not markdown)
2. update(): add field whitelist to prevent mass assignment (userId/deletedAt/etc)
3. createFolder: add userId permission check + parent folder validation
4. deleteFolder: cascade soft-delete to corresponding KnowledgeItem (itemType=folder)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-06 12:04:24 +08:00
wangdl
4b8653080e feat: #67 GET /activity/trend 新增 dailySeries 时间序列数据
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 43s
返回格式新增 dailySeries 字段 [{date, value, label}],支持 iOS 折线图/柱状图渲染。
数据来源:按日聚合 LearningActivity.durationSeconds。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-05 20:12:18 +08:00
wangdl
9c14bda0c2 feat: Phase 1 & 2 — KnowledgeItem/KB model补齐 + API增强
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 43s
#61 KnowledgeItem sourceType 自动检测(COS URL/HTML/Markdown/扩展名)
#59 KnowledgeItem 新增 durationSeconds 字段
#66 KnowledgeItem 新增 fileSize 字段,enrichItem 同步填充 COS 文件大小
#53 KnowledgeBase GET /knowledge-bases 支持 visibility/ownerType 查询筛选
#63 GET /knowledge-items 新增 sortBy/order 排序参数
#65 PATCH /knowledge-items/:id 支持 parentId 校验
#64 POST /knowledge-bases/:id/folders 同步创建 KnowledgeItem(itemType:folder)
#62 GET /learning-sessions 新增 status/sort 筛选参数
#69 KnowledgeItem detail 动态刷新 COS 预签名 URL(7天有效)
#60 GET /quizzes 跨知识库列表已实现,关 issue

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-05 20:01:43 +08:00
wangdl
d7a7611b36 fix: ChatCitation 字段 + BigInt 类型修复
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 48s
- ChatCitation.content → excerptText(对齐 Prisma schema)
- ChatCitation.score 不存在→ 移除
- UploadedFile.sizeBytes BigInt → Number() 转换

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-30 08:42:07 +08:00
wangdl
b90387dd51 fix: User 补充 Quiz 反向关联
Some checks failed
Deploy API Server / build-and-deploy (push) Failing after 20s
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-29 20:04:43 +08:00
wangdl
a1a4b26444 fix: User + KnowledgeBase 补充 Quiz 反向关联
Some checks failed
Deploy API Server / build-and-deploy (push) Failing after 11s
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-29 20:04:14 +08:00
wangdl
6033fbc997 feat: H0-12 Quiz 模型与 API
Some checks failed
Deploy API Server / build-and-deploy (push) Failing after 11s
Prisma 新增:
- Quiz(测验)
- QuizQuestion(题目,支持 choice/fill/judge 三种题型)
- QuizAttempt(答题记录)
- QuizAnswer(作答详情)

API:
- POST /quizzes(生成测验,自动从KB知识点抽题)
- GET /quizzes(列表)
- GET /quizzes/:id(含题目)
- POST /quizzes/:id/start(开始答题)
- POST /quizzes/:id/submit(提交答案+评分)
- GET /quizzes/:id/results?attemptId=(结果详情)
- GET /quizzes/history/list(历史记录)

题目生成策略:
- 选择题:题干=知识点标题,选项=内容片段+其他知识点干扰项
- 填空题:随机关键词挖空
- 判断题:随机生成对/错陈述

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-29 20:03:40 +08:00
wangdl
6ab54be309 feat: H0-11 RAG Chat 接入真实检索 + AI 生成管道
Some checks failed
Deploy API Server / build-and-deploy (push) Failing after 19s
- sendMessage 从 KB 加载知识点内容作为上下文(最多 30 条/4000 字符)
- 通过 AiGatewayService 调用 DeepSeek 生成回答
- AI 回复附带引用来源(ChatCitation)
- AI Gateway 不可用时降级提示
- 知识库为空时引导用户先添加内容

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-29 19:31:33 +08:00
wangdl
5fe31a8805 feat: H0-10 存储空间统计 + 学习资产计数
Some checks failed
Deploy API Server / build-and-deploy (push) Failing after 19s
- GET /users/me/storage(totalBytes/usedBytes/fileCount)
- GET /users/me/assets-summary(kbCount/itemCount/cardCount)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-29 19:29:22 +08:00
wangdl
d208fd7876 fix: User 模型补充 KnowledgeBaseSubscription 反向关联
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 44s
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-29 19:25:53 +08:00
wangdl
b9f8334245 feat: H0-08 KnowledgeBase 增加业务字段 + 订阅 + 发现 + 置顶 + 公开
Some checks failed
Deploy API Server / build-and-deploy (push) Failing after 11s
Schema 新增:
- coverType/coverIcon/coverColor(封面类型/系统图标/颜色)
- visibility(private/public)
- isPinned(置顶)
- ownerType(user/official)
- isVerified(认证标识)
- KnowledgeBaseSubscription 表

API 新增:
- POST /knowledge-bases/:id/pin(切换置顶)
- PATCH /knowledge-bases/:id/visibility(切换公开/私有)
- POST /knowledge-bases/:id/subscribe(订阅)
- DELETE /knowledge-bases/:id/subscribe(取消订阅)
- GET /knowledge-bases/subscribed(已订阅列表)
- GET /knowledge-bases/discover(发现公开库)

增强:
- findAll 支持 visibility/ownerType 筛选 + 置顶优先排序
- findOne 公开库允许任何人查看
- update 支持所有新字段

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-29 19:24:21 +08:00
wangdl
4f59569b7c feat: KB 列表返回 coverUrl(coverKey → 预签名下载URL)
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 43s
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-28 10:48:34 +08:00
wangdl
28caf1297f feat: KnowledgeBase 支持封面图 coverKey 字段
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 40s
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-28 10:42:58 +08:00
wangdl
c331d08644 feat: 知识点软删除 + 批量删除接口
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 41s
- DELETE /knowledge-items/:id 软删除(设 deletedAt)
- POST /knowledge-items/batch-delete 批量软删除
- softDelete 校验归属权 + 自动更新父KB的itemCount

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-27 22:47:22 +08:00
wangdl
b5de001dbb fix: FileUploadRateLimit 10→200/小时,支持批量上传
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 43s
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-27 22:41:56 +08:00
wangdl
53a4cc118a fix: 创建知识点时更新知识库 itemCount 计数
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 40s
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-27 22:38:34 +08:00
wangdl
846ba43f8f fix: COS domain fallback 从 cos.longde.cloud 改为空字符串
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 44s
storage.config.ts 兜底值 cos.longde.cloud → ''
配合 CosStorageProvider 的 domain ? {...} : {} 逻辑,
彻底移除无效 TLS 证书的自定义域名。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-27 21:52:24 +08:00
wangdl
859156a59b fix: COS 自定义域名空值时回退到原生域名
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 45s
- CosStorageProvider 初始化时 Domain 为空不再传入 SDK
- 原生 COS 域名 (cos.ap-beijing.myqcloud.com) 有有效 TLS 证书
- 生产环境移除 STORAGE_COS_DOMAIN 配置

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-27 21:48:33 +08:00
wangdl
b9e6055400 fix: H0-01 彻底阻断生产环境 mock + 结构化错误码 + iOS Auth 合同文档
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 41s
- apple-auth.service.ts: verifyIdentityToken 增加 NODE_ENV 检查,
  生产环境缺 APPLE_BUNDLE_ID 时运行时返回 401,不再走 mock
- 新增 CAPIErrorCode 语义错误码体系 (src/common/errors/)
- 新增 CapiException 携带 errorCode 的 HttpException 子类
- GlobalExceptionFilter 响应自动包含 errorCode 字段
- AuthService/JwtAuthGuard/AppleAuthService 全部改用 CapiException
- 新增 LoginResponseDto/RefreshResponseDto/LogoutResponseDto/UserDto
- Auth controller Swagger 添加 type 参数
- 新增 docs/ios-auth-api-contract.md

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-27 21:03:15 +08:00
wangdl
c6fd1731d5 fix(auth): OnModuleInit改为warn而非throw,避免生产缺APPLE_BUNDLE_ID时进程崩溃
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 45s
2026-05-27 20:24:23 +08:00
wangdl
5fcfc87f84 fix(auth): H0-01 Apple登录—nonce验证+启动检查+fullName补写修复
Some checks failed
Deploy API Server / build-and-deploy (push) Failing after 34s
2026-05-27 20:22:42 +08:00
6a13edc7fb feat: H0 milestone — iOS integration blocking fixes
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 44s
H0-01: Reject Apple login mock fallback in production
H0-02: Protect /internal/* with InternalAuthGuard (X-Internal-API-Key)
H0-03: JwtAuthGuard check user status (deletedAt, status)
H0-04: Refresh token check user status + revoke all on deleted
H0-05: User/admin JWT isolation (type=user/admin, enforce ADMIN_JWT_ACCESS_SECRET)
H0-06: Add DTOs for import/source/learning-session controllers
H0-07: 22 E2E tests (h0.e2e-spec.ts), 5 iOS integration docs

Tests: 47/47 (H0 22 + M0 25), no regression.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-25 16:55:04 +08:00
23988a1add fix: add sudo to rsync deploy commands to fix permission errors
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 40s
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 20:41:57 +08:00
ee5ebb5766 fix: add BigInt JSON serialization patch for Prisma BigInt columns
Some checks failed
Deploy API Server / build-and-deploy (push) Failing after 26s
UploadedFile.sizeBytes is BigInt → JSON.stringify throws TypeError.
Add BigInt.prototype.toJSON to convert to Number globally.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 20:38:46 +08:00
e36f9c9785 fix: project center — Gitea API wraps responses in {ok,data}, extract data field
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 44s
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 20:36:32 +08:00
b81b7fba92 fix: replace prisma migrate deploy with db push in CI pipeline
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 41s
prisma migrate deploy requires pre-generated migration files which won't
exist when schema is edited directly. db push syncs schema directly.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 20:31:22 +08:00
75f8dd27e7 fix: project center — fix empty repo list + Gitea tab bug + add repo selector
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 40s
- GiteaService: use /repos/search?q= with fallback to /user/repos, remove slow per-repo API calls
- Frontend: add RepoSelector dropdown to Issues/Milestones/Releases tabs
- Fix Gitea panel tab (was filtered out by conditional undefined)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 20:03:27 +08:00
7a7561363d perf: add missing createdAt indexes to 7 models for admin query performance
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 43s
- Affected: Notification, AiUsageLog, LearningSession, AiAnalysisResult,
  DocumentImport, ReviewLog, ChatSession, ChatMessage
- All admin list queries use ORDER BY createdAt DESC — without indexes
  these required full table scans on large tables

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 20:01:36 +08:00
2c164f46da perf: reduce SSH connection timeout from 5s to 2s for server metrics
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 41s
- Remote metrics SSH ConnectTimeout: 5s → 2s
- Remote metrics SSH command timeout: 8s → 4s
- Health check SSH timeouts remain at 3s (already reasonable)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 19:57:55 +08:00
f599af1b3c perf: add select clause to admin review query, exclude large TEXT columns
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 41s
- Only fetch display-needed columns, skip backText TEXT column
- Reduces data transfer and query time significantly

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 19:55:40 +08:00
8a6b103571 fix: add createdAt index to ReviewCard model to fix slow admin page load
Some checks failed
Deploy API Server / build-and-deploy (push) Has been cancelled
The admin review list query uses ORDER BY createdAt DESC but there was no
index on createdAt, causing full table scan + filesort on large tables.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 19:55:01 +08:00
d241407424 fix: M4 audit — add DELETE decisions, PATCH user-agreements, regular user list endpoint
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 44s
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 18:56:54 +08:00
c6d01534c8 feat: M4-11 — vendor billing + secret lifecycle management
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 42s
- Add VendorBill Prisma model (provider/billMonth/amount/usageSummary)
- VendorBillController: CRUD bills, list/rotate/revoke secrets
- Secret lifecycle: active → expiring → expired/rotated/revoked

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 18:25:58 +08:00
b3176b8ead feat: M4-10 — admin notification deepening (cost alerts, import failures, key expirations)
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 41s
- Add scope field to Notification model (user/admin)
- AdminNotificationsController: list, send, mark read
- Generate endpoints: cost-alert, import-failure, key-expiring

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 18:23:35 +08:00
c4089129c0 feat: M4-09 — compliance & safety module (policies, agreements, filings, data requests)
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 42s
- Add PrivacyPolicy, UserAgreement, FilingRecord, DataExportRequest Prisma models
- ComplianceController: privacy policies, user agreements, filings, deletion/export requests
- AAPI: /admin-api/compliance/* (6 resource groups)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 18:19:32 +08:00
cefc4d51c9 feat: M4-08 — release & decision module (changelogs, ADR, checklist)
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 42s
- Add DecisionRecord and ReleaseChecklist Prisma models
- ReleaseController: CRUD for changelogs, decisions, checklists
- AAPI: /admin-api/release/changelogs, /decisions, /checklists

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 18:14:53 +08:00
5d84769ac0 feat: M4-07 — Hermes Agent task/artifact management with approval workflow
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 40s
- Add AgentTask and AgentArtifact Prisma models
- HermesAgentController: list tasks, approve/reject, list artifacts
- AAPI: GET /admin-api/hermes/tasks, POST approve/reject, GET /admin-api/hermes/artifacts

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 18:10:37 +08:00
8abf94872a feat: M4-06 — project center with Gitea API integration
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 41s
- GiteaService: query repos, milestones, issues, releases, runners
- ProjectCenterController: 5 AAPI endpoints
- Replace iframe-only GiteaEmbed with full ProjectCenter page
  (repos table, issues, milestones cards, releases, runners, Gitea embed tab)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 18:06:19 +08:00
b188988e82 feat: M4-05 — reporting & export module (user/learning/review CSV)
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 42s
- Add ExportJob Prisma model
- ReportingService: userReport, learningReport, reviewReport
- ReportingController: GET export/users, export/learning, export/reviews

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 18:01:23 +08:00
76c42f437c feat: M4-04 — backup & cleanup module with admin interface
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 42s
- Add CleanupJob Prisma model
- Create BackupService with backup/cleanup job tracking
- Create BackupController (AAPI: GET jobs, POST trigger backup, GET cleanup, POST cleanup)
- Supports cleanup types: soft-delete, api-metrics, task-logs

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 17:56:26 +08:00
fc978a5e7f feat: M4-03 — server health checks (Docker/MySQL/Redis/Qdrant/Gitea/Nginx/Worker)
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 39s
- Add ServiceHealth Prisma model for health check records
- Add getHealthChecks() with local + remote service checks
- Add GET /admin-api/servers/health endpoint

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 17:51:20 +08:00
90e921366a feat: M4-02 — admin learning data views (sessions, AI analysis, AI usage logs)
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 44s
- Add AdminLearningController with 3 endpoints:
  GET /admin-api/learning/sessions — learning sessions list
  GET /admin-api/learning/analysis — AI analysis results
  GET /admin-api/learning/ai-usage — AI usage logs

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 17:45:43 +08:00