ai-cr 0.4.7__py3-none-any.whl → 0.4.8__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,9 @@
1
1
  import logging
2
+ import os
2
3
  from datetime import datetime
3
4
 
4
5
  import microcore as mc
6
+ from ai_code_review.utils import is_running_in_github_action
5
7
 
6
8
  from .constants import ENV_CONFIG_FILE
7
9
 
@@ -28,10 +30,30 @@ def bootstrap():
28
30
  """Bootstrap the application with the environment configuration."""
29
31
  setup_logging()
30
32
  logging.info("Bootstrapping...")
31
- mc.configure(
32
- DOT_ENV_FILE=ENV_CONFIG_FILE,
33
- VALIDATE_CONFIG=False,
34
- USE_LOGGING=True,
35
- EMBEDDING_DB_TYPE=mc.EmbeddingDbType.NONE,
36
- )
33
+ try:
34
+ mc.configure(
35
+ DOT_ENV_FILE=ENV_CONFIG_FILE,
36
+ USE_LOGGING=True,
37
+ EMBEDDING_DB_TYPE=mc.EmbeddingDbType.NONE,
38
+ )
39
+ except mc.LLMConfigError as e:
40
+ msg = str(e)
41
+ if is_running_in_github_action():
42
+ ref = os.getenv("GITHUB_WORKFLOW_REF", "")
43
+ if ref:
44
+ ref = f" ({ref})"
45
+ msg += (
46
+ f"\nPlease check your GitHub Action Secrets "
47
+ f"and `env` configuration section of the corresponding workflow step{ref}."
48
+ )
49
+ else:
50
+ msg += (
51
+ "\nPlease run 'ai-code-review setup' "
52
+ "to configure LLM API access (API keys, model, etc)."
53
+ )
54
+ print(mc.ui.red(msg))
55
+ raise SystemExit(2)
56
+ except Exception as e:
57
+ logging.error(f"Unexpected configuration error: {e}")
58
+ raise SystemExit(3)
37
59
  mc.logging.LoggingConfig.STRIP_REQUEST_LINES = [100, 15]
@@ -3,5 +3,5 @@ from pathlib import Path
3
3
 
4
4
  PROJECT_CONFIG_FILE = Path(".ai-code-review.toml")
5
5
  PROJECT_CONFIG_DEFAULTS_FILE = Path(__file__).resolve().parent / PROJECT_CONFIG_FILE
6
- ENV_CONFIG_FILE = Path("~/.env.ai-code-review").expanduser()
6
+ ENV_CONFIG_FILE = ""#Path("~/.env.ai-code-review").expanduser()
7
7
  JSON_REPORT_FILE_NAME = "code-review-report.json"
ai_code_review/utils.py CHANGED
@@ -1,3 +1,4 @@
1
+ import os
1
2
  from pathlib import Path
2
3
 
3
4
  _EXT_TO_HINT: dict[str, str] = {
@@ -61,11 +62,20 @@ _EXT_TO_HINT: dict[str, str] = {
61
62
  }
62
63
 
63
64
 
64
- def syntax_hint(file_name: str) -> str:
65
+ def syntax_hint(file_path: str | Path) -> str:
65
66
  """
66
- Get the syntax hint for a file based on its extension.
67
+ Returns a syntax highlighting hint based on the file's extension or name.
68
+
69
+ This can be used to annotate code blocks for rendering with syntax highlighting,
70
+ e.g., using Markdown-style code blocks: ```<syntax_hint>\n<code>\n```.
71
+
72
+ Args:
73
+ file_path (str | Path): Path to the file.
74
+
75
+ Returns:
76
+ str: A syntax identifier suitable for code highlighting (e.g., 'python', 'json').
67
77
  """
68
- p = Path(file_name)
78
+ p = Path(file_path)
69
79
  ext = p.suffix.lower()
70
80
  if not ext:
71
81
  name = p.name.lower()
@@ -73,3 +83,7 @@ def syntax_hint(file_name: str) -> str:
73
83
  return "dockerfile"
74
84
  return ""
75
85
  return _EXT_TO_HINT.get(ext, ext.lstrip("."))
86
+
87
+
88
+ def is_running_in_github_action():
89
+ return os.getenv("GITHUB_ACTIONS") == "true"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: ai-cr
3
- Version: 0.4.7
3
+ Version: 0.4.8
4
4
  Summary: LLM-agnostic GitHub AI Code Review Tool with integration to GitHub actions
5
5
  License: MIT
6
6
  Keywords: static code analysis,code review,code quality,ai,coding,assistant,llm,github,automation,devops,developer tools,github actions,workflows,git
@@ -70,7 +70,7 @@ jobs:
70
70
  uses: actions/setup-python@v5
71
71
  with: { python-version: "3.13" }
72
72
  - name: Install AI Code Review tool
73
- run: pip install ai-code-review==0.4.1
73
+ run: pip install ai-code-review==0.4.7
74
74
  - name: Run AI code analysis
75
75
  env:
76
76
  LLM_API_KEY: ${{ secrets.LLM_API_KEY }}
@@ -151,7 +151,9 @@ pytest
151
151
 
152
152
  ## 🤝 Contributing
153
153
 
154
- We ❤️ contributions! See [CONTRIBUTING.md](https://github.com/Nayjest/ai-code-review/blob/main/CONTRIBUTING.md).
154
+ **Looking for a specific feature or having trouble?**
155
+ Contributions are welcome! ❤️
156
+ See [CONTRIBUTING.md](https://github.com/Nayjest/ai-code-review/blob/main/CONTRIBUTING.md) for details.
155
157
 
156
158
  ## 📝 License
157
159
 
@@ -1,14 +1,14 @@
1
1
  ai_code_review/.ai-code-review.toml,sha256=z-3iliCvkkpdAr9l_yUyM-IbgRm9hbAA3CIV6ocuurY,10378
2
2
  ai_code_review/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
- ai_code_review/bootstrap.py,sha256=vhAWjrfhkyyA504YusXhBlndsXd_bg2RP9hQbfnvM1M,1280
3
+ ai_code_review/bootstrap.py,sha256=qiI_jcNYQ30BC0exNzUgjmI2TE_-BrsBSVzMW9JjoFI,2116
4
4
  ai_code_review/cli.py,sha256=lulkEEUmQ1Fn3j3aQ0ZXc6aPHPcQDsr4YqA_C6gFFH4,3409
5
- ai_code_review/constants.py,sha256=K9mNxTq9seTG3aVm__3r1lXb5oCOQjH24Cl3hfX9FsE,281
5
+ ai_code_review/constants.py,sha256=jac2dNiGjShe5jd64WXKCYxpM-4lSh1WcXsbQTIYnAU,284
6
6
  ai_code_review/core.py,sha256=LhstEanCpMD0rVEYja0EQ4GuwB47RXGJJNOTkD6WqYk,3888
7
7
  ai_code_review/project_config.py,sha256=RDbplmncALKw0zgqSG8POofi300z0DPvtF33wt7_1Sk,3651
8
8
  ai_code_review/report_struct.py,sha256=N-EnNMwBY9LyJ9sdFHpUzn2fwBvxo5TZYYiJagBl8Po,3488
9
- ai_code_review/utils.py,sha256=DLzX9kILl5ABAsuwqFJk_3kItjgzzeTUrgZ3RMnDgAY,1713
10
- ai_cr-0.4.7.dist-info/entry_points.txt,sha256=fQYGUz6CVCClhei9kNCTtJUX6ia-dTca6p1sZ9pnst8,48
11
- ai_cr-0.4.7.dist-info/LICENSE,sha256=XATf3zv-CppUSJqI18KLhwnPEomUXEl5WbBzFyb9OSU,1096
12
- ai_cr-0.4.7.dist-info/METADATA,sha256=QCXyksLtb1v8Jl8K5DE3p3nU6Nh-IEZv9XhI4G5vCf0,5530
13
- ai_cr-0.4.7.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
14
- ai_cr-0.4.7.dist-info/RECORD,,
9
+ ai_code_review/utils.py,sha256=xHocdWXr-_Ghna31Hz80Et37gIXokz59UbcM_zOqK_k,2171
10
+ ai_cr-0.4.8.dist-info/entry_points.txt,sha256=fQYGUz6CVCClhei9kNCTtJUX6ia-dTca6p1sZ9pnst8,48
11
+ ai_cr-0.4.8.dist-info/LICENSE,sha256=XATf3zv-CppUSJqI18KLhwnPEomUXEl5WbBzFyb9OSU,1096
12
+ ai_cr-0.4.8.dist-info/METADATA,sha256=mQCK_8YgDCeq-bsVCS56pcKxl2v0ufTS8K_vmWsHnfM,5607
13
+ ai_cr-0.4.8.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
14
+ ai_cr-0.4.8.dist-info/RECORD,,
File without changes
File without changes