From 97e9ffbe5c66f9543cae033dad4adbe3838083cd Mon Sep 17 00:00:00 2001 From: hidetzu Date: Sat, 11 Apr 2026 10:41:18 +0900 Subject: [PATCH] Release v0.2.0 - Update version to 0.2.0 - Mark CodeCommit as supported in README (link to prism-provider-codecommit) - Complete acceptance criteria in implementation guide - Complete implementation status in ADR-0001 - Translate docs to English --- README.md | 2 +- cmd/prism/main.go | 2 +- docs/adr/0001-provider-plugin-architecture.md | 149 ++++++++-------- docs/implementation/v0.2.0-provider-plugin.md | 163 +++++++++--------- 4 files changed, 153 insertions(+), 163 deletions(-) diff --git a/README.md b/README.md index 7002294..874a63d 100644 --- a/README.md +++ b/README.md @@ -236,7 +236,7 @@ prism analyze --provider github # Explicit provider | Provider | Type | Status | |----------|------|--------| | GitHub | Built-in | Supported | -| AWS CodeCommit | Plugin | In progress (v0.2.0) | +| AWS CodeCommit | Plugin | Supported ([prism-provider-codecommit](https://github.com/hidetzu/prism-provider-codecommit)) | ### Provider selection diff --git a/cmd/prism/main.go b/cmd/prism/main.go index 7d4bf2b..7073cc1 100644 --- a/cmd/prism/main.go +++ b/cmd/prism/main.go @@ -13,7 +13,7 @@ import ( "github.com/hidetzu/prism/internal/usecase" ) -const version = "0.2.0-alpha.1" +const version = "0.2.0" // Exit codes as defined in docs/spec.md. const ( diff --git a/docs/adr/0001-provider-plugin-architecture.md b/docs/adr/0001-provider-plugin-architecture.md index 6deb6a8..99ac5b6 100644 --- a/docs/adr/0001-provider-plugin-architecture.md +++ b/docs/adr/0001-provider-plugin-architecture.md @@ -8,135 +8,126 @@ Accepted ## Context -`prism` v0.2.0 では AWS CodeCommit の Pull Request 取得を追加したい。 -ただし、`prism` 本体の責務は **Pull Request を構造化コンテキストへ分解すること** であり、 -各ホスティングサービス固有の API 実装や認証処理を大量に抱え込むことではない。 +prism v0.2.0 aims to add AWS CodeCommit Pull Request support. +However, prism's core responsibility is **decomposing Pull Requests into structured review context**, not absorbing API implementations and authentication mechanisms for every hosting service. -現状の懸念は次の2点である。 +Two concerns drove this decision: -1. **プロバイダー検出の設計** - - 現在は GitHub 前提で実装されている - - GitHub / CodeCommit / 将来の Bitbucket などにどう拡張するかを整理する必要がある +1. **Provider detection design** + - The current implementation assumes GitHub + - Needs a strategy for extending to GitHub / CodeCommit / future Bitbucket, etc. -2. **認証と依存の違い** - - GitHub は `GITHUB_TOKEN` を用いた Bearer 認証 - - CodeCommit は AWS credential chain / IAM / region を前提とする - - Go 本体に AWS SDK を直接組み込むと、依存と責務が膨らむ +2. **Authentication and dependency differences** + - GitHub uses `GITHUB_TOKEN` with Bearer authentication + - CodeCommit requires AWS credential chain / IAM / region + - Embedding the AWS SDK directly into prism would bloat dependencies and blur responsibilities -また、CodeCommit については既存資産として `ccpr` が存在している。 -この資産を活用しつつ、`prism` 本体の責務を守る必要がある。 +Additionally, an existing tool `ccpr` already handles CodeCommit PR retrieval. This asset should be leveraged while preserving prism's core responsibilities. --- ## Decision -v0.2.0 では、**Provider を外部バイナリプラグイン方式で拡張する**。 +v0.2.0 extends providers via **external binary plugins**. -`prism` 本体は provider interface と plugin execution layer のみを持ち、 -CodeCommit 対応は `ccpr` 系の別バイナリとして実装・連携する。 +prism itself holds only the provider interface and plugin execution layer. CodeCommit support is implemented as a separate binary that wraps `ccpr`. -### 採用する方針 +### Approach -- Provider 拡張は **外部バイナリ方式** を採用する -- `prism-provider-codecommit` のような実行可能バイナリを想定する -- `prism` はサブプロセスとして provider plugin を呼び出す -- provider plugin は PR データを共通 JSON 形式で返す -- `prism` は返却された共通 JSON を `PullRequest` ドメインモデルへ変換して解析を続行する +- Provider extensibility uses the **external binary approach** +- Plugins are executable binaries such as `prism-provider-codecommit` +- prism invokes plugins as subprocesses +- Plugins return PR data in a standardized JSON format +- prism converts the returned JSON into `PullRequest` domain models and continues analysis -### GitHub provider の扱い +### GitHub provider handling -- v0.2.0 では **GitHub は本体内蔵(built-in)** とする -- `go install` だけで GitHub に対して即座に使えるユーザー体験を維持する -- ただし、内部的には plugin と同等の境界を保ち、将来的に plugin として外出し可能な構造にする -- CodeCommit 以降の外部 provider は plugin 方式とする +- In v0.2.0, **GitHub remains built-in** +- This preserves the user experience of working with GitHub immediately after `go install` +- Internally, the boundary is kept equivalent to plugins, allowing future extraction +- CodeCommit and subsequent providers use the plugin approach -### Provider 検出方針 +### Provider detection strategy -- デフォルトは **URL からの自動判定** -- `--provider` が明示指定された場合は **URL による自動判定を行わない** -- URL 自動判定が難しいケースや GitHub Enterprise などでは `--provider` で明示できる +- Default: **auto-detect from URL** +- When `--provider` is explicitly specified, **URL-based auto-detection is skipped** +- `--provider` enables use with GitHub Enterprise and other hosts where URL auto-detection is insufficient -### 初期ルール +### Initial rules -- `github.com` を含む URL は GitHub provider -- CodeCommit URL パターンに一致するものは CodeCommit provider -- `--provider github` などが指定された場合はその provider を強制利用する -- 自動判定できない場合は、分かりやすいエラーメッセージで `--provider` の指定を促す +- URLs containing `github.com` use the GitHub provider +- URLs matching CodeCommit patterns use the CodeCommit provider +- `--provider github` etc. forces the specified provider +- When auto-detection fails, a clear error message suggests using `--provider` --- ## Rationale -この判断の理由は次の通り。 +### 1. Preserves prism's responsibility +prism's essence is not fetching PRs, but **transforming fetched PRs into review context**. Absorbing provider-specific implementations would blur this responsibility. -### 1. `prism` の責務を保てる -`prism` の本質は PR の取得ではなく、**取得済み PR をレビュー用コンテキストへ変換すること** にある。 -プロバイダー固有の実装を本体に抱え込むと、この責務が曖昧になる。 +### 2. Leverages ccpr +For CodeCommit support, the existing `ccpr` tool can be reused. By wrapping it as an external provider rather than embedding the AWS SDK into prism, asset reuse and responsibility separation are achieved simultaneously. -### 2. `ccpr` を活かしやすい -CodeCommit 対応については既存の `ccpr` を活かせる。 -`prism` に AWS SDK を直接入れず、外部 provider としてラップすることで、資産再利用と責務分離を両立できる。 +### 3. Strong future extensibility +When considering future providers like Bitbucket, GitHub Enterprise, and GitLab, the plugin approach minimizes changes to prism itself. -### 3. 将来の拡張に強い -Bitbucket、GitHub Enterprise、GitLab など将来的な provider を想定したとき、 -プラグイン方式のほうが `prism` 本体の変更を最小化しやすい。 - -### 4. 依存分離が明確 -GitHub provider は軽量に保てる一方、CodeCommit provider は AWS 認証や SDK を独立して持てる。 -これにより本体のビルド、保守、配布がシンプルになる。 +### 4. Clear dependency separation +The GitHub provider remains lightweight, while the CodeCommit provider can independently manage AWS authentication and SDK dependencies. This keeps the core build, maintenance, and distribution simple. --- ## Alternatives Considered -## A. 外部バイナリ方式 -採用。 +## A. External binary approach +Adopted. -### メリット -- 依存が完全に分離できる -- `prism` 本体の責務が明確 -- `ccpr` を活かしやすい -- 将来 provider を増やしやすい +### Advantages +- Complete dependency isolation +- Clear prism core responsibility +- Easy to leverage ccpr +- Easy to add future providers -### デメリット -- プラグインとの入出力仕様を安定させる必要がある -- サブプロセス実行とエラー処理が必要 -- 配布方法を設計する必要がある +### Disadvantages +- Plugin input/output specification must be stabilized +- Subprocess execution and error handling required +- Distribution method must be designed -## B. Go internal 方式 -不採用。 +## B. Go internal approach +Rejected. -### 理由 -- `prism` 本体に provider 固有依存が入りやすい -- AWS SDK などの依存が本体に混ざる -- `prism` の思想である責務分離が崩れやすい +### Reasons +- Provider-specific dependencies would leak into prism core +- AWS SDK and similar dependencies would mix into the core +- Violates prism's principle of responsibility separation --- ## Consequences ### Positive -- v0.2.0 で CodeCommit 対応を追加しつつ、本体をシンプルに保てる -- `ccpr` を provider plugin として再利用する道が開ける -- 将来の provider 拡張戦略が明確になる +- CodeCommit support added in v0.2.0 while keeping the core simple +- Path opened for reusing ccpr as a provider plugin +- Future provider extension strategy made explicit ### Negative -- plugin protocol を設計する必要がある -- plugin discovery の仕様が必要になる -- ユーザー向けにはインストール説明が少し増える +- Plugin protocol must be designed +- Plugin discovery specification required +- User-facing installation instructions become slightly more complex --- ## Plugin Protocol -plugin の呼び出し規約、JSON schema、discovery 仕様の詳細は [Provider Plugin Protocol](../provider-plugin-protocol.md) を参照。 +See [Provider Plugin Protocol](../provider-plugin-protocol.md) for invocation conventions, JSON schema, and discovery specification. --- ## Implementation Status -- [x] plugin protocol の JSON schema を定義する -- [x] provider registry を実装する -- [x] provider auto detection ロジックを実装する -- [x] `--provider` 優先ルールを実装する -- [ ] CodeCommit plugin の第一候補として `ccpr` ラップ方式を検討する +- [x] Define plugin protocol JSON schema +- [x] Implement provider registry +- [x] Implement provider auto-detection logic +- [x] Implement `--provider` override rule +- [x] Adopt ccpr wrapper approach for CodeCommit plugin → [prism-provider-codecommit](https://github.com/hidetzu/prism-provider-codecommit) diff --git a/docs/implementation/v0.2.0-provider-plugin.md b/docs/implementation/v0.2.0-provider-plugin.md index ac6c54b..a7cc87b 100644 --- a/docs/implementation/v0.2.0-provider-plugin.md +++ b/docs/implementation/v0.2.0-provider-plugin.md @@ -2,17 +2,16 @@ ## Goal -v0.2.0 では **外部バイナリ方式の provider plugin architecture** を導入し、 -AWS CodeCommit 対応を追加する。 +Introduce an **external binary provider plugin architecture** in v0.2.0 and add AWS CodeCommit support. ### Design decisions (see ADR-0001) -- Provider 拡張は外部バイナリ方式 -- GitHub は本体内蔵(built-in)、将来的に plugin 化可能な構造を保つ -- CodeCommit 以降の外部 provider は plugin 方式 -- Provider 検出はデフォルト URL 自動判定、`--provider` 指定時は自動判定しない -- plugin invocation: `prism-provider- fetch ` -- plugin は共通 JSON を stdout に返す +- Provider extensibility via external binary plugins +- GitHub remains built-in; structured to allow future plugin extraction +- CodeCommit and subsequent providers use the plugin approach +- Provider detection defaults to URL-based auto-detection; `--provider` flag skips auto-detection +- Plugin invocation: `prism-provider- fetch ` +- Plugins return standardized JSON to stdout --- @@ -20,93 +19,93 @@ AWS CodeCommit 対応を追加する。 ### Must -- provider registry の導入 -- provider autodetection の導入 -- `--provider` 明示指定の導入(analyze / prompt / fetch) -- plugin executor の導入 -- provider plugin protocol の定義(JSON schema) -- GitHub provider を plugin と同等の境界を保つ構造へ整理 -- CodeCommit provider plugin の最小実装 -- `ccpr` 利用方針の具体化 -- テスト追加 -- README / docs 更新 +- Introduce provider registry +- Introduce provider auto-detection +- Add `--provider` flag to analyze / prompt / fetch +- Introduce plugin executor +- Define provider plugin protocol (JSON schema) +- Restructure GitHub provider to maintain plugin-equivalent boundaries +- Minimal CodeCommit provider plugin implementation +- Finalize `ccpr` integration strategy +- Add tests +- Update README / docs ### Nice to have -- plugin discovery path の将来拡張を見越したインターフェース整理 +- Interface refinement for future plugin discovery path extensions ### Out of scope -- Bitbucket 対応 -- plugin marketplace -- ネットワーク越し plugin -- 動的ロードライブラリ方式 +- Bitbucket support +- Plugin marketplace +- Network-based plugins +- Dynamic library loading --- ## Implementation Steps -### Step 1: Provider detection と `--provider` を導入する +### Step 1: Introduce provider detection and `--provider` flag -- `--provider` フラグを analyze / prompt / fetch に追加 -- URL からの provider 自動判定ロジックを実装 -- `--provider` 指定時は自動判定をスキップ -- 判定不能時は `--provider` を案内するエラーメッセージを返す +- Add `--provider` flag to analyze / prompt / fetch commands +- Implement URL-based provider auto-detection logic +- Skip auto-detection when `--provider` is specified +- Return clear error messages suggesting `--provider` when detection fails -期待動作: +Expected behavior: ```bash prism analyze https://github.com/owner/repo/pull/123 -# → GitHub を自動選択 +# → auto-selects GitHub prism analyze -# → CodeCommit を自動選択 +# → auto-selects CodeCommit prism analyze --provider github -# → GitHub を強制利用 +# → forces GitHub ``` -### Step 2: Provider registry / plugin discovery / plugin executor を導入する +### Step 2: Introduce provider registry / plugin discovery / plugin executor -- provider registry: built-in(GitHub)と plugin の両方を管理 -- plugin discovery: PATH 上の `prism-provider-` バイナリを探索 -- plugin executor: サブプロセスとして plugin を実行し、stdout JSON をパース +- Provider registry: manages both built-in (GitHub) and plugin providers +- Plugin discovery: searches for `prism-provider-` binaries on PATH +- Plugin executor: runs plugin as subprocess, parses stdout JSON -plugin invocation: +Plugin invocation: ```bash prism-provider-codecommit fetch ``` -設計指針: -- stdout のみを機械読取対象とする -- stderr はデバッグ用 -- exit code でエラー判定 +Design guidelines: +- Only stdout is machine-readable +- stderr is for diagnostics +- Exit code determines error state -### Step 3: ダミー plugin で integration test を通す +### Step 3: Pass integration tests with a dummy plugin -- テスト用のダミー provider plugin を作成 -- 正常系: 共通 JSON を返す -- 異常系: 不正 JSON、exit code 非 0、タイムアウト -- plugin discovery のテスト(PATH 上にバイナリがある / ない) +- Create a dummy provider plugin for testing +- Success case: returns valid protocol JSON +- Failure cases: invalid JSON, non-zero exit code, timeout +- Plugin discovery tests (binary present / absent on PATH) -### Step 4: CodeCommit plugin の最小対応を追加する +### Step 4: Add minimal CodeCommit plugin support -方針: -1. まず `ccpr` の出力形式を調査し、共通 JSON への変換可否を確認 -2. 変換可能なら `ccpr` ラップ方式で `prism-provider-codecommit` を実装 -3. 困難なら新規 plugin の雛形を作成 +Strategy: +1. Investigate ccpr output format and assess conversion to protocol JSON +2. If feasible, implement `prism-provider-codecommit` using ccpr wrapper approach +3. If not feasible, create a new plugin skeleton -### Step 5: README / docs を更新する +### Step 5: Update README / docs -- README に provider architecture 概要を追加 -- URL autodetection と `--provider` の説明 -- plugin install 方法 -- `docs/provider-plugins.md` を追加 +- Add provider architecture overview to README +- Document URL auto-detection and `--provider` flag +- Add plugin installation instructions +- Add `docs/provider-plugins.md` --- ## Plugin Protocol -詳細は [Provider Plugin Protocol](../provider-plugin-protocol.md) を参照。 +See [Provider Plugin Protocol](../provider-plugin-protocol.md) for details. --- @@ -114,44 +113,44 @@ prism-provider-codecommit fetch ### Unit tests -- provider autodetection(GitHub URL, CodeCommit URL, unknown URL) -- `--provider` 優先ロジック -- plugin discovery(PATH 上にバイナリがある / ない) -- plugin stdout JSON parsing(正常 / 不正 / 空) -- error mapping(plugin exit code → domain error) +- Provider auto-detection (GitHub URL, CodeCommit URL, unknown URL) +- `--provider` override logic +- Plugin discovery (binary present / absent on PATH) +- Plugin stdout JSON parsing (valid / invalid / empty) +- Error mapping (plugin exit code → domain error) ### Integration tests -- ダミー provider plugin バイナリを使った動作確認 -- 正常系 / 異常系 -- stdout / stderr / exit code の扱い +- End-to-end with dummy provider plugin binary +- Success and failure cases +- stdout / stderr / exit code handling ### Important -- 実際の AWS / GitHub ネットワーク依存テストに寄せすぎない -- plugin protocol と app 層の安定性を重視する +- Avoid relying on real AWS / GitHub network calls +- Focus on plugin protocol and application layer stability --- ## Acceptance Criteria -- [ ] `--provider` が analyze / prompt / fetch に実装されている -- [ ] URL 自動判定が機能する -- [ ] provider 判定不能時のエラーが分かりやすい -- [ ] plugin executor が動く -- [ ] provider plugin protocol が文書化されている -- [ ] CodeCommit 対応経路が存在する(plugin 最小実装 or ccpr ラップ) -- [ ] `ccpr` 活用方針がコードまたは文書で具体化されている -- [ ] tests が追加されている -- [ ] README / docs が更新されている +- [x] `--provider` implemented on analyze / prompt / fetch +- [x] URL auto-detection works +- [x] Clear error messages when provider cannot be detected +- [x] Plugin executor works +- [x] Provider plugin protocol documented +- [x] CodeCommit support path exists → [prism-provider-codecommit](https://github.com/hidetzu/prism-provider-codecommit) +- [x] `ccpr` integration strategy finalized → ccpr wrapper approach adopted +- [x] Tests added +- [x] README / docs updated --- ## Principles -- 1 PR 1 責務 -- 先に protocol と境界を固める -- いきなり CodeCommit の詳細実装に入らない -- `prism` 本体へ AWS SDK を直接追加しない -- 過剰設計しない -- ただし将来の provider 追加で破綻しない構造にする +- One responsibility per PR +- Establish protocol and boundaries first +- Do not jump into CodeCommit implementation details prematurely +- Do not add AWS SDK directly to `prism` +- Avoid over-engineering +- Ensure the structure does not break when adding future providers