code2schema 0.1.1__tar.gz → 0.1.2__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.
- {code2schema-0.1.1 → code2schema-0.1.2}/PKG-INFO +87 -26
- {code2schema-0.1.1 → code2schema-0.1.2}/README.md +86 -25
- {code2schema-0.1.1 → code2schema-0.1.2}/code2schema/__init__.py +1 -1
- {code2schema-0.1.1 → code2schema-0.1.2}/code2schema/cli.py +51 -9
- {code2schema-0.1.1 → code2schema-0.1.2}/code2schema.egg-info/PKG-INFO +87 -26
- {code2schema-0.1.1 → code2schema-0.1.2}/pyproject.toml +1 -1
- {code2schema-0.1.1 → code2schema-0.1.2}/LICENSE +0 -0
- {code2schema-0.1.1 → code2schema-0.1.2}/code2schema/analyzer/__init__.py +0 -0
- {code2schema-0.1.1 → code2schema-0.1.2}/code2schema/analyzer/cqrs.py +0 -0
- {code2schema-0.1.1 → code2schema-0.1.2}/code2schema/analyzer/events.py +0 -0
- {code2schema-0.1.1 → code2schema-0.1.2}/code2schema/analyzer/graph.py +0 -0
- {code2schema-0.1.1 → code2schema-0.1.2}/code2schema/codegen/__init__.py +0 -0
- {code2schema-0.1.1 → code2schema-0.1.2}/code2schema/codegen/visualizer.py +0 -0
- {code2schema-0.1.1 → code2schema-0.1.2}/code2schema/core/__init__.py +0 -0
- {code2schema-0.1.1 → code2schema-0.1.2}/code2schema/core/extractor.py +0 -0
- {code2schema-0.1.1 → code2schema-0.1.2}/code2schema/core/models.py +0 -0
- {code2schema-0.1.1 → code2schema-0.1.2}/code2schema.egg-info/SOURCES.txt +0 -0
- {code2schema-0.1.1 → code2schema-0.1.2}/code2schema.egg-info/dependency_links.txt +0 -0
- {code2schema-0.1.1 → code2schema-0.1.2}/code2schema.egg-info/entry_points.txt +0 -0
- {code2schema-0.1.1 → code2schema-0.1.2}/code2schema.egg-info/requires.txt +0 -0
- {code2schema-0.1.1 → code2schema-0.1.2}/code2schema.egg-info/top_level.txt +0 -0
- {code2schema-0.1.1 → code2schema-0.1.2}/setup.cfg +0 -0
- {code2schema-0.1.1 → code2schema-0.1.2}/tests/test_code2schema.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: code2schema
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.2
|
|
4
4
|
Summary: Semantic compiler: Code → AST → CQRS Model → Workflow DAG → Proto/Schema
|
|
5
5
|
License: Apache-2.0
|
|
6
6
|
Keywords: ast,cqrs,static-analysis,code-quality,schema
|
|
@@ -34,18 +34,16 @@ Dynamic: license-file
|
|
|
34
34
|
|
|
35
35
|
## AI Cost Tracking
|
|
36
36
|
|
|
37
|
-
     
|
|
38
|
+
  
|
|
39
39
|
|
|
40
40
|
- 🤖 **LLM usage:** $0.1500 (1 commits)
|
|
41
|
-
- 👤 **Human dev:** ~$
|
|
41
|
+
- 👤 **Human dev:** ~$200 (2.0h @ $100/h, 30min dedup)
|
|
42
42
|
|
|
43
43
|
Generated on 2026-05-04 using [openrouter/qwen/qwen3-coder-next](https://openrouter.ai/qwen/qwen3-coder-next)
|
|
44
44
|
|
|
45
45
|
---
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
49
47
|
**Semantic Compiler for Software Systems**
|
|
50
48
|
|
|
51
49
|
Przekształca kod Python w model semantyczny CQRS → kontrakty API → graf architektury.
|
|
@@ -80,33 +78,81 @@ pip install "code2schema[dev]" # pytest + ruff + black
|
|
|
80
78
|
## Szybki start
|
|
81
79
|
|
|
82
80
|
```bash
|
|
83
|
-
#
|
|
84
|
-
code2schema
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
81
|
+
# Analiza z auto-generowanymi nazwami plików (w katalogu bieżącym)
|
|
82
|
+
code2schema /home/tom/github/maskservice/c2004/backend
|
|
83
|
+
# → c2004_schema.json
|
|
84
|
+
|
|
85
|
+
# Pełna analiza ze wszystkimi formatami wyjściowymi
|
|
86
|
+
code2schema ./backend --proto --md --html
|
|
87
|
+
# → backend_schema.json
|
|
88
|
+
# → backend_api.proto
|
|
89
|
+
# → backend_report.md
|
|
90
|
+
# → backend_viz.html
|
|
91
|
+
|
|
92
|
+
# Pełna analiza ze szczegółami
|
|
93
|
+
code2schema ./backend --proto --md --html --graph-summary --events --cycles
|
|
93
94
|
```
|
|
94
95
|
|
|
95
96
|
Przykładowy output:
|
|
96
97
|
|
|
97
98
|
```
|
|
98
|
-
✅ Gotowe (1.
|
|
99
|
-
Modules :
|
|
100
|
-
Functions:
|
|
101
|
-
Queries :
|
|
102
|
-
Commands :
|
|
103
|
-
Orchest. :
|
|
104
|
-
Workflows:
|
|
105
|
-
Rules :
|
|
106
|
-
Graph :
|
|
107
|
-
→
|
|
99
|
+
✅ Gotowe (1.8s)
|
|
100
|
+
Modules : 607
|
|
101
|
+
Functions: 3142
|
|
102
|
+
Queries : 1518
|
|
103
|
+
Commands : 505
|
|
104
|
+
Orchest. : 1119
|
|
105
|
+
Workflows: 1118
|
|
106
|
+
Rules : 320
|
|
107
|
+
Graph : 2922N / 5612E
|
|
108
|
+
→ c2004_schema.json
|
|
109
|
+
→ c2004_api.proto
|
|
110
|
+
→ c2004_report.md
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Test na dużym projekcie (c2004 backend)
|
|
114
|
+
|
|
115
|
+
Analiza produkcyjnego projektu IoT (607 modułów, 3142 funkcje):
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
code2schema /home/tom/github/maskservice/c2004/backend --proto --md --html
|
|
119
|
+
# Pliki generowane w /home/tom/github/maskservice/c2004/ (katalog projektu)
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
**Wyniki:**
|
|
123
|
+
```
|
|
124
|
+
✅ Gotowe (1.8s)
|
|
125
|
+
Modules : 607
|
|
126
|
+
Functions: 3142
|
|
127
|
+
Queries : 1518
|
|
128
|
+
Commands : 505
|
|
129
|
+
Orchest. : 1119
|
|
130
|
+
Workflows: 1118
|
|
131
|
+
Rules : 320
|
|
132
|
+
Graph : 2922N / 5612E
|
|
133
|
+
→ c2004_schema.json
|
|
134
|
+
→ c2004_api.proto
|
|
135
|
+
→ c2004_report.md
|
|
136
|
+
→ c2004_viz.html
|
|
108
137
|
```
|
|
109
138
|
|
|
139
|
+
## Dokumentacja i przykłady
|
|
140
|
+
|
|
141
|
+
- **[Dokumentacja](docs/)** — przykłady użycia CLI i Python API
|
|
142
|
+
- [CLI examples](docs/examples/cli/basic.sh)
|
|
143
|
+
- [Python API — basic](docs/examples/api/basic.py)
|
|
144
|
+
- [Python API — advanced](docs/examples/api/advanced.py)
|
|
145
|
+
- [Sample outputs](docs/examples/outputs/)
|
|
146
|
+
|
|
147
|
+
Wykryte cykle w architekturze CQRS (do refaktoryzacji):
|
|
148
|
+
- `handle → publish → _execute → publish → handle`
|
|
149
|
+
|
|
150
|
+
**Wygenerowane artefakty:**
|
|
151
|
+
- `c2004_schema.json` (2.9MB) — pełny model
|
|
152
|
+
- `c2004_api.proto` (188KB) — gRPC contracts
|
|
153
|
+
- `c2004_report.md` (49KB) — podsumowanie jakości
|
|
154
|
+
- `c2004_viz.html` (1.1MB) — **interaktywny graf D3.js** z wyszukiwaniem i filtrowaniem
|
|
155
|
+
|
|
110
156
|
## Użycie w kodzie
|
|
111
157
|
|
|
112
158
|
```python
|
|
@@ -138,6 +184,21 @@ print(to_proto(schema))
|
|
|
138
184
|
print(to_markdown(schema))
|
|
139
185
|
```
|
|
140
186
|
|
|
187
|
+
## Wizualizacja HTML (`--html`)
|
|
188
|
+
|
|
189
|
+
Interaktywny graf D3.js z funkcjami:
|
|
190
|
+
- **Kolory ról**: 🟢 Query, 🟠 Command, 🟣 Orchestrator
|
|
191
|
+
- **Wyszukiwanie** — filtruje węzły w czasie rzeczywistym
|
|
192
|
+
- **Hover** — podświetla połączenia (call graph)
|
|
193
|
+
- **Klik** — szczegóły funkcji (fan-out, side effects, reguły jakości)
|
|
194
|
+
- **Filtry** — pokazuj/ukrywaj kategorie ról
|
|
195
|
+
- **Force layout** — przeciąganie węzłów
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
code2schema ./backend --html viz.html
|
|
199
|
+
# Otwórz w przeglądarce: open viz.html
|
|
200
|
+
```
|
|
201
|
+
|
|
141
202
|
## Architektura paczki
|
|
142
203
|
|
|
143
204
|
```
|
|
@@ -3,18 +3,16 @@
|
|
|
3
3
|
|
|
4
4
|
## AI Cost Tracking
|
|
5
5
|
|
|
6
|
-
     
|
|
7
|
+
  
|
|
8
8
|
|
|
9
9
|
- 🤖 **LLM usage:** $0.1500 (1 commits)
|
|
10
|
-
- 👤 **Human dev:** ~$
|
|
10
|
+
- 👤 **Human dev:** ~$200 (2.0h @ $100/h, 30min dedup)
|
|
11
11
|
|
|
12
12
|
Generated on 2026-05-04 using [openrouter/qwen/qwen3-coder-next](https://openrouter.ai/qwen/qwen3-coder-next)
|
|
13
13
|
|
|
14
14
|
---
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
16
|
**Semantic Compiler for Software Systems**
|
|
19
17
|
|
|
20
18
|
Przekształca kod Python w model semantyczny CQRS → kontrakty API → graf architektury.
|
|
@@ -49,33 +47,81 @@ pip install "code2schema[dev]" # pytest + ruff + black
|
|
|
49
47
|
## Szybki start
|
|
50
48
|
|
|
51
49
|
```bash
|
|
52
|
-
#
|
|
53
|
-
code2schema
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
50
|
+
# Analiza z auto-generowanymi nazwami plików (w katalogu bieżącym)
|
|
51
|
+
code2schema /home/tom/github/maskservice/c2004/backend
|
|
52
|
+
# → c2004_schema.json
|
|
53
|
+
|
|
54
|
+
# Pełna analiza ze wszystkimi formatami wyjściowymi
|
|
55
|
+
code2schema ./backend --proto --md --html
|
|
56
|
+
# → backend_schema.json
|
|
57
|
+
# → backend_api.proto
|
|
58
|
+
# → backend_report.md
|
|
59
|
+
# → backend_viz.html
|
|
60
|
+
|
|
61
|
+
# Pełna analiza ze szczegółami
|
|
62
|
+
code2schema ./backend --proto --md --html --graph-summary --events --cycles
|
|
62
63
|
```
|
|
63
64
|
|
|
64
65
|
Przykładowy output:
|
|
65
66
|
|
|
66
67
|
```
|
|
67
|
-
✅ Gotowe (1.
|
|
68
|
-
Modules :
|
|
69
|
-
Functions:
|
|
70
|
-
Queries :
|
|
71
|
-
Commands :
|
|
72
|
-
Orchest. :
|
|
73
|
-
Workflows:
|
|
74
|
-
Rules :
|
|
75
|
-
Graph :
|
|
76
|
-
→
|
|
68
|
+
✅ Gotowe (1.8s)
|
|
69
|
+
Modules : 607
|
|
70
|
+
Functions: 3142
|
|
71
|
+
Queries : 1518
|
|
72
|
+
Commands : 505
|
|
73
|
+
Orchest. : 1119
|
|
74
|
+
Workflows: 1118
|
|
75
|
+
Rules : 320
|
|
76
|
+
Graph : 2922N / 5612E
|
|
77
|
+
→ c2004_schema.json
|
|
78
|
+
→ c2004_api.proto
|
|
79
|
+
→ c2004_report.md
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Test na dużym projekcie (c2004 backend)
|
|
83
|
+
|
|
84
|
+
Analiza produkcyjnego projektu IoT (607 modułów, 3142 funkcje):
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
code2schema /home/tom/github/maskservice/c2004/backend --proto --md --html
|
|
88
|
+
# Pliki generowane w /home/tom/github/maskservice/c2004/ (katalog projektu)
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
**Wyniki:**
|
|
92
|
+
```
|
|
93
|
+
✅ Gotowe (1.8s)
|
|
94
|
+
Modules : 607
|
|
95
|
+
Functions: 3142
|
|
96
|
+
Queries : 1518
|
|
97
|
+
Commands : 505
|
|
98
|
+
Orchest. : 1119
|
|
99
|
+
Workflows: 1118
|
|
100
|
+
Rules : 320
|
|
101
|
+
Graph : 2922N / 5612E
|
|
102
|
+
→ c2004_schema.json
|
|
103
|
+
→ c2004_api.proto
|
|
104
|
+
→ c2004_report.md
|
|
105
|
+
→ c2004_viz.html
|
|
77
106
|
```
|
|
78
107
|
|
|
108
|
+
## Dokumentacja i przykłady
|
|
109
|
+
|
|
110
|
+
- **[Dokumentacja](docs/)** — przykłady użycia CLI i Python API
|
|
111
|
+
- [CLI examples](docs/examples/cli/basic.sh)
|
|
112
|
+
- [Python API — basic](docs/examples/api/basic.py)
|
|
113
|
+
- [Python API — advanced](docs/examples/api/advanced.py)
|
|
114
|
+
- [Sample outputs](docs/examples/outputs/)
|
|
115
|
+
|
|
116
|
+
Wykryte cykle w architekturze CQRS (do refaktoryzacji):
|
|
117
|
+
- `handle → publish → _execute → publish → handle`
|
|
118
|
+
|
|
119
|
+
**Wygenerowane artefakty:**
|
|
120
|
+
- `c2004_schema.json` (2.9MB) — pełny model
|
|
121
|
+
- `c2004_api.proto` (188KB) — gRPC contracts
|
|
122
|
+
- `c2004_report.md` (49KB) — podsumowanie jakości
|
|
123
|
+
- `c2004_viz.html` (1.1MB) — **interaktywny graf D3.js** z wyszukiwaniem i filtrowaniem
|
|
124
|
+
|
|
79
125
|
## Użycie w kodzie
|
|
80
126
|
|
|
81
127
|
```python
|
|
@@ -107,6 +153,21 @@ print(to_proto(schema))
|
|
|
107
153
|
print(to_markdown(schema))
|
|
108
154
|
```
|
|
109
155
|
|
|
156
|
+
## Wizualizacja HTML (`--html`)
|
|
157
|
+
|
|
158
|
+
Interaktywny graf D3.js z funkcjami:
|
|
159
|
+
- **Kolory ról**: 🟢 Query, 🟠 Command, 🟣 Orchestrator
|
|
160
|
+
- **Wyszukiwanie** — filtruje węzły w czasie rzeczywistym
|
|
161
|
+
- **Hover** — podświetla połączenia (call graph)
|
|
162
|
+
- **Klik** — szczegóły funkcji (fan-out, side effects, reguły jakości)
|
|
163
|
+
- **Filtry** — pokazuj/ukrywaj kategorie ról
|
|
164
|
+
- **Force layout** — przeciąganie węzłów
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
code2schema ./backend --html viz.html
|
|
168
|
+
# Otwórz w przeglądarce: open viz.html
|
|
169
|
+
```
|
|
170
|
+
|
|
110
171
|
## Architektura paczki
|
|
111
172
|
|
|
112
173
|
```
|
|
@@ -16,18 +16,38 @@ from code2schema.analyzer.graph import (
|
|
|
16
16
|
build_rich_graph, detect_cycles, graph_summary, write_dot, write_graphml,
|
|
17
17
|
)
|
|
18
18
|
from code2schema.codegen import write_json, write_markdown, write_proto
|
|
19
|
+
from code2schema.codegen.visualizer import write_html
|
|
19
20
|
from code2schema.core.extractor import extract_project
|
|
20
21
|
|
|
21
22
|
|
|
23
|
+
def _project_name_from_path(path: Path) -> str:
|
|
24
|
+
"""Extract project name from path (e.g., /path/to/c2004/backend -> c2004)."""
|
|
25
|
+
# Try to find a meaningful name from the path
|
|
26
|
+
parts = path.parts
|
|
27
|
+
for i, part in enumerate(reversed(parts)):
|
|
28
|
+
if part in ("backend", "frontend", "src", "app", "api"):
|
|
29
|
+
# Use parent directory name
|
|
30
|
+
if i < len(parts) - 1:
|
|
31
|
+
return parts[-(i + 2)]
|
|
32
|
+
# Skip common generic names
|
|
33
|
+
if part not in ("home", "github", "workspace", "projects", "src"):
|
|
34
|
+
return part
|
|
35
|
+
return path.name or "project"
|
|
36
|
+
|
|
37
|
+
|
|
22
38
|
def main(argv=None):
|
|
23
39
|
parser = argparse.ArgumentParser(prog="code2schema",
|
|
24
40
|
description="Semantic Compiler: Code → CQRS → Schema / Proto / Graph")
|
|
25
41
|
parser.add_argument("path")
|
|
26
|
-
parser.add_argument("-o", "--out",
|
|
27
|
-
parser.add_argument("--proto", metavar="FILE"
|
|
28
|
-
|
|
42
|
+
parser.add_argument("-o", "--out", metavar="FILE", help="Output JSON schema (default: <project>_schema.json)")
|
|
43
|
+
parser.add_argument("--proto", metavar="FILE", nargs="?", const=True, default=None,
|
|
44
|
+
help="Output .proto file (default: <project>_api.proto if flag present)")
|
|
45
|
+
parser.add_argument("--md", metavar="FILE", nargs="?", const=True, default=None,
|
|
46
|
+
help="Output Markdown report (default: <project>_report.md if flag present)")
|
|
29
47
|
parser.add_argument("--graphml", metavar="FILE")
|
|
30
48
|
parser.add_argument("--dot", metavar="FILE")
|
|
49
|
+
parser.add_argument("--html", metavar="FILE", nargs="?", const=True, default=None,
|
|
50
|
+
help="Interactive HTML visualization (default: <project>_viz.html if flag present)")
|
|
31
51
|
parser.add_argument("--events", action="store_true")
|
|
32
52
|
parser.add_argument("--cycles", action="store_true")
|
|
33
53
|
parser.add_argument("--graph-summary", action="store_true")
|
|
@@ -41,6 +61,19 @@ def main(argv=None):
|
|
|
41
61
|
print(f"ERROR: {root}", file=sys.stderr)
|
|
42
62
|
return 1
|
|
43
63
|
|
|
64
|
+
# Determine project name and output directory
|
|
65
|
+
proj_name = _project_name_from_path(root)
|
|
66
|
+
# Use parent dir if path ends with backend/frontend/src/app/api, otherwise use path itself
|
|
67
|
+
if root.is_dir() and root.name in ("backend", "frontend", "src", "app", "api"):
|
|
68
|
+
out_dir = root.parent
|
|
69
|
+
else:
|
|
70
|
+
out_dir = root if root.is_dir() else root.parent
|
|
71
|
+
|
|
72
|
+
out_path = (out_dir / args.out) if args.out else (out_dir / f"{proj_name}_schema.json")
|
|
73
|
+
proto_path = out_dir / args.proto if isinstance(args.proto, str) else (out_dir / f"{proj_name}_api.proto" if args.proto is True else None)
|
|
74
|
+
md_path = out_dir / args.md if isinstance(args.md, str) else (out_dir / f"{proj_name}_report.md" if args.md is True else None)
|
|
75
|
+
html_path = out_dir / args.html if isinstance(args.html, str) else (out_dir / f"{proj_name}_viz.html" if args.html is True else None)
|
|
76
|
+
|
|
44
77
|
t0 = time.perf_counter()
|
|
45
78
|
if not args.quiet:
|
|
46
79
|
print(f"⏳ Parsing: {root}")
|
|
@@ -74,11 +107,13 @@ def main(argv=None):
|
|
|
74
107
|
print("\n── Event Model ────────────────────────")
|
|
75
108
|
print(em.summary())
|
|
76
109
|
|
|
77
|
-
write_json(schema,
|
|
78
|
-
if
|
|
79
|
-
write_proto(schema,
|
|
80
|
-
if
|
|
81
|
-
write_markdown(schema,
|
|
110
|
+
write_json(schema, out_path)
|
|
111
|
+
if proto_path:
|
|
112
|
+
write_proto(schema, proto_path)
|
|
113
|
+
if md_path:
|
|
114
|
+
write_markdown(schema, md_path)
|
|
115
|
+
if html_path:
|
|
116
|
+
write_html(schema, html_path)
|
|
82
117
|
if args.graphml:
|
|
83
118
|
write_graphml(G, Path(args.graphml))
|
|
84
119
|
if args.dot:
|
|
@@ -86,6 +121,13 @@ def main(argv=None):
|
|
|
86
121
|
|
|
87
122
|
if not args.quiet:
|
|
88
123
|
funcs = schema.all_functions()
|
|
124
|
+
outputs = [f" → {out_path.name}"]
|
|
125
|
+
if proto_path:
|
|
126
|
+
outputs.append(f" → {proto_path.name}")
|
|
127
|
+
if md_path:
|
|
128
|
+
outputs.append(f" → {md_path.name}")
|
|
129
|
+
if html_path:
|
|
130
|
+
outputs.append(f" → {html_path.name}")
|
|
89
131
|
print(
|
|
90
132
|
f"\n✅ Gotowe ({time.perf_counter()-t0:.2f}s)\n"
|
|
91
133
|
f" Modules : {len(modules)}\n"
|
|
@@ -96,7 +138,7 @@ def main(argv=None):
|
|
|
96
138
|
f" Workflows: {len(schema.workflows)}\n"
|
|
97
139
|
f" Rules : {len(schema.rules)}\n"
|
|
98
140
|
f" Graph : {G.number_of_nodes()}N / {G.number_of_edges()}E\n"
|
|
99
|
-
|
|
141
|
+
+ "\n".join(outputs)
|
|
100
142
|
)
|
|
101
143
|
return 0
|
|
102
144
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: code2schema
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.2
|
|
4
4
|
Summary: Semantic compiler: Code → AST → CQRS Model → Workflow DAG → Proto/Schema
|
|
5
5
|
License: Apache-2.0
|
|
6
6
|
Keywords: ast,cqrs,static-analysis,code-quality,schema
|
|
@@ -34,18 +34,16 @@ Dynamic: license-file
|
|
|
34
34
|
|
|
35
35
|
## AI Cost Tracking
|
|
36
36
|
|
|
37
|
-
     
|
|
38
|
+
  
|
|
39
39
|
|
|
40
40
|
- 🤖 **LLM usage:** $0.1500 (1 commits)
|
|
41
|
-
- 👤 **Human dev:** ~$
|
|
41
|
+
- 👤 **Human dev:** ~$200 (2.0h @ $100/h, 30min dedup)
|
|
42
42
|
|
|
43
43
|
Generated on 2026-05-04 using [openrouter/qwen/qwen3-coder-next](https://openrouter.ai/qwen/qwen3-coder-next)
|
|
44
44
|
|
|
45
45
|
---
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
49
47
|
**Semantic Compiler for Software Systems**
|
|
50
48
|
|
|
51
49
|
Przekształca kod Python w model semantyczny CQRS → kontrakty API → graf architektury.
|
|
@@ -80,33 +78,81 @@ pip install "code2schema[dev]" # pytest + ruff + black
|
|
|
80
78
|
## Szybki start
|
|
81
79
|
|
|
82
80
|
```bash
|
|
83
|
-
#
|
|
84
|
-
code2schema
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
81
|
+
# Analiza z auto-generowanymi nazwami plików (w katalogu bieżącym)
|
|
82
|
+
code2schema /home/tom/github/maskservice/c2004/backend
|
|
83
|
+
# → c2004_schema.json
|
|
84
|
+
|
|
85
|
+
# Pełna analiza ze wszystkimi formatami wyjściowymi
|
|
86
|
+
code2schema ./backend --proto --md --html
|
|
87
|
+
# → backend_schema.json
|
|
88
|
+
# → backend_api.proto
|
|
89
|
+
# → backend_report.md
|
|
90
|
+
# → backend_viz.html
|
|
91
|
+
|
|
92
|
+
# Pełna analiza ze szczegółami
|
|
93
|
+
code2schema ./backend --proto --md --html --graph-summary --events --cycles
|
|
93
94
|
```
|
|
94
95
|
|
|
95
96
|
Przykładowy output:
|
|
96
97
|
|
|
97
98
|
```
|
|
98
|
-
✅ Gotowe (1.
|
|
99
|
-
Modules :
|
|
100
|
-
Functions:
|
|
101
|
-
Queries :
|
|
102
|
-
Commands :
|
|
103
|
-
Orchest. :
|
|
104
|
-
Workflows:
|
|
105
|
-
Rules :
|
|
106
|
-
Graph :
|
|
107
|
-
→
|
|
99
|
+
✅ Gotowe (1.8s)
|
|
100
|
+
Modules : 607
|
|
101
|
+
Functions: 3142
|
|
102
|
+
Queries : 1518
|
|
103
|
+
Commands : 505
|
|
104
|
+
Orchest. : 1119
|
|
105
|
+
Workflows: 1118
|
|
106
|
+
Rules : 320
|
|
107
|
+
Graph : 2922N / 5612E
|
|
108
|
+
→ c2004_schema.json
|
|
109
|
+
→ c2004_api.proto
|
|
110
|
+
→ c2004_report.md
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Test na dużym projekcie (c2004 backend)
|
|
114
|
+
|
|
115
|
+
Analiza produkcyjnego projektu IoT (607 modułów, 3142 funkcje):
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
code2schema /home/tom/github/maskservice/c2004/backend --proto --md --html
|
|
119
|
+
# Pliki generowane w /home/tom/github/maskservice/c2004/ (katalog projektu)
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
**Wyniki:**
|
|
123
|
+
```
|
|
124
|
+
✅ Gotowe (1.8s)
|
|
125
|
+
Modules : 607
|
|
126
|
+
Functions: 3142
|
|
127
|
+
Queries : 1518
|
|
128
|
+
Commands : 505
|
|
129
|
+
Orchest. : 1119
|
|
130
|
+
Workflows: 1118
|
|
131
|
+
Rules : 320
|
|
132
|
+
Graph : 2922N / 5612E
|
|
133
|
+
→ c2004_schema.json
|
|
134
|
+
→ c2004_api.proto
|
|
135
|
+
→ c2004_report.md
|
|
136
|
+
→ c2004_viz.html
|
|
108
137
|
```
|
|
109
138
|
|
|
139
|
+
## Dokumentacja i przykłady
|
|
140
|
+
|
|
141
|
+
- **[Dokumentacja](docs/)** — przykłady użycia CLI i Python API
|
|
142
|
+
- [CLI examples](docs/examples/cli/basic.sh)
|
|
143
|
+
- [Python API — basic](docs/examples/api/basic.py)
|
|
144
|
+
- [Python API — advanced](docs/examples/api/advanced.py)
|
|
145
|
+
- [Sample outputs](docs/examples/outputs/)
|
|
146
|
+
|
|
147
|
+
Wykryte cykle w architekturze CQRS (do refaktoryzacji):
|
|
148
|
+
- `handle → publish → _execute → publish → handle`
|
|
149
|
+
|
|
150
|
+
**Wygenerowane artefakty:**
|
|
151
|
+
- `c2004_schema.json` (2.9MB) — pełny model
|
|
152
|
+
- `c2004_api.proto` (188KB) — gRPC contracts
|
|
153
|
+
- `c2004_report.md` (49KB) — podsumowanie jakości
|
|
154
|
+
- `c2004_viz.html` (1.1MB) — **interaktywny graf D3.js** z wyszukiwaniem i filtrowaniem
|
|
155
|
+
|
|
110
156
|
## Użycie w kodzie
|
|
111
157
|
|
|
112
158
|
```python
|
|
@@ -138,6 +184,21 @@ print(to_proto(schema))
|
|
|
138
184
|
print(to_markdown(schema))
|
|
139
185
|
```
|
|
140
186
|
|
|
187
|
+
## Wizualizacja HTML (`--html`)
|
|
188
|
+
|
|
189
|
+
Interaktywny graf D3.js z funkcjami:
|
|
190
|
+
- **Kolory ról**: 🟢 Query, 🟠 Command, 🟣 Orchestrator
|
|
191
|
+
- **Wyszukiwanie** — filtruje węzły w czasie rzeczywistym
|
|
192
|
+
- **Hover** — podświetla połączenia (call graph)
|
|
193
|
+
- **Klik** — szczegóły funkcji (fan-out, side effects, reguły jakości)
|
|
194
|
+
- **Filtry** — pokazuj/ukrywaj kategorie ról
|
|
195
|
+
- **Force layout** — przeciąganie węzłów
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
code2schema ./backend --html viz.html
|
|
199
|
+
# Otwórz w przeglądarce: open viz.html
|
|
200
|
+
```
|
|
201
|
+
|
|
141
202
|
## Architektura paczki
|
|
142
203
|
|
|
143
204
|
```
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|