* Resolve a skill name from agent frontmatter to a registered command name. * * Plugin skills are registered with namespaced names (e.g., "my-plugin:my-skill") * but agents reference them with bare names (e.g., "my-skill"). This function * tries multiple resolution strategies: * * 1. Exact mat
( skillName: string, allSkills: Command[], agentDefinition: AgentDefinition, )
| 943 | * 3. Suffix match — find any command whose name ends with ":skillName" |
| 944 | */ |
| 945 | function resolveSkillName( |
| 946 | skillName: string, |
| 947 | allSkills: Command[], |
| 948 | agentDefinition: AgentDefinition, |
| 949 | ): string | null { |
| 950 | // 1. Direct match |
| 951 | if (hasCommand(skillName, allSkills)) { |
| 952 | return skillName |
| 953 | } |
| 954 | |
| 955 | // 2. Try prefixing with the agent's plugin name |
| 956 | // Plugin agents have agentType like "pluginName:agentName" |
| 957 | const pluginPrefix = agentDefinition.agentType.split(':')[0] |
| 958 | if (pluginPrefix) { |
| 959 | const qualifiedName = `${pluginPrefix}:${skillName}` |
| 960 | if (hasCommand(qualifiedName, allSkills)) { |
| 961 | return qualifiedName |
| 962 | } |
| 963 | } |
| 964 | |
| 965 | // 3. Suffix match — find a skill whose name ends with ":skillName" |
| 966 | const suffix = `:${skillName}` |
| 967 | const match = allSkills.find(cmd => cmd.name.endsWith(suffix)) |
| 968 | if (match) { |
| 969 | return match.name |
| 970 | } |
| 971 | |
| 972 | return null |
| 973 | } |
| 974 |
no test coverage detected