{ "intent": "Teach extract_shell_functions.py bash's `function name() {` spelling. It matched only `name() {`, so a file using the keyword form had those functions silently left behind while the tool still reported success.", "scope": [ "meta/scripts/extract_shell_functions.py: the function-detection regex and how the name is derived", "python_pkg/tests/test_extract_shell_functions.py: first tests for this script", "Non-goal: any change to how blocks are brace-matched or written out" ], "changes": [ "The regex now accepts `name() {`, `function name() {` and `function name {`. Parentheses stay MANDATORY in the non-keyword branch: making them optional everywhere would also match brace groups and control constructs, which would sweep non-function code into the library — the opposite failure and a worse one.", "The name comes from a named capture group instead of lines[start].split('(')[0], which yielded 'function name' for the keyword form and would have produced a corrupt --functions match and a wrong verify_shell_split.sh name." ], "verification": [ { "command": "python3 -m pytest python_pkg/tests/test_extract_shell_functions.py -q", "result": "pass", "evidence": "20 passed. Covers all five spellings bash accepts, nine negative cases (indented definitions, `while true; do {`, `if x {`, bare braces, a commented-out definition, a bare call), brace matching across a nested if/case body, single-line functions, and a file mixing all three forms." }, { "command": "find_function_blocks on the real files", "result": "pass", "evidence": "pacman_wrapper.sh now yields 31 functions where the old pattern found 13 — the 17 `function`-keyword definitions plus one the count had missed. cco_state.sh (13) and leechblock_fetch.sh (3) are unchanged, so the already-completed splits would extract identically." }, { "command": "pre-commit run --files ", "result": "pass", "evidence": "ruff (2 import-order fixes applied), ruff format, mypy, pylint, bandit, pytest-with-coverage and codespell all pass. No suppression added." } ], "risks": [ "A file that legitimately contains a top-level brace group opening at column 0 would now be misread if it also began with an identifier. The mandatory-parens rule plus the nine negative tests are what bound this; the alternative (missing real functions) is the failure that actually occurred.", "This changes the tool every remaining split depends on. It was verified against the three already-split files first, so a regression would have shown up as a different function count there." ], "rollback": [ "git revert the commit; the extractor returns to matching only `name() {` and the new tests fail, which is the intended signal rather than a silent regression." ] }