源码快照 @ 2026-09-01 (source-only, 剔除非源码素材)
Creator App Tests / PR Spam Gate (push) Skipped
Frontend Tests / PR Spam Gate (push) Skipped
NPM Format (website & console) / PR Spam Gate (push) Skipped
Pre-commit Checks / PR Spam Gate (push) Skipped
QwenPaw Creator Plugin Release / check-version (push) Canceled after 0s
QwenPaw Creator Plugin Release / upload-oss (push) Canceled after 0s
Tests / PR Spam Gate (push) Skipped
CodeQL / CodeQL (python) (push) Canceled after 0s
CodeQL / CodeQL (typescript) (push) Canceled after 0s
Creator App Tests / Creator Backend Tests (push) Canceled after 0s
Creator App Tests / Creator UI Build & Tests (push) Canceled after 0s
E2E Smoke Tests / Playwright UI Smoke (push) Canceled after 0s
Frontend Tests / Detect console changes (push) Canceled after 0s
NPM Format (website & console) / website format check (push) Canceled after 0s
NPM Format (website & console) / console format check (push) Canceled after 0s
Pre-commit Checks / Pre-commit (push) Canceled after 0s
QwenPaw Data Plugin Release / check-version (push) Canceled after 0s
Tests / Detect code changes (push) Canceled after 0s
Frontend Tests / Vitest Unit Tests (push) Canceled after 0s
Frontend Tests / Frontend Summary (push) Canceled after 0s
QwenPaw Data Plugin Release / upload-oss (push) Canceled after 0s
Tests / Maintainer Approval (push) Canceled after 0s
Tests / Unit Tests - py3.11 - macos-latest (push) Canceled after 0s
Tests / Unit Tests - py3.11 - ubuntu-latest (push) Canceled after 0s
Tests / Unit Tests - py3.13 - ubuntu-latest (push) Canceled after 0s
Tests / Unit Tests - py3.11 - windows-latest (push) Canceled after 0s
Tests / Contract Tests - py3.11 - macos-latest (push) Canceled after 0s
Tests / Contract Tests - py3.11 - ubuntu-latest (push) Canceled after 0s
Tests / Contract Tests - py3.13 - ubuntu-latest (push) Canceled after 0s
Tests / Contract Tests - py3.11 - windows-latest (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - macos-latest - p0 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - macos-latest - p1 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - macos-latest - p2 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - ubuntu-latest - fallback (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - ubuntu-latest - p0 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - ubuntu-latest - p1 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - ubuntu-latest - p2 (push) Canceled after 0s
Tests / Integrated Tests - py3.13 - ubuntu-latest - p0 (push) Canceled after 0s
Tests / Integrated Tests - py3.13 - ubuntu-latest - p1 (push) Canceled after 0s
Tests / Integrated Tests - py3.13 - ubuntu-latest - p2 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - windows-latest - p0 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - windows-latest - p1 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - windows-latest - p2 (push) Canceled after 0s
Tests / Coverage Report (push) Canceled after 0s
Tests / Test Summary (push) Canceled after 0s

This commit is contained in:
agent-radar
2026-09-01 20:01:50 +08:00
commit 1a3a4ccde1
4652 changed files with 1891610 additions and 0 deletions
+197
View File
@@ -0,0 +1,197 @@
# -*- coding: utf-8 -*-
"""Team pipeline gate — 5-phase with fix retry limit."""
from __future__ import annotations
import asyncio
from dataclasses import dataclass
from pathlib import Path
from typing import Any, Optional
from qwenpaw.loop.gates.base import StopAction, StopHandlerResult
from qwenpaw.loop.gates.loop_gate import LoopGate
from ..shared.constants import (
TEAM_MAX_FIX_ATTEMPTS,
TEAM_MAX_ITERATIONS,
)
from ..shared.fork_guard import forks_integrated, merge_blocked_continuation
from ..shared.role_prompts import FORK_MERGE_PROTOCOL
from ..shared.state import WorkflowState
from .prompts import build_continuation as _build_prompt
_POST_FORK_PHASES = frozenset({"verify", "fix", "completed"})
@dataclass
class _TeamState:
loop_dir: Path
workspace_dir: Path
active: bool = True
iteration: int = 0
max_iterations: int = TEAM_MAX_ITERATIONS
agent_count: int = 3
agent_role: str = "executor"
fix_attempts: int = 0
max_fix_attempts: int = TEAM_MAX_FIX_ATTEMPTS
phase: str = "plan"
blocked_on_merge: bool = False
class TeamPipelineGate(LoopGate):
"""Stop gate for the Team multi-agent pipeline."""
@property
def name(self) -> str:
return "team"
@property
def priority(self) -> int:
return 50
def activate_for_team(
self,
workspace_dir: Path,
agent_count: int = 3,
agent_role: str = "executor",
) -> Path:
try:
from qwenpaw.agents.fork_project import begin_fork_scope
begin_fork_scope(workspace_dir)
except ImportError:
import logging
logging.getLogger(__name__).warning(
"begin_fork_scope unavailable; fork merge scope disabled",
)
wf = WorkflowState(workspace_dir, "team")
loop_dir = wf.create_instance()
handoffs = loop_dir / "handoffs"
handoffs.mkdir(exist_ok=True)
results = loop_dir / "results"
results.mkdir(exist_ok=True)
state = _TeamState(
loop_dir=loop_dir,
workspace_dir=workspace_dir,
agent_count=agent_count,
agent_role=agent_role,
)
wf.write_state(
{
"current_phase": "plan",
"fix_attempts": 0,
},
)
self.activate(state)
return loop_dir
async def check( # pylint: disable=too-many-return-statements
self,
ctx: Any,
) -> Optional[StopHandlerResult]:
if isinstance(ctx, dict) and ctx.get("has_tool_calls"):
return StopHandlerResult(action=StopAction.BYPASS)
st: _TeamState | None = self._state()
if st is None:
return StopHandlerResult(
action=StopAction.BYPASS,
)
wf = WorkflowState.from_existing(
st.workspace_dir,
"team",
st.loop_dir,
)
data = await asyncio.to_thread(wf.read_state)
prev_phase = st.phase
phase = data.get("current_phase", "plan")
st.phase = phase
if phase in _POST_FORK_PHASES:
integrated = await asyncio.to_thread(
forks_integrated,
data,
st.workspace_dir,
)
if not integrated:
# Preserve target phase; do not burn iteration while merging.
st.blocked_on_merge = True
st.phase = phase
await asyncio.to_thread(
wf.update_state,
{
"merge_blocked": True,
"resume_phase": phase,
},
)
return StopHandlerResult(
action=StopAction.INTERRUPT_AND_CONTINUE,
reason="Team blocked: forks not integrated",
)
if data.get("merge_blocked"):
await asyncio.to_thread(
wf.update_state,
{"merge_blocked": False},
)
st.blocked_on_merge = False
st.iteration += 1
if st.iteration > st.max_iterations:
await asyncio.to_thread(wf.cleanup)
self.deactivate()
return StopHandlerResult(
action=StopAction.TERMINATE,
reason=f"Iteration limit ({st.max_iterations})",
)
if phase == "completed":
await asyncio.to_thread(wf.cleanup)
self.deactivate()
return StopHandlerResult(
action=StopAction.TERMINATE,
reason="Team pipeline completed",
)
# Count fix *rounds* (phase entry), not every agent turn.
if phase == "fix" and prev_phase != "fix":
st.fix_attempts += 1
if st.fix_attempts > st.max_fix_attempts:
await asyncio.to_thread(wf.cleanup)
self.deactivate()
return StopHandlerResult(
action=StopAction.TERMINATE,
reason=f"Fix retry limit ({st.max_fix_attempts})",
)
await asyncio.to_thread(
wf.update_state,
{"fix_attempts": st.fix_attempts},
)
return StopHandlerResult(
action=StopAction.INTERRUPT_AND_CONTINUE,
reason="Team pipeline in progress",
)
def build_continuation(self) -> str:
"""Build Team continuation from gate state."""
st: _TeamState | None = self._state()
if st is None:
return ""
if st.blocked_on_merge:
return merge_blocked_continuation(FORK_MERGE_PROTOCOL)
return _build_prompt(
phase=st.phase,
iteration=st.iteration,
max_iterations=st.max_iterations,
agent_count=st.agent_count,
agent_role=st.agent_role,
loop_dir=st.loop_dir,
fix_attempts=st.fix_attempts,
max_fix_attempts=st.max_fix_attempts,
)
+113
View File
@@ -0,0 +1,113 @@
# -*- coding: utf-8 -*-
"""TeamMode — multi-agent collaboration pipeline."""
from __future__ import annotations
import asyncio
import logging
import re
from pathlib import Path
from typing import TYPE_CHECKING, Optional
from qwenpaw.runtime.slash_command_registry import CommandSpec
from ..shared.args import split_args
from ..shared.loop_ui_i18n import loop_command_metadata, loop_help_text
from ..shared.mode_base import OMPModeBase, info_msg, rewrite_user_msg
from ..shared.role_prompts import resolve_role
from .gate import TeamPipelineGate
if TYPE_CHECKING:
from typing import Any
from agentscope.message import Msg
logger = logging.getLogger(__name__)
_HELP = loop_help_text("team")
class TeamMode(OMPModeBase):
"""AgentMode for the Team pipeline."""
name = "team"
gate_cls = TeamPipelineGate
plugin_id = "__omp_team__"
handler_name = "team-stop-handler"
scope = "omp-team"
def commands(self) -> list[CommandSpec]:
return [
CommandSpec(
name="team",
handler=self._handler,
category="builtin",
help_text=_HELP,
metadata=loop_command_metadata("team"),
),
]
async def _handler(self, ctx: "Any", args: str) -> Optional["Msg"]:
if not args or not args.strip() or args.strip().lower() == "help":
return info_msg(_HELP)
parsed = _parse_args(args)
if parsed is None:
return info_msg("Invalid arguments. " + _HELP)
task = parsed["task"]
if len(task) < 5:
return info_msg("Please provide a task description.\n\n" + _HELP)
workspace_dir = getattr(ctx, "workspace_dir", None)
if not workspace_dir:
return info_msg("ERROR: no workspace directory available.")
self.claim_workflow()
loop_dir = await asyncio.to_thread(
self._gate.activate_for_team,
Path(workspace_dir),
parsed["agent_count"],
parsed["agent_role"],
)
prompt = (
f"Team pipeline activated.\n"
f"Task: {task}\n"
f"Workers: {parsed['agent_count']}, Role: {parsed['agent_role']}\n"
f"State directory: {loop_dir}\n"
"Phase: plan \u2014 explore the codebase and "
"create a task breakdown."
)
rewrite_user_msg(ctx, prompt)
logger.info("Team started: %s", loop_dir)
return None
_TEAM_SPEC_RE = re.compile(r"^(\d+):(\w[\w-]*)$")
def _parse_args(raw: str) -> dict | None:
"""Parse /team arguments. ``None`` means invalid input."""
tokens = split_args(raw)
if tokens is None:
return None
agent_count = 3
agent_role = "executor"
task_parts: list[str] = []
for i, t in enumerate(tokens):
m = _TEAM_SPEC_RE.match(t)
if m and i == 0:
agent_count = int(m.group(1))
agent_role = m.group(2)
elif t in ("executor", "ralph") and i == 0:
agent_role = t
else:
task_parts.append(t)
return {
"task": " ".join(task_parts),
"agent_count": max(1, min(agent_count, 10)),
"agent_role": resolve_role(agent_role),
}
@@ -0,0 +1,199 @@
# -*- coding: utf-8 -*-
"""Team pipeline continuation prompt templates."""
from __future__ import annotations
from dataclasses import dataclass
from pathlib import Path
from ..shared.role_prompts import (
fork_merge_instructions,
format_batch_item,
format_spawn_call,
tools_literal,
)
@dataclass(frozen=True)
class TeamPromptCtx:
"""Typed context for Team phase prompt builders."""
loop_dir: Path
iteration: int
max_iterations: int
agent_count: int = 3
agent_role: str = "executor"
fix_attempts: int = 0
max_fix_attempts: int = 3
def build_continuation(
phase: str,
iteration: int,
max_iterations: int,
agent_count: int,
agent_role: str,
loop_dir: Path,
fix_attempts: int = 0,
max_fix_attempts: int = 3,
) -> str:
"""Return the controller prompt for the current pipeline phase."""
ctx = TeamPromptCtx(
loop_dir=loop_dir,
iteration=iteration,
max_iterations=max_iterations,
agent_count=agent_count,
agent_role=agent_role,
fix_attempts=fix_attempts,
max_fix_attempts=max_fix_attempts,
)
builders = {
"plan": _plan,
"prd": _prd,
"exec": _exec,
"verify": _verify,
"fix": _fix,
}
fn = builders.get(phase)
if fn is None:
return f"Unknown phase: {phase}. Update state.json."
return fn(ctx)
def _plan(ctx: TeamPromptCtx) -> str:
explore = format_spawn_call(
"explore",
"Explore the codebase and map relevant "
"files, modules, and dependencies.",
)
planner = format_spawn_call(
"planner",
"Create an implementation plan with "
"task breakdown and dependencies...",
)
return f"""\
Team Pipeline Controller — phase: plan.
Pipeline iteration: {ctx.iteration}/{ctx.max_iterations}
Use the omp-roles skill for role tool/skill config.
Execute:
1. Dispatch an explore subagent to map the codebase:
{explore}
2. After exploration, dispatch a planner subagent:
{planner}
3. Write the plan to {ctx.loop_dir}/handoffs/plan.md.
4. Update {ctx.loop_dir}/state.json: set current_phase="prd"."""
def _prd(ctx: TeamPromptCtx) -> str:
analyst = format_spawn_call(
"analyst",
(
"Read the plan and define acceptance "
"criteria for each sub-task..."
),
)
return f"""\
Team Pipeline Controller — phase: prd.
Pipeline iteration: {ctx.iteration}/{ctx.max_iterations}
Use the omp-roles skill for role tool/skill config.
Execute:
1. Read {ctx.loop_dir}/handoffs/plan.md for the task breakdown.
2. Dispatch an analyst subagent:
{analyst}
3. Write the PRD to {ctx.loop_dir}/handoffs/prd.md.
4. Update {ctx.loop_dir}/state.json: set current_phase="exec"."""
def _exec(ctx: TeamPromptCtx) -> str:
role = ctx.agent_role
item = format_batch_item(
role,
f"<sub-task 1>\\nWrite your result to "
f"{ctx.loop_dir}/results/agent-001.json",
fork=True,
)
tools_note = tools_literal(role)
tools_hint = (
"omit allowed_tools (inherit all)"
if tools_note is None
else f"allowed_tools={tools_note}"
)
return f"""\
Team Pipeline Controller — phase: exec.
Pipeline iteration: {ctx.iteration}/{ctx.max_iterations}
Workers: {ctx.agent_count}, Role: {role} ({tools_hint})
Use the omp-roles skill for role tool/skill config.
Execute:
1. Read {ctx.loop_dir}/handoffs/prd.md for sub-tasks and acceptance criteria.
2. Dispatch {ctx.agent_count} workers via batch mode:
spawn_subagent(task="", batch=[
{item},
...repeat for each worker...
])
3. Poll each worker with check_agent_task (wait >= 30s between polls).
4. Integrate forked worker results:
{fork_merge_instructions()}
5. After successful merges, update {ctx.loop_dir}/state.json:
set forks_integrated=true.
6. Read {ctx.loop_dir}/results/ files and summarize.
7. Write the summary to {ctx.loop_dir}/handoffs/exec-summary.md.
8. Update {ctx.loop_dir}/state.json: set current_phase="verify".
The gate rejects verify/completed until forks_integrated=true."""
def _verify(ctx: TeamPromptCtx) -> str:
verifier = format_batch_item(
"verifier",
"VERIFY: Check code changes for correctness and completeness...",
)
security = format_batch_item(
"security-reviewer",
"SECURITY REVIEW: Check for security vulnerabilities...",
)
code = format_batch_item(
"code-reviewer",
"CODE REVIEW: Review code quality and conventions...",
)
return f"""\
Team Pipeline Controller — phase: verify.
Pipeline iteration: {ctx.iteration}/{ctx.max_iterations}
Use the omp-roles skill for role tool/skill config.
Execute:
1. Read {ctx.loop_dir}/handoffs/exec-summary.md.
2. Dispatch three reviewers via batch mode:
spawn_subagent(task="", batch=[
{verifier},
{security},
{code}
])
3. If ALL pass -> update {ctx.loop_dir}/state.json: \
set current_phase="completed".
4. If any fail -> write report to {ctx.loop_dir}/handoffs/verify-report.md
-> update state.json: set current_phase="fix"."""
def _fix(ctx: TeamPromptCtx) -> str:
debugger = format_spawn_call(
"debugger",
"Fix the following issues from verification:\\n<issues>",
)
return f"""\
Team Pipeline Controller — phase: fix.
Pipeline iteration: {ctx.iteration}/{ctx.max_iterations}
Fix attempt: {ctx.fix_attempts}/{ctx.max_fix_attempts}
Use the omp-roles skill for role tool/skill config.
Execute:
1. Read {ctx.loop_dir}/handoffs/verify-report.md for failure details.
2. Dispatch a debugger subagent to fix the issues:
{debugger}
3. After fix, update {ctx.loop_dir}/state.json: set current_phase="verify"."""