名称: 依赖关系图生成器 描述: 生成模块依赖关系图,具备循环依赖检测和耦合度指标计算功能 允许使用的工具:
- Bash
- Read
- Write
- Glob
- Grep
依赖关系图生成器技能
概述
生成模块依赖关系图,具备循环依赖识别、耦合度指标计算功能,并支持以Graphviz或D3格式输出可视化结果。
功能
- 生成模块依赖关系图
- 识别循环依赖
- 计算耦合度指标(传入耦合、传出耦合)
- 计算不稳定性指标
- 可视化依赖关系(Graphviz、D3)
- 包/模块级别分析
- 外部依赖跟踪
目标流程
- 微服务解耦
- 重构规划
- 迁移策略
输入模式
{
"type": "object",
"required": ["entryPoints"],
"properties": {
"entryPoints": {
"type": "array",
"items": { "type": "string" },
"description": "入口点文件或目录"
},
"outputFormat": {
"type": "string",
"enum": ["dot", "json", "d3", "mermaid"],
"default": "dot"
},
"outputPath": {
"type": "string",
"description": "输出文件路径"
},
"options": {
"type": "object",
"properties": {
"depth": {
"type": "number",
"default": -1,
"description": "最大深度(-1表示无限制)"
},
"includeExternal": {
"type": "boolean",
"default": false
},
"groupByPackage": {
"type": "boolean",
"default": true
},
"detectCircular": {
"type": "boolean",
"default": true
}
}
}
}
}
输出模式
{
"type": "object",
"properties": {
"graph": {
"type": "object",
"properties": {
"nodes": { "type": "array" },
"edges": { "type": "array" }
}
},
"circularDependencies": {
"type": "array",
"items": {
"type": "array",
"items": { "type": "string" }
}
},
"metrics": {
"type": "object",
"properties": {
"totalModules": { "type": "number" },
"totalDependencies": { "type": "number" },
"averageCoupling": { "type": "number" }
}
},
"outputPath": {
"type": "string"
}
}
}
使用示例
{
kind: 'skill',
skill: {
name: 'dependency-graph-generator',
context: {
entryPoints: ['src/index.ts'],
outputFormat: 'dot',
outputPath: 'docs/dependencies.dot',
options: {
groupByPackage: true,
detectCircular: true
}
}
}
}