MCPcopy
hub / github.com/anomalyco/opencode / readPackageThemes

Function readPackageThemes

packages/opencode/src/plugin/shared.ts:238–262  ·  view source on GitHub ↗
(spec: string, pkg: PluginPackage)

Source from the content-addressed store, hash-verified

236}
237
238export function readPackageThemes(spec: string, pkg: PluginPackage) {
239 const field = pkg.json["oc-themes"]
240 if (field === undefined) return []
241 if (!Array.isArray(field)) {
242 throw new TypeError(`Plugin ${spec} has invalid oc-themes field`)
243 }
244
245 const list = field.map((item) => {
246 if (typeof item !== "string") {
247 throw new TypeError(`Plugin ${spec} has invalid oc-themes entry`)
248 }
249
250 const raw = item.trim()
251 if (!raw) {
252 throw new TypeError(`Plugin ${spec} has empty oc-themes entry`)
253 }
254 if (raw.startsWith("file://") || isAbsolutePath(raw)) {
255 throw new TypeError(`Plugin ${spec} oc-themes entry must be relative: ${item}`)
256 }
257
258 return resolvePackageFile(spec, raw, "oc-themes", pkg)
259 })
260
261 return Array.from(new Set(list))
262}
263
264export function readPluginId(id: unknown, spec: string) {
265 if (id === undefined) return

Callers 3

packageTargetsFunction · 0.90
readThemeFilesFunction · 0.90

Calls 3

isAbsolutePathFunction · 0.85
resolvePackageFileFunction · 0.85
fromMethod · 0.45

Tested by

no test coverage detected