feat(reference): Phase 3 - reference diff と resolve-symbol-at#190
Merged
Conversation
gwt-discussion で確定した方針に従い、Phase 3 として次の 2 機能を land: 1. reference diff: 2 cached Unity バージョン間の symbol-only / path 範囲 差分。デフォルトは --symbol <fqn> で symbol-only、--path <subpath> で path 範囲 (added/removed/changed) を opt-in。 2. reference resolve-symbol-at: project ファイルの cursor 位置から reference cache の候補を返す独立 RPC。csharp-lsp には触らない。 設計判断(採用方針): - 差分粒度 C: symbol-only コア + --path 全体走査 opt-in。MVP の line diff は all-or-nothing 単一 hunk で簡素実装。 - LSP 連携 C2: unity-cli 単体の独立 RPC。SPEC #185 の workspaceFolders 不混入の原則を維持。 主な変更: - src/reference/diff.rs (新規): Hunk / SymbolDiff / PathDiff 型、 compute_line_diff / compute_symbol_diff / compute_path_diff / ensure_cache_dir / split_fqn / read_excerpt - src/reference/mod.rs: maybe_execute_reference_tool に reference_diff と reference_resolve_symbol_at 分岐、execute_diff / execute_resolve_symbol_at / extract_token_at_cursor / collect_resolve_candidates、dispatcher 経由 test 計 9 件 - src/cli.rs: ReferenceCommand::Diff / ResolveSymbolAt - src/app/runner.rs: build_reference_call に 2 分岐と 4 件のテスト - src/tooling/tool_catalog.rs: 2 tool を TOOL_NAMES / executor / read_only / params_schema / parity count (125→127) に登録 - skill SKILL.md: diff / resolve-symbol-at 例とフォールバック説明 - references/version-diff-playbook.md (新規): Phase 3 の活用ガイド - docs/tools.md: Reference Cache (7→9 tools) と新 tool 行 - tests/fixtures/reference-cache-v2/{v1,v2}/: 差分テスト用 fixture (Animator changed、LegacyAnimator removed、Awaitable added) ローカル検証: - cargo fmt -- --check: clean - cargo clippy --all-targets -- -D warnings: clean - cargo test --bin unity-cli: 379 passed / 0 failed - cargo llvm-cov --all-targets: TOTAL line coverage 90.97% - unity-cli skills lint --severity error: 15 skills / 0 violations Refs #188 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
build_or_update_index が fixture 配下で実行されたときの生成物を追跡 対象から外す。再発防止として gitignore を追加。 Refs #188 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
unity-cli reference diff(バージョン差分) とunity-cli reference resolve-symbol-at(project cursor → reference cache wrapper) を land し、UnityCsReference 参照キャッシュの活用範囲を広げる。gwt-discussionで確定したスコープ:--pathで opt-in 全体走査Changes
src/reference/diff.rs(新規):Hunk/SymbolDiff/PathDiff型、compute_line_diff(MVP: all-or-nothing 単一 hunk)、compute_symbol_diff(Phase 2find_symbol+run_viewの組み合わせ)、compute_path_diff(added / removed / changed リスト + truncated フラグ)、ensure_cache_dir、split_fqn。src/reference/mod.rs:maybe_execute_reference_toolにreference_diff/reference_resolve_symbol_at分岐、execute_diff/execute_resolve_symbol_at/extract_token_at_cursor(project file の cursor 位置から identifier を抽出) /collect_resolve_candidates(cached versions に対する find-symbol + view)。dispatcher 経由テスト 9 件追加。src/cli.rs:ReferenceCommand::Diff { from, to, symbol, path, max_symbols }とReferenceCommand::ResolveSymbolAt { path, line, column, version }。src/app/runner.rs::build_reference_call: 2 分岐追加 + 4 件のテスト。src/tooling/tool_catalog.rs:reference_diff/reference_resolve_symbol_atをTOOL_NAMES/tool_executor::Local/is_read_only_tool/tool_params_schema(required:from/to、path/line/column) / parity count (125→127) に登録。.claude-plugin/plugins/unity-cli/skills/unity-csharp-reference/SKILL.md:## Preferred Flowに diff / resolve-symbol-at の使い分けを追記。.claude-plugin/plugins/unity-cli/skills/unity-csharp-reference/references/version-diff-playbook.md(新規): Phase 3 の典型ユースケースと anti-patterns。docs/tools.md: Reference Cache (7 → 9 tools) と新 tool の行を追加。tests/fixtures/reference-cache-v2/{v1,v2}/: 差分テスト用 fixture (Animator changed / LegacyAnimator removed / Awaitable added)。Testing
cargo fmt -- --check— cleancargo clippy --all-targets -- -D warnings— cleancargo test --bin unity-cli— 379 passed / 0 failedcargo llvm-cov --all-targets --summary-only -- --test-threads=1— TOTAL line coverage 90.97%unity-cli skills lint --severity error— 15 skills / 0 violationsClosing Issues
Related Issues / Links
Checklist
cargo clippy,cargo fmt,unity-cli skills lint)docs/tools.md、skill SKILL.md、references/version-diff-playbook.md)feat)Context
Phase 2 で
find-symbolがインデックスベース lookup を提供したので、Phase 3 はその上に「2 バージョン比較」と「project cursor → reference cache」の薄い橋を載せる。symbol-only diff はfind-symbolを 2 回呼んでrun_viewで抜粋する設計、resolve-symbol-atはカーソル位置の identifier を抽出して同じfind-symbol+run_viewを流用する。compute_line_diffは MVP 用に全行 before/after を 1 hunk に詰めるだけで、unified diff 風の細粒度ハンク化は Phase 4 以降の余地として残す。Risk / Impact
src/reference/diff.rs新規 + 既存 wiring。LSP のworkspaceFoldersには引き続き reference cache を混入させない(SPEC feat(reference): UnityCsReference のローカルキャッシュ参照機構(Phase 1) #185 の原則維持)。compute_path_diffは両 cache のシンボルインデックスを走査するだけで、新規 fixture 以外のディスク追加はない。--max-symbols 50、run_viewの window は 30 行 / symbol。1000 symbol を超える--path走査はtruncated: trueで抑制される。Notes
compute_line_diffは現状 all-or-nothing。LCS ベースの unified hunk への置換は別 Issue として後追い可能。resolve-symbol-atの token extractor は regex ベースで C# lexing を理解しない(コメント / 文字列内のカーソルでも identifier を拾う場合がある)。Phase 2.5 以降で改善余地あり。validate_kindの受理リストにはmethod/property/fieldも含まれているが、現状のfind_symbolは型のみを返す。member-level は Phase 2.5 で対応予定。