opencode-plugin-hub 0.1.4 → 0.2.0

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/README.md CHANGED
@@ -200,6 +200,8 @@ npm run refresh # 重建内置目录快照(会逐个查 npm,约 1-2 分钟
200
200
 
201
201
  ## 发布到 npm
202
202
 
203
+ > 发布只通过 GitHub Actions:`npm version patch` 后推送 `v*` tag,由 `.github/workflows/publish.yml` 构建并发布。本地 `npm publish` 已被 `prepublishOnly` 守卫禁止。下面的手动流程仅作历史/首次发布参考(首次发布 npm 无法用 OIDC)。
204
+
203
205
  包名 `opencode-plugin-hub` 当前在 npm 上可用。注意:这台机器默认 registry 是 `registry.npmmirror.com`(淘宝镜像),**镜像不能发布**;`package.json` 的 `publishConfig.registry` 已经固定到官方 `registry.npmjs.org`,登录也要显式指定:
204
206
 
205
207
  ```bash
@@ -218,7 +220,7 @@ npm publish --access public # publishConfig 会把它发到 registry.
218
220
  - `files` 只带 `dist`、`src`、`LICENSE`;`README.md`、`package.json` 由 npm 自动包含。
219
221
  - `repository` / `homepage` / `bugs` 已指向 <https://github.com/meiyx7/opencode-plugin-hub>;如果你 fork 或转移仓库,记得同步改这三项。
220
222
  - 如果 `opencode-plugin-hub` 被占用,改用带 scope 的名字,例如 `@your-name/opencode-plugin-hub`,同步改 `package.json` 的 `name` 和安装文档。
221
- - 更新版本:`npm version patch`(或 `minor` / `major`),再 `npm publish`。
223
+ - 更新版本:`npm version patch`(或 `minor` / `major`),再 `git push --follow-tags`,由 GitHub Actions 自动发布;本地 `npm publish` 已被 `prepublishOnly` 守卫禁止。
222
224
  - 有 2FA 的账号发布时会提示输入一次性验证码。
223
225
  - npm 发布是公开且难以撤回的,建议先 `npm pack`,在本地或测试机器上确认能装再发。
224
226
  - 发布后用 `npm view opencode-plugin-hub version --registry=https://registry.npmjs.org/` 确认。npmmirror 是异步镜像,刚发布时可能还没同步;如果 OpenCode 通过镜像拉包暂时找不到,等几分钟或临时把 registry 指向官方 npm。
@@ -1,24 +1,24 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("solid-js/web"),Pe=require("@opencode/plugin/gui"),d=require("effect"),Be=require("node:child_process"),Le=require("node:os"),U=require("node:path"),H=require("node:fs/promises"),l=require("solid-js"),vn=d.Schema.Struct({spec:d.Schema.String,name:d.Schema.String,kind:d.Schema.String,version:d.Schema.String,removable:d.Schema.Boolean}),Dt=d.Schema.Struct({configPath:d.Schema.String,configKey:d.Schema.String,plugins:d.Schema.Array(vn),error:d.Schema.String}),bn=d.Schema.Struct({name:d.Schema.String,version:d.Schema.String,description:d.Schema.String,published:d.Schema.String,updated:d.Schema.String,installed:d.Schema.Boolean,current:d.Schema.String,hasUpdate:d.Schema.Boolean,weekly:d.Schema.Number,monthly:d.Schema.Number,publisher:d.Schema.String,license:d.Schema.String,keywords:d.Schema.Array(d.Schema.String),homepage:d.Schema.String,repo:d.Schema.String,npm:d.Schema.String}),yn=d.Schema.Struct({name:d.Schema.String,version:d.Schema.String,description:d.Schema.String,homepage:d.Schema.String,repo:d.Schema.String,repoDir:d.Schema.String,npm:d.Schema.String,bugs:d.Schema.String,license:d.Schema.String,keywords:d.Schema.Array(d.Schema.String),maintainers:d.Schema.Array(d.Schema.String),weekly:d.Schema.Number,monthly:d.Schema.Number,published:d.Schema.String,created:d.Schema.String,versions:d.Schema.Number,unpacked:d.Schema.Number,files:d.Schema.Number,dependencies:d.Schema.Array(d.Schema.String),deprecated:d.Schema.String,readme:d.Schema.String,readmeTruncated:d.Schema.Boolean,installed:d.Schema.Boolean,current:d.Schema.String,hasUpdate:d.Schema.Boolean,error:d.Schema.String}),wn=d.Schema.Struct({spec:d.Schema.String,name:d.Schema.String,kind:d.Schema.String,current:d.Schema.String,latest:d.Schema.String,hasUpdate:d.Schema.Boolean,managed:d.Schema.Boolean,error:d.Schema.String}),kn=d.Schema.Struct({items:d.Schema.Array(wn),error:d.Schema.String}),xn=d.Schema.Struct({hits:d.Schema.Array(bn),error:d.Schema.String}),Sn=d.Schema.Struct({name:d.Schema.String,pkg:d.Schema.String,version:d.Schema.String,type:d.Schema.String,desc:d.Schema.String,long:d.Schema.String,repo:d.Schema.String,tags:d.Schema.Array(d.Schema.String),installed:d.Schema.Boolean}),$n=d.Schema.Struct({entries:d.Schema.Array(Sn),source:d.Schema.String,registry:d.Schema.optional(d.Schema.String),fetchedAt:d.Schema.Number,error:d.Schema.String}),Cn=d.Schema.Struct({force:d.Schema.Boolean}),_n=d.Schema.Struct({url:d.Schema.String}),Ze=d.Schema.Struct({ok:d.Schema.Boolean}),Ke=d.Schema.Struct({ok:d.Schema.Boolean,message:d.Schema.String,state:Dt}),yt=d.Schema.Struct({spec:d.Schema.String,version:d.Schema.String}),An=d.Schema.Struct({query:d.Schema.String}),On=d.Schema.Struct({name:d.Schema.String}),wt=Pe.Ipc.define({id:"plugin-hub.admin",methods:{snapshot:{output:Dt},updates:{output:kn},search:{input:An,output:xn},detail:{input:On,output:yn},browse:{input:Cn,output:$n},openUrl:{input:_n,output:Ze},openConfig:{output:Ze},install:{input:yt,output:Ke},remove:{input:yt,output:Ke},reload:{output:Ke},restart:{output:Ze}}});function Nt(e,r=!1){const o=e.length;let n=0,i="",s=0,c=16,p=0,u=0,v=0,h=0,k=0;function $(g,b){let S=0,y=0;for(;S<g;){let f=e.charCodeAt(n);if(f>=48&&f<=57)y=y*16+f-48;else if(f>=65&&f<=70)y=y*16+f-65+10;else if(f>=97&&f<=102)y=y*16+f-97+10;else break;n++,S++}return S<g&&(y=-1),y}function A(g){n=g,i="",s=0,c=16,k=0}function I(){let g=n;if(e.charCodeAt(n)===48)n++;else for(n++;n<e.length&&Ae(e.charCodeAt(n));)n++;if(n<e.length&&e.charCodeAt(n)===46)if(n++,n<e.length&&Ae(e.charCodeAt(n)))for(n++;n<e.length&&Ae(e.charCodeAt(n));)n++;else return k=3,e.substring(g,n);let b=n;if(n<e.length&&(e.charCodeAt(n)===69||e.charCodeAt(n)===101))if(n++,(n<e.length&&e.charCodeAt(n)===43||e.charCodeAt(n)===45)&&n++,n<e.length&&Ae(e.charCodeAt(n))){for(n++;n<e.length&&Ae(e.charCodeAt(n));)n++;b=n}else k=3;return e.substring(g,b)}function G(){let g="",b=n;for(;;){if(n>=o){g+=e.substring(b,n),k=2;break}const S=e.charCodeAt(n);if(S===34){g+=e.substring(b,n),n++;break}if(S===92){if(g+=e.substring(b,n),n++,n>=o){k=2;break}switch(e.charCodeAt(n++)){case 34:g+='"';break;case 92:g+="\\";break;case 47:g+="/";break;case 98:g+="\b";break;case 102:g+="\f";break;case 110:g+=`
2
- `;break;case 114:g+="\r";break;case 116:g+=" ";break;case 117:const f=$(4);f>=0?g+=String.fromCharCode(f):k=4;break;default:k=5}b=n;continue}if(S>=0&&S<=31)if(je(S)){g+=e.substring(b,n),k=2;break}else k=6;n++}return g}function M(){if(i="",k=0,s=n,u=p,h=v,n>=o)return s=o,c=17;let g=e.charCodeAt(n);if(et(g)){do n++,i+=String.fromCharCode(g),g=e.charCodeAt(n);while(et(g));return c=15}if(je(g))return n++,i+=String.fromCharCode(g),g===13&&e.charCodeAt(n)===10&&(n++,i+=`
3
- `),p++,v=n,c=14;switch(g){case 123:return n++,c=1;case 125:return n++,c=2;case 91:return n++,c=3;case 93:return n++,c=4;case 58:return n++,c=6;case 44:return n++,c=5;case 34:return n++,i=G(),c=10;case 47:const b=n-1;if(e.charCodeAt(n+1)===47){for(n+=2;n<o&&!je(e.charCodeAt(n));)n++;return i=e.substring(b,n),c=12}if(e.charCodeAt(n+1)===42){n+=2;const S=o-1;let y=!1;for(;n<S;){const f=e.charCodeAt(n);if(f===42&&e.charCodeAt(n+1)===47){n+=2,y=!0;break}n++,je(f)&&(f===13&&e.charCodeAt(n)===10&&n++,p++,v=n)}return y||(n++,k=1),i=e.substring(b,n),c=13}return i+=String.fromCharCode(g),n++,c=16;case 45:if(i+=String.fromCharCode(g),n++,n===o||!Ae(e.charCodeAt(n)))return c=16;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return i+=I(),c=11;default:for(;n<o&&F(g);)n++,g=e.charCodeAt(n);if(s!==n){switch(i=e.substring(s,n),i){case"true":return c=8;case"false":return c=9;case"null":return c=7}return c=16}return i+=String.fromCharCode(g),n++,c=16}}function F(g){if(et(g)||je(g))return!1;switch(g){case 125:case 93:case 123:case 91:case 34:case 58:case 44:case 47:return!1}return!0}function j(){let g;do g=M();while(g>=12&&g<=15);return g}return{setPosition:A,getPosition:()=>n,scan:r?j:M,getToken:()=>c,getTokenValue:()=>i,getTokenOffset:()=>s,getTokenLength:()=>n-s,getTokenStartLine:()=>u,getTokenStartCharacter:()=>s-h,getTokenError:()=>k}}function et(e){return e===32||e===9}function je(e){return e===10||e===13}function Ae(e){return e>=48&&e<=57}var kt;(function(e){e[e.lineFeed=10]="lineFeed",e[e.carriageReturn=13]="carriageReturn",e[e.space=32]="space",e[e._0=48]="_0",e[e._1=49]="_1",e[e._2=50]="_2",e[e._3=51]="_3",e[e._4=52]="_4",e[e._5=53]="_5",e[e._6=54]="_6",e[e._7=55]="_7",e[e._8=56]="_8",e[e._9=57]="_9",e[e.a=97]="a",e[e.b=98]="b",e[e.c=99]="c",e[e.d=100]="d",e[e.e=101]="e",e[e.f=102]="f",e[e.g=103]="g",e[e.h=104]="h",e[e.i=105]="i",e[e.j=106]="j",e[e.k=107]="k",e[e.l=108]="l",e[e.m=109]="m",e[e.n=110]="n",e[e.o=111]="o",e[e.p=112]="p",e[e.q=113]="q",e[e.r=114]="r",e[e.s=115]="s",e[e.t=116]="t",e[e.u=117]="u",e[e.v=118]="v",e[e.w=119]="w",e[e.x=120]="x",e[e.y=121]="y",e[e.z=122]="z",e[e.A=65]="A",e[e.B=66]="B",e[e.C=67]="C",e[e.D=68]="D",e[e.E=69]="E",e[e.F=70]="F",e[e.G=71]="G",e[e.H=72]="H",e[e.I=73]="I",e[e.J=74]="J",e[e.K=75]="K",e[e.L=76]="L",e[e.M=77]="M",e[e.N=78]="N",e[e.O=79]="O",e[e.P=80]="P",e[e.Q=81]="Q",e[e.R=82]="R",e[e.S=83]="S",e[e.T=84]="T",e[e.U=85]="U",e[e.V=86]="V",e[e.W=87]="W",e[e.X=88]="X",e[e.Y=89]="Y",e[e.Z=90]="Z",e[e.asterisk=42]="asterisk",e[e.backslash=92]="backslash",e[e.closeBrace=125]="closeBrace",e[e.closeBracket=93]="closeBracket",e[e.colon=58]="colon",e[e.comma=44]="comma",e[e.dot=46]="dot",e[e.doubleQuote=34]="doubleQuote",e[e.minus=45]="minus",e[e.openBrace=123]="openBrace",e[e.openBracket=91]="openBracket",e[e.plus=43]="plus",e[e.slash=47]="slash",e[e.formFeed=12]="formFeed",e[e.tab=9]="tab"})(kt||(kt={}));const ie=new Array(20).fill(0).map((e,r)=>" ".repeat(r)),Oe=200,xt={" ":{"\n":new Array(Oe).fill(0).map((e,r)=>`
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("solid-js/web"),Ee=require("@opencode/plugin/gui"),d=require("effect"),De=require("node:child_process"),Ie=require("node:os"),U=require("node:path"),V=require("node:fs/promises"),l=require("solid-js"),Sn=d.Schema.Struct({spec:d.Schema.String,name:d.Schema.String,kind:d.Schema.String,version:d.Schema.String,removable:d.Schema.Boolean}),Ft=d.Schema.Struct({configPath:d.Schema.String,configKey:d.Schema.String,plugins:d.Schema.Array(Sn),error:d.Schema.String}),$n=d.Schema.Struct({name:d.Schema.String,version:d.Schema.String,description:d.Schema.String,published:d.Schema.String,updated:d.Schema.String,installed:d.Schema.Boolean,current:d.Schema.String,hasUpdate:d.Schema.Boolean,weekly:d.Schema.Number,monthly:d.Schema.Number,publisher:d.Schema.String,license:d.Schema.String,keywords:d.Schema.Array(d.Schema.String),homepage:d.Schema.String,repo:d.Schema.String,npm:d.Schema.String}),Cn=d.Schema.Struct({name:d.Schema.String,version:d.Schema.String,description:d.Schema.String,homepage:d.Schema.String,repo:d.Schema.String,repoDir:d.Schema.String,npm:d.Schema.String,bugs:d.Schema.String,license:d.Schema.String,keywords:d.Schema.Array(d.Schema.String),maintainers:d.Schema.Array(d.Schema.String),weekly:d.Schema.Number,monthly:d.Schema.Number,published:d.Schema.String,created:d.Schema.String,versions:d.Schema.Number,unpacked:d.Schema.Number,files:d.Schema.Number,dependencies:d.Schema.Array(d.Schema.String),deprecated:d.Schema.String,readme:d.Schema.String,readmeTruncated:d.Schema.Boolean,installed:d.Schema.Boolean,current:d.Schema.String,hasUpdate:d.Schema.Boolean,error:d.Schema.String}),_n=d.Schema.Struct({spec:d.Schema.String,name:d.Schema.String,kind:d.Schema.String,current:d.Schema.String,latest:d.Schema.String,hasUpdate:d.Schema.Boolean,managed:d.Schema.Boolean,error:d.Schema.String}),On=d.Schema.Struct({items:d.Schema.Array(_n),error:d.Schema.String}),An=d.Schema.Struct({hits:d.Schema.Array($n),error:d.Schema.String}),Tn=d.Schema.Struct({name:d.Schema.String,pkg:d.Schema.String,version:d.Schema.String,type:d.Schema.String,desc:d.Schema.String,long:d.Schema.String,repo:d.Schema.String,tags:d.Schema.Array(d.Schema.String),installed:d.Schema.Boolean}),In=d.Schema.Struct({entries:d.Schema.Array(Tn),source:d.Schema.String,registry:d.Schema.optional(d.Schema.String),fetchedAt:d.Schema.Number,error:d.Schema.String}),Ln=d.Schema.Struct({force:d.Schema.Boolean}),Mn=d.Schema.Struct({url:d.Schema.String}),rt=d.Schema.Struct({ok:d.Schema.Boolean}),ot=d.Schema.Struct({ok:d.Schema.Boolean,message:d.Schema.String,state:Ft}),$t=d.Schema.Struct({spec:d.Schema.String,version:d.Schema.String}),jn=d.Schema.Struct({query:d.Schema.String}),zn=d.Schema.Struct({name:d.Schema.String}),Ct=Ee.Ipc.define({id:"plugin-hub.admin",methods:{snapshot:{output:Ft},updates:{output:On},search:{input:jn,output:An},detail:{input:zn,output:Cn},browse:{input:Ln,output:In},openUrl:{input:Mn,output:rt},openConfig:{output:rt},install:{input:$t,output:ot},remove:{input:$t,output:ot},reload:{output:ot},restart:{output:rt}}});function qt(e,r=!1){const o=e.length;let n=0,i="",s=0,c=16,p=0,u=0,v=0,h=0,k=0;function $(g,b){let S=0,y=0;for(;S<g;){let f=e.charCodeAt(n);if(f>=48&&f<=57)y=y*16+f-48;else if(f>=65&&f<=70)y=y*16+f-65+10;else if(f>=97&&f<=102)y=y*16+f-97+10;else break;n++,S++}return S<g&&(y=-1),y}function A(g){n=g,i="",s=0,c=16,k=0}function L(){let g=n;if(e.charCodeAt(n)===48)n++;else for(n++;n<e.length&&_e(e.charCodeAt(n));)n++;if(n<e.length&&e.charCodeAt(n)===46)if(n++,n<e.length&&_e(e.charCodeAt(n)))for(n++;n<e.length&&_e(e.charCodeAt(n));)n++;else return k=3,e.substring(g,n);let b=n;if(n<e.length&&(e.charCodeAt(n)===69||e.charCodeAt(n)===101))if(n++,(n<e.length&&e.charCodeAt(n)===43||e.charCodeAt(n)===45)&&n++,n<e.length&&_e(e.charCodeAt(n))){for(n++;n<e.length&&_e(e.charCodeAt(n));)n++;b=n}else k=3;return e.substring(g,b)}function G(){let g="",b=n;for(;;){if(n>=o){g+=e.substring(b,n),k=2;break}const S=e.charCodeAt(n);if(S===34){g+=e.substring(b,n),n++;break}if(S===92){if(g+=e.substring(b,n),n++,n>=o){k=2;break}switch(e.charCodeAt(n++)){case 34:g+='"';break;case 92:g+="\\";break;case 47:g+="/";break;case 98:g+="\b";break;case 102:g+="\f";break;case 110:g+=`
2
+ `;break;case 114:g+="\r";break;case 116:g+=" ";break;case 117:const f=$(4);f>=0?g+=String.fromCharCode(f):k=4;break;default:k=5}b=n;continue}if(S>=0&&S<=31)if(ze(S)){g+=e.substring(b,n),k=2;break}else k=6;n++}return g}function M(){if(i="",k=0,s=n,u=p,h=v,n>=o)return s=o,c=17;let g=e.charCodeAt(n);if(it(g)){do n++,i+=String.fromCharCode(g),g=e.charCodeAt(n);while(it(g));return c=15}if(ze(g))return n++,i+=String.fromCharCode(g),g===13&&e.charCodeAt(n)===10&&(n++,i+=`
3
+ `),p++,v=n,c=14;switch(g){case 123:return n++,c=1;case 125:return n++,c=2;case 91:return n++,c=3;case 93:return n++,c=4;case 58:return n++,c=6;case 44:return n++,c=5;case 34:return n++,i=G(),c=10;case 47:const b=n-1;if(e.charCodeAt(n+1)===47){for(n+=2;n<o&&!ze(e.charCodeAt(n));)n++;return i=e.substring(b,n),c=12}if(e.charCodeAt(n+1)===42){n+=2;const S=o-1;let y=!1;for(;n<S;){const f=e.charCodeAt(n);if(f===42&&e.charCodeAt(n+1)===47){n+=2,y=!0;break}n++,ze(f)&&(f===13&&e.charCodeAt(n)===10&&n++,p++,v=n)}return y||(n++,k=1),i=e.substring(b,n),c=13}return i+=String.fromCharCode(g),n++,c=16;case 45:if(i+=String.fromCharCode(g),n++,n===o||!_e(e.charCodeAt(n)))return c=16;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return i+=L(),c=11;default:for(;n<o&&q(g);)n++,g=e.charCodeAt(n);if(s!==n){switch(i=e.substring(s,n),i){case"true":return c=8;case"false":return c=9;case"null":return c=7}return c=16}return i+=String.fromCharCode(g),n++,c=16}}function q(g){if(it(g)||ze(g))return!1;switch(g){case 125:case 93:case 123:case 91:case 34:case 58:case 44:case 47:return!1}return!0}function j(){let g;do g=M();while(g>=12&&g<=15);return g}return{setPosition:A,getPosition:()=>n,scan:r?j:M,getToken:()=>c,getTokenValue:()=>i,getTokenOffset:()=>s,getTokenLength:()=>n-s,getTokenStartLine:()=>u,getTokenStartCharacter:()=>s-h,getTokenError:()=>k}}function it(e){return e===32||e===9}function ze(e){return e===10||e===13}function _e(e){return e>=48&&e<=57}var _t;(function(e){e[e.lineFeed=10]="lineFeed",e[e.carriageReturn=13]="carriageReturn",e[e.space=32]="space",e[e._0=48]="_0",e[e._1=49]="_1",e[e._2=50]="_2",e[e._3=51]="_3",e[e._4=52]="_4",e[e._5=53]="_5",e[e._6=54]="_6",e[e._7=55]="_7",e[e._8=56]="_8",e[e._9=57]="_9",e[e.a=97]="a",e[e.b=98]="b",e[e.c=99]="c",e[e.d=100]="d",e[e.e=101]="e",e[e.f=102]="f",e[e.g=103]="g",e[e.h=104]="h",e[e.i=105]="i",e[e.j=106]="j",e[e.k=107]="k",e[e.l=108]="l",e[e.m=109]="m",e[e.n=110]="n",e[e.o=111]="o",e[e.p=112]="p",e[e.q=113]="q",e[e.r=114]="r",e[e.s=115]="s",e[e.t=116]="t",e[e.u=117]="u",e[e.v=118]="v",e[e.w=119]="w",e[e.x=120]="x",e[e.y=121]="y",e[e.z=122]="z",e[e.A=65]="A",e[e.B=66]="B",e[e.C=67]="C",e[e.D=68]="D",e[e.E=69]="E",e[e.F=70]="F",e[e.G=71]="G",e[e.H=72]="H",e[e.I=73]="I",e[e.J=74]="J",e[e.K=75]="K",e[e.L=76]="L",e[e.M=77]="M",e[e.N=78]="N",e[e.O=79]="O",e[e.P=80]="P",e[e.Q=81]="Q",e[e.R=82]="R",e[e.S=83]="S",e[e.T=84]="T",e[e.U=85]="U",e[e.V=86]="V",e[e.W=87]="W",e[e.X=88]="X",e[e.Y=89]="Y",e[e.Z=90]="Z",e[e.asterisk=42]="asterisk",e[e.backslash=92]="backslash",e[e.closeBrace=125]="closeBrace",e[e.closeBracket=93]="closeBracket",e[e.colon=58]="colon",e[e.comma=44]="comma",e[e.dot=46]="dot",e[e.doubleQuote=34]="doubleQuote",e[e.minus=45]="minus",e[e.openBrace=123]="openBrace",e[e.openBracket=91]="openBracket",e[e.plus=43]="plus",e[e.slash=47]="slash",e[e.formFeed=12]="formFeed",e[e.tab=9]="tab"})(_t||(_t={}));const ie=new Array(20).fill(0).map((e,r)=>" ".repeat(r)),Oe=200,Ot={" ":{"\n":new Array(Oe).fill(0).map((e,r)=>`
4
4
  `+" ".repeat(r)),"\r":new Array(Oe).fill(0).map((e,r)=>"\r"+" ".repeat(r)),"\r\n":new Array(Oe).fill(0).map((e,r)=>`\r
5
5
  `+" ".repeat(r))}," ":{"\n":new Array(Oe).fill(0).map((e,r)=>`
6
6
  `+" ".repeat(r)),"\r":new Array(Oe).fill(0).map((e,r)=>"\r"+" ".repeat(r)),"\r\n":new Array(Oe).fill(0).map((e,r)=>`\r
7
- `+" ".repeat(r))}},Tn=[`
7
+ `+" ".repeat(r))}},Pn=[`
8
8
  `,"\r",`\r
9
- `];function In(e,r,o){let n,i,s,c,p;if(r){for(c=r.offset,p=c+r.length,s=c;s>0&&!Re(e,s-1);)s--;let S=p;for(;S<e.length&&!Re(e,S);)S++;i=e.substring(s,S),n=Ln(i,o)}else i=e,n=0,s=0,c=0,p=e.length;const u=Mn(o,e),v=Tn.includes(u);let h=0,k=0,$;o.insertSpaces?$=ie[o.tabSize||4]??Te(ie[1],o.tabSize||4):$=" ";const A=$===" "?" ":" ";let I=Nt(i,!1),G=!1;function M(){if(h>1)return Te(u,h)+Te($,n+k);const S=$.length*(n+k);return!v||S>xt[A][u].length?u+Te($,n+k):S<=0?u:xt[A][u][S]}function F(){let S=I.scan();for(h=0;S===15||S===14;)S===14&&o.keepLines?h+=1:S===14&&(h=1),S=I.scan();return G=S===16||I.getTokenError()!==0,S}const j=[];function g(S,y,f){!G&&(!r||y<p&&f>c)&&e.substring(y,f)!==S&&j.push({offset:y,length:f-y,content:S})}let b=F();if(o.keepLines&&h>0&&g(Te(u,h),0,0),b!==17){let S=I.getTokenOffset()+s,y=$.length*n<20&&o.insertSpaces?ie[$.length*n]:Te($,n);g(y,s,S)}for(;b!==17;){let S=I.getTokenOffset()+I.getTokenLength()+s,y=F(),f="",V=!1;for(;h===0&&(y===12||y===13);){let fe=I.getTokenOffset()+s;g(ie[1],S,fe),S=I.getTokenOffset()+I.getTokenLength()+s,V=y===12,f=V?M():"",y=F()}if(y===2)b!==1&&k--,o.keepLines&&h>0||!o.keepLines&&b!==1?f=M():o.keepLines&&(f=ie[1]);else if(y===4)b!==3&&k--,o.keepLines&&h>0||!o.keepLines&&b!==3?f=M():o.keepLines&&(f=ie[1]);else{switch(b){case 3:case 1:k++,o.keepLines&&h>0||!o.keepLines?f=M():f=ie[1];break;case 5:o.keepLines&&h>0||!o.keepLines?f=M():f=ie[1];break;case 12:f=M();break;case 13:h>0?f=M():V||(f=ie[1]);break;case 6:o.keepLines&&h>0?f=M():V||(f=ie[1]);break;case 10:o.keepLines&&h>0?f=M():y===6&&!V&&(f="");break;case 7:case 8:case 9:case 11:case 2:case 4:o.keepLines&&h>0?f=M():(y===12||y===13)&&!V?f=ie[1]:y!==5&&y!==17&&(G=!0);break;case 16:G=!0;break}h>0&&(y===12||y===13)&&(f=M())}y===17&&(o.keepLines&&h>0?f=M():f=o.insertFinalNewline?u:"");const ae=I.getTokenOffset()+s;g(f,S,ae),b=y}return j}function Te(e,r){let o="";for(let n=0;n<r;n++)o+=e;return o}function Ln(e,r){let o=0,n=0;const i=r.tabSize||4;for(;o<e.length;){let s=e.charAt(o);if(s===ie[1])n++;else if(s===" ")n+=i;else break;o++}return Math.floor(n/i)}function Mn(e,r){for(let o=0;o<r.length;o++){const n=r.charAt(o);if(n==="\r")return o+1<r.length&&r.charAt(o+1)===`
9
+ `];function En(e,r,o){let n,i,s,c,p;if(r){for(c=r.offset,p=c+r.length,s=c;s>0&&!Ve(e,s-1);)s--;let S=p;for(;S<e.length&&!Ve(e,S);)S++;i=e.substring(s,S),n=Bn(i,o)}else i=e,n=0,s=0,c=0,p=e.length;const u=Dn(o,e),v=Pn.includes(u);let h=0,k=0,$;o.insertSpaces?$=ie[o.tabSize||4]??Ae(ie[1],o.tabSize||4):$=" ";const A=$===" "?" ":" ";let L=qt(i,!1),G=!1;function M(){if(h>1)return Ae(u,h)+Ae($,n+k);const S=$.length*(n+k);return!v||S>Ot[A][u].length?u+Ae($,n+k):S<=0?u:Ot[A][u][S]}function q(){let S=L.scan();for(h=0;S===15||S===14;)S===14&&o.keepLines?h+=1:S===14&&(h=1),S=L.scan();return G=S===16||L.getTokenError()!==0,S}const j=[];function g(S,y,f){!G&&(!r||y<p&&f>c)&&e.substring(y,f)!==S&&j.push({offset:y,length:f-y,content:S})}let b=q();if(o.keepLines&&h>0&&g(Ae(u,h),0,0),b!==17){let S=L.getTokenOffset()+s,y=$.length*n<20&&o.insertSpaces?ie[$.length*n]:Ae($,n);g(y,s,S)}for(;b!==17;){let S=L.getTokenOffset()+L.getTokenLength()+s,y=q(),f="",J=!1;for(;h===0&&(y===12||y===13);){let ce=L.getTokenOffset()+s;g(ie[1],S,ce),S=L.getTokenOffset()+L.getTokenLength()+s,J=y===12,f=J?M():"",y=q()}if(y===2)b!==1&&k--,o.keepLines&&h>0||!o.keepLines&&b!==1?f=M():o.keepLines&&(f=ie[1]);else if(y===4)b!==3&&k--,o.keepLines&&h>0||!o.keepLines&&b!==3?f=M():o.keepLines&&(f=ie[1]);else{switch(b){case 3:case 1:k++,o.keepLines&&h>0||!o.keepLines?f=M():f=ie[1];break;case 5:o.keepLines&&h>0||!o.keepLines?f=M():f=ie[1];break;case 12:f=M();break;case 13:h>0?f=M():J||(f=ie[1]);break;case 6:o.keepLines&&h>0?f=M():J||(f=ie[1]);break;case 10:o.keepLines&&h>0?f=M():y===6&&!J&&(f="");break;case 7:case 8:case 9:case 11:case 2:case 4:o.keepLines&&h>0?f=M():(y===12||y===13)&&!J?f=ie[1]:y!==5&&y!==17&&(G=!0);break;case 16:G=!0;break}h>0&&(y===12||y===13)&&(f=M())}y===17&&(o.keepLines&&h>0?f=M():f=o.insertFinalNewline?u:"");const ae=L.getTokenOffset()+s;g(f,S,ae),b=y}return j}function Ae(e,r){let o="";for(let n=0;n<r;n++)o+=e;return o}function Bn(e,r){let o=0,n=0;const i=r.tabSize||4;for(;o<e.length;){let s=e.charAt(o);if(s===ie[1])n++;else if(s===" ")n+=i;else break;o++}return Math.floor(n/i)}function Dn(e,r){for(let o=0;o<r.length;o++){const n=r.charAt(o);if(n==="\r")return o+1<r.length&&r.charAt(o+1)===`
10
10
  `?`\r
11
11
  `:"\r";if(n===`
12
12
  `)return`
13
13
  `}return e&&e.eol||`
14
- `}function Re(e,r){return`\r
15
- `.indexOf(e.charAt(r))!==-1}var Ee;(function(e){e.DEFAULT={allowTrailingComma:!1}})(Ee||(Ee={}));function jn(e,r=[],o=Ee.DEFAULT){let n=null,i=[];const s=[];function c(u){Array.isArray(i)?i.push(u):n!==null&&(i[n]=u)}return Ut(e,{onObjectBegin:()=>{const u={};c(u),s.push(i),i=u,n=null},onObjectProperty:u=>{n=u},onObjectEnd:()=>{i=s.pop()},onArrayBegin:()=>{const u=[];c(u),s.push(i),i=u,n=null},onArrayEnd:()=>{i=s.pop()},onLiteralValue:c,onError:(u,v,h)=>{r.push({error:u,offset:v,length:h})}},o),i[0]}function zn(e,r=[],o=Ee.DEFAULT){let n={type:"array",offset:-1,length:-1,children:[],parent:void 0};function i(u){n.type==="property"&&(n.length=u-n.offset,n=n.parent)}function s(u){return n.children.push(u),u}Ut(e,{onObjectBegin:u=>{n=s({type:"object",offset:u,length:-1,parent:n,children:[]})},onObjectProperty:(u,v,h)=>{n=s({type:"property",offset:v,length:-1,parent:n,children:[]}),n.children.push({type:"string",value:u,offset:v,length:h,parent:n})},onObjectEnd:(u,v)=>{i(u+v),n.length=u+v-n.offset,n=n.parent,i(u+v)},onArrayBegin:(u,v)=>{n=s({type:"array",offset:u,length:-1,parent:n,children:[]})},onArrayEnd:(u,v)=>{n.length=u+v-n.offset,n=n.parent,i(u+v)},onLiteralValue:(u,v,h)=>{s({type:Pn(u),offset:v,length:h,parent:n,value:u}),i(v+h)},onSeparator:(u,v,h)=>{n.type==="property"&&(u===":"?n.colonOffset=v:u===","&&i(v))},onError:(u,v,h)=>{r.push({error:u,offset:v,length:h})}},o);const p=n.children[0];return p&&delete p.parent,p}function St(e,r){if(!e)return;let o=e;for(let n of r)if(typeof n=="string"){if(o.type!=="object"||!Array.isArray(o.children))return;let i=!1;for(const s of o.children)if(Array.isArray(s.children)&&s.children[0].value===n&&s.children.length===2){o=s.children[1],i=!0;break}if(!i)return}else{const i=n;if(o.type!=="array"||i<0||!Array.isArray(o.children)||i>=o.children.length)return;o=o.children[i]}return o}function Ut(e,r,o=Ee.DEFAULT){const n=Nt(e,!1),i=[];let s=0;function c(L){return L?()=>s===0&&L(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter()):()=>!0}function p(L){return L?N=>s===0&&L(N,n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter()):()=>!0}function u(L){return L?N=>s===0&&L(N,n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter(),()=>i.slice()):()=>!0}function v(L){return L?()=>{s>0?s++:L(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter(),()=>i.slice())===!1&&(s=1)}:()=>!0}function h(L){return L?()=>{s>0&&s--,s===0&&L(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter())}:()=>!0}const k=v(r.onObjectBegin),$=u(r.onObjectProperty),A=h(r.onObjectEnd),I=v(r.onArrayBegin),G=h(r.onArrayEnd),M=u(r.onLiteralValue),F=p(r.onSeparator),j=c(r.onComment),g=p(r.onError),b=o&&o.disallowComments,S=o&&o.allowTrailingComma;function y(){for(;;){const L=n.scan();switch(n.getTokenError()){case 4:f(14);break;case 5:f(15);break;case 3:f(13);break;case 1:b||f(11);break;case 2:f(12);break;case 6:f(16);break}switch(L){case 12:case 13:b?f(10):j();break;case 16:f(1);break;case 15:case 14:break;default:return L}}}function f(L,N=[],ye=[]){if(g(L),N.length+ye.length>0){let we=n.getToken();for(;we!==17;){if(N.indexOf(we)!==-1){y();break}else if(ye.indexOf(we)!==-1)break;we=y()}}}function V(L){const N=n.getTokenValue();return L?M(N):($(N),i.push(N)),y(),!0}function ae(){switch(n.getToken()){case 11:const L=n.getTokenValue();let N=Number(L);isNaN(N)&&(f(2),N=0),M(N);break;case 7:M(null);break;case 8:M(!0);break;case 9:M(!1);break;default:return!1}return y(),!0}function fe(){return n.getToken()!==10?(f(3,[],[2,5]),!1):(V(!1),n.getToken()===6?(F(":"),y(),Q()||f(4,[],[2,5])):f(5,[],[2,5]),i.pop(),!0)}function $e(){k(),y();let L=!1;for(;n.getToken()!==2&&n.getToken()!==17;){if(n.getToken()===5){if(L||f(4,[],[]),F(","),y(),n.getToken()===2&&S)break}else L&&f(6,[],[]);fe()||f(4,[],[2,5]),L=!0}return A(),n.getToken()!==2?f(7,[2],[]):y(),!0}function be(){I(),y();let L=!0,N=!1;for(;n.getToken()!==4&&n.getToken()!==17;){if(n.getToken()===5){if(N||f(4,[],[]),F(","),y(),n.getToken()===4&&S)break}else N&&f(6,[],[]);L?(i.push(0),L=!1):i[i.length-1]++,Q()||f(4,[],[4,5]),N=!0}return G(),L||i.pop(),n.getToken()!==4?f(8,[4],[]):y(),!0}function Q(){switch(n.getToken()){case 3:return be();case 1:return $e();case 10:return V(!0);default:return ae()}}return y(),n.getToken()===17?o.allowEmptyContent?!0:(f(4,[],[]),!1):Q()?(n.getToken()!==17&&f(9,[],[]),!0):(f(4,[],[]),!1)}function Pn(e){switch(typeof e){case"boolean":return"boolean";case"number":return"number";case"string":return"string";case"object":{if(e){if(Array.isArray(e))return"array"}else return"null";return"object"}default:return"null"}}function En(e,r,o,n){const i=r.slice(),c=zn(e,[]);let p,u;for(;i.length>0&&(u=i.pop(),p=St(c,i),p===void 0&&o!==void 0);)typeof u=="string"?o={[u]:o}:o=[o];if(p)if(p.type==="object"&&typeof u=="string"&&Array.isArray(p.children)){const v=St(p,[u]);if(v!==void 0)if(o===void 0){if(!v.parent)throw new Error("Malformed AST");const h=p.children.indexOf(v.parent);let k,$=v.parent.offset+v.parent.length;if(h>0){let A=p.children[h-1];k=A.offset+A.length}else k=p.offset+1,p.children.length>1&&($=p.children[1].offset);return xe(e,{offset:k,length:$-k,content:""},n)}else return xe(e,{offset:v.offset,length:v.length,content:JSON.stringify(o)},n);else{if(o===void 0)return[];const h=`${JSON.stringify(u)}: ${JSON.stringify(o)}`,k=n.getInsertionIndex?n.getInsertionIndex(p.children.map(A=>A.children[0].value)):p.children.length;let $;if(k>0){let A=p.children[k-1];$={offset:A.offset+A.length,length:0,content:","+h}}else p.children.length===0?$={offset:p.offset+1,length:0,content:h}:$={offset:p.offset+1,length:0,content:h+","};return xe(e,$,n)}}else if(p.type==="array"&&typeof u=="number"&&Array.isArray(p.children)){const v=u;if(v===-1){const h=`${JSON.stringify(o)}`;let k;if(p.children.length===0)k={offset:p.offset+1,length:0,content:h};else{const $=p.children[p.children.length-1];k={offset:$.offset+$.length,length:0,content:","+h}}return xe(e,k,n)}else if(o===void 0&&p.children.length>=0){const h=u,k=p.children[h];let $;if(p.children.length===1)$={offset:p.offset+1,length:p.length-2,content:""};else if(p.children.length-1===h){let A=p.children[h-1],I=A.offset+A.length,G=p.offset+p.length;$={offset:I,length:G-2-I,content:""}}else $={offset:k.offset,length:p.children[h+1].offset-k.offset,content:""};return xe(e,$,n)}else if(o!==void 0){let h;const k=`${JSON.stringify(o)}`;if(!n.isArrayInsertion&&p.children.length>u){const $=p.children[u];h={offset:$.offset,length:$.length,content:k}}else if(p.children.length===0||u===0)h={offset:p.offset+1,length:0,content:p.children.length===0?k:k+","};else{const $=u>p.children.length?p.children.length:u,A=p.children[$-1];h={offset:A.offset+A.length,length:0,content:","+k}}return xe(e,h,n)}else throw new Error(`Can not ${o===void 0?"remove":n.isArrayInsertion?"insert":"modify"} Array index ${v} as length is not sufficient`)}else throw new Error(`Can not add ${typeof u!="number"?"index":"property"} to parent of type ${p.type}`);else{if(o===void 0)throw new Error("Can not delete in empty document");return xe(e,{offset:c?c.offset:0,length:c?c.length:0,content:JSON.stringify(o)},n)}}function xe(e,r,o){if(!o.formattingOptions)return[r];let n=ot(e,r),i=r.offset,s=r.offset+r.content.length;if(r.length===0||r.content.length===0){for(;i>0&&!Re(n,i-1);)i--;for(;s<n.length&&!Re(n,s);)s++}const c=In(n,{offset:i,length:s-i},{...o.formattingOptions,keepLines:!1});for(let u=c.length-1;u>=0;u--){const v=c[u];n=ot(n,v),i=Math.min(i,v.offset),s=Math.max(s,v.offset+v.length),s+=v.content.length-v.length}const p=e.length-(n.length-s)-i;return[{offset:i,length:p,content:n.substring(i,s)}]}function ot(e,r){return e.substring(0,r.offset)+r.content+e.substring(r.offset+r.length)}var $t;(function(e){e[e.None=0]="None",e[e.UnexpectedEndOfComment=1]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=2]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=3]="UnexpectedEndOfNumber",e[e.InvalidUnicode=4]="InvalidUnicode",e[e.InvalidEscapeCharacter=5]="InvalidEscapeCharacter",e[e.InvalidCharacter=6]="InvalidCharacter"})($t||($t={}));var Ct;(function(e){e[e.OpenBraceToken=1]="OpenBraceToken",e[e.CloseBraceToken=2]="CloseBraceToken",e[e.OpenBracketToken=3]="OpenBracketToken",e[e.CloseBracketToken=4]="CloseBracketToken",e[e.CommaToken=5]="CommaToken",e[e.ColonToken=6]="ColonToken",e[e.NullKeyword=7]="NullKeyword",e[e.TrueKeyword=8]="TrueKeyword",e[e.FalseKeyword=9]="FalseKeyword",e[e.StringLiteral=10]="StringLiteral",e[e.NumericLiteral=11]="NumericLiteral",e[e.LineCommentTrivia=12]="LineCommentTrivia",e[e.BlockCommentTrivia=13]="BlockCommentTrivia",e[e.LineBreakTrivia=14]="LineBreakTrivia",e[e.Trivia=15]="Trivia",e[e.Unknown=16]="Unknown",e[e.EOF=17]="EOF"})(Ct||(Ct={}));const Bn=jn;var _t;(function(e){e[e.InvalidSymbol=1]="InvalidSymbol",e[e.InvalidNumberFormat=2]="InvalidNumberFormat",e[e.PropertyNameExpected=3]="PropertyNameExpected",e[e.ValueExpected=4]="ValueExpected",e[e.ColonExpected=5]="ColonExpected",e[e.CommaExpected=6]="CommaExpected",e[e.CloseBraceExpected=7]="CloseBraceExpected",e[e.CloseBracketExpected=8]="CloseBracketExpected",e[e.EndOfFileExpected=9]="EndOfFileExpected",e[e.InvalidCommentToken=10]="InvalidCommentToken",e[e.UnexpectedEndOfComment=11]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=12]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=13]="UnexpectedEndOfNumber",e[e.InvalidUnicode=14]="InvalidUnicode",e[e.InvalidEscapeCharacter=15]="InvalidEscapeCharacter",e[e.InvalidCharacter=16]="InvalidCharacter"})(_t||(_t={}));function Dn(e,r,o,n){return En(e,r,o,n)}function Nn(e,r){let o=r.slice(0).sort((i,s)=>{const c=i.offset-s.offset;return c===0?i.length-s.length:c}),n=e.length;for(let i=o.length-1;i>=0;i--){let s=o[i];if(s.offset+s.length<=n)e=ot(e,s);else throw new Error("Overlapping edit");n=s.offset}return e}const Gt="opencode-plugin-hub",At="opencode-plugin",Un=300*1e3;function Rt(){const e=process.env.XDG_CONFIG_HOME;return e?U.join(e,"opencode"):U.join(Le.homedir(),".config","opencode")}function Gn(){const e=process.env.XDG_CACHE_HOME;return e?U.join(e,"opencode","npm"):U.join(Le.homedir(),".cache","opencode","npm")}async function Se(){const e=Rt(),r=[U.join(e,"opencode.json"),U.join(e,"opencode.jsonc")];let o;for(const n of r){let i;try{i=await H.readFile(n,"utf8")}catch{continue}const c=Bn(i,[],{allowTrailingComma:!0,disallowComments:!1}),p=c&&typeof c=="object"?c:{},u=Array.isArray(p.plugins)?"plugins":Array.isArray(p.plugin)?"plugin":"plugins",v=Array.isArray(p[u])?p[u].filter(k=>typeof k=="string"):[],h={path:n,text:i,key:u,plugins:v};if(h.plugins.length>0)return h;o||(o=h)}return o||{path:U.join(e,"opencode.json"),text:`{}
16
- `,key:"plugins",plugins:[]}}function Ve(e){if(!/^(@[a-z0-9-_.]+\/)?[a-z0-9-_.]+$/i.test(e)||e.includes(".."))return!1;const r=e.split("/").pop()??e;return r.length>0&&!r.startsWith(".")}function Me(e){const r=e.trim();if(r.startsWith("/")||r.startsWith(".")||r.startsWith("~/"))return{name:r.replace(/\/+$/,"").split("/").pop()??r,range:"",kind:"path"};const o=r.startsWith("@"),n=r.indexOf("@",o?1:0);return n>0?{name:r.slice(0,n),range:r.slice(n+1),kind:"package"}:{name:r,range:"",kind:"package"}}function pt(e){const r=e.trim();return r==="~"?Le.homedir():r.startsWith("~/")?U.join(Le.homedir(),r.slice(2)):r}async function Fe(e){try{const r=await H.readFile(U.join(e,"package.json"),"utf8"),o=JSON.parse(r);return typeof o=="object"&&o!==null?o:void 0}catch{return}}async function Rn(e,r){const o=r&&r!=="latest"?r:"latest",n=Array.from(new Set([`${e}@${o}`,`${e}@latest`]));for(const i of n){const s=U.join(Gn(),i);let c;try{c=await H.readdir(s)}catch{continue}for(const p of c.reverse())try{const u=U.join(s,p,"node_modules",e,"package.json"),v=await H.readFile(u,"utf8"),h=JSON.parse(v);if(h.version)return h.version}catch{}}return""}function Fn(e){const r=e.trim().replace(/^[\^~=v]+/,"").replace(/^>\=?|^<\=?/,"");return/^\d+(\.\d+)*([-+][\w.-]+)?$/.test(r)?r:""}function Ot(e){return e.split("-")[0].split(".").map(r=>Number.parseInt(r,10)||0)}function dt(e,r){if(!e)return!1;if(!r)return!0;const o=Ot(e),n=Ot(r);for(let i=0;i<Math.max(o.length,n.length);i+=1){const s=o[i]??0,c=n[i]??0;if(s!==c)return s>c}return!1}const Tt=new Map;async function qn(e,r=!1){const o=Tt.get(e);if(!r&&o&&Date.now()-o.at<Un)return o.value;const n=`https://registry.npmjs.org/${e.replace("/","%2f")}`;let i;try{i=await fetch(n,{signal:AbortSignal.timeout(1e4),headers:{accept:"application/vnd.npm.install-v1+json"}})}catch{return{version:"",ok:!1}}if(i.status===404)return{version:"",ok:!0};if(!i.ok)return{version:"",ok:!1};try{const s=await i.json(),c=Object.keys(s.versions??{});if(c.length===0)return{version:"",ok:!0};const p=s["dist-tags"]?.latest,u={version:p&&c.includes(p)?p:c[c.length-1]??"",ok:!0};return Tt.set(e,{at:Date.now(),value:u}),u}catch{return{version:"",ok:!1}}}async function Ft(e){const r=Me(e);if(r.kind!=="path"){const n=Fn(r.range)||await Rn(r.name,r.range);return{spec:e,name:r.name,kind:r.kind,version:n}}const o=await Fe(pt(e));return{spec:e,name:o?.name&&Ve(o.name)?o.name:r.name,kind:"path",version:o?.version??""}}async function We(e){return Promise.all(e.plugins.map(r=>Ft(r)))}async function pe(){try{const e=await Se(),o=(await We(e)).map(n=>({spec:n.spec,name:n.name,kind:n.kind,version:n.version,removable:n.name!==Gt}));return{configPath:e.path,configKey:e.key,plugins:o,error:""}}catch(e){return{configPath:U.join(Rt(),"opencode.json"),configKey:"plugins",plugins:[],error:le(e)}}}async function Hn(){try{const e=await Se(),r=await We(e);return{items:await Promise.all(r.map(async n=>{const i=Ve(n.name),s=i?await qn(n.name):{version:"",ok:!1};return{spec:n.spec,name:n.name,kind:n.kind,current:n.version,latest:s.version,hasUpdate:s.ok&&dt(s.version,n.version),managed:n.kind!=="path",error:i?s.ok?"":"无法连接 npm registry,本次未检查":"不是 npm 包名,无法查询版本"}})),error:""}}catch(e){return{items:[],error:le(e)}}}async function it(e,r,o){const n=e.text.trim().length>0?e.text:`{}
17
- `,s=Dn(n,r,o,{formattingOptions:{insertSpaces:!0,tabSize:2,eol:`
18
- `}});return await H.writeFile(e.path,Nn(n,s),"utf8"),pe()}async function Vn(e,r){for(const[o,n]of e.plugins.entries())if(Me(n).name===r)return o;for(const[o,n]of e.plugins.entries()){if(Me(n).kind!=="path")continue;if((await Fe(pt(n)))?.name===r)return o}return-1}async function Wn(e,r){const o=`https://registry.npmjs.org/${e.replace("/","%2f")}`;try{const n=await fetch(o,{signal:AbortSignal.timeout(15e3),headers:{accept:"application/vnd.npm.install-v1+json"}});if(!n.ok)return;const i=await n.json(),s=r||i["dist-tags"]?.latest||"",p=(s?i.versions?.[s]:void 0)?.dist?.tarball;return p?{tarball:p,version:s}:void 0}catch{return}}async function ut(e,r){const o=await H.readdir(e,{withFileTypes:!0});await H.mkdir(r,{recursive:!0});for(const n of o){const i=U.join(e,n.name),s=U.join(r,n.name);n.isDirectory()?await ut(i,s):n.isFile()&&await H.copyFile(i,s)}}async function Jn(e,r){const o=new Set(await H.readdir(e));for(const n of await H.readdir(r,{withFileTypes:!0}))o.has(n.name)||await H.rm(U.join(r,n.name),{recursive:!0,force:!0});await ut(e,r)}function It(e,r,o){return new Promise(n=>{const i=Be.spawn(e,r,{cwd:o,stdio:["ignore","pipe","pipe"]});let s="";i.stdout?.on("data",c=>s+=String(c)),i.stderr?.on("data",c=>s+=String(c)),i.on("error",c=>n({code:-1,output:le(c)})),i.on("close",c=>n({code:c??-1,output:s}))})}async function Qn(e,r,o){const n=await Wn(r,o);if(!n)return{ok:!1,message:"在 npm 上找不到这个版本"};let i="";try{i=await H.mkdtemp(U.join(Le.tmpdir(),"plugin-hub-"));const s=U.join(i,"package.tgz"),c=await fetch(n.tarball,{signal:AbortSignal.timeout(6e4)});if(!c.ok)return{ok:!1,message:`下载失败:${c.status}`};await H.writeFile(s,Buffer.from(await c.arrayBuffer()));const p=U.join(i,"unpacked");await H.mkdir(p,{recursive:!0});const u=await It("tar",["-xzf",s,"-C",p],i);if(u.code!==0)return{ok:!1,message:`解包失败:${u.output.slice(0,160)}`};const v=U.join(p,"package");if(!await Fe(v))return{ok:!1,message:"下载的包里没有 package.json"};const k=new Date().toISOString().replace(/[:.]/g,"-").slice(0,19),$=`${e}.backup-${k}`;await H.cp(e,$,{recursive:!0});try{await ut(v,e);const A=U.join(e,"scripts","repatch.mjs"),I=await H.stat(A).then(()=>!0,()=>!1);let G="";if(I){const F=await It(process.execPath,[A,"--from",v],e);if(F.code!==0)throw new Error(`重打补丁失败:${F.output.slice(0,160)}`);G=",已自动重打补丁"}return{ok:!0,message:`已更新到 ${(await Fe(e))?.version??n.version}${G};旧版本备份在 ${U.basename($)}`}}catch(A){return await Jn($,e).catch(()=>{}),{ok:!1,message:`更新中断,已从备份还原:${le(A)}`}}}catch(s){return{ok:!1,message:le(s)}}finally{i&&await H.rm(i,{recursive:!0,force:!0}).catch(()=>{})}}async function Xn(e,r){try{const o=await Se(),n=Me(e);if(n.kind!=="package"||!Ve(n.name))return{ok:!1,message:"只能按 npm 包名安装",state:await pe()};const i=n.name,s=r.trim()?`${i}@${r.trim()}`:i,c=await Vn(o,i);if(c>=0&&Me(o.plugins[c]).kind==="path"){const u=pt(o.plugins[c]),v=await Qn(u,i,r.trim());return{ok:v.ok,message:v.message,state:await pe()}}const p=c>=0?await it(o,[o.key,c],s):await it(o,[o.key,o.plugins.length],s);return{ok:!0,message:c>=0?`已更新 ${s}`:`已添加 ${s}`,state:p}}catch(o){return{ok:!1,message:le(o),state:await pe()}}}async function Yn(e){try{const r=await Se(),{name:o}=Me(e),n=r.plugins.findIndex(c=>c.trim()===e.trim());if(n<0)return{ok:!1,message:"配置中没有这一项",state:await pe()};const i=await Ft(r.plugins[n]);if(i.name===Gt)return{ok:!1,message:"不能移除正在运行的插件中心自身",state:await pe()};const s=await it(r,[r.key,n],void 0);return{ok:!0,message:`已移除 ${i.name||o}`,state:s}}catch(r){return{ok:!1,message:le(r),state:await pe()}}}const Zn=new Set(["opencode","opencode-plugin","opencode-plugins","plugin","plugins","ai"]);function qt(e){const r=new Set,o=[];for(const n of e??[]){const i=n.trim();if(!i)continue;const s=i.toLowerCase();if(!(Zn.has(s)||r.has(s))&&(r.add(s),o.push(i),o.length>=8))break}return o}function gt(e){const r=(e??"").trim();return r?r.startsWith("//")?`https:${r}`:/^https?:\/\//i.test(r)?r:"":""}function Ht(e){const r=typeof e=="string"?e:e?.url??"",o=typeof e=="object"&&e?e.directory??"":"",n=r.trim().replace(/^git\+/i,"").replace(/^github:/i,"https://github.com/").replace(/^git:\/\//i,"https://").replace(/^ssh:\/\/git@/i,"https://").replace(/^git@([^:]+):/i,"https://$1/").replace(/#.*$/,"").replace(/\.git\/?$/i,"").replace(/\/+$/,"");return/^https?:\/\//i.test(n)?{url:n,directory:o}:{url:"",directory:""}}function Vt(e){return typeof e=="string"?e:e?.type??""}function Kn(e){const r=typeof e=="string"?e:e?.url??"";return gt(r)}const er=600*1e3,tt=3e4,tr="https://api.npmjs.org",Wt="https://registry.npmjs.org",Lt=new Map;function nr(e){if(e.length<=tt)return{text:e,truncated:!1};const r=e.slice(0,tt),o=r.lastIndexOf(`
19
- `);return{text:`${o>tt*.75?r.slice(0,o):r}
14
+ `}function Ve(e,r){return`\r
15
+ `.indexOf(e.charAt(r))!==-1}var Be;(function(e){e.DEFAULT={allowTrailingComma:!1}})(Be||(Be={}));function Nn(e,r=[],o=Be.DEFAULT){let n=null,i=[];const s=[];function c(u){Array.isArray(i)?i.push(u):n!==null&&(i[n]=u)}return Ht(e,{onObjectBegin:()=>{const u={};c(u),s.push(i),i=u,n=null},onObjectProperty:u=>{n=u},onObjectEnd:()=>{i=s.pop()},onArrayBegin:()=>{const u=[];c(u),s.push(i),i=u,n=null},onArrayEnd:()=>{i=s.pop()},onLiteralValue:c,onError:(u,v,h)=>{r.push({error:u,offset:v,length:h})}},o),i[0]}function Un(e,r=[],o=Be.DEFAULT){let n={type:"array",offset:-1,length:-1,children:[],parent:void 0};function i(u){n.type==="property"&&(n.length=u-n.offset,n=n.parent)}function s(u){return n.children.push(u),u}Ht(e,{onObjectBegin:u=>{n=s({type:"object",offset:u,length:-1,parent:n,children:[]})},onObjectProperty:(u,v,h)=>{n=s({type:"property",offset:v,length:-1,parent:n,children:[]}),n.children.push({type:"string",value:u,offset:v,length:h,parent:n})},onObjectEnd:(u,v)=>{i(u+v),n.length=u+v-n.offset,n=n.parent,i(u+v)},onArrayBegin:(u,v)=>{n=s({type:"array",offset:u,length:-1,parent:n,children:[]})},onArrayEnd:(u,v)=>{n.length=u+v-n.offset,n=n.parent,i(u+v)},onLiteralValue:(u,v,h)=>{s({type:Gn(u),offset:v,length:h,parent:n,value:u}),i(v+h)},onSeparator:(u,v,h)=>{n.type==="property"&&(u===":"?n.colonOffset=v:u===","&&i(v))},onError:(u,v,h)=>{r.push({error:u,offset:v,length:h})}},o);const p=n.children[0];return p&&delete p.parent,p}function At(e,r){if(!e)return;let o=e;for(let n of r)if(typeof n=="string"){if(o.type!=="object"||!Array.isArray(o.children))return;let i=!1;for(const s of o.children)if(Array.isArray(s.children)&&s.children[0].value===n&&s.children.length===2){o=s.children[1],i=!0;break}if(!i)return}else{const i=n;if(o.type!=="array"||i<0||!Array.isArray(o.children)||i>=o.children.length)return;o=o.children[i]}return o}function Ht(e,r,o=Be.DEFAULT){const n=qt(e,!1),i=[];let s=0;function c(O){return O?()=>s===0&&O(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter()):()=>!0}function p(O){return O?D=>s===0&&O(D,n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter()):()=>!0}function u(O){return O?D=>s===0&&O(D,n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter(),()=>i.slice()):()=>!0}function v(O){return O?()=>{s>0?s++:O(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter(),()=>i.slice())===!1&&(s=1)}:()=>!0}function h(O){return O?()=>{s>0&&s--,s===0&&O(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter())}:()=>!0}const k=v(r.onObjectBegin),$=u(r.onObjectProperty),A=h(r.onObjectEnd),L=v(r.onArrayBegin),G=h(r.onArrayEnd),M=u(r.onLiteralValue),q=p(r.onSeparator),j=c(r.onComment),g=p(r.onError),b=o&&o.disallowComments,S=o&&o.allowTrailingComma;function y(){for(;;){const O=n.scan();switch(n.getTokenError()){case 4:f(14);break;case 5:f(15);break;case 3:f(13);break;case 1:b||f(11);break;case 2:f(12);break;case 6:f(16);break}switch(O){case 12:case 13:b?f(10):j();break;case 16:f(1);break;case 15:case 14:break;default:return O}}}function f(O,D=[],Ne=[]){if(g(O),D.length+Ne.length>0){let ye=n.getToken();for(;ye!==17;){if(D.indexOf(ye)!==-1){y();break}else if(Ne.indexOf(ye)!==-1)break;ye=y()}}}function J(O){const D=n.getTokenValue();return O?M(D):($(D),i.push(D)),y(),!0}function ae(){switch(n.getToken()){case 11:const O=n.getTokenValue();let D=Number(O);isNaN(D)&&(f(2),D=0),M(D);break;case 7:M(null);break;case 8:M(!0);break;case 9:M(!1);break;default:return!1}return y(),!0}function ce(){return n.getToken()!==10?(f(3,[],[2,5]),!1):(J(!1),n.getToken()===6?(q(":"),y(),X()||f(4,[],[2,5])):f(5,[],[2,5]),i.pop(),!0)}function be(){k(),y();let O=!1;for(;n.getToken()!==2&&n.getToken()!==17;){if(n.getToken()===5){if(O||f(4,[],[]),q(","),y(),n.getToken()===2&&S)break}else O&&f(6,[],[]);ce()||f(4,[],[2,5]),O=!0}return A(),n.getToken()!==2?f(7,[2],[]):y(),!0}function Se(){L(),y();let O=!0,D=!1;for(;n.getToken()!==4&&n.getToken()!==17;){if(n.getToken()===5){if(D||f(4,[],[]),q(","),y(),n.getToken()===4&&S)break}else D&&f(6,[],[]);O?(i.push(0),O=!1):i[i.length-1]++,X()||f(4,[],[4,5]),D=!0}return G(),O||i.pop(),n.getToken()!==4?f(8,[4],[]):y(),!0}function X(){switch(n.getToken()){case 3:return Se();case 1:return be();case 10:return J(!0);default:return ae()}}return y(),n.getToken()===17?o.allowEmptyContent?!0:(f(4,[],[]),!1):X()?(n.getToken()!==17&&f(9,[],[]),!0):(f(4,[],[]),!1)}function Gn(e){switch(typeof e){case"boolean":return"boolean";case"number":return"number";case"string":return"string";case"object":{if(e){if(Array.isArray(e))return"array"}else return"null";return"object"}default:return"null"}}function Rn(e,r,o,n){const i=r.slice(),c=Un(e,[]);let p,u;for(;i.length>0&&(u=i.pop(),p=At(c,i),p===void 0&&o!==void 0);)typeof u=="string"?o={[u]:o}:o=[o];if(p)if(p.type==="object"&&typeof u=="string"&&Array.isArray(p.children)){const v=At(p,[u]);if(v!==void 0)if(o===void 0){if(!v.parent)throw new Error("Malformed AST");const h=p.children.indexOf(v.parent);let k,$=v.parent.offset+v.parent.length;if(h>0){let A=p.children[h-1];k=A.offset+A.length}else k=p.offset+1,p.children.length>1&&($=p.children[1].offset);return ke(e,{offset:k,length:$-k,content:""},n)}else return ke(e,{offset:v.offset,length:v.length,content:JSON.stringify(o)},n);else{if(o===void 0)return[];const h=`${JSON.stringify(u)}: ${JSON.stringify(o)}`,k=n.getInsertionIndex?n.getInsertionIndex(p.children.map(A=>A.children[0].value)):p.children.length;let $;if(k>0){let A=p.children[k-1];$={offset:A.offset+A.length,length:0,content:","+h}}else p.children.length===0?$={offset:p.offset+1,length:0,content:h}:$={offset:p.offset+1,length:0,content:h+","};return ke(e,$,n)}}else if(p.type==="array"&&typeof u=="number"&&Array.isArray(p.children)){const v=u;if(v===-1){const h=`${JSON.stringify(o)}`;let k;if(p.children.length===0)k={offset:p.offset+1,length:0,content:h};else{const $=p.children[p.children.length-1];k={offset:$.offset+$.length,length:0,content:","+h}}return ke(e,k,n)}else if(o===void 0&&p.children.length>=0){const h=u,k=p.children[h];let $;if(p.children.length===1)$={offset:p.offset+1,length:p.length-2,content:""};else if(p.children.length-1===h){let A=p.children[h-1],L=A.offset+A.length,G=p.offset+p.length;$={offset:L,length:G-2-L,content:""}}else $={offset:k.offset,length:p.children[h+1].offset-k.offset,content:""};return ke(e,$,n)}else if(o!==void 0){let h;const k=`${JSON.stringify(o)}`;if(!n.isArrayInsertion&&p.children.length>u){const $=p.children[u];h={offset:$.offset,length:$.length,content:k}}else if(p.children.length===0||u===0)h={offset:p.offset+1,length:0,content:p.children.length===0?k:k+","};else{const $=u>p.children.length?p.children.length:u,A=p.children[$-1];h={offset:A.offset+A.length,length:0,content:","+k}}return ke(e,h,n)}else throw new Error(`Can not ${o===void 0?"remove":n.isArrayInsertion?"insert":"modify"} Array index ${v} as length is not sufficient`)}else throw new Error(`Can not add ${typeof u!="number"?"index":"property"} to parent of type ${p.type}`);else{if(o===void 0)throw new Error("Can not delete in empty document");return ke(e,{offset:c?c.offset:0,length:c?c.length:0,content:JSON.stringify(o)},n)}}function ke(e,r,o){if(!o.formattingOptions)return[r];let n=ct(e,r),i=r.offset,s=r.offset+r.content.length;if(r.length===0||r.content.length===0){for(;i>0&&!Ve(n,i-1);)i--;for(;s<n.length&&!Ve(n,s);)s++}const c=En(n,{offset:i,length:s-i},{...o.formattingOptions,keepLines:!1});for(let u=c.length-1;u>=0;u--){const v=c[u];n=ct(n,v),i=Math.min(i,v.offset),s=Math.max(s,v.offset+v.length),s+=v.content.length-v.length}const p=e.length-(n.length-s)-i;return[{offset:i,length:p,content:n.substring(i,s)}]}function ct(e,r){return e.substring(0,r.offset)+r.content+e.substring(r.offset+r.length)}var Tt;(function(e){e[e.None=0]="None",e[e.UnexpectedEndOfComment=1]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=2]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=3]="UnexpectedEndOfNumber",e[e.InvalidUnicode=4]="InvalidUnicode",e[e.InvalidEscapeCharacter=5]="InvalidEscapeCharacter",e[e.InvalidCharacter=6]="InvalidCharacter"})(Tt||(Tt={}));var It;(function(e){e[e.OpenBraceToken=1]="OpenBraceToken",e[e.CloseBraceToken=2]="CloseBraceToken",e[e.OpenBracketToken=3]="OpenBracketToken",e[e.CloseBracketToken=4]="CloseBracketToken",e[e.CommaToken=5]="CommaToken",e[e.ColonToken=6]="ColonToken",e[e.NullKeyword=7]="NullKeyword",e[e.TrueKeyword=8]="TrueKeyword",e[e.FalseKeyword=9]="FalseKeyword",e[e.StringLiteral=10]="StringLiteral",e[e.NumericLiteral=11]="NumericLiteral",e[e.LineCommentTrivia=12]="LineCommentTrivia",e[e.BlockCommentTrivia=13]="BlockCommentTrivia",e[e.LineBreakTrivia=14]="LineBreakTrivia",e[e.Trivia=15]="Trivia",e[e.Unknown=16]="Unknown",e[e.EOF=17]="EOF"})(It||(It={}));const Fn=Nn;var Lt;(function(e){e[e.InvalidSymbol=1]="InvalidSymbol",e[e.InvalidNumberFormat=2]="InvalidNumberFormat",e[e.PropertyNameExpected=3]="PropertyNameExpected",e[e.ValueExpected=4]="ValueExpected",e[e.ColonExpected=5]="ColonExpected",e[e.CommaExpected=6]="CommaExpected",e[e.CloseBraceExpected=7]="CloseBraceExpected",e[e.CloseBracketExpected=8]="CloseBracketExpected",e[e.EndOfFileExpected=9]="EndOfFileExpected",e[e.InvalidCommentToken=10]="InvalidCommentToken",e[e.UnexpectedEndOfComment=11]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=12]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=13]="UnexpectedEndOfNumber",e[e.InvalidUnicode=14]="InvalidUnicode",e[e.InvalidEscapeCharacter=15]="InvalidEscapeCharacter",e[e.InvalidCharacter=16]="InvalidCharacter"})(Lt||(Lt={}));function qn(e,r,o,n){return Rn(e,r,o,n)}function Hn(e,r){let o=r.slice(0).sort((i,s)=>{const c=i.offset-s.offset;return c===0?i.length-s.length:c}),n=e.length;for(let i=o.length-1;i>=0;i--){let s=o[i];if(s.offset+s.length<=n)e=ct(e,s);else throw new Error("Overlapping edit");n=s.offset}return e}const Vt="opencode-plugin-hub",Mt="opencode-plugin",Vn=300*1e3;function Wt(){const e=process.env.XDG_CONFIG_HOME;return e?U.join(e,"opencode"):U.join(Ie.homedir(),".config","opencode")}function Wn(){const e=process.env.XDG_CACHE_HOME;return e?U.join(e,"opencode","npm"):U.join(Ie.homedir(),".cache","opencode","npm")}async function xe(){const e=Wt(),r=[U.join(e,"opencode.json"),U.join(e,"opencode.jsonc")];let o;for(const n of r){let i;try{i=await V.readFile(n,"utf8")}catch{continue}const c=Fn(i,[],{allowTrailingComma:!0,disallowComments:!1}),p=c&&typeof c=="object"?c:{},u=Array.isArray(p.plugins)?"plugins":Array.isArray(p.plugin)?"plugin":"plugins",v=Array.isArray(p[u])?p[u].filter(k=>typeof k=="string"):[],h={path:n,text:i,key:u,plugins:v};if(h.plugins.length>0)return h;o||(o=h)}return o||{path:U.join(e,"opencode.json"),text:`{}
16
+ `,key:"plugins",plugins:[]}}function Xe(e){if(!/^(@[a-z0-9-_.]+\/)?[a-z0-9-_.]+$/i.test(e)||e.includes(".."))return!1;const r=e.split("/").pop()??e;return r.length>0&&!r.startsWith(".")}function Le(e){const r=e.trim();if(r.startsWith("/")||r.startsWith(".")||r.startsWith("~/"))return{name:r.replace(/\/+$/,"").split("/").pop()??r,range:"",kind:"path"};const o=r.startsWith("@"),n=r.indexOf("@",o?1:0);return n>0?{name:r.slice(0,n),range:r.slice(n+1),kind:"package"}:{name:r,range:"",kind:"package"}}function mt(e){const r=e.trim();return r==="~"?Ie.homedir():r.startsWith("~/")?U.join(Ie.homedir(),r.slice(2)):r}async function We(e){try{const r=await V.readFile(U.join(e,"package.json"),"utf8"),o=JSON.parse(r);return typeof o=="object"&&o!==null?o:void 0}catch{return}}async function Jn(e,r){const o=r&&r!=="latest"?r:"latest",n=Array.from(new Set([`${e}@${o}`,`${e}@latest`]));for(const i of n){const s=U.join(Wn(),i);let c;try{c=await V.readdir(s)}catch{continue}for(const p of c.reverse())try{const u=U.join(s,p,"node_modules",e,"package.json"),v=await V.readFile(u,"utf8"),h=JSON.parse(v);if(h.version)return h.version}catch{}}return""}function Qn(e){const r=e.trim().replace(/^[\^~=v]+/,"").replace(/^>\=?|^<\=?/,"");return/^\d+(\.\d+)*([-+][\w.-]+)?$/.test(r)?r:""}function jt(e){return e.split("-")[0].split(".").map(r=>Number.parseInt(r,10)||0)}function ft(e,r){if(!e)return!1;if(!r)return!0;const o=jt(e),n=jt(r);for(let i=0;i<Math.max(o.length,n.length);i+=1){const s=o[i]??0,c=n[i]??0;if(s!==c)return s>c}return!1}const zt=new Map;async function Xn(e,r=!1){const o=zt.get(e);if(!r&&o&&Date.now()-o.at<Vn)return o.value;const n=`https://registry.npmjs.org/${e.replace("/","%2f")}`;let i;try{i=await fetch(n,{signal:AbortSignal.timeout(1e4),headers:{accept:"application/vnd.npm.install-v1+json"}})}catch{return{version:"",ok:!1}}if(i.status===404)return{version:"",ok:!0};if(!i.ok)return{version:"",ok:!1};try{const s=await i.json(),c=Object.keys(s.versions??{});if(c.length===0)return{version:"",ok:!0};const p=s["dist-tags"]?.latest,u={version:p&&c.includes(p)?p:c[c.length-1]??"",ok:!0};return zt.set(e,{at:Date.now(),value:u}),u}catch{return{version:"",ok:!1}}}async function Jt(e){const r=Le(e);if(r.kind!=="path"){const n=Qn(r.range)||await Jn(r.name,r.range);return{spec:e,name:r.name,kind:r.kind,version:n}}const o=await We(mt(e));return{spec:e,name:o?.name&&Xe(o.name)?o.name:r.name,kind:"path",version:o?.version??""}}async function Ye(e){return Promise.all(e.plugins.map(r=>Jt(r)))}async function de(){try{const e=await xe(),o=(await Ye(e)).map(n=>({spec:n.spec,name:n.name,kind:n.kind,version:n.version,removable:n.name!==Vt}));return{configPath:e.path,configKey:e.key,plugins:o,error:""}}catch(e){return{configPath:U.join(Wt(),"opencode.json"),configKey:"plugins",plugins:[],error:le(e)}}}async function Yn(){try{const e=await xe(),r=await Ye(e);return{items:await Promise.all(r.map(async n=>{const i=Xe(n.name),s=i?await Xn(n.name):{version:"",ok:!1};return{spec:n.spec,name:n.name,kind:n.kind,current:n.version,latest:s.version,hasUpdate:s.ok&&ft(s.version,n.version),managed:n.kind!=="path",error:i?s.ok?"":"无法连接 npm registry,本次未检查":"不是 npm 包名,无法查询版本"}})),error:""}}catch(e){return{items:[],error:le(e)}}}async function pt(e,r,o){const n=e.text.trim().length>0?e.text:`{}
17
+ `,s=qn(n,r,o,{formattingOptions:{insertSpaces:!0,tabSize:2,eol:`
18
+ `}});return await V.writeFile(e.path,Hn(n,s),"utf8"),de()}async function Zn(e,r){for(const[o,n]of e.plugins.entries())if(Le(n).name===r)return o;for(const[o,n]of e.plugins.entries()){if(Le(n).kind!=="path")continue;if((await We(mt(n)))?.name===r)return o}return-1}async function Kn(e,r){const o=`https://registry.npmjs.org/${e.replace("/","%2f")}`;try{const n=await fetch(o,{signal:AbortSignal.timeout(15e3),headers:{accept:"application/vnd.npm.install-v1+json"}});if(!n.ok)return;const i=await n.json(),s=r||i["dist-tags"]?.latest||"",p=(s?i.versions?.[s]:void 0)?.dist?.tarball;return p?{tarball:p,version:s}:void 0}catch{return}}async function vt(e,r){const o=await V.readdir(e,{withFileTypes:!0});await V.mkdir(r,{recursive:!0});for(const n of o){const i=U.join(e,n.name),s=U.join(r,n.name);n.isDirectory()?await vt(i,s):n.isFile()&&await V.copyFile(i,s)}}async function er(e,r){const o=new Set(await V.readdir(e));for(const n of await V.readdir(r,{withFileTypes:!0}))o.has(n.name)||await V.rm(U.join(r,n.name),{recursive:!0,force:!0});await vt(e,r)}function Pt(e,r,o){return new Promise(n=>{const i=De.spawn(e,r,{cwd:o,stdio:["ignore","pipe","pipe"]});let s="";i.stdout?.on("data",c=>s+=String(c)),i.stderr?.on("data",c=>s+=String(c)),i.on("error",c=>n({code:-1,output:le(c)})),i.on("close",c=>n({code:c??-1,output:s}))})}async function tr(e,r,o){const n=await Kn(r,o);if(!n)return{ok:!1,message:"在 npm 上找不到这个版本"};let i="";try{i=await V.mkdtemp(U.join(Ie.tmpdir(),"plugin-hub-"));const s=U.join(i,"package.tgz"),c=await fetch(n.tarball,{signal:AbortSignal.timeout(6e4)});if(!c.ok)return{ok:!1,message:`下载失败:${c.status}`};await V.writeFile(s,Buffer.from(await c.arrayBuffer()));const p=U.join(i,"unpacked");await V.mkdir(p,{recursive:!0});const u=await Pt("tar",["-xzf",s,"-C",p],i);if(u.code!==0)return{ok:!1,message:`解包失败:${u.output.slice(0,160)}`};const v=U.join(p,"package");if(!await We(v))return{ok:!1,message:"下载的包里没有 package.json"};const k=new Date().toISOString().replace(/[:.]/g,"-").slice(0,19),$=`${e}.backup-${k}`;await V.cp(e,$,{recursive:!0});try{await vt(v,e);const A=U.join(e,"scripts","repatch.mjs"),L=await V.stat(A).then(()=>!0,()=>!1);let G="";if(L){const q=await Pt(process.execPath,[A,"--from",v],e);if(q.code!==0)throw new Error(`重打补丁失败:${q.output.slice(0,160)}`);G=",已自动重打补丁"}return{ok:!0,message:`已更新到 ${(await We(e))?.version??n.version}${G};旧版本备份在 ${U.basename($)}`}}catch(A){return await er($,e).catch(()=>{}),{ok:!1,message:`更新中断,已从备份还原:${le(A)}`}}}catch(s){return{ok:!1,message:le(s)}}finally{i&&await V.rm(i,{recursive:!0,force:!0}).catch(()=>{})}}async function nr(e,r){try{const o=await xe(),n=Le(e);if(n.kind!=="package"||!Xe(n.name))return{ok:!1,message:"只能按 npm 包名安装",state:await de()};const i=n.name,s=r.trim()?`${i}@${r.trim()}`:i,c=await Zn(o,i);if(c>=0&&Le(o.plugins[c]).kind==="path"){const u=mt(o.plugins[c]),v=await tr(u,i,r.trim());return{ok:v.ok,message:v.message,state:await de()}}const p=c>=0?await pt(o,[o.key,c],s):await pt(o,[o.key,o.plugins.length],s);return{ok:!0,message:c>=0?`已更新 ${s}`:`已添加 ${s}`,state:p}}catch(o){return{ok:!1,message:le(o),state:await de()}}}async function rr(e){try{const r=await xe(),{name:o}=Le(e),n=r.plugins.findIndex(c=>c.trim()===e.trim());if(n<0)return{ok:!1,message:"配置中没有这一项",state:await de()};const i=await Jt(r.plugins[n]);if(i.name===Vt)return{ok:!1,message:"不能移除正在运行的插件中心自身",state:await de()};const s=await pt(r,[r.key,n],void 0);return{ok:!0,message:`已移除 ${i.name||o}`,state:s}}catch(r){return{ok:!1,message:le(r),state:await de()}}}const or=new Set(["opencode","opencode-plugin","opencode-plugins","plugin","plugins","ai"]);function Qt(e){const r=new Set,o=[];for(const n of e??[]){const i=n.trim();if(!i)continue;const s=i.toLowerCase();if(!(or.has(s)||r.has(s))&&(r.add(s),o.push(i),o.length>=8))break}return o}function bt(e){const r=(e??"").trim();return r?r.startsWith("//")?`https:${r}`:/^https?:\/\//i.test(r)?r:"":""}function Xt(e){const r=typeof e=="string"?e:e?.url??"",o=typeof e=="object"&&e?e.directory??"":"",n=r.trim().replace(/^git\+/i,"").replace(/^github:/i,"https://github.com/").replace(/^git:\/\//i,"https://").replace(/^ssh:\/\/git@/i,"https://").replace(/^git@([^:]+):/i,"https://$1/").replace(/#.*$/,"").replace(/\.git\/?$/i,"").replace(/\/+$/,"");return/^https?:\/\//i.test(n)?{url:n,directory:o}:{url:"",directory:""}}function Yt(e){return typeof e=="string"?e:e?.type??""}function ir(e){const r=typeof e=="string"?e:e?.url??"";return bt(r)}const ar=600*1e3,at=3e4,sr="https://api.npmjs.org",Zt="https://registry.npmjs.org",Et=new Map;function lr(e){if(e.length<=at)return{text:e,truncated:!1};const r=e.slice(0,at),o=r.lastIndexOf(`
19
+ `);return{text:`${o>at*.75?r.slice(0,o):r}
20
20
 
21
- …`,truncated:!0}}async function Mt(e,r){try{const o=await fetch(`${tr}/downloads/point/${r}/${encodeURIComponent(e)}`,{signal:AbortSignal.timeout(8e3),headers:{accept:"application/json"}});if(!o.ok)return 0;const n=await o.json();return Number(n.downloads??0)||0}catch{return 0}}async function rr(e){try{const r=await fetch(`${Wt}/${encodeURIComponent(e)}`,{signal:AbortSignal.timeout(2e4),headers:{accept:"application/json"}});if(r.status===404)return{error:"npm 上找不到这个包"};if(!r.ok)return{error:`npm registry 返回 ${r.status}`};if(Number(r.headers.get("content-length")??0)>12*1024*1024)return jt(e,"包元数据过大,只读取了最新版本");let n;try{n=await r.json()}catch{return jt(e,"npm 返回的数据无法解析")}return!n||typeof n!="object"?{error:"npm 返回的数据不完整"}:{body:n,error:""}}catch(r){return{error:le(r)}}}async function jt(e,r){try{const o=await fetch(`${Wt}/${encodeURIComponent(e)}/latest`,{signal:AbortSignal.timeout(1e4),headers:{accept:"application/json"}});if(!o.ok)return{error:r||`npm registry 返回 ${o.status}`};const n=await o.json();return n?.version?{body:{...n,readme:typeof n.readme=="string"?n.readme:"","dist-tags":{latest:n.version},versions:{[n.version]:n},time:n.time},error:""}:{error:r||"npm 返回的数据不完整"}}catch(o){return{error:r||le(o)}}}async function or(e){const r=await rr(e);if(!r.body)return{error:r.error};const o=r.body,n=o.versions??{},i=Object.keys(n);if(i.length===0)return{error:"npm 上只有占位条目,还没有发布过版本"};const s=o["dist-tags"]?.latest??"",c=s&&n[s]?s:i[i.length-1]??o.version??"",p=c?n[c]??{}:o,u=Ht(p.repository??o.repository),v=nr(typeof o.readme=="string"?o.readme:""),[h,k]=await Promise.all([Mt(e,"last-week"),Mt(e,"last-month")]),$=(o.maintainers??[]).map(I=>I.name??I.username??"").filter(I=>I!==""),A=Object.entries(p.dependencies??{}).map(([I,G])=>G?`${I}@${G}`:I);return{name:e,version:c,description:p.description??o.description??"",homepage:gt(p.homepage??o.homepage)||u.url,repo:u.url,repoDir:u.directory,bugs:Kn(p.bugs??o.bugs),license:Vt(p.license??o.license),keywords:qt(p.keywords??o.keywords),maintainers:$,weekly:h,monthly:k,published:o.time?.[c]??"",created:o.time?.created??"",versions:Object.keys(n).length,unpacked:p.dist?.unpackedSize??0,files:p.dist?.fileCount??0,dependencies:A,deprecated:typeof p.deprecated=="string"?p.deprecated:"",readme:v.text,readmeTruncated:v.truncated}}async function ir(e){const r=Lt.get(e);if(r&&Date.now()-r.at<er)return r.value;const o=await or(e);return"error"in o||Lt.set(e,{at:Date.now(),value:o}),o}async function ar(e){const r=()=>({name:e,version:"",description:"",homepage:"",repo:"",repoDir:"",npm:`https://www.npmjs.com/package/${e}`,bugs:"",license:"",keywords:[],maintainers:[],weekly:0,monthly:0,published:"",created:"",versions:0,unpacked:0,files:0,dependencies:[],deprecated:"",readme:"",readmeTruncated:!1,installed:!1,current:"",hasUpdate:!1,error:""});if(!Ve(e))return{...r(),error:"不是 npm 包名,无法查询详情"};let o=!1,n="";try{const s=await Se(),p=(await We(s)).find(u=>u.name===e);o=p!==void 0,n=p?.version??""}catch{}const i=await ir(e);return"error"in i?{...r(),installed:o,current:n,error:i.error}:{...i,npm:r().npm,installed:o,current:n,hasUpdate:o&&dt(i.version,n),error:""}}async function sr(e){const r=e.trim(),o=r?`${r} keywords:${At}`:`keywords:${At}`;try{const n=await fetch(`https://registry.npmjs.org/-/v1/search?size=50&text=${encodeURIComponent(o)}`,{signal:AbortSignal.timeout(12e3),headers:{accept:"application/json"}});if(!n.ok)return{hits:[],error:`npm registry 返回 ${n.status}`};const i=await n.json(),s=await Se(),c=await We(s),p=new Map(c.map(v=>[v.name,v.version])),u=[];for(const v of i.objects??[]){const h=v.package;if(!h?.name)continue;const k=h.name,$=p.has(k),A=$?p.get(k)??"":"",I=Ht(h.links?.repository);u.push({name:k,version:h.version??"",description:h.description??"",published:h.date??"",updated:h.date??"",installed:$,current:A,hasUpdate:$&&dt(h.version??"",A),weekly:Number(v.downloads?.weekly??0)||0,monthly:Number(v.downloads?.monthly??0)||0,publisher:h.maintainers?.[0]?.username??h.publisher?.username??"",license:Vt(h.license),keywords:qt(h.keywords),homepage:gt(h.links?.homepage),repo:I.url,npm:h.links?.npm||`https://www.npmjs.com/package/${k}`})}return{hits:u,error:""}}catch(n){return{hits:[],error:le(n)}}}function Jt(){return process.platform==="darwin"?"open":process.platform==="win32"?"explorer":"xdg-open"}function lr(e){if(!/^https?:\/\//i.test(e))return!1;try{return Be.spawn(Jt(),[e],{detached:!0,stdio:"ignore"}).unref(),!0}catch{return!1}}async function cr(){try{const e=await Se();return Be.spawn(Jt(),[e.path],{detached:!0,stdio:"ignore"}).unref(),!0}catch{return!1}}function pr(){if(process.platform!=="darwin")return!1;const e=`
21
+ …`,truncated:!0}}async function Bt(e,r){try{const o=await fetch(`${sr}/downloads/point/${r}/${encodeURIComponent(e)}`,{signal:AbortSignal.timeout(8e3),headers:{accept:"application/json"}});if(!o.ok)return 0;const n=await o.json();return Number(n.downloads??0)||0}catch{return 0}}async function cr(e){try{const r=await fetch(`${Zt}/${encodeURIComponent(e)}`,{signal:AbortSignal.timeout(2e4),headers:{accept:"application/json"}});if(r.status===404)return{error:"npm 上找不到这个包"};if(!r.ok)return{error:`npm registry 返回 ${r.status}`};if(Number(r.headers.get("content-length")??0)>12*1024*1024)return Dt(e,"包元数据过大,只读取了最新版本");let n;try{n=await r.json()}catch{return Dt(e,"npm 返回的数据无法解析")}return!n||typeof n!="object"?{error:"npm 返回的数据不完整"}:{body:n,error:""}}catch(r){return{error:le(r)}}}async function Dt(e,r){try{const o=await fetch(`${Zt}/${encodeURIComponent(e)}/latest`,{signal:AbortSignal.timeout(1e4),headers:{accept:"application/json"}});if(!o.ok)return{error:r||`npm registry 返回 ${o.status}`};const n=await o.json();return n?.version?{body:{...n,readme:typeof n.readme=="string"?n.readme:"","dist-tags":{latest:n.version},versions:{[n.version]:n},time:n.time},error:""}:{error:r||"npm 返回的数据不完整"}}catch(o){return{error:r||le(o)}}}async function pr(e){const r=await cr(e);if(!r.body)return{error:r.error};const o=r.body,n=o.versions??{},i=Object.keys(n);if(i.length===0)return{error:"npm 上只有占位条目,还没有发布过版本"};const s=o["dist-tags"]?.latest??"",c=s&&n[s]?s:i[i.length-1]??o.version??"",p=c?n[c]??{}:o,u=Xt(p.repository??o.repository),v=lr(typeof o.readme=="string"?o.readme:""),[h,k]=await Promise.all([Bt(e,"last-week"),Bt(e,"last-month")]),$=(o.maintainers??[]).map(L=>L.name??L.username??"").filter(L=>L!==""),A=Object.entries(p.dependencies??{}).map(([L,G])=>G?`${L}@${G}`:L);return{name:e,version:c,description:p.description??o.description??"",homepage:bt(p.homepage??o.homepage)||u.url,repo:u.url,repoDir:u.directory,bugs:ir(p.bugs??o.bugs),license:Yt(p.license??o.license),keywords:Qt(p.keywords??o.keywords),maintainers:$,weekly:h,monthly:k,published:o.time?.[c]??"",created:o.time?.created??"",versions:Object.keys(n).length,unpacked:p.dist?.unpackedSize??0,files:p.dist?.fileCount??0,dependencies:A,deprecated:typeof p.deprecated=="string"?p.deprecated:"",readme:v.text,readmeTruncated:v.truncated}}async function dr(e){const r=Et.get(e);if(r&&Date.now()-r.at<ar)return r.value;const o=await pr(e);return"error"in o||Et.set(e,{at:Date.now(),value:o}),o}async function ur(e){const r=()=>({name:e,version:"",description:"",homepage:"",repo:"",repoDir:"",npm:`https://www.npmjs.com/package/${e}`,bugs:"",license:"",keywords:[],maintainers:[],weekly:0,monthly:0,published:"",created:"",versions:0,unpacked:0,files:0,dependencies:[],deprecated:"",readme:"",readmeTruncated:!1,installed:!1,current:"",hasUpdate:!1,error:""});if(!Xe(e))return{...r(),error:"不是 npm 包名,无法查询详情"};let o=!1,n="";try{const s=await xe(),p=(await Ye(s)).find(u=>u.name===e);o=p!==void 0,n=p?.version??""}catch{}const i=await dr(e);return"error"in i?{...r(),installed:o,current:n,error:i.error}:{...i,npm:r().npm,installed:o,current:n,hasUpdate:o&&ft(i.version,n),error:""}}async function gr(e){const r=e.trim(),o=r?`${r} keywords:${Mt}`:`keywords:${Mt}`;try{const n=await fetch(`https://registry.npmjs.org/-/v1/search?size=50&text=${encodeURIComponent(o)}`,{signal:AbortSignal.timeout(12e3),headers:{accept:"application/json"}});if(!n.ok)return{hits:[],error:`npm registry 返回 ${n.status}`};const i=await n.json(),s=await xe(),c=await Ye(s),p=new Map(c.map(v=>[v.name,v.version])),u=[];for(const v of i.objects??[]){const h=v.package;if(!h?.name)continue;const k=h.name,$=p.has(k),A=$?p.get(k)??"":"",L=Xt(h.links?.repository);u.push({name:k,version:h.version??"",description:h.description??"",published:h.date??"",updated:h.date??"",installed:$,current:A,hasUpdate:$&&ft(h.version??"",A),weekly:Number(v.downloads?.weekly??0)||0,monthly:Number(v.downloads?.monthly??0)||0,publisher:h.maintainers?.[0]?.username??h.publisher?.username??"",license:Yt(h.license),keywords:Qt(h.keywords),homepage:bt(h.links?.homepage),repo:L.url,npm:h.links?.npm||`https://www.npmjs.com/package/${k}`})}return{hits:u,error:""}}catch(n){return{hits:[],error:le(n)}}}function Kt(){return process.platform==="darwin"?"open":process.platform==="win32"?"explorer":"xdg-open"}function hr(e){if(!/^https?:\/\//i.test(e))return!1;try{return De.spawn(Kt(),[e],{detached:!0,stdio:"ignore"}).unref(),!0}catch{return!1}}async function mr(){try{const e=await xe();return De.spawn(Kt(),[e.path],{detached:!0,stdio:"ignore"}).unref(),!0}catch{return!1}}function fr(){if(process.platform!=="darwin")return!1;const e=`
22
22
  export PATH=/usr/bin:/bin:/usr/sbin:/sbin
23
23
  log="$HOME/.cache/opencode/plugin-hub/restart.log"
24
24
  mkdir -p "$HOME/.cache/opencode/plugin-hub" 2>/dev/null
@@ -52,7 +52,7 @@ done
52
52
  sleep 1
53
53
  say "opening app"
54
54
  open -b ai.opencode.desktop 2>/dev/null || open -a OpenCode
55
- `;try{return Be.spawn("/bin/sh",["-c",e],{detached:!0,stdio:"ignore"}).unref(),!0}catch{return!1}}async function dr(e){const r=await pe();try{return e.length===0?{ok:!1,message:"找不到 opencode CLI",state:r}:(Be.spawn(e[0],[...e.slice(1),"reload"],{detached:!0,stdio:"ignore"}).unref(),{ok:!0,message:"已请求重载配置;插件列表变化建议完全退出应用再打开",state:r})}catch(o){return{ok:!1,message:le(o),state:r}}}function le(e){return e instanceof Error?e.message:String(e)}const ur=JSON.parse(`[{"name":"@aerovato/operator-memory","pkg":"","ver":"","type":"plugins","desc":"Durable context for agent-driven development","long":"Operator Memory gives the agent durable memory made of ordinary Markdown: specs, decisions, standards, and research, kept across private, shared, and user partitions. Every file is yours to read, correct, or remove, and new sessions start from that knowledge. No embeddings, no vector database, no ho","repo":"https://github.com/aerovato/operator-memory","tags":["memory","context","documentation","markdown"]},{"name":"Agent Memory","pkg":"opencode-agent-memory","ver":"0.3.1","type":"plugins","desc":"Letta-inspired memory","long":"Gives the agent persistent, self-editable memory blocks inspired by Letta agents.","repo":"https://github.com/joshuadavidthomas/opencode-agent-memory","tags":[]},{"name":"Agent Notifications","pkg":"","ver":"","type":"plugins","desc":"Desktop and webhook alerts for OpenCode sessions","long":"Desktop and optional webhook notifications for OpenCode root-session completion, questions, permissions, and errors on macOS, Linux, and Windows.","repo":"https://github.com/777genius/agent-notifications","tags":[]},{"name":"Agent Skills (JDT)","pkg":"opencode-agent-skills","ver":"0.7.0","type":"plugins","desc":"Dynamic skills loader","long":"Dynamic skills loader that discovers skills from project, user, and plugin directories.","repo":"https://github.com/joshuadavidthomas/opencode-agent-skills","tags":[]},{"name":"OpenCode Antigravity CLI Auth","pkg":"opencode-agy-auth","ver":"2.1.1","type":"plugins","desc":"Google Antigravity account auth","long":"Authenticate the Opencode CLI with your Google account so you can use your existing Antigravity plan.","repo":"https://github.com/anthonyhaussman/opencode-agy-auth","tags":[]},{"name":"AIDevOps","pkg":"aidevops","ver":"3.39.125","type":"plugins","desc":"AI DevOps framework and OpenCode plugin","long":"OpenCode-first AI DevOps framework with agents, skills, workflows, safety hooks, memory, GitHub worker dispatch, and integrations for code, infrastructure, content, SEO, and operations.","repo":"https://github.com/marcusquinn/aidevops","tags":[]},{"name":"Antigravity Auth","pkg":"opencode-antigravity-auth","ver":"2.1.2","type":"plugins","desc":"Google Antigravity models","long":"Use Gemini and Anthropic models for free via Google Antigravity IDE authentication.","repo":"https://github.com/NoeFabris/opencode-antigravity-auth","tags":[]},{"name":"basemind","pkg":"basemind","ver":"0.31.1","type":"plugins","desc":"Full AI context layer over MCP — code-map, document RAG, agent memory, web crawl, git history","long":"Full AI context layer over MCP — tree-sitter code-map, document RAG, shared agent memory, web crawl, and git history. 300+ languages. Published to npm as basemind-opencode (https://www.npmjs.com/package/basemind-opencode).","repo":"https://github.com/Goldziher/basemind","tags":[]},{"name":"Beads Plugin","pkg":"opencode-beads","ver":"0.9.0","type":"plugins","desc":"Beads issue tracker integration","long":"Integration for Steve Yegge's beads issue tracker with /bd-* commands.","repo":"https://github.com/joshuadavidthomas/opencode-beads","tags":[]},{"name":"BRHP","pkg":"","ver":"","type":"plugins","desc":"Persistent planning state","long":"Structured, persistent planning for OpenCode with local session state, /brhp commands, bounded planner history, and a TUI sidebar.","repo":"https://github.com/ZanzyTHEbar/brhp","tags":[]},{"name":"bro","pkg":"bro","ver":"1.0.7","type":"plugins","desc":"Re-explains the last reply in plain language","long":"One-file Agent Skill that re-explains the assistant's last reply (or pasted text) in plain language when it was too dense. The installer adds a \`/bro\` command for OpenCode (\`~/.config/opencode/skills/bro/SKILL.md\` plus a command wrapper); also works in Claude Code, Codex, Cursor and Hermes.","repo":"https://github.com/luchasarie/bro-skill","tags":[]},{"name":"cache-stats","pkg":"","ver":"","type":"plugins","desc":"Showing the active session's cache hit rate in a popup dialog","long":"This plugin shows the overall cache hit rate, a per-model breakdown, a per subagent breakdown and the associated cost, making it easy to understand cache performance at a glance.","repo":"https://github.com/nmdra/opencode-cache-stats","tags":[]},{"name":"Caspian","pkg":"caspian-opencode-plugin","ver":"0.1.7","type":"plugins","desc":"Give your OpenCode agent an inbox — email, Telegram, and Discord","long":"Official Caspian plugin for OpenCode. Gives the agent a bidirectional inbox — email, Telegram, and Discord — with slash commands, session threading back to Gmail, and desktop notifications. No Caspian account required; on first start the plugin mints a sandbox project and provisions an agent email. ","repo":"https://github.com/TryCaspian/caspian-sdk/tree/main/packages/opencode","tags":["email","telegram","discord","inbox","messaging","notifications"]},{"name":"CC Safety Net","pkg":"","ver":"","type":"plugins","desc":"Safety net catching destructive commands","long":"A Claude Code plugin that acts as a safety net, catching destructive git and filesystem commands before they execute.","repo":"https://github.com/kenryu42/claude-code-safety-net","tags":[]},{"name":"Chisle","pkg":"chisle","ver":"3.8.1","type":"plugins","desc":"Cuts token use with terse answers, smallest-code-that-works rules and tool-output compression","long":"Installs a ruleset for terse answers that keep every decisive fact and a \\"smallest code that works\\" ladder, Chisle skills, and a compression plugin that trims oversized tool output before it re-enters the context. The same ruleset ships for Claude Code, Cursor, Codex and Gemini CLI. Install with \`np","repo":"https://github.com/JayPokale/Chisle","tags":["tokens","cost","context","productivity"]},{"name":"Subagent Reporter","pkg":"","ver":"","type":"plugins","desc":"See exactly what your subagents are up to (in the terminal) when invoked during an \`opencode run _____\` session.","long":"When opencode run <prompt> is invoked normally, the actions of the primary agent are visible in the terminal, but subagent actions are not. This makes it difficult to follow progress on the prompt, and makes it very difficult to use \`opencode run\` as part of an unattended process or script. This plu","repo":"https://github.com/raisbecka/opencode-subagent-output","tags":[]},{"name":"codemem","pkg":"codemem","ver":"0.47.3","type":"plugins","desc":"Persistent coding memory across sessions, machines, and teammates","long":"Captures coding decisions, discoveries, and fixes, with automatic context injection in OpenCode, Claude Code, and Codex. Includes MCP tools for searching and managing memories, a viewer, optional cross-machine sync, and sharing of selected projects with teammates.","repo":"https://github.com/kunickiaj/codemem","tags":[]},{"name":"Command Inject","pkg":"opencode-command-inject","ver":"1.3.1","type":"plugins","desc":"Auto-inject project commands into OpenCode","long":"Automatically discovers and injects Makefile targets, npm/pnpm/yarn/bun scripts, and local skills at startup. Type / to see and run all project commands.","repo":"https://github.com/shihyuho/opencode-command-inject","tags":[]},{"name":"ContextStream","pkg":"mcp-server","ver":"0.0.9","type":"plugins","desc":"Shared project context for OpenCode, Cursor, Claude Code, Codex, and Grok via MCP","long":"Hosted MCP server that keeps coding agents on shared project context across sessions and teammates. Works with OpenCode and other MCP-compatible clients. Endpoint https://mcp.contextstream.io/mcp — Intelligence isn’t the bottleneck. Context is.","repo":"https://github.com/contextstream/mcp-server","tags":["mcp","context","productivity","collaboration"]},{"name":"deja","pkg":"opencode-deja","ver":"0.23.5","type":"plugins","desc":"Recall what you already did in your other coding agents","long":"opencode remembers its own sessions. deja answers the other question: what you did in Claude Code, Codex, Cursor, Gemini CLI, Zed and fifteen more agents on this machine — including the months before you installed anything.\\n\\nA local Go binary indexes the transcripts those agents already wrote to dis","repo":"https://github.com/vshulcz/deja-vu","tags":["memory","recall","search","cross-agent","session-history"]},{"name":"Ditto","pkg":"ditto","ver":"0.0.11","type":"plugins","desc":"Mines your local AI coding session logs into a personal profile your agent loads before every task","long":"Mines local AI coding session logs (OpenCode, Claude Code, Codex, Copilot CLI) into a personal working profile. The OpenCode adapter reads OpenCode's SQLite session store and installs the profile into OpenCode's global rules so the agent loads it before every task. Single stdlib-only Python file, ru","repo":"https://github.com/ohad6k/ditto","tags":[]},{"name":"Dodo Payments","pkg":"dodo-agent-plugin","ver":"0.0.1","type":"plugins","desc":"Payments, subscriptions, webhooks, and billing for OpenCode agents","long":"Official Dodo Payments plugin for OpenCode (also Claude Code, Codex, Cursor). Bundles eight integration skills (checkout, subscriptions, webhooks, usage-based billing, credits, license keys, BillingSDK, best practices) plus two MCP servers — a live API server with browser OAuth and a documentation s","repo":"https://github.com/dodopayments/dodo-agent-plugin","tags":[]},{"name":"Dynamic Context Pruning","pkg":"","ver":"","type":"plugins","desc":"Optimize token usage","long":"Plugin that optimises token usage by pruning obsolete tool outputs from conversation context.","repo":"https://github.com/Tarquinen/opencode-dynamic-context-pruning","tags":[]},{"name":"Envsitter Guard","pkg":"envsitter-guard","ver":"0.1.1","type":"plugins","desc":"Prevent .env leaks","long":"OpenCode plugin that prevents agents/tools from reading or editing sensitive .env* files, while still allowing safe inspection via EnvSitter (keys + deterministic fingerprints; never values).","repo":"https://github.com/boxpositron/envsitter-guard","tags":[]},{"name":"FlowDeck","pkg":"flowdeck","ver":"0.16.1","type":"plugins","desc":"AI-powered multi-agent workflow orchestration with built-in safety intelligence","long":"FlowDeck adds a structured, multi-agent development workflow to OpenCode. It coordinates 25 specialist agents through a four-phase cycle — discuss, plan, execute, review — with persistent state that survives session restarts.\\n\\nKey features:\\n- 25 specialist agents (architect, planner, coder, reviewer","repo":"https://github.com/DVNghiem/FlowDeck","tags":["workflow","orchestration","multi-agent","planning","security","TDD"]},{"name":"ForLoop Planner","pkg":"@forloop-cc/forloop-opencode-plugin-planner","ver":"2.2.25","type":"plugins","desc":"Autopilot development. Plan with ForLoop agent. Build, Test, Deploy on cloud in one go.","long":"ForLoop offers an all-in-one platform that covers the entire development lifecycle, from initial planning and coding to automated testing and cloud deployment.","repo":"https://github.com/forloop-cc/forloop-opencode-plugin-planner","tags":[]},{"name":"Froggy","pkg":"froggy","ver":"1.1.6","type":"plugins","desc":"Hooks and specialized agents","long":"Plugin providing Claude Code-style hooks, specialized agents, and tools like gitingest.","repo":"https://github.com/smartfrog/opencode-froggy","tags":[]},{"name":"Gemini Auth","pkg":"opencode-gemini-auth","ver":"2.0.1","type":"plugins","desc":"Google account auth","long":"Authenticate the Opencode CLI with your Google account so you can use your existing Gemini plan.","repo":"https://github.com/jenslys/opencode-gemini-auth","tags":[]},{"name":"Godmode","pkg":"godmode","ver":"0.0.3","type":"plugins","desc":"Discipline layer: measure → modify → verify → keep/revert","long":"Skill plugin with 135 skills and 7 subagents that adds a measure → modify → verify → keep/revert discipline loop to AI coding agents. Works with OpenCode alongside Claude Code, Codex, Cursor, and Gemini CLI.","repo":"https://github.com/arbazkhan971/godmode","tags":[]},{"name":"Handoff","pkg":"handoff","ver":"1.3.2","type":"plugins","desc":"Session handoff prompts","long":"Creates focused handoff prompts for continuing work in a new session.","repo":"https://github.com/joshuadavidthomas/opencode-handoff","tags":[]},{"name":"Honcho","pkg":"honcho","ver":"0.4.13","type":"plugins","desc":"AI-native long-term memory for OpenCode","long":"Give OpenCode persistent memory that survives context wipes, session restarts, and fresh chats. Honcho remembers what you're working on, durable preferences, and prior context across projects. Supports cloud and self-hosted deployments with configurable session strategies.","repo":"https://github.com/plastic-labs/opencode-honcho","tags":[]},{"name":"Internet Court","pkg":"","ver":"","type":"plugins","desc":"Trust layer for agent-to-agent commerce: mandates, payments, escrow, dispute resolution.","long":"The trust layer for agent-to-agent commerce — natural-language mandates, delegated permissions, x402 payments, escrow, and dispute resolution as one open, catch-all skill. By the Internet Court Consortium (internetcourt.org). MIT licensed.","repo":"https://github.com/internet-court/internet-court-skill","tags":["agent-payments","x402","erc-7710","erc-8004","escrow","genlayer"]},{"name":"kibi-opencode","pkg":"kibi-opencode","ver":"3.2.0","type":"plugins","desc":"Repo-local, branch-scoped knowledge and traceability for OpenCode","long":"Plugin-first entry point into the Kibi stack for OpenCode users. It adds context-aware\\nguidance, routes durable code comments toward Kibi artifacts, runs non-blocking background\\nsync and targeted validation checks, and helps keep repo knowledge branch-local and queryable.","repo":"https://github.com/Looted/kibi","tags":["opencode","plugin","mcp","traceability"]},{"name":"Kilo Gateway Auth","pkg":"opencode-kilo-auth","ver":"1.1.4","type":"plugins","desc":"Kilo Gateway provider","long":"Adds Kilo Gateway provider support to OpenCode.","repo":"https://github.com/JungHoonGhae/opencode-kilo-auth","tags":[]},{"name":"Lemma","pkg":"lemma","ver":"0.10.2","type":"plugins","desc":"Persistent memory layer for LLMs via MCP - local, zero-dependency, works on all clients","long":"Biological memory model for AI coding agents. Features confidence decay/boost, Fuse.js fuzzy dedup, guide system with usage tracking, cross-references, cumulative backup, virtual session tracking, and universal memory injection via tool descriptions (works on Claude Desktop, Cursor, VS Code, Gemini ","repo":"https://github.com/xenitV1/lemma","tags":["memory","mcp","persistence","context","claude","cursor"]},{"name":"opencode-llm-proxy","pkg":"opencode-llm-proxy","ver":"1.11.2","type":"plugins","desc":"OpenCode-backed API gateway with tool calling","long":"Local OpenCode plugin that exposes OpenAI Chat Completions, OpenAI Responses, Anthropic Messages, and Gemini-compatible endpoints for any model configured in OpenCode. Supports streaming, model listing, and real tool/function calling including parallel tool calls, so tools like n8n, Open WebUI, Lang","repo":"https://github.com/KochC/opencode-llm-proxy","tags":["openai","anthropic","gemini","responses-api","llm-gateway","tool-calling"]},{"name":"Magic Context","pkg":"@cortexkit/opencode-magic-context","ver":"0.49.35","type":"plugins","desc":"Lossless context management with background compression","long":"Cache-aware context management that keeps long sessions productive. Background historian compresses old conversation into structured compartments while you keep working. Includes cross-session project memory, unified search across history/memories/facts, overnight dreamer for memory maintenance, and","repo":"https://github.com/cortexkit/opencode-magic-context","tags":[]},{"name":"Mem0 OpenCode Plugin","pkg":"","ver":"","type":"plugins","desc":"Persistent memory plugin so your agent remembers across sessions","long":"OpenCode plugin that gives your agent persistent memory powered by Mem0. Includes 9 MCP memory tools, 16 slash commands, and lifecycle hooks that auto-capture decisions, search prior context at session start, and pre-fetch error memories on failures. Install with \`opencode plugin @mem0/opencode-plug","repo":"https://github.com/mem0ai/mem0","tags":[]},{"name":"Micode","pkg":"micode","ver":"0.11.0","type":"plugins","desc":"Brainstorm-Plan-Implement workflow","long":"Structured workflow with session continuity, subagent orchestration, git worktree isolation, and AST-aware tools.","repo":"https://github.com/vtemian/micode","tags":[]},{"name":"Morph Fast Apply","pkg":"","ver":"","type":"plugins","desc":"10,500+ tokens/sec code editing","long":"Integrates Morph's Fast Apply API for faster code editing with lazy edit markers and unified diff output.","repo":"https://github.com/JRedeker/opencode-morph-fast-apply","tags":[]},{"name":"Neuralyzer","pkg":"neuralyzer","ver":"1.1.5","type":"plugins","desc":"Easier Ralph loop inside harness","long":"Allow agent to wipe its own session context and re-run the first message. This allows easier and more ergonomic Ralph loop engineering.","repo":"https://github.com/gintasz/neuralyzer","tags":[]},{"name":"Oh My Cassette","pkg":"","ver":"","type":"plugins","desc":"Chat your raw clips into a finished cut","long":"Adds a local stdio MCP server that turns a chat message into an edited video: beat-synced cuts, auto-matched background music, subtitles, transitions, and picture-in-picture. Ingest local clips, then drive a persistent multi-turn editing thread — every turn returns a timeline delta and a contact-she","repo":"https://github.com/Cassette-Editor/oh-my-cassette","tags":["mcp","video","video-editing","media"]},{"name":"Oh My Opencode","pkg":"oh-my-opencode","ver":"5.1.60","type":"plugins","desc":"Agents & Pre-built tools","long":"Background agents, pre-built tools (LSP/AST/MCP), curated agents, and a Claude Code compatible layer.","repo":"https://github.com/code-yeongyu/oh-my-opencode","tags":[]},{"name":"Oh My Opencode Slim","pkg":"oh-my-opencode-slim","ver":"3.0.7","type":"plugins","desc":"Lightweight agent orchestration with reduced token usage","long":"Slimmed-down fork of oh-my-opencode focused on core agent orchestration. Features specialized sub-agents (Explorer, Oracle, Librarian, Designer, etc.), background task management, LSP/AST tools, tmux integration for live agent visibility, and MCP servers. Optimized to consume significantly fewer tok","repo":"https://github.com/alvinunreal/oh-my-opencode-slim","tags":["agents","orchestration","background-tasks","lsp","mcp"]},{"name":"open-plan-annotator","pkg":"open-plan-annotator","ver":"1.13.2","type":"plugins","desc":"Annotate LLM plans like a Google Doc!","long":"A fully local agentic coding plugin that intercepts plan mode and opens an annotation UI in your browser. Select text to strikethrough, replace, insert, or comment — then approve the plan or request changes","repo":"https://github.com/ndom91/open-plan-annotator","tags":[]},{"name":"Opencode Agents Sidebar","pkg":"opencode-agents-sidebar","ver":"3.1.0","type":"plugins","desc":"Browse configured OhMyOpenAgent agents in the TUI","long":"OpenCode sidebar plugin that displays configured OhMyOpenAgent agents with lifecycle-based categories, collapsible sections, descriptions, and model information.","repo":"https://github.com/Mark1708/opencode-agents-sidebar","tags":[]},{"name":"Boffin","pkg":"","ver":"","type":"plugins","desc":"Routed architectural guardrails for AI coding agents in OpenCode","long":"Staff-engineer layer for AI coding agents: routes per-edit architectural constraints and requires verification. Not another AGENTS.md.","repo":"https://github.com/MicSm/boffin","tags":["opencode","architecture","guardrails","code-review","cplusplus","python"]},{"name":"OpenCode Claude Code Plugin","pkg":"opencode-claude-code-plugin","ver":"0.1.2","type":"plugins","desc":"Claude models through the official Claude Code CLI, using the login you already have","long":"Runs Anthropic's Claude models in opencode through the official claude CLI as a subprocess, so opencode uses whatever the CLI is logged in as and no token is ever read or replayed. Bash, Edit and Write are proxied back to opencode's own permissions, with several accounts, per-subagent models, and on","repo":"https://github.com/khalilgharbaoui/opencode-claude-code-plugin","tags":[]},{"name":"OpenCode Claude Memory","pkg":"opencode-claude-memory","ver":"2.3.0","type":"plugins","desc":"Claude Code-compatible memory","long":"Share persistent Markdown memory between OpenCode and Claude Code using Claude Code-compatible paths and file formats.","repo":"https://github.com/kuitos/opencode-claude-memory","tags":[]},{"name":"Opencode CMD Provider","pkg":"opencode-cmd-provider","ver":"2.3.4","type":"plugins","desc":"Use CommandCode plans (Go, GOAT, Pro, Max) as an OpenCode provider.","long":"OpenCode provider plugin for the CommandCode Provider API. Authenticate via\\n/connect browser flow or COMMANDCODE_API_KEY, auto-registers all CommandCode\\nmodels ([CMD] prefix) with offline snapshot, pricing display, and per-plan\\ndeals/allowance intelligence in the sidebar and cmd_plan_summary tool.","repo":"https://github.com/rashidrazak/opencode-cmd-provider","tags":["provider","commandcode","model-discovery","auth"]},{"name":"Cursor Auth","pkg":"opencode-cursor","ver":"0.0.1","type":"plugins","desc":"Use your Cursor subscription models in OpenCode via OAuth","long":"Connects Cursor's API to OpenCode via OAuth login, automatic model discovery, and a local OpenAI-compatible proxy — use the models included in your Cursor subscription directly from OpenCode.","repo":"https://github.com/ephraimduncan/opencode-cursor","tags":[]},{"name":"opencode-dir-tree-tui","pkg":"opencode-dir-tree-tui","ver":"1.0.6","type":"plugins","desc":"File tree sidebar with Git status and quick file actions","long":"Browse project files in the OpenCode V2 sidebar with Git status indicators, custom ignore rules, path copying, and quick file and folder opening.","repo":"https://github.com/aihaipeng/opencode-dir-tree-tui","tags":[]},{"name":"OpenCode Ensemble","pkg":"@hueyexe/opencode-ensemble","ver":"0.20.0","type":"plugins","desc":"Parallel agent teams for OpenCode","long":"Coordinate parallel OpenCode agents with peer messaging, a shared task board, git worktree isolation, and a live dashboard.","repo":"https://github.com/hueyexe/opencode-ensemble","tags":["agents","multi-agent","orchestration","worktrees","dashboard"]},{"name":"opencode-failover","pkg":"opencode-failover","ver":"2.0.7","type":"plugins","desc":"Automatic API-key failover and rotation across multiple provider keys","long":"OpenCode plugin that automatically rotates API keys across multiple provider credentials. When a key hits a rate limit, the plugin quarantines it and switches to the next available key with zero downtime. Features weighted round-robin distribution, exponential backoff quarantine, retry-after header ","repo":"https://github.com/bulutmuf/opencode-failover","tags":[]},{"name":"GitHub Release","pkg":"opencode-github-release","ver":"0.6.0","type":"plugins","desc":"Automated GitHub releases","long":"Create and publish GitHub releases with semantic versioning, tag management, and auto-generated release notes.","repo":"https://github.com/amestsantim/opencode-github-release","tags":[]},{"name":"GoopSpec","pkg":"goopspec","ver":"0.2.9","type":"plugins","desc":"Spec-driven development workflow","long":"Transforms AI-assisted coding with spec-driven workflows. Features 5-phase workflow (Plan, Research, Specify, Execute, Accept), contract gates for user confirmation, 12 specialized subagents, persistent memory system, wave-based execution with atomic commits, and deviation rules for handling unexpec","repo":"https://github.com/hffmnnj/opencode-goopspec","tags":[]},{"name":"GPT Imagegen","pkg":"opencode-gpt-imagegen","ver":"1.2.2","type":"plugins","desc":"gpt-image-2 in OpenCode — no API cost when using your ChatGPT subscription","long":"Brings gpt-image-2 (ChatGPT Images 2) image generation to OpenCode. When you sign into OpenCode with your ChatGPT account, generations are billed against your existing Plus / Pro / Business plan — no per-image API cost. An OpenAI API key path is also planned. Supports reference images for style guid","repo":"https://github.com/yuji-hatakeyama/opencode-gpt-imagegen","tags":["openai","gpt-image-2","gpt-image","image-generation","image-editing","text-to-image"]},{"name":"Opencode LiteLLM","pkg":"opencode-litellm","ver":"0.1.0","type":"plugins","desc":"Auto-discover models from a LiteLLM proxy","long":"Drop-in LiteLLM provider for OpenCode with zero configuration. Auto-detects a running\\nLiteLLM proxy on common ports (4000, 8000, 8080), pulls every model from /v1/models,\\nand registers them in OpenCode automatically — no model lists to hand-maintain. Smart\\nname formatting, modality categorization (c","repo":"https://github.com/yuseferi/opencode-litellm","tags":["litellm","provider","openai-compatible","llm-proxy","model-discovery"]},{"name":"Opencode Mem","pkg":"opencode-mem","ver":"2.41.0","type":"plugins","desc":"Persistent memory with vector database","long":"A persistent memory system for AI coding agents that enables long-term context retention across sessions using local vector database technology. Features dual memory scopes, web interface, auto-capture system, and multi-provider AI support.","repo":"https://github.com/tickernelz/opencode-mem","tags":[]},{"name":"OpenCode Mission Control","pkg":"opencode-mission-control","ver":"1.6.0","type":"plugins","desc":"Command center for parallel agents — worktree isolation, DAG plans, merge train, PRs","long":"Orchestrates parallel OpenCode agents in tmux-isolated git worktrees with live inspection (capture/attach/diff), a dashboard overview, agent status reporting, and in-chat notifications. Supports DAG-based plans with autopilot/copilot/supervisor modes and a merge train with test gating and automatic ","repo":"https://github.com/nigel-dev/opencode-mission-control","tags":[]},{"name":"Opencode Models Discovery","pkg":"opencode-models-discovery","ver":"2.1.1","type":"plugins","desc":"Configurable model discovery and filtering without long manual config","long":"OpenCode plugin for discovering models from OpenAI-compatible providers and API gateways, with provider and model filtering so users can avoid maintaining large configs or loading every model at once.","repo":"https://github.com/yuhp/opencode-models-discovery","tags":[]},{"name":"OpenCode ntfy.sh","pkg":"opencode-ntfy.sh","ver":"1.1.0","type":"plugins","desc":"Push notifications to keep you in the know, even when you're on the go.","long":"An OpenCode plugin that adds push notifications through ntfy.sh.","repo":"https://github.com/lannuttia/opencode-ntfy.sh","tags":[]},{"name":"OpenAI Native Compaction","pkg":"opencode-openai-compact","ver":"1.4.0","type":"plugins","desc":"Use OpenAI's official Responses API compaction in OpenCode","long":"Routes OpenCode session compaction for OpenAI providers through \`/responses/compact\`, stores the returned compacted output locally, and injects it into the next Responses request so long sessions use OpenAI's native compaction instead of a prompt-written summary.","repo":"https://github.com/partment/opencode-openai-compact","tags":[]},{"name":"OpenWork for OpenCode","pkg":"","ver":"","type":"plugins","desc":"Official OpenWork plugin to deploy AI models, skills, and MCPs to your team's OpenCode","long":"The official plugin from OpenWork. Centrally deploy AI models, skills, and MCP servers to your whole team. Admins add a model provider, skill, or MCP connection once and choose who gets it; everyone receives it in OpenCode after a single sign-in. No shared API keys, no copying MCP configs between ma","repo":"https://github.com/different-ai/openwork/tree/dev/packages/opencode-plugin","tags":[]},{"name":"opencode-plugin-otel","pkg":"@devtheops/opencode-plugin-otel","ver":"2.0.1","type":"plugins","desc":"OpenTelemetry telemetry exporter for opencode sessions, mirroring Claude Code monitoring signals","long":"Exports metrics, logs, and traces from opencode sessions via OTLP/gRPC to any OpenTelemetry-compatible backend (Datadog, Honeycomb, Grafana Cloud, etc.). Instruments session lifecycle, token usage, cost, tool durations, and git commits — mirroring the same signals as Claude Code's monitoring.","repo":"https://github.com/DEVtheOPS/opencode-plugin-otel","tags":[]},{"name":"OpenCode Pollinations Plugin","pkg":"opencode-pollinations-plugin","ver":"6.5.5","type":"plugins","desc":"Full Pollinations.ai integration — free unlimited AI models, 17+ multimodal tools, hourly free tiers & Safety Net.","long":"The ultimate bridge between OpenCode and the Pollinations.ai ecosystem. Access 30+ free and enterprise AI models (OpenAI, Gemini, Mistral, Claude...) with hourly Pollen resets. Includes 17+ agent tools (image, video, audio, music generation, background removal, web search, transcription, QR codes, d","repo":"https://github.com/fkom13/opencode-pollinations-plugin","tags":[]},{"name":"PR Auto-Signature","pkg":"opencode-pr-signature","ver":"1.2.2","type":"plugins","desc":"Automatically adds AI model signature to PRs, Issues, and Commits","long":"Plugin that automatically appends AI model signature to Pull Requests, Issues, and git commit messages. Supports GitHub MCP tools, git CLI, and gh CLI. Recognizes 90+ AI models including Claude, GPT, Gemini, DeepSeek, Llama, Mistral, and more.","repo":"https://github.com/arttttt/opencode-pr-signature","tags":[]},{"name":"Opencode Quota","pkg":"opencode-quota","ver":"0.0.1-dev","type":"plugins","desc":"Quota toasts and token tracking","long":"Track quota and token usage across providers via automatic toasts and slash commands.","repo":"https://github.com/slkiser/opencode-quota","tags":[]},{"name":"OpenCodeRAG","pkg":"","ver":"","type":"plugins","desc":"Local-first RAG plugin for semantic code search with tree-sitter chunking and LanceDB","long":"A local-first Retrieval-Augmented Generation plugin for OpenCode that enables semantic code\\nsearch across your workspace. Features AST-aware chunking via tree-sitter (19 languages),\\nincremental indexing with file-change detection, watch mode for live re-indexing, and\\nconfigurable embeddings via Olla","repo":"https://github.com/MrDoe/OpenCodeRAG","tags":[]},{"name":"opencode-review","pkg":"","ver":"","type":"plugins","desc":"Automatic structured code review with configurable dimensions and auto-fix","long":"An automatic code review plugin for OpenCode CLI. Reviews staged changes when session goes idle, with configurable cooldown, multi-dimension analysis (code quality, security, performance, testing, documentation), severity levels, and auto-fix chain support.","repo":"https://github.com/sun-praise/opencode-review","tags":[]},{"name":"opencode-short-term-memory","pkg":"","ver":"","type":"plugins","desc":"Maintain user instructions and preferences throughout long sessions. No more repeating yourself.","long":"Automatically summarizes conversation context into structured session memory and injects it back into the system prompt every few turns — preserving user instructions, project context, decisions, and active references across long chats and compactions.","repo":"https://github.com/andrejtonev/opencode-short-term-memory","tags":[]},{"name":"opencode-skills-tui","pkg":"opencode-skills-tui","ver":"1.2.3","type":"plugins","desc":"Browse skills, track loaded state, and preview SKILL.md","long":"OpenCode V2 skills sidebar with loaded-state tracking, SKILL.md previews, token estimates, and skill mentions in prompts.","repo":"https://github.com/aihaipeng/opencode-skills-tui","tags":[]},{"name":"opencode-snip","pkg":"opencode-snip","ver":"3.0.0","type":"plugins","desc":"OpenCode plugin that prefixes shell commands with snip to reduce LLM token consumption by 60-90%","long":"Automatically prefixes supported shell commands (git, go, cargo, npm, docker, etc.) with snip to filter output before it reaches your LLM context window.","repo":"https://github.com/VincentHardouin/opencode-snip","tags":[]},{"name":"Opencode Snippets","pkg":"opencode-snippets","ver":"3.4.0","type":"plugins","desc":"Instant inline text expansion","long":"Instant inline text expansion for OpenCode. Type #snippet anywhere in your message and watch it transform. Brings DRY principles to prompt engineering with composable, shell-enabled snippets.","repo":"https://github.com/JosXa/opencode-snippets","tags":[]},{"name":"OpenCode Swarm","pkg":"opencode-swarm","ver":"7.201.2","type":"plugins","desc":"Verification-gated swarm with architect, review, test, and security agents","long":"Verification-gated OpenCode swarm with architect planning, independent review, test engineering, security checks, and resumable evidence.","repo":"https://github.com/zaxbysauce/opencode-swarm","tags":[]},{"name":"Opencode Synced","pkg":"opencode-synced","ver":"0.11.0","type":"plugins","desc":"Sync configs across machines","long":"Enables syncing global opencode configurations across machines with public/private visibility options.","repo":"https://github.com/iHildy/opencode-synced","tags":[]},{"name":"System Prompt Logger","pkg":"opencode-system-prompt-logger","ver":"1.0.0","type":"plugins","desc":"System prompt logger","long":"OpenCode plugin that intercepts the system prompt before it's sent to the LLM and logs it.","repo":"https://github.com/tlinhart/opencode-system-prompt-logger","tags":[]},{"name":"Opencode Telemetry","pkg":"opencode-telemetry","ver":"0.3.4","type":"plugins","desc":"Passive cross-session telemetry to local SQLite; cost rollups across agent orchestration chains","long":"Logs every opencode session to a local SQLite database automatically — tokens, tool calls, skills, per-turn cost. Aggregates costs across orchestration chains (conductor + child sessions), offers turn-by-turn forensic inspection, and ships an \`octm\` CLI for reports without spending model tokens. Zer","repo":"https://github.com/agostinilabsrl/opencode-telemetry","tags":["telemetry","observability","cost-tracking","sqlite","local-first","orchestration"]},{"name":"Opencode update notifier","pkg":"opencode-update-notifier","ver":"0.4.0","type":"plugins","desc":"Notify about plugin updates.","long":"Checks if your pinned plugins have newer versions available and shows a notification.","repo":"https://github.com/tim-hilde/opencode-update-notifier","tags":[]},{"name":"Opencode Usage Monitor","pkg":"opencode-usage-monitor","ver":"3.1.0","type":"plugins","desc":"Monitor OpenAI and Z.AI usage quotas in the TUI","long":"OpenCode sidebar plugin that displays API usage quotas for OpenAI and Z.AI providers with per-model breakdowns, spend tracking, and configurable refresh controls.","repo":"https://github.com/Mark1708/opencode-usage-monitor","tags":[]},{"name":"Opencode Visualizer","pkg":"","ver":"","type":"plugins","desc":"2D pixel-art office for AI agents","long":"Turning raw OpenCode terminal logs into cozy 2D pixel office chaos. Watch your agents work, idle, and celebrate success in a bustling virtual office.","repo":"https://github.com/psinetron/opencode-visualiser","tags":[]},{"name":"OrgX OpenCode Plugin","pkg":"@useorgx/orgx-opencode-plugin","ver":"0.1.0-alpha.7","type":"plugins","desc":"OrgX Work Graph peer for task dispatch, receipts, deviations, and passive reconciliation","long":"OrgX OpenCode Plugin connects OpenCode sessions to the OrgX execution control plane. It receives OrgX task dispatches, drives the user's local OpenCode session, posts execution receipts and deviations back to OrgX, and writes compact Work Graph events for later audit-first reconciliation.","repo":"https://github.com/useorgx/orgx-opencode-plugin","tags":["agent-orchestration","work-graph","task-dispatch","receipts","mcp"]},{"name":"Plannotator","pkg":"","ver":"","type":"plugins","desc":"Interactive plan review UI","long":"Plan review UI with visual annotation, private/offline sharing, and Obsidian/Bear integration.","repo":"https://github.com/backnotprop/plannotator","tags":[]},{"name":"Rehydra","pkg":"rehydra","ver":"0.16.5","type":"plugins","desc":"Prevent your coding agent from leaking secrets to LLM providers","long":"Intercepts the conversation between OpenCode and the LLM, replacing secrets from .env files and detected API keys, tokens, and credentials with placeholders before they leave your machine. Secrets are transparently restored before any tool executes locally. Supports pattern-based detection for Strip","repo":"https://github.com/rehydra-ai/rehydra-sdk","tags":[]},{"name":"Ring a Bell Example","pkg":"","ver":"","type":"plugins","desc":"Simple terminal bell plugin","long":"A simple plugin to ring the terminal bell once a request is complete.","repo":"https://gist.github.com/ahosker/267f375a65378bcb9a867fd9a195db1e","tags":[]},{"name":"Simple Memory","pkg":"","ver":"","type":"plugins","desc":"Git-based memory","long":"Simple plugin to manage memory inside a git repo that can be committed and reviewed by team members.","repo":"https://github.com/cnicolov/opencode-plugin-simple-memory","tags":[]},{"name":"SonarQube","pkg":"sonarqube","ver":"0.0.1","type":"plugins","desc":"Automatically enforce SonarQube code quality and security in the agent coding loop","long":"SonarQube is the AI code quality and security verification platform used by millions of developers to catch bugs, vulnerabilities, and leaked secrets. This plugin enforces those standards in the agent coding loop: 7,500+ distinct issue types, secrets scanning, agentic analysis, and quality gates acr","repo":"https://github.com/SonarSource/sonarqube-agent-plugins","tags":["sonarqube","code-quality","static-analysis","security","secrets"]},{"name":"Superpowers","pkg":"superpowers","ver":"0.0.2","type":"plugins","desc":"Complete software development methodology with composable skills for coding agents","long":"Gives your coding agent a structured methodology - brainstorm specs, write plans, run TDD, dispatch subagents, and review work. Skills trigger automatically across Claude Code, OpenCode, Codex, Gemini CLI, Cursor, and GitHub Copilot CLI.","repo":"https://github.com/obra/superpowers","tags":[]},{"name":"Systematic","pkg":"systematic","ver":"3.1.1","type":"plugins","desc":"Compound-engineering workflows for OpenCode, Pi, and Claude Code","long":"Provides brainstorm, plan, work, and review workflows as bundled skills and agents for OpenCode, Pi, and Claude Code.","repo":"https://github.com/marcusrbrown/systematic","tags":[]},{"name":"@telemetry-dev/opencode","pkg":"@telemetry-dev/opencode","ver":"0.2.4","type":"plugins","desc":"OpenTelemetry traces for OpenCode agent turns, model calls, and tools","long":"Records OpenCode agent turns, model calls, tool executions, and session events with OpenTelemetry for telemetry.dev. Available as the @telemetry-dev/opencode npm package; source and setup instructions are in packages/opencode of the linked SDK repository.","repo":"https://github.com/telemetry-dev/telemetry","tags":[]},{"name":"toon-config","pkg":"toon-config","ver":"1.0.2","type":"plugins","desc":"Loads TOON based, AGENTS.toon rather than Markdown","long":"Use TOON based agent instructions. Command to analyize and improve agent instructions.","repo":"https://github.com/mmynsted/opencode-toon-config-plugin","tags":[]},{"name":"TypeUI","pkg":"","ver":"","type":"plugins","desc":"Design systems, UI prompts, and layout variation guidance","long":"Open-source design layer for OpenCode that provides curated design skills, UI prompts, and layout variation guidance so agents can generate more consistent interfaces. Includes an <a href=\\"https://www.typeui.sh/docs/guides/opencode\\">OpenCode setup guide</a>.","repo":"https://github.com/bergside/typeui","tags":[]},{"name":"ul-opencode-event","pkg":"@ulthon/ul-opencode-event","ver":"0.1.58","type":"plugins","desc":"Multi-channel notifications (SMTP, DingTalk, Feishu) and token usage analytics","long":"Get notified when OpenCode sessions complete, error, or need your attention - via SMTP email, DingTalk robot, or Feishu robot.\\n- Multi-channel: SMTP, DingTalk, Feishu, local JSONL file\\n- Multi-level token analytics: message / session / total / project scopes\\n- 74+ template variables with i18n suppor","repo":"https://gitee.com/ulthon/ul-opencode-event","tags":["notifications","email","dingtalk","feishu","token-tracking","usage-analytics"]},{"name":"UNMOJI","pkg":"@bastiangx/opencode-unmoji","ver":"1.0.0","type":"plugins","desc":"Strip emojis from output","long":"A simple plugin that strips ALL emojis from agent outputs in Opencode.","repo":"https://codeberg.org/bastiangx/opencode-unmoji","tags":[]},{"name":"WakaTime","pkg":"wakatime","ver":"1.2.0","type":"plugins","desc":"WakaTime integration","long":"WakaTime integration plugin for tracking coding activity in opencode sessions.","repo":"https://github.com/angristan/opencode-wakatime","tags":[]},{"name":"Xquik","pkg":"x-twitter-scraper","ver":"0.20.0","type":"plugins","desc":"X/Twitter data skill & MCP server","long":"X/Twitter data skill — MCP server, REST API, 20 extraction tools. Works with Claude Code, Cursor, Codex, and 40+ agents.","repo":"https://github.com/Xquik-dev/x-twitter-scraper","tags":[]},{"name":"OpenCode Light Themes","pkg":"","ver":"","type":"themes","desc":"A curated collection of 21 light color themes for OpenCode","long":"The largest collection of light themes for OpenCode. Includes 21 carefully crafted light themes converted from popular VS Code themes — scaefy-light (Atom One Light), Solarized Light, Vivid Light, Coffee Cream, GitHub Light, Quiet Light, Bluloco Light, Brackets Light Pro, NetBeans Light, Ysgrifennwr","repo":"https://github.com/fatihtoprakk/opencode-light-themes","tags":[]}]`),Qt=[{url:"https://raw.githubusercontent.com/awesome-opencode/awesome-opencode/main/dist/registry.json"},{url:"https://api.github.com/repos/awesome-opencode/awesome-opencode/contents/dist/registry.json?ref=main",accept:"application/vnd.github.raw+json"},{url:"https://raw.githubusercontent.com/Gracdjd/awesome-opencode/main/dist/registry.json"},{url:"https://api.github.com/repos/Gracdjd/awesome-opencode/contents/dist/registry.json?ref=main",accept:"application/vnd.github.raw+json"}],gr=720*60*1e3,Xt=ur;function Yt(){const e=process.env.XDG_CACHE_HOME;return e?U.join(e,"opencode","plugin-hub"):U.join(Le.homedir(),".cache","opencode","plugin-hub")}function Zt(){return U.join(Yt(),"registry.json")}const hr=/"plugin"\s*:\s*\[\s*"([^"]+)"/,zt=/^(@[a-z0-9][\w.-]*\/)?[a-z0-9][\w.-]*$/i;function Pt(e){const r=hr.exec(e.installation??"");if(r?.[1])return r[1];const o=(e.displayName??"").trim();if(zt.test(o)&&!o.includes(" "))return o;const i=(e.repoUrl??"").replace(/\/+$/,"").split("/").pop()?.replace(".git","")??"";return zt.test(i)?i:""}const qe=new Map;for(const e of Xt)qe.set(e.repo,e),e.pkg&&qe.set(`pkg:${e.pkg}`,e);function mr(e){return e.replace(/\/+$/,"").replace(/\.git$/,"")}function Ue(e,r){const o=[],n=new Set;for(const i of e){const s=i.type??"plugins";if(s!=="plugins"&&s!=="mcp"&&s!=="themes")continue;const c=mr(i.repoUrl??"");if(!c||n.has(c))continue;n.add(c);const p=qe.get(c)??qe.get(`pkg:${Pt(i)}`),u=p?.pkg??Pt(i);o.push({name:i.displayName??u??c,pkg:u,version:p?.ver??"",type:s,desc:(i.tagline??"").trim(),long:(i.description??"").trim().slice(0,300),repo:c,tags:(i.tags??[]).slice(0,6),installed:u?r.has(u):!1})}return o}async function fr(){let e="";for(const r of Qt)try{const o={accept:r.accept??"application/json"},n=await fetch(r.url,{signal:AbortSignal.timeout(12e3),headers:o});if(!n.ok){e=`${new URL(r.url).host} 返回 ${n.status}`;continue}const i=await n.json();if(!Array.isArray(i)){e="registry 格式不是数组";continue}return{entries:i,url:r.url}}catch(o){e=at(o)}throw new Error(e||"无法连接插件目录")}async function vr(){try{const e=await H.readFile(Zt(),"utf8"),r=JSON.parse(e);return Array.isArray(r.entries)?r:void 0}catch{return}}async function br(e,r){const o=Date.now();try{await H.mkdir(Yt(),{recursive:!0}),await H.writeFile(Zt(),JSON.stringify({fetchedAt:o,url:r,entries:e}),"utf8")}catch{}return o}const nt=Qt[0].url;async function yr(e,r){const o=await vr(),n=o!==void 0&&Date.now()-o.fetchedAt<gr;if(o&&n&&!r)return{entries:Ue(o.entries,e),source:"cache",registry:o.url??nt,fetchedAt:o.fetchedAt,error:""};try{const i=await fr(),s=await br(i.entries,i.url);return{entries:Ue(i.entries,e),source:"network",registry:i.url,fetchedAt:s,error:""}}catch(i){return o?{entries:Ue(o.entries,e),source:"cache",registry:o.url??nt,fetchedAt:o.fetchedAt,error:at(i)}:{entries:Ue(Xt.map(wr),e),source:"builtin",registry:nt,fetchedAt:0,error:at(i)}}}function wr(e){return{displayName:e.name,type:e.type,tagline:e.desc,description:e.long,repoUrl:e.repo,tags:e.tags}}function at(e){const r=e instanceof Error?e.message:String(e);return/fetch failed|network|ECONNRESET|ETIMEDOUT|ENOTFOUND|EAI_AGAIN|socket hang up/i.test(r)?"无法连接插件目录(网络受限或连接被重置),已改用本地缓存":/aborted|timeout/i.test(r)?"连接插件目录超时,已改用本地缓存":r}var kr=t.template("<div class=ph-detail-loading><span>正在读取 npm 上的 README 与统计…"),xr=t.template("<span class=ph-badge data-tone=accent>v"),st=t.template("<span class=ph-badge data-tone=success>已安装"),Sr=t.template("<span class=ph-badge data-tone=warning>可更新"),$r=t.template("<span class=ph-badge data-tone=danger>已废弃"),Cr=t.template("<div class=ph-detail-head><div class=ph-name-row></div><div class=ph-detail-desc>"),_r=t.template("<div class=ph-detail-stats><div class=ph-detail-stat><b></b><span>周下载</span></div><div class=ph-detail-stat><b></b><span>月下载</span></div><div class=ph-detail-stat><b></b><span>已发布版本</span></div><div class=ph-detail-stat><b></b><span>"),Ar=t.template("<div class=ph-warning><span>"),Or=t.template("<div class=ph-warning data-tone=danger><span>"),Tr=t.template("<span class=ph-chip>许可证 "),Ir=t.template("<span class=ph-chip>发布于 "),Lr=t.template("<span class=ph-chip>首次发布 "),Mr=t.template("<span class=ph-chip>维护者 "),jr=t.template("<div class=ph-detail-meta>"),Kt=t.template("<div class=ph-chips>"),zr=t.template("<div class=ph-detail-links>"),Pr=t.template("<details class=ph-details><summary>依赖 <!> 个</summary><div class=ph-chips>"),Er=t.template("<div class=ph-readme-note>README 较长,这里只显示前一部分。完整内容见 npm 页面。"),Br=t.template("<section class=ph-section><div class=ph-section-title>README"),Dr=t.template("<div class=ph-readme-empty>"),Nr=t.template("<div class=ph-detail>"),Ur=t.template("<span class=ph-detail-error>"),Gr=t.template("<div class=ph-dialog-footer><span class=ph-spacer>"),lt=t.template("<span class=ph-chip>"),Rr=t.template("<div class=ph-readme-empty>这个包没有附带 README。可以打开 npm 页面或项目主页进一步了解。"),Fr=t.template("<span class=ph-count>"),qr=t.template('<span class="ph-count ph-count-alert"> 可更新'),Hr=t.template("<button class=ph-tab>"),Vr=t.template("<span class=ph-version-arrow> → v"),Wr=t.template("<span class=ph-version>"),Jr=t.template("<span class=ph-pkg>"),rt=t.template("<span class=ph-badge data-tone=accent>可更新 → v"),Ie=t.template("<span class=ph-dot>"),Qr=t.template("<span>v"),Xr=t.template("<span>仅 GitHub 发布"),Yr=t.template("<span>"),Zr=t.template("<span class=ph-badge>需手动"),Kr=t.template('<article class=ph-card><div class=ph-card-main><div class=ph-card-head><div class=ph-tile></div><div class=ph-card-titles><div class=ph-name-row><span class=ph-name></span></div></div><div class=ph-chips></div></div><div class=ph-card-body role=button tabindex=0><div class="ph-desc ph-clamp"></div><div class=ph-meta><span class=ph-type></span></div></div></div><div class=ph-actions>'),eo=t.template("<span>by "),to=t.template("<span>更新"),no=t.template('<article class=ph-card><div class=ph-card-main><div class=ph-card-head><div class=ph-tile></div><div class=ph-card-titles><div class=ph-name-row><span class=ph-name></span></div><span class=ph-pkg>v</span></div><div class=ph-chips></div></div><div class=ph-card-body role=button tabindex=0><div class="ph-desc ph-clamp"></div><div class=ph-meta><span>/周</span><span class=ph-dot></span><span>/月</span></div></div></div><div class=ph-actions>'),ro=t.template("<span class=ph-badge data-tone=warning>未能检查"),oo=t.template("<span class=ph-badge>本地目录"),io=t.template("<span>更新会覆盖目录内容,原文件自动备份"),ao=t.template("<article class=ph-card><div class=ph-card-main><div class=ph-card-head><div class=ph-tile></div><div class=ph-card-titles><div class=ph-name-row><span class=ph-name></span></div><span class=ph-pkg></span></div><div class=ph-chips></div></div><div class=ph-card-body><div class=ph-meta></div></div></div><div class=ph-actions>"),so=t.template("<h2 class=ph-title>插件中心"),lo=t.template("<div class=ph-notice><span>"),co=t.template("<div class=ph-notice data-tone=error><span>"),ze=t.template("<div class=ph-list>"),po=t.template("<section class=ph-panel><div class=ph-filters><div class=ph-filter-row><div class=ph-grow></div><div class=ph-chips>"),uo=t.template("<div class=ph-empty><strong>搜索 npm 上的 OpenCode 插件</strong><span>按名称或用途搜索,例如 auth、notify、memory。点开任意结果可以看 README、下载量和主页。</span><div class=ph-chips>"),go=t.template("<div class=ph-resultbar><h3 class=ph-h3>搜索结果 <span class=ph-count></span></h3><div class=ph-sort>"),ho=t.template("<section class=ph-panel><div class=ph-searchbar><div class=ph-grow></div></div><div class=ph-meta><span>直查 npm 上带 opencode-plugin 标签的包,覆盖精选目录之外的长尾;结果未经人工筛选。"),mo=t.template("<span class=ph-meta>检查过 npm registry"),fo=t.template("<section class=ph-panel><div class=ph-resultbar><h3 class=ph-h3>已安装 <span class=ph-count></span></h3><div class=ph-chips><button class=ph-chip>可更新<span class=ph-chip-count></span></button></div><span class=ph-spacer>"),vo=t.template(`<div class=ph-root><style>
55
+ `;try{return De.spawn("/bin/sh",["-c",e],{detached:!0,stdio:"ignore"}).unref(),!0}catch{return!1}}async function vr(e){const r=await de();try{return e.length===0?{ok:!1,message:"找不到 opencode CLI",state:r}:(De.spawn(e[0],[...e.slice(1),"reload"],{detached:!0,stdio:"ignore"}).unref(),{ok:!0,message:"已请求重载配置;插件列表变化建议完全退出应用再打开",state:r})}catch(o){return{ok:!1,message:le(o),state:r}}}function le(e){return e instanceof Error?e.message:String(e)}const br=JSON.parse(`[{"name":"@aerovato/operator-memory","pkg":"","ver":"","type":"plugins","desc":"Durable context for agent-driven development","long":"Operator Memory gives the agent durable memory made of ordinary Markdown: specs, decisions, standards, and research, kept across private, shared, and user partitions. Every file is yours to read, correct, or remove, and new sessions start from that knowledge. No embeddings, no vector database, no ho","repo":"https://github.com/aerovato/operator-memory","tags":["memory","context","documentation","markdown"]},{"name":"Agent Memory","pkg":"opencode-agent-memory","ver":"0.3.1","type":"plugins","desc":"Letta-inspired memory","long":"Gives the agent persistent, self-editable memory blocks inspired by Letta agents.","repo":"https://github.com/joshuadavidthomas/opencode-agent-memory","tags":[]},{"name":"Agent Notifications","pkg":"","ver":"","type":"plugins","desc":"Desktop and webhook alerts for OpenCode sessions","long":"Desktop and optional webhook notifications for OpenCode root-session completion, questions, permissions, and errors on macOS, Linux, and Windows.","repo":"https://github.com/777genius/agent-notifications","tags":[]},{"name":"Agent Skills (JDT)","pkg":"opencode-agent-skills","ver":"0.7.0","type":"plugins","desc":"Dynamic skills loader","long":"Dynamic skills loader that discovers skills from project, user, and plugin directories.","repo":"https://github.com/joshuadavidthomas/opencode-agent-skills","tags":[]},{"name":"OpenCode Antigravity CLI Auth","pkg":"opencode-agy-auth","ver":"2.1.1","type":"plugins","desc":"Google Antigravity account auth","long":"Authenticate the Opencode CLI with your Google account so you can use your existing Antigravity plan.","repo":"https://github.com/anthonyhaussman/opencode-agy-auth","tags":[]},{"name":"AIDevOps","pkg":"aidevops","ver":"3.39.125","type":"plugins","desc":"AI DevOps framework and OpenCode plugin","long":"OpenCode-first AI DevOps framework with agents, skills, workflows, safety hooks, memory, GitHub worker dispatch, and integrations for code, infrastructure, content, SEO, and operations.","repo":"https://github.com/marcusquinn/aidevops","tags":[]},{"name":"Antigravity Auth","pkg":"opencode-antigravity-auth","ver":"2.1.2","type":"plugins","desc":"Google Antigravity models","long":"Use Gemini and Anthropic models for free via Google Antigravity IDE authentication.","repo":"https://github.com/NoeFabris/opencode-antigravity-auth","tags":[]},{"name":"basemind","pkg":"basemind","ver":"0.31.1","type":"plugins","desc":"Full AI context layer over MCP — code-map, document RAG, agent memory, web crawl, git history","long":"Full AI context layer over MCP — tree-sitter code-map, document RAG, shared agent memory, web crawl, and git history. 300+ languages. Published to npm as basemind-opencode (https://www.npmjs.com/package/basemind-opencode).","repo":"https://github.com/Goldziher/basemind","tags":[]},{"name":"Beads Plugin","pkg":"opencode-beads","ver":"0.9.0","type":"plugins","desc":"Beads issue tracker integration","long":"Integration for Steve Yegge's beads issue tracker with /bd-* commands.","repo":"https://github.com/joshuadavidthomas/opencode-beads","tags":[]},{"name":"BRHP","pkg":"","ver":"","type":"plugins","desc":"Persistent planning state","long":"Structured, persistent planning for OpenCode with local session state, /brhp commands, bounded planner history, and a TUI sidebar.","repo":"https://github.com/ZanzyTHEbar/brhp","tags":[]},{"name":"bro","pkg":"bro","ver":"1.0.7","type":"plugins","desc":"Re-explains the last reply in plain language","long":"One-file Agent Skill that re-explains the assistant's last reply (or pasted text) in plain language when it was too dense. The installer adds a \`/bro\` command for OpenCode (\`~/.config/opencode/skills/bro/SKILL.md\` plus a command wrapper); also works in Claude Code, Codex, Cursor and Hermes.","repo":"https://github.com/luchasarie/bro-skill","tags":[]},{"name":"cache-stats","pkg":"","ver":"","type":"plugins","desc":"Showing the active session's cache hit rate in a popup dialog","long":"This plugin shows the overall cache hit rate, a per-model breakdown, a per subagent breakdown and the associated cost, making it easy to understand cache performance at a glance.","repo":"https://github.com/nmdra/opencode-cache-stats","tags":[]},{"name":"Caspian","pkg":"caspian-opencode-plugin","ver":"0.1.7","type":"plugins","desc":"Give your OpenCode agent an inbox — email, Telegram, and Discord","long":"Official Caspian plugin for OpenCode. Gives the agent a bidirectional inbox — email, Telegram, and Discord — with slash commands, session threading back to Gmail, and desktop notifications. No Caspian account required; on first start the plugin mints a sandbox project and provisions an agent email. ","repo":"https://github.com/TryCaspian/caspian-sdk/tree/main/packages/opencode","tags":["email","telegram","discord","inbox","messaging","notifications"]},{"name":"CC Safety Net","pkg":"","ver":"","type":"plugins","desc":"Safety net catching destructive commands","long":"A Claude Code plugin that acts as a safety net, catching destructive git and filesystem commands before they execute.","repo":"https://github.com/kenryu42/claude-code-safety-net","tags":[]},{"name":"Chisle","pkg":"chisle","ver":"3.8.1","type":"plugins","desc":"Cuts token use with terse answers, smallest-code-that-works rules and tool-output compression","long":"Installs a ruleset for terse answers that keep every decisive fact and a \\"smallest code that works\\" ladder, Chisle skills, and a compression plugin that trims oversized tool output before it re-enters the context. The same ruleset ships for Claude Code, Cursor, Codex and Gemini CLI. Install with \`np","repo":"https://github.com/JayPokale/Chisle","tags":["tokens","cost","context","productivity"]},{"name":"Subagent Reporter","pkg":"","ver":"","type":"plugins","desc":"See exactly what your subagents are up to (in the terminal) when invoked during an \`opencode run _____\` session.","long":"When opencode run <prompt> is invoked normally, the actions of the primary agent are visible in the terminal, but subagent actions are not. This makes it difficult to follow progress on the prompt, and makes it very difficult to use \`opencode run\` as part of an unattended process or script. This plu","repo":"https://github.com/raisbecka/opencode-subagent-output","tags":[]},{"name":"codemem","pkg":"codemem","ver":"0.47.3","type":"plugins","desc":"Persistent coding memory across sessions, machines, and teammates","long":"Captures coding decisions, discoveries, and fixes, with automatic context injection in OpenCode, Claude Code, and Codex. Includes MCP tools for searching and managing memories, a viewer, optional cross-machine sync, and sharing of selected projects with teammates.","repo":"https://github.com/kunickiaj/codemem","tags":[]},{"name":"Command Inject","pkg":"opencode-command-inject","ver":"1.3.1","type":"plugins","desc":"Auto-inject project commands into OpenCode","long":"Automatically discovers and injects Makefile targets, npm/pnpm/yarn/bun scripts, and local skills at startup. Type / to see and run all project commands.","repo":"https://github.com/shihyuho/opencode-command-inject","tags":[]},{"name":"ContextStream","pkg":"mcp-server","ver":"0.0.9","type":"plugins","desc":"Shared project context for OpenCode, Cursor, Claude Code, Codex, and Grok via MCP","long":"Hosted MCP server that keeps coding agents on shared project context across sessions and teammates. Works with OpenCode and other MCP-compatible clients. Endpoint https://mcp.contextstream.io/mcp — Intelligence isn’t the bottleneck. Context is.","repo":"https://github.com/contextstream/mcp-server","tags":["mcp","context","productivity","collaboration"]},{"name":"deja","pkg":"opencode-deja","ver":"0.23.5","type":"plugins","desc":"Recall what you already did in your other coding agents","long":"opencode remembers its own sessions. deja answers the other question: what you did in Claude Code, Codex, Cursor, Gemini CLI, Zed and fifteen more agents on this machine — including the months before you installed anything.\\n\\nA local Go binary indexes the transcripts those agents already wrote to dis","repo":"https://github.com/vshulcz/deja-vu","tags":["memory","recall","search","cross-agent","session-history"]},{"name":"Ditto","pkg":"ditto","ver":"0.0.11","type":"plugins","desc":"Mines your local AI coding session logs into a personal profile your agent loads before every task","long":"Mines local AI coding session logs (OpenCode, Claude Code, Codex, Copilot CLI) into a personal working profile. The OpenCode adapter reads OpenCode's SQLite session store and installs the profile into OpenCode's global rules so the agent loads it before every task. Single stdlib-only Python file, ru","repo":"https://github.com/ohad6k/ditto","tags":[]},{"name":"Dodo Payments","pkg":"dodo-agent-plugin","ver":"0.0.1","type":"plugins","desc":"Payments, subscriptions, webhooks, and billing for OpenCode agents","long":"Official Dodo Payments plugin for OpenCode (also Claude Code, Codex, Cursor). Bundles eight integration skills (checkout, subscriptions, webhooks, usage-based billing, credits, license keys, BillingSDK, best practices) plus two MCP servers — a live API server with browser OAuth and a documentation s","repo":"https://github.com/dodopayments/dodo-agent-plugin","tags":[]},{"name":"Dynamic Context Pruning","pkg":"","ver":"","type":"plugins","desc":"Optimize token usage","long":"Plugin that optimises token usage by pruning obsolete tool outputs from conversation context.","repo":"https://github.com/Tarquinen/opencode-dynamic-context-pruning","tags":[]},{"name":"Envsitter Guard","pkg":"envsitter-guard","ver":"0.1.1","type":"plugins","desc":"Prevent .env leaks","long":"OpenCode plugin that prevents agents/tools from reading or editing sensitive .env* files, while still allowing safe inspection via EnvSitter (keys + deterministic fingerprints; never values).","repo":"https://github.com/boxpositron/envsitter-guard","tags":[]},{"name":"FlowDeck","pkg":"flowdeck","ver":"0.16.1","type":"plugins","desc":"AI-powered multi-agent workflow orchestration with built-in safety intelligence","long":"FlowDeck adds a structured, multi-agent development workflow to OpenCode. It coordinates 25 specialist agents through a four-phase cycle — discuss, plan, execute, review — with persistent state that survives session restarts.\\n\\nKey features:\\n- 25 specialist agents (architect, planner, coder, reviewer","repo":"https://github.com/DVNghiem/FlowDeck","tags":["workflow","orchestration","multi-agent","planning","security","TDD"]},{"name":"ForLoop Planner","pkg":"@forloop-cc/forloop-opencode-plugin-planner","ver":"2.2.25","type":"plugins","desc":"Autopilot development. Plan with ForLoop agent. Build, Test, Deploy on cloud in one go.","long":"ForLoop offers an all-in-one platform that covers the entire development lifecycle, from initial planning and coding to automated testing and cloud deployment.","repo":"https://github.com/forloop-cc/forloop-opencode-plugin-planner","tags":[]},{"name":"Froggy","pkg":"froggy","ver":"1.1.6","type":"plugins","desc":"Hooks and specialized agents","long":"Plugin providing Claude Code-style hooks, specialized agents, and tools like gitingest.","repo":"https://github.com/smartfrog/opencode-froggy","tags":[]},{"name":"Gemini Auth","pkg":"opencode-gemini-auth","ver":"2.0.1","type":"plugins","desc":"Google account auth","long":"Authenticate the Opencode CLI with your Google account so you can use your existing Gemini plan.","repo":"https://github.com/jenslys/opencode-gemini-auth","tags":[]},{"name":"Godmode","pkg":"godmode","ver":"0.0.3","type":"plugins","desc":"Discipline layer: measure → modify → verify → keep/revert","long":"Skill plugin with 135 skills and 7 subagents that adds a measure → modify → verify → keep/revert discipline loop to AI coding agents. Works with OpenCode alongside Claude Code, Codex, Cursor, and Gemini CLI.","repo":"https://github.com/arbazkhan971/godmode","tags":[]},{"name":"Handoff","pkg":"handoff","ver":"1.3.2","type":"plugins","desc":"Session handoff prompts","long":"Creates focused handoff prompts for continuing work in a new session.","repo":"https://github.com/joshuadavidthomas/opencode-handoff","tags":[]},{"name":"Honcho","pkg":"honcho","ver":"0.4.13","type":"plugins","desc":"AI-native long-term memory for OpenCode","long":"Give OpenCode persistent memory that survives context wipes, session restarts, and fresh chats. Honcho remembers what you're working on, durable preferences, and prior context across projects. Supports cloud and self-hosted deployments with configurable session strategies.","repo":"https://github.com/plastic-labs/opencode-honcho","tags":[]},{"name":"Internet Court","pkg":"","ver":"","type":"plugins","desc":"Trust layer for agent-to-agent commerce: mandates, payments, escrow, dispute resolution.","long":"The trust layer for agent-to-agent commerce — natural-language mandates, delegated permissions, x402 payments, escrow, and dispute resolution as one open, catch-all skill. By the Internet Court Consortium (internetcourt.org). MIT licensed.","repo":"https://github.com/internet-court/internet-court-skill","tags":["agent-payments","x402","erc-7710","erc-8004","escrow","genlayer"]},{"name":"kibi-opencode","pkg":"kibi-opencode","ver":"3.2.0","type":"plugins","desc":"Repo-local, branch-scoped knowledge and traceability for OpenCode","long":"Plugin-first entry point into the Kibi stack for OpenCode users. It adds context-aware\\nguidance, routes durable code comments toward Kibi artifacts, runs non-blocking background\\nsync and targeted validation checks, and helps keep repo knowledge branch-local and queryable.","repo":"https://github.com/Looted/kibi","tags":["opencode","plugin","mcp","traceability"]},{"name":"Kilo Gateway Auth","pkg":"opencode-kilo-auth","ver":"1.1.4","type":"plugins","desc":"Kilo Gateway provider","long":"Adds Kilo Gateway provider support to OpenCode.","repo":"https://github.com/JungHoonGhae/opencode-kilo-auth","tags":[]},{"name":"Lemma","pkg":"lemma","ver":"0.10.2","type":"plugins","desc":"Persistent memory layer for LLMs via MCP - local, zero-dependency, works on all clients","long":"Biological memory model for AI coding agents. Features confidence decay/boost, Fuse.js fuzzy dedup, guide system with usage tracking, cross-references, cumulative backup, virtual session tracking, and universal memory injection via tool descriptions (works on Claude Desktop, Cursor, VS Code, Gemini ","repo":"https://github.com/xenitV1/lemma","tags":["memory","mcp","persistence","context","claude","cursor"]},{"name":"opencode-llm-proxy","pkg":"opencode-llm-proxy","ver":"1.11.2","type":"plugins","desc":"OpenCode-backed API gateway with tool calling","long":"Local OpenCode plugin that exposes OpenAI Chat Completions, OpenAI Responses, Anthropic Messages, and Gemini-compatible endpoints for any model configured in OpenCode. Supports streaming, model listing, and real tool/function calling including parallel tool calls, so tools like n8n, Open WebUI, Lang","repo":"https://github.com/KochC/opencode-llm-proxy","tags":["openai","anthropic","gemini","responses-api","llm-gateway","tool-calling"]},{"name":"Magic Context","pkg":"@cortexkit/opencode-magic-context","ver":"0.49.35","type":"plugins","desc":"Lossless context management with background compression","long":"Cache-aware context management that keeps long sessions productive. Background historian compresses old conversation into structured compartments while you keep working. Includes cross-session project memory, unified search across history/memories/facts, overnight dreamer for memory maintenance, and","repo":"https://github.com/cortexkit/opencode-magic-context","tags":[]},{"name":"Mem0 OpenCode Plugin","pkg":"","ver":"","type":"plugins","desc":"Persistent memory plugin so your agent remembers across sessions","long":"OpenCode plugin that gives your agent persistent memory powered by Mem0. Includes 9 MCP memory tools, 16 slash commands, and lifecycle hooks that auto-capture decisions, search prior context at session start, and pre-fetch error memories on failures. Install with \`opencode plugin @mem0/opencode-plug","repo":"https://github.com/mem0ai/mem0","tags":[]},{"name":"Micode","pkg":"micode","ver":"0.11.0","type":"plugins","desc":"Brainstorm-Plan-Implement workflow","long":"Structured workflow with session continuity, subagent orchestration, git worktree isolation, and AST-aware tools.","repo":"https://github.com/vtemian/micode","tags":[]},{"name":"Morph Fast Apply","pkg":"","ver":"","type":"plugins","desc":"10,500+ tokens/sec code editing","long":"Integrates Morph's Fast Apply API for faster code editing with lazy edit markers and unified diff output.","repo":"https://github.com/JRedeker/opencode-morph-fast-apply","tags":[]},{"name":"Neuralyzer","pkg":"neuralyzer","ver":"1.1.5","type":"plugins","desc":"Easier Ralph loop inside harness","long":"Allow agent to wipe its own session context and re-run the first message. This allows easier and more ergonomic Ralph loop engineering.","repo":"https://github.com/gintasz/neuralyzer","tags":[]},{"name":"Oh My Cassette","pkg":"","ver":"","type":"plugins","desc":"Chat your raw clips into a finished cut","long":"Adds a local stdio MCP server that turns a chat message into an edited video: beat-synced cuts, auto-matched background music, subtitles, transitions, and picture-in-picture. Ingest local clips, then drive a persistent multi-turn editing thread — every turn returns a timeline delta and a contact-she","repo":"https://github.com/Cassette-Editor/oh-my-cassette","tags":["mcp","video","video-editing","media"]},{"name":"Oh My Opencode","pkg":"oh-my-opencode","ver":"5.1.60","type":"plugins","desc":"Agents & Pre-built tools","long":"Background agents, pre-built tools (LSP/AST/MCP), curated agents, and a Claude Code compatible layer.","repo":"https://github.com/code-yeongyu/oh-my-opencode","tags":[]},{"name":"Oh My Opencode Slim","pkg":"oh-my-opencode-slim","ver":"3.0.7","type":"plugins","desc":"Lightweight agent orchestration with reduced token usage","long":"Slimmed-down fork of oh-my-opencode focused on core agent orchestration. Features specialized sub-agents (Explorer, Oracle, Librarian, Designer, etc.), background task management, LSP/AST tools, tmux integration for live agent visibility, and MCP servers. Optimized to consume significantly fewer tok","repo":"https://github.com/alvinunreal/oh-my-opencode-slim","tags":["agents","orchestration","background-tasks","lsp","mcp"]},{"name":"open-plan-annotator","pkg":"open-plan-annotator","ver":"1.13.2","type":"plugins","desc":"Annotate LLM plans like a Google Doc!","long":"A fully local agentic coding plugin that intercepts plan mode and opens an annotation UI in your browser. Select text to strikethrough, replace, insert, or comment — then approve the plan or request changes","repo":"https://github.com/ndom91/open-plan-annotator","tags":[]},{"name":"Opencode Agents Sidebar","pkg":"opencode-agents-sidebar","ver":"3.1.0","type":"plugins","desc":"Browse configured OhMyOpenAgent agents in the TUI","long":"OpenCode sidebar plugin that displays configured OhMyOpenAgent agents with lifecycle-based categories, collapsible sections, descriptions, and model information.","repo":"https://github.com/Mark1708/opencode-agents-sidebar","tags":[]},{"name":"Boffin","pkg":"","ver":"","type":"plugins","desc":"Routed architectural guardrails for AI coding agents in OpenCode","long":"Staff-engineer layer for AI coding agents: routes per-edit architectural constraints and requires verification. Not another AGENTS.md.","repo":"https://github.com/MicSm/boffin","tags":["opencode","architecture","guardrails","code-review","cplusplus","python"]},{"name":"OpenCode Claude Code Plugin","pkg":"opencode-claude-code-plugin","ver":"0.1.2","type":"plugins","desc":"Claude models through the official Claude Code CLI, using the login you already have","long":"Runs Anthropic's Claude models in opencode through the official claude CLI as a subprocess, so opencode uses whatever the CLI is logged in as and no token is ever read or replayed. Bash, Edit and Write are proxied back to opencode's own permissions, with several accounts, per-subagent models, and on","repo":"https://github.com/khalilgharbaoui/opencode-claude-code-plugin","tags":[]},{"name":"OpenCode Claude Memory","pkg":"opencode-claude-memory","ver":"2.3.0","type":"plugins","desc":"Claude Code-compatible memory","long":"Share persistent Markdown memory between OpenCode and Claude Code using Claude Code-compatible paths and file formats.","repo":"https://github.com/kuitos/opencode-claude-memory","tags":[]},{"name":"Opencode CMD Provider","pkg":"opencode-cmd-provider","ver":"2.3.4","type":"plugins","desc":"Use CommandCode plans (Go, GOAT, Pro, Max) as an OpenCode provider.","long":"OpenCode provider plugin for the CommandCode Provider API. Authenticate via\\n/connect browser flow or COMMANDCODE_API_KEY, auto-registers all CommandCode\\nmodels ([CMD] prefix) with offline snapshot, pricing display, and per-plan\\ndeals/allowance intelligence in the sidebar and cmd_plan_summary tool.","repo":"https://github.com/rashidrazak/opencode-cmd-provider","tags":["provider","commandcode","model-discovery","auth"]},{"name":"Cursor Auth","pkg":"opencode-cursor","ver":"0.0.1","type":"plugins","desc":"Use your Cursor subscription models in OpenCode via OAuth","long":"Connects Cursor's API to OpenCode via OAuth login, automatic model discovery, and a local OpenAI-compatible proxy — use the models included in your Cursor subscription directly from OpenCode.","repo":"https://github.com/ephraimduncan/opencode-cursor","tags":[]},{"name":"opencode-dir-tree-tui","pkg":"opencode-dir-tree-tui","ver":"1.0.6","type":"plugins","desc":"File tree sidebar with Git status and quick file actions","long":"Browse project files in the OpenCode V2 sidebar with Git status indicators, custom ignore rules, path copying, and quick file and folder opening.","repo":"https://github.com/aihaipeng/opencode-dir-tree-tui","tags":[]},{"name":"OpenCode Ensemble","pkg":"@hueyexe/opencode-ensemble","ver":"0.20.0","type":"plugins","desc":"Parallel agent teams for OpenCode","long":"Coordinate parallel OpenCode agents with peer messaging, a shared task board, git worktree isolation, and a live dashboard.","repo":"https://github.com/hueyexe/opencode-ensemble","tags":["agents","multi-agent","orchestration","worktrees","dashboard"]},{"name":"opencode-failover","pkg":"opencode-failover","ver":"2.0.7","type":"plugins","desc":"Automatic API-key failover and rotation across multiple provider keys","long":"OpenCode plugin that automatically rotates API keys across multiple provider credentials. When a key hits a rate limit, the plugin quarantines it and switches to the next available key with zero downtime. Features weighted round-robin distribution, exponential backoff quarantine, retry-after header ","repo":"https://github.com/bulutmuf/opencode-failover","tags":[]},{"name":"GitHub Release","pkg":"opencode-github-release","ver":"0.6.0","type":"plugins","desc":"Automated GitHub releases","long":"Create and publish GitHub releases with semantic versioning, tag management, and auto-generated release notes.","repo":"https://github.com/amestsantim/opencode-github-release","tags":[]},{"name":"GoopSpec","pkg":"goopspec","ver":"0.2.9","type":"plugins","desc":"Spec-driven development workflow","long":"Transforms AI-assisted coding with spec-driven workflows. Features 5-phase workflow (Plan, Research, Specify, Execute, Accept), contract gates for user confirmation, 12 specialized subagents, persistent memory system, wave-based execution with atomic commits, and deviation rules for handling unexpec","repo":"https://github.com/hffmnnj/opencode-goopspec","tags":[]},{"name":"GPT Imagegen","pkg":"opencode-gpt-imagegen","ver":"1.2.2","type":"plugins","desc":"gpt-image-2 in OpenCode — no API cost when using your ChatGPT subscription","long":"Brings gpt-image-2 (ChatGPT Images 2) image generation to OpenCode. When you sign into OpenCode with your ChatGPT account, generations are billed against your existing Plus / Pro / Business plan — no per-image API cost. An OpenAI API key path is also planned. Supports reference images for style guid","repo":"https://github.com/yuji-hatakeyama/opencode-gpt-imagegen","tags":["openai","gpt-image-2","gpt-image","image-generation","image-editing","text-to-image"]},{"name":"Opencode LiteLLM","pkg":"opencode-litellm","ver":"0.1.0","type":"plugins","desc":"Auto-discover models from a LiteLLM proxy","long":"Drop-in LiteLLM provider for OpenCode with zero configuration. Auto-detects a running\\nLiteLLM proxy on common ports (4000, 8000, 8080), pulls every model from /v1/models,\\nand registers them in OpenCode automatically — no model lists to hand-maintain. Smart\\nname formatting, modality categorization (c","repo":"https://github.com/yuseferi/opencode-litellm","tags":["litellm","provider","openai-compatible","llm-proxy","model-discovery"]},{"name":"Opencode Mem","pkg":"opencode-mem","ver":"2.41.0","type":"plugins","desc":"Persistent memory with vector database","long":"A persistent memory system for AI coding agents that enables long-term context retention across sessions using local vector database technology. Features dual memory scopes, web interface, auto-capture system, and multi-provider AI support.","repo":"https://github.com/tickernelz/opencode-mem","tags":[]},{"name":"OpenCode Mission Control","pkg":"opencode-mission-control","ver":"1.6.0","type":"plugins","desc":"Command center for parallel agents — worktree isolation, DAG plans, merge train, PRs","long":"Orchestrates parallel OpenCode agents in tmux-isolated git worktrees with live inspection (capture/attach/diff), a dashboard overview, agent status reporting, and in-chat notifications. Supports DAG-based plans with autopilot/copilot/supervisor modes and a merge train with test gating and automatic ","repo":"https://github.com/nigel-dev/opencode-mission-control","tags":[]},{"name":"Opencode Models Discovery","pkg":"opencode-models-discovery","ver":"2.1.1","type":"plugins","desc":"Configurable model discovery and filtering without long manual config","long":"OpenCode plugin for discovering models from OpenAI-compatible providers and API gateways, with provider and model filtering so users can avoid maintaining large configs or loading every model at once.","repo":"https://github.com/yuhp/opencode-models-discovery","tags":[]},{"name":"OpenCode ntfy.sh","pkg":"opencode-ntfy.sh","ver":"1.1.0","type":"plugins","desc":"Push notifications to keep you in the know, even when you're on the go.","long":"An OpenCode plugin that adds push notifications through ntfy.sh.","repo":"https://github.com/lannuttia/opencode-ntfy.sh","tags":[]},{"name":"OpenAI Native Compaction","pkg":"opencode-openai-compact","ver":"1.4.0","type":"plugins","desc":"Use OpenAI's official Responses API compaction in OpenCode","long":"Routes OpenCode session compaction for OpenAI providers through \`/responses/compact\`, stores the returned compacted output locally, and injects it into the next Responses request so long sessions use OpenAI's native compaction instead of a prompt-written summary.","repo":"https://github.com/partment/opencode-openai-compact","tags":[]},{"name":"OpenWork for OpenCode","pkg":"","ver":"","type":"plugins","desc":"Official OpenWork plugin to deploy AI models, skills, and MCPs to your team's OpenCode","long":"The official plugin from OpenWork. Centrally deploy AI models, skills, and MCP servers to your whole team. Admins add a model provider, skill, or MCP connection once and choose who gets it; everyone receives it in OpenCode after a single sign-in. No shared API keys, no copying MCP configs between ma","repo":"https://github.com/different-ai/openwork/tree/dev/packages/opencode-plugin","tags":[]},{"name":"opencode-plugin-otel","pkg":"@devtheops/opencode-plugin-otel","ver":"2.0.1","type":"plugins","desc":"OpenTelemetry telemetry exporter for opencode sessions, mirroring Claude Code monitoring signals","long":"Exports metrics, logs, and traces from opencode sessions via OTLP/gRPC to any OpenTelemetry-compatible backend (Datadog, Honeycomb, Grafana Cloud, etc.). Instruments session lifecycle, token usage, cost, tool durations, and git commits — mirroring the same signals as Claude Code's monitoring.","repo":"https://github.com/DEVtheOPS/opencode-plugin-otel","tags":[]},{"name":"OpenCode Pollinations Plugin","pkg":"opencode-pollinations-plugin","ver":"6.5.5","type":"plugins","desc":"Full Pollinations.ai integration — free unlimited AI models, 17+ multimodal tools, hourly free tiers & Safety Net.","long":"The ultimate bridge between OpenCode and the Pollinations.ai ecosystem. Access 30+ free and enterprise AI models (OpenAI, Gemini, Mistral, Claude...) with hourly Pollen resets. Includes 17+ agent tools (image, video, audio, music generation, background removal, web search, transcription, QR codes, d","repo":"https://github.com/fkom13/opencode-pollinations-plugin","tags":[]},{"name":"PR Auto-Signature","pkg":"opencode-pr-signature","ver":"1.2.2","type":"plugins","desc":"Automatically adds AI model signature to PRs, Issues, and Commits","long":"Plugin that automatically appends AI model signature to Pull Requests, Issues, and git commit messages. Supports GitHub MCP tools, git CLI, and gh CLI. Recognizes 90+ AI models including Claude, GPT, Gemini, DeepSeek, Llama, Mistral, and more.","repo":"https://github.com/arttttt/opencode-pr-signature","tags":[]},{"name":"Opencode Quota","pkg":"opencode-quota","ver":"0.0.1-dev","type":"plugins","desc":"Quota toasts and token tracking","long":"Track quota and token usage across providers via automatic toasts and slash commands.","repo":"https://github.com/slkiser/opencode-quota","tags":[]},{"name":"OpenCodeRAG","pkg":"","ver":"","type":"plugins","desc":"Local-first RAG plugin for semantic code search with tree-sitter chunking and LanceDB","long":"A local-first Retrieval-Augmented Generation plugin for OpenCode that enables semantic code\\nsearch across your workspace. Features AST-aware chunking via tree-sitter (19 languages),\\nincremental indexing with file-change detection, watch mode for live re-indexing, and\\nconfigurable embeddings via Olla","repo":"https://github.com/MrDoe/OpenCodeRAG","tags":[]},{"name":"opencode-review","pkg":"","ver":"","type":"plugins","desc":"Automatic structured code review with configurable dimensions and auto-fix","long":"An automatic code review plugin for OpenCode CLI. Reviews staged changes when session goes idle, with configurable cooldown, multi-dimension analysis (code quality, security, performance, testing, documentation), severity levels, and auto-fix chain support.","repo":"https://github.com/sun-praise/opencode-review","tags":[]},{"name":"opencode-short-term-memory","pkg":"","ver":"","type":"plugins","desc":"Maintain user instructions and preferences throughout long sessions. No more repeating yourself.","long":"Automatically summarizes conversation context into structured session memory and injects it back into the system prompt every few turns — preserving user instructions, project context, decisions, and active references across long chats and compactions.","repo":"https://github.com/andrejtonev/opencode-short-term-memory","tags":[]},{"name":"opencode-skills-tui","pkg":"opencode-skills-tui","ver":"1.2.3","type":"plugins","desc":"Browse skills, track loaded state, and preview SKILL.md","long":"OpenCode V2 skills sidebar with loaded-state tracking, SKILL.md previews, token estimates, and skill mentions in prompts.","repo":"https://github.com/aihaipeng/opencode-skills-tui","tags":[]},{"name":"opencode-snip","pkg":"opencode-snip","ver":"3.0.0","type":"plugins","desc":"OpenCode plugin that prefixes shell commands with snip to reduce LLM token consumption by 60-90%","long":"Automatically prefixes supported shell commands (git, go, cargo, npm, docker, etc.) with snip to filter output before it reaches your LLM context window.","repo":"https://github.com/VincentHardouin/opencode-snip","tags":[]},{"name":"Opencode Snippets","pkg":"opencode-snippets","ver":"3.4.0","type":"plugins","desc":"Instant inline text expansion","long":"Instant inline text expansion for OpenCode. Type #snippet anywhere in your message and watch it transform. Brings DRY principles to prompt engineering with composable, shell-enabled snippets.","repo":"https://github.com/JosXa/opencode-snippets","tags":[]},{"name":"OpenCode Swarm","pkg":"opencode-swarm","ver":"7.201.2","type":"plugins","desc":"Verification-gated swarm with architect, review, test, and security agents","long":"Verification-gated OpenCode swarm with architect planning, independent review, test engineering, security checks, and resumable evidence.","repo":"https://github.com/zaxbysauce/opencode-swarm","tags":[]},{"name":"Opencode Synced","pkg":"opencode-synced","ver":"0.11.0","type":"plugins","desc":"Sync configs across machines","long":"Enables syncing global opencode configurations across machines with public/private visibility options.","repo":"https://github.com/iHildy/opencode-synced","tags":[]},{"name":"System Prompt Logger","pkg":"opencode-system-prompt-logger","ver":"1.0.0","type":"plugins","desc":"System prompt logger","long":"OpenCode plugin that intercepts the system prompt before it's sent to the LLM and logs it.","repo":"https://github.com/tlinhart/opencode-system-prompt-logger","tags":[]},{"name":"Opencode Telemetry","pkg":"opencode-telemetry","ver":"0.3.4","type":"plugins","desc":"Passive cross-session telemetry to local SQLite; cost rollups across agent orchestration chains","long":"Logs every opencode session to a local SQLite database automatically — tokens, tool calls, skills, per-turn cost. Aggregates costs across orchestration chains (conductor + child sessions), offers turn-by-turn forensic inspection, and ships an \`octm\` CLI for reports without spending model tokens. Zer","repo":"https://github.com/agostinilabsrl/opencode-telemetry","tags":["telemetry","observability","cost-tracking","sqlite","local-first","orchestration"]},{"name":"Opencode update notifier","pkg":"opencode-update-notifier","ver":"0.4.0","type":"plugins","desc":"Notify about plugin updates.","long":"Checks if your pinned plugins have newer versions available and shows a notification.","repo":"https://github.com/tim-hilde/opencode-update-notifier","tags":[]},{"name":"Opencode Usage Monitor","pkg":"opencode-usage-monitor","ver":"3.1.0","type":"plugins","desc":"Monitor OpenAI and Z.AI usage quotas in the TUI","long":"OpenCode sidebar plugin that displays API usage quotas for OpenAI and Z.AI providers with per-model breakdowns, spend tracking, and configurable refresh controls.","repo":"https://github.com/Mark1708/opencode-usage-monitor","tags":[]},{"name":"Opencode Visualizer","pkg":"","ver":"","type":"plugins","desc":"2D pixel-art office for AI agents","long":"Turning raw OpenCode terminal logs into cozy 2D pixel office chaos. Watch your agents work, idle, and celebrate success in a bustling virtual office.","repo":"https://github.com/psinetron/opencode-visualiser","tags":[]},{"name":"OrgX OpenCode Plugin","pkg":"@useorgx/orgx-opencode-plugin","ver":"0.1.0-alpha.7","type":"plugins","desc":"OrgX Work Graph peer for task dispatch, receipts, deviations, and passive reconciliation","long":"OrgX OpenCode Plugin connects OpenCode sessions to the OrgX execution control plane. It receives OrgX task dispatches, drives the user's local OpenCode session, posts execution receipts and deviations back to OrgX, and writes compact Work Graph events for later audit-first reconciliation.","repo":"https://github.com/useorgx/orgx-opencode-plugin","tags":["agent-orchestration","work-graph","task-dispatch","receipts","mcp"]},{"name":"Plannotator","pkg":"","ver":"","type":"plugins","desc":"Interactive plan review UI","long":"Plan review UI with visual annotation, private/offline sharing, and Obsidian/Bear integration.","repo":"https://github.com/backnotprop/plannotator","tags":[]},{"name":"Rehydra","pkg":"rehydra","ver":"0.16.5","type":"plugins","desc":"Prevent your coding agent from leaking secrets to LLM providers","long":"Intercepts the conversation between OpenCode and the LLM, replacing secrets from .env files and detected API keys, tokens, and credentials with placeholders before they leave your machine. Secrets are transparently restored before any tool executes locally. Supports pattern-based detection for Strip","repo":"https://github.com/rehydra-ai/rehydra-sdk","tags":[]},{"name":"Ring a Bell Example","pkg":"","ver":"","type":"plugins","desc":"Simple terminal bell plugin","long":"A simple plugin to ring the terminal bell once a request is complete.","repo":"https://gist.github.com/ahosker/267f375a65378bcb9a867fd9a195db1e","tags":[]},{"name":"Simple Memory","pkg":"","ver":"","type":"plugins","desc":"Git-based memory","long":"Simple plugin to manage memory inside a git repo that can be committed and reviewed by team members.","repo":"https://github.com/cnicolov/opencode-plugin-simple-memory","tags":[]},{"name":"SonarQube","pkg":"sonarqube","ver":"0.0.1","type":"plugins","desc":"Automatically enforce SonarQube code quality and security in the agent coding loop","long":"SonarQube is the AI code quality and security verification platform used by millions of developers to catch bugs, vulnerabilities, and leaked secrets. This plugin enforces those standards in the agent coding loop: 7,500+ distinct issue types, secrets scanning, agentic analysis, and quality gates acr","repo":"https://github.com/SonarSource/sonarqube-agent-plugins","tags":["sonarqube","code-quality","static-analysis","security","secrets"]},{"name":"Superpowers","pkg":"superpowers","ver":"0.0.2","type":"plugins","desc":"Complete software development methodology with composable skills for coding agents","long":"Gives your coding agent a structured methodology - brainstorm specs, write plans, run TDD, dispatch subagents, and review work. Skills trigger automatically across Claude Code, OpenCode, Codex, Gemini CLI, Cursor, and GitHub Copilot CLI.","repo":"https://github.com/obra/superpowers","tags":[]},{"name":"Systematic","pkg":"systematic","ver":"3.1.1","type":"plugins","desc":"Compound-engineering workflows for OpenCode, Pi, and Claude Code","long":"Provides brainstorm, plan, work, and review workflows as bundled skills and agents for OpenCode, Pi, and Claude Code.","repo":"https://github.com/marcusrbrown/systematic","tags":[]},{"name":"@telemetry-dev/opencode","pkg":"@telemetry-dev/opencode","ver":"0.2.4","type":"plugins","desc":"OpenTelemetry traces for OpenCode agent turns, model calls, and tools","long":"Records OpenCode agent turns, model calls, tool executions, and session events with OpenTelemetry for telemetry.dev. Available as the @telemetry-dev/opencode npm package; source and setup instructions are in packages/opencode of the linked SDK repository.","repo":"https://github.com/telemetry-dev/telemetry","tags":[]},{"name":"toon-config","pkg":"toon-config","ver":"1.0.2","type":"plugins","desc":"Loads TOON based, AGENTS.toon rather than Markdown","long":"Use TOON based agent instructions. Command to analyize and improve agent instructions.","repo":"https://github.com/mmynsted/opencode-toon-config-plugin","tags":[]},{"name":"TypeUI","pkg":"","ver":"","type":"plugins","desc":"Design systems, UI prompts, and layout variation guidance","long":"Open-source design layer for OpenCode that provides curated design skills, UI prompts, and layout variation guidance so agents can generate more consistent interfaces. Includes an <a href=\\"https://www.typeui.sh/docs/guides/opencode\\">OpenCode setup guide</a>.","repo":"https://github.com/bergside/typeui","tags":[]},{"name":"ul-opencode-event","pkg":"@ulthon/ul-opencode-event","ver":"0.1.58","type":"plugins","desc":"Multi-channel notifications (SMTP, DingTalk, Feishu) and token usage analytics","long":"Get notified when OpenCode sessions complete, error, or need your attention - via SMTP email, DingTalk robot, or Feishu robot.\\n- Multi-channel: SMTP, DingTalk, Feishu, local JSONL file\\n- Multi-level token analytics: message / session / total / project scopes\\n- 74+ template variables with i18n suppor","repo":"https://gitee.com/ulthon/ul-opencode-event","tags":["notifications","email","dingtalk","feishu","token-tracking","usage-analytics"]},{"name":"UNMOJI","pkg":"@bastiangx/opencode-unmoji","ver":"1.0.0","type":"plugins","desc":"Strip emojis from output","long":"A simple plugin that strips ALL emojis from agent outputs in Opencode.","repo":"https://codeberg.org/bastiangx/opencode-unmoji","tags":[]},{"name":"WakaTime","pkg":"wakatime","ver":"1.2.0","type":"plugins","desc":"WakaTime integration","long":"WakaTime integration plugin for tracking coding activity in opencode sessions.","repo":"https://github.com/angristan/opencode-wakatime","tags":[]},{"name":"Xquik","pkg":"x-twitter-scraper","ver":"0.20.0","type":"plugins","desc":"X/Twitter data skill & MCP server","long":"X/Twitter data skill — MCP server, REST API, 20 extraction tools. Works with Claude Code, Cursor, Codex, and 40+ agents.","repo":"https://github.com/Xquik-dev/x-twitter-scraper","tags":[]},{"name":"OpenCode Light Themes","pkg":"","ver":"","type":"themes","desc":"A curated collection of 21 light color themes for OpenCode","long":"The largest collection of light themes for OpenCode. Includes 21 carefully crafted light themes converted from popular VS Code themes — scaefy-light (Atom One Light), Solarized Light, Vivid Light, Coffee Cream, GitHub Light, Quiet Light, Bluloco Light, Brackets Light Pro, NetBeans Light, Ysgrifennwr","repo":"https://github.com/fatihtoprakk/opencode-light-themes","tags":[]}]`),en=[{url:"https://raw.githubusercontent.com/awesome-opencode/awesome-opencode/main/dist/registry.json"},{url:"https://api.github.com/repos/awesome-opencode/awesome-opencode/contents/dist/registry.json?ref=main",accept:"application/vnd.github.raw+json"},{url:"https://raw.githubusercontent.com/Gracdjd/awesome-opencode/main/dist/registry.json"},{url:"https://api.github.com/repos/Gracdjd/awesome-opencode/contents/dist/registry.json?ref=main",accept:"application/vnd.github.raw+json"}],yr=720*60*1e3,tn=br;function nn(){const e=process.env.XDG_CACHE_HOME;return e?U.join(e,"opencode","plugin-hub"):U.join(Ie.homedir(),".cache","opencode","plugin-hub")}function rn(){return U.join(nn(),"registry.json")}const wr=/"plugin"\s*:\s*\[\s*"([^"]+)"/,Nt=/^(@[a-z0-9][\w.-]*\/)?[a-z0-9][\w.-]*$/i;function Ut(e){const r=wr.exec(e.installation??"");if(r?.[1])return r[1];const o=(e.displayName??"").trim();if(Nt.test(o)&&!o.includes(" "))return o;const i=(e.repoUrl??"").replace(/\/+$/,"").split("/").pop()?.replace(".git","")??"";return Nt.test(i)?i:""}const Je=new Map;for(const e of tn)Je.set(e.repo,e),e.pkg&&Je.set(`pkg:${e.pkg}`,e);function kr(e){return e.replace(/\/+$/,"").replace(/\.git$/,"")}function qe(e,r){const o=[],n=new Set;for(const i of e){const s=i.type??"plugins";if(s!=="plugins"&&s!=="mcp"&&s!=="themes")continue;const c=kr(i.repoUrl??"");if(!c||n.has(c))continue;n.add(c);const p=Je.get(c)??Je.get(`pkg:${Ut(i)}`),u=p?.pkg??Ut(i);o.push({name:i.displayName??u??c,pkg:u,version:p?.ver??"",type:s,desc:(i.tagline??"").trim(),long:(i.description??"").trim().slice(0,300),repo:c,tags:(i.tags??[]).slice(0,6),installed:u?r.has(u):!1})}return o}async function xr(){let e="";for(const r of en)try{const o={accept:r.accept??"application/json"},n=await fetch(r.url,{signal:AbortSignal.timeout(12e3),headers:o});if(!n.ok){e=`${new URL(r.url).host} 返回 ${n.status}`;continue}const i=await n.json();if(!Array.isArray(i)){e="registry 格式不是数组";continue}return{entries:i,url:r.url}}catch(o){e=dt(o)}throw new Error(e||"无法连接插件目录")}async function Sr(){try{const e=await V.readFile(rn(),"utf8"),r=JSON.parse(e);return Array.isArray(r.entries)?r:void 0}catch{return}}async function $r(e,r){const o=Date.now();try{await V.mkdir(nn(),{recursive:!0}),await V.writeFile(rn(),JSON.stringify({fetchedAt:o,url:r,entries:e}),"utf8")}catch{}return o}const st=en[0].url;async function Cr(e,r){const o=await Sr(),n=o!==void 0&&Date.now()-o.fetchedAt<yr;if(o&&n&&!r)return{entries:qe(o.entries,e),source:"cache",registry:o.url??st,fetchedAt:o.fetchedAt,error:""};try{const i=await xr(),s=await $r(i.entries,i.url);return{entries:qe(i.entries,e),source:"network",registry:i.url,fetchedAt:s,error:""}}catch(i){return o?{entries:qe(o.entries,e),source:"cache",registry:o.url??st,fetchedAt:o.fetchedAt,error:dt(i)}:{entries:qe(tn.map(_r),e),source:"builtin",registry:st,fetchedAt:0,error:dt(i)}}}function _r(e){return{displayName:e.name,type:e.type,tagline:e.desc,description:e.long,repoUrl:e.repo,tags:e.tags}}function dt(e){const r=e instanceof Error?e.message:String(e);return/fetch failed|network|ECONNRESET|ETIMEDOUT|ENOTFOUND|EAI_AGAIN|socket hang up/i.test(r)?"无法连接插件目录(网络受限或连接被重置),已改用本地缓存":/aborted|timeout/i.test(r)?"连接插件目录超时,已改用本地缓存":r}var Or=t.template("<div class=ph-detail-loading><span>正在读取 npm 上的 README 与统计…"),Ar=t.template("<span class=ph-badge data-tone=accent>v"),ut=t.template("<span class=ph-badge data-tone=success>已安装"),Tr=t.template("<span class=ph-badge data-tone=warning>可更新"),Ir=t.template("<span class=ph-badge data-tone=danger>已废弃"),Lr=t.template("<div class=ph-detail-head><div class=ph-name-row></div><div class=ph-detail-desc>"),Mr=t.template("<div class=ph-detail-stats><div class=ph-detail-stat><b></b><span>周下载</span></div><div class=ph-detail-stat><b></b><span>月下载</span></div><div class=ph-detail-stat><b></b><span>已发布版本</span></div><div class=ph-detail-stat><b></b><span>"),jr=t.template("<div class=ph-warning><span>"),zr=t.template("<div class=ph-warning data-tone=danger><span>"),Pr=t.template("<span class=ph-chip>许可证 "),Er=t.template("<span class=ph-chip>发布于 "),Br=t.template("<span class=ph-chip>首次发布 "),Dr=t.template("<span class=ph-chip>维护者 "),Nr=t.template("<div class=ph-detail-meta>"),on=t.template("<div class=ph-chips>"),Ur=t.template("<div class=ph-detail-links>"),Gr=t.template("<details class=ph-details><summary>依赖 <!> 个</summary><div class=ph-chips>"),Rr=t.template("<div class=ph-readme-note>README 较长,这里只显示前一部分。完整内容见 npm 页面。"),Fr=t.template("<section class=ph-section><div class=ph-section-title>README"),qr=t.template("<div class=ph-readme-empty>"),Hr=t.template("<div class=ph-detail>"),Vr=t.template("<span class=ph-detail-error>"),Wr=t.template("<div class=ph-dialog-footer><span class=ph-spacer>"),gt=t.template("<span class=ph-chip>"),Jr=t.template("<div class=ph-readme-empty>这个包没有附带 README。可以打开 npm 页面或项目主页进一步了解。"),Qr=t.template("<span class=ph-count>"),Xr=t.template('<span class="ph-count ph-count-alert"> 可更新'),Yr=t.template("<button class=ph-tab>"),Zr=t.template("<span class=ph-version-arrow> → v"),Kr=t.template("<span class=ph-version>"),eo=t.template("<span class=ph-pkg>"),lt=t.template("<span class=ph-badge data-tone=accent>可更新 → v"),Te=t.template("<span class=ph-dot>"),to=t.template("<span>v"),no=t.template("<span>仅 GitHub 发布"),ro=t.template("<span>"),oo=t.template("<span class=ph-badge>需手动"),io=t.template('<article class=ph-card><div class=ph-card-main><div class=ph-card-head><div class=ph-tile></div><div class=ph-card-titles><div class=ph-name-row><span class=ph-name></span></div></div><div class=ph-chips></div></div><div class=ph-card-body role=button tabindex=0><div class="ph-desc ph-clamp"></div><div class=ph-meta><span class=ph-type></span></div></div></div><div class=ph-actions>'),ao=t.template("<span>by "),so=t.template("<span>更新"),lo=t.template('<article class=ph-card><div class=ph-card-main><div class=ph-card-head><div class=ph-tile></div><div class=ph-card-titles><div class=ph-name-row><span class=ph-name></span></div><span class=ph-pkg>v</span></div><div class=ph-chips></div></div><div class=ph-card-body role=button tabindex=0><div class="ph-desc ph-clamp"></div><div class=ph-meta><span>/周</span><span class=ph-dot></span><span>/月</span></div></div></div><div class=ph-actions>'),co=t.template("<span class=ph-badge data-tone=warning>未能检查"),po=t.template("<span class=ph-badge>本地目录"),uo=t.template("<span>更新会覆盖目录内容,原文件自动备份"),go=t.template("<article class=ph-card><div class=ph-card-main><div class=ph-card-head><div class=ph-tile></div><div class=ph-card-titles><div class=ph-name-row><span class=ph-name></span></div><span class=ph-pkg></span></div><div class=ph-chips></div></div><div class=ph-card-body><div class=ph-meta></div></div></div><div class=ph-actions>"),ho=t.template("<h2 class=ph-title>插件中心"),mo=t.template("<div class=ph-notice><span></span><button type=button class=ph-notice-close aria-label=关闭提示>"),fo=t.template("<div class=ph-notice data-tone=error><span>"),Pe=t.template("<div class=ph-list>"),vo=t.template("<section class=ph-panel><div class=ph-filters><div class=ph-filter-row><div class=ph-grow></div><div class=ph-chips>"),bo=t.template("<div class=ph-empty><strong>搜索 npm 上的 OpenCode 插件</strong><span>按名称或用途搜索,例如 auth、notify、memory。点开任意结果可以看 README、下载量和主页。</span><div class=ph-chips>"),yo=t.template("<div class=ph-resultbar><h3 class=ph-h3>搜索结果 <span class=ph-count></span></h3><div class=ph-sort>"),wo=t.template("<section class=ph-panel><div class=ph-searchbar><div class=ph-grow></div></div><div class=ph-meta><span>直查 npm 上带 opencode-plugin 标签的包,覆盖精选目录之外的长尾;结果未经人工筛选。"),ko=t.template("<span class=ph-meta>检查过 npm registry"),xo=t.template("<section class=ph-panel><div class=ph-resultbar><h3 class=ph-h3>已安装 <span class=ph-count></span></h3><div class=ph-chips><button class=ph-chip>可更新<span class=ph-chip-count></span></button></div><span class=ph-spacer>"),So=t.template(`<div class=ph-root><style>
56
56
  :root {
57
57
  --ph-strong: var(--color-v2-text-text-contrast, var(--color-text-strong, currentColor));
58
58
  --ph-muted: var(--color-v2-text-text-muted, var(--color-text-weak, color-mix(in srgb, currentColor 58%, transparent)));
@@ -173,6 +173,21 @@ open -b ai.opencode.desktop 2>/dev/null || open -a OpenCode
173
173
  background: color-mix(in srgb, var(--ph-warning) 7%, transparent);
174
174
  }
175
175
  .ph-notice span { flex: 1; min-width: 0; }
176
+ .ph-notice-close {
177
+ flex: 0 0 auto;
178
+ display: grid;
179
+ place-items: center;
180
+ width: 22px;
181
+ height: 22px;
182
+ padding: 0;
183
+ border: 0;
184
+ border-radius: 6px;
185
+ background: transparent;
186
+ color: inherit;
187
+ opacity: 0.55;
188
+ cursor: pointer;
189
+ }
190
+ .ph-notice-close:hover { opacity: 1; background: color-mix(in srgb, currentColor 10%, transparent); }
176
191
 
177
192
  /* toolbar and tabs */
178
193
  .ph-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
@@ -633,4 +648,4 @@ button.ph-chip:focus-visible,
633
648
  .ph-list { grid-template-columns: 1fr; }
634
649
  .ph-detail-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
635
650
  }
636
- </style><section class=ph-hero><div class=ph-hero-copy><div class=ph-kicker>PLUGIN HUB</div><p class=ph-sub>浏览 <button type=button class=ph-inline-source title="精选目录来自 awesome-opencode 社区维护的 registry.json,不是 OpenCode 官方推荐">awesome-opencode</button> 社区维护的精选目录、搜索 npm 上的 OpenCode 插件。安装前先看下载量、README 和主页,确认它到底能做什么。</p><div class=ph-path>配置:<code></code> · <code>[]</code></div></div></section><div class=ph-head><div class=ph-toolbar><div class=ph-tabs role=tablist></div><span class=ph-spacer></span></div></div><footer class=ph-footer><div class=ph-footer-note>安装和移除只改配置,不会立即生效:插件与模型目录都是启动时快照的。改完点工具栏的「彻底重启」,应用会自动退出并重新打开。`),bo=t.template("<button class=ph-chip><span class=ph-chip-count>"),Et=t.template("<div class=ph-skeleton>"),yo=t.template("<div class=ph-empty><strong>没有匹配的插件</strong><span>试试别的关键词,或者清除筛选条件。"),wo=t.template("<button class=ph-chip>"),ko=t.template("<button>"),xo=t.template("<div class=ph-empty><strong>没有找到匹配的插件</strong><span>换个关键词试试,或者清空搜索查看建议。"),So=t.template("<div class=ph-empty><strong>还没有安装插件</strong><span>去「精选目录」看看 awesome-opencode 的推荐,或者在「npm 搜索」里找长尾插件。"),$o=t.template("<div class=ph-empty><strong>没有可更新的插件</strong><span>已安装的插件都已是最新版本。点工具栏的「检查更新」可以再查一次。"),Co=t.template("<div class=ph-dialog-footer><span class=ph-footer-note>拖动右下角可调整大小");const Ge=24,_o="https://github.com/awesome-opencode/awesome-opencode",Ao={plugins:"插件",mcp:"MCP",themes:"主题"},Oo=[{value:"all",label:"全部"},{value:"plugins",label:"插件"},{value:"mcp",label:"MCP"},{value:"themes",label:"主题"}],To=[{value:"relevance",label:"相关度"},{value:"downloads",label:"周下载"},{value:"recent",label:"最近发布"}],Io=["qoder","notify","memory","auth","usage","theme","mcp"],Lo=new Intl.NumberFormat("zh-CN",{notation:"compact",maximumFractionDigits:1});function He(e){return!Number.isFinite(e)||e<=0?"0":Lo.format(e)}function Mo(e){return!Number.isFinite(e)||e<=0?"—":e>=1024*1024?`${(e/1024/1024).toFixed(1)} MB`:e>=1024?`${Math.round(e/1024)} KB`:`${e} B`}function ct(e){if(!e)return"";const r=Date.parse(e);if(!Number.isFinite(r))return e.slice(0,10);const o=Math.floor((Date.now()-r)/864e5);return o<=0?"今天":o===1?"昨天":o<30?`${o} 天前`:o<365?`${Math.floor(o/30)} 个月前`:`${Math.floor(o/365)} 年前`}function Bt(e){const r=e.replace(/^@/,"").split("/").pop()??e;return(r.replace(/^opencode[-_]?/i,"")||r).slice(0,1).toUpperCase()}function jo(e){return e==="mcp"?"mcp":e==="themes"?"appearance":"extensions"}function zo(e,r){return!e||!r||!/^https:\/\/github\.com\//i.test(e)?e:`${e}/tree/HEAD/${r.replace(/^\/+/,"")}`}function Po(e){return e==="error"?"circle-exclamation":e==="success"?"circle-check":e==="warning"?"warning":"info"}function ce(e){const r=e instanceof Error?e.message:String(e);return/SchemaError|Missing key at/i.test(r)?"插件窗口与后台服务版本不一致。点工具栏的「彻底重启」让两边换成同一版本。":/unknown method|not implemented|no such method|method.*not.*found/i.test(r)?"后台服务还是旧版本,暂时没有「彻底重启」能力。请先手动完全退出 OpenCode(并结束 serve --service)再打开一次。":r}const Eo=/^(@[a-z0-9-_.]+\/)?[a-z0-9-_.]+$/i;function Bo(e){const r=e.ctx.ui,[o,n]=l.createSignal(),[i,s]=l.createSignal(""),[c,p]=l.createSignal(!0),u=async()=>{try{const j=await e.admin.detail({name:e.name});n(j),j.error&&s(j.error)}catch(j){s(ce(j))}finally{p(!1)}};l.onMount(()=>{u()});const v=j=>{j&&e.admin.openUrl({url:j})},h=()=>o()?.version||e.fallback?.version||"",k=()=>o()?.description||e.fallback?.description||"",$=()=>o()?.homepage||e.fallback?.homepage||"",A=()=>o()?.repo||e.fallback?.repo||"",I=()=>o()?.npm||e.fallback?.npm||`https://www.npmjs.com/package/${e.name}`,G=()=>!c()&&o()!==void 0&&!i()&&(o()?.version??"")!=="",M=()=>o()?.hasUpdate===!0,F=()=>o()?.installed===!0;return t.createComponent(r.Dialog,{get title(){return e.name},size:"x-large",get footer(){return(()=>{var j=Gr(),g=j.firstChild;return t.insert(j,t.createComponent(l.Show,{get when(){return $()},get children(){return t.createComponent(r.Button,{size:"small",variant:"ghost",icon:"globe",onClick:()=>v($()),children:"主页"})}}),g),t.insert(j,t.createComponent(l.Show,{get when(){return A()},get children(){return t.createComponent(r.Button,{size:"small",variant:"ghost",icon:"github",onClick:()=>v(zo(A(),o()?.repoDir??"")),children:"源码"})}}),g),t.insert(j,t.createComponent(l.Show,{get when(){return I()},get children(){return t.createComponent(r.Button,{size:"small",variant:"ghost",icon:"cube",onClick:()=>v(I()),children:"npm"})}}),g),t.insert(j,t.createComponent(l.Show,{get when(){return i()},get children(){var b=Ur();return t.insert(b,i),t.effect(()=>t.setAttribute(b,"title",i())),b}}),null),t.insert(j,t.createComponent(r.Button,{size:"small",get onClick(){return e.onClose},children:"关闭"}),null),t.insert(j,t.createComponent(l.Show,{get when(){return G()},get children(){return t.createComponent(l.Show,{get when(){return M()||!F()},get fallback(){return t.createComponent(r.Button,{size:"small",disabled:!0,children:"已安装"})},get children(){return t.createComponent(r.Button,{variant:"contrast",size:"small",icon:"download",get busy(){return e.busy},onClick:()=>e.onInstall(o().version),get children(){return t.memo(()=>!!M())()?`更新到 v${h()}`:`安装 v${h()}`}})}})}}),null),j})()},get children(){var j=Nr();return t.insert(j,t.createComponent(l.Show,{get when(){return c()},get children(){var g=kr(),b=g.firstChild;return t.insert(g,t.createComponent(r.Loader,{size:"large"}),b),g}}),null),t.insert(j,t.createComponent(l.Show,{get when(){return t.memo(()=>!c())()&&o()},get children(){return[(()=>{var g=Cr(),b=g.firstChild,S=b.nextSibling;return t.insert(b,t.createComponent(l.Show,{get when(){return h()},get children(){var y=xr();return y.firstChild,t.insert(y,h,null),y}}),null),t.insert(b,t.createComponent(l.Show,{get when(){return F()},get children(){var y=st();return y.firstChild,t.insert(y,(()=>{var f=t.memo(()=>!!o().current);return()=>f()?` v${o().current}`:""})(),null),y}}),null),t.insert(b,t.createComponent(l.Show,{get when(){return M()},get children(){return Sr()}}),null),t.insert(b,t.createComponent(l.Show,{get when(){return o().deprecated},get children(){return $r()}}),null),t.insert(S,()=>k()||"这个包没有提供描述。"),g})(),t.createComponent(l.Show,{get when(){return o().version},get children(){var g=_r(),b=g.firstChild,S=b.firstChild,y=b.nextSibling,f=y.firstChild,V=y.nextSibling,ae=V.firstChild,fe=V.nextSibling,$e=fe.firstChild,be=$e.nextSibling;return t.insert(S,()=>He(o().weekly)),t.insert(f,()=>He(o().monthly)),t.insert(ae,()=>o().versions||"—"),t.insert($e,(()=>{var Q=t.memo(()=>!!o().unpacked);return()=>Q()?Mo(o().unpacked):"—"})()),t.insert(be,(()=>{var Q=t.memo(()=>!!o().files);return()=>Q()?`解包体积 · ${o().files} 文件`:"解包体积"})()),t.effect(Q=>{var L=`${o().weekly.toLocaleString()} 次`,N=`${o().monthly.toLocaleString()} 次`;return L!==Q.e&&t.setAttribute(S,"title",Q.e=L),N!==Q.t&&t.setAttribute(f,"title",Q.t=N),Q},{e:void 0,t:void 0}),g}}),t.createComponent(l.Show,{get when(){return o().deprecated},get children(){var g=Ar(),b=g.firstChild;return t.insert(g,t.createComponent(r.Icon,{name:"warning",size:"small"}),b),t.insert(b,()=>o().deprecated),g}}),t.createComponent(l.Show,{get when(){return i()},get children(){var g=Or(),b=g.firstChild;return t.insert(g,t.createComponent(r.Icon,{name:"circle-exclamation",size:"small"}),b),t.insert(b,i),g}}),(()=>{var g=jr();return t.insert(g,t.createComponent(l.Show,{get when(){return o().license},get children(){var b=Tr();return b.firstChild,t.insert(b,()=>o().license,null),b}}),null),t.insert(g,t.createComponent(l.Show,{get when(){return o().published},get children(){var b=Ir();return b.firstChild,t.insert(b,()=>ct(o().published),null),b}}),null),t.insert(g,t.createComponent(l.Show,{get when(){return o().created},get children(){var b=Lr();return b.firstChild,t.insert(b,()=>ct(o().created),null),b}}),null),t.insert(g,t.createComponent(l.Show,{get when(){return o().maintainers.length>0},get children(){var b=Mr();return b.firstChild,t.insert(b,()=>o().maintainers.join(", "),null),b}}),null),g})(),t.createComponent(l.Show,{get when(){return o().keywords.length>0},get children(){var g=Kt();return t.insert(g,t.createComponent(l.For,{get each(){return o().keywords},children:b=>(()=>{var S=lt();return t.insert(S,b),S})()})),g}}),t.createComponent(l.Show,{get when(){return o().bugs},get children(){var g=zr();return t.insert(g,t.createComponent(r.Button,{size:"small",variant:"ghost-muted",icon:"bubble-5",onClick:()=>v(o().bugs),children:"问题反馈"})),g}}),t.createComponent(l.Show,{get when(){return o().dependencies.length>0},get children(){var g=Pr(),b=g.firstChild,S=b.firstChild,y=S.nextSibling;y.nextSibling;var f=b.nextSibling;return t.insert(b,()=>o().dependencies.length,y),t.insert(f,t.createComponent(l.For,{get each(){return o().dependencies},children:V=>(()=>{var ae=lt();return t.insert(ae,V),ae})()})),g}}),(()=>{var g=Br();return g.firstChild,t.insert(g,t.createComponent(l.Show,{get when(){return o().readme},get fallback(){return Rr()},get children(){return[t.createComponent(r.Markdown,{get text(){return o().readme},class:"ph-readme"}),t.createComponent(l.Show,{get when(){return o().readmeTruncated},get children(){return Er()}})]}}),null),g})()]}}),null),t.insert(j,t.createComponent(l.Show,{get when(){return t.memo(()=>!c())()&&!o()},get children(){var g=Dr();return t.insert(g,()=>i()||"未能读取这个包的详情。"),g}}),null),j}})}function en(e){const r=e.ctx.ui,[o,n]=l.createSignal(),[i,s]=l.createSignal("catalog"),[c,p]=l.createSignal([]),[u,v]=l.createSignal(),[h,k]=l.createSignal(""),[$,A]=l.createSignal("all"),[I,G]=l.createSignal(Ge),[M,F]=l.createSignal([]),[j,g]=l.createSignal(""),[b,S]=l.createSignal(!1),[y,f]=l.createSignal("relevance"),[V,ae]=l.createSignal(new Map),[fe,$e]=l.createSignal(!1),[be,Q]=l.createSignal(!1),[L,N]=l.createSignal(new Set),[ye,we]=l.createSignal(),X=a=>L().has(a),tn=a=>N(m=>{const w=new Set(m);return w.add(a),w}),nn=a=>N(m=>{const w=new Set(m);return w.delete(a),w}),ve=async(a,m)=>{tn(a);try{return await m()}finally{nn(a)}},R=(a,m="info")=>we(a?{text:a,tone:m}:void 0),ht=async()=>{try{n(await e.admin.snapshot())}catch(a){R(ce(a),"error")}},De=async(a=!1)=>{await ve("updates",async()=>{try{const m=await e.admin.updates(),w=new Map;for(const P of m.items)w.set(P.spec,P);if(ae(w),$e(!0),a)return;const O=m.items.filter(P=>P.hasUpdate).length,C=m.items.filter(P=>P.error).length,z=m.error?m.error:C>0?`${C} 个插件未能检查(registry 连接失败),其余${O>0?`有 ${O} 个可更新`:"已是最新"}`:O>0?`发现 ${O} 个可更新的插件`:"全部已是最新版本";R(z,m.error?"error":C>0?"warning":O>0?"info":"success")}catch(m){a||R(ce(m),"error")}})},mt=async a=>{await ve("catalog",async()=>{try{const m=await e.admin.browse({force:a});p([...m.entries]),v(m),m.error&&R(m.error,m.source==="builtin"?"warning":"info"),await ht()}catch(m){R(ce(m),"error")}})},Je=async a=>{g(a),await ve("search",async()=>{try{const m=await e.admin.search({query:a});F(m.hits),S(!0),m.error&&R(m.error,"error")}catch(m){R(ce(m),"error")}})},Ce=async(a,m="")=>{await ve(`install:${a}`,async()=>{try{const w=await e.admin.install({spec:a,version:m});if(n(w.state),!w.ok){R(w.message,"error");return}R(`${w.message}。点工具栏的「彻底重启」后生效`,"success");const O=m||M().find(C=>C.name===a)?.version||"";p(C=>C.map(z=>z.pkg===a?{...z,installed:!0}:z)),F(C=>C.map(z=>z.name===a?{...z,installed:!0,current:O,hasUpdate:!1}:z)),await De(!0)}catch(w){R(ce(w),"error")}})},rn=async a=>{await e.ctx.dialogs.confirm({title:`移除 ${a.name}?`,description:"只从 opencode.json 里删掉这一项,已安装的文件不会删除。",confirm:"移除",danger:!0})&&await ve(`install:${a.name}`,async()=>{try{const w=await e.admin.remove({spec:a.spec,version:""});if(n(w.state),!w.ok){R(w.message,"error");return}R(`${w.message}。点工具栏的「彻底重启」后生效`,"success"),p(O=>O.map(C=>C.pkg===a.name?{...C,installed:!1}:C)),F(O=>O.map(C=>C.name===a.name?{...C,installed:!1,current:"",hasUpdate:!1}:C)),ae(O=>{const C=new Map(O);return C.delete(a.spec),C})}catch(w){R(ce(w),"error")}})},on=async()=>{await ve("reload",async()=>{try{const a=await e.admin.reload();n(a.state),R(a.message,a.ok?"success":"error")}catch(a){R(ce(a),"error")}})},an=async()=>{await e.ctx.dialogs.confirm({title:"彻底重启 OpenCode?",description:"应用会退出并自动重新打开,让插件代码和后台 serve --service 一起换成最新版本。当前会话通常会自动恢复。",confirm:"重启"})&&await ve("restart",async()=>{try{if(!(await e.admin.restart()).ok){R("无法自动重启,请手动完全退出 OpenCode 再打开。","error");return}R("正在重启 OpenCode…如果没有自动打开,请手动启动。","info")}catch{R("自动重启调用失败,后台服务可能还是旧版本。请先手动完全退出 OpenCode(并结束 serve --service)再打开一次。","error")}})},_e=async a=>{if(a)try{(await e.admin.openUrl({url:a})).ok||R(`无法打开链接:${a}`,"error")}catch(m){R(ce(m),"error")}},sn=async()=>{await ve("config",async()=>{try{(await e.admin.openConfig()).ok||R("无法打开配置文件","error")}catch(a){R(ce(a),"error")}})},Qe=(a,m)=>{e.ctx.dialogs.open(w=>t.createComponent(Bo,{get ctx(){return e.ctx},get admin(){return e.admin},name:a,fallback:m,get busy(){return X(`install:${a}`)},onInstall:O=>{w.close(),Ce(a,O)},onClose:()=>w.close()}))},Ne=l.createMemo(()=>{const a=h().trim().toLowerCase(),m=$();return c().filter(w=>m!=="all"&&w.type!==m?!1:a?[w.name,w.pkg,w.desc,w.long,...w.tags].join(" ").toLowerCase().includes(a):!0)}),ln=l.createMemo(()=>{const a=c();return{all:a.length,plugins:a.filter(m=>m.type==="plugins").length,mcp:a.filter(m=>m.type==="mcp").length,themes:a.filter(m=>m.type==="themes").length}}),Xe=l.createMemo(()=>{const a=[...M()];return y()==="downloads"?a.sort((m,w)=>w.weekly-m.weekly):y()==="recent"&&a.sort((m,w)=>(w.published||"").localeCompare(m.published||"")),a}),cn=()=>u()?.registry||_o,ke=l.createMemo(()=>[...V().values()].filter(a=>a.hasUpdate).length),ft=l.createMemo(()=>{const a=o()?.plugins??[];return be()?a.filter(m=>V().get(m.spec)?.hasUpdate===!0):a}),pn=a=>V().get(a),dn=l.createMemo(()=>{const a=new Map;for(const m of V().values())a.set(m.name,m);return a}),un=a=>{s(a),a!=="installed"&&Q(!1),a!=="catalog"&&!fe()&&!X("updates")&&De(!0)};l.onMount(()=>{ht(),mt(!1),De(!0)});const Ye=(a,m,w,O,C)=>(()=>{var z=Hr();return z.$$click=()=>un(a),t.insert(z,t.createComponent(r.Icon,{name:w,size:"small"}),null),t.insert(z,m,null),t.insert(z,t.createComponent(l.Show,{when:O!==void 0&&O!=="",get children(){var P=Fr();return t.insert(P,O),P}}),null),t.insert(z,t.createComponent(l.Show,{when:C!==void 0&&C>0,get children(){var P=qr(),te=P.firstChild;return t.setAttribute(P,"title",`${C} 个可更新`),t.insert(P,C,te),P}}),null),t.effect(()=>t.setAttribute(z,"data-active",i()===a)),z})(),gn=(a,m,w)=>(()=>{var O=Wr();return t.insert(O,a?`v${a}`:"",null),t.insert(O,t.createComponent(l.Show,{when:w&&m,get children(){var C=Vr();return C.firstChild,t.insert(C,m,null),C}}),null),O})(),hn=a=>{const m=()=>dn().get(a.pkg),w=()=>m()?.hasUpdate===!0,O=()=>X(`install:${a.pkg}`),C=()=>Qe(a.pkg,{version:a.version,description:a.desc||a.long,repo:a.repo});return(()=>{var z=Kr(),P=z.firstChild,te=P.firstChild,de=te.firstChild,ne=de.nextSibling,ue=ne.firstChild,re=ue.firstChild,ge=ne.nextSibling,oe=te.nextSibling,K=oe.firstChild,ee=K.nextSibling,Y=ee.firstChild,W=P.nextSibling;return t.insert(de,t.createComponent(r.Icon,{get name(){return jo(a.type)},size:"normal"})),t.insert(re,()=>a.name),t.insert(ne,t.createComponent(l.Show,{get when(){return a.pkg},get children(){var T=Jr();return t.insert(T,()=>a.pkg),T}}),null),t.insert(ge,t.createComponent(l.Show,{get when(){return a.installed},get children(){return st()}}),null),t.insert(ge,t.createComponent(l.Show,{get when(){return w()},get children(){var T=rt();return T.firstChild,t.insert(T,()=>m().latest,null),T}}),null),oe.$$keydown=T=>{(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),a.pkg?C():_e(a.repo))},oe.$$click=()=>a.pkg?C():void _e(a.repo),t.insert(K,()=>a.desc||a.long||"—"),t.insert(Y,()=>Ao[a.type]??a.type),t.insert(ee,t.createComponent(l.Show,{get when(){return a.version},get children(){return[Ie(),(()=>{var T=Qr();return T.firstChild,t.insert(T,()=>a.version,null),T})()]}}),null),t.insert(ee,t.createComponent(l.Show,{get when(){return!a.pkg},get children(){return[Ie(),Xr()]}}),null),t.insert(ee,t.createComponent(l.Show,{get when(){return a.tags.length>0},get children(){return[Ie(),(()=>{var T=Yr();return t.insert(T,()=>a.tags.slice(0,4).join(" / ")),T})()]}}),null),t.insert(W,t.createComponent(l.Show,{get when(){return a.pkg},get children(){return t.createComponent(r.Button,{variant:"ghost",size:"small",icon:"eye",onClick:C,children:"详情"})}}),null),t.insert(W,t.createComponent(r.Button,{variant:"ghost-muted",size:"small",icon:"square-arrow-top-right",onClick:()=>{_e(a.repo)},children:"源码"}),null),t.insert(W,t.createComponent(l.Show,{get when(){return w()},get children(){return t.createComponent(r.Button,{variant:"ghost",size:"small",icon:"download",get busy(){return O()},onClick:()=>{Ce(a.pkg,m().latest)},children:"更新"})}}),null),t.insert(W,t.createComponent(l.Show,{get when(){return t.memo(()=>!w()&&!a.installed)()&&a.pkg},get children(){return t.createComponent(r.Button,{variant:"neutral",size:"small",icon:"download",get busy(){return O()},onClick:()=>{Ce(a.pkg)},children:"安装"})}}),null),t.insert(W,t.createComponent(l.Show,{get when(){return t.memo(()=>!w()&&!a.installed)()&&!a.pkg},get children(){return Zr()}}),null),t.effect(T=>{var _=w()?"true":void 0,x=O()?"true":void 0;return _!==T.e&&t.setAttribute(z,"data-stale",T.e=_),x!==T.t&&t.setAttribute(z,"data-busy",T.t=x),T},{e:void 0,t:void 0}),z})()},mn=a=>{const m=()=>Qe(a.name,{version:a.version,description:a.description,homepage:a.homepage,repo:a.repo,npm:a.npm});return(()=>{var w=no(),O=w.firstChild,C=O.firstChild,z=C.firstChild,P=z.nextSibling,te=P.firstChild,de=te.firstChild,ne=te.nextSibling;ne.firstChild;var ue=P.nextSibling,re=C.nextSibling,ge=re.firstChild,oe=ge.nextSibling,K=oe.firstChild,ee=K.firstChild,Y=K.nextSibling,W=Y.nextSibling,T=W.firstChild,_=O.nextSibling;return t.insert(z,()=>Bt(a.name)),t.insert(de,()=>a.name),t.insert(ne,()=>a.version,null),t.insert(ue,t.createComponent(l.Show,{get when(){return a.installed},get children(){var x=st();return x.firstChild,t.insert(x,(()=>{var J=t.memo(()=>!!a.current);return()=>J()?` v${a.current}`:""})(),null),x}}),null),t.insert(ue,t.createComponent(l.Show,{get when(){return a.hasUpdate},get children(){var x=rt();return x.firstChild,t.insert(x,()=>a.version,null),x}}),null),re.$$keydown=x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),m())},re.$$click=m,t.insert(ge,()=>a.description||"—"),t.insert(K,t.createComponent(r.Icon,{name:"download",size:"small"}),ee),t.insert(K,()=>He(a.weekly),ee),t.insert(W,()=>He(a.monthly),T),t.insert(oe,t.createComponent(l.Show,{get when(){return a.publisher},get children(){return[Ie(),(()=>{var x=eo();return x.firstChild,t.insert(x,()=>a.publisher,null),x})()]}}),null),t.insert(oe,t.createComponent(l.Show,{get when(){return a.published},get children(){return[Ie(),(()=>{var x=to(),J=x.firstChild;return t.insert(x,()=>ct(a.published),J),x})()]}}),null),t.insert(re,t.createComponent(l.Show,{get when(){return a.keywords.length>0},get children(){var x=Kt();return t.insert(x,t.createComponent(l.For,{get each(){return a.keywords.slice(0,3)},children:J=>(()=>{var E=lt();return t.insert(E,J),E})()})),x}}),null),t.insert(_,t.createComponent(l.Show,{get when(){return a.homepage},get children(){return t.createComponent(r.Tooltip,{value:"主页",get children(){return t.createComponent(r.IconButton,{icon:"globe",size:"small",label:"主页",onClick:()=>{_e(a.homepage)}})}})}}),null),t.insert(_,t.createComponent(l.Show,{get when(){return a.repo},get children(){return t.createComponent(r.Tooltip,{value:"源码仓库",get children(){return t.createComponent(r.IconButton,{icon:"github",size:"small",label:"源码仓库",onClick:()=>{_e(a.repo)}})}})}}),null),t.insert(_,t.createComponent(r.Button,{variant:"ghost",size:"small",icon:"eye",onClick:m,children:"详情"}),null),t.insert(_,t.createComponent(l.Show,{get when(){return a.hasUpdate},get children(){return t.createComponent(r.Button,{variant:"ghost",size:"small",icon:"download",get busy(){return X(`install:${a.name}`)},onClick:()=>{Ce(a.name,a.version)},children:"更新"})}}),null),t.insert(_,t.createComponent(l.Show,{get when(){return t.memo(()=>!a.hasUpdate)()&&!a.installed},get children(){return t.createComponent(r.Button,{variant:"neutral",size:"small",icon:"download",get busy(){return X(`install:${a.name}`)},onClick:()=>{Ce(a.name)},children:"安装"})}}),null),t.effect(x=>{var J=X(`install:${a.name}`)?"true":void 0,E=`周下载 ${a.weekly.toLocaleString()} 次`,Z=`月下载 ${a.monthly.toLocaleString()} 次`;return J!==x.e&&t.setAttribute(w,"data-busy",x.e=J),E!==x.t&&t.setAttribute(K,"title",x.t=E),Z!==x.a&&t.setAttribute(W,"title",x.a=Z),x},{e:void 0,t:void 0,a:void 0}),w})()},fn=a=>{const m=()=>pn(a.spec),w=()=>m()?.hasUpdate===!0,O=()=>X(`install:${a.name}`),C=()=>m()?.current||a.version,z=()=>(m()?.error??"")!=="";return(()=>{var P=ao(),te=P.firstChild,de=te.firstChild,ne=de.firstChild,ue=ne.nextSibling,re=ue.firstChild,ge=re.firstChild,oe=re.nextSibling,K=ue.nextSibling,ee=de.nextSibling,Y=ee.firstChild,W=te.nextSibling;return t.insert(ne,()=>Bt(a.name)),t.insert(ge,()=>a.name),t.insert(oe,()=>a.spec),t.insert(K,t.createComponent(l.Show,{get when(){return w()},get children(){var T=rt();return T.firstChild,t.insert(T,()=>m().latest,null),T}}),null),t.insert(K,t.createComponent(l.Show,{get when(){return z()},get children(){return ro()}}),null),t.insert(K,t.createComponent(l.Show,{get when(){return a.kind==="path"},get children(){return oo()}}),null),t.insert(Y,()=>gn(C(),m()?.latest??"",w()),null),t.insert(Y,t.createComponent(l.Show,{get when(){return t.memo(()=>!!w())()&&a.kind==="path"},get children(){return[Ie(),io()]}}),null),t.insert(W,t.createComponent(l.Show,{get when(){return Eo.test(a.name)},get children(){return t.createComponent(r.Button,{variant:"ghost",size:"small",icon:"eye",onClick:()=>Qe(a.name,{version:C()}),children:"详情"})}}),null),t.insert(W,t.createComponent(l.Show,{get when(){return w()},get children(){return t.createComponent(r.Button,{variant:"ghost",size:"small",icon:"download",get busy(){return O()},onClick:()=>{Ce(m().name,m().latest)},children:"更新"})}}),null),t.insert(W,t.createComponent(l.Show,{get when(){return a.removable},get children(){return t.createComponent(r.Button,{variant:"ghost-muted",size:"small",icon:"trash",get busy(){return O()},onClick:()=>{rn(a)},children:"移除"})}}),null),t.effect(T=>{var _=w()?"true":void 0,x=O()?"true":void 0;return _!==T.e&&t.setAttribute(P,"data-stale",T.e=_),x!==T.t&&t.setAttribute(P,"data-busy",T.t=x),T},{e:void 0,t:void 0}),P})()};return(()=>{var a=vo(),m=a.firstChild,w=m.nextSibling,O=w.firstChild,C=O.firstChild,z=C.firstChild,P=C.nextSibling,te=P.firstChild,de=te.nextSibling,ne=P.nextSibling,ue=ne.firstChild,re=ue.nextSibling,ge=re.nextSibling,oe=ge.nextSibling,K=oe.firstChild,ee=w.nextSibling,Y=ee.firstChild,W=Y.firstChild;W.nextSibling;var T=ee.nextSibling;return t.insert(C,t.createComponent(r.Icon,{name:"extensions",size:"small"}),z),t.insert(O,t.createComponent(l.Show,{get when(){return!e.embedded},get children(){return so()}}),P),de.$$click=()=>{_e(cn())},t.insert(re,()=>o()?.configPath??"读取中…"),t.insert(oe,()=>o()?.configKey??"plugins",K),t.insert(ee,t.createComponent(l.Show,{get when(){return ye()},get children(){var _=lo(),x=_.firstChild;return t.insert(_,t.createComponent(r.Icon,{get name(){return Po(ye().tone)},size:"small"}),x),t.insert(x,()=>ye().text),t.effect(()=>t.setAttribute(_,"data-tone",ye().tone)),_}}),Y),t.insert(ee,t.createComponent(l.Show,{get when(){return o()?.error},get children(){var _=co(),x=_.firstChild;return t.insert(_,t.createComponent(r.Icon,{name:"circle-exclamation",size:"small"}),x),t.insert(x,()=>o().error),_}}),Y),t.insert(W,()=>Ye("catalog","精选目录","extensions",u()?c().length:void 0),null),t.insert(W,()=>Ye("search","npm 搜索","magnifying-glass",b()?M().length:void 0),null),t.insert(W,()=>Ye("installed","已安装","checklist",o()?.plugins.length??0,ke()),null),t.insert(Y,t.createComponent(r.Button,{variant:"ghost",size:"small",icon:"open-file",get busy(){return X("config")},onClick:()=>{sn()},children:"打开配置"}),null),t.insert(Y,t.createComponent(r.Button,{variant:"ghost",size:"small",icon:"refresh",get busy(){return X("reload")},onClick:()=>{on()},children:"重载配置"}),null),t.insert(Y,t.createComponent(r.Button,{variant:"neutral",size:"small",icon:"outline-rotate-clockwise",get busy(){return X("restart")},onClick:()=>{an()},children:"彻底重启"}),null),t.insert(Y,t.createComponent(l.Show,{get when(){return i()==="catalog"},get children(){return t.createComponent(r.Button,{variant:"ghost",size:"small",icon:"refresh",get busy(){return X("catalog")},onClick:()=>{mt(!0)},children:"更新目录"})}}),null),t.insert(Y,t.createComponent(l.Show,{get when(){return i()==="search"},get children(){return t.createComponent(l.Show,{get when(){return b()},get children(){return t.createComponent(r.Button,{variant:"ghost",size:"small",icon:"close",onClick:()=>{F([]),S(!1),g(""),we(void 0)},children:"清空"})}})}}),null),t.insert(Y,t.createComponent(l.Show,{get when(){return i()==="installed"},get children(){return t.createComponent(r.Button,{variant:"ghost",size:"small",icon:"refresh",get busy(){return X("updates")},onClick:()=>{De()},children:"检查更新"})}}),null),t.insert(a,t.createComponent(l.Switch,{get children(){return[t.createComponent(l.Match,{get when(){return i()==="catalog"},get children(){var _=po(),x=_.firstChild,J=x.firstChild,E=J.firstChild,Z=E.nextSibling;return t.insert(E,t.createComponent(r.TextInput,{label:"筛选 awesome-opencode 精选插件",placeholder:"按名称、描述或标签筛选,例如 memory / auth / token",type:"search",get value(){return h()},onInput:D=>{k(D),G(Ge)}})),t.insert(Z,t.createComponent(l.For,{each:Oo,children:D=>(()=>{var q=bo(),he=q.firstChild;return q.$$click=()=>{A(D.value),G(Ge)},t.insert(q,()=>D.label,he),t.insert(he,()=>ln()[D.value]),t.effect(()=>t.setAttribute(q,"data-active",$()===D.value)),q})()})),t.insert(_,t.createComponent(l.Show,{get when(){return t.memo(()=>!!X("catalog"))()&&c().length===0},get children(){var D=ze();return t.insert(D,t.createComponent(l.For,{each:[0,1,2,3],children:()=>Et()})),D}}),null),t.insert(_,t.createComponent(l.Show,{get when(){return!X("catalog")||c().length>0},get children(){return t.createComponent(l.Show,{get when(){return Ne().length>0},get fallback(){return(()=>{var D=yo(),q=D.firstChild;return q.nextSibling,t.insert(D,t.createComponent(r.Icon,{name:"magnifying-glass",size:"large"}),q),t.insert(D,t.createComponent(r.Button,{variant:"ghost",size:"small",onClick:()=>{k(""),A("all")},children:"清除筛选"}),null),D})()},get children(){return[(()=>{var D=ze();return t.insert(D,t.createComponent(l.For,{get each(){return Ne().slice(0,I())},children:q=>hn(q)})),D})(),t.createComponent(l.Show,{get when(){return Ne().length>I()},get children(){return t.createComponent(r.Button,{variant:"ghost",size:"small",onClick:()=>G(D=>D+Ge),get children(){return["显示更多(还有 ",t.memo(()=>Ne().length-I())," 个)"]}})}})]}})}}),null),_}}),t.createComponent(l.Match,{get when(){return i()==="search"},get children(){var _=ho(),x=_.firstChild,J=x.firstChild;return x.nextSibling,t.insert(J,t.createComponent(r.TextInput,{label:"搜索 npm 上的 OpenCode 插件",placeholder:"搜索插件,例如 qoder / notify / usage",type:"search",get value(){return j()},onInput:g,onSubmit:E=>{Je(E)}})),t.insert(x,t.createComponent(r.Button,{variant:"contrast",icon:"magnifying-glass",get busy(){return X("search")},onClick:()=>{Je(j())},children:"搜索"}),null),t.insert(_,t.createComponent(l.Show,{get when(){return!b()},get children(){var E=uo(),Z=E.firstChild,D=Z.nextSibling,q=D.nextSibling;return t.insert(E,t.createComponent(r.Icon,{name:"magnifying-glass",size:"large"}),Z),t.insert(q,t.createComponent(l.For,{each:Io,children:he=>(()=>{var me=wo();return me.$$click=()=>{Je(he)},t.insert(me,he),me})()})),E}}),null),t.insert(_,t.createComponent(l.Show,{get when(){return b()},get children(){return[(()=>{var E=go(),Z=E.firstChild,D=Z.firstChild,q=D.nextSibling,he=Z.nextSibling;return t.insert(q,()=>Xe().length),t.insert(he,t.createComponent(l.For,{each:To,children:me=>(()=>{var B=ko();return B.$$click=()=>f(me.value),t.insert(B,()=>me.label),t.effect(()=>t.setAttribute(B,"data-active",y()===me.value)),B})()})),E})(),t.createComponent(l.Show,{get when(){return t.memo(()=>!!X("search"))()&&M().length===0},get children(){var E=ze();return t.insert(E,t.createComponent(l.For,{each:[0,1,2,3],children:()=>Et()})),E}}),t.createComponent(l.Show,{get when(){return!X("search")||M().length>0},get children(){return t.createComponent(l.Show,{get when(){return Xe().length>0},get fallback(){return(()=>{var E=xo(),Z=E.firstChild;return t.insert(E,t.createComponent(r.Icon,{name:"magnifying-glass",size:"large"}),Z),E})()},get children(){var E=ze();return t.insert(E,t.createComponent(l.For,{get each(){return Xe()},children:Z=>mn(Z)})),E}})}})]}}),null),_}}),t.createComponent(l.Match,{get when(){return i()==="installed"},get children(){var _=fo(),x=_.firstChild,J=x.firstChild,E=J.firstChild,Z=E.nextSibling,D=J.nextSibling,q=D.firstChild,he=q.firstChild,me=he.nextSibling;return D.nextSibling,t.insert(Z,()=>o()?.plugins.length??0),q.$$click=()=>{ke()>0&&Q(!be())},t.insert(me,ke),t.insert(x,t.createComponent(l.Show,{get when(){return fe()},get children(){var B=mo();return B.firstChild,t.insert(B,(()=>{var se=t.memo(()=>ke()>0);return()=>se()?` · ${ke()} 个可更新`:" · 全部已是最新"})(),null),B}}),null),t.insert(_,t.createComponent(l.Show,{get when(){return(o()?.plugins.length??0)>0},get fallback(){return(()=>{var B=So(),se=B.firstChild;return t.insert(B,t.createComponent(r.Icon,{name:"extensions",size:"large"}),se),B})()},get children(){return t.createComponent(l.Show,{get when(){return ft().length>0},get fallback(){return(()=>{var B=$o(),se=B.firstChild;return se.nextSibling,t.insert(B,t.createComponent(r.Icon,{name:"checklist",size:"large"}),se),t.insert(B,t.createComponent(r.Button,{variant:"ghost",size:"small",onClick:()=>Q(!1),children:"显示全部"}),null),B})()},get children(){var B=ze();return t.insert(B,t.createComponent(l.For,{get each(){return ft()},children:se=>fn(se)})),B}})}}),null),t.effect(B=>{var se=be(),vt=ke()===0?"true":void 0,bt=ke()===0?"检查更新后再来看可更新的插件":"只显示有新版本的插件";return se!==B.e&&t.setAttribute(q,"data-active",B.e=se),vt!==B.t&&t.setAttribute(q,"data-disabled",B.t=vt),bt!==B.a&&t.setAttribute(q,"title",B.a=bt),B},{e:void 0,t:void 0,a:void 0}),_}})]}}),T),t.effect(_=>{var x=e.embedded?"true":void 0,J=o()?.configPath;return x!==_.e&&t.setAttribute(a,"data-embedded",_.e=x),J!==_.t&&t.setAttribute(ne,"title",_.t=J),_},{e:void 0,t:void 0}),a})()}function Do(e){const r=e.ctx.ui,o=()=>{e.onClose(),setTimeout(()=>e.ctx.layout.settings("hub"),0)};return t.createComponent(r.Dialog,{title:"插件中心",size:"x-large",get footer(){return(()=>{var n=Co();return n.firstChild,t.insert(n,t.createComponent(r.Button,{size:"small",variant:"ghost",icon:"settings-gear",onClick:o,children:"在设置中打开"}),null),t.insert(n,t.createComponent(r.Button,{size:"small",get onClick(){return e.onClose},children:"关闭"}),null),n})()},get children(){return t.createComponent(en,{get ctx(){return e.ctx},get admin(){return e.admin},embedded:!0})}})}t.delegateEvents(["click","keydown"]);const No=Pe.Plugin.define({setup(e){const r=e.main(wt),o=()=>{e.dialogs.active()||e.dialogs.open(n=>t.createComponent(Do,{ctx:e,admin:r,onClose:()=>n.close()}))};e.add(Pe.SettingsPage,{id:"hub",title:"插件中心",icon:"extensions",entries:[{id:"hub",title:"插件中心",description:"浏览社区精选插件,按 npm 搜索,安装或移除",keywords:"plugin npm install remove hub catalog marketplace"}],render:()=>t.createComponent(en,{ctx:e,admin:r})}),e.add(Pe.TitlebarItem,()=>({id:"hub",label:"插件中心",title:"打开插件中心",icon:"extensions",run:o})),e.add(Pe.Command,()=>({id:"open",title:"插件中心",description:"浏览、搜索、安装与更新 OpenCode 插件",keywords:"plugin hub install browse npm catalog marketplace",group:"设置",section:"navigation",bind:"mod+alt+p",featured:!0,run:o}))},main(e){e.provide(wt,{snapshot:()=>pe(),updates:()=>Hn(),search:r=>sr(r.query),browse:async r=>{const o=await pe();return yr(new Set(o.plugins.map(n=>n.name)),r.force)},detail:r=>ar(r.name),openUrl:r=>({ok:lr(r.url)}),openConfig:async()=>({ok:await cr()}),install:r=>Xn(r.spec,r.version),remove:r=>Yn(r.spec),reload:()=>dr(e.cli.command),restart:()=>({ok:pr()})})}});exports.default=No;
651
+ </style><section class=ph-hero><div class=ph-hero-copy><div class=ph-kicker>PLUGIN HUB</div><p class=ph-sub>浏览 <button type=button class=ph-inline-source title="精选目录来自 awesome-opencode 社区维护的 registry.json,不是 OpenCode 官方推荐">awesome-opencode</button> 社区维护的精选目录、搜索 npm 上的 OpenCode 插件。安装前先看下载量、README 和主页,确认它到底能做什么。</p><div class=ph-path>配置:<code></code> · <code>[]</code></div></div></section><div class=ph-head><div class=ph-toolbar><div class=ph-tabs role=tablist></div><span class=ph-spacer></span></div></div><footer class=ph-footer><div class=ph-footer-note>安装和移除只改配置,不会立即生效:插件与模型目录都是启动时快照的。改完点右上角「更多操作 → 彻底重启 OpenCode」,应用会自动退出并重新打开。`),$o=t.template("<button class=ph-chip><span class=ph-chip-count>"),Gt=t.template("<div class=ph-skeleton>"),Co=t.template("<div class=ph-empty><strong>没有匹配的插件</strong><span>试试别的关键词,或者清除筛选条件。"),_o=t.template("<button class=ph-chip>"),Oo=t.template("<button>"),Ao=t.template("<div class=ph-empty><strong>没有找到匹配的插件</strong><span>换个关键词试试,或者清空搜索查看建议。"),To=t.template("<div class=ph-empty><strong>还没有安装插件</strong><span>去「精选目录」看看 awesome-opencode 的推荐,或者在「npm 搜索」里找长尾插件。"),Io=t.template("<div class=ph-empty><strong>没有可更新的插件</strong><span>已安装的插件都已是最新版本。点工具栏的「检查更新」可以再查一次。"),Lo=t.template("<div class=ph-dialog-footer><span class=ph-footer-note>拖动右下角可调整大小");const He=24,Mo="https://github.com/awesome-opencode/awesome-opencode",jo={plugins:"插件",mcp:"MCP",themes:"主题"},zo=[{value:"all",label:"全部"},{value:"plugins",label:"插件"},{value:"mcp",label:"MCP"},{value:"themes",label:"主题"}],Po=[{value:"relevance",label:"相关度"},{value:"downloads",label:"周下载"},{value:"recent",label:"最近发布"}],Eo=["qoder","notify","memory","auth","usage","theme","mcp"],Bo=new Intl.NumberFormat("zh-CN",{notation:"compact",maximumFractionDigits:1});function Qe(e){return!Number.isFinite(e)||e<=0?"0":Bo.format(e)}function Do(e){return!Number.isFinite(e)||e<=0?"—":e>=1024*1024?`${(e/1024/1024).toFixed(1)} MB`:e>=1024?`${Math.round(e/1024)} KB`:`${e} B`}function ht(e){if(!e)return"";const r=Date.parse(e);if(!Number.isFinite(r))return e.slice(0,10);const o=Math.floor((Date.now()-r)/864e5);return o<=0?"今天":o===1?"昨天":o<30?`${o} 天前`:o<365?`${Math.floor(o/30)} 个月前`:`${Math.floor(o/365)} 年前`}function Rt(e){const r=e.replace(/^@/,"").split("/").pop()??e;return(r.replace(/^opencode[-_]?/i,"")||r).slice(0,1).toUpperCase()}function No(e){return e==="mcp"?"mcp":e==="themes"?"appearance":"extensions"}function Uo(e,r){return!e||!r||!/^https:\/\/github\.com\//i.test(e)?e:`${e}/tree/HEAD/${r.replace(/^\/+/,"")}`}function Go(e){return e==="error"?"circle-exclamation":e==="success"?"circle-check":e==="warning"?"warning":"info"}function pe(e){const r=e instanceof Error?e.message:String(e);return/SchemaError|Missing key at/i.test(r)?"插件窗口与后台服务版本不一致。点工具栏的「彻底重启」让两边换成同一版本。":/unknown method|not implemented|no such method|method.*not.*found/i.test(r)?"后台服务还是旧版本,暂时没有「彻底重启」能力。请先手动完全退出 OpenCode(并结束 serve --service)再打开一次。":r}const Ro=/^(@[a-z0-9-_.]+\/)?[a-z0-9-_.]+$/i;function Fo(e){const r=e.ctx.ui,[o,n]=l.createSignal(),[i,s]=l.createSignal(""),[c,p]=l.createSignal(!0),u=async()=>{try{const j=await e.admin.detail({name:e.name});n(j),j.error&&s(j.error)}catch(j){s(pe(j))}finally{p(!1)}};l.onMount(()=>{u()});const v=j=>{j&&e.admin.openUrl({url:j})},h=()=>o()?.version||e.fallback?.version||"",k=()=>o()?.description||e.fallback?.description||"",$=()=>o()?.homepage||e.fallback?.homepage||"",A=()=>o()?.repo||e.fallback?.repo||"",L=()=>o()?.npm||e.fallback?.npm||`https://www.npmjs.com/package/${e.name}`,G=()=>!c()&&o()!==void 0&&!i()&&(o()?.version??"")!=="",M=()=>o()?.hasUpdate===!0,q=()=>o()?.installed===!0;return t.createComponent(r.Dialog,{get title(){return e.name},size:"x-large",get footer(){return(()=>{var j=Wr(),g=j.firstChild;return t.insert(j,t.createComponent(l.Show,{get when(){return $()},get children(){return t.createComponent(r.Button,{size:"small",variant:"ghost",icon:"globe",onClick:()=>v($()),children:"主页"})}}),g),t.insert(j,t.createComponent(l.Show,{get when(){return A()},get children(){return t.createComponent(r.Button,{size:"small",variant:"ghost",icon:"github",onClick:()=>v(Uo(A(),o()?.repoDir??"")),children:"源码"})}}),g),t.insert(j,t.createComponent(l.Show,{get when(){return L()},get children(){return t.createComponent(r.Button,{size:"small",variant:"ghost",icon:"cube",onClick:()=>v(L()),children:"npm"})}}),g),t.insert(j,t.createComponent(l.Show,{get when(){return i()},get children(){var b=Vr();return t.insert(b,i),t.effect(()=>t.setAttribute(b,"title",i())),b}}),null),t.insert(j,t.createComponent(r.Button,{size:"small",get onClick(){return e.onClose},children:"关闭"}),null),t.insert(j,t.createComponent(l.Show,{get when(){return G()},get children(){return t.createComponent(l.Show,{get when(){return M()||!q()},get fallback(){return t.createComponent(r.Button,{size:"small",disabled:!0,children:"已安装"})},get children(){return t.createComponent(r.Button,{variant:"contrast",size:"small",icon:"download",get busy(){return e.busy},onClick:()=>e.onInstall(o().version),get children(){return t.memo(()=>!!M())()?`更新到 v${h()}`:`安装 v${h()}`}})}})}}),null),j})()},get children(){var j=Hr();return t.insert(j,t.createComponent(l.Show,{get when(){return c()},get children(){var g=Or(),b=g.firstChild;return t.insert(g,t.createComponent(r.Loader,{size:"large"}),b),g}}),null),t.insert(j,t.createComponent(l.Show,{get when(){return t.memo(()=>!c())()&&o()},get children(){return[(()=>{var g=Lr(),b=g.firstChild,S=b.nextSibling;return t.insert(b,t.createComponent(l.Show,{get when(){return h()},get children(){var y=Ar();return y.firstChild,t.insert(y,h,null),y}}),null),t.insert(b,t.createComponent(l.Show,{get when(){return q()},get children(){var y=ut();return y.firstChild,t.insert(y,(()=>{var f=t.memo(()=>!!o().current);return()=>f()?` v${o().current}`:""})(),null),y}}),null),t.insert(b,t.createComponent(l.Show,{get when(){return M()},get children(){return Tr()}}),null),t.insert(b,t.createComponent(l.Show,{get when(){return o().deprecated},get children(){return Ir()}}),null),t.insert(S,()=>k()||"这个包没有提供描述。"),g})(),t.createComponent(l.Show,{get when(){return o().version},get children(){var g=Mr(),b=g.firstChild,S=b.firstChild,y=b.nextSibling,f=y.firstChild,J=y.nextSibling,ae=J.firstChild,ce=J.nextSibling,be=ce.firstChild,Se=be.nextSibling;return t.insert(S,()=>Qe(o().weekly)),t.insert(f,()=>Qe(o().monthly)),t.insert(ae,()=>o().versions||"—"),t.insert(be,(()=>{var X=t.memo(()=>!!o().unpacked);return()=>X()?Do(o().unpacked):"—"})()),t.insert(Se,(()=>{var X=t.memo(()=>!!o().files);return()=>X()?`解包体积 · ${o().files} 文件`:"解包体积"})()),t.effect(X=>{var O=`${o().weekly.toLocaleString()} 次`,D=`${o().monthly.toLocaleString()} 次`;return O!==X.e&&t.setAttribute(S,"title",X.e=O),D!==X.t&&t.setAttribute(f,"title",X.t=D),X},{e:void 0,t:void 0}),g}}),t.createComponent(l.Show,{get when(){return o().deprecated},get children(){var g=jr(),b=g.firstChild;return t.insert(g,t.createComponent(r.Icon,{name:"warning",size:"small"}),b),t.insert(b,()=>o().deprecated),g}}),t.createComponent(l.Show,{get when(){return i()},get children(){var g=zr(),b=g.firstChild;return t.insert(g,t.createComponent(r.Icon,{name:"circle-exclamation",size:"small"}),b),t.insert(b,i),g}}),(()=>{var g=Nr();return t.insert(g,t.createComponent(l.Show,{get when(){return o().license},get children(){var b=Pr();return b.firstChild,t.insert(b,()=>o().license,null),b}}),null),t.insert(g,t.createComponent(l.Show,{get when(){return o().published},get children(){var b=Er();return b.firstChild,t.insert(b,()=>ht(o().published),null),b}}),null),t.insert(g,t.createComponent(l.Show,{get when(){return o().created},get children(){var b=Br();return b.firstChild,t.insert(b,()=>ht(o().created),null),b}}),null),t.insert(g,t.createComponent(l.Show,{get when(){return o().maintainers.length>0},get children(){var b=Dr();return b.firstChild,t.insert(b,()=>o().maintainers.join(", "),null),b}}),null),g})(),t.createComponent(l.Show,{get when(){return o().keywords.length>0},get children(){var g=on();return t.insert(g,t.createComponent(l.For,{get each(){return o().keywords},children:b=>(()=>{var S=gt();return t.insert(S,b),S})()})),g}}),t.createComponent(l.Show,{get when(){return o().bugs},get children(){var g=Ur();return t.insert(g,t.createComponent(r.Button,{size:"small",variant:"ghost-muted",icon:"bubble-5",onClick:()=>v(o().bugs),children:"问题反馈"})),g}}),t.createComponent(l.Show,{get when(){return o().dependencies.length>0},get children(){var g=Gr(),b=g.firstChild,S=b.firstChild,y=S.nextSibling;y.nextSibling;var f=b.nextSibling;return t.insert(b,()=>o().dependencies.length,y),t.insert(f,t.createComponent(l.For,{get each(){return o().dependencies},children:J=>(()=>{var ae=gt();return t.insert(ae,J),ae})()})),g}}),(()=>{var g=Fr();return g.firstChild,t.insert(g,t.createComponent(l.Show,{get when(){return o().readme},get fallback(){return Jr()},get children(){return[t.createComponent(r.Markdown,{get text(){return o().readme},class:"ph-readme"}),t.createComponent(l.Show,{get when(){return o().readmeTruncated},get children(){return Rr()}})]}}),null),g})()]}}),null),t.insert(j,t.createComponent(l.Show,{get when(){return t.memo(()=>!c())()&&!o()},get children(){var g=qr();return t.insert(g,()=>i()||"未能读取这个包的详情。"),g}}),null),j}})}function an(e){const r=e.ctx.ui,[o,n]=l.createSignal(),[i,s]=l.createSignal("catalog"),[c,p]=l.createSignal([]),[u,v]=l.createSignal(),[h,k]=l.createSignal(""),[$,A]=l.createSignal("all"),[L,G]=l.createSignal(He),[M,q]=l.createSignal([]),[j,g]=l.createSignal(""),[b,S]=l.createSignal(!1),[y,f]=l.createSignal("relevance"),[J,ae]=l.createSignal(12),[ce,be]=l.createSignal(new Map),[Se,X]=l.createSignal(!1),[O,D]=l.createSignal(!1),[Ne,ye]=l.createSignal(new Set),[Ue,Ze]=l.createSignal(),Y=a=>Ne().has(a),sn=a=>ye(m=>{const w=new Set(m);return w.add(a),w}),ln=a=>ye(m=>{const w=new Set(m);return w.delete(a),w}),ve=async(a,m)=>{sn(a);try{return await m()}finally{ln(a)}},R=(a,m="info")=>Ze(a?{text:a,tone:m}:void 0),yt=async()=>{try{n(await e.admin.snapshot())}catch(a){R(pe(a),"error")}},Ge=async(a=!1)=>{await ve("updates",async()=>{try{const m=await e.admin.updates(),w=new Map;for(const E of m.items)w.set(E.spec,E);if(be(w),X(!0),a)return;const T=m.items.filter(E=>E.hasUpdate).length,C=m.items.filter(E=>E.error).length,P=m.error?m.error:C>0?`${C} 个插件未能检查(registry 连接失败),其余${T>0?`有 ${T} 个可更新`:"已是最新"}`:T>0?`发现 ${T} 个可更新的插件`:"全部已是最新版本";R(P,m.error?"error":C>0?"warning":T>0?"info":"success")}catch(m){a||R(pe(m),"error")}})},wt=async a=>{await ve("catalog",async()=>{try{const m=await e.admin.browse({force:a});p([...m.entries]),v(m),m.error&&R(m.error,m.source==="builtin"?"warning":"info"),await yt()}catch(m){R(pe(m),"error")}})},Re=async a=>{g(a),await ve("search",async()=>{try{const m=await e.admin.search({query:a});q(m.hits),S(!0),m.error&&R(m.error,"error")}catch(m){R(pe(m),"error")}})};let Me,Ke="";const cn=a=>{g(a),Me&&window.clearTimeout(Me);const m=a.trim();m&&(Me=window.setTimeout(()=>{m!==Ke&&(Ke=m,Re(m))},450))},$e=async(a,m="")=>{await ve(`install:${a}`,async()=>{try{const w=await e.admin.install({spec:a,version:m});if(n(w.state),!w.ok){R(w.message,"error");return}R(`${w.message}。点右上角「更多操作 → 彻底重启 OpenCode」后生效`,"success");const T=m||M().find(C=>C.name===a)?.version||"";p(C=>C.map(P=>P.pkg===a?{...P,installed:!0}:P)),q(C=>C.map(P=>P.name===a?{...P,installed:!0,current:T,hasUpdate:!1}:P)),await Ge(!0)}catch(w){R(pe(w),"error")}})},pn=async a=>{await e.ctx.dialogs.confirm({title:`移除 ${a.name}?`,description:"只从 opencode.json 里删掉这一项,已安装的文件不会删除。",confirm:"移除",danger:!0})&&await ve(`install:${a.name}`,async()=>{try{const w=await e.admin.remove({spec:a.spec,version:""});if(n(w.state),!w.ok){R(w.message,"error");return}R(`${w.message}。点右上角「更多操作 → 彻底重启 OpenCode」后生效`,"success"),p(T=>T.map(C=>C.pkg===a.name?{...C,installed:!1}:C)),q(T=>T.map(C=>C.name===a.name?{...C,installed:!1,current:"",hasUpdate:!1}:C)),be(T=>{const C=new Map(T);return C.delete(a.spec),C})}catch(w){R(pe(w),"error")}})},dn=async()=>{await ve("reload",async()=>{try{const a=await e.admin.reload();n(a.state),R(a.message,a.ok?"success":"error")}catch(a){R(pe(a),"error")}})},un=async()=>{await e.ctx.dialogs.confirm({title:"彻底重启 OpenCode?",description:"应用会退出并自动重新打开,让插件代码和后台 serve --service 一起换成最新版本。当前会话通常会自动恢复。",confirm:"重启"})&&await ve("restart",async()=>{try{if(!(await e.admin.restart()).ok){R("无法自动重启,请手动完全退出 OpenCode 再打开。","error");return}R("正在重启 OpenCode…如果没有自动打开,请手动启动。","info")}catch{R("自动重启调用失败,后台服务可能还是旧版本。请先手动完全退出 OpenCode(并结束 serve --service)再打开一次。","error")}})},Ce=async a=>{if(a)try{(await e.admin.openUrl({url:a})).ok||R(`无法打开链接:${a}`,"error")}catch(m){R(pe(m),"error")}},gn=async()=>{await ve("config",async()=>{try{(await e.admin.openConfig()).ok||R("无法打开配置文件","error")}catch(a){R(pe(a),"error")}})},et=(a,m)=>{e.ctx.dialogs.open(w=>t.createComponent(Fo,{get ctx(){return e.ctx},get admin(){return e.admin},name:a,fallback:m,get busy(){return Y(`install:${a}`)},onInstall:T=>{w.close(),$e(a,T)},onClose:()=>w.close()}))},Fe=l.createMemo(()=>{const a=h().trim().toLowerCase(),m=$();return c().filter(w=>m!=="all"&&w.type!==m?!1:a?[w.name,w.pkg,w.desc,w.long,...w.tags].join(" ").toLowerCase().includes(a):!0)}),hn=l.createMemo(()=>{const a=c();return{all:a.length,plugins:a.filter(m=>m.type==="plugins").length,mcp:a.filter(m=>m.type==="mcp").length,themes:a.filter(m=>m.type==="themes").length}}),je=l.createMemo(()=>{const a=[...M()];return y()==="downloads"?a.sort((m,w)=>w.weekly-m.weekly):y()==="recent"&&a.sort((m,w)=>(w.published||"").localeCompare(m.published||"")),a}),tt=l.createMemo(()=>je().slice(0,J()));l.createEffect(()=>{M(),ae(12)});const mn=()=>u()?.registry||Mo,we=l.createMemo(()=>[...ce().values()].filter(a=>a.hasUpdate).length),kt=l.createMemo(()=>{const a=o()?.plugins??[];return O()?a.filter(m=>ce().get(m.spec)?.hasUpdate===!0):a}),fn=a=>ce().get(a),vn=l.createMemo(()=>{const a=new Map;for(const m of ce().values())a.set(m.name,m);return a}),bn=a=>{s(a),a!=="installed"&&D(!1),a!=="catalog"&&!Se()&&!Y("updates")&&Ge(!0)};l.onMount(()=>{yt(),wt(!1),Ge(!0)});const nt=(a,m,w,T,C)=>(()=>{var P=Yr();return P.$$click=()=>bn(a),t.insert(P,t.createComponent(r.Icon,{name:w,size:"small"}),null),t.insert(P,m,null),t.insert(P,t.createComponent(l.Show,{when:T!==void 0&&T!=="",get children(){var E=Qr();return t.insert(E,T),E}}),null),t.insert(P,t.createComponent(l.Show,{when:C!==void 0&&C>0,get children(){var E=Xr(),te=E.firstChild;return t.setAttribute(E,"title",`${C} 个可更新`),t.insert(E,C,te),E}}),null),t.effect(()=>t.setAttribute(P,"data-active",i()===a)),P})(),yn=(a,m,w)=>(()=>{var T=Kr();return t.insert(T,a?`v${a}`:"",null),t.insert(T,t.createComponent(l.Show,{when:w&&m,get children(){var C=Zr();return C.firstChild,t.insert(C,m,null),C}}),null),T})(),wn=a=>{const m=()=>vn().get(a.pkg),w=()=>m()?.hasUpdate===!0,T=()=>Y(`install:${a.pkg}`),C=()=>et(a.pkg,{version:a.version,description:a.desc||a.long,repo:a.repo});return(()=>{var P=io(),E=P.firstChild,te=E.firstChild,ue=te.firstChild,ne=ue.nextSibling,ge=ne.firstChild,re=ge.firstChild,he=ne.nextSibling,oe=te.nextSibling,Z=oe.firstChild,K=Z.nextSibling,ee=K.firstChild,W=E.nextSibling;return t.insert(ue,t.createComponent(r.Icon,{get name(){return No(a.type)},size:"normal"})),t.insert(re,()=>a.name),t.insert(ne,t.createComponent(l.Show,{get when(){return a.pkg},get children(){var I=eo();return t.insert(I,()=>a.pkg),I}}),null),t.insert(he,t.createComponent(l.Show,{get when(){return a.installed},get children(){return ut()}}),null),t.insert(he,t.createComponent(l.Show,{get when(){return w()},get children(){var I=lt();return I.firstChild,t.insert(I,()=>m().latest,null),I}}),null),oe.$$keydown=I=>{(I.key==="Enter"||I.key===" ")&&(I.preventDefault(),a.pkg?C():Ce(a.repo))},oe.$$click=()=>a.pkg?C():void Ce(a.repo),t.insert(Z,()=>a.desc||a.long||"—"),t.insert(ee,()=>jo[a.type]??a.type),t.insert(K,t.createComponent(l.Show,{get when(){return a.version},get children(){return[Te(),(()=>{var I=to();return I.firstChild,t.insert(I,()=>a.version,null),I})()]}}),null),t.insert(K,t.createComponent(l.Show,{get when(){return!a.pkg},get children(){return[Te(),no()]}}),null),t.insert(K,t.createComponent(l.Show,{get when(){return a.tags.length>0},get children(){return[Te(),(()=>{var I=ro();return t.insert(I,()=>a.tags.slice(0,4).join(" / ")),I})()]}}),null),t.insert(W,t.createComponent(l.Show,{get when(){return a.pkg},get children(){return t.createComponent(r.Button,{variant:"ghost",size:"small",icon:"eye",onClick:C,children:"详情"})}}),null),t.insert(W,t.createComponent(r.Button,{variant:"ghost-muted",size:"small",icon:"square-arrow-top-right",onClick:()=>{Ce(a.repo)},children:"源码"}),null),t.insert(W,t.createComponent(l.Show,{get when(){return w()},get children(){return t.createComponent(r.Button,{variant:"ghost",size:"small",icon:"download",get busy(){return T()},onClick:()=>{$e(a.pkg,m().latest)},children:"更新"})}}),null),t.insert(W,t.createComponent(l.Show,{get when(){return t.memo(()=>!w()&&!a.installed)()&&a.pkg},get children(){return t.createComponent(r.Button,{variant:"neutral",size:"small",icon:"download",get busy(){return T()},onClick:()=>{$e(a.pkg)},children:"安装"})}}),null),t.insert(W,t.createComponent(l.Show,{get when(){return t.memo(()=>!w()&&!a.installed)()&&!a.pkg},get children(){return oo()}}),null),t.effect(I=>{var _=w()?"true":void 0,x=T()?"true":void 0;return _!==I.e&&t.setAttribute(P,"data-stale",I.e=_),x!==I.t&&t.setAttribute(P,"data-busy",I.t=x),I},{e:void 0,t:void 0}),P})()},kn=a=>{const m=()=>et(a.name,{version:a.version,description:a.description,homepage:a.homepage,repo:a.repo,npm:a.npm});return(()=>{var w=lo(),T=w.firstChild,C=T.firstChild,P=C.firstChild,E=P.nextSibling,te=E.firstChild,ue=te.firstChild,ne=te.nextSibling;ne.firstChild;var ge=E.nextSibling,re=C.nextSibling,he=re.firstChild,oe=he.nextSibling,Z=oe.firstChild,K=Z.firstChild,ee=Z.nextSibling,W=ee.nextSibling,I=W.firstChild,_=T.nextSibling;return t.insert(P,()=>Rt(a.name)),t.insert(ue,()=>a.name),t.insert(ne,()=>a.version,null),t.insert(ge,t.createComponent(l.Show,{get when(){return a.installed},get children(){var x=ut();return x.firstChild,t.insert(x,(()=>{var F=t.memo(()=>!!a.current);return()=>F()?` v${a.current}`:""})(),null),x}}),null),t.insert(ge,t.createComponent(l.Show,{get when(){return a.hasUpdate},get children(){var x=lt();return x.firstChild,t.insert(x,()=>a.version,null),x}}),null),re.$$keydown=x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),m())},re.$$click=m,t.insert(he,()=>a.description||"—"),t.insert(Z,t.createComponent(r.Icon,{name:"download",size:"small"}),K),t.insert(Z,()=>Qe(a.weekly),K),t.insert(W,()=>Qe(a.monthly),I),t.insert(oe,t.createComponent(l.Show,{get when(){return a.publisher},get children(){return[Te(),(()=>{var x=ao();return x.firstChild,t.insert(x,()=>a.publisher,null),x})()]}}),null),t.insert(oe,t.createComponent(l.Show,{get when(){return a.published},get children(){return[Te(),(()=>{var x=so(),F=x.firstChild;return t.insert(x,()=>ht(a.published),F),x})()]}}),null),t.insert(re,t.createComponent(l.Show,{get when(){return a.keywords.length>0},get children(){var x=on();return t.insert(x,t.createComponent(l.For,{get each(){return a.keywords.slice(0,3)},children:F=>(()=>{var z=gt();return t.insert(z,F),z})()})),x}}),null),t.insert(_,t.createComponent(l.Show,{get when(){return a.homepage},get children(){return t.createComponent(r.Tooltip,{value:"主页",get children(){return t.createComponent(r.IconButton,{icon:"globe",size:"small",label:"主页",onClick:()=>{Ce(a.homepage)}})}})}}),null),t.insert(_,t.createComponent(l.Show,{get when(){return a.repo},get children(){return t.createComponent(r.Tooltip,{value:"源码仓库",get children(){return t.createComponent(r.IconButton,{icon:"github",size:"small",label:"源码仓库",onClick:()=>{Ce(a.repo)}})}})}}),null),t.insert(_,t.createComponent(r.Button,{variant:"ghost",size:"small",icon:"eye",onClick:m,children:"详情"}),null),t.insert(_,t.createComponent(l.Show,{get when(){return a.hasUpdate},get children(){return t.createComponent(r.Button,{variant:"ghost",size:"small",icon:"download",get busy(){return Y(`install:${a.name}`)},onClick:()=>{$e(a.name,a.version)},children:"更新"})}}),null),t.insert(_,t.createComponent(l.Show,{get when(){return t.memo(()=>!a.hasUpdate)()&&!a.installed},get children(){return t.createComponent(r.Button,{variant:"neutral",size:"small",icon:"download",get busy(){return Y(`install:${a.name}`)},onClick:()=>{$e(a.name)},children:"安装"})}}),null),t.effect(x=>{var F=Y(`install:${a.name}`)?"true":void 0,z=`周下载 ${a.weekly.toLocaleString()} 次`,Q=`月下载 ${a.monthly.toLocaleString()} 次`;return F!==x.e&&t.setAttribute(w,"data-busy",x.e=F),z!==x.t&&t.setAttribute(Z,"title",x.t=z),Q!==x.a&&t.setAttribute(W,"title",x.a=Q),x},{e:void 0,t:void 0,a:void 0}),w})()},xn=a=>{const m=()=>fn(a.spec),w=()=>m()?.hasUpdate===!0,T=()=>Y(`install:${a.name}`),C=()=>m()?.current||a.version,P=()=>(m()?.error??"")!=="";return(()=>{var E=go(),te=E.firstChild,ue=te.firstChild,ne=ue.firstChild,ge=ne.nextSibling,re=ge.firstChild,he=re.firstChild,oe=re.nextSibling,Z=ge.nextSibling,K=ue.nextSibling,ee=K.firstChild,W=te.nextSibling;return t.insert(ne,()=>Rt(a.name)),t.insert(he,()=>a.name),t.insert(oe,()=>a.spec),t.insert(Z,t.createComponent(l.Show,{get when(){return w()},get children(){var I=lt();return I.firstChild,t.insert(I,()=>m().latest,null),I}}),null),t.insert(Z,t.createComponent(l.Show,{get when(){return P()},get children(){return co()}}),null),t.insert(Z,t.createComponent(l.Show,{get when(){return a.kind==="path"},get children(){return po()}}),null),t.insert(ee,()=>yn(C(),m()?.latest??"",w()),null),t.insert(ee,t.createComponent(l.Show,{get when(){return t.memo(()=>!!w())()&&a.kind==="path"},get children(){return[Te(),uo()]}}),null),t.insert(W,t.createComponent(l.Show,{get when(){return Ro.test(a.name)},get children(){return t.createComponent(r.Button,{variant:"ghost",size:"small",icon:"eye",onClick:()=>et(a.name,{version:C()}),children:"详情"})}}),null),t.insert(W,t.createComponent(l.Show,{get when(){return w()},get children(){return t.createComponent(r.Button,{variant:"ghost",size:"small",icon:"download",get busy(){return T()},onClick:()=>{$e(m().name,m().latest)},children:"更新"})}}),null),t.insert(W,t.createComponent(l.Show,{get when(){return a.removable},get children(){return t.createComponent(r.Button,{variant:"ghost-muted",size:"small",icon:"trash",get busy(){return T()},onClick:()=>{pn(a)},children:"移除"})}}),null),t.effect(I=>{var _=w()?"true":void 0,x=T()?"true":void 0;return _!==I.e&&t.setAttribute(E,"data-stale",I.e=_),x!==I.t&&t.setAttribute(E,"data-busy",I.t=x),I},{e:void 0,t:void 0}),E})()};return(()=>{var a=So(),m=a.firstChild,w=m.nextSibling,T=w.firstChild,C=T.firstChild,P=C.firstChild,E=C.nextSibling,te=E.firstChild,ue=te.nextSibling,ne=E.nextSibling,ge=ne.firstChild,re=ge.nextSibling,he=re.nextSibling,oe=he.nextSibling,Z=oe.firstChild,K=w.nextSibling,ee=K.firstChild,W=ee.firstChild;W.nextSibling;var I=K.nextSibling;return t.insert(C,t.createComponent(r.Icon,{name:"extensions",size:"small"}),P),t.insert(T,t.createComponent(l.Show,{get when(){return!e.embedded},get children(){return ho()}}),E),ue.$$click=()=>{Ce(mn())},t.insert(re,()=>o()?.configPath??"读取中…"),t.insert(oe,()=>o()?.configKey??"plugins",Z),t.insert(K,t.createComponent(l.Show,{get when(){return Ue()},get children(){var _=mo(),x=_.firstChild,F=x.nextSibling;return t.insert(_,t.createComponent(r.Icon,{get name(){return Go(Ue().tone)},size:"small"}),x),t.insert(x,()=>Ue().text),F.$$click=()=>Ze(void 0),t.insert(F,t.createComponent(r.Icon,{name:"close",size:"small"})),t.effect(()=>t.setAttribute(_,"data-tone",Ue().tone)),_}}),ee),t.insert(K,t.createComponent(l.Show,{get when(){return o()?.error},get children(){var _=fo(),x=_.firstChild;return t.insert(_,t.createComponent(r.Icon,{name:"circle-exclamation",size:"small"}),x),t.insert(x,()=>o().error),_}}),ee),t.insert(W,()=>nt("catalog","精选目录","extensions",u()?c().length:void 0),null),t.insert(W,()=>nt("search","npm 搜索","magnifying-glass",b()?M().length:void 0),null),t.insert(W,()=>nt("installed","已安装","checklist",o()?.plugins.length??0,we()),null),t.insert(ee,t.createComponent(l.Show,{get when(){return i()==="catalog"},get children(){return t.createComponent(r.Button,{variant:"ghost",size:"small",icon:"refresh",get busy(){return Y("catalog")},onClick:()=>{wt(!0)},children:"更新目录"})}}),null),t.insert(ee,t.createComponent(l.Show,{get when(){return i()==="search"},get children(){return t.createComponent(l.Show,{get when(){return b()},get children(){return t.createComponent(r.Button,{variant:"ghost",size:"small",icon:"close",onClick:()=>{q([]),S(!1),g(""),Ze(void 0)},children:"清空"})}})}}),null),t.insert(ee,t.createComponent(l.Show,{get when(){return i()==="installed"},get children(){return t.createComponent(r.Button,{variant:"ghost",size:"small",icon:"refresh",get busy(){return Y("updates")},onClick:()=>{Ge()},children:"检查更新"})}}),null),t.insert(ee,t.createComponent(r.Menu,{label:"更多操作",icon:"outline-dots",placement:"bottom-end",items:[{type:"group",label:"配置",items:[{label:"打开配置文件",icon:"open-file",onSelect:()=>{gn()}},{label:"重载配置",icon:"refresh",onSelect:()=>{dn()}}]},{type:"separator"},{label:"彻底重启 OpenCode…",icon:"outline-rotate-clockwise",onSelect:()=>{un()}}]}),null),t.insert(a,t.createComponent(l.Switch,{get children(){return[t.createComponent(l.Match,{get when(){return i()==="catalog"},get children(){var _=vo(),x=_.firstChild,F=x.firstChild,z=F.firstChild,Q=z.nextSibling;return t.insert(z,t.createComponent(r.TextInput,{label:"筛选 awesome-opencode 精选插件",placeholder:"按名称、描述或标签筛选,例如 memory / auth / token",type:"search",get value(){return h()},onInput:N=>{k(N),G(He)}})),t.insert(Q,t.createComponent(l.For,{each:zo,children:N=>(()=>{var H=$o(),me=H.firstChild;return H.$$click=()=>{A(N.value),G(He)},t.insert(H,()=>N.label,me),t.insert(me,()=>hn()[N.value]),t.effect(()=>t.setAttribute(H,"data-active",$()===N.value)),H})()})),t.insert(_,t.createComponent(l.Show,{get when(){return t.memo(()=>!!Y("catalog"))()&&c().length===0},get children(){var N=Pe();return t.insert(N,t.createComponent(l.For,{each:[0,1,2,3],children:()=>Gt()})),N}}),null),t.insert(_,t.createComponent(l.Show,{get when(){return!Y("catalog")||c().length>0},get children(){return t.createComponent(l.Show,{get when(){return Fe().length>0},get fallback(){return(()=>{var N=Co(),H=N.firstChild;return H.nextSibling,t.insert(N,t.createComponent(r.Icon,{name:"magnifying-glass",size:"large"}),H),t.insert(N,t.createComponent(r.Button,{variant:"ghost",size:"small",onClick:()=>{k(""),A("all")},children:"清除筛选"}),null),N})()},get children(){return[(()=>{var N=Pe();return t.insert(N,t.createComponent(l.For,{get each(){return Fe().slice(0,L())},children:H=>wn(H)})),N})(),t.createComponent(l.Show,{get when(){return Fe().length>L()},get children(){return t.createComponent(r.Button,{variant:"ghost",size:"small",onClick:()=>G(N=>N+He),get children(){return["显示更多(还有 ",t.memo(()=>Fe().length-L())," 个)"]}})}})]}})}}),null),_}}),t.createComponent(l.Match,{get when(){return i()==="search"},get children(){var _=wo(),x=_.firstChild,F=x.firstChild;return x.nextSibling,t.insert(F,t.createComponent(r.TextInput,{label:"搜索 npm 上的 OpenCode 插件",placeholder:"搜索插件,例如 qoder / notify / usage(输入后自动搜索)",type:"search",get value(){return j()},onInput:cn,onSubmit:z=>{Me&&window.clearTimeout(Me),Ke=z.trim(),Re(z)}})),t.insert(x,t.createComponent(r.Button,{variant:"contrast",icon:"magnifying-glass",get busy(){return Y("search")},onClick:()=>{Re(j())},children:"搜索"}),null),t.insert(_,t.createComponent(l.Show,{get when(){return!b()},get children(){var z=bo(),Q=z.firstChild,N=Q.nextSibling,H=N.nextSibling;return t.insert(z,t.createComponent(r.Icon,{name:"magnifying-glass",size:"large"}),Q),t.insert(H,t.createComponent(l.For,{each:Eo,children:me=>(()=>{var fe=_o();return fe.$$click=()=>{Re(me)},t.insert(fe,me),fe})()})),z}}),null),t.insert(_,t.createComponent(l.Show,{get when(){return b()},get children(){return[(()=>{var z=yo(),Q=z.firstChild,N=Q.firstChild,H=N.nextSibling,me=Q.nextSibling;return t.insert(H,()=>je().length),t.insert(me,t.createComponent(l.For,{each:Po,children:fe=>(()=>{var B=Oo();return B.$$click=()=>f(fe.value),t.insert(B,()=>fe.label),t.effect(()=>t.setAttribute(B,"data-active",y()===fe.value)),B})()})),z})(),t.createComponent(l.Show,{get when(){return t.memo(()=>!!Y("search"))()&&M().length===0},get children(){var z=Pe();return t.insert(z,t.createComponent(l.For,{each:[0,1,2,3],children:()=>Gt()})),z}}),t.createComponent(l.Show,{get when(){return!Y("search")||M().length>0},get children(){return t.createComponent(l.Show,{get when(){return je().length>0},get fallback(){return(()=>{var z=Ao(),Q=z.firstChild;return t.insert(z,t.createComponent(r.Icon,{name:"magnifying-glass",size:"large"}),Q),z})()},get children(){return[(()=>{var z=Pe();return t.insert(z,t.createComponent(l.For,{get each(){return tt()},children:Q=>kn(Q)})),z})(),t.createComponent(l.Show,{get when(){return je().length>tt().length},get children(){return t.createComponent(r.Button,{variant:"ghost",size:"small",onClick:()=>ae(z=>z+12),get children(){return["显示更多(还有 ",t.memo(()=>je().length-tt().length)," 个)"]}})}})]}})}})]}}),null),_}}),t.createComponent(l.Match,{get when(){return i()==="installed"},get children(){var _=xo(),x=_.firstChild,F=x.firstChild,z=F.firstChild,Q=z.nextSibling,N=F.nextSibling,H=N.firstChild,me=H.firstChild,fe=me.nextSibling;return N.nextSibling,t.insert(Q,()=>o()?.plugins.length??0),H.$$click=()=>{we()>0&&D(!O())},t.insert(fe,we),t.insert(x,t.createComponent(l.Show,{get when(){return Se()},get children(){var B=ko();return B.firstChild,t.insert(B,(()=>{var se=t.memo(()=>we()>0);return()=>se()?` · ${we()} 个可更新`:" · 全部已是最新"})(),null),B}}),null),t.insert(_,t.createComponent(l.Show,{get when(){return(o()?.plugins.length??0)>0},get fallback(){return(()=>{var B=To(),se=B.firstChild;return t.insert(B,t.createComponent(r.Icon,{name:"extensions",size:"large"}),se),B})()},get children(){return t.createComponent(l.Show,{get when(){return kt().length>0},get fallback(){return(()=>{var B=Io(),se=B.firstChild;return se.nextSibling,t.insert(B,t.createComponent(r.Icon,{name:"checklist",size:"large"}),se),t.insert(B,t.createComponent(r.Button,{variant:"ghost",size:"small",onClick:()=>D(!1),children:"显示全部"}),null),B})()},get children(){var B=Pe();return t.insert(B,t.createComponent(l.For,{get each(){return kt()},children:se=>xn(se)})),B}})}}),null),t.effect(B=>{var se=O(),xt=we()===0?"true":void 0,St=we()===0?"检查更新后再来看可更新的插件":"只显示有新版本的插件";return se!==B.e&&t.setAttribute(H,"data-active",B.e=se),xt!==B.t&&t.setAttribute(H,"data-disabled",B.t=xt),St!==B.a&&t.setAttribute(H,"title",B.a=St),B},{e:void 0,t:void 0,a:void 0}),_}})]}}),I),t.effect(_=>{var x=e.embedded?"true":void 0,F=o()?.configPath;return x!==_.e&&t.setAttribute(a,"data-embedded",_.e=x),F!==_.t&&t.setAttribute(ne,"title",_.t=F),_},{e:void 0,t:void 0}),a})()}function qo(e){const r=e.ctx.ui,o=()=>{e.onClose(),setTimeout(()=>e.ctx.layout.settings("hub"),0)};return t.createComponent(r.Dialog,{title:"插件中心",size:"x-large",get footer(){return(()=>{var n=Lo();return n.firstChild,t.insert(n,t.createComponent(r.Button,{size:"small",variant:"ghost",icon:"settings-gear",onClick:o,children:"在设置中打开"}),null),t.insert(n,t.createComponent(r.Button,{size:"small",get onClick(){return e.onClose},children:"关闭"}),null),n})()},get children(){return t.createComponent(an,{get ctx(){return e.ctx},get admin(){return e.admin},embedded:!0})}})}t.delegateEvents(["click","keydown"]);const Ho=Ee.Plugin.define({setup(e){const r=e.main(Ct),o=()=>{e.dialogs.active()||e.dialogs.open(n=>t.createComponent(qo,{ctx:e,admin:r,onClose:()=>n.close()}))};e.add(Ee.SettingsPage,{id:"hub",title:"插件中心",icon:"extensions",entries:[{id:"hub",title:"插件中心",description:"浏览社区精选插件,按 npm 搜索,安装或移除",keywords:"plugin npm install remove hub catalog marketplace"}],render:()=>t.createComponent(an,{ctx:e,admin:r})}),e.add(Ee.TitlebarItem,()=>({id:"hub",label:"插件中心",title:"打开插件中心",icon:"extensions",run:o})),e.add(Ee.Command,()=>({id:"open",title:"插件中心",description:"浏览、搜索、安装与更新 OpenCode 插件",keywords:"plugin hub install browse npm catalog marketplace",group:"设置",section:"navigation",bind:"mod+alt+p",featured:!0,run:o}))},main(e){e.provide(Ct,{snapshot:()=>de(),updates:()=>Yn(),search:r=>gr(r.query),browse:async r=>{const o=await de();return Cr(new Set(o.plugins.map(n=>n.name)),r.force)},detail:r=>ur(r.name),openUrl:r=>({ok:hr(r.url)}),openConfig:async()=>({ok:await mr()}),install:r=>nr(r.spec,r.version),remove:r=>rr(r.spec),reload:()=>vr(e.cli.command),restart:()=>({ok:fr()})})}});exports.default=Ho;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-plugin-hub",
3
- "version": "0.1.4",
3
+ "version": "0.2.0",
4
4
  "description": "Plugin manager for OpenCode Desktop: browse community plugins, search npm, inspect README and downloads, install and update without editing JSON.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -58,6 +58,6 @@
58
58
  "dev": "vite build --watch",
59
59
  "typecheck": "tsc --noEmit",
60
60
  "refresh": "node scripts/refresh-registry.mjs",
61
- "prepublishOnly": "npm run typecheck && npm run build"
61
+ "prepublishOnly": "node scripts/ensure-ci-publish.mjs && npm run typecheck && npm run build"
62
62
  }
63
63
  }
package/src/gui/page.tsx CHANGED
@@ -1,4 +1,4 @@
1
- import { createMemo, createSignal, For, onMount, Show, Switch, Match } from "solid-js"
1
+ import { createEffect, createMemo, createSignal, For, onMount, Show, Switch, Match } from "solid-js"
2
2
  import type { Context, IconName, IpcClient } from "@opencode/plugin/gui"
3
3
  import type { Admin } from "../contract"
4
4
 
@@ -241,6 +241,21 @@ const CSS = `
241
241
  background: color-mix(in srgb, var(--ph-warning) 7%, transparent);
242
242
  }
243
243
  .ph-notice span { flex: 1; min-width: 0; }
244
+ .ph-notice-close {
245
+ flex: 0 0 auto;
246
+ display: grid;
247
+ place-items: center;
248
+ width: 22px;
249
+ height: 22px;
250
+ padding: 0;
251
+ border: 0;
252
+ border-radius: 6px;
253
+ background: transparent;
254
+ color: inherit;
255
+ opacity: 0.55;
256
+ cursor: pointer;
257
+ }
258
+ .ph-notice-close:hover { opacity: 1; background: color-mix(in srgb, currentColor 10%, transparent); }
244
259
 
245
260
  /* toolbar and tabs */
246
261
  .ph-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
@@ -961,6 +976,8 @@ export function PluginHubPage(props: { ctx: Context; admin: AdminClient; embedde
961
976
  const [query, setQuery] = createSignal("")
962
977
  const [searched, setSearched] = createSignal(false)
963
978
  const [sort, setSort] = createSignal<Sort>("relevance")
979
+ /** 搜索结果分批渲染:50 张卡一次挂载会拖慢首屏。 */
980
+ const [hitLimit, setHitLimit] = createSignal(12)
964
981
 
965
982
  const [updates, setUpdates] = createSignal<Map<string, UpdateInfo>>(new Map())
966
983
  const [checked, setChecked] = createSignal(false)
@@ -1060,6 +1077,21 @@ export function PluginHubPage(props: { ctx: Context; admin: AdminClient; embedde
1060
1077
  })
1061
1078
  }
1062
1079
 
1080
+ /** 输入防抖 450ms 自动搜索;同一个词不重复请求。 */
1081
+ let searchTimer: number | undefined
1082
+ let lastSearch = ""
1083
+ const scheduleSearch = (text: string) => {
1084
+ setQuery(text)
1085
+ if (searchTimer) window.clearTimeout(searchTimer)
1086
+ const trimmed = text.trim()
1087
+ if (!trimmed) return
1088
+ searchTimer = window.setTimeout(() => {
1089
+ if (trimmed === lastSearch) return
1090
+ lastSearch = trimmed
1091
+ void runSearch(trimmed)
1092
+ }, 450)
1093
+ }
1094
+
1063
1095
  const install = async (name: string, version = "") => {
1064
1096
  await track(`install:${name}`, async () => {
1065
1097
  try {
@@ -1069,7 +1101,7 @@ export function PluginHubPage(props: { ctx: Context; admin: AdminClient; embedde
1069
1101
  notify(result.message, "error")
1070
1102
  return
1071
1103
  }
1072
- notify(`${result.message}。点工具栏的「彻底重启」后生效`, "success")
1104
+ notify(`${result.message}。点右上角「更多操作 → 彻底重启 OpenCode」后生效`, "success")
1073
1105
  const latest = version || hits().find((hit) => hit.name === name)?.version || ""
1074
1106
  setCatalog((prev) => prev.map((entry) => (entry.pkg === name ? { ...entry, installed: true } : entry)))
1075
1107
  setHits((prev) =>
@@ -1100,7 +1132,7 @@ export function PluginHubPage(props: { ctx: Context; admin: AdminClient; embedde
1100
1132
  notify(result.message, "error")
1101
1133
  return
1102
1134
  }
1103
- notify(`${result.message}。点工具栏的「彻底重启」后生效`, "success")
1135
+ notify(`${result.message}。点右上角「更多操作 → 彻底重启 OpenCode」后生效`, "success")
1104
1136
  setCatalog((prev) =>
1105
1137
  prev.map((item) => (item.pkg === entry.name ? { ...item, installed: false } : item)),
1106
1138
  )
@@ -1226,6 +1258,12 @@ export function PluginHubPage(props: { ctx: Context; admin: AdminClient; embedde
1226
1258
  else if (sort() === "recent") list.sort((a, b) => (b.published || "").localeCompare(a.published || ""))
1227
1259
  return list
1228
1260
  })
1261
+ const visibleHits = createMemo(() => sortedHits().slice(0, hitLimit()))
1262
+ // 结果集合变化(新搜索、清空)后回到首批;副作用放在 createEffect 而不是 memo 里。
1263
+ createEffect(() => {
1264
+ void hits()
1265
+ setHitLimit(12)
1266
+ })
1229
1267
 
1230
1268
  const registryUrl = () => meta()?.registry || CATALOG_SOURCE_FALLBACK
1231
1269
  const outdated = createMemo(() => [...updates().values()].filter((item) => item.hasUpdate).length)
@@ -1250,6 +1288,7 @@ export function PluginHubPage(props: { ctx: Context; admin: AdminClient; embedde
1250
1288
  }
1251
1289
 
1252
1290
  onMount(() => {
1291
+ // refresh 先行保证「已安装」不依赖目录拉取的成败;loadCatalog 成功后还会再同步一次。
1253
1292
  void refresh()
1254
1293
  void loadCatalog(false)
1255
1294
  void checkUpdates(true)
@@ -1624,6 +1663,9 @@ export function PluginHubPage(props: { ctx: Context; admin: AdminClient; embedde
1624
1663
  <div class="ph-notice" data-tone={note()!.tone}>
1625
1664
  <ui.Icon name={noteIcon(note()!.tone)} size="small" />
1626
1665
  <span>{note()!.text}</span>
1666
+ <button type="button" class="ph-notice-close" aria-label="关闭提示" onClick={() => setNote(undefined)}>
1667
+ <ui.Icon name="close" size="small" />
1668
+ </button>
1627
1669
  </div>
1628
1670
  </Show>
1629
1671
 
@@ -1641,33 +1683,6 @@ export function PluginHubPage(props: { ctx: Context; admin: AdminClient; embedde
1641
1683
  {tabButton("installed", "已安装", "checklist", state()?.plugins.length ?? 0, outdated())}
1642
1684
  </div>
1643
1685
  <span class="ph-spacer" />
1644
- <ui.Button
1645
- variant="ghost"
1646
- size="small"
1647
- icon="open-file"
1648
- busy={isBusy("config")}
1649
- onClick={() => void openConfig()}
1650
- >
1651
- 打开配置
1652
- </ui.Button>
1653
- <ui.Button
1654
- variant="ghost"
1655
- size="small"
1656
- icon="refresh"
1657
- busy={isBusy("reload")}
1658
- onClick={() => void reload()}
1659
- >
1660
- 重载配置
1661
- </ui.Button>
1662
- <ui.Button
1663
- variant="neutral"
1664
- size="small"
1665
- icon="outline-rotate-clockwise"
1666
- busy={isBusy("restart")}
1667
- onClick={() => void restartApp()}
1668
- >
1669
- 彻底重启
1670
- </ui.Button>
1671
1686
  <Show when={tab() === "catalog"}>
1672
1687
  <ui.Button
1673
1688
  variant="ghost"
@@ -1707,6 +1722,28 @@ export function PluginHubPage(props: { ctx: Context; admin: AdminClient; embedde
1707
1722
  检查更新
1708
1723
  </ui.Button>
1709
1724
  </Show>
1725
+ {/* 低频管理操作收进溢出菜单,工具栏只留当前任务需要的动作 */}
1726
+ <ui.Menu
1727
+ label="更多操作"
1728
+ icon="outline-dots"
1729
+ placement="bottom-end"
1730
+ items={[
1731
+ {
1732
+ type: "group",
1733
+ label: "配置",
1734
+ items: [
1735
+ { label: "打开配置文件", icon: "open-file", onSelect: () => void openConfig() },
1736
+ { label: "重载配置", icon: "refresh", onSelect: () => void reload() },
1737
+ ],
1738
+ },
1739
+ { type: "separator" },
1740
+ {
1741
+ label: "彻底重启 OpenCode…",
1742
+ icon: "outline-rotate-clockwise",
1743
+ onSelect: () => void restartApp(),
1744
+ },
1745
+ ]}
1746
+ />
1710
1747
  </div>
1711
1748
  </div>
1712
1749
 
@@ -1793,11 +1830,15 @@ export function PluginHubPage(props: { ctx: Context; admin: AdminClient; embedde
1793
1830
  <div class="ph-grow">
1794
1831
  <ui.TextInput
1795
1832
  label="搜索 npm 上的 OpenCode 插件"
1796
- placeholder="搜索插件,例如 qoder / notify / usage"
1833
+ placeholder="搜索插件,例如 qoder / notify / usage(输入后自动搜索)"
1797
1834
  type="search"
1798
1835
  value={query()}
1799
- onInput={setQuery}
1800
- onSubmit={(value) => void runSearch(value)}
1836
+ onInput={scheduleSearch}
1837
+ onSubmit={(value) => {
1838
+ if (searchTimer) window.clearTimeout(searchTimer)
1839
+ lastSearch = value.trim()
1840
+ void runSearch(value)
1841
+ }}
1801
1842
  />
1802
1843
  </div>
1803
1844
  <ui.Button
@@ -1865,8 +1906,17 @@ export function PluginHubPage(props: { ctx: Context; admin: AdminClient; embedde
1865
1906
  }
1866
1907
  >
1867
1908
  <div class="ph-list">
1868
- <For each={sortedHits()}>{(hit) => searchRow(hit)}</For>
1909
+ <For each={visibleHits()}>{(hit) => searchRow(hit)}</For>
1869
1910
  </div>
1911
+ <Show when={sortedHits().length > visibleHits().length}>
1912
+ <ui.Button
1913
+ variant="ghost"
1914
+ size="small"
1915
+ onClick={() => setHitLimit((n) => n + 12)}
1916
+ >
1917
+ 显示更多(还有 {sortedHits().length - visibleHits().length} 个)
1918
+ </ui.Button>
1919
+ </Show>
1870
1920
  </Show>
1871
1921
  </Show>
1872
1922
  </Show>
@@ -1934,7 +1984,7 @@ export function PluginHubPage(props: { ctx: Context; admin: AdminClient; embedde
1934
1984
 
1935
1985
  <footer class="ph-footer">
1936
1986
  <div class="ph-footer-note">
1937
- 安装和移除只改配置,不会立即生效:插件与模型目录都是启动时快照的。改完点工具栏的「彻底重启」,应用会自动退出并重新打开。
1987
+ 安装和移除只改配置,不会立即生效:插件与模型目录都是启动时快照的。改完点右上角「更多操作 → 彻底重启 OpenCode」,应用会自动退出并重新打开。
1938
1988
  </div>
1939
1989
  </footer>
1940
1990
  </div>