feat: add filesystem, thinking, and structured reasoning tools#43
feat: add filesystem, thinking, and structured reasoning tools#43chhot2u wants to merge 7 commits intococoindex-io:mainfrom
Conversation
…rectory_tree) Add 4 new MCP tools for fast filesystem operations that complement the existing semantic search tool: - find_files: glob-based file discovery with language/path filters - read_file: direct file reading with optional line range - grep_code: regex text search with context lines - directory_tree: project structure listing Includes path traversal protection, binary file detection, excluded directory filtering, and 41 new tests covering all tools. All existing tests continue to pass.
Adds write_file MCP tool that creates or overwrites files within the codebase root. Features auto-creation of parent directories, 1 MB size limit, path traversal protection, and write-then-read roundtrip safety. Includes 9 new tests (65 total, all passing).
Adds edit_file MCP tool for surgical edits: finds old_string in a file and replaces with new_string. Requires unique match by default (safety), with replace_all option for bulk renames. Supports multiline strings, deletion (replace with empty), and insertion (replace anchor text). Includes 10 new tests (75 total, all passing).
|
Thanks for the PR! Can you elaborate when these tools are needed a little bit? I think most of them are already native capabilities of the coding agents like Claude Code. So in which cases we need the agent doing these through the MCP? |
…ing loop, RL) Add 6 new MCP tools for structured reasoning and self-improvement: - sequential_thinking: step-by-step problem solving with branching/revision - extended_thinking: deep analysis with automatic checkpoints - ultra_thinking: phased hypothesis generation, verification, synthesis - learning_loop: reflect on sessions and extract learnings to JSONL - self_improve: recommend strategies ranked by historical reward - reward_thinking: reinforcement learning feedback signals Includes ThinkingEngine with persistent memory, 31 new tests (119 total, all passing), and ruff-clean code.
|
Great question! Here's the breakdown: Filesystem Tools — Why MCP instead of native agent?You're right that Claude Code / Cursor etc. have native file ops. But not every MCP client does. cocoindex-code is designed to work with any MCP-compatible client (OpenCode, Continue, Zed, custom agents, etc.). The filesystem tools make it a self-contained codebase assistant — one MCP server gives you search + read + write + grep without depending on the client having those built in. Also, these tools are codebase-aware by default: they respect Example — agent using cocoindex-code to explore an unfamiliar codebase: Thinking Tools — What agents can't do nativelyThe thinking tools are not about basic chain-of-thought (which LLMs do naturally). They add three things agents can't do on their own: 1. Persistent learning across sessionsNative agents forget everything between conversations. The Example — RL loop over multiple sessions: 2. Structured hypothesis testing (ultra_thinking)Native LLMs mix exploration and verification in a single stream. Example — debugging a complex issue: 3. Long reasoning with checkpoints (extended_thinking)For deep analysis (50+ steps), native agents lose coherence. Example: TL;DR
|
…imator tools Add 4 new thinking tools with effort_mode (low/medium/high) support: - evidence_tracker: attach typed, weighted evidence to ultra_thinking hypotheses (code_ref, data_point, external, assumption, test_result) - premortem: structured pre-failure risk analysis with 5 phases (describe_plan, imagine_failure, identify_causes, rank_risks, mitigate) - inversion_thinking: Munger-style invert-then-reinvert reasoning with 6 phases (define_goal, invert, list_failure_causes, rank_causes, reinvert, action_plan) - effort_estimator: three-point PERT estimation with confidence intervals (68% CI at medium, 95% CI at high effort) Includes 53 new tests (159 total passing), all ruff-clean.
…mode support Add code_intelligence_tools (find_definition, find_references, list_symbols, code_metrics, rename_symbol, search) and patch_tools (apply_patch, large_write). Extend thinking_tools with plan_optimizer, effort_estimator, inversion_thinking, premortem, and evidence_tracker with configurable effort modes. Register all new tools in server. Add comprehensive tests.
Summary
find_files,read_file,write_file,edit_file,grep_code,directory_treesequential_thinking,extended_thinking,ultra_thinking,learning_loop,self_improve,reward_thinkingeffort_mode(low/medium/high) support:evidence_tracker— attach typed, weighted evidence to ultra_thinking hypothesespremortem— structured pre-failure risk analysis (5 phases)inversion_thinking— Munger-style invert-then-reinvert reasoning (6 phases)effort_estimator— three-point PERT estimation with confidence intervalsEffort Mode
All 4 new structured reasoning tools support an
effort_modeparameter:lowmediumhighTesting
Commits
01bd322— fast filesystem tools (find_files, read_file, grep_code, directory_tree)6c66601— write_file tool8286e5d— edit_file tool4c9c253— core thinking tools (sequential, extended, ultra, learning loop, RL)f5f57ec— evidence_tracker, premortem, inversion_thinking, effort_estimator with effort_mode