bitbucket-gemini-action 1.0.10 → 1.0.12

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.
package/README.md CHANGED
@@ -52,6 +52,8 @@ pipelines:
52
52
  - `@gemini what does this function do?`
53
53
  - `@gemini check for security issues`
54
54
 
55
+ > **Note**: `@gemini` 멘션 기능을 사용하려면 [웹훅 설정](#webhook-setup-for-gemini-mentions)이 필요합니다.
56
+
55
57
  ## Configuration
56
58
 
57
59
  ### Environment Variables
@@ -235,6 +237,119 @@ Triggered by providing a `PROMPT` variable. Executes predefined tasks automatica
235
237
  - npx bitbucket-gemini-action
236
238
  ```
237
239
 
240
+ ### 자동 리뷰 + @gemini 멘션 동시 사용
241
+
242
+ 두 기능을 동시에 사용하려면:
243
+
244
+ 1. **자동 리뷰**: `PROMPT` 환경변수로 PR 생성/업데이트 시 자동 실행
245
+ 2. **@gemini 멘션**: 웹훅으로 코멘트 이벤트 수신 시 실행
246
+
247
+ ```yaml
248
+ image: node:20
249
+
250
+ pipelines:
251
+ pull-requests:
252
+ '**':
253
+ - step:
254
+ name: AI Code Review
255
+ script:
256
+ - export PROMPT="Review this PR"
257
+ - export ALLOW_BOTS=true
258
+ - export REVIEW_PRESETS="middle,nextjs,typescript"
259
+ - npx bitbucket-gemini-action@latest
260
+
261
+ custom:
262
+ gemini-comment:
263
+ - step:
264
+ name: Gemini Comment Handler
265
+ script:
266
+ - export ALLOW_BOTS=true
267
+ - npx bitbucket-gemini-action@latest
268
+ ```
269
+
270
+ - `pull-requests` 파이프라인: PR 생성/업데이트 시 자동 리뷰
271
+ - `custom/gemini-comment` 파이프라인: 웹훅에서 코멘트 이벤트 수신 시 `@gemini` 멘션 처리
272
+
273
+ ## Webhook Setup for @gemini Mentions
274
+
275
+ `@gemini` 멘션 기능을 사용하려면 Bitbucket 웹훅과 중간 서버가 필요합니다.
276
+
277
+ ### 왜 중간 서버가 필요한가?
278
+
279
+ Bitbucket Pipelines는 **외부 웹훅 URL로 직접 트리거할 수 없습니다**. 따라서:
280
+
281
+ 1. 웹훅 → 중간 서버 → Bitbucket API로 파이프라인 트리거
282
+
283
+ ### 옵션 1: 외부 서버 사용 (권장)
284
+
285
+ AWS Lambda, Cloudflare Workers, 또는 별도 서버에서 웹훅을 수신하고 Bitbucket API를 호출:
286
+
287
+ ```javascript
288
+ // Cloudflare Worker 예시
289
+ export default {
290
+ async fetch(request, env) {
291
+ const payload = await request.json();
292
+
293
+ // @gemini 멘션 확인
294
+ if (!payload.comment?.content?.raw?.includes('@gemini')) {
295
+ return new Response('No trigger', { status: 200 });
296
+ }
297
+
298
+ // Bitbucket Pipeline API 호출
299
+ const response = await fetch(
300
+ `https://api.bitbucket.org/2.0/repositories/${payload.repository.full_name}/pipelines/`,
301
+ {
302
+ method: 'POST',
303
+ headers: {
304
+ 'Authorization': `Bearer ${env.BITBUCKET_ACCESS_TOKEN}`,
305
+ 'Content-Type': 'application/json',
306
+ },
307
+ body: JSON.stringify({
308
+ target: {
309
+ ref_type: 'branch',
310
+ type: 'pipeline_ref_target',
311
+ ref_name: payload.pullrequest.source.branch.name,
312
+ selector: {
313
+ type: 'custom',
314
+ pattern: 'gemini-comment',
315
+ },
316
+ },
317
+ variables: [
318
+ { key: 'WEBHOOK_PAYLOAD', value: JSON.stringify(payload) },
319
+ { key: 'TRIGGER_EVENT', value: 'pullrequest:comment_created' },
320
+ ],
321
+ }),
322
+ }
323
+ );
324
+
325
+ return new Response('Pipeline triggered', { status: 200 });
326
+ },
327
+ };
328
+ ```
329
+
330
+ ### 옵션 2: Bitbucket Connect 앱 개발
331
+
332
+ 더 깊은 통합이 필요하면 Bitbucket Connect 앱을 개발하세요.
333
+
334
+ ### 웹훅 설정 방법
335
+
336
+ 1. **Repository Settings → Webhooks → Add webhook**
337
+ 2. **Title**: `bitbucket-gemini`
338
+ 3. **URL**: 중간 서버 URL (예: `https://your-worker.workers.dev/webhook`)
339
+ 4. **Triggers 선택**:
340
+ - ✅ Pull request: Comment created
341
+ - ✅ Pull request: Comment updated (선택사항)
342
+ 5. **Save**
343
+
344
+ ### 환경 변수
345
+
346
+ 웹훅 핸들러에서 파이프라인 트리거 시 다음 변수를 전달해야 합니다:
347
+
348
+ | Variable | Description |
349
+ |----------|-------------|
350
+ | `WEBHOOK_PAYLOAD` | 웹훅 페이로드 JSON 문자열 |
351
+ | `TRIGGER_EVENT` | `pullrequest:comment_created` 또는 `pullrequest:comment_updated` |
352
+
238
353
  ## Pipeline Examples
239
354
 
240
355
  ### Basic PR Review
package/dist/cli.js CHANGED
@@ -2320,7 +2320,11 @@ ${formatComments(context.comments)}` : ""}
2320
2320
 
2321
2321
  **모든 코멘트와 피드백은 반드시 한국어로 작성하세요.**
2322
2322
 
2323
- 특정 라인에 인라인 코멘트를 남기고, 전체적인 피드백은 요약 코멘트로 작성하세요.`;
2323
+ ## 중요: 도구 사용 방법
2324
+ 1. **create_inline_comment**: 코드의 특정 라인에 피드백을 남길 때 반드시 이 도구를 사용하세요. 개선이 필요한 각 코드 라인마다 개별적으로 호출하세요.
2325
+ 2. **create_pr_comment**: 전체적인 요약만 이 도구로 작성하세요.
2326
+
2327
+ 피드백이 있는 모든 코드 라인에 대해 create_inline_comment를 사용해야 합니다.`;
2324
2328
  }
2325
2329
  function buildTagModePrompt(context, userMessage, mentionAuthor) {
2326
2330
  const filesSummary = context.files.map((f) => `- ${f.path} (${f.status}): +${f.additions}/-${f.deletions}`).join(`
@@ -2462,7 +2466,7 @@ ${presetPrompt}`;
2462
2466
  // src/gemini/tools.ts
2463
2467
  var createInlineCommentTool = {
2464
2468
  name: "create_inline_comment",
2465
- description: "Create an inline comment on a specific line of code in the pull request. Use this ONLY for significant issues like bugs, security problems, or important improvements. Do NOT comment on minor style issues or obvious code.",
2469
+ description: "Create an inline comment on a specific line of code in the pull request. Use this tool for each line where you have feedback. This is the PRIMARY tool for code review comments.",
2466
2470
  parameters: {
2467
2471
  type: "object",
2468
2472
  properties: {
@@ -3420,7 +3420,11 @@ ${formatComments2(context.comments)}` : ""}
3420
3420
 
3421
3421
  **모든 코멘트와 피드백은 반드시 한국어로 작성하세요.**
3422
3422
 
3423
- 특정 라인에 인라인 코멘트를 남기고, 전체적인 피드백은 요약 코멘트로 작성하세요.`;
3423
+ ## 중요: 도구 사용 방법
3424
+ 1. **create_inline_comment**: 코드의 특정 라인에 피드백을 남길 때 반드시 이 도구를 사용하세요. 개선이 필요한 각 코드 라인마다 개별적으로 호출하세요.
3425
+ 2. **create_pr_comment**: 전체적인 요약만 이 도구로 작성하세요.
3426
+
3427
+ 피드백이 있는 모든 코드 라인에 대해 create_inline_comment를 사용해야 합니다.`;
3424
3428
  }
3425
3429
  function buildTagModePrompt(context, userMessage, mentionAuthor) {
3426
3430
  const filesSummary = context.files.map((f) => `- ${f.path} (${f.status}): +${f.additions}/-${f.deletions}`).join(`
@@ -3562,7 +3566,7 @@ ${presetPrompt}`;
3562
3566
  // src/gemini/tools.ts
3563
3567
  var createInlineCommentTool = {
3564
3568
  name: "create_inline_comment",
3565
- description: "Create an inline comment on a specific line of code in the pull request. Use this ONLY for significant issues like bugs, security problems, or important improvements. Do NOT comment on minor style issues or obvious code.",
3569
+ description: "Create an inline comment on a specific line of code in the pull request. Use this tool for each line where you have feedback. This is the PRIMARY tool for code review comments.",
3566
3570
  parameters: {
3567
3571
  type: "object",
3568
3572
  properties: {
@@ -2319,7 +2319,11 @@ ${formatComments(context.comments)}` : ""}
2319
2319
 
2320
2320
  **모든 코멘트와 피드백은 반드시 한국어로 작성하세요.**
2321
2321
 
2322
- 특정 라인에 인라인 코멘트를 남기고, 전체적인 피드백은 요약 코멘트로 작성하세요.`;
2322
+ ## 중요: 도구 사용 방법
2323
+ 1. **create_inline_comment**: 코드의 특정 라인에 피드백을 남길 때 반드시 이 도구를 사용하세요. 개선이 필요한 각 코드 라인마다 개별적으로 호출하세요.
2324
+ 2. **create_pr_comment**: 전체적인 요약만 이 도구로 작성하세요.
2325
+
2326
+ 피드백이 있는 모든 코드 라인에 대해 create_inline_comment를 사용해야 합니다.`;
2323
2327
  }
2324
2328
  function buildTagModePrompt(context, userMessage, mentionAuthor) {
2325
2329
  const filesSummary = context.files.map((f) => `- ${f.path} (${f.status}): +${f.additions}/-${f.deletions}`).join(`
@@ -2461,7 +2465,7 @@ ${presetPrompt}`;
2461
2465
  // src/gemini/tools.ts
2462
2466
  var createInlineCommentTool = {
2463
2467
  name: "create_inline_comment",
2464
- description: "Create an inline comment on a specific line of code in the pull request. Use this ONLY for significant issues like bugs, security problems, or important improvements. Do NOT comment on minor style issues or obvious code.",
2468
+ description: "Create an inline comment on a specific line of code in the pull request. Use this tool for each line where you have feedback. This is the PRIMARY tool for code review comments.",
2465
2469
  parameters: {
2466
2470
  type: "object",
2467
2471
  properties: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bitbucket-gemini-action",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
4
4
  "description": "Bitbucket Pipeline action for AI-powered code review using Google Gemini",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",