@alpsckr/unitycli 0.4.0 → 0.4.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/README.md +109 -300
- package/contracts/init-contract.json +57 -0
- package/contracts/instances-contract.json +49 -0
- package/contracts/package-assembly-closure.json +33 -0
- package/contracts/package-files.json +1953 -0
- package/dist/bridge/session-supervisor.d.ts +2 -0
- package/dist/bridge/session-supervisor.js +52 -19
- package/dist/bridge/session-supervisor.js.map +1 -1
- package/dist/cli-commands/command.js +33 -15
- package/dist/cli-commands/command.js.map +1 -1
- package/dist/cli-commands/init-discovery.d.ts +4 -0
- package/dist/cli-commands/init-discovery.js +175 -0
- package/dist/cli-commands/init-discovery.js.map +1 -0
- package/dist/cli-commands/init-help.d.ts +3 -0
- package/dist/cli-commands/init-help.js +37 -0
- package/dist/cli-commands/init-help.js.map +1 -0
- package/dist/cli-commands/init-skill.d.ts +10 -0
- package/dist/cli-commands/init-skill.js +105 -0
- package/dist/cli-commands/init-skill.js.map +1 -0
- package/dist/cli-commands/instances.d.ts +4 -0
- package/dist/cli-commands/instances.js +90 -0
- package/dist/cli-commands/instances.js.map +1 -0
- package/dist/cli-commands/package.d.ts +2 -2
- package/dist/cli-commands/package.js +57 -137
- package/dist/cli-commands/package.js.map +1 -1
- package/dist/cli-commands/skill-installer.d.ts +14 -6
- package/dist/cli-commands/skill-installer.js +37 -38
- package/dist/cli-commands/skill-installer.js.map +1 -1
- package/dist/cli-commands/types.d.ts +1 -0
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +44 -37
- package/dist/cli.js.map +1 -1
- package/dist/contracts/command-contract.js +1 -0
- package/dist/contracts/command-contract.js.map +1 -1
- package/dist/doctor.js +1 -1
- package/dist/doctor.js.map +1 -1
- package/dist/instances.d.ts +1 -1
- package/dist/instances.js +63 -38
- package/dist/instances.js.map +1 -1
- package/dist/output.d.ts +4 -4
- package/dist/output.js +3 -4
- package/dist/output.js.map +1 -1
- package/dist/package-manager.d.ts +43 -2
- package/dist/package-manager.js +255 -16
- package/dist/package-manager.js.map +1 -1
- package/dist/tools/.generated-schemas.js +2 -2
- package/dist/tools/.generated-schemas.js.map +1 -1
- package/dist/tools/commands.js +11 -4
- package/dist/tools/commands.js.map +1 -1
- package/dist/tools/dispatcher.js +1 -1
- package/dist/tools/dispatcher.js.map +1 -1
- package/dist/tools/tools/group-list.d.ts +4 -8
- package/dist/tools/tools/group-list.js +12 -13
- package/dist/tools/tools/group-list.js.map +1 -1
- package/dist/tools/tools/pagination.d.ts +17 -0
- package/dist/tools/tools/pagination.js +28 -0
- package/dist/tools/tools/pagination.js.map +1 -0
- package/dist/tools/tools/search.d.ts +3 -5
- package/dist/tools/tools/search.js +12 -12
- package/dist/tools/tools/search.js.map +1 -1
- package/docs/README.md +7 -4
- package/docs/architecture.md +103 -0
- package/docs/availability-differences.md +1 -1
- package/docs/command-execution.md +6 -1
- package/docs/development.md +91 -0
- package/docs/error-codes.md +5 -5
- package/docs/extensions.md +11 -13
- package/docs/target-and-instance.md +6 -4
- package/docs/tool-discovery.md +12 -10
- package/docs/tool-execution.md +3 -2
- package/package.json +10 -4
- package/schemas/init.schema.json +124 -0
- package/schemas/instances.schema.json +104 -0
- package/skills/unitycli/SKILL.md +18 -6
- package/skills/unitycli/manifest.json +2 -2
- package/skills/unitycli/references/custom-tools.md +3 -3
- package/skills/unitycli/references/operation-protocol.md +6 -4
- package/skills/unitycli/reports/output_quality_scorecard.md +1 -1
- package/skills/unitycli/reports/trust-report.md +1 -1
- package/unitypkg/Editor/Bridge/BridgeCommandRegistry.cs +1 -0
- package/unitypkg/Editor/Bridge/BridgeWorkQueue.cs +18 -6
- package/unitypkg/Editor/Infrastructure/CodeExecSupport.cs +8 -77
- package/unitypkg/Editor/Infrastructure/UnityCliInstanceCleanup.cs +295 -0
- package/unitypkg/Editor/Infrastructure/UnityCliInstanceRegistry.cs +166 -10
- package/unitypkg/Editor/Infrastructure/UnityCliOperationCoordinator.cs +1 -0
- package/unitypkg/Editor/UnityCliBridge.cs +5 -1
- package/unitypkg/Tests/Editor/UnityCliInstanceCleanupTests.cs +232 -0
- package/unitypkg/Tests/Editor/UnityCliInstancePublicationRetryTests.cs +143 -0
- package/unitypkg/UnityCli.Editor.asmdef +1 -5
- package/unitypkg/package.json +1 -1
- package/unitypkg/Editor/Roslyn/LICENSE.txt +0 -23
- package/unitypkg/Editor/Roslyn/Microsoft.CodeAnalysis.CSharp.dll +0 -0
- package/unitypkg/Editor/Roslyn/Microsoft.CodeAnalysis.dll +0 -0
- package/unitypkg/Editor/Roslyn/System.Collections.Immutable.dll +0 -0
- package/unitypkg/Editor/Roslyn/System.Reflection.Metadata.dll +0 -0
package/README.md
CHANGED
|
@@ -1,389 +1,198 @@
|
|
|
1
1
|
# UnityCLI
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Windows-first Unity Editor automation CLI for AI agents. The executable is `unitycli`; the npm package is `@alpsckr/unitycli`; the Unity Package is `com.alpsckr.unitycli`.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
运行环境:Windows + Node.js 20+
|
|
7
|
-
当前方向:冻结决策 - 独立 CLI 实现、Windows-only、npm-first 安装;公开 Tool 与 CLI 控制面调用即授权。
|
|
5
|
+
## Requirements
|
|
8
6
|
|
|
9
|
-
|
|
7
|
+
- Windows
|
|
8
|
+
- Node.js 20 or newer
|
|
9
|
+
- Unity 2022.3 or newer
|
|
10
|
+
- A Unity project when installing the Bridge
|
|
11
|
+
- An opened Unity Editor only when using live Unity capabilities; installation does not start or stop Unity
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
## Install
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
Install the CLI once for the current user:
|
|
14
16
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
项目代码、文档、命令形态和注释必须表达当前项目规范。发现旧语义、阶段性语义或兼容性语义时,应统一改为当前规范;无法干净迁移时,优先删除,而不是保留多套说法。
|
|
18
|
-
|
|
19
|
-
### 2. Top-Level CLI Shape
|
|
20
|
-
|
|
21
|
-
用户可见顶层命令分为两类:能力入口和 CLI 控制面。
|
|
22
|
-
|
|
23
|
-
能力入口只允许:
|
|
24
|
-
|
|
25
|
-
- `tools`
|
|
26
|
-
- `command`
|
|
27
|
-
|
|
28
|
-
CLI控制面只允许:
|
|
29
|
-
|
|
30
|
-
- `init`
|
|
31
|
-
- `extensions`
|
|
32
|
-
- `target`
|
|
33
|
-
- `instances`
|
|
34
|
-
- `doctor`
|
|
35
|
-
|
|
36
|
-
Unity项目内容与Editor能力域必须进入唯一Tool catalog,例如scene、asset、game-object、prefab、editor、screenshot、package、docs、reflect、build、test、code、profiler、physics、graphics等。`tools run <tool> --input <json>`与`command <name> <business-args>`只是同一descriptor和dispatcher的两种调用语法。
|
|
37
|
-
|
|
38
|
-
`target`、`instances`、`doctor` 是 CLI 自身的状态、路由和诊断控制面;它们可以作为顶层命令存在,但不得重新引入 Unity 能力域的顶层入口。
|
|
39
|
-
|
|
40
|
-
内部 Bridge、协调器和 registry 可以作为实现细节存在,但不得定义超出上述清单的用户可见顶层命令形态。
|
|
41
|
-
|
|
42
|
-
本产品只吸收必须由已打开 Unity Editor 或 development Player 提供的项目内自动化价值。auth、Unity Hub、Editor 安装或打开、Cloud、License 和 proxy 配置属于外部控制面,必须直接使用系统或官方控制面工具,不进入 Tool catalog,也不新增顶层命令。
|
|
43
|
-
|
|
44
|
-
### 3. AI-First Tool Interface
|
|
45
|
-
|
|
46
|
-
本 CLI 主要提供给 AI 使用。项目哲学不是维护一套面向人工记忆的传统命令手册,而是提供可发现、可描述、可审计的工具目录。
|
|
47
|
-
|
|
48
|
-
AI 的标准流程是:
|
|
49
|
-
|
|
50
|
-
```text
|
|
51
|
-
unitycli tools group/search
|
|
52
|
-
unitycli tools describe <tool>
|
|
53
|
-
unitycli tools run <tool> --input <json>
|
|
54
|
-
unitycli command
|
|
55
|
-
unitycli command <name> --field <value>
|
|
56
|
-
|
|
57
|
-
unitycli target alias list/set/unset
|
|
58
|
-
unitycli instances list/prune
|
|
59
|
-
unitycli doctor
|
|
60
|
-
|
|
61
|
-
unitycli extensions list/install/remove/doctor
|
|
62
|
-
unitycli init
|
|
17
|
+
```powershell
|
|
18
|
+
npm install -g @alpsckr/unitycli
|
|
63
19
|
```
|
|
64
20
|
|
|
65
|
-
|
|
21
|
+
Start your AI in the directory where you normally work and tell it:
|
|
66
22
|
|
|
67
|
-
|
|
23
|
+
> 执行 unitycli init help,然后照做。
|
|
68
24
|
|
|
69
|
-
|
|
70
|
-
# 安装
|
|
71
|
-
npm install -g @alpsckr/unitycli
|
|
25
|
+
`init help` contains the complete AI installation protocol. The AI first runs read-only discovery, then asks you:
|
|
72
26
|
|
|
73
|
-
|
|
74
|
-
|
|
27
|
+
- which discovered Unity projects should receive the Bridge;
|
|
28
|
+
- whether the Skill target is generic Agent Skills (`.agents`) or Claude;
|
|
29
|
+
- whether the Skill belongs to one workspace or to the current user;
|
|
30
|
+
- which directory is your normal AI workspace when workspace scope is selected.
|
|
75
31
|
|
|
76
|
-
|
|
77
|
-
# 修改后从下一次Domain Reload或Editor启动生效
|
|
32
|
+
The AI does not silently choose these values. Multiple Bridge projects are installed one at a time. Installation does not start, close, restart, or terminate Unity.
|
|
78
33
|
|
|
79
|
-
|
|
80
|
-
unitycli --help
|
|
81
|
-
unitycli --version
|
|
82
|
-
```
|
|
34
|
+
## Manual Setup
|
|
83
35
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
### 1. 发现目标实例
|
|
36
|
+
Read the same protocol and inspect the current directory:
|
|
87
37
|
|
|
88
38
|
```powershell
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
unitycli instances list
|
|
92
|
-
# 需要审计历史/offline 合法记录时显式展开
|
|
93
|
-
unitycli instances list --all
|
|
94
|
-
|
|
95
|
-
# 已知实例时,在后续每条 Bridge 命令上显式传入
|
|
96
|
-
unitycli tools group --instance <instanceId>
|
|
97
|
-
# 可先创建稳定别名,再继续显式传入
|
|
98
|
-
unitycli target alias set <instanceId> my-project
|
|
99
|
-
unitycli tools group --instance my-project
|
|
39
|
+
unitycli init help
|
|
40
|
+
unitycli init discover
|
|
100
41
|
```
|
|
101
42
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
推荐按组逐层发现,避免一次展开全量工具:
|
|
43
|
+
Install or repair the Bridge in one explicit Unity project:
|
|
105
44
|
|
|
106
45
|
```powershell
|
|
107
|
-
|
|
108
|
-
unitycli
|
|
109
|
-
|
|
110
|
-
# 第二步:按组查看工具摘要
|
|
111
|
-
unitycli tools group list camera
|
|
112
|
-
# 或搜索关键词(使用 | 分隔多关键词,OR 匹配;PowerShell必须单引号包住整段)
|
|
113
|
-
unitycli tools search 'screenshot|camera'
|
|
114
|
-
|
|
115
|
-
# 第三步:查看工具完整描述(执行前必做)
|
|
116
|
-
unitycli tools describe camera.screenshot
|
|
117
|
-
|
|
118
|
-
# 第四步:执行工具
|
|
119
|
-
unitycli tools run camera.screenshot --input '{"target":"Main Camera","output":"Artifacts/shot.png"}'
|
|
46
|
+
unitycli init package --project C:\path\UnityProject
|
|
47
|
+
unitycli init package --project C:\path\UnityProject --check
|
|
120
48
|
```
|
|
121
49
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
当前版本通过 `docs.get/search` 查询 Unity API 文档,通过 `reflect.*` 查询类型缓存;这些 Tool 仍从已连接实例的统一 catalog 发现和调用:
|
|
50
|
+
Install or check generic Agent Skills in one workspace:
|
|
125
51
|
|
|
126
52
|
```powershell
|
|
127
|
-
|
|
128
|
-
unitycli
|
|
129
|
-
unitycli tools run docs.search "Render Pipeline"
|
|
130
|
-
|
|
131
|
-
# 类型反射
|
|
132
|
-
unitycli tools run reflect.type UnityEngine.Camera
|
|
133
|
-
unitycli tools run reflect.member UnityEngine.Camera.fieldOfView
|
|
53
|
+
unitycli init skill --agent .agents --scope workspace --workspace C:\path\Workspace
|
|
54
|
+
unitycli init skill --agent .agents --scope workspace --workspace C:\path\Workspace --check
|
|
134
55
|
```
|
|
135
56
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
### 4. 项目注册能力
|
|
139
|
-
|
|
140
|
-
Unity 项目可通过异步 C# `IUnityCliTool<TReq,TRes>` 注册能力;完成编译后自动进入该实例的完整目录,与 package 内置和 Extension 能力使用同一路径:
|
|
57
|
+
Install or check Claude Skills in one workspace:
|
|
141
58
|
|
|
142
59
|
```powershell
|
|
143
|
-
|
|
144
|
-
unitycli
|
|
145
|
-
|
|
146
|
-
# 描述并执行项目 Tool
|
|
147
|
-
unitycli tools describe my.custom-tool --instance <id|projectPath|alias>
|
|
148
|
-
unitycli tools run my.custom-tool --input '{"key":"value"}' --instance <id|projectPath|alias>
|
|
60
|
+
unitycli init skill --agent claude --scope workspace --workspace C:\path\Workspace
|
|
61
|
+
unitycli init skill --agent claude --scope workspace --workspace C:\path\Workspace --check
|
|
149
62
|
```
|
|
150
63
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
### 5. 使用command语法
|
|
154
|
-
|
|
155
|
-
`command`按目标Tool的live `inputSchema`解析named、attached、boolean裸开关和声明顺序positional参数,然后进入与`tools run`相同的dispatcher和JSON envelope:
|
|
64
|
+
Install or check one user-level Skill:
|
|
156
65
|
|
|
157
66
|
```powershell
|
|
158
|
-
|
|
159
|
-
unitycli
|
|
67
|
+
unitycli init skill --agent .agents --scope user
|
|
68
|
+
unitycli init skill --agent .agents --scope user --check
|
|
160
69
|
|
|
161
|
-
|
|
162
|
-
unitycli
|
|
163
|
-
|
|
164
|
-
# [CliCommand("test")]在tools中名为UnityPipeline_test,command可用attribute原名
|
|
165
|
-
unitycli command test --mode EditMode
|
|
166
|
-
unitycli command UnityPipeline_test --mode EditMode
|
|
70
|
+
unitycli init skill --agent claude --scope user
|
|
71
|
+
unitycli init skill --agent claude --scope user --check
|
|
167
72
|
```
|
|
168
73
|
|
|
169
|
-
|
|
74
|
+
Workspace and user scope are separate choices. UnityCLI does not install both automatically. A workspace can be the parent of one or more Unity projects.
|
|
170
75
|
|
|
171
|
-
|
|
76
|
+
## Verify And Diagnose
|
|
172
77
|
|
|
173
|
-
|
|
78
|
+
Package and Skill checks are read-only:
|
|
174
79
|
|
|
175
80
|
```powershell
|
|
176
|
-
|
|
177
|
-
unitycli
|
|
178
|
-
|
|
179
|
-
# 诊断预检(通过 Bridge)
|
|
180
|
-
unitycli tools run diagnose.preflight
|
|
81
|
+
unitycli init package --project C:\path\UnityProject --check
|
|
82
|
+
unitycli init skill --agent .agents --scope workspace --workspace C:\path\Workspace --check
|
|
181
83
|
```
|
|
182
84
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
| 规则 | 说明 |
|
|
186
|
-
|------|------|
|
|
187
|
-
| Tool 可有副作用 | 调用即授权;`destructiveHint`、`sideEffects` 与 `supportsDryRun` 仅描述风险和可选预览 |
|
|
188
|
-
| 读取型 Tool 纯只读 | 读取型 Tool 不触发写入、import、compile、domain reload 或 PlayMode 变化 |
|
|
189
|
-
| Extension 不能绕过 descriptor/envelope | 项目工具必须可描述、可审计、可阻断 |
|
|
190
|
-
| 内部完整性不匹配默认阻止 | 自定义工具的 handler 代码与 descriptor 不一致时,默认阻止执行 |
|
|
191
|
-
|
|
192
|
-
## 安装与构建
|
|
85
|
+
After the user opens or refreshes Unity, inspect registered Editor sessions:
|
|
193
86
|
|
|
194
87
|
```powershell
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
# 本地开发
|
|
199
|
-
npm install
|
|
200
|
-
npm run build
|
|
201
|
-
npm test
|
|
202
|
-
npm link
|
|
88
|
+
unitycli instances list
|
|
89
|
+
unitycli instances prune --instance C:\path\UnityProject
|
|
90
|
+
unitycli doctor --project C:\path\UnityProject
|
|
203
91
|
```
|
|
204
92
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
所有命令输出统一 JSON envelope:
|
|
208
|
-
|
|
209
|
-
```json
|
|
210
|
-
{
|
|
211
|
-
"ok": true,
|
|
212
|
-
"requestId": "req-xxx",
|
|
213
|
-
"data": { ... }
|
|
214
|
-
}
|
|
215
|
-
```
|
|
93
|
+
`instances list`默认隐藏offline记录;`instances list --all`仅用于展开审计。Unity启动、编译或重载时,live命令会在本次timeout内等待当前连接ready。旧格式、损坏或不可读记录会逐文件隔离,不阻断合法实例,并通过`invalidRecordCount`返回数量;当前项目由Unity自动恢复。需要清理历史记录时运行`instances prune --instance <id|projectPath|alias>`并检查`removed`、`remaining`和`deferred`,不要手工读取或删除内部文件。
|
|
216
94
|
|
|
217
|
-
|
|
95
|
+
To create a stable selector:
|
|
218
96
|
|
|
219
|
-
```
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
"requestId": "req-xxx",
|
|
223
|
-
"error": {
|
|
224
|
-
"code": "E_INSTANCE_CONFLICT",
|
|
225
|
-
"message": "...",
|
|
226
|
-
"transient": false,
|
|
227
|
-
"nextActions": ["Close duplicate Editor sessions for the selected project."],
|
|
228
|
-
"retryAfterMs": 0
|
|
229
|
-
}
|
|
230
|
-
}
|
|
97
|
+
```powershell
|
|
98
|
+
unitycli target alias set C:\path\UnityProject my-project
|
|
99
|
+
unitycli target alias list
|
|
231
100
|
```
|
|
232
101
|
|
|
233
|
-
##
|
|
234
|
-
|
|
235
|
-
需要 Unity 执行的 Tool 只连接已打开的 Unity Editor,并在同一次 direct 调用中返回最终业务结果。`build.run`、`test.run`、`editor.refresh`、`code.exec` 以及需要 Editor 刷新的 Package Tool 都会等待终态;它们不创建可查询的后台任务。每个live Editor/Development Player session使用默认5/3任务池,CLI在业务请求前自动等待放行。`--timeout-ms T`分别提供最多`T`的准入等待与放行后最多`T`的执行预算;调用CLI的外层进程必须等待CLI退出,host预算至少为`2 * T + 5000`毫秒。准入`E_UNITY_BUSY`证明业务请求未发送;放行后的`E_EXECUTION_TIMEOUT`仍是outcome unknown。CLI在stdout写完或最多再等待1秒后退出。
|
|
236
|
-
|
|
237
|
-
`code.exec`保留完整同步C#执行能力:它不会拒绝死循环、阻塞等待或长期占用Unity主线程的代码。提交这类代码前应先判断是否确有必要;一旦开始执行,timeout只能停止CLI等待,不能中止代码,结果可能未知且Unity可能需要结束进程才能恢复。CLI进程退出也不证明Unity中的C#已停止。完整边界见`tools describe code.exec`和`docs/safety-boundaries.md`。
|
|
102
|
+
## First Unity Call
|
|
238
103
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
公开能力不维护静态命令清单。Tool 的当前输入 schema、可用性、示例与调用边界以 CLI discovery 为准;结果 schema 留在内部 contract 中校验实际业务 data:
|
|
104
|
+
With the selected Unity project open and ready:
|
|
242
105
|
|
|
243
106
|
```powershell
|
|
244
|
-
unitycli tools group
|
|
245
|
-
unitycli tools
|
|
246
|
-
unitycli tools
|
|
247
|
-
unitycli tools
|
|
248
|
-
unitycli tools run <tool-name> --input '<json>' [--instance <id|projectPath|alias>]
|
|
107
|
+
unitycli tools group --instance C:\path\UnityProject
|
|
108
|
+
unitycli tools search 'editor|state' --instance C:\path\UnityProject
|
|
109
|
+
unitycli tools describe editor.state --instance C:\path\UnityProject
|
|
110
|
+
unitycli tools run editor.state --input '{}' --instance C:\path\UnityProject
|
|
249
111
|
```
|
|
250
112
|
|
|
251
|
-
Tool
|
|
252
|
-
|
|
253
|
-
Bridge-backed Tool在Unity主线程执行。CLI使用Registry/Health v3与只读内存pulse,在一个不可变deadline内处理compile、import、domain reload和listener generation交接。mutation只允许在同一`editorSessionId`内用完全相同的请求续接;首次POST后session改变时禁止向新session重投,并返回outcome unknown的`E_EXECUTION_TIMEOUT`。`unitycli tools run editor.state --input '{}'`、`editor.dialogs`与`editor.dialog.click`使用exact frozen本地descriptor进入同一dispatcher,因此统一状态观察和弹窗恢复不依赖被阻断的Live catalog;其他Tool仍严格依赖Live catalog。
|
|
113
|
+
Do not guess Tool names or inputs. Discover the current catalog, read one descriptor, then call that exact Tool. `command <name>` is a schema-argument projection of the same live catalog, not a second capability system.
|
|
254
114
|
|
|
255
|
-
|
|
115
|
+
Optional extensions use their dedicated control plane:
|
|
256
116
|
|
|
257
117
|
```powershell
|
|
258
|
-
|
|
259
|
-
unitycli
|
|
260
|
-
unitycli
|
|
261
|
-
unitycli
|
|
118
|
+
unitycli extensions list --project C:\path\UnityProject
|
|
119
|
+
unitycli extensions install <id> --project C:\path\UnityProject
|
|
120
|
+
unitycli extensions remove <id> --project C:\path\UnityProject
|
|
121
|
+
unitycli extensions doctor --project C:\path\UnityProject
|
|
262
122
|
```
|
|
263
123
|
|
|
264
|
-
|
|
124
|
+
Discovery lists default to 20 items, allow at most 100, and continue with `pageInfo.nextCursor`:
|
|
265
125
|
|
|
266
126
|
```powershell
|
|
267
|
-
|
|
268
|
-
unitycli
|
|
269
|
-
unitycli
|
|
270
|
-
unitycli target alias list
|
|
127
|
+
unitycli tools group list <group> --page-size 20 --instance <id|projectPath|alias>
|
|
128
|
+
unitycli tools search '<k1|k2|...>' --page-size 20 --instance <id|projectPath|alias>
|
|
129
|
+
unitycli command --project-path C:\path\UnityProject --page-size 20
|
|
271
130
|
```
|
|
272
131
|
|
|
273
|
-
|
|
132
|
+
In PowerShell, quote pipe-separated search keywords with single quotes.
|
|
274
133
|
|
|
275
|
-
|
|
134
|
+
## Output
|
|
276
135
|
|
|
277
|
-
|
|
136
|
+
Every command returns one JSON envelope. stdout is compact single-line JSON by default; use `--pretty` only for indented output.
|
|
278
137
|
|
|
279
|
-
|
|
138
|
+
Success:
|
|
280
139
|
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
| *(none)* | 安装/更新 Bridge 包(copy 模式),并为已存在的 Agent 目录安装 Skill |
|
|
284
|
-
| `--pkg-only` | 仅安装 Bridge 包,不安装 Skill |
|
|
285
|
-
| `--skill-only [--agent <agent>]` | 仅安装 Skill;未传 `--agent` 时使用已存在的 Agent 目录 |
|
|
286
|
-
| `--check` | 检查安装状态,不修改项目 |
|
|
287
|
-
| `--agent <pi\|claude\|.agents,...>` | 显式指定 Skill 安装目标 |
|
|
288
|
-
|
|
289
|
-
```powershell
|
|
290
|
-
# 默认安装 Bridge;若项目已有 .pi/.claude/.agents,则自动安装 Skill
|
|
291
|
-
unitycli init --project C:\path\MyProject
|
|
292
|
-
|
|
293
|
-
# 仅 Bridge 包
|
|
294
|
-
unitycli init --project C:\path\MyProject --pkg-only
|
|
295
|
-
|
|
296
|
-
# 显式安装 Skill 到 pi
|
|
297
|
-
unitycli init --project C:\path\MyProject --skill-only --agent pi
|
|
298
|
-
|
|
299
|
-
# 检查安装状态;未传 --agent 时同样会检查已存在的 Agent 目录
|
|
300
|
-
unitycli init --check --project C:\path\MyProject
|
|
140
|
+
```json
|
|
141
|
+
{"ok":true,"requestId":"req-...","data":{}}
|
|
301
142
|
```
|
|
302
143
|
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
## Unity Editor Bridge
|
|
144
|
+
Failure:
|
|
306
145
|
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
146
|
+
```json
|
|
147
|
+
{"ok":false,"requestId":"req-...","error":{"code":"...","message":"...","nextActions":[],"transient":false,"retryAfterMs":0}}
|
|
148
|
+
```
|
|
310
149
|
|
|
311
|
-
|
|
150
|
+
Follow structured `nextActions`. With `--timeout-ms T`, use a host budget of at least `2 * T + 5000` milliseconds and wait for the unitycli process to exit. `E_EXECUTION_TIMEOUT` means no trusted terminal result; timeout does not stop Unity effects or synchronous C# already running. Inspect business state before deciding whether to submit a new mutation.
|
|
312
151
|
|
|
313
|
-
##
|
|
152
|
+
## Update And Remove
|
|
314
153
|
|
|
315
|
-
|
|
154
|
+
Update the global CLI, then let the AI run the installation protocol again:
|
|
316
155
|
|
|
317
156
|
```powershell
|
|
318
|
-
|
|
319
|
-
unitycli
|
|
320
|
-
unitycli tools describe my.editor-tool --instance <id|projectPath|alias>
|
|
321
|
-
unitycli tools run my.editor-tool --input '{"message":"hello"}' --instance <id|projectPath|alias>
|
|
157
|
+
npm install -g @alpsckr/unitycli@latest
|
|
158
|
+
unitycli init help
|
|
322
159
|
```
|
|
323
160
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
所有能力都以 Tool 呈现。`target: "editor" | "runtime" | "both"` 只是可用性与路由约束,不是两套用户入口。
|
|
327
|
-
|
|
328
|
-
`runtime` 表示 Unity gameplay/runtime layer;具体 tool 是否需要 Play Mode,由 `availabilityScope` 和 `nextActions` 说明。
|
|
161
|
+
To remove a workspace or user Skill, delete only the selected `unitycli` Skill directory:
|
|
329
162
|
|
|
330
|
-
|
|
163
|
+
```text
|
|
164
|
+
<workspace>/.agents/skills/unitycli
|
|
165
|
+
<workspace>/.claude/skills/unitycli
|
|
166
|
+
~/.agents/skills/unitycli
|
|
167
|
+
~/.claude/skills/unitycli
|
|
168
|
+
```
|
|
331
169
|
|
|
332
|
-
|
|
333
|
-
- **Envelope**:所有输入输出必须通过统一 envelope 格式
|
|
334
|
-
- **内部完整性校验**:handler 与 descriptor 不一致时默认阻止执行
|
|
335
|
-
- **target-scoped availability**:工具可用性依赖目标实例和 Play Mode 状态
|
|
336
|
-
- **禁止项**:不允许任意方法调用、反射 escape hatch、绕过 registry 直接执行
|
|
170
|
+
To remove the managed Bridge, first inspect the current `package.bridge-remove` descriptor and follow it:
|
|
337
171
|
|
|
338
|
-
|
|
172
|
+
```powershell
|
|
173
|
+
unitycli tools describe package.bridge-remove --instance C:\path\UnityProject
|
|
174
|
+
```
|
|
339
175
|
|
|
340
|
-
|
|
176
|
+
Remove the global CLI with:
|
|
341
177
|
|
|
342
178
|
```powershell
|
|
343
|
-
|
|
344
|
-
unitycli tools group list probuilder --instance <id|projectPath|alias>
|
|
345
|
-
unitycli tools describe probuilder.create-shape --instance <id|projectPath|alias>
|
|
346
|
-
unitycli tools run probuilder.create-shape --input '{"shapeType":"Cube","name":"MyCube"}' --instance <id|projectPath|alias>
|
|
179
|
+
npm uninstall -g @alpsckr/unitycli
|
|
347
180
|
```
|
|
348
181
|
|
|
349
|
-
##
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
## 更多文档
|
|
364
|
-
|
|
365
|
-
- [文档索引](docs/README.md) — 当前使用、扩展与诊断文档入口
|
|
366
|
-
- [Target 与 Instance](docs/target-and-instance.md) — 目标选择与实例管理
|
|
367
|
-
- [工具发现](docs/tool-discovery.md) — group-first 分层发现详解
|
|
368
|
-
- [工具执行](docs/tool-execution.md) — tools run 执行通道详解
|
|
369
|
-
- [安全边界](docs/safety-boundaries.md) — 调用授权、风险元数据与正确性边界
|
|
370
|
-
- [风险与副作用](docs/risk-and-side-effects.md) — destructive/dry-run 描述与可选预览
|
|
371
|
-
- [错误码](docs/error-codes.md) — 结构化错误与 nextActions
|
|
372
|
-
- [可用性差异](docs/availability-differences.md) — 不同实例的工具有效性
|
|
373
|
-
- [扩展包](docs/extensions.md) — 可选扩展安装、卸载与诊断
|
|
374
|
-
- [自定义 Tool](skills/unitycli/references/custom-tools.md) — 项目侧 Tool 注册开发
|
|
375
|
-
- [AI Agent Skill](skills/unitycli/SKILL.md) — Agent 最小入口卡片
|
|
376
|
-
|
|
377
|
-
## 本地开发
|
|
378
|
-
|
|
379
|
-
```bash
|
|
380
|
-
npm install
|
|
381
|
-
npm run build
|
|
382
|
-
npm test
|
|
383
|
-
npm link
|
|
384
|
-
unitycli --help
|
|
385
|
-
```
|
|
182
|
+
## Documentation
|
|
183
|
+
|
|
184
|
+
- [Documentation index](docs/README.md)
|
|
185
|
+
- [Architecture and public boundaries](docs/architecture.md)
|
|
186
|
+
- [Local development](docs/development.md)
|
|
187
|
+
- [Tool discovery](docs/tool-discovery.md)
|
|
188
|
+
- [Tool execution](docs/tool-execution.md)
|
|
189
|
+
- [Command execution](docs/command-execution.md)
|
|
190
|
+
- [Target and instance selection](docs/target-and-instance.md)
|
|
191
|
+
- [Safety boundaries](docs/safety-boundaries.md)
|
|
192
|
+
- [Errors](docs/error-codes.md)
|
|
193
|
+
- [Extensions](docs/extensions.md)
|
|
194
|
+
- [Public AI Skill](skills/unitycli/SKILL.md)
|
|
386
195
|
|
|
387
|
-
##
|
|
196
|
+
## License
|
|
388
197
|
|
|
389
198
|
MIT
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"topLevel": "init",
|
|
4
|
+
"schema": "schemas/init.schema.json",
|
|
5
|
+
"subcommands": {
|
|
6
|
+
"help": {
|
|
7
|
+
"options": []
|
|
8
|
+
},
|
|
9
|
+
"discover": {
|
|
10
|
+
"options": []
|
|
11
|
+
},
|
|
12
|
+
"package": {
|
|
13
|
+
"options": [
|
|
14
|
+
"project",
|
|
15
|
+
"check",
|
|
16
|
+
"timeout-ms"
|
|
17
|
+
],
|
|
18
|
+
"required": [
|
|
19
|
+
"project"
|
|
20
|
+
],
|
|
21
|
+
"checkStatuses": [
|
|
22
|
+
"installed",
|
|
23
|
+
"missing",
|
|
24
|
+
"damaged",
|
|
25
|
+
"drifted",
|
|
26
|
+
"conflict"
|
|
27
|
+
]
|
|
28
|
+
},
|
|
29
|
+
"skill": {
|
|
30
|
+
"options": [
|
|
31
|
+
"agent",
|
|
32
|
+
"scope",
|
|
33
|
+
"workspace",
|
|
34
|
+
"check",
|
|
35
|
+
"timeout-ms"
|
|
36
|
+
],
|
|
37
|
+
"required": [
|
|
38
|
+
"agent",
|
|
39
|
+
"scope"
|
|
40
|
+
],
|
|
41
|
+
"agents": [
|
|
42
|
+
".agents",
|
|
43
|
+
"claude"
|
|
44
|
+
],
|
|
45
|
+
"scopes": [
|
|
46
|
+
"workspace",
|
|
47
|
+
"user"
|
|
48
|
+
],
|
|
49
|
+
"checkStatuses": [
|
|
50
|
+
"installed",
|
|
51
|
+
"missing",
|
|
52
|
+
"drifted",
|
|
53
|
+
"damaged"
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"topLevel": "instances",
|
|
4
|
+
"schema": "schemas/instances.schema.json",
|
|
5
|
+
"registry": {
|
|
6
|
+
"version": 3,
|
|
7
|
+
"canonicalizationVersion": 1,
|
|
8
|
+
"statuses": [
|
|
9
|
+
"ready",
|
|
10
|
+
"transitioning",
|
|
11
|
+
"blocked",
|
|
12
|
+
"unresponsive",
|
|
13
|
+
"unverifiable",
|
|
14
|
+
"offline",
|
|
15
|
+
"conflict"
|
|
16
|
+
],
|
|
17
|
+
"readerPollMs": 100,
|
|
18
|
+
"writer": "unity-bridge"
|
|
19
|
+
},
|
|
20
|
+
"subcommands": {
|
|
21
|
+
"list": {
|
|
22
|
+
"options": ["all"],
|
|
23
|
+
"readOnly": true
|
|
24
|
+
},
|
|
25
|
+
"prune": {
|
|
26
|
+
"options": ["instance", "timeout-ms"],
|
|
27
|
+
"privateCommand": "internal.instances.prune",
|
|
28
|
+
"mutation": true,
|
|
29
|
+
"retention": {
|
|
30
|
+
"offlineMax": 100,
|
|
31
|
+
"damagedMax": 20,
|
|
32
|
+
"maxAgeDays": 30,
|
|
33
|
+
"scanLimit": 2000,
|
|
34
|
+
"deleteLimit": 20
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"errors": [
|
|
39
|
+
"E_INSTANCE_NOT_FOUND",
|
|
40
|
+
"E_INSTANCE_NOT_RUNNING",
|
|
41
|
+
"E_INSTANCE_UNVERIFIABLE",
|
|
42
|
+
"E_UNITY_TRANSITION_TIMEOUT",
|
|
43
|
+
"E_UNITY_BUSY",
|
|
44
|
+
"E_EXECUTION_TIMEOUT",
|
|
45
|
+
"E_BRIDGE_RESPONSE_INVALID",
|
|
46
|
+
"E_SCHEMA_INVALID",
|
|
47
|
+
"BRIDGE_CONNECTION_FAILED"
|
|
48
|
+
]
|
|
49
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"packageName": "com.alpsckr.unitycli",
|
|
4
|
+
"minimumUnityVersion": "2022.3",
|
|
5
|
+
"bundledAssemblies": [],
|
|
6
|
+
"editorProvidedAssemblies": [
|
|
7
|
+
{
|
|
8
|
+
"fileName": "Newtonsoft.Json.dll",
|
|
9
|
+
"assemblyName": "Newtonsoft.Json",
|
|
10
|
+
"minimumAssemblyVersion": "13.0.0.0",
|
|
11
|
+
"provider": "Unity Editor/Data/Managed",
|
|
12
|
+
"referencedBy": "UnityCli.Editor.asmdef"
|
|
13
|
+
}
|
|
14
|
+
],
|
|
15
|
+
"compiler": {
|
|
16
|
+
"mode": "editor-bundled-csc-subprocess",
|
|
17
|
+
"monoRelativePath": "MonoBleedingEdge/bin/mono.exe",
|
|
18
|
+
"compilerRelativePath": "MonoBleedingEdge/lib/mono/4.5/csc.exe",
|
|
19
|
+
"packageOwnedRoslyn": false,
|
|
20
|
+
"temporaryRoot": "Library/UnityCli/code-exec-temp"
|
|
21
|
+
},
|
|
22
|
+
"conflictPolicy": {
|
|
23
|
+
"protectedAssemblyFileNames": [
|
|
24
|
+
"Newtonsoft.Json.dll"
|
|
25
|
+
],
|
|
26
|
+
"allowedPackageProviders": [
|
|
27
|
+
"com.unity.nuget.newtonsoft-json"
|
|
28
|
+
],
|
|
29
|
+
"maxDirectories": 4096,
|
|
30
|
+
"maxFiles": 50000,
|
|
31
|
+
"maxConflicts": 100
|
|
32
|
+
}
|
|
33
|
+
}
|