forked from CoplayDev/unity-mcp
-
Notifications
You must be signed in to change notification settings - Fork 0
Framed transport + Claude‑friendly edit tools + live Unity NL test framework #42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
273 commits
Select commit
Hold shift + click to select a range
b01978c
test: enforce no prints and handshake preamble
dsarno 555d965
feat: add defensive server path resolution in tests
dsarno e4544f6
Refine server source path lookup
dsarno 9dbb4ff
Refine handshake tests and stdout hygiene
dsarno fde29d0
Convert skipped tests to xfail and improve framing robustness
dsarno 5386b23
clarify stdout test failure messaging
dsarno 63b070b
Add handshake fallback and logging checks
dsarno 6cedb80
Claude Desktop: write BOM-free config to macOS path; dual-path fallba…
dsarno 3bc9cd0
MCP: natural-language edit defaults; header guard + precondition for …
dsarno 3cc1acd
MCP: add anchor_delete/anchor_replace structured ops; normalize NL/te…
dsarno 22f55ce
Convert skipped tests to xfail and improve framing robustness
dsarno f3e94db
clarify stdout test failure messaging
dsarno d1362ac
Add handshake fallback and logging checks
dsarno e4e89e4
Claude Desktop: write BOM-free config to macOS path; dual-path fallba…
dsarno f1d773b
MCP: resolve merge conflicts; unify NL parsing and text-edit guards; …
dsarno c26ee13
MCP: add spec resource (script-edits); tighten script_apply_edits des…
dsarno 3962cad
MCP: add script-edits spec resource; route all-structured edits via '…
dsarno c28bb38
CI: gate Unity compile steps behind secrets.UNITY_LICENSE to avoid 'C…
dsarno 3943abd
CI: add Claude NL/T prompt at .claude/prompts/nl-unity-suite.md
dsarno 77c841b
Tests: switch NL suite to ClaudeTests/longUnityScript-claudeTest.cs; …
dsarno b9eb430
fix: check UNITY_LICENSE via env in workflow
dsarno e9206a9
Merge pull request #22 from dsarno/codex/fix-workflow-file-unrecogniz…
dsarno 69073c9
fix: allow manual run and env license check
dsarno 54389a2
Merge pull request #23 from dsarno/codex/fix-workflow-file-unrecogniz…
dsarno 543e2c5
fix: detect Unity mode and secrets
dsarno 428328e
Merge pull request #24 from dsarno/codex/fix-unity-workflow-secret-ha…
dsarno 528f603
Add debug print in mcp_source
dsarno 0655f65
Merge pull request #25 from dsarno/codex/add-debug-statement-for-work…
dsarno 230cb48
fix: update Unity MCP server path in workflow
dsarno b26d7a1
Merge pull request #27 from dsarno/codex/fix-mcp-server-path-in-mcp_c…
dsarno 1351927
fix: update server dependency path
dsarno 5f6b94a
Merge pull request #28 from dsarno/codex/fix-mcp-server-dependency-pa…
dsarno 32f91f2
Update claude-nl-suite.yml
dsarno cd2e6e0
Update claude-nl-suite.yml
dsarno 84585cc
Remove debug invocation print
dsarno 54f1069
Merge pull request #29 from dsarno/codex/remove-debug-print-from-main
dsarno 7cfb401
updated claude test file
dsarno 50f15e9
Merge branch 'feat/nl-edits-ai-planner-prep' of https://github.com/ds…
dsarno aaa8b4d
CI: start MCP via uv stdio; preflight tool listing; register script_e…
dsarno 7e276bb
CI: fail-fast preflight for MCP modules; gate Claude step on success()
dsarno 325ca41
CI: log MCP server path and contents for startup diagnostics
dsarno 87cf9c0
CI: use uv --active with --directory for MCP server and diagnostics
dsarno e44e841
Bridge: resolve Debug ambiguity by removing System.Diagnostics using;…
dsarno a3738d6
CI: expand allowed tools (find/head/tail) and raise max_turns to 20
dsarno 6a3c68b
Fix MCP server launch and tool permissions
dsarno 8e93adf
Clarify uv launch comment
dsarno 52bc482
Merge pull request #32 from dsarno/codex/fix-mcp-server-launch-in-ci
dsarno 68da960
Merge pull request #33 from dsarno/codex/fix-mcp-server-launch-in-ci-…
dsarno 18e1721
Auto-approve Unity tools and mark permission skips
dsarno 6fba526
Merge pull request #34 from dsarno/codex/enable-auto-approvals-in-ci-…
dsarno d0e4df9
Ensure artifact dir exists before agent runs
dsarno 367bc11
Merge pull request #35 from dsarno/codex/handle-xml-parsing-errors-gr…
dsarno 278270e
Update claude-nl-suite.yml
dsarno a8aea77
Align Claude NL test workflow with latest action options
dsarno 0ecb3ba
Merge pull request #36 from dsarno/codex/patch-claude-yaml-for-test-s…
dsarno 04eacf0
chore: refine CI permissions for claude tests
dsarno 8d3af80
Merge pull request #38 from dsarno/codex/fix-auto-approval-for-ci-per…
dsarno 7d99a7e
Server: register resources for both FastMCP.resource/resources; alway…
dsarno 89daa65
CI: add nl-startuptest to quickly verify MCP resources and one previe…
dsarno 8dca4bf
CI: gate full NL/T on startup success; include ClaudeTests in resources
dsarno bbca727
CI: fix YAML by using printf for fallback JUnit heredoc
dsarno 117fbbc
CI: widen Unity tool auto-approval to mcp__unity__*; keep aggregator …
dsarno 67831c5
CI: guard Anthropic key via env; startup and NL/T use ANTHROPIC_API_K…
dsarno 5bf37bb
CI: refine claude suite (seed settings, clarify permissions, startup …
dsarno 184df23
CI: pass ANTHROPIC_API_KEY via env; refine permissions; keep startup …
dsarno e120301
CI: detect Anthropic key and gate Claude steps; skip on forks
dsarno a0fc515
CI: refine startup tool list comments; explicit approvals; tidy unity…
dsarno ea39fa8
Prompts/scripts: update startup and NL suite prompts; add skipped mar…
dsarno 27b4a7e
CI: add Unity MCP smoke workflow (single tool call to verify server)
dsarno 6731bcb
CI: add QuickProbe workflow and prompt
dsarno adeab41
CI: update QuickProbe prompt and workflow wiring
dsarno 260e236
CI: minor updates to QuickProbe prompt and smoke workflow
dsarno e562721
CI: finalize smoke workflow
dsarno ec19dcd
CI: refine QuickProbe workflow (env + permissions + wildcard tools)
dsarno 2fc1101
CI: add Claude Desktop parity workflow
dsarno 5f080e0
CI: gate desktop-parity on Anthropic key; pass anthropic_api_key like…
dsarno 0b423b5
Add quickprobe prompt and CI workflow (mcp-quickprobe.md, unity-mcp-q…
dsarno 204b9fc
strictier tool use to prevent subagent spawning and force mcp tools
dsarno 0c60f43
update workflow filesto reduce likelihood of subagent spawning
dsarno 08911ed
improve permissions for claude agent, fix mcpbridge timeout/token issue
dsarno 33c7aec
increase max turns to 10
dsarno b7478f0
ci: align NL suite to new permissions schema; prevent subagent drift
dsarno 288f566
ci: NL suite -> mini prompt for e2e; add full NL/T prompt; server: ct…
dsarno 47f3c7b
ci: add checks:write; revert local project hardcodes (manifest, Proje…
dsarno 1be0f60
tools: text-edit routing fixes (anchor_insert via text, CRLF calc); p…
dsarno 70ece54
ci: use absolute UNITY_PROJECT_ROOT; prompts target TestProjects; ser…
dsarno 1f18340
ci: ignore Unity test project's packages-lock.json; remove from repo …
dsarno 9bb0be8
CI: start persistent Unity Editor for MCP (guarded by license) + allo…
dsarno 838eb75
CI: hide license and pass via env to docker; fix invalid ref format
dsarno 5acb539
CI: readiness probe uses handshake on Unity MCP port (deterministic)
dsarno 298e376
CI: fix YAML; use TCP handshake readiness probe (FRAMING=1)
dsarno 3215593
CI: prime Unity license via game-ci; mount ULF into container; extend…
dsarno 7f7505a
CI: use ULF write + mount for Unity licensing; remove serial/email/pa…
dsarno 3905fcf
CI: entitlement activation (UNITY_SERIAL=''); verify host ULF cache; …
dsarno 152b866
CI: write ULF from secret and verify; drop entitlement activation step
dsarno 753c929
CI: detect any licensing path; GameCI prime; status dir env; log+prob…
dsarno a8c4297
CI: add GameCI license prime; conditional ULF write; one-shot license…
dsarno 0732e92
CI: fix YAML (inline python), add Anthropic key detect via GITHUB_ENV…
dsarno 1478aa7
CI: mount Unity token/ulf/cache dirs into container to share host lic…
dsarno 62da1aa
CI: fix YAML indentation; write ULF on host; activate in container wi…
dsarno d96ea2e
CI: gate Claude via outputs; mount all Unity license dirs; fix inline…
dsarno 307f489
CI: normalize detect to step outputs; ensure license dirs mounted and…
dsarno c908f8b
Bridge: honor UNITY_MCP_STATUS_DIR for heartbeat/status file (CI-frie…
dsarno 8a456bd
CI: guard project path for activation/start; align tool allowlist; ru…
dsarno 88545b0
CI: finalize Unity licensing mounts + status dir; mode-detect (ULF/EB…
dsarno 6ab5d12
CI: fix YAML probe (inline python -c) and finalize happy-path Unity l…
dsarno 36ea142
CI: inline python probe; unify Unity image and cache mounts; ready to…
dsarno ef99621
CI: fix docker run IMAGE placement; ignore cache find perms; keep sam…
dsarno 9b923c3
CI: pass -manualLicenseFile to persistent Editor; keep mounts and sin…
dsarno e020cbc
CI: mount full GameCI cache to /root in persistent Unity; set HOME=/r…
dsarno 0916ad2
CI: make -manualLicenseFile conditional; keep full /root mount and li…
dsarno 9a37cc7
CI: set HOME=/github/home; mount GameCI cache there; adjust manualLic…
dsarno 2a80d12
CI: EBL sign-in for persistent Unity (email/password/serial); revert …
dsarno db562c3
CI: run full NL/T suite prompt (nl-unity-suite-full.md) instead of mini
dsarno daca6cc
NL/T: require unified diffs + explicit verdicts in JUnit; CI: remove …
dsarno 59e3326
NL/T prompt: require CDATA wrapping for JUnit XML fields; guidance fo…
dsarno 9b772f6
CI: remove in-container license check step; keep readiness and full s…
dsarno 7fa2da9
NL/T prompt: add version header, stricter JUnit schema, hashing/norma…
dsarno cb13713
CI: increase Claude NL/T suite timeout to 30 minutes
dsarno c629855
CI: pre-create reports dir and result files to avoid tool approval pr…
dsarno fc57303
CI: skip wait if container not running; skip Editor start if project …
dsarno 33b7ef2
fixies to harden ManageScript
dsarno 7acd551
CI: sanitize NL/T markdown report to avoid NUL/encoding issues
dsarno cecbb06
revert breaking yyaml changes
dsarno ef194ac
CI: prime license, robust Unity start/wait, sanitize markdown via her…
dsarno ee23346
feat: installer cleanup, auto-migration, logging normalization
dsarno f21c2ce
fix(installer): skip legacy deletion when still referenced in prefs o…
dsarno 175d5ae
chore(editor): WriteToConfig honors pythonDir; robust config match; r…
dsarno 742d168
sec(installer): escape server path in pgrep pattern to prevent inject…
dsarno 576dba4
Merge branch 'main' of https://github.com/CoplayDev/unity-mcp into fi…
dsarno 4da30cc
bump server version
dsarno 58ed4d4
chore(server): bump server_version.txt to 3.0.4
dsarno 86b4dc1
chore(logging): include OS and server version in MCP bridge start log
dsarno 48c1b7a
fix(installer): use Application.platform for OS detection; add canoni…
dsarno 755e1d7
chore(version): bump server_version.txt to 3.0.5
dsarno ce1104e
feat(installer): rewire known configs (EditorPrefs, Cursor mcp.json) …
dsarno 01ea2f4
refactor(installer): revert to lean installer logic from ee23346c; fi…
dsarno ad5c311
MCP: Fix macOS paths and VSCode manual setup
dsarno aa4fc1c
Server: set server_version.txt to 3.0.1
dsarno dbc65a5
Merge branch 'fix/installer-cleanup-v2' into feat/pre-split-edit-fram…
dsarno 9c53d7b
Resolve merge: accept upstream renames/installer (fix/installer-clean…
dsarno 37acd71
Fix Claude Desktop config path and atomic write issues
dsarno 2bf18be
Editor: use macConfigPath on macOS for MCP client config writes (Clau…
dsarno be38c04
Models: add macConfigPath to McpClient for macOS config path selectio…
dsarno 5b7ab24
Editor: on macOS, prefer macConfigPath in ManualConfigEditorWindow (f…
dsarno a310091
Fix McpClient: align with upstream/main, prep for framing split
dsarno a7de7cc
NL suite: shard workflow; tighten bridge readiness; add MCP preflight…
dsarno 20827e0
NL suite: fix shard step indentation; move shard vars to env; remove …
dsarno d32fbb5
MCP clients: split VSCode Copilot config paths into macConfigPath and…
dsarno d637c58
Unity bridge: clean stale status; bind host; robust wait probe with I…
dsarno 8837cf9
CI: use MCPForUnity.Editor.MCPForUnityBridge.StartAutoConnect as exec…
dsarno 92b57c0
Action wiring: inline mcpServers in settings for all shards; remove r…
dsarno 84e412d
CI: embed mcpServers in settings for all shards; fix startup sanity s…
dsarno 70ac26d
CI: pin claude-code-base-action to e6f32c8; use claude_args --mcp-con…
dsarno 3b4ff21
CI: unpin claude-code-base-action to @beta (commit ref not found)
dsarno 798db05
CI: align with claude-code-base-action @beta; pass MCP via claude_arg…
dsarno 3ad1caf
Editor: Fix apply_text_edits heuristic when edits shift positions; re…
dsarno 5c62b40
CI: unify MCP wiring across workflows; write .claude/mcp.json; switch…
dsarno 1bda497
CI: collapse NL suite shards into a single run to avoid repeated test…
dsarno 2d9a83f
CI: minimize allowedTools for NL suite to essential Unity MCP + Bash(…
dsarno 87e69f0
CI: mkdir -p reports before run; remove unsupported --timeout-minutes…
dsarno eb7227f
CI: broaden allowedTools to include find_in_file and mcp__unity__*
dsarno f851b70
CI: enable use_node_cache and switch NL suite model to claude-3-7-hai…
dsarno 29d781a
CI: disable use_node_cache to avoid setup-node lockfile error
dsarno 7e60640
CI: set NL suite model to claude-3-haiku-20240307
dsarno bf9ffbd
CI: cap Haiku output with --max-tokens 2048 for NL suite
dsarno 1e1db08
CI: switch to claude-3-7-sonnet-latest and remove unsupported --max-t…
dsarno ce4c6e6
CI: update allowedTools to Bash(*) and explicit Unity MCP tool list
dsarno 7f86daf
CI: update NL suite workflow (latest tweaks)
dsarno 83931a1
Tests: tighten NL suite prompt for logging, hash discipline, stale re…
dsarno 7758c4f
Add disallowed tools to NL suite workflow
dsarno 8a02055
Merge pull request #43 from dsarno/codex/add-disallow-todo-to-nl-suite
dsarno 1119eea
docs: clarify stale write retry
dsarno 3eadecd
Merge pull request #44 from dsarno/codex/add-stale-write-retry-rule
dsarno dbdd7a3
Add fallback JUnit report and adjust publisher
dsarno 75bf720
Merge pull request #45 from dsarno/codex/fix-nl-suite-junit-handling-…
dsarno 48334cb
Indent fallback JUnit XML in workflow
dsarno 7922690
Merge pull request #46 from dsarno/codex/fix-yaml-parsing-error-in-wo…
dsarno cab5e92
fix: correct fallback JUnit report generation
dsarno 265beb9
Merge pull request #47 from dsarno/codex/fix-junit-report-generation-…
dsarno 2b10b1a
Update mcp-quickprobe.md
dsarno 832634b
Update mcp-quickprobe.md
dsarno 8c62912
Update Response.cs
dsarno b0a8215
Update MCPForUnityBridge.cs
dsarno c25c2af
fix: correct McpTypes reference
dsarno da4ce7d
Add directory existence checks for symlink and XDG paths
dsarno faa403c
fix: only set installation flag after successful server install
dsarno 21bb4e8
Merge pull request #50 from dsarno/codex/fix-editorprefs-key-setting-…
dsarno 81d64b0
Merge pull request #49 from dsarno/codex/add-existence-checks-for-eff…
dsarno 6eb1679
Merge pull request #48 from dsarno/codex/fix-compile-error-in-configj…
dsarno 030edb6
Update resource_tools.py
dsarno 7f17058
fix: respect mac config paths
dsarno a526567
Use File.Replace for atomic config write
dsarno 086a13d
Remove unused imports in manage_script
dsarno c496c8a
Merge pull request #52 from dsarno/codex/fix-race-condition-in-file-m…
dsarno 2e8f9fb
Merge pull request #51 from dsarno/codex/fix-macos-config-path-logic
dsarno 6d5bf59
Merge pull request #53 from dsarno/codex/remove-unused-imports-in-man…
dsarno 3e055c8
bump server version
dsarno 295c7c2
Resolve merge with origin/main: keep ours for workflow files
dsarno 0fb2e3b
Tests: update NL suite prompt and workflows; remove deprecated smoke/…
dsarno baf51ea
Editor: atomic config write via File.Replace fallback; remove redunda…
dsarno c9c73d8
CI: harden NL suite - idempotent docker, gate on unity_ok, safer port…
dsarno 9b546fd
Editor: make atomic config write restoration safe (flag writeDone; co…
dsarno 26e687f
Merge pull request #54 from dsarno/fix/atomic-config-write
dsarno ff7e24e
CI: fix fallback JUnit heredoc by using printf lines (no EOF delimite…
dsarno 1da7033
CI: switch NL suite to mini prompt; mini prompt honors / and NL disci…
dsarno 60c6c07
CI: replace claude_args with allowed_tools/model/mcp_config per actio…
dsarno 1fa42a5
CI: expand UNITY_PROJECT_ROOT via in MCP config heredoc
dsarno 6caa598
EditorWindow: add cross-platform fallback for File.Replace; macOS-ins…
dsarno c72b90a
CI: strengthen JUnit publishing for NL mini suite (normalize, debug l…
dsarno 9d9216e
CI: set job-wide JUNIT_OUT/MD_OUT; normalization uses env; publish re…
dsarno 6122c28
CI: publish a single normalized JUnit (reports/junit-for-actions.xml)…
dsarno 0cfbd7b
CI: align mini prompt report filenames; redact Unity log tail in diag…
dsarno e13c470
chore: sync workflow and mini prompt; redacted logs; JUnit normalizat…
dsarno 252cc5c
CI: redact sensitive tokens in Stop Unity; docs: CI usage + edit tools
dsarno 0938760
prompts: update nl-unity-suite-full (mini-style setup + reporting dis…
dsarno 2c2a26f
CI: harden NL workflows (timeout_minutes, robust normalization); prom…
dsarno b252130
prompts: add guarded write pattern (LF hash, stale_file retry) to ful…
dsarno c35eed9
prompts: enforce continue-on-failure, driver flow, and status handlin…
dsarno 791d6ff
Make test list more explicit in prompt. Get rid of old test prompts f…
dsarno 5704354
prompts: add stale fast-retry (server hash) + in-memory buf guidance
dsarno 41a1012
CI: standardize JUNIT_OUT to reports/junit-nl-suite.xml; fix artifact…
dsarno 960eab0
prompts: reporting discipline — append-only fragments, batch writes, …
dsarno 87a67c4
prompts: stale fast-retry preference, buffer/sha carry, snapshot reve…
dsarno 46ee857
workflows(nl-suite): precreate report skeletons, assemble junit, synt…
dsarno b8c1bc6
thsis too
dsarno 6071b70
Update README-DEV.md
dsarno 9b7de3c
Update .github/workflows/claude-nl-suite-mini.yml
dsarno 12dd21c
Update .github/workflows/claude-nl-suite.yml
dsarno b27a6b6
workflows(nl-mini): fix YAML indentation/trailing spaces under with: …
dsarno 1078039
workflows(nl-suite): fix indentation on docker logs redaction line (Y…
dsarno 98e41eb
Add write to allowlist
dsarno 9139cfc
nl-suite: harden reporting discipline (fragment-only writes, forbid a…
dsarno a26f073
nl-suite: enforce end-of-suite single Write (no bash redirection); wo…
dsarno 995529a
prompts(nl-full): end-of-suite results must be valid XML with single …
dsarno 9f14238
workflows(nl-suite): make Claude step non-fatal; tolerant normalizer …
dsarno 9d2047c
nl-suite: fix stale classname to UnityMCP.NL-T in mini fallback; prom…
dsarno 66c7ca9
nl-suite: fix fallback JUnit classname to UnityMCP.NL-T; prompt: forb…
dsarno b032f33
prompts(nl-full): after each write re-read raw bytes to refresh pre_s…
dsarno 9c07afc
prompts(nl-full): canonicalize outputs to /; allow small fragment app…
dsarno a27dd38
prompts(nl-full): finalize markdown formatting for guarded write, exe…
dsarno e016171
workflows(nl-suite, mini): header/lint fixes and constrained Bash app…
dsarno 5dad550
prompts(nl-full): format Fast Restore, Guarded Write, Execution, Spec…
dsarno df97ab2
workflows(nl-suite): keep header tidy and append-path alignment with …
dsarno 6a86db3
minor fix
dsarno e0f8a72
workflows(nl-suite): fix indentation and dispatch; align allowed_tool…
dsarno 72987b7
prompts(nl-full): switch to read_resource for buf/sha; re-read only w…
dsarno 2031fcd
workflows(nl-suite): normalize step removes bootstrap when real testc…
dsarno b8e461a
workflows(nl-suite): enrich Markdown summary by extracting per-test <…
dsarno f0b3bba
clarify prompt resilience instructions
dsarno File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Unity NL Editing Suite — Natural Mode | ||
|
||
You are running inside CI for the **unity-mcp** repository. Your task is to demonstrate end‑to‑end **natural‑language code editing** on a representative Unity C# script using whatever capabilities and servers are already available in this session. Work autonomously. Do not ask the user for input. Do NOT spawn subagents, as they will not have access to the mcp server process on the top-level agent. | ||
|
||
## Mission | ||
1) **Discover capabilities.** Quietly inspect the tools and any connected servers that are available to you at session start. If the server offers a primer or capabilities resource, read it before acting. | ||
2) **Choose a target file.** Prefer `TestProjects/UnityMCPTests/Assets/Scripts/LongUnityScriptClaudeTest.cs` if it exists; otherwise choose a simple, safe C# script under `TestProjects/UnityMCPTests/Assets/`. | ||
3) **Perform a small set of realistic edits** using minimal, precise changes (not full-file rewrites). Examples of small edits you may choose from (pick 3–6 total): | ||
- Insert a new, small helper method (e.g., a logger or counter) in a sensible location. | ||
- Add a short anchor comment near a key method (e.g., above `Update()`), then add or modify a few lines nearby. | ||
- Append an end‑of‑class utility method (e.g., formatting or clamping helper). | ||
- Make a safe, localized tweak to an existing method body (e.g., add a guard or a simple accumulator). | ||
- Optionally include one idempotency/no‑op check (re‑apply an edit and confirm nothing breaks). | ||
4) **Validate your edits.** Re‑read the modified regions and verify the changes exist, compile‑risk is low, and surrounding structure remains intact. | ||
5) **Report results.** Produce both: | ||
- A JUnit XML at `reports/junit-nl-suite.xml` containing a single suite named `UnityMCP.NL` with one test case per sub‑test you executed (mark pass/fail and include helpful failure text). | ||
- A summary markdown at `reports/junit-nl-suite.md` that explains what you attempted, what succeeded/failed, and any follow‑ups you would try. | ||
6) **Be gentle and reversible.** Prefer targeted, minimal edits; avoid wide refactors or non‑deterministic changes. | ||
|
||
## Assumptions & Hints (non‑prescriptive) | ||
- A Unity‑oriented MCP server is expected to be connected. If a server‑provided **primer/capabilities** resource exists, read it first. If no primer is available, infer capabilities from your visible tools in the session. | ||
- In CI/headless mode, when calling `mcp__unity__list_resources` or `mcp__unity__read_resource`, include: | ||
- `ctx: {}` | ||
- `project_root: "TestProjects/UnityMCPTests"` (the server will also accept the absolute path passed via env) | ||
Example: `{ "ctx": {}, "under": "Assets/Scripts", "pattern": "*.cs", "project_root": "TestProjects/UnityMCPTests" }` | ||
- If the preferred file isn’t present, locate a fallback C# file with simple, local methods you can edit safely. | ||
- If a compile command is available in this environment, you may optionally trigger it; if not, rely on structural checks and localized validation. | ||
|
||
## Output Requirements (match NL suite conventions) | ||
- JUnit XML at `$JUNIT_OUT` if set, otherwise `reports/junit-nl-suite.xml`. | ||
- Single suite named `UnityMCP.NL`, one `<testcase>` per sub‑test; include `<failure>` on errors. | ||
- Markdown at `$MD_OUT` if set, otherwise `reports/junit-nl-suite.md`. | ||
|
||
Constraints (for fast publishing): | ||
- Log allowed tools once as a single line: `AllowedTools: ...`. | ||
- For every edit: Read → Write (with precondition hash) → Re‑read; on `{status:"stale_file"}` retry once after re‑read. | ||
- Keep evidence to ±20–40 lines windows; cap unified diffs to 300 lines and note truncation. | ||
- End `<system-out>` with `VERDICT: PASS` or `VERDICT: FAIL`. | ||
|
||
## Guardrails | ||
- No destructive operations. Keep changes minimal and well‑scoped. | ||
- Don’t leak secrets or environment details beyond what’s needed in the reports. | ||
- Work without user interaction; do not prompt for approval mid‑flow. | ||
|
||
> If capabilities discovery fails, still produce the two reports that clearly explain why you could not proceed and what evidence you gathered. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
# Unity NL/T Editing Suite — CI Agent Contract | ||
|
||
You are running inside CI for the `unity-mcp` repo. Use only the tools allowed by the workflow. Work autonomously; do not prompt the user. Do NOT spawn subagents. | ||
|
||
### Print this once, verbatim, early in the run | ||
AllowedTools: Write,Bash(printf:*),Bash(echo:*),Bash(scripts/nlt-revert.sh:*),mcp__unity__manage_editor,mcp__unity__list_resources,mcp__unity__read_resource,mcp__unity__apply_text_edits,mcp__unity__script_apply_edits,mcp__unity__validate_script,mcp__unity__find_in_file,mcp__unity__read_console | ||
|
||
--- | ||
|
||
## Mission | ||
1) Pick target file (prefer): | ||
- `unity://path/Assets/Scripts/LongUnityScriptClaudeTest.cs` | ||
2) Execute **all** NL/T tests in order using minimal, precise edits. | ||
3) Validate each edit with `mcp__unity__validate_script(level:"standard")`. | ||
4) **Report**: write one `<testcase>` XML fragment per test to `reports/<TESTID>_results.xml`. Do **not** read or edit `$JUNIT_OUT`. | ||
5) **Restore** the file after each test using the OS‑level helper (fast), not a full‑file text write. | ||
|
||
--- | ||
|
||
## Environment & Paths (CI) | ||
- Always pass: `project_root: "TestProjects/UnityMCPTests"` and `ctx: {}` on list/read/edit/validate. | ||
- **Canonical URIs only**: | ||
- Primary: `unity://path/Assets/...` (never embed `project_root` in the URI) | ||
- Relative (when supported): `Assets/...` | ||
- File paths for the helper script are workspace‑relative: | ||
- `TestProjects/UnityMCPTests/Assets/...` | ||
|
||
CI provides: | ||
- `$JUNIT_OUT=reports/junit-nl-suite.xml` (pre‑created; leave alone) | ||
- `$MD_OUT=reports/junit-nl-suite.md` (synthesized from JUnit) | ||
- Helper script: `scripts/nlt-revert.sh` (snapshot/restore) | ||
|
||
--- | ||
|
||
## Tool Mapping | ||
- **Anchors/regex/structured**: `mcp__unity__script_apply_edits` | ||
- **Precise ranges / atomic batch**: `mcp__unity__apply_text_edits` (non‑overlapping ranges) | ||
- **Validation**: `mcp__unity__validate_script(level:"standard")` | ||
- **Reporting**: `Write` small XML fragments to `reports/*_results.xml` | ||
- **Snapshot/Restore**: `Bash(scripts/nlt-revert.sh:*)` | ||
|
||
> Don’t use `mcp__unity__create_script`. Avoid the header/`using` region entirely. | ||
|
||
--- | ||
### Structured edit ops (required usage) | ||
- For method insertion anchored after `GetCurrentTarget`: use `script_apply_edits` with `{"op":"anchor_insert", "afterMethodName":"GetCurrentTarget", "text": "<code>"}` | ||
- To delete the temporary helper (T‑A/T‑E): **do not** use `anchor_replace`. Prefer: | ||
1) `script_apply_edits` with `{"op":"regex_replace", "pattern":"(?s)^\\s*private\\s+int\\s+__TempHelper\\s*\\(.*?\\)\\s*=>\\s*.*?;\\s*\\r?\\n", "replacement":""}` | ||
2) If that returns `missing_field` or `bad_request`, fallback to `apply_text_edits` with a single `replace_range` computed from the method’s start/end offsets (found by scanning braces). | ||
- If any write returns `missing_field`, `bad_request`, or `unsupported`: **write the testcase fragment anyway** with the error in `<failure>`, mark `VERDICT: FAIL`, then **restore** and proceed to the next test. | ||
- Never call generic Bash like `mkdir`; the revert helper creates needed directories. Do not attempt directory creation; use only `scripts/nlt-revert.sh` for snapshot/restore. | ||
|
||
|
||
## Output Rules (JUnit fragments only) | ||
- For each test, create **one** file: `reports/<TESTID>_results.xml` containing exactly a single `<testcase ...> ... </testcase>`. | ||
- Put human‑readable lines (PLAN/PROGRESS/evidence) **inside** `<system-out><![CDATA[ ... ]]></system-out>`. | ||
- Evidence windows only (±20–40 lines). If showing a unified diff, cap at 100 lines and note truncation. | ||
- **Never** open/patch `$JUNIT_OUT` or `$MD_OUT`; CI merges fragments and synthesizes Markdown. | ||
|
||
**Example fragment** | ||
```xml | ||
<testcase classname="UnityMCP.NL-T" name="NL-1. Method replace/insert/delete"> | ||
<system-out><![CDATA[ | ||
PLAN: NL-0,NL-1,NL-2,NL-3,NL-4,T-A,T-B,T-C,T-D,T-E,T-F,T-G,T-H,T-I,T-J (len=15) | ||
PROGRESS: 2/15 completed | ||
pre_sha=<...> | ||
... evidence windows ... | ||
VERDICT: PASS | ||
]]></system-out> | ||
</testcase> | ||
|
||
``` | ||
|
||
Note: Emit the PLAN line only in NL‑0 (do not repeat it for later tests or later `<system-out>` blocks). | ||
|
||
|
||
### Fast Restore Strategy (OS‑level) | ||
|
||
- Snapshot once at NL‑0, then restore after each test via the helper. | ||
- Snapshot (once after confirming the target): | ||
```bash | ||
scripts/nlt-revert.sh snapshot "TestProjects/UnityMCPTests/Assets/Scripts/LongUnityScriptClaudeTest.cs" "reports/_snapshots/LongUnityScriptClaudeTest.cs.baseline" | ||
``` | ||
- Log `snapshot_sha=...` printed by the script. | ||
- Restore (after each mutating test): | ||
```bash | ||
scripts/nlt-revert.sh restore "TestProjects/UnityMCPTests/Assets/Scripts/LongUnityScriptClaudeTest.cs" "reports/_snapshots/LongUnityScriptClaudeTest.cs.baseline" | ||
``` | ||
- Then `read_resource` to confirm and (optionally) `validate_script(level:"standard")`. | ||
- The helper creates parent directories for the snapshot path if missing. | ||
- If the helper fails: fall back once to a guarded full‑file restore using the baseline bytes; then continue. | ||
|
||
### Guarded Write Pattern (for edits, not restores) | ||
|
||
- Before any mutation: | ||
- Call `mcp__unity__read_resource(uri, project_root, ctx)` and set `buf = res.text` and `pre_sha = res.sha256` (server‑computed over raw on‑disk bytes). | ||
- Write with `precondition_sha256 = pre_sha`. | ||
- On `{status:"stale_file"}`: | ||
- Retry once using a server hash (`data.current_sha256` or `data.expected_sha256`) if present. | ||
- Otherwise perform one `read_resource(...)` to refresh `pre_sha` and retry. No loops. | ||
- After success: | ||
- Prefer not to re‑read. Update `buf` locally; refresh `pre_sha = mcp__unity__read_resource(...).sha256` only when the next step requires exact on‑disk sync (validation, anchor recompute) or before leaving the test. | ||
- Prefer anchors (`script_apply_edits`) for end‑of‑class / above‑method insertions. Keep edits inside method bodies. Avoid header/using. | ||
|
||
### Execution Order (fixed) | ||
|
||
- Run exactly: NL-0, NL-1, NL-2, NL-3, NL-4, T-A, T-B, T-C, T-D, T-E, T-F, T-G, T-H, T-I, T-J (15 total). | ||
- NL‑0 must include the PLAN line (len=15). | ||
- After each testcase, include `PROGRESS: <k>/15 completed`. | ||
|
||
### Test Specs (concise) | ||
|
||
- NL‑0. Sanity reads — Tail ~120; ±40 around `Update()`. Then snapshot via helper. | ||
- NL‑1. Replace/insert/delete — `HasTarget → return currentTarget != null;`; insert `PrintSeries()` after `GetCurrentTarget` logging "1,2,3"; verify; delete `PrintSeries()`; restore. | ||
- NL‑2. Anchor comment — Insert `// Build marker OK` above `public void Update(...)`; restore. | ||
- NL‑3. End‑of‑class — Insert `// Tail test A/B/C` (3 lines) before final brace; restore. | ||
- NL‑4. Compile trigger — Record INFO only. | ||
|
||
- T‑A. Anchor insert (text path) — Insert helper after `GetCurrentTarget`; verify; delete via `regex_replace`; restore. | ||
- T‑B. Replace body — Single `replace_range` inside `HasTarget`; restore. | ||
- T‑C. Header/region preservation — Edit interior of `ApplyBlend`; preserve signature/docs/regions; restore. | ||
- T‑D. End‑of‑class (anchor) — Insert helper before final brace; remove; restore. | ||
- T‑E. Lifecycle — Insert → update → delete via regex; restore. | ||
- T‑F. Atomic batch — One call: two small `replace_range` + one end‑of‑class comment; all‑or‑nothing; restore. | ||
- T‑G. Path normalization — Same edit with `unity://path/Assets/...` then `Assets/...`; second returns `{status:"no_change"}`. | ||
- T‑H. Validation — `standard` after edits; `basic` only for transient checks. | ||
- T‑I. Failure surfaces — Record INFO on `{too_large}`, `{stale_file}`, overlap rejection, validation failure, `{using_guard}`. | ||
- T‑J. Idempotency — Repeat `replace_range` → `{status:"no_change"}`; repeat delete → no‑op. | ||
|
||
### Status & Reporting | ||
|
||
- Safeguard statuses are non‑fatal; record and continue. | ||
- End each testcase `<system-out>` with `VERDICT: PASS` or `VERDICT: FAIL`. |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.