feat: add search learnings MCP tool#126
Conversation
📝 WalkthroughWalkthroughThis PR adds a ChangesLearnings MCP Feature
Estimated code review effort: 4 (Complex) | ~60 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
plugin/scripts/mcp-server.sh (1)
17-29: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueUnquoted command substitution in
forloop risks word-splitting on spaced$HOME.Line 19 uses unquoted
$(ls -dt ...)inside theforloop. If$HOMEcontains spaces, each path segment would be iterated separately, breaking the fallback search. This is a pre-existing pattern from_lib.sh, so the risk is low and consistent with the codebase, but quoting the expansion (e.g., viamapfile/read -ra) would make it robust.The shellcheck SC2093 warning on line 27 (
execinside a loop) is a false positive — theexecis an intentional process replacement for the redirect, not a loop continuation concern.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@plugin/scripts/mcp-server.sh` around lines 17 - 29, The fallback search in mcp-server.sh is vulnerable to word-splitting because the candidate list in the for loop is built from an unquoted command substitution, so paths with spaces in $HOME can break the scan. Update the loop setup around current_real, candidate_real, and claude_smart_plugin_python to iterate over a safely parsed list of candidate paths (for example by reading the ls output into an array before looping) while keeping the existing redirect logic and exec-based handoff unchanged.Source: Linters/SAST tools
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@plugin/scripts/mcp-server.sh`:
- Around line 17-29: The fallback search in mcp-server.sh is vulnerable to
word-splitting because the candidate list in the for loop is built from an
unquoted command substitution, so paths with spaces in $HOME can break the scan.
Update the loop setup around current_real, candidate_real, and
claude_smart_plugin_python to iterate over a safely parsed list of candidate
paths (for example by reading the ls output into an array before looping) while
keeping the existing redirect logic and exec-based handoff unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 85830657-869e-4520-b2d4-8cc4af0a1104
⛔ Files ignored due to path filters (1)
plugin/uv.lockis excluded by!**/*.lock
📒 Files selected for processing (29)
ARCHITECTURE.mdbin/claude-smart.jspackage.jsonplugin/.claude-plugin/plugin.jsonplugin/.codex-plugin/plugin.jsonplugin/.mcp.jsonplugin/README.mdplugin/hooks/codex-mcp.jsonplugin/hooks/hooks.jsonplugin/pyproject.tomlplugin/scripts/mcp-server.shplugin/skills/claude-smart/SKILL.mdplugin/src/README.mdplugin/src/claude_smart/context_format.pyplugin/src/claude_smart/context_inject.pyplugin/src/claude_smart/cs_cite.pyplugin/src/claude_smart/events/pre_tool.pyplugin/src/claude_smart/events/user_prompt.pyplugin/src/claude_smart/hook.pyplugin/src/claude_smart/learnings_search.pyplugin/src/claude_smart/mcp_server.pyplugin/src/claude_smart/query_compose.pyplugin/src/claude_smart/reflexio_adapter.pytests/test_codex_support.pytests/test_events.pytests/test_install_scripts.pytests/test_learnings_search.pytests/test_mcp_server.pytests/test_query_compose.py
💤 Files with no reviewable changes (6)
- plugin/src/claude_smart/events/pre_tool.py
- tests/test_query_compose.py
- plugin/hooks/hooks.json
- plugin/src/claude_smart/hook.py
- plugin/src/claude_smart/query_compose.py
- tests/test_events.py
Summary
search_learningsMCP tool.cwdfor learning search so results are scoped to the project the model is answering for.Changes
search_learningsMCP server plumbing, learned-state search adapter, and MCP manifests for Claude Code/Codex.cwdvalidation, package contents, cache refresh, durable registration, and launcher fallback.Test Plan
node --check bin/claude-smart.jsbash -n plugin/scripts/mcp-server.shgit diff --check origin/main...HEADuv run --project plugin pytest tests/test_install_scripts.py -q -k 'npm_pack_ignore_scripts_includes_learnings_mcp_files or node_install_refreshes_claude_cache_and_registers_learnings_mcp or node_update_retries_install_after_uninstall or mcp_server_redirects_unprepared_root_to_prepared_cache'uv run --project plugin pytest tests/test_mcp_server.py tests/test_learnings_search.py -qnpm pack --ignore-scripts --dry-run --jsonand verified MCP files are included while generated coverage artifacts are excluded.claude-smartfor Claude Code and Codex; verified direct MCPtools/list/tools/callfrom global, Claude cache, and Codex cache roots with an explicit absolutecwd.search_learnings, called it, and received relevant learning content.Summary by CodeRabbit
cwdvalidation, clearer empty/error vs unavailable handling).Follow-ups
bash, skip System32/WSL bash stubs, preserve that executable through launcher re-exec, and read~/.reflexio/plugin-root.txtas a fallback when symlink/junction metadata is unavailable.plugin-root.txtlauncher fallback.claude-smartfirst, then re-pin the enterprise submodule pointer to the mergedclaude-smartmain commit before merging enterprise.