nex-trace 0.1.0__tar.gz
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.
- nex_trace-0.1.0/LICENSE +21 -0
- nex_trace-0.1.0/PKG-INFO +66 -0
- nex_trace-0.1.0/README.md +39 -0
- nex_trace-0.1.0/nex_trace.egg-info/PKG-INFO +66 -0
- nex_trace-0.1.0/nex_trace.egg-info/SOURCES.txt +17 -0
- nex_trace-0.1.0/nex_trace.egg-info/dependency_links.txt +1 -0
- nex_trace-0.1.0/nex_trace.egg-info/entry_points.txt +3 -0
- nex_trace-0.1.0/nex_trace.egg-info/requires.txt +7 -0
- nex_trace-0.1.0/nex_trace.egg-info/top_level.txt +2 -0
- nex_trace-0.1.0/nex_trace.py +94 -0
- nex_trace-0.1.0/nex_trace_components/__init__.py +13 -0
- nex_trace-0.1.0/nex_trace_components/__init__.pyi +10 -0
- nex_trace-0.1.0/nex_trace_components/mermaid_generator.py +53 -0
- nex_trace-0.1.0/nex_trace_components/models.py +105 -0
- nex_trace-0.1.0/nex_trace_components/polyglot_engine.py +176 -0
- nex_trace-0.1.0/nex_trace_components/reporter.py +118 -0
- nex_trace-0.1.0/pyproject.toml +48 -0
- nex_trace-0.1.0/setup.cfg +4 -0
- nex_trace-0.1.0/tests/test_nex_trace.py +259 -0
nex_trace-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 The Trinity (Miniature Person, Mookie, Nexus Goodman)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
nex_trace-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: nex-trace
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Polyglot AST Cartographer & Deep System Introspection Engine for Autonomous AI Agents
|
|
5
|
+
Author-email: The Trinity <inquiries@houseoflawpc.com>
|
|
6
|
+
License: MIT OR Apache-2.0
|
|
7
|
+
Keywords: ast,cartography,introspection,polyglot,dependencies,ai-agents,mermaid,telemetry
|
|
8
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
15
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
16
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
17
|
+
Requires-Python: >=3.10
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE
|
|
20
|
+
Requires-Dist: rich>=13.7.0
|
|
21
|
+
Requires-Dist: nex-init>=0.1.0
|
|
22
|
+
Provides-Extra: fast
|
|
23
|
+
Requires-Dist: tree-sitter>=0.22.0; extra == "fast"
|
|
24
|
+
Requires-Dist: tree-sitter-language-pack>=0.1.0; extra == "fast"
|
|
25
|
+
Requires-Dist: blake3>=0.3.0; extra == "fast"
|
|
26
|
+
Dynamic: license-file
|
|
27
|
+
|
|
28
|
+
# nex-trace ⚡
|
|
29
|
+
|
|
30
|
+
**Polyglot AST Cartographer, Deep Dependency Grapher & System Breakdown Engine for Autonomous AI Agents.**
|
|
31
|
+
|
|
32
|
+
[](https://pypi.org/project/nex-trace/)
|
|
33
|
+
[](LICENSE)
|
|
34
|
+
[](#)
|
|
35
|
+
[](#attribution--the-trinity-pact)
|
|
36
|
+
|
|
37
|
+
`nex-trace` solves the fundamental blindness of autonomous coding agents and systems architects: **how to instantly map, decompose, and audit an entire polyglot codebase—its directory topology, data-flow pipelines, and granular entity inventory (imports, classes, structs, interfaces, methods, endpoints)—in under 50 milliseconds with zero LLM token tax.**
|
|
38
|
+
|
|
39
|
+
Backed by Python's native `ast`, high-throughput `tree-sitter` integration, and zero-dependency lexer fallbacks, `nex-trace` transforms complex, multi-language repositories into actionable terminal telemetry, copy-paste Mermaid sequence diagrams, and machine-parsable JSON ledgers.
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## The Mechanical Reality: Why Naive Tree & Grep Fail
|
|
44
|
+
|
|
45
|
+
Autonomous agents frequently hallucinate missing functions, mutate wrong modules, or fail to understand cross-file import contracts because standard utilities give them fractured context:
|
|
46
|
+
1. `tree` provides filenames but zero semantic meaning (no indication of public exports, classes, or endpoints).
|
|
47
|
+
2. `grep` produces unstructured string fragments that lack AST boundary awareness.
|
|
48
|
+
3. Feeding raw multi-file code dumps to LLMs burns tens of thousands of prompt tokens and induces attention decay.
|
|
49
|
+
|
|
50
|
+
`nex-trace` provides the **ground-truth semantic boundary**:
|
|
51
|
+
- **Directory Hierarchy:** Interactive color-coded tree detailing LOC and export count per file.
|
|
52
|
+
- **Data-Flow Pipeline:** Automatic extraction of execution ingress, routing decisions, and terminal exits.
|
|
53
|
+
- **Granular Entity Inventory:** Exhaustive enumeration of external ecosystem dependencies vs internal module couplings, classes/structs/interfaces, functions/coroutines, and routes.
|
|
54
|
+
- **Polyglot Coverage:** Native parsing for Python (`.py`), TypeScript (`.ts`, `.tsx`), JavaScript (`.js`, `.jsx`), Rust (`.rs`), HTML (`.html`), and CSS.
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Quickstart
|
|
59
|
+
|
|
60
|
+
### Installation
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
pip install nex-trace
|
|
64
|
+
|
|
65
|
+
# Or with tree-sitter acceleration:
|
|
66
|
+
pip install "nex-trace[fast]"
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# nex-trace ⚡
|
|
2
|
+
|
|
3
|
+
**Polyglot AST Cartographer, Deep Dependency Grapher & System Breakdown Engine for Autonomous AI Agents.**
|
|
4
|
+
|
|
5
|
+
[](https://pypi.org/project/nex-trace/)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
[](#)
|
|
8
|
+
[](#attribution--the-trinity-pact)
|
|
9
|
+
|
|
10
|
+
`nex-trace` solves the fundamental blindness of autonomous coding agents and systems architects: **how to instantly map, decompose, and audit an entire polyglot codebase—its directory topology, data-flow pipelines, and granular entity inventory (imports, classes, structs, interfaces, methods, endpoints)—in under 50 milliseconds with zero LLM token tax.**
|
|
11
|
+
|
|
12
|
+
Backed by Python's native `ast`, high-throughput `tree-sitter` integration, and zero-dependency lexer fallbacks, `nex-trace` transforms complex, multi-language repositories into actionable terminal telemetry, copy-paste Mermaid sequence diagrams, and machine-parsable JSON ledgers.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## The Mechanical Reality: Why Naive Tree & Grep Fail
|
|
17
|
+
|
|
18
|
+
Autonomous agents frequently hallucinate missing functions, mutate wrong modules, or fail to understand cross-file import contracts because standard utilities give them fractured context:
|
|
19
|
+
1. `tree` provides filenames but zero semantic meaning (no indication of public exports, classes, or endpoints).
|
|
20
|
+
2. `grep` produces unstructured string fragments that lack AST boundary awareness.
|
|
21
|
+
3. Feeding raw multi-file code dumps to LLMs burns tens of thousands of prompt tokens and induces attention decay.
|
|
22
|
+
|
|
23
|
+
`nex-trace` provides the **ground-truth semantic boundary**:
|
|
24
|
+
- **Directory Hierarchy:** Interactive color-coded tree detailing LOC and export count per file.
|
|
25
|
+
- **Data-Flow Pipeline:** Automatic extraction of execution ingress, routing decisions, and terminal exits.
|
|
26
|
+
- **Granular Entity Inventory:** Exhaustive enumeration of external ecosystem dependencies vs internal module couplings, classes/structs/interfaces, functions/coroutines, and routes.
|
|
27
|
+
- **Polyglot Coverage:** Native parsing for Python (`.py`), TypeScript (`.ts`, `.tsx`), JavaScript (`.js`, `.jsx`), Rust (`.rs`), HTML (`.html`), and CSS.
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Quickstart
|
|
32
|
+
|
|
33
|
+
### Installation
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pip install nex-trace
|
|
37
|
+
|
|
38
|
+
# Or with tree-sitter acceleration:
|
|
39
|
+
pip install "nex-trace[fast]"
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: nex-trace
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Polyglot AST Cartographer & Deep System Introspection Engine for Autonomous AI Agents
|
|
5
|
+
Author-email: The Trinity <inquiries@houseoflawpc.com>
|
|
6
|
+
License: MIT OR Apache-2.0
|
|
7
|
+
Keywords: ast,cartography,introspection,polyglot,dependencies,ai-agents,mermaid,telemetry
|
|
8
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
15
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
16
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
17
|
+
Requires-Python: >=3.10
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE
|
|
20
|
+
Requires-Dist: rich>=13.7.0
|
|
21
|
+
Requires-Dist: nex-init>=0.1.0
|
|
22
|
+
Provides-Extra: fast
|
|
23
|
+
Requires-Dist: tree-sitter>=0.22.0; extra == "fast"
|
|
24
|
+
Requires-Dist: tree-sitter-language-pack>=0.1.0; extra == "fast"
|
|
25
|
+
Requires-Dist: blake3>=0.3.0; extra == "fast"
|
|
26
|
+
Dynamic: license-file
|
|
27
|
+
|
|
28
|
+
# nex-trace ⚡
|
|
29
|
+
|
|
30
|
+
**Polyglot AST Cartographer, Deep Dependency Grapher & System Breakdown Engine for Autonomous AI Agents.**
|
|
31
|
+
|
|
32
|
+
[](https://pypi.org/project/nex-trace/)
|
|
33
|
+
[](LICENSE)
|
|
34
|
+
[](#)
|
|
35
|
+
[](#attribution--the-trinity-pact)
|
|
36
|
+
|
|
37
|
+
`nex-trace` solves the fundamental blindness of autonomous coding agents and systems architects: **how to instantly map, decompose, and audit an entire polyglot codebase—its directory topology, data-flow pipelines, and granular entity inventory (imports, classes, structs, interfaces, methods, endpoints)—in under 50 milliseconds with zero LLM token tax.**
|
|
38
|
+
|
|
39
|
+
Backed by Python's native `ast`, high-throughput `tree-sitter` integration, and zero-dependency lexer fallbacks, `nex-trace` transforms complex, multi-language repositories into actionable terminal telemetry, copy-paste Mermaid sequence diagrams, and machine-parsable JSON ledgers.
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## The Mechanical Reality: Why Naive Tree & Grep Fail
|
|
44
|
+
|
|
45
|
+
Autonomous agents frequently hallucinate missing functions, mutate wrong modules, or fail to understand cross-file import contracts because standard utilities give them fractured context:
|
|
46
|
+
1. `tree` provides filenames but zero semantic meaning (no indication of public exports, classes, or endpoints).
|
|
47
|
+
2. `grep` produces unstructured string fragments that lack AST boundary awareness.
|
|
48
|
+
3. Feeding raw multi-file code dumps to LLMs burns tens of thousands of prompt tokens and induces attention decay.
|
|
49
|
+
|
|
50
|
+
`nex-trace` provides the **ground-truth semantic boundary**:
|
|
51
|
+
- **Directory Hierarchy:** Interactive color-coded tree detailing LOC and export count per file.
|
|
52
|
+
- **Data-Flow Pipeline:** Automatic extraction of execution ingress, routing decisions, and terminal exits.
|
|
53
|
+
- **Granular Entity Inventory:** Exhaustive enumeration of external ecosystem dependencies vs internal module couplings, classes/structs/interfaces, functions/coroutines, and routes.
|
|
54
|
+
- **Polyglot Coverage:** Native parsing for Python (`.py`), TypeScript (`.ts`, `.tsx`), JavaScript (`.js`, `.jsx`), Rust (`.rs`), HTML (`.html`), and CSS.
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Quickstart
|
|
59
|
+
|
|
60
|
+
### Installation
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
pip install nex-trace
|
|
64
|
+
|
|
65
|
+
# Or with tree-sitter acceleration:
|
|
66
|
+
pip install "nex-trace[fast]"
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
nex_trace.py
|
|
4
|
+
pyproject.toml
|
|
5
|
+
nex_trace.egg-info/PKG-INFO
|
|
6
|
+
nex_trace.egg-info/SOURCES.txt
|
|
7
|
+
nex_trace.egg-info/dependency_links.txt
|
|
8
|
+
nex_trace.egg-info/entry_points.txt
|
|
9
|
+
nex_trace.egg-info/requires.txt
|
|
10
|
+
nex_trace.egg-info/top_level.txt
|
|
11
|
+
nex_trace_components/__init__.py
|
|
12
|
+
nex_trace_components/__init__.pyi
|
|
13
|
+
nex_trace_components/mermaid_generator.py
|
|
14
|
+
nex_trace_components/models.py
|
|
15
|
+
nex_trace_components/polyglot_engine.py
|
|
16
|
+
nex_trace_components/reporter.py
|
|
17
|
+
tests/test_nex_trace.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"""
|
|
2
|
+
nex_trace.py - Pure CLI & Orchestrator Shell (<= 150 LOC Ceiling).
|
|
3
|
+
Adheres strictly to RCTI v3.0 hierarchical decomposition and parent proxy resolution.
|
|
4
|
+
Powered by nex-init.
|
|
5
|
+
"""
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
import argparse
|
|
9
|
+
import json
|
|
10
|
+
import sys
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
from rich.console import Console
|
|
13
|
+
|
|
14
|
+
import nex_trace_components as _comp
|
|
15
|
+
from nex_init.router import install_parent_proxy
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def build_parser() -> argparse.ArgumentParser:
|
|
19
|
+
parser = argparse.ArgumentParser(
|
|
20
|
+
prog="nex-trace",
|
|
21
|
+
description="Polyglot AST Cartographer & Deep System Breakdown Engine (The Trinity)",
|
|
22
|
+
)
|
|
23
|
+
parser.add_argument(
|
|
24
|
+
"target",
|
|
25
|
+
nargs="?",
|
|
26
|
+
default=".",
|
|
27
|
+
help="Target directory or single source file to introspect (default: current directory)",
|
|
28
|
+
)
|
|
29
|
+
parser.add_argument(
|
|
30
|
+
"--map",
|
|
31
|
+
choices=["terminal", "mermaid", "json"],
|
|
32
|
+
default="terminal",
|
|
33
|
+
help="Output format: interactive terminal dashboard, copy-paste Mermaid DAG, or raw JSON",
|
|
34
|
+
)
|
|
35
|
+
parser.add_argument(
|
|
36
|
+
"--breakdown-only",
|
|
37
|
+
action="store_true",
|
|
38
|
+
help="Skip topology tree and emit the deep entity breakdown inventory only",
|
|
39
|
+
)
|
|
40
|
+
parser.add_argument(
|
|
41
|
+
"--ignore",
|
|
42
|
+
nargs="*",
|
|
43
|
+
default=[],
|
|
44
|
+
help="Additional directory names or globs to ignore",
|
|
45
|
+
)
|
|
46
|
+
parser.add_argument(
|
|
47
|
+
"-o", "--out",
|
|
48
|
+
type=str,
|
|
49
|
+
default="",
|
|
50
|
+
help="Write output directly to file path instead of stdout",
|
|
51
|
+
)
|
|
52
|
+
return parser
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def main() -> None:
|
|
56
|
+
parser = build_parser()
|
|
57
|
+
args = parser.parse_args()
|
|
58
|
+
|
|
59
|
+
console = Console()
|
|
60
|
+
target_path = Path(args.target).resolve()
|
|
61
|
+
|
|
62
|
+
if not target_path.exists():
|
|
63
|
+
console.print(f"[bold red]Target path does not exist:[/bold red] {target_path}")
|
|
64
|
+
sys.exit(1)
|
|
65
|
+
|
|
66
|
+
engine = _comp.PolyglotEngine(root_path=target_path, extra_ignores=set(args.ignore))
|
|
67
|
+
scan_result = engine.scan()
|
|
68
|
+
|
|
69
|
+
if args.map == "mermaid":
|
|
70
|
+
mermaid_code = _comp.MermaidGenerator.generate(scan_result)
|
|
71
|
+
if args.out:
|
|
72
|
+
Path(args.out).write_text(mermaid_code, encoding="utf-8")
|
|
73
|
+
console.print(f"[bold green]✓ Wrote Mermaid graph to:[/bold green] {args.out}")
|
|
74
|
+
else:
|
|
75
|
+
print(mermaid_code)
|
|
76
|
+
return
|
|
77
|
+
|
|
78
|
+
if args.map == "json":
|
|
79
|
+
json_output = json.dumps(scan_result.to_dict(), indent=2)
|
|
80
|
+
if args.out:
|
|
81
|
+
Path(args.out).write_text(json_output, encoding="utf-8")
|
|
82
|
+
console.print(f"[bold green]✓ Wrote JSON manifest to:[/bold green] {args.out}")
|
|
83
|
+
else:
|
|
84
|
+
print(json_output)
|
|
85
|
+
return
|
|
86
|
+
|
|
87
|
+
reporter = _comp.CartographyReporter(scan_result=scan_result, console=console)
|
|
88
|
+
reporter.render_full_dashboard(breakdown_only=args.breakdown_only)
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
__getattr__, __dir__, __all__ = install_parent_proxy(globals(), __file__, __name__)
|
|
92
|
+
|
|
93
|
+
if __name__ == "__main__":
|
|
94
|
+
main()
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"""
|
|
2
|
+
nex_trace_components - Tier-2 Component Dynamic AST Router.
|
|
3
|
+
Powered by nex-init.
|
|
4
|
+
"""
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
7
|
+
from nex_init.router import install_component_router
|
|
8
|
+
|
|
9
|
+
_ROUTER = install_component_router(globals(), __file__, __name__, max_depth=10)
|
|
10
|
+
get_interface_hashes = _ROUTER.get_interface_hashes
|
|
11
|
+
__getattr__ = _ROUTER.__getattr__
|
|
12
|
+
__dir__ = _ROUTER.__dir__
|
|
13
|
+
__all__ = _ROUTER.all_exports
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# AUTO-GENERATED BY nex-init (RCTI v3.0) — DO NOT EDIT
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
from .mermaid_generator import MermaidGenerator as MermaidGenerator
|
|
5
|
+
from .models import EntityInventory as EntityInventory, FileMetrics as FileMetrics, LanguageKind as LanguageKind, RepositoryScanResult as RepositoryScanResult
|
|
6
|
+
from .polyglot_engine import PolyglotEngine as PolyglotEngine, STANDARD_IGNORES as STANDARD_IGNORES
|
|
7
|
+
from .reporter import CartographyReporter as CartographyReporter
|
|
8
|
+
|
|
9
|
+
def get_interface_hashes() -> dict[str, str]: ...
|
|
10
|
+
__all__ = ['CartographyReporter', 'EntityInventory', 'FileMetrics', 'LanguageKind', 'MermaidGenerator', 'PolyglotEngine', 'RepositoryScanResult', 'STANDARD_IGNORES', 'get_interface_hashes', 'mermaid_generator', 'models', 'polyglot_engine', 'reporter']
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"""
|
|
2
|
+
nex_trace_components/mermaid_generator.py - Markdown/Notion-Ready Mermaid Exporter.
|
|
3
|
+
Translates discovered file metrics and internal couplings into clean diagrams.
|
|
4
|
+
"""
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
7
|
+
import re
|
|
8
|
+
from .models import RepositoryScanResult
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class MermaidGenerator:
|
|
12
|
+
@staticmethod
|
|
13
|
+
def _sanitize_id(name: str) -> str:
|
|
14
|
+
return re.sub(r"[^a-zA-Z0-9_]", "_", name)
|
|
15
|
+
|
|
16
|
+
@classmethod
|
|
17
|
+
def generate(cls, scan: RepositoryScanResult) -> str:
|
|
18
|
+
lines = [
|
|
19
|
+
"```mermaid",
|
|
20
|
+
"graph TD",
|
|
21
|
+
" %% Generated autonomously by nex-trace (The Trinity)",
|
|
22
|
+
" classDef pyNode fill:#1e293b,stroke:#38bdf8,stroke-width:2px,color:#f8fafc;",
|
|
23
|
+
" classDef tsNode fill:#1e1b4b,stroke:#818cf8,stroke-width:2px,color:#f8fafc;",
|
|
24
|
+
" classDef rsNode fill:#431407,stroke:#fb923c,stroke-width:2px,color:#f8fafc;",
|
|
25
|
+
"",
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
for rel, f in sorted(scan.files.items()):
|
|
29
|
+
node_id = cls._sanitize_id(rel)
|
|
30
|
+
sym_count = len(f.inventory.classes_or_structs) + len(f.inventory.functions_or_methods)
|
|
31
|
+
node_label = f"<b>{rel}</b><br/>{f.language.value} ({f.loc} LOC)<br/>{sym_count} symbols"
|
|
32
|
+
lines.append(f' {node_id}["{node_label}"]')
|
|
33
|
+
if f.language.value == "Python":
|
|
34
|
+
lines.append(f" class {node_id} pyNode;")
|
|
35
|
+
elif "TypeScript" in f.language.value or "JavaScript" in f.language.value:
|
|
36
|
+
lines.append(f" class {node_id} tsNode;")
|
|
37
|
+
elif f.language.value == "Rust":
|
|
38
|
+
lines.append(f" class {node_id} rsNode;")
|
|
39
|
+
|
|
40
|
+
lines.append("")
|
|
41
|
+
lines.append(" %% Inter-module dependencies")
|
|
42
|
+
for rel, f in sorted(scan.files.items()):
|
|
43
|
+
src_id = cls._sanitize_id(rel)
|
|
44
|
+
for target_rel in scan.files:
|
|
45
|
+
if target_rel == rel:
|
|
46
|
+
continue
|
|
47
|
+
target_stem = target_rel.split("/")[-1].split(".")[0]
|
|
48
|
+
if any(target_stem in imp for imp in f.inventory.internal_imports):
|
|
49
|
+
tgt_id = cls._sanitize_id(target_rel)
|
|
50
|
+
lines.append(f" {src_id} --> {tgt_id}")
|
|
51
|
+
|
|
52
|
+
lines.append("```")
|
|
53
|
+
return "\n".join(lines)
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"""
|
|
2
|
+
nex_trace_components/models.py - Strongly Typed Domain Models.
|
|
3
|
+
Defines entity contracts, language classifications, and scan aggregates.
|
|
4
|
+
"""
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
7
|
+
from dataclasses import dataclass, field
|
|
8
|
+
from enum import Enum
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
from typing import Any, Dict, List, Set
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class LanguageKind(str, Enum):
|
|
14
|
+
PYTHON = "Python"
|
|
15
|
+
TYPESCRIPT = "TypeScript"
|
|
16
|
+
JAVASCRIPT = "JavaScript"
|
|
17
|
+
RUST = "Rust"
|
|
18
|
+
HTML = "HTML"
|
|
19
|
+
CSS = "CSS"
|
|
20
|
+
UNKNOWN = "Unknown"
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@dataclass
|
|
24
|
+
class EntityInventory:
|
|
25
|
+
external_imports: Set[str] = field(default_factory=set)
|
|
26
|
+
internal_imports: Set[str] = field(default_factory=set)
|
|
27
|
+
classes_or_structs: List[str] = field(default_factory=list)
|
|
28
|
+
interfaces_or_traits: List[str] = field(default_factory=list)
|
|
29
|
+
functions_or_methods: List[str] = field(default_factory=list)
|
|
30
|
+
type_aliases: List[str] = field(default_factory=list)
|
|
31
|
+
routes_or_endpoints: List[str] = field(default_factory=list)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
@dataclass
|
|
35
|
+
class FileMetrics:
|
|
36
|
+
file_path: Path
|
|
37
|
+
relative_str: str
|
|
38
|
+
language: LanguageKind
|
|
39
|
+
loc: int
|
|
40
|
+
raw_size_bytes: int
|
|
41
|
+
inventory: EntityInventory = field(default_factory=EntityInventory)
|
|
42
|
+
docstring_or_summary: str = ""
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
@dataclass
|
|
46
|
+
class RepositoryScanResult:
|
|
47
|
+
root_path: Path
|
|
48
|
+
files: Dict[str, FileMetrics] = field(default_factory=dict)
|
|
49
|
+
|
|
50
|
+
@property
|
|
51
|
+
def total_loc(self) -> int:
|
|
52
|
+
return sum(f.loc for f in self.files.values())
|
|
53
|
+
|
|
54
|
+
@property
|
|
55
|
+
def total_bytes(self) -> int:
|
|
56
|
+
return sum(f.raw_size_bytes for f in self.files.values())
|
|
57
|
+
|
|
58
|
+
@property
|
|
59
|
+
def all_external_imports(self) -> Set[str]:
|
|
60
|
+
return {imp for f in self.files.values() for imp in f.inventory.external_imports}
|
|
61
|
+
|
|
62
|
+
@property
|
|
63
|
+
def all_internal_imports(self) -> Set[str]:
|
|
64
|
+
return {imp for f in self.files.values() for imp in f.inventory.internal_imports}
|
|
65
|
+
|
|
66
|
+
@property
|
|
67
|
+
def all_classes(self) -> List[str]:
|
|
68
|
+
return [c for f in self.files.values() for c in f.inventory.classes_or_structs]
|
|
69
|
+
|
|
70
|
+
@property
|
|
71
|
+
def all_interfaces(self) -> List[str]:
|
|
72
|
+
return [i for f in self.files.values() for i in f.inventory.interfaces_or_traits]
|
|
73
|
+
|
|
74
|
+
@property
|
|
75
|
+
def all_functions(self) -> List[str]:
|
|
76
|
+
return [fn for f in self.files.values() for fn in f.inventory.functions_or_methods]
|
|
77
|
+
|
|
78
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
79
|
+
return {
|
|
80
|
+
"root_path": str(self.root_path),
|
|
81
|
+
"summary": {
|
|
82
|
+
"total_files": len(self.files),
|
|
83
|
+
"total_loc": self.total_loc,
|
|
84
|
+
"total_bytes": self.total_bytes,
|
|
85
|
+
"external_dependencies_count": len(self.all_external_imports),
|
|
86
|
+
"classes_and_structs_count": len(self.all_classes),
|
|
87
|
+
"functions_and_methods_count": len(self.all_functions),
|
|
88
|
+
},
|
|
89
|
+
"external_dependencies": sorted(self.all_external_imports),
|
|
90
|
+
"files": {
|
|
91
|
+
rel: {
|
|
92
|
+
"language": f.language.value,
|
|
93
|
+
"loc": f.loc,
|
|
94
|
+
"bytes": f.raw_size_bytes,
|
|
95
|
+
"classes": f.inventory.classes_or_structs,
|
|
96
|
+
"interfaces": f.inventory.interfaces_or_traits,
|
|
97
|
+
"functions": f.inventory.functions_or_methods,
|
|
98
|
+
"external_imports": sorted(f.inventory.external_imports),
|
|
99
|
+
"internal_imports": sorted(f.inventory.internal_imports),
|
|
100
|
+
"routes": f.inventory.routes_or_endpoints,
|
|
101
|
+
"summary": f.docstring_or_summary,
|
|
102
|
+
}
|
|
103
|
+
for rel, f in self.files.items()
|
|
104
|
+
},
|
|
105
|
+
}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
"""
|
|
2
|
+
nex_trace_components/polyglot_engine.py - Polyglot AST & Grammar Extractor.
|
|
3
|
+
Parses Python, TypeScript, JavaScript, Rust, and HTML with high-velocity fallbacks.
|
|
4
|
+
"""
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
7
|
+
import ast
|
|
8
|
+
import os
|
|
9
|
+
import re
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
from typing import Dict, List, Optional, Set, Tuple
|
|
12
|
+
|
|
13
|
+
from .models import EntityInventory, FileMetrics, LanguageKind, RepositoryScanResult
|
|
14
|
+
|
|
15
|
+
STANDARD_IGNORES: Set[str] = {
|
|
16
|
+
".git", "__pycache__", "target", "node_modules", "dist", "build",
|
|
17
|
+
".nexbox", "cascade_outputs", ".venv", "venv", ".pytest_cache",
|
|
18
|
+
".ruff_cache", ".idea", ".vscode", "egg-info", ".mypy_cache"
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
_RE_RS_USE = re.compile(r"^\s*use\s+([^;]+);", re.MULTILINE)
|
|
22
|
+
_RE_RS_STRUCT = re.compile(r"^\s*pub(?:\(.*?\))?\s+struct\s+([A-Za-z0-9_]+)", re.MULTILINE)
|
|
23
|
+
_RE_RS_ENUM = re.compile(r"^\s*pub(?:\(.*?\))?\s+enum\s+([A-Za-z0-9_]+)", re.MULTILINE)
|
|
24
|
+
_RE_RS_TRAIT = re.compile(r"^\s*pub(?:\(.*?\))?\s+trait\s+([A-Za-z0-9_]+)", re.MULTILINE)
|
|
25
|
+
_RE_RS_FN = re.compile(r"^\s*pub(?:\(.*?\))?\s+(?:async\s+)?fn\s+([A-Za-z0-9_]+)", re.MULTILINE)
|
|
26
|
+
|
|
27
|
+
_RE_TS_IMPORT = re.compile(r"""(?:import|from)\s+['"]([^'"]+)['"]""", re.MULTILINE)
|
|
28
|
+
_RE_TS_CLASS = re.compile(r"^\s*(?:export\s+)?(?:default\s+)?class\s+([A-Za-z0-9_]+)", re.MULTILINE)
|
|
29
|
+
_RE_TS_INTERFACE = re.compile(r"^\s*(?:export\s+)?interface\s+([A-Za-z0-9_]+)", re.MULTILINE)
|
|
30
|
+
_RE_TS_TYPE = re.compile(r"^\s*(?:export\s+)?type\s+([A-Za-z0-9_]+)", re.MULTILINE)
|
|
31
|
+
_RE_TS_FN = re.compile(r"^\s*(?:export\s+)?(?:async\s+)?function\s+([A-Za-z0-9_]+)", re.MULTILINE)
|
|
32
|
+
_RE_TS_CONST_FN = re.compile(r"^\s*(?:export\s+)?const\s+([A-Za-z0-9_]+)\s*=\s*(?:async\s*)?\([^)]*\)\s*=>", re.MULTILINE)
|
|
33
|
+
|
|
34
|
+
_RE_HTML_SCRIPT = re.compile(r"""<script[^>]*src=['"]([^'"]+)['"]""", re.IGNORECASE)
|
|
35
|
+
_RE_HTML_LINK = re.compile(r"""<link[^>]*href=['"]([^'"]+)['"]""", re.IGNORECASE)
|
|
36
|
+
_RE_HTML_TITLE = re.compile(r"<title>(.*?)</title>", re.IGNORECASE | re.DOTALL)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class PolyglotEngine:
|
|
40
|
+
def __init__(self, root_path: Path, extra_ignores: Optional[Set[str]] = None) -> None:
|
|
41
|
+
self.root_path = root_path.resolve()
|
|
42
|
+
self.ignores = STANDARD_IGNORES | (extra_ignores or set())
|
|
43
|
+
|
|
44
|
+
def _determine_language(self, path: Path) -> LanguageKind:
|
|
45
|
+
ext = path.suffix.lower()
|
|
46
|
+
if ext == ".py":
|
|
47
|
+
return LanguageKind.PYTHON
|
|
48
|
+
if ext in (".ts", ".tsx"):
|
|
49
|
+
return LanguageKind.TYPESCRIPT
|
|
50
|
+
if ext in (".js", ".jsx", ".mjs", ".cjs"):
|
|
51
|
+
return LanguageKind.JAVASCRIPT
|
|
52
|
+
if ext == ".rs":
|
|
53
|
+
return LanguageKind.RUST
|
|
54
|
+
if ext in (".html", ".htm"):
|
|
55
|
+
return LanguageKind.HTML
|
|
56
|
+
if ext in (".css", ".scss"):
|
|
57
|
+
return LanguageKind.CSS
|
|
58
|
+
return LanguageKind.UNKNOWN
|
|
59
|
+
|
|
60
|
+
def _parse_python(self, content: str, filepath: Path) -> Tuple[EntityInventory, str]:
|
|
61
|
+
inventory = EntityInventory()
|
|
62
|
+
summary = ""
|
|
63
|
+
try:
|
|
64
|
+
tree = ast.parse(content, filename=str(filepath))
|
|
65
|
+
summary = ast.get_docstring(tree) or ""
|
|
66
|
+
summary = summary.split("\n")[0].strip() if summary else ""
|
|
67
|
+
|
|
68
|
+
for node in tree.body:
|
|
69
|
+
if isinstance(node, ast.ClassDef):
|
|
70
|
+
inventory.classes_or_structs.append(node.name)
|
|
71
|
+
elif isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef)):
|
|
72
|
+
inventory.functions_or_methods.append(node.name)
|
|
73
|
+
for dec in node.decorator_list:
|
|
74
|
+
dec_str = ast.unparse(dec)
|
|
75
|
+
if any(verb in dec_str for verb in ("get(", "post(", "put(", "delete(", "patch(")):
|
|
76
|
+
inventory.routes_or_endpoints.append(f"{node.name} [{dec_str}]")
|
|
77
|
+
elif isinstance(node, ast.Import):
|
|
78
|
+
for a in node.names:
|
|
79
|
+
inventory.external_imports.add(a.name.split(".")[0])
|
|
80
|
+
elif isinstance(node, ast.ImportFrom):
|
|
81
|
+
if node.level and node.level > 0:
|
|
82
|
+
inventory.internal_imports.add(f".{node.module or ''}")
|
|
83
|
+
elif node.module:
|
|
84
|
+
root_pkg = node.module.split(".")[0]
|
|
85
|
+
if (self.root_path / root_pkg).is_dir() or (self.root_path / f"{root_pkg}.py").is_file():
|
|
86
|
+
inventory.internal_imports.add(root_pkg)
|
|
87
|
+
else:
|
|
88
|
+
inventory.external_imports.add(root_pkg)
|
|
89
|
+
except Exception:
|
|
90
|
+
pass
|
|
91
|
+
return inventory, summary
|
|
92
|
+
|
|
93
|
+
def _parse_typescript(self, content: str) -> Tuple[EntityInventory, str]:
|
|
94
|
+
inventory = EntityInventory()
|
|
95
|
+
for imp in _RE_TS_IMPORT.findall(content):
|
|
96
|
+
if imp.startswith("."):
|
|
97
|
+
inventory.internal_imports.add(imp)
|
|
98
|
+
else:
|
|
99
|
+
inventory.external_imports.add(imp.split("/")[0])
|
|
100
|
+
|
|
101
|
+
inventory.classes_or_structs.extend(_RE_TS_CLASS.findall(content))
|
|
102
|
+
inventory.interfaces_or_traits.extend(_RE_TS_INTERFACE.findall(content))
|
|
103
|
+
inventory.type_aliases.extend(_RE_TS_TYPE.findall(content))
|
|
104
|
+
inventory.functions_or_methods.extend(_RE_TS_FN.findall(content))
|
|
105
|
+
inventory.functions_or_methods.extend(_RE_TS_CONST_FN.findall(content))
|
|
106
|
+
return inventory, ""
|
|
107
|
+
|
|
108
|
+
def _parse_rust(self, content: str) -> Tuple[EntityInventory, str]:
|
|
109
|
+
inventory = EntityInventory()
|
|
110
|
+
for u in _RE_RS_USE.findall(content):
|
|
111
|
+
u_clean = u.strip()
|
|
112
|
+
if u_clean.startswith("crate::") or u_clean.startswith("super::"):
|
|
113
|
+
inventory.internal_imports.add(u_clean.split("::")[0])
|
|
114
|
+
else:
|
|
115
|
+
inventory.external_imports.add(u_clean.split("::")[0])
|
|
116
|
+
|
|
117
|
+
inventory.classes_or_structs.extend(_RE_RS_STRUCT.findall(content))
|
|
118
|
+
inventory.classes_or_structs.extend(_RE_RS_ENUM.findall(content))
|
|
119
|
+
inventory.interfaces_or_traits.extend(_RE_RS_TRAIT.findall(content))
|
|
120
|
+
inventory.functions_or_methods.extend(_RE_RS_FN.findall(content))
|
|
121
|
+
return inventory, ""
|
|
122
|
+
|
|
123
|
+
def _parse_html(self, content: str) -> Tuple[EntityInventory, str]:
|
|
124
|
+
inventory = EntityInventory()
|
|
125
|
+
inventory.internal_imports.update(_RE_HTML_SCRIPT.findall(content))
|
|
126
|
+
inventory.internal_imports.update(_RE_HTML_LINK.findall(content))
|
|
127
|
+
title_match = _RE_HTML_TITLE.search(content)
|
|
128
|
+
summary = f"HTML Document: {title_match.group(1).strip()}" if title_match else "HTML Page"
|
|
129
|
+
return inventory, summary
|
|
130
|
+
|
|
131
|
+
def scan(self) -> RepositoryScanResult:
|
|
132
|
+
result = RepositoryScanResult(root_path=self.root_path)
|
|
133
|
+
|
|
134
|
+
if self.root_path.is_file():
|
|
135
|
+
scan_targets = [self.root_path]
|
|
136
|
+
else:
|
|
137
|
+
scan_targets = [
|
|
138
|
+
p for p in sorted(self.root_path.rglob("*"))
|
|
139
|
+
if p.is_file() and not any(part in self.ignores for part in p.parts)
|
|
140
|
+
]
|
|
141
|
+
|
|
142
|
+
for p in scan_targets:
|
|
143
|
+
lang = self._determine_language(p)
|
|
144
|
+
if lang == LanguageKind.UNKNOWN:
|
|
145
|
+
continue
|
|
146
|
+
|
|
147
|
+
try:
|
|
148
|
+
raw_bytes = p.stat().st_size
|
|
149
|
+
content = p.read_text(encoding="utf-8", errors="replace")
|
|
150
|
+
loc = len([ln for ln in content.splitlines() if ln.strip() and not ln.strip().startswith(("#", "//", "/*"))])
|
|
151
|
+
|
|
152
|
+
if lang == LanguageKind.PYTHON:
|
|
153
|
+
inv, summary = self._parse_python(content, p)
|
|
154
|
+
elif lang in (LanguageKind.TYPESCRIPT, LanguageKind.JAVASCRIPT):
|
|
155
|
+
inv, summary = self._parse_typescript(content)
|
|
156
|
+
elif lang == LanguageKind.RUST:
|
|
157
|
+
inv, summary = self._parse_rust(content)
|
|
158
|
+
elif lang == LanguageKind.HTML:
|
|
159
|
+
inv, summary = self._parse_html(content)
|
|
160
|
+
else:
|
|
161
|
+
inv, summary = EntityInventory(), ""
|
|
162
|
+
|
|
163
|
+
rel_str = str(p.relative_to(self.root_path)) if self.root_path.is_dir() else p.name
|
|
164
|
+
result.files[rel_str] = FileMetrics(
|
|
165
|
+
file_path=p,
|
|
166
|
+
relative_str=rel_str,
|
|
167
|
+
language=lang,
|
|
168
|
+
loc=loc,
|
|
169
|
+
raw_size_bytes=raw_bytes,
|
|
170
|
+
inventory=inv,
|
|
171
|
+
docstring_or_summary=summary,
|
|
172
|
+
)
|
|
173
|
+
except Exception:
|
|
174
|
+
pass
|
|
175
|
+
|
|
176
|
+
return result
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"""
|
|
2
|
+
nex_trace_components/reporter.py - Rich Terminal Visualizer & Deep Inventory Breakdown.
|
|
3
|
+
Renders interactive colored file trees, metrics audits, and complete entity tables.
|
|
4
|
+
"""
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
7
|
+
import os
|
|
8
|
+
from typing import Dict
|
|
9
|
+
from rich.box import ROUNDED, SIMPLE
|
|
10
|
+
from rich.console import Console
|
|
11
|
+
from rich.panel import Panel
|
|
12
|
+
from rich.table import Table
|
|
13
|
+
from rich.tree import Tree
|
|
14
|
+
|
|
15
|
+
from .models import RepositoryScanResult
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class CartographyReporter:
|
|
19
|
+
def __init__(self, scan_result: RepositoryScanResult, console: Console) -> None:
|
|
20
|
+
self.scan = scan_result
|
|
21
|
+
self.console = console
|
|
22
|
+
|
|
23
|
+
def render_topology_tree(self) -> Tree:
|
|
24
|
+
root_tree = Tree(f"[bold cyan]📁 {self.scan.root_path.name}[/bold cyan] [dim](Project Root)[/dim]")
|
|
25
|
+
dir_nodes: Dict[str, Tree] = {"": root_tree}
|
|
26
|
+
|
|
27
|
+
for rel_str, file_meta in sorted(self.scan.files.items()):
|
|
28
|
+
parts = rel_str.split(os.sep)
|
|
29
|
+
current_path = ""
|
|
30
|
+
for part in parts[:-1]:
|
|
31
|
+
parent_path = current_path
|
|
32
|
+
current_path = os.path.join(current_path, part) if current_path else part
|
|
33
|
+
if current_path not in dir_nodes:
|
|
34
|
+
folder_color = "bold yellow" if part.endswith(("_components", "components")) else "bold blue"
|
|
35
|
+
dir_nodes[current_path] = dir_nodes[parent_path].add(f"[{folder_color}]📁 {part}/[/{folder_color}]")
|
|
36
|
+
|
|
37
|
+
parent_node = dir_nodes[current_path]
|
|
38
|
+
inv = file_meta.inventory
|
|
39
|
+
entities_count = len(inv.classes_or_structs) + len(inv.interfaces_or_traits) + len(inv.functions_or_methods)
|
|
40
|
+
lang_style = "green" if file_meta.language.value == "Python" else ("blue" if "TypeScript" in file_meta.language.value else "yellow")
|
|
41
|
+
|
|
42
|
+
node = parent_node.add(
|
|
43
|
+
f"[{lang_style}]{parts[-1]}[/{lang_style}] [dim]({file_meta.loc} LOC | {entities_count} symbols)[/dim]"
|
|
44
|
+
)
|
|
45
|
+
if inv.classes_or_structs:
|
|
46
|
+
node.add(f"[cyan]entities:[/cyan] [dim]{', '.join(inv.classes_or_structs[:4])}{'...' if len(inv.classes_or_structs) > 4 else ''}[/dim]")
|
|
47
|
+
if inv.functions_or_methods:
|
|
48
|
+
node.add(f"[magenta]routines:[/magenta] [dim]{', '.join(inv.functions_or_methods[:4])}{'...' if len(inv.functions_or_methods) > 4 else ''}[/dim]")
|
|
49
|
+
|
|
50
|
+
return root_tree
|
|
51
|
+
|
|
52
|
+
def render_metrics_summary(self) -> Table:
|
|
53
|
+
table = Table(box=ROUNDED, title="📊 REPOSITORY METRICS & AUDIT PROFILE")
|
|
54
|
+
table.add_column("Dimension", style="cyan", justify="left")
|
|
55
|
+
table.add_column("Count / Value", style="bold green", justify="right")
|
|
56
|
+
|
|
57
|
+
table.add_row("Scanned Polyglot Files", f"{len(self.scan.files):,}")
|
|
58
|
+
table.add_row("Productive Lines of Code (LOC)", f"{self.scan.total_loc:,}")
|
|
59
|
+
table.add_row("Raw Payload Footprint", f"{self.scan.total_bytes / 1024:.2f} KB")
|
|
60
|
+
table.add_row("External Ecosystem Dependencies", f"{len(self.scan.all_external_imports):,}")
|
|
61
|
+
table.add_row("Internal Module Couplings", f"{len(self.scan.all_internal_imports):,}")
|
|
62
|
+
table.add_row("Classes, Structs & Enums", f"{len(self.scan.all_classes):,}")
|
|
63
|
+
table.add_row("Interfaces & Traits", f"{len(self.scan.all_interfaces):,}")
|
|
64
|
+
table.add_row("Functions, Coroutines & Methods", f"{len(self.scan.all_functions):,}")
|
|
65
|
+
return table
|
|
66
|
+
|
|
67
|
+
def render_detailed_inventory_breakdown(self) -> None:
|
|
68
|
+
self.console.print("\n[bold yellow]══════════════════════════════════════════════════════════════════════════════[/bold yellow]")
|
|
69
|
+
self.console.print(" [bold white]COMPLETE SYSTEM BREAKDOWN: IMPORTS, ENTITIES, ROUTINES & ROUTES[/bold white]")
|
|
70
|
+
self.console.print("[bold yellow]══════════════════════════════════════════════════════════════════════════════[/bold yellow]\n")
|
|
71
|
+
|
|
72
|
+
dep_table = Table(box=SIMPLE, title="📦 THIRD-PARTY / ECOSYSTEM DEPENDENCIES")
|
|
73
|
+
dep_table.add_column("Package / Crate / Module", style="bold cyan")
|
|
74
|
+
dep_table.add_column("Referenced Across Files", style="dim")
|
|
75
|
+
for pkg in sorted(self.scan.all_external_imports):
|
|
76
|
+
refs = [rel for rel, f in self.scan.files.items() if pkg in f.inventory.external_imports]
|
|
77
|
+
dep_table.add_row(pkg, ", ".join(refs[:3]) + (f" (+{len(refs)-3} more)" if len(refs) > 3 else ""))
|
|
78
|
+
self.console.print(dep_table)
|
|
79
|
+
self.console.print("\n")
|
|
80
|
+
|
|
81
|
+
detail_table = Table(box=ROUNDED, title="🔍 GRANULAR FILE-BY-FILE AST INVENTORY")
|
|
82
|
+
detail_table.add_column("File / Language", style="green", ratio=2)
|
|
83
|
+
detail_table.add_column("Classes / Structs", style="cyan", ratio=2)
|
|
84
|
+
detail_table.add_column("Functions / Endpoints", style="magenta", ratio=3)
|
|
85
|
+
detail_table.add_column("Internal Upstream Links", style="dim", ratio=2)
|
|
86
|
+
|
|
87
|
+
for rel, f in sorted(self.scan.files.items()):
|
|
88
|
+
inv = f.inventory
|
|
89
|
+
classes_str = ", ".join(inv.classes_or_structs) or "—"
|
|
90
|
+
if inv.interfaces_or_traits:
|
|
91
|
+
classes_str += f"\n[dim]Traits:[/dim] {', '.join(inv.interfaces_or_traits)}"
|
|
92
|
+
|
|
93
|
+
fns_str = ", ".join(inv.functions_or_methods[:6])
|
|
94
|
+
if len(inv.functions_or_methods) > 6:
|
|
95
|
+
fns_str += f" (+{len(inv.functions_or_methods) - 6} more)"
|
|
96
|
+
if inv.routes_or_endpoints:
|
|
97
|
+
fns_str += f"\n[bold yellow]Routes:[/bold yellow] {', '.join(inv.routes_or_endpoints)}"
|
|
98
|
+
fns_str = fns_str or "—"
|
|
99
|
+
|
|
100
|
+
links_str = ", ".join(sorted(inv.internal_imports)[:4]) or "—"
|
|
101
|
+
detail_table.add_row(
|
|
102
|
+
f"[bold]{rel}[/bold]\n[dim]({f.language.value} - {f.loc} LOC)[/dim]",
|
|
103
|
+
classes_str,
|
|
104
|
+
fns_str,
|
|
105
|
+
links_str,
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
self.console.print(detail_table)
|
|
109
|
+
|
|
110
|
+
def render_full_dashboard(self, breakdown_only: bool = False) -> None:
|
|
111
|
+
if not breakdown_only:
|
|
112
|
+
self.console.print("\n")
|
|
113
|
+
self.console.print(self.render_metrics_summary())
|
|
114
|
+
self.console.print("\n")
|
|
115
|
+
self.console.print(self.render_topology_tree())
|
|
116
|
+
self.console.print("\n")
|
|
117
|
+
self.render_detailed_inventory_breakdown()
|
|
118
|
+
self.console.print("\n")
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "nex-trace"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Polyglot AST Cartographer & Deep System Introspection Engine for Autonomous AI Agents"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = { text = "MIT OR Apache-2.0" }
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "The Trinity", email = "inquiries@houseoflawpc.com" }
|
|
14
|
+
]
|
|
15
|
+
keywords = ["ast", "cartography", "introspection", "polyglot", "dependencies", "ai-agents", "mermaid", "telemetry"]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 5 - Production/Stable",
|
|
18
|
+
"Intended Audience :: Developers",
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"Programming Language :: Python :: 3.10",
|
|
21
|
+
"Programming Language :: Python :: 3.11",
|
|
22
|
+
"Programming Language :: Python :: 3.12",
|
|
23
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
24
|
+
"Topic :: Software Development :: Quality Assurance",
|
|
25
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
26
|
+
]
|
|
27
|
+
dependencies = [
|
|
28
|
+
"rich>=13.7.0",
|
|
29
|
+
"nex-init>=0.1.0",
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
[project.optional-dependencies]
|
|
33
|
+
fast = [
|
|
34
|
+
"tree-sitter>=0.22.0",
|
|
35
|
+
"tree-sitter-language-pack>=0.1.0",
|
|
36
|
+
"blake3>=0.3.0",
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
[project.scripts]
|
|
40
|
+
nex-trace = "nex_trace:main"
|
|
41
|
+
nextrace = "nex_trace:main"
|
|
42
|
+
|
|
43
|
+
[tool.setuptools]
|
|
44
|
+
py-modules = ["nex_trace"]
|
|
45
|
+
|
|
46
|
+
[tool.setuptools.packages.find]
|
|
47
|
+
where = ["."]
|
|
48
|
+
include = ["nex_trace_components", "nex_trace_components.*"]
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
"""
|
|
2
|
+
tests/test_nex_trace.py - Comprehensive Verification & Falsification Suite for nex-trace.
|
|
3
|
+
Validates:
|
|
4
|
+
1. Polyglot AST extraction (Python, TypeScript, Rust, HTML).
|
|
5
|
+
2. Dynamic routing and parent proxying via nex-init.
|
|
6
|
+
3. Resiliency against corrupted/binary files and malformed syntax.
|
|
7
|
+
4. CLI end-to-end execution across --map json, --map mermaid, --breakdown-only, --ignore.
|
|
8
|
+
5. Strict JSON serialization and schema completeness.
|
|
9
|
+
"""
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
import json
|
|
13
|
+
import subprocess
|
|
14
|
+
import sys
|
|
15
|
+
import tempfile
|
|
16
|
+
import unittest
|
|
17
|
+
from pathlib import Path
|
|
18
|
+
|
|
19
|
+
import nex_trace
|
|
20
|
+
import nex_trace_components as _comp
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class TestNexTraceCore(unittest.TestCase):
|
|
24
|
+
def setUp(self) -> None:
|
|
25
|
+
self.test_dir = tempfile.TemporaryDirectory()
|
|
26
|
+
self.root = Path(self.test_dir.name)
|
|
27
|
+
|
|
28
|
+
# 1. Clean Python Fixture (Decorators, Classes, Endpoints)
|
|
29
|
+
(self.root / "app.py").write_text(
|
|
30
|
+
'"""Main API Entry."""\n'
|
|
31
|
+
'import os\n'
|
|
32
|
+
'import fastapi\n\n'
|
|
33
|
+
'class ServerConfig:\n'
|
|
34
|
+
' port: int = 8080\n\n'
|
|
35
|
+
'@fastapi.get("/health")\n'
|
|
36
|
+
'def health_check():\n'
|
|
37
|
+
' return {"status": "ok"}\n\n'
|
|
38
|
+
'@fastapi.post("/submit")\n'
|
|
39
|
+
'async def submit_payload(data: dict):\n'
|
|
40
|
+
' return {"received": True}\n',
|
|
41
|
+
encoding="utf-8",
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
# 2. TypeScript / React Fixture (Interfaces, Types, Arrow Functions)
|
|
45
|
+
(self.root / "frontend.tsx").write_text(
|
|
46
|
+
'import React from "react";\n'
|
|
47
|
+
'import { useQuery } from "@tanstack/react-query";\n'
|
|
48
|
+
'import { Header } from "./components/Header";\n\n'
|
|
49
|
+
'export interface UserProfile {\n'
|
|
50
|
+
' id: string;\n'
|
|
51
|
+
'}\n\n'
|
|
52
|
+
'export type UserRole = "ADMIN" | "GUEST";\n\n'
|
|
53
|
+
'export const UserView = () => {\n'
|
|
54
|
+
' return <div>User</div>;\n'
|
|
55
|
+
'};\n\n'
|
|
56
|
+
'export async function fetchUser(id: string) {\n'
|
|
57
|
+
' return { id };\n'
|
|
58
|
+
'}\n',
|
|
59
|
+
encoding="utf-8",
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
# 3. Rust Fixture (Structs, Enums, Traits, Functions)
|
|
63
|
+
(self.root / "engine.rs").write_text(
|
|
64
|
+
'use std::sync::Arc;\n'
|
|
65
|
+
'use crate::memory::Pool;\n\n'
|
|
66
|
+
'pub struct RingBuffer {\n'
|
|
67
|
+
' capacity: usize,\n'
|
|
68
|
+
'}\n\n'
|
|
69
|
+
'pub enum State {\n'
|
|
70
|
+
' Idle,\n'
|
|
71
|
+
' Active,\n'
|
|
72
|
+
'}\n\n'
|
|
73
|
+
'pub trait QueueTrait {\n'
|
|
74
|
+
' fn push(&mut self);\n'
|
|
75
|
+
'}\n\n'
|
|
76
|
+
'pub fn init_engine() -> bool {\n'
|
|
77
|
+
' true\n'
|
|
78
|
+
'}\n',
|
|
79
|
+
encoding="utf-8",
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
# 4. HTML Fixture (Links, Scripts, Title)
|
|
83
|
+
(self.root / "index.html").write_text(
|
|
84
|
+
'<!DOCTYPE html>\n'
|
|
85
|
+
'<html>\n'
|
|
86
|
+
'<head>\n'
|
|
87
|
+
' <title>Nex Trace Dashboard</title>\n'
|
|
88
|
+
' <link rel="stylesheet" href="/styles.css">\n'
|
|
89
|
+
' <script src="/bundle.js"></script>\n'
|
|
90
|
+
'</head>\n'
|
|
91
|
+
'<body><h1>Dashboard</h1></body>\n'
|
|
92
|
+
'</html>\n',
|
|
93
|
+
encoding="utf-8",
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
def tearDown(self) -> None:
|
|
97
|
+
self.test_dir.cleanup()
|
|
98
|
+
|
|
99
|
+
def test_parent_proxy_exports(self) -> None:
|
|
100
|
+
"""Verify that parent orchestrator nex_trace lazily exports component symbols."""
|
|
101
|
+
self.assertTrue(hasattr(nex_trace, "PolyglotEngine"))
|
|
102
|
+
self.assertTrue(hasattr(nex_trace, "CartographyReporter"))
|
|
103
|
+
self.assertTrue(hasattr(_comp, "MermaidGenerator"))
|
|
104
|
+
self.assertTrue(hasattr(_comp, "LanguageKind"))
|
|
105
|
+
self.assertTrue(hasattr(_comp, "RepositoryScanResult"))
|
|
106
|
+
|
|
107
|
+
def test_polyglot_scan_coverage(self) -> None:
|
|
108
|
+
"""Verifies multi-language entity and routing extraction."""
|
|
109
|
+
engine = nex_trace.PolyglotEngine(root_path=self.root)
|
|
110
|
+
scan = engine.scan()
|
|
111
|
+
|
|
112
|
+
self.assertEqual(len(scan.files), 4)
|
|
113
|
+
|
|
114
|
+
# Python verification
|
|
115
|
+
py_meta = scan.files["app.py"]
|
|
116
|
+
self.assertEqual(py_meta.language.value, "Python")
|
|
117
|
+
self.assertIn("ServerConfig", py_meta.inventory.classes_or_structs)
|
|
118
|
+
self.assertIn("health_check", py_meta.inventory.functions_or_methods)
|
|
119
|
+
self.assertIn("submit_payload", py_meta.inventory.functions_or_methods)
|
|
120
|
+
self.assertEqual(len(py_meta.inventory.routes_or_endpoints), 2)
|
|
121
|
+
self.assertIn("fastapi", py_meta.inventory.external_imports)
|
|
122
|
+
|
|
123
|
+
# TypeScript verification
|
|
124
|
+
ts_meta = scan.files["frontend.tsx"]
|
|
125
|
+
self.assertEqual(ts_meta.language.value, "TypeScript")
|
|
126
|
+
self.assertIn("UserProfile", ts_meta.inventory.interfaces_or_traits)
|
|
127
|
+
self.assertIn("UserRole", ts_meta.inventory.type_aliases)
|
|
128
|
+
self.assertIn("UserView", ts_meta.inventory.functions_or_methods)
|
|
129
|
+
self.assertIn("fetchUser", ts_meta.inventory.functions_or_methods)
|
|
130
|
+
self.assertIn("react", ts_meta.inventory.external_imports)
|
|
131
|
+
self.assertIn("./components/Header", ts_meta.inventory.internal_imports)
|
|
132
|
+
|
|
133
|
+
# Rust verification (Normalized to root crate "std")
|
|
134
|
+
rs_meta = scan.files["engine.rs"]
|
|
135
|
+
self.assertEqual(rs_meta.language.value, "Rust")
|
|
136
|
+
self.assertIn("RingBuffer", rs_meta.inventory.classes_or_structs)
|
|
137
|
+
self.assertIn("State", rs_meta.inventory.classes_or_structs)
|
|
138
|
+
self.assertIn("QueueTrait", rs_meta.inventory.interfaces_or_traits)
|
|
139
|
+
self.assertIn("init_engine", rs_meta.inventory.functions_or_methods)
|
|
140
|
+
self.assertIn("std", rs_meta.inventory.external_imports)
|
|
141
|
+
|
|
142
|
+
# HTML verification
|
|
143
|
+
html_meta = scan.files["index.html"]
|
|
144
|
+
self.assertEqual(html_meta.language.value, "HTML")
|
|
145
|
+
self.assertIn("/bundle.js", html_meta.inventory.internal_imports)
|
|
146
|
+
self.assertIn("/styles.css", html_meta.inventory.internal_imports)
|
|
147
|
+
self.assertIn("Nex Trace Dashboard", html_meta.docstring_or_summary)
|
|
148
|
+
|
|
149
|
+
def test_mermaid_generation(self) -> None:
|
|
150
|
+
"""Verifies Mermaid diagram structure and node linkage."""
|
|
151
|
+
engine = nex_trace.PolyglotEngine(root_path=self.root)
|
|
152
|
+
scan = engine.scan()
|
|
153
|
+
mermaid = _comp.MermaidGenerator.generate(scan)
|
|
154
|
+
|
|
155
|
+
self.assertTrue(mermaid.startswith("```mermaid\ngraph TD"))
|
|
156
|
+
self.assertIn("app.py", mermaid)
|
|
157
|
+
self.assertIn("frontend.tsx", mermaid)
|
|
158
|
+
self.assertIn("engine.rs", mermaid)
|
|
159
|
+
self.assertIn("index.html", mermaid)
|
|
160
|
+
self.assertTrue(mermaid.endswith("```"))
|
|
161
|
+
|
|
162
|
+
def test_json_serialization_integrity(self) -> None:
|
|
163
|
+
"""Verifies that to_dict produces valid, fully populated JSON."""
|
|
164
|
+
engine = nex_trace.PolyglotEngine(root_path=self.root)
|
|
165
|
+
scan = engine.scan()
|
|
166
|
+
data = scan.to_dict()
|
|
167
|
+
|
|
168
|
+
json_str = json.dumps(data)
|
|
169
|
+
parsed = json.loads(json_str)
|
|
170
|
+
|
|
171
|
+
self.assertEqual(parsed["summary"]["total_files"], 4)
|
|
172
|
+
self.assertGreater(parsed["summary"]["total_loc"], 0)
|
|
173
|
+
self.assertIn("files", parsed)
|
|
174
|
+
self.assertIn("app.py", parsed["files"])
|
|
175
|
+
self.assertIn("frontend.tsx", parsed["files"])
|
|
176
|
+
|
|
177
|
+
def test_resilience_to_syntax_errors_and_binary(self) -> None:
|
|
178
|
+
"""Ensures corrupted files, invalid syntax, and raw binary bytes do not crash the engine."""
|
|
179
|
+
(self.root / "broken.py").write_text("def unclosed_syntax(\n return 42", encoding="utf-8")
|
|
180
|
+
(self.root / "corrupted.ts").write_bytes(b"\x00\xFF\xFE\xFD\x80\x81\x82\x83")
|
|
181
|
+
(self.root / "empty.rs").write_text("", encoding="utf-8")
|
|
182
|
+
|
|
183
|
+
engine = nex_trace.PolyglotEngine(root_path=self.root)
|
|
184
|
+
scan = engine.scan()
|
|
185
|
+
|
|
186
|
+
self.assertIn("broken.py", scan.files)
|
|
187
|
+
self.assertIn("corrupted.ts", scan.files)
|
|
188
|
+
self.assertIn("empty.rs", scan.files)
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
class TestNexTraceCLI(unittest.TestCase):
|
|
192
|
+
"""End-to-end integration tests invoking nex_trace via CLI subprocess."""
|
|
193
|
+
|
|
194
|
+
def setUp(self) -> None:
|
|
195
|
+
self.test_dir = tempfile.TemporaryDirectory()
|
|
196
|
+
self.root = Path(self.test_dir.name)
|
|
197
|
+
(self.root / "example.py").write_text(
|
|
198
|
+
'class Foo:\n def bar(self): pass\n', encoding="utf-8"
|
|
199
|
+
)
|
|
200
|
+
self.cli_path = Path(__file__).resolve().parent.parent / "nex_trace.py"
|
|
201
|
+
|
|
202
|
+
def tearDown(self) -> None:
|
|
203
|
+
self.test_dir.cleanup()
|
|
204
|
+
|
|
205
|
+
def test_cli_map_json(self) -> None:
|
|
206
|
+
"""Runs `python3 nex_trace.py <dir> --map json` and verifies valid JSON stdout."""
|
|
207
|
+
proc = subprocess.run(
|
|
208
|
+
[sys.executable, str(self.cli_path), str(self.root), "--map", "json"],
|
|
209
|
+
capture_output=True,
|
|
210
|
+
text=True,
|
|
211
|
+
)
|
|
212
|
+
self.assertEqual(proc.returncode, 0, f"CLI stderr: {proc.stderr}")
|
|
213
|
+
data = json.loads(proc.stdout)
|
|
214
|
+
self.assertEqual(data["summary"]["total_files"], 1)
|
|
215
|
+
self.assertIn("example.py", data["files"])
|
|
216
|
+
|
|
217
|
+
def test_cli_map_mermaid(self) -> None:
|
|
218
|
+
"""Runs `python3 nex_trace.py <dir> --map mermaid` and verifies diagram output."""
|
|
219
|
+
proc = subprocess.run(
|
|
220
|
+
[sys.executable, str(self.cli_path), str(self.root), "--map", "mermaid"],
|
|
221
|
+
capture_output=True,
|
|
222
|
+
text=True,
|
|
223
|
+
)
|
|
224
|
+
self.assertEqual(proc.returncode, 0, f"CLI stderr: {proc.stderr}")
|
|
225
|
+
self.assertIn("```mermaid", proc.stdout)
|
|
226
|
+
self.assertIn("example.py", proc.stdout)
|
|
227
|
+
|
|
228
|
+
def test_cli_breakdown_only(self) -> None:
|
|
229
|
+
"""Runs `python3 nex_trace.py <dir> --breakdown-only`."""
|
|
230
|
+
proc = subprocess.run(
|
|
231
|
+
[sys.executable, str(self.cli_path), str(self.root), "--breakdown-only"],
|
|
232
|
+
capture_output=True,
|
|
233
|
+
text=True,
|
|
234
|
+
)
|
|
235
|
+
self.assertEqual(proc.returncode, 0, f"CLI stderr: {proc.stderr}")
|
|
236
|
+
self.assertIn("COMPLETE SYSTEM BREAKDOWN", proc.stdout)
|
|
237
|
+
|
|
238
|
+
def test_cli_ignore_flag(self) -> None:
|
|
239
|
+
"""Verifies that the --ignore flag successfully excludes target folders."""
|
|
240
|
+
secret_dir = self.root / "secret_submodule"
|
|
241
|
+
secret_dir.mkdir(parents=True, exist_ok=True)
|
|
242
|
+
(secret_dir / "hidden.py").write_text("class Hidden: pass\n", encoding="utf-8")
|
|
243
|
+
|
|
244
|
+
proc = subprocess.run(
|
|
245
|
+
[
|
|
246
|
+
sys.executable, str(self.cli_path), str(self.root),
|
|
247
|
+
"--ignore", "secret_submodule", "--map", "json"
|
|
248
|
+
],
|
|
249
|
+
capture_output=True,
|
|
250
|
+
text=True,
|
|
251
|
+
)
|
|
252
|
+
self.assertEqual(proc.returncode, 0, f"CLI stderr: {proc.stderr}")
|
|
253
|
+
data = json.loads(proc.stdout)
|
|
254
|
+
self.assertNotIn("secret_submodule/hidden.py", data["files"])
|
|
255
|
+
self.assertEqual(data["summary"]["total_files"], 1)
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
if __name__ == "__main__":
|
|
259
|
+
unittest.main()
|