Repository navigation
Conversation
main() built all 19 top-level commands' parsers inline: 640 lines, each block 652 to 1,783 lines above the handler it feeds. Each block now moves, byte for byte, into _add_<command>_parser(subparsers), placed directly above the command's first handler, and main() calls the builders in the same order. The two shared argument helpers move above their first builder, and _work_assumptions, _work_impact and _debrief_orchestrator move below the handlers that dispatch to them. main() goes from 640 to 79 lines. Nothing else changes: with the builders inlined, main() has the same syntax tree as before, and the parser main() builds is the same on all 52 command paths.
2 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Move-only. Each command's parser now sits beside its handler, and
main()goes from 640 lines to 79. This is a draft until #795 and #796 merge: both editmain()'s parser blocks, and Git can't carry an edit across a move. Once they merge, the branch is regenerated on main by the same script. Its conflicts are never resolved by hand.Premise
main()inautoform_cli/__main__.pybuilt every top-level command's parser inline. It ran 640 of the file's 2,496 lines, with 47add_parserand 147add_argumentcalls. Each command's parser block sat 652 to 1,783 lines above its first handler, so changing one command meant editing two distant places. The file also changes often: 46 commits in the last 30 days touchedmain()'s lines._add_<command>_parser(subparsers), directly above the command's first handler.main()keeps everything else unchanged: the SIGCHLD reset, the root parser and--version, the builder calls in the old registration order (the order--helplists commands in), the parse,page_workers, and the dispatch. Five whole functions also move, unchanged:_add_claim_board_argumentsgoes above_add_claim_parser, its only user;_add_probe_timeout_argumentgoes above_add_skeleton_parser, the first of its three users;_work_assumptions,_work_impactand_debrief_orchestratorgo below the handlers that dispatch to them.autoform_cli.__main__. No import changes.Checks
The change was generated by a script, not edited by hand, then checked three ways:
main()gives the same AST as the oldmain(). Every other top-level statement is unchanged apart from the five whole-function moves. No builder reads a name the oldmain()bound in another block, reads a local before it is bound, or binds a namemain()binds. Result: equivalent.main()builds: captured the waytests/test_skill_examples.pydoes, so no handler runs. Compared on all 52 command paths: help and usage at 80 columns, prog, exclusive groups, and every action's option strings, dest, nargs, const, default, type, choices, required flag, help and metavar, withAUTOFORM_WORKER_IDset so the defaults that read it show. No path differs. This covers thecheck,renderandwork assumptionshelp that the generated workflows grep.ruff check autoform_cli servers tests(ruff 0.15.17) passes. Run directly, since load was over the limit for pytest, these pass:test_documented_autoform_commands_parse,test_cli_reference_documents_only_commands_that_exist, the version tests intest_release.py, andtest_ui_boundary.py. CI runs the rest; no test changes.To review, read
git diff --histogram --color-movedbeside this. Of its 718 removed lines, all but three show as moved: two)lines and a blank line at block edges. Git's default algorithm counts 730 removed lines and leaves six of them unmarked. Each of those six has an identical unmarked twin on the added side, so it's an artifact of the diff, not a change. The only new lines are the 19def _add_<command>_parser(subparsers: argparse._SubParsersAction) -> None:headers and the 19 calls. GitHub's diff shows no move markers.No CHANGELOG line: nothing users run or import changes.
After this merges
A PR that edits a command's options edits its
_add_<command>_parser. A PR that is already open and editsmain()'s old parser region does one of two things: it lands first, and this branch is regenerated, or it reapplies its hunk inside the builder (same lines, same indentation).Posted by Claude Code, at Jack's request.