chore: rename Tiji→Kangkang test imports + scheme + sync docs

Rename @testable imports across all test/UI test files after the Tiji→Kangkang
project rename in 44ed01a. Add shared scheme. Sync CLAUDE.md / W2 plan / spec
v1.0 to current scope (Symptom feature noted, C1/C2 flow lockdown).
This commit is contained in:
link2026
2026-05-25 23:18:00 +08:00
parent 44ed01acf4
commit 53da442424
14 changed files with 256 additions and 136 deletions

View File

@@ -18,23 +18,23 @@
| 路径 | 职责 |
|---|---|
| `体己/AI/AIRuntime.swift` | actor 单例,推理串行化,暴露 prepare / generate / lastDecodeRate |
| `体己/AI/ModelStore.swift` | 模型路径管理 + bundle 旁路 |
| `体己/AI/LLMSession.swift` | Qwen3-1.7B 加载 + 流式生成 |
| `体己/AI/TokenChunk.swift` | 流式数据结构 |
| `体己/Persistence/FileVault.swift` | `Application Support/Vault/` 加密目录读写 |
| `体己/Debug/DebugAIRunner.swift` | DEBUG-only 测试入口,挂在 MeView 末尾 |
| `体己Tests/FileVaultTests.swift` | FileVault 单元测试 |
| `体己Tests/ModelStoreTests.swift` | ModelStore 单元测试 |
| `康康/AI/AIRuntime.swift` | actor 单例,推理串行化,暴露 prepare / generate / lastDecodeRate |
| `康康/AI/ModelStore.swift` | 模型路径管理 + bundle 旁路 |
| `康康/AI/LLMSession.swift` | Qwen3-1.7B 加载 + 流式生成 |
| `康康/AI/TokenChunk.swift` | 流式数据结构 |
| `康康/Persistence/FileVault.swift` | `Application Support/Vault/` 加密目录读写 |
| `康康/Debug/DebugAIRunner.swift` | DEBUG-only 测试入口,挂在 MeView 末尾 |
| `康康Tests/FileVaultTests.swift` | FileVault 单元测试 |
| `康康Tests/ModelStoreTests.swift` | ModelStore 单元测试 |
### 修改
| 路径 | 改什么 |
|---|---|
| `体己/Models/Models.swift` | 加 Asset / ChatTurn,Indicator 加 report/asset/pinned,Report 加 indicators/assets 关系,DiaryEntry 加 tags |
| `体己/App/TijiApp.swift` | Schema 加入两个新 @Model |
| `体己/Features/Me/MeView.swift` | DEBUG 块挂 DebugAIRunner |
| `体己.xcodeproj` | SPM 加入 mlx-swift 与 mlx-swift-examples |
| `康康/Models/Models.swift` | 加 Asset / ChatTurn,Indicator 加 report/asset/pinned,Report 加 indicators/assets 关系,DiaryEntry 加 tags |
| `康康/App/KangkangApp.swift` | Schema 加入两个新 @Model |
| `康康/Features/Me/MeView.swift` | DEBUG 块挂 DebugAIRunner |
| `康康.xcodeproj` | SPM 加入 mlx-swift 与 mlx-swift-examples |
### 不动(W2 不碰)
@@ -45,12 +45,12 @@
## Task 1:Xcode 项目加入 MLX Swift SPM 依赖
**Files:**
- Modify: `体己.xcodeproj/project.pbxproj`(通过 Xcode UI 修改,不要手编)
- Modify: `康康.xcodeproj/project.pbxproj`(通过 Xcode UI 修改,不要手编)
- [ ] **Step 1:打开 Xcode 项目**
```bash
open /Users/xuhuayong/apps/体己/体己.xcodeproj
open /Users/xuhuayong/apps/康康/康康.xcodeproj
```
- [ ] **Step 2:加入 MLX Swift 依赖**
@@ -61,7 +61,7 @@ open /Users/xuhuayong/apps/体己/体己.xcodeproj
https://github.com/ml-explore/mlx-swift
```
选 "Up to Next Major" → 添加,勾选这些 product 加到 **体己** target:
选 "Up to Next Major" → 添加,勾选这些 product 加到 **康康** target:
- `MLX`
- `MLXFast`
- `MLXNN`
@@ -76,13 +76,13 @@ https://github.com/ml-explore/mlx-swift
https://github.com/ml-explore/mlx-swift-examples
```
勾选 `MLXLLM``MLXLMCommon` 加到 **体己** target。
勾选 `MLXLLM``MLXLMCommon` 加到 **康康** target。
- [ ] **Step 4:确认 Build Settings**
Xcode → 体己 target → Build Settings → 搜 "Swift Language Version" → 确认 Swift 5(MLX 不支持 Swift 6 严格并发)。
Xcode → 康康 target → Build Settings → 搜 "Swift Language Version" → 确认 Swift 5(MLX 不支持 Swift 6 严格并发)。
体己 target → General → Minimum Deployments → iOS 17.0(MLX 要求)。
康康 target → General → Minimum Deployments → iOS 17.0(MLX 要求)。
- [ ] **Step 5:Build 验证**
@@ -93,8 +93,8 @@ Expected:Build Succeeded,无依赖错误。
- [ ] **Step 6:提交**
```bash
cd /Users/xuhuayong/apps/体己
git add 体己.xcodeproj
cd /Users/xuhuayong/apps/康康
git add 康康.xcodeproj
git commit -m "build: add MLX Swift SPM dependencies"
```
@@ -103,11 +103,11 @@ git commit -m "build: add MLX Swift SPM dependencies"
## Task 2:扩展 Models.swift —— Asset 与 ChatTurn
**Files:**
- Modify: `体己/Models/Models.swift`(全文重写)
- Modify: `康康/Models/Models.swift`(全文重写)
- [ ] **Step 1:把 Models.swift 替换为新内容**
打开 `体己/Models/Models.swift`,**整文件替换**为:
打开 `康康/Models/Models.swift`,**整文件替换**为:
```swift
import Foundation
@@ -268,9 +268,9 @@ final class ChatTurn {
}
```
- [ ] **Step 2:更新 TijiApp.swift Schema**
- [ ] **Step 2:更新 KangkangApp.swift Schema**
打开 `体己/App/TijiApp.swift`,替换 Schema 数组:
打开 `康康/App/KangkangApp.swift`,替换 Schema 数组:
```swift
let schema = Schema([
@@ -302,7 +302,7 @@ Expected:App 启动到 RootView,无 fatalError。
- [ ] **Step 5:提交**
```bash
git add 体己/Models/Models.swift 体己/App/TijiApp.swift
git add 康康/Models/Models.swift 康康/App/KangkangApp.swift
git commit -m "feat(models): add Asset/ChatTurn, indicator-report relationship, pinned flag"
```
@@ -311,17 +311,17 @@ git commit -m "feat(models): add Asset/ChatTurn, indicator-report relationship,
## Task 3:FileVault —— 加密目录读写(TDD)
**Files:**
- Create: `体己/Persistence/FileVault.swift`
- Test: `体己Tests/FileVaultTests.swift`
- Create: `康康/Persistence/FileVault.swift`
- Test: `康康Tests/FileVaultTests.swift`
- [ ] **Step 1:写失败的测试**
创建 `体己Tests/FileVaultTests.swift`:
创建 `康康Tests/FileVaultTests.swift`:
```swift
import Testing
import UIKit
@testable import
@testable import
@MainActor
struct FileVaultTests {
@@ -377,7 +377,7 @@ Expected:`FileVaultTests` 编译错误 "Cannot find 'FileVault' in scope"。
- [ ] **Step 3:写最小 FileVault 实现**
创建 `体己/Persistence/FileVault.swift`:
创建 `康康/Persistence/FileVault.swift`:
```swift
import Foundation
@@ -454,11 +454,11 @@ final class FileVault {
}
```
- [ ] **Step 4:把 FileVault.swift 加入 体己 target**
- [ ] **Step 4:把 FileVault.swift 加入 康康 target**
Xcode 右键 `体己/` 目录 → New Group "Persistence" → 把 FileVault.swift 拖进去,确认 Target Membership 勾选 "体己"。
Xcode 右键 `康康/` 目录 → New Group "Persistence" → 把 FileVault.swift 拖进去,确认 Target Membership 勾选 "康康"。
把 FileVaultTests.swift 拖进 体己Tests target,确认 Target Membership 勾选 "体己Tests"。
把 FileVaultTests.swift 拖进 康康Tests target,确认 Target Membership 勾选 "康康Tests"。
- [ ] **Step 5:跑测试,确认全 pass**
@@ -469,7 +469,7 @@ Expected:`writeAndReadJPEGRoundtrip` / `removeMakesFileGone` / `wipeRemovesAllFi
- [ ] **Step 6:提交**
```bash
git add 体己/Persistence/FileVault.swift 体己Tests/FileVaultTests.swift 体己.xcodeproj
git add 康康/Persistence/FileVault.swift 康康Tests/FileVaultTests.swift 康康.xcodeproj
git commit -m "feat(persistence): add FileVault with complete file protection"
```
@@ -478,17 +478,17 @@ git commit -m "feat(persistence): add FileVault with complete file protection"
## Task 4:ModelStore —— 模型路径与 bundle 旁路(TDD)
**Files:**
- Create: `体己/AI/ModelStore.swift`
- Test: `体己Tests/ModelStoreTests.swift`
- Create: `康康/AI/ModelStore.swift`
- Test: `康康Tests/ModelStoreTests.swift`
- [ ] **Step 1:写失败的测试**
创建 `体己Tests/ModelStoreTests.swift`:
创建 `康康Tests/ModelStoreTests.swift`:
```swift
import Testing
import Foundation
@testable import
@testable import
@MainActor
struct ModelStoreTests {
@@ -537,7 +537,7 @@ struct ModelStoreTests {
- [ ] **Step 3:写 ModelStore 实现**
创建 `体己/AI/ModelStore.swift`:
创建 `康康/AI/ModelStore.swift`:
```swift
import Foundation
@@ -621,8 +621,8 @@ final class ModelStore {
- [ ] **Step 4:Xcode 中把文件加入 target**
右键 `体己/` → New Group "AI" → 拖入 ModelStore.swift,勾 "体己" target。
ModelStoreTests.swift 拖入 体己Tests target。
右键 `康康/` → New Group "AI" → 拖入 ModelStore.swift,勾 "康康" target。
ModelStoreTests.swift 拖入 康康Tests target。
- [ ] **Step 5:跑测试,全绿**
@@ -633,7 +633,7 @@ Expected:3 个测试全 pass。
- [ ] **Step 6:提交**
```bash
git add 体己/AI/ModelStore.swift 体己Tests/ModelStoreTests.swift 体己.xcodeproj
git add 康康/AI/ModelStore.swift 康康Tests/ModelStoreTests.swift 康康.xcodeproj
git commit -m "feat(ai): add ModelStore with path management and bundle seed"
```
@@ -642,8 +642,8 @@ git commit -m "feat(ai): add ModelStore with path management and bundle seed"
## Task 5:TokenChunk + AIRuntime actor 骨架
**Files:**
- Create: `体己/AI/TokenChunk.swift`
- Create: `体己/AI/AIRuntime.swift`
- Create: `康康/AI/TokenChunk.swift`
- Create: `康康/AI/AIRuntime.swift`
本任务**不接 MLX**,只搭骨架。Task 6 才接真模型。
@@ -762,7 +762,7 @@ actor AIRuntime {
- [ ] **Step 4:把文件加入 target**
把 TokenChunk.swift 和 AIRuntime.swift 拖进 AI group,勾 "体己" target。
把 TokenChunk.swift 和 AIRuntime.swift 拖进 AI group,勾 "康康" target。
(此时 Build 还是失败,正常)
@@ -775,7 +775,7 @@ actor AIRuntime {
## Task 6:LLMSession —— 接 MLX 跑 Qwen3-1.7B
**Files:**
- Create: `体己/AI/LLMSession.swift`
- Create: `康康/AI/LLMSession.swift`
**预先准备(开发者手动一次)**:
@@ -798,7 +798,7 @@ Expected:目录里有 `config.json` / `model.safetensors` / `tokenizer.json` 等
- [ ] **Step 2:写 LLMSession 实现**
创建 `体己/AI/LLMSession.swift`:
创建 `康康/AI/LLMSession.swift`:
```swift
import Foundation
@@ -866,7 +866,7 @@ actor LLMSession {
> **注**:`MLXLMCommon` 的具体 API 版本可能在 GenerateParameters/stream 处略有差异。如果 Step 4 编译报错,查看 mlx-swift-examples 仓库 `Libraries/MLXLLM` 的最新示例,以仓库示例为准小幅调整。
- [ ] **Step 3:把 LLMSession.swift 加入 体己 target**
- [ ] **Step 3:把 LLMSession.swift 加入 康康 target**
拖入 AI group,确认 Target Membership。
@@ -878,9 +878,9 @@ Expected:Build Succeeded。
若 MLX API 签名不匹配,参考 https://github.com/ml-explore/mlx-swift-examples 中 `Libraries/MLXLLM` 的最新 LLM 示例修正。
- [ ] **Step 5:在 TijiApp 启动时打印沙盒路径(临时调试)**
- [ ] **Step 5:在 KangkangApp 启动时打印沙盒路径(临时调试)**
打开 `体己/App/TijiApp.swift`,在 `WindowGroup { RootView() }` 内加一个 `.onAppear`:
打开 `康康/App/KangkangApp.swift`,在 `WindowGroup { RootView() }` 内加一个 `.onAppear`:
```swift
.onAppear {
@@ -912,7 +912,7 @@ cp -R ~/tiji-models/Qwen3-1.7B-MLX-4bit "$APP_SUPPORT/Models/"
- [ ] **Step 7:提交(本任务 + Task 5 一起)**
```bash
git add 体己/AI/ 体己/App/TijiApp.swift 体己.xcodeproj
git add 康康/AI/ 康康/App/KangkangApp.swift 康康.xcodeproj
git commit -m "feat(ai): add AIRuntime actor and LLMSession with MLX Qwen3-1.7B"
```
@@ -921,12 +921,12 @@ git commit -m "feat(ai): add AIRuntime actor and LLMSession with MLX Qwen3-1.7B"
## Task 7:DebugAIRunner —— DEBUG 测试入口
**Files:**
- Create: `体己/Debug/DebugAIRunner.swift`
- Modify: `体己/Features/Me/MeView.swift`
- Create: `康康/Debug/DebugAIRunner.swift`
- Modify: `康康/Features/Me/MeView.swift`
- [ ] **Step 1:创建 DebugAIRunner**
`体己/Debug/DebugAIRunner.swift`:
`康康/Debug/DebugAIRunner.swift`:
```swift
#if DEBUG
@@ -1000,7 +1000,7 @@ struct DebugAIRunner: View {
- [ ] **Step 2:在 MeView 末尾挂上(仅 DEBUG)**
打开 `体己/Features/Me/MeView.swift`,把现有内容整体替换为:
打开 `康康/Features/Me/MeView.swift`,把现有内容整体替换为:
```swift
import SwiftUI
@@ -1027,7 +1027,7 @@ struct MeView: View {
- [ ] **Step 3:在 Xcode 中加入文件**
右键 `体己/` → New Group "Debug" → 拖入 DebugAIRunner.swift,勾 "体己" target。
右键 `康康/` → New Group "Debug" → 拖入 DebugAIRunner.swift,勾 "康康" target。
- [ ] **Step 4:Build,确认 OK**
@@ -1036,7 +1036,7 @@ struct MeView: View {
- [ ] **Step 5:提交**
```bash
git add 体己/Debug/ 体己/Features/Me/MeView.swift 体己.xcodeproj
git add 康康/Debug/ 康康/Features/Me/MeView.swift 康康.xcodeproj
git commit -m "chore(debug): add AI self-test runner in MeView (DEBUG only)"
```
@@ -1092,7 +1092,7 @@ git commit --allow-empty -m "milestone: W2 LLM 自检通过 (simulator)"
## Task 9:加一组 schema 重建烟测(防回归)
**Files:**
- Create: `体己Tests/ModelsSchemaTests.swift`
- Create: `康康Tests/ModelsSchemaTests.swift`
- [ ] **Step 1:写 schema 烟测**
@@ -1100,7 +1100,7 @@ git commit --allow-empty -m "milestone: W2 LLM 自检通过 (simulator)"
import Testing
import SwiftData
import Foundation
@testable import
@testable import
@MainActor
struct ModelsSchemaTests {
@@ -1179,7 +1179,7 @@ struct ModelsSchemaTests {
}
```
- [ ] **Step 2:加入 体己Tests target,跑测试**
- [ ] **Step 2:加入 康康Tests target,跑测试**
⌘U。
@@ -1190,7 +1190,7 @@ Expected:3 个测试全 pass。
- [ ] **Step 3:提交**
```bash
git add 体己Tests/ModelsSchemaTests.swift 体己.xcodeproj
git add 康康Tests/ModelsSchemaTests.swift 康康.xcodeproj
git commit -m "test(models): add schema smoke tests for relationships and cascade"
```

View File

@@ -1,4 +1,4 @@
# 康记 / 体己 —— 功能设计 Spec(v1.0)
# 康 —— 功能设计 Spec(v1.0)
**日期**:2026-05-25
**状态**:Draft, 已与产品方对齐 §1-§6
@@ -8,7 +8,7 @@
## 0. 概要
是一个 iOS 原生健康影像档案 App,**100% 端侧 AI 推理**,基于 SwiftUI + SwiftData + MLX Swift,目标 6 周交付决赛 demo。本 spec 把原始功能清单收敛为 **方案 B**:核心 5 模块 + Live Activity + 分享摘要,其余 P2/P3 全部 deferred。
是一个 iOS 原生健康影像档案 App,**100% 端侧 AI 推理**,基于 SwiftUI + SwiftData + MLX Swift,目标 6 周交付决赛 demo。本 spec 把原始功能清单收敛为 **方案 B**:核心 5 模块 + Live Activity + 分享摘要,其余 P2/P3 全部 deferred。
**5 大核心模块**
@@ -77,7 +77,7 @@ Persistence
### 2.1 `AIRuntime` 接口
```
体己/AI/
康康/AI/
├── AIRuntime.swift // actor 单例,推理串行化
├── ModelStore.swift // 模型路径管理 + 下载 + bundle 旁路
├── LLMSession.swift // Qwen3-1.7B 文本生成,流式
@@ -376,7 +376,7 @@ User → UI(B2Scan) → CaptureService → AIRuntime → Persistence
### 4.3 服务层文件
```
体己/AI/ [7.5d]
康康/AI/ [7.5d]
├── AIRuntime.swift 2d
├── ModelStore.swift 1d
├── LLMSession.swift 1d
@@ -387,17 +387,17 @@ User → UI(B2Scan) → CaptureService → AIRuntime → Persistence
├── KeywordExtraction.swift
└── TrendNarrative.swift
体己/Services/ [4.5d]
康康/Services/ [4.5d]
├── CaptureService.swift 1.5d
├── AskService.swift 1.5d
├── TrendService.swift 1d
└── ReportCompareService.swift 0.5d
体己/Persistence/ [1d]
康康/Persistence/ [1d]
├── FileVault.swift 0.5d
└── PermanentDelete.swift 0.5d
体己/Security/ [0.5d]
康康/Security/ [0.5d]
└── AppLock.swift 0.5d
```