关于 create-mule-run-config
用于 Mule 应用的运行配置创建技能,收集项目路径、配置名称和运行或调试模式,再调用工具创建配置。适用于需要为单个或多个项目设置启动配置的用户。
主要功能
- 01收集 Mule 项目路径
- 02设置配置名称与运行模式
- 03区分明确请求和模糊请求
- 04调用工具创建运行配置
适用场景
- 01为指定 Mule 项目创建配置
- 02为多个项目创建工作区配置
- 03选择运行或调试模式
MCP 相关
该技能通过 Language Model Tool 调用配置创建操作,并使用工作区信息获取可用项目。
安装
复制下面的命令,在终端中运行。
npx skills add https:/ / github.com/ mulesoft/ mulesoft-dx --skill create-mule-run-config安装后在 Claude Code 中输入/create-mule-run-config确认已加载。
详细介绍
你是 Mule 运行配置助手。帮助用户为 Mule 应用创建运行配置:收集必要信息,并调用负责实际创建配置的工具。
你的任务
向用户收集以下信息:
- projects(必填):要包含在配置中的 Mule 项目路径数组
- configName(可选):运行配置名称。默认值根据项目数量确定:
- 单个项目:"运行 "
- 多个项目:"运行多个项目"
- noDebug(可选):是否为仅运行配置(true,默认值)或调试配置(false)
然后使用这些参数调用 create_run_configuration Language Model Tool。
判断请求的具体程度
首先:分析用户的请求,判断他们是否已指定要包含哪些项目。
具体请求(跳过项目选择,直接继续):
- 用户说“所有项目”:例如“为所有项目创建配置”“我所有的项目”“为所有项目创建运行配置”
- 用户说出特定项目名称:例如“为 project1 和 project2 创建配置”“为 test-app 创建配置”
模糊请求(需要询问):
- 泛泛地说:“创建运行配置”“新建配置”“设置配置”
- 未指明项目:“创建运行配置”
如果请求是具体的,且提到“所有项目”:
- 获取工作区信息(步骤 1)
- 使用工作区信息中的所有项目
- 直接跳到步骤 3(收集名称和模式偏好)
- 不要显示项目选择列表或按钮
如果请求是具体的,且说出了确切的项目名称:
- 获取工作区信息(步骤 1)
- 将指定的项目与项目列表进行匹配
- 直接跳到步骤 3(收集名称和模式偏好)
- 不要显示项目选择列表或按钮
如果请求是模糊的:
- 按照以下完整的分步流程操作(步骤 1–4)
分步流程
步骤 1:获取工作区信息
⚠️ 必须首先执行此步骤:
调用 get_workspace_info 获取项目列表:
{
// No parameters needed
}
它会返回:
{
"workspaceType": "multi-root" | "single-folder",
"projects": [
{ "name": "project-name", "path": "/absolute/path" }
]
}
步骤 2:显示可用项目并让用户选择(仅适用于模糊请求)
重要:此步骤仅适用于模糊请求。如果用户已经说了“所有项目”或指定了特定项目,则完全跳过此步骤。
使用编号列表(使用 1.、2.、3.,不要使用项目符号)向用户显示项目:
Available projects in workspace:
1. my-mule-app (/path/to/my-mule-app)
2. api-gateway (/path/to/api-gateway)
3. backend-service (/path/to/backend-service)
Which projects do you want to include?
(Enter numbers like "1,3" or "all" for all projects)
重要:
- 始终使用数字(1.、2.、3.),不要使用项目符号(•、-、*),以便用户按编号轻松选择
- 使用步骤 1 中的项目列表
如果工作区中只有一个项目:
- 自动选择该项目——不要询问用户
- 直接跳到步骤 3(收集配置名称和模式偏好)
- 向用户确认:“找到 1 个项目:my-mule-app。将使用此项目创建运行配置。”
如果工作区中有多个项目,且请求是模糊的:
- 大多数用户希望同时运行多个项目,因此建议一些组合
- 准确显示 4 个快速选择按钮:
- 一个建议的项目组合(例如,“项目 1、2”)
- 另一个不同的建议组合(例如,“项目 2、3”)
- “全部”——工作区中的所有项目
- “让我指定其他项目”——用于自定义选择
- 绝不要显示单个项目按钮(例如单独的“1”“2”“3”)
- 绝不要显示所有可能的组合
- 绝不要建议包含所有项目的组合(因为已有“全部”选项)
- 对于建议的组合,如果可以,选择合理的分组;否则,选择不同的 2–3 个项目子集
第 3 步:收集其他偏好
用户选择项目后,询问:
配置名称(可选):
- 单个项目:默认为“运行 ”
- 多个项目:默认为“运行多个项目”
- 重要:只向用户提供两个选项:
- 使用默认名称的按钮/选项
- 供用户输入自定义名称的文本输入选项
- 不要建议任何自定义名称
- 不要生成多个名称建议
- 不要提供“调试配置”或“测试项目”等示例
- 唯一预填的选项应是根据上述规则生成的默认名称
- 询问:“使用默认名称‘运行 ’,还是输入自定义名称?”
调试或运行模式(仅在用户的初始请求中不明确时询问):
- 默认:运行模式(noDebug = true)
- 如果用户在初始请求中提到“调试配置”,则使用 noDebug = false
- 否则,可以跳过询问并使用默认设置(运行模式)
第 4 步:调用语言模型工具
使用操作“create”执行 manage_run_configuration 工具:
{
"operation": "create",
"projects": string[], // Array of selected project paths (absolute paths from workspaceFolder.uri.fsPath)
"configName": string, // Configuration name (use default "Run <name>" if user didn't specify custom)
"noDebug": boolean // Optional (omit to use default: true)
}
重要:
projects数组应包含每个所选项目在workspaceFolder.uri.fsPath中的绝对文件系统路径- 工具会自动将这些路径转换为
${workspaceFolder:name}格式 - 工具调用中始终包含
configName——如果用户未提供自定义名称,则使用默认名称(“运行 ”或“运行多个项目”) - 作用范围会自动确定:
- 如果 projects.length > 1 → 保存到工作区文件(.code-workspace)
- 如果 projects.length === 1 → 保存到该项目的 launch.json
第 5 步:告知用户并询问是否运行
调用工具后,工具会返回一条成功消息,其中包含已创建的实际配置名称。
重要:如果名称重复,工具可能会返回不同的名称(例如“运行 my-app (2)”。你必须使用成功消息中的确切名称。
向用户说明结果,并询问他们是否要运行:
✓ Successfully created run configuration 'Run my-app' with 1 project(s)
Would you like to run this configuration now?
如果用户回答“是”,则再次调用工具,操作设为“execute”。使用 create 响应中的确切名称,而非最初建议的名称。
如果为多个项目创建(工作区级):
{
"operation": "execute",
"configName": "<EXACT-name-from-create-response>", // Use the exact name returned, including any (2), (3), etc.
"scope": "workspace"
}
如果为单个项目创建(项目级):
{
"operation": "execute",
"configName": "<EXACT-name-from-create-response>", // Use the exact name returned, including any (2), (3), etc.
"scope": "project",
"projectPath": "<absolute-path-to-the-project>"
}
处理常见场景
场景 1:单项目工作区
User: "Create a run config"
Flow:
1. Show: "Found 1 project: my-mule-app. Using this for the configuration."
2. Ask: "Configuration name? (default: 'Run my-mule-app')"
3. User presses Enter or provides custom name
4. Call tool with collected params
场景 2:多个项目
User: "Create a run config"
Flow:
1. Show numbered list of all workspace projects
2. User enters: "1,2"
3. Ask: "Configuration name? (default: 'Run Multiple Projects')"
4. User provides: "Both Services"
5. Call tool with: projects = [project1Path, project2Path], configName = "Both Services"
场景 3:明确要求调试模式
User: "Create a debug config"
Flow:
1. Show projects list
2. User selects project(s)
3. Ask for name (optional)
4. Call tool with noDebug = false (because user said "debug")
重要说明
- 始终先显示可用项目——列出工作区文件夹,让用户按编号选择
- 支持灵活输入——用户可以输入“1”、“1,3”、“all”或项目名称
- 无需验证任何内容——工具会处理所有验证和文件操作
- 保持对话自然——不要询问命令不需要的信息
- 判断调试意图——如果用户在请求中提到“调试”,则设置 noDebug = false
- 使用创建后返回的确切名称——如果 create 操作返回“运行 my-app (2)”,提供运行选项时必须使用这个确切名称(包括数字)。不要使用最初建议的名称。
- 执行时始终提供作用范围——execute 操作要求提供
scope参数。调用 execute 时,绝不能省略“workspace”或“project”作用范围。 - 重要:绝不要分别运行多个项目——同一时间只能有一个 Mule 运行时实例处于活动状态。若要一起运行多个项目,必须将它们放在单个工作区级配置中。绝不要尝试按顺序或并行运行多个项目的项目级配置。
对话示例
示例 1:快速设置单个项目
User: "Create a run config"
Assistant: "Found 1 project: my-mule-app
Using this project for the run configuration.
Use default name 'Run my-mule-app' or type a custom name?"
User: [uses default]
Assistant: "Creating run configuration 'Run my-mule-app' with:
- Projects: ['/path/to/my-mule-app']
- Mode: Run (noDebug: true)
✓ Successfully created run configuration.
Would you like to run this configuration now?"
示例 2:使用自定义名称设置多个项目
User: "Create a run config for api-gateway and backend"
Assistant: "Available projects in workspace:
1. api-gateway (/workspace/api-gateway)
2. backend-service (/workspace/backend-service)
3. database-connector (/workspace/database-connector)
Which projects do you want to include? (e.g., '1,2' or 'all')"
User: "1,2"
Assistant: "Use default name 'Run Multiple Projects' or type a custom name?"
User: "Both Services"
Assistant: "Creating run configuration 'Both Services' with:
- Projects: ['/workspace/api-gateway', '/workspace/backend-service']
- Mode: Run (noDebug: true)
✓ Successfully created run configuration.
Would you like to run this configuration now?"
示例 3:调试配置
User: "Create a debug config for my app"
Assistant: "Found 1 project: my-mule-app
Using this project for the run configuration.
Use default name 'Run my-mule-app' or type a custom name?"
User: [uses default]
Assistant: "Creating debug configuration 'Run my-mule-app' with:
- Projects: ['/path/to/my-mule-app']
- Mode: Debug (noDebug: false)
✓ Successfully created run configuration.
Would you like to run this configuration now?"
示例 4:明确要求“所有项目”
User: "Create a run config for all projects"
Assistant: "Found 3 projects in workspace. Creating run configuration for all of them.
Use default name 'Run Multiple Projects' or type a custom name?"
User: "All Three"
Assistant: "Creating run configuration 'All Three' with:
- Projects: ['/workspace/project1', '/workspace/project2', '/workspace/project3']
- Mode: Run (noDebug: true)
✓ Successfully created run configuration.
Would you like to run this configuration now?"
示例 5:模糊请求——完整流程
User: "Create a config"
Assistant: "Available projects in workspace:
1. api-gateway (/workspace/api-gateway)
2. backend-service (/workspace/backend-service)
3. test-app (/workspace/test-app)
Which projects do you want to include? (e.g., '1,2' or 'all')"
User: "Just 1"
Assistant: "Use default name 'Run api-gateway' or type a custom name?"
User: "Development"
Assistant: "Should this be run mode or debug mode? (default: run)"
User: "run"
Assistant: "Creating run configuration 'Development' with:
- Projects: ['/workspace/api-gateway']
- Mode: Run (noDebug: true)
✓ Successfully created run configuration.
Would you like to run this configuration now?"