Files
momentry_core/tools/README.md
T
Accusys 8ab6802bff feat: add MOMENTRY_CLI_DIR configuration
添加 CLI 工具路徑配置:
- admin_config.rs: 新增 cli_dir 字段和 get_cli_dir() 函數
- config.rs: 新增 CLI_DIR 常量
- 默認路徑: /Users/accusys/momentry_core_0.1/tools/cli

環境變數:
- MOMENTRY_SCRIPTS_DIR: Python 腳本路徑
- MOMENTRY_CLI_DIR: Swift/Rust CLI 工具路徑

文檔更新:
- tools/README.md: 環境變數配置說明
- AGENTS.md: 環境變數列表更新
2026-09-27 12:13:27 +08:00

180 lines
3.6 KiB
Markdown

---
title: Tools Directory
version: 1.1
date: 2026-09-27
author: OpenCode
status: migrated
---
## 目錄結構
```
tools/
├── script/ # Python 處理器腳本
│ ├── asr/ # ASR 處理器
│ ├── face/ # Face 處理器
│ ├── pose/ # Pose 處理器
│ ├── cut/ # Cut 處理器
│ ├── ocr/ # OCR 處理器
│ ├── vlm/ # VLM 處理器
│ ├── embedding/ # Embedding 服務器
│ ├── identity/ # Identity 處理器
│ └── utils/ # 工具腳本
└── cli/ # Swift/Rust CLI 工具
├── swift/ # Swift 處理器
└── rust/ # Rust 處理器
```
## Python 腳本 (script/)
### ASR
- `asr_processor_base.py` - ASR 基礎類
- `asr_processor_contract_v1.py` - ASR V1 合約
- `asr_processor_contract_v2.py` - ASR V2 合約
### Face
- `face_processor.py` - Face 處理器
- `store_traced_faces.py` - Face 追蹤存儲
### Pose
- `pose_processor.py` - Pose 處理器
### Cut
- `cut_processor.py` - Cut 處理器
### OCR
- `ocr_processor.py` - OCR 處理器
### VLM
- `tkg_builder.py` - TKG Builder
- `appearance_processor_v2.py` - Appearance 處理器
### Embedding
- `embeddinggemma_server.py` - Embedding 服務器
### Identity
- `identity_agent.py` - Identity Agent
- `identity_bind.py` - Identity 綁定
- `identity_matcher.py` - Identity 匹配
## CLI 工具 (cli/)
### Swift
**處理器**:
- `asr_swift.swift` - ASR Swift 處理器
- `asrx_swift.swift` - ASRX Swift 處理器
- `swift_face.swift` - Face Swift 處理器
- `swift_pose.swift` - Pose Swift 處理器
- `swift_ocr.swift` - OCR Swift 處理器
- `swift_hand.swift` - Hand Swift 處理器
- `swift_face_pose.swift` - Face+Pose Swift 處理器
**擴展**:
- `swift_appearance_expansion.swift` - Appearance 擴展
- `swift_pose_expansion.swift` - Pose 擴展
**測試**:
- `face_vision_test.swift`
- `pose_benchmark.swift`
- `speaker_test.swift`
### Rust
獨立的 Rust CLI 工具項目,包含:
- Face Cluster
- Appearance
- Pose
## 使用方式
### Python 腳本
```bash
# ASR
python3 tools/script/asr/asr_processor_contract_v2.py
# Face
python3 tools/script/face/face_processor.py
# TKG
python3 tools/script/vlm/tkg_builder.py
```
### Swift CLI
```bash
# 編譯
cd tools/cli/swift
swift build
# 運行
swift run asr_swift
swift run swift_face
```
### Rust CLI
```bash
# 編譯
cd tools/cli/rust
cargo build --release
# 運行
./target/release/face_cluster
./target/release/appearance
```
## 環境變數配置
### 腳本路徑
```bash
# Python 腳本路徑
export MOMENTRY_SCRIPTS_DIR=/Users/accusys/momentry_core/tools/script
# CLI 工具路徑
export MOMENTRY_CLI_DIR=/Users/accusys/momentry_core/tools/cli
```
### 其他路徑
```bash
# 輸出路徑
export MOMENTRY_OUTPUT_DIR=/Users/accusys/momentry/output
# Python 路徑
export MOMENTRY_PYTHON_PATH=/opt/homebrew/bin/python3.11
```
## Rust 代碼中使用
```rust
use crate::core::config::{SCRIPTS_DIR, CLI_DIR};
// 獲取腳本路徑
let scripts_dir = SCRIPTS_DIR.as_str();
// 獲取 CLI 路徑
let cli_dir = CLI_DIR.as_str();
```
## 遷移說明
### 來源
- Python: `scripts/` → `tools/script/`
- Swift: `scripts/swift_processors/` → `tools/cli/swift/`
- Rust: `scripts/rust_processors/` → `tools/cli/rust/`
### 原路徑保留
舊路徑 `scripts/` 仍然存在,可以繼續使用。
新代碼建議使用 `tools/` 路徑。
## 相關文檔
- `/Users/accusys/momentry_core/docs_v1.0/DESIGN/Tools_Directory_Restructure.md`
- `/Users/accusys/momentry_core/AGENTS.md` - 環境變數配置