honestcode 0.2.0__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.
Potentially problematic release.
This version of honestcode might be problematic. Click here for more details.
- honestcode/__init__.py +19 -0
- honestcode/cli.py +338 -0
- honestcode/graph/__init__.py +13 -0
- honestcode/graph/graph_store.py +229 -0
- honestcode/graph/watcher.py +116 -0
- honestcode/honest/__init__.py +19 -0
- honestcode/honest/project_binding.py +157 -0
- honestcode/honest/router.py +200 -0
- honestcode/honest/symbol_index.py +291 -0
- honestcode/mcp/__init__.py +46 -0
- honestcode/mcp/knowledge_base.py +141 -0
- honestcode/mcp/server.py +305 -0
- honestcode/mcp/tools.py +1267 -0
- honestcode/py.typed +0 -0
- honestcode/sandbox/__init__.py +195 -0
- honestcode/structure/__init__.py +6 -0
- honestcode/structure/extractor.py +296 -0
- honestcode/structure/multi_lang.py +180 -0
- honestcode/structure/relations.py +43 -0
- honestcode/structure/utils.py +31 -0
- honestcode-0.2.0.dist-info/METADATA +811 -0
- honestcode-0.2.0.dist-info/RECORD +26 -0
- honestcode-0.2.0.dist-info/WHEEL +5 -0
- honestcode-0.2.0.dist-info/entry_points.txt +3 -0
- honestcode-0.2.0.dist-info/licenses/LICENSE +21 -0
- honestcode-0.2.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"""Relation types and shared data structures for structural code analysis."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from dataclasses import dataclass
|
|
6
|
+
from enum import Enum
|
|
7
|
+
|
|
8
|
+
__all__ = ["RelationType", "StructEdge", "ParseResult"]
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class RelationType(Enum):
|
|
12
|
+
DEF_CALL = "def_call"
|
|
13
|
+
VAR_DEF_USE = "var_def_use"
|
|
14
|
+
AST_PARENT_CHILD = "ast_parent_child"
|
|
15
|
+
IMPORT = "import"
|
|
16
|
+
IMPORT_REF = "import_ref"
|
|
17
|
+
SAME_SCOPE = "same_scope"
|
|
18
|
+
CROSS_FILE_REF = "cross_file_ref" # def in file_a -> call in file_b
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@dataclass(frozen=True)
|
|
22
|
+
class StructEdge:
|
|
23
|
+
src_start: int
|
|
24
|
+
src_end: int
|
|
25
|
+
tgt_start: int
|
|
26
|
+
tgt_end: int
|
|
27
|
+
relation_type: str
|
|
28
|
+
name: str | None = None
|
|
29
|
+
# For cross-file edges: which file the source/target belongs to
|
|
30
|
+
src_file: str | None = None
|
|
31
|
+
tgt_file: str | None = None
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
@dataclass
|
|
35
|
+
class ParseResult:
|
|
36
|
+
edges: list[StructEdge]
|
|
37
|
+
func_defs: dict[str, tuple[int, int]]
|
|
38
|
+
class_defs: dict[str, tuple[int, int]]
|
|
39
|
+
var_defs: dict[str, tuple[int, int]]
|
|
40
|
+
imports: set[str]
|
|
41
|
+
# Cross-file: symbols imported from / exported to other files
|
|
42
|
+
imported_symbols: dict[str, str] | None = None # name -> source_module
|
|
43
|
+
exported_symbols: set[str] | None = None # names defined here, usable by others
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"""Shared AST utilities for HonestCode."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import ast
|
|
6
|
+
|
|
7
|
+
__all__ = ["call_name", "call_base"]
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def call_name(node: ast.expr) -> str | None:
|
|
11
|
+
"""Return a dotted name for a call target (e.g. ``obj.method``).
|
|
12
|
+
|
|
13
|
+
Returns ``None`` for complex expressions (e.g. ``(a + b).foo()``).
|
|
14
|
+
"""
|
|
15
|
+
if isinstance(node, ast.Name):
|
|
16
|
+
return node.id
|
|
17
|
+
if isinstance(node, ast.Attribute):
|
|
18
|
+
parts: list[str] = []
|
|
19
|
+
current: ast.expr = node
|
|
20
|
+
while isinstance(current, ast.Attribute):
|
|
21
|
+
parts.append(current.attr)
|
|
22
|
+
current = current.value
|
|
23
|
+
if isinstance(current, ast.Name):
|
|
24
|
+
parts.append(current.id)
|
|
25
|
+
return ".".join(reversed(parts))
|
|
26
|
+
return None
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def call_base(name: str) -> str:
|
|
30
|
+
"""Return the first component of a dotted name."""
|
|
31
|
+
return name.split(".")[0]
|