|
1 | | -# Analysis: Feature Proposals & Implementations |
| 1 | +# Suggestions |
2 | 2 |
|
3 | | -## 💡 Standout Ideas and Incremental Enhancements |
| 3 | +## Incremental indexing resets status to "starting" |
4 | 4 |
|
5 | | -### 1. 🔄 Live Tracking for "Token Savings" & "Cost Avoided" |
6 | | -**Concept:** |
7 | | -- Instead of just calculating saved tokens per request ephemerally, maintain a global tracker (`~/.ragcode/savings.json`) that cumulatively stores `total_tokens_saved` across all sessions. |
8 | | -- Provide a feature that calculates the real-world USD value of the saved tokens based on standard LLM pricing (e.g., Claude 3.5 Sonnet token costs). |
9 | | -- Send this telemetry back to the AI under the MCP `_meta` response so the user directly sees the financial value RagCode generates (e.g., "RagCode saved you $42 this month"). |
| 5 | +Când se re-indexează incremental un singur fișier, `StartIndexingAsync` suprascrie statusul la `state: "starting"` cu totul de la zero, ștergând informația că 99% din index e deja acolo și funcțional. AI-ul vede `"starting"` + `"processed": 0` și crede că nu are date. |
10 | 6 |
|
11 | | -### 2. 🔄 O(1) Fetch via Byte Offsets |
12 | | -**Concept:** |
13 | | -- While extracting AST symbols, store exact `Byte Offsets` (start and end) in addition to Line Numbers. |
14 | | -- When `rag_read_file_context` is called, instead of reading the file line-by-line or using regex, perform a strict `seek()` operation to jump straight to the exact byte. This prevents loading massive files strictly into RAM. |
15 | | - |
16 | | -### 3. 🔄 Stable Symbol IDs |
17 | | -**Concept:** |
18 | | -- Expose fixed, semantic ID targets for every AST Node, such as `{file_path}::{qualified_name}#{kind}` (e.g., `pkg/parser/php/laravel/adapter.go::Parser.Extract#method`). |
19 | | -- Instead of searching, an Agent could request the direct structure of a known unique ID. |
20 | | - |
21 | | -### 5. 🔄 Active Symbol Summarization (During Indexing) |
22 | | -**Concept:** |
23 | | -- If a function or class lacks a Docstring, forward the chunk asynchronously to a cheap LLM (like Gemini Flash or Claude Haiku) *during* the indexing phase. |
24 | | -- Pre-generate a "One Line Summary" and embed that summary instead of the raw cryptic code. This drastically improves the semantic vector matching quality for poorly documented code. |
25 | | - |
26 | | ---- |
27 | | - |
28 | | -## 🤖 AI Agent Validated Implementations (Already Deployed) |
29 | | - |
30 | | -Based on rigorous real-world Agent usage, the following core features have been definitively implemented to drastically reduce LLM "decision fatigue". |
31 | | - |
32 | | -### 6. ✅ IMPLEMENTED — `rag_search`: Dual Search + Adaptive Response |
33 | | -**Status:** Deployed in `internal/service/tools/smart_search.go` |
34 | | - |
35 | | -**Challenge:** Agents used to guess between `mode: "exact"` and `"discovery"`. Even when they found results, pulling 5 full files instantly maxed out the context window. |
36 | | -**Solution:** |
37 | | -1. **Parallel Dual Search**: Executes `SearchCode` (Semantic Vector Qdrant) and `HybridSearchCode` (Exact Path/Substrings) simultaneously across Goroutines. |
38 | | -2. **Merging & Deduplication**: Vector IDs are matched, and results are tagged by provenance (`_source: "semantic" | "hybrid" | "both"`). |
39 | | -3. **Adaptive Formatting**: |
40 | | - - **Compact Mode**: If >4 results are found, returns only the signatures, paths, and scores (costs ~500 tokens). |
41 | | - - **Full Source**: Returns raw source code *only* for highly-confident, tight matches. |
42 | | - |
43 | | -### 7. ✅ IMPLEMENTED — Indexing Status & Health Metrics + Lazy Stale Cleanup |
44 | | -**Status:** Deployed across all `internal/service/tools/` endpoints. |
45 | | - |
46 | | -**Challenge:** Agents would search and hallucinate code that had actually been deleted by the user simply because the Qdrant index was stale. |
47 | | -**Solution:** |
48 | | -- **Pre-flight Disk Verification**: `rag_search` verifies `os.Stat` before returning matches. |
49 | | -- **Lazy Stale Cleanup**: Stale results are **filtered out** from the response (they never reach the AI). Additionally, the engine triggers an **async deletion** of all vectors for the stale file from every language collection in the workspace — a self-healing mechanism with a 10-minute dedup cooldown. |
50 | | -- **Auto-Cleanup Warning**: The response includes a `🧹 N stale file(s) detected and filtered out. Auto-cleanup triggered.` warning giving the AI full observability. |
51 | | -- **Chronological Awareness**: The response schema appends `index_age` (e.g., `"3 minutes ago"`) and `indexing_progress` strictly to maintain absolute validity. |
52 | | - |
53 | | -### 8. 🔄 PROPOSED — Migrate from `langchaingo` to Native Ollama Client |
54 | | -**Challenge:** Using `langchaingo` masks underlying context cancellations, causing deadlocks. |
55 | | -**Solution:** Replace it fully with the native `github.com/ollama/ollama/api` which provides direct HTTP keep-alive manipulation, native batch embedding capabilities, and proper Context Propagation timeouts. |
56 | | - |
57 | | -### 9. ✅ IMPLEMENTED — Smart Search Consolidation |
58 | | -**Challenge:** Agents suffered from "tool overwhelm" when attempting code searches. |
59 | | -**Solution:** Deprecated `rag_search_code` and moved everything explicitly to `rag_search`. Input schemas were simplified to `query` + `include_full_content` boolean overrides. |
60 | | - |
61 | | -### 10. ✅ IMPLEMENTED — Markdown Documentation Indexing |
62 | | -**Challenge:** The engine only understood codebase logic, completely blinding the AI to `README.md` architectural guidelines or implementation plans. |
63 | | -**Solution:** Integrated advanced hierarchical chunking (`MarkdownHeaderTextSplitter`) that natively indexes Headings, Tables, and Lists while keeping overlapping sliding windows for vectors. When an AI searches via `include_docs: true`, it searches the markdown chunks simultaneously with source code. |
64 | | - |
65 | | -### 11. ✅ IMPLEMENTED — Deep WordPress & WooCommerce Native Parsers |
66 | | -**Challenge:** The baseline PHP Tree-sitter AST parser could not navigate the massive WordPress hook ecosystem. |
67 | | -**Solution:** Created `pkg/parser/php/wordpress/`, a hyper-specialized sub-package that detects explicit CMS structures: |
68 | | -- Native extraction of **Hooks** (`add_action`, `add_filter`, `do_action`). |
69 | | -- Automatic identification of **Custom Post Types**, **Taxonomies**, and **Shortcodes**. |
70 | | -- **WooCommerce Integration**: Specifically isolates `woocommerce_` hooks and shopping cart overrides. |
71 | | -- **Oxygen Builder**: AST scanning for `extends OxyEl`, rendering layouts, and `ct_builder_json` dynamic components. |
| 7 | +Fix-ul corect ar fi: la indexare incrementală, nu reseta starea la `"starting"` — folosește ceva gen `"updating"` sau păstrează `"completed"` cu un sub-status. Dar asta e un issue separat, nu din PR review-ul curent. |
0 commit comments