Refactor plugin/config loading, add theme-only plugin package support (#20556)

This commit is contained in:
Sebastian
2026-04-02 01:50:22 +02:00
committed by GitHub
parent 854484babf
commit f6fd43e574
24 changed files with 1246 additions and 539 deletions

View File

@@ -46,9 +46,9 @@ test("loads npm tui plugin from package ./tui export", async () => {
process.env.OPENCODE_PLUGIN_META_FILE = path.join(tmp.path, "plugin-meta.json")
const get = spyOn(TuiConfig, "get").mockResolvedValue({
plugin: [[tmp.extra.spec, { marker: tmp.extra.marker }]],
plugin_records: [
plugin_origins: [
{
item: [tmp.extra.spec, { marker: tmp.extra.marker }],
spec: [tmp.extra.spec, { marker: tmp.extra.marker }],
scope: "local",
source: path.join(tmp.path, "tui.json"),
},
@@ -108,9 +108,9 @@ test("does not use npm package exports dot for tui entry", async () => {
process.env.OPENCODE_PLUGIN_META_FILE = path.join(tmp.path, "plugin-meta.json")
const get = spyOn(TuiConfig, "get").mockResolvedValue({
plugin: [tmp.extra.spec],
plugin_records: [
plugin_origins: [
{
item: tmp.extra.spec,
spec: tmp.extra.spec,
scope: "local",
source: path.join(tmp.path, "tui.json"),
},
@@ -171,9 +171,9 @@ test("rejects npm tui export that resolves outside plugin directory", async () =
process.env.OPENCODE_PLUGIN_META_FILE = path.join(tmp.path, "plugin-meta.json")
const get = spyOn(TuiConfig, "get").mockResolvedValue({
plugin: [tmp.extra.spec],
plugin_records: [
plugin_origins: [
{
item: tmp.extra.spec,
spec: tmp.extra.spec,
scope: "local",
source: path.join(tmp.path, "tui.json"),
},
@@ -234,9 +234,9 @@ test("rejects npm tui plugin that exports server and tui together", async () =>
process.env.OPENCODE_PLUGIN_META_FILE = path.join(tmp.path, "plugin-meta.json")
const get = spyOn(TuiConfig, "get").mockResolvedValue({
plugin: [tmp.extra.spec],
plugin_records: [
plugin_origins: [
{
item: tmp.extra.spec,
spec: tmp.extra.spec,
scope: "local",
source: path.join(tmp.path, "tui.json"),
},
@@ -293,9 +293,9 @@ test("does not use npm package main for tui entry", async () => {
process.env.OPENCODE_PLUGIN_META_FILE = path.join(tmp.path, "plugin-meta.json")
const get = spyOn(TuiConfig, "get").mockResolvedValue({
plugin: [tmp.extra.spec],
plugin_records: [
plugin_origins: [
{
item: tmp.extra.spec,
spec: tmp.extra.spec,
scope: "local",
source: path.join(tmp.path, "tui.json"),
},
@@ -359,9 +359,9 @@ test("does not use directory package main for tui entry", async () => {
process.env.OPENCODE_PLUGIN_META_FILE = path.join(tmp.path, "plugin-meta.json")
const get = spyOn(TuiConfig, "get").mockResolvedValue({
plugin: [tmp.extra.spec],
plugin_records: [
plugin_origins: [
{
item: tmp.extra.spec,
spec: tmp.extra.spec,
scope: "local",
source: path.join(tmp.path, "tui.json"),
},
@@ -407,9 +407,9 @@ test("uses directory index fallback for tui when package.json is missing", async
process.env.OPENCODE_PLUGIN_META_FILE = path.join(tmp.path, "plugin-meta.json")
const get = spyOn(TuiConfig, "get").mockResolvedValue({
plugin: [tmp.extra.spec],
plugin_records: [
plugin_origins: [
{
item: tmp.extra.spec,
spec: tmp.extra.spec,
scope: "local",
source: path.join(tmp.path, "tui.json"),
},
@@ -465,9 +465,9 @@ test("uses npm package name when tui plugin id is omitted", async () => {
process.env.OPENCODE_PLUGIN_META_FILE = path.join(tmp.path, "plugin-meta.json")
const get = spyOn(TuiConfig, "get").mockResolvedValue({
plugin: [[tmp.extra.spec, { marker: tmp.extra.marker }]],
plugin_records: [
plugin_origins: [
{
item: [tmp.extra.spec, { marker: tmp.extra.marker }],
spec: [tmp.extra.spec, { marker: tmp.extra.marker }],
scope: "local",
source: path.join(tmp.path, "tui.json"),
},