From 4a73cf3828856653d736bc97b3c7178c19782d9f Mon Sep 17 00:00:00 2001 From: 4gray Date: Mon, 21 Sep 2026 00:34:28 +0200 Subject: [PATCH] fix(agents): normalize punctuation for extensionless imports --- docs/development/agent-workflow.md | 3 ++- tools/skills/validate-agent-guidance.mjs | 4 +++- tools/skills/validate-agent-guidance.test.mjs | 13 +++++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/docs/development/agent-workflow.md b/docs/development/agent-workflow.md index d319228ee..7a919bf83 100644 --- a/docs/development/agent-workflow.md +++ b/docs/development/agent-workflow.md @@ -63,7 +63,8 @@ HTML video, audio, source and track `src` assets and video posters use the same existence checks as images. Entity decoding uses full HTML text/attribute rules, including references whose semicolon may be omitted. Inline guidance imports are rejected after punctuation as well as whitespace. -Extensionless inline candidates are also imports when they resolve to repository files. +Extensionless inline candidates are also imports when they resolve to repository files, +after removing prose punctuation, including Unicode separators. Declared scoped dependencies, scope wildcards and matching TypeScript path aliases are recognized as package/alias mentions. Traversal and document-file imports are rejected before those exemptions. TypeScript configuration is parsed as JSONC. diff --git a/tools/skills/validate-agent-guidance.mjs b/tools/skills/validate-agent-guidance.mjs index 6470e0551..4d7119b4d 100644 --- a/tools/skills/validate-agent-guidance.mjs +++ b/tools/skills/validate-agent-guidance.mjs @@ -188,7 +188,9 @@ export async function validateAgentGuidance({ rootDir }) { inlineImports.push(token); continue; } - const candidate = token.replace(/[?!.,;:)"'\]}]+$/u, ''); + const candidate = token + .split(/(?=[^\x00-\x7f])\p{P}/u, 1)[0] + .replace(/[?!.,;:)"'\]}]+$/u, ''); try { if ((await stat(resolve(rootDir, candidate))).isFile()) inlineImports.push(token); diff --git a/tools/skills/validate-agent-guidance.test.mjs b/tools/skills/validate-agent-guidance.test.mjs index adb3e80a1..b68b652d0 100644 --- a/tools/skills/validate-agent-guidance.test.mjs +++ b/tools/skills/validate-agent-guidance.test.mjs @@ -1123,3 +1123,16 @@ for (const punctuation of ['—its', '–its', '…', ',next', '。next', '” ); }); } + +for (const suffix of ['—then', ',next', '”']) { + test(`extensionless imports stop at Unicode punctuation: ${suffix}`, async (t) => { + const result = await diagnostics(t, { + 'CLAUDE.md': + '@AGENTS.md\n\nRead @INSTRUCTIONS' + suffix + ' continue', + INSTRUCTIONS: 'Additional guidance', + }); + assert.ok( + result.some((message) => message.includes('additional or inline')) + ); + }); +}