43 lines
3.0 KiB
Python
43 lines
3.0 KiB
Python
from model_routing.ladder import highest, Rung
|
|
from loop_claude.project.records import HUMAN_RULE_NAMES, RECORD_FILES
|
|
from markdown_text import quoted
|
|
from loop_claude.routing import Route
|
|
|
|
def either(names: tuple[str, ...]) -> str:
|
|
"""The names as `a, b or c`."""
|
|
return f"{', '.join(names[:-1])} or {names[-1]}"
|
|
|
|
|
|
# Where the judge may quote an answer from, named as the human and the worker see them; of README.md the judge sees only the premises.
|
|
QUOTE_SOURCES = either(("README.md's Goals and Audience", *RECORD_FILES, *HUMAN_RULE_NAMES))
|
|
# Where the worker may write an answer the human typed, so it counts as recorded.
|
|
ANSWER_DESTINATIONS = "README.md's Goals or Audience, " + ", ".join(RECORD_FILES) + ", todo.md or a comment"
|
|
ANSWERS_RECORDED = f"every answer the human typed in it that a later chunk could need is recorded in {ANSWER_DESTINATIONS} at the one place it governs"
|
|
|
|
|
|
def fresh(task: str, premises: str, route: Route, anchor: Rung | None) -> str:
|
|
routed = f"{routed_by(route, anchor)}\n\n" if route.item else ""
|
|
return f"{task}\n\nContinue any open draft PR or worktree for the chunk before creating a new one.\n\n{routed}The chunk's todo.md items, or else the task above, set its scope. The goals below choose between ways to deliver that scope, and never widen it.\n\nFrom README.md:\n{premises}"
|
|
|
|
|
|
def routed_by(route: Route, anchor: Rung | None) -> str:
|
|
said = f"loop-claude runs you on {route.rung}, routed by item {route.item}'s R + C of {route.risk_and_complexity}. Name each todo.md item this chunk takes, with its R + C, whether or not it is item {route.item}."
|
|
if anchor is None or highest(route.rung, anchor) == route.rung:
|
|
return said
|
|
# The Agent tool takes a model's family name, such as opus, and runs that family's latest model, which each ladder rung names.
|
|
return f"{said} Your rung is below the project's, {anchor}: launch each reviewer, each comprehension seat and the security pass's subagent with the Agent tool's model `{anchor.model.split('-')[1]}` and effort `{anchor.effort}`, and run a full scan only from such a subagent, since the scan's agents run on the model that starts them."
|
|
|
|
|
|
def resumed(unfinished_evidence: str) -> str:
|
|
ruled = f" A judge ruled the chunk unfinished, quoting this passage of your transcript as the work remaining:\n\n{quoted(unfinished_evidence)}\n\n" if unfinished_evidence else " "
|
|
return f"Continue the task; the previous run ended before the chunk was finished.{ruled}The chunk is finished once it is merged, or nothing remains that you could do on your own. Even then, it is finished only once {ANSWERS_RECORDED}."
|
|
|
|
|
|
def answered(question: str, answer: str) -> str:
|
|
return f"Your question: {question}\n\n{QUOTE_SOURCES} answers it:\n\n{answer}\n\nContinue the task."
|
|
|
|
|
|
def past_the_cap(question: str, answer: str, cap: int) -> str:
|
|
"""The question a quoted answer puts to the human once the cycle's quoted answers reach the cap."""
|
|
return f"{question}\n\n{QUOTE_SOURCES} says:\n{answer}\n\nThose files have answered {cap} questions this cycle, the most allowed, so this one comes to you."
|