11import { describe , expect } from "bun:test"
2- import { NodeFileSystem } from "@effect/platform-node"
3- import { Config } from "@opencode-ai/core/config"
42import { AppNodeBuilder } from "@opencode-ai/core/effect/app-node-builder"
5- import { FSUtil } from "@opencode-ai/util/fs-util"
6- import { Location } from "@opencode-ai/core/location"
7- import { Effect , Stream } from "effect"
3+ import { ConfigPluginSource } from "@opencode-ai/core/config/plugin/source"
4+ import { Effect , Layer , Stream } from "effect"
85import { SkillPlugin } from "@opencode-ai/core/plugin/skill"
9- import { AbsolutePath } from "@opencode-ai/core/schema"
106import { Skill } from "@opencode-ai/core/skill"
11- import { location } from "../fixture/location"
127import { testEffect } from "../lib/effect"
138import { host } from "./host"
149
1510const it = testEffect ( AppNodeBuilder . build ( Skill . node ) )
11+ const sources = ( operations : readonly ConfigPluginSource . Operation [ ] = [ ] ) =>
12+ Layer . succeed (
13+ ConfigPluginSource . Service ,
14+ ConfigPluginSource . Service . of ( { operations : ( ) => Effect . succeed ( operations ) , changes : ( ) => Stream . never } ) ,
15+ )
1616
1717describe ( "SkillPlugin.Plugin" , ( ) => {
1818 it . effect ( "registers built-in skills" , ( ) =>
@@ -27,15 +27,7 @@ describe("SkillPlugin.Plugin", () => {
2727 reload : skill . reload ,
2828 } ,
2929 } ) ,
30- ) . pipe (
31- Effect . provide ( Config . testLayer ( ) ) ,
32- Effect . provideService (
33- Location . Service ,
34- Location . Service . of ( location ( { directory : AbsolutePath . make ( import . meta. dir ) } ) ) ,
35- ) ,
36- Effect . provide ( AppNodeBuilder . build ( FSUtil . node ) ) ,
37- Effect . provide ( NodeFileSystem . layer ) ,
38- )
30+ ) . pipe ( Effect . provide ( sources ( ) ) )
3931 const skills = yield * skill . list ( )
4032 const report = skills . find ( ( item ) => item . id === "report" )
4133
@@ -58,4 +50,30 @@ describe("SkillPlugin.Plugin", () => {
5850 expect ( report ?. content ) . toContain ( "- install/channel: beta" )
5951 } ) ,
6052 )
53+
54+ it . effect ( "reports canonical configured plugin sources with existing labels and ordering" , ( ) =>
55+ Effect . gen ( function * ( ) {
56+ const skill = yield * Skill . Service
57+ yield * SkillPlugin . Plugin . effect (
58+ host ( {
59+ skill : {
60+ list : ( ) => Effect . die ( "unused skill.list" ) ,
61+ transform : skill . transform ,
62+ reload : skill . reload ,
63+ } ,
64+ } ) ,
65+ )
66+ const report = ( yield * skill . list ( ) ) . find ( ( item ) => item . id === "report" )
67+ expect ( report ?. content ) . toContain ( "- Active plugins: -disabled, local.ts, package-plugin, package-plugin" )
68+ } ) . pipe (
69+ Effect . provide (
70+ sources ( [
71+ { type : "add" , target : "package-plugin" , options : { } } ,
72+ { type : "remove" , target : "disabled" } ,
73+ { type : "add" , target : "local.ts" , options : { } , mtime : 1 } ,
74+ { type : "add" , target : "package-plugin" , options : { enabled : true } } ,
75+ ] ) ,
76+ ) ,
77+ ) ,
78+ )
6179} )
0 commit comments