diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 0000000..2b00b6e --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,66 @@ +name: Bug report +description: Report a reproducible problem in refix +title: "[Bug] " +labels: + - bug +body: + - type: markdown + attributes: + value: | + Thanks for reporting a bug. Please provide enough detail for us to reproduce and investigate it quickly. + - type: textarea + id: summary + attributes: + label: Summary + description: What happened? + placeholder: A short description of the problem. + validations: + required: true + - type: textarea + id: steps + attributes: + label: Steps to reproduce + description: Please list the exact steps. + placeholder: | + 1. Configure ... + 2. Run ... + 3. Observe ... + validations: + required: true + - type: textarea + id: expected + attributes: + label: Expected behavior + placeholder: What did you expect to happen? + validations: + required: true + - type: textarea + id: actual + attributes: + label: Actual behavior + placeholder: What actually happened? + validations: + required: true + - type: textarea + id: config + attributes: + label: Relevant configuration + description: Share the relevant parts of `.refix.yaml` after redacting secrets. + render: yaml + - type: textarea + id: logs + attributes: + label: Logs and screenshots + description: Paste terminal output, workflow logs, or attach screenshots if available. + - type: input + id: version + attributes: + label: Version or commit + description: What version, branch, or commit are you using? + placeholder: main / v1.2.3 / abc1234 + - type: input + id: environment + attributes: + label: Environment + description: OS, Python version, and execution context. + placeholder: ubuntu-latest, Python 3.12, GitHub Actions diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..0086358 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1 @@ +blank_issues_enabled: true diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml new file mode 100644 index 0000000..773e721 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -0,0 +1,44 @@ +name: Feature request +description: Suggest an improvement for refix +title: "[Feature] " +labels: + - enhancement +body: + - type: markdown + attributes: + value: | + Thanks for sharing an idea. Clear problem statements and expected outcomes help us evaluate requests faster. + - type: textarea + id: problem + attributes: + label: Problem to solve + description: What pain point or limitation are you trying to address? + placeholder: I want refix to ... + validations: + required: true + - type: textarea + id: proposal + attributes: + label: Proposed solution + description: Describe the behavior you would like to see. + placeholder: Add support for ... + validations: + required: true + - type: textarea + id: alternatives + attributes: + label: Alternatives considered + description: Describe workarounds or other approaches you have considered. + - type: textarea + id: use_cases + attributes: + label: Use cases + description: Share concrete scenarios where this would help. + placeholder: | + - In CI, ... + - For multi-repository setups, ... + - type: textarea + id: extra + attributes: + label: Additional context + description: Links, mockups, logs, or other supporting information. diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..8d1bf3d --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,22 @@ +## Summary + +- + +## Related issues + +- Closes # + +## Changes + +- + +## Testing + +- + +## Checklist + +- [ ] I verified the change locally or in CI as appropriate. +- [ ] I added or updated tests when needed. +- [ ] I updated documentation for user-facing changes. +- [ ] I confirmed there are no unintended breaking changes, or documented them clearly. diff --git a/.refix.yaml.sample b/.refix.yaml.sample index 3e88169..6c63f1a 100644 --- a/.refix.yaml.sample +++ b/.refix.yaml.sample @@ -1,19 +1,7 @@ -# ========================================== -# Auto Review Fixer (refix) Configuration File -# ========================================== - -# Model settings (Optional) -# Specifies the models to use when executing the Claude CLI. -# Options: "haiku", "sonnet", "opus", etc. models: - # Model used for summarizing code reviews (Default: "haiku") summarize: "haiku" - # Model used for automatically fixing code (Default: "sonnet") fix: "sonnet" -# Maximum number of lines for CI error logs included in the prompt (Optional) -# Minimum value is 20. -# Default: 120 ci_log_max_lines: 120 # Automatically merge PR when it reaches refix:done state (Optional) @@ -27,17 +15,4 @@ process_draft_prs: false # Target repository settings (Required) # List the target repositories and their corresponding git commit settings. repositories: - - # Repository name (Required: format "owner/repo") - # You can use wildcards. Examples: - # - Single repo: "owner/repo" - # - Wildcard in repo name: "owner/repo*" - # - All repos for owner/org: "owner/*" - repo: "octocat/Hello-World" - - # git user.name for fix commits (Optional) - # If omitted, the existing repository settings will be used. - user_name: "Refix Bot" - - # git user.email for fix commits (Optional) - # If omitted, the existing repository settings will be used. - user_email: "bot@example.com" + - repo: "owner/repo" diff --git a/.ruler/AGENTS.md b/.ruler/AGENTS.md index b1c6c32..d5b0fc8 100644 --- a/.ruler/AGENTS.md +++ b/.ruler/AGENTS.md @@ -19,6 +19,7 @@ Auto Review Fixer (refix) — GitHub PR 上の CodeRabbit レビューコメン - **型ヒント**: Python 3.12 に準拠した型ヒント(標準の `list` や `dict`、`str | int` など)を積極的に記述し、静的解析の精度を高めること。 - **モック化**: 外部API(Claude、GitHub API など)の呼び出しを伴う実装を追加・変更する場合は、`tests/` 内のテストケースで必ず全モック化すること。シークレット情報を必要とするテストは書かない。 - **品質保証 (CI)**: コードを変更した後は必ず `make ci` を実行し、テストがすべて成功することを確認すること。エラーが発生した場合はただちに修正すること。 +- **README 更新**: ユーザーに影響のある大きな機能改修や設定変更を行った場合は、`README.md` と `README.ja.md` を実装に合わせて更新すること。 ## Key commands diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..0acef12 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 HappyOnigiri + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.ja.md b/README.ja.md new file mode 100644 index 0000000..003d7f1 --- /dev/null +++ b/README.ja.md @@ -0,0 +1,274 @@ +# Auto Review Fixer (refix) + +[English README](README.md) + +`refix` は、Claude と GitHub CLI を使って GitHub Pull Request 上の未解決な CodeRabbit フィードバックを自動的に整理・修正する Python CLI です。 + +## これは何をするツールか + +`refix` は、CodeRabbit を使っているリポジトリで、レビュー指摘の消化を自動化したいケースを想定しています。 + +設定された各リポジトリに対して、`refix` は次のような処理を行えます。 + +- オープンな Pull Request を走査する +- 未解決の CodeRabbit レビューと未解決のインラインスレッドを検出する +- 修正前にレビュー内容を要約する +- 失敗している GitHub Actions のログ抜粋を修正プロンプトに含める +- ベースブランチに追従していない PR ブランチを更新する +- Claude にコード修正を依頼する +- 修正コミットを PR ブランチへ push する +- 修正後にレビュー スレッドを解決する +- PR 上の状態管理コメントと `refix:running` / `refix:done` ラベルで進捗を記録する + +## 主な機能 + +### レビュー要約 + +修正に入る前に、未解決レビューを AI エージェントが扱いやすい形に要約できます。 + +### 自動コード修正 + +Claude を使って PR ブランチ上のコードを直接修正し、生成されたコミットをそのまま push します。 + +### CI を踏まえた修正フロー + +GitHub Actions が失敗している場合は、失敗ログの重要部分を収集して修正プロンプトに含め、まず CI エラーの解消を試みます。 + +### ブランチ追従と競合対応 + +PR ブランチがベースブランチに追従していない場合はマージして進められます。競合が発生した場合も Claude ベースの修正フローで扱えます。 + +### 複数リポジトリ対応 + +`owner/repo` の単体指定だけでなく、`owner/*` でオーナー配下の全リポジトリを対象にできます。 + +### 重複実行を避ける状態管理 + +処理済みのレビュー項目は PR 上に記録されるため、同じ未解決フィードバックを繰り返し処理しにくい設計です。 + +## 必要条件 + +- Python 3.12 +- GitHub 認証済みの `gh` CLI +- 実際に修正を走らせる場合の Claude CLI 認証 +- `.refix.yaml` 設定ファイル +- 必要に応じてローカル用の `.env` ファイル + +## クイックスタート + +### ローカル実行 + +1. 依存関係を入れ、テンプレートファイルを作成します。 + + `make setup` + +2. `.refix.yaml.sample` をもとに `.refix.yaml` を編集します。 + +3. 必要な CLI を認証します。 + + - `gh auth login` + - Claude CLI の認証、または `CLAUDE_CODE_OAUTH_TOKEN` の設定 + +4. 用途に応じてコマンドを実行します。 + + - `make dry-run` — Claude を呼ばずに挙動だけ確認 + - `make run-summarize-only` — 要約のみ実行 + - `make run` — 詳細ログつきでフル実行 + - `make run-silent` — ログを抑えてフル実行 + +## YAML 設定リファレンス + +`refix` はリポジトリルートの `.refix.yaml` を読み込みます。別パスを使う場合は `--config` で指定できます。 + +### 完全なスキーマ + +```yaml +models: + summarize: "haiku" + fix: "sonnet" + +ci_log_max_lines: 120 + +repositories: + - repo: "owner/repo" + user_name: "Refix Bot" + user_email: "bot@example.com" +``` + +### トップレベルキー + +#### `models` + +Claude ベースの処理で使うモデル設定です。 + +- 型: マッピング +- 必須: いいえ +- デフォルト: + + ```yaml + models: + summarize: "haiku" + fix: "sonnet" + ``` + +利用できる子キーは次の 2 つです。 + +- `summarize` +- `fix` + +未知の子キーは警告を出して無視されます。 + +#### `ci_log_max_lines` + +修正プロンプトに含める失敗 CI ログの最大行数です。 + +- 型: 整数 +- 必須: いいえ +- デフォルト: `120` +- 実効最小値: `20` + +PR に失敗中の GitHub Actions がある場合、この値でプロンプトへ渡すログ量を調整できます。値を小さくするとプロンプトは軽くなり、大きくすると文脈を多く渡せます。 + +#### `auto_merge` + +PR が `refix:done` 状態になった際に自動マージします。 + +- 型: boolean +- 必須: いいえ +- デフォルト: `false` + +有効にすると、`refix` は修正適用後に GitHub の auto-merge をトリガーします。auto-merge は必須のステータスチェックがすべて通過した後に完了します。 + +#### `process_draft_prs` + +ドラフト PR を処理対象に含めるかどうかを設定します。 + +- 型: boolean +- 必須: いいえ +- デフォルト: `false` + +`false`(デフォルト)の場合、ドラフト PR はスキップされます。`true` にすると、通常のオープン PR と同様にドラフト PR も処理されます。 + +#### `repositories` + +`refix` が処理する対象リポジトリの一覧です。 + +- 型: 空でないリスト +- 必須: はい +- デフォルト: なし + +各要素では次のキーを使えます。 + +### リポジトリエントリのキー + +#### `repositories[].repo` + +`owner/repo` 形式の対象リポジトリです。 + +- 型: 文字列 +- 必須: はい +- 例: `octocat/Hello-World` + +`owner/*` を指定すると、そのオーナー配下の全リポジトリへ展開できます。一方で `owner/repo*` のような別形式のワイルドカードは現在の実装では対応していません。 + +#### `repositories[].user_name` + +`refix` が作成するコミットに使う Git author 名です。 + +- 型: 文字列 +- 必須: いいえ +- デフォルト: 未設定 + +省略した場合は、実行環境で有効な Git identity にフォールバックします。 + +#### `repositories[].user_email` + +`refix` が作成するコミットに使う Git author メールアドレスです。 + +- 型: 文字列 +- 必須: いいえ +- デフォルト: 未設定 + +省略した場合は、実行環境で有効な Git identity にフォールバックします。 + +### 挙動とバリデーションの補足 + +- YAML のルートはマッピングである必要があります。 +- `repositories` は必須で、1 件以上の要素が必要です。 +- 未知のキーは即エラーではなく、警告を出して無視されます。 +- `models.summarize` で要約処理で使用するモデルを指定します。この設定は環境変数 `REFIX_MODEL_SUMMARIZE` より優先されます。 +- `models.fix` で修正処理で使用するモデルを指定します。 + +## GitHub Actions での実行方法 + +このリポジトリには、`refix` を GitHub Actions で動かすためのワークフロー `.github/workflows/run-auto-review.yml` が含まれています。 + +### ワークフローが行うこと + +このワークフローは次の順で動作します。 + +1. リポジトリを checkout する +2. Python 3.12 と Python 依存関係をセットアップする +3. Claude CLI をインストールする +4. GitHub Actions 変数 `REFIX_CONFIG_YAML` から `.refix.yaml` を生成する +5. push 用の Git 認証を設定する +6. `cd src && python auto_fixer.py --config ../.refix.yaml` を実行する + +### 必要な GitHub Actions 設定 + +対象リポジトリ、またはオーガニゼーションに次の値を設定します。 + +#### Variables + +- `REFIX_CONFIG_YAML` + - `refix` 用 YAML 設定の全文です。 + - ローカルの `.refix.yaml` に書く内容をそのまま保存してください。 + +#### Secrets + +- `GH_PAT` + - GitHub API 利用と修正コミット push に使う Personal Access Token +- `CLAUDE_CODE_OAUTH_TOKEN` + - Claude CLI が自動修正時に使うトークン + +### セットアップ手順 + +1. `Settings` -> `Secrets and variables` -> `Actions` を開きます。 +2. `REFIX_CONFIG_YAML` を Variable として追加します。 +3. `GH_PAT` と `CLAUDE_CODE_OAUTH_TOKEN` を Secret として追加します。 +4. Actions タブで `Run auto review` ワークフローを開きます。 +5. `Run workflow` で手動実行します。 + +### `REFIX_CONFIG_YAML` の例 + +```yaml +models: + summarize: "haiku" + fix: "sonnet" + +ci_log_max_lines: 120 + +repositories: + - repo: "your-org/your-repo" + user_name: "Refix Bot" + user_email: "bot@example.com" +``` + +### このリポジトリに含まれるワークフロー + +- `.github/workflows/run-auto-review.yml` + - 実際の自動修正フローを手動実行するためのワークフロー +- `.github/workflows/test.yml` + - Pull Request 時と手動実行でテストを回すワークフロー + +## Contributing + +コントリビュート歓迎です。 + +- バグ報告、要望、質問は Issue を作成してください。 +- 修正、改善、ドキュメント更新は Pull Request を歓迎します。 +- 追加した Issue / PR テンプレートを使うと、内容を整理しやすくなります。 + +## ライセンス + +このプロジェクトは MIT License で提供されます。詳細は [LICENSE](LICENSE) を参照してください。 diff --git a/README.md b/README.md index cbf2b59..8341fc1 100644 --- a/README.md +++ b/README.md @@ -1,60 +1,281 @@ # Auto Review Fixer (refix) -GitHub PR 上の CodeRabbit レビューコメントを Claude AI で自動修正する Python CLI ツールです。 +[Japanese version](README.ja.md) -## 前提条件 +`refix` is a Python CLI that automatically triages and fixes unresolved CodeRabbit feedback on GitHub pull requests by using Claude and the GitHub CLI. + +## What this tool does + +`refix` is designed for repositories that use CodeRabbit for automated PR review and want to close the loop automatically. + +For each configured repository, `refix` can: + +- scan open pull requests, +- detect unresolved CodeRabbit reviews and unresolved inline review threads, +- summarize review feedback before starting a fix pass, +- inspect failing GitHub Actions checks and include failed log excerpts in the fix prompt, +- update PR branches that are behind the base branch, +- ask Claude to apply code fixes, +- push commits back to the PR branch, +- resolve review threads after successful fixes, and +- persist progress in a PR state comment and with labels such as `refix:running` and `refix:done`. + +## Features + +### Review summarization + +Before fixing code, `refix` can summarize unresolved review feedback into a more actionable prompt for the coding agent. + +### Automatic code fixing + +The tool invokes Claude to apply the requested changes directly in the checked-out pull request branch and pushes the resulting commits. + +### CI-aware repair flow + +When a pull request has failing GitHub Actions checks, `refix` fetches failed log output and feeds the most relevant excerpts into the fix prompt so the agent can repair CI failures first. + +### Branch catch-up and conflict handling + +If a PR branch is behind the base branch, `refix` can merge the latest base branch into it and continue the repair flow. Merge conflicts are also routed through the Claude-based fixing flow. + +### Multi-repository targeting + +You can target a single repository such as `owner/repo`, or expand all repositories under an owner with `owner/*`. + +### Repeat-safe state tracking + +Processed review items are recorded back to the pull request, which prevents the same unresolved feedback from being handled repeatedly. + +## Requirements - Python 3.12 -- `gh` CLI(認証済み) -- `.env` ファイル -- `.refix.yaml` 実行設定ファイル +- `gh` CLI authenticated against GitHub +- Claude CLI authentication for actual fix runs +- A `.refix.yaml` configuration file +- Optional `.env` file for local environment variables + +## Quick start + +### Local setup + +1. Install dependencies and create local template files: + + `make setup` -## 設定方法 +2. Edit `.refix.yaml` based on `.refix.yaml.sample`. -本ツールはリポジトリ直下の `.refix.yaml` という YAML 形式のファイルを使用して動作設定を行います。 +3. Authenticate the required CLIs: -### 1. ローカルでの設定方法 + - `gh auth login` + - Claude CLI authentication, or set `CLAUDE_CODE_OAUTH_TOKEN` -リポジトリルートに `.refix.yaml` を作成し、以下のような設定を記述します。 +4. Run one of the following commands: + + - `make dry-run` — show what would happen without calling Claude + - `make run-summarize-only` — summarize review feedback only + - `make run` — run the full fix flow with verbose logs + - `make run-silent` — run the full fix flow with reduced logs + +## YAML configuration reference + +`refix` reads configuration from `.refix.yaml` in the repository root, or from a path passed with `--config`. + +### Full schema ```yaml -# モデル設定 (省略可能) models: - summarize: "haiku" # レビュー要約用モデル - fix: "sonnet" # コード修正用モデル + summarize: "haiku" + fix: "sonnet" -# CIログの取得最大行数 (省略可能) ci_log_max_lines: 120 -# refix:done 状態到達時の自動マージ設定 (省略可能, デフォルト false) +# Automatically merge PR when it reaches refix:done state (optional, default false) auto_merge: false -# DRAFT PR も処理対象にするか (省略可能) -# デフォルト: false(DRAFT はスキップ) +# Whether to process draft PRs (optional) +# Default: false (draft PRs are skipped) process_draft_prs: false -# 実行対象のリポジトリ設定 (必須) +# Repository targets (required) repositories: - - repo: "owner/repo" # リポジトリ名 (必須: owner/repo 形式) - user_name: "Refix Bot" # (オプション) git commit 時のユーザー名 - user_email: "bot@example.com" # (オプション) git commit 時のメールアドレス + - repo: "owner/repo" + user_name: "Refix Bot" + user_email: "bot@example.com" ``` -作成後、以下のコマンドで実行できます。 +### Top-level keys + +#### `models` + +Model settings for Claude-based processing. + +- Type: mapping +- Required: no +- Default: + + ```yaml + models: + summarize: "haiku" + fix: "sonnet" + ``` + +Supported nested keys: + +- `summarize` +- `fix` + +Unknown nested keys are ignored with a warning. + +#### `ci_log_max_lines` + +Maximum number of failed CI log lines included in the fix prompt. + +- Type: integer +- Required: no +- Default: `120` +- Minimum effective value: `20` + +Use this to control prompt size when a PR has failing GitHub Actions checks. Smaller values reduce prompt volume, while larger values include more context from failed jobs. + +#### `auto_merge` + +Automatically merge the fix PR when it reaches the `refix:done` state. + +- Type: boolean +- Required: no +- Default: `false` + +When enabled, `refix` will trigger GitHub's auto-merge on the PR after applying fixes. Auto-merge only completes once all required status checks pass. + +#### `process_draft_prs` + +Whether to include draft PRs in the processing targets. -```bash -make run +- Type: boolean +- Required: no +- Default: `false` + +When set to `false` (the default), draft PRs are skipped. Set to `true` to process draft PRs alongside regular open PRs. + +#### `repositories` + +List of repositories that `refix` should process. + +- Type: non-empty list +- Required: yes +- Default: none + +Each entry supports the keys below. + +### Repository entry keys + +#### `repositories[].repo` + +Repository target in `owner/repo` format. + +- Type: string +- Required: yes +- Example: `octocat/Hello-World` + +You can also use `owner/*` to expand all repositories under a GitHub user or organization. Other wildcard styles such as `owner/repo*` are not supported by the current implementation. + +#### `repositories[].user_name` + +Git author name used for commits created by `refix`. + +- Type: string +- Required: no +- Default: not set + +If omitted, `refix` falls back to the effective Git identity available in the execution environment. + +#### `repositories[].user_email` + +Git author email used for commits created by `refix`. + +- Type: string +- Required: no +- Default: not set + +If omitted, `refix` falls back to the effective Git identity available in the execution environment. + +### Behavior and validation notes + +- The YAML root must be a mapping. +- `repositories` must be present and must contain at least one entry. +- Unknown keys are ignored with warnings rather than treated as hard errors. +- `models.summarize` in YAML takes priority over the `REFIX_MODEL_SUMMARIZE` environment variable when selecting the summarization model. + +## Running in CI with GitHub Actions + +This repository already includes the workflow used to run `refix` in GitHub Actions: `.github/workflows/run-auto-review.yml`. + +### What the workflow does + +The workflow: + +1. checks out the repository, +2. installs Python 3.12 and Python dependencies, +3. installs the Claude CLI, +4. writes `.refix.yaml` from the GitHub Actions variable `REFIX_CONFIG_YAML`, +5. configures Git authentication for push operations, and +6. changes to the `src` directory and runs `python auto_fixer.py --config ../.refix.yaml`. + +### Required GitHub Actions configuration + +Set the following values in the target repository or organization: + +#### Repository or organization variables + +- `REFIX_CONFIG_YAML` + - The full YAML configuration text for `refix`. + - Store the same content that you would place in a local `.refix.yaml` file. + +#### Repository or organization secrets + +- `GH_PAT` + - Personal access token used for GitHub API access and pushing fix commits. +- `CLAUDE_CODE_OAUTH_TOKEN` + - Token used by the Claude CLI during automated fix runs. + +### Step-by-step setup + +1. Open `Settings` -> `Secrets and variables` -> `Actions`. +2. Add the `REFIX_CONFIG_YAML` variable. +3. Add the `GH_PAT` and `CLAUDE_CODE_OAUTH_TOKEN` secrets. +4. Open the `Run auto review` workflow in the Actions tab. +5. Trigger the workflow with `Run workflow`. + +### Example `REFIX_CONFIG_YAML` + +```yaml +models: + summarize: "haiku" + fix: "sonnet" + +ci_log_max_lines: 120 + +repositories: + - repo: "your-org/your-repo" + user_name: "Refix Bot" + user_email: "bot@example.com" ``` -※ ドライランモード(Claudeの呼び出しなし)で実行する場合は `make dry-run` を使用します。 +### Included workflows in this repository + +- `.github/workflows/run-auto-review.yml` + - Manual (`workflow_dispatch`) execution for the actual auto-fix flow. +- `.github/workflows/test.yml` + - Test workflow triggered on pull requests and on manual dispatch. + +## Contributing -### 2. CI (GitHub Actions) での設定方法 +Contributions are welcome. -本ツールを GitHub Actions で動作させる場合、YAML の内容を GitHub リポジトリの Variables(変数)として登録します。 +- Open an issue for bugs, ideas, or questions. +- Submit a pull request for fixes, improvements, or documentation updates. +- Use the provided issue and pull request templates to keep reports actionable. -1. 対象リポジトリ(オーガナイゼーション)の `Settings` > `Secrets and variables` > `Actions` > **`Variables`** タブを開きます。 -2. `New repository variable` (または `New organization variable`)をクリックします。 -3. **Name** に `REFIX_CONFIG_YAML` と入力します。 -4. **Value** に、ローカルと同様の YAML 形式のテキストを貼り付け、保存します。 +## License -これにより、CI ワークフロー実行時に自動的に設定が読み込まれ、ツールが動作します。 +This project is licensed under the MIT License. See [LICENSE](LICENSE). diff --git a/src/auto_fixer.py b/src/auto_fixer.py index f137599..3a8d13e 100644 --- a/src/auto_fixer.py +++ b/src/auto_fixer.py @@ -1437,7 +1437,7 @@ def process_repo( label = f"{path} " if path else "" summaries[rid] = f"(インラインコメント {i} {label}の要約)" else: - summaries = summarize_reviews(unresolved_reviews, unresolved_comments, silent=silent) + summaries = summarize_reviews(unresolved_reviews, unresolved_comments, silent=silent, model=summarize_model) summary_target_ids = _summarization_target_ids(unresolved_reviews, unresolved_comments) summarized_count = sum(1 for sid in summary_target_ids if summaries.get(sid, "").strip()) if summary_target_ids: @@ -1662,7 +1662,7 @@ def process_repo( label = f"{path} " if path else "" summaries[rid] = f"(インラインコメント {i} {label}の要約)" else: - summaries = summarize_reviews(unresolved_reviews, unresolved_comments, silent=silent) + summaries = summarize_reviews(unresolved_reviews, unresolved_comments, silent=silent, model=summarize_model) summary_target_ids = _summarization_target_ids(unresolved_reviews, unresolved_comments) summarized_count = sum(1 for sid in summary_target_ids if summaries.get(sid, "").strip()) diff --git a/src/summarizer.py b/src/summarizer.py index e2e592f..9e3b250 100644 --- a/src/summarizer.py +++ b/src/summarizer.py @@ -43,10 +43,12 @@ def summarize_reviews( reviews: list[dict[str, Any]], comments: list[dict[str, Any]], silent: bool = False, + model: str | None = None, ) -> dict[str, str]: """Return {id: summary} for all reviews and inline comments. - Uses a single claude CLI call. Model: REFIX_MODEL_SUMMARIZE (default: haiku). + Uses a single claude CLI call. Model priority: `model` parameter > + REFIX_MODEL_SUMMARIZE env var > "haiku". Raises ClaudeUsageLimitError on usage limit detection. Raises ClaudeCommandFailedError on non-zero exit code or subprocess error. Falls back to empty dict only on JSON parse failure. @@ -91,7 +93,7 @@ def summarize_reviews( env = os.environ.copy() env.pop("CLAUDECODE", None) - model = os.environ.get("REFIX_MODEL_SUMMARIZE", "haiku").strip() or "haiku" + model = (model or os.environ.get("REFIX_MODEL_SUMMARIZE", "")).strip() or "haiku" summarizer_cmd = [ "claude", "--model", model,