Repository navigation
fix: Detect V2 Unity projects with file:/embedded package references or ambiguous git cache generations - #1847
Conversation
…uous-cache layouts The V3 dispatcher's V2 detection relied on manifest.json + packages-lock.json + PackageCache heuristics, which missed file: references, embedded packages (no manifest.json entry at all), and left git-dependency PackageCache ambiguity unresolved even though packages-lock.json records a git hash. Since Unity loads file:/embedded packages directly from their on-disk directory rather than a PackageCache mirror, that directory's own package.json (name + version) is the authoritative source for those layouts, while registry/git dependencies keep using the resolved lock version as before. This requires no V2-side release and fixes detection for every existing V2 project immediately. - Resolve file: manifest dependencies against Packages/ (normalizing backslashes for Windows-authored manifests) and read the target package.json directly when the lock has no usable version. - Scan Packages/ for embedded packages when manifest.json has no dependency entry at all; flag multi-candidate embedded matches distinctly so recovery guidance can point at removing duplicate directories instead of refreshing packages-lock.json. - Disambiguate multiple cached git package generations by matching packages-lock.json's resolved commit hash as a prefix of each PackageCache directory's suffix.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughV2 dispatcher detection now resolves ChangesUnity V2 detection and guidance
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant UnityProject
participant DispatcherDetector
participant PackageMetadata
participant DispatcherRunner
UnityProject->>DispatcherDetector: Provide manifest, Packages, PackageCache, and lockfile
DispatcherDetector->>PackageMetadata: Read package names and versions
PackageMetadata-->>DispatcherDetector: Return V2 candidates and ambiguity state
DispatcherDetector-->>DispatcherRunner: Return detected project metadata
DispatcherRunner-->>UnityProject: Emit version or embedded-duplication guidance
Possibly related issues
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
…or ambiguous git cache generations (hatayama#1847)
Summary
file:path, embed it directly underPackages/, or resolve it through a git dependency with multiple cached generations were misdetected as V3 and hit confusing pin-resolution errors instead of being delegated to the V2 CLI.package.json(name+version) directly from disk for these on-disk layouts, so detection works immediately for every existing V2 project without requiring any V2-side release.User Impact
file:-referenced and embedded V2 packages were not recognized as V2 at all, so commands fell through to the V3 pin-resolution path and failed with an unrelated internal error. A git-dependency project with multiple cached package generations always hit a hard "multiple package generations found" error, even when packages-lock.json already recorded which generation was actually resolved.uloop: executing in V2 mode). When multiple generations are genuinely ambiguous, the guidance now differs by cause: PackageCache ambiguity still suggests reopening Unity to refresh the lock, while duplicate embedded package directories are told to remove the duplicates instead (refreshing the lock cannot fix that case).Changes
file:manifest dependency values againstPackages/(normalizing\to/first for Windows-authored manifests) and read the targetpackage.jsondirectly when the lock has no usable version for it.Packages/for embedded packages whenmanifest.jsonhas no dependency entry at all, matching bypackage.jsonname rather than directory naming.Packages/packages-lock.json/Library/PackageCache).protocolVersion/CliConstants.REQUIRED_CLI_PROTOCOL_VERSION— this only changes how the dispatcher classifies a project locally; the IPC wire format between the CLI and Unity package is untouched.Verification
go test ./internal/dispatcher/...incli/dispatcher: all detection/dispatch tests pass, including new cases forfile:references, embedded packages, embedded-ambiguity guidance, and git-hash disambiguation (including a non-default suffix length case).scripts/check-go-cli.sh: fmt/vet/lint/test pass forcli/common,cli/release-automation, andcli/project-runner;verify-go-cli-dist.sh(native binary build) passes. One unrelated pre-existing failure,TestCommandHelpUsesWatchToolSchemaForDefaultWatchCommandsincli/dispatcher, was confirmed to reproduce identically onorigin/v3-betabefore this change (verified viagit stash) and is unaffected by this PR.dist/darwin-arm64/uloop) and ran it against disposable Unity project layouts using the real V2package.json(io.github.hatayama.uloopmcp2.2.0, fromorigin/main) as afile:reference and as an embedded package underPackages/. Both reacheduloop: executing in V2 mode; the same binary built from before this change failed both with an unrelated internal pin-resolution error.