can you clean up both of htese pelase: prompts.py (1531 lines) — make it a package. The…
- User
can you clean up both of htese pelase: prompts.py (1531 lines) — make it a package. The split is obvious:
prompts/
init.py # create_claude_prompt, create_codex_prompt, create_hermes_prompt + dispatch tables _shared.py # debt blocks, research/prep block renderers, settled decisions (~150 lines)
planning.py # _prep_prompt, _plan_prompt, _research_prompt (~250 lines)
critique.py # _critique_prompt, _render_critique_checks, _render_critique_template, _revise_prompt (~350 lines)
gate.py # _gate_prompt, _gate_signals, _flag_summary (~200 lines)
execute.py # _execute_prompt, _execute_batch_prompt, helpers (~250 lines)
finalize.py # _finalize_prompt (~100 lines)
review.py # _review_prompt, _settled_decisions (~200 lines)Each file is one phase's prompts + its helpers. _shared.py holds the debt/research/prep block renderers that multiple
phases use.execution.py (1233 lines) — don't make it a package, but extract two helpers:
execution.py # handle_execute_one_batch, handle_execute_auto_loop, _run_and_merge_batch (~700 lines)
execution_timeout.py # _recover_execute_timeout, _merge_timeout_checkpoint, _reset_timeout_invalid_tasks (~250 lines)
execution_quality.py # _collect_quality_deviations, _observe_git_changes, evidence checking (~250 lines) - Assistant
Using the
desloppifyskill here because this is a codebase cleanup/refactor request. I’m reading the repo structure and the two target modules first so I can split them along the existing phase boundaries without changing behavior. - Assistant
I found multiple
prompts.pyfiles; the large one is likelymegaplan/prompts.py, and that’s the one I’m targeting alongsidemegaplan/execution.py. I’m mapping current function boundaries now so the split matches the existing phases and doesn’t fight the unrelated in-progress changes already in the tree. - Assistant
I’ve mapped the execution split points. Next I’m checking the lower half of both modules and the existing prompt tests so I can move code without accidentally breaking internal imports or test expectations.
- Assistant
I’ve got the current dependency surface. The main risk is internal-name compatibility: tests and runtime import private prompt helpers directly, so I’m checking those call sites before I cut files and re-export the same symbols from the new package/modules.
- Assistant
I have enough structure to start the refactor. I’m going to generate the new prompt package files from the existing source boundaries, then I’ll tighten imports/re-exports and do the smaller execution split the same way so the public API stays stable.
- Assistant
I’m editing now. The prompt refactor will be a mechanical split first, with the old symbol surface re-exported from
megaplan.promptsso the rest of the repo and tests don’t need to change. - Assistant
The prompt split compiles. I’m doing the smaller execution split now, keeping the old names available from
megaplan.executionso existing patches and imports still resolve. - Assistant
I hit one real regression in the mechanical split:
BatchResultlost its@dataclassdecorator when I rebuiltexecution.py. I’m patching that directly before running the prompt and execution-focused tests. - Assistant
The code compiles. I’ve started the prompt suite and the execute-focused megaplan tests in parallel so I can catch any import-surface regressions from the split before I touch cleanup details.
- Assistant
The prompt suite is green. The execute-focused suite found one missing import on the timeout path in
execution.py; the split leftstore_raw_worker_outputbehind in the main module’s auto-loop timeout branch. I’m patching that and rerunning the execute tests. - Assistant
The main targeted paths are passing now. I’m doing one more compatibility pass on worker-facing prompt imports so this doesn’t only work in the direct prompt tests.
- Assistant
The functional surface looks stable. I’m formatting just the refactored files now so the split doesn’t leave behind mechanically awkward spacing from the extraction step.
- Assistant
Refactored the prompt layer into a real package and split execution timeout/quality helpers out of the main module.
megaplan.promptsis now a package rooted at megaplan/prompts/init.py, with phase files at megaplan/prompts/_shared.py, , , , , , and . The old file was removed, and re-exports the existing builders/private helpers so current imports and tests still work.