fix: preserve absolute mention paths (#123)

Co-authored-by: iliya <iliyazelenkog@gmail.com>
This commit is contained in:
infiniti 2026-05-16 18:19:54 +03:00 committed by GitHub
parent f08e228a7d
commit a6ba6072c0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 27 additions and 0 deletions

View file

@ -27,6 +27,10 @@ export function resolveFilePath(base: string, relativePath: string): string {
cleanRelative = cleanRelative.slice(1);
}
if (isAbsolutePath(cleanRelative)) {
return cleanRelative;
}
// Tilde paths (~/) are home-relative absolute paths - pass through as-is
// The main process will expand ~ to the actual home directory
if (cleanRelative.startsWith('~/') || cleanRelative.startsWith('~\\') || cleanRelative === '~') {

View file

@ -99,6 +99,9 @@ function joinPaths(base: string, relative: string): string {
if (cleanRelative.startsWith('@')) {
cleanRelative = cleanRelative.slice(1);
}
if (isAbsolutePath(cleanRelative)) {
return cleanRelative;
}
// Handle ./ prefix (current directory)
if (cleanRelative.startsWith('./') || cleanRelative.startsWith('.\\')) {

View file

@ -482,6 +482,9 @@ function joinPaths(base: string, relative: string): string {
if (cleanRelative.startsWith('@')) {
cleanRelative = cleanRelative.slice(1);
}
if (isAbsolutePath(cleanRelative)) {
return cleanRelative;
}
// Handle ./ prefix (current directory)
if (cleanRelative.startsWith('./') || cleanRelative.startsWith('.\\')) {

View file

@ -41,6 +41,14 @@ describe('resolveFilePath', () => {
expect(resolveFilePath('/repo', '@~/some/file.ts')).toBe('~/some/file.ts');
});
it('passes through @-prefixed absolute paths after stripping the mention marker', () => {
expect(resolveFilePath('/repo', '@/outside/file.ts')).toBe('/outside/file.ts');
expect(resolveFilePath('C:\\repo', '@C:\\outside\\file.ts')).toBe('C:\\outside\\file.ts');
expect(resolveFilePath('C:\\repo', '@\\\\server\\share\\file.ts')).toBe(
'\\\\server\\share\\file.ts'
);
});
it('passes through bare tilde as-is', () => {
expect(resolveFilePath('/repo', '~')).toBe('~');
});

View file

@ -195,4 +195,13 @@ describe('extractUserMentionPaths Windows paths', () => {
['~\\.claude\\CLAUDE.md']
);
});
it('strips mention markers before preserving absolute mention paths', () => {
expect(extractUserMentionPaths(userGroupWithPath('@C:\\Other\\file.ts'), 'C:\\Repo')).toEqual([
'C:\\Other\\file.ts',
]);
expect(
extractUserMentionPaths(userGroupWithPath('@\\\\server\\share\\file.ts'), 'C:\\Repo')
).toEqual(['\\\\server\\share\\file.ts']);
});
});