CLI s&box
Interface en ligne de commande native pour le moteur de jeu s&box (Facepunch Studios, Source 2). 79+ commandes réparties en 14 groupes. Manipulez directement les fichiers JSON .scene, .prefab, .vmat, .sound, Input.config, Collision.config, générez des composants C# idiomatiques et exécutez un graphe d'actifs en temps réel sur le projet.
Installation
pip install git+https://github.com/HKUDS/CLI-Anything.git#subdirectory=sbox/agent-harness
Prérequis
- Python 3.10+
- s&box installé via Steam – détection automatique, ou définissez
SBOX_PATHpour un répertoire d'installation personnalisé. - La plupart des commandes fonctionnent entièrement sur les fichiers JSON du projet – s&box n'a pas besoin d'être en cours d'exécution.
Options globales
--json Sortie JSON lisible par machine (toujours passer pour une utilisation par agent)
--project PATH Répertoire du projet (détection automatique depuis le cwd si un fichier .sbproj s'y trouve)
Groupes de commandes
project - Gérer les projets s&box
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.libsdf
# Vérification : références d'actifs cassées, GUID en double, Input.config mal formé
cli-anything-sbox --json --project ./MyGame project validate
cli-anything-sbox --project ./MyGame project validate --no-inputs --no-guids
scene - Manipuler les fichiers .scene
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}'
# Trouver des objets correspondant à un ou plusieurs filtres (combinés avec ET)
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"
# Extraire chaque référence d'actif (.vmdl, .vmat, .vsnd, .vtex, .vpcf, .prefab) d'une scène
cli-anything-sbox --json scene refs ./scene.scene
# Appliquer la même modification à chaque objet correspondant à une requête
cli-anything-sbox --json scene bulk-modify ./scene.scene --has-tag tower --position "0,0,100" --enable
# Diff structurel entre deux scènes (GameObjects ajoutés/supprimés/modifiés + SceneProperties)
cli-anything-sbox --json scene diff ./old.scene ./new.scene
# Insérer un préfabriqué en tant que GameObject dans une scène
cli-anything-sbox --json scene instantiate-prefab ./level.scene ./Assets/prefabs/bullet.prefab --position "10,0,0"
prefab - Gérer les fichiers .prefab
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 list
# Références d'actifs à l'intérieur d'un préfabriqué
cli-anything-sbox --json prefab refs ./prefab.prefab
# Modifier les propriétés d'un composant sur un préfabriqué (par type de composant ou GUID de composant)
cli-anything-sbox --json prefab modify-component ./prefab.prefab --component-type Sandbox.Rigidbody --properties '{"Gravity":false,"MassOverride":50}'
# Diff structurel entre deux préfabriqués (racine + enfants nommés)
cli-anything-sbox --json prefab diff ./old.prefab ./new.prefab
codegen - Générer du code C#
# Composant simple
cli-anything-sbox codegen component --name PlayerController --methods OnUpdate,OnFixedUpdate -o ./Code/PlayerController.cs
# Composant avec champs [Property]
cli-anything-sbox --json codegen component --name Tower --properties '[{"name":"Damage","type":"float","default":"25f"},{"name":"Range","type":"float","default":"500f"}]'
# Composant réseau (classe partielle) avec des squelettes de méthodes RPC
cli-anything-sbox codegen component --name NetPlayer --networked --methods OnUpdate,OnFixedUpdate --rpc-methods "Fire:Broadcast,TakeDamage:Host" -o ./Code/NetPlayer.cs
# GameResource
cli-anything-sbox codegen gameresource --name TowerData --display-name "Tower Data" --extension tower -o ./Code/TowerData.cs
# Menu d'éditeur (assembly Editor/)
cli-anything-sbox codegen editor-menu --name MyTools --menu-path "Editor/My Tools/Open" -o ./Editor/MyTools.cs
# Composant d'interface utilisateur Razor simple (.razor + .razor.scss)
cli-anything-sbox codegen razor --name HudPanel --properties '[{"name":"Score","type":"int","default":"0"}]' -o ./UI/HudPanel.razor
# Classe statique ou dérivée d'une classe de base
cli-anything-sbox codegen class --name Math2 --static -o ./Code/Math2.cs
# PanelComponent + échafaudage ScreenPanel associé (gère la particularité de s&box où
# l'entrée PanelComponent ne fonctionne que lorsque les deux sont sur le même GameObject).
# Émet .razor + .razor.scss + un extrait GameObject prêt à coller, ou ajoute
# directement à une scène avec --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
input - Gérer Input.config
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 mouse1
collision - Gérer Collision.config
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 projectile
material - Gérer les matériaux .vmat
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.8
sound - Gérer les événements sonores .sound
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.5
localization - Gérer les traductions
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 - Serveur dédié
cli-anything-sbox server info
cli-anything-sbox server start --game my_game --map facepunch.flatgrass
asset - Gestion des actifs et recherches inverses
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.vmat
# Quelles scènes/préfabriqués référencent cet actif ?
cli-anything-sbox --json --project ./MyGame asset find-refs models/myteam/widget.vmdl
# Trouver les actifs non référencés (par type, ou dans tous les types référençables)
cli-anything-sbox --json --project ./MyGame asset find-unused
cli-anything-sbox --json --project ./MyGame asset find-unused --type model --type material
# Renommer un actif et mettre à jour chaque référence de scène/préfabriqué (extension conservée si omise)
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
# Déplacer un actif entre répertoires et mettre à jour chaque référence
cli-anything-sbox --json --project ./MyGame asset move models/team/widget.vmdl models/shared/widget.vmdl
session - Gestion d'état
cli-anything-sbox session status
cli-anything-sbox session undo
cli-anything-sbox session redo
test - Harnais automatisé de génération de carte/scène
cli-anything-sbox test setup
cli-anything-sbox --json test run
launch - Ouvrir le projet dans l'éditeur s&box
cli-anything-sbox launch
Presets de composants
29 noms courts utilisables avec --components sur scene add-object, prefab new, etc. Chacun correspond à un type de composant Sandbox.*.
| Preset | Type de composant |
|---|---|
model | Sandbox.ModelRenderer |
box_collider | Sandbox.BoxCollider |
sphere_collider | Sandbox.SphereCollider |
capsule_collider | Sandbox.CapsuleCollider |
plane_collider | Sandbox.PlaneCollider |
model_collider | Sandbox.ModelCollider |
rigidbody | Sandbox.Rigidbody |
character_controller | Sandbox.CharacterController |
player_controller | Sandbox.PlayerController |
camera | Sandbox.CameraComponent |
light_directional | Sandbox.DirectionalLight |
light_point | Sandbox.PointLight |
spot_light | Sandbox.SpotLight |
ambient_light | Sandbox.AmbientLight |
sprite_renderer | Sandbox.SpriteRenderer |
skinned_model_renderer | Sandbox.SkinnedModelRenderer |
text_renderer | Sandbox.TextRenderer |
line_renderer | Sandbox.LineRenderer |
decal_renderer | Sandbox.DecalRenderer |
trail_renderer | Sandbox.TrailRenderer |
particle_effect | Sandbox.ParticleEffect |
sound_point | Sandbox.SoundPointComponent |
nav_mesh_agent | Sandbox.NavMeshAgent |
screen_panel | Sandbox.ScreenPanel |
world_panel | Sandbox.WorldPanel |
fixed_joint | Sandbox.FixedJoint |
hinge_joint | Sandbox.HingeJoint |
spring_joint | Sandbox.SpringJoint |
ball_socket_joint | Sandbox.BallSocketJoint |
scene list-presets retourne le registre des presets en direct au format JSON.
Modèle d'utilisation pour agent
Passez l'option --json pour chaque invocation pilotée par un agent. Utilisez jq pour chaîner les GUID et les chemins entre les commandes :
# Amorcer un projet
sbproj=$(cli-anything-sbox --json project new --name MyGame --output-dir /tmp/MyGame | jq -r '.sbproj')
cd /tmp/MyGame
# Ajouter une tour avec une disposition de composants spécifique, capturer son GUID
guid=$(cli-anything-sbox --json scene add-object ./Assets/scenes/main.scene Tower \
--components "model,box_collider,rigidbody" --tags "tower" \
| jq -r '.guid')
# Générer le composant C# correspondant, en réseau
cli-anything-sbox --json codegen component --name Tower --networked \
--rpc-methods "Fire:Host" --properties '[{"name":"Damage","type":"float","default":"25f"}]' \
-o ./Code/Tower.cs
# Modification en masse de chaque tour dans la scène
cli-anything-sbox --json scene bulk-modify ./Assets/scenes/main.scene \
--has-tag tower --enable --position-y-add 50
# Valider avant de valider
cli-anything-sbox --json project validate
Mode REPL
cli-anything-sbox sans argument entre dans un REPL interactif avec une invite stylisée :
$ 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
Variables d'environnement
| Variable | Description | Par défaut |
|---|---|---|
SBOX_PATH | Répertoire d'installation de s&box | Détection automatique à partir des dossiers de bibliothèque Steam |
CLI_ANYTHING_SKILL_REPO | Remplace le dépôt que repl_skin lit SKILL.md | HKUDS/CLI-Anything |