包含从项目创建至今的全部代码首次入库: 核心框架: - TaskQueue(SQLite,6 种状态,原子 dequeue) - Executor(asyncio 并发,semaphore 限流,agent_role 路由) - Scheduler(APScheduler,三队列独立调度) - Watchdog(超时检测 + 优先级防饥饿) - Scanner(项目扫描,README/TODO/CLAUDE.md 提取) Agent 体系(20+ 角色): - 项目交付组:architect/developer/tester/productizer - 基础技术组:base-architect/validator/hw/os/kernel/lowlevel/system-tester - 算法组:algo-antishake/position/nav - 洞察组:planner/vision-analyst/media-producer - 市场组:market-pm/sport/elder/safety - 组织层:boss/group-leader/senior-dev/ops - 平台扩展:nrf-dev/esp32-dev - 三专项调研:rtp-researcher/net-researcher/kernel-analyzer 工具层: - ProjectMemory(goals/facts/history SQLite) - VersionPipeline(并行版本流水线 + 反幻觉门控) - EventBus(Redis Streams,5 consumer groups) - DailyReport(append-only 日报 + Boss 决策视图) - AgentScorer(4 维评分:完成度/质量/自主性/协作) - DeviceAgent(SSH rsync + 板端执行) - EnvCollector(本机+SSH 环境采集) - ArchVersion(快照/优化/promote/rollback) Dashboard(React + Vite + Tailwind): - 看板/项目/配置/洞察/日报/Visual 六标签页 - WebSocket 实时更新 - Markdown 渲染(react-markdown + remark-gfm) 测试:314 passed Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
52 lines
1.8 KiB
Python
52 lines
1.8 KiB
Python
from __future__ import annotations
|
|
|
|
import logging
|
|
|
|
from nmfs_agents.agents.developer import AgentResult
|
|
from nmfs_agents.config import AgentsConfig
|
|
from nmfs_agents.core.queue import Task
|
|
from nmfs_agents.tools.device_agent import DeviceAgent
|
|
from nmfs_agents.tools.file_tools import run_command
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
class TesterAgent:
|
|
def __init__(self, config: AgentsConfig) -> None:
|
|
self._config = config
|
|
|
|
def run(self, task: Task) -> AgentResult:
|
|
proj_cfg = self._config.projects.get(task.project)
|
|
if not proj_cfg:
|
|
return AgentResult(status="failed", summary=f"项目不存在: {task.project}")
|
|
|
|
lines = []
|
|
# 1. 本地测试
|
|
local_result = run_command(
|
|
"source venv/bin/activate && pytest tests/ -v --tb=short -q",
|
|
cwd=str(proj_cfg.path),
|
|
)
|
|
lines.append(f"=== 本地测试 ===\n{local_result}")
|
|
|
|
# 2. 设备端测试(如有配置)
|
|
if proj_cfg.device_workspace and self._config.devices:
|
|
dev_name = next(iter(self._config.devices))
|
|
dev_cfg = self._config.devices[dev_name]
|
|
device = DeviceAgent(dev_cfg)
|
|
# 先同步
|
|
sync_result = device.sync(str(proj_cfg.path), proj_cfg.device_workspace)
|
|
lines.append(f"=== 设备同步 ===\n{sync_result}")
|
|
# 然后运行板端测试
|
|
board_result = device.run_command(
|
|
"pytest tests/ -v --tb=short -q",
|
|
proj_cfg.device_workspace,
|
|
)
|
|
lines.append(f"=== 板端测试 ({dev_name}) ===\n{board_result}")
|
|
|
|
summary = "\n\n".join(lines)
|
|
failed = "FAILED" in summary or "ERROR" in summary
|
|
return AgentResult(
|
|
status="failed" if failed else "done",
|
|
summary=summary,
|
|
)
|