fix(bin): derive --help usage output from header content instead of hard-coded line ranges - #2852
Open
pramendra wants to merge 4 commits into
Open
fix(bin): derive --help usage output from header content instead of hard-coded line ranges#2852pramendra wants to merge 4 commits into
pramendra wants to merge 4 commits into
Conversation
added 4 commits
August 23, 2026 15:34
bin/fm-afk-launch.sh --help sliced its own file header with `sed -n '2,34p'`, a magic range that the header has since outgrown: the stop entry was cut off mid-sentence and the reconcile entry never printed. Replace the range with the repo's established awk idiom that prints the header comment until the first non-comment line, so the help keeps tracking the header as it grows. The same latent truncation existed in fm-afk-start.sh, fm-afk-return.sh, fm-herdr-lab.sh, and fm-procevent-when.sh (each with a different stale range); apply the identical mechanical fix there. fm-procevent.sh and fm-procevent-lavish.sh use the same pattern but their ranges are still in sync, so they are left untouched. Add a regression test that derives the declared subcommands from the header's Usage block and asserts --help prints every one, so a future truncation fails the suite instead of silently dropping an entry.
…den afk-launch usage test
The no-mistakes review-fix commit b0f40f4 staged the Serena MCP tool's machine-local config (.serena/.gitignore and .serena/project.yml), which has no relation to the help-truncation fix. Remove them from the change and gitignore .serena/ so the running tool's local config cannot leak into the PR again.
…st in header comment
Confidence Score: 5/5The PR appears safe to merge, with no concrete changed-code defect identified. The new awk implementation correctly reads each changed script’s contiguous leading comment block, preserves existing help control flow, and the targeted regression test covers the reported truncation. Reviews (1): Last reviewed commit: "no-mistakes(document): Document new --he..." | Re-trigger Greptile |
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.
Intent
Fix
bin/fm-afk-launch.sh --help, which silently truncates its own Usage block. The usage function prints help by slicing its own file header with a hard-coded line range (sed -n '2,34p'); the header has grown past line 34, so --help cuts thestopentry off mid-sentence and never shows thereconcileentry. This is pre-existing at the base commit, not introduced by any branch.Acceptance criteria:
bin/fm-afk-launch.sh --helpprints the complete Usage block, withstopwhole andreconcilepresent.set -euo pipefail, 2-space indent, shellcheck-clean, one sentence per line in prose, no agent co-author trailer.Decisions made while implementing: I used the awk idiom already established elsewhere in the repo (print the header comment until the first non-comment line) to derive the range from content. I fixed the four siblings that share the exact truncation defect - fm-afk-start.sh, fm-afk-return.sh, fm-herdr-lab.sh, and fm-procevent-when.sh - with the identical mechanical change, and left fm-procevent.sh and fm-procevent-lavish.sh untouched because their hard-coded ranges are still in sync with their headers. The regression test derives the declared subcommands from the header's Usage block and asserts --help prints each one, so any future truncation fails the suite.
Delivery: push through the no-mistakes gate (fork pramendra/firstmate, PR against origin kunchenguid/firstmate); do not hand-open a PR and do not merge.
What Changed
bin/fm-afk-launch.sh'sfm_afk_launch_usagereplaced its hard-codedsed -n '2,34p'slice with anawkidiom that prints the header comment block from line 2 until the first non-comment line, so--helpprints the full Usage block (including thestopandreconcileentries) regardless of header length.usage/-h|--helphandlers had the same hard-coded-range defect:fm-afk-return.sh,fm-afk-start.sh,fm-herdr-lab.sh,fm-inactive-reconcile.sh,fm-kimi-turnend-hook.sh,fm-on.sh,fm-procevent-remote-reply.sh,fm-procevent-when.sh,fm-remote-delta-read.sh,fm-remote-doctor.sh,fm-remote-home-seed.sh,fm-remote-secondmate-control.sh, andfm-startup-memory-budget.sh.unit_usage_prints_complete_headertotests/fm-afk-launch.test.sh, which derives the declared subcommands and final header line from the script's own header and asserts--helpoutput contains all of them, catching future truncation instead of pinning today's output..serena/to.gitignore.Risk Assessment
✅ Low: The fix correctly replaces hard-coded sed line-ranges with a content-derived awk idiom in fm-afk-launch.sh and 13 sibling scripts, all of which were verified to have had a genuine header/range mismatch before the fix; a scan of the remaining bin/ scripts using the same sed pattern (fm-remote-file.sh, fm-lint.sh, fm-lint-workflows.sh, fm-remote-inherit.sh, fm-backlog-receive.sh, fm-stow-cascade.sh, fm-procevent.sh, fm-procevent-lavish.sh) confirms their ranges are still in sync with their headers, so no further sibling was missed; the new regression test executes the real --help output and derives expectations from the header via the same boundary rule, correctly reproducing the reported truncation before the fix and passing after; shellcheck shows only pre-existing, unrelated SC1091/SC2034 notices; a follow-on commit expanded the sibling-fix scope beyond the four originally named and a further commit cleaned up an accidentally committed .serena config, both of which are net improvements consistent with the stated acceptance criteria.
Testing
Ran the targeted fm-afk-launch.test.sh suite (57/57 pass) and manually exercised
bin/fm-afk-launch.sh --helpend-to-end, confirming the previously truncatedstopentry now prints whole andreconcilenow appears; also proved the new regression test genuinely catches the original defect by re-running it against the base commit's unfixed script (it failed exactly as expected) before restoring the fix (it passed). Spot-checked two of the additional sibling scripts fixed by the automated review pass and confirmed their--helpoutput is no longer truncated. No findings — all acceptance criteria are satisfied and the working tree is clean of test artifacts.Evidence: fm-afk-launch.sh --help full output (post-fix)
Evidence: Regression proof: test fails against pre-fix sed -n '2,34p' script, passes after fix
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
bash tests/fm-afk-launch.test.sh— 57/57 pass, 0 failures, exit 0, including the 5 new usage-completeness assertionsManual:FM_HOME=<tmp> FM_STATE_OVERRIDE=<tmp>/state bin/fm-afk-launch.sh --help— confirmed full header prints,stopentry ends whole,reconcileentry present (both were previously cut off by thesed -n '2,34p'slice)Regression proof: swapped in the base commit's fm-afk-launch.sh (pre-fixsed -n '2,34p') and reran the test suite — the two new usage assertions failed as expected (reconcilemissing, header truncated), then restored the target commit's file and reran to confirm they pass — proves the test is a real regression catch, not a tautologyManual spot-check of two of the newly-fixed siblings from the review commit:bin/fm-startup-memory-budget.sh --helpandbin/fm-on.sh --helpboth print their full header text without truncationReviewed full diff (8714c9a..aa9dbb7) across all 3 commits to confirm every sibling fix uses the identical awk idiom, the cleanup commit correctly removes accidentally-committed.serena/config unrelated to the fix, and the final test hardening removed a previously hard-coded content match (the literal 'stop' sentence) in favor of deriving expectations from the header content itself✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.