fix(coding-agent): display path of sibling dependent extensions (#6964)
fixes: #6619
This commit is contained in:
@@ -1077,8 +1077,16 @@ export class InteractiveMode {
|
||||
* Get a short path relative to the package root for display.
|
||||
*/
|
||||
private getShortPath(fullPath: string, sourceInfo?: SourceInfo): string {
|
||||
const normalizedFullPath = fullPath.replace(/\\/g, "/");
|
||||
const baseDir = sourceInfo?.baseDir;
|
||||
if (baseDir && this.isPackageSource(sourceInfo)) {
|
||||
const normalizedBaseDir = baseDir.replace(/\\/g, "/");
|
||||
const npmRootMatch = normalizedBaseDir.match(/^(.*\/node_modules)\/(@?[^/]+(?:\/[^/]+)?)$/);
|
||||
// If fullPath is under the same node_modules root as baseDir, preserve that relative topology.
|
||||
if (npmRootMatch?.[1] && normalizedFullPath.startsWith(`${npmRootMatch[1]}/`)) {
|
||||
return path.posix.relative(normalizedBaseDir, normalizedFullPath);
|
||||
}
|
||||
|
||||
const relativePath = path.relative(path.resolve(baseDir), path.resolve(fullPath));
|
||||
if (
|
||||
relativePath &&
|
||||
@@ -1092,12 +1100,12 @@ export class InteractiveMode {
|
||||
}
|
||||
|
||||
const source = sourceInfo?.source ?? "";
|
||||
const npmMatch = fullPath.match(/node_modules\/(@?[^/]+(?:\/[^/]+)?)\/(.*)/);
|
||||
const npmMatch = normalizedFullPath.match(/node_modules\/(@?[^/]+(?:\/[^/]+)?)\/(.*)/);
|
||||
if (npmMatch && source.startsWith("npm:")) {
|
||||
return npmMatch[2];
|
||||
}
|
||||
|
||||
const gitMatch = fullPath.match(/git\/[^/]+\/[^/]+\/(.*)/);
|
||||
const gitMatch = normalizedFullPath.match(/git\/[^/]+\/[^/]+\/(.*)/);
|
||||
if (gitMatch && source.startsWith("git:")) {
|
||||
return gitMatch[1];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user