38 lines
2.7 KiB
Python
38 lines
2.7 KiB
Python
"""What a do-epic cycle's worker is told: its task, from the issue, and its first prompt. The resumed prompt and the rung sentences are the ones loop-claude's cycles use, naming do-epic."""
|
|
from do_epic.backend.protocol import EpicIssue
|
|
from do_epic import findings
|
|
from loop_claude.project.records import HUMAN_RULE_NAMES, RECORD_FILES
|
|
from text_files.markdown_text import listed
|
|
from model_routing.ladder import ProjectRung
|
|
from loop_claude.cycle import prompts
|
|
from model_routing.route import Route
|
|
|
|
# The entry point's name as the worker, the judge and the human read it.
|
|
DRIVER = "do-epic"
|
|
|
|
|
|
def task(issue: EpicIssue, epic: str, checkout: str | None) -> str:
|
|
"""The task of the chunk that works issue, of the epic with the key epic: in checkout, or without a repo where it is None."""
|
|
where = f"in the checkout {checkout}, on the branch {issue.key}" if checkout else "which changes no repo: work in the folder you start in"
|
|
return f"Work the Jira issue {issue.key} of the epic {epic} as one chunk, {where}. {findings.instructions(epic)} Its summary: {issue.summary}" + (f"\n\nIts description:\n\n{issue.detail}" if issue.detail else "")
|
|
|
|
|
|
CODE_HEALTH = '~/.claude/CLAUDE.md → "Shared goal"'
|
|
|
|
|
|
def fresh(task: str, premises: str, route: Route, project: ProjectRung | None, facts: str) -> str:
|
|
"""A chunk's first prompt. facts is empty: do-epic runs no preflight."""
|
|
routed = f"{DRIVER} runs you on {route.rung}, routed by the issue's L of {route.likelihood}. Where a sentence below names item {route.item}, it means the issue." if route.item else ""
|
|
opening = " ".join(filter(None, [routed, *prompts.rung_sentences(DRIVER, route, project)]))
|
|
return f"{task}\n\nContinue any open draft PR or worktree for the chunk before creating a new one. {prompts.READING_RULE}\n\n{opening and f'{opening}{chr(10)}{chr(10)}'}The issue sets the chunk's scope. The goals below choose between ways to deliver that scope, and never widen it. The epic's goals rank first, then code health ({CODE_HEALTH}), then the repo's.\n\nFrom {premises}"
|
|
|
|
|
|
# The worker names no plan items: the chunk's one item is its issue.
|
|
# The epic's records come first, as its goals do; a chunk without a repo has only those and the human's rules.
|
|
NAMES = prompts.RecordNames(
|
|
quote_sources=listed(("the epic's description", "the repo's goals file's Goals and Audience", *RECORD_FILES, *HUMAN_RULE_NAMES), "or"),
|
|
answer_destinations="the epic's description under ## Decisions, the repo's goals file's Goals or Audience, " + ", ".join(RECORD_FILES) + ", the repo's plan or a comment",
|
|
records_named="the epic's scoring and decisions, then the repo's working rules and decisions, then the human's rules for every project",
|
|
)
|
|
WORKER = prompts.worker_prompts(DRIVER, fresh, "", NAMES)
|