TRAE指挥官

TotalClaw 作者 vichard998 v1.0.0

协调 TRAE IDE,通过多代理协作进行自动化软件开发。当用户想要使用 TRAE 开发软件或需要自动化项目管理时调用。

源码 ↗

安装 / 下载方式

TotalClaw CLI推荐
totalclaw install totalclaw:vichard998~trae-orchestrator
cURL直接下载,无需登录
curl -fsSL https://skills.taituai.com/api/skills/totalclaw%3Avichard998~trae-orchestrator/file -o trae-orchestrator.md
Git 仓库获取源码
git clone https://github.com/openclaw/skills/commit/2068cb01c12f3256799ab03dfb559d81824ad68e
# TRAE Orchestrator

Automated software development controller that orchestrates TRAE IDE for fully autonomous project delivery.

## When to Invoke

- User wants to develop software using TRAE
- User needs automated project management
- User provides software requirements and project directory
- User asks for multi-agent development workflow
- User wants to automate TRAE with Python scripts

## Quick Start (Recommended)

### One-Line Project Launch

```python
from automation_helper import quick_start

# 一键启动项目
quick_start(
    project_dir='D:\\MyProject',
    requirements={
        'name': '我的项目',
        'description': '项目描述...',
        'features': ['功能1', '功能2'],
        'tech_stack': 'Node.js + React'
    }
)
```

This will:
1. ✅ Create project structure
2. ✅ Create requirements.md
3. ✅ Create prompt for TRAE
4. ✅ Launch TRAE IDE
5. ✅ Send development task to TRAE

## Automation Helper Module

A practical Python module (`automation_helper.py`) is provided for easy automation:

### TRAEController - IDE Controller

```python
from automation_helper import TRAEController

# Initialize (auto-detects TRAE path)
controller = TRAEController()
# Or specify path
controller = TRAEController('E:\\software\\Trae CN\\Trae CN.exe')

# First-time setup
controller.setup('E:\\software\\Trae CN\\Trae CN.exe')

# Launch TRAE with project
controller.launch('D:\\MyProject')

# Send prompt (requires pyautogui)
controller.send_prompt("Create a web app...", delay=5)
```

### ProjectManager - Project Setup

```python
from automation_helper import ProjectManager

# Create project structure
ProjectManager.create_project(
    project_dir='D:\\MyProject',
    requirements={
        'name': '星空篝火游戏',
        'description': '多人联机游戏',
        'features': ['3D场景', '多人联机', '聊天系统'],
        'tech_stack': 'Three.js + Node.js'
    }
)

# Create prompt for TRAE
ProjectManager.create_prompt('D:\\MyProject')
```

### ProgressMonitor - Monitor Progress

```python
from automation_helper import ProgressMonitor

# Monitor project progress
monitor = ProgressMonitor('D:\\MyProject')

# Check signals
if monitor.check_signal('project_done'):
    print("Project complete!")

# Get status summary
status = monitor.get_status()
print(status)

# Wait for completion
monitor.wait_for_completion(timeout=3600)  # 1 hour timeout
```

### User Control Functions

```python
from automation_helper import pause_project, resume_project, stop_project

pause_project('D:\\MyProject')   # Pause
resume_project('D:\\MyProject')  # Resume
stop_project('D:\\MyProject')    # Stop
```

## Token Optimization Strategy

### CRITICAL: Minimize openclaw Token Usage

| openclaw Does | TRAE Does (Free) |
|---------------|------------------|
| Orchestrate workflow | All code generation |
| Read only: task_plan.md, progress.md | Read/write all source files |
| Send prompts | Execute prompts |
| Detect completion | Self-check quality |
| Intervene on loops | Auto-fix bugs (3 attempts) |

### Event-Driven Completion Detection (No Polling!)

**DO NOT poll every 30 seconds.** Use these efficient methods:

#### Method 1: Signal File (Most Efficient)

TRAE creates a signal file when done - openclaw only checks if file exists:

```
# In prompt, instruct TRAE:
"When phase complete, create file: .trae-docs/.signal_{PHASE}_DONE"

# openclaw checks:
if os.path.exists('.trae-docs/.signal_planning_done'):
    # Phase complete, read progress.md once
    # Delete signal file after reading
```

**Token cost: 0** (file existence check is free)

#### Method 2: File Modification Time

Only read when timestamp changes:

```python
last_mtime = 0

def check_progress():
    global last_mtime
    current_mtime = os.path.getmtime('.trae-docs/progress.md')
    if current_mtime > last_mtime:
        last_mtime = current_mtime
        return read_file('.trae-docs/progress.md')
    return None  # No change, don't read
```

**Token cost: 0** until file actually changes

#### Method 3: Watchdog File Monitor (Background)

Use filesystem events instead of polling:

```python
from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler

class ProgressHandler(FileSystemEventHandler):
    def on_modified(self, event):
        if 'progress.md' in event.src_path:
            # File changed, now read it
            content = read_file(event.src_path)
            process_status(content)

observer = Observer()
observer.schedule(ProgressHandler(), path='.trae-docs/')
observer.start()
```

**Token cost: 0** until file changes, then only 1 read

### Recommended: Signal File + Timestamp Combo

```
┌─────────────────────────────────────────────────────────┐
│  TRAE completes task                                    │
│       ↓                                                 │
│  TRAE creates .signal_done (empty file)                 │
│       ↓                                                 │
│  openclaw detects signal file exists (0 tokens)         │
│       ↓                                                 │
│  openclaw reads progress.md once                        │
│       ↓                                                 │
│  openclaw deletes signal file                           │
│       ↓                                                 │
│  openclaw sends next prompt                             │
└─────────────────────────────────────────────────────────┘
```

## First-Time Setup

### Step 1: Get TRAE Installation Path

```
Ask user: "Please provide the TRAE installation directory path"
Example: "C:\Users\XXX\AppData\Local\Programs\Trae CN"
```

### Step 2: Verify and Save

1. Check if directory contains `Trae CN.exe`
2. Launch TRAE to verify it works
3. Save to `config.json`:
```json
{
  "trae_install_path": "USER_PROVIDED_PATH",
  "trae_executable": "Trae CN.exe",
  "window_identifier": "Trae CN",
  "max_instances": 3,
  "version": "1.0.0"
}
```

## Project Structure

```
{project_dir}/
├── .trae-docs/
│   ├── requirements.md    # User requirements
│   ├── architecture.md    # System design
│   ├── task_plan.md       # Development plan
│   ├── progress.md        # Current status (openclaw reads this)
│   └── review_log.md      # Review history
└── src/                   # Generated code (TRAE manages)
```

## Super-Efficient Workflow

### Phase 1: Planning (One Prompt)

**Send single comprehensive prompt:**

```
Develop [SOFTWARE_TYPE] with these requirements:

[REQUIREMENTS]

Tech stack: [TECHNOLOGIES]

INSTRUCTIONS:
1. Create .trae-docs/architecture.md with system design
2. Create .trae-docs/task_plan.md with task breakdown
3. Create .trae-docs/progress.md with initial status
4. Each task must be completable within 200k tokens
5. Include acceptance criteria for each task
6. Mark task dependencies clearly

COMPLETION SIGNAL:
When done, create empty file: .trae-docs/.signal_planning_done
Also update progress.md with:
STATUS: PLANNING_COMPLETE
TASKS_TOTAL: N
ESTIMATED_TOKENS: N

Use SOLO mode. Work autonomously.
```

**Detection:** Check if `.signal_planning_done` exists (0 tokens), then read `progress.md` once.

### Phase 2: Batch Implementation

**Send tasks in batches (not one by one):**

```
BATCH IMPLEMENTATION - Tasks [START_ID] to [END_ID]

Read .trae-docs/task_plan.md for task details.

For each task:
1. Implement following architecture.md
2. Write unit tests
3. Update progress.md with completion status
4. Mark task as [x] in task_plan.md

COMPLETION SIGNAL:
After ALL tasks in batch:
1. Create empty file: .trae-docs/.signal_batch_[N]_done
2. Update progress.md with:
   STATUS: BATCH_[N]_COMPLETE
   COMPLETED_TASKS: [IDs]
   REMAINING_TASKS: [IDs]

Work autonomously in SOLO mode.
```

**Detection:** Check if `.signal_batch_N_done` exists (0 tokens), then read `progress.md` once.

### Phase 3: Self-Review

**Let TRAE review itself:**

```
SELF-REVIEW PHASE

Review all implemented code:
1. Check against requirements.md
2. Run all tests
3. Check code quality
4. Document issues in review_log.md

If issues found:
- Fix them automati