@aefree/pi-unity 0.9.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +184 -173
- package/README.md +197 -197
- package/index.ts +1724 -1724
- package/package.json +75 -75
- package/skills/unity-batchmode-tests/SKILL.md +145 -145
- package/skills/unity-interactive-playmode-authoring/SKILL.md +91 -91
- package/skills/unity-pipeline-workflows/SKILL.md +52 -52
- package/src/unity-artifact-profile.ts +110 -110
- package/src/unity-batchmode.ts +355 -355
- package/src/unity-cli.ts +635 -635
- package/src/unity-file-discovery-filter.ts +89 -89
- package/src/unity-pipeline.ts +487 -487
package/package.json
CHANGED
|
@@ -1,75 +1,75 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@aefree/pi-unity",
|
|
3
|
-
"version": "0.9.
|
|
4
|
-
"type": "module",
|
|
5
|
-
"exports": {
|
|
6
|
-
".": "./index.ts"
|
|
7
|
-
},
|
|
8
|
-
"keywords": [
|
|
9
|
-
"pi-package",
|
|
10
|
-
"pi-extension"
|
|
11
|
-
],
|
|
12
|
-
"pi": {
|
|
13
|
-
"extensions": [
|
|
14
|
-
"./index.ts"
|
|
15
|
-
],
|
|
16
|
-
"skills": [
|
|
17
|
-
"./skills"
|
|
18
|
-
]
|
|
19
|
-
},
|
|
20
|
-
"scripts": {
|
|
21
|
-
"test": "tsx tests/unity-core.test.ts && tsx tests/unity-pipeline.test.ts && tsx tests/unity-processes.test.ts && tsx tests/pi-unity-settings.test.ts && tsx tests/unity-projects.test.ts && tsx tests/unity-guidance-audit.test.ts && tsx tests/unity-batchmode.test.ts && tsx tests/unity-test-batch.test.ts && tsx tests/unity-cli.test.ts && tsx tests/unity-project-lock.test.ts && tsx tests/unity-artifact-profile.test.ts && tsx tests/unity-file-discovery-filter.test.ts && tsx tests/unity-registration.test.ts && tsx tests/unity-optional-integrations.test.ts && tsx tests/unity-package-validation.test.ts",
|
|
22
|
-
"eval:guidance-skill": "tsx evals/auditing-unity-agent-guidance/run-eval.ts"
|
|
23
|
-
},
|
|
24
|
-
"dependencies": {
|
|
25
|
-
"typebox": "1.3.8"
|
|
26
|
-
},
|
|
27
|
-
"peerDependencies": {
|
|
28
|
-
"@earendil-works/pi-ai": "*",
|
|
29
|
-
"@earendil-works/pi-coding-agent": "*",
|
|
30
|
-
"@earendil-works/pi-tui": "*",
|
|
31
|
-
"@aefree/pi-project-artifacts": "^0.1.0",
|
|
32
|
-
"@aefree/pi-file-discovery": "^0.1.0"
|
|
33
|
-
},
|
|
34
|
-
"engines": {
|
|
35
|
-
"node": ">=22.19.0"
|
|
36
|
-
},
|
|
37
|
-
"description": "Pi tools and skills for Unity workflows, with optional artifact and file-discovery integrations.",
|
|
38
|
-
"license": "MIT",
|
|
39
|
-
"publishConfig": {
|
|
40
|
-
"access": "public"
|
|
41
|
-
},
|
|
42
|
-
"repository": {
|
|
43
|
-
"type": "git",
|
|
44
|
-
"url": "git+ssh://git@github.com/aefreedman/pi-unity.git"
|
|
45
|
-
},
|
|
46
|
-
"bugs": {
|
|
47
|
-
"url": "https://github.com/aefreedman/pi-unity/issues"
|
|
48
|
-
},
|
|
49
|
-
"homepage": "https://github.com/aefreedman/pi-unity#readme",
|
|
50
|
-
"devDependencies": {
|
|
51
|
-
"@earendil-works/pi-ai": "0.83.0",
|
|
52
|
-
"@earendil-works/pi-coding-agent": "0.83.0",
|
|
53
|
-
"@earendil-works/pi-tui": "0.83.0",
|
|
54
|
-
"@aefree/pi-project-artifacts": "^0.1.0",
|
|
55
|
-
"@aefree/pi-file-discovery": "^0.1.0",
|
|
56
|
-
"tsx": "^4.23.5"
|
|
57
|
-
},
|
|
58
|
-
"peerDependenciesMeta": {
|
|
59
|
-
"@earendil-works/pi-ai": {
|
|
60
|
-
"optional": true
|
|
61
|
-
},
|
|
62
|
-
"@earendil-works/pi-coding-agent": {
|
|
63
|
-
"optional": true
|
|
64
|
-
},
|
|
65
|
-
"@earendil-works/pi-tui": {
|
|
66
|
-
"optional": true
|
|
67
|
-
},
|
|
68
|
-
"@aefree/pi-project-artifacts": {
|
|
69
|
-
"optional": true
|
|
70
|
-
},
|
|
71
|
-
"@aefree/pi-file-discovery": {
|
|
72
|
-
"optional": true
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@aefree/pi-unity",
|
|
3
|
+
"version": "0.9.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"exports": {
|
|
6
|
+
".": "./index.ts"
|
|
7
|
+
},
|
|
8
|
+
"keywords": [
|
|
9
|
+
"pi-package",
|
|
10
|
+
"pi-extension"
|
|
11
|
+
],
|
|
12
|
+
"pi": {
|
|
13
|
+
"extensions": [
|
|
14
|
+
"./index.ts"
|
|
15
|
+
],
|
|
16
|
+
"skills": [
|
|
17
|
+
"./skills"
|
|
18
|
+
]
|
|
19
|
+
},
|
|
20
|
+
"scripts": {
|
|
21
|
+
"test": "tsx tests/unity-core.test.ts && tsx tests/unity-pipeline.test.ts && tsx tests/unity-processes.test.ts && tsx tests/pi-unity-settings.test.ts && tsx tests/unity-projects.test.ts && tsx tests/unity-guidance-audit.test.ts && tsx tests/unity-batchmode.test.ts && tsx tests/unity-test-batch.test.ts && tsx tests/unity-cli.test.ts && tsx tests/unity-project-lock.test.ts && tsx tests/unity-artifact-profile.test.ts && tsx tests/unity-file-discovery-filter.test.ts && tsx tests/unity-registration.test.ts && tsx tests/unity-optional-integrations.test.ts && tsx tests/unity-package-validation.test.ts",
|
|
22
|
+
"eval:guidance-skill": "tsx evals/auditing-unity-agent-guidance/run-eval.ts"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"typebox": "1.3.8"
|
|
26
|
+
},
|
|
27
|
+
"peerDependencies": {
|
|
28
|
+
"@earendil-works/pi-ai": "*",
|
|
29
|
+
"@earendil-works/pi-coding-agent": "*",
|
|
30
|
+
"@earendil-works/pi-tui": "*",
|
|
31
|
+
"@aefree/pi-project-artifacts": "^0.1.0",
|
|
32
|
+
"@aefree/pi-file-discovery": "^0.1.0"
|
|
33
|
+
},
|
|
34
|
+
"engines": {
|
|
35
|
+
"node": ">=22.19.0"
|
|
36
|
+
},
|
|
37
|
+
"description": "Pi tools and skills for Unity workflows, with optional artifact and file-discovery integrations.",
|
|
38
|
+
"license": "MIT",
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public"
|
|
41
|
+
},
|
|
42
|
+
"repository": {
|
|
43
|
+
"type": "git",
|
|
44
|
+
"url": "git+ssh://git@github.com/aefreedman/pi-unity.git"
|
|
45
|
+
},
|
|
46
|
+
"bugs": {
|
|
47
|
+
"url": "https://github.com/aefreedman/pi-unity/issues"
|
|
48
|
+
},
|
|
49
|
+
"homepage": "https://github.com/aefreedman/pi-unity#readme",
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@earendil-works/pi-ai": "0.83.0",
|
|
52
|
+
"@earendil-works/pi-coding-agent": "0.83.0",
|
|
53
|
+
"@earendil-works/pi-tui": "0.83.0",
|
|
54
|
+
"@aefree/pi-project-artifacts": "^0.1.0",
|
|
55
|
+
"@aefree/pi-file-discovery": "^0.1.0",
|
|
56
|
+
"tsx": "^4.23.5"
|
|
57
|
+
},
|
|
58
|
+
"peerDependenciesMeta": {
|
|
59
|
+
"@earendil-works/pi-ai": {
|
|
60
|
+
"optional": true
|
|
61
|
+
},
|
|
62
|
+
"@earendil-works/pi-coding-agent": {
|
|
63
|
+
"optional": true
|
|
64
|
+
},
|
|
65
|
+
"@earendil-works/pi-tui": {
|
|
66
|
+
"optional": true
|
|
67
|
+
},
|
|
68
|
+
"@aefree/pi-project-artifacts": {
|
|
69
|
+
"optional": true
|
|
70
|
+
},
|
|
71
|
+
"@aefree/pi-file-discovery": {
|
|
72
|
+
"optional": true
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -1,145 +1,145 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: unity-batchmode-tests
|
|
3
|
-
description: Run isolated/report-producing Unity Test Framework EditMode/PlayMode tests through Unity CLI or direct Editor batchmode. Use for CI, NUnit XML evidence, closed projects, or when connected Pipeline testing is unavailable; not the default for an already-open reachable Pipeline Editor.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Unity Batchmode Tests
|
|
7
|
-
|
|
8
|
-
Run Unity Test Framework tests from the command line without opening the Editor GUI.
|
|
9
|
-
|
|
10
|
-
## Critical Warnings
|
|
11
|
-
|
|
12
|
-
- **Inspect the exact project copy first** - call `unity_project_status`; if that copy is already open with reachable Pipeline test commands, prefer the connected workflow instead of closing it for batchmode.
|
|
13
|
-
- **Never pass `-quit` with `-runTests`** - Unity exits immediately before tests complete, producing no results file.
|
|
14
|
-
- **Use absolute paths** for `-testResults` and `-logFile` to ensure logs are easy to find.
|
|
15
|
-
- **Unity allows only one process per project folder** - GUI Editor and batchmode/headless both count as that one process.
|
|
16
|
-
- **Do not open the GUI editor for the same project before or during batchmode runs** - `/unity-open` and `unity_open_editor` launch the full Unity Editor GUI and are not equivalent to headless batchmode.
|
|
17
|
-
- **Do not close a reachable Pipeline Editor merely to run tests** - an already-open exact copy can run supported tests through `run_tests` plus `test_status`; use the `unity-pipeline-workflows` skill.
|
|
18
|
-
- **Only close a blocking Unity Editor through `unity_launch_batchmode` safeguards after deliberately choosing isolated execution** - this is limited to cases such as required NUnit XML, unsupported connected filters/commands, or explicit isolation. Use `closeBlockingUnityProcess: true` only when `unity_project_status` shows `piUnity.allowCloseRunningUnityProcess` is enabled or the user explicitly says it is enabled; pi-unity re-scans the resolved project and never accepts arbitrary PIDs.
|
|
19
|
-
- **Use `unity_launch_batchmode` when you want to run headless Unity directly** - keep test-specific flags deliberate, especially around `-runTests` and `-quit`.
|
|
20
|
-
- **Bundle tests into one Unity batchmode turn whenever practical** - starting/stopping Unity, importing assets, and domain reloads dominate runtime. A broader single run is usually faster than many sequential one-test Unity launches, and same-project runs cannot use useful parallelism.
|
|
21
|
-
- **Default to headless/no-graphics validation** - `unity_launch_batchmode` adds `-nographics` by default to reduce focus stealing and unnecessary graphics initialization.
|
|
22
|
-
- **Distinguish graphics-agnostic test runs from graphics-required visual runs** - screenshot, render-texture, and other visual-capture tests require an active graphics device and must not use `-nographics`.
|
|
23
|
-
- **Only request graphics when required by the user's work** - set `useGraphics: true` only for screenshots, visual capture, render checks, or graphics-dependent PlayMode tests.
|
|
24
|
-
- **Do not treat a graphics-disabled run as valid evidence for screenshot workflows** - graphics-required tests should fail clearly or be excluded from that run.
|
|
25
|
-
|
|
26
|
-
## Validation Scope and Stop Rules
|
|
27
|
-
|
|
28
|
-
- Explicit user instructions and project guidance to skip PlayMode tests override generic validation defaults. Record PlayMode as intentionally skipped; do not launch it anyway to seek extra evidence.
|
|
29
|
-
- Treat project-required compile validation and relevant EditMode tests as the baseline when they apply. PlayMode is additional evidence only when the user requests it, project/review guidance requires it, or the behavior cannot be validated honestly outside PlayMode.
|
|
30
|
-
- Plan and bundle the applicable evidence before launching Unity. Do not turn validation into an open-ended sequence of one-test processes.
|
|
31
|
-
- After a timeout, hang, missing-results infrastructure failure, or killed Unity process, call `unity_inspect_artifacts` once with the exact current-run `-testResults`/`-logFile` paths and `latestFromLogs: false`, then stop relaunching. Do not use an older "latest" artifact as evidence for the failed run. Retry only when there is a new, stated hypothesis that changes the command/environment, or the user explicitly requests another attempt.
|
|
32
|
-
- A failing product assertion may justify a targeted rerun after an implementation change. An unchanged infrastructure failure does not.
|
|
33
|
-
- Treat a completed test run as passing evidence only when its parsed results report a known positive executed-test count and no failures. Zero, omitted, or otherwise unknown totals are non-passing even when Unity exits zero.
|
|
34
|
-
- Report required evidence as passed, failed, intentionally skipped, or blocked. Never imply an unrun PlayMode check passed.
|
|
35
|
-
|
|
36
|
-
## Workflow
|
|
37
|
-
|
|
38
|
-
### 1. Prefer the packaged Unity tools
|
|
39
|
-
|
|
40
|
-
Use the `pi-unity` tools first instead of forming raw Unity CLI commands on the fly:
|
|
41
|
-
- `unity_project_status` to inspect lockfile/process state without launching Unity
|
|
42
|
-
- `unity_inspect_artifacts` to summarize existing Unity logs/test XML without launching Unity
|
|
43
|
-
- `unity_run_test_batch` for isolated/report-producing Unity Test Framework runs with one platform and bundled filters/categories
|
|
44
|
-
- `unity_launch_batchmode` for custom headless Unity execution that needs raw Editor arguments
|
|
45
|
-
- `unity_open_editor` only when the user explicitly wants the GUI Editor
|
|
46
|
-
- `/unity-open` as the user-facing GUI launcher helper
|
|
47
|
-
|
|
48
|
-
`unity_run_test_batch` should be the default for isolated or report-producing Unity Test Framework work. It generates unique absolute XML/log paths under the project `Logs` directory, normalizes filter/category arrays into one launch, omits `-quit`, and uses the same guarded executor as `unity_launch_batchmode`. For an already-open reachable exact-copy Pipeline Editor, use the `unity-pipeline-workflows` skill instead.
|
|
49
|
-
|
|
50
|
-
`unity_launch_batchmode` remains the default for custom agent-run headless Unity work because it already:
|
|
51
|
-
- resolves the Unity project from a direct project root, a coordination root, or another nearby folder
|
|
52
|
-
- reads `ProjectSettings/ProjectVersion.txt`
|
|
53
|
-
- prefers the installed `unity run` CLI when available, falling back to OS-aware direct editor launch
|
|
54
|
-
- uses OS-aware standard install probing
|
|
55
|
-
- supports explicit `UNITY_EDITOR_PATH` / `unityEditorPath` overrides
|
|
56
|
-
- strips direct-Editor flags managed by `unity run` (`-batchmode`, `-projectPath`, `-quit`) before forwarding args in Unity CLI mode
|
|
57
|
-
- supports `launcher: "editor-executable"` when Unity CLI argument forwarding differs from direct Editor executable behavior
|
|
58
|
-
- checks Unity CLI status and running Unity processes before launch
|
|
59
|
-
- can close same-project blocking Unity processes only when `closeBlockingUnityProcess: true` is set and `piUnity.allowCloseRunningUnityProcess` is enabled in Pi settings; by default this is limited to Unity Test Framework runs
|
|
60
|
-
- may remove the exact resolved project's stale `Temp/UnityLockfile` after a guarded same-call process close, but only after verifying no matching Unity process remains
|
|
61
|
-
- delegates stale native `Temp/UnityLockfile` handling to `unity run` when the Unity CLI launcher is selected; direct Editor executable mode still blocks on native lockfiles for safety unless pi-unity just created the stale-lockfile condition through a guarded close
|
|
62
|
-
- uses a Pi-side project mutex so duplicate packaged batchmode calls fail before spawning Unity
|
|
63
|
-
- can summarize Unity Test Framework results compactly when `-testResults` and `-logFile` are provided
|
|
64
|
-
|
|
65
|
-
After a failed run, prefer `unity_inspect_artifacts` for follow-up inspection of existing result XML/log files instead of ad hoc `bash`/`sed`/Python parsing. This avoids shell quoting mistakes and does not start another Unity process.
|
|
66
|
-
|
|
67
|
-
If a launch is blocked by a native Unity lockfile, call `unity_project_status` before asking the user to remove anything. Only fall back to direct CLI commands if the packaged Unity tools are unavailable or fail to resolve the environment correctly.
|
|
68
|
-
|
|
69
|
-
### 2. Get the Project's Unity Version
|
|
70
|
-
|
|
71
|
-
If you are in direct CLI fallback mode, read `ProjectSettings/ProjectVersion.txt` in the Unity project root:
|
|
72
|
-
|
|
73
|
-
```
|
|
74
|
-
m_EditorVersion: ####.#.#f#
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
### 3. Find the Unity Executable
|
|
78
|
-
|
|
79
|
-
If you are in direct CLI fallback mode, check these locations based on platform and version:
|
|
80
|
-
|
|
81
|
-
**Windows:**
|
|
82
|
-
```
|
|
83
|
-
C:\Program Files\Unity\Hub\Editor\<version>\Editor\Unity.exe
|
|
84
|
-
C:\Program Files\Unity\<version>\Editor\Unity.exe
|
|
85
|
-
C:\UnityInstalls\<version>\Editor\Unity.exe
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
**macOS:**
|
|
89
|
-
```
|
|
90
|
-
/Applications/Unity/Hub/Editor/<version>/Unity.app/Contents/MacOS/Unity
|
|
91
|
-
/Applications/Unity/<version>/Unity.app/Contents/MacOS/Unity
|
|
92
|
-
/Applications/Unity*
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
If not found, ask the user for their Unity install path.
|
|
96
|
-
|
|
97
|
-
### 4. Choose the execution route, then run tests
|
|
98
|
-
|
|
99
|
-
Route before planning a batch:
|
|
100
|
-
1. Call `unity_project_status` for the exact project copy.
|
|
101
|
-
2. If that copy is already open, Pipeline is reachable, and `run_tests` plus `test_status` are advertised, use `unity-pipeline-workflows`; do not close the Editor or invoke `unity_run_test_batch` merely because the test tool is more convenient.
|
|
102
|
-
3. Choose isolated `unity_run_test_batch` only when the Editor is closed, connected testing is unavailable, CI/isolation is intentional, required filters are unsupported, or NUnit XML/log artifacts are required. State the reason.
|
|
103
|
-
4. If project state is uncertain, stop rather than closing the Editor or starting batchmode.
|
|
104
|
-
|
|
105
|
-
After choosing the isolated route:
|
|
106
|
-
- plan the full validation batch before launching Unity
|
|
107
|
-
- bundle all tests that can share the same project, `-testPlatform`, and graphics mode into one `unity_launch_batchmode` call
|
|
108
|
-
- when several specific tests are relevant, prefer a broader class/namespace/suite/category filter, or no `-testFilter` for the affected platform, over separate Unity launches
|
|
109
|
-
- use a single-test launch only for a quick smoke check or to isolate/rerun a known failure; do not use one-test launches as the default validation strategy
|
|
110
|
-
- do not queue multiple `unity_launch_batchmode` calls back-to-back in one agent turn; wait for the structured summary, inspect failures, and only then decide whether another Unity launch is necessary
|
|
111
|
-
- call `unity_run_test_batch` for isolated/report-producing tests; use `unity_launch_batchmode` only when custom raw Unity arguments are required
|
|
112
|
-
- pass one `testPlatform` (`EditMode` or `PlayMode`) and bundle applicable `testFilters`/`testCategories`; empty arrays mean all tests on that platform
|
|
113
|
-
- use the generated exact result/log paths from the tool report for any follow-up artifact inspection
|
|
114
|
-
- pass `closeBlockingUnityProcess: true` only after connected testing was ruled out or isolated evidence was explicitly required, a same-project Unity process is blocking the chosen run, and Pi settings enable `piUnity.allowCloseRunningUnityProcess`
|
|
115
|
-
- prefer `launcher: "auto"` or `launcher: "unity-cli"` when using `closeBlockingUnityProcess: true`; force `launcher: "editor-executable"` only when direct Editor execution is explicitly required
|
|
116
|
-
- pass the explicit test arguments needed for the bundled run
|
|
117
|
-
- rely on the tool to remove direct-Editor lifecycle flags (`-batchmode`, `-projectPath`, `-quit`) before forwarding args through `unity run`
|
|
118
|
-
- use `launcher: "editor-executable"` if the installed `unity run` wrapper rejects or changes another argument that works with direct Editor batchmode
|
|
119
|
-
- always provide absolute `-testResults` and `-logFile` paths when practical so the tool can summarize results compactly for the agent
|
|
120
|
-
- keep test-specific flags deliberate, especially around `-runTests` and `-quit`
|
|
121
|
-
- decide up front whether the run is graphics-agnostic or graphics-required
|
|
122
|
-
- rely on the default `useGraphics: false` / `-nographics` mode for ordinary EditMode, non-visual PlayMode, asset import, build, and CI-style checks
|
|
123
|
-
- set `useGraphics: true` only when the requested work requires an active graphics device
|
|
124
|
-
- exclude graphics-required screenshot/visual-capture tests from no-graphics runs
|
|
125
|
-
- prefer project test categories such as `RequiresGraphics` / `VisualCapture` when the project exposes them
|
|
126
|
-
|
|
127
|
-
Direct CLI fallback templates:
|
|
128
|
-
```
|
|
129
|
-
unity test "<ProjectPath>" --mode <EditMode|PlayMode> --filter "<Full.Test.Name>" --output "<ResultsPath>" -- -logFile "<LogPath>"
|
|
130
|
-
"<UnityEditorPath>" -batchmode -nographics -projectPath "<ProjectPath>" -runTests -testPlatform <EditMode|PlayMode> -testFilter "<Full.Test.Name>" -testResults "<ResultsPath>" -logFile "<LogPath>"
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
Fallback parameters:
|
|
134
|
-
- `-testPlatform`: `EditMode` or `PlayMode`
|
|
135
|
-
- `-testFilter`: Full test name (e.g., `MyNamespace.MyTests.TestMethodName`)
|
|
136
|
-
- `-testCategory`: Optional category filter when the project uses NUnit categories for routing runs such as `RequiresGraphics`
|
|
137
|
-
- `-testResults`: Absolute path for XML results (e.g., `<ProjectPath>/Logs/test-results.xml`)
|
|
138
|
-
- `-logFile`: Absolute path for log output (e.g., `<ProjectPath>/Logs/test-run.log`)
|
|
139
|
-
|
|
140
|
-
## Project-Specific Configuration
|
|
141
|
-
|
|
142
|
-
Check the project's `AGENTS.md` for:
|
|
143
|
-
- Recommended log output locations
|
|
144
|
-
- Common test namespaces/filters
|
|
145
|
-
- Any project-specific testing notes
|
|
1
|
+
---
|
|
2
|
+
name: unity-batchmode-tests
|
|
3
|
+
description: Run isolated/report-producing Unity Test Framework EditMode/PlayMode tests through Unity CLI or direct Editor batchmode. Use for CI, NUnit XML evidence, closed projects, or when connected Pipeline testing is unavailable; not the default for an already-open reachable Pipeline Editor.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Unity Batchmode Tests
|
|
7
|
+
|
|
8
|
+
Run Unity Test Framework tests from the command line without opening the Editor GUI.
|
|
9
|
+
|
|
10
|
+
## Critical Warnings
|
|
11
|
+
|
|
12
|
+
- **Inspect the exact project copy first** - call `unity_project_status`; if that copy is already open with reachable Pipeline test commands, prefer the connected workflow instead of closing it for batchmode.
|
|
13
|
+
- **Never pass `-quit` with `-runTests`** - Unity exits immediately before tests complete, producing no results file.
|
|
14
|
+
- **Use absolute paths** for `-testResults` and `-logFile` to ensure logs are easy to find.
|
|
15
|
+
- **Unity allows only one process per project folder** - GUI Editor and batchmode/headless both count as that one process.
|
|
16
|
+
- **Do not open the GUI editor for the same project before or during batchmode runs** - `/unity-open` and `unity_open_editor` launch the full Unity Editor GUI and are not equivalent to headless batchmode.
|
|
17
|
+
- **Do not close a reachable Pipeline Editor merely to run tests** - an already-open exact copy can run supported tests through `run_tests` plus `test_status`; use the `unity-pipeline-workflows` skill.
|
|
18
|
+
- **Only close a blocking Unity Editor through `unity_launch_batchmode` safeguards after deliberately choosing isolated execution** - this is limited to cases such as required NUnit XML, unsupported connected filters/commands, or explicit isolation. Use `closeBlockingUnityProcess: true` only when `unity_project_status` shows `piUnity.allowCloseRunningUnityProcess` is enabled or the user explicitly says it is enabled; pi-unity re-scans the resolved project and never accepts arbitrary PIDs.
|
|
19
|
+
- **Use `unity_launch_batchmode` when you want to run headless Unity directly** - keep test-specific flags deliberate, especially around `-runTests` and `-quit`.
|
|
20
|
+
- **Bundle tests into one Unity batchmode turn whenever practical** - starting/stopping Unity, importing assets, and domain reloads dominate runtime. A broader single run is usually faster than many sequential one-test Unity launches, and same-project runs cannot use useful parallelism.
|
|
21
|
+
- **Default to headless/no-graphics validation** - `unity_launch_batchmode` adds `-nographics` by default to reduce focus stealing and unnecessary graphics initialization.
|
|
22
|
+
- **Distinguish graphics-agnostic test runs from graphics-required visual runs** - screenshot, render-texture, and other visual-capture tests require an active graphics device and must not use `-nographics`.
|
|
23
|
+
- **Only request graphics when required by the user's work** - set `useGraphics: true` only for screenshots, visual capture, render checks, or graphics-dependent PlayMode tests.
|
|
24
|
+
- **Do not treat a graphics-disabled run as valid evidence for screenshot workflows** - graphics-required tests should fail clearly or be excluded from that run.
|
|
25
|
+
|
|
26
|
+
## Validation Scope and Stop Rules
|
|
27
|
+
|
|
28
|
+
- Explicit user instructions and project guidance to skip PlayMode tests override generic validation defaults. Record PlayMode as intentionally skipped; do not launch it anyway to seek extra evidence.
|
|
29
|
+
- Treat project-required compile validation and relevant EditMode tests as the baseline when they apply. PlayMode is additional evidence only when the user requests it, project/review guidance requires it, or the behavior cannot be validated honestly outside PlayMode.
|
|
30
|
+
- Plan and bundle the applicable evidence before launching Unity. Do not turn validation into an open-ended sequence of one-test processes.
|
|
31
|
+
- After a timeout, hang, missing-results infrastructure failure, or killed Unity process, call `unity_inspect_artifacts` once with the exact current-run `-testResults`/`-logFile` paths and `latestFromLogs: false`, then stop relaunching. Do not use an older "latest" artifact as evidence for the failed run. Retry only when there is a new, stated hypothesis that changes the command/environment, or the user explicitly requests another attempt.
|
|
32
|
+
- A failing product assertion may justify a targeted rerun after an implementation change. An unchanged infrastructure failure does not.
|
|
33
|
+
- Treat a completed test run as passing evidence only when its parsed results report a known positive executed-test count and no failures. Zero, omitted, or otherwise unknown totals are non-passing even when Unity exits zero.
|
|
34
|
+
- Report required evidence as passed, failed, intentionally skipped, or blocked. Never imply an unrun PlayMode check passed.
|
|
35
|
+
|
|
36
|
+
## Workflow
|
|
37
|
+
|
|
38
|
+
### 1. Prefer the packaged Unity tools
|
|
39
|
+
|
|
40
|
+
Use the `pi-unity` tools first instead of forming raw Unity CLI commands on the fly:
|
|
41
|
+
- `unity_project_status` to inspect lockfile/process state without launching Unity
|
|
42
|
+
- `unity_inspect_artifacts` to summarize existing Unity logs/test XML without launching Unity
|
|
43
|
+
- `unity_run_test_batch` for isolated/report-producing Unity Test Framework runs with one platform and bundled filters/categories
|
|
44
|
+
- `unity_launch_batchmode` for custom headless Unity execution that needs raw Editor arguments
|
|
45
|
+
- `unity_open_editor` only when the user explicitly wants the GUI Editor
|
|
46
|
+
- `/unity-open` as the user-facing GUI launcher helper
|
|
47
|
+
|
|
48
|
+
`unity_run_test_batch` should be the default for isolated or report-producing Unity Test Framework work. It generates unique absolute XML/log paths under the project `Logs` directory, normalizes filter/category arrays into one launch, omits `-quit`, and uses the same guarded executor as `unity_launch_batchmode`. For an already-open reachable exact-copy Pipeline Editor, use the `unity-pipeline-workflows` skill instead.
|
|
49
|
+
|
|
50
|
+
`unity_launch_batchmode` remains the default for custom agent-run headless Unity work because it already:
|
|
51
|
+
- resolves the Unity project from a direct project root, a coordination root, or another nearby folder
|
|
52
|
+
- reads `ProjectSettings/ProjectVersion.txt`
|
|
53
|
+
- prefers the installed `unity run` CLI when available, falling back to OS-aware direct editor launch
|
|
54
|
+
- uses OS-aware standard install probing
|
|
55
|
+
- supports explicit `UNITY_EDITOR_PATH` / `unityEditorPath` overrides
|
|
56
|
+
- strips direct-Editor flags managed by `unity run` (`-batchmode`, `-projectPath`, `-quit`) before forwarding args in Unity CLI mode
|
|
57
|
+
- supports `launcher: "editor-executable"` when Unity CLI argument forwarding differs from direct Editor executable behavior
|
|
58
|
+
- checks Unity CLI status and running Unity processes before launch
|
|
59
|
+
- can close same-project blocking Unity processes only when `closeBlockingUnityProcess: true` is set and `piUnity.allowCloseRunningUnityProcess` is enabled in Pi settings; by default this is limited to Unity Test Framework runs
|
|
60
|
+
- may remove the exact resolved project's stale `Temp/UnityLockfile` after a guarded same-call process close, but only after verifying no matching Unity process remains
|
|
61
|
+
- delegates stale native `Temp/UnityLockfile` handling to `unity run` when the Unity CLI launcher is selected; direct Editor executable mode still blocks on native lockfiles for safety unless pi-unity just created the stale-lockfile condition through a guarded close
|
|
62
|
+
- uses a Pi-side project mutex so duplicate packaged batchmode calls fail before spawning Unity
|
|
63
|
+
- can summarize Unity Test Framework results compactly when `-testResults` and `-logFile` are provided
|
|
64
|
+
|
|
65
|
+
After a failed run, prefer `unity_inspect_artifacts` for follow-up inspection of existing result XML/log files instead of ad hoc `bash`/`sed`/Python parsing. This avoids shell quoting mistakes and does not start another Unity process.
|
|
66
|
+
|
|
67
|
+
If a launch is blocked by a native Unity lockfile, call `unity_project_status` before asking the user to remove anything. Only fall back to direct CLI commands if the packaged Unity tools are unavailable or fail to resolve the environment correctly.
|
|
68
|
+
|
|
69
|
+
### 2. Get the Project's Unity Version
|
|
70
|
+
|
|
71
|
+
If you are in direct CLI fallback mode, read `ProjectSettings/ProjectVersion.txt` in the Unity project root:
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
m_EditorVersion: ####.#.#f#
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### 3. Find the Unity Executable
|
|
78
|
+
|
|
79
|
+
If you are in direct CLI fallback mode, check these locations based on platform and version:
|
|
80
|
+
|
|
81
|
+
**Windows:**
|
|
82
|
+
```
|
|
83
|
+
C:\Program Files\Unity\Hub\Editor\<version>\Editor\Unity.exe
|
|
84
|
+
C:\Program Files\Unity\<version>\Editor\Unity.exe
|
|
85
|
+
C:\UnityInstalls\<version>\Editor\Unity.exe
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
**macOS:**
|
|
89
|
+
```
|
|
90
|
+
/Applications/Unity/Hub/Editor/<version>/Unity.app/Contents/MacOS/Unity
|
|
91
|
+
/Applications/Unity/<version>/Unity.app/Contents/MacOS/Unity
|
|
92
|
+
/Applications/Unity*
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
If not found, ask the user for their Unity install path.
|
|
96
|
+
|
|
97
|
+
### 4. Choose the execution route, then run tests
|
|
98
|
+
|
|
99
|
+
Route before planning a batch:
|
|
100
|
+
1. Call `unity_project_status` for the exact project copy.
|
|
101
|
+
2. If that copy is already open, Pipeline is reachable, and `run_tests` plus `test_status` are advertised, use `unity-pipeline-workflows`; do not close the Editor or invoke `unity_run_test_batch` merely because the test tool is more convenient.
|
|
102
|
+
3. Choose isolated `unity_run_test_batch` only when the Editor is closed, connected testing is unavailable, CI/isolation is intentional, required filters are unsupported, or NUnit XML/log artifacts are required. State the reason.
|
|
103
|
+
4. If project state is uncertain, stop rather than closing the Editor or starting batchmode.
|
|
104
|
+
|
|
105
|
+
After choosing the isolated route:
|
|
106
|
+
- plan the full validation batch before launching Unity
|
|
107
|
+
- bundle all tests that can share the same project, `-testPlatform`, and graphics mode into one `unity_launch_batchmode` call
|
|
108
|
+
- when several specific tests are relevant, prefer a broader class/namespace/suite/category filter, or no `-testFilter` for the affected platform, over separate Unity launches
|
|
109
|
+
- use a single-test launch only for a quick smoke check or to isolate/rerun a known failure; do not use one-test launches as the default validation strategy
|
|
110
|
+
- do not queue multiple `unity_launch_batchmode` calls back-to-back in one agent turn; wait for the structured summary, inspect failures, and only then decide whether another Unity launch is necessary
|
|
111
|
+
- call `unity_run_test_batch` for isolated/report-producing tests; use `unity_launch_batchmode` only when custom raw Unity arguments are required
|
|
112
|
+
- pass one `testPlatform` (`EditMode` or `PlayMode`) and bundle applicable `testFilters`/`testCategories`; empty arrays mean all tests on that platform
|
|
113
|
+
- use the generated exact result/log paths from the tool report for any follow-up artifact inspection
|
|
114
|
+
- pass `closeBlockingUnityProcess: true` only after connected testing was ruled out or isolated evidence was explicitly required, a same-project Unity process is blocking the chosen run, and Pi settings enable `piUnity.allowCloseRunningUnityProcess`
|
|
115
|
+
- prefer `launcher: "auto"` or `launcher: "unity-cli"` when using `closeBlockingUnityProcess: true`; force `launcher: "editor-executable"` only when direct Editor execution is explicitly required
|
|
116
|
+
- pass the explicit test arguments needed for the bundled run
|
|
117
|
+
- rely on the tool to remove direct-Editor lifecycle flags (`-batchmode`, `-projectPath`, `-quit`) before forwarding args through `unity run`
|
|
118
|
+
- use `launcher: "editor-executable"` if the installed `unity run` wrapper rejects or changes another argument that works with direct Editor batchmode
|
|
119
|
+
- always provide absolute `-testResults` and `-logFile` paths when practical so the tool can summarize results compactly for the agent
|
|
120
|
+
- keep test-specific flags deliberate, especially around `-runTests` and `-quit`
|
|
121
|
+
- decide up front whether the run is graphics-agnostic or graphics-required
|
|
122
|
+
- rely on the default `useGraphics: false` / `-nographics` mode for ordinary EditMode, non-visual PlayMode, asset import, build, and CI-style checks
|
|
123
|
+
- set `useGraphics: true` only when the requested work requires an active graphics device
|
|
124
|
+
- exclude graphics-required screenshot/visual-capture tests from no-graphics runs
|
|
125
|
+
- prefer project test categories such as `RequiresGraphics` / `VisualCapture` when the project exposes them
|
|
126
|
+
|
|
127
|
+
Direct CLI fallback templates:
|
|
128
|
+
```
|
|
129
|
+
unity test "<ProjectPath>" --mode <EditMode|PlayMode> --filter "<Full.Test.Name>" --output "<ResultsPath>" -- -logFile "<LogPath>"
|
|
130
|
+
"<UnityEditorPath>" -batchmode -nographics -projectPath "<ProjectPath>" -runTests -testPlatform <EditMode|PlayMode> -testFilter "<Full.Test.Name>" -testResults "<ResultsPath>" -logFile "<LogPath>"
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Fallback parameters:
|
|
134
|
+
- `-testPlatform`: `EditMode` or `PlayMode`
|
|
135
|
+
- `-testFilter`: Full test name (e.g., `MyNamespace.MyTests.TestMethodName`)
|
|
136
|
+
- `-testCategory`: Optional category filter when the project uses NUnit categories for routing runs such as `RequiresGraphics`
|
|
137
|
+
- `-testResults`: Absolute path for XML results (e.g., `<ProjectPath>/Logs/test-results.xml`)
|
|
138
|
+
- `-logFile`: Absolute path for log output (e.g., `<ProjectPath>/Logs/test-run.log`)
|
|
139
|
+
|
|
140
|
+
## Project-Specific Configuration
|
|
141
|
+
|
|
142
|
+
Check the project's `AGENTS.md` for:
|
|
143
|
+
- Recommended log output locations
|
|
144
|
+
- Common test namespaces/filters
|
|
145
|
+
- Any project-specific testing notes
|