包含从项目创建至今的全部代码首次入库: 核心框架: - 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>
61 lines
2.5 KiB
Python
61 lines
2.5 KiB
Python
from __future__ import annotations
|
|
import pytest
|
|
from unittest.mock import MagicMock
|
|
from nmfs_agents.config import AgentsConfig, ClaudeConfig
|
|
from nmfs_agents.core.queue import Task
|
|
from nmfs_agents.tools.project_memory import ProjectMemory
|
|
|
|
|
|
def _make_config():
|
|
cfg = MagicMock(spec=AgentsConfig)
|
|
cfg.projects = {}
|
|
cfg.claude = ClaudeConfig(model="claude-sonnet-4-6", api_key=None)
|
|
cfg.devices = {}
|
|
return cfg
|
|
|
|
|
|
def _make_task(role):
|
|
return Task(project="base", type="research", title="test",
|
|
context="", priority=3, mode="auto", agent_role=role)
|
|
|
|
|
|
def test_os_engineer_context_contains_perf_domains(tmp_path):
|
|
from nmfs_agents.agents.os_engineer import OsEngineerAgent
|
|
mem = ProjectMemory(db_path=tmp_path / "m.db")
|
|
agent = OsEngineerAgent(_make_config(), memory=mem)
|
|
ctx = agent._build_context(_make_task("os-engineer"))
|
|
assert "内存" in ctx
|
|
assert "NPU" in ctx or "valgrind" in ctx
|
|
|
|
|
|
def test_algo_researcher_context_contains_algorithm_domains(tmp_path):
|
|
from nmfs_agents.agents.algo_researcher import AlgoResearcherAgent
|
|
mem = ProjectMemory(db_path=tmp_path / "m.db")
|
|
agent = AlgoResearcherAgent(_make_config(), memory=mem)
|
|
ctx = agent._build_context(_make_task("algo-researcher"))
|
|
# AlgoResearcher 已改为代码迭代模式,聚焦 rk3566 验证
|
|
assert "rk3566" in ctx or "算法" in ctx or "numpy" in ctx
|
|
|
|
|
|
def test_algo_researcher_injects_hardware_facts(tmp_path):
|
|
from nmfs_agents.agents.algo_researcher import AlgoResearcherAgent
|
|
mem = ProjectMemory(db_path=tmp_path / "m.db")
|
|
mem.set_fact("__hardware__", "rk3588.npu", "6TOPS", role="hw-engineer")
|
|
agent = AlgoResearcherAgent(_make_config(), memory=mem)
|
|
ctx = agent._build_context(_make_task("algo-researcher"))
|
|
assert "6TOPS" in ctx
|
|
|
|
|
|
def test_base_architect_context_focuses_on_platform(tmp_path):
|
|
from nmfs_agents.agents.base_architect import BaseArchitectAgent
|
|
from nmfs_agents.core.queue import TaskQueue
|
|
mem = ProjectMemory(db_path=tmp_path / "m.db")
|
|
q = TaskQueue(db_path=tmp_path / "t.db")
|
|
agent = BaseArchitectAgent(_make_config(), queue=q, memory=mem)
|
|
# base-architect 继承 ArchitectAgent,有 run() 方法
|
|
assert hasattr(agent, "run")
|
|
# system prompt 包含基础技术相关词汇
|
|
from nmfs_agents.agents.base_architect import BASE_ARCHITECT_SYSTEM
|
|
assert "平台" in BASE_ARCHITECT_SYSTEM or "基础技术" in BASE_ARCHITECT_SYSTEM
|
|
assert "os-engineer" in BASE_ARCHITECT_SYSTEM or "algo-researcher" in BASE_ARCHITECT_SYSTEM
|