diff --git a/bin/do_epic/backend/jira.py b/bin/do_epic/backend/jira.py index 3cfdaa31..f9a6d1c3 100644 --- a/bin/do_epic/backend/jira.py +++ b/bin/do_epic/backend/jira.py @@ -132,7 +132,7 @@ class JiraEpic: def close(self, summary: str) -> None | Failure: if self.finish is None: - return Failure(f"do-epic's settings name no transition to close an epic by: set `{JIRA_FINISH_TRANSITION}` and `{JIRA_FINISH_STATUS}`, as config.py's docstring shows") + return Failure(f"do-epic's settings name no transition to close an epic by: set `{JIRA_FINISH_TRANSITION}` and `{JIRA_FINISH_STATUS}` in ~/.claude-projects/do-epic/config.toml, to the names Jira shows, such as \"Mark as done\" and \"Done\"") authorization = basic_auth(self.env_file) if isinstance(authorization, Failure): return authorization @@ -141,7 +141,7 @@ class JiraEpic: body = self.to_adf(summary) if isinstance(body, Failure): return Failure(f"cannot convert the summary to a Jira comment: {body.reason}") - # Read before the comment is posted, so that an epic that cannot move gets no summary, and a second try posts no second one. + # The transition is read before the comment is posted, so an epic that cannot move gets no summary. transition = finishing_transition(self.epic.site, self.epic_key, self.finish, authorization, self.http) if isinstance(transition, Failure): return transition diff --git a/bin/do_epic/backend/protocol.py b/bin/do_epic/backend/protocol.py index ab50bdba..94b4e7bc 100644 --- a/bin/do_epic/backend/protocol.py +++ b/bin/do_epic/backend/protocol.py @@ -68,7 +68,7 @@ class EpicStore(typing.Protocol): """Whether the epic itself is in a status the tracker counts as done.""" def close(self, summary: str) -> None | Failure: - """Posts summary, markdown, as a comment on the epic, then moves the epic to a status the tracker counts as done. A blank summary is refused, and so is an epic the tracker cannot move so, before anything is posted. Where the move fails after the comment is posted, the Failure says so.""" + """Posts summary, markdown, as a comment on the epic, then moves the epic to a status the tracker counts as done. Before anything is posted, it refuses a blank summary, and an epic the tracker cannot move to such a status. Where the move fails after the comment is posted, the Failure says so.""" def unfit(summary: str, labels: tuple[str, ...]) -> Failure | None: diff --git a/bin/do_epic/backend/test_jira.py b/bin/do_epic/backend/test_jira.py index 9253a4b4..af2db03d 100644 --- a/bin/do_epic/backend/test_jira.py +++ b/bin/do_epic/backend/test_jira.py @@ -181,7 +181,7 @@ class Jira(Case): no_such = JiraEpic(EPIC, self.env_file, self.jira, to_markdown, to_adf, Finish("Close", "Done")) unconverted = JiraEpic(EPIC, self.env_file, self.jira, to_markdown, lambda markdown: Failure("adf-codec refused it"), Finish("Mark as done", "Done")) for store, reason in ( - (unnamed, "do-epic's settings name no transition to close an epic by: set `jira-finish-transition` and `jira-finish-status`, as config.py's docstring shows"), + (unnamed, "do-epic's settings name no transition to close an epic by: set `jira-finish-transition` and `jira-finish-status` in ~/.claude-projects/do-epic/config.toml, to the names Jira shows, such as \"Mark as done\" and \"Done\""), (wrong_status, "ABC-12's transition 'Start' leads to the status 'In Progress', not to 'Done', which `jira-finish-status` names"), (unconverted, "cannot convert the summary to a Jira comment: adf-codec refused it"), ): diff --git a/bin/do_epic/chunk_prompt.py b/bin/do_epic/chunk_prompt.py index c5aa911b..e5780438 100644 --- a/bin/do_epic/chunk_prompt.py +++ b/bin/do_epic/chunk_prompt.py @@ -1,4 +1,6 @@ """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.""" +import dataclasses + from do_epic.backend.protocol import EpicIssue from do_epic import findings from loop_claude.project.records import HUMAN_RULE_NAMES, RECORD_FILES @@ -36,3 +38,8 @@ NAMES = prompts.RecordNames( 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) + + +def restating(task: str) -> prompts.WorkerPrompts: + """WORKER for a chunk whose task follows the epic's state, as its finishing's does: the prompt that resumes its worker states task, which may not be the one its session began with.""" + return dataclasses.replace(WORKER, resumed=lambda evidence, route, project: f"{WORKER.resumed(evidence, route, project)}\n\nThe task follows the epic's state, so it may have changed since you began. It is now:\n\n{task}") diff --git a/bin/do_epic/config.py b/bin/do_epic/config.py index 53b77fbb..f3852832 100644 --- a/bin/do_epic/config.py +++ b/bin/do_epic/config.py @@ -13,13 +13,13 @@ One pair per machine, the same for every epic (docs/decisions.md → `do-epic: d - `repoless-model` is the model that works an epic item with no repo: a model on the routing ladder, `model_routing/routing-ladder.json`. - `clone-folder` is the folder a missing repo is cloned into: a path that starts with / or ~/. `~/code` where left out. - `language` is the default language of Jira text, by its English name. English where left out. -- `jira-finish-transition` and `jira-finish-status` say how a finished epic closes, as a project's config says it of a plan item: the name of the workflow transition, such as "Mark as done", and of the status it leads to, such as "Done". Set both or neither; without them do-epic closes no epic. +- `jira-finish-transition` and `jira-finish-status` name the workflow transition that closes a finished epic, such as "Mark as done", and the status it leads to, such as "Done". A project's config names a plan item's the same way. Set both or neither; without them do-epic closes no epic. - `repo-rule.md` is prose that says how to tell an item's repo, and mustn't be blank.""" import dataclasses import pathlib import re -from project_config.settings import anywhere, CONFIG, DO_EPIC, ENV_FILE, Finish, JIRA_FINISH, LANGUAGE, language_fault, lies_in, name_of, parsed, PROJECTS, SITE +from project_config.settings import anywhere, CONFIG, DO_EPIC, ENV_FILE, Finish, finish_faults, finish_of, JIRA_FINISH, LANGUAGE, language_fault, lies_in, parsed, PROJECTS, SITE from failure import Failure from text_files.markdown_text import listed from model_routing.ladder_file import read_ladder, SHIPPED @@ -77,13 +77,11 @@ def load(home: pathlib.Path, ladder_file: pathlib.Path = SHIPPED) -> DoEpicConfi *([f"`{ENV_FILE}` is {values[ENV_FILE]!r}, inside a folder of ~/{PROJECTS} or the clone folder, which hold git checkouts"] if env_file and lies_in(env_file, *config_folders, *([clone_folder] if clone_folder else [])) else []), *([f"`{LANGUAGE}` is {language!r}, {fault}"] if LANGUAGE in values and (fault := language_fault(language)) else []), *([f"`{REPOLESS_MODEL}` is {model!r}, not a model on the routing ladder: {', '.join(models)}"] if REPOLESS_MODEL in values and model not in models else []), - *(f"`{name}` is {values[name]!r}, not the name Jira shows, such as \"{example}\"" for name, example in zip(JIRA_FINISH, ("Mark as done", "Done")) if name in values and not name_of(values[name])), - *(f"`{name}` is set, so `{other}` must be too" for name, other in (JIRA_FINISH, JIRA_FINISH[::-1]) if name in values and other not in values), + *finish_faults(values), *([rule.reason] if isinstance(rule, Failure) else [f"`{REPO_RULE}` is blank"] if not rule.strip() else []), ] if faults: return Failure(f"{folder}: {'; '.join(faults)}. {LISTED}") # Without a fault, each value above is present and of the type asserted here. assert clone_folder and env_file and isinstance(url, str) and isinstance(model, str) and isinstance(language, str) and isinstance(rule, str) - finish = [name for setting in JIRA_FINISH if (name := name_of(values.get(setting)))] - return DoEpicConfig(folder, url, env_file, clone_folder, language, model, rule, Finish(*finish) if len(finish) == 2 else None) + return DoEpicConfig(folder, url, env_file, clone_folder, language, model, rule, finish_of(values)) diff --git a/bin/do_epic/findings.py b/bin/do_epic/findings.py index d2eefb9d..92336512 100644 --- a/bin/do_epic/findings.py +++ b/bin/do_epic/findings.py @@ -10,6 +10,7 @@ from do_epic.repo_pick import CLAUDE_LABEL, HUMAN_LABEL, of_label, REPO_PREFIX, from do_epic.epic_record import EpicRecord from do_epic.backend.protocol import EpicStore from failure import Failure +from text_files.markdown_text import listed from text_files.piped_text import piped # Three readers, seated as the human and as a chunk's worker, picked each spelling from four: ` --file` over `--file `, `add` and `--finding`, and `--record-decision` over `--decision` and `--decide`. @@ -24,6 +25,7 @@ USAGE = f"""do-epic {FILE} [{LABEL}