@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/README.md
CHANGED
|
@@ -1,197 +1,197 @@
|
|
|
1
|
-
# Pi Unity
|
|
2
|
-
|
|
3
|
-
Pi skill and tool package for reusable Unity workflows.
|
|
4
|
-
|
|
5
|
-
## Contents
|
|
6
|
-
|
|
7
|
-
- skill: `unity-debugging`
|
|
8
|
-
- skill: `unity-pipeline-workflows`
|
|
9
|
-
- skill: `unity-batchmode-tests`
|
|
10
|
-
- skill: `unity-interactive-playmode-authoring`
|
|
11
|
-
- skill: `auditing-unity-agent-guidance`
|
|
12
|
-
- tool: `unity_guidance_audit`
|
|
13
|
-
- tool: `unity_project_status`
|
|
14
|
-
- tool: `unity_pipeline_recompile`
|
|
15
|
-
- tool: `unity_pipeline_run_tests`
|
|
16
|
-
- tool: `unity_pipeline_eval`
|
|
17
|
-
- tool: `unity_pipeline_inspect`
|
|
18
|
-
- tool: `unity_inspect_artifacts`
|
|
19
|
-
- tool: `unity_open_editor`
|
|
20
|
-
- tool: `unity_launch_batchmode`
|
|
21
|
-
- tool: `unity_run_test_batch`
|
|
22
|
-
- commands: `/unity-open`, `/unity-playmode-exit`
|
|
23
|
-
|
|
24
|
-
## Skill boundaries
|
|
25
|
-
|
|
26
|
-
Each packaged skill owns a distinct kind of Unity work:
|
|
27
|
-
|
|
28
|
-
- `unity-debugging` owns reusable diagnostic strategy across Editor, runtime, package, asset, lifecycle, callback, and feature-activation problems.
|
|
29
|
-
- `unity-pipeline-workflows` owns connected compilation and focused test execution through an already-running exact-copy Pipeline Editor.
|
|
30
|
-
- `unity-batchmode-tests` owns isolated or report-producing Unity Test Framework execution.
|
|
31
|
-
- `unity-interactive-playmode-authoring` owns explicit temporary inspection and tuning of live runtime state, followed by deliberate persistence when requested.
|
|
32
|
-
- `auditing-unity-agent-guidance` owns review and migration of project-local Unity automation instructions.
|
|
33
|
-
|
|
34
|
-
Operation-specific failure handling remains with the owning operational skill. `unity-debugging` owns reusable diagnostic strategy, not every troubleshooting instruction associated with Unity operations.
|
|
35
|
-
|
|
36
|
-
## Install
|
|
37
|
-
|
|
38
|
-
From GitHub:
|
|
39
|
-
|
|
40
|
-
```bash
|
|
41
|
-
pi install git:git@github.com:aefreedman/pi-unity.git
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
Local development install:
|
|
45
|
-
|
|
46
|
-
```bash
|
|
47
|
-
pi install <path-to-pi-unity>
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
Project-local install:
|
|
51
|
-
|
|
52
|
-
```bash
|
|
53
|
-
pi install -l <path-to-pi-unity>
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
## Notes
|
|
57
|
-
|
|
58
|
-
- Pi discovers packaged skills from `skills/` and extensions from `index.ts`.
|
|
59
|
-
- `unity-debugging` provides general-purpose, evidence-first Unity diagnosis. For inactive features it routes agents through exact-version documentation, documented feature gates, and observable activation signals before project code, reflection, assembly searches, or Unity internals. Its UI Toolkit example checks the Game View Live Reload setting before callback diagnosis.
|
|
60
|
-
- `@aefree/pi-project-artifacts` and `@aefree/pi-file-discovery` are independent optional peer integrations. When their Pi tools are active, pi-unity uses the capability contracts' global registry rendezvous to register a Unity solution-artifact profile candidate and/or generated-directory file-discovery filter. It never resolves optional peers from pi-unity's own module root, so separately installed Git/local packages compose correctly. Core Unity tools load without them; an advertised malformed registry contract fails visibly. Registrations are scoped, reverse-load-order safe, transactional across active integrations, and a delayed old-session shutdown cannot remove another scope's current records. Project artifacts remains schema-open: the Unity profile contributes applicability, definitions, validation, and confidence only; Unity metadata remains raw-filterable when this provider is absent. Provider development follows the [project-artifacts profile-provider contract](https://github.com/aefreedman/pi-project-artifacts/blob/main/docs/artifact-profile-providers.md).
|
|
61
|
-
- The Unity filter recommends excluding `Library`, `Temp`, `Logs`, `obj`, `Build`, `Builds`, `UserSettings`, and `.vs` from broad project-root discovery. Broad exclusions declare `filterDecision: "applied"` with decision code `unity_broad_generated_directories_applied`; an exact generated or `Library/PackageCache/...` root is searched with the explicit `filterDecision: "bypassed"` code `unity_exact_generated_root_bypassed`, rather than a compatibility sentinel glob. File-discovery filter failures degrade discovery filtering rather than authorizing or blocking inspection; the canonical file-discovery package remains Unity-neutral.
|
|
62
|
-
- The optional artifact profile describes `engine`, `unity_version`, `unity_packages`, `render_pipeline`, and `platforms` for solution and memory artifacts. Every field is optional; present fields receive type/enum validation while undeclared project metadata remains open. Artifact paths already distinguish solutions from memories, and evolving project vocabulary belongs in generic `tags`, `module`, or `component` fields rather than a Unity-owned document taxonomy. The profile contributes only when the workspace has Unity `ProjectVersion.txt` evidence, so a conventional artifact path never selects it by itself.
|
|
63
|
-
- `unity_guidance_audit` performs a bounded, read-only scan of AGENTS.md, CLAUDE.md, Copilot, and Cursor guidance for outdated Unity CLI/Pipeline, batchmode, test, lifecycle, and exact-project-copy instructions. The `auditing-unity-agent-guidance` skill owns contextual migration and user-authorized edits.
|
|
64
|
-
- `unity_open_editor` launches the full Unity Editor GUI.
|
|
65
|
-
- `unity_open_editor` prefers the installed `unity open` CLI when available, falling back to direct editor executable launch.
|
|
66
|
-
- `unity_project_status` reports native Unity lockfile state, Unity CLI status output, running Unity processes, the locally declared `com.unity.pipeline` version, exact-project-copy Pipeline instances, and bounded live advertised commands without launching Unity. Pipeline discovery has distinct `absent`, `timeout`, and `unavailable` states; a timeout is startup uncertainty rather than proof of absence. Rendered process command lines redact access tokens and credential-like values.
|
|
67
|
-
- `unity_inspect_artifacts` summarizes existing Unity Test Framework XML results and Unity logs without launching Unity, reducing ad hoc shell parsing after failures.
|
|
68
|
-
- Planning and test routing preserve the exact project copy: a reachable Pipeline Editor is a positive connected inspection surface, and the project should run connected tests without closing the Editor or replacing it with a second Editor. Other connected operations use that same exact copy. `unity_pipeline_eval` rechecks canonical identity and advertised `eval` immediately before dispatch and is the general REPL escape hatch for project-specific properties and questions that registered commands did not anticipate. `unity_pipeline_inspect` exposes the package-owned purpose-built inspection commands when their structured results fit the question. Tooling should bound the request and result, preserve exact-copy evidence, and distinguish reads from mutations—not maintain a brittle API-property allowlist or pretend arbitrary C# can be proven read-only from syntax alone.
|
|
69
|
-
- `unity-pipeline-workflows` routes focused connected work through `unity_pipeline_recompile` and `unity_pipeline_run_tests`. Each performs exact-copy preflight, advertised-command checks, lifecycle inspection, identity-aware bounded internal polling, and compact output in one model-visible call. `unity_pipeline_recompile` never preemptively sends `editor_stop`: while Play Mode is active it honors Unity's Script Changes While Playing policy (continue, stop-and-recompile, or defer) when future `editor_status` payloads expose it, and reports unavailable policy as uncertainty. Connected tests retain a separate explicit lifecycle guard. Pipeline `no_tests`/idle status is treated as safe pre-dispatch inactivity rather than uncertainty. Timeouts are uncertain and do not cancel, retry, close Unity, or switch to batchmode. Connected tests do not inherently produce NUnit XML.
|
|
70
|
-
- `unity_run_test_batch` is the preferred isolated/report-producing Unity Test Framework entry point, not a reason to close a reachable Pipeline Editor. Choose it for a closed project, intentional CI isolation, category/multiple filters unsupported by the single connected test-name filter, or required NUnit XML/log artifacts. It runs exactly one EditMode or PlayMode batch, combines filter/category arrays into one launch, creates collision-safe absolute XML/log paths under the project `Logs` directory, omits `-quit`, and uses the same guarded launcher as `unity_launch_batchmode`.
|
|
71
|
-
- `unity_launch_batchmode` prefers the installed `unity run` CLI when available, falling back to direct editor executable batchmode launch; use it when custom raw Editor arguments are required.
|
|
72
|
-
- `unity_launch_batchmode` adds `-nographics` by default to avoid unnecessary graphics initialization and reduce focus stealing; set `useGraphics: true` only for screenshots, visual capture, render checks, or graphics-dependent PlayMode tests.
|
|
73
|
-
- Unity GUI, generic batchmode, and test-batch tools expose `launcher` (`auto`, `unity-cli`, or `editor-executable`) so workflows can force direct Editor execution when Unity CLI argument handling differs from `Unity.exe`/`Unity`. Every launch route keeps same-project process verification and a per-project mutex; unknown process state blocks launch. Direct Editor execution blocks native lockfiles, while Unity CLI may handle a stale lockfile only after pi-unity verifies no matching project process.
|
|
74
|
-
- In Unity CLI mode, `unity_launch_batchmode` forwards args after `unity run <project> --` and strips direct-Editor flags managed by the CLI (`-batchmode`, `-projectPath`, `-quit`).
|
|
75
|
-
- `unity_run_test_batch`, `unity_launch_batchmode`, and `unity_inspect_artifacts` require parsed Unity Test Framework results to report a known positive executed-test count and no failures before treating them as passing evidence. Zero-test, unknown-total, missing-result, malformed-result, and failing batches are non-passing; full artifacts remain on disk while session details retain bounded excerpts and byte counts.
|
|
76
|
-
- Validation guidance treats explicit user/project PlayMode skips as authoritative, distinguishes baseline compile/EditMode evidence from optional PlayMode evidence, and stops unchanged relaunch loops after hangs or infrastructure failures in favor of one inspection of the exact current-run artifact paths.
|
|
77
|
-
- `unity_launch_batchmode` uses Unity CLI status and direct process scans before launch. In Unity CLI mode, stale native `Temp/UnityLockfile` detection is delegated to `unity run`; direct Editor executable mode still blocks on the native lockfile for safety. A Pi-side project mutex prevents duplicate packaged batchmode calls from spawning Unity concurrently.
|
|
78
|
-
- `unity_launch_batchmode` can close a same-project blocking Unity process only when isolated execution was deliberately selected, the tool call sets `closeBlockingUnityProcess: true`, and Pi settings enable `piUnity.allowCloseRunningUnityProcess`. Do not use this to replace reachable connected Pipeline testing. The tool re-scans and selects matching Unity processes itself; it never accepts a model-supplied PID.
|
|
79
|
-
- After a guarded same-call close, `unity_launch_batchmode` may remove the exact resolved project's stale `Temp/UnityLockfile` only after verifying no matching Unity process remains. It still refuses general lockfile deletion outside that guarded continuation.
|
|
80
|
-
- When using `closeBlockingUnityProcess: true`, prefer `launcher: "auto"` or `launcher: "unity-cli"`; force `launcher: "editor-executable"` only when direct Editor execution is explicitly required.
|
|
81
|
-
- If a Unity launch is blocked by a lockfile, run `unity_project_status` before asking a user to remove anything.
|
|
82
|
-
- `/unity-open` is the user-facing GUI launcher helper.
|
|
83
|
-
- The package resolves Unity project copies from a direct project root, a coordination root containing multiple copies, or another nearby folder. Pipeline routing validates canonical project-path identity after CLI discovery so similarly named copies are not treated as interchangeable; connected commands always receive the exact resolved project path.
|
|
84
|
-
- Installing and starting `com.unity.pipeline@0.3.1-exp.1` is a broader project mutation than adding its manifest entry: its server startup assigns `Application.runInBackground = true`, which Unity persists as `PlayerSettings.runInBackground` in `ProjectSettings/ProjectSettings.asset`. Review that tracked change alongside `manifest.json` and `packages-lock.json`.
|
|
85
|
-
- Unity install probing is OS-aware and avoids machine-specific assumptions by using the project's `ProjectSettings/ProjectVersion.txt`, the optional `unity` CLI, standard per-OS install locations, and optional `UNITY_EDITOR_PATH` overrides.
|
|
86
|
-
- Unity allows only one process per project folder; GUI and batchmode both count.
|
|
87
|
-
- The `unity-batchmode-tests` skill is intended for Unity Test Framework CLI runs.
|
|
88
|
-
- Keep skill-specific references and helper assets under the skill directory beside `SKILL.md`.
|
|
89
|
-
|
|
90
|
-
## Connected Pipeline and `eval` policy
|
|
91
|
-
|
|
92
|
-
Registered Pipeline commands are ergonomic shortcuts for anticipated workflows. Advertised `eval` covers the operations and inspections that were not anticipated: it compiles C# with Roslyn, runs it on the connected Editor's main thread, and returns the result. This is a live REPL into the exact running project, not merely a restricted planning expression evaluator.
|
|
93
|
-
|
|
94
|
-
Use the registered `unity_pipeline_eval` tool with bounded C# `code`, for example:
|
|
95
|
-
|
|
96
|
-
```text
|
|
97
|
-
{ code: "return UnityEditor.EditorSettings.scriptChangesDuringPlay;" }
|
|
98
|
-
{ code: "var s = UnityEngine.Application.dataPath; return s.Length;" }
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
Use `unity_pipeline_inspect` for purpose-built connected reads such as `editor_status` or `get_scene_hierarchy`; eval is intentionally owned only by `unity_pipeline_eval`.
|
|
102
|
-
|
|
103
|
-
Because `eval` reaches the same engine and Editor APIs as project code, its security token and exact-copy identity are meaningful trust boundaries. A static snippet allowlist is not: ordinary property getters can call code, while apparently simple expressions can still have side effects. Pi-unity therefore treats declared task intent as the boundary: regular inspection through `unity_pipeline_eval` is allowed; mutations must match the user's request; lifecycle, destructive, persistent-setting, asset, scene-save, package, build, and test changes require the same explicit authorization they would through a typed command. Typed tools remain preferred when they provide better validation, polling, compact evidence, or recovery semantics, but they are assistance rather than exclusive gateways. Results and diagnostics remain bounded, and an uncertain dispatch is never silently retried through another route.
|
|
104
|
-
|
|
105
|
-
## Settings
|
|
106
|
-
|
|
107
|
-
`pi-unity` reads optional package-specific settings from global `~/.pi/agent/settings.json` and, for trusted projects, project `.pi/settings.json`:
|
|
108
|
-
|
|
109
|
-
```json
|
|
110
|
-
{
|
|
111
|
-
"piUnity": {
|
|
112
|
-
"allowCloseRunningUnityProcess": false,
|
|
113
|
-
"closeRunningUnityProcessOnlyForTests": true,
|
|
114
|
-
"closeRunningUnityProcessTimeoutMs": 30000
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
- `allowCloseRunningUnityProcess` defaults to `false`. When enabled, `unity_launch_batchmode` may close only Unity processes that target the resolved project and only when the tool call explicitly sets `closeBlockingUnityProcess: true`.
|
|
120
|
-
- `closeRunningUnityProcessOnlyForTests` defaults to `true`, limiting process closure to Unity Test Framework launches (`-runTests`).
|
|
121
|
-
- `closeRunningUnityProcessTimeoutMs` defaults to `30000` and is clamped between 1000 and 120000 milliseconds.
|
|
122
|
-
|
|
123
|
-
Autonomous Play Mode exit is a separate session-scoped toggle and defaults to disallowed. Use `/unity-playmode-exit allow` only to authorize package-owned typed lifecycle operations that may exit Play Mode, `/unity-playmode-exit disallow` to restore the default, or `/unity-playmode-exit status` to inspect it. `unity_pipeline_recompile` never sends `editor_stop` and does not override Unity's Script Changes While Playing preference: a known continue/defer policy needs no exit authorization, a known stop-and-recompile policy does, and a missing policy is conservatively treated as potentially exiting. `unity_pipeline_run_tests` retains its separate verified `editor_stop` lifecycle path when authorized. The choice is recorded in the current session branch so it survives reload/resume, but it is not a global or project setting. Output/details identify explicit agent exit separately from Unity-policy-driven or unavailable-policy behavior; pi-unity never enters Play Mode autonomously.
|
|
124
|
-
|
|
125
|
-
## Skill evaluation
|
|
126
|
-
|
|
127
|
-
The `auditing-unity-agent-guidance` skill has an opt-in behavioral eval under `evals/auditing-unity-agent-guidance/`. It runs isolated fixtures through Pi, checks triggering, filesystem outcomes, instruction fidelity, and tool-call efficiency, and can compare skill-enabled runs with a no-skill baseline. Because it invokes an agent and may incur provider costs, it is not part of `npm test`.
|
|
128
|
-
|
|
129
|
-
```bash
|
|
130
|
-
npm run eval:guidance-skill -- --cases audit_legacy_instructions,migrate_mixed_harness_guidance,unrelated_typescript_review
|
|
131
|
-
npm run eval:guidance-skill -- --condition both --trials 3
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
See `evals/auditing-unity-agent-guidance/README.md` for the rubric.
|
|
135
|
-
|
|
136
|
-
## Package layout
|
|
137
|
-
|
|
138
|
-
```text
|
|
139
|
-
pi-unity/
|
|
140
|
-
index.ts
|
|
141
|
-
src/
|
|
142
|
-
unity-core.ts
|
|
143
|
-
unity-batchmode.ts
|
|
144
|
-
unity-cli.ts
|
|
145
|
-
unity-launch.ts
|
|
146
|
-
unity-processes.ts
|
|
147
|
-
unity-project-lock.ts
|
|
148
|
-
unity-projects.ts
|
|
149
|
-
skills/
|
|
150
|
-
unity-debugging/
|
|
151
|
-
SKILL.md
|
|
152
|
-
auditing-unity-agent-guidance/
|
|
153
|
-
SKILL.md
|
|
154
|
-
references/
|
|
155
|
-
assets/
|
|
156
|
-
unity-pipeline-workflows/
|
|
157
|
-
SKILL.md
|
|
158
|
-
unity-batchmode-tests/
|
|
159
|
-
SKILL.md
|
|
160
|
-
tests/
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
## Optional artifact metadata
|
|
164
|
-
|
|
165
|
-
When `@aefree/pi-project-artifacts` is also active in a Unity workspace, solution and memory Markdown may use the following profile-enriched fields:
|
|
166
|
-
|
|
167
|
-
```yaml
|
|
168
|
-
---
|
|
169
|
-
engine: unity
|
|
170
|
-
unity_version: "6000.0"
|
|
171
|
-
unity_packages:
|
|
172
|
-
- com.unity.inputsystem
|
|
173
|
-
render_pipeline: urp
|
|
174
|
-
platforms:
|
|
175
|
-
- windows
|
|
176
|
-
- android
|
|
177
|
-
---
|
|
178
|
-
```
|
|
179
|
-
|
|
180
|
-
Supported `render_pipeline` values are `builtin`, `urp`, `hdrp`, `custom`, and `agnostic`. Keep `unity_version` quoted because Unity versions are identifiers rather than numeric values. Omit inapplicable fields instead of adding placeholders. These fields improve exact retrieval and diagnostics but are not required for indexing or raw filtering.
|
|
181
|
-
|
|
182
|
-
## Testing
|
|
183
|
-
|
|
184
|
-
```bash
|
|
185
|
-
npm test
|
|
186
|
-
npm pack --dry-run
|
|
187
|
-
```
|
|
188
|
-
|
|
189
|
-
The package declares optional peer integrations for `@aefree/pi-project-artifacts` and `@aefree/pi-file-discovery`; install only the integrations needed for artifact profiles or file-discovery filtering. The standalone Unity tools and skills do not require them. The package archive contains no copied dependency tree, sibling `file:` path, or workspace link.
|
|
190
|
-
|
|
191
|
-
## Release status
|
|
192
|
-
|
|
193
|
-
A registry-clean `package-lock.json` is committed, optional development packages resolve from the public registry, and the manifest is prepared for public scoped publication. Publishing remains a separate manual operation requiring npm authentication and explicit authorization.
|
|
194
|
-
|
|
195
|
-
## License
|
|
196
|
-
|
|
197
|
-
MIT. See `LICENSE`.
|
|
1
|
+
# Pi Unity
|
|
2
|
+
|
|
3
|
+
Pi skill and tool package for reusable Unity workflows.
|
|
4
|
+
|
|
5
|
+
## Contents
|
|
6
|
+
|
|
7
|
+
- skill: `unity-debugging`
|
|
8
|
+
- skill: `unity-pipeline-workflows`
|
|
9
|
+
- skill: `unity-batchmode-tests`
|
|
10
|
+
- skill: `unity-interactive-playmode-authoring`
|
|
11
|
+
- skill: `auditing-unity-agent-guidance`
|
|
12
|
+
- tool: `unity_guidance_audit`
|
|
13
|
+
- tool: `unity_project_status`
|
|
14
|
+
- tool: `unity_pipeline_recompile`
|
|
15
|
+
- tool: `unity_pipeline_run_tests`
|
|
16
|
+
- tool: `unity_pipeline_eval`
|
|
17
|
+
- tool: `unity_pipeline_inspect`
|
|
18
|
+
- tool: `unity_inspect_artifacts`
|
|
19
|
+
- tool: `unity_open_editor`
|
|
20
|
+
- tool: `unity_launch_batchmode`
|
|
21
|
+
- tool: `unity_run_test_batch`
|
|
22
|
+
- commands: `/unity-open`, `/unity-playmode-exit`
|
|
23
|
+
|
|
24
|
+
## Skill boundaries
|
|
25
|
+
|
|
26
|
+
Each packaged skill owns a distinct kind of Unity work:
|
|
27
|
+
|
|
28
|
+
- `unity-debugging` owns reusable diagnostic strategy across Editor, runtime, package, asset, lifecycle, callback, and feature-activation problems.
|
|
29
|
+
- `unity-pipeline-workflows` owns connected compilation and focused test execution through an already-running exact-copy Pipeline Editor.
|
|
30
|
+
- `unity-batchmode-tests` owns isolated or report-producing Unity Test Framework execution.
|
|
31
|
+
- `unity-interactive-playmode-authoring` owns explicit temporary inspection and tuning of live runtime state, followed by deliberate persistence when requested.
|
|
32
|
+
- `auditing-unity-agent-guidance` owns review and migration of project-local Unity automation instructions.
|
|
33
|
+
|
|
34
|
+
Operation-specific failure handling remains with the owning operational skill. `unity-debugging` owns reusable diagnostic strategy, not every troubleshooting instruction associated with Unity operations.
|
|
35
|
+
|
|
36
|
+
## Install
|
|
37
|
+
|
|
38
|
+
From GitHub:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
pi install git:git@github.com:aefreedman/pi-unity.git
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Local development install:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
pi install <path-to-pi-unity>
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Project-local install:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
pi install -l <path-to-pi-unity>
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Notes
|
|
57
|
+
|
|
58
|
+
- Pi discovers packaged skills from `skills/` and extensions from `index.ts`.
|
|
59
|
+
- `unity-debugging` provides general-purpose, evidence-first Unity diagnosis. For inactive features it routes agents through exact-version documentation, documented feature gates, and observable activation signals before project code, reflection, assembly searches, or Unity internals. Its UI Toolkit example checks the Game View Live Reload setting before callback diagnosis.
|
|
60
|
+
- `@aefree/pi-project-artifacts` and `@aefree/pi-file-discovery` are independent optional peer integrations. When their Pi tools are active, pi-unity uses the capability contracts' global registry rendezvous to register a Unity solution-artifact profile candidate and/or generated-directory file-discovery filter. It never resolves optional peers from pi-unity's own module root, so separately installed Git/local packages compose correctly. Core Unity tools load without them; an advertised malformed registry contract fails visibly. Registrations are scoped, reverse-load-order safe, transactional across active integrations, and a delayed old-session shutdown cannot remove another scope's current records. Project artifacts remains schema-open: the Unity profile contributes applicability, definitions, validation, and confidence only; Unity metadata remains raw-filterable when this provider is absent. Provider development follows the [project-artifacts profile-provider contract](https://github.com/aefreedman/pi-project-artifacts/blob/main/docs/artifact-profile-providers.md).
|
|
61
|
+
- The Unity filter recommends excluding `Library`, `Temp`, `Logs`, `obj`, `Build`, `Builds`, `UserSettings`, and `.vs` from broad project-root discovery. Broad exclusions declare `filterDecision: "applied"` with decision code `unity_broad_generated_directories_applied`; an exact generated or `Library/PackageCache/...` root is searched with the explicit `filterDecision: "bypassed"` code `unity_exact_generated_root_bypassed`, rather than a compatibility sentinel glob. File-discovery filter failures degrade discovery filtering rather than authorizing or blocking inspection; the canonical file-discovery package remains Unity-neutral.
|
|
62
|
+
- The optional artifact profile describes `engine`, `unity_version`, `unity_packages`, `render_pipeline`, and `platforms` for solution and memory artifacts. Every field is optional; present fields receive type/enum validation while undeclared project metadata remains open. Artifact paths already distinguish solutions from memories, and evolving project vocabulary belongs in generic `tags`, `module`, or `component` fields rather than a Unity-owned document taxonomy. The profile contributes only when the workspace has Unity `ProjectVersion.txt` evidence, so a conventional artifact path never selects it by itself.
|
|
63
|
+
- `unity_guidance_audit` performs a bounded, read-only scan of AGENTS.md, CLAUDE.md, Copilot, and Cursor guidance for outdated Unity CLI/Pipeline, batchmode, test, lifecycle, and exact-project-copy instructions. The `auditing-unity-agent-guidance` skill owns contextual migration and user-authorized edits.
|
|
64
|
+
- `unity_open_editor` launches the full Unity Editor GUI.
|
|
65
|
+
- `unity_open_editor` prefers the installed `unity open` CLI when available, falling back to direct editor executable launch.
|
|
66
|
+
- `unity_project_status` reports native Unity lockfile state, Unity CLI status output, running Unity processes, the locally declared `com.unity.pipeline` version, exact-project-copy Pipeline instances, and bounded live advertised commands without launching Unity. Pipeline discovery has distinct `absent`, `timeout`, and `unavailable` states; a timeout is startup uncertainty rather than proof of absence. Rendered process command lines redact access tokens and credential-like values.
|
|
67
|
+
- `unity_inspect_artifacts` summarizes existing Unity Test Framework XML results and Unity logs without launching Unity, reducing ad hoc shell parsing after failures.
|
|
68
|
+
- Planning and test routing preserve the exact project copy: a reachable Pipeline Editor is a positive connected inspection surface, and the project should run connected tests without closing the Editor or replacing it with a second Editor. Other connected operations use that same exact copy. `unity_pipeline_eval` rechecks canonical identity and advertised `eval` immediately before dispatch and is the general REPL escape hatch for project-specific properties and questions that registered commands did not anticipate. `unity_pipeline_inspect` exposes the package-owned purpose-built inspection commands when their structured results fit the question. Tooling should bound the request and result, preserve exact-copy evidence, and distinguish reads from mutations—not maintain a brittle API-property allowlist or pretend arbitrary C# can be proven read-only from syntax alone.
|
|
69
|
+
- `unity-pipeline-workflows` routes focused connected work through `unity_pipeline_recompile` and `unity_pipeline_run_tests`. Each performs exact-copy preflight, advertised-command checks, lifecycle inspection, identity-aware bounded internal polling, and compact output in one model-visible call. `unity_pipeline_recompile` never preemptively sends `editor_stop`: while Play Mode is active it honors Unity's Script Changes While Playing policy (continue, stop-and-recompile, or defer) when future `editor_status` payloads expose it, and reports unavailable policy as uncertainty. Connected tests retain a separate explicit lifecycle guard. Pipeline `no_tests`/idle status is treated as safe pre-dispatch inactivity rather than uncertainty. Timeouts are uncertain and do not cancel, retry, close Unity, or switch to batchmode. Connected tests do not inherently produce NUnit XML.
|
|
70
|
+
- `unity_run_test_batch` is the preferred isolated/report-producing Unity Test Framework entry point, not a reason to close a reachable Pipeline Editor. Choose it for a closed project, intentional CI isolation, category/multiple filters unsupported by the single connected test-name filter, or required NUnit XML/log artifacts. It runs exactly one EditMode or PlayMode batch, combines filter/category arrays into one launch, creates collision-safe absolute XML/log paths under the project `Logs` directory, omits `-quit`, and uses the same guarded launcher as `unity_launch_batchmode`.
|
|
71
|
+
- `unity_launch_batchmode` prefers the installed `unity run` CLI when available, falling back to direct editor executable batchmode launch; use it when custom raw Editor arguments are required.
|
|
72
|
+
- `unity_launch_batchmode` adds `-nographics` by default to avoid unnecessary graphics initialization and reduce focus stealing; set `useGraphics: true` only for screenshots, visual capture, render checks, or graphics-dependent PlayMode tests.
|
|
73
|
+
- Unity GUI, generic batchmode, and test-batch tools expose `launcher` (`auto`, `unity-cli`, or `editor-executable`) so workflows can force direct Editor execution when Unity CLI argument handling differs from `Unity.exe`/`Unity`. Every launch route keeps same-project process verification and a per-project mutex; unknown process state blocks launch. Direct Editor execution blocks native lockfiles, while Unity CLI may handle a stale lockfile only after pi-unity verifies no matching project process.
|
|
74
|
+
- In Unity CLI mode, `unity_launch_batchmode` forwards args after `unity run <project> --` and strips direct-Editor flags managed by the CLI (`-batchmode`, `-projectPath`, `-quit`).
|
|
75
|
+
- `unity_run_test_batch`, `unity_launch_batchmode`, and `unity_inspect_artifacts` require parsed Unity Test Framework results to report a known positive executed-test count and no failures before treating them as passing evidence. Zero-test, unknown-total, missing-result, malformed-result, and failing batches are non-passing; full artifacts remain on disk while session details retain bounded excerpts and byte counts.
|
|
76
|
+
- Validation guidance treats explicit user/project PlayMode skips as authoritative, distinguishes baseline compile/EditMode evidence from optional PlayMode evidence, and stops unchanged relaunch loops after hangs or infrastructure failures in favor of one inspection of the exact current-run artifact paths.
|
|
77
|
+
- `unity_launch_batchmode` uses Unity CLI status and direct process scans before launch. In Unity CLI mode, stale native `Temp/UnityLockfile` detection is delegated to `unity run`; direct Editor executable mode still blocks on the native lockfile for safety. A Pi-side project mutex prevents duplicate packaged batchmode calls from spawning Unity concurrently.
|
|
78
|
+
- `unity_launch_batchmode` can close a same-project blocking Unity process only when isolated execution was deliberately selected, the tool call sets `closeBlockingUnityProcess: true`, and Pi settings enable `piUnity.allowCloseRunningUnityProcess`. Do not use this to replace reachable connected Pipeline testing. The tool re-scans and selects matching Unity processes itself; it never accepts a model-supplied PID.
|
|
79
|
+
- After a guarded same-call close, `unity_launch_batchmode` may remove the exact resolved project's stale `Temp/UnityLockfile` only after verifying no matching Unity process remains. It still refuses general lockfile deletion outside that guarded continuation.
|
|
80
|
+
- When using `closeBlockingUnityProcess: true`, prefer `launcher: "auto"` or `launcher: "unity-cli"`; force `launcher: "editor-executable"` only when direct Editor execution is explicitly required.
|
|
81
|
+
- If a Unity launch is blocked by a lockfile, run `unity_project_status` before asking a user to remove anything.
|
|
82
|
+
- `/unity-open` is the user-facing GUI launcher helper.
|
|
83
|
+
- The package resolves Unity project copies from a direct project root, a coordination root containing multiple copies, or another nearby folder. Pipeline routing validates canonical project-path identity after CLI discovery so similarly named copies are not treated as interchangeable; connected commands always receive the exact resolved project path.
|
|
84
|
+
- Installing and starting `com.unity.pipeline@0.3.1-exp.1` is a broader project mutation than adding its manifest entry: its server startup assigns `Application.runInBackground = true`, which Unity persists as `PlayerSettings.runInBackground` in `ProjectSettings/ProjectSettings.asset`. Review that tracked change alongside `manifest.json` and `packages-lock.json`.
|
|
85
|
+
- Unity install probing is OS-aware and avoids machine-specific assumptions by using the project's `ProjectSettings/ProjectVersion.txt`, the optional `unity` CLI, standard per-OS install locations, and optional `UNITY_EDITOR_PATH` overrides.
|
|
86
|
+
- Unity allows only one process per project folder; GUI and batchmode both count.
|
|
87
|
+
- The `unity-batchmode-tests` skill is intended for Unity Test Framework CLI runs.
|
|
88
|
+
- Keep skill-specific references and helper assets under the skill directory beside `SKILL.md`.
|
|
89
|
+
|
|
90
|
+
## Connected Pipeline and `eval` policy
|
|
91
|
+
|
|
92
|
+
Registered Pipeline commands are ergonomic shortcuts for anticipated workflows. Advertised `eval` covers the operations and inspections that were not anticipated: it compiles C# with Roslyn, runs it on the connected Editor's main thread, and returns the result. This is a live REPL into the exact running project, not merely a restricted planning expression evaluator.
|
|
93
|
+
|
|
94
|
+
Use the registered `unity_pipeline_eval` tool with bounded C# `code`, for example:
|
|
95
|
+
|
|
96
|
+
```text
|
|
97
|
+
{ code: "return UnityEditor.EditorSettings.scriptChangesDuringPlay;" }
|
|
98
|
+
{ code: "var s = UnityEngine.Application.dataPath; return s.Length;" }
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Use `unity_pipeline_inspect` for purpose-built connected reads such as `editor_status` or `get_scene_hierarchy`; eval is intentionally owned only by `unity_pipeline_eval`.
|
|
102
|
+
|
|
103
|
+
Because `eval` reaches the same engine and Editor APIs as project code, its security token and exact-copy identity are meaningful trust boundaries. A static snippet allowlist is not: ordinary property getters can call code, while apparently simple expressions can still have side effects. Pi-unity therefore treats declared task intent as the boundary: regular inspection through `unity_pipeline_eval` is allowed; mutations must match the user's request; lifecycle, destructive, persistent-setting, asset, scene-save, package, build, and test changes require the same explicit authorization they would through a typed command. Typed tools remain preferred when they provide better validation, polling, compact evidence, or recovery semantics, but they are assistance rather than exclusive gateways. Results and diagnostics remain bounded, and an uncertain dispatch is never silently retried through another route.
|
|
104
|
+
|
|
105
|
+
## Settings
|
|
106
|
+
|
|
107
|
+
`pi-unity` reads optional package-specific settings from global `~/.pi/agent/settings.json` and, for trusted projects, project `.pi/settings.json`:
|
|
108
|
+
|
|
109
|
+
```json
|
|
110
|
+
{
|
|
111
|
+
"piUnity": {
|
|
112
|
+
"allowCloseRunningUnityProcess": false,
|
|
113
|
+
"closeRunningUnityProcessOnlyForTests": true,
|
|
114
|
+
"closeRunningUnityProcessTimeoutMs": 30000
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
- `allowCloseRunningUnityProcess` defaults to `false`. When enabled, `unity_launch_batchmode` may close only Unity processes that target the resolved project and only when the tool call explicitly sets `closeBlockingUnityProcess: true`.
|
|
120
|
+
- `closeRunningUnityProcessOnlyForTests` defaults to `true`, limiting process closure to Unity Test Framework launches (`-runTests`).
|
|
121
|
+
- `closeRunningUnityProcessTimeoutMs` defaults to `30000` and is clamped between 1000 and 120000 milliseconds.
|
|
122
|
+
|
|
123
|
+
Autonomous Play Mode exit is a separate session-scoped toggle and defaults to disallowed. Use `/unity-playmode-exit allow` only to authorize package-owned typed lifecycle operations that may exit Play Mode, `/unity-playmode-exit disallow` to restore the default, or `/unity-playmode-exit status` to inspect it. `unity_pipeline_recompile` never sends `editor_stop` and does not override Unity's Script Changes While Playing preference: a known continue/defer policy needs no exit authorization, a known stop-and-recompile policy does, and a missing policy is conservatively treated as potentially exiting. `unity_pipeline_run_tests` retains its separate verified `editor_stop` lifecycle path when authorized. The choice is recorded in the current session branch so it survives reload/resume, but it is not a global or project setting. Output/details identify explicit agent exit separately from Unity-policy-driven or unavailable-policy behavior; pi-unity never enters Play Mode autonomously.
|
|
124
|
+
|
|
125
|
+
## Skill evaluation
|
|
126
|
+
|
|
127
|
+
The `auditing-unity-agent-guidance` skill has an opt-in behavioral eval under `evals/auditing-unity-agent-guidance/`. It runs isolated fixtures through Pi, checks triggering, filesystem outcomes, instruction fidelity, and tool-call efficiency, and can compare skill-enabled runs with a no-skill baseline. Because it invokes an agent and may incur provider costs, it is not part of `npm test`.
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
npm run eval:guidance-skill -- --cases audit_legacy_instructions,migrate_mixed_harness_guidance,unrelated_typescript_review
|
|
131
|
+
npm run eval:guidance-skill -- --condition both --trials 3
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
See `evals/auditing-unity-agent-guidance/README.md` for the rubric.
|
|
135
|
+
|
|
136
|
+
## Package layout
|
|
137
|
+
|
|
138
|
+
```text
|
|
139
|
+
pi-unity/
|
|
140
|
+
index.ts
|
|
141
|
+
src/
|
|
142
|
+
unity-core.ts
|
|
143
|
+
unity-batchmode.ts
|
|
144
|
+
unity-cli.ts
|
|
145
|
+
unity-launch.ts
|
|
146
|
+
unity-processes.ts
|
|
147
|
+
unity-project-lock.ts
|
|
148
|
+
unity-projects.ts
|
|
149
|
+
skills/
|
|
150
|
+
unity-debugging/
|
|
151
|
+
SKILL.md
|
|
152
|
+
auditing-unity-agent-guidance/
|
|
153
|
+
SKILL.md
|
|
154
|
+
references/
|
|
155
|
+
assets/
|
|
156
|
+
unity-pipeline-workflows/
|
|
157
|
+
SKILL.md
|
|
158
|
+
unity-batchmode-tests/
|
|
159
|
+
SKILL.md
|
|
160
|
+
tests/
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## Optional artifact metadata
|
|
164
|
+
|
|
165
|
+
When `@aefree/pi-project-artifacts` is also active in a Unity workspace, solution and memory Markdown may use the following profile-enriched fields:
|
|
166
|
+
|
|
167
|
+
```yaml
|
|
168
|
+
---
|
|
169
|
+
engine: unity
|
|
170
|
+
unity_version: "6000.0"
|
|
171
|
+
unity_packages:
|
|
172
|
+
- com.unity.inputsystem
|
|
173
|
+
render_pipeline: urp
|
|
174
|
+
platforms:
|
|
175
|
+
- windows
|
|
176
|
+
- android
|
|
177
|
+
---
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Supported `render_pipeline` values are `builtin`, `urp`, `hdrp`, `custom`, and `agnostic`. Keep `unity_version` quoted because Unity versions are identifiers rather than numeric values. Omit inapplicable fields instead of adding placeholders. These fields improve exact retrieval and diagnostics but are not required for indexing or raw filtering.
|
|
181
|
+
|
|
182
|
+
## Testing
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
npm test
|
|
186
|
+
npm pack --dry-run
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
The package declares optional peer integrations for `@aefree/pi-project-artifacts` and `@aefree/pi-file-discovery`; install only the integrations needed for artifact profiles or file-discovery filtering. The standalone Unity tools and skills do not require them. The package archive contains no copied dependency tree, sibling `file:` path, or workspace link.
|
|
190
|
+
|
|
191
|
+
## Release status
|
|
192
|
+
|
|
193
|
+
A registry-clean `package-lock.json` is committed, optional development packages resolve from the public registry, and the manifest is prepared for public scoped publication. Publishing remains a separate manual operation requiring npm authentication and explicit authorization.
|
|
194
|
+
|
|
195
|
+
## License
|
|
196
|
+
|
|
197
|
+
MIT. See `LICENSE`.
|