MCPcopy Index your code
hub / github.com/anomalyco/opencode / resolvePathPluginTarget

Function resolvePathPluginTarget

packages/opencode/src/plugin/shared.ts:175–192  ·  view source on GitHub ↗
(spec: string)

Source from the content-addressed store, hash-verified

173}
174
175export async function resolvePathPluginTarget(spec: string) {
176 const raw = spec.startsWith("file://") ? fileURLToPath(spec) : spec
177 const file = path.isAbsolute(raw) || /^[A-Za-z]:[\\/]/.test(raw) ? raw : path.resolve(raw)
178 const stat = await Filesystem.statAsync(file)
179 if (!stat?.isDirectory()) {
180 if (spec.startsWith("file://")) return spec
181 return pathToFileURL(file).href
182 }
183
184 if (await Filesystem.exists(path.join(file, "package.json"))) {
185 return pathToFileURL(file).href
186 }
187
188 const index = await resolveDirectoryIndex(file)
189 if (index) return pathToFileURL(index).href
190
191 throw new Error(`Plugin directory ${file} is missing package.json or index file`)
192}
193
194export async function checkPluginCompatibility(target: string, opencodeVersion: string, pkg?: PluginPackage) {
195 if (!semver.valid(opencodeVersion) || semver.major(opencodeVersion) === 0) return

Callers 2

resolvePluginSpecFunction · 0.90
resolvePluginTargetFunction · 0.85

Calls 2

resolveDirectoryIndexFunction · 0.85
existsMethod · 0.45

Tested by

no test coverage detected