cli-anything-sbox
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chineses&box CLI
s&box CLI
Agent-native CLI for the s&box game engine (Facepunch Studios, Source 2). 79+ commands across 14 groups. Manipulate , , , , , JSON files directly, generate idiomatic C# components, and run a real-time asset graph over the project.
.scene.prefab.vmat.soundInput.configCollision.config面向s&box游戏引擎(Facepunch Studios,Source 2)的Agent原生CLI。涵盖14个命令组,共79+条命令。可直接操作、、、、、等JSON文件,生成符合规范的C#组件,并在项目上运行实时资源图谱。
.scene.prefab.vmat.soundInput.configCollision.configInstallation
安装
bash
pip install git+https://github.com/HKUDS/CLI-Anything.git#subdirectory=sbox/agent-harnessbash
pip install git+https://github.com/HKUDS/CLI-Anything.git#subdirectory=sbox/agent-harnessRequirements
要求
- Python 3.10+
- s&box installed via Steam - auto-detected, or set to a custom installation directory.
SBOX_PATH - Most commands work entirely on the project's JSON files - s&box does not need to be running.
- Python 3.10+
- 通过Steam安装s&box - 会自动检测,或设置指定自定义安装目录。
SBOX_PATH - 大多数命令仅基于项目的JSON文件运行 - 无需启动s&box。
Global Options
全局选项
--json Machine-readable JSON output (always pass for agent use)
--project PATH Project directory (auto-detects from cwd .sbproj if omitted)--json 机器可读的JSON输出(Agent调用时需始终传入)
--project PATH 项目目录(若省略,会自动从当前工作目录的.sbproj文件检测)Command Groups
命令组
project - Manage s&box projects
project - 管理s&box项目
bash
cli-anything-sbox project new --name MyGame --output-dir ./MyGame
cli-anything-sbox --json project info
cli-anything-sbox project config --max-players 32 --tick-rate 64
cli-anything-sbox --json --project ./MyGame project add-package facepunch.libsdf
cli-anything-sbox --json --project ./MyGame project remove-package facepunch.libsdfbash
cli-anything-sbox project new --name MyGame --output-dir ./MyGame
cli-anything-sbox --json project info
cli-anything-sbox project config --max-players 32 --tick-rate 64
cli-anything-sbox --json --project ./MyGame project add-package facepunch.libsdf
cli-anything-sbox --json --project ./MyGame project remove-package facepunch.libsdfLint: broken asset refs, duplicate GUIDs, malformed Input.config
代码检查:损坏的资源引用、重复GUID、格式错误的Input.config
cli-anything-sbox --json --project ./MyGame project validate
cli-anything-sbox --project ./MyGame project validate --no-inputs --no-guids
undefinedcli-anything-sbox --json --project ./MyGame project validate
cli-anything-sbox --project ./MyGame project validate --no-inputs --no-guids
undefinedscene - Manipulate .scene
files
.scenescene - 操作.scene文件
bash
cli-anything-sbox scene new --name gameplay -o ./Assets/scenes/gameplay.scene
cli-anything-sbox --json scene info ./scene.scene
cli-anything-sbox --json scene list ./scene.scene
cli-anything-sbox scene add-object ./scene.scene Enemy --position "100,0,0" --components "model,box_collider,rigidbody" --tags "enemy"
cli-anything-sbox scene remove-object ./scene.scene --name Enemy
cli-anything-sbox scene add-component ./scene.scene <object-guid> Sandbox.PointLight
cli-anything-sbox scene remove-component ./scene.scene <object-guid> --component-type Sandbox.Rigidbody
cli-anything-sbox --json scene modify-object ./scene.scene --guid <guid> --name NewName --position "200,0,0"
cli-anything-sbox --json scene clone-object ./scene.scene --name Enemy --new-name EnemyCopy --position "300,0,0"
cli-anything-sbox --json scene get-object ./scene.scene --name Sun
cli-anything-sbox scene set-property ./scene.scene --fixed-update-freq 64 --timescale 0.5
cli-anything-sbox scene set-navmesh ./scene.scene --enabled --agent-height 72 --agent-radius 16
cli-anything-sbox --json scene list-presets
cli-anything-sbox --json scene modify-component ./scene.scene <object-guid> <component-guid> --properties '{"Damage":50}'bash
cli-anything-sbox scene new --name gameplay -o ./Assets/scenes/gameplay.scene
cli-anything-sbox --json scene info ./scene.scene
cli-anything-sbox --json scene list ./scene.scene
cli-anything-sbox scene add-object ./scene.scene Enemy --position "100,0,0" --components "model,box_collider,rigidbody" --tags "enemy"
cli-anything-sbox scene remove-object ./scene.scene --name Enemy
cli-anything-sbox scene add-component ./scene.scene <object-guid> Sandbox.PointLight
cli-anything-sbox scene remove-component ./scene.scene <object-guid> --component-type Sandbox.Rigidbody
cli-anything-sbox --json scene modify-object ./scene.scene --guid <guid> --name NewName --position "200,0,0"
cli-anything-sbox --json scene clone-object ./scene.scene --name Enemy --new-name EnemyCopy --position "300,0,0"
cli-anything-sbox --json scene get-object ./scene.scene --name Sun
cli-anything-sbox scene set-property ./scene.scene --fixed-update-freq 64 --timescale 0.5
cli-anything-sbox scene set-navmesh ./scene.scene --enabled --agent-height 72 --agent-radius 16
cli-anything-sbox --json scene list-presets
cli-anything-sbox --json scene modify-component ./scene.scene <object-guid> <component-guid> --properties '{"Damage":50}'Find objects matching one or more filters (AND-combined)
查找匹配一个或多个筛选条件的对象(条件为AND关系)
cli-anything-sbox --json scene query ./scene.scene --has-component rigidbody --has-tag tower
cli-anything-sbox --json scene query ./scene.scene --name-regex "^Tower\d$" --in-bounds "0,-500,-50,1000,500,50"
cli-anything-sbox --json scene query ./scene.scene --has-component rigidbody --has-tag tower
cli-anything-sbox --json scene query ./scene.scene --name-regex "^Tower\d$" --in-bounds "0,-500,-50,1000,500,50"
Extract every asset reference (.vmdl, .vmat, .vsnd, .vtex, .vpcf, .prefab) from a scene
提取场景中的所有资源引用(.vmdl、.vmat、.vsnd、.vtex、.vpcf、.prefab)
cli-anything-sbox --json scene refs ./scene.scene
cli-anything-sbox --json scene refs ./scene.scene
Apply the same modification to every object that matches a query
对所有匹配查询条件的对象应用相同修改
cli-anything-sbox --json scene bulk-modify ./scene.scene --has-tag tower --position "0,0,100" --enable
cli-anything-sbox --json scene bulk-modify ./scene.scene --has-tag tower --position "0,0,100" --enable
Structural diff between two scenes (added/removed/modified GameObjects + SceneProperties)
两个场景之间的结构差异(新增/删除/修改的GameObject及SceneProperties)
cli-anything-sbox --json scene diff ./old.scene ./new.scene
cli-anything-sbox --json scene diff ./old.scene ./new.scene
Insert a prefab as a GameObject in a scene
将预制件作为GameObject插入场景
cli-anything-sbox --json scene instantiate-prefab ./level.scene ./Assets/prefabs/bullet.prefab --position "10,0,0"
undefinedcli-anything-sbox --json scene instantiate-prefab ./level.scene ./Assets/prefabs/bullet.prefab --position "10,0,0"
undefinedprefab - Manage .prefab
files
.prefabprefab - 管理.prefab文件
bash
cli-anything-sbox prefab new --name Bullet -o ./Assets/prefabs/bullet.prefab --components "model,sphere_collider,rigidbody"
cli-anything-sbox --json prefab info ./Assets/prefabs/bullet.prefab
cli-anything-sbox prefab from-scene ./scene.scene <object-guid> -o ./Assets/prefabs/extracted.prefab
cli-anything-sbox --json prefab add-component ./prefab.prefab rigidbody
cli-anything-sbox prefab remove-component ./prefab.prefab --component-type Sandbox.Rigidbody
cli-anything-sbox --json prefab listbash
cli-anything-sbox prefab new --name Bullet -o ./Assets/prefabs/bullet.prefab --components "model,sphere_collider,rigidbody"
cli-anything-sbox --json prefab info ./Assets/prefabs/bullet.prefab
cli-anything-sbox prefab from-scene ./scene.scene <object-guid> -o ./Assets/prefabs/extracted.prefab
cli-anything-sbox --json prefab add-component ./prefab.prefab rigidbody
cli-anything-sbox prefab remove-component ./prefab.prefab --component-type Sandbox.Rigidbody
cli-anything-sbox --json prefab listAsset references inside a prefab
预制件内的资源引用
cli-anything-sbox --json prefab refs ./prefab.prefab
cli-anything-sbox --json prefab refs ./prefab.prefab
Modify component properties on a prefab (by component type or component GUID)
修改预制件上的组件属性(按组件类型或组件GUID)
cli-anything-sbox --json prefab modify-component ./prefab.prefab --component-type Sandbox.Rigidbody --properties '{"Gravity":false,"MassOverride":50}'
cli-anything-sbox --json prefab modify-component ./prefab.prefab --component-type Sandbox.Rigidbody --properties '{"Gravity":false,"MassOverride":50}'
Structural diff between two prefabs (root + named children)
两个预制件之间的结构差异(根节点及命名子节点)
cli-anything-sbox --json prefab diff ./old.prefab ./new.prefab
undefinedcli-anything-sbox --json prefab diff ./old.prefab ./new.prefab
undefinedcodegen - Generate C# code
codegen - 生成C#代码
bash
undefinedbash
undefinedPlain Component
普通组件
cli-anything-sbox codegen component --name PlayerController --methods OnUpdate,OnFixedUpdate -o ./Code/PlayerController.cs
cli-anything-sbox codegen component --name PlayerController --methods OnUpdate,OnFixedUpdate -o ./Code/PlayerController.cs
Component with [Property] fields
带[Property]字段的组件
cli-anything-sbox --json codegen component --name Tower --properties '[{"name":"Damage","type":"float","default":"25f"},{"name":"Range","type":"float","default":"500f"}]'
cli-anything-sbox --json codegen component --name Tower --properties '[{"name":"Damage","type":"float","default":"25f"},{"name":"Range","type":"float","default":"500f"}]'
Networked component (partial class) with RPC method stubs
带RPC方法存根的网络组件(分部类)
cli-anything-sbox codegen component --name NetPlayer --networked --methods OnUpdate,OnFixedUpdate --rpc-methods "Fire:Broadcast,TakeDamage:Host" -o ./Code/NetPlayer.cs
cli-anything-sbox codegen component --name NetPlayer --networked --methods OnUpdate,OnFixedUpdate --rpc-methods "Fire:Broadcast,TakeDamage:Host" -o ./Code/NetPlayer.cs
GameResource
GameResource
cli-anything-sbox codegen gameresource --name TowerData --display-name "Tower Data" --extension tower -o ./Code/TowerData.cs
cli-anything-sbox codegen gameresource --name TowerData --display-name "Tower Data" --extension tower -o ./Code/TowerData.cs
Editor menu (Editor/ assembly)
编辑器菜单(Editor/程序集)
cli-anything-sbox codegen editor-menu --name MyTools --menu-path "Editor/My Tools/Open" -o ./Editor/MyTools.cs
cli-anything-sbox codegen editor-menu --name MyTools --menu-path "Editor/My Tools/Open" -o ./Editor/MyTools.cs
Plain Razor UI component (.razor + .razor.scss)
普通Razor UI组件(.razor + .razor.scss)
cli-anything-sbox codegen razor --name HudPanel --properties '[{"name":"Score","type":"int","default":"0"}]' -o ./UI/HudPanel.razor
cli-anything-sbox codegen razor --name HudPanel --properties '[{"name":"Score","type":"int","default":"0"}]' -o ./UI/HudPanel.razor
Static or base-derived class
静态类或继承基类的类
cli-anything-sbox codegen class --name Math2 --static -o ./Code/Math2.cs
cli-anything-sbox codegen class --name Math2 --static -o ./Code/Math2.cs
PanelComponent + sibling ScreenPanel scaffold (handles the s&box quirk where
PanelComponent + 同级ScreenPanel脚手架(解决s&box的特殊限制:
PanelComponent input only works when both are on the same GameObject).
PanelComponent输入仅在两者位于同一GameObject时生效)。
Emits .razor + .razor.scss + a paste-ready GameObject snippet, or appends
生成.razor + .razor.scss + 可直接粘贴的GameObject代码片段,或通过--scene参数直接追加到场景中。
directly to a scene with --scene.
—
cli-anything-sbox --json codegen panel-component --name HudBar -o ./UI/HudBar.razor
cli-anything-sbox codegen panel-component --name Crosshair -o ./UI/Crosshair.razor --scene ./Assets/scenes/game.scene
undefinedcli-anything-sbox --json codegen panel-component --name HudBar -o ./UI/HudBar.razor
cli-anything-sbox codegen panel-component --name Crosshair -o ./UI/Crosshair.razor --scene ./Assets/scenes/game.scene
undefinedinput - Manage Input.config
Input.configinput - 管理Input.config
bash
cli-anything-sbox --json input list
cli-anything-sbox input add --name PlaceTower --group Gameplay --keyboard mouse1 --gamepad RightTrigger
cli-anything-sbox input remove --name PlaceTower
cli-anything-sbox input set --name Attack1 --keyboard mouse1bash
cli-anything-sbox --json input list
cli-anything-sbox input add --name PlaceTower --group Gameplay --keyboard mouse1 --gamepad RightTrigger
cli-anything-sbox input remove --name PlaceTower
cli-anything-sbox input set --name Attack1 --keyboard mouse1collision - Manage Collision.config
Collision.configcollision - 管理Collision.config
bash
cli-anything-sbox --json collision list
cli-anything-sbox collision add-layer --name projectile --default Collide
cli-anything-sbox collision add-rule --layer-a projectile --layer-b solid --result Collide
cli-anything-sbox collision remove-rule --layer-a projectile --layer-b solid
cli-anything-sbox collision remove-layer --name projectilebash
cli-anything-sbox --json collision list
cli-anything-sbox collision add-layer --name projectile --default Collide
cli-anything-sbox collision add-rule --layer-a projectile --layer-b solid --result Collide
cli-anything-sbox collision remove-rule --layer-a projectile --layer-b solid
cli-anything-sbox collision remove-layer --name projectilematerial - Manage .vmat
materials
.vmatmaterial - 管理.vmat材质
bash
cli-anything-sbox --json material new --name floor --shader complex --color-texture "textures/floor.tga" --metalness 0.3 -o ./Assets/materials/floor.vmat
cli-anything-sbox --json material info ./Assets/materials/floor.vmat
cli-anything-sbox --json material list
cli-anything-sbox --json material set ./Assets/materials/floor.vmat --metalness 0.8bash
cli-anything-sbox --json material new --name floor --shader complex --color-texture "textures/floor.tga" --metalness 0.3 -o ./Assets/materials/floor.vmat
cli-anything-sbox --json material info ./Assets/materials/floor.vmat
cli-anything-sbox --json material list
cli-anything-sbox --json material set ./Assets/materials/floor.vmat --metalness 0.8sound - Manage .sound
events
.soundsound - 管理.sound事件
bash
cli-anything-sbox --json sound new --name gunshot --sounds "sounds/gun1.vsnd,sounds/gun2.vsnd" --volume 0.8 -o ./Assets/sounds/gunshot.sound
cli-anything-sbox --json sound info ./Assets/sounds/gunshot.sound
cli-anything-sbox --json sound list
cli-anything-sbox --json sound set ./Assets/sounds/gunshot.sound --volume 0.5bash
cli-anything-sbox --json sound new --name gunshot --sounds "sounds/gun1.vsnd,sounds/gun2.vsnd" --volume 0.8 -o ./Assets/sounds/gunshot.sound
cli-anything-sbox --json sound info ./Assets/sounds/gunshot.sound
cli-anything-sbox --json sound list
cli-anything-sbox --json sound set ./Assets/sounds/gunshot.sound --volume 0.5localization - Manage translations
localization - 管理翻译
bash
cli-anything-sbox localization new --lang en -o ./Localization/en.json
cli-anything-sbox localization set ./Localization/en.json --key "game.title" --value "My Game"
cli-anything-sbox --json localization list ./Localization/en.json
cli-anything-sbox localization get ./Localization/en.json --key "game.title"
cli-anything-sbox localization remove ./Localization/en.json --key "game.title"
cli-anything-sbox localization bulk-set ./Localization/en.json --keys '{"ui.start":"Start","ui.quit":"Quit"}'bash
cli-anything-sbox localization new --lang en -o ./Localization/en.json
cli-anything-sbox localization set ./Localization/en.json --key "game.title" --value "My Game"
cli-anything-sbox --json localization list ./Localization/en.json
cli-anything-sbox localization get ./Localization/en.json --key "game.title"
cli-anything-sbox localization remove ./Localization/en.json --key "game.title"
cli-anything-sbox localization bulk-set ./Localization/en.json --keys '{"ui.start":"Start","ui.quit":"Quit"}'server - Dedicated server
server - 专用服务器
bash
cli-anything-sbox server info
cli-anything-sbox server start --game my_game --map facepunch.flatgrassbash
cli-anything-sbox server info
cli-anything-sbox server start --game my_game --map facepunch.flatgrassasset - Asset management & reverse lookups
asset - 资源管理与反向查找
bash
cli-anything-sbox --json asset list --type scene
cli-anything-sbox --json asset info ./Assets/scenes/minimal.scene
cli-anything-sbox asset compile ./Assets/materials/floor.vmatbash
cli-anything-sbox --json asset list --type scene
cli-anything-sbox --json asset info ./Assets/scenes/minimal.scene
cli-anything-sbox asset compile ./Assets/materials/floor.vmatWhich scenes/prefabs reference this asset?
哪些场景/预制件引用了该资源?
cli-anything-sbox --json --project ./MyGame asset find-refs models/myteam/widget.vmdl
cli-anything-sbox --json --project ./MyGame asset find-refs models/myteam/widget.vmdl
Find unreferenced assets (per type, or across all referenceable types)
查找未被引用的资源(按类型,或跨所有可引用类型)
cli-anything-sbox --json --project ./MyGame asset find-unused
cli-anything-sbox --json --project ./MyGame asset find-unused --type model --type material
cli-anything-sbox --json --project ./MyGame asset find-unused
cli-anything-sbox --json --project ./MyGame asset find-unused --type model --type material
Rename an asset and update every scene/prefab reference (extension preserved if omitted)
重命名资源并更新所有场景/预制件中的引用(若省略扩展名则保留原扩展名)
cli-anything-sbox --json --project ./MyGame asset rename models/team/widget.vmdl gizmo
cli-anything-sbox --project ./MyGame asset rename models/team/widget.vmdl gizmo --dry-run
cli-anything-sbox --json --project ./MyGame asset rename models/team/widget.vmdl gizmo
cli-anything-sbox --project ./MyGame asset rename models/team/widget.vmdl gizmo --dry-run
Move an asset across directories and update every reference
将资源移动到其他目录并更新所有引用
cli-anything-sbox --json --project ./MyGame asset move models/team/widget.vmdl models/shared/widget.vmdl
undefinedcli-anything-sbox --json --project ./MyGame asset move models/team/widget.vmdl models/shared/widget.vmdl
undefinedsession - State management
session - 状态管理
bash
cli-anything-sbox session status
cli-anything-sbox session undo
cli-anything-sbox session redobash
cli-anything-sbox session status
cli-anything-sbox session undo
cli-anything-sbox session redotest - Automated map/scene generation harness
test - 自动化地图/场景生成测试工具
bash
cli-anything-sbox test setup
cli-anything-sbox --json test runbash
cli-anything-sbox test setup
cli-anything-sbox --json test runlaunch - Open project in s&box editor
launch - 在s&box编辑器中打开项目
bash
cli-anything-sbox launchbash
cli-anything-sbox launchComponent Presets
组件预设
29 short names usable with on , , etc. Each maps to a component type.
--componentsscene add-objectprefab newSandbox.*| Preset | Component Type |
|---|---|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
scene list-presets在、等命令中使用参数时,可使用29个短名称。每个名称对应一个组件类型。
scene add-objectprefab new--componentsSandbox.*| 预设名称 | 组件类型 |
|---|---|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
scene list-presetsAgent Usage Pattern
Agent使用模式
Pass for every agent-driven invocation. Pipe through to thread GUIDs and paths between commands:
--jsonjqbash
undefined每次Agent驱动的调用都需传入参数。可通过管道结合在命令之间传递GUID和路径:
--jsonjqbash
undefinedBootstrap a project
初始化项目
sbproj=$(cli-anything-sbox --json project new --name MyGame --output-dir /tmp/MyGame | jq -r '.sbproj')
cd /tmp/MyGame
sbproj=$(cli-anything-sbox --json project new --name MyGame --output-dir /tmp/MyGame | jq -r '.sbproj')
cd /tmp/MyGame
Add a tower with a specific component layout, capture its GUID
添加一个具有特定组件布局的塔楼,捕获其GUID
guid=$(cli-anything-sbox --json scene add-object ./Assets/scenes/main.scene Tower
--components "model,box_collider,rigidbody" --tags "tower"
| jq -r '.guid')
--components "model,box_collider,rigidbody" --tags "tower"
| jq -r '.guid')
guid=$(cli-anything-sbox --json scene add-object ./Assets/scenes/main.scene Tower
--components "model,box_collider,rigidbody" --tags "tower"
| jq -r '.guid')
--components "model,box_collider,rigidbody" --tags "tower"
| jq -r '.guid')
Generate the corresponding C# component, networked
生成对应的网络版C#组件
cli-anything-sbox --json codegen component --name Tower --networked
--rpc-methods "Fire:Host" --properties '[{"name":"Damage","type":"float","default":"25f"}]'
-o ./Code/Tower.cs
--rpc-methods "Fire:Host" --properties '[{"name":"Damage","type":"float","default":"25f"}]'
-o ./Code/Tower.cs
cli-anything-sbox --json codegen component --name Tower --networked
--rpc-methods "Fire:Host" --properties '[{"name":"Damage","type":"float","default":"25f"}]'
-o ./Code/Tower.cs
--rpc-methods "Fire:Host" --properties '[{"name":"Damage","type":"float","default":"25f"}]'
-o ./Code/Tower.cs
Bulk-tweak every tower in the scene
批量调整场景中的所有塔楼
cli-anything-sbox --json scene bulk-modify ./Assets/scenes/main.scene
--has-tag tower --enable --position-y-add 50
--has-tag tower --enable --position-y-add 50
cli-anything-sbox --json scene bulk-modify ./Assets/scenes/main.scene
--has-tag tower --enable --position-y-add 50
--has-tag tower --enable --position-y-add 50
Validate before committing
提交前进行验证
cli-anything-sbox --json project validate
undefinedcli-anything-sbox --json project validate
undefinedREPL Mode
REPL模式
cli-anything-sbox$ cli-anything-sbox
cli-anything-sbox> project info
cli-anything-sbox> scene list ./Assets/scenes/main.scene
cli-anything-sbox> codegen component --name Foo -o ./Code/Foo.cs
cli-anything-sbox> quit不带任何参数运行会进入交互式REPL,带有样式化提示符:
cli-anything-sbox$ cli-anything-sbox
cli-anything-sbox> project info
cli-anything-sbox> scene list ./Assets/scenes/main.scene
cli-anything-sbox> codegen component --name Foo -o ./Code/Foo.cs
cli-anything-sbox> quitEnvironment Variables
环境变量
| Variable | Description | Default |
|---|---|---|
| s&box installation directory | Auto-detected from Steam library folders |
| Override the repo | |
| 变量 | 描述 | 默认值 |
|---|---|---|
| s&box安装目录 | 从Steam库文件夹自动检测 |
| 覆盖 | |