MCPcopy Create free account
hub / github.com/Noumena-Network/code / resolveSkillName

Function resolveSkillName

src/tools/AgentTool/runAgent.ts:947–975  ·  view source on GitHub ↗

* 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,
)

Source from the content-addressed store, hash-verified

945 * 3. Suffix match — find any command whose name ends with ":skillName"
946 */
947function resolveSkillName(
948 skillName: string,
949 allSkills: Command[],
950 agentDefinition: AgentDefinition,
951): string | null {
952 // 1. Direct match
953 if (hasCommand(skillName, allSkills)) {
954 return skillName
955 }
956
957 // 2. Try prefixing with the agent's plugin name
958 // Plugin agents have agentType like "pluginName:agentName"
959 const pluginPrefix = agentDefinition.agentType.split(':')[0]
960 if (pluginPrefix) {
961 const qualifiedName = `${pluginPrefix}:${skillName}`
962 if (hasCommand(qualifiedName, allSkills)) {
963 return qualifiedName
964 }
965 }
966
967 // 3. Suffix match — find a skill whose name ends with ":skillName"
968 const suffix = `:${skillName}`
969 const match = allSkills.find(cmd => cmd.name.endsWith(suffix))
970 if (match) {
971 return match.name
972 }
973
974 return null
975}

Callers 1

runAgentFunction · 0.85

Calls 1

hasCommandFunction · 0.50

Tested by

no test coverage detected