fix: Windows spawn, prefab path, preview API, asset deps, error messages; add execute-context resource, tool descriptions, scene/script/asset tools
Bug fixes (verified against Cocos Creator 3.8.8): - diagnostics: shell:true for .cmd/.bat on Windows (T125/T126) - prefabs: duplicatePrefab target resolves under assets/ (T420) - cocos-project: add preview.open candidate for 3.8.8 (T444) - assets-advanced: detect directory assets in inspectAssetDependencies (T110) - scene: improve component-not-found errors with compilation hint (T429) Documentation improvements: - tool-registry: add enum and injected vars to execute_javascript, path format examples, asset ref limitation note - resources: add cocos://mcp/execute-context resource with variables, patterns, pitfalls New tools (core 37->38, full 101->110): - scene-management: create_scene, query_scene_state (core), copy_paste_node, rename_node, reparent_node - scripts: create_script with component/plain templates - prefabs: create_prefab - assets-advanced: batch_asset_ops, find_unused_assets
This commit is contained in:
@@ -88,6 +88,35 @@ When adding a new tool:
|
||||
6. Add clear input schema descriptions so AI clients can choose the tool correctly.
|
||||
7. Test the tool with `tools/list` and `tools/call`.
|
||||
|
||||
### Asset Creation via Template Files
|
||||
|
||||
When a tool creates a new Cocos asset with a complex serialized format
|
||||
(scene, prefab, animation clip, material, etc.), **store a template file in
|
||||
`resources/` and pass its content to `asset-db: create-asset`** rather than
|
||||
hard-coding JSON strings in source.
|
||||
|
||||
Why:
|
||||
|
||||
- Cocos serialized formats are version-specific and contain many required
|
||||
sub-objects (e.g. a scene needs `cc.SceneGlobals` → `cc.AmbientInfo`,
|
||||
`cc.ShadowsInfo`, `cc.SkyboxInfo`, `cc.FogInfo`, `cc.OctreeInfo`,
|
||||
`cc.SkinInfo`, `cc.LightProbeInfo`, `cc.PostSettingsInfo`). Missing or
|
||||
misnamed classes cause silent import failures or runtime errors.
|
||||
- A real template file can be created/verified in the Cocos editor and
|
||||
updated by simply replacing the file.
|
||||
- `asset-db: create-asset(url, content)` handles `.meta` generation and
|
||||
import in one step — no need for `fs.writeFileSync` + `refreshAssets`.
|
||||
|
||||
Pattern:
|
||||
|
||||
1. Create the template file at `resources/template.<ext>` (e.g.
|
||||
`resources/template.scene`).
|
||||
2. Add `"resources/"` to the `files` array in `package.json` so it ships
|
||||
in the npm package.
|
||||
3. In the tool handler, read the template with `fs.readFileSync`, optionally
|
||||
replace `_name` fields, then call `create-asset` with the content string.
|
||||
4. Export a pure helper (e.g. `buildSceneContent`) for unit testing.
|
||||
|
||||
## Documentation
|
||||
|
||||
The documentation is bilingual:
|
||||
|
||||
Reference in New Issue
Block a user