Skip to content

refactor(lib): simplify exec-bash.mjs and fetch-docs.sh internals - #14615

Merged
kyle-sexton merged 1 commit into
mainfrom
work-resolve-issue/issue-14329-42612684223-1
Nov 9, 2026
Merged

kyle-sexton merged 1 commit into
mainfrom
work-resolve-issue/issue-14329-42612684223-1

Conversation

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor

Closes #14329

Summary

Opened by the work-resolve-issue lane. The run's own summary:

Simplified lib/exec-bash.mjs: inlined the one-use shellBase, turned the firstExisting loop into find, collapsed the five try/catch file probes (isFile and the DISK methods) into one orElse helper, built the Windows Git candidates with flatMap, and shortened literal(). Simplified lib/fetch-docs.sh: one HERE for the script directory, dropped a redundant second H_* reset in http_get, shortened resolve_python's cached return, and wrote the manifest step as two plain || die lines. lib/docs-raw.sh is left unchanged: after reading it I found no simplification that kept every output byte the same and was worth the churn. Shared copies were regenerated and every carrying plugin has a patch fragment.

Not verified

  • Node and bash test suites for exec-bash.mjs and fetch-docs.sh (e.g. lib/exec-bash*.test.mjs, fetch-docs tests) were not run: this lane runs no test runner. Left to the PR's CI.
  • ci-status green is a PR CI check; left to the PR's CI.
  • Tidy not run: the change is under lib/, a listed shared path, and spans over 10 files.
  • lib/docs-raw.sh was reviewed but not changed: no edit found that was both simpler and byte-for-byte output-preserving.

Fix

  • lib/exec-bash.mjs: inlined shellBase, firstExisting uses Array.find, one orElse helper replaces the five try/catch wrappers (isFile now a const defined before DISK), flatMap for the Windows Git bash candidates, literal() is value || null
  • lib/fetch-docs.sh: HERE holds the script directory for DOCS_CACHE and CONVERTER; http_get resets H_CTYPE_LC in its first reset and drops the redundant second reset; resolve_python returns the [[ ]] status directly; the manifest write is jq || die, then mv || die
  • plugins//hooks/exec-bash.mjs (24 copies) and plugins//scripts/fetch-docs.sh (14 copies): regenerated by scripts/sync-shared-copies.sh
  • .changes/<plugin>/work-resolve-issue-issue-14329-*.md (36 fragments): patch fragments for each plugin carrying a changed copy

Verification

The runner ran each check from the base copy against d157943:

  • scripts/check-changelog-fragments.sh --check: passed
  • scripts/check-changed-skills.sh --merge-base: passed

The run reports:

  • sync-shared-copies (scripts/sync-shared-copies.sh): regenerated 38 copies, exit 0
  • check-changelog-fragments: all 42 fragments valid
  • check-changed-skills: no changed skills, nothing to gate
  • check-affected: 13 passed, 6 skipped, 0 failed over 76 changed files (the first run failed shellcheck SC2154 on H_CTYPE_LC, assigned only through dc_lower's printf -v; fixed by putting H_CTYPE_LC="" in http_get's first reset)
  • fresh-context review subagent over the full diff: no behavior change or lint problem found (TDZ order of const isFile, H_CTYPE_LC read only when H_RC is 0, HERE not used by docs-cache.sh)
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/42612684223

Left out: the items under Not verified.

Related

#14329

Lane-Activity: work-resolve-issue/resolve-issue
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

claude-security-review reviewed d15794399d6c99b33f3a1f3faab5ac842f7bed34: read 76 of 76 changed file(s); 0 finding(s), 0 as inline comments.

Security review: PR #14615 (refactor of lib/exec-bash.mjs and lib/fetch-docs.sh)

No security issues found.

critical-findings: 0

Scope

I read the whole change of all seven distinct files: lib/exec-bash.mjs, lib/fetch-docs.sh, plugins/actionlint/hooks/exec-bash.mjs, plugins/attribution/scripts/fetch-docs.sh, and the three distinct changelog fragment bodies (actionlint, attribution, harness-ops). I skipped the other copies as identical.txt lists them. Each copy sits in the same role at its own plugin (hooks/exec-bash.mjs, scripts/fetch-docs.sh, .changes/<plugin>/*.md), so no copy's path changes what its content does. No changed file matches a TRUSTED PATHS glob. The diff changes no plugin manifest, workflow or trust control.

What I checked

  • Bash launcher candidate filtering (lib/exec-bash.mjs). After inlining shellBase, acceptBash still checks three things in the same order: the file exists, the basename is in the SHELL_NAMES allowlist, and a WSL relay is rejected on win32 (!(platform === "win32" && isWslRelay(p))). Rewriting firstExisting with find(...) ?? null and building the Windows Git candidates with flatMap keep the same order and the same result. Bash resolution accepts nothing it rejected before.
  • The orElse helper. Each DISK probe returns the same fallback when it throws as the old try/catch did (false, null, null, []). Moving isFile to a const creates no use before definition: every reference is inside a function body or a default parameter that runs at call time (lib/exec-bash.mjs:578 and :648), after line 343 has run.
  • literal(). value || null is the same as value ? value : null.
  • Docs fetcher reset in http_get (lib/fetch-docs.sh:385). The first reset now also clears H_CTYPE_LC. Nothing between that reset and the read -r H_STATUS H_EFF H_CTYPE at line 405 assigns any H_* variable, so dropping the second reset leaves no stale value behind. The PUBLIC_ONLY path is unchanged: url_parts, then pin, then --noproxy '*' --connect-to "::$PIN:". The curl call keeps --proto =https --proto-redir =https, so redirects are still limited to https.
  • HERE variable. DOCS_CACHE and CONVERTER resolve to the same paths as before. FETCH_DOCS_HTML2MD still takes precedence over the default converter path, as before.
  • resolve_python and the manifest write. The cached check still returns 0 only when the state is ok. The manifest write still dies when jq fails and when mv fails.

Pull request context

The description's claims match the diff. The pull request text contains no embedded instruction aimed at the review.

Spend: none. The change starts no new runs and touches no billing.

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

claude-review reviewed d15794399d6c99b33f3a1f3faab5ac842f7bed34: read 76 of 76 changed file(s); 0 finding(s), 0 as inline comments.

Code review: PR #14615, simplify lib/exec-bash.mjs and lib/fetch-docs.sh

Result: no findings. Every hunk in both source files keeps the old behavior.

What I read

  • The two source files, lib/exec-bash.mjs and lib/fetch-docs.sh.
  • The first regenerated copy of each: plugins/actionlint/hooks/exec-bash.mjs and plugins/attribution/scripts/fetch-docs.sh. Their hunks match the lib/ sources apart from line offsets.
  • The first file of each of the three changelog-fragment groups, as identical.txt lists them. All copies sit at the plugin's usual hooks/exec-bash.mjs, scripts/fetch-docs.sh or .changes/<plugin>/ path, so no copy's location changes what its content does.

Why each change keeps the old behavior

  • acceptBash: inlining shellBase and returning !(win32 && isWslRelay) gives the same result.
  • firstExisting: find(...) ?? null matches the old loop. acceptBash rejects falsy candidates, so a find that matches nothing still gives null.
  • literal: value || null is the same as value ? value : null.
  • orElse and DISK: each probe still takes one argument and gives the same fallback (false, null or []).
  • isFile changed from a hoisted function to a const:
    • Every use is inside a function body, a default parameter evaluated at call time (bpsSeed), or main().
    • main() runs only from the last line (L719), after the const is set at L343.
    • So nothing reads it before it is defined.
  • resolveBash: flatMap keeps the order of the candidate paths.
  • http_get: nothing between the first reset (L385) and read -r (L405) sets any H_* variable apart from H_RC, and the early pin/url_parts returns come after the reset. Dropping the second reset therefore changes nothing.
  • resolve_python: the script runs set -uo pipefail with no -e, and both callers use if. A bare return after [[ ]] gives the same status as before.
  • Manifest write: jq … || die then mv … || die takes the same two failure paths as the old if/else.
  • HERE: the PR says the sourced docs-cache.sh does not use HERE, and a grep confirmed it.

Closing issue #14329

  • Behavior unchanged: met, from reading the code. No flags, exported names or printed text changed.
  • Edits only the listed files and fragments: met. Two files are edited by hand; the rest are generated copies and patch fragments.
  • Within 400 lines and 15 hand-edited files: met.
  • Shared copies regenerated and committed: the copies I read match the lib/ sources.
  • ci-status green: not checked. This lane has no CI access, so it is left to the PR's checks.
  • Author-claimed, not checked by me: the PR body's test runs, shellcheck results and check-affected output. I ran no tests.

Other checks

  • Changelog fragments: every fragment uses bump: patch, which fits a refactor that keeps behavior.
  • Plugin manifests: none changed.
  • Path-scoped rules: .claude/rules/mod-authoring.md covers plugins/*/hooks/**, but exec-bash.mjs is a hook launcher, not a mods module, so nothing in it applies.
  • Embedded instructions: none found in the PR context.

@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 9, 2026
Merged via the queue into main with commit c6eb5b0 Nov 9, 2026
55 checks passed
@kyle-sexton
kyle-sexton deleted the work-resolve-issue/issue-14329-42612684223-1 branch November 9, 2026 13:29
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Post-merge mutation testing

Killed 0, survived 3, timeout 0, no coverage 0, invalid 0, not run 4.
Covered-code score 0%; mutation score 0%.

File Killed Survived Timeout No coverage Invalid Not run
lib/exec-bash.mjs 0 0 0 0 0 4
lib/fetch-docs.sh 0 3 0 0 0 0

Surviving mutants

Location Operator Disposition Cause
lib/fetch-docs.sh:385 SBR unclassified none
lib/fetch-docs.sh:658 ROR productive input-gap
lib/fetch-docs.sh:1037 SBR productive input-gap

The run's summary has the full report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Simplify the docs-raw.sh, exec-bash.mjs and fetch-docs.sh shared lib sources

1 participant