opencode-codeops 2.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -184,11 +184,33 @@ function entrySpec(item) {
|
|
|
184
184
|
return undefined
|
|
185
185
|
}
|
|
186
186
|
|
|
187
|
+
/**
|
|
188
|
+
* Normalize the plugin entries from one configuration document.
|
|
189
|
+
*
|
|
190
|
+
* A document's `info` may carry the native `plugins` array or the legacy
|
|
191
|
+
* singular `plugin` array; both are read so mixed configurations are reported
|
|
192
|
+
* correctly.
|
|
193
|
+
*
|
|
194
|
+
* @param info - Configuration document info object
|
|
195
|
+
* @returns The document's plugin spec strings
|
|
196
|
+
*/
|
|
197
|
+
function documentPlugins(info) {
|
|
198
|
+
if (!info || typeof info !== "object") return []
|
|
199
|
+
const raw = Array.isArray(info.plugins)
|
|
200
|
+
? info.plugins
|
|
201
|
+
: Array.isArray(info.plugin)
|
|
202
|
+
? info.plugin
|
|
203
|
+
: []
|
|
204
|
+
return raw.map(entrySpec).filter((spec) => typeof spec === "string")
|
|
205
|
+
}
|
|
206
|
+
|
|
187
207
|
/**
|
|
188
208
|
* Reads the resolved plugin list from OpenCode's effective config.
|
|
189
209
|
*
|
|
190
|
-
* OpenCode 2
|
|
191
|
-
*
|
|
210
|
+
* OpenCode 2 prints the list of configuration sources, each with its document
|
|
211
|
+
* under `info`; OpenCode 1 printed one resolved config object. Both shapes are
|
|
212
|
+
* understood, and the legacy `plugin` key is read as a fallback so mixed
|
|
213
|
+
* configurations are reported correctly.
|
|
192
214
|
*
|
|
193
215
|
* @param details - Inspection inputs
|
|
194
216
|
* @param details.cwd - Working directory
|
|
@@ -200,14 +222,17 @@ export function readConfiguredPlugin({ cwd, run = defaultRun } = {}) {
|
|
|
200
222
|
const result = run("opencode", ["debug", "config"], { cwd })
|
|
201
223
|
if (result.error || result.status !== 0) return undefined
|
|
202
224
|
|
|
203
|
-
const
|
|
204
|
-
const
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
225
|
+
const parsed = JSON.parse(result.stdout)
|
|
226
|
+
const sources = Array.isArray(parsed) ? parsed : [parsed]
|
|
227
|
+
const specs = []
|
|
228
|
+
for (const source of sources) {
|
|
229
|
+
if (source && typeof source === "object" && "info" in source) {
|
|
230
|
+
specs.push(...documentPlugins(source.info))
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
if (specs.length > 0) return specs
|
|
209
234
|
|
|
210
|
-
return
|
|
235
|
+
return documentPlugins(parsed)
|
|
211
236
|
} catch {
|
|
212
237
|
return undefined
|
|
213
238
|
}
|
package/package.json
CHANGED
|
Binary file
|