cocos-vscene
npx skills add https://github.com/jerikchan/cocos-vscene --skill cocos-vscene
Agent 安装分布
Skill 文档
Cocos VScene – Scene Index & Analysis System
Design Philosophy
VScene = Index (ç´¢å¼) + Analysis (åæ)
âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
â VScene System â
âââââââââââââââââââââââââââ¬ââââââââââââââââââââââââââââââââââââ¤
â Index Layer (ç´¢å¼å±) â Analysis Layer (åæå±) â
âââââââââââââââââââââââââââ¼ââââââââââââââââââââââââââââââââââââ¤
â ⢠Fast lookup â ⢠Structure quality scoring â
â ⢠Node/Component cache â ⢠Code-scene relation analysis â
â ⢠Offline capable â ⢠Business module identification â
â ⢠Minimal context â ⢠Self-check & iteration â
âââââââââââââââââââââââââââ´ââââââââââââââââââââââââââââââââââââ
| Principle | Description |
|---|---|
| Index only | Store name, path, component types – NOT property values |
| Query on demand | Fetch details via MCP when needed |
| Progressive load | Load large scenes in layers |
| AI friendly | Minimal structure for fast lookup |
| Quality scoring | Rate structure and code-scene relations |
| Self-iterating | Support review and improvement suggestions |
Commands
| Command | MCP | Description |
|---|---|---|
vscene pull |
â | Build/update index from editor |
vscene read [--depth N] |
â | Read from cache (default depth: 3) |
vscene find <pattern> |
â | Search nodes by name/type |
vscene detail <uuid> |
â | Get full node properties |
vscene diff |
â | Compare index vs real scene |
vscene status |
â | View index status |
vscene analyze |
â | Generate quality analysis with scoring |
vscene review |
â | Self-check analysis, suggest improvements |
vscene pretty |
â | Analyze hierarchy, propose & execute optimizations |
Directory Structure
.vscene/
âââ manifest.json # Scene manifest (åºæ¯æ¸
å)
âââ scenes/
â âââ {sceneName}.json # Scene index (åºæ¯ç´¢å¼)
âââ analysis/
âââ {sceneName}.analysis.md # Quality analysis (è´¨éåæ)
Index Layer (ç´¢å¼å±)
VNode Format (Enhanced)
{
"u": "uuid",
"n": "NodeName",
"c": ["GameManager", "AudioSource"],
"k": true,
"d": 0,
"role": "logic",
"desc": "游æé»è¾æ ¹èç¹",
"_": []
}
| Field | Full name | Description |
|---|---|---|
u |
uuid | Node UUID |
n |
name | Node name |
c |
components | Component type names (excludes cc.* engine) |
k |
key | Is key node (has important components) |
d |
depth | Hierarchy depth |
role |
role | Node role: logic/ui/render/data/container |
desc |
description | One-line description (䏿) |
_ |
children | Child nodes array |
Node Role Classification
| Role | Description | Examples |
|---|---|---|
logic |
Business logic, controllers | GameManager, PlayerController |
ui |
User interface elements | Canvas, Button, Label |
render |
Visual elements only | MeshRenderer, Sprite (no script) |
data |
Data containers | ConfigNode, AssetsNode |
container |
Organizational grouping | Managers, World, UI |
Analysis Layer (åæå±)
analyze Command Flow
vscene analyze
â
ââ Step 1: Check/Load Index
â ââ If no index â auto pull
â
ââ Step 2: Structure Analysis (ç»æåæ)
â ââ Hierarchy depth analysis
â ââ Node naming conventions
â ââ Module organization
â ââ Component distribution
â
ââ Step 3: Code-Scene Relation Analysis (代ç -åºæ¯å
³ç³»åæ)
â ââ Grep: getChildByName / find patterns
â ââ Grep: getComponent patterns
â ââ Match code references to scene nodes
â ââ Identify missing/orphan references
â
ââ Step 4: Quality Scoring (è´¨éè¯å)
â ââ Structure Score (ç»æå)
â ââ Naming Score (å½åå)
â ââ Code-Scene Coupling Score (è¦åå)
â ââ Overall Score (æ»å)
â
ââ Step 5: Generate Issues & Suggestions (é®é¢ä¸å»ºè®®)
â ââ Critical issues (严é��é¢)
â ââ Warnings (è¦å)
â ââ Improvement suggestions (æ¹è¿å»ºè®®)
â
ââ Output: .vscene/analysis/{sceneName}.analysis.md
Quality Scoring System (è¯åä½ç³»)
Total Score: 100 points
| Dimension | Weight | Criteria |
|---|---|---|
| Structure (ç»æ) | 30 | Hierarchy depth, module organization, node grouping |
| Naming (å½å) | 20 | Consistent naming, semantic clarity, no magic names |
| Code-Scene (代ç -åºæ¯) | 30 | Clean references, no hardcoded paths, proper coupling |
| Maintainability (å¯ç»´æ¤æ§) | 20 | Component reuse, prefab usage, separation of concerns |
Scoring Rules
Structure Score (30 points)
| Rule | Points | Deduction |
|---|---|---|
| Max depth ⤠6 | +10 | -2 per level over 6 |
| Logic nodes grouped under one root | +10 | -5 if scattered |
| UI nodes under Canvas | +5 | -5 if mixed |
| Clear module separation | +5 | -2 per violation |
Naming Score (20 points)
| Rule | Points | Deduction |
|---|---|---|
| PascalCase for nodes | +5 | -1 per violation |
| Semantic names (not node1, node2) | +5 | -2 per violation |
| Consistent prefixes (e.g., UI_, Btn_) | +5 | -1 per inconsistency |
| Chinese comments for key nodes | +5 | -1 per missing |
Code-Scene Score (30 points)
| Rule | Points | Deduction |
|---|---|---|
| No hardcoded getChildByName paths >2 levels | +10 | -2 per violation |
| Scene references match actual nodes | +10 | -5 per orphan ref |
| Components attached to appropriate nodes | +5 | -2 per misplacement |
| Events properly scoped | +5 | -2 per global leak |
Maintainability Score (20 points)
| Rule | Points | Deduction |
|---|---|---|
| Prefab usage for repeated structures | +5 | -2 per copy-paste |
| Single responsibility per component | +5 | -2 per god component |
| No circular references | +5 | -5 per cycle |
| Clear data flow direction | +5 | -2 per unclear flow |
Score Levels
| Score | Level | Emoji | Description |
|---|---|---|---|
| 90-100 | Excellent | ð | Production ready, well architected |
| 75-89 | Good | â | Minor issues, acceptable |
| 60-74 | Fair | â ï¸ | Needs improvement before release |
| 40-59 | Poor | â | Significant refactoring needed |
| 0-39 | Critical | ð¨ | Architectural problems, redesign required |
review Command (Self-Check & Iterate)
vscene review
â
ââ Step 1: Load existing analysis
â
ââ Step 2: Verify issues still exist
â ââ Re-check each reported issue
â
ââ Step 3: Check if suggestions implemented
â ââ Compare with previous analysis
â
ââ Step 4: Update scores
â ââ Recalculate based on current state
â
ââ Output: Updated analysis with delta
Review Output Example:
## Review: gameScene
### Score Change
| Dimension | Previous | Current | Delta |
|-----------|----------|---------|-------|
| Structure | 22/30 | 25/30 | +3 â
|
| Naming | 12/20 | 15/20 | +3 â
|
| Code-Scene | 20/30 | 20/30 | 0 |
| Total | 64/100 | 70/100 | +6 â
|
### Resolved Issues
- â
[S-001] node1 renamed to Environment
- â
[N-002] Added Chinese comments
### Remaining Issues
- â ï¸ [C-001] Still has hardcoded path in PlayerController.ts:45
pretty Command (Hierarchy Optimization)
Core Workflow: Analyze â Propose â Confirm â Execute
vscene pretty
â
ââ Phase 1: Analysis (åæé¶æ®µ)
â ââ Check/Load index (auto pull if needed)
â ââ Detect naming issues (node1, New Node, etc.)
â ââ Detect hierarchy issues (depth > 6, scattered nodes)
â ââ Detect structure issues (ungrouped, mixed concerns)
â ââ Generate issue list with severity
â
ââ Phase 2: Proposal (æ¹æ¡çæ)
â ââ Generate optimization operations
â â ââ Rename operations (éå½å)
â â ââ Reparent operations (è°æ´ç¶èç¹)
â â ââ Reorder operations (è°æ´é¡ºåº)
â â ââ Group operations (åç»æ´ç)
â ââ Preview before/after structure
â ââ Estimate impact (affected nodes count)
â
ââ Phase 3: Confirmation (ç¨æ·ç¡®è®¤) â¸ï¸
â ââ Display proposal to user
â ââ Wait for user decision:
â â ââ "åæ" / "æ§è¡" â Proceed to Phase 4
â â ââ "ä¿®æ¹" + feedback â Revise proposal
â â ââ "åæ¶" â Abort
â ââ User can select specific operations
â
ââ Phase 4: Execution (æ§è¡é¶æ®µ)
ââ Execute via MCP node_modify
ââ Batch operations for efficiency
ââ Update local index
ââ Output: Execution summary
Optimization Rules (ä¼åè§å)
1. Naming Optimization (å½åä¼å)
| Pattern | Issue | Suggested Fix |
|---|---|---|
node, node1, node2 |
æ æä¹å½å | æ ¹æ®åèç¹/ç»ä»¶æ¨æè¯ä¹å |
New Node, Node |
é»è®¤åç§° | æ ¹æ®ä¸ä¸ææ¨æ |
èç¹1, æµè¯ |
临æ¶å½å | æç¤ºç¨æ·æä¾è¯ä¹å |
Mixed case (playerNode) |
大å°åä¸è§è | PlayerNode (PascalCase) |
2. Hierarchy Optimization (å±çº§ä¼å)
| Issue | Criteria | Action |
|---|---|---|
| è¿æ·±å±çº§ | depth > 6 | æåå°åéç¶èç¹ |
| ååèç¹é¾ | AâBâC (each has 1 child) | æå¹³åï¼åå¹¶ä¸é´èç¹ |
| æ£è½é»è¾èç¹ | Logic nodes under render | ç§»å¨å° LogicRoot |
| æ£è½ UI èç¹ | UI nodes outside Canvas | ç§»å¨å° Canvas ä¸ |
3. Structure Optimization (ç»æä¼å)
| Issue | Criteria | Action |
|---|---|---|
| æªåç» | >10 siblings at root | æç±»ååç»å°å®¹å¨ |
| æ··åå ³æ³¨ç¹ | UI + Logic + Render mixed | å离å°ä¸åå®¹å¨ |
| éå¤ç»æ | Similar node patterns | 建议转为 Prefab |
Proposal Output Format (æ¹æ¡è¾åºæ ¼å¼)
## VScene Pretty: gameScene
### æ£æµå°çé®é¢ (Issues Found)
| # | ç±»å | èç¹ | é®é¢ | 严é度 |
|---|------|------|------|--------|
| 1 | å½å | `node1` | æ æä¹å½å | â ï¸ |
| 2 | å½å | `New Node` | é»è®¤åç§° | â ï¸ |
| 3 | å±çº§ | `A/B/C/D/E/F/G` | å±çº§è¿æ·± (7å±) | â |
| 4 | ç»æ | `Canvas/PlayerCtrl` | é»è¾ç»ä»¶å¨UI容å¨ä¸ | â ï¸ |
### ä¼åæ¹æ¡ (Optimization Plan)
#### éå½åæä½ (Rename)
| # | ååç§° | æ°åç§° | UUID |
|---|--------|--------|------|
| R1 | `node1` | `Environment` | abc123 |
| R2 | `New Node` | `GameManager` | def456 |
#### å±çº§è°æ´ (Reparent)
| # | èç¹ | åç¶èç¹ | æ°ç¶èç¹ | åå |
|---|------|----------|----------|------|
| P1 | `PlayerCtrl` | `Canvas` | `LogicRoot` | é»è¾ç»ä»¶åºå¨é»è¾å®¹å¨ |
| P2 | `DeepNode` | `A/B/C/D/E/F` | `A/B` | å±çº§æå¹³å |
#### åç»æä½ (Group)
| # | æ°å®¹å¨ | å
å«èç¹ | åå |
|---|--------|----------|------|
| G1 | `Managers` | `GameMgr, AudioMgr, UIMgr` | 管çå¨åç» |
### é¢è§ (Preview)
**Before:**
gameScene ââ node1 ââ New Node [GameManager] ââ Canvas â ââ PlayerCtrl [PlayerController] â ï¸ ââ A/B/C/D/E/F/G â
**After:**
gameScene ââ Environment (å node1) ââ LogicRoot â ââ GameManager (å New Node) â ââ PlayerCtrl â ââ Canvas ââ A/B/DeepNode â
### å½±åèå´
- éå½å: 2 个è���
- ç§»å¨: 2 个èç¹
- æ°å»ºå®¹å¨: 1 个
---
**请确认æ¯å¦æ§è¡ä»¥ä¸ä¼åï¼**
- è¾å
¥ `åæ` æ `æ§è¡` æ§è¡å
¨é¨æä½
- è¾å
¥ `æ§è¡ R1 P1` æ§è¡æå®æä½
- è¾å
¥ `ä¿®æ¹` + åé¦ è°æ´æ¹æ¡
- è¾å
¥ `åæ¶` æ¾å¼ä¼å
Execution Output (æ§è¡ç»æ)
## æ§è¡å®æ â
### æ§è¡ç»æ
| # | æä½ | ç¶æ |
|---|------|------|
| R1 | `node1` â `Environment` | â
æå |
| R2 | `New Node` â `GameManager` | â
æå |
| P1 | `PlayerCtrl` â `LogicRoot` | â
æå |
### ç´¢å¼å·²æ´æ°
åºæ¯å·²ä¿åï¼å»ºè®®è¿è¡ `vscene analyze` æ¥çä¼ååè¯åã
Analysis Document Template
See references/analysis-template.md for full template.
Key Sections
- Header – Scene name, stats, score summary
- Score Card – Detailed scoring breakdown
- Structure Overview – Annotated hierarchy tree
- Module Analysis – Business module identification
- Code-Scene Relations – Reference mapping table
- Issues & Suggestions – Prioritized improvement list
- Iteration Log – Review history
Quick Start
First Analysis
vscene pull # Build index
vscene analyze # Generate analysis
# Review .vscene/analysis/{scene}.analysis.md
Iterate on Quality
# Make improvements to scene...
vscene review # Check progress
vscene analyze # Full re-analysis
Auto Optimization
vscene pretty # Analyze and propose optimizations
# Review proposal, then:
# - "åæ" to execute all
# - "æ§è¡ R1 P1" to execute specific operations
# - "ä¿®æ¹" + feedback to revise
# - "åæ¶" to abort
Check Specific Issues
vscene find node* # Find poorly named nodes
vscene detail <uuid> # Inspect specific node
Index Output Format
vscene read (depth: 3)
## VScene: gameScene (226 nodes, depth 8)
Cached: 2026-01-26 | Score: 72/100 â ï¸
gameScene # åºæ¯æ ¹èç¹
ââ Main Light [DirectionalLight] # 主å
æº
ââ Main Camera [CameraComponent] # ä¸»ç¸æº
ââ Canvas [Canvas] â
# UI ç»å¸
â ââ JoystickUI # æææ§å¶
â ââ DragtoMove # ææ½æç¤º
ââ node1 # â ï¸ å½åä¸è§è
â ââ [+36 nodes]
ââ LogicRoot â
# é»è¾æ ¹èç¹
ââ Player â
# ç©å®¶è§è²
ââ Unlock â
# è§£éç³»ç»
ââ UnlockBuildings â
# å¯è§£é建ç
â
= Key node | â ï¸ = Has issues | [+N] = Collapsed
Key Node Detection
Nodes with these components are marked as key (k: true):
Priority 1 (Always):
*Manager,*Controller,*System,Root*Assets,*Factory,*Spawner
Priority 2 (Business):
*Trigger,*Handler,*Generator- Any custom component (not
cc.*prefixed)
Detailed References
- references/data-structure.md – Full JSON schema
- references/auto-sync.md – Auto-sync flow details
- references/mcp-integration.md – MCP API usage
- references/analysis-template.md – Analysis document template
- references/scoring-rules.md – Detailed scoring criteria
Error Handling
| Scenario | Handling |
|---|---|
| MCP disconnected + has cache | read/find/status/review work offline |
| MCP disconnected + no cache | Error, prompt to start editor |
| MCP disconnected + analyze | Error, MCP required for full analysis |
| Index corrupted | Auto rebuild |
| Analysis outdated | Warn on read, suggest re-analyze |