codemind-sh 0.1.7__tar.gz → 0.2.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.
- codemind_sh-0.2.0/LICENSE +21 -0
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/PKG-INFO +7 -7
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/README.md +5 -5
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/__init__.py +1 -1
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/cli.py +175 -146
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/graph/builder.py +71 -0
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/license/client.py +29 -46
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/license/keygen.py +15 -12
- codemind_sh-0.2.0/codemind/license/license.py +96 -0
- codemind_sh-0.2.0/codemind/license/pricing.py +103 -0
- codemind_sh-0.2.0/codemind/license/state.py +48 -0
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/pyproject.toml +2 -2
- codemind_sh-0.1.7/LICENSE +0 -91
- codemind_sh-0.1.7/codemind/license/enforcer.py +0 -102
- codemind_sh-0.1.7/codemind/license/license.py +0 -164
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/__main__.py +0 -0
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/ai/__init__.py +0 -0
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/ai/enricher.py +0 -0
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/ai/pro_features.py +0 -0
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/ai/stack_learner.py +0 -0
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/analyzer/__init__.py +0 -0
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/analyzer/base.py +0 -0
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/analyzer/dependency_analyzer.py +0 -0
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/analyzer/java_analyzer.py +0 -0
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/analyzer/typescript_analyzer.py +0 -0
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/context/__init__.py +0 -0
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/context/engine.py +0 -0
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/core/__init__.py +0 -0
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/core/config.py +0 -0
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/core/constants.py +0 -0
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/core/graph.py +0 -0
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/core/project.py +0 -0
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/git/__init__.py +0 -0
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/graph/__init__.py +0 -0
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/graph/query.py +0 -0
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/graph/store.py +0 -0
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/health/__init__.py +0 -0
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/health/checker.py +0 -0
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/health/dependency_check.py +0 -0
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/health/pattern_check.py +0 -0
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/health/test_coverage.py +0 -0
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/knowledge/__init__.py +0 -0
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/knowledge/architecture.py +0 -0
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/knowledge/connection_builder.py +0 -0
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/knowledge/connections.py +0 -0
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/knowledge/generator.py +0 -0
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/knowledge/index_builder.py +0 -0
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/license/__init__.py +0 -0
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/mcp/__init__.py +0 -0
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/mcp/connect.py +0 -0
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/mcp/decisions.py +0 -0
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/mcp/server.py +0 -0
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/mcp/tools.py +0 -0
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/parser/__init__.py +0 -0
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/parser/base.py +0 -0
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/parser/gap_detector.py +0 -0
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/parser/java_parser.py +0 -0
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/parser/python_parser.py +0 -0
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/parser/registry.py +0 -0
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/parser/rule_cache.py +0 -0
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/parser/typescript_parser.py +0 -0
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/router/__init__.py +0 -0
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/router/call_extractor.py +0 -0
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/router/linker.py +0 -0
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/router/route_extractor.py +0 -0
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/scaffold/__init__.py +0 -0
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/scaffold/generator.py +0 -0
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/scaffold/pattern_extractor.py +0 -0
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/scaffold/templates/java/controller.java.j2 +0 -0
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/scaffold/templates/java/entity.java.j2 +0 -0
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/scaffold/templates/java/repository.java.j2 +0 -0
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/scaffold/templates/java/service.java.j2 +0 -0
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/scaffold/templates/java/test.java.j2 +0 -0
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/scaffold/templates/typescript/service.ts.j2 +0 -0
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/tasks/__init__.py +0 -0
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/watcher/__init__.py +0 -0
- {codemind_sh-0.1.7 → codemind_sh-0.2.0}/codemind/watcher/handler.py +0 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 OnixSolutions (onixsolutions.net)
|
|
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.
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: codemind-sh
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: Local-first knowledge graph for software projects. Gives AI tools structural facts about your codebase via 11 MCP tools.
|
|
5
5
|
License: MIT
|
|
6
6
|
License-File: LICENSE
|
|
7
7
|
Keywords: ai,developer-tools,codebase,mcp,context,architecture
|
|
8
8
|
Author: Mohammed
|
|
9
|
-
Author-email:
|
|
9
|
+
Author-email: support@onixsolutions.net
|
|
10
10
|
Requires-Python: >=3.11,<4.0
|
|
11
11
|
Classifier: Development Status :: 3 - Alpha
|
|
12
12
|
Classifier: Environment :: Console
|
|
@@ -240,7 +240,7 @@ nothing. One `codemind review` (~$0.003) generates a report the whole team benef
|
|
|
240
240
|
|
|
241
241
|
```bash
|
|
242
242
|
# Core
|
|
243
|
-
codemind init # Initialize .codemind/ (
|
|
243
|
+
codemind init # Initialize .codemind/ (free, unlimited projects)
|
|
244
244
|
codemind scan # Parse codebase → graph.json + ARCHITECTURE.md + modules/
|
|
245
245
|
codemind status # Graph stats overview
|
|
246
246
|
|
|
@@ -259,7 +259,7 @@ codemind query "" --connections KpiService # get_connections
|
|
|
259
259
|
codemind query "" --impact ThresholdEvaluator # impact_analysis
|
|
260
260
|
codemind query "" --pattern # get_pattern
|
|
261
261
|
|
|
262
|
-
#
|
|
262
|
+
# AI features (BYOK — requires ANTHROPIC_API_KEY)
|
|
263
263
|
codemind review # Architectural review
|
|
264
264
|
codemind brief # Onboarding brief
|
|
265
265
|
codemind impact <component> --ai # Impact + AI risk assessment
|
|
@@ -330,9 +330,9 @@ The optional BYOK AI enricher (gap-filling injection edges) sends only small str
|
|
|
330
330
|
|
|
331
331
|
## License
|
|
332
332
|
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
333
|
+
**Free & open source (MIT).** No paywall, no license keys, no telemetry. Use it on
|
|
334
|
+
unlimited projects. The optional AI features are BYOK — bring your own
|
|
335
|
+
`ANTHROPIC_API_KEY`; everything else runs entirely offline and free.
|
|
336
336
|
|
|
337
337
|
Built by [OnixSolutions](https://onixsolutions.net)
|
|
338
338
|
|
|
@@ -196,7 +196,7 @@ nothing. One `codemind review` (~$0.003) generates a report the whole team benef
|
|
|
196
196
|
|
|
197
197
|
```bash
|
|
198
198
|
# Core
|
|
199
|
-
codemind init # Initialize .codemind/ (
|
|
199
|
+
codemind init # Initialize .codemind/ (free, unlimited projects)
|
|
200
200
|
codemind scan # Parse codebase → graph.json + ARCHITECTURE.md + modules/
|
|
201
201
|
codemind status # Graph stats overview
|
|
202
202
|
|
|
@@ -215,7 +215,7 @@ codemind query "" --connections KpiService # get_connections
|
|
|
215
215
|
codemind query "" --impact ThresholdEvaluator # impact_analysis
|
|
216
216
|
codemind query "" --pattern # get_pattern
|
|
217
217
|
|
|
218
|
-
#
|
|
218
|
+
# AI features (BYOK — requires ANTHROPIC_API_KEY)
|
|
219
219
|
codemind review # Architectural review
|
|
220
220
|
codemind brief # Onboarding brief
|
|
221
221
|
codemind impact <component> --ai # Impact + AI risk assessment
|
|
@@ -286,8 +286,8 @@ The optional BYOK AI enricher (gap-filling injection edges) sends only small str
|
|
|
286
286
|
|
|
287
287
|
## License
|
|
288
288
|
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
289
|
+
**Free & open source (MIT).** No paywall, no license keys, no telemetry. Use it on
|
|
290
|
+
unlimited projects. The optional AI features are BYOK — bring your own
|
|
291
|
+
`ANTHROPIC_API_KEY`; everything else runs entirely offline and free.
|
|
292
292
|
|
|
293
293
|
Built by [OnixSolutions](https://onixsolutions.net)
|
|
@@ -17,8 +17,14 @@ from codemind.core.config import CodemindConfig, StructureConfig, TechStackConfi
|
|
|
17
17
|
from codemind.core.project import CodemindProject
|
|
18
18
|
from codemind.core.constants import CODEMIND_DIR
|
|
19
19
|
from codemind.license.license import LicenseManager
|
|
20
|
-
from codemind.license.
|
|
21
|
-
from codemind.license.
|
|
20
|
+
from codemind.license.client import LicenseClient
|
|
21
|
+
from codemind.license.pricing import (
|
|
22
|
+
GITHUB_REPO_URL,
|
|
23
|
+
donation_info,
|
|
24
|
+
get_pricing,
|
|
25
|
+
refresh_pricing_cache,
|
|
26
|
+
)
|
|
27
|
+
from codemind.license.state import get_flag, set_flag
|
|
22
28
|
|
|
23
29
|
# ── App Setup ──
|
|
24
30
|
app = typer.Typer(
|
|
@@ -32,6 +38,72 @@ console = Console()
|
|
|
32
38
|
_err = Console(stderr=True)
|
|
33
39
|
|
|
34
40
|
|
|
41
|
+
def _ask_optional_email(prompt_label: str) -> str:
|
|
42
|
+
"""Prompt for an optional email. Enter skips; light validation if entered."""
|
|
43
|
+
while True:
|
|
44
|
+
entered = Prompt.ask(prompt_label, default="").strip().lower()
|
|
45
|
+
if not entered:
|
|
46
|
+
return ""
|
|
47
|
+
if "@" in entered and "." in entered.split("@")[-1]:
|
|
48
|
+
return entered
|
|
49
|
+
console.print(" [yellow]⚠[/yellow] That doesn't look like an email — "
|
|
50
|
+
"try again or press Enter to skip.")
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def _render_support_line(pricing: dict) -> str:
|
|
54
|
+
"""One warm line from the pricing config — donation today, freemium-aware.
|
|
55
|
+
|
|
56
|
+
Renders whatever the server config says: donation mode shows the donation
|
|
57
|
+
URL; a future ``mode: freemium`` with ``paid.enabled`` shows the paid
|
|
58
|
+
offer instead — no CLI release needed to flip.
|
|
59
|
+
"""
|
|
60
|
+
paid = pricing.get("paid") or {}
|
|
61
|
+
if pricing.get("mode") == "freemium" and paid.get("enabled"):
|
|
62
|
+
price = paid.get("price_display") or ""
|
|
63
|
+
checkout = paid.get("checkout_url") or ""
|
|
64
|
+
parts = [p for p in (price, checkout) if p]
|
|
65
|
+
if parts:
|
|
66
|
+
return (
|
|
67
|
+
f" [red]♥[/red] CodeMind Pro: [cyan]{' · '.join(parts)}[/cyan]"
|
|
68
|
+
)
|
|
69
|
+
donation = pricing.get("donation") or {}
|
|
70
|
+
if donation.get("enabled") is False:
|
|
71
|
+
return ""
|
|
72
|
+
url, _ = donation_info(pricing)
|
|
73
|
+
return f" [red]♥[/red] CodeMind is free & open source. If it helps: [cyan]{url}[/cyan]"
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def _maybe_backfill_email(lic_state, lic_mgr: LicenseManager) -> None:
|
|
77
|
+
"""Ask once — ever — for an optional recovery email during scan.
|
|
78
|
+
|
|
79
|
+
Legacy installs may have a key but no email. We ask a single time, only
|
|
80
|
+
on an interactive terminal (never blocks pipes/CI), and persist an
|
|
81
|
+
``email_prompted`` flag in ~/.codemind/state.json so a skip is final.
|
|
82
|
+
"""
|
|
83
|
+
import sys as _sys
|
|
84
|
+
|
|
85
|
+
if not lic_state.license_key or lic_state.email:
|
|
86
|
+
return
|
|
87
|
+
if not _sys.stdin.isatty():
|
|
88
|
+
return
|
|
89
|
+
if get_flag("email_prompted"):
|
|
90
|
+
return
|
|
91
|
+
|
|
92
|
+
console.print()
|
|
93
|
+
console.print(
|
|
94
|
+
" [dim]◆ Optional: add an email to recover your install key if you "
|
|
95
|
+
"reinstall. Press Enter to skip.[/dim]"
|
|
96
|
+
)
|
|
97
|
+
email = _ask_optional_email(" [bold]Email address[/bold] [dim](optional)[/dim]")
|
|
98
|
+
set_flag("email_prompted")
|
|
99
|
+
if email:
|
|
100
|
+
LicenseClient().register_email(lic_state.license_key, email)
|
|
101
|
+
lic_state.email = email
|
|
102
|
+
lic_mgr.save(lic_state)
|
|
103
|
+
console.print(f" [green]✓[/green] Email registered: [dim]{email}[/dim]")
|
|
104
|
+
console.print()
|
|
105
|
+
|
|
106
|
+
|
|
35
107
|
def version_callback(value: bool) -> None:
|
|
36
108
|
"""Print version and exit."""
|
|
37
109
|
if value:
|
|
@@ -64,56 +136,45 @@ def init(
|
|
|
64
136
|
"""
|
|
65
137
|
project_root = (path or Path.cwd()).resolve()
|
|
66
138
|
|
|
67
|
-
# ──
|
|
139
|
+
# ── Server-driven pricing config — best-effort refresh, never blocks ──────
|
|
140
|
+
import threading as _threading
|
|
141
|
+
_pricing_thread = _threading.Thread(target=refresh_pricing_cache, daemon=True)
|
|
142
|
+
_pricing_thread.start()
|
|
143
|
+
|
|
144
|
+
# ── Install identity (free — never blocks) ─────────────────────────────────
|
|
68
145
|
_lic_mgr = LicenseManager()
|
|
69
146
|
if not _lic_mgr.exists():
|
|
70
|
-
# First run —
|
|
71
|
-
|
|
72
|
-
console.print(" [cyan]◆[/cyan] First run — activating your free CodeMind license.")
|
|
147
|
+
# First run — optional email, then create an anonymous install identity.
|
|
148
|
+
# Server registration is best-effort; offline works out of the box.
|
|
73
149
|
console.print()
|
|
74
|
-
|
|
75
|
-
console.print(" [dim]Your email is stored on the license server to allow key recovery.[/dim]")
|
|
76
|
-
console.print(" [dim]We don't spam. You'll only hear from us about your license.[/dim]")
|
|
150
|
+
console.print(" [cyan]◆[/cyan] First run — setting up your free CodeMind install.")
|
|
77
151
|
console.print()
|
|
78
152
|
_email = ""
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
trial_state = LicenseClient().generate_trial(email=_email)
|
|
85
|
-
except RuntimeError as e:
|
|
86
|
-
console.print()
|
|
87
|
-
console.print(f" [red]✗[/red] {e}")
|
|
153
|
+
if not non_interactive:
|
|
154
|
+
console.print(
|
|
155
|
+
" [dim]Email is optional — used only to recover your install key. "
|
|
156
|
+
"Press Enter to skip.[/dim]"
|
|
157
|
+
)
|
|
88
158
|
console.print()
|
|
89
|
-
|
|
159
|
+
_email = _ask_optional_email(" [bold]Email address[/bold] [dim](optional)[/dim]")
|
|
160
|
+
set_flag("email_prompted") # asked once — scan never re-asks
|
|
161
|
+
trial_state = LicenseClient().generate_trial(email=_email)
|
|
90
162
|
trial_state.email = _email
|
|
91
163
|
_lic_mgr.save(trial_state)
|
|
92
164
|
console.print()
|
|
93
165
|
console.print(
|
|
94
|
-
f" [green]✓[/green]
|
|
166
|
+
f" [green]✓[/green] Install key: [bold]{trial_state.license_key}[/bold]"
|
|
95
167
|
)
|
|
96
|
-
|
|
97
|
-
f" [green]✓[/green] Email registered: [dim]{_email}[/dim]"
|
|
98
|
-
)
|
|
99
|
-
console.print(" [dim]Free plan: 1 project, no credit card required.[/dim]")
|
|
168
|
+
if _email:
|
|
169
|
+
console.print(f" [green]✓[/green] Email registered: [dim]{_email}[/dim]")
|
|
170
|
+
console.print(" [dim]CodeMind is free. No account, no credit card, works offline.[/dim]")
|
|
100
171
|
|
|
101
172
|
_lic_state = _lic_mgr.load()
|
|
102
173
|
|
|
103
174
|
# Load project_id if project already exists (reinit case)
|
|
104
175
|
_existing_project = CodemindProject(project_root)
|
|
105
176
|
_project_id = _existing_project.config.project_id if _existing_project.is_initialized else ""
|
|
106
|
-
|
|
107
|
-
_check = LicenseEnforcer().check_init(_lic_state, _project_id)
|
|
108
|
-
if not _check.allowed:
|
|
109
|
-
console.print()
|
|
110
|
-
console.print(f" [red]✗[/red] {_check.reason}")
|
|
111
|
-
console.print()
|
|
112
|
-
raise typer.Exit(1)
|
|
113
|
-
if _check.warning:
|
|
114
|
-
console.print()
|
|
115
|
-
console.print(f" [yellow]⚠[/yellow] {_check.warning}")
|
|
116
|
-
# ── End license check ──────────────────────────────────────────────────────
|
|
177
|
+
# ── End install identity ───────────────────────────────────────────────────
|
|
117
178
|
|
|
118
179
|
# Check if already initialized
|
|
119
180
|
if (project_root / CODEMIND_DIR).exists():
|
|
@@ -198,67 +259,23 @@ def init(
|
|
|
198
259
|
|
|
199
260
|
# ── Initialize ──
|
|
200
261
|
project = CodemindProject(project_root)
|
|
262
|
+
# Preserve existing project_id on reinit — changing it would break Class A status
|
|
263
|
+
if _project_id:
|
|
264
|
+
config.project_id = _project_id
|
|
201
265
|
project.initialize(config)
|
|
202
266
|
|
|
203
|
-
# ──
|
|
204
|
-
# The server is the source of truth. Local license.yml can be edited by
|
|
205
|
-
# anyone — only the server DB count is tamper-proof.
|
|
267
|
+
# ── Best-effort server registration (never blocks, never rolls back) ───────
|
|
206
268
|
if project.config.project_id and _lic_state.license_key:
|
|
207
|
-
_is_class_a = _lic_state.is_class_a(project.config.project_id)
|
|
208
269
|
try:
|
|
209
270
|
updated = LicenseClient().validate(
|
|
210
271
|
_lic_state.license_key, project.config.project_id
|
|
211
272
|
)
|
|
212
273
|
if updated:
|
|
274
|
+
if _lic_state.email and not updated.email:
|
|
275
|
+
updated.email = _lic_state.email
|
|
213
276
|
_lic_mgr.save(updated)
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
# Server unreachable AND this is a new (unregistered) project —
|
|
217
|
-
# roll back to prevent unlimited offline bypass
|
|
218
|
-
import shutil
|
|
219
|
-
_codemind_dir = project_root / CODEMIND_DIR
|
|
220
|
-
if _codemind_dir.exists():
|
|
221
|
-
shutil.rmtree(_codemind_dir)
|
|
222
|
-
console.print()
|
|
223
|
-
console.print(
|
|
224
|
-
" [red]✗[/red] Could not reach the license server to activate this project."
|
|
225
|
-
)
|
|
226
|
-
console.print(
|
|
227
|
-
" [dim]Please check your internet connection and run "
|
|
228
|
-
"[bold]codemind init[/bold] again.[/dim]"
|
|
229
|
-
)
|
|
230
|
-
console.print()
|
|
231
|
-
raise typer.Exit(1)
|
|
232
|
-
else:
|
|
233
|
-
# Class A project (already registered) — offline reinit is fine
|
|
234
|
-
_lic_mgr.add_activated_project(project.config.project_id)
|
|
235
|
-
except LicenseLimitReached as e:
|
|
236
|
-
if _is_class_a:
|
|
237
|
-
# Class A project — was activated before, keep it working locally.
|
|
238
|
-
# Server 402 means they hit the limit for NEW projects, not existing ones.
|
|
239
|
-
_lic_mgr.add_activated_project(project.config.project_id)
|
|
240
|
-
console.print()
|
|
241
|
-
console.print(
|
|
242
|
-
" [yellow]⚠[/yellow] This project was already activated on your license "
|
|
243
|
-
"and will keep working."
|
|
244
|
-
)
|
|
245
|
-
console.print(
|
|
246
|
-
" [dim]Upgrade at [cyan]codemind.sh/upgrade[/cyan] to register "
|
|
247
|
-
"additional projects.[/dim]"
|
|
248
|
-
)
|
|
249
|
-
else:
|
|
250
|
-
# New project hitting the server limit — rollback
|
|
251
|
-
import shutil
|
|
252
|
-
_codemind_dir = project_root / CODEMIND_DIR
|
|
253
|
-
if _codemind_dir.exists():
|
|
254
|
-
shutil.rmtree(_codemind_dir)
|
|
255
|
-
console.print()
|
|
256
|
-
console.print(f" [red]✗[/red] {e.detail}")
|
|
257
|
-
console.print(
|
|
258
|
-
" Upgrade at [cyan]codemind.sh/upgrade[/cyan] to add unlimited projects."
|
|
259
|
-
)
|
|
260
|
-
console.print()
|
|
261
|
-
raise typer.Exit(1)
|
|
277
|
+
except Exception:
|
|
278
|
+
pass # offline is a first-class citizen — nothing to do
|
|
262
279
|
|
|
263
280
|
# ── Show result ──
|
|
264
281
|
console.print()
|
|
@@ -298,6 +315,18 @@ def init(
|
|
|
298
315
|
console.print(" [green]2.[/green] Run [bold cyan]codemind serve[/bold cyan] to start MCP for Claude Code / Cursor")
|
|
299
316
|
console.print()
|
|
300
317
|
|
|
318
|
+
# ── One-time donation note — shown once ever, across all projects ─────────
|
|
319
|
+
if not get_flag("donation_note_shown"):
|
|
320
|
+
_pricing_thread.join(timeout=2.0) # give the fetch a moment; cache/default otherwise
|
|
321
|
+
_support_line = _render_support_line(get_pricing())
|
|
322
|
+
if _support_line:
|
|
323
|
+
console.print(_support_line)
|
|
324
|
+
console.print(
|
|
325
|
+
" [dim](run 'codemind support' anytime — this won't be shown again)[/dim]"
|
|
326
|
+
)
|
|
327
|
+
console.print()
|
|
328
|
+
set_flag("donation_note_shown")
|
|
329
|
+
|
|
301
330
|
|
|
302
331
|
# ══════════════════════════════════════
|
|
303
332
|
# STATUS COMMAND
|
|
@@ -401,6 +430,54 @@ def status(
|
|
|
401
430
|
)
|
|
402
431
|
|
|
403
432
|
console.print()
|
|
433
|
+
console.print(" [dim]♥ Free & open source · run 'codemind support'[/dim]")
|
|
434
|
+
console.print()
|
|
435
|
+
|
|
436
|
+
|
|
437
|
+
# ══════════════════════════════════════
|
|
438
|
+
# SUPPORT COMMAND
|
|
439
|
+
# ══════════════════════════════════════
|
|
440
|
+
@app.command()
|
|
441
|
+
def support() -> None:
|
|
442
|
+
"""Support CodeMind — it's free & open source, and donations keep it that way."""
|
|
443
|
+
pricing = get_pricing() # cache → bundled default; never needs network
|
|
444
|
+
url, message = donation_info(pricing)
|
|
445
|
+
|
|
446
|
+
lines = [
|
|
447
|
+
"[bold]Thank you for using CodeMind![/bold]",
|
|
448
|
+
"",
|
|
449
|
+
f"[dim]{message}[/dim]",
|
|
450
|
+
"",
|
|
451
|
+
f" [red]♥[/red] Donate: [cyan]{url}[/cyan]",
|
|
452
|
+
f" [yellow]★[/yellow] GitHub: [cyan]{GITHUB_REPO_URL}[/cyan]",
|
|
453
|
+
]
|
|
454
|
+
|
|
455
|
+
# Future-proof: if the server ever flips to freemium, render the paid offer
|
|
456
|
+
# from the same config — no CLI release needed.
|
|
457
|
+
paid = pricing.get("paid") or {}
|
|
458
|
+
if pricing.get("mode") == "freemium" and paid.get("enabled"):
|
|
459
|
+
price = paid.get("price_display") or ""
|
|
460
|
+
checkout = paid.get("checkout_url") or ""
|
|
461
|
+
offer = " · ".join(p for p in (price, checkout) if p)
|
|
462
|
+
if offer:
|
|
463
|
+
lines.append(f" [green]◆[/green] Pro: [cyan]{offer}[/cyan]")
|
|
464
|
+
|
|
465
|
+
lines += [
|
|
466
|
+
"",
|
|
467
|
+
"[dim]A star on GitHub helps other developers find CodeMind — "
|
|
468
|
+
"that's worth as much as a coffee.[/dim]",
|
|
469
|
+
]
|
|
470
|
+
|
|
471
|
+
console.print()
|
|
472
|
+
console.print(
|
|
473
|
+
Panel(
|
|
474
|
+
"\n".join(lines),
|
|
475
|
+
title="[red]♥[/red] Support CodeMind",
|
|
476
|
+
border_style="cyan",
|
|
477
|
+
padding=(1, 2),
|
|
478
|
+
)
|
|
479
|
+
)
|
|
480
|
+
console.print()
|
|
404
481
|
|
|
405
482
|
|
|
406
483
|
# ══════════════════════════════════════
|
|
@@ -425,56 +502,16 @@ def scan(
|
|
|
425
502
|
|
|
426
503
|
project = _get_project(path)
|
|
427
504
|
|
|
428
|
-
# ──
|
|
505
|
+
# ── Install identity — free, never blocks scan ──────────────────────────────
|
|
429
506
|
_lic_mgr = LicenseManager()
|
|
430
507
|
_lic_state = _lic_mgr.load()
|
|
431
508
|
_project_id = project.config.project_id
|
|
432
|
-
_graph_exists = project.graph_path.exists()
|
|
433
|
-
|
|
434
|
-
# Legacy projects (pre-Phase 7) have no project_id — treat as Class A
|
|
435
|
-
if not _project_id and _graph_exists:
|
|
436
|
-
_project_id = "__legacy__"
|
|
437
|
-
if "__legacy__" not in _lic_state.activated_projects:
|
|
438
|
-
_lic_mgr.add_activated_project("__legacy__")
|
|
439
|
-
_lic_state = _lic_mgr.load()
|
|
440
|
-
|
|
441
|
-
_scan_check = LicenseEnforcer().check_scan(_lic_state, _project_id, _graph_exists)
|
|
442
|
-
if not _scan_check.allowed:
|
|
443
|
-
console.print()
|
|
444
|
-
console.print(f" [red]✗[/red] {_scan_check.reason}")
|
|
445
|
-
console.print()
|
|
446
|
-
raise typer.Exit(1)
|
|
447
|
-
if _scan_check.warning:
|
|
448
|
-
console.print()
|
|
449
|
-
console.print(f" [yellow]⚠[/yellow] {_scan_check.warning}")
|
|
450
|
-
|
|
451
|
-
_ai_ok = LicenseEnforcer().ai_allowed(_lic_state)
|
|
452
509
|
|
|
453
|
-
#
|
|
454
|
-
|
|
455
|
-
console.print()
|
|
456
|
-
console.print(
|
|
457
|
-
" [yellow]◆[/yellow] Your license has no email address on file."
|
|
458
|
-
)
|
|
459
|
-
console.print(
|
|
460
|
-
" [dim]Email is required to recover your license key if you reinstall.[/dim]"
|
|
461
|
-
)
|
|
462
|
-
console.print()
|
|
463
|
-
_scan_email = ""
|
|
464
|
-
while not _scan_email or "@" not in _scan_email or "." not in _scan_email.split("@")[-1]:
|
|
465
|
-
_scan_email = Prompt.ask(" [bold]Email address[/bold]").strip().lower()
|
|
466
|
-
if not _scan_email or "@" not in _scan_email or "." not in _scan_email.split("@")[-1]:
|
|
467
|
-
console.print(" [red]✗[/red] Please enter a valid email address.")
|
|
468
|
-
LicenseClient().register_email(_lic_state.license_key, _scan_email)
|
|
469
|
-
_lic_state.email = _scan_email
|
|
470
|
-
_lic_mgr.save(_lic_state)
|
|
471
|
-
console.print(f" [green]✓[/green] Email registered: [dim]{_scan_email}[/dim]")
|
|
472
|
-
console.print()
|
|
510
|
+
# Optional email backfill (legacy installs) — asked once ever, never blocks
|
|
511
|
+
_maybe_backfill_email(_lic_state, _lic_mgr)
|
|
473
512
|
|
|
474
|
-
# ── Background registration —
|
|
475
|
-
|
|
476
|
-
# Fire-and-forget: success = they appear in dashboard; failure = no impact.
|
|
477
|
-
if _lic_state.license_key and _project_id and _project_id != "__legacy__":
|
|
513
|
+
# ── Background registration — best-effort, fire-and-forget ─────────────────
|
|
514
|
+
if _lic_state.license_key and _project_id:
|
|
478
515
|
import threading
|
|
479
516
|
_scan_email_for_bg = _lic_state.email
|
|
480
517
|
def _bg_register() -> None:
|
|
@@ -484,14 +521,11 @@ def scan(
|
|
|
484
521
|
if _scan_email_for_bg and not updated.email:
|
|
485
522
|
updated.email = _scan_email_for_bg
|
|
486
523
|
LicenseManager().save(updated)
|
|
487
|
-
|
|
488
|
-
# If email is now on file but not on server, push it
|
|
489
|
-
if _scan_email_for_bg:
|
|
490
|
-
LicenseClient().register_email(_lic_state.license_key, _scan_email_for_bg)
|
|
524
|
+
refresh_pricing_cache() # opportunistic — keeps pricing.json fresh
|
|
491
525
|
except Exception:
|
|
492
526
|
pass
|
|
493
527
|
threading.Thread(target=_bg_register, daemon=True).start()
|
|
494
|
-
# ── End
|
|
528
|
+
# ── End install identity ────────────────────────────────────────────────────
|
|
495
529
|
|
|
496
530
|
console.print()
|
|
497
531
|
console.print(
|
|
@@ -521,15 +555,10 @@ def scan(
|
|
|
521
555
|
codemind_dir=project.codemind_dir,
|
|
522
556
|
project_name=project.config.project_name or project.root.name,
|
|
523
557
|
progress_callback=_scan_progress,
|
|
524
|
-
ai_enrich=
|
|
558
|
+
ai_enrich=None, # auto-detect: BYOK via ANTHROPIC_API_KEY
|
|
525
559
|
)
|
|
526
560
|
progress.remove_task(t)
|
|
527
561
|
|
|
528
|
-
# Ensure project is registered as Class A after every successful scan
|
|
529
|
-
_real_id = project.config.project_id
|
|
530
|
-
if _real_id:
|
|
531
|
-
_lic_mgr.add_activated_project(_real_id)
|
|
532
|
-
|
|
533
562
|
# ── Cross-layer routing enrichment (fullstack projects) ──────────────────
|
|
534
563
|
if project.config.structure.project_type == "fullstack" or _has_fullstack_signals(graph):
|
|
535
564
|
from codemind.router.route_extractor import enrich_graph_with_routes
|
|
@@ -1381,7 +1410,7 @@ def review(
|
|
|
1381
1410
|
strengths, risks, recommendations, and key metrics.
|
|
1382
1411
|
Output is written to ``.codemind/REVIEW.md`` and cached.
|
|
1383
1412
|
|
|
1384
|
-
Requires ``ANTHROPIC_API_KEY`` (
|
|
1413
|
+
Requires ``ANTHROPIC_API_KEY`` (BYOK — you pay Anthropic directly).
|
|
1385
1414
|
|
|
1386
1415
|
Example::
|
|
1387
1416
|
|
|
@@ -1436,7 +1465,7 @@ def brief(
|
|
|
1436
1465
|
the 3 domains to understand first, key patterns, and a glossary.
|
|
1437
1466
|
Output is written to ``.codemind/BRIEF.md`` and cached.
|
|
1438
1467
|
|
|
1439
|
-
Requires ``ANTHROPIC_API_KEY`` (
|
|
1468
|
+
Requires ``ANTHROPIC_API_KEY`` (BYOK — you pay Anthropic directly).
|
|
1440
1469
|
|
|
1441
1470
|
Example::
|
|
1442
1471
|
|
|
@@ -1491,7 +1520,7 @@ def impact(
|
|
|
1491
1520
|
Without ``--ai``: runs the structural BFS (same as ``codemind query --impact``).
|
|
1492
1521
|
With ``--ai``: adds Claude's risk assessment on top of the structural result.
|
|
1493
1522
|
|
|
1494
|
-
Requires ``ANTHROPIC_API_KEY`` for ``--ai`` (
|
|
1523
|
+
Requires ``ANTHROPIC_API_KEY`` for ``--ai`` (BYOK — you pay Anthropic directly).
|
|
1495
1524
|
|
|
1496
1525
|
Examples::
|
|
1497
1526
|
|
|
@@ -243,6 +243,12 @@ class GraphBuilder:
|
|
|
243
243
|
meta=edge.meta,
|
|
244
244
|
))
|
|
245
245
|
|
|
246
|
+
# BUG-1: regenerate cross-layer routing after the incremental rebuild.
|
|
247
|
+
# `remove_file` above dropped the changed node's cross_layer edges and
|
|
248
|
+
# its router-written metadata (routes / api_calls), and the parser does
|
|
249
|
+
# NOT recreate them. Without this the graph decays after the first scan.
|
|
250
|
+
_reenrich_cross_layer(graph, project_root)
|
|
251
|
+
|
|
246
252
|
self._store.save(graph, codemind_dir)
|
|
247
253
|
return graph
|
|
248
254
|
|
|
@@ -356,6 +362,71 @@ def _count_gaps(graph: CodeGraph) -> int:
|
|
|
356
362
|
return 0
|
|
357
363
|
|
|
358
364
|
|
|
365
|
+
def _looks_fullstack(graph: CodeGraph) -> bool:
|
|
366
|
+
"""Cheap check: could this graph contain cross-layer (frontend↔backend) edges?
|
|
367
|
+
|
|
368
|
+
Mirrors ``cli._has_fullstack_signals`` so single-stack projects pay nothing
|
|
369
|
+
for cross-layer re-enrichment on every incremental save.
|
|
370
|
+
"""
|
|
371
|
+
langs = {n.language for n in graph.nodes.values()}
|
|
372
|
+
# Classic Spring/Java backend + Angular/React (TypeScript) frontend
|
|
373
|
+
if "java" in langs and "typescript" in langs:
|
|
374
|
+
return True
|
|
375
|
+
# TypeScript monorepo: NestJS backend (class/controller) + frontend component
|
|
376
|
+
if "typescript" in langs:
|
|
377
|
+
ts_types = {n.type for n in graph.nodes.values() if n.language == "typescript"}
|
|
378
|
+
if "component" in ts_types and (ts_types & {"class", "controller"}):
|
|
379
|
+
return True
|
|
380
|
+
return False
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
def _reenrich_cross_layer(graph: CodeGraph, project_root: Path) -> None:
|
|
384
|
+
"""Regenerate cross-layer routing after an incremental ``rebuild_file``.
|
|
385
|
+
|
|
386
|
+
BUG-1 fix. Cross-layer routing (frontend HTTP call → backend route
|
|
387
|
+
``cross_layer`` edges, powering ``trace_request`` and cross-layer
|
|
388
|
+
``get_connections``) previously ran ONLY during a full ``codemind scan``.
|
|
389
|
+
The incremental path — ``rebuild_file``, invoked by the watcher on every
|
|
390
|
+
save — re-parsed the changed file but never re-ran the router. Because
|
|
391
|
+
``CodeGraph.remove_file`` deletes the changed node together with its
|
|
392
|
+
``cross_layer`` edges and its router-written ``metadata["routes"]`` /
|
|
393
|
+
``["api_calls"]`` (which the parser does NOT recreate), editing any
|
|
394
|
+
frontend/backend file silently dropped its cross-layer links until the
|
|
395
|
+
next full scan.
|
|
396
|
+
|
|
397
|
+
Approach — graph-wide re-link. The linker matches every frontend call
|
|
398
|
+
against the FULL backend route table (and vice-versa), so a change on one
|
|
399
|
+
layer can affect links on the opposite layer. We therefore re-run the whole
|
|
400
|
+
enrichment over the in-memory graph. Route / api_call metadata is recomputed
|
|
401
|
+
cheaply from each node's source, and the linkers dedupe on (source, target),
|
|
402
|
+
so re-running is idempotent and never double-adds.
|
|
403
|
+
|
|
404
|
+
PERF (follow-up): this is graph-wide on every save. A tightly-scoped
|
|
405
|
+
"neighbourhood only" re-link is deferred — it ties into the separate P2
|
|
406
|
+
storage/indexing work. Correctness first.
|
|
407
|
+
"""
|
|
408
|
+
# Skip single-stack projects: they can never have cross-layer edges, so the
|
|
409
|
+
# (file-reading) enrichment would be pure overhead. Also keeps this a no-op
|
|
410
|
+
# during a full scan, which handles its own enrichment and never calls
|
|
411
|
+
# rebuild_file.
|
|
412
|
+
if not _looks_fullstack(graph):
|
|
413
|
+
return
|
|
414
|
+
|
|
415
|
+
try:
|
|
416
|
+
from codemind.router.route_extractor import enrich_graph_with_routes
|
|
417
|
+
from codemind.router.call_extractor import enrich_graph_with_api_calls
|
|
418
|
+
from codemind.router.linker import create_cross_layer_edges, route_first_link
|
|
419
|
+
|
|
420
|
+
enrich_graph_with_routes(graph, project_root)
|
|
421
|
+
enrich_graph_with_api_calls(graph, project_root)
|
|
422
|
+
create_cross_layer_edges(graph)
|
|
423
|
+
route_first_link(graph, project_root)
|
|
424
|
+
except Exception:
|
|
425
|
+
# Never let router enrichment crash an incremental rebuild — the parser
|
|
426
|
+
# edges are already applied; cross-layer links catch up on next save/scan.
|
|
427
|
+
pass
|
|
428
|
+
|
|
429
|
+
|
|
359
430
|
def _detect_frameworks(project_root: Path) -> list[str]:
|
|
360
431
|
"""Heuristic framework detection from build files."""
|
|
361
432
|
frameworks: set[str] = set()
|