源码快照 @ 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
+164
View File
@@ -0,0 +1,164 @@
# -*- coding: utf-8 -*-
"""Ralph gate — PRD-driven continuous loop with reviewer + deslop."""
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 RALPH_MAX_ITERATIONS
from ..shared.state import WorkflowState
from .prompts import build_continuation as _build_prompt
@dataclass
class _RalphState:
loop_dir: Path
workspace_dir: Path
active: bool = True
iteration: int = 0
max_iterations: int = RALPH_MAX_ITERATIONS
no_deslop: bool = False
critic_type: str = "architect"
prd_summary: str = ""
prd_cache: dict[str, Any] = field(default_factory=dict)
prd_mtime_ns: int = -1
class RalphGate(LoopGate):
"""Stop gate for the Ralph PRD-driven loop."""
@property
def name(self) -> str:
return "ralph"
@property
def priority(self) -> int:
return 50
def activate_for_ralph(
self,
workspace_dir: Path,
no_deslop: bool = False,
critic_type: str = "architect",
max_iterations: int = RALPH_MAX_ITERATIONS,
) -> Path:
wf = WorkflowState(workspace_dir, "ralph")
loop_dir = wf.create_instance()
state = _RalphState(
loop_dir=loop_dir,
workspace_dir=workspace_dir,
max_iterations=max_iterations,
no_deslop=no_deslop,
critic_type=critic_type,
)
wf.write_state(
{
"iteration": 0,
"completed": False,
},
)
self.activate(state)
return loop_dir
async def check(self, ctx: Any) -> Optional[StopHandlerResult]:
if isinstance(ctx, dict) and ctx.get("has_tool_calls"):
return StopHandlerResult(action=StopAction.BYPASS)
st: _RalphState | None = self._state()
if st is None:
return StopHandlerResult(
action=StopAction.BYPASS,
)
wf = WorkflowState.from_existing(
st.workspace_dir,
"ralph",
st.loop_dir,
)
data = await asyncio.to_thread(wf.read_state)
prd = await asyncio.to_thread(_read_prd_cached, st, wf)
# Gate owns iteration in memory.
st.iteration += 1
if st.iteration > st.max_iterations:
await asyncio.to_thread(wf.cleanup)
self.deactivate()
return StopHandlerResult(
action=StopAction.TERMINATE,
reason=f"Reached max iterations ({st.max_iterations})",
)
st.prd_summary = _summarize_prd(prd)
completed = bool(data.get("completed")) or _all_stories_passed(prd)
if completed:
await asyncio.to_thread(wf.cleanup)
self.deactivate()
return StopHandlerResult(
action=StopAction.TERMINATE,
reason="All stories completed and verified",
)
await asyncio.to_thread(
wf.update_state,
{"iteration": st.iteration},
)
return StopHandlerResult(
action=StopAction.INTERRUPT_AND_CONTINUE,
reason="Ralph iteration in progress",
)
def build_continuation(self) -> str:
"""Build Ralph continuation from gate state."""
st: _RalphState | None = self._state()
if st is None:
return ""
return _build_prompt(
iteration=st.iteration,
max_iterations=st.max_iterations,
critic_type=st.critic_type,
no_deslop=st.no_deslop,
loop_dir=st.loop_dir,
prd_summary=st.prd_summary,
)
def _read_prd_cached(
st: _RalphState,
wf: WorkflowState,
) -> dict[str, Any]:
"""Reload prd.json only when the file mtime changes."""
prd_path = st.loop_dir / "prd.json"
try:
mtime_ns = prd_path.stat().st_mtime_ns if prd_path.exists() else -1
except OSError:
mtime_ns = -1
if mtime_ns == st.prd_mtime_ns:
return st.prd_cache
prd = wf.read_prd()
st.prd_cache = prd
st.prd_mtime_ns = mtime_ns
return prd
def _all_stories_passed(prd: dict) -> bool:
"""Return True when PRD exists and every story has passes=true."""
stories = prd.get("stories") or []
if not stories:
return False
return all(s.get("passes") for s in stories)
def _summarize_prd(prd: dict) -> str:
"""Build a one-line PRD progress summary."""
stories = prd.get("stories", [])
if not stories:
return "PRD: not yet created."
done = sum(1 for s in stories if s.get("passes"))
return f"PRD progress: {done}/{len(stories)} stories completed."
+103
View File
@@ -0,0 +1,103 @@
# -*- coding: utf-8 -*-
"""RalphMode — PRD-driven continuous implementation loop."""
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 RalphGate
if TYPE_CHECKING:
from typing import Any
from agentscope.message import Msg
logger = logging.getLogger(__name__)
_HELP = loop_help_text("ralph")
class RalphMode(OMPModeBase):
"""AgentMode for the Ralph workflow."""
name = "ralph"
gate_cls = RalphGate
plugin_id = "__omp_ralph__"
handler_name = "ralph-stop-handler"
scope = "omp-ralph"
def commands(self) -> list[CommandSpec]:
return [
CommandSpec(
name="ralph",
handler=self._handler,
category="builtin",
help_text=_HELP,
metadata=loop_command_metadata("ralph"),
),
]
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_ralph,
Path(workspace_dir),
parsed["no_deslop"],
parsed["critic_type"],
)
from .prompts import build_initial_prd_prompt
prompt = build_initial_prd_prompt(task, loop_dir)
rewrite_user_msg(ctx, prompt)
logger.info("Ralph started: %s", loop_dir)
return None
def _parse_args(raw: str) -> dict | None:
"""Parse /ralph arguments. ``None`` means invalid input."""
tokens = split_args(raw)
if tokens is None:
return None
no_deslop = False
critic_type = "architect"
task_parts: list[str] = []
for t in tokens:
if t == "--no-deslop":
no_deslop = True
elif t.startswith("--critic="):
critic_type = t.split("=", 1)[1]
if critic_type not in ("architect", "critic", "codex"):
critic_type = "architect"
else:
task_parts.append(t)
return {
"task": " ".join(task_parts),
"no_deslop": no_deslop,
"critic_type": critic_type,
}
@@ -0,0 +1,93 @@
# -*- coding: utf-8 -*-
"""Ralph continuation prompt templates."""
from __future__ import annotations
from pathlib import Path
from ..shared.role_prompts import format_spawn_call, resolve_role
def build_continuation(
iteration: int,
max_iterations: int,
critic_type: str,
no_deslop: bool,
loop_dir: Path,
prd_summary: str,
) -> str:
"""Build the controller continuation for a Ralph iteration."""
deslop_block = ""
if not no_deslop:
deslop_block = (
"7.5. Run deslop cleanup on changed files.\n"
"7.6. Re-run tests/build/lint to verify "
"no regressions from deslop.\n"
)
reviewer = resolve_role(critic_type)
# Sequential story loop runs in the main workspace (no fork): each
# story must land on the shared tree before the next story starts.
executor_spawn = format_spawn_call(
"executor",
"Implement the following user story:\\n"
"<story details + acceptance criteria>",
fork=False,
)
reviewer_spawn = format_spawn_call(
reviewer,
"REVIEW: Verify the complete implementation against the PRD...",
)
return f"""\
Ralph PRD-driven loop — iteration {iteration}/{max_iterations}.
{prd_summary}
Use the omp-roles skill for role tool/skill config.
Execute the current step:
1. Read {loop_dir}/prd.json for the user stories list.
2. Pick the highest-priority story with passes=false.
3. Dispatch an executor subagent to implement it:
{executor_spawn}
4. After completion, verify every acceptance criterion (run tests/build/lint).
5. If verified, update prd.json: set passes=true for this story.
Write progress to {loop_dir}/progress.txt.
6. If all stories pass, proceed to step 7. Otherwise loop to step 2.
7. Dispatch a {reviewer} reviewer to verify the overall implementation:
{reviewer_spawn}
{deslop_block}\
8. When the reviewer approves, update {loop_dir}/state.json:
set completed=true (required for the loop to terminate).
9. Then report completion to the user.
WARNING — POLITE-STOP ANTI-PATTERN:
After the reviewer approves, do NOT stop to report results.
Continue immediately through deslop -> regression check -> cleanup.
Stopping mid-chain to ask the user is a known failure mode."""
def build_initial_prd_prompt(task: str, loop_dir: Path) -> str:
"""Build the prompt for the initial PRD creation step."""
return f"""\
Ralph activated. Task: {task}
Step 1 — PRD Setup:
1. Analyze the task and create {loop_dir}/prd.json with this structure:
{{
"title": "<task title>",
"stories": [
{{
"id": "S1",
"title": "<story title>",
"description": "<what to implement>",
"acceptance_criteria": ["<criterion 1>", "..."],
"priority": 1,
"passes": false
}}
]
}}
2. Break the task into concrete user stories
with measurable acceptance criteria.
3. After creating prd.json, begin the implementation loop."""