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,360 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Language configuration for code indexer.
|
|
3
|
+
Maps languages to their file extensions, tree-sitter grammars, and node types.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
# Language imports
|
|
7
|
+
try:
|
|
8
|
+
from tree_sitter_python import language as python_language
|
|
9
|
+
except ImportError:
|
|
10
|
+
python_language = None
|
|
11
|
+
|
|
12
|
+
try:
|
|
13
|
+
from tree_sitter_go import language as go_language
|
|
14
|
+
except ImportError:
|
|
15
|
+
go_language = None
|
|
16
|
+
|
|
17
|
+
try:
|
|
18
|
+
from tree_sitter_language_pack import get_language as csharp_language_pack
|
|
19
|
+
|
|
20
|
+
c_sharp_language = csharp_language_pack("csharp")
|
|
21
|
+
except ImportError:
|
|
22
|
+
c_sharp_language = None
|
|
23
|
+
|
|
24
|
+
try:
|
|
25
|
+
from tree_sitter_language_pack import get_language as javascript_language_pack
|
|
26
|
+
|
|
27
|
+
javascript_language = javascript_language_pack("javascript")
|
|
28
|
+
except ImportError:
|
|
29
|
+
javascript_language = None
|
|
30
|
+
|
|
31
|
+
try:
|
|
32
|
+
from tree_sitter_language_pack import get_language as typescript_language_pack
|
|
33
|
+
|
|
34
|
+
typescript_language = typescript_language_pack("typescript")
|
|
35
|
+
except ImportError:
|
|
36
|
+
typescript_language = None
|
|
37
|
+
|
|
38
|
+
try:
|
|
39
|
+
from tree_sitter_language_pack import get_language as tsx_language_pack
|
|
40
|
+
|
|
41
|
+
tsx_language = tsx_language_pack("tsx")
|
|
42
|
+
except ImportError:
|
|
43
|
+
tsx_language = None
|
|
44
|
+
|
|
45
|
+
try:
|
|
46
|
+
from tree_sitter_rust import language as rust_language
|
|
47
|
+
except ImportError:
|
|
48
|
+
rust_language = None
|
|
49
|
+
|
|
50
|
+
try:
|
|
51
|
+
from tree_sitter_zig import language as zig_language
|
|
52
|
+
except ImportError:
|
|
53
|
+
zig_language = None
|
|
54
|
+
|
|
55
|
+
try:
|
|
56
|
+
from tree_sitter_elixir import language as elixir_language
|
|
57
|
+
except ImportError:
|
|
58
|
+
elixir_language = None
|
|
59
|
+
|
|
60
|
+
try:
|
|
61
|
+
from tree_sitter_cpp import language as cpp_language
|
|
62
|
+
except ImportError:
|
|
63
|
+
cpp_language = None
|
|
64
|
+
|
|
65
|
+
try:
|
|
66
|
+
from tree_sitter_c import language as c_language
|
|
67
|
+
except ImportError:
|
|
68
|
+
c_language = None
|
|
69
|
+
|
|
70
|
+
try:
|
|
71
|
+
from tree_sitter_php import language_php as php_language
|
|
72
|
+
except ImportError:
|
|
73
|
+
php_language = None
|
|
74
|
+
|
|
75
|
+
try:
|
|
76
|
+
from tree_sitter_language_pack import get_language as dart_language_pack
|
|
77
|
+
|
|
78
|
+
dart_language = dart_language_pack("dart")
|
|
79
|
+
except ImportError:
|
|
80
|
+
dart_language = None
|
|
81
|
+
|
|
82
|
+
try:
|
|
83
|
+
from tree_sitter_language_pack import get_language as java_language_pack
|
|
84
|
+
|
|
85
|
+
java_language = java_language_pack("java")
|
|
86
|
+
except ImportError:
|
|
87
|
+
java_language = None
|
|
88
|
+
|
|
89
|
+
try:
|
|
90
|
+
from tree_sitter_language_pack import get_language as kotlin_language_pack
|
|
91
|
+
|
|
92
|
+
kotlin_language = kotlin_language_pack("kotlin")
|
|
93
|
+
except ImportError:
|
|
94
|
+
kotlin_language = None
|
|
95
|
+
|
|
96
|
+
try:
|
|
97
|
+
from tree_sitter_language_pack import get_language as html_language_pack
|
|
98
|
+
|
|
99
|
+
html_language = html_language_pack("html")
|
|
100
|
+
except ImportError:
|
|
101
|
+
html_language = None
|
|
102
|
+
|
|
103
|
+
try:
|
|
104
|
+
from tree_sitter_language_pack import get_language as css_language_pack
|
|
105
|
+
|
|
106
|
+
css_language = css_language_pack("css")
|
|
107
|
+
except ImportError:
|
|
108
|
+
css_language = None
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
LANGUAGE_CONFIG = {
|
|
112
|
+
"python": {
|
|
113
|
+
"extensions": [".py"],
|
|
114
|
+
"language_module": python_language,
|
|
115
|
+
"node_types": {
|
|
116
|
+
"function": ["function_definition"],
|
|
117
|
+
"class": ["class_definition"],
|
|
118
|
+
"assignment": ["assignment"],
|
|
119
|
+
"type_alias": ["type_alias"],
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
"go": {
|
|
123
|
+
"extensions": [".go"],
|
|
124
|
+
"language_module": go_language,
|
|
125
|
+
"node_types": {
|
|
126
|
+
"function": ["function_declaration", "method_declaration"],
|
|
127
|
+
"class": None,
|
|
128
|
+
"struct": ["type_declaration"],
|
|
129
|
+
"interface": ["type_declaration"],
|
|
130
|
+
"method": ["method_declaration"],
|
|
131
|
+
"assignment": ["assignment_statement", "short_var_declaration"],
|
|
132
|
+
"type_alias": ["type_declaration"],
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
"csharp": {
|
|
136
|
+
"extensions": [".cs"],
|
|
137
|
+
"language_module": c_sharp_language,
|
|
138
|
+
"node_types": {
|
|
139
|
+
"function": ["method_declaration", "constructor_declaration"],
|
|
140
|
+
"class": ["class_declaration", "record_declaration", "record_struct_declaration"],
|
|
141
|
+
"assignment": ["assignment_expression"],
|
|
142
|
+
"type_alias": None,
|
|
143
|
+
"public_field": [
|
|
144
|
+
"property_declaration",
|
|
145
|
+
"event_declaration",
|
|
146
|
+
"event_field_declaration",
|
|
147
|
+
],
|
|
148
|
+
"interface": ["interface_declaration"],
|
|
149
|
+
"struct": ["struct_declaration"],
|
|
150
|
+
"enum": ["enum_declaration"],
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
"javascript": {
|
|
154
|
+
"extensions": [".js", ".jsx"],
|
|
155
|
+
"language_module": javascript_language,
|
|
156
|
+
"node_types": {
|
|
157
|
+
"function": [
|
|
158
|
+
"function_declaration",
|
|
159
|
+
"generator_function_declaration",
|
|
160
|
+
"method_definition",
|
|
161
|
+
],
|
|
162
|
+
"class": ["class_declaration"],
|
|
163
|
+
"assignment": ["assignment_expression", "lexical_declaration", "variable_declaration"],
|
|
164
|
+
"type_alias": None,
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
"typescript": {
|
|
168
|
+
"extensions": [".ts"],
|
|
169
|
+
"language_module": typescript_language,
|
|
170
|
+
"node_types": {
|
|
171
|
+
"function": ["function_declaration"],
|
|
172
|
+
"class": ["class_declaration", "abstract_class_declaration"],
|
|
173
|
+
"interface": ["interface_declaration"],
|
|
174
|
+
"assignment": ["assignment_expression", "lexical_declaration", "variable_declaration"],
|
|
175
|
+
"type_alias": ["type_alias_declaration"],
|
|
176
|
+
"method": ["method_definition"],
|
|
177
|
+
"public_field": ["public_field_definition"],
|
|
178
|
+
"enum": ["enum_declaration"],
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
"tsx": {
|
|
182
|
+
"extensions": [".tsx"],
|
|
183
|
+
"language_module": tsx_language,
|
|
184
|
+
"node_types": {
|
|
185
|
+
"function": ["function_declaration"],
|
|
186
|
+
"class": ["class_declaration", "abstract_class_declaration"],
|
|
187
|
+
"interface": ["interface_declaration"],
|
|
188
|
+
"assignment": ["assignment_expression"],
|
|
189
|
+
"type_alias": ["type_alias_declaration"],
|
|
190
|
+
"method": ["method_definition"],
|
|
191
|
+
"public_field": ["public_field_definition"],
|
|
192
|
+
"enum": ["enum_declaration"],
|
|
193
|
+
},
|
|
194
|
+
},
|
|
195
|
+
"rust": {
|
|
196
|
+
"extensions": [".rs"],
|
|
197
|
+
"language_module": rust_language,
|
|
198
|
+
"node_types": {
|
|
199
|
+
"function": ["function_item"],
|
|
200
|
+
"class": None,
|
|
201
|
+
"struct": ["struct_item"],
|
|
202
|
+
"enum": ["enum_item"],
|
|
203
|
+
"interface": ["trait_item"],
|
|
204
|
+
"assignment": ["let_declaration"],
|
|
205
|
+
"type_alias": ["type_item"],
|
|
206
|
+
},
|
|
207
|
+
},
|
|
208
|
+
"zig": {
|
|
209
|
+
"extensions": [".zig"],
|
|
210
|
+
"language_module": zig_language,
|
|
211
|
+
"node_types": {
|
|
212
|
+
"function": ["function_declaration"],
|
|
213
|
+
"class": None,
|
|
214
|
+
"assignment": ["variable_declaration"],
|
|
215
|
+
"type_alias": None,
|
|
216
|
+
},
|
|
217
|
+
},
|
|
218
|
+
"elixir": {
|
|
219
|
+
"extensions": [".ex", ".exs"],
|
|
220
|
+
"language_module": elixir_language,
|
|
221
|
+
"node_types": {
|
|
222
|
+
"function": None,
|
|
223
|
+
"class": None,
|
|
224
|
+
"assignment": ["binary_operator"],
|
|
225
|
+
"type_alias": None,
|
|
226
|
+
},
|
|
227
|
+
},
|
|
228
|
+
"cpp": {
|
|
229
|
+
"extensions": [".cpp", ".cc", ".cxx", ".hpp", ".h", ".hxx"],
|
|
230
|
+
"language_module": cpp_language,
|
|
231
|
+
"node_types": {
|
|
232
|
+
"function": ["function_definition"],
|
|
233
|
+
"class": ["class_specifier", "struct_specifier"],
|
|
234
|
+
"struct": ["struct_specifier"],
|
|
235
|
+
"enum": ["enum_specifier"],
|
|
236
|
+
"assignment": ["assignment_expression"],
|
|
237
|
+
"type_alias": ["type_alias_declaration", "alias_declaration"],
|
|
238
|
+
},
|
|
239
|
+
},
|
|
240
|
+
"c": {
|
|
241
|
+
"extensions": [".c", ".h"],
|
|
242
|
+
"language_module": c_language,
|
|
243
|
+
"node_types": {
|
|
244
|
+
"function": ["function_definition"],
|
|
245
|
+
"class": None,
|
|
246
|
+
"struct": ["struct_specifier"],
|
|
247
|
+
"enum": ["enum_specifier"],
|
|
248
|
+
"assignment": ["declaration"],
|
|
249
|
+
"type_alias": ["type_definition"],
|
|
250
|
+
},
|
|
251
|
+
},
|
|
252
|
+
"php": {
|
|
253
|
+
"extensions": [".php"],
|
|
254
|
+
"language_module": php_language,
|
|
255
|
+
"node_types": {
|
|
256
|
+
"function": ["function_definition", "method_declaration"],
|
|
257
|
+
"class": ["class_declaration"],
|
|
258
|
+
"interface": ["interface_declaration"],
|
|
259
|
+
"assignment": ["assignment_expression"],
|
|
260
|
+
"type_alias": None,
|
|
261
|
+
},
|
|
262
|
+
},
|
|
263
|
+
"dart": {
|
|
264
|
+
"extensions": [".dart"],
|
|
265
|
+
"language_module": dart_language,
|
|
266
|
+
"node_types": {
|
|
267
|
+
"function": [
|
|
268
|
+
"function_signature",
|
|
269
|
+
"getter_signature",
|
|
270
|
+
"setter_signature",
|
|
271
|
+
"constructor_signature",
|
|
272
|
+
"method_signature",
|
|
273
|
+
],
|
|
274
|
+
"class": ["class_definition", "mixin_declaration", "extension_declaration"],
|
|
275
|
+
"assignment": ["assignment_expression"],
|
|
276
|
+
"type_alias": ["type_alias"],
|
|
277
|
+
},
|
|
278
|
+
},
|
|
279
|
+
"java": {
|
|
280
|
+
"extensions": [".java"],
|
|
281
|
+
"language_module": java_language,
|
|
282
|
+
"node_types": {
|
|
283
|
+
"function": ["method_declaration", "constructor_declaration"],
|
|
284
|
+
"class": ["class_declaration", "record_declaration", "annotation_type_declaration"],
|
|
285
|
+
"interface": ["interface_declaration"],
|
|
286
|
+
"enum": ["enum_declaration"],
|
|
287
|
+
"assignment": ["assignment_expression"],
|
|
288
|
+
"type_alias": None,
|
|
289
|
+
},
|
|
290
|
+
},
|
|
291
|
+
"kotlin": {
|
|
292
|
+
"extensions": [".kt", ".kts"],
|
|
293
|
+
"language_module": kotlin_language,
|
|
294
|
+
"node_types": {
|
|
295
|
+
"function": ["function_declaration"],
|
|
296
|
+
"class": ["class_declaration", "object_declaration"],
|
|
297
|
+
"assignment": ["assignment"],
|
|
298
|
+
"type_alias": ["type_alias"],
|
|
299
|
+
},
|
|
300
|
+
},
|
|
301
|
+
"html": {
|
|
302
|
+
"extensions": [".html", ".htm"],
|
|
303
|
+
"language_module": html_language,
|
|
304
|
+
"node_types": {
|
|
305
|
+
"element": ["element", "void_element"],
|
|
306
|
+
"text": ["text"],
|
|
307
|
+
"script_element": ["script_element"],
|
|
308
|
+
"style_element": ["style_element"],
|
|
309
|
+
},
|
|
310
|
+
},
|
|
311
|
+
"css": {
|
|
312
|
+
"extensions": [".css"],
|
|
313
|
+
"language_module": css_language,
|
|
314
|
+
"node_types": {
|
|
315
|
+
"rule_set": ["rule_set"],
|
|
316
|
+
"selectors": ["selectors"],
|
|
317
|
+
"block": ["block"],
|
|
318
|
+
"declaration": ["declaration"],
|
|
319
|
+
"import_statement": ["import_statement"],
|
|
320
|
+
"keyframes_statement": ["keyframes_statement"],
|
|
321
|
+
},
|
|
322
|
+
},
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
def get_language_for_extension(file_extension):
|
|
327
|
+
"""Get language name for a given file extension."""
|
|
328
|
+
file_ext = file_extension.lower()
|
|
329
|
+
for lang, config in LANGUAGE_CONFIG.items():
|
|
330
|
+
if file_ext in config["extensions"]:
|
|
331
|
+
return lang
|
|
332
|
+
return None
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
def get_extensions_for_languages(languages):
|
|
336
|
+
"""Get all file extensions for a list of languages."""
|
|
337
|
+
extensions = set()
|
|
338
|
+
for lang in languages:
|
|
339
|
+
if lang in LANGUAGE_CONFIG:
|
|
340
|
+
extensions.update(LANGUAGE_CONFIG[lang]["extensions"])
|
|
341
|
+
return extensions
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
def is_language_available(language):
|
|
345
|
+
"""Check if a language's tree-sitter grammar is available."""
|
|
346
|
+
if language not in LANGUAGE_CONFIG:
|
|
347
|
+
return False
|
|
348
|
+
return LANGUAGE_CONFIG[language]["language_module"] is not None
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
def get_available_languages():
|
|
352
|
+
"""Get list of languages with available grammars."""
|
|
353
|
+
return [lang for lang in LANGUAGE_CONFIG.keys() if is_language_available(lang)]
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
def get_node_types(language):
|
|
357
|
+
"""Get node type mapping for a language."""
|
|
358
|
+
if language in LANGUAGE_CONFIG:
|
|
359
|
+
return LANGUAGE_CONFIG[language]["node_types"]
|
|
360
|
+
return {}
|
indexing/models.py
ADDED
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Data models for the Code Index SDK.
|
|
4
|
+
Dataclasses representing code entities stored in the SQLite index.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import json
|
|
8
|
+
import sqlite3
|
|
9
|
+
from typing import List, Dict, Optional
|
|
10
|
+
from dataclasses import dataclass
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@dataclass
|
|
14
|
+
class Location:
|
|
15
|
+
"""Source code location."""
|
|
16
|
+
start_line: int
|
|
17
|
+
start_column: int
|
|
18
|
+
end_line: int
|
|
19
|
+
end_column: int
|
|
20
|
+
start_byte: Optional[int] = None
|
|
21
|
+
end_byte: Optional[int] = None
|
|
22
|
+
|
|
23
|
+
@classmethod
|
|
24
|
+
def from_dict(cls, data: Dict) -> 'Location':
|
|
25
|
+
known = {f.name for f in cls.__dataclass_fields__.values()}
|
|
26
|
+
return cls(**{k: v for k, v in data.items() if k in known})
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
@dataclass
|
|
30
|
+
class Function:
|
|
31
|
+
"""Function or method definition."""
|
|
32
|
+
id: int
|
|
33
|
+
name: str
|
|
34
|
+
type: str # 'function' or 'method'
|
|
35
|
+
file_id: int
|
|
36
|
+
file_path: str
|
|
37
|
+
location: Location
|
|
38
|
+
parameters: List[Dict]
|
|
39
|
+
return_type: Optional[str]
|
|
40
|
+
docstring: Optional[str]
|
|
41
|
+
description: Optional[str] = None
|
|
42
|
+
receiver: Optional[str] = None
|
|
43
|
+
parent_id: Optional[int] = None
|
|
44
|
+
parent_type: Optional[str] = None
|
|
45
|
+
branch_count: int = 0
|
|
46
|
+
|
|
47
|
+
@classmethod
|
|
48
|
+
def from_row(cls, row: sqlite3.Row, file_path: str) -> 'Function':
|
|
49
|
+
return cls(
|
|
50
|
+
id=row['id'],
|
|
51
|
+
name=row['name'],
|
|
52
|
+
type=row['type'],
|
|
53
|
+
file_id=row['file_id'],
|
|
54
|
+
file_path=file_path,
|
|
55
|
+
location=Location.from_dict(json.loads(row['location'])),
|
|
56
|
+
parameters=json.loads(row['parameters']),
|
|
57
|
+
return_type=row['return_type'],
|
|
58
|
+
docstring=row['docstring'],
|
|
59
|
+
description=row['description'] if 'description' in row.keys() else None,
|
|
60
|
+
receiver=row['receiver'],
|
|
61
|
+
parent_id=row['parent_id'],
|
|
62
|
+
parent_type=row['parent_type'],
|
|
63
|
+
branch_count=row['branch_count'] if 'branch_count' in row.keys() else 0
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
@dataclass
|
|
68
|
+
class Class:
|
|
69
|
+
"""Class definition."""
|
|
70
|
+
id: int
|
|
71
|
+
name: str
|
|
72
|
+
file_id: int
|
|
73
|
+
file_path: str
|
|
74
|
+
location: Location
|
|
75
|
+
base_classes: List[str]
|
|
76
|
+
docstring: Optional[str]
|
|
77
|
+
description: Optional[str] = None
|
|
78
|
+
parent_id: Optional[int] = None
|
|
79
|
+
namespace: Optional[str] = None
|
|
80
|
+
|
|
81
|
+
@classmethod
|
|
82
|
+
def from_row(cls, row: sqlite3.Row, file_path: str) -> 'Class':
|
|
83
|
+
return cls(
|
|
84
|
+
id=row['id'],
|
|
85
|
+
name=row['name'],
|
|
86
|
+
file_id=row['file_id'],
|
|
87
|
+
file_path=file_path,
|
|
88
|
+
location=Location.from_dict(json.loads(row['location'])),
|
|
89
|
+
base_classes=json.loads(row['base_classes']),
|
|
90
|
+
docstring=row['docstring'],
|
|
91
|
+
description=row['description'] if 'description' in row.keys() else None,
|
|
92
|
+
parent_id=row['parent_id'],
|
|
93
|
+
namespace=row['namespace'] if 'namespace' in row.keys() else None
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
@dataclass
|
|
98
|
+
class Variable:
|
|
99
|
+
"""Variable or attribute definition."""
|
|
100
|
+
id: int
|
|
101
|
+
name: str
|
|
102
|
+
type: str # 'variable' or 'attribute'
|
|
103
|
+
file_id: int
|
|
104
|
+
file_path: str
|
|
105
|
+
location: Location
|
|
106
|
+
field_type: Optional[str] = None
|
|
107
|
+
description: Optional[str] = None
|
|
108
|
+
parent_id: Optional[int] = None
|
|
109
|
+
parent_type: Optional[str] = None
|
|
110
|
+
|
|
111
|
+
@classmethod
|
|
112
|
+
def from_row(cls, row: sqlite3.Row, file_path: str) -> 'Variable':
|
|
113
|
+
return cls(
|
|
114
|
+
id=row['id'],
|
|
115
|
+
name=row['name'],
|
|
116
|
+
type=row['type'],
|
|
117
|
+
file_id=row['file_id'],
|
|
118
|
+
file_path=file_path,
|
|
119
|
+
location=Location.from_dict(json.loads(row['location'])),
|
|
120
|
+
field_type=row['field_type'],
|
|
121
|
+
description=row['description'] if 'description' in row.keys() else None,
|
|
122
|
+
parent_id=row['parent_id'],
|
|
123
|
+
parent_type=row['parent_type']
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
@dataclass
|
|
128
|
+
class TypeAlias:
|
|
129
|
+
"""Type alias definition."""
|
|
130
|
+
id: int
|
|
131
|
+
name: str
|
|
132
|
+
file_id: int
|
|
133
|
+
file_path: str
|
|
134
|
+
location: Location
|
|
135
|
+
type_definition: Optional[str]
|
|
136
|
+
description: Optional[str] = None
|
|
137
|
+
|
|
138
|
+
@classmethod
|
|
139
|
+
def from_row(cls, row: sqlite3.Row, file_path: str) -> 'TypeAlias':
|
|
140
|
+
return cls(
|
|
141
|
+
id=row['id'],
|
|
142
|
+
name=row['name'],
|
|
143
|
+
file_id=row['file_id'],
|
|
144
|
+
file_path=file_path,
|
|
145
|
+
location=Location.from_dict(json.loads(row['location'])),
|
|
146
|
+
type_definition=row['type_definition'],
|
|
147
|
+
description=row['description'] if 'description' in row.keys() else None
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
@dataclass
|
|
152
|
+
class Struct:
|
|
153
|
+
"""Struct definition (Go, Rust, C, etc.)."""
|
|
154
|
+
id: int
|
|
155
|
+
name: str
|
|
156
|
+
file_id: int
|
|
157
|
+
file_path: str
|
|
158
|
+
location: Location
|
|
159
|
+
description: Optional[str] = None
|
|
160
|
+
|
|
161
|
+
@classmethod
|
|
162
|
+
def from_row(cls, row: sqlite3.Row, file_path: str) -> 'Struct':
|
|
163
|
+
return cls(
|
|
164
|
+
id=row['id'],
|
|
165
|
+
name=row['name'],
|
|
166
|
+
file_id=row['file_id'],
|
|
167
|
+
file_path=file_path,
|
|
168
|
+
location=Location.from_dict(json.loads(row['location'])),
|
|
169
|
+
description=row['description'] if 'description' in row.keys() else None
|
|
170
|
+
)
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
@dataclass
|
|
174
|
+
class Interface:
|
|
175
|
+
"""Interface/trait definition (Go, Rust, TypeScript, etc.)."""
|
|
176
|
+
id: int
|
|
177
|
+
name: str
|
|
178
|
+
file_id: int
|
|
179
|
+
file_path: str
|
|
180
|
+
location: Location
|
|
181
|
+
description: Optional[str] = None
|
|
182
|
+
|
|
183
|
+
@classmethod
|
|
184
|
+
def from_row(cls, row: sqlite3.Row, file_path: str) -> 'Interface':
|
|
185
|
+
return cls(
|
|
186
|
+
id=row['id'],
|
|
187
|
+
name=row['name'],
|
|
188
|
+
file_id=row['file_id'],
|
|
189
|
+
file_path=file_path,
|
|
190
|
+
location=Location.from_dict(json.loads(row['location'])),
|
|
191
|
+
description=row['description'] if 'description' in row.keys() else None
|
|
192
|
+
)
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
@dataclass
|
|
196
|
+
class Enum:
|
|
197
|
+
"""Enum definition (Rust, etc.)."""
|
|
198
|
+
id: int
|
|
199
|
+
name: str
|
|
200
|
+
file_id: int
|
|
201
|
+
file_path: str
|
|
202
|
+
location: Location
|
|
203
|
+
description: Optional[str] = None
|
|
204
|
+
|
|
205
|
+
@classmethod
|
|
206
|
+
def from_row(cls, row: sqlite3.Row, file_path: str) -> 'Enum':
|
|
207
|
+
return cls(
|
|
208
|
+
id=row['id'],
|
|
209
|
+
name=row['name'],
|
|
210
|
+
file_id=row['file_id'],
|
|
211
|
+
file_path=file_path,
|
|
212
|
+
location=Location.from_dict(json.loads(row['location'])),
|
|
213
|
+
description=row['description'] if 'description' in row.keys() else None
|
|
214
|
+
)
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
@dataclass
|
|
218
|
+
class Namespace:
|
|
219
|
+
"""Namespace definition (C#, etc.)."""
|
|
220
|
+
id: int
|
|
221
|
+
name: str
|
|
222
|
+
file_id: int
|
|
223
|
+
file_path: str
|
|
224
|
+
location: Location
|
|
225
|
+
description: Optional[str] = None
|
|
226
|
+
|
|
227
|
+
@classmethod
|
|
228
|
+
def from_row(cls, row: sqlite3.Row, file_path: str) -> 'Namespace':
|
|
229
|
+
return cls(
|
|
230
|
+
id=row['id'],
|
|
231
|
+
name=row['name'],
|
|
232
|
+
file_id=row['file_id'],
|
|
233
|
+
file_path=file_path,
|
|
234
|
+
location=Location.from_dict(json.loads(row['location'])),
|
|
235
|
+
description=row['description'] if 'description' in row.keys() else None
|
|
236
|
+
)
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
@dataclass
|
|
240
|
+
class File:
|
|
241
|
+
"""File information."""
|
|
242
|
+
id: int
|
|
243
|
+
path: str
|
|
244
|
+
absolute_path: str
|
|
245
|
+
language: str
|
|
246
|
+
|
|
247
|
+
@classmethod
|
|
248
|
+
def from_row(cls, row: sqlite3.Row) -> 'File':
|
|
249
|
+
return cls(
|
|
250
|
+
id=row['id'],
|
|
251
|
+
path=row['path'],
|
|
252
|
+
absolute_path=row['absolute_path'],
|
|
253
|
+
language=row['language']
|
|
254
|
+
)
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
@dataclass
|
|
258
|
+
class Dependency:
|
|
259
|
+
"""Dependency information (imports and function calls)."""
|
|
260
|
+
id: int
|
|
261
|
+
file_id: int
|
|
262
|
+
file_path: str
|
|
263
|
+
dependency_type: str # 'import' or 'function_call'
|
|
264
|
+
name: str
|
|
265
|
+
source_function_id: Optional[int] = None
|
|
266
|
+
target_function_id: Optional[int] = None
|
|
267
|
+
target_class_id: Optional[int] = None
|
|
268
|
+
location: Optional[Location] = None
|
|
269
|
+
is_external: bool = True # True for external dependencies, False for internal
|
|
270
|
+
|
|
271
|
+
@classmethod
|
|
272
|
+
def from_row(cls, row: sqlite3.Row, file_path: str) -> 'Dependency':
|
|
273
|
+
return cls(
|
|
274
|
+
id=row['id'],
|
|
275
|
+
file_id=row['file_id'],
|
|
276
|
+
file_path=file_path,
|
|
277
|
+
dependency_type=row['dependency_type'],
|
|
278
|
+
name=row['name'],
|
|
279
|
+
source_function_id=row['source_function_id'],
|
|
280
|
+
target_function_id=row['target_function_id'] if 'target_function_id' in row.keys() else None,
|
|
281
|
+
target_class_id=row['target_class_id'] if 'target_class_id' in row.keys() else None,
|
|
282
|
+
location=Location.from_dict(json.loads(row['location'])) if row['location'] else None,
|
|
283
|
+
is_external=bool(row['is_external']) if 'is_external' in row.keys() else True
|
|
284
|
+
)
|