docs: add Tools Architecture section to AGENTS.md
新增內容: - Tools 目錄結構 (tools/cli/, tools/script/) - Rust CLI 工具列表及說明 - Swift CLI 工具列表及說明 - Python Scripts 分類說明 - 環境變數更新 - Worker 整合機制 - Legacy 位置標記 (待清理) 更新: - MOMENTRY_SCRIPTS_DIR 預設路徑 - MOMENTRY_CLI_DIR 預設路徑 目的: - 統一工具架構規範 - 明確遷移狀態 - 方便開發者遵循
This commit is contained in:
@@ -531,6 +531,139 @@ src/
|
||||
└── watcher/ # File system watcher
|
||||
```
|
||||
|
||||
## Tools Architecture
|
||||
|
||||
### Directory Structure
|
||||
|
||||
```
|
||||
tools/
|
||||
├── cli/ # Compiled CLI binaries
|
||||
│ ├── rust/ # Rust CLI tools
|
||||
│ │ ├── src/
|
||||
│ │ │ └── bin/ # Binary source files
|
||||
│ │ │ ├── rust_appearance.rs
|
||||
│ │ │ ├── rust_face_cluster.rs
|
||||
│ │ │ ├── rust_pose.rs
|
||||
│ │ │ └── rust_vad.rs
|
||||
│ │ ├── Cargo.toml
|
||||
│ │ └── target/ # Build output
|
||||
│ │ └── release/ # Release binaries
|
||||
│ └── swift/ # Swift CLI tools
|
||||
│ ├── Sources/
|
||||
│ ├── Package.swift
|
||||
│ └── .build/ # Build output
|
||||
│ └── release/
|
||||
└── script/ # Python scripts (organized by processor)
|
||||
├── asr/ # ASR scripts
|
||||
├── chunk/ # Chunking scripts
|
||||
├── cut/ # Cut detection scripts
|
||||
├── embedding/ # Embedding scripts
|
||||
├── face/ # Face processing scripts
|
||||
├── identity/ # Identity management scripts
|
||||
├── ocr/ # OCR scripts
|
||||
├── pose/ # Pose estimation scripts
|
||||
├── scene/ # Scene detection scripts
|
||||
├── utils/ # Utility scripts
|
||||
├── vlm/ # Vision Language Model scripts
|
||||
├── worker/ # Worker scripts
|
||||
└── yolo/ # YOLO detection scripts
|
||||
```
|
||||
|
||||
### Tool Categories
|
||||
|
||||
#### Rust CLI Tools (tools/cli/rust/)
|
||||
|
||||
| Binary | Purpose | Status |
|
||||
|--------|---------|--------|
|
||||
| `rust_appearance` | Face appearance analysis | ✅ Working |
|
||||
| `rust_face_cluster` | Face clustering | ✅ Working |
|
||||
| `rust_pose` | Pose interpolation | ✅ Working |
|
||||
| `rust_vad` | Voice Activity Detection | ✅ Working |
|
||||
|
||||
**Build**:
|
||||
```bash
|
||||
cd tools/cli/rust
|
||||
cargo build --release
|
||||
```
|
||||
|
||||
**Usage**:
|
||||
```bash
|
||||
# Worker automatically finds binaries in tools/cli/rust/target/release/
|
||||
# Set MOMENTRY_USE_RUST_PROCESSORS=true to enable
|
||||
```
|
||||
|
||||
#### Swift CLI Tools (tools/cli/swift/)
|
||||
|
||||
| Binary | Purpose | Status |
|
||||
|--------|---------|--------|
|
||||
| `swift_pose` | Apple Vision Pose | ✅ Working |
|
||||
| `swift_face` | Apple Vision Face | ✅ Working |
|
||||
| `swift_scene` | Scene detection | ✅ Working |
|
||||
| `swift_yolo` | YOLO detection | ✅ Working |
|
||||
|
||||
**Build**:
|
||||
```bash
|
||||
cd tools/cli/swift
|
||||
swift build -c release
|
||||
```
|
||||
|
||||
#### Python Scripts (tools/script/)
|
||||
|
||||
Organized by processor type. Each directory contains related scripts.
|
||||
|
||||
| Directory | Purpose |
|
||||
|-----------|---------|
|
||||
| `asr/` | ASR (Automatic Speech Recognition) |
|
||||
| `chunk/` | Sentence chunking |
|
||||
| `cut/` | Cut detection |
|
||||
| `embedding/` | Vector embedding generation |
|
||||
| `face/` | Face detection, tracking, clustering |
|
||||
| `identity/` | Identity management |
|
||||
| `ocr/` | Optical Character Recognition |
|
||||
| `pose/` | Pose estimation (MediaPipe, YOLOv8) |
|
||||
| `scene/` | Scene detection |
|
||||
| `utils/` | Shared utilities |
|
||||
| `vlm/` | Vision Language Model (VLM) |
|
||||
| `worker/` | Worker-specific scripts |
|
||||
| `yolo/` | YOLO object detection |
|
||||
|
||||
### Environment Variables
|
||||
|
||||
- `MOMENTRY_SCRIPTS_DIR` - Scripts directory (default: `tools/script/`)
|
||||
- `MOMENTRY_CLI_DIR` - CLI tools directory (default: `tools/cli/`)
|
||||
- `MOMENTRY_USE_RUST_PROCESSORS` - Enable Rust processors (default: `false`)
|
||||
|
||||
### Worker Integration
|
||||
|
||||
The Worker (`src/core/processor/executor.rs`) automatically locates tools:
|
||||
|
||||
1. **Python Scripts**: `tools/script/<processor>/`
|
||||
2. **Rust Binaries**: `tools/cli/rust/target/release/`
|
||||
3. **Swift Binaries**: `tools/cli/swift/.build/release/`
|
||||
|
||||
**Priority Order**:
|
||||
1. Python scripts (default)
|
||||
2. Rust binaries (if `MOMENTRY_USE_RUST_PROCESSORS=true`)
|
||||
3. Swift binaries (for Apple Vision processors)
|
||||
|
||||
### Legacy Locations (To Be Removed)
|
||||
|
||||
⚠️ The following locations are deprecated and will be removed:
|
||||
|
||||
- `scripts/rust_processors/` → Migrate to `tools/cli/rust/`
|
||||
- `scripts/swift_processors/` → Migrate to `tools/cli/swift/`
|
||||
- `scripts/*.py` (scattered) → Migrate to `tools/script/<processor>/`
|
||||
|
||||
### Migration Status
|
||||
|
||||
| Component | Current Location | Target Location | Status |
|
||||
|-----------|-----------------|-----------------|--------|
|
||||
| Rust CLI | `tools/cli/rust/` | `tools/cli/rust/` | ✅ Done |
|
||||
| Swift CLI | `tools/cli/swift/` | `tools/cli/swift/` | ✅ Done |
|
||||
| Python Scripts | `tools/script/` | `tools/script/` | ✅ Done |
|
||||
| Legacy Rust | `scripts/rust_processors/` | Remove | ⚠️ Pending |
|
||||
| Legacy Swift | `scripts/swift_processors/` | Remove | ⚠️ Pending |
|
||||
|
||||
## Key Dependencies
|
||||
|
||||
- **Error handling**: `anyhow`, `thiserror`
|
||||
@@ -567,8 +700,8 @@ cargo run --features player --bin momentry_player -- -o
|
||||
### Paths
|
||||
- `MOMENTRY_OUTPUT_DIR` - Output directory (default: `/Users/accusys/momentry/output`)
|
||||
- `MOMENTRY_BACKUP_DIR` - Backup directory
|
||||
- `MOMENTRY_SCRIPTS_DIR` - Scripts directory (default: `/Users/accusys/momentry_core_0.1/tools/script`)
|
||||
- `MOMENTRY_CLI_DIR` - CLI tools directory (default: `/Users/accusys/momentry_core_0.1/tools/cli`)
|
||||
- `MOMENTRY_SCRIPTS_DIR` - Scripts directory (default: `tools/script/`)
|
||||
- `MOMENTRY_CLI_DIR` - CLI tools directory (default: `tools/cli/`)
|
||||
- `MOMENTRY_PYTHON_PATH` - Python path (default: `/opt/homebrew/bin/python3.11`)
|
||||
|
||||
### Critical Variables for Startup Scripts
|
||||
|
||||
Reference in New Issue
Block a user