Skip to content

Commit b260e51

Browse files
committed
Merge branch 'unity-tests-fork-backup'
* unity-tests-fork-backup: (26 commits) diag fixes Cleanup Fixes to improve CI testing Add MCP preflight workflow and update NL suite another try Point MCP server to src/server.py and fix preflight Fix YAML indentation for MCP preflight step Use latest claude sonnet/haiku models in workflow Use available Anthropic models for T pass Write Unity logs to file and list config dir in debug Allow Unity config dir writable for MCP heartbeat/logs Mount Unity cache rw and dump Editor log for MCP debug Allow Unity local share writable for MCP status Fail fast when Unity MCP status file missing Add Unity bridge debug step in CI update yaml Fix CI: share unity-mcp status dir update claude haiku version for NL/T tests Harden NL suite prompts for deterministic anchors ...
2 parents a987862 + 482abc5 commit b260e51

File tree

11 files changed

+676
-95
lines changed

11 files changed

+676
-95
lines changed

.claude/prompts/nl-unity-suite-nl.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,25 +103,27 @@ STRICT OP GUARDRAILS
103103
**Goal**: Demonstrate method replacement operations
104104
**Actions**:
105105
- Replace `HasTarget()` method body: `public bool HasTarget() { return currentTarget != null; }`
106-
- Insert `PrintSeries()` method after `GetCurrentTarget()`: `public void PrintSeries() { Debug.Log("1,2,3"); }`
107-
- Verify both methods exist and are properly formatted
106+
- Validate.
107+
- Insert `PrintSeries()` method after a unique anchor method. Prefer `GetCurrentTarget()` if unique; otherwise use another unique method such as `ApplyBlend`. Insert: `public void PrintSeries() { Debug.Log("1,2,3"); }`
108+
- Validate that both methods exist and are properly formatted.
108109
- Delete `PrintSeries()` method (cleanup for next test)
109110
- **Expected final state**: `HasTarget()` modified, file structure intact, no temporary methods
110111

111112
### NL-2. Anchor Comment Insertion (Additive State B)
112113
**Goal**: Demonstrate anchor-based insertions above methods
113114
**Actions**:
114-
- Use `find_in_file` to locate current position of `Update()` method
115+
- Use `find_in_file` with a tolerant anchor to locate the `Update()` method, e.g. `(?m)^\\s*(?:public|private|protected|internal)?\\s*void\\s+Update\\s*\\(\\s*\\)`
116+
- Expect exactly one match; if multiple, fail clearly rather than guessing.
115117
- Insert `// Build marker OK` comment line above `Update()` method
116118
- Verify comment exists and `Update()` still functions
117119
- **Expected final state**: State A + build marker comment above `Update()`
118120

119121
### NL-3. End-of-Class Content (Additive State C)
120-
**Goal**: Demonstrate end-of-class insertions with smart brace matching
122+
**Goal**: Demonstrate end-of-class insertions without ambiguous anchors
121123
**Actions**:
122-
- Match the final class-closing brace by scanning from EOF (e.g., last `^\s*}\s*$`)
123-
or compute via `find_in_file` + ranges; insert immediately before it.
124-
- Insert three comment lines before final class brace:
124+
- Use `find_in_file` to locate brace-only lines (e.g., `(?m)^\\s*}\\s*$`). Select the **last** such line (preferably indentation 0 if multiples).
125+
- Compute an exact insertion point immediately before that last brace using `apply_text_edits` (do not use `anchor_insert` for this step).
126+
- Insert three comment lines before the final class brace:
125127
```
126128
// Tail test A
127129
// Tail test B
@@ -159,7 +161,7 @@ find_in_file(pattern: "public bool HasTarget\\(\\)")
159161

160162
**Anchor-based insertions:**
161163
```json
162-
{"op": "anchor_insert", "anchor": "private void Update\\(\\)", "position": "before", "text": "// comment"}
164+
{"op": "anchor_insert", "anchor": "(?m)^\\s*(?:public|private|protected|internal)?\\s*void\\s+Update\\s*\\(\\s*\\)", "position": "before", "text": "// comment"}
163165
```
164166

165167
---
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Claude MCP Preflight (no Unity)
2+
3+
on: [workflow_dispatch]
4+
5+
permissions:
6+
contents: read
7+
8+
jobs:
9+
mcp-preflight:
10+
runs-on: ubuntu-latest
11+
timeout-minutes: 15
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 0
17+
18+
- uses: astral-sh/setup-uv@v4
19+
with:
20+
python-version: "3.11"
21+
22+
- name: Install MCP server deps
23+
run: |
24+
set -eux
25+
uv venv
26+
echo "VIRTUAL_ENV=$GITHUB_WORKSPACE/.venv" >> "$GITHUB_ENV"
27+
echo "$GITHUB_WORKSPACE/.venv/bin" >> "$GITHUB_PATH"
28+
if [ -f Server/pyproject.toml ]; then
29+
uv pip install -e Server
30+
elif [ -f Server/requirements.txt ]; then
31+
uv pip install -r Server/requirements.txt
32+
else
33+
echo "No MCP Python deps found" >&2
34+
exit 1
35+
fi
36+
37+
- name: Preflight MCP server (stdio)
38+
env:
39+
PYTHONUNBUFFERED: "1"
40+
MCP_LOG_LEVEL: debug
41+
UNITY_PROJECT_ROOT: ${{ github.workspace }}/TestProjects/UnityMCPTests
42+
UNITY_MCP_STATUS_DIR: ${{ github.workspace }}/.unity-mcp-dummy
43+
UNITY_MCP_HOST: 127.0.0.1
44+
run: |
45+
set -euxo pipefail
46+
mkdir -p "$UNITY_MCP_STATUS_DIR"
47+
# Create a dummy status file with an unreachable port; help should not require it
48+
cat > "$UNITY_MCP_STATUS_DIR/unity-mcp-status-dummy.json" <<JSON
49+
{ "unity_port": 0, "reason": "dummy", "reloading": false, "project_path": "$UNITY_PROJECT_ROOT/Assets" }
50+
JSON
51+
uv run --active --directory Server mcp-for-unity --transport stdio --help \
52+
> /tmp/mcp-preflight.log 2>&1 || { cat /tmp/mcp-preflight.log; exit 1; }
53+
cat /tmp/mcp-preflight.log
54+
55+

0 commit comments

Comments
 (0)