unity-cli
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseUnity CLI
Unity CLI
One CLI () drives the Unity Editor/Player. The default authoring surface is
grouped into six agent-facing domains so only the relevant schema enters context;
control-plane and project custom commands use explicit views.
is a control-plane CLI discovery operation, not the canonical
package contract . Its CLI flags are never arguments,
and discovery invocations must not be represented as canonical command routes.
Only use when the user explicitly requests that package contract.
The records returned by discovery carry authoring, custom, or control-plane tiers.
cscs list-commandscommand/listcommand/listcommand/list一个 CLI()可驱动 Unity Editor/Player。默认创作界面按六个面向 Agent 的领域划分,因此只有相关 schema 会进入上下文;control-plane 和项目 custom commands 使用显式视图。
是 control-plane CLI 的发现操作,而不是规范的 package contract 。它的 CLI flags 绝不能作为 的参数,发现调用也不得表示为规范的 command routes。
仅当用户明确请求该 package contract 时,才使用 。
发现操作返回的 records 带有 authoring、custom 或 control-plane 层级。
cscs list-commandscommand/listcommand/listcommand/listRunning cs
cs运行 cs
cscsbash
python "<SKILL_DIR>/scripts/cli/cs.py"<SKILL_DIR>csDo not enumerate other skill installations or run to rediscover this
documented surface; this file and its returned Route Cards are complete for
routing.
cs --helpDo not pass during normal use. The CLI locates the Unity project by
walking up from both the working directory and its own committed location.
is only for deliberately targeting a different project.
--project--project <path>The CLI runs in place; there is no bootstrap or copy step. is a
convenience, not a gate. If the package is absent or is used, setup
writes the shared . Before any write-producing setup,
state the exact source it will add and obtain the user's approval. See
.
cs setup--updatePackages/manifest.jsonreferences/setup.md下文中的 表示:
csbash
python "<SKILL_DIR>/scripts/cli/cs.py"<SKILL_DIR>cs不要枚举其他 skill 安装,也不要运行 重新探查这一已文档化的界面;此文件及其返回的 Route Cards 已完整覆盖路由需求。
cs --help正常使用期间不要传入 。CLI 会从工作目录及其自身提交位置分别向上查找 Unity 项目。
仅用于有意指定另一个项目。
--project--project <path>CLI 会原地运行;无需 bootstrap 或复制步骤。 是一项便捷功能,而不是必经关卡。如果 package 不存在或使用了 ,setup 会写入共享的 。在任何会产生写入的 setup 之前,必须说明它将添加的确切 source,并获得用户批准。请参阅 。
cs setup--updatePackages/manifest.jsonreferences/setup.mdPassing inputs
传入输入
Never pass C# code or structured command parameters inline through the shell.
Write a file, then pass its absolute path:
- Raw C# for goes in a
execfile via.cs.--file - Structured parameters for and
commandgo in a JSON file viabatch.--input
The mandatory scratch directory is:
text
<project-root>/Temp/CSharpConsole/AgentScratch/This is inside Unity's managed , is not imported, and is normally ignored
by git. Always use the full absolute path. Name files for the semantic task and
overwrite the same file when revising it serially; use a random suffix only when
another agent is known to work on the same Unity project concurrently.
Temp/Scratch payloads are one-shot. Put reusable C# in the snippet library. Clean only
; never delete , which contains service state.
Never write REPL payloads under : importing them can break project
compilation and prevent the service from restarting.
AgentScratch/Temp/CSharpConsole/Assets/bash
cs exec --file "<project-root>/Temp/CSharpConsole/AgentScratch/inspect-camera.cs"
cs command --json --input "<project-root>/Temp/CSharpConsole/AgentScratch/req-create-cube.json"
cs batch --json --input "<project-root>/Temp/CSharpConsole/AgentScratch/req-batch.json"绝不通过 shell 内联传递 C# 代码或结构化 command 参数。
应先写入文件,然后传入其绝对路径:
- 的原始 C# 写入
exec文件,并通过.cs传入。--file - 和
command的结构化参数写入 JSON 文件,并通过batch传入。--input
必须使用以下 scratch 目录:
text
<project-root>/Temp/CSharpConsole/AgentScratch/该目录位于 Unity 管理的 内,不会被导入,并且通常会被 git 忽略。始终使用完整绝对路径。按语义任务为文件命名;串行修改时覆盖同一文件。只有在已知另一个 Agent 正在并发处理同一 Unity 项目时,才使用随机后缀。
Temp/Scratch 载荷只能使用一次。将可复用的 C# 放入 snippet library。仅清理 ;绝不删除 ,其中保存着服务状态。
绝不将 REPL 载荷写入 下:导入这些载荷可能破坏项目编译,并阻止服务重新启动。
AgentScratch/Temp/CSharpConsole/Assets/bash
cs exec --file "<project-root>/Temp/CSharpConsole/AgentScratch/inspect-camera.cs"
cs command --json --input "<project-root>/Temp/CSharpConsole/AgentScratch/req-create-cube.json"
cs batch --json --input "<project-root>/Temp/CSharpConsole/AgentScratch/req-batch.json"REPL sessions
REPL 会话
cs execusingbash
cs exec --session agent-a1b2c3 --file "<project-root>/Temp/CSharpConsole/AgentScratch/inspect-camera.cs"
cs exec --session agent-a1b2c3 --file "<project-root>/Temp/CSharpConsole/AgentScratch/use-camera.cs"Never share a session between unrelated tasks or agents. A domain reload clears
session state, so after rebuild the context or use a new id. See
for lifecycle and reset details.
cs refreshreferences/exec-code.mdcs execusingbash
cs exec --session agent-a1b2c3 --file "<project-root>/Temp/CSharpConsole/AgentScratch/inspect-camera.cs"
cs exec --session agent-a1b2c3 --file "<project-root>/Temp/CSharpConsole/AgentScratch/use-camera.cs"绝不要在无关任务或 Agent 之间共享会话。Domain reload 会清除会话状态,因此在执行 后,应重新构建上下文或使用新 id。有关生命周期和重置细节,请参阅 。
cs refreshreferences/exec-code.mdRouting
路由
Use this canonical order for every task: built-in command → project custom
command → snippet → raw exec. Do not skip a matching built-in in favor of C#.
The package registry is the executable contract authority; the committed custom
catalog is only a shared shortlist.
For a structured Unity operation, finish discovery before loading execution
details:
The routine built-in authoring discovery budget is one Route Card call per
non-empty tier, then one exact-ID call total. Only a genuinely new requirement
after closure permits one narrow built-in lookup, with its reason recorded.
Keep a discovery ledger. Scope that ledger to the current agent session and
resolved project target. Its key includes selector kind ( or ),
normalized view, tier, sorted selectors, and resolution mode (, ,
or explicit ), plus projection/detail mode ( or ).
Mark a signature in flight before launch and completed after success; a completed
or in-flight signature must be reused or awaited. Never use an offline entry to
satisfy the required live comparison. A stored live or refresh entry may satisfy
the otherwise identical offline request only for the same project, ledger
generation, and detail mode after ; no other cross-mode or
cross-detail reuse is valid. The ledger is in-memory agent bookkeeping; do not
query wall-clock time or create a ledger file.
Refresh is an exclusive barrier: wait for every in-flight lookup for that project,
then launch refresh alone. Only a refresh result with and
creates a new ledger generation; record that refresh as its
first entry and invalidate the older completed entries. A stale-cache or fallback
refresh never advances the generation or satisfies a later offline lookup; discard
any late result from an older ledger generation instead of recording or using it.
Do not retry a live or refresh lookup after timeout or an unknown terminal state;
stop and report its state as uncertain. Only an offline lookup with a confirmed
non-zero exit and no result may be retried once, under the same ledger entry and
with its reason recorded. A successful lookup is never resent.
domainidliveofflinerefreshcompactverbosecacheStored:truesource:"live"cacheStored:true- Close domains before calling. Build the complete Core and Advanced domain
sets from every requested mutation, prerequisite, explicit invariant,
independent proof, and fallback check. The table below is the routine Domain
Index; skip an unfiltered index call. The Advanced-only list is conditional,
not a checklist: direct editing,
prefab/asset_*, asset-folder creation, and Scene View capture are Advanced.prefab/unpackandprefab/createstay inprefab/instantiate; generic prefab enumeration stays inprefabs/core. The same domain may belong to both tiers. A folder plus material workflow putsassets/corein both sets: folder creation is Advanced, while material creation, inspection, and assignment are Core. Never let an Advanced intent replace another requested Core operation in that domain. When prefab-domain intents exist, omitassetsonly if all of them are directprefabs/coreoperations orprefab/asset_*. Every domain/tier selection must map to an affirmative requested operation; exclusions, examples, and parallelism never widen the query set. An explicitly named read or proof selects its tier, while a generic read-back for a mutation does not because the exact bundle supplies its direct relation. A possible later drill-down never widens the initial domain sets; wait until an upstream read makes it necessary. A domain whose only possible use is such a deferred drill-down is empty and must be omitted. For example, a hierarchy-wide scene scan does not selectprefab/unpackmerely because one returned object might later need inspection; the scan/report intent is the hierarchy read, not an implicit per-object or per-component read. For a scan of every prefab-asset hierarchy, enumeration isobjectsand hierarchy inspection isassets/core; omitprefabs/advanced.prefabs/core - Run the Route Card round. Use exactly one multi-domain query for each
non-empty tier. The compact result retains because it guards generation continuity. The first live call performs the session's one fingerprint comparison. When both tiers are non-empty in a live workflow, Core is the first live call; Advanced may be first only when Core is empty. Finish that live call before any later offline tier call. If it reports
cacheStoredwithsource:"live", stop and report the persistence failure instead of mixing registry generations. A generated fallback may continue planning-only. In an explicit offline/no-project dry-run, addcacheStored:falseimmediately and, when both tiers are non-empty, launch the Core and Advanced queries together in one tool round. Do not probe--offline, the filesystem, or the working directory to reconfirm supplied context. If Core alone reveals that a requested operation needs Advanced, make the one Advanced call for all such unresolved operations. A stale cache or generated fallback is planning-only; execution requires a registry verified live during that invocation.status - Run the exact round once. Wait for every Route Card call to finish before
building the one exact-ID command. Take the union of IDs selected from every
tier and branch, closing it over every mutation, producer, consumer, loop
branch, invariant, and proof; copy IDs only from returned cards.
Issue one multi-ID exact query in exactly one shell invocation. The domain-query
parallelism rule never applies to exact discovery: do not split the union into
parallel or later calls, and do not add a later exact lookup for any original
task requirement. Do not exact-load a conditional drill-down whose necessity
depends on a future read. Omit deferred drill-downs from both the exact selector
set and the invocation plan; record only their trigger in prose until it fires.
Invocation-plan routes are executable in the current phase, so never add a
deferred route with an "if" or "when" purpose. In a broad scan, a per-item
getter whose contract does not name the required diagnostic signal cannot close
that gap; record the capability gap instead of selecting the getter.
Runtime selector binding alone does not make a known consumer conditional;
include its contract in the original closure. After a read justifies genuinely
new drill-down IDs, combine them into at most one narrow follow-up lookup.
Treat ,
selected, andrelatedas one closed result:deniedandselectedare complete executable contracts, whilerelatedentries are non-executable policy records, not contracts. Remove every returned ID from the unresolved set and never query one merely to promote it todenied.selectedis the complete direct, deduplicated prepare/read-back layer, not a recursive expansion. A denied requested intent is terminal: stop as blocked and do not enter fallback. Contract evidence is closed-world for task-specific signals: a generic result container or summary does not promise an unnamed marker or field. If the executable bundle lacks a required capability or proof, or a limitation blocks one, record a capability gap instead of probing for a stronger built-in. Selected and related contract entries are capabilities, not mandatory invocations; use one only for a requested mutation, prerequisite, or independent proof.related - Plan concrete invocations. Assign each postcondition to the smallest
independent proof and remove fully redundant reads. Deduplicate contracts, not
invocations. An explicit verifier limitation is authoritative; another generic
read closes it only when that read's own contract names the required
postcondition, otherwise record a proof gap. Do not collapse materially
different argument values or user-named selectors into prose: retain one
template for each distinct argument branch and one invocation for each explicit
read-back target; a uniform generated series may remain one counted loop. A
counted uniform series uses its first generated item as the concrete template.
When a producer can create an object under its requested known parent, create
it at that parent directly; do not add a later reparent mutation. When argument
behavior branches by a predicate such as parity, use the first member of every
branch as its template; do not substitute arbitrary later samples. One contract
supports all of them without more discovery. Do not add speculative existence,
conflict, or overwrite prechecks unless the task or selected contract requires
them. A default may satisfy an exact invariant without making the invariant
optional:
a newly created Cube already has exactly one ; use it instead of adding another, but retain “exactly one” as an explicit requirement and proof obligation. Never use a current or default value to drop an explicitly requested assignment: for example, still plan
BoxColliderwhen the user asks to set that existing collider'scomponent/modify, even when its default already matches.m_IsTrigger - Separate planning from execution. A dry-run still plans every supported requested mutation; state separately that nothing was executed. Static batches may use caller-defined deterministic paths. When Unity chooses an identity, execute the producer separately and bind consumers to its returned selector instead of predicting a name. Discover a repair only when it may execute; missing rules keep diagnosis read-only and exclude repair commands from domain selection, exact lookup, and the invocation plan. A transport failure after mutation leaves state uncertain: read back first and never blindly repeat a non-idempotent create, duplicate, destroy, import, or equivalent mutation.
bash
cs list-commands [--offline] --domain scene --domain objects --tier core --json
cs list-commands --offline --id gameobject/create --id gameobject/get --jsonIn a returned contract, means there are no named parameters; do
not invent an argument named . Only an actual request uses the
outer wrapper.
arguments: []argscommand"args": {}Do not mix with ; use only with domains. Preserve
or when exact-loading an ID from that view;
authoring IDs use the default view.
--domain--id--tier--view control--view customFor planning or discovery only, do not load ; these
routing rules plus the returned Route Cards and Contract Bundle are complete.
Before invoking or , read completely
once for the request, preflight, and retry protocol. Then write exactly
to the mandatory scratch JSON file and run
; is required even when empty.
references/commands.mdcommandbatchreferences/commands.md{"id":"<canonical-id>","args":{...}}cs command --json --input <file>argsDiscover contracts only through ; never read or search
, generated registry data, routing metadata, or Python
implementation files to recover command details. Those files are
non-agent-facing implementation data and may be much larger than the selected
contract bundle.
list-commandsscripts/cliEnter fallback only after the complete built-in plan has a concrete gap. Run
, load a suggested exact custom contract, then try
, and finally raw . Do not return to
built-in discovery for a requirement knowable before fallback; a genuinely new
requirement permits one narrow exact lookup with the reason recorded. If no Unity
project is available, mark custom and snippet stages unavailable without probing
them. An unavailable fallback stage is not selected; do not load its reference.
Merely describing the fallback order does not select a stage. Load its reference
only immediately before performing that stage's documented operation. The
selected custom-contract lookup is the fallback-stage exception to the built-in
one-exact budget. A dry-run that stops before authoring raw C# records the
decision without reading .
cs catalog listcs snippets search "<intent>"execexecreferences/exec-code.mdUse only when the user explicitly asks to update
the command list. Do not load or print the unfiltered 62-command package registry
during routine work.
cs list-commands --refresh …| Domain | Positive intent | Exclude / route elsewhere |
|---|---|---|
| Editor state, play mode, test runs, console maintenance | Scene contents, object selection, asset files |
| Scene listing/open/save and hierarchy-wide reads, including component summaries | Properties of an identified GameObject/component, prefab contents |
| Operations on an explicitly identified scene GameObject, component, transform, or selection | Hierarchy-wide scans, unknown future targets, project assets, prefab-file editing |
| Asset search/import/CRUD, materials, and ScriptableObjects | Scene hierarchy, prefab contents |
| Create/instantiate/unpack or directly inspect/edit prefab contents | Generic prefab enumeration ( |
| Scene/Game screenshots and Profiler recording | Structured state inspection |
The five control-plane contracts are outside the default authoring view. Inspect
them only when the user's requested capability is itself control-plane, using
. Merely using
for discovery does not justify querying the control view or
loading or planning the contract.
--view control --domain control --tier control-planecs list-commandscommand/listeditor/menu.openeditor/window.openlist-commands --iddeniedinvoke=falseexec每项任务都应遵循这一规范顺序:built-in command → project custom command → snippet → raw exec。如果存在匹配的 built-in,不要跳过它而改用 C#。
Package registry 是可执行契约的权威来源;已提交的 custom catalog 只是共享候选清单。
对于结构化 Unity 操作,在加载执行详情之前完成发现:
例行 built-in 创作发现预算为每个非空 tier 进行一次 Route Card 调用,然后总共进行一次 exact-ID 调用。仅在闭包完成后出现真正的新需求时,才允许进行一次窄范围 built-in 查找,并记录原因。
维护一份 discovery ledger。将该 ledger 限定到当前 Agent 会话和已解析的项目目标。其 key 包含 selector kind( 或 )、normalized view、tier、排序后的 selectors、resolution mode(、 或显式 ),以及 projection/detail mode( 或 )。在启动前将 signature 标记为 in-flight,成功后标记为 completed;已完成或进行中的 signature 必须复用或等待。绝不能用 offline entry 满足必需的 live comparison。只有在同一 project、ledger generation 和 detail mode 下,且发生在 之后,存储的 live 或 refresh entry 才可满足其他方面相同的 offline 请求;其他跨 mode 或跨 detail 的复用均无效。该 ledger 是内存中的 Agent 记账;不要查询挂钟时间,也不要创建 ledger 文件。
Refresh 是排他性屏障:等待该 project 的所有 in-flight lookup 完成,然后单独启动 refresh。只有同时包含 和 的 refresh 结果才能创建新的 ledger generation;将该 refresh 记录为首个条目,并使较早的 completed 条目失效。陈旧缓存或 fallback refresh 绝不会推进 generation,也不会满足后续 offline lookup;应丢弃来自较早 ledger generation 的迟到结果,而不是记录或使用它。
发生 timeout 或未知终态后,不要重试 live 或 refresh lookup;应停止并将其状态报告为不确定。只有已确认以非零状态退出且没有结果的 offline lookup 才可在同一 ledger entry 下重试一次,并记录原因。成功的 lookup 绝不重新发送。
domainidliveofflinerefreshcompactverbosecacheStored:truesource:"live"cacheStored:true- 调用前先闭合领域。 根据每项请求的 mutation、prerequisite、显式 invariant、独立 proof 和 fallback check,构建完整的 Core 与 Advanced domain 集合。下方表格是例行 Domain Index;不要执行未筛选的 index 调用。Advanced-only 列表是条件性的,而不是核对清单:直接进行 编辑、
prefab/asset_*、asset-folder 创建以及 Scene View capture 属于 Advanced。prefab/unpack和prefab/create仍归入prefab/instantiate;通用 prefab 枚举仍归入prefabs/core。同一 domain 可以同时属于两个 tier。folder 与 material 工作流会将assets/core同时加入两个集合:folder 创建属于 Advanced,而 material 的创建、检查和赋值属于 Core。绝不能让 Advanced 意图替代该 domain 中另一项已请求的 Core 操作。存在 prefab-domain 意图时,只有当所有意图均为直接assets操作或prefab/asset_*时,才能省略prefab/unpack。 每项 domain/tier 选择都必须对应明确请求的操作;排除项、示例和并行操作绝不扩大查询集合。明确点名的 read 或 proof 会选择其 tier,而 mutation 的一般性 read-back 不会,因为 exact bundle 已提供其直接关联。潜在的后续 drill-down 绝不扩大初始 domain 集合;应等待上游 read 证明确有必要后再进行扩展。如果某个 domain 的唯一潜在用途仅是这种延后的 drill-down,则该 domain 为空,必须省略。例如,层级范围的 scene scan 不会仅因为某个返回对象之后可能需要检查就选择prefabs/core;scan/report 意图是层级读取,而不是隐含的逐对象或逐 component 读取。要扫描每个 prefab-asset 的 hierarchy 时,枚举属于objects,hierarchy 检查属于assets/core,并省略prefabs/advanced。prefabs/core - 执行 Route Card 轮次。 每个非空 tier 恰好使用一次 multi-domain query。Compact 结果会保留 ,因为它用于保护 generation 连续性。第一次 live 调用会执行本会话唯一的一次 fingerprint comparison。当 live workflow 中两个 tier 都非空时,Core 是第一个 live 调用;仅当 Core 为空时,Advanced 才可先执行。必须在任何后续 offline tier 调用之前完成该 live 调用。如果调用报告
cacheStored且source:"live",则停止并报告持久化失败,而不是混用 registry generations。生成的 fallback 可以继续用于仅规划操作。在显式 offline/no-project dry-run 中,立即添加cacheStored:false;当两个 tier 都非空时,在同一 tool round 中同时启动 Core 和 Advanced 查询。不要探测--offline、文件系统或工作目录来重新确认已提供的上下文。如果仅从 Core 就发现某项请求的操作需要 Advanced,则为所有此类未解决操作进行一次 Advanced 调用。陈旧缓存或生成的 fallback 仅用于规划;执行要求在本次调用中以 live 方式验证 registry。status - 只执行一次 exact 轮次。 在构建唯一的 exact-ID 命令前,等待所有 Route Card 调用完成。取得每个 tier 和 branch 中 selected 的 ID 并集,使其覆盖每项 mutation、producer、consumer、loop branch、invariant 和 proof;只能从返回的 cards 中复制 ID。
必须且仅在一次 shell invocation 中发出一次 multi-ID exact query。domain-query 的并行规则绝不适用于 exact discovery:不要将并集拆分到并行或后续调用中,也不要为原始任务需求增加后续 exact lookup。不要 exact-load 其必要性取决于未来 read 的条件性 drill-down。应从 exact selector 集合和 invocation plan 中同时省略延后的 drill-down;在其触发前,只在说明文字中记录触发条件。Invocation-plan 中的 routes 在当前阶段必须可执行,因此绝不添加以“if”或“when”为目的的延后 route。在广泛 scan 中,如果某项逐项 getter 的 contract 未指明所需的 diagnostic signal,就不能用它弥补缺口;应记录 capability gap,而不是选择该 getter。仅凭 runtime selector binding 不会使已知 consumer 变成条件性操作;应将其 contract 纳入原始闭包。当一次 read 证明确实需要新的 drill-down ID 时,将它们合并到最多一次窄范围的后续 lookup 中。
将 、
selected和related视为一个闭合结果:denied和selected是完整的可执行 contracts,而related条目是不可执行的 policy records,并非 contracts。从 unresolved 集合中移除每个返回的 ID,绝不能仅为将某个 ID 提升为denied而查询它。selected是完整、直接、去重的 prepare/read-back 层,而不是递归扩展。被拒绝的请求意图是终态:停止并将其视为 blocked,绝不进入 fallback。对于任务专属 signals,contract 证据采用封闭世界规则:通用 result container 或 summary 并不承诺任何未点名的 marker 或 field。如果可执行 bundle 缺少所需 capability 或 proof,或某项限制阻塞了它,则记录 capability gap,而不是探测更强的 built-in。related和selectedcontract 条目代表 capabilities,而非强制 invocations;仅在它们对应已请求的 mutation、prerequisite 或独立 proof 时才使用。related - 规划具体调用。 为每个 postcondition 分配最小的独立 proof,并移除完全冗余的 reads。去重对象是 contracts,而不是 invocations。显式 verifier limitation 具有权威性;只有当另一个通用 read 自身的 contract 指明所需 postcondition 时,它才能弥补该限制,否则应记录 proof gap。绝不将实质不同的 argument values 或用户点名的 selectors 合并到说明文字中:为每个不同的 argument branch 保留一个模板,并为每个显式 read-back target 保留一次 invocation;统一生成的 series 可以保留为一次计数 loop。计数统一 series 使用其首个生成项作为具体模板。当 producer 可以在请求的已知 parent 下创建对象时,直接在该 parent 下创建;不要增加后续 reparent mutation。当 argument 行为依据 parity 等 predicate 分支时,使用每个 branch 的首个成员作为模板;不要替换为任意后续样本。无需更多发现,一个 contract 即可支持所有这些分支。除非任务或 selected contract 有要求,不要添加推测性的 existence、conflict 或 overwrite precheck。默认行为可以满足精确 invariant,而不会使该 invariant 变成可选项:新建的 Cube 已经恰好包含一个 ,因此直接使用它而不必再添加另一个,但仍须将“恰好一个”保留为显式要求和 proof obligation。绝不能使用当前值或默认值来省略显式请求的赋值。例如,即使用户要求设置的现有 collider 的
BoxCollider默认值已经匹配,仍须规划m_IsTrigger。component/modify - 将规划与执行分离。 Dry-run 仍须规划每项受支持的已请求 mutation;并另行说明未执行任何操作。Static batches 可以使用调用方定义的确定性 paths。当 Unity 自行选择 identity 时,分别执行 producer,并将 consumers 绑定到其返回的 selector,而不是预测名称。仅当 repair 可能实际执行时才进行发现;如果缺少规则,诊断应保持只读,并从 domain selection、exact lookup 和 invocation plan 中排除 repair commands。Mutation 之后发生 transport failure 会使状态处于不确定状态:先执行 read-back,绝不盲目重复非幂等的 create、duplicate、destroy、import 或同等 mutation。
bash
cs list-commands [--offline] --domain scene --domain objects --tier core --json
cs list-commands --offline --id gameobject/create --id gameobject/get --json在返回的 contract 中, 表示没有命名参数;不要发明名为 的参数。只有实际的 request 才使用外层 wrapper。
arguments: []argscommand"args": {}不要混用 和 ;仅在 domain 查询中使用 。从 control 或 custom 视图 exact-load ID 时,应保留相应的 或 ;authoring IDs 使用默认视图。
--domain--id--tier--view control--view custom仅在规划或发现阶段,不要加载 ;这些路由规则以及返回的 Route Cards 和 Contract Bundle 已完整覆盖需求。
调用 或 前,针对该请求完整读取一次 ,以了解 request、preflight 和 retry protocol。然后将完全符合 的内容写入必需的 scratch JSON 文件,并运行 ;即使值为空,也必须提供 。
references/commands.mdcommandbatchreferences/commands.md{"id":"<canonical-id>","args":{...}}cs command --json --input <file>args仅通过 发现 contracts;绝不读取或搜索 、生成的 registry data、routing metadata 或 Python implementation files 来恢复 command details。这些文件并非面向 Agent 的实现数据,其体积可能远大于 selected contract bundle。
list-commandsscripts/cli仅当完整的 built-in plan 出现明确缺口时,才进入 fallback。运行 ,加载建议的 exact custom contract,然后尝试 ,最后才使用 raw 。对于 fallback 前已经可知的需求,不要返回 built-in discovery;真正的新需求允许进行一次窄范围 exact lookup,并记录原因。如果没有可用的 Unity 项目,不要探测 custom 和 snippet stages,而应将其标记为 unavailable。Unavailable fallback stage 不算 selected,因此不要加载其 reference。仅仅描述 fallback 顺序并不表示选择了某个 stage。只有在立即执行该 stage 的已文档化操作之前,才加载其 reference。Selected custom-contract lookup 是 built-in 单一 exact 查询预算在 fallback stage 中的例外。Dry-run 在编写 raw C# 前停止时,只需记录 决策,而无需读取 。
cs catalog listcs snippets search "<intent>"execexecreferences/exec-code.md仅当用户明确要求更新 command list 时,才使用 。例行工作中,不要加载或打印未筛选的 62-command package registry。
cs list-commands --refresh …| 领域 | 明确意图 | 排除或路由至其他位置 |
|---|---|---|
| Editor 状态、play mode、测试运行、console 维护 | Scene 内容、对象选择、asset 文件 |
| Scene 列出、打开、保存和 hierarchy-wide reads,包括 component summaries | 已识别 GameObject/component 的属性、prefab 内容 |
| 对明确识别的 scene GameObject、component、transform 或 selection 执行操作 | Hierarchy-wide scans、未知的未来目标、project assets、prefab-file editing |
| Asset 搜索、导入、CRUD、materials 和 ScriptableObjects | Scene hierarchy、prefab 内容 |
| 创建、实例化、解包,或直接检查和编辑 prefab 内容 | 通用 prefab 枚举( |
| Scene/Game screenshots 和 Profiler recording | 结构化状态检查 |
五个 control-plane contracts 位于默认 authoring view 之外。仅当用户请求的能力本身属于 control-plane 时,才使用 检查它们。仅仅使用 进行发现,并不构成查询 control view 或加载、规划 contract 的理由。
--view control --domain control --tier control-planecs list-commandscommand/listeditor/menu.openeditor/window.openlist-commands --iddeniedinvoke=falseexecDebugging a running player
调试正在运行的 Player
When the question is about what a player actually does, open the runtime channel
before investigating anything else. names the process
that answers. Follow the command-first routing order for state inspection; use
for state the available commands cannot read.
cs health --mode runtimecs exec --mode runtime --file <file>Use the running process as the primary source for runtime state. If execution is
unavailable or the question concerns which code a build contains, inspect logs,
source and build artifacts as supporting evidence. Match build GUIDs where
available, distinguish current source from shipped code, and label inferences.
A substring hit or file timestamp alone does not establish which code executed.
A runtime submission is refused with when the editor
holds no compile set for the build the player reports. Ask the user for that
build's compile-set ZIP at once, naming the build. By default it is exported as
beside the build output on the build machine;
Project Settings > C# Console can change its path or disable export. Ask whoever
built it for the matching ZIP. If a candidate is already available, checking its
build GUID is useful evidence; do not register it or choose skip without the
user's decision. File inspection does not bypass the runtime execution gate.
[REPL ALIGNMENT REQUIRED]CSharpConsoleCompileSet.zipRead a player log by collecting it first:
returns the path of the file it writes, which can then be searched locally.
A foreground follow streams the whole log, shader chatter included.
cs logs --mode runtime --background当问题涉及 Player 的实际行为时,在调查其他内容之前先打开 runtime channel。 会给出负责应答的进程名称。对于状态检查,遵循 command-first 的路由顺序;对于可用 commands 无法读取的状态,使用 。
cs health --mode runtimecs exec --mode runtime --file <file>应将运行中的进程作为 runtime state 的主要来源。如果无法执行,或问题关注某个 build 包含哪些代码,则将日志、源代码和 build artifacts 作为辅助证据进行检查。在可用时匹配 build GUIDs,区分当前源代码与已交付代码,并标注推断。仅凭子字符串命中或文件时间戳无法确定实际执行了哪段代码。
当 Editor 中没有 Player 所报告 build 的 compile set 时,runtime submission 会被拒绝并显示 。立即向用户索取该 build 的 compile-set ZIP,并明确说明 build 名称。默认情况下,它会导出为 ,位于 build machine 上 build 输出旁边;Project Settings > C# Console 可以更改其路径或禁用导出。向 build 的创建者索取匹配的 ZIP。如果已有候选文件,检查其 build GUID 是有用的证据;但未经用户决定,不得注册它或选择跳过。文件检查不能绕过 runtime execution gate。
[REPL ALIGNMENT REQUIRED]CSharpConsoleCompileSet.zip读取 Player 日志时,先采集日志: 会返回其写入文件的路径,随后可在本地搜索该文件。前台 follow 会流式输出完整日志,包括 shader chatter。
cs logs --mode runtime --backgroundOther subcommands
其他 subcommands
| Task | Subcommand | Detail |
|---|---|---|
| Raw C# fallback | | |
| Reusable C# | | |
| Snippet audit | | |
| Refresh and compile | | |
| Readiness diagnosis / wait | | |
| Unity Test Framework runs | | |
| Editor log inspection | | |
| A running player, and its files | | |
| Compiling for a player's build | | |
| Watching a log as it is written | | |
| Custom-command catalog | | |
| Package / connection state | | |
| Package setup | | |
| 任务 | Subcommand | 详情 |
|---|---|---|
| Raw C# fallback | | |
| 可复用 C# | | |
| Snippet 审计 | | |
| Refresh 和编译 | | |
| 就绪诊断或等待 | | |
| Unity Test Framework 运行 | | |
| Editor 日志检查 | | |
| 正在运行的 Player 及其文件 | | |
| 为 Player build 编译 | | |
| 实时观察日志写入 | | |
| Custom-command catalog | | |
| Package 或连接状态 | | |
| Package setup | | |
Output conventions
输出约定
- Use on
--json,command, andlist-commands. In the default compact form, checkbatchand the CLI process exit status. Addokonly for diagnostics; its full envelope also exposes--verbose, which must agree with the process status.exitCode - Other subcommands print a cheaper text form. Add to
--jsononly when its structured envelope is specifically needed.exec - A version mismatch means the installed package and CLI are on different
lines, and every command that drives Unity is refused (exit 1) until they agree.
major.minorandcs setupare exempt so the mismatch can be fixed and seen; commands that never reach Unity —cs status,cs doctor, offline listings — are unaffected. Followcs wait-ready.references/setup.md - Expanded CLI commands and JSON payloads are agent-internal. When Unity must be
opened or focused, tell the user what action is needed in plain language, then
run yourself to verify the result.
cs status
- 对 、
command和list-commands使用batch。在默认 compact 形式下,检查--json和 CLI 进程退出状态。仅在诊断时添加ok;其完整 envelope 还会公开--verbose,该值必须与进程状态一致。exitCode - 其他 subcommands 会输出开销更低的形式。仅在明确需要结构化 envelope 时,才为 添加
exec。--json - Version mismatch 表示已安装的 package 和 CLI 位于不同的 版本线上。在两者一致之前,所有驱动 Unity 的 commands 都会被拒绝并以 exit 1 退出。
major.minor和cs setup不受此限制,以便修复并查看 mismatch;永远不会访问 Unity 的 commands——cs status、cs doctor和 offline listings——不受影响。请参阅cs wait-ready。references/setup.md - 展开后的 CLI commands 和 JSON payloads 属于 Agent 内部内容。当必须打开或聚焦 Unity 时,先用通俗语言告诉用户需要执行的操作,然后自行运行 验证结果。
cs status