Skip to content

feat(reference): Phase 2 - シンボル lookup インデックス(reference find-symbol)#189

Merged
akiojin merged 1 commit into
developfrom
work/20260511-0223
May 11, 2026
Merged

feat(reference): Phase 2 - シンボル lookup インデックス(reference find-symbol)#189
akiojin merged 1 commit into
developfrom
work/20260511-0223

Conversation

@akiojin
Copy link
Copy Markdown
Owner

@akiojin akiojin commented May 11, 2026

Summary

Changes

  • src/reference/index.rs (新規): ReferenceSymbolEntry / ReferenceSymbolIndex / extract_symbols_from_text(軽量 regex で型定義抽出)/ build_or_update_index(size + mtime ベース incremental)/ find_symbol / validate_kind / file_signature。LSP workspace には混入させない独立空間。
  • src/reference/mod.rs: maybe_execute_reference_tool"reference_find_symbol" 分岐と execute_find_symbol を追加。required name パラメータ、optional kind / namespace / version / projectRoot。dispatcher 経由 test を 6 件追加。
  • src/cli.rs: ReferenceCommand::FindSymbol { name, kind, namespace, version } variant を追加。
  • src/app/runner.rs::build_reference_call: FindSymbol 分岐と 2 件の test。
  • src/tooling/tool_catalog.rs: reference_find_symbolTOOL_NAMES / tool_executor::Local / is_read_only_tool / tool_params_schema (required: name) / parity count (124→125) に登録。
  • .claude-plugin/plugins/unity-cli/skills/unity-csharp-reference/SKILL.md: ## Preferred Flowreference find-symbol 例 + 使い分けガイド (find-symbol → grep への fallback)。
  • .claude-plugin/plugins/unity-cli/skills/unity-csharp-reference/references/symbol-lookup-playbook.md: workflow step 1 に find-symbol 例とインクリメンタル index の説明。
  • docs/tools.md: 「Reference Cache (6 → 7 tools)」に行追加。
  • tasks/lessons.md: SPEC feat(reference): UnityCsReference のローカルキャッシュ参照機構(Phase 1) #185 振り返り 3 件 (clippy 1.95 のローカル差、coverage 90% を新 module 追加時に確保する手順、gwtd issue spec create の section markers 運用)。

Testing

  • cargo fmt -- --check — clean
  • cargo clippy --all-targets -- -D warnings — clean (clippy 1.95 想定の unnecessary-map-iter 修正含む)
  • cargo test --bin unity-cli — 356 passed / 0 failed (Phase 2 で 9 + 6 + 2 + schema test を追加)
  • cargo llvm-cov --all-targets --summary-only -- --test-threads=1 — TOTAL line coverage 90.69% (≥ 90% gate を満たす)
  • unity-cli skills lint --severity error — 15 skills / 0 violations

Closing Issues

Related Issues / Links

Checklist

  • Tests added/updated (src/reference/index.rs 9 件、dispatcher 6 件、build_reference_call 2 件)
  • Lint/format passed (cargo clippy, cargo fmt, unity-cli skills lint)
  • Documentation updated (docs/tools.md、skill SKILL.md、references/symbol-lookup-playbook.md、tasks/lessons.md)
  • Migration/backfill plan included — Not applicable: no schema or data change. reference find-symbol の初回実行で ~/.unity/cache/UnityCsReference/<version>/.unity-cli-index/symbols.json を新規生成するだけで、既存 Phase 1 cache (.unity-cli-meta.json 等) には触らない。
  • CHANGELOG impact considered — minor bump per Conventional Commits (feat)

Context

  • Phase 1 で land した reference grep / view / search は walkdir + regex の線形検索のため、UnityEngine.Animator のような頻出シンボルを LLM が連続して引くと毎回フルスキャンが走り高コスト。
  • Phase 2 で per-version の .unity-cli-index/symbols.json を持ち、初回 lookup 時に build、以降は size + mtime ベースで incremental 更新する。

Risk / Impact

  • Affected areas: 新規 src/reference/index.rs + CLI / catalog / local dispatcher への配線。新 skill / docs は既存 Phase 1 用のものに追記のみ。LSP の workspaceFolders には reference cache を引き続き混入させない(Phase 1 と同じ方針)。
  • Disk footprint: 1 バージョンあたりの index は数 MB 程度の JSON。Phase 1 の shallow clone (400-600 MB / 版) に対する追加は小さい。
  • Rollback plan: この commit を revert すれば Phase 1 の動作に戻る。.unity-cli-index/ ディレクトリを手動で削除しても良い (reference clean も次回以降のみ)。

Notes

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 11, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 9c2df440-f28c-4766-8d69-f9debd7d08c7

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch work/20260511-0223

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

SPEC #187 (Phase 2 シンボル lookup インデックス) を land し、Phase 1
で得た知見を tasks/lessons.md に追記する。Phase 1 は PR #186 で
develop 統合済みのため、本 PR の diff は Phase 2 と lessons のみ。

採用方針 B (独自 ReferenceSymbolEntry) と Symbol scope (型のみ) は
gwt-discussion で確定済み。member-level lookup は Phase 2.5 以降の
拡張余地として残し、validate_kind の受理リストには method/property/
field も含めておく。

主な変更:

- src/reference/index.rs (新規): ReferenceSymbolEntry と
  ReferenceSymbolIndex 構造、build_or_update_index で size+mtime
  ベースの incremental 更新、find_symbol で kind / namespace フィルタ
- src/reference/mod.rs: maybe_execute_reference_tool に
  reference_find_symbol 分岐と execute_find_symbol を追加、
  dispatcher 経由テスト 6 件
- src/cli.rs: ReferenceCommand::FindSymbol variant
- src/app/runner.rs: build_reference_call に FindSymbol 分岐と
  2 件のテスト
- src/tooling/tool_catalog.rs: reference_find_symbol を TOOL_NAMES /
  executor / read_only / params_schema / parity count(125) に登録
- .claude-plugin/.../unity-csharp-reference/SKILL.md: Preferred Flow
  に find-symbol 例とフォールバック説明
- references/symbol-lookup-playbook.md: workflow step 1 を反映
- docs/tools.md: Reference Cache (6 -> 7 tools)
- tasks/lessons.md: SPEC #185 振り返り 3 件 (clippy 1.95 差、
  coverage 90% 維持、SPEC section markers)

ローカル検証:

- cargo fmt -- --check: clean
- cargo clippy --all-targets -- -D warnings: clean
- cargo test --bin unity-cli: 356 passed / 0 failed
- cargo llvm-cov --all-targets: TOTAL line coverage 90.69%
- unity-cli skills lint --severity error: 15 skills / 0 violations

Refs #187

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@akiojin akiojin force-pushed the work/20260511-0223 branch from 6c8311f to ebc1f3f Compare May 11, 2026 14:34
@akiojin
Copy link
Copy Markdown
Owner Author

akiojin commented May 11, 2026

CI gate clear: merge_state CLEAN

gwt-discussion で確定した方針(採用方針 B + 型のみ scope)に基づく Phase 2 (#187) 実装を完成させ、CI を緑にしました。

修正サマリ

  • Markdown & Commitlint (commitlint failure): 旧 WIP commit (f813632) が wip(reference): という type-enum 違反、加えて footer の長行が 100 char overflow していた。3 commits を 1 commit feat(reference): Phase 2 - reference find-symbol と Phase 1 振り返り に squash し、--force-with-lease で push し直して履歴を整理。

現在の CI 状態(全 SUCCESS)

  • Rust Format & Lint
  • Rust Tests / LSP Tests / LSP Performance
  • Rust Coverage / LSP Coverage (>= 90%)
  • Skill Contract Lint / Markdown & Commitlint / CodeRabbit
  • mergeable: MERGEABLE, merge_state: CLEAN

Phase 2 で land する内容

  • unity-cli reference find-symbol --name <name> [--kind ...] [--namespace ...] [--version ...] — per-version on-disk index (~/.unity/cache/UnityCsReference/<version>/.unity-cli-index/symbols.json) で型定義を定数時間 lookup
  • 初回 lookup で full scan、以降は size + mtime で incremental 更新
  • skill SKILL.md / docs/tools.md / symbol-lookup-playbook.md に find-symbol の使い分けを反映
  • tasks/lessons.md に SPEC feat(reference): UnityCsReference のローカルキャッシュ参照機構(Phase 1) #185 振り返り 3 件 (clippy 1.95 のローカル差、coverage 90% 維持、SPEC section markers)

Out of Scope(Phase 3 #188 へ)

  • バージョン差分表示 (reference diff <v1> <v2> --symbol <fqn>)
  • LSP go-to-definition 連携実験
  • member-level lookup (method / property / field)

レビューと merge をお願いします。Phase 3 は別 SPEC #188 で後続。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant