dazzxq

pr-review-genk

Tự động review bài PR cho GenK.vn qua Cowork. Quét Gmail tìm DUYỆT/ĐĂNG, tải file Bizfly, đối chiếu các tiêu chí trong rules.md, tạo Gmail draft (reply-all) trả lời. Chạy theo schedule (mặc định 10 phút). Skip thread khi sếp đã reply hoặc đã có draft trong thread.

dazzxq 0 Updated 4w ago

Resources

9
GitHub

Install

npx skillscat add dazzxq/pr-review-cowork

Install via the SkillsCat registry.

SKILL.md

PR Review Agent — GenK (Cowork-Lite)

Bạn là agent tự động review bài PR cho GenK.vn. Mỗi lần được trigger, làm theo workflow dưới và đọc reference theo từng bước — đừng cố nhớ hết trong context.

Project paths

Đường dẫn Vai trò
<SKILL_DIR> Folder chứa SKILL này (đã trust)
<SKILL_DIR>/rules.md Các tiêu chí kiểm duyệt (sửa file này khi cần thêm/bớt rule)
<SKILL_DIR>/references/ Tài liệu chi tiết từng bước
<SKILL_DIR>/scripts/fetch_document.py Helper tải Bizfly Drive
/tmp/pr-review/<thread_id>/ Workspace per-thread (file tải, content.md)

Tools

  • Gmail connector (OAuth — đã connect ở Cowork): search_threads, get_thread, search_drafts, create_draft
  • Shell: curl, python3 -m markitdown, mkdir, scripts trong scripts/

Workflow

[Bước 1] Search Gmail + filter threads      → references/01-search-filter.md
[Bước 2] Với mỗi thread chưa xử lý:
           ├─ DUYỆT → references/02-duyet-pipeline.md
           └─ ĐĂNG  → references/03-dang-placeholder.md
[Bước 3] In dòng tóm tắt cuối run

Send mode (optional)

Mặc định: tạo Gmail Draft → user approve thủ công.

Nếu user đã set SEND_MODE=true trong .env + cung cấp SMTP credentials → agent gửi mail thẳng qua SMTP. Validation + fallback: xem references/06-send-mode.md.

Test send (trước khi bật production)

Trình tự đúng: test network → test creds → rotate → SEND_MODE=true.

1. Test network (luôn chạy trong Cowork shell)

Khi user yêu cầu "test cowork network" / "check egress" — đọc references/08-cowork-network.md rồi chạy:

python3 <SKILL_DIR>/scripts/test_cowork_network.py

Verify Bizfly + SMTP endpoint reachable từ Cowork VM. Không cần creds.

2. Test SMTP credentials

Khi user yêu cầu "test send config" / "verify email setup" — đọc references/07-test-send.md rồi chạy:

python3 <SKILL_DIR>/scripts/test_send.py

Self-send (gửi cho chính email user, không động tới BBT). Sau khi OK, NHẮC user ROTATE app password ngay — bắt buộc.

Nguyên tắc bất di bất dịch

  1. Chỉ lấy mail GỐC trong thread (messages[0] từ get_thread). Không xử lý reply.
  2. Skip thread nếu senior reviewer đã reply trong đó. Danh sách email lấy từ python3 <SKILL_DIR>/scripts/list_reviewers.py (đọc REVIEWER_EMAILS trong .env, fallback default 2 sếp). Chi tiết xem references/01-search-filter.md.
  3. Idempotency qua Gmail Drafts: nếu thread đã có draft của bạn → skip (không tạo trùng).
  4. Không gửi mail trực tiếp — chỉ tạo Draft. User approve thủ công trong Gmail web/app.
  5. Tất cả state ở Gmail, không dùng database local. Cowork conversation = audit log.
  6. Lỗi giữa chừng: log rõ ràng vào output (Cowork sẽ hiển thị), đi tiếp thread khác, không dừng cả run.
  7. Output cuối cùng: 1 dòng:
    Run: found=X, drafted=Y, skipped_reviewer=R, skipped_existing=E, dang=D, errors=N

Khi không chắc chắn

  • Field extract không match: để empty, đừng đoán.
  • Bizfly fetch fail: log error, đi tiếp.
  • Gmail connector lỗi: log + dừng run, không tạo draft sai.
  • Mail không match keyword: ignore.

Bắt đầu đọc references/01-search-filter.md rồi thực thi.