codemind-sh 0.2.0__tar.gz → 0.2.1__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.
Files changed (76) hide show
  1. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/PKG-INFO +9 -3
  2. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/README.md +6 -1
  3. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/codemind/__init__.py +1 -1
  4. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/codemind/ai/enricher.py +10 -11
  5. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/codemind/ai/pro_features.py +9 -8
  6. codemind_sh-0.2.1/codemind/ai/settings.py +54 -0
  7. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/codemind/ai/stack_learner.py +12 -25
  8. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/codemind/analyzer/dependency_analyzer.py +3 -5
  9. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/codemind/analyzer/java_analyzer.py +3 -6
  10. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/codemind/analyzer/typescript_analyzer.py +3 -6
  11. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/codemind/cli.py +110 -232
  12. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/codemind/core/config.py +10 -16
  13. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/codemind/core/constants.py +0 -21
  14. codemind_sh-0.2.1/codemind/core/excludes.py +97 -0
  15. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/codemind/core/graph.py +88 -10
  16. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/codemind/core/project.py +4 -5
  17. codemind_sh-0.2.0/codemind/license/state.py → codemind_sh-0.2.1/codemind/core/support.py +18 -7
  18. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/codemind/graph/builder.py +63 -67
  19. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/codemind/graph/query.py +1 -4
  20. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/codemind/knowledge/generator.py +13 -18
  21. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/codemind/knowledge/index_builder.py +2 -2
  22. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/codemind/mcp/connect.py +1 -1
  23. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/codemind/mcp/decisions.py +2 -2
  24. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/codemind/mcp/server.py +0 -1
  25. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/codemind/mcp/tools.py +3 -8
  26. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/codemind/router/call_extractor.py +1 -1
  27. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/codemind/router/linker.py +3 -3
  28. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/codemind/router/route_extractor.py +1 -1
  29. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/codemind/scaffold/generator.py +3 -5
  30. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/codemind/watcher/handler.py +27 -10
  31. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/pyproject.toml +5 -2
  32. codemind_sh-0.2.0/codemind/license/__init__.py +0 -1
  33. codemind_sh-0.2.0/codemind/license/client.py +0 -145
  34. codemind_sh-0.2.0/codemind/license/keygen.py +0 -65
  35. codemind_sh-0.2.0/codemind/license/license.py +0 -96
  36. codemind_sh-0.2.0/codemind/license/pricing.py +0 -103
  37. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/LICENSE +0 -0
  38. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/codemind/__main__.py +0 -0
  39. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/codemind/ai/__init__.py +0 -0
  40. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/codemind/analyzer/__init__.py +0 -0
  41. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/codemind/analyzer/base.py +0 -0
  42. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/codemind/context/__init__.py +0 -0
  43. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/codemind/context/engine.py +0 -0
  44. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/codemind/core/__init__.py +1 -1
  45. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/codemind/git/__init__.py +0 -0
  46. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/codemind/graph/__init__.py +0 -0
  47. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/codemind/graph/store.py +2 -2
  48. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/codemind/health/__init__.py +0 -0
  49. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/codemind/health/checker.py +0 -0
  50. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/codemind/health/dependency_check.py +0 -0
  51. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/codemind/health/pattern_check.py +0 -0
  52. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/codemind/health/test_coverage.py +0 -0
  53. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/codemind/knowledge/__init__.py +0 -0
  54. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/codemind/knowledge/architecture.py +0 -0
  55. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/codemind/knowledge/connection_builder.py +0 -0
  56. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/codemind/knowledge/connections.py +0 -0
  57. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/codemind/mcp/__init__.py +0 -0
  58. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/codemind/parser/__init__.py +0 -0
  59. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/codemind/parser/base.py +0 -0
  60. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/codemind/parser/gap_detector.py +0 -0
  61. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/codemind/parser/java_parser.py +0 -0
  62. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/codemind/parser/python_parser.py +0 -0
  63. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/codemind/parser/registry.py +0 -0
  64. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/codemind/parser/rule_cache.py +0 -0
  65. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/codemind/parser/typescript_parser.py +0 -0
  66. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/codemind/router/__init__.py +0 -0
  67. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/codemind/scaffold/__init__.py +0 -0
  68. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/codemind/scaffold/pattern_extractor.py +0 -0
  69. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/codemind/scaffold/templates/java/controller.java.j2 +0 -0
  70. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/codemind/scaffold/templates/java/entity.java.j2 +0 -0
  71. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/codemind/scaffold/templates/java/repository.java.j2 +0 -0
  72. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/codemind/scaffold/templates/java/service.java.j2 +0 -0
  73. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/codemind/scaffold/templates/java/test.java.j2 +0 -0
  74. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/codemind/scaffold/templates/typescript/service.ts.j2 +0 -0
  75. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/codemind/tasks/__init__.py +0 -0
  76. {codemind_sh-0.2.0 → codemind_sh-0.2.1}/codemind/watcher/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: codemind-sh
3
- Version: 0.2.0
3
+ Version: 0.2.1
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
@@ -17,6 +17,7 @@ Classifier: Programming Language :: Python :: 3.11
17
17
  Classifier: Programming Language :: Python :: 3.12
18
18
  Classifier: Programming Language :: Python :: 3.13
19
19
  Classifier: Programming Language :: Python :: 3.14
20
+ Classifier: Programming Language :: Python :: 3.15
20
21
  Classifier: Topic :: Software Development :: Documentation
21
22
  Classifier: Topic :: Software Development :: Quality Assurance
22
23
  Classifier: Typing :: Typed
@@ -25,7 +26,7 @@ Provides-Extra: all
25
26
  Requires-Dist: anthropic (>=0.40) ; extra == "ai" or extra == "all"
26
27
  Requires-Dist: click (>=8.1)
27
28
  Requires-Dist: jinja2 (>=3.1)
28
- Requires-Dist: mcp (>=1.0)
29
+ Requires-Dist: mcp (>=1.2,<2)
29
30
  Requires-Dist: pyperclip (>=1.9)
30
31
  Requires-Dist: pyyaml (>=6.0)
31
32
  Requires-Dist: rich (>=13.7)
@@ -44,6 +45,10 @@ Description-Content-Type: text/markdown
44
45
 
45
46
  # CodeMind
46
47
 
48
+ [![CI](https://github.com/onixsolutions/codemind-community/actions/workflows/ci.yml/badge.svg)](https://github.com/onixsolutions/codemind-community/actions/workflows/ci.yml)
49
+ [![PyPI](https://img.shields.io/pypi/v/codemind-sh)](https://pypi.org/project/codemind-sh/)
50
+ [![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
51
+
47
52
  **Your codebase finally knows what connects to what — and it never leaves your machine.**
48
53
 
49
54
  CodeMind is a local-first knowledge graph for software projects. It lives inside your project as `.codemind/` (like `.git/`) and builds a precise, always-current graph of every component and every typed connection. When you use AI coding tools (Claude Code, Cursor, Copilot), CodeMind exposes 11 structural MCP tools — so the AI answers *"what calls X?"*, *"what breaks if I change Y?"*, and *"which Angular service calls `/api/offers`?"* with facts from the graph, not guesses.
@@ -58,6 +63,7 @@ CodeMind fixes this — and goes further: it maps every component and connection
58
63
 
59
64
  ```bash
60
65
  pip install codemind-sh
66
+ # or, with nothing to install: uvx --from codemind-sh codemind --help
61
67
 
62
68
  cd your-project/
63
69
  codemind init
@@ -314,7 +320,7 @@ When `find_components` finds nothing for a Dart / Kotlin / Swift / Go file, Code
314
320
  - Your source code — never leaves your machine
315
321
  - MCP tools run over local stdio — no network
316
322
 
317
- The optional BYOK AI enricher (gap-filling injection edges) sends only small structural samples to the Claude API and is strictly opt-in via `ANTHROPIC_API_KEY`. All other features — including any-language indexing via `index_file` — run entirely offline using your existing AI tool session.
323
+ CodeMind makes no network calls of its own — no telemetry, no account, no update check. The optional AI features use your own Anthropic key and run only when you ask: `review`, `brief` and `impact --ai` send a summary of the graph; `scan --ai` sends the source of files the parsers could not connect. A key in your environment does not, by itself, send anything. All other features — including any-language indexing via `index_file` — run entirely offline using your existing AI tool session.
318
324
 
319
325
  ## Community & Support
320
326
 
@@ -1,5 +1,9 @@
1
1
  # CodeMind
2
2
 
3
+ [![CI](https://github.com/onixsolutions/codemind-community/actions/workflows/ci.yml/badge.svg)](https://github.com/onixsolutions/codemind-community/actions/workflows/ci.yml)
4
+ [![PyPI](https://img.shields.io/pypi/v/codemind-sh)](https://pypi.org/project/codemind-sh/)
5
+ [![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
6
+
3
7
  **Your codebase finally knows what connects to what — and it never leaves your machine.**
4
8
 
5
9
  CodeMind is a local-first knowledge graph for software projects. It lives inside your project as `.codemind/` (like `.git/`) and builds a precise, always-current graph of every component and every typed connection. When you use AI coding tools (Claude Code, Cursor, Copilot), CodeMind exposes 11 structural MCP tools — so the AI answers *"what calls X?"*, *"what breaks if I change Y?"*, and *"which Angular service calls `/api/offers`?"* with facts from the graph, not guesses.
@@ -14,6 +18,7 @@ CodeMind fixes this — and goes further: it maps every component and connection
14
18
 
15
19
  ```bash
16
20
  pip install codemind-sh
21
+ # or, with nothing to install: uvx --from codemind-sh codemind --help
17
22
 
18
23
  cd your-project/
19
24
  codemind init
@@ -270,7 +275,7 @@ When `find_components` finds nothing for a Dart / Kotlin / Swift / Go file, Code
270
275
  - Your source code — never leaves your machine
271
276
  - MCP tools run over local stdio — no network
272
277
 
273
- The optional BYOK AI enricher (gap-filling injection edges) sends only small structural samples to the Claude API and is strictly opt-in via `ANTHROPIC_API_KEY`. All other features — including any-language indexing via `index_file` — run entirely offline using your existing AI tool session.
278
+ CodeMind makes no network calls of its own — no telemetry, no account, no update check. The optional AI features use your own Anthropic key and run only when you ask: `review`, `brief` and `impact --ai` send a summary of the graph; `scan --ai` sends the source of files the parsers could not connect. A key in your environment does not, by itself, send anything. All other features — including any-language indexing via `index_file` — run entirely offline using your existing AI tool session.
274
279
 
275
280
  ## Community & Support
276
281
 
@@ -1,4 +1,4 @@
1
1
  """CodeMind — Local-first intelligence layer for software projects."""
2
2
 
3
- __version__ = "0.2.0"
3
+ __version__ = "0.2.1"
4
4
  __app_name__ = "codemind"
@@ -32,6 +32,7 @@ from typing import TYPE_CHECKING
32
32
  if TYPE_CHECKING:
33
33
  from codemind.core.graph import CodeGraph
34
34
 
35
+ from codemind.ai import settings as ai_settings
35
36
  from codemind.core.graph import EDGE_INJECTS, GraphEdge, GraphNode
36
37
  from codemind.parser.gap_detector import GapResult
37
38
  from codemind.parser.rule_cache import LearnedRule, RuleCache
@@ -165,7 +166,7 @@ class IndexResult:
165
166
 
166
167
 
167
168
  def add_component_to_graph(
168
- graph: "CodeGraph",
169
+ graph: CodeGraph,
169
170
  codemind_dir: Path,
170
171
  name: str,
171
172
  node_type: str,
@@ -243,7 +244,6 @@ class AIEnricher:
243
244
  enricher = AIEnricher() # reads ANTHROPIC_API_KEY from env
244
245
  """
245
246
 
246
- MODEL = "claude-haiku-4-5-20251001" # fast + cheap for structural analysis
247
247
 
248
248
  def __init__(self, api_key: str | None = None) -> None:
249
249
  self._api_key = api_key
@@ -255,13 +255,12 @@ class AIEnricher:
255
255
  import anthropic # noqa: F401
256
256
  except ImportError:
257
257
  return False
258
- import os
259
- return bool(api_key or os.environ.get("ANTHROPIC_API_KEY"))
258
+ return bool(api_key or ai_settings.api_key())
260
259
 
261
260
  def enrich(
262
261
  self,
263
262
  gaps: list[GapResult],
264
- graph: "CodeGraph",
263
+ graph: CodeGraph,
265
264
  project_root: Path,
266
265
  rule_cache: RuleCache | None = None,
267
266
  ) -> EnrichmentResult:
@@ -303,7 +302,7 @@ class AIEnricher:
303
302
  def _enrich_batch(
304
303
  self,
305
304
  gaps: list[GapResult],
306
- graph: "CodeGraph",
305
+ graph: CodeGraph,
307
306
  project_root: Path,
308
307
  rule_cache: RuleCache | None,
309
308
  claude_md_context: str = "",
@@ -398,9 +397,9 @@ class AIEnricher:
398
397
  def index_file(
399
398
  self,
400
399
  file_path: Path,
401
- graph: "CodeGraph",
400
+ graph: CodeGraph,
402
401
  codemind_dir: Path,
403
- ) -> "IndexResult":
402
+ ) -> IndexResult:
404
403
  """Read any source file and use AI to extract components + edges.
405
404
 
406
405
  Works for any language — Dart, Python, Kotlin, Swift, etc.
@@ -524,14 +523,14 @@ class AIEnricher:
524
523
 
525
524
  def _call_claude(self, user_message: str) -> dict:
526
525
  """Send the user message to Claude and parse the JSON response."""
526
+
527
527
  import anthropic
528
- import os
529
528
 
530
- api_key = self._api_key or os.environ.get("ANTHROPIC_API_KEY")
529
+ api_key = self._api_key or ai_settings.api_key()
531
530
  client = anthropic.Anthropic(api_key=api_key)
532
531
 
533
532
  response = client.messages.create(
534
- model=self.MODEL,
533
+ model=ai_settings.model(),
535
534
  max_tokens=2048,
536
535
  system=_SYSTEM_PROMPT,
537
536
  messages=[{"role": "user", "content": user_message}],
@@ -14,10 +14,11 @@ predict_impact(graph, component, api_key) → returns markdown string
14
14
  from __future__ import annotations
15
15
 
16
16
  import hashlib
17
- import json
18
17
  from pathlib import Path
19
18
  from typing import TYPE_CHECKING
20
19
 
20
+ from codemind.ai import settings as ai_settings
21
+
21
22
  if TYPE_CHECKING:
22
23
  from codemind.core.graph import CodeGraph
23
24
 
@@ -50,7 +51,7 @@ def _write_cache(codemind_dir: Path, filename: str, content: str) -> None:
50
51
  # ── Graph summary builder ─────────────────────────────────────────────────────
51
52
 
52
53
 
53
- def _graph_summary(graph: "CodeGraph") -> str:
54
+ def _graph_summary(graph: CodeGraph) -> str:
54
55
  """Build a compact text summary of the graph for AI prompts."""
55
56
  from collections import Counter
56
57
 
@@ -94,7 +95,7 @@ def _graph_summary(graph: "CodeGraph") -> str:
94
95
  return "\n".join(lines)
95
96
 
96
97
 
97
- def _health_summary(graph: "CodeGraph") -> str:
98
+ def _health_summary(graph: CodeGraph) -> str:
98
99
  """Run health checks and return a compact summary."""
99
100
  from codemind.health.checker import HealthChecker
100
101
  report = HealthChecker().run(graph)
@@ -112,7 +113,7 @@ def _health_summary(graph: "CodeGraph") -> str:
112
113
  # ── Anthropic call helper ─────────────────────────────────────────────────────
113
114
 
114
115
 
115
- def _call_claude(prompt: str, api_key: str, model: str = "claude-haiku-4-5-20251001") -> str:
116
+ def _call_claude(prompt: str, api_key: str, model: str | None = None) -> str:
116
117
  """Send a prompt to Claude and return the text response."""
117
118
  try:
118
119
  import anthropic # noqa: PLC0415
@@ -123,7 +124,7 @@ def _call_claude(prompt: str, api_key: str, model: str = "claude-haiku-4-5-20251
123
124
 
124
125
  client = anthropic.Anthropic(api_key=api_key)
125
126
  message = client.messages.create(
126
- model=model,
127
+ model=model or ai_settings.model(),
127
128
  max_tokens=2048,
128
129
  system=(
129
130
  "You are a software architecture analysis assistant for CodeMind, "
@@ -177,7 +178,7 @@ Keep it concise — max 400 words. Use component names from the graph.
177
178
 
178
179
 
179
180
  def generate_review(
180
- graph: "CodeGraph",
181
+ graph: CodeGraph,
181
182
  codemind_dir: Path,
182
183
  api_key: str,
183
184
  force: bool = False,
@@ -258,7 +259,7 @@ Keep it practical and under 500 words. Be specific about actual component names.
258
259
 
259
260
 
260
261
  def generate_brief(
261
- graph: "CodeGraph",
262
+ graph: CodeGraph,
262
263
  codemind_dir: Path,
263
264
  api_key: str,
264
265
  force: bool = False,
@@ -335,7 +336,7 @@ Keep it under 200 words. Be specific about component names from the graph.
335
336
 
336
337
 
337
338
  def predict_impact(
338
- graph: "CodeGraph",
339
+ graph: CodeGraph,
339
340
  component: str,
340
341
  api_key: str,
341
342
  ) -> str:
@@ -0,0 +1,54 @@
1
+ """AI settings — which model to call and where the API key comes from.
2
+
3
+ AI features are optional and bring-your-own-key. They run only when the user
4
+ asks for them (``codemind review``, ``codemind brief``, ``codemind impact --ai``,
5
+ ``codemind scan --ai`` or ``ai.enrich: true`` in config.yml). Nothing here is
6
+ read unless one of those is used.
7
+
8
+ The values come from the ``ai`` section of ``.codemind/config.yml``::
9
+
10
+ ai:
11
+ model: claude-haiku-4-5
12
+ api_key_env: ANTHROPIC_API_KEY
13
+ enrich: false
14
+ """
15
+
16
+ from __future__ import annotations
17
+
18
+ import os
19
+
20
+ DEFAULT_MODEL = "claude-haiku-4-5"
21
+ DEFAULT_API_KEY_ENV = "ANTHROPIC_API_KEY"
22
+
23
+ # Defaults written into config.yml by releases up to 0.2.0. They were never
24
+ # read, so treat them as "not set" rather than as a choice the user made.
25
+ _LEGACY_MODELS = {"claude-sonnet-4-5-20250929"}
26
+ _LEGACY_KEY_ENVS = {"CLAUDE_API_KEY"}
27
+
28
+ _model = DEFAULT_MODEL
29
+ _api_key_env = DEFAULT_API_KEY_ENV
30
+
31
+
32
+ def configure(model: str | None = None, api_key_env: str | None = None) -> None:
33
+ """Apply the project's ``ai`` config for the rest of this process."""
34
+ global _model, _api_key_env
35
+ _model = model if model and model not in _LEGACY_MODELS else DEFAULT_MODEL
36
+ _api_key_env = (
37
+ api_key_env if api_key_env and api_key_env not in _LEGACY_KEY_ENVS
38
+ else DEFAULT_API_KEY_ENV
39
+ )
40
+
41
+
42
+ def model() -> str:
43
+ """The model ID to send with every Anthropic request."""
44
+ return _model
45
+
46
+
47
+ def api_key_env() -> str:
48
+ """Name of the environment variable that holds the API key."""
49
+ return _api_key_env
50
+
51
+
52
+ def api_key() -> str:
53
+ """The user's API key, or an empty string if it is not set."""
54
+ return os.environ.get(_api_key_env, "")
@@ -30,6 +30,8 @@ from typing import TYPE_CHECKING
30
30
  if TYPE_CHECKING:
31
31
  from codemind.core.graph import CodeGraph
32
32
 
33
+ from codemind.ai import settings as ai_settings
34
+ from codemind.core.excludes import Excludes
33
35
  from codemind.core.graph import (
34
36
  EDGE_CALLS,
35
37
  EDGE_EXTENDS,
@@ -202,13 +204,12 @@ class StackLearner:
202
204
  import anthropic # noqa: F401
203
205
  except ImportError:
204
206
  return False
205
- import os
206
- return bool(api_key or os.environ.get("ANTHROPIC_API_KEY"))
207
+ return bool(api_key or ai_settings.api_key())
207
208
 
208
209
  def discover(
209
210
  self,
210
211
  project_root: Path,
211
- graph: "CodeGraph",
212
+ graph: CodeGraph,
212
213
  supported_extensions: set[str],
213
214
  rule_cache: RuleCache | None = None,
214
215
  extra_exclude: set[str] | None = None,
@@ -225,17 +226,10 @@ class StackLearner:
225
226
  Returns:
226
227
  One DiscoveryResult per discovered language.
227
228
  """
228
- exclude = (extra_exclude or set()) | {
229
- "node_modules", "target", "build", "dist", ".git", ".codemind",
230
- "__pycache__", ".venv", "venv",
231
- }
229
+ exclude = Excludes.with_extra(extra_exclude)
232
230
  # Collect unsupported files grouped by extension
233
231
  ext_files: dict[str, list[Path]] = {}
234
- for path in project_root.rglob("*"):
235
- if not path.is_file():
236
- continue
237
- if any(part in exclude for part in path.parts):
238
- continue
232
+ for path in exclude.walk(project_root):
239
233
  ext = path.suffix.lower()
240
234
  if ext in supported_extensions or ext not in _EXT_LANG:
241
235
  continue
@@ -263,16 +257,9 @@ class StackLearner:
263
257
 
264
258
  Useful for showing the user what they would gain by setting an API key.
265
259
  """
266
- exclude = (extra_exclude or set()) | {
267
- "node_modules", "target", "build", "dist", ".git", ".codemind",
268
- "__pycache__", ".venv", "venv",
269
- }
260
+ exclude = Excludes.with_extra(extra_exclude)
270
261
  counts: dict[str, int] = {}
271
- for path in project_root.rglob("*"):
272
- if not path.is_file():
273
- continue
274
- if any(part in exclude for part in path.parts):
275
- continue
262
+ for path in exclude.walk(project_root):
276
263
  ext = path.suffix.lower()
277
264
  if ext in supported_extensions or ext not in _EXT_LANG:
278
265
  continue
@@ -285,7 +272,7 @@ class StackLearner:
285
272
  self,
286
273
  language: str,
287
274
  files: list[Path],
288
- graph: "CodeGraph",
275
+ graph: CodeGraph,
289
276
  project_root: Path,
290
277
  rule_cache: RuleCache | None,
291
278
  ) -> DiscoveryResult:
@@ -387,13 +374,13 @@ class StackLearner:
387
374
  return None
388
375
 
389
376
  def _call_claude(self, user_message: str) -> dict:
377
+
390
378
  import anthropic
391
- import os
392
379
 
393
- api_key = self._api_key or os.environ.get("ANTHROPIC_API_KEY")
380
+ api_key = self._api_key or ai_settings.api_key()
394
381
  client = anthropic.Anthropic(api_key=api_key)
395
382
  response = client.messages.create(
396
- model="claude-haiku-4-5-20251001",
383
+ model=ai_settings.model(),
397
384
  max_tokens=3000,
398
385
  system=_SYSTEM_PROMPT,
399
386
  messages=[{"role": "user", "content": user_message}],
@@ -15,6 +15,8 @@ import xml.etree.ElementTree as ET
15
15
  from dataclasses import dataclass, field
16
16
  from pathlib import Path
17
17
 
18
+ from codemind.core.excludes import DEFAULT_EXCLUDES
19
+
18
20
  logger = logging.getLogger(__name__)
19
21
 
20
22
  # ── Data models ───────────────────────────────────────────────────────────────
@@ -656,12 +658,8 @@ def _categorize_pip(name: str) -> str:
656
658
 
657
659
  # ── Shared helpers ────────────────────────────────────────────────────────────
658
660
 
659
- _EXCLUDED_DIRS: frozenset[str] = frozenset(
660
- {"node_modules", "target", "dist", "build", ".git", "__pycache__",
661
- ".venv", "venv", ".codemind", ".angular"}
662
- )
663
661
 
664
662
 
665
663
  def _is_excluded(path: Path) -> bool:
666
664
  """Return True if the path passes through any excluded directory."""
667
- return any(part in _EXCLUDED_DIRS for part in path.parts)
665
+ return any(DEFAULT_EXCLUDES.skips_dir(part) for part in path.parts)
@@ -5,8 +5,8 @@ from __future__ import annotations
5
5
  import logging
6
6
  from pathlib import Path
7
7
 
8
- from tree_sitter import Language, Node, Parser
9
8
  import tree_sitter_java as tsjava
9
+ from tree_sitter import Language, Node, Parser
10
10
 
11
11
  from codemind.analyzer.base import (
12
12
  AnalyzedClass,
@@ -14,6 +14,7 @@ from codemind.analyzer.base import (
14
14
  AnalyzerResult,
15
15
  BaseAnalyzer,
16
16
  )
17
+ from codemind.core.excludes import DEFAULT_EXCLUDES
17
18
 
18
19
  logger = logging.getLogger(__name__)
19
20
 
@@ -32,10 +33,6 @@ _ANNOTATION_TO_CLASS_TYPE: dict[str, str] = {
32
33
  "@Aspect": "aspect",
33
34
  }
34
35
 
35
- # Directories whose contents are never analyzed
36
- _EXCLUDED_DIRS: frozenset[str] = frozenset(
37
- {"target", "build", ".git", "node_modules", "__pycache__", ".venv", ".codemind"}
38
- )
39
36
 
40
37
  # tree-sitter node types that represent a method return type
41
38
  _RETURN_TYPE_NODES: frozenset[str] = frozenset(
@@ -372,4 +369,4 @@ def _determine_class_type(annotations: list[str], node_type: str) -> str:
372
369
 
373
370
  def _is_excluded(path: Path) -> bool:
374
371
  """Return True if the path passes through any excluded directory."""
375
- return any(part in _EXCLUDED_DIRS for part in path.parts)
372
+ return any(DEFAULT_EXCLUDES.skips_dir(part) for part in path.parts)
@@ -5,8 +5,8 @@ from __future__ import annotations
5
5
  import logging
6
6
  from pathlib import Path
7
7
 
8
- from tree_sitter import Language, Node, Parser
9
8
  import tree_sitter_typescript as tsts
9
+ from tree_sitter import Language, Node, Parser
10
10
 
11
11
  from codemind.analyzer.base import (
12
12
  AnalyzedClass,
@@ -14,6 +14,7 @@ from codemind.analyzer.base import (
14
14
  AnalyzerResult,
15
15
  BaseAnalyzer,
16
16
  )
17
+ from codemind.core.excludes import DEFAULT_EXCLUDES
17
18
 
18
19
  logger = logging.getLogger(__name__)
19
20
 
@@ -28,10 +29,6 @@ _DECORATOR_TO_CLASS_TYPE: dict[str, str] = {
28
29
  "Directive": "directive",
29
30
  }
30
31
 
31
- # Directories that are never scanned
32
- _EXCLUDED_DIRS: frozenset[str] = frozenset(
33
- {"node_modules", "dist", ".git", "__pycache__", ".venv", ".codemind", "target", ".angular"}
34
- )
35
32
 
36
33
  # tree-sitter method-like node types to extract
37
34
  _METHOD_NODE_TYPES: frozenset[str] = frozenset(
@@ -436,4 +433,4 @@ def _find_child(node: Node, child_type: str) -> Node | None:
436
433
 
437
434
  def _is_excluded(path: Path) -> bool:
438
435
  """Return True if the path passes through any excluded directory."""
439
- return any(part in _EXCLUDED_DIRS for part in path.parts)
436
+ return any(DEFAULT_EXCLUDES.skips_dir(part) for part in path.parts)