@alpsckr/unitycli

中文文档
0.10.6发布于 2026/10/24MITES Module零依赖近 30 天下载 2371

Windows-first CLI for UnityCLI automation.

原始使用文档
文档目录10 节
  1. Requirements
  2. Install
  3. Manual Setup
  4. Verify And Diagnose
  5. First Unity Call
  6. Live Method Hooks
  7. Output
  8. Update And Remove
  9. Documentation
  10. License

UnityCLI

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.

Requirements

  • Windows
  • Node.js 20 or newer
  • Unity 2022.3 or newer
  • A Unity project when installing the Bridge
  • An opened Unity Editor only when using live Unity capabilities; installation may normally close only the exact target Editor after explicit user approval

Install

Install the CLI once for the current user:

npm install -g @alpsckr/unitycli

Start your AI in the directory where you normally work and tell it:

执行 unitycli init help,然后照做。

init help contains the complete AI installation protocol. Read-only discovery uses the unique current Unity project and workspace without asking you to repeat them, reports the installed and available Bridge versions, and accepts any exact Skill directory you already named. It asks only when a real choice remains, such as which of several discovered Unity projects receives the Bridge. An open Unity Editor is a normal installation state: the Bridge is replaced in place. Closing is a fallback: only after the publish reports a real directory lock may the AI normally close that exact project, and only after the user approves it. It never force-terminates Unity or decides an unsaved-scene prompt.

Manual Setup

Read the same protocol and inspect the current directory:

unitycli init help
unitycli init discover

Install or repair the Bridge in one explicit Unity project. Keep the Editor open: an existing package is converged file by file in place, and its directory is never renamed. A blocked file is reported by path, and rerunning the same command converges it. --close-editor stays available for an operator's own decision; the installation protocol never asks for a close:

unitycli init package --project C:\path\UnityProject
unitycli init package --project C:\path\UnityProject --close-editor
unitycli init package --project C:\path\UnityProject --check

Install or check an exact user-selected Skill directory, including Pi:

unitycli init skill --target C:\path\Workspace\.pi\skills\unitycli
unitycli init skill --target C:\path\Workspace\.pi\skills\unitycli --check

Generic Agent Skills remain available as a preset:

unitycli init skill --agent .agents --scope workspace --workspace C:\path\Workspace
unitycli init skill --agent .agents --scope workspace --workspace C:\path\Workspace --check

Install or check Claude Skills in one workspace:

unitycli init skill --agent claude --scope workspace --workspace C:\path\Workspace
unitycli init skill --agent claude --scope workspace --workspace C:\path\Workspace --check

Install or check one user-level Skill:

unitycli init skill --agent .agents --scope user
unitycli init skill --agent .agents --scope user --check

unitycli init skill --agent claude --scope user
unitycli init skill --agent claude --scope user --check

Preset workspace and user scope are separate choices. An exact --target is final user intent and cannot be combined with preset agent/scope options. Bridge and Skill are independently authorized effects; failure of one does not invalidate or block the other.

Verify And Diagnose

Package and Skill checks are read-only:

unitycli init package --project C:\path\UnityProject --check
unitycli init skill --target C:\path\Workspace\.pi\skills\unitycli --check
unitycli init skill --agent .agents --scope workspace --workspace C:\path\Workspace --check

After the user opens or refreshes Unity, inspect registered Editor sessions:

unitycli instances list
unitycli instances prune --instance C:\path\UnityProject
unitycli doctor --project C:\path\UnityProject

instances list默认隐藏offline记录;instances list --all仅用于展开审计。Unity启动、编译或重载时,live命令会在本次timeout内等待当前连接ready。旧格式、损坏或不可读记录会逐文件隔离,不阻断合法实例,并通过invalidRecordCount返回数量;当前项目由Unity自动恢复。需要清理历史记录时运行instances prune --instance <name|alias|projectPath>并检查removed、remaining和deferred,不要手工读取或删除内部文件。

To create a stable selector:

unitycli target alias set C:\path\UnityProject my-project
unitycli target alias list

First Unity Call

With the selected Unity project open and ready:

unitycli tools group --instance C:\path\UnityProject
unitycli tools search 'editor|state' --instance C:\path\UnityProject
unitycli tools describe editor.state --instance C:\path\UnityProject
unitycli tools run editor.state --input '{}' --instance C:\path\UnityProject

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. 调用方明确要求的业务值优先于schema default和example值;不要把default或example当作连通性、probe或smoke调用。

Optional extensions use their dedicated control plane:

unitycli extensions list --project C:\path\UnityProject
unitycli extensions install <id> --project C:\path\UnityProject
unitycli extensions remove <id> --project C:\path\UnityProject
unitycli extensions doctor --project C:\path\UnityProject

Discovery lists default to 20 items, allow at most 100, and continue with pageInfo.nextCursor:

unitycli tools group list <group> --page-size 20 --cursor <nextCursor> --instance <name|alias|projectPath>
unitycli tools search '<k1|k2|...>' --page-size 20 --cursor <nextCursor> --instance <name|alias|projectPath>
unitycli command --project-path C:\path\UnityProject --page-size 20 --cursor <nextCursor>

In PowerShell, quote pipe-separated search keywords with single quotes.

Live Method Hooks

The debug group hosts the live interceptor tools: debug.hook-* installs interceptors on an exact managed method of the current Editor domain before a Play run, observes calls, modifies behaviour, or executes bounded C# callbacks, and keeps those definitions across Play sessions and domain reloads within one Editor session:

unitycli command debug.hook-install --label ai-movement-order --target '{"assemblyName":"Assembly-CSharp","typeName":"Game.AiController","methodName":"BeginMovement","parameterTypes":[],"returnType":"System.Void","isStatic":false}' --capture '{"arguments":true}' --instance C:\path\UnityProject
unitycli command debug.hook-list --instance C:\path\UnityProject
unitycli command debug.events-read --hook-id hook-0123456789abcdef --instance C:\path\UnityProject

Boundaries worth knowing before using the group:

  • Definitions belong to one Editor session and are discarded on Editor restart; installing a hook is not persistent authorization for arbitrary code.
  • Call sites compiled before the patch keep the original behaviour, so an installed definition can legitimately produce no hits. Use debug.events-read or a real business readback to prove a hit.
  • Callback source is compiled on demand through the editor-bundled C# compiler and loaded into the current domain; this is not a project compile, but it costs a compiler subprocess and cannot be unloaded individually.
  • disable and remove stop future dispatch and restore the original behaviour; they do not roll back effects that earlier invocations already produced.

unitycli tools describe debug.hook-install documents the exact target identity, capture options, callback context API, resource budgets and error recovery for the selected instance. Pure observation with capture options starts no compiler, because a definition without callback source does not need one.

Output

Every command returns one JSON envelope. stdout is compact single-line JSON by default; use --pretty only for indented output.

Success:

{"ok":true,"requestId":"req-...","data":{}}

Failure:

{"ok":false,"requestId":"req-...","error":{"code":"...","message":"...","nextActions":[],"transient":false,"retryAfterMs":0}}

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. For asset.refresh, player build, Play Mode, Package installation (including exact version changes), Package removal, and test.run, discover the matching domain .status Tool and pass the original root requestId; status reads the same-session active phase or exact terminal without replaying the effect. Otherwise inspect business state before deciding whether to submit a new mutation.

Update And Remove

Update the global CLI, then let the AI run the installation protocol again:

npm install -g @alpsckr/unitycli@latest
unitycli init help

To remove a workspace or user Skill, delete only the selected unitycli Skill directory:

<explicit-target>/unitycli
<workspace>/.agents/skills/unitycli
<workspace>/.claude/skills/unitycli
~/.agents/skills/unitycli
~/.claude/skills/unitycli

To remove the managed Bridge, first inspect the current package.bridge-remove descriptor and follow it:

unitycli tools describe package.bridge-remove --instance C:\path\UnityProject

Remove the global CLI with:

npm uninstall -g @alpsckr/unitycli

Documentation

License

MIT

版本与发布记录

@alpsckr/unitycli 共发布 27 个版本,首次发布于 2026/08/26;过去 12 个月发布了 27 个版本。

版本发布日期距今
0.10.6latest2026/10/2414 天前
0.10.52026/10/2414 天前
0.10.42026/10/2414 天前
0.10.32026/10/2414 天前
0.10.22026/10/2315 天前
0.10.12026/10/2315 天前

关于 @alpsckr/unitycli 的常见问题

@alpsckr/unitycli 是什么?

Windows-first CLI for UnityCLI automation.

如何安装 @alpsckr/unitycli?

在项目目录运行 npm install @alpsckr/unitycli,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 unitycli,可以用 npx unitycli 直接运行。

@alpsckr/unitycli 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/alpsckr__unitycli 是否存在。

@alpsckr/unitycli 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@alpsckr/unitycli 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@alpsckr/unitycli 可以商用吗?

@alpsckr/unitycli 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@alpsckr/unitycli 的下载量有多少?

根据 npm 官方下载统计,@alpsckr/unitycli 在 2026/10/06 – 2026/11/04 这 30 天内被下载 2,371 次,日均约 79 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@alpsckr/unitycli 还在维护吗?

最新版本 0.10.6 发布于 2026/10/24(14 天前);至今共发布 27 个版本,其中过去 12 个月发布了 27 个;首次发布于 2026/08/26。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。