mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-04-28 11:41:04 +00:00
fix(core): allow Unicode characters in agent names (#3194)
The agent name validation regex only permitted ASCII letters, numbers,
hyphens, and underscores, silently rejecting agents with non-ASCII names
(e.g., Chinese "项目管理"). Replace the regex with Unicode property
escapes (\p{L}\p{N}) to allow letters and numbers from any script.
Also guard the lowercase naming convention warning so it only fires when
the name contains ASCII letters, since case is meaningless for CJK
scripts.
Fixes #3149
This commit is contained in:
parent
8d74a0cf0a
commit
34d560adcf
2 changed files with 20 additions and 4 deletions
|
|
@ -22,6 +22,11 @@ describe('SubagentValidator', () => {
|
|||
'code_reviewer',
|
||||
'agent123',
|
||||
'my-helper',
|
||||
'项目管理',
|
||||
'コードレビュー',
|
||||
'코드리뷰',
|
||||
'项目-manager',
|
||||
'проект_менеджер',
|
||||
];
|
||||
|
||||
for (const name of validNames) {
|
||||
|
|
@ -120,6 +125,14 @@ describe('SubagentValidator', () => {
|
|||
);
|
||||
});
|
||||
|
||||
it('should not warn about case for non-Latin names', () => {
|
||||
const result = validator.validateName('项目管理');
|
||||
expect(result.isValid).toBe(true);
|
||||
expect(result.warnings).not.toContain(
|
||||
'Consider using lowercase names for consistency',
|
||||
);
|
||||
});
|
||||
|
||||
it('should warn about mixed separators', () => {
|
||||
const result = validator.validateName('test-agent_helper');
|
||||
expect(result.isValid).toBe(true);
|
||||
|
|
|
|||
|
|
@ -116,8 +116,8 @@ export class SubagentValidator {
|
|||
errors.push('Name must be 50 characters or less');
|
||||
}
|
||||
|
||||
// Check valid characters (alphanumeric, hyphens, underscores)
|
||||
const validNameRegex = /^[a-zA-Z0-9_-]+$/;
|
||||
// Check valid characters (Unicode letters/numbers, hyphens, underscores)
|
||||
const validNameRegex = /^[\p{L}\p{N}_-]+$/u;
|
||||
if (!validNameRegex.test(trimmedName)) {
|
||||
errors.push(
|
||||
'Name can only contain letters, numbers, hyphens, and underscores',
|
||||
|
|
@ -147,8 +147,11 @@ export class SubagentValidator {
|
|||
errors.push(`"${trimmedName}" is a reserved name and cannot be used`);
|
||||
}
|
||||
|
||||
// Warnings for naming conventions
|
||||
if (trimmedName !== trimmedName.toLowerCase()) {
|
||||
// Warnings for naming conventions (only for names that have case distinctions)
|
||||
if (
|
||||
trimmedName !== trimmedName.toLowerCase() &&
|
||||
/[a-zA-Z]/.test(trimmedName)
|
||||
) {
|
||||
warnings.push('Consider using lowercase names for consistency');
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue