Commit Graph

459 Commits (2649d9c3792be09c4a778d04d59e13efd3be3dce)

Author SHA1 Message Date
David Sarno 1e003748d8 telemetry: bounded queue + single worker; INFO-level send logs; endpoint to Cloud Run; add unit test for backpressure 2025-09-09 18:45:09 -07:00
David Sarno bd55a56d1c MCP server: hardened startup + telemetry queue
- Logging to stderr with force; quiet httpx/urllib3
- Async lifespan fix; defer telemetry in first second
- Bounded telemetry queue with single worker
- Reduce initial Unity connect timeout to 1s
- Keep server_version in file
2025-09-09 12:14:00 -07:00
dsarno 9d17061452
Add Windows legacy server cleanup for %LOCALAPPDATA%\Programs\UnityMCP\UnityMcpServer (#272)
- Detect and clean up legacy server installations in LocalApplicationData
- Prevents accumulation of old server copies during package updates
- Improves cleanup of Windows-specific legacy installation paths
2025-09-09 10:18:22 -07:00
David Sarno ba45051a40 fix she descrip 2025-09-08 21:37:06 -07:00
David Sarno 2e907f189e tests: disable telemetry during pytest via conftest; lock milestone saves 2025-09-08 20:55:00 -07:00
David Sarno 2abca24e9d telemetry: pluggable Unity sender; add MCP_DISABLE_TELEMETRY; server reads version file; locks for milestones 2025-09-08 20:45:45 -07:00
David Sarno f6a5568865 telemetry: prefer config with env override; validate scheme; robust load\n\n- TelemetryConfig reads config.telemetry_enabled/endpoint, env can override\n- Validate endpoint scheme; revalidate on send\n- Split UUID/milestones load error handling\n- Add tests for config precedence, scheme validation, UUID preservation\n- validate_script: optional include_diagnostics with documented behavior 2025-09-08 20:37:38 -07:00
David Sarno 7f0527f708 chore: apply CodeRabbit suggestions
- README path separators (todo in separate doc commit)
- manage_gameobject: pop prefabFolder not prefab_folder
- execute_menu_item: make sync to avoid blocking event loop
- telemetry: validate endpoint scheme (allow http/https only) and re-validate at send time
2025-09-08 20:25:07 -07:00
David Sarno 979757e38a tests green: align SDK outputs + harden inputs\n\n- find_in_file: start/end positions with 1-based exclusive endCol\n- read_resource: metadata-only default + lengthBytes; selection returns text\n- read_console: strip stacktrace when include_stacktrace=false\n- validate_script: summary counts; get_sha: minimal fields\n- silence stdout in test_telemetry helper 2025-09-08 20:14:49 -07:00
David Sarno bbe4b07558 feat: improve telemetry and parameter validation
- Add server-side integer coercion for numeric parameters in all tools
- Fix parameter type validation issues (read_resource, find_in_file, read_console, manage_scene, manage_asset)
- Add proper tool descriptions with ctx parameter documentation
- Fix Context type annotations (use Context instead of Any for ctx)
- All tools now accept flexible numeric inputs (strings, floats) and coerce to integers
- Telemetry system working with all tool_execution events captured in BigQuery
- Remove invalid parameter type warnings from client-side validation
2025-09-08 20:06:04 -07:00
David Sarno f127024d01 telemetry: enable tool_execution across tools via strict, async-aware decorator; add endpoint env override + urllib fallback; enrich OS fields; fix TelemetryHelper invocation 2025-09-08 16:39:47 -07:00
David Sarno 81dcd69722 Merge commit '3e83f993bfe632034bf7302d4319e3cd16353eb8' into feat/telemetry
* commit '3e83f993bfe632034bf7302d4319e3cd16353eb8':
  Improved ci prompt testing suite (#270)
  chore: bump version to 3.3.2
  Fix: Unity Editor reload crash + debug-noise reduction (#266)
  Revise README for improved clarity and organization
  docs: install uv via official installer (curl/winget)
  Update README.md
  docs: fix Windows uv path to use WinGet shim, keep macOS AppSupport symlink path
  docs: update README.md with improved installation paths, documentation, and logo
  fix: Update README installation paths to match ServerInstaller.cs
2025-09-08 10:11:46 -07:00
dsarno 3e83f993bf
Improved ci prompt testing suite (#270)
* CI: streamline Unity licensing (ULF/EBL); drop cache mounts & EBL-in-container; NL suite: clarify T-E/T-J, anchor positions, EOF brace targeting, SHA preconditions

* CI: support both ULF + EBL; validate ULF before -manualLicenseFile; robust readiness wait; use game-ci @v2 actions

* CI: activate EBL via container using UNITY_IMAGE; fix readiness regex grouping

* CI: minimal patch — guard manualLicenseFile by ulf.ok, expand error patterns, keep return-license @v2 for linter

* CI: harden ULF staging (printf+chmod); pass ULF_OK via env; use manual_args array for -manualLicenseFile

* CI: assert EBL activation writes entitlement to host mount; fail fast if missing

* CI: use heredoc in wait step to avoid nested-quote issues; remove redundant EBL artifact copy; drop job-level if and unused UNITY_VERSION

* CI: harden wait step (container status check, broader ready patterns, longer timeout); make license return non-blocking

* CI: wait step — confirm bridge readiness via status JSON (unity_port) + host socket probe

* CI: YAML-safe readiness fallback (grep/sed unity_port + bash TCP probe); workflow_dispatch trigger + ASCII step names

* CI: refine license error pattern to ignore benign LicensingClient channel startup; only match true activation/return failures

* Improve Unity bridge wait logic in CI workflow

- Increase timeout from 600s to 900s for Unity startup
- Add 'bound' to readiness pattern to catch more bridge signals
- Refine error detection to focus only on license failures
- Remove non-license error patterns that could cause false failures
- Improve error reporting with descriptive messages
- Fix regex escaping for unity port parsing
- Fix case sensitivity in sed commands

* Add comprehensive Unity workflow improvements

- Add project warm-up step to pre-import Library before bridge startup
- Expand license mounts to capture full Unity config and local-share directories
- Update bridge container to use expanded directory mounts instead of narrow license paths
- Provide ULF licenses in both legacy and standard local-share paths
- Improve EBL activation to capture complete Unity authentication context
- Update verification logic to check full config directories for entitlements

These changes eliminate cold import delays during bridge startup and provide
Unity with all necessary authentication data, reducing edge cases and improving
overall workflow reliability.

* Refine Unity workflow licensing and permissions

- Make EBL verification conditional on ULF presence to allow ULF-only runs
- Remove read-only mounts from warm-up container for Unity user directories
- Align secrets gate with actual licensing requirements (remove UNITY_SERIAL only)
- Keep return-license action at v2 (latest available version)

These changes prevent workflow failures when EBL has issues but ULF is valid,
allow Unity to write preferences during warm-up, and ensure secrets detection
matches the actual licensing logic used by the workflow steps.

* fix workflow YAML parse

* Normalize NL/T JUnit names and robust summary

* Fix Python import syntax in workflow debug step

* Improve prompt clarity for XML test fragment format

- Add detailed XML format requirements with exact specifications
- Emphasize NO prologue, epilogue, code fences, or extra characters
- Add specific instructions for T-D and T-J tests to write fragments immediately
- Include exact XML template and TESTID requirements
- Should fix T-D and T-J test failures in CI by ensuring proper fragment format

* Fix problematic regex substitution in test name canonicalization

- Replace unsafe regex substitution that could create malformed names
- New approach: preserve correctly formatted names, extract titles safely
- Prevents edge cases where double processing could corrupt test names
- Uses proper em dash (—) separator consistently
- More robust handling of various input formats

* CI: NL/T hardening — enforce filename-derived IDs, robust backfill, single-testcase guard; tighten prompt emissions; disallow Bash

* fix: keep file ID when canonicalizing test names

* CI: move Unity Pro license return to teardown after stopping Unity; keep placeholder at original site

* CI: remove revert helper & baseline snapshot; stop creating scripts dir; prompt: standardize T-B validation to level=standard

* CI: remove mini workflow and obsolete NL prompts; redact email in all Unity log dumps

* NL/T prompt: enforce allowed ops, require per-test fragment emission (incl. failures), add T-F..T-J XML templates

* NL suite: enforce strict NL-4 emission; remove brittle relabeling; keep canonicalization + backfill

* NL/T: minimize transcript; tighten NL-4 console reads; add final errors scan in T-J

* ci: add local validate-nlt-coverage helper

* CI: add staged report fragment promotion step (reports/_staging -> reports/) to support multi-edit reporting

* CI: add staged report fragment promotion step (reports/_staging -> reports/) to support multi-edit reporting

* CI: minor polish and guardrails; keep staged reports promotion and placeholder detection

* read_console: default count=50; normalize types str->list; tolerate legacy payload shapes

* read_console: harden response parsing for legacy shapes (data as list, tuple entries)

* Docs: refresh CI workflow and prompts (remove mini suite refs; per-test emissions, staging, guard)

* CI: move T coverage check after staged promotion; accept _staging as present; dedupe promotion step

* CI: make T retry conditional on explicit coverage probe (not failure()); respect _staging in probe
2025-09-07 15:47:56 -07:00
GitHub Actions e219080576 chore: bump version to 3.3.2 2025-09-06 18:00:57 +00:00
dsarno eaf14ef46f
Fix: Unity Editor reload crash + debug-noise reduction (#266)
* Editor: fix reload crash via cooperative cancellation + safe shutdown; gate ExecuteMenuItem logs behind debug flag

* Dev: add tools/stress_mcp.py stress utility and document usage in README-DEV

* docs: document immediate-reload stress test and streamline stress tool (immediate refresh, precondition SHA, EOF edits); revert to manage_script.read for compatibility

* fix: harden editor reload shutdown; gate logs; structured errors for ManageGameObject; test hardening

* tools(stress): cross-platform Assets path derivation using Path.parts with project-root fallback

* stress: add IO timeouts, jitter, retries, and storm mode to reduce reload crashes
2025-09-06 10:58:11 -07:00
dsarno 741b4f7671
Merge pull request #265 from dsarno/update-readme-docs
Update * Clean up README, fix install paths, add logo
2025-09-05 11:10:21 -07:00
dsarno 2d3ec51a2b
Revise README for improved clarity and organization
Updated section headings for clarity and consistency. Removed redundant instructions for Claude Code registration.
2025-09-05 11:08:58 -07:00
David Sarno 94fcff4c90 docs: install uv via official installer (curl/winget) 2025-09-05 09:17:17 -07:00
dsarno 963b5e1afd
Update README.md
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
2025-09-05 08:55:17 -07:00
David Sarno 574d104425 docs: fix Windows uv path to use WinGet shim, keep macOS AppSupport symlink path 2025-09-05 08:48:50 -07:00
David Sarno 8d0539b039 docs: update README.md with improved installation paths, documentation, and logo 2025-09-05 08:32:00 -07:00
Justin Barnett 99beca7cfe endpoint adjustment 2025-09-04 14:43:41 -04:00
Justin Barnett 8303ed1dbc Merge remote-tracking branch 'origin/main' into feat/telemetry 2025-09-04 12:12:14 -04:00
Justin Barnett e5039c8acc added optional telemetry 2025-09-04 12:09:34 -04:00
David Sarno 4553641a39 fix: Update README installation paths to match ServerInstaller.cs
- Windows: Fix path from AppData\Local\Programs\UnityMCP to AppData\Local\UnityMCP
- macOS: Update from /usr/local/bin/UnityMCP to Library/AppSupport/UnityMCP (uses symlink)
- Linux: Change from /home/USERNAME/bin/UnityMCP to .local/share/UnityMCP
- Update Claude Code command examples with correct paths

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-03 18:13:19 -07:00
GitHub Actions b7411e2cde chore: bump version to 3.3.1 2025-09-04 01:12:17 +00:00
dsarno 3a2a31b066
Merge pull request #260 from dsarno/fix/brace-validation-improvements
Fix/brace validation improvements
2025-09-03 18:02:13 -07:00
David Sarno 064dc29213 fix: Implement CodeRabbit resource management and type safety improvements
- Move RenderTexture cleanup to finally block to ensure proper disposal
- Add PNG data validation before Base64 conversion
- Add explicit TextureFormat.RGB24 specification
- Add bool() coercion for prefer_last parameter to handle non-boolean JSON values

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-03 17:58:05 -07:00
David Sarno 264b585ceb fix: address CodeRabbit feedback on resource leaks and shader safety
- Fix material creation to handle missing shaders (URP/HDRP fallbacks)
- Add try/finally blocks for RenderTexture resource management
- Fix Python closure variable binding (ruff B023)

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-03 17:11:30 -07:00
David Sarno 290c913a0f chore: remove vestigial sentinel flip code
- Remove deprecated _trigger_sentinel_async function and all call sites
- Clean up force_sentinel_reload option handling (replaced with Unity's synchronous system)
- Addresses repeated CodeRabbit flagging of unused vestigial code

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-03 16:58:13 -07:00
David Sarno 9697653b64 fix: address CodeRabbit and Greptile feedback
CodeRabbit fixes:
- Fix Python test assertions to use assert instead of print/return
- Update version consistency: server_version.txt from 3.2.0 to 3.3.0
- Assembly definition references already correctly configured

Greptile style fixes:
- Add missing newlines at end of Unity meta files and source files
- Fix test logic assumptions: use GreaterOrEqual instead of exact counts
- Make test assertions more robust for fuzzy matching algorithms

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-03 16:37:45 -07:00
David Sarno 28a9bc69bd test: Add comprehensive validation tests for improved brace validation
- Add ManageScriptValidationTests.cs: Unity-based validation tests for structural balance checking
- Add test_improved_anchor_matching.py: Python tests for enhanced anchor pattern matching
- Remove obsolete test_regex_delete_guard.py (functionality moved to C# validation)
- Tests validate the scoped validation fixes and anchor matching improvements

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-03 15:39:19 -07:00
David Sarno 548a4f4f29 feat: Add additive test suite and improve validation robustness
- Add nl-unity-suite-full-additive.md: new additive test design that builds state progressively instead of requiring resets
- Update claude-nl-suite.yml workflow to use additive test suite
- Fix validation scoping bugs in ManageScript.cs:
  - Correct scoped validation scope calculation (was using newText.Length instead of originalLength)
  - Enable always-on final structural validation regardless of relaxed mode
- Unify regex_replace and anchor_insert to use same smart matching logic in manage_script_edits.py
- Additive tests demonstrate better real-world workflow testing and expose interaction bugs between operations
- Self-healing capability: tools can recover from and fix broken file states

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-03 15:36:21 -07:00
dsarno 1cc4ffcebd
Merge pull request #259 from dsarno/fix/component-resolver-test
fix: Replace missing TicTacToe3D with existing CustomComponent in Com…
2025-09-03 10:25:44 -07:00
David Sarno 8601c90552 fix: Replace missing TicTacToe3D with existing CustomComponent in ComponentResolver test
The TryResolve_PrefersPlayerAssemblies test was failing in CI because it referenced
TicTacToe3D.cs which exists only locally and is not committed to the repository.

- Replace test reference from "TicTacToe3D" to "CustomComponent"
- CustomComponent exists in Assets/Scripts/TestAsmdef/ and is tracked in git
- CustomComponent is properly compiled into the TestAsmdef Player assembly
- Add explicit assertion to verify resolution from correct TestAsmdef assembly
- Test maintains same functionality: verifying ComponentResolver finds user scripts from Player assemblies

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-03 10:24:52 -07:00
GitHub Actions 65fdb4d090 chore: bump version to 3.3.0 2025-09-03 17:07:45 +00:00
dsarno 4401de15d6
Merge pull request #256 from dsarno/feat/robust-component-resolver
Feat/robust component resolver
2025-09-03 10:06:54 -07:00
David Sarno 715600956c fix: Implement collect-and-continue behavior for component property operations
- Change from fail-fast to collect-and-continue at component iteration level
- Previously: first component error would halt processing of remaining components
- Now: all components are processed, errors collected and returned together
- Maintain existing collect-and-continue behavior within individual components
- Add comprehensive tests validating the collect-and-continue behavior works correctly
- All valid properties are applied even when invalid ones fail
- Processing continues through exceptions with proper error aggregation

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-03 09:57:12 -07:00
David Sarno 43abb003ef perf: Implement CodeRabbit nitpick improvements and fix TestAsmdef
Performance & Quality Improvements:
- Add shared JsonSerializer to eliminate per-call allocation overhead
- Optimize ComponentResolver with CacheByName for short-name lookups
- Deduplicate Vector3 parsing implementations to reduce maintenance burden
- Improve property name normalization for better fuzzy matching quality
- Reduce log noise by avoiding duplicate component resolution warnings

Code Quality:
- Keep using static import for ComponentResolver (CodeRabbit was incorrect about this)
- Normalize property names consistently in AI suggestions algorithm
- Remove duplicate ParseVector3 implementation

TestAsmdef Fix:
- Revert TestAsmdef back to runtime-compatible (remove "includePlatforms": ["Editor"])
- CustomComponent now works correctly for asmdef testing as originally intended
- Validates that ComponentResolver properly handles both short and FQN for asmdef components

Live Testing Validation:
- All ComponentResolver functionality verified through live MCP connection
- AI property matching working perfectly with natural language input
- Assembly definition support fully functional for both default and custom assemblies
- Error handling provides helpful suggestions and complete context

All 45 C# tests + 31 Python tests still passing. Production ready!

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-03 09:12:44 -07:00
David Sarno 17ad011b42 fix: Address CodeRabbit review issues and improve robustness
Critical Bug Fixes:
- Fix operator precedence bug in ManageAsset.cs that could cause null reference exceptions
- Fix GameObject memory leak in primitive creation when name validation fails
- Add proper cleanup with DestroyImmediate when primitive creation fails

ComponentResolver Integration:
- Replace fragile string-based GetComponent() calls with robust ComponentResolver
- Add ComponentResolver integration in ManageAsset.cs for component lookups
- Add fallback to string-based lookup in ManageGameObject.cs for compatibility

Enhanced Error Handling:
- Surface specific ComponentResolver error context in ScriptableObject creation failures
- Add support for setting private [SerializeField] fields in property matching
- Improve debugging with detailed error messages

Assembly Definition Fixes:
- Configure TestAsmdef as Editor-only to prevent build bloat
- Add explicit TestAsmdef reference to test assembly for proper component resolution
- Fix ComponentResolverTests to use accessible CustomComponent instead of TicTacToe3D

Code Quality:
- Disable nullable reference types for legacy codebase to eliminate 100+ warnings
- Maintain backward compatibility while improving reliability

All 45 unit tests pass, ensuring no regressions while significantly improving robustness.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-03 08:27:34 -07:00
David Sarno aac237c5cf test: Add comprehensive unit tests for ComponentResolver and intelligent property matching
- Add AIPropertyMatchingTests.cs with 14 tests covering property enumeration, fuzzy matching, caching, and Unity naming conventions
- Add ManageGameObjectTests.cs with 10 integration tests for component resolution, property matching, and error handling
- Add ComponentResolverTests.cs.meta for existing comprehensive ComponentResolver tests
- Add AssemblyInfo.cs.meta for test assembly access
- Fix ManageGameObject.HandleCommand null parameter handling to prevent NullReferenceException

All 45 unit tests now pass, providing full coverage of:
- Robust component resolution avoiding Assembly.LoadFrom
- Intelligent property name suggestions using rule-based fuzzy matching
- Assembly definition (asmdef) support via CompilationPipeline
- Comprehensive error handling with helpful suggestions

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-02 19:27:40 -07:00
David Sarno cb42364263 feat: add AI-powered property matching system for component properties
- Add intelligent property name suggestions when property setting fails
- Implement GetAllComponentProperties to enumerate available properties
- Add rule-based AI algorithm for property name matching (camelCase, spaces, etc.)
- Include comprehensive error messages with suggestions and full property lists
- Add Levenshtein distance calculation for fuzzy string matching
- Cache suggestions to improve performance on repeated queries
- Add comprehensive unit tests (11 tests) covering all ComponentResolver scenarios
- Add InternalsVisibleTo attribute for test access to internal classes

Examples of improved error messages:
- "Max Reach Distance" → "Did you mean: maxReachDistance?"
- Shows all available properties when property not found
- Handles Unity Inspector display names vs actual field names

All tests passing (21/21) including new ComponentResolver test suite.
The system eliminates silent property setting failures and provides
actionable feedback to developers.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-02 19:08:59 -07:00
David Sarno c40f3d0357 feat: implement robust ComponentResolver for assembly definitions
- Replace Assembly.LoadFrom with already-loaded assembly search
- Prioritize Player assemblies over Editor assemblies using CompilationPipeline
- Support both short names and fully-qualified component names
- Add comprehensive caching and error handling with disambiguation
- Use Undo.AddComponent for proper editor integration
- Handle ReflectionTypeLoadException safely during type enumeration
- Add fallback to TypeCache for comprehensive type discovery in Editor

Fixes component resolution across custom assembly definitions and eliminates
"Could not load the file 'Assembly-CSharp-Editor'" errors.

Tested with:
- Built-in Unity components (Rigidbody, MeshRenderer, AudioSource)
- Custom user scripts in Assembly-CSharp (TicTacToe3D)
- Custom assembly definition components (TestNamespace.CustomComponent)
- Error handling for non-existent components

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-02 18:45:30 -07:00
Jos van der Westhuizen 7c7a893462
Update README.md 2025-09-02 18:43:59 -07:00
GitHub Actions 43d1d91327 chore: bump version to 3.2.2 2025-09-02 22:23:58 +00:00
dsarno c27b8bfdf0
Merge pull request #253 from dsarno/fix/winstore-uv-detection
Fix/winstore uv detection
2025-09-02 15:23:09 -07:00
dsarno b22f3e3b4d
Merge pull request #254 from dsarno/fix/windows-auto-reload-managescript
Fix/windows auto reload managescript
2025-09-02 15:20:32 -07:00
dsarno 96326ee6a1 Editor: Detect Windows Store Python (PythonSoftwareFoundation) uv.exe in FindUvPath 2025-09-02 14:41:29 -07:00
dsarno 8c2b4a2ca8 Editor: Improve Windows auto-reload in ManageScript\n- Force synchronous ImportAsset and RequestScriptCompilation\n- Debounced refresh calls ImportAsset instead of Refresh\n- Path sanitation for Assets/ and slashes\n- Atomic writes with Windows-safe fallbacks\n- Nudge Editor tick for debounce reliability 2025-09-02 14:13:13 -07:00
GitHub Actions 35e7d89cbc chore: bump version to 3.2.1 2025-09-02 16:44:15 +00:00