docs: add ToolSelector V3 integration status report
當前狀態: - ✅ ProcessorConfigV3 模組完成 - ✅ ToolSelector V3 支持完成 - 🔄 Processor 更新進行中 Processor 狀態: - POSE: 使用 ToolSelector,需要添加 Rust CLI 支持 - FACE: 使用 ToolSelector,需要添加 Rust CLI 支持 - FACE_TRACE: 直接調用 CLI - CUT: 直接調用 CLI 問題: - 當前手動構建 args,未使用 tool.args - 缺少 Rust CLI 分支 下一步: 1. 更新 pose.rs 添加 Rust CLI 支持 2. 更新 face.rs 同上 3. 測試 V3 配置
This commit is contained in:
@@ -0,0 +1,185 @@
|
||||
---
|
||||
title: ToolSelector V3 Integration Status
|
||||
version: 1.0
|
||||
date: 2026-09-28
|
||||
author: OpenCode
|
||||
status: in_progress
|
||||
---
|
||||
|
||||
## 當前狀態
|
||||
|
||||
### ✅ 已完成
|
||||
|
||||
1. **ProcessorConfigV3 模組** ✅
|
||||
- `src/core/processor/processor_config_v3.rs`
|
||||
- 動態配置加載
|
||||
- 變量替換支持
|
||||
|
||||
2. **ToolSelector V3 支持** ✅
|
||||
- `select_tool_v3()` 方法
|
||||
- 自動降級到 V2
|
||||
- `SelectedTool` 新增 `args` 和 `timeout`
|
||||
|
||||
---
|
||||
|
||||
### 🔄 進行中
|
||||
|
||||
**Processor 更新**:
|
||||
|
||||
| Processor | 使用 ToolSelector | 需要更新 |
|
||||
|-----------|-------------------|----------|
|
||||
| POSE | ✅ | 需要使用 `tool.args` |
|
||||
| FACE | ✅ | 需要使用 `tool.args` |
|
||||
| FACE_TRACE | ❌ | 直接調用 CLI |
|
||||
| CUT | ❌ | 直接調用 CLI |
|
||||
|
||||
---
|
||||
|
||||
## 當前實現
|
||||
|
||||
### POSE (pose.rs)
|
||||
|
||||
**當前**:
|
||||
```rust
|
||||
match tool.name.as_str() {
|
||||
"mediapipe" => {
|
||||
executor.run_with_frames("pose_processor_mediapipe.py", ...)
|
||||
}
|
||||
"swift" => {
|
||||
let mut args = vec![...]; // 手動構建
|
||||
tokio::process::Command::new(&tool.path)
|
||||
.args(&args)
|
||||
.output()
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**需要改進**:
|
||||
- 使用 `tool.args` 而不是手動構建
|
||||
- 支持 Rust CLI (`rust_pose`)
|
||||
|
||||
---
|
||||
|
||||
### FACE (face.rs)
|
||||
|
||||
**當前**: 類似 POSE
|
||||
|
||||
**需要改進**: 同上
|
||||
|
||||
---
|
||||
|
||||
## 問題分析
|
||||
|
||||
### 為什麼沒有使用 tool.args?
|
||||
|
||||
1. **歷史原因**: V1/V2 配置沒有 args 字段
|
||||
2. **硬編碼**: 參數在代碼中手動構建
|
||||
3. **缺少分支**: 沒有 Rust CLI 的分支
|
||||
|
||||
---
|
||||
|
||||
## 更新策略
|
||||
|
||||
### Phase 1: 添加 Rust CLI 支持
|
||||
|
||||
```rust
|
||||
match tool.name.as_str() {
|
||||
"rust" => {
|
||||
// 使用 tool.args
|
||||
let output = tokio::process::Command::new(&tool.path)
|
||||
.args(&tool.args) // ← 使用配置中的 args
|
||||
.output()
|
||||
.await?;
|
||||
}
|
||||
"swift" => {
|
||||
// 保持現有實現或改用 tool.args
|
||||
}
|
||||
"mediapipe" | "python" => {
|
||||
// Python 腳本
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Phase 2: 統一使用 tool.args
|
||||
|
||||
```rust
|
||||
match tool.name.as_str() {
|
||||
"rust" | "swift" => {
|
||||
// CLI 工具
|
||||
let output = tokio::process::Command::new(&tool.path)
|
||||
.args(&tool.args)
|
||||
.output()
|
||||
.await?;
|
||||
}
|
||||
"python" | "mediapipe" | ... => {
|
||||
// Python 腳本
|
||||
executor.run_script(&tool.path, &tool.args, ...)?;
|
||||
}
|
||||
_ => {
|
||||
// 備用
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## V3 配置示例
|
||||
|
||||
### POSE (Rust CLI)
|
||||
|
||||
**配置**:
|
||||
```json
|
||||
{
|
||||
"tool": "rust",
|
||||
"priority": 0,
|
||||
"enabled": true,
|
||||
"command": {
|
||||
"executable": "tools/cli/rust/target/release/rust_pose",
|
||||
"args": [
|
||||
"--video", "{video_path}",
|
||||
"--output", "{output_path}",
|
||||
"--uuid", "{file_uuid}"
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**變量替換**:
|
||||
- `{video_path}` → `/path/to/video.mp4`
|
||||
- `{output_path}` → `/path/to/output.json`
|
||||
- `{file_uuid}` → `b496a688...`
|
||||
|
||||
**結果**:
|
||||
```
|
||||
tool.path = "tools/cli/rust/target/release/rust_pose"
|
||||
tool.args = ["--video", "/path/to/video.mp4", "--output", "/path/to/output.json", "--uuid", "b496a688..."]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 下一步
|
||||
|
||||
### 立即行動
|
||||
|
||||
1. **更新 pose.rs**: 添加 Rust CLI 支持
|
||||
2. **更新 face.rs**: 同上
|
||||
3. **測試**: 驗證 V3 配置工作
|
||||
|
||||
### 中期計劃
|
||||
|
||||
1. 統一 CLI 調用邏輯
|
||||
2. 移除硬編碼參數構建
|
||||
3. 完善錯誤處理
|
||||
|
||||
---
|
||||
|
||||
## 提交記錄
|
||||
|
||||
| Commit | 內容 |
|
||||
|--------|------|
|
||||
| `f371ff1` | ToolSelector V3 支持 |
|
||||
| `dd8b911` | ProcessorConfigV3 模組 |
|
||||
|
||||
---
|
||||
|
||||
**狀態**: 🔄 **ToolSelector V3 集成完成,Processor 更新進行中**
|
||||
Reference in New Issue
Block a user