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

Function validateInput

src/tools/SkillTool/SkillTool.ts:355–431  ·  view source on GitHub ↗
({ skill }, context)

Source from the content-addressed store, hash-verified

353 toAutoClassifierInput: ({ skill }) => skill ?? '',
354
355 async validateInput({ skill }, context): Promise<ValidationResult> {
356 // Skills are just skill names, no arguments
357 const trimmed = skill.trim()
358 if (!trimmed) {
359 return {
360 result: false,
361 message: `Invalid skill format: ${skill}`,
362 errorCode: 1,
363 }
364 }
365
366 // Remove leading slash if present (for compatibility)
367 const hasLeadingSlash = trimmed.startsWith('/')
368 if (hasLeadingSlash) {
369 logEvent('ncode_skill_tool_slash_prefix', {})
370 }
371 const normalizedCommandName = hasLeadingSlash
372 ? trimmed.substring(1)
373 : trimmed
374
375 // Remote canonical skill handling (ant-only experimental). Intercept
376 // `_canonical_<slug>` names before local command lookup since remote
377 // skills are not in the local command registry.
378 if (
379 feature('EXPERIMENTAL_SKILL_SEARCH') &&
380 isInternalBuild()
381 ) {
382 const slug = remoteSkillModules!.stripCanonicalPrefix(
383 normalizedCommandName,
384 )
385 if (slug !== null) {
386 const meta = remoteSkillModules!.getDiscoveredRemoteSkill(slug)
387 if (!meta) {
388 return {
389 result: false,
390 message: `Remote skill ${slug} was not discovered in this session. Use DiscoverSkills to find remote skills first.`,
391 errorCode: 6,
392 }
393 }
394 // Discovered remote skill — valid. Loading happens in call().
395 return { result: true }
396 }
397 }
398
399 // Get available commands (including MCP skills)
400 const commands = await getAllCommands(context)
401
402 // Check if command exists
403 const foundCommand = findCommand(normalizedCommandName, commands)
404 if (!foundCommand) {
405 return {
406 result: false,
407 message: `Unknown skill: ${normalizedCommandName}`,
408 errorCode: 2,
409 }
410 }
411
412 // Check if command has model invocation disabled

Callers

nothing calls this directly

Calls 4

isInternalBuildFunction · 0.85
findCommandFunction · 0.85
logEventFunction · 0.70
getAllCommandsFunction · 0.70

Tested by

no test coverage detected