|
|
@@ -1,6 +1,7 @@
|
|
|
import { Log } from "../util/log"
|
|
|
import path from "path"
|
|
|
-import { pathToFileURL } from "url"
|
|
|
+import { pathToFileURL, fileURLToPath } from "url"
|
|
|
+import { createRequire } from "module"
|
|
|
import os from "os"
|
|
|
import z from "zod"
|
|
|
import { Filesystem } from "../util/filesystem"
|
|
|
@@ -276,7 +277,6 @@ export namespace Config {
|
|
|
"@opencode-ai/plugin": targetVersion,
|
|
|
}
|
|
|
await Filesystem.writeJson(pkg, json)
|
|
|
- await new Promise((resolve) => setTimeout(resolve, 3000))
|
|
|
|
|
|
const gitignore = path.join(dir, ".gitignore")
|
|
|
const hasGitIgnore = await Filesystem.exists(gitignore)
|
|
|
@@ -1332,7 +1332,16 @@ export namespace Config {
|
|
|
const plugin = data.plugin[i]
|
|
|
try {
|
|
|
data.plugin[i] = import.meta.resolve!(plugin, options.path)
|
|
|
- } catch (err) {}
|
|
|
+ } catch (e) {
|
|
|
+ try {
|
|
|
+ // import.meta.resolve sometimes fails with newly created node_modules
|
|
|
+ const require = createRequire(options.path)
|
|
|
+ const resolvedPath = require.resolve(plugin)
|
|
|
+ data.plugin[i] = pathToFileURL(resolvedPath).href
|
|
|
+ } catch {
|
|
|
+ // Ignore, plugin might be a generic string identifier like "mcp-server"
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
return data
|