fix(agents): preserve imports after bare URL punctuation

This commit is contained in:
4gray committed 2026-09-21 03:33:08 +02:00
1 parent 5a8b233840
commit ad5050ca78
3 files changed
+17 -1

No files matched your search

+1
View File
@@ -72,6 +72,7 @@ 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.
At-signs inside external URLs are excluded per HTML text node, preserving adjacent imports.
A closing bracket followed by punctuation and an at-sign terminates a bare URL exclusion.
Extensionless inline candidates are also imports when they resolve to repository files,
checking the full filename before prefixes at ASCII/Unicode prose separators.
Declared scoped dependencies, scope wildcards and matching TypeScript path aliases
+1 -1
View File
@@ -147,7 +147,7 @@ export function guidanceProse(markdown) {
return ' ';
if (node.nodeName === '#text')
return node.value.replace(
/(?:\b[a-z][a-z\d+.-]*:\/\/|\/\/)[^\s]+/giu,
/(?:\b[a-z][a-z\d+.-]*:\/\/|\/\/)[^\s]*?(?=[)\]}>][.,;:!?]*@|\s|$)/giu,
' '
);
const content = (node.childNodes ?? []).map(text).join('');
@@ -1489,3 +1489,18 @@ test('local HTML base uses native filesystem paths', async (t) => {
[]
);
});
for (const boundary of [').', '];', '}']) {
test(`bare URL preserves adjacent import after ${boundary}`, async (t) => {
assert.ok(
(
await diagnostics(t, {
'CLAUDE.md':
'@AGENTS.md\n\nhttps://example.com/path' +
boundary +
'@docs/guide.md',
})
).some((message) => message.includes('additional or inline'))
);
});
}