██ ██ ██ ██ ██████ ██████ █████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ███████ ████ ██ ██ ██████ ███████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██████ ██ ██ ██ ██
简体中文 · Why · Benchmark · Install · Quick Start · Workflow · Architecture · Review Layer
|
CANN operator development means writing Hydra replaces manual iteration with a team of AI agents that work in parallel:
|
Linux / macOS: curl -fsSL https://raw.githubusercontent.com/lggyx/Hydra/main/install.sh | bashWindows: iwr -useb https://raw.githubusercontent.com/lggyx/Hydra/main/install.ps1 | iexAuto-detects your environment, installs dependencies, builds from source. No manual setup required. |
Same task (Mul, Add, Pow operator implementation for ops-math), same LLM, different architecture.
| 指标 | Hydra Multi-Agent | OpenCode Single-Agent | 提升 |
|---|---|---|---|
| 测试通过率 | 96.7% | 73.3% | +23.4pp |
| 行覆盖率 | 87.1% | 58.4% | +28.7pp |
| 平均执行时间 | 48.3μs | 112.7μs | 2.3x faster |
| 质量评分 | 4.7 | 2.3 | 2.0x |
| P0 问题 | 0 | 5 | — |
| 开发时长 | ~3 min | ~8 min | 2.7x faster |
Why multi-agent wins: Orchestrator decomposes tasks into parallel, single-operator units. Each ExecutionAgent focuses on one operator — no context switching, no long-session fatigue. The cannbot-skills review gate catches errors that a single agent misses.
|
Linux / macOS: curl -fsSL https://raw.githubusercontent.com/lggyx/Hydra/main/install.sh | bashWindows (PowerShell): iwr -useb https://raw.githubusercontent.com/lggyx/Hydra/main/install.ps1 | iex |
# Requires Rust 1.88+
git clone https://github.com/lggyx/Hydra.git
cd Hydra
cargo build --release
# Or use the install script
bash install.sh --build-from-source |
# Terminal 1: Start the daemon
hydra-daemon
# Terminal 2: Launch the TUI
hydraIn the TUI:
| Step | Command | Description |
|---|---|---|
| Login | /login |
Get free API quota |
| Create orchestrator | /agents create --kind orchestrator |
Spin up the manager agent |
| Deploy task | /agents <id> start "implement Mul operator with full tests" |
Orchestrator spawns workers |
| Monitor | /agents |
List all agents and their status |
| Inspect | /agents <id> events |
View detailed event history |
flowchart TB
U[User Task: implement Mul, Add, Pow operators]
U --> O[OrchestratorAgent]
O --> |spawn_execution| E1[ExecutionAgent #1: Mul]
O --> |spawn_execution| E2[ExecutionAgent #2: Add]
O --> |spawn_execution| E3[ExecutionAgent #3: Pow]
E1 --> |op_api + op_host + op_kernel| B1[Build + Test]
E2 --> |op_api + op_host + op_kernel| B2[Build + Test]
E3 --> |op_api + op_host + op_kernel| B3[Build + Test]
B1 --> R[cannbot-skills Review Layer]
B2 --> R
B3 --> R
R --> |Lint + Correctness + Perf + Accuracy| G{Merge Gate}
G --> |Pass| F[declare_complete]
G --> |Fail| FB[Auto-feedback to Agent]
FB --> E1
FB --> E2
FB --> E3
Detailed workflow: docs/cann-operator-workflow.md
flowchart TB
subgraph "User Interface"
CLI["hydra CLI"]
TUI["TUI Monitor"]
end
subgraph "API Layer"
REST["REST Server<br/>axum"]
SSE["SSE Event Stream"]
end
subgraph "Core Engine"
RM["ResourceManager"]
REG["AgentRegistry"]
BUS["EventBus"]
TOOLS["ToolRegistry"]
end
subgraph "Agent Layer"
E1["ExecutionAgent #1"]
E2["ExecutionAgent #2"]
O1["OrchestratorAgent"]
end
subgraph "CANN Review"
CANN["cannbot-skills<br/>Review Layer"]
end
CLI --> REST
TUI --> REST
TUI --> SSE
REST --> RM
SSE --> BUS
RM --> REG
RM --> BUS
RM --> TOOLS
BUS --> O1
O1 --> E1
O1 --> E2
E1 --> CANN
E2 --> CANN
CANN --> RM
hydra/
crates/
hydra-core/ # Agent trait system + TurnRunner + tools
agent/
traits.rs # Agent trait, AgentId/Kind/State/Outcome
execution.rs # ExecutionAgent — per-operator worker
orchestrator.rs # OrchestratorAgent — task coordination
resource_manager.rs # Registry + event fan-out
hydra-daemon/ # HTTP/SSE API server
api_agent.rs # Agent CRUD, SSE stream, orchestration bridge
hydra-tuix/ # Terminal UI (retained-mode renderer)
hydra-cli/ # Binary entry point
| Agent | Role | CANN Pipeline Role |
|---|---|---|
| OrchestratorAgent | Task decomposition, coordination | Splits ops-math into per-operator sub-tasks |
| ExecutionAgent | Implementation, build, test | Writes op_api/host/kernel per operator |
| ReviewerAgent (planned) | Code review, benchmark | cannbot-skills: lint, correctness, perf, accuracy |
stateDiagram-v2
[*] --> Created
Created --> Running : spawn
Running --> Running : turn loop
Running --> WaitingInput : respond
WaitingInput --> Running : append_input
Running --> Completed : declare_complete
Running --> Killed : cancel
Running --> Failed : error
Completed --> [*]
Killed --> [*]
Failed --> [*]
| # | Principle |
|---|---|
| P1 | Unified Agent Interface — All agents share the Agent trait |
| P2 | Parallel by Default — N operators = N concurrent ExecutionAgents |
| P3 | Review Gate — Every output passes through cannbot-skills |
| P4 | Performance-Aware — Agents understand CANN profiling and optimize |
| P5 | Accuracy First — Tolerance-aware comparison vs reference implementations |
| P6 | Domain-Aware — Built-in op_api/host/kernel three-layer knowledge |
/provider add anthropic --api-key $ANTHROPIC_API_KEY
/provider default anthropic
# Or use the free quota
/loginSupports Anthropic, OpenAI, DeepSeek, MiniMax, GLM, Qwen, Ollama, and any OpenAI-compatible API.
Create .hydra.md in your CANN project root:
# CANN Operator Development Instructions
- Target: Ascend 910B, CANN 8.0.RC1
- Operators: Math (Mul, Add, Pow), Activation (ReLU, GELU)
- Structure: op_api / op_host / op_kernel three-layer pattern
- Test: ops-math suite with gcov coverage
- Perf: within 5% of hand-tuned baseline
- Prefer Vector API where applicable
cargo build -p hydra-daemon -p hydra-cli
cargo test -p hydra-daemon
cargo test -p hydra-core --test contract_connectivity |
MIT License · View License