40 lines
2.5 KiB
Python
40 lines
2.5 KiB
Python
from loop_claude.project.records import HUMAN_RULE_NAMES, RECORD_FILES
|
|
from todo_table import Item
|
|
from markdown_text import quoted
|
|
from loop_claude.cycle.routing import risk_and_complexity
|
|
from model_routing.ladder import Rung
|
|
|
|
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, routed: str = "") -> str:
|
|
route = f"{routed}\n\n" if routed else ""
|
|
return f"{task}\n\nContinue any open draft PR or worktree for the chunk before creating a new one.\n\n{route}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(worker: Rung, item: Item) -> str:
|
|
return f"loop-claude runs you on {worker}, the rung item {item.id}'s R + C of {risk_and_complexity(item)} picks. When the chunk takes in a todo.md item whose R + C is higher, say so, naming that item and its R + C."
|
|
|
|
|
|
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."
|