feat(tools): 添加 CLI 模块管理命令和文档验证 demos

- CLI 新增 list/add/remove 命令管理项目模块
- 创建 demos 包验证模块文档正确性
- 包含 Timer/FSM/Pathfinding/Procgen/Spatial 5个模块的完整测试
This commit is contained in:
yhh
2025-12-26 22:09:01 +08:00
parent 4a16e30794
commit 881ffad3bc
11 changed files with 1460 additions and 4 deletions

View File

@@ -0,0 +1,122 @@
/**
* @zh ESEngine 可用模块定义
* @en ESEngine Available Modules Definition
*/
export interface ModuleInfo {
id: string;
name: string;
package: string;
version: string;
description: string;
category: 'core' | 'ai' | 'physics' | 'rendering' | 'network' | 'utility';
dependencies?: string[];
}
/**
* @zh 可用模块列表
* @en Available modules list
*/
export const AVAILABLE_MODULES: ModuleInfo[] = [
// Core
{
id: 'core',
name: 'ECS Core',
package: '@esengine/ecs-framework',
version: 'latest',
description: 'ECS 核心框架 | Core ECS framework',
category: 'core'
},
{
id: 'math',
name: 'Math',
package: '@esengine/ecs-framework-math',
version: 'latest',
description: '数学库 (向量、矩阵) | Math library (vectors, matrices)',
category: 'core'
},
// AI
{
id: 'fsm',
name: 'FSM',
package: '@esengine/fsm',
version: 'latest',
description: '有限状态机 | Finite State Machine',
category: 'ai'
},
{
id: 'behavior-tree',
name: 'Behavior Tree',
package: '@esengine/behavior-tree',
version: 'latest',
description: '行为树 AI 系统 | Behavior Tree AI system',
category: 'ai'
},
{
id: 'pathfinding',
name: 'Pathfinding',
package: '@esengine/pathfinding',
version: 'latest',
description: '寻路系统 (A*, NavMesh) | Pathfinding (A*, NavMesh)',
category: 'ai'
},
// Utility
{
id: 'timer',
name: 'Timer',
package: '@esengine/timer',
version: 'latest',
description: '定时器和冷却系统 | Timer and cooldown system',
category: 'utility'
},
{
id: 'spatial',
name: 'Spatial',
package: '@esengine/spatial',
version: 'latest',
description: '空间索引和 AOI 系统 | Spatial index and AOI system',
category: 'utility'
},
{
id: 'procgen',
name: 'Procgen',
package: '@esengine/procgen',
version: 'latest',
description: '程序化生成 (噪声、随机) | Procedural generation',
category: 'utility'
},
{
id: 'blueprint',
name: 'Blueprint',
package: '@esengine/blueprint',
version: 'latest',
description: '可视化脚本系统 | Visual scripting system',
category: 'utility'
}
];
/**
* @zh 获取模块信息
* @en Get module info by id
*/
export function getModuleById(id: string): ModuleInfo | undefined {
return AVAILABLE_MODULES.find(m => m.id === id);
}
/**
* @zh 按分类获取模块
* @en Get modules by category
*/
export function getModulesByCategory(category: ModuleInfo['category']): ModuleInfo[] {
return AVAILABLE_MODULES.filter(m => m.category === category);
}
/**
* @zh 获取所有模块 ID
* @en Get all module IDs
*/
export function getAllModuleIds(): string[] {
return AVAILABLE_MODULES.map(m => m.id);
}