Add AIHelper + filesystem query/smart_edit AI actions
AIHelper (navi/core/ai_helper.py):
- Reusable LLM utility for AI-enhanced tools: ask() and ask_json()
- Reads current_model ContextVar (set per-turn) so tools always use
  the session's active model without extra wiring
- Robust JSON extraction: strips markdown fences, bracket-matching fallback

current_model ContextVar (navi/tools/base.py):
- New ContextVar set by run_stream() and run_ephemeral() after profile
  is resolved; AIHelper reads it to pick the right model automatically

filesystem query action:
- Natural language question about any file, chunked at ~20k tokens of
  content (~80k chars) with 30-line overlap between chunks
- Single-chunk: one LLM call; multi-chunk: partial answers accumulated
  then synthesized in a final call

filesystem smart_edit action:
- Natural language edit instruction on files up to ~200k chars
- LLM outputs JSON patch ops: replace / delete / insert (1-based lines)
- Ops validated then applied bottom-up to preserve line numbers
- Returns unified diff of changes; preserves trailing newline

registry: AIHelper created once, OllamaBackend reused (no double init),
FilesystemTool receives ai_helper at construction

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 59cdf7f commit 533f9ee9f73ea03ec3d69dd9dc2b3822245c10a4
@Eugene Sukhodolskiy Eugene Sukhodolskiy authored on 16 Apr
Showing 5 changed files
View
navi/core/agent.py
View
navi/core/ai_helper.py 0 → 100644
View
navi/core/registry.py
View
navi/tools/base.py
View
navi/tools/filesystem.py