feat: stateless nREPL port auto-discovery via process scanning - #21
Merged
Merged
Conversation
…tion Merge validate-nrepl-port and get-nrepl-cwd into a single gather-port-info function that reuses one TCP connection per port. Replace sequential reduce with pmap for parallel scanning. Lower socket timeout from 2000ms to 100ms since real nREPL servers respond in <5ms on localhost.
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.
Closes #20
Summary
When no
.nrepl-portfile,-pflag, orBREPL_PORTenv var is found, brepl now automatically discovers running nREPL servers by scanning OS processes. Zero configuration, fully stateless.How it works
lsofto find TCP ports listened on by Java/Clojure/Babashka processespmap)describeto confirm nREPL, thenevalto get the server's working directoryPort resolution order (updated)
-p <port>CLI argument.nrepl-portfile (walks up from file dir for-f)BREPL_PORTenvironment variablePerformance
Changes
src/brepl/lib/discovery.clj— new module:get-listening-ports,parse-lsof-output,gather-port-info,discover-nrepl-portsrc/brepl.clj—discover-nrepl-portadded as final fallback inresolve-port'sorchainREADME.md— documents process auto-discovery in Port Configuration sectionDesign decisions
user.dirmatches your CWD, it's a matchlsoffails or no matching port found, falls through to error messageInspired by clojure-mcp-light's discovery approach, with improvements: single-connection validation, parallel scanning via
pmap, IPv6-aware lsof parsing, and Clojure-side command filtering (no shellgrep).