testsAndMisc/docs/superpowers/evidence/wsg-grabber-cli-split-2026-08-16.json
Krzysztof kuhy Rudnicki 8ce453690f Split wsg_grabber/cli.py under the 250-line cap
The `logs` subcommand's reporting -- show_logs() and summarise() -- is
read-only analysis of the JSONL session logs and shares nothing with the
scrape/review flow, so it moves to _logs_report.py.

cli.py re-exports both through __all__ so cli.show_logs / cli.summarise stay
valid for test_cli.py and the dispatch table. The PEP 484 `X as X` alias form
does NOT survive here: ruff flags it PLC0414, autofixes it away, and then
deletes the import as unused under F401 -- which would break cli.summarise
with lint still green. Recorded in the handoff so it is not re-derived.

cli.py 282 -> 247, new _logs_report.py 76. 277 wsg_grabber tests pass.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011w2Pj4Ek3ZNMQVYcFHgXDY
2026-08-16 15:39:10 +02:00

36 lines
2.6 KiB
JSON

{
"intent": "Bring python_pkg/wsg_grabber/cli.py under the 250-line file cap by extracting the `logs` subcommand's reporting functions into a sibling module, keeping cli.show_logs and cli.summarise working for existing callers and tests.",
"scope": [
"python_pkg/wsg_grabber/cli.py",
"python_pkg/wsg_grabber/_logs_report.py (new)",
"refactor_claude_todo_resume.md (handoff: record the settled re-export form)",
"Non-goal: no behaviour change, no test changes, no CLI surface change"
],
"changes": [
"Moved show_logs() and summarise() plus their _emit helper into python_pkg/wsg_grabber/_logs_report.py; they are read-only reporting over the JSONL session logs and share nothing with the scrape/review flow.",
"cli.py re-exports both names via __all__ so cli.show_logs / cli.summarise remain valid attributes for tests and the `logs` subcommand dispatch.",
"Recorded the working re-export form in the handoff file: the `X as X` alias form is rejected by ruff PLC0414 and then stripped by F401, so __all__ is required.",
"cli.py 282 -> 247 lines; _logs_report.py is 76 lines. Both under the 250-line cap."
],
"verification": [
{
"command": "python3 -m pytest python_pkg/wsg_grabber/tests/ -q",
"result": "pass",
"evidence": "277 passed in 15.00s, unchanged from before the split. test_cli.py calls cli.show_logs() and cli.summarise() directly, so these passing prove the re-export resolves through the old path."
},
{
"command": "pre-commit run --files python_pkg/wsg_grabber/cli.py python_pkg/wsg_grabber/_logs_report.py",
"result": "pass",
"evidence": "All hooks pass with no output after filtering Passed/Skipped, including ruff, ruff format, mypy, pylint and 'pytest with coverage enforcement'. An earlier run of this exact command with the `X as X` alias form failed with 2 x PLC0414 + 1 x F401; switching to __all__ fixed it without any suppression."
}
],
"risks": [
"ruff's F401 autofix can silently delete a re-export that is not covered by __all__, which would break cli.summarise at runtime while lint stays green. Mitigated by __all__ and by test_cli.py exercising both names.",
"One transient test failure appeared in an earlier combined run and did not reproduce on two subsequent full runs of the package suite; it was in another package's tests, not wsg_grabber."
],
"rollback": [
"git revert the commit; cli.py returns to its 282-line form and _logs_report.py is deleted.",
"After rollback, run python3 -m pytest python_pkg/wsg_grabber/tests/ -q to confirm 277 tests still pass."
]
}