raggiecode 0.2.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- Agent/__init__.py +0 -0
- Agent/agent.py +891 -0
- Agent/chat_history_db.py +1500 -0
- Agent/command.py +49 -0
- Agent/config.py +46 -0
- Agent/effort_levels.py +33 -0
- Agent/git_manager.py +727 -0
- Agent/tools.py +35 -0
- Commands/__init__.py +18 -0
- Commands/effort.py +42 -0
- Commands/global_todo.py +23 -0
- Commands/help.py +22 -0
- Commands/reasoning.py +24 -0
- Commands/redo.py +11 -0
- Commands/reindex.py +27 -0
- Commands/shell.py +28 -0
- Commands/stream.py +24 -0
- Commands/undo.py +13 -0
- Commands/unlimited_effort.py +8 -0
- Commands/window_size.py +29 -0
- RAG/__init__.py +0 -0
- RAG/document.py +119 -0
- RAG/find.py +408 -0
- RAG/graph.py +231 -0
- Tools/GetFileCodeStructure.py +43 -0
- Tools/GetSymbolSourceCode.py +27 -0
- Tools/__init__.py +39 -0
- Tools/ask_user.py +102 -0
- Tools/dispatch_subagent.py +215 -0
- Tools/document.py +35 -0
- Tools/edit_symbol.py +250 -0
- Tools/fuzzy_search.py +119 -0
- Tools/list_dir.py +51 -0
- Tools/read.py +49 -0
- Tools/read_image.py +75 -0
- Tools/remove.py +75 -0
- Tools/replace.py +305 -0
- Tools/search.py +41 -0
- Tools/shell.py +149 -0
- Tools/shell_kill.py +87 -0
- Tools/temp_background_service.py +113 -0
- Tools/todo_list.py +481 -0
- Tools/utils.py +116 -0
- Tools/view_changes.py +179 -0
- Tools/walk_call_tree.py +30 -0
- Tools/web_fetch.py +175 -0
- Tools/web_search.py +69 -0
- Tools/write.py +48 -0
- cli.py +111 -0
- config/__init__.py +0 -0
- config/coder_system_prompt.md +119 -0
- config/roles.json +43 -0
- config/tools.json +709 -0
- indexing/__init__.py +0 -0
- indexing/cli.py +128 -0
- indexing/code_index_sdk.py +832 -0
- indexing/code_indexer.py +1763 -0
- indexing/db_schema.py +396 -0
- indexing/export_to_json.py +346 -0
- indexing/extractors.py +189 -0
- indexing/file_utils.py +97 -0
- indexing/frontend/__init__.py +0 -0
- indexing/frontend/css_extractor.py +195 -0
- indexing/frontend/css_parser.py +387 -0
- indexing/frontend/css_selector_utils.py +226 -0
- indexing/frontend/edit_safety.py +573 -0
- indexing/frontend/graph.py +838 -0
- indexing/frontend/html_extractor.py +496 -0
- indexing/frontend/html_parser.py +314 -0
- indexing/frontend/jsx_extractor.py +1204 -0
- indexing/frontend/location_lookup.py +247 -0
- indexing/frontend/resolver.py +485 -0
- indexing/frontend/runtime_resolver.py +862 -0
- indexing/frontend/semantic_output.py +705 -0
- indexing/frontend/source_location.py +69 -0
- indexing/frontend_config.py +72 -0
- indexing/frontend_models.py +347 -0
- indexing/language_config.py +360 -0
- indexing/models.py +284 -0
- indexing/node_utils.py +1112 -0
- indexing/parse_worker.py +1082 -0
- indexing/queries.py +1542 -0
- indexing/sdk_examples.py +426 -0
- interactive.py +248 -0
- raggie.py +673 -0
- raggiecode-0.2.1.dist-info/METADATA +944 -0
- raggiecode-0.2.1.dist-info/RECORD +93 -0
- raggiecode-0.2.1.dist-info/WHEEL +5 -0
- raggiecode-0.2.1.dist-info/entry_points.txt +2 -0
- raggiecode-0.2.1.dist-info/top_level.txt +10 -0
- skills/__init__.py +3 -0
- skills/manager.py +114 -0
- skills/tool.py +121 -0
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Source-location lookup for frontend semantic entities.
|
|
4
|
+
|
|
5
|
+
Given a file path, line, and column, returns the most specific frontend
|
|
6
|
+
semantic entity at that location. Queries all frontend tables for entities
|
|
7
|
+
whose source range contains the position, returning the narrowest matches
|
|
8
|
+
sorted by range width.
|
|
9
|
+
|
|
10
|
+
This is the core building block for "go-to-definition", "hover", and
|
|
11
|
+
runtime element resolution (Phase 9) features.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
import json
|
|
15
|
+
import sqlite3
|
|
16
|
+
from dataclasses import dataclass, field
|
|
17
|
+
from typing import List, Dict, Optional, Any
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@dataclass
|
|
21
|
+
class EntityMatch:
|
|
22
|
+
"""A single entity matched at a source location."""
|
|
23
|
+
|
|
24
|
+
entity_type: str
|
|
25
|
+
entity_id: int
|
|
26
|
+
file_id: int
|
|
27
|
+
file_path: str
|
|
28
|
+
source_range: Dict[str, int]
|
|
29
|
+
name: Optional[str] = None
|
|
30
|
+
extra: Dict[str, Any] = field(default_factory=dict)
|
|
31
|
+
|
|
32
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
33
|
+
d = {
|
|
34
|
+
"entity_type": self.entity_type,
|
|
35
|
+
"entity_id": self.entity_id,
|
|
36
|
+
"file_id": self.file_id,
|
|
37
|
+
"file_path": self.file_path,
|
|
38
|
+
"source_range": self.source_range,
|
|
39
|
+
"name": self.name,
|
|
40
|
+
}
|
|
41
|
+
d.update(self.extra)
|
|
42
|
+
return d
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def _parse_range(raw: Optional[str]) -> Optional[Dict[str, int]]:
|
|
46
|
+
"""Parse a JSON source_range or location column value."""
|
|
47
|
+
if not raw:
|
|
48
|
+
return None
|
|
49
|
+
try:
|
|
50
|
+
r = json.loads(raw)
|
|
51
|
+
if "start_line" not in r:
|
|
52
|
+
return None
|
|
53
|
+
return r
|
|
54
|
+
except (json.JSONDecodeError, TypeError):
|
|
55
|
+
return None
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def _range_contains(r: Dict[str, int], line: int, column: int) -> bool:
|
|
59
|
+
"""Check if a 1-indexed line/column falls within the given source range."""
|
|
60
|
+
sl = r.get("start_line", 0)
|
|
61
|
+
sc = r.get("start_column", 0)
|
|
62
|
+
el = r.get("end_line", 0)
|
|
63
|
+
ec = r.get("end_column", 0)
|
|
64
|
+
|
|
65
|
+
if line < sl or line > el:
|
|
66
|
+
return False
|
|
67
|
+
if line == sl and column < sc:
|
|
68
|
+
return False
|
|
69
|
+
if line == el and column >= ec:
|
|
70
|
+
return False
|
|
71
|
+
return True
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def _range_width(r: Dict[str, int]) -> int:
|
|
75
|
+
"""Compute a rough width metric for sorting by narrowness."""
|
|
76
|
+
sl = r.get("start_line", 0)
|
|
77
|
+
sc = r.get("start_column", 0)
|
|
78
|
+
el = r.get("end_line", 0)
|
|
79
|
+
ec = r.get("end_column", 0)
|
|
80
|
+
return (el - sl) * 10000 + (ec - sc)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
# Table configurations: (table_name, entity_type_label, name_column, extra_columns)
|
|
84
|
+
# Ordered roughly from most specific (attributes/bindings) to broadest (components)
|
|
85
|
+
_FRONTEND_TABLES = [
|
|
86
|
+
{
|
|
87
|
+
"table": "frontend_events",
|
|
88
|
+
"type": "event_binding",
|
|
89
|
+
"name_col": "event_name",
|
|
90
|
+
"extra_cols": ["handler_type", "handler_expression", "resolution_status", "element_id"],
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"table": "frontend_bindings",
|
|
94
|
+
"type": "property_binding",
|
|
95
|
+
"name_col": "binding_name",
|
|
96
|
+
"extra_cols": ["binding_type", "binding_expression", "resolution_status", "element_id"],
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"table": "style_custom_properties",
|
|
100
|
+
"type": "custom_property",
|
|
101
|
+
"name_col": "name",
|
|
102
|
+
"extra_cols": ["value", "scope_selector"],
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"table": "style_custom_property_usages",
|
|
106
|
+
"type": "custom_property_usage",
|
|
107
|
+
"name_col": "property_name",
|
|
108
|
+
"extra_cols": ["resolved_property_id", "selector_id"],
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"table": "style_selectors",
|
|
112
|
+
"type": "style_selector",
|
|
113
|
+
"name_col": "selector_text",
|
|
114
|
+
"extra_cols": ["selector_type", "normalized_selector", "is_scoped"],
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
"table": "style_keyframes",
|
|
118
|
+
"type": "keyframes",
|
|
119
|
+
"name_col": "name",
|
|
120
|
+
"extra_cols": [],
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
"table": "style_imports",
|
|
124
|
+
"type": "style_import",
|
|
125
|
+
"name_col": "import_path",
|
|
126
|
+
"extra_cols": ["is_external", "resolved_file_id"],
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
"table": "markup_elements",
|
|
130
|
+
"type": "markup_element",
|
|
131
|
+
"name_col": "tag_name",
|
|
132
|
+
"extra_cols": ["element_type", "element_id_attr", "component_id", "parent_element_id"],
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
"table": "frontend_components",
|
|
136
|
+
"type": "component",
|
|
137
|
+
"name_col": "name",
|
|
138
|
+
"extra_cols": ["framework", "is_exported", "impl_function_id", "impl_class_id"],
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
"table": "frontend_diagnostics",
|
|
142
|
+
"type": "diagnostic",
|
|
143
|
+
"name_col": "diagnostic_type",
|
|
144
|
+
"extra_cols": ["severity", "message"],
|
|
145
|
+
},
|
|
146
|
+
]
|
|
147
|
+
|
|
148
|
+
# Backend tables that also have location data (for completeness)
|
|
149
|
+
_BACKEND_TABLES = [
|
|
150
|
+
{
|
|
151
|
+
"table": "functions",
|
|
152
|
+
"type": "executable_symbol",
|
|
153
|
+
"name_col": "name",
|
|
154
|
+
"range_col": "location",
|
|
155
|
+
"extra_cols": ["type", "parent_type"],
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
"table": "classes",
|
|
159
|
+
"type": "executable_symbol",
|
|
160
|
+
"name_col": "name",
|
|
161
|
+
"range_col": "location",
|
|
162
|
+
"extra_cols": [],
|
|
163
|
+
},
|
|
164
|
+
]
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
def lookup_entity_at_location(
|
|
168
|
+
conn: sqlite3.Connection,
|
|
169
|
+
file_path: str,
|
|
170
|
+
line: int,
|
|
171
|
+
column: int,
|
|
172
|
+
include_backend: bool = False,
|
|
173
|
+
) -> List[EntityMatch]:
|
|
174
|
+
"""Find the most specific frontend semantic entity at a source location.
|
|
175
|
+
|
|
176
|
+
Args:
|
|
177
|
+
conn: SQLite connection to the index database.
|
|
178
|
+
file_path: Project-relative path of the file to look up.
|
|
179
|
+
line: 1-indexed line number.
|
|
180
|
+
column: 0-indexed column number (consistent with tree-sitter columns).
|
|
181
|
+
include_backend: If True, also search functions/classes tables.
|
|
182
|
+
|
|
183
|
+
Returns:
|
|
184
|
+
List of EntityMatch objects sorted by narrowest range first.
|
|
185
|
+
Empty list if no entity contains the location or file is not found.
|
|
186
|
+
"""
|
|
187
|
+
cursor = conn.cursor()
|
|
188
|
+
|
|
189
|
+
# Resolve file_path to file_id
|
|
190
|
+
cursor.execute("SELECT id, path FROM files WHERE path = ?", (file_path,))
|
|
191
|
+
row = cursor.fetchone()
|
|
192
|
+
if row is None:
|
|
193
|
+
return []
|
|
194
|
+
|
|
195
|
+
file_id, resolved_path = row[0], row[1]
|
|
196
|
+
|
|
197
|
+
matches: List[EntityMatch] = []
|
|
198
|
+
|
|
199
|
+
table_configs = list(_FRONTEND_TABLES)
|
|
200
|
+
if include_backend:
|
|
201
|
+
table_configs.extend(_BACKEND_TABLES)
|
|
202
|
+
|
|
203
|
+
for cfg in table_configs:
|
|
204
|
+
table = cfg["table"]
|
|
205
|
+
range_col = cfg.get("range_col", "source_range")
|
|
206
|
+
name_col = cfg["name_col"]
|
|
207
|
+
extra_cols = cfg.get("extra_cols", [])
|
|
208
|
+
entity_type = cfg["type"]
|
|
209
|
+
|
|
210
|
+
cols = [range_col, name_col] + extra_cols
|
|
211
|
+
col_list = ", ".join(cols)
|
|
212
|
+
|
|
213
|
+
cursor.execute(
|
|
214
|
+
f"SELECT id, {col_list} FROM {table} WHERE file_id = ?",
|
|
215
|
+
(file_id,)
|
|
216
|
+
)
|
|
217
|
+
rows = cursor.fetchall()
|
|
218
|
+
|
|
219
|
+
for row in rows:
|
|
220
|
+
entity_id = row[0]
|
|
221
|
+
raw_range = row[1]
|
|
222
|
+
name = row[2]
|
|
223
|
+
extra_values = row[3:]
|
|
224
|
+
|
|
225
|
+
r = _parse_range(raw_range)
|
|
226
|
+
if r is None:
|
|
227
|
+
continue
|
|
228
|
+
|
|
229
|
+
if _range_contains(r, line, column):
|
|
230
|
+
extra = {}
|
|
231
|
+
for i, col_name in enumerate(extra_cols):
|
|
232
|
+
extra[col_name] = extra_values[i]
|
|
233
|
+
|
|
234
|
+
matches.append(EntityMatch(
|
|
235
|
+
entity_type=entity_type,
|
|
236
|
+
entity_id=entity_id,
|
|
237
|
+
file_id=file_id,
|
|
238
|
+
file_path=resolved_path,
|
|
239
|
+
source_range=r,
|
|
240
|
+
name=name,
|
|
241
|
+
extra=extra,
|
|
242
|
+
))
|
|
243
|
+
|
|
244
|
+
# Sort by narrowest range first
|
|
245
|
+
matches.sort(key=lambda m: _range_width(m.source_range))
|
|
246
|
+
|
|
247
|
+
return matches
|