fix(plugin): load local toolkit and expose status tool

This commit is contained in:
sargatxet committed 2026-10-08 13:35:44 +02:00
1 parent aac5627e98
commit 2fcfe2fbf7
14 files changed
+145 -34

No files matched your search

+17 -1
View File
@@ -1,6 +1,6 @@
import assert from "node:assert/strict"
import test from "node:test"
import { addPlugin, removePlugin } from "../dist/installer/config.js"
import { addPlugin, removePlugin, replacePlugin } from "../dist/installer/config.js"
const pluginName = "@sargatxet/opencode-toolkit"
@@ -36,6 +36,22 @@ test("removes only the requested package plugin", () => {
assert.deepEqual(JSON.parse(result.content).plugins, ["other-plugin"])
})
test("replaces a managed plugin entry while preserving JSONC comments", () => {
const original = `{
"plugins": [
// Added by the previous installer version.
"${pluginName}"
]
}`
const replacement = "../node_modules/@sargatxet/opencode-toolkit"
const result = replacePlugin(original, pluginName, replacement)
assert.equal(result.replaced, true)
assert.deepEqual(JSON.parse(result.content.replace(" // Added by the previous installer version.\n", "")).plugins, [replacement])
assert.match(result.content, /Added by the previous installer version/)
})
test("rejects malformed or incompatible plugin configuration", () => {
assert.throws(() => addPlugin('{ "plugins": "not-an-array" }', pluginName), /plugins.*array/i)
assert.throws(() => addPlugin('{ broken', pluginName), /invalid JSONC/i)