fix(windows): resolve symlinked config paths for plugin detection (fixes #2271)

This commit is contained in:
MoerAI
2026-03-20 10:44:19 +09:00
parent d2a49428b9
commit 23a30e86f2
5 changed files with 146 additions and 14 deletions
@@ -1,6 +1,7 @@
import { existsSync, readFileSync } from "fs"
import { homedir } from "os"
import { join } from "path"
import { basename, join } from "path"
import { fileURLToPath } from "url"
import { log } from "../../shared/logger"
import type {
InstalledPluginsDatabase,
@@ -79,8 +80,23 @@ function loadPluginManifest(installPath: string): PluginManifest | null {
}
function derivePluginNameFromKey(pluginKey: string): string {
const atIndex = pluginKey.indexOf("@")
return atIndex > 0 ? pluginKey.substring(0, atIndex) : pluginKey
const keyWithoutSource = pluginKey.startsWith("npm:") ? pluginKey.slice(4) : pluginKey
const versionSeparator = keyWithoutSource.lastIndexOf("@")
const keyWithoutVersion = versionSeparator > 0 ? keyWithoutSource.slice(0, versionSeparator) : keyWithoutSource
if (keyWithoutVersion.startsWith("file://")) {
try {
return basename(fileURLToPath(keyWithoutVersion))
} catch {
return basename(keyWithoutVersion)
}
}
if (keyWithoutVersion.includes("/") || keyWithoutVersion.includes("\\")) {
return basename(keyWithoutVersion)
}
return keyWithoutVersion
}
function isPluginEnabled(