code-review-ai-cli 1.0.0__tar.gz → 1.0.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.
Files changed (28) hide show
  1. code_review_ai_cli-1.0.2/PKG-INFO +195 -0
  2. code_review_ai_cli-1.0.2/README.md +158 -0
  3. code_review_ai_cli-1.0.2/code_review_ai_cli.egg-info/PKG-INFO +195 -0
  4. {code_review_ai_cli-1.0.0 → code_review_ai_cli-1.0.2}/code_review_ai_cli.egg-info/SOURCES.txt +1 -0
  5. {code_review_ai_cli-1.0.0 → code_review_ai_cli-1.0.2}/pyproject.toml +1 -1
  6. {code_review_ai_cli-1.0.0 → code_review_ai_cli-1.0.2}/src/ai_review.py +42 -19
  7. {code_review_ai_cli-1.0.0 → code_review_ai_cli-1.0.2}/src/config.py +16 -7
  8. {code_review_ai_cli-1.0.0 → code_review_ai_cli-1.0.2}/src/llm_client.py +274 -10
  9. {code_review_ai_cli-1.0.0 → code_review_ai_cli-1.0.2}/src/prompts/config.yaml.template +5 -5
  10. code_review_ai_cli-1.0.2/src/prompts/review_prompt.md.template +42 -0
  11. {code_review_ai_cli-1.0.0 → code_review_ai_cli-1.0.2}/tests/test_ai_review.py +162 -1
  12. {code_review_ai_cli-1.0.0 → code_review_ai_cli-1.0.2}/tests/test_config.py +39 -1
  13. {code_review_ai_cli-1.0.0 → code_review_ai_cli-1.0.2}/tests/test_llm_client.py +177 -9
  14. code_review_ai_cli-1.0.0/PKG-INFO +0 -441
  15. code_review_ai_cli-1.0.0/README.md +0 -404
  16. code_review_ai_cli-1.0.0/code_review_ai_cli.egg-info/PKG-INFO +0 -441
  17. {code_review_ai_cli-1.0.0 → code_review_ai_cli-1.0.2}/code_review_ai_cli.egg-info/dependency_links.txt +0 -0
  18. {code_review_ai_cli-1.0.0 → code_review_ai_cli-1.0.2}/code_review_ai_cli.egg-info/entry_points.txt +0 -0
  19. {code_review_ai_cli-1.0.0 → code_review_ai_cli-1.0.2}/code_review_ai_cli.egg-info/requires.txt +0 -0
  20. {code_review_ai_cli-1.0.0 → code_review_ai_cli-1.0.2}/code_review_ai_cli.egg-info/top_level.txt +0 -0
  21. {code_review_ai_cli-1.0.0 → code_review_ai_cli-1.0.2}/setup.cfg +0 -0
  22. {code_review_ai_cli-1.0.0 → code_review_ai_cli-1.0.2}/src/__init__.py +0 -0
  23. {code_review_ai_cli-1.0.0 → code_review_ai_cli-1.0.2}/src/formatter.py +0 -0
  24. {code_review_ai_cli-1.0.0 → code_review_ai_cli-1.0.2}/src/git_utils.py +0 -0
  25. {code_review_ai_cli-1.0.0 → code_review_ai_cli-1.0.2}/src/tfs_client.py +0 -0
  26. {code_review_ai_cli-1.0.0 → code_review_ai_cli-1.0.2}/tests/test_formatter.py +0 -0
  27. {code_review_ai_cli-1.0.0 → code_review_ai_cli-1.0.2}/tests/test_git_utils.py +0 -0
  28. {code_review_ai_cli-1.0.0 → code_review_ai_cli-1.0.2}/tests/test_tfs_client.py +0 -0
@@ -0,0 +1,195 @@
1
+ Metadata-Version: 2.4
2
+ Name: code-review-ai-cli
3
+ Version: 1.0.2
4
+ Summary: Automated AI-powered code review CLI for Azure DevOps / TFS Pull Requests
5
+ License: MIT
6
+ Keywords: code-review,ai,azure-devops,tfs,pull-request,llm
7
+ Classifier: Development Status :: 4 - Beta
8
+ Classifier: Environment :: Console
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Topic :: Software Development :: Quality Assurance
16
+ Requires-Python: >=3.10
17
+ Description-Content-Type: text/markdown
18
+ Requires-Dist: requests>=2.28.0
19
+ Requires-Dist: PyYAML>=6.0
20
+ Provides-Extra: bedrock
21
+ Requires-Dist: boto3>=1.34.0; extra == "bedrock"
22
+ Provides-Extra: openai
23
+ Requires-Dist: openai>=1.0.0; extra == "openai"
24
+ Provides-Extra: gemini
25
+ Requires-Dist: google-generativeai>=0.3.0; extra == "gemini"
26
+ Provides-Extra: claude
27
+ Requires-Dist: anthropic>=0.18.0; extra == "claude"
28
+ Provides-Extra: all
29
+ Requires-Dist: boto3>=1.34.0; extra == "all"
30
+ Requires-Dist: openai>=1.0.0; extra == "all"
31
+ Requires-Dist: google-generativeai>=0.3.0; extra == "all"
32
+ Requires-Dist: anthropic>=0.18.0; extra == "all"
33
+ Provides-Extra: dev
34
+ Requires-Dist: pytest>=8.3.0; extra == "dev"
35
+ Requires-Dist: pytest-cov>=5.0.0; extra == "dev"
36
+ Requires-Dist: pytest-mock>=3.14.0; extra == "dev"
37
+
38
+ # AI Code Review CLI
39
+
40
+ Automated code review tool with Pull Request integration for Azure DevOps/TFS and support for multiple LLM providers.
41
+ **Documentation where** [docs/index.md](docs/index.md) for complete guides on CLI usage, LLM configuration, and architecture.
42
+
43
+ ## Features
44
+
45
+ - **AI Pull Request Review** — Automated code analysis with configurable LLM providers
46
+ - **Structured Comments** — Inline suggestions + general summary comments
47
+ - **Dry-run Mode** — Validate reviews before posting
48
+ - **Multiple LLM Providers** — OpenAI, Azure OpenAI, Gemini, Claude, Ollama, GitHub Copilot, AWS Bedrock
49
+ - **Smart Filtering** — Filter by file extensions, limit diff size
50
+ - **Customizable Prompts** — Markdown-based review guidelines
51
+ - **Interactive CLI** — Menu-driven selection and confirmation
52
+
53
+ ## Installation & Quick Start
54
+
55
+ ### 1. Install Package
56
+
57
+ From PyPI:
58
+
59
+ ```bash
60
+ pip install code-review-ai-cli
61
+ ```
62
+
63
+ With optional LLM SDK extras:
64
+
65
+ ```bash
66
+ pip install "code-review-ai-cli[bedrock]" # AWS Bedrock
67
+ pip install "code-review-ai-cli[openai]" # OpenAI SDK
68
+ pip install "code-review-ai-cli[gemini]" # Google Gemini SDK
69
+ pip install "code-review-ai-cli[claude]" # Anthropic Claude SDK
70
+ pip install "code-review-ai-cli[all]" # All optional SDKs
71
+ ```
72
+
73
+ For development:
74
+
75
+ ```bash
76
+ pip install -r requirements.txt
77
+ pip install "code-review-ai-cli[dev]" # Test suite + linting
78
+ ```
79
+
80
+ ### 2. Initialize Configuration
81
+
82
+ Generate config templates in your project directory:
83
+
84
+ ```bash
85
+ ai-review init
86
+ ```
87
+
88
+ Creates:
89
+ - `config.yaml` — LLM and review settings
90
+ - `review_prompt.md` — Customizable review guidelines
91
+
92
+ ### 3. Run Your First Review
93
+
94
+ ```bash
95
+ # List active PRs
96
+ ai-review list-prs
97
+
98
+ # Review a specific PR
99
+ ai-review pr-review 42
100
+
101
+ # Dry-run (preview without posting)
102
+ ai-review pr-review 42 --dry-run
103
+ ```
104
+
105
+ ## Configuration File
106
+
107
+ After `ai-review init`, edit `config.yaml`:
108
+
109
+ ```yaml
110
+ llm:
111
+ provider: bedrock # or: openai, gemini, claude, etc.
112
+ model: anthropic.claude-3-5-sonnet-20240620-v1:0
113
+
114
+ bedrock:
115
+ region: us-east-1
116
+
117
+ tfs:
118
+ base_url: https://dev.azure.com/your-org
119
+ project: YourProject
120
+ pat: xxxxxxxxx
121
+
122
+ review:
123
+ language: pt
124
+ verbosity: detailed # or: quick, security
125
+ file_extensions_filter: [".cs", ".ts", ".py"]
126
+ max_diff_files: 50
127
+ ```
128
+
129
+ ## Development & Testing
130
+
131
+ This is a standard Python project with the following structure:
132
+
133
+ ```
134
+ src/
135
+ ai_review.py # CLI entry point
136
+ config.py # Configuration management
137
+ llm_client.py # LLM provider abstraction
138
+ tfs_client.py # Azure DevOps integration
139
+ git_utils.py # Git diff processing
140
+ formatter.py # Output formatting (terminal, markdown, JSON)
141
+
142
+ tests/
143
+ test_*.py # Unit and integration tests
144
+ ```
145
+
146
+ ### Run Tests
147
+
148
+ ```bash
149
+ python -m pytest --cov=src --cov-report=term
150
+ ```
151
+
152
+ ### Code Quality
153
+
154
+ Project follows PEP8 with Black formatter and Ruff linter:
155
+
156
+ ```bash
157
+ # Format code
158
+ black src/ tests/
159
+
160
+ # Lint
161
+ ruff check src/ tests/
162
+
163
+ # Type checking (if using mypy)
164
+ mypy src/
165
+ ```
166
+
167
+
168
+ ## VS Code Integration
169
+
170
+ Predefined tasks for quick execution in VS Code:
171
+
172
+ ### Available Tasks
173
+
174
+ 1. **AI Review: Pull Request (Interactive)**
175
+ - Interactive mode with main menu
176
+ - Run with: `Ctrl+Shift+B` → Select task
177
+
178
+ 2. **AI Review: PR (Dry-Run)**
179
+ - Dry-run for a specific PR
180
+ - Prompts for PR ID
181
+
182
+ 3. **AI Review: List Active PRs**
183
+ - Lists active PRs
184
+ - Quick diagnostics
185
+
186
+ 4. **AI Review: Interactive Mode**
187
+ - Full tool menu
188
+ - Runs in background
189
+
190
+ ### How to run tasks
191
+
192
+ In VS Code:
193
+ 1. `Ctrl+Shift+P` → "Tasks: Run Task"
194
+ 2. Select the desired task
195
+ 3. Fill in parameters if needed
@@ -0,0 +1,158 @@
1
+ # AI Code Review CLI
2
+
3
+ Automated code review tool with Pull Request integration for Azure DevOps/TFS and support for multiple LLM providers.
4
+ **Documentation where** [docs/index.md](docs/index.md) for complete guides on CLI usage, LLM configuration, and architecture.
5
+
6
+ ## Features
7
+
8
+ - **AI Pull Request Review** — Automated code analysis with configurable LLM providers
9
+ - **Structured Comments** — Inline suggestions + general summary comments
10
+ - **Dry-run Mode** — Validate reviews before posting
11
+ - **Multiple LLM Providers** — OpenAI, Azure OpenAI, Gemini, Claude, Ollama, GitHub Copilot, AWS Bedrock
12
+ - **Smart Filtering** — Filter by file extensions, limit diff size
13
+ - **Customizable Prompts** — Markdown-based review guidelines
14
+ - **Interactive CLI** — Menu-driven selection and confirmation
15
+
16
+ ## Installation & Quick Start
17
+
18
+ ### 1. Install Package
19
+
20
+ From PyPI:
21
+
22
+ ```bash
23
+ pip install code-review-ai-cli
24
+ ```
25
+
26
+ With optional LLM SDK extras:
27
+
28
+ ```bash
29
+ pip install "code-review-ai-cli[bedrock]" # AWS Bedrock
30
+ pip install "code-review-ai-cli[openai]" # OpenAI SDK
31
+ pip install "code-review-ai-cli[gemini]" # Google Gemini SDK
32
+ pip install "code-review-ai-cli[claude]" # Anthropic Claude SDK
33
+ pip install "code-review-ai-cli[all]" # All optional SDKs
34
+ ```
35
+
36
+ For development:
37
+
38
+ ```bash
39
+ pip install -r requirements.txt
40
+ pip install "code-review-ai-cli[dev]" # Test suite + linting
41
+ ```
42
+
43
+ ### 2. Initialize Configuration
44
+
45
+ Generate config templates in your project directory:
46
+
47
+ ```bash
48
+ ai-review init
49
+ ```
50
+
51
+ Creates:
52
+ - `config.yaml` — LLM and review settings
53
+ - `review_prompt.md` — Customizable review guidelines
54
+
55
+ ### 3. Run Your First Review
56
+
57
+ ```bash
58
+ # List active PRs
59
+ ai-review list-prs
60
+
61
+ # Review a specific PR
62
+ ai-review pr-review 42
63
+
64
+ # Dry-run (preview without posting)
65
+ ai-review pr-review 42 --dry-run
66
+ ```
67
+
68
+ ## Configuration File
69
+
70
+ After `ai-review init`, edit `config.yaml`:
71
+
72
+ ```yaml
73
+ llm:
74
+ provider: bedrock # or: openai, gemini, claude, etc.
75
+ model: anthropic.claude-3-5-sonnet-20240620-v1:0
76
+
77
+ bedrock:
78
+ region: us-east-1
79
+
80
+ tfs:
81
+ base_url: https://dev.azure.com/your-org
82
+ project: YourProject
83
+ pat: xxxxxxxxx
84
+
85
+ review:
86
+ language: pt
87
+ verbosity: detailed # or: quick, security
88
+ file_extensions_filter: [".cs", ".ts", ".py"]
89
+ max_diff_files: 50
90
+ ```
91
+
92
+ ## Development & Testing
93
+
94
+ This is a standard Python project with the following structure:
95
+
96
+ ```
97
+ src/
98
+ ai_review.py # CLI entry point
99
+ config.py # Configuration management
100
+ llm_client.py # LLM provider abstraction
101
+ tfs_client.py # Azure DevOps integration
102
+ git_utils.py # Git diff processing
103
+ formatter.py # Output formatting (terminal, markdown, JSON)
104
+
105
+ tests/
106
+ test_*.py # Unit and integration tests
107
+ ```
108
+
109
+ ### Run Tests
110
+
111
+ ```bash
112
+ python -m pytest --cov=src --cov-report=term
113
+ ```
114
+
115
+ ### Code Quality
116
+
117
+ Project follows PEP8 with Black formatter and Ruff linter:
118
+
119
+ ```bash
120
+ # Format code
121
+ black src/ tests/
122
+
123
+ # Lint
124
+ ruff check src/ tests/
125
+
126
+ # Type checking (if using mypy)
127
+ mypy src/
128
+ ```
129
+
130
+
131
+ ## VS Code Integration
132
+
133
+ Predefined tasks for quick execution in VS Code:
134
+
135
+ ### Available Tasks
136
+
137
+ 1. **AI Review: Pull Request (Interactive)**
138
+ - Interactive mode with main menu
139
+ - Run with: `Ctrl+Shift+B` → Select task
140
+
141
+ 2. **AI Review: PR (Dry-Run)**
142
+ - Dry-run for a specific PR
143
+ - Prompts for PR ID
144
+
145
+ 3. **AI Review: List Active PRs**
146
+ - Lists active PRs
147
+ - Quick diagnostics
148
+
149
+ 4. **AI Review: Interactive Mode**
150
+ - Full tool menu
151
+ - Runs in background
152
+
153
+ ### How to run tasks
154
+
155
+ In VS Code:
156
+ 1. `Ctrl+Shift+P` → "Tasks: Run Task"
157
+ 2. Select the desired task
158
+ 3. Fill in parameters if needed
@@ -0,0 +1,195 @@
1
+ Metadata-Version: 2.4
2
+ Name: code-review-ai-cli
3
+ Version: 1.0.2
4
+ Summary: Automated AI-powered code review CLI for Azure DevOps / TFS Pull Requests
5
+ License: MIT
6
+ Keywords: code-review,ai,azure-devops,tfs,pull-request,llm
7
+ Classifier: Development Status :: 4 - Beta
8
+ Classifier: Environment :: Console
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Topic :: Software Development :: Quality Assurance
16
+ Requires-Python: >=3.10
17
+ Description-Content-Type: text/markdown
18
+ Requires-Dist: requests>=2.28.0
19
+ Requires-Dist: PyYAML>=6.0
20
+ Provides-Extra: bedrock
21
+ Requires-Dist: boto3>=1.34.0; extra == "bedrock"
22
+ Provides-Extra: openai
23
+ Requires-Dist: openai>=1.0.0; extra == "openai"
24
+ Provides-Extra: gemini
25
+ Requires-Dist: google-generativeai>=0.3.0; extra == "gemini"
26
+ Provides-Extra: claude
27
+ Requires-Dist: anthropic>=0.18.0; extra == "claude"
28
+ Provides-Extra: all
29
+ Requires-Dist: boto3>=1.34.0; extra == "all"
30
+ Requires-Dist: openai>=1.0.0; extra == "all"
31
+ Requires-Dist: google-generativeai>=0.3.0; extra == "all"
32
+ Requires-Dist: anthropic>=0.18.0; extra == "all"
33
+ Provides-Extra: dev
34
+ Requires-Dist: pytest>=8.3.0; extra == "dev"
35
+ Requires-Dist: pytest-cov>=5.0.0; extra == "dev"
36
+ Requires-Dist: pytest-mock>=3.14.0; extra == "dev"
37
+
38
+ # AI Code Review CLI
39
+
40
+ Automated code review tool with Pull Request integration for Azure DevOps/TFS and support for multiple LLM providers.
41
+ **Documentation where** [docs/index.md](docs/index.md) for complete guides on CLI usage, LLM configuration, and architecture.
42
+
43
+ ## Features
44
+
45
+ - **AI Pull Request Review** — Automated code analysis with configurable LLM providers
46
+ - **Structured Comments** — Inline suggestions + general summary comments
47
+ - **Dry-run Mode** — Validate reviews before posting
48
+ - **Multiple LLM Providers** — OpenAI, Azure OpenAI, Gemini, Claude, Ollama, GitHub Copilot, AWS Bedrock
49
+ - **Smart Filtering** — Filter by file extensions, limit diff size
50
+ - **Customizable Prompts** — Markdown-based review guidelines
51
+ - **Interactive CLI** — Menu-driven selection and confirmation
52
+
53
+ ## Installation & Quick Start
54
+
55
+ ### 1. Install Package
56
+
57
+ From PyPI:
58
+
59
+ ```bash
60
+ pip install code-review-ai-cli
61
+ ```
62
+
63
+ With optional LLM SDK extras:
64
+
65
+ ```bash
66
+ pip install "code-review-ai-cli[bedrock]" # AWS Bedrock
67
+ pip install "code-review-ai-cli[openai]" # OpenAI SDK
68
+ pip install "code-review-ai-cli[gemini]" # Google Gemini SDK
69
+ pip install "code-review-ai-cli[claude]" # Anthropic Claude SDK
70
+ pip install "code-review-ai-cli[all]" # All optional SDKs
71
+ ```
72
+
73
+ For development:
74
+
75
+ ```bash
76
+ pip install -r requirements.txt
77
+ pip install "code-review-ai-cli[dev]" # Test suite + linting
78
+ ```
79
+
80
+ ### 2. Initialize Configuration
81
+
82
+ Generate config templates in your project directory:
83
+
84
+ ```bash
85
+ ai-review init
86
+ ```
87
+
88
+ Creates:
89
+ - `config.yaml` — LLM and review settings
90
+ - `review_prompt.md` — Customizable review guidelines
91
+
92
+ ### 3. Run Your First Review
93
+
94
+ ```bash
95
+ # List active PRs
96
+ ai-review list-prs
97
+
98
+ # Review a specific PR
99
+ ai-review pr-review 42
100
+
101
+ # Dry-run (preview without posting)
102
+ ai-review pr-review 42 --dry-run
103
+ ```
104
+
105
+ ## Configuration File
106
+
107
+ After `ai-review init`, edit `config.yaml`:
108
+
109
+ ```yaml
110
+ llm:
111
+ provider: bedrock # or: openai, gemini, claude, etc.
112
+ model: anthropic.claude-3-5-sonnet-20240620-v1:0
113
+
114
+ bedrock:
115
+ region: us-east-1
116
+
117
+ tfs:
118
+ base_url: https://dev.azure.com/your-org
119
+ project: YourProject
120
+ pat: xxxxxxxxx
121
+
122
+ review:
123
+ language: pt
124
+ verbosity: detailed # or: quick, security
125
+ file_extensions_filter: [".cs", ".ts", ".py"]
126
+ max_diff_files: 50
127
+ ```
128
+
129
+ ## Development & Testing
130
+
131
+ This is a standard Python project with the following structure:
132
+
133
+ ```
134
+ src/
135
+ ai_review.py # CLI entry point
136
+ config.py # Configuration management
137
+ llm_client.py # LLM provider abstraction
138
+ tfs_client.py # Azure DevOps integration
139
+ git_utils.py # Git diff processing
140
+ formatter.py # Output formatting (terminal, markdown, JSON)
141
+
142
+ tests/
143
+ test_*.py # Unit and integration tests
144
+ ```
145
+
146
+ ### Run Tests
147
+
148
+ ```bash
149
+ python -m pytest --cov=src --cov-report=term
150
+ ```
151
+
152
+ ### Code Quality
153
+
154
+ Project follows PEP8 with Black formatter and Ruff linter:
155
+
156
+ ```bash
157
+ # Format code
158
+ black src/ tests/
159
+
160
+ # Lint
161
+ ruff check src/ tests/
162
+
163
+ # Type checking (if using mypy)
164
+ mypy src/
165
+ ```
166
+
167
+
168
+ ## VS Code Integration
169
+
170
+ Predefined tasks for quick execution in VS Code:
171
+
172
+ ### Available Tasks
173
+
174
+ 1. **AI Review: Pull Request (Interactive)**
175
+ - Interactive mode with main menu
176
+ - Run with: `Ctrl+Shift+B` → Select task
177
+
178
+ 2. **AI Review: PR (Dry-Run)**
179
+ - Dry-run for a specific PR
180
+ - Prompts for PR ID
181
+
182
+ 3. **AI Review: List Active PRs**
183
+ - Lists active PRs
184
+ - Quick diagnostics
185
+
186
+ 4. **AI Review: Interactive Mode**
187
+ - Full tool menu
188
+ - Runs in background
189
+
190
+ ### How to run tasks
191
+
192
+ In VS Code:
193
+ 1. `Ctrl+Shift+P` → "Tasks: Run Task"
194
+ 2. Select the desired task
195
+ 3. Fill in parameters if needed
@@ -14,6 +14,7 @@ src/git_utils.py
14
14
  src/llm_client.py
15
15
  src/tfs_client.py
16
16
  src/prompts/config.yaml.template
17
+ src/prompts/review_prompt.md.template
17
18
  tests/test_ai_review.py
18
19
  tests/test_config.py
19
20
  tests/test_formatter.py
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "code-review-ai-cli"
7
- version = "1.0.0"
7
+ version = "1.0.2"
8
8
  description = "Automated AI-powered code review CLI for Azure DevOps / TFS Pull Requests"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -40,6 +40,7 @@ Version: see pyproject.toml
40
40
  """
41
41
 
42
42
  import argparse
43
+ import importlib.resources
43
44
  import os
44
45
  import sys
45
46
  import time
@@ -872,16 +873,16 @@ def _show_config(config: ReviewConfig) -> None:
872
873
  # Init command
873
874
  # ---------------------------------------------------------------------------
874
875
  def cmd_init() -> int:
875
- """Copies a config.yaml template to the current working directory.
876
+ """Copies a config.yaml template and review_prompt.md to the current working directory.
876
877
 
877
878
  Creates a ``config.yaml`` file pre-populated with all available options
878
- and inline documentation. If the file already exists in the current
879
- directory the user is prompted for confirmation before overwriting.
879
+ and inline documentation, and a ``review_prompt.md`` file with default
880
+ review style rules. If either file already exists in the current directory
881
+ the user is prompted for confirmation before overwriting.
880
882
 
881
- The template is bundled with the package at
882
- ``src/prompts/config.yaml.template`` and is resolved at runtime via
883
- :mod:`importlib.resources`, so it works regardless of how the package
884
- was installed.
883
+ Both files are bundled with the package at ``src/prompts/`` and are
884
+ resolved at runtime via :mod:`importlib.resources`, so they work
885
+ regardless of how the package was installed.
885
886
 
886
887
  Returns:
887
888
  int: Exit code. ``0`` on success or user cancellation, ``1`` on error.
@@ -891,14 +892,15 @@ def cmd_init() -> int:
891
892
 
892
893
  $ ai-review init
893
894
  ✅ config.yaml created at: /home/user/my-project/config.yaml
894
- Edit it to add your credentials and preferences.
895
+ ✅ review_prompt.md created at: /home/user/my-project/review_prompt.md
896
+ Edit them to add your credentials, preferences and review rules.
895
897
  """
896
- import importlib.resources as pkg_resources
897
-
898
- dest = os.path.join(os.getcwd(), "config.yaml")
898
+ cwd = os.getcwd()
899
899
  c = Colors()
900
900
 
901
- if os.path.exists(dest):
901
+ # --- config.yaml ---
902
+ config_dest = os.path.join(cwd, "config.yaml")
903
+ if os.path.exists(config_dest):
902
904
  print(f"{c.YELLOW}config.yaml already exists in the current directory.{c.RESET}")
903
905
  answer = input("Overwrite? [y/N] ").strip().lower()
904
906
  if answer != "y":
@@ -906,17 +908,38 @@ def cmd_init() -> int:
906
908
  return 0
907
909
 
908
910
  try:
909
- ref = pkg_resources.files("src.prompts").joinpath("config.yaml.template")
910
- template_content = ref.read_text(encoding="utf-8")
911
+ ref = importlib.resources.files("src.prompts").joinpath("config.yaml.template")
912
+ config_content = ref.read_text(encoding="utf-8")
913
+ except (FileNotFoundError, TypeError) as exc:
914
+ print(f"{c.RED}Error: could not locate config template: {exc}{c.RESET}")
915
+ return 1
916
+
917
+ with open(config_dest, "w", encoding="utf-8") as fh:
918
+ fh.write(config_content)
919
+
920
+ # --- review_prompt.md ---
921
+ prompt_dest = os.path.join(cwd, "review_prompt.md")
922
+ if os.path.exists(prompt_dest):
923
+ print(f"{c.YELLOW}review_prompt.md already exists in the current directory.{c.RESET}")
924
+ answer = input("Overwrite? [y/N] ").strip().lower()
925
+ if answer != "y":
926
+ print(f"{c.GREEN}✅ config.yaml created at:{c.RESET} {config_dest}")
927
+ print(" Skipped review_prompt.md (kept existing).")
928
+ return 0
929
+
930
+ try:
931
+ ref = importlib.resources.files("src.prompts").joinpath("review_prompt.md.template")
932
+ prompt_content = ref.read_text(encoding="utf-8")
911
933
  except (FileNotFoundError, TypeError) as exc:
912
- print(f"{c.RED}Error: could not locate template file: {exc}{c.RESET}")
934
+ print(f"{c.RED}Error: could not locate review_prompt template: {exc}{c.RESET}")
913
935
  return 1
914
936
 
915
- with open(dest, "w", encoding="utf-8") as fh:
916
- fh.write(template_content)
937
+ with open(prompt_dest, "w", encoding="utf-8") as fh:
938
+ fh.write(prompt_content)
917
939
 
918
- print(f"{c.GREEN}✅ config.yaml created at:{c.RESET} {dest}")
919
- print(f" Edit it to add your credentials and preferences.")
940
+ print(f"{c.GREEN}✅ config.yaml created at:{c.RESET} {config_dest}")
941
+ print(f"{c.GREEN}✅ review_prompt.md created at:{c.RESET} {prompt_dest}")
942
+ print(" Edit them to add your credentials, preferences and review rules.")
920
943
  return 0
921
944
 
922
945