-
-
Notifications
You must be signed in to change notification settings - Fork 59
Fixes #109 - Make pattern matching stricter when parsing for port #110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughReplaced broad, case-insensitive nREPL port-detection regex with a specific matcher for "nREPL server started on port\s{1,10}(\d+)"; removed other generic patterns while retaining explicit 4–5 digit extraction patterns like Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant Launcher as nREPL Launcher
participant Proc as Clojure Process
participant Parser as Port Parser
User->>Launcher: start()
Launcher->>Proc: spawn nREPL process
Proc-->>Launcher: stdout/stderr lines
Launcher->>Parser: parse(line)
alt matches specific "nREPL server started on port" or explicit 4–5 digit patterns
Note over Parser: Primary: /nREPL server started on port\s{1,10}(\d+)/\nFallbacks: /:(\d{4,5})/, /Started.*?(\d{4,5})/, /Listening.*?(\d{4,5})/
Parser-->>Launcher: port number
Launcher-->>User: return connected client
else no match (generic pattern removed)
Parser-->>Launcher: no port
Launcher-->>Proc: continue reading output
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Man all these regexes could be tighter... |
How about making it configurable and leave it to the user. or {:start-nrepl Or something along those lines? A bit less plug'n'play, but gives control to users. Could also combine with existing default parsing behavior... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/clojure_mcp/nrepl_launcher.clj
(1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
src/**/*.{clj,cljc}
📄 CodeRabbit inference engine (CLAUDE.md)
src/**/*.{clj,cljc}
: Use:require
with ns aliases for imports (e.g.,[clojure.string :as string]
)
Include clear tool:description
for LLM guidance
Validate inputs and provide helpful error messages in MCP tools
Return structured data with both result and error status in MCP tools
Maintain atom-based state for consistent service access in MCP tools
Files:
src/clojure_mcp/nrepl_launcher.clj
**/*.{clj,cljc}
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.{clj,cljc}
: Use kebab-case for vars/functions; end predicates with?
(e.g.,is-top-level-form?
)
Usetry/catch
with specific exception handling; use atom for tracking errors
Use 2-space indentation and maintain whitespace in edited forms
Align namespaces with directory structure (e.g.,clojure-mcp.repl-tools
)
Files:
src/clojure_mcp/nrepl_launcher.clj
🧠 Learnings (1)
📚 Learning: 2025-08-18T00:39:24.837Z
Learnt from: hugoduncan
PR: bhauman/clojure-mcp#86
File: src/clojure_mcp/subprocess.clj:0-0
Timestamp: 2025-08-18T00:39:24.837Z
Learning: In the clojure-mcp project, the user prefers to only parse stdout for nREPL port discovery in the subprocess.clj module, and explicitly does not want to parse stderr for port information.
Applied to files:
src/clojure_mcp/nrepl_launcher.clj
🔇 Additional comments (1)
src/clojure_mcp/nrepl_launcher.clj (1)
20-22
: Patterns passed initial false-positive tests but still need full verification.We ran these regexes against common non-port log entries (e.g., “Started batch job 45000”, “Listening to 30000 events”) and observed no matches. However, please validate against your complete logs and consider tightening each pattern with more context (for example,
#"Listening on port (\d{4,5})\b"
) or adopting the configurable parsing approach suggested by @gveres.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Thanks for starting this work @gveres! I've created PR #113 which builds on your changes with some additional improvements:
The new patterns pass all existing tests while preventing the FlowStorm false positive. Feel free to review #113 and let me know if you have any feedback! |
Closing this PR in favor of #113 which includes these changes plus additional improvements. Thank you for the initial work on this issue! |
See #109
Summary by CodeRabbit