bitbucket-gemini-action 1.0.0

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.
@@ -0,0 +1,8 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(bun run typecheck:*)",
5
+ "Bash(bun install:*)"
6
+ ]
7
+ }
8
+ }
package/.prettierrc ADDED
@@ -0,0 +1,8 @@
1
+ {
2
+ "semi": true,
3
+ "singleQuote": false,
4
+ "tabWidth": 2,
5
+ "trailingComma": "es5",
6
+ "printWidth": 80,
7
+ "useTabs": false
8
+ }
package/CLAUDE.md ADDED
@@ -0,0 +1,150 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code when working with this repository.
4
+
5
+ ## Project Overview
6
+
7
+ This is a Bitbucket Pipeline action that enables AI-powered code review using Google Gemini. The action responds to @gemini mentions in PR comments and can perform automated code reviews.
8
+
9
+ ## Development Tools
10
+
11
+ - Runtime: Bun 1.2+
12
+ - TypeScript with strict configuration
13
+ - Target: Node.js 20+
14
+
15
+ ## Common Development Tasks
16
+
17
+ ```bash
18
+ # Install dependencies
19
+ bun install
20
+
21
+ # Type checking
22
+ bun run typecheck
23
+
24
+ # Format code
25
+ bun run format
26
+ bun run format:check
27
+
28
+ # Run tests
29
+ bun test
30
+
31
+ # Build
32
+ bun run build
33
+ ```
34
+
35
+ ## Architecture Overview
36
+
37
+ The action operates in two phases:
38
+
39
+ ### Phase 1: Prepare (`src/entrypoints/prepare.ts`)
40
+
41
+ 1. Parse Bitbucket Pipeline context and environment
42
+ 2. Validate trigger conditions (@gemini mention or explicit prompt)
43
+ 3. Validate actor permissions
44
+ 4. Create tracking comment for progress visibility
45
+ 5. Output context for execution phase
46
+
47
+ ### Phase 2: Execute (`src/entrypoints/execute.ts`)
48
+
49
+ 1. Load context from prepare phase
50
+ 2. Fetch PR data (diff, comments, commits)
51
+ 3. Build prompt with PR context
52
+ 4. Call Gemini API with function calling
53
+ 5. Process tool calls (create comments, inline feedback)
54
+ 6. Update tracking comment with results
55
+
56
+ ## Key Components
57
+
58
+ ### Bitbucket Integration (`src/bitbucket/`)
59
+
60
+ - **api/client.ts**: REST API client for Bitbucket Cloud v2.0
61
+ - **context.ts**: Parse pipeline environment variables
62
+ - **data/fetcher.ts**: Fetch PR data with timestamp filtering
63
+ - **data/formatter.ts**: Format data for prompts
64
+ - **validation/**: Permission and trigger validation
65
+ - **operations/**: Comment creation and updates
66
+
67
+ ### Gemini Integration (`src/gemini/`)
68
+
69
+ - **client.ts**: Gemini API wrapper using @google/generative-ai
70
+ - **prompts.ts**: System prompts and prompt builders
71
+ - **tools.ts**: Function declarations for tool calling
72
+
73
+ ### Mode System (`src/modes/`)
74
+
75
+ - **tag/**: Interactive mode triggered by @gemini mentions
76
+ - **agent/**: Automated mode with explicit prompts
77
+ - **registry.ts**: Mode detection and selection
78
+
79
+ ## Environment Variables
80
+
81
+ Required:
82
+ - `GEMINI_API_KEY` or `GOOGLE_API_KEY`: Gemini API key
83
+ - `BITBUCKET_ACCESS_TOKEN` or `BITBUCKET_USERNAME`/`BITBUCKET_APP_PASSWORD`: Bitbucket credentials
84
+
85
+ Pipeline-provided:
86
+ - `BITBUCKET_WORKSPACE`: Workspace slug
87
+ - `BITBUCKET_REPO_SLUG`: Repository slug
88
+ - `BITBUCKET_COMMIT`: Current commit hash
89
+ - `BITBUCKET_PR_ID`: PR number (if PR context)
90
+
91
+ Optional:
92
+ - `TRIGGER_PHRASE`: Custom trigger (default: "@gemini")
93
+ - `GEMINI_MODEL`: Model to use (default: "gemini-2.0-flash")
94
+ - `MODE`: Force mode ("tag" or "agent")
95
+ - `PROMPT`: Explicit prompt for agent mode
96
+
97
+ ## Code Conventions
98
+
99
+ - Use Bun-specific TypeScript with `moduleResolution: "bundler"`
100
+ - Strict TypeScript with `noUnusedLocals` and `noUnusedParameters`
101
+ - Explicit error handling with detailed messages
102
+ - Use Zod for runtime validation
103
+ - Implement retry logic for API operations
104
+
105
+ ## Security Considerations
106
+
107
+ 1. **Timestamp Filtering**: Filter out comments modified after trigger time to prevent injection
108
+ 2. **Bot Detection**: Check if comment author is the bot itself to prevent loops
109
+ 3. **Permission Validation**: Verify write permissions before taking action
110
+ 4. **Content Sanitization**: Remove potential prompt injection patterns
111
+
112
+ ## Testing
113
+
114
+ Tests use Bun's built-in test runner:
115
+
116
+ ```bash
117
+ # Run all tests
118
+ bun test
119
+
120
+ # Run specific test file
121
+ bun test src/bitbucket/api/client.test.ts
122
+
123
+ # Watch mode
124
+ bun test --watch
125
+ ```
126
+
127
+ ## Project Structure
128
+
129
+ ```
130
+ src/
131
+ ├── bitbucket/ # Bitbucket API integration
132
+ │ ├── api/ # REST client
133
+ │ ├── data/ # Fetching & formatting
134
+ │ ├── operations/ # PR/comment operations
135
+ │ └── validation/ # Permissions & triggers
136
+ ├── gemini/ # Gemini API integration
137
+ │ ├── client.ts # API wrapper
138
+ │ ├── prompts.ts # Prompt templates
139
+ │ └── tools.ts # Function calling
140
+ ├── modes/ # Execution modes
141
+ │ ├── tag/ # @mention mode
142
+ │ ├── agent/ # Automation mode
143
+ │ └── registry.ts # Mode detection
144
+ ├── entrypoints/ # Pipeline entry points
145
+ │ ├── prepare.ts # Phase 1
146
+ │ └── execute.ts # Phase 2
147
+ └── utils/ # Shared utilities
148
+ ├── env.ts # Environment config
149
+ └── retry.ts # Retry logic
150
+ ```
package/README.md ADDED
@@ -0,0 +1,375 @@
1
+ # Bitbucket Gemini Action
2
+
3
+ AI-powered code review for Bitbucket using Google Gemini. Automatically review pull requests, respond to mentions, and provide intelligent code feedback.
4
+
5
+ ## Features
6
+
7
+ - 🤖 **AI Code Review**: Automatically analyze PRs for bugs, security issues, and code quality
8
+ - 💬 **@gemini Mentions**: Respond to questions and requests in PR comments
9
+ - 🔧 **Inline Comments**: Post targeted feedback on specific lines of code
10
+ - 📊 **Progress Tracking**: Visual tracking comments show review progress
11
+ - 🔄 **Two Modes**: Tag mode (interactive) and Agent mode (automated)
12
+
13
+ ## Quick Start
14
+
15
+ ### 1. Set up Repository Variables
16
+
17
+ Go to **Repository settings > Repository variables** and add:
18
+
19
+ | Variable | Required | Description |
20
+ |----------|----------|-------------|
21
+ | `GEMINI_API_KEY` | Yes | Your Google Gemini API key |
22
+ | `BITBUCKET_ACCESS_TOKEN` | Yes* | Bitbucket access token with PR permissions |
23
+ | `BITBUCKET_USERNAME` | Yes* | Username for basic auth |
24
+ | `BITBUCKET_APP_PASSWORD` | Yes* | App password for basic auth |
25
+
26
+ *Either `BITBUCKET_ACCESS_TOKEN` OR both `BITBUCKET_USERNAME` and `BITBUCKET_APP_PASSWORD` are required.
27
+
28
+ ### 2. Add Pipeline Configuration
29
+
30
+ Create or update your `bitbucket-pipelines.yml`:
31
+
32
+ ```yaml
33
+ image: node:20
34
+
35
+ pipelines:
36
+ pull-requests:
37
+ '**':
38
+ - step:
39
+ name: AI Code Review
40
+ script:
41
+ - curl -fsSL https://bun.sh/install | bash
42
+ - export PATH="$HOME/.bun/bin:$PATH"
43
+ - npx bitbucket-gemini-action
44
+ ```
45
+
46
+ ### 3. Use the Action
47
+
48
+ **Automatic Review**: PRs are automatically reviewed when opened or updated.
49
+
50
+ **Manual Trigger**: Comment `@gemini` followed by your request:
51
+ - `@gemini review this PR`
52
+ - `@gemini what does this function do?`
53
+ - `@gemini check for security issues`
54
+
55
+ ## Configuration
56
+
57
+ ### Environment Variables
58
+
59
+ | Variable | Default | Description |
60
+ |----------|---------|-------------|
61
+ | `GEMINI_API_KEY` | - | Google Gemini API key |
62
+ | `GOOGLE_API_KEY` | - | Alternative to GEMINI_API_KEY |
63
+ | `TRIGGER_PHRASE` | `@gemini` | Phrase to trigger bot |
64
+ | `GEMINI_MODEL` | `gemini-2.0-flash` | Gemini model to use |
65
+ | `MODE` | auto | `tag` or `agent` |
66
+ | `CREATE_TRACKING_COMMENT` | `true` | Show progress comment |
67
+ | `PROMPT` | - | Custom prompt for agent mode |
68
+
69
+ ### Available Models
70
+
71
+ - `gemini-2.0-flash` (default) - Fast and efficient
72
+ - `gemini-2.0-flash-lite` - Faster, lower cost
73
+ - `gemini-1.5-pro` - More capable, slower
74
+ - `gemini-1.5-flash` - Balanced option
75
+
76
+ ## Review Presets
77
+
78
+ 리뷰 프리셋을 사용하여 리뷰 스타일과 관점을 커스터마이징할 수 있습니다.
79
+
80
+ ### 환경 변수
81
+
82
+ | Variable | Description |
83
+ |----------|-------------|
84
+ | `REVIEW_PRESETS` | 쉼표로 구분된 프리셋 키 목록 (예: `junior,nextjs,security`) |
85
+ | `CUSTOM_PROMPT` | 추가 커스텀 프롬프트 |
86
+
87
+ ### 사용 예시
88
+
89
+ ```yaml
90
+ # 주니어 개발자 + Next.js 프로젝트
91
+ - step:
92
+ script:
93
+ - export REVIEW_PRESETS="junior,nextjs"
94
+ - npx bitbucket-gemini-action
95
+
96
+ # 시니어 + 아키텍처 + 보안 리뷰
97
+ - step:
98
+ script:
99
+ - export REVIEW_PRESETS="senior,architecture,security"
100
+ - npx bitbucket-gemini-action
101
+
102
+ # 챗봇 프로젝트 + RAG 시스템
103
+ - step:
104
+ script:
105
+ - export REVIEW_PRESETS="chatbot,rag,typescript"
106
+ - npx bitbucket-gemini-action
107
+
108
+ # 커스텀 프롬프트 추가
109
+ - step:
110
+ script:
111
+ - export REVIEW_PRESETS="middle,nestjs"
112
+ - export CUSTOM_PROMPT="특히 DB 쿼리 최적화에 집중해주세요"
113
+ - npx bitbucket-gemini-action
114
+ ```
115
+
116
+ ### 사용 가능한 프리셋
117
+
118
+ #### 경험 레벨 (Experience)
119
+
120
+ | Key | Name | Description |
121
+ |-----|------|-------------|
122
+ | `junior` | 주니어 개발자용 | 친절하고 교육적인 리뷰, 기본 개념 설명 포함 |
123
+ | `middle` | 미들급 개발자용 | 디자인 패턴, 트레이드오프 분석 |
124
+ | `senior` | 시니어 개발자용 | 아키텍처 수준 피드백, 간결한 분석 |
125
+ | `lead` | 테크 리드용 | 팀 관점, 멘토링 기회 식별 |
126
+
127
+ #### 리뷰 관점 (Perspective)
128
+
129
+ | Key | Name | Description |
130
+ |-----|------|-------------|
131
+ | `architecture` | 아키텍처/설계 | SOLID, 모듈화, 확장성 |
132
+ | `security` | 보안 | 취약점, 인증/인가, 민감 데이터 |
133
+ | `performance` | 성능 | 알고리즘, DB, 메모리, 비동기 |
134
+ | `testing` | 테스트 | 커버리지, 테스트 품질, 모킹 |
135
+ | `accessibility` | 접근성 (a11y) | 시맨틱 HTML, ARIA, 키보드 |
136
+ | `errorHandling` | 에러 핸들링 | 예외 처리, 복구 전략 |
137
+ | `codeStyle` | 코드 스타일 | 네이밍, 가독성, 일관성 |
138
+
139
+ #### 프레임워크 (Framework)
140
+
141
+ | Key | Name | Description |
142
+ |-----|------|-------------|
143
+ | `react` | React | Hooks, 컴포넌트 설계, 상태 관리 |
144
+ | `nextjs` | Next.js | App Router, Server Components, Data Fetching |
145
+ | `vue` | Vue.js | Composition API, Composables |
146
+ | `angular` | Angular | 모듈, DI, RxJS |
147
+ | `nestjs` | NestJS | 모듈, Guard/Pipe, DTO |
148
+ | `express` | Express.js | 미들웨어, 라우팅, 보안 |
149
+ | `fastify` | Fastify | 플러그인, 스키마, 훅 |
150
+ | `springboot` | Spring Boot | 레이어, JPA, Security |
151
+ | `django` | Django | 모델, ORM, DRF |
152
+ | `flask` | Flask | 블루프린트, SQLAlchemy |
153
+
154
+ #### 도메인 (Domain)
155
+
156
+ | Key | Name | Description |
157
+ |-----|------|-------------|
158
+ | `frontend` | 프론트엔드 일반 | UI/UX, 상태 관리, 스타일링 |
159
+ | `backend` | 백엔드 일반 | API 설계, DB, 인증 |
160
+ | `fullstack` | 풀스택 | API 계약, 데이터 흐름 |
161
+ | `mobile` | 모바일 | React Native, Flutter |
162
+ | `devops` | DevOps/인프라 | CI/CD, IaC, K8s |
163
+ | `database` | 데이터베이스 | 스키마, 인덱스, 쿼리 |
164
+
165
+ #### 프로그래밍 언어 (Language)
166
+
167
+ | Key | Name | Description |
168
+ |-----|------|-------------|
169
+ | `typescript` | TypeScript | 타입 시스템, 제네릭, 유틸리티 타입 |
170
+ | `javascript` | JavaScript | ES6+, 비동기, 모듈 |
171
+ | `python` | Python | PEP 8, Pythonic 코드 |
172
+ | `go` | Go | 관용구, 동시성, 에러 처리 |
173
+ | `java` | Java | 모던 Java, OOP, 동시성 |
174
+ | `rust` | Rust | 소유권, 에러 처리, 동시성 |
175
+
176
+ #### AI/ML
177
+
178
+ | Key | Name | Description |
179
+ |-----|------|-------------|
180
+ | `chatbot` | 챗봇/대화형 AI | 대화 관리, 프롬프트, RAG |
181
+ | `llmIntegration` | LLM API 통합 | API 클라이언트, 에러 처리, 비용 |
182
+ | `rag` | RAG 시스템 | 문서 처리, 임베딩, 검색 |
183
+ | `aiAgent` | AI 에이전트 | 계획-실행, 도구 사용, 안전성 |
184
+ | `mlOps` | MLOps | 모델 관리, 파이프라인, 모니터링 |
185
+ | `promptEngineering` | 프롬프트 엔지니어링 | 프롬프트 설계, 최적화 |
186
+ | `vectorDB` | 벡터 데이터베이스 | 인덱스, 쿼리 최적화 |
187
+ | `langchain` | LangChain | 체인, 에이전트, 메모리 |
188
+
189
+ #### 코드 품질 (Quality)
190
+
191
+ | Key | Name | Description |
192
+ |-----|------|-------------|
193
+ | `cleanCode` | 클린 코드 | 클린 코드 원칙 |
194
+ | `refactoring` | 리팩토링 기회 | 코드 스멜 식별 |
195
+ | `documentation` | 문서화 | API 문서, 주석 |
196
+ | `maintainability` | 유지보수성 | 가독성, 모듈성, 테스트 가능성 |
197
+
198
+ ### 프리셋 조합 예시
199
+
200
+ ```yaml
201
+ # 프론트엔드 팀
202
+ REVIEW_PRESETS="junior,react,frontend,accessibility"
203
+
204
+ # 백엔드 팀
205
+ REVIEW_PRESETS="middle,nestjs,backend,security,performance"
206
+
207
+ # AI/챗봇 팀
208
+ REVIEW_PRESETS="senior,chatbot,rag,langchain,typescript"
209
+
210
+ # 풀스택 코드 리뷰
211
+ REVIEW_PRESETS="middle,nextjs,nestjs,fullstack"
212
+
213
+ # 코드 품질 중심
214
+ REVIEW_PRESETS="cleanCode,refactoring,maintainability,testing"
215
+ ```
216
+
217
+ ## Modes
218
+
219
+ ### Tag Mode (Interactive)
220
+
221
+ Triggered by `@gemini` mentions in comments. Responds directly to user requests.
222
+
223
+ ```
224
+ @gemini Can you explain what this function does?
225
+ ```
226
+
227
+ ### Agent Mode (Automated)
228
+
229
+ Triggered by providing a `PROMPT` variable. Executes predefined tasks automatically.
230
+
231
+ ```yaml
232
+ - step:
233
+ script:
234
+ - export PROMPT="Review for security vulnerabilities"
235
+ - npx bitbucket-gemini-action
236
+ ```
237
+
238
+ ## Pipeline Examples
239
+
240
+ ### Basic PR Review
241
+
242
+ ```yaml
243
+ pipelines:
244
+ pull-requests:
245
+ '**':
246
+ - step:
247
+ name: AI Code Review
248
+ script:
249
+ - curl -fsSL https://bun.sh/install | bash
250
+ - export PATH="$HOME/.bun/bin:$PATH"
251
+ - npx bitbucket-gemini-action
252
+ ```
253
+
254
+ ### Custom Review Prompt
255
+
256
+ ```yaml
257
+ pipelines:
258
+ custom:
259
+ security-review:
260
+ - step:
261
+ name: Security Review
262
+ script:
263
+ - curl -fsSL https://bun.sh/install | bash
264
+ - export PATH="$HOME/.bun/bin:$PATH"
265
+ - export MODE="agent"
266
+ - export PROMPT="Focus on security: SQL injection, XSS, authentication issues"
267
+ - npx bitbucket-gemini-action
268
+ ```
269
+
270
+ ### Scheduled Reviews
271
+
272
+ ```yaml
273
+ definitions:
274
+ steps:
275
+ - step: &review
276
+ name: Review
277
+ script:
278
+ - npx bitbucket-gemini-action
279
+
280
+ schedules:
281
+ - cron: "0 9 * * 1-5"
282
+ pipeline: custom/daily-review
283
+ ```
284
+
285
+ ## How It Works
286
+
287
+ 1. **Prepare Phase**: Parses Bitbucket context, validates triggers, creates tracking comment
288
+ 2. **Execute Phase**: Calls Gemini API, processes response, posts comments
289
+
290
+ ```
291
+ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
292
+ │ PR Event or │────▶│ Prepare Phase │────▶│ Execute Phase │
293
+ │ @gemini Tag │ │ - Parse context│ │ - Call Gemini │
294
+ │ │ │ - Validate │ │ - Post comments│
295
+ └─────────────────┘ └─────────────────┘ └─────────────────┘
296
+ ```
297
+
298
+ ## Project Structure
299
+
300
+ ```
301
+ bitbucket-gemini-action/
302
+ ├── src/
303
+ │ ├── bitbucket/ # Bitbucket API integration
304
+ │ │ ├── api/ # REST API client
305
+ │ │ ├── data/ # Data fetching & formatting
306
+ │ │ ├── operations/ # Comment operations
307
+ │ │ └── validation/ # Permission & trigger validation
308
+ │ ├── gemini/ # Gemini API integration
309
+ │ │ ├── client.ts # API client
310
+ │ │ ├── prompts.ts # Prompt templates
311
+ │ │ └── tools.ts # Function calling tools
312
+ │ ├── modes/ # Execution modes
313
+ │ │ ├── tag/ # @gemini mention mode
314
+ │ │ └── agent/ # Automation mode
315
+ │ ├── entrypoints/ # Pipeline entry points
316
+ │ │ ├── prepare.ts # Phase 1
317
+ │ │ └── execute.ts # Phase 2
318
+ │ └── utils/ # Shared utilities
319
+ ├── examples/ # Pipeline examples
320
+ ├── bitbucket-pipelines.yml # Main pipeline config
321
+ └── package.json
322
+ ```
323
+
324
+ ## Security
325
+
326
+ - **Timestamp Filtering**: Comments modified after trigger time are ignored
327
+ - **Bot Detection**: Prevents infinite loops from bot comments
328
+ - **Permission Validation**: Verifies actor has write permissions
329
+ - **Content Sanitization**: Removes potential prompt injection attempts
330
+
331
+ ## Development
332
+
333
+ ```bash
334
+ # Install dependencies
335
+ bun install
336
+
337
+ # Type check
338
+ bun run typecheck
339
+
340
+ # Format code
341
+ bun run format
342
+
343
+ # Run tests
344
+ bun test
345
+ ```
346
+
347
+ ## Troubleshooting
348
+
349
+ ### "Missing Gemini API key"
350
+
351
+ Ensure `GEMINI_API_KEY` or `GOOGLE_API_KEY` is set in repository variables.
352
+
353
+ ### "Missing Bitbucket credentials"
354
+
355
+ Set either:
356
+ - `BITBUCKET_ACCESS_TOKEN`, or
357
+ - Both `BITBUCKET_USERNAME` and `BITBUCKET_APP_PASSWORD`
358
+
359
+ ### "Comment does not contain trigger phrase"
360
+
361
+ The default trigger is `@gemini`. Check if you've customized `TRIGGER_PHRASE`.
362
+
363
+ ### Bot not responding to comments
364
+
365
+ 1. Ensure the pipeline is triggered by PR events
366
+ 2. Check that credentials have PR comment permissions
367
+ 3. Verify the trigger phrase is in the comment
368
+
369
+ ## License
370
+
371
+ MIT
372
+
373
+ ## Credits
374
+
375
+ Inspired by [claude-code-action](https://github.com/anthropics/claude-code-action) by Anthropic.
@@ -0,0 +1,95 @@
1
+ # Bitbucket Gemini Action Pipeline
2
+ # AI-powered code review using Google Gemini
3
+
4
+ image: node:20
5
+
6
+ definitions:
7
+ caches:
8
+ bun: ~/.bun
9
+
10
+ steps:
11
+ - step: &gemini-review
12
+ name: Gemini Code Review
13
+ caches:
14
+ - bun
15
+ script:
16
+ # Install Bun
17
+ - curl -fsSL https://bun.sh/install | bash
18
+ - export BUN_INSTALL="$HOME/.bun"
19
+ - export PATH="$BUN_INSTALL/bin:$PATH"
20
+ - bun --version
21
+
22
+ # Clone the action repository (or use as a submodule)
23
+ - |
24
+ if [ ! -d ".gemini-action" ]; then
25
+ git clone https://github.com/your-org/bitbucket-gemini-action.git .gemini-action
26
+ fi
27
+
28
+ # Install dependencies
29
+ - cd .gemini-action && bun install && cd ..
30
+
31
+ # Run prepare phase
32
+ - bun run .gemini-action/src/entrypoints/prepare.ts
33
+
34
+ # Check if we should continue
35
+ - |
36
+ if [ -f ".gemini-action-output.json" ]; then
37
+ SHOULD_CONTINUE=$(cat .gemini-action-output.json | jq -r '.containsTrigger')
38
+ if [ "$SHOULD_CONTINUE" != "true" ]; then
39
+ echo "No trigger detected, skipping execution"
40
+ exit 0
41
+ fi
42
+ fi
43
+
44
+ # Run execute phase
45
+ - bun run .gemini-action/src/entrypoints/execute.ts
46
+
47
+ pipelines:
48
+ pull-requests:
49
+ '**':
50
+ - step:
51
+ <<: *gemini-review
52
+ name: AI Code Review
53
+ condition:
54
+ changesets:
55
+ includePaths:
56
+ - "**/*"
57
+
58
+ custom:
59
+ gemini-review:
60
+ - variables:
61
+ - name: PROMPT
62
+ default: "Review this PR for bugs, security issues, and code quality."
63
+ - name: MODE
64
+ default: "agent"
65
+ - step:
66
+ <<: *gemini-review
67
+ name: Manual Gemini Review
68
+
69
+ gemini-full-review:
70
+ - step:
71
+ <<: *gemini-review
72
+ name: Full Code Review
73
+ script:
74
+ - curl -fsSL https://bun.sh/install | bash
75
+ - export BUN_INSTALL="$HOME/.bun"
76
+ - export PATH="$BUN_INSTALL/bin:$PATH"
77
+ - |
78
+ if [ ! -d ".gemini-action" ]; then
79
+ git clone https://github.com/your-org/bitbucket-gemini-action.git .gemini-action
80
+ fi
81
+ - cd .gemini-action && bun install && cd ..
82
+ - PROMPT="Perform a comprehensive code review focusing on: 1) Security vulnerabilities 2) Performance issues 3) Code quality 4) Best practices 5) Documentation" bun run .gemini-action/src/entrypoints/prepare.ts
83
+ - bun run .gemini-action/src/entrypoints/execute.ts
84
+
85
+ # Environment variables required:
86
+ # - GEMINI_API_KEY or GOOGLE_API_KEY: Your Google Gemini API key
87
+ # - BITBUCKET_ACCESS_TOKEN: Bitbucket access token with PR comment permissions
88
+ # OR
89
+ # - BITBUCKET_USERNAME and BITBUCKET_APP_PASSWORD: Basic auth credentials
90
+ #
91
+ # Optional variables:
92
+ # - TRIGGER_PHRASE: Phrase to trigger review (default: "@gemini")
93
+ # - GEMINI_MODEL: Gemini model to use (default: "gemini-2.0-flash")
94
+ # - CREATE_TRACKING_COMMENT: Create progress comment (default: "true")
95
+ # - MODE: Execution mode - "tag" or "agent" (default: auto-detect)