fix(schema): allow digits in compound trigger shortcuts

The COMPOUND_TRIGGER_PATTERN and description bracket regex only
accepted [A-Z]{1,3}, rejecting shortcuts like QD2 that include
digits. Update both regexes to accept [A-Z][A-Z0-9]{0,2} so
alphanumeric shortcuts work while still requiring a leading letter.

Add test fixture covering the alphanumeric shortcut case.
This commit is contained in:
Alex Verkhovsky 2026-02-22 14:17:57 -07:00
parent 4dd5a0c871
commit 375148a554
2 changed files with 5 additions and 2 deletions

View File

@ -29,3 +29,6 @@ agent:
- trigger: H or fuzzy match on help - trigger: H or fuzzy match on help
description: "[H] Single-word compound trigger (1-letter shortcut)" description: "[H] Single-word compound trigger (1-letter shortcut)"
action: help action: help
- trigger: QD2 or fuzzy match on quick-dev2
description: "[QD2] Alphanumeric shortcut with trailing digit"
action: quick_dev2

View File

@ -4,7 +4,7 @@ const { z } = require('zod');
const COMMAND_TARGET_KEYS = ['workflow', 'validate-workflow', 'exec', 'action', 'tmpl', 'data']; const COMMAND_TARGET_KEYS = ['workflow', 'validate-workflow', 'exec', 'action', 'tmpl', 'data'];
const TRIGGER_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/; const TRIGGER_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
const COMPOUND_TRIGGER_PATTERN = /^([A-Z]{1,3}) or fuzzy match on ([a-z0-9]+(?:-[a-z0-9]+)*)$/; const COMPOUND_TRIGGER_PATTERN = /^([A-Z][A-Z0-9]{0,2}) or fuzzy match on ([a-z0-9]+(?:-[a-z0-9]+)*)$/;
/** /**
* Derive the expected shortcut from a kebab-case trigger. * Derive the expected shortcut from a kebab-case trigger.
@ -100,7 +100,7 @@ function agentSchema(options = {}) {
} }
// Validate that shortcut matches description brackets // Validate that shortcut matches description brackets
const descriptionMatch = item.description?.match(/^\[([A-Z]{1,3})\]/); const descriptionMatch = item.description?.match(/^\[([A-Z][A-Z0-9]{0,2})\]/);
if (!descriptionMatch) { if (!descriptionMatch) {
ctx.addIssue({ ctx.addIssue({
code: 'custom', code: 'custom',