Refactor preflight() to skip/warn for missing fj/rg instead of hard-failing #168
Labels
No labels
bug
chore
documentation
enhancement
feature
ready
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
david/pi-extensions-and-skills#168
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Change
scripts/local-install.mjs'spreflight()so a missingrgbinary or an unusablefjno longer abort the whole install. Instead,preflight()prints an appropriate message and returns a tool-state object that later steps use to decide what to skip.Background
scripts/local-install.mjs'spreflight()currently contains two hard-fail blocks:fail(message)prints[install:local] Aborted: <message>and callsprocess.exit(1), terminating the entire install — including unrelated extensions likepostgres,forgejo,grillme, andvictorialogsthat have nothing to do withrgorfj.The desired behavior (per the agreed plan):
rgabsent from PATHrgextension only; print a skip message; do not abortfjabsent from PATHpr-commentsextension andforgejo-cliskill only; print a skip message; do not abortfjpresent butfj auth listfails/empty (unauthenticated)pr-comments+forgejo-clinormally; do not abortfjpresent and authenticatedThis does not touch the
extensions/forgejoextension (only needsFORGEJO_TOKEN, already warn-only and untouched) or any other extension/skill.Depends on: #167 (Add fj/rg tool-detection helpers (rgAvailable, detectFjState) with unit tests) — this step consumes
rgAvailable()anddetectFjState()from that step.Implementation Details
Remove the two hard-fail blocks shown above from
preflight(). Replace them with non-aborting branches using the detection helpers, and havepreflight()return a{ rgOk, fjState }object:Update
main()to capture and use the return value:Note: this issue only changes
preflight()'s control flow andmain()'s threading of the return value. It does NOT implement the settings.json filter rewrite indedupeAndRegister()or the dynamicreminder()output — those are separate, dependent steps that will consumetoolState. IfdedupeAndRegister()andreminder()don't yet accept a second/toolStateargument, add the parameter now as an unused pass-through so this step'smain()change doesn't break, and leave a// TODO: consumed by <next milestone>comment.Acceptance Criteria
preflight()no longer callsfail()for a missingrgbinary.preflight()no longer callsfail()for a missing or unauthenticatedfj.rgis absent,preflight()prints a message containing "rg binary not found on PATH" and "skipping the rg extension", and does not abort.fjis absent,preflight()prints a message containing "fj CLI not found on PATH" and mentions both "pr-comments" and "forgejo-cli", and does not abort.fjis present but unauthenticated,preflight()prints a message containing "not authenticated" and "fj auth login", and does not abort — and does NOT print the "skipping" message.fjandrgare fully available,preflight()prints neither warning and returns{ rgOk: true, fjState: "ok" }.preflight()returns{ rgOk, fjState }matching the detected state in all cases.main()capturespreflight()'s return value and passes it through todedupeAndRegister()andreminder()(even if those functions don't yet use it meaningfully).Test Plan
"preflight aborts when rg is missing"with a test assertingaborted === false, the new message substrings appear in stderr, and the returnedrgOk === false."preflight aborts when fj auth fails"and"preflight aborts when fj reports no authenticated accounts"with tests assertingaborted === false, the new unauthenticated-warning substrings appear, andfjState === "unauthenticated".withFj: false) →aborted === false, skip message present,fjState === "absent".fjandrgabsent simultaneously →aborted === false, both skip messages present,{ rgOk: false, fjState: "absent" }.aborted === false, no fj/rg-related warnings in stderr,{ rgOk: true, fjState: "ok" }.FORGEJO_TOKENwarn-only) all still pass unmodified.npm test— all green.pi-loop opened and merged a pull request for this issue: #177