源码快照 @ 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 committed 2026-09-01 20:01:50 +08:00
commit 1a3a4ccde1
4652 files changed
+1891610

No files matched your search

Whitespace-only changes.
@@ -0,0 +1,212 @@
# -*- coding: utf-8 -*-
"""Autopilot gate — lifecycle pipeline with cleanup + completed."""
from __future__ import annotations
import asyncio
from dataclasses import dataclass, field
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 (
AUTOPILOT_MAX_ITERATIONS,
AUTOPILOT_MAX_PHASE_ITERATIONS,
AUTOPILOT_MAX_VALIDATION_ROUNDS,
)
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(
{"qa", "validation", "cleanup", "completed"},
)
@dataclass
class _AutopilotState:
loop_dir: Path
workspace_dir: Path
active: bool = True
iteration: int = 0
max_iterations: int = AUTOPILOT_MAX_ITERATIONS
phase_entry_iteration: dict[str, int] = field(
default_factory=dict,
)
skip_qa: bool = False
skip_validation: bool = False
validation_round: int = 0
max_validation_rounds: int = AUTOPILOT_MAX_VALIDATION_ROUNDS
phase: str = "expansion"
blocked_on_merge: bool = False
class AutopilotGate(LoopGate):
"""Stop gate for the 6-phase Autopilot pipeline."""
@property
def name(self) -> str:
return "autopilot"
@property
def priority(self) -> int:
return 50
def activate_for_autopilot(
self,
workspace_dir: Path,
skip_qa: bool = False,
skip_validation: bool = False,
) -> 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, "autopilot")
loop_dir = wf.create_instance()
state = _AutopilotState(
loop_dir=loop_dir,
workspace_dir=workspace_dir,
skip_qa=skip_qa,
skip_validation=skip_validation,
)
wf.write_state(
{
"phase": "expansion",
"validation_round": 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: _AutopilotState | None = self._state()
if st is None:
return StopHandlerResult(
action=StopAction.BYPASS,
)
wf = WorkflowState.from_existing(
st.workspace_dir,
"autopilot",
st.loop_dir,
)
data = await asyncio.to_thread(wf.read_state)
phase = data.get("phase", "expansion")
st.phase = phase
st.validation_round = data.get(
"validation_round",
st.validation_round,
)
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/stall budget
# while waiting on merge (same as Ultrawork).
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="Autopilot 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"Total iteration limit ({st.max_iterations})",
)
if phase == "completed":
await asyncio.to_thread(wf.cleanup)
self.deactivate()
return StopHandlerResult(
action=StopAction.TERMINATE,
reason="Autopilot completed",
)
if (
phase == "validation"
and st.validation_round > st.max_validation_rounds
):
await asyncio.to_thread(wf.cleanup)
self.deactivate()
return StopHandlerResult(
action=StopAction.TERMINATE,
reason=(
f"Validation round limit " f"({st.max_validation_rounds})"
),
)
if phase not in st.phase_entry_iteration:
st.phase_entry_iteration[phase] = st.iteration
elif (
st.iteration - st.phase_entry_iteration[phase]
> AUTOPILOT_MAX_PHASE_ITERATIONS
):
await asyncio.to_thread(wf.cleanup)
self.deactivate()
return StopHandlerResult(
action=StopAction.TERMINATE,
reason=f"Phase '{phase}' stalled",
)
return StopHandlerResult(
action=StopAction.INTERRUPT_AND_CONTINUE,
reason="Autopilot in progress",
)
def build_continuation(self) -> str:
"""Build Autopilot continuation from gate state."""
st: _AutopilotState | 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,
loop_dir=st.loop_dir,
skip_qa=st.skip_qa,
skip_validation=st.skip_validation,
validation_round=st.validation_round,
max_validation_rounds=st.max_validation_rounds,
)
@@ -0,0 +1,104 @@
# -*- coding: utf-8 -*-
"""AutopilotMode — full lifecycle pipeline."""
from __future__ import annotations
import asyncio
import logging
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 .gate import AutopilotGate
if TYPE_CHECKING:
from typing import Any
from agentscope.message import Msg
logger = logging.getLogger(__name__)
_HELP = loop_help_text("autopilot")
class AutopilotMode(OMPModeBase):
"""AgentMode for the Autopilot pipeline."""
name = "autopilot"
gate_cls = AutopilotGate
plugin_id = "__omp_autopilot__"
handler_name = "autopilot-stop-handler"
scope = "omp-autopilot"
def commands(self) -> list[CommandSpec]:
return [
CommandSpec(
name="autopilot",
handler=self._handler,
category="builtin",
help_text=_HELP,
metadata=loop_command_metadata("autopilot"),
),
]
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_autopilot,
Path(workspace_dir),
parsed["skip_qa"],
parsed["skip_validation"],
)
prompt = (
f"Autopilot activated.\n"
f"Task: {task}\n"
f"State directory: {loop_dir}\n"
f"Phase: expansion — analyze requirements and create spec.md."
)
rewrite_user_msg(ctx, prompt)
logger.info("Autopilot started: %s", loop_dir)
return None
def _parse_args(raw: str) -> dict | None:
"""Parse /autopilot arguments. ``None`` means invalid input."""
tokens = split_args(raw)
if tokens is None:
return None
skip_qa = False
skip_validation = False
task_parts: list[str] = []
for t in tokens:
if t == "--skip-qa":
skip_qa = True
elif t == "--skip-validation":
skip_validation = True
else:
task_parts.append(t)
return {
"task": " ".join(task_parts),
"skip_qa": skip_qa,
"skip_validation": skip_validation,
}
@@ -0,0 +1,232 @@
# -*- coding: utf-8 -*-
"""Autopilot continuation prompt templates — one per phase."""
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,
)
PHASES = (
"expansion",
"planning",
"execution",
"qa",
"validation",
"cleanup",
"completed",
)
@dataclass(frozen=True)
class AutopilotPromptCtx:
"""Typed context for Autopilot phase prompt builders."""
loop_dir: Path
iteration: int
max_iterations: int
skip_qa: bool = False
skip_validation: bool = False
validation_round: int = 0
max_validation_rounds: int = 3
def build_continuation(
phase: str,
iteration: int,
max_iterations: int,
loop_dir: Path,
skip_qa: bool = False,
skip_validation: bool = False,
validation_round: int = 0,
max_validation_rounds: int = 3,
) -> str:
"""Return the controller prompt for the current phase."""
ctx = AutopilotPromptCtx(
loop_dir=loop_dir,
iteration=iteration,
max_iterations=max_iterations,
skip_qa=skip_qa,
skip_validation=skip_validation,
validation_round=validation_round,
max_validation_rounds=max_validation_rounds,
)
builders = {
"expansion": _expansion,
"planning": _planning,
"execution": _execution,
"qa": _qa,
"validation": _validation,
"cleanup": _cleanup,
}
fn = builders.get(phase)
if fn is None:
return (
f"Unknown phase: {phase}. " f"Valid phases: {', '.join(PHASES)}."
)
return fn(ctx)
def _expansion(ctx: AutopilotPromptCtx) -> str:
analyst = format_spawn_call(
"analyst",
"Analyze requirements and produce spec.md...",
)
return f"""\
Autopilot Controller — phase: expansion.
Iteration: {ctx.iteration}/{ctx.max_iterations}
Use the omp-roles skill for role tool/skill config.
Execute:
1. Analyze the task requirements.
2. Dispatch an analyst subagent to extract requirements:
{analyst}
3. Dispatch an architect subagent to validate and expand the spec.
4. Write the final spec to {ctx.loop_dir}/spec.md.
5. Update {ctx.loop_dir}/state.json: set phase="planning"."""
def _planning(ctx: AutopilotPromptCtx) -> str:
architect = format_spawn_call(
"architect",
"Create implementation plan from spec...",
)
critic = format_spawn_call(
"critic",
"Review the implementation plan; challenge gaps and risks...",
)
return f"""\
Autopilot Controller — phase: planning.
Iteration: {ctx.iteration}/{ctx.max_iterations}
Use the omp-roles skill for role tool/skill config.
Execute:
1. Read {ctx.loop_dir}/spec.md.
2. Dispatch an architect subagent to create an implementation plan:
{architect}
3. Dispatch a critic subagent to review the plan:
{critic}
4. Write the final plan to {ctx.loop_dir}/plan.md.
5. Update {ctx.loop_dir}/state.json: set phase="execution"."""
def _execution(ctx: AutopilotPromptCtx) -> str:
item1 = format_batch_item("executor", "<task 1 from plan>", fork=True)
item2 = format_batch_item("executor", "<task 2 from plan>", fork=True)
return f"""\
Autopilot Controller — phase: execution.
Iteration: {ctx.iteration}/{ctx.max_iterations}
Use the omp-roles skill for role tool/skill config.
Execute:
1. Read {ctx.loop_dir}/plan.md for the task list.
2. Identify independent tasks that can run in parallel.
3. Dispatch executor workers via batch mode:
spawn_subagent(task="", batch=[
{item1},
{item2},
...
])
4. Poll each worker with check_agent_task (wait >= 30s between polls).
5. Integrate forked worker results:
{fork_merge_instructions()}
6. After successful merges, update {ctx.loop_dir}/state.json:
set forks_integrated=true.
7. Verify outputs in the main workspace.
8. Update {ctx.loop_dir}/state.json: set phase="qa".
The gate rejects qa/later phases until forks_integrated=true."""
def _qa(ctx: AutopilotPromptCtx) -> str:
if ctx.skip_qa:
return f"""\
Autopilot Controller — phase: qa (SKIPPED via --skip-qa).
Update {ctx.loop_dir}/state.json: set phase="validation"."""
architect = format_spawn_call(
"architect",
"DIAGNOSE FAILURE: paste test output; give root cause + fixes.",
)
executor = format_spawn_call(
"executor",
"FIX: apply the architect recommendations precisely.",
)
return f"""\
Autopilot Controller — phase: qa.
Iteration: {ctx.iteration}/{ctx.max_iterations}
Use the omp-roles skill for role tool/skill config.
Execute the UltraQA-style 3-agent cycle:
1. Run the project test suite.
2. If all tests pass, update {ctx.loop_dir}/state.json: set phase="validation".
3. If tests fail:
a. Dispatch architect subagent:
{architect}
b. Dispatch executor subagent:
{executor}
c. Re-run tests. Repeat up to 5 cycles."""
def _validation(ctx: AutopilotPromptCtx) -> str:
if ctx.skip_validation:
return f"""\
Autopilot Controller — phase: validation \
(SKIPPED via --skip-validation).
Update {ctx.loop_dir}/state.json: set phase="cleanup"."""
verifier = format_batch_item(
"verifier",
"REVIEW - Functional Completeness: Verify all spec requirements...",
)
security = format_batch_item(
"security-reviewer",
"REVIEW - Security: Check for vulnerabilities, injection vectors...",
)
code = format_batch_item(
"code-reviewer",
"REVIEW - Code Quality: Review quality and maintainability...",
)
return f"""\
Autopilot Controller — phase: validation.
Validation round: {ctx.validation_round}/{ctx.max_validation_rounds}
WARNING: You are the Controller — do NOT review
code yourself. Dispatch subagents.
Use the omp-roles skill for role tool/skill config.
Execute parallel validation:
1. Use spawn_subagent batch mode for three reviewers:
spawn_subagent(task="", batch=[
{verifier},
{security},
{code}
])
2. Wait for all reviewers to complete.
3. If ALL approve -> update {ctx.loop_dir}/state.json: set phase="cleanup".
4. If any reject -> fix issues -> increment validation_round -> re-validate.
5. If validation_round > {ctx.max_validation_rounds} -> STOP and report."""
def _cleanup(ctx: AutopilotPromptCtx) -> str:
return f"""\
Autopilot Controller — phase: cleanup.
Iteration: {ctx.iteration}/{ctx.max_iterations}
This is a real model turn. Perform final cleanup before completion.
Execute:
1. Review changed files; run deslop / remove debug leftovers if needed.
2. Re-run tests/build/lint for a final verification pass.
3. Confirm no unresolved merge conflicts remain.
4. Write a short completion note to {ctx.loop_dir}/progress.txt.
5. Update {ctx.loop_dir}/state.json: set phase="completed".
Do NOT set phase="completed" until verification succeeds."""