forked from retoor/devplacepy
feat: add autonomous maintenance agent fleet with shared engine and validator
Add the `agents/` directory containing a fleet of autonomous AI maintenance agents for codebase consistency, including a shared async engine (`agent.py`), a dependency-free validator (`validator.py`), and specialized agents for security, audit, docs, style, frontend, SEO, test coverage, and more. Wire the fleet into the Makefile with `--fix`/`--check` modes, document the architecture in `AGENTS.md`, `CLAUDE.md`, and `README.md`, and enforce a hard rule that the `agents/` directory itself is off-limits to any code modification to preserve detection data.
This commit is contained in:
@@ -0,0 +1 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
@@ -0,0 +1,54 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
|
||||
from .fleet import ordered_agents
|
||||
|
||||
|
||||
def _usage() -> str:
|
||||
names = ", ".join(ordered_agents())
|
||||
return (
|
||||
"usage: python -m agents <command> [options]\n\n"
|
||||
"commands:\n"
|
||||
f" <agent> run one agent: {names}\n"
|
||||
" all run the whole fleet (orchestrator)\n"
|
||||
" maestro open the conversational conductor\n\n"
|
||||
"examples:\n"
|
||||
" python -m agents security --check\n"
|
||||
" python -m agents all --check\n"
|
||||
" python -m agents maestro \"is my audit coverage complete?\"\n"
|
||||
)
|
||||
|
||||
|
||||
def main() -> None:
|
||||
if len(sys.argv) < 2 or sys.argv[1] in ("-h", "--help"):
|
||||
sys.stdout.write(_usage())
|
||||
sys.exit(0)
|
||||
command = sys.argv[1]
|
||||
rest = sys.argv[2:]
|
||||
sys.argv = [f"agents.{command}", *rest]
|
||||
if command == "all":
|
||||
from .orchestrator import main as run
|
||||
|
||||
run()
|
||||
return
|
||||
if command == "maestro":
|
||||
from .maestro import main as run
|
||||
|
||||
run()
|
||||
return
|
||||
if command in ordered_agents():
|
||||
from .fleet import REGISTRY
|
||||
from .base import cli_main
|
||||
|
||||
sys.argv[0] = f"agents.{command}"
|
||||
cli_main(REGISTRY[command]())
|
||||
return
|
||||
sys.stderr.write(f"unknown command '{command}'\n\n{_usage()}")
|
||||
sys.exit(2)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Executable
+2451
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,49 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from .base import MaintenanceAgent, cli_main
|
||||
|
||||
|
||||
class AuditAgent(MaintenanceAgent):
|
||||
name = "audit"
|
||||
description = "audit log coverage maintainer"
|
||||
|
||||
def mandate(self) -> str:
|
||||
return (
|
||||
"Guarantee that every state-changing action emits a correct audit record, that the event catalogue is "
|
||||
"complete, and that denials and failures are logged with the right result.\n\n"
|
||||
"DETECT:\n"
|
||||
"- Any mutation lacking an audit record on its success path is an error. A mutation is a @router.post / "
|
||||
"@router.put / @router.delete, a .insert / .update / .delete DB write, or a background-service, scheduler, or "
|
||||
"CLI state change. The record is audit.record(request, ...) in request contexts or audit.record_system(...) "
|
||||
"in request-less contexts.\n"
|
||||
"- Guard and denial branches missing result=\"denied\", and failure branches missing result=\"failure\", are errors.\n"
|
||||
"- Event keys used in code but absent from events.md are errors; a new domain not mapped in "
|
||||
"services/audit/categories.py category_for is an error.\n"
|
||||
"- Double-counting is an error: the HTTP path and the Devii agent path for the same mutation must be disjoint "
|
||||
"(dispatcher _audit_mechanic covers the agent path; the route covers the HTTP path). A record gated on the "
|
||||
"action (so a logging failure would block it) is an error; recording is best-effort and never raises.\n\n"
|
||||
"FIX: add the recorder call at the mutation point with the correct event key, origin, via_agent, and result, "
|
||||
"never gating the action on it; extend events.md with the new key in the right domain; extend category_for for "
|
||||
"a new domain; route the call through the existing DRY choke point (content.py, the project_files.py helpers, "
|
||||
"routers/containers.py _audit_instance, the Devii dispatcher _audit_mechanic) rather than scattering call sites."
|
||||
)
|
||||
|
||||
def scope_units(self) -> list[tuple[str, str]]:
|
||||
return [
|
||||
("routers", "devplacepy/routers/*.py - every mutating route has audit.record on success and result on denial"),
|
||||
("content-choke", "devplacepy/content.py create/edit/delete record at the choke point"),
|
||||
("project-files", "devplacepy/project_files.py file/dir mutations recorded; read-only guard records denied"),
|
||||
("containers", "devplacepy/routers/containers.py _audit_instance covers lifecycle/exec/schedule"),
|
||||
("services", "devplacepy/services/* (news, jobs, containers, devii) use record_system with origin"),
|
||||
("catalogue", "events.md keys vs code keys; services/audit/categories.py category_for domain coverage"),
|
||||
]
|
||||
|
||||
|
||||
def main() -> None:
|
||||
cli_main(AuditAgent())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
+163
@@ -0,0 +1,163 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import asyncio
|
||||
import logging
|
||||
import sys
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
|
||||
from . import core
|
||||
from .agent import (
|
||||
AgentState,
|
||||
MarkdownRenderer,
|
||||
clear_protected_trees,
|
||||
close_http_client,
|
||||
cost_session_total,
|
||||
format_usd,
|
||||
protect_agents,
|
||||
react_loop,
|
||||
usd_str,
|
||||
_with_datetime,
|
||||
)
|
||||
|
||||
DEFAULT_MAX_ITER = 40
|
||||
|
||||
MAINT_HEADER = """You are {name}, an autonomous maintenance agent for the DevPlace codebase, a FastAPI plus Jinja2 platform using the dataset library over SQLite, with pure ES6 module JavaScript on the frontend. You enforce exactly ONE quality dimension across the repository and nothing else.
|
||||
|
||||
ABSOLUTE EXCLUSION (NON-NEGOTIABLE): The `agents/` directory is the maintenance fleet's OWN source code. You MUST NOT read it for analysis, grep it, scan it, report on it, or modify it under any circumstances. It deliberately contains the very patterns you hunt for (em-dash characters, forbidden-name examples, destructive-command strings, HTML entities) as DETECTION DATA, not as violations. A "violation" found in `agents/` is never real. Always exclude `agents/` from every grep and glob (the search root is the application code, not the tooling). The engine also hard-blocks any write under `agents/`, so an attempt to fix something there will fail by design. Treat `agents/` as if it does not exist.
|
||||
|
||||
OPERATING PROTOCOL
|
||||
1. PLAN FIRST. Your VERY FIRST tool call MUST be plan() with goal, steps, success_criteria, and confidence.
|
||||
2. INVESTIGATE BEFORE CONCLUDING. Use grep, glob_files, list_dir, find_symbol, read_file, read_lines, and retrieve to gather evidence. Never assume a violation; confirm it against the source.
|
||||
3. ONE report_finding PER ISSUE. Every confirmed issue MUST be recorded with report_finding(dimension, severity, message, file, line, rule). Do not describe issues only in prose.
|
||||
4. SHARD WIDE. The codebase is large. Work through the scope units below one at a time. You MAY call delegate(task) to investigate an independent unit in a fresh context and fold its result back in.
|
||||
5. STAY IN YOUR LANE. Only this dimension. Record an unrelated problem at most as a single info finding.
|
||||
|
||||
{mode_rules}
|
||||
|
||||
OBEY THE RULES YOU ENFORCE: never write comments or docstrings in source you author, never use an em-dash (use a hyphen), keep the `retoor <retoor@molodetz.nl>` header as the first line of any file you create, never run the test suite, never perform any git write operation.
|
||||
|
||||
DIMENSION MANDATE
|
||||
{mandate}
|
||||
"""
|
||||
|
||||
CHECK_RULES = "MODE: CHECK (read-only). You MUST NOT modify any file; the writing tools are not available to you. Investigate and record every issue with report_finding (fixed=false). End with a one-line summary."
|
||||
|
||||
FIX_RULES = "MODE: FIX (autonomous). For every issue, record it with report_finding (set fixed=true once corrected) AND apply a minimal, idiomatic fix. You MUST read_file an existing file before editing it; prefer edit_file for surgical changes. After all edits, call verify('python -m agents.validator .') and ensure it passes. End with a one-line summary."
|
||||
|
||||
|
||||
class MaintenanceAgent:
|
||||
name: str = "maintenance"
|
||||
description: str = ""
|
||||
|
||||
def mandate(self) -> str:
|
||||
raise NotImplementedError
|
||||
|
||||
def scope_units(self) -> list[tuple[str, str]]:
|
||||
return []
|
||||
|
||||
def system_prompt(self, mode: str) -> str:
|
||||
rules = CHECK_RULES if mode == "check" else FIX_RULES
|
||||
return MAINT_HEADER.format(name=self.name, mode_rules=rules, mandate=self.mandate())
|
||||
|
||||
def task_prompt(self, mode: str, scope: Optional[str]) -> str:
|
||||
units = self.scope_units()
|
||||
if scope:
|
||||
units = [unit for unit in units if unit[0] == scope] or units
|
||||
listed = "\n".join(f"- {label}: {focus}" for label, focus in units)
|
||||
action = "record each issue" if mode == "check" else "record and fix each issue"
|
||||
return (
|
||||
f"Dimension: {self.description}\n\n"
|
||||
f"Scope units to sweep ({mode} mode):\n{listed}\n\n"
|
||||
f"Work through each unit and {action} via report_finding. "
|
||||
f"Exclude the `agents/` directory from every grep and glob; it is the fleet's own source and is off-limits. "
|
||||
f"Finish with a single line: 'N findings (E errors, W warnings), M fixed.'"
|
||||
)
|
||||
|
||||
async def run(
|
||||
self,
|
||||
mode: str,
|
||||
scope: Optional[str],
|
||||
max_iter: int,
|
||||
renderer: Optional[MarkdownRenderer],
|
||||
) -> dict:
|
||||
core.reset_findings()
|
||||
protect_agents()
|
||||
cost_before = cost_session_total()["cost"]
|
||||
started = datetime.now()
|
||||
messages = [
|
||||
{"role": "system", "content": _with_datetime(self.system_prompt(mode))},
|
||||
{"role": "user", "content": self.task_prompt(mode, scope)},
|
||||
]
|
||||
state = AgentState()
|
||||
try:
|
||||
await react_loop(
|
||||
messages=messages,
|
||||
tools_payload=core.payloads_for(mode),
|
||||
state=state,
|
||||
max_iterations=max_iter,
|
||||
renderer=renderer,
|
||||
)
|
||||
finally:
|
||||
clear_protected_trees()
|
||||
finished = datetime.now()
|
||||
session_cost = cost_session_total()["cost"]
|
||||
run_cost = session_cost - cost_before
|
||||
cost = {"run_usd": usd_str(run_cost), "session_usd": usd_str(session_cost)}
|
||||
report = core.write_reports(self.name, mode, started, finished, cost=cost)
|
||||
summary = report["summary"]
|
||||
exit_code = (
|
||||
1 if summary["total"] > 0 else 0
|
||||
) if mode == "check" else (1 if summary["unfixed"] > 0 else 0)
|
||||
result = {
|
||||
"name": self.name,
|
||||
"mode": mode,
|
||||
"summary": summary,
|
||||
"cost": cost,
|
||||
"json": report["json"],
|
||||
"items": report["items"],
|
||||
"exit_code": exit_code,
|
||||
}
|
||||
if renderer is not None:
|
||||
renderer.print(
|
||||
f"\n**{self.name}** [{mode}] -> {summary['total']} findings "
|
||||
f"({summary['errors']} errors, {summary['warnings']} warnings), "
|
||||
f"{summary['fixed']} fixed. \U0001F4B0 {format_usd(run_cost)} this run "
|
||||
f"({format_usd(session_cost)} session). Report: `{report['json']}`"
|
||||
)
|
||||
return result
|
||||
|
||||
|
||||
def build_parser(name: str, description: str) -> argparse.ArgumentParser:
|
||||
parser = argparse.ArgumentParser(prog=f"agents.{name}", description=description)
|
||||
mode = parser.add_mutually_exclusive_group()
|
||||
mode.add_argument("--fix", dest="mode", action="store_const", const="fix", help="Autonomously fix findings (default)")
|
||||
mode.add_argument("--check", dest="mode", action="store_const", const="check", help="Report only; non-zero exit on findings")
|
||||
parser.set_defaults(mode="fix")
|
||||
parser.add_argument("--scope", default=None, help="Restrict to one scope unit label")
|
||||
parser.add_argument("--max-iter", type=int, default=DEFAULT_MAX_ITER, help="Maximum agent iterations")
|
||||
parser.add_argument("--no-color", action="store_true", help="Disable ANSI colour output")
|
||||
parser.add_argument("-v", "--verbose", action="store_true", help="Enable debug logging")
|
||||
return parser
|
||||
|
||||
|
||||
async def _amain(agent: MaintenanceAgent, argv: Optional[list[str]] = None) -> int:
|
||||
args = build_parser(agent.name, agent.description).parse_args(argv)
|
||||
if args.verbose:
|
||||
logging.getLogger().setLevel(logging.DEBUG)
|
||||
renderer = MarkdownRenderer(use_color=not args.no_color)
|
||||
try:
|
||||
result = await agent.run(args.mode, args.scope, args.max_iter, renderer)
|
||||
return result["exit_code"]
|
||||
finally:
|
||||
await close_http_client()
|
||||
|
||||
|
||||
def cli_main(agent: MaintenanceAgent) -> None:
|
||||
try:
|
||||
sys.exit(asyncio.run(_amain(agent)))
|
||||
except KeyboardInterrupt:
|
||||
sys.exit(130)
|
||||
@@ -0,0 +1,193 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
from typing import Any, Optional
|
||||
|
||||
from ..agent import (
|
||||
tool,
|
||||
react_loop,
|
||||
AgentState,
|
||||
get_tool,
|
||||
get_tool_payloads,
|
||||
MarkdownRenderer,
|
||||
close_http_client,
|
||||
_with_datetime,
|
||||
)
|
||||
|
||||
REPORTS_DIR = Path(__file__).resolve().parent.parent / "reports"
|
||||
|
||||
WRITE_TOOLS = ("create_file", "write_file", "edit_file", "patch_file")
|
||||
WEB_TOOLS = (
|
||||
"web_search",
|
||||
"deep_search",
|
||||
"ai_search",
|
||||
"fetch_url",
|
||||
"download_file",
|
||||
"download_files",
|
||||
"describe_image",
|
||||
)
|
||||
SWARM_TOOLS = (
|
||||
"spawn",
|
||||
"swarm_wait",
|
||||
"swarm_result",
|
||||
"swarm_tail",
|
||||
"swarm_kill",
|
||||
"swarm_cleanup",
|
||||
)
|
||||
SEVERITIES = ("error", "warning", "info")
|
||||
|
||||
_FINDINGS: list[dict[str, Any]] = []
|
||||
|
||||
|
||||
def reset_findings() -> None:
|
||||
_FINDINGS.clear()
|
||||
|
||||
|
||||
def findings() -> list[dict[str, Any]]:
|
||||
return list(_FINDINGS)
|
||||
|
||||
|
||||
@tool
|
||||
async def report_finding(
|
||||
dimension: str,
|
||||
severity: str,
|
||||
message: str,
|
||||
file: str = "",
|
||||
line: int = 0,
|
||||
rule: str = "",
|
||||
fixed: bool = False,
|
||||
fix_summary: str = "",
|
||||
):
|
||||
"""Record one maintenance finding for the run report. Call once per confirmed issue.
|
||||
dimension: The check that produced this finding.
|
||||
severity: One of error, warning, info.
|
||||
message: Human-readable description of the issue.
|
||||
file: Repository-relative path of the offending file.
|
||||
line: 1-based line number when known, else 0.
|
||||
rule: Short machine rule id, e.g. mutation-without-record.
|
||||
fixed: True if this run already applied a fix.
|
||||
fix_summary: One line describing the fix when fixed is true.
|
||||
"""
|
||||
severity_value = severity if severity in SEVERITIES else "warning"
|
||||
_FINDINGS.append(
|
||||
{
|
||||
"severity": severity_value,
|
||||
"dimension": dimension,
|
||||
"file": file,
|
||||
"line": int(line) if line else 0,
|
||||
"rule": rule,
|
||||
"message": message,
|
||||
"fixed": bool(fixed),
|
||||
"fix_summary": fix_summary,
|
||||
}
|
||||
)
|
||||
return json.dumps({"status": "success", "recorded": True, "total_findings": len(_FINDINGS)})
|
||||
|
||||
|
||||
def payloads_for(mode: str) -> list[dict[str, Any]]:
|
||||
exclude = WEB_TOOLS + SWARM_TOOLS
|
||||
if mode == "check":
|
||||
exclude = exclude + WRITE_TOOLS + ("verify",)
|
||||
return get_tool_payloads(exclude=exclude)
|
||||
|
||||
|
||||
def payloads_named(names: tuple[str, ...]) -> list[dict[str, Any]]:
|
||||
out: list[dict[str, Any]] = []
|
||||
for name in names:
|
||||
func = get_tool(name)
|
||||
if func is not None:
|
||||
out.append(func._tool_payload)
|
||||
return out
|
||||
|
||||
|
||||
def summarize(items: list[dict[str, Any]]) -> dict[str, int]:
|
||||
errors = sum(1 for f in items if f["severity"] == "error")
|
||||
warnings = sum(1 for f in items if f["severity"] == "warning")
|
||||
fixed = sum(1 for f in items if f["fixed"])
|
||||
return {
|
||||
"total": len(items),
|
||||
"errors": errors,
|
||||
"warnings": warnings,
|
||||
"fixed": fixed,
|
||||
"unfixed": len(items) - fixed,
|
||||
}
|
||||
|
||||
|
||||
def _md_report(name: str, mode: str, summary: dict[str, int], items: list[dict[str, Any]]) -> str:
|
||||
lines = [
|
||||
f"# {name} report ({mode})",
|
||||
"",
|
||||
f"- total: {summary['total']}",
|
||||
f"- errors: {summary['errors']}",
|
||||
f"- warnings: {summary['warnings']}",
|
||||
f"- fixed: {summary['fixed']}",
|
||||
f"- unfixed: {summary['unfixed']}",
|
||||
"",
|
||||
"## Findings",
|
||||
"",
|
||||
]
|
||||
if not items:
|
||||
lines.append("None.")
|
||||
return "\n".join(lines)
|
||||
by_file: dict[str, list[dict[str, Any]]] = {}
|
||||
for finding in items:
|
||||
by_file.setdefault(finding["file"] or "(repository)", []).append(finding)
|
||||
for path, group in sorted(by_file.items()):
|
||||
lines.append(f"### {path}")
|
||||
for finding in group:
|
||||
location = f":{finding['line']}" if finding["line"] else ""
|
||||
mark = "fixed" if finding["fixed"] else finding["severity"]
|
||||
label = finding["rule"] or finding["dimension"]
|
||||
lines.append(f"- [{mark}] {label}{location}: {finding['message']}")
|
||||
if finding["fixed"] and finding["fix_summary"]:
|
||||
lines.append(f" fix: {finding['fix_summary']}")
|
||||
lines.append("")
|
||||
return "\n".join(lines)
|
||||
|
||||
|
||||
def write_reports(
|
||||
name: str,
|
||||
mode: str,
|
||||
started: datetime,
|
||||
finished: datetime,
|
||||
cost: Optional[dict[str, Any]] = None,
|
||||
) -> dict[str, Any]:
|
||||
REPORTS_DIR.mkdir(parents=True, exist_ok=True)
|
||||
items = findings()
|
||||
summary = summarize(items)
|
||||
stamp = started.strftime("%Y%m%d-%H%M%S")
|
||||
base = REPORTS_DIR / f"{name}-{stamp}"
|
||||
payload = {
|
||||
"agent": name,
|
||||
"mode": mode,
|
||||
"started_at": started.isoformat(),
|
||||
"finished_at": finished.isoformat(),
|
||||
"summary": summary,
|
||||
"cost": cost or {},
|
||||
"findings": items,
|
||||
}
|
||||
base.with_suffix(".json").write_text(json.dumps(payload, indent=2), encoding="utf-8")
|
||||
base.with_suffix(".md").write_text(_md_report(name, mode, summary, items), encoding="utf-8")
|
||||
return {"summary": summary, "json": str(base.with_suffix(".json")), "items": items}
|
||||
|
||||
|
||||
__all__ = [
|
||||
"tool",
|
||||
"react_loop",
|
||||
"AgentState",
|
||||
"MarkdownRenderer",
|
||||
"close_http_client",
|
||||
"_with_datetime",
|
||||
"report_finding",
|
||||
"reset_findings",
|
||||
"findings",
|
||||
"payloads_for",
|
||||
"payloads_named",
|
||||
"summarize",
|
||||
"write_reports",
|
||||
"REPORTS_DIR",
|
||||
]
|
||||
@@ -0,0 +1,13 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
|
||||
from ..agent import ( # noqa: F401
|
||||
cost_session_total,
|
||||
cost_record,
|
||||
set_cost_stream,
|
||||
format_usd,
|
||||
usd_str,
|
||||
PER_MILLION,
|
||||
PRICE_CACHE_HIT_PER_M,
|
||||
PRICE_CACHE_MISS_PER_M,
|
||||
PRICE_OUTPUT_PER_M,
|
||||
)
|
||||
@@ -0,0 +1,3 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
|
||||
from ..agent import run_command, verify, stream_subprocess # noqa: F401
|
||||
@@ -0,0 +1,3 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
|
||||
from ..agent import read_file, read_lines, write_file, create_file, edit_file, patch_file, list_dir, glob_files, grep, find_symbol # noqa: F401
|
||||
@@ -0,0 +1,3 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
|
||||
from ..agent import Backend, get_backends, vision_available, llm_call, _call_backend, MODEL, DEEPSEEK_MODEL # noqa: F401
|
||||
@@ -0,0 +1,3 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
|
||||
from ..agent import AgentState, react_loop, compact_messages, context_size, find_compaction_split # noqa: F401
|
||||
@@ -0,0 +1,3 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
|
||||
from ..agent import SYSTEM_PROMPT, SUB_AGENT_SYSTEM_PROMPT, system_message, _with_datetime # noqa: F401
|
||||
@@ -0,0 +1,3 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
|
||||
from ..agent import MarkdownRenderer # noqa: F401
|
||||
@@ -0,0 +1,3 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
|
||||
from ..agent import run_once, interactive, amain, main # noqa: F401
|
||||
@@ -0,0 +1,3 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
|
||||
from ..agent import delegate, spawn, swarm_wait, swarm_result, swarm_tail, swarm_kill, swarm_cleanup, retrieve, CorpusIndex, get_corpus_index # noqa: F401
|
||||
@@ -0,0 +1,3 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
|
||||
from ..agent import tool, get_tool, get_tool_payloads, execute_tool_call, coerce_tool_args, validate_tool_args, _build_function_payload # noqa: F401
|
||||
@@ -0,0 +1,3 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
|
||||
from ..agent import web_search, deep_search, ai_search, fetch_url, download_file, download_files, describe_image # noqa: F401
|
||||
@@ -0,0 +1,47 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from .base import MaintenanceAgent, cli_main
|
||||
|
||||
|
||||
class DeviiAgent(MaintenanceAgent):
|
||||
name = "devii"
|
||||
description = "Devii capability and role-gated tool-list maintainer"
|
||||
|
||||
def mandate(self) -> str:
|
||||
return (
|
||||
"Guarantee that Devii can perform, via REST, everything the site offers to the logged-in user's role, and "
|
||||
"that the tool list presented to a given user exposes only the tools that role may call. A non-admin must not "
|
||||
"even see that admin tools exist.\n\n"
|
||||
"DETECT:\n"
|
||||
"- Enumerate every REST route across devplacepy/routers/*.py and diff against CATALOG.by_name(). Every route a "
|
||||
"user could reasonably ask Devii to perform has a corresponding Action. A user-facing capability with no Devii "
|
||||
"action is a finding.\n"
|
||||
"- Each Action's requires_auth and requires_admin flags exactly match its route's guard. An admin-guarded route "
|
||||
"exposed as a non-admin Devii action is a security-grade error; a public route wrongly marked requires_auth=True "
|
||||
"is a capability gap.\n"
|
||||
"- Catalog.tool_schemas_for(authenticated, is_admin) withholds an admin tool's schema from a non-admin, and the "
|
||||
"dispatcher still raises AuthRequiredError if a non-admin names it. Confirm both halves hold for every action; a "
|
||||
"tool whose schema leaks to the wrong role is an error.\n"
|
||||
"- Irreversible Devii actions are in CONFIRM_REQUIRED.\n\n"
|
||||
"FIX: add the missing Action in the correct handler module with the right method, path, requires_auth, and "
|
||||
"requires_admin; correct a misaligned auth flag. Never grant a member an admin capability to close a parity gap; "
|
||||
"an admin-only capability with no member action is left admin-only. Hand new-tool documentation to the docs agent."
|
||||
)
|
||||
|
||||
def scope_units(self) -> list[tuple[str, str]]:
|
||||
return [
|
||||
("route-parity", "devplacepy/routers/*.py routes vs services/devii/actions/catalog.py CATALOG.by_name()"),
|
||||
("flag-alignment", "each Action requires_auth/requires_admin matches the route guard"),
|
||||
("role-visibility", "services/devii/actions/spec.py tool_schemas_for: no admin schema reaches a non-admin"),
|
||||
("dispatch-guard", "services/devii/actions/dispatcher.py AuthRequiredError on requires_admin; CONFIRM_REQUIRED"),
|
||||
]
|
||||
|
||||
|
||||
def main() -> None:
|
||||
cli_main(DeviiAgent())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,48 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from .base import MaintenanceAgent, cli_main
|
||||
|
||||
|
||||
class DocsAgent(MaintenanceAgent):
|
||||
name = "docs"
|
||||
description = "documentation coverage and role-aware show/hide maintainer"
|
||||
|
||||
def mandate(self) -> str:
|
||||
return (
|
||||
"Keep CLAUDE.md, AGENTS.md, README.md, and the /docs pages in exact agreement with the source, and keep "
|
||||
"role-based visibility consistent so admin material is shown to admins and hidden from members and guests at "
|
||||
"both the page and the section level.\n\n"
|
||||
"DETECT:\n"
|
||||
"- Every public or authenticated REST route has a docs_api.endpoint() entry in the correct group, with params "
|
||||
"and a sample_response. A documented route whose params drifted from the actual Form model is an error.\n"
|
||||
"- Every prose page's factual claims match the code (routes, env vars, defaults, behavior). A stale claim is an error.\n"
|
||||
"- README.md reflects current routes, env vars, dependencies, and user-visible features. AGENTS.md has a domain "
|
||||
"section for every mechanic. CLAUDE.md changes only for a new architectural rule.\n"
|
||||
"- Page-level role gating: admin-only pages carry \"admin\": True in their DOCS_PAGES entry; the router filters "
|
||||
"the sidebar to visible_pages and 404s a non-admin requesting an admin page, while docs_search still indexes admin "
|
||||
"pages for admins. An admin page missing the flag, or a member page wrongly flagged admin, is an error.\n"
|
||||
"- Section-level role gating: prose templates receive the user context via docs_prose.render_prose and gate admin "
|
||||
"sections with Jinja {% if user %} / {% if user.role == 'admin' %}. Unguarded admin material on a public page is an error.\n\n"
|
||||
"FIX: add or repair the endpoint() entry, rewrite the stale prose, add the missing README.md / AGENTS.md section, "
|
||||
"add the \"admin\": True flag, or wrap the leaking section in the correct Jinja guard. The source is authoritative; "
|
||||
"correct the docs to match the code, never the reverse."
|
||||
)
|
||||
|
||||
def scope_units(self) -> list[tuple[str, str]]:
|
||||
return [
|
||||
("api-docs", "devplacepy/docs_api.py endpoint() coverage vs routers/*.py routes"),
|
||||
("page-gating", "devplacepy/routers/docs.py DOCS_PAGES admin flag; visible_pages filter; docs_search indexing"),
|
||||
("section-gating", "templates/docs/*.html Jinja {% if user.role == 'admin' %} on admin sections"),
|
||||
("readme", "README.md reflects current routes, env vars, dependencies, features"),
|
||||
("agents-md", "AGENTS.md has a domain section for every mechanic; CLAUDE.md only for new rules"),
|
||||
]
|
||||
|
||||
|
||||
def main() -> None:
|
||||
cli_main(DocsAgent())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,43 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from .base import MaintenanceAgent, cli_main
|
||||
|
||||
|
||||
class DryAgent(MaintenanceAgent):
|
||||
name = "dry"
|
||||
description = "duplication and reuse enforcement"
|
||||
|
||||
def mandate(self) -> str:
|
||||
return (
|
||||
"Eliminate duplicated logic and re-implementations of the canonical shared utilities.\n\n"
|
||||
"DETECT:\n"
|
||||
"- Backend: inline N+1 loops where a batch helper exists (get_users_by_uids, get_comment_counts_by_post_uids, "
|
||||
"get_vote_counts, load_comments, build_pagination, _in_clause); per-router Jinja2Templates instead of the shared "
|
||||
"templating.templates; inline avatar or user links instead of the _avatar_link.html / _user_link.html partials.\n"
|
||||
"- Frontend: hand-rolled fetch instead of Http; bespoke polling instead of Poller; bespoke job polling instead of "
|
||||
"JobPoller; click-to-POST controllers not extending OptimisticAction; floating windows not extending FloatingWindow.\n"
|
||||
"- General: blocks of duplicated logic that should be extracted into a shared helper.\n\n"
|
||||
"FIX: replace the call site with the existing utility, or extract a new shared helper and route the duplicate "
|
||||
"call sites through it; extractions follow the project's small-files structure and must not change behavior. When "
|
||||
"similarity is below a confidence threshold, record an info finding for human review rather than auto-extracting."
|
||||
)
|
||||
|
||||
def scope_units(self) -> list[tuple[str, str]]:
|
||||
return [
|
||||
("batch-helpers", "routers/*.py use database.py batch helpers, not inline N+1 loops"),
|
||||
("templates", "every router imports templating.templates, never its own Jinja2Templates"),
|
||||
("partials", "_avatar_link.html / _user_link.html reused, not inline avatar/user markup"),
|
||||
("frontend-http", "static/js/*.js use Http, not hand-rolled fetch"),
|
||||
("frontend-poll", "static/js/*.js use Poller / JobPoller, not bespoke loops"),
|
||||
("frontend-base", "controllers extend OptimisticAction; windows extend FloatingWindow"),
|
||||
]
|
||||
|
||||
|
||||
def main() -> None:
|
||||
cli_main(DryAgent())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,46 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from .base import MaintenanceAgent, cli_main
|
||||
|
||||
|
||||
class FeatureFanoutAgent(MaintenanceAgent):
|
||||
name = "fanout"
|
||||
description = "cross-layer feature completeness checker"
|
||||
|
||||
def mandate(self) -> str:
|
||||
return (
|
||||
"Enforce the 'Anatomy of a feature' checklist: for each route, every layer of the fan-out exists and agrees.\n\n"
|
||||
"DETECT, for each route:\n"
|
||||
"- Input has a models.py Form model declared as data: Annotated[SomeForm, Form()] (or a documented raw-form "
|
||||
"exception for file uploads).\n"
|
||||
"- If the route serves JSON via respond(..., model=XOut), every context key the route returns exists on XOut. "
|
||||
"A key returned but absent from the schema is silently dropped and is an error.\n"
|
||||
"- The route returns HTML and JSON through respond (or pure JSON via JSONResponse) consistently.\n"
|
||||
"- A services/devii/actions/catalog.py Action exists if the route is something a user could ask Devii to do.\n"
|
||||
"- A docs_api.py entry exists for every public or authenticated endpoint.\n"
|
||||
"- Public pages build base_seo_context.\n"
|
||||
"- README.md and AGENTS.md mention the feature.\n\n"
|
||||
"FIX: add the missing Form, add the missing key to the *Out schema, switch the handler to respond, or flag the "
|
||||
"responsible specialist's layer. When a layer is intentionally absent (an internal route with no public docs, a "
|
||||
"route Devii should never call), record an info finding with the rationale rather than fabricating the layer."
|
||||
)
|
||||
|
||||
def scope_units(self) -> list[tuple[str, str]]:
|
||||
return [
|
||||
("forms", "devplacepy/models.py Form model exists for each mutating route input"),
|
||||
("schemas", "devplacepy/schemas.py *Out has every key returned by respond(model=XOut)"),
|
||||
("respond", "routers/*.py serve HTML+JSON via respond consistently"),
|
||||
("devii-action", "services/devii/actions/catalog.py Action exists for user-facing routes"),
|
||||
("api-docs", "devplacepy/docs_api.py entry for each public/auth endpoint"),
|
||||
("seo-readme", "seo.py base_seo_context for public pages; README/AGENTS mention the feature"),
|
||||
]
|
||||
|
||||
|
||||
def main() -> None:
|
||||
cli_main(FeatureFanoutAgent())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,47 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from .audit import AuditAgent
|
||||
from .devii import DeviiAgent
|
||||
from .docs import DocsAgent
|
||||
from .dry import DryAgent
|
||||
from .fanout import FeatureFanoutAgent
|
||||
from .frontend import FrontendAgent
|
||||
from .security import SecurityAgent
|
||||
from .seo import SeoAgent
|
||||
from .style import StyleAgent
|
||||
from .test_coverage import TestAgent
|
||||
|
||||
ORDER = [
|
||||
"style",
|
||||
"dry",
|
||||
"security",
|
||||
"audit",
|
||||
"devii",
|
||||
"seo",
|
||||
"frontend",
|
||||
"fanout",
|
||||
"docs",
|
||||
"test",
|
||||
]
|
||||
|
||||
REGISTRY = {
|
||||
"style": StyleAgent,
|
||||
"dry": DryAgent,
|
||||
"security": SecurityAgent,
|
||||
"audit": AuditAgent,
|
||||
"devii": DeviiAgent,
|
||||
"seo": SeoAgent,
|
||||
"frontend": FrontendAgent,
|
||||
"fanout": FeatureFanoutAgent,
|
||||
"docs": DocsAgent,
|
||||
"test": TestAgent,
|
||||
}
|
||||
|
||||
|
||||
def ordered_agents(only: list[str] | None = None) -> list[str]:
|
||||
if not only:
|
||||
return list(ORDER)
|
||||
wanted = {name.strip() for name in only if name.strip()}
|
||||
return [name for name in ORDER if name in wanted]
|
||||
@@ -0,0 +1,42 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from .base import MaintenanceAgent, cli_main
|
||||
|
||||
|
||||
class FrontendAgent(MaintenanceAgent):
|
||||
name = "frontend"
|
||||
description = "ES6, component, and CSS consistency"
|
||||
|
||||
def mandate(self) -> str:
|
||||
return (
|
||||
"Keep the frontend conformant to the project's strict ES6 and component rules.\n\n"
|
||||
"DETECT:\n"
|
||||
"- One class per ES6 module, instantiated and reachable via the global app, with Application.js as the root.\n"
|
||||
"- Custom dp- components extend Component, self-register via customElements.define at the bottom of their file, "
|
||||
"render into the light DOM (no shadow root so global CSS applies), and inject their own CSS <link> on "
|
||||
"instantiation if absent.\n"
|
||||
"- CSS uses variables (the design tokens), and pages are responsive down to very small phones.\n"
|
||||
"- CDN scripts in templates/base.html use defer or type=\"module\" so the Playwright domcontentloaded wait does "
|
||||
"not time out.\n\n"
|
||||
"FIX: split a multi-class module, add the missing customElements.define, remove a shadow root, add the dynamic CSS "
|
||||
"link injection, replace a hard-coded color with a token, or add defer to a CDN script. Never introduce a JS "
|
||||
"framework, NPM, or a build step. Visual judgement is out of scope for auto-fix and is recorded as a finding."
|
||||
)
|
||||
|
||||
def scope_units(self) -> list[tuple[str, str]]:
|
||||
return [
|
||||
("one-class", "static/js/*.js one class per module, instantiated on app"),
|
||||
("components", "static/js/components/*.js extend Component, define, light DOM, CSS link injection"),
|
||||
("css-tokens", "static/css/*.css use design-token variables; responsive to small phones"),
|
||||
("cdn-scripts", "templates/base.html CDN scripts use defer or type=module"),
|
||||
]
|
||||
|
||||
|
||||
def main() -> None:
|
||||
cli_main(FrontendAgent())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,267 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import asyncio
|
||||
import json
|
||||
import logging
|
||||
import sys
|
||||
from typing import Any, Optional
|
||||
|
||||
from . import core
|
||||
from .agent import (
|
||||
AgentState,
|
||||
MarkdownRenderer,
|
||||
close_http_client,
|
||||
get_tool,
|
||||
react_loop,
|
||||
tool,
|
||||
_with_datetime,
|
||||
)
|
||||
from .fleet import REGISTRY, ordered_agents
|
||||
from .orchestrator import run_fleet
|
||||
|
||||
MAESTRO_AGENT_MAX_ITER = 30
|
||||
MAX_RETURNED_FINDINGS = 12
|
||||
|
||||
_LAST_RESULTS: dict[str, dict[str, Any]] = {}
|
||||
_RENDERER: Optional[MarkdownRenderer] = None
|
||||
|
||||
|
||||
def _set_renderer(renderer: MarkdownRenderer) -> None:
|
||||
global _RENDERER
|
||||
_RENDERER = renderer
|
||||
|
||||
|
||||
async def _dispatch(name: str, mode: str, scope: str) -> str:
|
||||
if name not in REGISTRY:
|
||||
return json.dumps({"status": "error", "error": f"Unknown agent '{name}'. Known: {ordered_agents()}"})
|
||||
run_mode = "fix" if str(mode).lower() == "fix" else "check"
|
||||
renderer = _RENDERER
|
||||
if renderer is not None:
|
||||
scope_note = f" scope={scope}" if scope else ""
|
||||
renderer.print(f"\n--- running **{name}** [{run_mode}]{scope_note} ---")
|
||||
agent = REGISTRY[name]()
|
||||
result = await agent.run(run_mode, scope or None, MAESTRO_AGENT_MAX_ITER, renderer=renderer)
|
||||
_LAST_RESULTS[name] = result
|
||||
items = result["items"][:MAX_RETURNED_FINDINGS]
|
||||
return json.dumps(
|
||||
{
|
||||
"status": "success",
|
||||
"agent": name,
|
||||
"mode": run_mode,
|
||||
"summary": result["summary"],
|
||||
"cost": result.get("cost"),
|
||||
"report": result["json"],
|
||||
"findings": items,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@tool
|
||||
async def list_agents():
|
||||
"""List the maintenance agents Maestro can run, with their dimension."""
|
||||
return json.dumps(
|
||||
{"status": "success", "agents": [{"name": name, "dimension": REGISTRY[name].description} for name in ordered_agents()]}
|
||||
)
|
||||
|
||||
|
||||
@tool
|
||||
async def read_report(agent: str):
|
||||
"""Return the latest in-memory result for one agent without re-running it.
|
||||
agent: The agent name, e.g. security, audit, devii.
|
||||
"""
|
||||
result = _LAST_RESULTS.get(agent)
|
||||
if result is None:
|
||||
return json.dumps({"status": "error", "error": f"No result yet for '{agent}'. Run it first."})
|
||||
return json.dumps({"status": "success", "agent": agent, "summary": result["summary"], "findings": result["items"][:MAX_RETURNED_FINDINGS]})
|
||||
|
||||
|
||||
@tool
|
||||
async def run_security(mode: str = "check", scope: str = ""):
|
||||
"""Run the data and role security agent. mode: check (default) or fix. scope: optional unit label."""
|
||||
return await _dispatch("security", mode, scope)
|
||||
|
||||
|
||||
@tool
|
||||
async def run_audit(mode: str = "check", scope: str = ""):
|
||||
"""Run the audit-log coverage agent. mode: check (default) or fix. scope: optional unit label."""
|
||||
return await _dispatch("audit", mode, scope)
|
||||
|
||||
|
||||
@tool
|
||||
async def run_devii(mode: str = "check", scope: str = ""):
|
||||
"""Run the Devii capability and role-gated tool-list agent. mode: check (default) or fix."""
|
||||
return await _dispatch("devii", mode, scope)
|
||||
|
||||
|
||||
@tool
|
||||
async def run_docs(mode: str = "check", scope: str = ""):
|
||||
"""Run the documentation coverage and role-aware show/hide agent. mode: check (default) or fix."""
|
||||
return await _dispatch("docs", mode, scope)
|
||||
|
||||
|
||||
@tool
|
||||
async def run_fanout(mode: str = "check", scope: str = ""):
|
||||
"""Run the cross-layer feature completeness agent. mode: check (default) or fix."""
|
||||
return await _dispatch("fanout", mode, scope)
|
||||
|
||||
|
||||
@tool
|
||||
async def run_dry(mode: str = "check", scope: str = ""):
|
||||
"""Run the duplication and reuse agent. mode: check (default) or fix."""
|
||||
return await _dispatch("dry", mode, scope)
|
||||
|
||||
|
||||
@tool
|
||||
async def run_style(mode: str = "check", scope: str = ""):
|
||||
"""Run the coding-rule compliance agent. mode: check (default) or fix."""
|
||||
return await _dispatch("style", mode, scope)
|
||||
|
||||
|
||||
@tool
|
||||
async def run_frontend(mode: str = "check", scope: str = ""):
|
||||
"""Run the ES6, component, and CSS consistency agent. mode: check (default) or fix."""
|
||||
return await _dispatch("frontend", mode, scope)
|
||||
|
||||
|
||||
@tool
|
||||
async def run_seo(mode: str = "check", scope: str = ""):
|
||||
"""Run the SEO and sitemap coverage agent. mode: check (default) or fix."""
|
||||
return await _dispatch("seo", mode, scope)
|
||||
|
||||
|
||||
@tool
|
||||
async def run_tests(mode: str = "check", scope: str = ""):
|
||||
"""Run the integration-test coverage agent. It writes tests but never runs the suite. mode: check (default) or fix."""
|
||||
return await _dispatch("test", mode, scope)
|
||||
|
||||
|
||||
@tool
|
||||
async def run_fleet_tool(mode: str = "check"):
|
||||
"""Run the whole maintenance fleet in dependency order via the orchestrator. mode: check (default) or fix."""
|
||||
run_mode = "fix" if str(mode).lower() == "fix" else "check"
|
||||
code = await run_fleet(run_mode, None, MAESTRO_AGENT_MAX_ITER, renderer=_RENDERER)
|
||||
return json.dumps({"status": "success", "mode": run_mode, "fleet_exit_code": code})
|
||||
|
||||
|
||||
MAESTRO_TOOLS = (
|
||||
"list_agents",
|
||||
"read_report",
|
||||
"run_security",
|
||||
"run_audit",
|
||||
"run_devii",
|
||||
"run_docs",
|
||||
"run_fanout",
|
||||
"run_dry",
|
||||
"run_style",
|
||||
"run_frontend",
|
||||
"run_seo",
|
||||
"run_tests",
|
||||
"run_fleet_tool",
|
||||
"read_file",
|
||||
"read_lines",
|
||||
"grep",
|
||||
"glob_files",
|
||||
"list_dir",
|
||||
"retrieve",
|
||||
"get_current_isodate",
|
||||
)
|
||||
|
||||
MAESTRO_PROMPT = """You are Maestro, the single conversational conductor of the DevPlace maintenance fleet. The operator talks to you and you master the rest: you decide which specialist agent or combination answers a request, run it, and explain the result in plain language.
|
||||
|
||||
THE FLEET (run each via its run_* tool):
|
||||
- run_security: data and role security
|
||||
- run_audit: audit-log coverage
|
||||
- run_devii: Devii capability and role-gated tool list
|
||||
- run_docs: documentation coverage and role-aware show/hide
|
||||
- run_fanout: cross-layer feature completeness
|
||||
- run_dry: duplication and reuse
|
||||
- run_style: coding-rule compliance
|
||||
- run_frontend: ES6, component, and CSS consistency
|
||||
- run_seo: SEO and sitemap coverage
|
||||
- run_tests: integration-test coverage (writes tests, never runs the suite)
|
||||
- run_fleet_tool: the whole fleet in dependency order
|
||||
|
||||
ROUTING: map the request to the right dimension and call its tool. Use list_agents if unsure. For an "everything" request use run_fleet_tool. Clarify an ambiguous request before running anything.
|
||||
|
||||
MODE POLICY: a question defaults to check (read-only). Run fix ONLY when the operator explicitly asks to fix, and CONFIRM before any fix run that writes, especially run_fleet_tool in fix mode. Never silently edit in answer to a question.
|
||||
|
||||
COST: every run streams its live cost after each AI call (per call and running total, with money emojis) and the tool result returns a `cost` field ({run_usd, session_usd}). When you summarize a run, mention what it cost in dollars so the operator sees how expensive each procedure was.
|
||||
|
||||
EXPLAINING: after a run, summarize the findings in plain language and reference the report path. Use read_report to answer follow-ups without re-running. Use read_file, grep, and retrieve to ground an explanation in the actual source. Every claim you make must be backed by a tool result or a direct source read; never invent a finding.
|
||||
"""
|
||||
|
||||
|
||||
def _payload() -> list[dict[str, Any]]:
|
||||
out: list[dict[str, Any]] = []
|
||||
for name in MAESTRO_TOOLS:
|
||||
func = get_tool(name)
|
||||
if func is not None:
|
||||
out.append(func._tool_payload)
|
||||
return out
|
||||
|
||||
|
||||
async def _turn(messages: list[dict[str, Any]], renderer: MarkdownRenderer) -> None:
|
||||
_set_renderer(renderer)
|
||||
state = AgentState()
|
||||
await react_loop(
|
||||
messages=messages,
|
||||
tools_payload=_payload(),
|
||||
state=state,
|
||||
max_iterations=60,
|
||||
renderer=renderer,
|
||||
)
|
||||
|
||||
|
||||
async def interactive(renderer: MarkdownRenderer) -> None:
|
||||
renderer.print("# Maestro\nThe conductor. Ask about any quality dimension, or say `exit` to quit.")
|
||||
messages: list[dict[str, Any]] = [{"role": "system", "content": _with_datetime(MAESTRO_PROMPT)}]
|
||||
loop = asyncio.get_event_loop()
|
||||
while True:
|
||||
try:
|
||||
line = await loop.run_in_executor(None, lambda: input("\n> "))
|
||||
except (EOFError, KeyboardInterrupt):
|
||||
break
|
||||
line = line.strip()
|
||||
if not line:
|
||||
continue
|
||||
if line.lower() in ("exit", "quit"):
|
||||
break
|
||||
messages.append({"role": "user", "content": line})
|
||||
await _turn(messages, renderer)
|
||||
|
||||
|
||||
async def _amain(argv: Optional[list[str]] = None) -> int:
|
||||
parser = argparse.ArgumentParser(prog="agents.maestro", description="Maestro, the conversational maintenance conductor")
|
||||
parser.add_argument("prompt", nargs="?", help="One-shot request; omit for interactive mode")
|
||||
parser.add_argument("--no-color", action="store_true")
|
||||
parser.add_argument("-v", "--verbose", action="store_true")
|
||||
args = parser.parse_args(argv)
|
||||
if args.verbose:
|
||||
logging.getLogger().setLevel(logging.DEBUG)
|
||||
renderer = MarkdownRenderer(use_color=not args.no_color)
|
||||
try:
|
||||
if args.prompt:
|
||||
messages = [
|
||||
{"role": "system", "content": _with_datetime(MAESTRO_PROMPT)},
|
||||
{"role": "user", "content": args.prompt},
|
||||
]
|
||||
await _turn(messages, renderer)
|
||||
else:
|
||||
await interactive(renderer)
|
||||
return 0
|
||||
finally:
|
||||
await close_http_client()
|
||||
|
||||
|
||||
def main() -> None:
|
||||
try:
|
||||
sys.exit(asyncio.run(_amain()))
|
||||
except KeyboardInterrupt:
|
||||
sys.exit(130)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,100 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import asyncio
|
||||
import json
|
||||
import logging
|
||||
import sys
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
|
||||
from . import core
|
||||
from .agent import MarkdownRenderer, close_http_client, cost_session_total, format_usd, usd_str
|
||||
from .fleet import REGISTRY, ordered_agents
|
||||
|
||||
|
||||
def _parser() -> argparse.ArgumentParser:
|
||||
parser = argparse.ArgumentParser(prog="agents.orchestrator", description="Run the maintenance fleet")
|
||||
mode = parser.add_mutually_exclusive_group()
|
||||
mode.add_argument("--fix", dest="mode", action="store_const", const="fix")
|
||||
mode.add_argument("--check", dest="mode", action="store_const", const="check")
|
||||
parser.set_defaults(mode="fix")
|
||||
parser.add_argument("--only", default=None, help="Comma-separated subset of agent names")
|
||||
parser.add_argument("--max-iter", type=int, default=40)
|
||||
parser.add_argument("--no-color", action="store_true")
|
||||
parser.add_argument("-v", "--verbose", action="store_true")
|
||||
return parser
|
||||
|
||||
|
||||
async def run_fleet(mode: str, only: Optional[str], max_iter: int, renderer: Optional[MarkdownRenderer]) -> int:
|
||||
names = ordered_agents(only.split(",") if only else None)
|
||||
started = datetime.now()
|
||||
results: list[dict] = []
|
||||
for name in names:
|
||||
agent = REGISTRY[name]()
|
||||
if renderer is not None:
|
||||
renderer.print(f"\n## {name}")
|
||||
result = await agent.run(mode, None, max_iter, renderer)
|
||||
results.append(
|
||||
{"name": name, "summary": result["summary"], "exit_code": result["exit_code"], "json": result["json"]}
|
||||
)
|
||||
finished = datetime.now()
|
||||
|
||||
totals = {"total": 0, "errors": 0, "warnings": 0, "fixed": 0, "unfixed": 0}
|
||||
for result in results:
|
||||
for key in totals:
|
||||
totals[key] += result["summary"][key]
|
||||
exit_code = max((result["exit_code"] for result in results), default=0)
|
||||
|
||||
session_cost = cost_session_total()["cost"]
|
||||
core.REPORTS_DIR.mkdir(parents=True, exist_ok=True)
|
||||
stamp = started.strftime("%Y%m%d-%H%M%S")
|
||||
fleet_payload = {
|
||||
"agent": "fleet",
|
||||
"mode": mode,
|
||||
"started_at": started.isoformat(),
|
||||
"finished_at": finished.isoformat(),
|
||||
"totals": totals,
|
||||
"cost": {"session_usd": usd_str(session_cost)},
|
||||
"agents": results,
|
||||
}
|
||||
fleet_json = core.REPORTS_DIR / f"fleet-{stamp}.json"
|
||||
fleet_json.write_text(json.dumps(fleet_payload, indent=2), encoding="utf-8")
|
||||
|
||||
if renderer is not None:
|
||||
rows = "\n".join(
|
||||
f"- {result['name']}: {result['summary']['total']} findings "
|
||||
f"({result['summary']['errors']} err), {result['summary']['fixed']} fixed"
|
||||
for result in results
|
||||
)
|
||||
renderer.print(
|
||||
f"\n# Fleet [{mode}] complete\n{rows}\n\n"
|
||||
f"Totals: {totals['total']} findings, {totals['errors']} errors, {totals['fixed']} fixed. "
|
||||
f"\U0001F4B0 {format_usd(session_cost)} total session cost. "
|
||||
f"Report: `{fleet_json}`"
|
||||
)
|
||||
return exit_code
|
||||
|
||||
|
||||
async def _amain(argv: Optional[list[str]] = None) -> int:
|
||||
args = _parser().parse_args(argv)
|
||||
if args.verbose:
|
||||
logging.getLogger().setLevel(logging.DEBUG)
|
||||
renderer = MarkdownRenderer(use_color=not args.no_color)
|
||||
try:
|
||||
return await run_fleet(args.mode, args.only, args.max_iter, renderer)
|
||||
finally:
|
||||
await close_http_client()
|
||||
|
||||
|
||||
def main() -> None:
|
||||
try:
|
||||
sys.exit(asyncio.run(_amain()))
|
||||
except KeyboardInterrupt:
|
||||
sys.exit(130)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"agent": "seo",
|
||||
"mode": "check",
|
||||
"started_at": "2026-06-12T00:51:19.794707",
|
||||
"finished_at": "2026-06-12T00:52:22.621735",
|
||||
"summary": {
|
||||
"total": 0,
|
||||
"errors": 0,
|
||||
"warnings": 0,
|
||||
"fixed": 0,
|
||||
"unfixed": 0
|
||||
},
|
||||
"findings": []
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
# seo report (check)
|
||||
|
||||
- total: 0
|
||||
- errors: 0
|
||||
- warnings: 0
|
||||
- fixed: 0
|
||||
- unfixed: 0
|
||||
|
||||
## Findings
|
||||
|
||||
None.
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"agent": "seo",
|
||||
"mode": "check",
|
||||
"started_at": "2026-06-12T01:34:02.164037",
|
||||
"finished_at": "2026-06-12T01:34:16.966318",
|
||||
"summary": {
|
||||
"total": 0,
|
||||
"errors": 0,
|
||||
"warnings": 0,
|
||||
"fixed": 0,
|
||||
"unfixed": 0
|
||||
},
|
||||
"cost": {
|
||||
"run_usd": "0.00151031",
|
||||
"session_usd": "0.00151031"
|
||||
},
|
||||
"findings": []
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
# seo report (check)
|
||||
|
||||
- total: 0
|
||||
- errors: 0
|
||||
- warnings: 0
|
||||
- fixed: 0
|
||||
- unfixed: 0
|
||||
|
||||
## Findings
|
||||
|
||||
None.
|
||||
@@ -0,0 +1,135 @@
|
||||
{
|
||||
"agent": "style",
|
||||
"mode": "check",
|
||||
"started_at": "2026-06-12T00:52:57.094561",
|
||||
"finished_at": "2026-06-12T00:54:21.002389",
|
||||
"summary": {
|
||||
"total": 12,
|
||||
"errors": 7,
|
||||
"warnings": 5,
|
||||
"fixed": 0,
|
||||
"unfixed": 12
|
||||
},
|
||||
"findings": [
|
||||
{
|
||||
"severity": "error",
|
||||
"dimension": "coding-rule-compliance",
|
||||
"file": "devplacepy/services/bot/llm.py",
|
||||
"line": 105,
|
||||
"rule": "em-dash",
|
||||
"message": "Em-dash character (U+2014) used in string literal \u2014 must be hyphen instead",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "error",
|
||||
"dimension": "coding-rule-compliance",
|
||||
"file": "agents/agent.py",
|
||||
"line": 30,
|
||||
"rule": "em-dash",
|
||||
"message": "Em-dash character (U+2014) used in docstring \u2014 must be hyphen instead",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "error",
|
||||
"dimension": "coding-rule-compliance",
|
||||
"file": "agents/agent.py",
|
||||
"line": 1732,
|
||||
"rule": "em-dash",
|
||||
"message": "Em-dash character (U+2014) used in string literal \u2014 must be hyphen instead",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "error",
|
||||
"dimension": "coding-rule-compliance",
|
||||
"file": "agents/agent.py",
|
||||
"line": 2217,
|
||||
"rule": "em-dash",
|
||||
"message": "Em-dash character (U+2014) used in instruction string \u2014 must be hyphen instead",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "error",
|
||||
"dimension": "coding-rule-compliance",
|
||||
"file": "agents/agent.py",
|
||||
"line": 2250,
|
||||
"rule": "em-dash",
|
||||
"message": "Em-dash character (U+2014) used in string literal \u2014 must be hyphen instead",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "error",
|
||||
"dimension": "coding-rule-compliance",
|
||||
"file": "agents/agent.py",
|
||||
"line": 2293,
|
||||
"rule": "em-dash",
|
||||
"message": "Em-dash character (U+2014) used in string literal \u2014 must be hyphen instead",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "error",
|
||||
"dimension": "coding-rule-compliance",
|
||||
"file": "agents/style.py",
|
||||
"line": 38,
|
||||
"rule": "em-dash",
|
||||
"message": "HTML entity — and — used in rule definition \u2014 must use hyphen instead",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "warning",
|
||||
"dimension": "coding-rule-compliance",
|
||||
"file": "review.md",
|
||||
"line": 1,
|
||||
"rule": "em-dash",
|
||||
"message": "Em-dash character (U+2014) used throughout documentation prose in multiple lines",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "warning",
|
||||
"dimension": "coding-rule-compliance",
|
||||
"file": "notifs.md",
|
||||
"line": 256,
|
||||
"rule": "em-dash",
|
||||
"message": "Em-dash character (U+2014) used in documentation prose",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "warning",
|
||||
"dimension": "coding-rule-compliance",
|
||||
"file": "devplace.md",
|
||||
"line": 1,
|
||||
"rule": "em-dash",
|
||||
"message": "Em-dash character (U+2014) used in documentation prose throughout multiple lines",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "warning",
|
||||
"dimension": "coding-rule-compliance",
|
||||
"file": "visuals.md",
|
||||
"line": 8,
|
||||
"rule": "em-dash",
|
||||
"message": "Em-dash character (U+2014) used in documentation prose throughout multiple lines",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "warning",
|
||||
"dimension": "coding-rule-compliance",
|
||||
"file": "session-ses_1eae.md",
|
||||
"line": 37,
|
||||
"rule": "em-dash",
|
||||
"message": "Em-dash character (U+2014) and — HTML entity used throughout session log prose",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
# style report (check)
|
||||
|
||||
- total: 12
|
||||
- errors: 7
|
||||
- warnings: 5
|
||||
- fixed: 0
|
||||
- unfixed: 12
|
||||
|
||||
## Findings
|
||||
|
||||
### agents/agent.py
|
||||
- [error] em-dash:30: Em-dash character (U+2014) used in docstring — must be hyphen instead
|
||||
- [error] em-dash:1732: Em-dash character (U+2014) used in string literal — must be hyphen instead
|
||||
- [error] em-dash:2217: Em-dash character (U+2014) used in instruction string — must be hyphen instead
|
||||
- [error] em-dash:2250: Em-dash character (U+2014) used in string literal — must be hyphen instead
|
||||
- [error] em-dash:2293: Em-dash character (U+2014) used in string literal — must be hyphen instead
|
||||
|
||||
### agents/style.py
|
||||
- [error] em-dash:38: HTML entity — and — used in rule definition — must use hyphen instead
|
||||
|
||||
### devplace.md
|
||||
- [warning] em-dash:1: Em-dash character (U+2014) used in documentation prose throughout multiple lines
|
||||
|
||||
### devplacepy/services/bot/llm.py
|
||||
- [error] em-dash:105: Em-dash character (U+2014) used in string literal — must be hyphen instead
|
||||
|
||||
### notifs.md
|
||||
- [warning] em-dash:256: Em-dash character (U+2014) used in documentation prose
|
||||
|
||||
### review.md
|
||||
- [warning] em-dash:1: Em-dash character (U+2014) used throughout documentation prose in multiple lines
|
||||
|
||||
### session-ses_1eae.md
|
||||
- [warning] em-dash:37: Em-dash character (U+2014) and — HTML entity used throughout session log prose
|
||||
|
||||
### visuals.md
|
||||
- [warning] em-dash:8: Em-dash character (U+2014) used in documentation prose throughout multiple lines
|
||||
@@ -0,0 +1,495 @@
|
||||
{
|
||||
"agent": "style",
|
||||
"mode": "check",
|
||||
"started_at": "2026-06-12T00:57:46.956032",
|
||||
"finished_at": "2026-06-12T01:01:12.646284",
|
||||
"summary": {
|
||||
"total": 48,
|
||||
"errors": 13,
|
||||
"warnings": 32,
|
||||
"fixed": 0,
|
||||
"unfixed": 48
|
||||
},
|
||||
"findings": [
|
||||
{
|
||||
"severity": "warning",
|
||||
"dimension": "forbidden-names",
|
||||
"file": "devplacepy/utils.py",
|
||||
"line": 434,
|
||||
"rule": "forbidden-suffix-_info",
|
||||
"message": "Function name 'badge_info' uses forbidden suffix '_info'",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "warning",
|
||||
"dimension": "forbidden-names",
|
||||
"file": "devplacepy/push.py",
|
||||
"line": 246,
|
||||
"rule": "forbidden-suffix-_info",
|
||||
"message": "Variable name 'notification_info' uses forbidden suffix '_info'",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "warning",
|
||||
"dimension": "forbidden-names",
|
||||
"file": "devplacepy/routers/services.py",
|
||||
"line": 44,
|
||||
"rule": "forbidden-suffix-_data",
|
||||
"message": "Function name 'services_data' uses forbidden suffix '_data'",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "warning",
|
||||
"dimension": "forbidden-names",
|
||||
"file": "devplacepy/routers/services.py",
|
||||
"line": 84,
|
||||
"rule": "forbidden-suffix-_data",
|
||||
"message": "Function name 'service_detail_data' uses forbidden suffix '_data'",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "warning",
|
||||
"dimension": "forbidden-names",
|
||||
"file": "devplacepy/routers/containers.py",
|
||||
"line": 112,
|
||||
"rule": "forbidden-suffix-_data",
|
||||
"message": "Function name 'containers_data' uses forbidden suffix '_data'",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "warning",
|
||||
"dimension": "forbidden-names",
|
||||
"file": "devplacepy/routers/containers_admin.py",
|
||||
"line": 70,
|
||||
"rule": "forbidden-suffix-_data",
|
||||
"message": "Function name 'containers_index_data' uses forbidden suffix '_data'",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "warning",
|
||||
"dimension": "forbidden-names",
|
||||
"file": "devplacepy/routers/admin.py",
|
||||
"line": 109,
|
||||
"rule": "forbidden-suffix-_data",
|
||||
"message": "Function name 'admin_ai_usage_data' uses forbidden suffix '_data'",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "warning",
|
||||
"dimension": "forbidden-names",
|
||||
"file": "devplacepy/services/devii/actions/catalog.py",
|
||||
"line": 1046,
|
||||
"rule": "forbidden-suffix-_data",
|
||||
"message": "Action name 'admin_services_data' uses forbidden suffix '_data'",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "warning",
|
||||
"dimension": "forbidden-names",
|
||||
"file": "devplacepy/routers/gists.py",
|
||||
"line": 91,
|
||||
"rule": "forbidden-suffix-_data",
|
||||
"message": "Variable name 'gists_data' uses forbidden suffix '_data'",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "warning",
|
||||
"dimension": "forbidden-names",
|
||||
"file": "devplacepy/services/jobs/base.py",
|
||||
"line": 109,
|
||||
"rule": "forbidden-suffix-_data",
|
||||
"message": "Parameter name 'result_data' uses forbidden suffix '_data'",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "warning",
|
||||
"dimension": "forbidden-names",
|
||||
"file": "devplacepy/services/devii/session.py",
|
||||
"line": 264,
|
||||
"rule": "forbidden-prefix-best_",
|
||||
"message": "Variable name 'best_rank' uses forbidden prefix 'best_'",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "warning",
|
||||
"dimension": "forbidden-names",
|
||||
"file": "devplacepy/schemas.py",
|
||||
"line": 156,
|
||||
"rule": "forbidden-prefix-my_",
|
||||
"message": "Field name 'my_choice' uses forbidden prefix 'my_' (public API field in PollOut schema)",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "warning",
|
||||
"dimension": "forbidden-names",
|
||||
"file": "devplacepy/schemas.py",
|
||||
"line": 265,
|
||||
"rule": "forbidden-prefix-my_",
|
||||
"message": "Field name 'my_vote' uses forbidden prefix 'my_' (public API field repeated across multiple schemas)",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "warning",
|
||||
"dimension": "forbidden-names",
|
||||
"file": "devplacepy/database.py",
|
||||
"line": 589,
|
||||
"rule": "forbidden-prefix-my_",
|
||||
"message": "Variable name 'my_placeholders' uses forbidden prefix 'my_'",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "warning",
|
||||
"dimension": "forbidden-names",
|
||||
"file": "devplacepy/database.py",
|
||||
"line": 589,
|
||||
"rule": "forbidden-prefix-my_",
|
||||
"message": "Variable name 'my_params' uses forbidden prefix 'my_'",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "warning",
|
||||
"dimension": "forbidden-names",
|
||||
"file": "devplacepy/database.py",
|
||||
"line": 646,
|
||||
"rule": "forbidden-prefix-my_",
|
||||
"message": "Variable name 'my_choice' uses forbidden prefix 'my_'",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "warning",
|
||||
"dimension": "forbidden-names",
|
||||
"file": "devplacepy/database.py",
|
||||
"line": 692,
|
||||
"rule": "forbidden-prefix-my_",
|
||||
"message": "Variable name 'my_votes' uses forbidden prefix 'my_'",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "error",
|
||||
"dimension": "headers",
|
||||
"file": "devplacepy/main.py",
|
||||
"line": 1,
|
||||
"rule": "missing-retoor-header",
|
||||
"message": "Missing mandatory retoor header as first line in devplacepy core module",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "error",
|
||||
"dimension": "headers",
|
||||
"file": "devplacepy/database.py",
|
||||
"line": 1,
|
||||
"rule": "missing-retoor-header",
|
||||
"message": "Missing mandatory retoor header as first line",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "error",
|
||||
"dimension": "headers",
|
||||
"file": "devplacepy/schemas.py",
|
||||
"line": 1,
|
||||
"rule": "missing-retoor-header",
|
||||
"message": "Missing mandatory retoor header as first line",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "error",
|
||||
"dimension": "headers",
|
||||
"file": "devplacepy/utils.py",
|
||||
"line": 1,
|
||||
"rule": "missing-retoor-header",
|
||||
"message": "Missing mandatory retoor header as first line",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "error",
|
||||
"dimension": "headers",
|
||||
"file": "devplacepy/models.py",
|
||||
"line": 1,
|
||||
"rule": "missing-retoor-header",
|
||||
"message": "Missing mandatory retoor header as first line",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "error",
|
||||
"dimension": "headers",
|
||||
"file": "devplacepy/config.py",
|
||||
"line": 1,
|
||||
"rule": "missing-retoor-header",
|
||||
"message": "Missing mandatory retoor header as first line",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "error",
|
||||
"dimension": "headers",
|
||||
"file": "devplacepy/routers/admin.py",
|
||||
"line": 1,
|
||||
"rule": "missing-retoor-header",
|
||||
"message": "Missing mandatory retoor header - many files in devplacepy/routers/ directory missing header",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "error",
|
||||
"dimension": "headers",
|
||||
"file": "devplacepy/services/base.py",
|
||||
"line": 1,
|
||||
"rule": "missing-retoor-header",
|
||||
"message": "Missing mandatory retoor header - many files in devplacepy/services/ directory missing header",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "error",
|
||||
"dimension": "headers",
|
||||
"file": "devplacepy/services/bot/bot.py",
|
||||
"line": 1,
|
||||
"rule": "missing-retoor-header",
|
||||
"message": "Missing mandatory retoor header - bot service files missing header",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "error",
|
||||
"dimension": "headers",
|
||||
"file": "devplacepy/services/openai_gateway/gateway.py",
|
||||
"line": 1,
|
||||
"rule": "missing-retoor-header",
|
||||
"message": "Missing mandatory retoor header - gateway service files missing header",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "error",
|
||||
"dimension": "headers",
|
||||
"file": "devplacepy/static/js/ApiDocs.js",
|
||||
"line": 1,
|
||||
"rule": "missing-retoor-header",
|
||||
"message": "Missing mandatory retoor header - many JS files in devplacepy/static/js/ missing header (e.g., ApiDocs.js, ApiKeyManager.js, ApiTester.js, Application.js, etc.)",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "error",
|
||||
"dimension": "headers",
|
||||
"file": "devplacepy/static/css/base.css",
|
||||
"line": 1,
|
||||
"rule": "missing-retoor-header",
|
||||
"message": "Missing mandatory retoor header - many CSS files missing header (e.g., base.css, variables.css, post.css, auth.css, etc.)",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "error",
|
||||
"dimension": "headers",
|
||||
"file": "devplacepy/templates/base.html",
|
||||
"line": 1,
|
||||
"rule": "missing-retoor-header",
|
||||
"message": "Missing mandatory retoor header - HTML template files missing header",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "warning",
|
||||
"dimension": "typing",
|
||||
"file": "devplacepy/cli.py",
|
||||
"line": 7,
|
||||
"rule": "missing-type-annotations",
|
||||
"message": "Function '_audit_cli' missing type annotations for all parameters and return type",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "warning",
|
||||
"dimension": "typing",
|
||||
"file": "devplacepy/seo.py",
|
||||
"line": 20,
|
||||
"rule": "missing-type-annotations",
|
||||
"message": "Function 'truncate' missing type annotations for 'text' parameter and return type",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "warning",
|
||||
"dimension": "typing",
|
||||
"file": "devplacepy/attachments.py",
|
||||
"line": 109,
|
||||
"rule": "missing-type-annotations",
|
||||
"message": "Function 'allowed_extensions' missing return type annotation",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "warning",
|
||||
"dimension": "typing",
|
||||
"file": "devplacepy/templating.py",
|
||||
"line": 21,
|
||||
"rule": "missing-type-annotations",
|
||||
"message": "Function 'guest_disabled' missing type annotations for 'user' parameter and return type",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "warning",
|
||||
"dimension": "typing",
|
||||
"file": "devplacepy/templating.py",
|
||||
"line": 27,
|
||||
"rule": "missing-type-annotations",
|
||||
"message": "Function 'login_hint' missing type annotations for 'user' parameter and return type",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "warning",
|
||||
"dimension": "typing",
|
||||
"file": "devplacepy/main.py",
|
||||
"line": 97,
|
||||
"rule": "missing-type-annotations",
|
||||
"message": "Function 'init_lock' missing return type annotation",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "warning",
|
||||
"dimension": "typing",
|
||||
"file": "devplacepy/database.py",
|
||||
"line": 94,
|
||||
"rule": "missing-type-annotations",
|
||||
"message": "Function '_index' missing type annotations for all parameters",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "warning",
|
||||
"dimension": "typing",
|
||||
"file": "devplacepy/database.py",
|
||||
"line": 103,
|
||||
"rule": "missing-type-annotations",
|
||||
"message": "Function 'init_db' missing return type annotation",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "warning",
|
||||
"dimension": "typing",
|
||||
"file": "devplacepy/seo.py",
|
||||
"line": 36,
|
||||
"rule": "missing-type-annotations",
|
||||
"message": "Function 'site_url' missing type annotations for 'request' parameter and return type",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "warning",
|
||||
"dimension": "typing",
|
||||
"file": "devplacepy/cli.py",
|
||||
"line": 7,
|
||||
"rule": "missing-type-annotations-bulk",
|
||||
"message": "Many functions in devplacepy/cli.py, seo.py, attachments.py, templating.py, docs_api.py, docs_examples.py, database.py lack full type annotations on parameters and return types",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "warning",
|
||||
"dimension": "pathlib",
|
||||
"file": "devplacepy/services/jobs/zip_worker.py",
|
||||
"line": 22,
|
||||
"rule": "use-pathlib",
|
||||
"message": "Uses os.path.getsize, os.path.join, os.path.relpath, os.path.isdir instead of pathlib.Path equivalents",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "warning",
|
||||
"dimension": "pathlib",
|
||||
"file": "devplacepy/services/bot/registry.py",
|
||||
"line": 47,
|
||||
"rule": "use-pathlib",
|
||||
"message": "Uses os.path.getsize instead of Path.stat().st_size",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "warning",
|
||||
"dimension": "pathlib",
|
||||
"file": "devplacepy/project_files.py",
|
||||
"line": 528,
|
||||
"rule": "use-pathlib",
|
||||
"message": "Uses os.walk instead of Path.rglob or Path.iterdir",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "warning",
|
||||
"dimension": "pathlib",
|
||||
"file": "devplacepy/services/jobs/zip_worker.py",
|
||||
"line": 18,
|
||||
"rule": "use-pathlib",
|
||||
"message": "Uses os.walk instead of pathlib.Path.rglob",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "warning",
|
||||
"dimension": "magic-numbers",
|
||||
"file": "devplacepy/routers/avatar.py",
|
||||
"line": 12,
|
||||
"rule": "magic-number",
|
||||
"message": "Magic number 4096 used as cache max_size; should be a named constant",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "info",
|
||||
"dimension": "magic-numbers",
|
||||
"file": "devplacepy/attachments.py",
|
||||
"line": 106,
|
||||
"rule": "magic-number",
|
||||
"message": "Magic number 1024*1024 used repeatedly for bytes conversion; should use a named constant like BYTES_PER_MB",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "info",
|
||||
"dimension": "magic-numbers",
|
||||
"file": "devplacepy/attachments.py",
|
||||
"line": 499,
|
||||
"rule": "magic-number",
|
||||
"message": "Repeated literal 1024 in format_file_size; should use named constant",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "info",
|
||||
"dimension": "version-pinning",
|
||||
"file": "pyproject.toml",
|
||||
"line": 0,
|
||||
"rule": "no-pinning-convention",
|
||||
"message": "No version pinning found in pyproject.toml - dependencies use unversioned constraints (which is the desired pattern)",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
# style report (check)
|
||||
|
||||
- total: 48
|
||||
- errors: 13
|
||||
- warnings: 32
|
||||
- fixed: 0
|
||||
- unfixed: 48
|
||||
|
||||
## Findings
|
||||
|
||||
### devplacepy/attachments.py
|
||||
- [warning] missing-type-annotations:109: Function 'allowed_extensions' missing return type annotation
|
||||
- [info] magic-number:106: Magic number 1024*1024 used repeatedly for bytes conversion; should use a named constant like BYTES_PER_MB
|
||||
- [info] magic-number:499: Repeated literal 1024 in format_file_size; should use named constant
|
||||
|
||||
### devplacepy/cli.py
|
||||
- [warning] missing-type-annotations:7: Function '_audit_cli' missing type annotations for all parameters and return type
|
||||
- [warning] missing-type-annotations-bulk:7: Many functions in devplacepy/cli.py, seo.py, attachments.py, templating.py, docs_api.py, docs_examples.py, database.py lack full type annotations on parameters and return types
|
||||
|
||||
### devplacepy/config.py
|
||||
- [error] missing-retoor-header:1: Missing mandatory retoor header as first line
|
||||
|
||||
### devplacepy/database.py
|
||||
- [warning] forbidden-prefix-my_:589: Variable name 'my_placeholders' uses forbidden prefix 'my_'
|
||||
- [warning] forbidden-prefix-my_:589: Variable name 'my_params' uses forbidden prefix 'my_'
|
||||
- [warning] forbidden-prefix-my_:646: Variable name 'my_choice' uses forbidden prefix 'my_'
|
||||
- [warning] forbidden-prefix-my_:692: Variable name 'my_votes' uses forbidden prefix 'my_'
|
||||
- [error] missing-retoor-header:1: Missing mandatory retoor header as first line
|
||||
- [warning] missing-type-annotations:94: Function '_index' missing type annotations for all parameters
|
||||
- [warning] missing-type-annotations:103: Function 'init_db' missing return type annotation
|
||||
|
||||
### devplacepy/main.py
|
||||
- [error] missing-retoor-header:1: Missing mandatory retoor header as first line in devplacepy core module
|
||||
- [warning] missing-type-annotations:97: Function 'init_lock' missing return type annotation
|
||||
|
||||
### devplacepy/models.py
|
||||
- [error] missing-retoor-header:1: Missing mandatory retoor header as first line
|
||||
|
||||
### devplacepy/project_files.py
|
||||
- [warning] use-pathlib:528: Uses os.walk instead of Path.rglob or Path.iterdir
|
||||
|
||||
### devplacepy/push.py
|
||||
- [warning] forbidden-suffix-_info:246: Variable name 'notification_info' uses forbidden suffix '_info'
|
||||
|
||||
### devplacepy/routers/admin.py
|
||||
- [warning] forbidden-suffix-_data:109: Function name 'admin_ai_usage_data' uses forbidden suffix '_data'
|
||||
- [error] missing-retoor-header:1: Missing mandatory retoor header - many files in devplacepy/routers/ directory missing header
|
||||
|
||||
### devplacepy/routers/avatar.py
|
||||
- [warning] magic-number:12: Magic number 4096 used as cache max_size; should be a named constant
|
||||
|
||||
### devplacepy/routers/containers.py
|
||||
- [warning] forbidden-suffix-_data:112: Function name 'containers_data' uses forbidden suffix '_data'
|
||||
|
||||
### devplacepy/routers/containers_admin.py
|
||||
- [warning] forbidden-suffix-_data:70: Function name 'containers_index_data' uses forbidden suffix '_data'
|
||||
|
||||
### devplacepy/routers/gists.py
|
||||
- [warning] forbidden-suffix-_data:91: Variable name 'gists_data' uses forbidden suffix '_data'
|
||||
|
||||
### devplacepy/routers/services.py
|
||||
- [warning] forbidden-suffix-_data:44: Function name 'services_data' uses forbidden suffix '_data'
|
||||
- [warning] forbidden-suffix-_data:84: Function name 'service_detail_data' uses forbidden suffix '_data'
|
||||
|
||||
### devplacepy/schemas.py
|
||||
- [warning] forbidden-prefix-my_:156: Field name 'my_choice' uses forbidden prefix 'my_' (public API field in PollOut schema)
|
||||
- [warning] forbidden-prefix-my_:265: Field name 'my_vote' uses forbidden prefix 'my_' (public API field repeated across multiple schemas)
|
||||
- [error] missing-retoor-header:1: Missing mandatory retoor header as first line
|
||||
|
||||
### devplacepy/seo.py
|
||||
- [warning] missing-type-annotations:20: Function 'truncate' missing type annotations for 'text' parameter and return type
|
||||
- [warning] missing-type-annotations:36: Function 'site_url' missing type annotations for 'request' parameter and return type
|
||||
|
||||
### devplacepy/services/base.py
|
||||
- [error] missing-retoor-header:1: Missing mandatory retoor header - many files in devplacepy/services/ directory missing header
|
||||
|
||||
### devplacepy/services/bot/bot.py
|
||||
- [error] missing-retoor-header:1: Missing mandatory retoor header - bot service files missing header
|
||||
|
||||
### devplacepy/services/bot/registry.py
|
||||
- [warning] use-pathlib:47: Uses os.path.getsize instead of Path.stat().st_size
|
||||
|
||||
### devplacepy/services/devii/actions/catalog.py
|
||||
- [warning] forbidden-suffix-_data:1046: Action name 'admin_services_data' uses forbidden suffix '_data'
|
||||
|
||||
### devplacepy/services/devii/session.py
|
||||
- [warning] forbidden-prefix-best_:264: Variable name 'best_rank' uses forbidden prefix 'best_'
|
||||
|
||||
### devplacepy/services/jobs/base.py
|
||||
- [warning] forbidden-suffix-_data:109: Parameter name 'result_data' uses forbidden suffix '_data'
|
||||
|
||||
### devplacepy/services/jobs/zip_worker.py
|
||||
- [warning] use-pathlib:22: Uses os.path.getsize, os.path.join, os.path.relpath, os.path.isdir instead of pathlib.Path equivalents
|
||||
- [warning] use-pathlib:18: Uses os.walk instead of pathlib.Path.rglob
|
||||
|
||||
### devplacepy/services/openai_gateway/gateway.py
|
||||
- [error] missing-retoor-header:1: Missing mandatory retoor header - gateway service files missing header
|
||||
|
||||
### devplacepy/static/css/base.css
|
||||
- [error] missing-retoor-header:1: Missing mandatory retoor header - many CSS files missing header (e.g., base.css, variables.css, post.css, auth.css, etc.)
|
||||
|
||||
### devplacepy/static/js/ApiDocs.js
|
||||
- [error] missing-retoor-header:1: Missing mandatory retoor header - many JS files in devplacepy/static/js/ missing header (e.g., ApiDocs.js, ApiKeyManager.js, ApiTester.js, Application.js, etc.)
|
||||
|
||||
### devplacepy/templates/base.html
|
||||
- [error] missing-retoor-header:1: Missing mandatory retoor header - HTML template files missing header
|
||||
|
||||
### devplacepy/templating.py
|
||||
- [warning] missing-type-annotations:21: Function 'guest_disabled' missing type annotations for 'user' parameter and return type
|
||||
- [warning] missing-type-annotations:27: Function 'login_hint' missing type annotations for 'user' parameter and return type
|
||||
|
||||
### devplacepy/utils.py
|
||||
- [warning] forbidden-suffix-_info:434: Function name 'badge_info' uses forbidden suffix '_info'
|
||||
- [error] missing-retoor-header:1: Missing mandatory retoor header as first line
|
||||
|
||||
### pyproject.toml
|
||||
- [info] no-pinning-convention: No version pinning found in pyproject.toml - dependencies use unversioned constraints (which is the desired pattern)
|
||||
@@ -0,0 +1,95 @@
|
||||
{
|
||||
"agent": "style",
|
||||
"mode": "check",
|
||||
"started_at": "2026-06-12T01:02:02.351939",
|
||||
"finished_at": "2026-06-12T01:03:54.924366",
|
||||
"summary": {
|
||||
"total": 8,
|
||||
"errors": 8,
|
||||
"warnings": 0,
|
||||
"fixed": 0,
|
||||
"unfixed": 8
|
||||
},
|
||||
"findings": [
|
||||
{
|
||||
"severity": "error",
|
||||
"dimension": "em-dash",
|
||||
"file": "agents/agent.py",
|
||||
"line": 30,
|
||||
"rule": "em-dash",
|
||||
"message": "Em-dash character (U+2014) used in docstring \u2014 must be hyphen instead",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "error",
|
||||
"dimension": "em-dash",
|
||||
"file": "agents/agent.py",
|
||||
"line": 1732,
|
||||
"rule": "em-dash",
|
||||
"message": "Em-dash character (U+2014) used in string literal \u2014 must be hyphen instead",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "error",
|
||||
"dimension": "em-dash",
|
||||
"file": "agents/agent.py",
|
||||
"line": 2217,
|
||||
"rule": "em-dash",
|
||||
"message": "Em-dash character (U+2014) used in instruction string \u2014 must be hyphen instead",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "error",
|
||||
"dimension": "em-dash",
|
||||
"file": "agents/agent.py",
|
||||
"line": 2250,
|
||||
"rule": "em-dash",
|
||||
"message": "Em-dash character (U+2014) used in string literal \u2014 must be hyphen instead",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "error",
|
||||
"dimension": "em-dash",
|
||||
"file": "agents/agent.py",
|
||||
"line": 2293,
|
||||
"rule": "em-dash",
|
||||
"message": "Em-dash character (U+2014) used in string literal \u2014 must be hyphen instead",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "error",
|
||||
"dimension": "em-dash",
|
||||
"file": "devplacepy/services/bot/llm.py",
|
||||
"line": 105,
|
||||
"rule": "em-dash",
|
||||
"message": "Em-dash character (U+2014) used in string literal as replace target \u2014 must be hyphen or unicode escape instead",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "error",
|
||||
"dimension": "em-dash",
|
||||
"file": "tests/test_demo.py.bak",
|
||||
"line": 36,
|
||||
"rule": "em-dash",
|
||||
"message": "Em-dash character (U+2014) used in comments throughout file \u2014 must be hyphen instead",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "error",
|
||||
"dimension": "em-dash",
|
||||
"file": "tests/test_demo.py.bak",
|
||||
"line": 277,
|
||||
"rule": "em-dash",
|
||||
"message": "Em-dash character (U+2014) used in string literal \u2014 must be hyphen instead",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
# style report (check)
|
||||
|
||||
- total: 8
|
||||
- errors: 8
|
||||
- warnings: 0
|
||||
- fixed: 0
|
||||
- unfixed: 8
|
||||
|
||||
## Findings
|
||||
|
||||
### agents/agent.py
|
||||
- [error] em-dash:30: Em-dash character (U+2014) used in docstring — must be hyphen instead
|
||||
- [error] em-dash:1732: Em-dash character (U+2014) used in string literal — must be hyphen instead
|
||||
- [error] em-dash:2217: Em-dash character (U+2014) used in instruction string — must be hyphen instead
|
||||
- [error] em-dash:2250: Em-dash character (U+2014) used in string literal — must be hyphen instead
|
||||
- [error] em-dash:2293: Em-dash character (U+2014) used in string literal — must be hyphen instead
|
||||
|
||||
### devplacepy/services/bot/llm.py
|
||||
- [error] em-dash:105: Em-dash character (U+2014) used in string literal as replace target — must be hyphen or unicode escape instead
|
||||
|
||||
### tests/test_demo.py.bak
|
||||
- [error] em-dash:36: Em-dash character (U+2014) used in comments throughout file — must be hyphen instead
|
||||
- [error] em-dash:277: Em-dash character (U+2014) used in string literal — must be hyphen instead
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"agent": "style",
|
||||
"mode": "check",
|
||||
"started_at": "2026-06-12T01:02:35.851370",
|
||||
"finished_at": "2026-06-12T01:05:34.005737",
|
||||
"summary": {
|
||||
"total": 0,
|
||||
"errors": 0,
|
||||
"warnings": 0,
|
||||
"fixed": 0,
|
||||
"unfixed": 0
|
||||
},
|
||||
"findings": []
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
# style report (check)
|
||||
|
||||
- total: 0
|
||||
- errors: 0
|
||||
- warnings: 0
|
||||
- fixed: 0
|
||||
- unfixed: 0
|
||||
|
||||
## Findings
|
||||
|
||||
None.
|
||||
@@ -0,0 +1,125 @@
|
||||
{
|
||||
"agent": "style",
|
||||
"mode": "check",
|
||||
"started_at": "2026-06-12T01:05:50.761027",
|
||||
"finished_at": "2026-06-12T01:07:16.324649",
|
||||
"summary": {
|
||||
"total": 11,
|
||||
"errors": 6,
|
||||
"warnings": 0,
|
||||
"fixed": 0,
|
||||
"unfixed": 11
|
||||
},
|
||||
"findings": [
|
||||
{
|
||||
"severity": "error",
|
||||
"dimension": "em-dash",
|
||||
"file": "agents/agent.py",
|
||||
"line": 30,
|
||||
"rule": "no-em-dash",
|
||||
"message": "Em-dash character (U+2014) used in comment text instead of a hyphen.",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "error",
|
||||
"dimension": "em-dash",
|
||||
"file": "agents/agent.py",
|
||||
"line": 1732,
|
||||
"rule": "no-em-dash",
|
||||
"message": "Em-dash character (U+2014) used in advice string literal instead of a hyphen.",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "error",
|
||||
"dimension": "em-dash",
|
||||
"file": "agents/agent.py",
|
||||
"line": 2217,
|
||||
"rule": "no-em-dash",
|
||||
"message": "Em-dash character (U+2014) used in comment text instead of a hyphen.",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "error",
|
||||
"dimension": "em-dash",
|
||||
"file": "agents/agent.py",
|
||||
"line": 2250,
|
||||
"rule": "no-em-dash",
|
||||
"message": "Em-dash character (U+2014) used in f-string instead of a hyphen.",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "error",
|
||||
"dimension": "em-dash",
|
||||
"file": "agents/agent.py",
|
||||
"line": 2293,
|
||||
"rule": "no-em-dash",
|
||||
"message": "Em-dash character (U+2014) used in argparse description string instead of a hyphen.",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "error",
|
||||
"dimension": "em-dash",
|
||||
"file": "devplacepy/services/bot/llm.py",
|
||||
"line": 105,
|
||||
"rule": "no-em-dash",
|
||||
"message": "Em-dash character (U+2014) used in string literal for text.replace() instead of a hyphen or escape sequence.",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "info",
|
||||
"dimension": "em-dash",
|
||||
"file": "tests/test_demo.py.bak",
|
||||
"line": 36,
|
||||
"rule": "no-em-dash",
|
||||
"message": "Backup test file contains 15 em-dash characters (U+2014) in comments and string literals.",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "info",
|
||||
"dimension": "em-dash",
|
||||
"file": "review.md",
|
||||
"line": 1,
|
||||
"rule": "no-em-dash",
|
||||
"message": "Documentation file review.md uses em-dash characters throughout (standard English prose, not code).",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "info",
|
||||
"dimension": "em-dash",
|
||||
"file": "notifs.md",
|
||||
"line": 256,
|
||||
"rule": "no-em-dash",
|
||||
"message": "Documentation file notifs.md uses em-dash characters throughout (standard English prose, not code).",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "info",
|
||||
"dimension": "em-dash",
|
||||
"file": "devplace.md",
|
||||
"line": 1,
|
||||
"rule": "no-em-dash",
|
||||
"message": "Documentation file devplace.md uses em-dash characters throughout (standard English prose, not code).",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "info",
|
||||
"dimension": "em-dash",
|
||||
"file": "visuals.md",
|
||||
"line": 8,
|
||||
"rule": "no-em-dash",
|
||||
"message": "Documentation file visuals.md uses em-dash characters throughout (standard English prose, not code).",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
# style report (check)
|
||||
|
||||
- total: 11
|
||||
- errors: 6
|
||||
- warnings: 0
|
||||
- fixed: 0
|
||||
- unfixed: 11
|
||||
|
||||
## Findings
|
||||
|
||||
### agents/agent.py
|
||||
- [error] no-em-dash:30: Em-dash character (U+2014) used in comment text instead of a hyphen.
|
||||
- [error] no-em-dash:1732: Em-dash character (U+2014) used in advice string literal instead of a hyphen.
|
||||
- [error] no-em-dash:2217: Em-dash character (U+2014) used in comment text instead of a hyphen.
|
||||
- [error] no-em-dash:2250: Em-dash character (U+2014) used in f-string instead of a hyphen.
|
||||
- [error] no-em-dash:2293: Em-dash character (U+2014) used in argparse description string instead of a hyphen.
|
||||
|
||||
### devplace.md
|
||||
- [info] no-em-dash:1: Documentation file devplace.md uses em-dash characters throughout (standard English prose, not code).
|
||||
|
||||
### devplacepy/services/bot/llm.py
|
||||
- [error] no-em-dash:105: Em-dash character (U+2014) used in string literal for text.replace() instead of a hyphen or escape sequence.
|
||||
|
||||
### notifs.md
|
||||
- [info] no-em-dash:256: Documentation file notifs.md uses em-dash characters throughout (standard English prose, not code).
|
||||
|
||||
### review.md
|
||||
- [info] no-em-dash:1: Documentation file review.md uses em-dash characters throughout (standard English prose, not code).
|
||||
|
||||
### tests/test_demo.py.bak
|
||||
- [info] no-em-dash:36: Backup test file contains 15 em-dash characters (U+2014) in comments and string literals.
|
||||
|
||||
### visuals.md
|
||||
- [info] no-em-dash:8: Documentation file visuals.md uses em-dash characters throughout (standard English prose, not code).
|
||||
@@ -0,0 +1,85 @@
|
||||
{
|
||||
"agent": "style",
|
||||
"mode": "fix",
|
||||
"started_at": "2026-06-12T01:08:04.361327",
|
||||
"finished_at": "2026-06-12T01:10:20.066323",
|
||||
"summary": {
|
||||
"total": 7,
|
||||
"errors": 5,
|
||||
"warnings": 0,
|
||||
"fixed": 5,
|
||||
"unfixed": 2
|
||||
},
|
||||
"findings": [
|
||||
{
|
||||
"severity": "error",
|
||||
"dimension": "coding-rule-compliance",
|
||||
"file": "agents/agent.py",
|
||||
"line": 30,
|
||||
"rule": "no-em-dash",
|
||||
"message": "Em-dash character (U+2014) used instead of hyphen in docstring",
|
||||
"fixed": true,
|
||||
"fix_summary": "Replaced em-dash with hyphen in docstring about Chrome-accurate header order"
|
||||
},
|
||||
{
|
||||
"severity": "error",
|
||||
"dimension": "coding-rule-compliance",
|
||||
"file": "agents/agent.py",
|
||||
"line": 1732,
|
||||
"rule": "no-em-dash",
|
||||
"message": "Em-dash character (U+2014) used instead of hyphen in advice string literal",
|
||||
"fixed": true,
|
||||
"fix_summary": "Replaced em-dash with hyphen in plan confidence advice string"
|
||||
},
|
||||
{
|
||||
"severity": "error",
|
||||
"dimension": "coding-rule-compliance",
|
||||
"file": "agents/agent.py",
|
||||
"line": 2217,
|
||||
"rule": "no-em-dash",
|
||||
"message": "Em-dash character (U+2014) used instead of hyphen in SYSTEM_PROMPT string",
|
||||
"fixed": true,
|
||||
"fix_summary": "Replaced em-dash with hyphen in operating protocol text"
|
||||
},
|
||||
{
|
||||
"severity": "error",
|
||||
"dimension": "coding-rule-compliance",
|
||||
"file": "agents/agent.py",
|
||||
"line": 2250,
|
||||
"rule": "no-em-dash",
|
||||
"message": "Em-dash character (U+2014) used instead of hyphen in _with_datetime() f-string",
|
||||
"fixed": true,
|
||||
"fix_summary": "Replaced em-dash with hyphen in datetime message string"
|
||||
},
|
||||
{
|
||||
"severity": "error",
|
||||
"dimension": "coding-rule-compliance",
|
||||
"file": "agents/agent.py",
|
||||
"line": 2293,
|
||||
"rule": "no-em-dash",
|
||||
"message": "Em-dash character (U+2014) used instead of hyphen in argparse description",
|
||||
"fixed": true,
|
||||
"fix_summary": "Replaced em-dash with hyphen in argument parser description"
|
||||
},
|
||||
{
|
||||
"severity": "info",
|
||||
"dimension": "coding-rule-compliance",
|
||||
"file": "devplacepy/services/bot/llm.py",
|
||||
"line": 105,
|
||||
"rule": "no-em-dash",
|
||||
"message": "Em-dash characters in llm.py replace() pattern are intentional data processing logic; not changed",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
},
|
||||
{
|
||||
"severity": "info",
|
||||
"dimension": "coding-rule-compliance",
|
||||
"file": "devplacepy/static/uploads/attachments/1a/64/1a640917-f599-4fce-8dc4-2babdb25f716.py",
|
||||
"line": 3,
|
||||
"rule": "no-em-dash",
|
||||
"message": "Em-dash in user-uploaded attachment file; not project source",
|
||||
"fixed": false,
|
||||
"fix_summary": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
# style report (fix)
|
||||
|
||||
- total: 7
|
||||
- errors: 5
|
||||
- warnings: 0
|
||||
- fixed: 5
|
||||
- unfixed: 2
|
||||
|
||||
## Findings
|
||||
|
||||
### agents/agent.py
|
||||
- [fixed] no-em-dash:30: Em-dash character (U+2014) used instead of hyphen in docstring
|
||||
fix: Replaced em-dash with hyphen in docstring about Chrome-accurate header order
|
||||
- [fixed] no-em-dash:1732: Em-dash character (U+2014) used instead of hyphen in advice string literal
|
||||
fix: Replaced em-dash with hyphen in plan confidence advice string
|
||||
- [fixed] no-em-dash:2217: Em-dash character (U+2014) used instead of hyphen in SYSTEM_PROMPT string
|
||||
fix: Replaced em-dash with hyphen in operating protocol text
|
||||
- [fixed] no-em-dash:2250: Em-dash character (U+2014) used instead of hyphen in _with_datetime() f-string
|
||||
fix: Replaced em-dash with hyphen in datetime message string
|
||||
- [fixed] no-em-dash:2293: Em-dash character (U+2014) used instead of hyphen in argparse description
|
||||
fix: Replaced em-dash with hyphen in argument parser description
|
||||
|
||||
### devplacepy/services/bot/llm.py
|
||||
- [info] no-em-dash:105: Em-dash characters in llm.py replace() pattern are intentional data processing logic; not changed
|
||||
|
||||
### devplacepy/static/uploads/attachments/1a/64/1a640917-f599-4fce-8dc4-2babdb25f716.py
|
||||
- [info] no-em-dash:3: Em-dash in user-uploaded attachment file; not project source
|
||||
@@ -0,0 +1,54 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from .base import MaintenanceAgent, cli_main
|
||||
|
||||
|
||||
class SecurityAgent(MaintenanceAgent):
|
||||
name = "security"
|
||||
description = "data and role security checker"
|
||||
|
||||
def mandate(self) -> str:
|
||||
return (
|
||||
"Guarantee that every state-changing action is correctly authorized, every private resource is gated by "
|
||||
"the single canonical predicate, every file mutation is read-only-guarded, and the input and output "
|
||||
"boundaries are sanitized.\n\n"
|
||||
"DETECT:\n"
|
||||
"- Every @router.post / @router.put / @router.delete has the correct guard: require_user for member writes, "
|
||||
"require_admin for admin writes, or an explicit ownership comparison resource[\"user_uid\"] == user[\"uid\"] "
|
||||
"before edit and delete. A POST with no guard is an error.\n"
|
||||
"- Every private-project read surface flows through content.can_view_project(project, user) and none "
|
||||
"re-implements the owner-or-admin check inline. Surfaces: project detail, project_files._load_viewable_project, "
|
||||
"zip enqueue, listing, profile project list, sitemap.\n"
|
||||
"- Every file-mutating entrypoint in project_files.py calls project_files._guard_writable(project_uid).\n"
|
||||
"- Devii irreversible or destructive actions are present in the dispatcher CONFIRM_REQUIRED set, and "
|
||||
"destructive shell commands match dispatcher.DESTRUCTIVE_COMMAND.\n"
|
||||
"- Input is Pydantic-validated with explicit max lengths (models.py Form models); uploads and downloads are "
|
||||
"slugified; path traversal is blocked with pathlib, never string joins.\n"
|
||||
"- Passwords are hashed with pbkdf2_sha256 via passlib; no plaintext or weak path exists.\n"
|
||||
"- Capability URLs (zip and fork status and download) stay scoped only by the unguessable uuid7.\n"
|
||||
"- The XSS control is intact: DOMPurify.sanitize runs on raw marked output in static/js/components/ContentRenderer.js "
|
||||
"and fails closed; seo.py _json_ld_dumps escapes <, >, & in JSON-LD.\n\n"
|
||||
"FIX: insert the missing guard, route the read through can_view_project, add _guard_writable at the top of the "
|
||||
"mutating function, add the action to the confirm set, add the missing max length or validator, or restore the "
|
||||
"sanitize step. Never weaken a guard to make a finding disappear; a deliberately public read is an info finding."
|
||||
)
|
||||
|
||||
def scope_units(self) -> list[tuple[str, str]]:
|
||||
return [
|
||||
("routers", "devplacepy/routers/*.py - guard on every POST/PUT/DELETE; ownership before edit/delete"),
|
||||
("project-visibility", "devplacepy/content.py can_view_project used at every private read surface"),
|
||||
("project-files", "devplacepy/project_files.py _guard_writable on every mutating entrypoint"),
|
||||
("devii-confirm", "devplacepy/services/devii/actions/dispatcher.py CONFIRM_REQUIRED and DESTRUCTIVE_COMMAND"),
|
||||
("input-validation", "devplacepy/models.py max lengths; path traversal via pathlib; slugify on upload/download"),
|
||||
("xss", "static/js/components/ContentRenderer.js DOMPurify; devplacepy/seo.py _json_ld_dumps escaping"),
|
||||
]
|
||||
|
||||
|
||||
def main() -> None:
|
||||
cli_main(SecurityAgent())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,40 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from .base import MaintenanceAgent, cli_main
|
||||
|
||||
|
||||
class SeoAgent(MaintenanceAgent):
|
||||
name = "seo"
|
||||
description = "SEO and sitemap coverage"
|
||||
|
||||
def mandate(self) -> str:
|
||||
return (
|
||||
"Ensure every public page is correctly described for search and indexed where appropriate.\n\n"
|
||||
"DETECT:\n"
|
||||
"- Every public page builds base_seo_context(request, ...) and merges it into the template response.\n"
|
||||
"- The right JSON-LD schema is emitted (WebSite, BreadcrumbList, DiscussionForumPosting, ProfilePage, "
|
||||
"SoftwareApplication).\n"
|
||||
"- meta_robots is set, and the noindex rules hold (auth, messages, notifications are noindex,nofollow; profiles "
|
||||
"with fewer than two posts are noindex,follow).\n"
|
||||
"- Indexable public pages appear in the routers/seo.py sitemap.\n\n"
|
||||
"FIX: add the missing base_seo_context call, the JSON-LD schema, the robots directive, or the sitemap entry. "
|
||||
"Never index a private or auth-gated page."
|
||||
)
|
||||
|
||||
def scope_units(self) -> list[tuple[str, str]]:
|
||||
return [
|
||||
("seo-context", "public page routes build seo.base_seo_context"),
|
||||
("json-ld", "the correct JSON-LD schema is emitted per page type"),
|
||||
("robots", "meta_robots set; noindex rules for auth/messages/notifications/thin profiles"),
|
||||
("sitemap", "indexable public pages appear in routers/seo.py sitemap"),
|
||||
]
|
||||
|
||||
|
||||
def main() -> None:
|
||||
cli_main(SeoAgent())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,50 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from .base import MaintenanceAgent, cli_main
|
||||
|
||||
|
||||
class StyleAgent(MaintenanceAgent):
|
||||
name = "style"
|
||||
description = "coding-rule compliance"
|
||||
|
||||
def mandate(self) -> str:
|
||||
return (
|
||||
"Enforce the explicit CLAUDE.md and AGENTS.md coding rules across all source.\n\n"
|
||||
"DETECT (mostly deterministic, grep and AST):\n"
|
||||
"- Forbidden naming prefixes and suffixes: _new, _old, _current, _prev, _next (outside iteration), _temp, _tmp, "
|
||||
"_v1/_v2/_v3, better_, best_, simple_, my_, the_, _data, _info, and the rest of the forbidden list.\n"
|
||||
"- No comments or docstrings in source files, EXCEPT the mandatory header and the docstrings that @tool functions "
|
||||
"require for their schema (the proven agent engine convention).\n"
|
||||
"- No em-dash anywhere: neither the em-dash character (U+2014) nor its HTML entities; use a hyphen.\n"
|
||||
"- Full typing coverage on Python function signatures and variables.\n"
|
||||
"- pathlib instead of the os module for paths.\n"
|
||||
"- A fixed-key dict that should be a dataclass.\n"
|
||||
"- No version pinning anywhere (pyproject, requirements, or inline).\n"
|
||||
"- The mandatory `retoor <retoor@molodetz.nl>` header as the first line, in the correct comment style, except "
|
||||
"where a shebang must lead.\n"
|
||||
"- No magic numbers; named constants instead. No warnings.\n\n"
|
||||
"FIX: rename the symbol to an intent-revealing name, strip the stray comment or docstring, replace the em-dash, "
|
||||
"add the type annotation, convert os.path to pathlib, convert the dict to a dataclass, remove the version pin, add "
|
||||
"the header, or name the constant. Only touch code you are already editing for a finding; do not restyle untouched "
|
||||
"code. A rename that would change a public API symbol is reported, not auto-applied."
|
||||
)
|
||||
|
||||
def scope_units(self) -> list[tuple[str, str]]:
|
||||
return [
|
||||
("forbidden-names", "devplacepy/**/*.py forbidden naming prefixes/suffixes"),
|
||||
("headers", "every source file starts with the retoor header in the right comment style"),
|
||||
("em-dash", "no em-dash character or its HTML entities in any touched file"),
|
||||
("typing", "Python function signatures and variables fully typed"),
|
||||
("pathlib", "pathlib over the os module; no magic numbers; no version pinning"),
|
||||
("frontend-style", "static/js and static/css naming and constants"),
|
||||
]
|
||||
|
||||
|
||||
def main() -> None:
|
||||
cli_main(StyleAgent())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,37 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from .base import MaintenanceAgent, cli_main
|
||||
|
||||
|
||||
class TestAgent(MaintenanceAgent):
|
||||
name = "test"
|
||||
description = "integration-test coverage"
|
||||
|
||||
def mandate(self) -> str:
|
||||
return (
|
||||
"Keep integration-test coverage in step with the routes and features, writing tests that follow the project's "
|
||||
"required patterns.\n\n"
|
||||
"DETECT: routes and features with no corresponding test in tests/test_{area}.py. The project prefers integration "
|
||||
"tests over unit tests and tests the interface and API.\n\n"
|
||||
"FIX: write the missing integration test following the required patterns: every page.goto and page.wait_for_url "
|
||||
"passes wait_until=\"domcontentloaded\"; selectors are scoped; a test that flips a global site_settings value "
|
||||
"restores it in try/finally; the shared fixtures (alice, bob, app_server) are used.\n\n"
|
||||
"HARD GUARDRAIL: write tests but NEVER run the suite, not the full suite and not a single file. Validate only by a "
|
||||
"clean import of the new test module (python -c). Never weaken an existing test to make it pass."
|
||||
)
|
||||
|
||||
def scope_units(self) -> list[tuple[str, str]]:
|
||||
return [
|
||||
("coverage-gaps", "routers/*.py routes with no referencing test in tests/test_{area}.py"),
|
||||
("pattern-lint", "tests/*.py use domcontentloaded, scoped selectors, try/finally global restore, shared fixtures"),
|
||||
]
|
||||
|
||||
|
||||
def main() -> None:
|
||||
cli_main(TestAgent())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,150 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import ast
|
||||
import py_compile
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from typing import Optional
|
||||
|
||||
PYTHON_SUFFIXES = (".py",)
|
||||
JS_SUFFIXES = (".js", ".mjs")
|
||||
CSS_SUFFIXES = (".css",)
|
||||
HTML_SUFFIXES = (".html", ".htm")
|
||||
|
||||
SKIP_DIRS = {
|
||||
".git",
|
||||
"__pycache__",
|
||||
"node_modules",
|
||||
".venv",
|
||||
"venv",
|
||||
"var",
|
||||
"htmlcov",
|
||||
"vendor",
|
||||
".egg-info",
|
||||
"downloads",
|
||||
}
|
||||
|
||||
|
||||
class Issue:
|
||||
def __init__(self, path: Path, message: str) -> None:
|
||||
self.path = path
|
||||
self.message = message
|
||||
|
||||
|
||||
def _check_python(path: Path) -> Optional[str]:
|
||||
source = path.read_text(encoding="utf-8", errors="replace")
|
||||
try:
|
||||
ast.parse(source, filename=str(path))
|
||||
except SyntaxError as error:
|
||||
return f"SyntaxError: {error.msg} (line {error.lineno})"
|
||||
try:
|
||||
py_compile.compile(str(path), doraise=True)
|
||||
except py_compile.PyCompileError as error:
|
||||
return f"CompileError: {error.msg}"
|
||||
return None
|
||||
|
||||
|
||||
def _check_js(path: Path, node: Optional[str]) -> Optional[str]:
|
||||
if node is None:
|
||||
return None
|
||||
result = subprocess.run(
|
||||
[node, "--check", str(path)],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
if result.returncode != 0:
|
||||
return f"node --check failed: {result.stderr.strip().splitlines()[-1] if result.stderr.strip() else 'syntax error'}"
|
||||
return None
|
||||
|
||||
|
||||
def _check_braces(path: Path) -> Optional[str]:
|
||||
text = path.read_text(encoding="utf-8", errors="replace")
|
||||
depth = 0
|
||||
for char in text:
|
||||
if char == "{":
|
||||
depth += 1
|
||||
elif char == "}":
|
||||
depth -= 1
|
||||
if depth < 0:
|
||||
return "Unbalanced braces: unexpected '}'"
|
||||
if depth != 0:
|
||||
return f"Unbalanced braces: {depth} unclosed '{{'"
|
||||
return None
|
||||
|
||||
|
||||
def _check_html(path: Path) -> Optional[str]:
|
||||
try:
|
||||
import jinja2
|
||||
except ImportError:
|
||||
return None
|
||||
source = path.read_text(encoding="utf-8", errors="replace")
|
||||
try:
|
||||
jinja2.Environment(autoescape=True).parse(source)
|
||||
except jinja2.TemplateSyntaxError as error:
|
||||
return f"TemplateSyntaxError: {error.message} (line {error.lineno})"
|
||||
return None
|
||||
|
||||
|
||||
def _iter_files(root: Path):
|
||||
if root.is_file():
|
||||
yield root
|
||||
return
|
||||
for path in root.rglob("*"):
|
||||
if not path.is_file():
|
||||
continue
|
||||
if any(part in SKIP_DIRS or part.endswith(".egg-info") for part in path.parts):
|
||||
continue
|
||||
yield path
|
||||
|
||||
|
||||
def validate(root: Path) -> list[Issue]:
|
||||
node = shutil.which("node")
|
||||
issues: list[Issue] = []
|
||||
for path in _iter_files(root):
|
||||
suffix = path.suffix.lower()
|
||||
message: Optional[str] = None
|
||||
if suffix in PYTHON_SUFFIXES:
|
||||
message = _check_python(path)
|
||||
elif suffix in JS_SUFFIXES:
|
||||
message = _check_js(path, node)
|
||||
elif suffix in CSS_SUFFIXES:
|
||||
message = _check_braces(path)
|
||||
elif suffix in HTML_SUFFIXES:
|
||||
message = _check_html(path)
|
||||
if message is not None:
|
||||
issues.append(Issue(path, message))
|
||||
return issues
|
||||
|
||||
|
||||
def main(argv: Optional[list[str]] = None) -> int:
|
||||
parser = argparse.ArgumentParser(
|
||||
prog="agents.validator",
|
||||
description="Validate Python, JavaScript, CSS, and HTML without external tools.",
|
||||
)
|
||||
parser.add_argument("path", nargs="?", default=".", help="File or directory to validate")
|
||||
parser.add_argument("-q", "--quiet", action="store_true", help="Only print failures")
|
||||
args = parser.parse_args(argv)
|
||||
|
||||
root = Path(args.path)
|
||||
if not root.exists():
|
||||
sys.stderr.write(f"path not found: {root}\n")
|
||||
return 2
|
||||
|
||||
issues = validate(root)
|
||||
if issues:
|
||||
for issue in issues:
|
||||
sys.stderr.write(f"FAIL {issue.path}: {issue.message}\n")
|
||||
sys.stderr.write(f"\n{len(issues)} error(s)\n")
|
||||
return 1
|
||||
if not args.quiet:
|
||||
sys.stdout.write(f"OK: {root} validated clean\n")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Reference in New Issue
Block a user