/**
 * Command name validation for the Ion workflow engine.
 *
 * Command names must be lowercase kebab-case: lowercase alphanumeric
 * segments separated by single hyphens.
 */

/** Pattern for valid command names: lowercase kebab-case. */
const COMMAND_NAME_PATTERN = /^[a-z0-9]+(-[a-z0-9]+)*$/;

/**
 * Validate a command name.
 *
 * Valid names match the pattern: `^[a-z0-9]+(-[a-z0-9]+)*$`
 * - Lowercase alphanumeric segments
 * - Segments separated by single hyphens
 * - No leading or trailing hyphens
 * - No consecutive hyphens
 *
 * @returns `true` if the name is valid, `false` otherwise.
 */
export function isValidCommandName(name: string): boolean {
  if (name.length === 0) {
    return false;
  }
  return COMMAND_NAME_PATTERN.test(name);
}