Skip to content

refactor: realign fork-only helpers with upstream idioms - #12

Merged
onlyfeng merged 1 commit into
betafrom
refactor/align-fork-helpers-with-upstream
Oct 9, 2026
Merged

onlyfeng merged 1 commit into
betafrom
refactor/align-fork-helpers-with-upstream

Conversation

@onlyfeng

@onlyfeng onlyfeng commented Oct 9, 2026

Copy link
Copy Markdown
Owner

Summary

Part 3 of the fork alignment audit (follows #11): keep the fork-only behavior, but write it the way upstream already does. Net −132 lines.

  • Skill sync: git source detection via PackageInfo. GetDefaultRepoUrl now uses PackageInfo.FindForAssembly (same idiom as AssetPathUtility): when source == PackageSource.Git, the repo URL is taken from packageId (name@<url as written in manifest.json>). This replaces hand-parsing Packages/manifest.json plus LooksLikeGitPackageUrl, which guessed git-ness from host names (github/gitlab) and special-cased bare file: URIs. Unity already knows the source, so the heuristics are gone.
  • Skill sync: git runs through ExecPath.TryRun. Drops the duplicate RunProcess (its own Process plumbing and 120s timeout) and QuoteProcessArgument, which used different quoting rules from AssetPathUtility.QuoteCommandLineArg; both now go through the shared helpers.
  • run_tests: cache key matches the focus-nudge key. (transport_mode, user_id, instance_hash, job_id) instead of a custom "user:…|instance:…" string. user_id is read only when remote-hosted, exactly as get_test_job already did for the nudge (it is only ever resolved from API keys in remote-hosted mode, so production behavior is unchanged). LRU uses OrderedDict.move_to_end / popitem(last=False) like _nudge_states.
  • Middleware: tool name from context.message.name. Replaces _command_name_from_context, which probed name / tool_name / command attributes plus a dict branch; mirrors how the same method already reads context.message.arguments.

Test plan

  • Python: full suite 1596 passed, 18 skipped. test_cached_test_jobs_are_scoped_by_user_for_same_instance now sets http_remote_hosted=True (the only mode where user_id exists); LRU test asserts the new key tuple.
  • Unity 2022.3.62f3, full EditMode run: 1597 cases, 1519 passed, 0 failed, 78 skipped (Windows-only). New SkillSyncServiceTests 6/6 (packageId parsing for https, git+https, scp-style git@, no @; non-git install falls back to upstream).
  • End-to-end: minimal Unity project installing this branch via https://github.com/onlyfeng/unity-mcp.git?path=/MCPForUnity#refactor/align-fork-helpers-with-upstream reports source=Git, packageId=com.coplaydev.unity-mcp@https://github.com/onlyfeng/unity-mcp.git?path=/MCPForUnity#refactor/align-fork-helpers-with-upstream, and GetDefaultRepoUrl() returns https://github.com/onlyfeng/unity-mcp.git.

🤖 Generated with Claude Code

- Skill sync: detect a git-installed package with PackageInfo.FindForAssembly
  (source == PackageSource.Git, URL from packageId), like AssetPathUtility,
  instead of parsing Packages/manifest.json with host-name heuristics.
- Skill sync: run git through ExecPath.TryRun and quote with
  AssetPathUtility.QuoteCommandLineArg, dropping the duplicate RunProcess and
  QuoteProcessArgument helpers.
- run_tests: key the test job cache like the focus-nudge state
  (transport_mode, user_id, instance hash, job_id), reading user_id only when
  remote-hosted as get_test_job already did, and use OrderedDict for LRU.
- Middleware: read the tool name from context.message.name instead of probing
  several attribute names.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-09T08:32:18.590250Z b4fa90c PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@onlyfeng
onlyfeng merged commit d1e2f52 into beta Oct 9, 2026
12 checks passed
@onlyfeng
onlyfeng deleted the refactor/align-fork-helpers-with-upstream branch October 9, 2026 14:44
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