rovecode 0.4.0-beta.2 → 0.4.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/README.md +13 -0
- package/dist/cli/app-j6gn14w3.js +2 -0
- package/dist/cli/{ask-user-p8hq4xgj.js → ask-user-cwstt8fz.js} +1 -1
- package/dist/cli/auth-login-9bbp9915.js +2 -0
- package/dist/cli/{bench-xv3ypwev.js → bench-16zqdms5.js} +1 -1
- package/dist/cli/catalog-1xchffa4.js +2 -0
- package/dist/cli/cli-1n1zb64f.js +2 -0
- package/dist/cli/client-2t9gjkck.js +2 -0
- package/dist/cli/{commands-3p7e4xxs.js → commands-exafvm2b.js} +1 -1
- package/dist/cli/connect-6zde0kn3.js +2 -0
- package/dist/cli/{context-cmd-eqxmxhzq.js → context-cmd-5t43wgqt.js} +1 -1
- package/dist/cli/context-report-kt01pw8y.js +2 -0
- package/dist/cli/{count-remote-mby98cd0.js → count-remote-ap7x3vh6.js} +1 -1
- package/dist/cli/{design-122y0axd.js → design-ne5zszyh.js} +1 -1
- package/dist/cli/dispatch-2r5myxye.js +2 -0
- package/dist/cli/doctor-ws4fh4tn.js +3 -0
- package/dist/cli/{executor-ftvg6tsy.js → executor-bdrjn634.js} +1 -1
- package/dist/cli/export-1mxb9g5p.js +2 -0
- package/dist/cli/{files-cez9a96p.js → files-g104xghh.js} +1 -1
- package/dist/cli/gauntlet-07xrjpj7.js +2 -0
- package/dist/cli/{gauntlet-runner-r515m7kk.js → gauntlet-runner-xvy64436.js} +1 -1
- package/dist/cli/{gauntlet-wave3-bnkjk2v2.js → gauntlet-wave3-jm91yt5w.js} +1 -1
- package/dist/cli/{gauntlet-wave4-acs9s60q.js → gauntlet-wave4-r13py7p1.js} +1 -1
- package/dist/cli/hashline-znvrat11.js +2 -0
- package/dist/cli/http-xafw6fsh.js +143 -0
- package/dist/cli/{index-z5qt1s76.js → index-1sgjm25y.js} +1 -1
- package/dist/cli/init-g2m0tn4m.js +51 -0
- package/dist/cli/install-avaqjjqq.js +2 -0
- package/dist/cli/loop-mmpfft01.js +2 -0
- package/dist/cli/{main-a3f51n0x.js → main-0904f6ps.js} +1 -1
- package/dist/cli/{main-f33fc5je.js → main-0ab9fc26.js} +2 -2
- package/dist/cli/{main-n6qrdbmy.js → main-0mtcdbs7.js} +2 -2
- package/dist/cli/main-0z1w2zsg.js +3 -0
- package/dist/cli/{main-rvetps99.js → main-1dchs7xv.js} +2 -2
- package/dist/cli/{main-rpg7h8mb.js → main-1ereejm1.js} +2 -2
- package/dist/cli/{main-6vjeds42.js → main-1k1kw6b5.js} +2 -2
- package/dist/cli/{main-hrrvcfan.js → main-27y4sm2k.js} +2 -2
- package/dist/cli/{main-8c1tbazx.js → main-2wwjex5j.js} +2 -2
- package/dist/cli/main-2yfck9b5.js +3 -0
- package/dist/cli/main-2zmzgkwh.js +3 -0
- package/dist/cli/{main-xt9zc3n6.js → main-351pz3z7.js} +1 -1
- package/dist/cli/{main-kba6zeyd.js → main-3gjqfh7a.js} +1 -1
- package/dist/cli/{main-s4bb0jav.js → main-3nf3kgve.js} +1 -1
- package/dist/cli/{main-2z3dek0b.js → main-3pjrb2hd.js} +1 -1
- package/dist/cli/{main-qj2djy17.js → main-3rxcvgna.js} +3 -3
- package/dist/cli/{main-9a9rnh47.js → main-4b3jgy66.js} +1 -1
- package/dist/cli/{main-6dtqmbt6.js → main-4wndhjdc.js} +1 -1
- package/dist/cli/{main-9ht36z12.js → main-4xcmvxnk.js} +2 -2
- package/dist/cli/{main-vp2dfb7s.js → main-5tbz0wbz.js} +2 -2
- package/dist/cli/{main-wpkyraxh.js → main-5ywnwthm.js} +2 -2
- package/dist/cli/{main-yrjt2sqt.js → main-6b62vkz0.js} +2 -2
- package/dist/cli/{main-2zgsknth.js → main-6dnk69vp.js} +1 -1
- package/dist/cli/{main-nvc3yjay.js → main-6genrmhs.js} +2 -2
- package/dist/cli/{main-rsy72qmw.js → main-73g7eff4.js} +2 -2
- package/dist/cli/{main-jak598k9.js → main-7c5thhjd.js} +1 -1
- package/dist/cli/{main-y5c82rxr.js → main-7rn6bqje.js} +1 -1
- package/dist/cli/{main-4p4e2w7x.js → main-80haw7qk.js} +2 -2
- package/dist/cli/{main-01pv9206.js → main-875s60s2.js} +2 -2
- package/dist/cli/{main-ywbxshqc.js → main-8kjxbpw4.js} +1 -1
- package/dist/cli/{main-1ztz6fkj.js → main-90ds1z4e.js} +1 -1
- package/dist/cli/{main-mjt2p7aj.js → main-9etavkew.js} +1 -1
- package/dist/cli/main-a9njrkk1.js +3 -0
- package/dist/cli/{main-fvnpq46y.js → main-aecrjq2d.js} +2 -2
- package/dist/cli/{main-23q7cmww.js → main-ck9asesq.js} +2 -2
- package/dist/cli/{main-wqt32p5x.js → main-cta9racd.js} +2 -2
- package/dist/cli/{main-wm997zjx.js → main-ddv7j2ag.js} +1 -1
- package/dist/cli/{main-ntqef02r.js → main-dfreez27.js} +1 -1
- package/dist/cli/{main-m8vm17zq.js → main-f7rw7des.js} +1 -1
- package/dist/cli/{main-rebtt91r.js → main-ggcn7rd7.js} +2 -2
- package/dist/cli/{main-gbbty4d4.js → main-gzkmycnv.js} +1 -1
- package/dist/cli/{main-vxnwe5xx.js → main-hq51jg8v.js} +2 -2
- package/dist/cli/{main-vqbr22sz.js → main-jft389w9.js} +2 -2
- package/dist/cli/{main-qvarybsp.js → main-k1eqkg83.js} +2 -2
- package/dist/cli/{main-2wyax8k9.js → main-k2y8a2aw.js} +2 -2
- package/dist/cli/main-kcpbykxz.js +4 -0
- package/dist/cli/{main-45rn3trk.js → main-kd488vje.js} +1 -1
- package/dist/cli/main-kh32yvgk.js +5 -0
- package/dist/cli/{main-z13755t8.js → main-kqxnqjnv.js} +4 -4
- package/dist/cli/{main-b8zq261k.js → main-kyn0xnsg.js} +2 -2
- package/dist/cli/{main-evgz4mp5.js → main-m1kk6fp5.js} +1 -1
- package/dist/cli/{main-5py0rkmc.js → main-mv40pcr2.js} +1 -1
- package/dist/cli/{main-vhrrq337.js → main-n0t3973w.js} +1 -1
- package/dist/cli/{main-s9v8k74e.js → main-pknhvrmj.js} +2 -2
- package/dist/cli/{main-kwwsz6rq.js → main-pn1w7a7j.js} +2 -2
- package/dist/cli/{main-6h9x282m.js → main-prxxs70n.js} +2 -2
- package/dist/cli/{main-2rzbexn2.js → main-q3vsesf9.js} +1 -1
- package/dist/cli/{main-gth53dnt.js → main-rdgdw24b.js} +7 -7
- package/dist/cli/{main-4y0tnfpa.js → main-rfth4tbm.js} +1 -1
- package/dist/cli/{main-wk2csfnj.js → main-rg0wn0xf.js} +2 -2
- package/dist/cli/{main-xx2z3zh5.js → main-sdmxhtv8.js} +1 -1
- package/dist/cli/{main-mg9b20ac.js → main-skbp13js.js} +1 -1
- package/dist/cli/{main-xfekqh9m.js → main-t4xnd213.js} +1 -1
- package/dist/cli/{main-7kt6r53y.js → main-vqak588n.js} +2 -2
- package/dist/cli/{main-hqbz10aw.js → main-w2n1303f.js} +1 -1
- package/dist/cli/{main-na7wse0x.js → main-wbrdspr2.js} +2 -2
- package/dist/cli/{main-a2yfvcy9.js → main-wsrg79c1.js} +2 -2
- package/dist/cli/{main-hzwtsb2m.js → main-x4r0fne4.js} +2 -2
- package/dist/cli/{main-78gq4bt9.js → main-xea2f3tn.js} +1 -1
- package/dist/cli/{main-v8y60bb2.js → main-xg704a3c.js} +1 -1
- package/dist/cli/{main-p0cfn6nr.js → main-xvnrabfp.js} +2 -2
- package/dist/cli/{main-45ejth3a.js → main-xy53xf0r.js} +2 -2
- package/dist/cli/{main-x9ct6y1a.js → main-y1fqy60y.js} +2 -2
- package/dist/cli/{main-j7ttv0sd.js → main-yn8cd281.js} +4 -4
- package/dist/cli/{main-zc7pyrbj.js → main-yr0ksc0h.js} +1 -1
- package/dist/cli/{main-tkgarpjj.js → main-z2ex2vyf.js} +2 -2
- package/dist/cli/{main-mgb9ccnx.js → main-z3aayzvq.js} +1 -1
- package/dist/cli/{main-tjvwmscs.js → main-zaqh35jg.js} +2 -2
- package/dist/cli/{main-edxc3yzt.js → main-zc2e8e46.js} +2 -2
- package/dist/cli/{main-bxtvnf6d.js → main-zzrfw6cf.js} +2 -2
- package/dist/cli/main.js +5 -4
- package/dist/cli/{market-cmd-bm5xvn9f.js → market-cmd-e14kmx9n.js} +2 -2
- package/dist/cli/{mcp-login-bthtfpt7.js → mcp-login-wq7ktdek.js} +1 -1
- package/dist/cli/mcp-market-cmd-9mg3jecy.js +2 -0
- package/dist/cli/{notify-54v5z9dz.js → notify-b7qc0cjb.js} +1 -1
- package/dist/cli/{oauth-g5gme95c.js → oauth-z8whcgfx.js} +1 -1
- package/dist/cli/{output-satndjap.js → output-b3ewj3ps.js} +1 -1
- package/dist/cli/{profiles-sfhpbq3m.js → profiles-6mr5he5e.js} +1 -1
- package/dist/cli/{provider-config-hv3xtdt4.js → provider-config-g7j42q8x.js} +1 -1
- package/dist/cli/provider-jr1y8vvm.js +2 -0
- package/dist/cli/registry-s8yk86g0.js +2 -0
- package/dist/cli/{registry-fh0hdnyn.js → registry-t6p8d4mn.js} +1 -1
- package/dist/cli/{repl-t4z03mqq.js → repl-bajwe1mh.js} +1 -1
- package/dist/cli/{resume-fqt4chg8.js → resume-rwn9nz7y.js} +1 -1
- package/dist/cli/run-flags-nah7ndpt.js +2 -0
- package/dist/cli/runtime-n7gafzhb.js +2 -0
- package/dist/cli/{sandbox-config-g4qxd7y5.js → sandbox-config-emdy18x4.js} +1 -1
- package/dist/cli/{server-r0b6bksk.js → server-b0nvs2bn.js} +1 -1
- package/dist/cli/session-arg-y75wd4kj.js +2 -0
- package/dist/cli/session-j62evmjq.js +2 -0
- package/dist/cli/{sessions-cmd-adw7svfn.js → sessions-cmd-tsnwz0ns.js} +1 -1
- package/dist/cli/{settings-y9rzcqx8.js → settings-df10wfez.js} +1 -1
- package/dist/cli/{setup-jmbr11j0.js → setup-jzvv72fg.js} +1 -1
- package/dist/cli/{sextant-smoke-tcth0vea.js → sextant-smoke-37m81ke6.js} +1 -1
- package/dist/cli/{skills-cmd-zbdy99v6.js → skills-cmd-gjxnxnhx.js} +1 -1
- package/dist/cli/smoke-p7748apt.js +8 -0
- package/dist/cli/{start-chat-p01cdks3.js → start-chat-s4st3mm0.js} +3 -3
- package/dist/cli/stream-gmeyewds.js +2 -0
- package/dist/cli/task-gh0kkp3n.js +2 -0
- package/dist/cli/tasks-z1kfpe8e.js +2 -0
- package/dist/cli/{thinking-a5ngvqyh.js → thinking-0eqkrz6t.js} +1 -1
- package/dist/cli/{todo-1wxpcecx.js → todo-5brcrt9m.js} +1 -1
- package/dist/cli/{tools-x1tj4fxm.js → tools-7pzm0vj9.js} +1 -1
- package/dist/cli/{tools-2ftsya7w.js → tools-s635p6s8.js} +1 -1
- package/dist/cli/trust-cmd-cjav8zgm.js +2 -0
- package/dist/cli/{update-check-ygt3vd7m.js → update-check-pt31bm2f.js} +1 -1
- package/dist/cli/{update-cmd-v23qhr8c.js → update-cmd-tk131s9t.js} +1 -1
- package/dist/cli/{voice-g1gtck92.js → voice-56nabd8d.js} +1 -1
- package/dist/cli/{webfetch-0nnrjgb5.js → webfetch-xd8q596m.js} +1 -1
- package/dist/cli/{websearch-f0vr2p7d.js → websearch-5hkf98k1.js} +1 -1
- package/dist/cli/workflow-cmd-cy3cvzjp.js +4 -0
- package/dist/cli/{workspace-9rq1w4ta.js → workspace-q10g5z3e.js} +1 -1
- package/dist/lib/index.js +44 -44
- package/dist/lib/plugins.js +54 -5
- package/dist/lib/public-api.js +15 -15
- package/dist/lib/sdk.js +360 -0
- package/package.json +3 -2
- package/dist/cli/app-dybnr56b.js +0 -2
- package/dist/cli/auth-login-ewpgw5sm.js +0 -2
- package/dist/cli/catalog-737wb2s0.js +0 -2
- package/dist/cli/cli-arhg40m0.js +0 -2
- package/dist/cli/client-cf2pxx8q.js +0 -2
- package/dist/cli/connect-3q93d7cb.js +0 -2
- package/dist/cli/context-report-hbw9zfes.js +0 -2
- package/dist/cli/dispatch-b4egzvvh.js +0 -2
- package/dist/cli/doctor-x4jkv72e.js +0 -3
- package/dist/cli/export-pdgdhkch.js +0 -2
- package/dist/cli/gauntlet-r3xxaszc.js +0 -2
- package/dist/cli/hashline-ewg5hbe3.js +0 -2
- package/dist/cli/http-n0kehsk8.js +0 -5
- package/dist/cli/install-80mp63kx.js +0 -2
- package/dist/cli/loop-12twjcat.js +0 -2
- package/dist/cli/main-7jd5vh3x.js +0 -4
- package/dist/cli/main-mg4f96e1.js +0 -3
- package/dist/cli/main-wgph00xf.js +0 -5
- package/dist/cli/main-ys6zj3yr.js +0 -3
- package/dist/cli/mcp-market-cmd-mbeshfyd.js +0 -2
- package/dist/cli/provider-kwzq6g84.js +0 -2
- package/dist/cli/registry-y1y8e94r.js +0 -2
- package/dist/cli/run-flags-rysbag9t.js +0 -2
- package/dist/cli/runtime-j19fjbsa.js +0 -2
- package/dist/cli/session-arg-txmn5g4x.js +0 -2
- package/dist/cli/session-ed250d9j.js +0 -2
- package/dist/cli/smoke-1bg937kx.js +0 -8
- package/dist/cli/stream-4wmyaypz.js +0 -2
- package/dist/cli/task-eg4s093s.js +0 -2
- package/dist/cli/tasks-12v9rr9k.js +0 -2
- package/dist/cli/trust-cmd-hccxehzb.js +0 -2
- package/dist/rovecode.exe +0 -4
package/dist/lib/plugins.js
CHANGED
|
@@ -1,6 +1,55 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{readFileSync as
|
|
3
|
-
`),i}function y(e){let t=[],i=(o)=>{let u;try{u=qt(o,{withFileTypes:!0})}catch{return}for(let c of u){if(Qt.has(c.name))continue;let r=O(o,c.name);if(c.isDirectory())i(r);else if(c.isFile())t.push(It(e,r).replace(/\\/g,"/"))}};return i(e),t.sort()}function K(e){let t=bt("sha256");for(let i of y(e)){t.update(i),t.update("\x00");try{t.update(et(O(e,i)))}catch{}t.update("\x00")}return t.digest("hex")}var M=(e)=>Et(e).replace(/\\/g,"/");function it(e,t,i){return e.trusted[M(t)]===i}function b(e){try{return Bt(e).isDirectory()}catch{return!1}}var Kt=/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g,Lt=/<[^<>]*[a-z][^<>]*>/g;function Pt(e,t,i){return e.replace(Kt,(o,u)=>{let c=t[u];if(c===void 0)return i.push(u),"";return c})}function x(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function ot(e,t,i,o,u=process.env,c={}){if(!x(t)){o.push(`${i}: server "${e}" is not an object; skipped`);return}let r=[],s=(v)=>Pt(v,u,r),m=typeof t.command==="string"&&t.command.length>0?t.command:void 0,n=typeof t.url==="string"&&t.url.length>0?s(t.url):void 0,a=typeof t.transport==="string"?t.transport:typeof t.type==="string"?t.type:void 0,l;if(a==="stdio")l="stdio";else if(a==="http"||a==="streamable-http"||a==="streamable_http")l="http";else if(a==="sse")l="sse";else if(a!==void 0){o.push(`${i}: server "${e}" has unknown transport "${a}"; skipped`);return}else l=n!==void 0?"http":m!==void 0?"stdio":void 0;if(l===void 0){o.push(`${i}: server "${e}" has neither command nor url; skipped`);return}if(l==="stdio"&&m===void 0){o.push(`${i}: stdio server "${e}" is missing command; skipped`);return}if(l==="http"||l==="sse"){if(n===void 0){o.push(`${i}: ${l} server "${e}" is missing url; skipped`);return}try{new URL(n)}catch{o.push(`${i}: ${l} server "${e}" has invalid url "${n}"; skipped`);return}}let p;if(t.args!==void 0)if(Array.isArray(t.args)&&t.args.every((v)=>typeof v==="string"))p=t.args.map(s);else{o.push(`${i}: server "${e}" has non-string args; skipped`);return}let d;if(x(t.env)){d={};for(let[v,Y]of Object.entries(t.env))if(typeof Y==="string")d[v]=s(Y)}let f;if(x(t.headers)){f={};for(let[v,Y]of Object.entries(t.headers))if(typeof Y==="string")f[v]=s(Y)}let w;if(x(t.oauth)){if(w={},typeof t.oauth.clientId==="string"&&t.oauth.clientId.length>0)w.clientId=t.oauth.clientId;if(typeof t.oauth.scope==="string"&&t.oauth.scope.length>0)w.scope=t.oauth.scope;if(Object.keys(w).length===0)w=void 0}if(r.length>0){o.push(`${i}: server "${e}" needs ${[...new Set(r)].map((v)=>`\${${v}}`).join(", ")} set in the environment; skipped`);return}let P=Yt({args:p,env:d,headers:f,url:n});if(P.length>0&&c.allowPlaceholders!==!0){o.push(`${i}: server "${e}" still has ${P.join(", ")} to fill in; skipped (edit that line and it will connect)`);return}let q={name:e,transport:l};if(m!==void 0)q.command=m;if(p!==void 0)q.args=p;if(d!==void 0)q.env=d;if(n!==void 0)q.url=n;if(f!==void 0)q.headers=f;if(w!==void 0)q.oauth=w;if(typeof t.enabled==="boolean")q.enabled=t.enabled;return q}function Yt(e){return[...new Set([...e.args??[],...Object.values(e.env??{}),...Object.values(e.headers??{}),...e.url!==void 0?[e.url]:[]].flatMap((t)=>[...t.matchAll(Lt)].map((i)=>i[0])))]}var A=1,I="plugin.json",yt=200,ut=/^[a-z0-9][a-z0-9-]{0,63}$/,Vt=/\.(?:[cm]?[jt]s)$/i;function Dt(e){if(e.length===0||e.startsWith("/")||e.startsWith("\\")||/^[A-Za-z]:/.test(e))return!1;return!e.split(/[\\/]/).some((t)=>t==="..")}function V(e,t,i){let o;try{o=JSON.parse(e)}catch(m){return i.push(`${t}: not valid JSON \u2014 ${m.message}`),null}if(!x(o))return i.push(`${t}: must be an object`),null;let u=o.api;if(u!==A){let m=u===void 0?"missing":typeof u==="string"?JSON.stringify(u):String(u);return i.push(`${t}: plugin API version ${m} is not supported (this rovecode speaks ${A}) \u2014 skipped`),null}let c=o.name;if(typeof c!=="string"||!ut.test(c))return i.push(`${t}: "name" must match ${ut} \u2014 skipped`),null;let r=typeof o.version==="string"&&o.version.trim()?o.version.trim().slice(0,40):null;if(r===null)return i.push(`${t}: "version" must be a non-empty string \u2014 skipped`),null;let s={name:c,version:r,description:"",api:A};if(o.description!==void 0)if(typeof o.description==="string")s.description=o.description.replace(/\s+/g," ").trim().slice(0,yt);else i.push(`${t}: "description" is not a string \u2014 ignored`);for(let m of["entry","commands","skills"]){let n=o[m];if(n===void 0)continue;if(typeof n!=="string"||!Dt(n)){i.push(`${t}: "${m}" must be a relative path inside the plugin \u2014 ignored`);continue}if(m==="entry"&&!Vt.test(n)){i.push(`${t}: "entry" must be a .ts or .js module \u2014 ignored`);continue}s[m]=n.replace(/\\/g,"/")}if(o.mcp!==void 0)if(x(o.mcp))s.mcp=o.mcp;else i.push(`${t}: "mcp" must be an object of servers keyed by name \u2014 ignored`);for(let m of Object.keys(o))if(!["name","version","description","api","entry","commands","skills","mcp"].includes(m))i.push(`${t}: unknown field "${m}" ignored`);return s}function D(e){let t=[];if(e.entry)t.push(`code: ${e.entry}`);if(e.commands)t.push(`commands: ${e.commands}/`);if(e.skills)t.push(`skills: ${e.skills}/`);if(e.mcp)t.push(`mcp: ${Object.keys(e.mcp).join(", ")||"(none)"}`);return t}function T(e,t){let i=L(t,"plugins"),o=L(e,".rovecode","plugins");return at(i)===at(o)?[["project",o]]:[["user",i],["project",o]]}function E(e,t={}){let i={plugins:[],warnings:[]};if(process.env.ROVECODE_NO_PLUGINS==="1")return i;let o=t.home??z(),u=t.state??g(o),c=new Map;for(let[r,s]of T(e,o)){if(!b(s))continue;let m;try{m=Gt(s).sort()}catch(n){i.warnings.push(`${s}: cannot list \u2014 ${n.message}`);continue}for(let n of m){let a=L(s,n);if(!b(a)||!Nt(L(a,I)))continue;let l=Ct(a,n,r,u),p=c.get(l.name);if(p)i.warnings.push(`${a}: plugin "${l.name}" shadows ${p.dir} (project over user)`);c.set(l.name,l);for(let d of l.problems)i.warnings.push(d)}}return i.plugins=[...c.values()].sort((r,s)=>r.name.localeCompare(s.name)),i}function Ct(e,t,i,o){let u=L(e,I),c=[],r=null;try{r=V(Tt(u,"utf8"),u,c)}catch(f){c.push(`${u}: cannot read \u2014 ${f.message}`)}let s=null;try{s=K(e)}catch{s=null}let m=r?.name??t;if(r&&r.name!==t)c.push(`${u}: name "${r.name}" differs from its folder "${t}" \u2014 the manifest name is the plugin's identity`);let n;if(r===null)n="broken";else if(o.disabled.includes(m))n="disabled";else if(i==="project"&&(s===null||!it(o,e,s)))n="untrusted";else n="active";let a=`plugin ${m}`,l=r?lt(e,r.commands,`${a}: commands`,c):null,p=r?lt(e,r.skills,`${a}: skills`,c):null,d=[];if(r?.mcp)for(let[f,w]of Object.entries(r.mcp)){let P=ot(f,w,u,c);if(P)d.push(P)}return{name:m,dir:e,scope:i,manifest:r,status:n,digest:s,problems:c,commandsDir:l,skillsDir:p,mcp:d}}function lt(e,t,i,o){if(!t)return null;let u=L(e,t);try{if(St(u).isDirectory())return u}catch{}return o.push(`${i} directory "${t}" does not exist \u2014 ignored`),null}import{existsSync as Ot}from"fs";import{join as Ft}from"path";import{pathToFileURL as Rt}from"url";var F=Object.keys({pre_run:0,post_run:0,pre_tool:0,post_tool:0,approval:0,compaction:0,session_open:0,session_close:0,on_event:0});var Oe=Symbol("rovecode.hook.timeout");var rt=5000;function Ut(e=process.env){let t=Number(e.ROVECODE_PLUGIN_TIMEOUT_MS);return Number.isFinite(t)&&t>=1?Math.floor(t):rt}var nt=["read","write","execute","spawn","memory","network","custom"],ct=/^[a-z][a-z0-9_]{0,63}$/,R=Symbol("timed-out");async function pt(e,t){let i,o=new Promise((u)=>{i=setTimeout(()=>u(R),t)});try{return await Promise.race([e,o])}finally{if(i!==void 0)clearTimeout(i)}}var st=(e)=>e instanceof Error?e.message:String(e);async function U(e,t){let i=[],o=[];for(let u of e)o.push(await Xt(u,t,i));return{plugins:o,warnings:i}}async function Xt(e,t,i){let o={...e,tools:[],hooks:null};if(e.status!=="active"||e.manifest===null)return o;let u=e.manifest,c=`plugin ${e.name}`;if(!u.entry)return o;let r=Ft(e.dir,u.entry);if(!Ot(r))return i.push(`${c}: entry ${u.entry} does not exist \u2014 no tools or hooks loaded`),o;let s=t.timeoutMs??Ut(),m;try{m=await pt(import(Rt(r).href),s)}catch(a){return i.push(`${c}: ${u.entry} failed to load \u2014 ${st(a)}`),o}if(m===R)return i.push(`${c}: ${u.entry} load timed out after ${s}ms (top-level await?) \u2014 skipped`),o;let n=x(m)?m.default:void 0;if(!x(n))return i.push(`${c}: ${u.entry} must \`export default { api: ${A}, tools?, hooks? }\` \u2014 skipped`),o;if(n.api!==A)return i.push(`${c}: ${u.entry} declares api ${String(n.api)}; this rovecode speaks ${A} \u2014 skipped`),o;for(let a of Object.keys(n))if(!["api","tools","hooks"].includes(a))i.push(`${c}: ${u.entry} exports unknown member "${a}" \u2014 ignored`);if(n.tools!==void 0){let a;try{let p=n.tools;a=typeof p==="function"?await pt(Promise.resolve(p({cwd:t.cwd,home:t.home,pluginDir:e.dir})),s):p}catch(p){i.push(`${c}: tools() threw \u2014 ${st(p)}`),a=[]}if(a===R)i.push(`${c}: tools() timed out after ${s}ms \u2014 no tools loaded`),a=[];if(!Array.isArray(a))i.push(`${c}: "tools" must be an array (or a function returning one) \u2014 ignored`),a=[];let l=new Set;for(let p of a){let d=Wt(p,c,i);if(!d)continue;if(l.has(d.schema.name)){i.push(`${c}: tool "${d.schema.name}" declared twice \u2014 first kept`);continue}l.add(d.schema.name),o.tools.push(d)}}if(n.hooks!==void 0)if(!x(n.hooks))i.push(`${c}: "hooks" must be an object of hook functions \u2014 ignored`);else{let a={};for(let[l,p]of Object.entries(n.hooks)){if(!F.includes(l)){i.push(`${c}: unknown hook "${l}" ignored (known: ${F.join(", ")})`);continue}if(typeof p!=="function"){i.push(`${c}: hook "${l}" is not a function \u2014 ignored`);continue}a[l]=p}if(Object.keys(a).length)o.hooks=a}return o}function Wt(e,t,i){if(!x(e)||!x(e.schema))return i.push(`${t}: a tool without a schema was dropped`),null;let o=e.schema,u=o.name;if(typeof u!=="string"||!ct.test(u))return i.push(`${t}: tool name ${JSON.stringify(u)} must match ${ct} \u2014 dropped`),null;if(typeof o.description!=="string"||!o.description.trim())return i.push(`${t}: tool "${u}" needs a description \u2014 dropped`),null;if(!x(o.args))return i.push(`${t}: tool "${u}" needs a JSON-Schema "args" object \u2014 dropped`),null;if(!nt.includes(e.kind))return i.push(`${t}: tool "${u}" kind ${JSON.stringify(e.kind)} is not one of ${nt.join("|")} \u2014 dropped (the kind is its permission class)`),null;if(typeof e.execute!=="function")return i.push(`${t}: tool "${u}" has no execute() \u2014 dropped`),null;return e}import{cpSync as Zt,existsSync as N,lstatSync as Ht,mkdirSync as Jt,mkdtempSync as mt,readFileSync as $t,renameSync as jt,rmSync as G}from"fs";import{tmpdir as te}from"os";import{join as _,resolve as X,sep as ee}from"path";var ie=(e,t)=>`${e}#${t??""}`;var oe=/^(?:https?:\/\/|git@|ssh:\/\/|git:\/\/)|\.git$/i,dt=(e)=>oe.test(e)&&!N(e),ue=async(e,t)=>{let i=Bun.spawn(e,{cwd:t,stdout:"ignore",stderr:"pipe",stdin:"ignore"}),o=await new Response(i.stderr).text();return{code:await i.exited,stderr:o}};function h(e,t,i){return T(t,i).find(([o])=>o===e)?.[1]??_(i,"plugins")}function ae(e){try{return Ht(e).isSymbolicLink()}catch{return!0}}async function W(e,t){let i=e,o=null,u=t.copy??((c,r,s)=>Zt(c,r,{recursive:!0,filter:s}));try{if(dt(e)){let l=ie(e),p=t.cloneCache?.get(l);if(p!==void 0&&b(p))i=p;else{o=mt(_(te(),"rovecode-plugin-"));let d=await(t.spawn??ue)(["git","clone","--depth","1","--quiet","--",e,"."],o);if(d.code!==0)return{ok:!1,error:`git clone failed (exit ${d.code})${d.stderr.trim()?`: ${d.stderr.trim().split(`
|
|
4
|
-
`)
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
var Lt=Object.defineProperty;var Pt=(e)=>e;function Yt(e,t){this[e]=Pt.bind(null,t)}var yt=(e,t)=>{for(var i in t)Lt(e,i,{get:t[i],enumerable:!0,configurable:!0,set:Yt.bind(t,i)})};var q=(e,t)=>()=>(e&&(t=e(e=0)),t);var mt=()=>{};import{readFileSync as Ue,writeFileSync as Xe,mkdirSync as We,chmodSync as Vt,cpSync as Dt,existsSync as H,rmSync as Ze}from"fs";import{join as J}from"path";import{homedir as Nt}from"os";function K(){let e=process.env.ROVECODE_HOME,t=e??J(xt(),".rovecode");return Tt(t,{explicit:e!==void 0}),t}function Tt(e,t={}){if(dt&&t.legacyDir===void 0)return;if(t.legacyDir===void 0)dt=!0;try{if(H(e))return;let i=t.legacyDir??J(xt(),".cumulus");if(t.explicit===!0)return;if(e===i||!H(i))return;Dt(i,e,{recursive:!0}),(t.note??((u)=>console.error(u)))(`migrated ${i} \u2192 ${e} (the config directory was renamed; the old one is untouched)`);let o=J(e,"credentials.json");if(H(o)&&process.platform!=="win32")Vt(o,Gt)}catch{}}var Gt=384,xt=()=>(process.platform==="win32"?process.env.USERPROFILE:process.env.HOME)||Nt(),dt=!1;var C=q(()=>{mt()});import{createHash as Ct}from"crypto";import{mkdirSync as Ot,readFileSync as gt,readdirSync as St,statSync as Ft,writeFileSync as Rt}from"fs";import{dirname as Ut,join as $,relative as Xt,resolve as Wt}from"path";function g(e){let t={disabled:[],trusted:{}},i;try{i=JSON.parse(gt(V(e),"utf8"))}catch{return t}if(typeof i!=="object"||i===null)return t;let o=i;if(Array.isArray(o.disabled))t.disabled=o.disabled.filter((u)=>typeof u==="string");if(typeof o.trusted==="object"&&o.trusted!==null&&!Array.isArray(o.trusted)){for(let[u,a]of Object.entries(o.trusted))if(typeof a==="string")t.trusted[u]=a}return t}function I(e,t){let i=V(e);return Ot(Ut(i),{recursive:!0}),Rt(i,JSON.stringify({disabled:[...t.disabled].sort(),trusted:t.trusted},null,2)+`
|
|
3
|
+
`),i}function O(e){let t=[],i=(o)=>{let u;try{u=St(o,{withFileTypes:!0})}catch{return}for(let a of u){if(Ht.has(a.name))continue;let m=$(o,a.name);if(a.isDirectory())i(m);else if(a.isFile())t.push(Xt(e,m).replace(/\\/g,"/"))}};return i(e),t.sort()}function D(e){let t=Ct("sha256");for(let i of O(e)){t.update(i),t.update("\x00");try{t.update(gt($(e,i)))}catch{}t.update("\x00")}return t.digest("hex")}function _t(e,t,i){return e.trusted[z(t)]===i}function B(e){try{return Ft(e).isDirectory()}catch{return!1}}var Zt="plugins.json",V=(e)=>$(e,Zt),Ht,z=(e)=>Wt(e).replace(/\\/g,"/");var L=q(()=>{Ht=new Set(["node_modules",".git"])});var j=q(()=>{L()});function jt(e,t,i){return e.replace(Jt,(o,u)=>{let a=t[u];if(a===void 0)return i.push(u),"";return a})}function x(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function ht(e,t,i,o,u=process.env,a={}){if(!x(t)){o.push(`${i}: server "${e}" is not an object; skipped`);return}let m=[],p=(k)=>jt(k,u,m),s=typeof t.command==="string"&&t.command.length>0?t.command:void 0,l=typeof t.url==="string"&&t.url.length>0?p(t.url):void 0,n=typeof t.transport==="string"?t.transport:typeof t.type==="string"?t.type:void 0,c;if(n==="stdio")c="stdio";else if(n==="http"||n==="streamable-http"||n==="streamable_http")c="http";else if(n==="sse")c="sse";else if(n!==void 0){o.push(`${i}: server "${e}" has unknown transport "${n}"; skipped`);return}else c=l!==void 0?"http":s!==void 0?"stdio":void 0;if(c===void 0){o.push(`${i}: server "${e}" has neither command nor url; skipped`);return}if(c==="stdio"&&s===void 0){o.push(`${i}: stdio server "${e}" is missing command; skipped`);return}if(c==="http"||c==="sse"){if(l===void 0){o.push(`${i}: ${c} server "${e}" is missing url; skipped`);return}try{new URL(l)}catch{o.push(`${i}: ${c} server "${e}" has invalid url "${l}"; skipped`);return}}let r;if(t.args!==void 0)if(Array.isArray(t.args)&&t.args.every((k)=>typeof k==="string"))r=t.args.map(p);else{o.push(`${i}: server "${e}" has non-string args; skipped`);return}let d;if(x(t.env)){d={};for(let[k,T]of Object.entries(t.env))if(typeof T==="string")d[k]=p(T)}let v;if(x(t.headers)){v={};for(let[k,T]of Object.entries(t.headers))if(typeof T==="string")v[k]=p(T)}let b;if(x(t.oauth)){if(b={},typeof t.oauth.clientId==="string"&&t.oauth.clientId.length>0)b.clientId=t.oauth.clientId;if(typeof t.oauth.scope==="string"&&t.oauth.scope.length>0)b.scope=t.oauth.scope;if(Object.keys(b).length===0)b=void 0}if(m.length>0){o.push(`${i}: server "${e}" needs ${[...new Set(m)].map((k)=>`\${${k}}`).join(", ")} set in the environment; skipped`);return}let G=te({args:r,env:d,headers:v,url:l});if(G.length>0&&a.allowPlaceholders!==!0){o.push(`${i}: server "${e}" still has ${G.join(", ")} to fill in; skipped (edit that line and it will connect)`);return}let A={name:e,transport:c};if(s!==void 0)A.command=s;if(r!==void 0)A.args=r;if(d!==void 0)A.env=d;if(l!==void 0)A.url=l;if(v!==void 0)A.headers=v;if(b!==void 0)A.oauth=b;if(typeof t.enabled==="boolean")A.enabled=t.enabled;return A}function te(e){return[...new Set([...e.args??[],...Object.values(e.env??{}),...Object.values(e.headers??{}),...e.url!==void 0?[e.url]:[]].flatMap((t)=>[...t.matchAll($t)].map((i)=>i[0])))]}var Jt,$t;var R=q(()=>{j();Jt=/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g,$t=/<[^<>]*[a-z][^<>]*>/g});function oe(e){if(e.length===0||e.startsWith("/")||e.startsWith("\\")||/^[A-Za-z]:/.test(e))return!1;return!e.split(/[\\/]/).some((t)=>t==="..")}function P(e,t,i){let o;try{o=JSON.parse(e)}catch(s){return i.push(`${t}: not valid JSON \u2014 ${s.message}`),null}if(!x(o))return i.push(`${t}: must be an object`),null;let u=o.api;if(u!==_){let s=u===void 0?"missing":typeof u==="string"?JSON.stringify(u):String(u);return i.push(`${t}: plugin API version ${s} is not supported (this rovecode speaks ${_}) \u2014 skipped`),null}let a=o.name;if(typeof a!=="string"||!ft.test(a))return i.push(`${t}: "name" must match ${ft} \u2014 skipped`),null;let m=typeof o.version==="string"&&o.version.trim()?o.version.trim().slice(0,40):null;if(m===null)return i.push(`${t}: "version" must be a non-empty string \u2014 skipped`),null;let p={name:a,version:m,description:"",api:_};if(o.description!==void 0)if(typeof o.description==="string")p.description=o.description.replace(/\s+/g," ").trim().slice(0,ee);else i.push(`${t}: "description" is not a string \u2014 ignored`);for(let s of["entry","commands","skills"]){let l=o[s];if(l===void 0)continue;if(typeof l!=="string"||!oe(l)){i.push(`${t}: "${s}" must be a relative path inside the plugin \u2014 ignored`);continue}if(s==="entry"&&!ie.test(l)){i.push(`${t}: "entry" must be a .ts or .js module \u2014 ignored`);continue}p[s]=l.replace(/\\/g,"/")}if(o.mcp!==void 0)if(x(o.mcp))p.mcp=o.mcp;else i.push(`${t}: "mcp" must be an object of servers keyed by name \u2014 ignored`);if(o.permissions!==void 0){let s=o.permissions;if(Array.isArray(s)&&s.every((l)=>typeof l==="string"&&/^[a-z][a-z0-9.*-]{0,63}$/.test(l))){if(p.permissions=s.slice(0,16),s.length>16)i.push(`${t}: "permissions" capped at 16 entries`)}else i.push(`${t}: "permissions" must be an array of action names (e.g. "shell.exec") \u2014 ignored`)}for(let s of Object.keys(o))if(!["name","version","description","api","entry","commands","skills","mcp","permissions"].includes(s))i.push(`${t}: unknown field "${s}" ignored`);return p}function Y(e){let t=[];if(e.entry)t.push(`code: ${e.entry}`);if(e.commands)t.push(`commands: ${e.commands}/`);if(e.skills)t.push(`skills: ${e.skills}/`);if(e.mcp)t.push(`mcp: ${Object.keys(e.mcp).join(", ")||"(none)"}`);if(e.permissions)t.push(`permissions: ${e.permissions.length>0?e.permissions.join(", "):"(none \u2014 read-only)"}`);return t}var _=1,h="plugin.json",ee=200,ft,ie;var y=q(()=>{R();ft=/^[a-z0-9][a-z0-9-]{0,63}$/,ie=/\.(?:[cm]?[jt]s)$/i});var tt,ki;var bt=q(()=>{C();j();tt=Object.keys({pre_run:0,post_run:0,pre_tool:0,post_tool:0,approval:0,compaction:0,session_open:0,session_close:0,on_event:0}),ki=Symbol("rovecode.hook.timeout")});import{existsSync as pe}from"fs";import{join as se}from"path";import{pathToFileURL as re}from"url";function me(e=process.env){let t=Number(e.ROVECODE_PLUGIN_TIMEOUT_MS);return Number.isFinite(t)&&t>=1?Math.floor(t):At}function xe(e,t,i){if(t===void 0)return e;let o=de[e.kind];if(o===void 0)return e;if(t.includes(o)||t.includes("*"))return e;return{...e,execute:async(u,a)=>({ok:!1,output:`Permission denied: plugin '${i}' did not declare '${o}' \u2014 add it to the manifest's "permissions" and re-install, or remove this tool`})}}async function Bt(e,t){let i,o=new Promise((u)=>{i=setTimeout(()=>u(et),t)});try{return await Promise.race([e,o])}finally{if(i!==void 0)clearTimeout(i)}}async function S(e,t){let i=[],o=[];for(let u of e)o.push(await ge(u,t,i));return{plugins:o,warnings:i}}async function ge(e,t,i){let o={...e,tools:[],hooks:null};if(e.status!=="active"||e.manifest===null)return o;let u=e.manifest,a=`plugin ${e.name}`;if(!u.entry)return o;let m=se(e.dir,u.entry);if(!pe(m))return i.push(`${a}: entry ${u.entry} does not exist \u2014 no tools or hooks loaded`),o;let p=t.timeoutMs??me(),s;try{s=await Bt(import(re(m).href),p)}catch(n){return i.push(`${a}: ${u.entry} failed to load \u2014 ${Mt(n)}`),o}if(s===et)return i.push(`${a}: ${u.entry} load timed out after ${p}ms (top-level await?) \u2014 skipped`),o;let l=x(s)?s.default:void 0;if(!x(l))return i.push(`${a}: ${u.entry} must \`export default { api: ${_}, tools?, hooks? }\` \u2014 skipped`),o;if(l.api!==_)return i.push(`${a}: ${u.entry} declares api ${String(l.api)}; this rovecode speaks ${_} \u2014 skipped`),o;for(let n of Object.keys(l))if(!["api","tools","hooks"].includes(n))i.push(`${a}: ${u.entry} exports unknown member "${n}" \u2014 ignored`);if(l.tools!==void 0){let n;try{let r=l.tools;n=typeof r==="function"?await Bt(Promise.resolve(r({cwd:t.cwd,home:t.home,pluginDir:e.dir})),p):r}catch(r){i.push(`${a}: tools() threw \u2014 ${Mt(r)}`),n=[]}if(n===et)i.push(`${a}: tools() timed out after ${p}ms \u2014 no tools loaded`),n=[];if(!Array.isArray(n))i.push(`${a}: "tools" must be an array (or a function returning one) \u2014 ignored`),n=[];let c=new Set;for(let r of n){let d=_e(r,a,i);if(!d)continue;if(c.has(d.schema.name)){i.push(`${a}: tool "${d.schema.name}" declared twice \u2014 first kept`);continue}c.add(d.schema.name),o.tools.push(xe(d,u.permissions,a))}}if(l.hooks!==void 0)if(!x(l.hooks))i.push(`${a}: "hooks" must be an object of hook functions \u2014 ignored`);else{let n={};for(let[c,r]of Object.entries(l.hooks)){if(!tt.includes(c)){i.push(`${a}: unknown hook "${c}" ignored (known: ${tt.join(", ")})`);continue}if(typeof r!=="function"){i.push(`${a}: hook "${c}" is not a function \u2014 ignored`);continue}n[c]=r}if(Object.keys(n).length)o.hooks=n}return o}function _e(e,t,i){if(!x(e)||!x(e.schema))return i.push(`${t}: a tool without a schema was dropped`),null;let o=e.schema,u=o.name;if(typeof u!=="string"||!qt.test(u))return i.push(`${t}: tool name ${JSON.stringify(u)} must match ${qt} \u2014 dropped`),null;if(typeof o.description!=="string"||!o.description.trim())return i.push(`${t}: tool "${u}" needs a description \u2014 dropped`),null;if(!x(o.args))return i.push(`${t}: tool "${u}" needs a JSON-Schema "args" object \u2014 dropped`),null;if(!kt.includes(e.kind))return i.push(`${t}: tool "${u}" kind ${JSON.stringify(e.kind)} is not one of ${kt.join("|")} \u2014 dropped (the kind is its permission class)`),null;if(typeof e.execute!=="function")return i.push(`${t}: tool "${u}" has no execute() \u2014 dropped`),null;return e}var At=5000,kt,qt,de,et,Mt=(e)=>e instanceof Error?e.message:String(e);var X=q(()=>{bt();R();y();kt=["read","write","execute","spawn","memory","network","custom"],qt=/^[a-z][a-z0-9_]{0,63}$/,de={read:"file.read",write:"file.write",execute:"shell.exec",spawn:"spawn",memory:"memory.write",network:"net.fetch"};et=Symbol("timed-out")});var pt={};yt(pt,{cmdPluginTest:()=>Ne,cmdPluginInit:()=>De});import{mkdirSync as ze,mkdtempSync as Ee,readFileSync as Qe,rmSync as Ke,writeFileSync as Z,existsSync as ct}from"fs";import{tmpdir as Le}from"os";import{join as Q,resolve as Pe}from"path";async function De(e,t){let i=e[0];if(!i||!Et.test(i))return t.err(`plugin init: name must match ${Et}`),2;let o=Q(t.cwd,i);if(ct(o))return t.err(`plugin init: ${o} already exists`),1;ze(o,{recursive:!0});let u={name:i,version:"0.1.0",description:`${i} plugin`,api:_,entry:"index.ts",permissions:[]};return Z(Q(o,h),JSON.stringify(u,null,2)+`
|
|
4
|
+
`),Z(Q(o,"index.ts"),Ye.replaceAll("<name>",i).replaceAll("<tool>",i.replaceAll("-","_"))),Z(Q(o,"plugin.test.ts"),ye),Z(Q(o,"README.md"),Ve(i)),t.out(`scaffolded ${i} at ${o}`),t.out(`next: rovecode plugin test ${o} \xB7 rovecode plugin add ${o}`),0}async function Ne(e,t){let i=Pe(t.cwd,e??"."),o=Q(i,h);if(!ct(o))return t.err(`plugin test: no ${h} in ${i}`),2;let u=[],a=P(Qe(o,"utf8"),o,u);if(!a){for(let s of u)t.err(s);return 1}t.out(`manifest ok: ${a.name}@${a.version} (api ${a.api})`);for(let s of Y(a))t.out(` ${s}`);let m=Ee(Q(Le(),"rovecode-plugintest-"));try{let s={dir:i,name:a.name,scope:"project",status:"active",manifest:a,digest:null,problems:[],commandsDir:null,skillsDir:null,mcp:[]},{plugins:l,warnings:n}=await S([s],{cwd:m,home:m});for(let d of n)t.err(`warning: ${d}`);let c=l[0],r=c?.tools??[];if(t.out(`activated: ${r.length} tool(s)${r.length?` [${r.map((d)=>`${d.schema.name}:${d.kind}`).join(", ")}]`:""}, hooks ${c?.hooks?"yes":"none"}`),n.length>0)return 1}finally{Ke(m,{recursive:!0,force:!0})}let p=Q(i,"plugin.test.ts");if(ct(p)){t.out(`running ${p} \u2026`);let l=await Bun.spawn([process.execPath,"test",p],{cwd:i,stdout:"inherit",stderr:"inherit"}).exited;if(l!==0)return t.err(`plugin.test.ts failed (exit ${l})`),1}else t.out("no plugin.test.ts \u2014 add one for `plugin test` to exercise behavior, not just shape");return t.out("plugin test: ok"),0}var Et,Ye,ye,Ve=(e)=>`# ${e}
|
|
5
|
+
|
|
6
|
+
A rovecode plugin.
|
|
7
|
+
|
|
8
|
+
- \\"permissions\\" in plugin.json declares the policy actions its tools may take
|
|
9
|
+
(file.read, file.write, shell.exec, spawn, memory.write, net.fetch). A tool whose
|
|
10
|
+
kind is not declared is refused at run time \u2014 the list is a promise, not a comment.
|
|
11
|
+
- Develop: \\\`rovecode plugin test .\\\` in this folder.
|
|
12
|
+
- Install: \\\`rovecode plugin add .\\\` (user scope) or \\\`rovecode plugin add . --project\\\`.
|
|
13
|
+
`;var st=q(()=>{y();X();Et=/^[a-z0-9][a-z0-9-]{0,63}$/,Ye=`/** <name> \u2014 a rovecode plugin. The default export is the whole contract:
|
|
14
|
+
* api (PLUGIN_API_VERSION), tools (Tool[] or a factory), hooks (HookSet).
|
|
15
|
+
* Docs: docs/design/sdk-blueprint.md \xA76 */
|
|
16
|
+
import type { Tool, HookSet } from "rovecode/core"; // resolved by rovecode at load time
|
|
17
|
+
|
|
18
|
+
const hello: Tool = {
|
|
19
|
+
schema: {
|
|
20
|
+
name: "<tool>_hello",
|
|
21
|
+
description: "Says hello from the <name> plugin.",
|
|
22
|
+
args: { type: "object", properties: { who: { type: "string" } } },
|
|
23
|
+
},
|
|
24
|
+
kind: "read", // read = no workspace effect; kinds map to policy actions (see plugin.json permissions)
|
|
25
|
+
// sequential: false \u2014 concurrent with siblings in a batch; only stateful tools go sequential
|
|
26
|
+
async execute(args) {
|
|
27
|
+
const a = args as { who?: string };
|
|
28
|
+
return { ok: true, output: \`hello, \${typeof a.who === "string" ? a.who : "world"}!\` };
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const hooks: HookSet = {
|
|
33
|
+
// pre_tool: async ({ tool }) => tool === "bash" ? { deny: "nope" } : undefined,
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export default { api: ${_}, tools: [hello], hooks };
|
|
37
|
+
`,ye=`/** The plugin's own tests \u2014 \`rovecode plugin test\` runs this file under bun:test. */
|
|
38
|
+
import { test, expect } from "bun:test";
|
|
39
|
+
import plugin from "./index.ts";
|
|
40
|
+
|
|
41
|
+
test("module shape", () => {
|
|
42
|
+
expect(plugin.api).toBe(${_});
|
|
43
|
+
expect(Array.isArray(plugin.tools)).toBe(true);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
test("hello tool", async () => {
|
|
47
|
+
const tool = (plugin.tools ?? [])[0]!;
|
|
48
|
+
const out = await tool.execute({ who: "tests" }, {} as never);
|
|
49
|
+
expect(out.ok).toBe(true);
|
|
50
|
+
expect(out.output).toContain("hello, tests!");
|
|
51
|
+
});
|
|
52
|
+
`});C();C();R();y();L();import{existsSync as ue,readFileSync as ae,readdirSync as le,statSync as ne}from"fs";import{join as N,resolve as wt}from"path";function U(e,t){let i=N(t,"plugins"),o=N(e,".rovecode","plugins");return wt(i)===wt(o)?[["project",o]]:[["user",i],["project",o]]}function E(e,t={}){let i={plugins:[],warnings:[]};if(process.env.ROVECODE_NO_PLUGINS==="1")return i;let o=t.home??K(),u=t.state??g(o),a=new Map;for(let[m,p]of U(e,o)){if(!B(p))continue;let s;try{s=le(p).sort()}catch(l){i.warnings.push(`${p}: cannot list \u2014 ${l.message}`);continue}for(let l of s){let n=N(p,l);if(!B(n)||!ue(N(n,h)))continue;let c=ce(n,l,m,u),r=a.get(c.name);if(r)i.warnings.push(`${n}: plugin "${c.name}" shadows ${r.dir} (project over user)`);a.set(c.name,c);for(let d of c.problems)i.warnings.push(d)}}return i.plugins=[...a.values()].sort((m,p)=>m.name.localeCompare(p.name)),i}function ce(e,t,i,o){let u=N(e,h),a=[],m=null;try{m=P(ae(u,"utf8"),u,a)}catch(v){a.push(`${u}: cannot read \u2014 ${v.message}`)}let p=null;try{p=D(e)}catch{p=null}let s=m?.name??t;if(m&&m.name!==t)a.push(`${u}: name "${m.name}" differs from its folder "${t}" \u2014 the manifest name is the plugin's identity`);let l;if(m===null)l="broken";else if(o.disabled.includes(s))l="disabled";else if(i==="project"&&(p===null||!_t(o,e,p)))l="untrusted";else l="active";let n=`plugin ${s}`,c=m?vt(e,m.commands,`${n}: commands`,a):null,r=m?vt(e,m.skills,`${n}: skills`,a):null,d=[];if(m?.mcp)for(let[v,b]of Object.entries(m.mcp)){let G=ht(v,b,u,a);if(G)d.push(G)}return{name:s,dir:e,scope:i,manifest:m,status:l,digest:p,problems:a,commandsDir:c,skillsDir:r,mcp:d}}function vt(e,t,i,o){if(!t)return null;let u=N(e,t);try{if(ne(u).isDirectory())return u}catch{}return o.push(`${i} directory "${t}" does not exist \u2014 ignored`),null}X();L();y();L();X();import{cpSync as he,existsSync as F,lstatSync as fe,mkdirSync as we,mkdtempSync as It,readFileSync as ve,renameSync as be,rmSync as W}from"fs";import{tmpdir as ke}from"os";import{join as f,resolve as it,sep as qe}from"path";y();L();var Be=(e,t)=>`${e}#${t??""}`;var Me=/^(?:https?:\/\/|git@|ssh:\/\/|git:\/\/)|\.git$/i,zt=(e)=>Me.test(e)&&!F(e),Ae=async(e,t)=>{let i=Bun.spawn(e,{cwd:t,stdout:"ignore",stderr:"pipe",stdin:"ignore"}),o=await new Response(i.stderr).text();return{code:await i.exited,stderr:o}};function w(e,t,i){return U(t,i).find(([o])=>o===e)?.[1]??f(i,"plugins")}function Ie(e){try{return fe(e).isSymbolicLink()}catch{return!0}}async function ot(e,t){let i=e,o=null,u=t.copy??((a,m,p)=>he(a,m,{recursive:!0,filter:p}));try{if(zt(e)){let c=Be(e),r=t.cloneCache?.get(c);if(r!==void 0&&B(r))i=r;else{o=It(f(ke(),"rovecode-plugin-"));let d=await(t.spawn??Ae)(["git","clone","--depth","1","--quiet","--",e,"."],o);if(d.code!==0)return{ok:!1,error:`git clone failed (exit ${d.code})${d.stderr.trim()?`: ${d.stderr.trim().split(`
|
|
53
|
+
`).at(-1)}`:""}`};if(i=o,t.cloneCache!==void 0)t.cloneCache.set(c,o),o=null}}if(i=it(i),t.subfolder!==void 0&&t.subfolder!==""){let c=t.subfolder.split("\\").join("/");if(c.startsWith("/")||/^[A-Za-z]:/.test(c)||c.split("/").includes(".."))return{ok:!1,error:`subfolder "${t.subfolder}" escapes the source`};let r=it(f(i,c));if(r!==i&&!r.startsWith(i+qe))return{ok:!1,error:`subfolder "${t.subfolder}" escapes the source`};if(!B(r))return{ok:!1,error:`${e}: no folder "${t.subfolder}" inside it`};i=r}if(!B(i))return{ok:!1,error:`${e}: not a directory`};let a=f(i,h);if(!F(a))return{ok:!1,error:`${e}: no ${h} \u2014 a plugin is a folder with a manifest`};let m=[],p=P(ve(a,"utf8"),a,m);if(p===null)return{ok:!1,error:m.join("; ")||`${a}: invalid manifest`};let s=w(t.scope,t.cwd,t.home),l=f(s,p.name);if(it(l)===i)return{ok:!1,error:`${e} is already the installed copy`};if(F(l)&&!t.force)return{ok:!1,error:`plugin "${p.name}" already exists at ${l} (use --force to replace)`};we(s,{recursive:!0});let n=It(f(s,`.rovecode-add-${p.name}-`));try{if(u(i,n,(c)=>!/(?:^|[\\/])(?:node_modules|\.git)(?:[\\/]|$)/.test(c)&&!Ie(c)),F(l))W(l,{recursive:!0,force:!0});be(n,l)}catch(c){return{ok:!1,error:`could not install "${p.name}" into ${l}: ${c instanceof Error?c.message:String(c)}`}}finally{W(n,{recursive:!0,force:!0})}if(t.scope==="project"){let c=g(t.home);c.trusted[z(l)]=D(l),I(t.home,c)}return{ok:!0,name:p.name,dir:l,scope:t.scope,manifest:p}}finally{if(o)W(o,{recursive:!0,force:!0})}}function ut(e,t){let i=f(w(t.scope,t.cwd,t.home),e);if(!B(i))return{ok:!1,error:`no ${t.scope} plugin "${e}" at ${i}`};W(i,{recursive:!0,force:!0});let o=g(t.home);return delete o.trusted[z(i)],I(t.home,o),{ok:!0,dir:i}}function at(e,t,i){let o=g(i);if(o.disabled=o.disabled.filter((u)=>u!==e),!t)o.disabled.push(e);return I(i,o)}function lt(e,t){let i=f(w("project",t.cwd,t.home),e);if(!B(i)||!F(f(i,h)))return{ok:!1,error:`no project plugin "${e}" under ${w("project",t.cwd,t.home)}`};let o=D(i),u=g(t.home);return u.trusted[z(i)]=o,I(t.home,u),{ok:!0,dir:i,digest:o}}function nt(e,t){let i=f(w("project",t.cwd,t.home),e),o=g(t.home),u=z(i)in o.trusted;return delete o.trusted[z(i)],I(t.home,o),u}C();import{relative as Ge}from"path";y();L();var M=["usage: rovecode plugin <command>"," list every plugin in ~/.rovecode/plugins and .rovecode/plugins, with its status"," init <name> [--project] scaffold a new plugin folder (manifest, entry, test, README) ready for `plugin add`"," test [path] validate + activate a plugin in a dry harness, then run its plugin.test.ts"," add <folder|git-url> [--project] [--force]"," copy (or shallow-clone) a plugin into the user scope, or this repo's .rovecode/plugins"," remove <name> [--project] delete the installed copy"," enable <name> \xB7 disable <name>"," switch a plugin off/on in every scope (~/.rovecode/plugins.json)"," trust <name> approve a PROJECT plugin's current files on this machine \u2014 until they change"," untrust <name> withdraw that approval"," show <name> manifest, files and what it contributes, without running any of it","status: active \xB7 disabled \xB7 untrusted (project plugin not yet approved here) \xB7 broken (see problems)"].join(`
|
|
54
|
+
`),Qt=(e,t)=>e.includes(t),rt=(e)=>e.filter((t)=>!t.startsWith("--"));async function Te(e,t={}){let i=t.cwd??process.cwd(),o=t.home??K(),u=t.out??((n)=>console.log(n)),a=t.err??((n)=>console.error(n)),[m="list",...p]=e,s=Qt(p,"--project")?"project":"user",l=rt(p)[0];switch(m){case"init":return await Promise.resolve().then(() => (st(),pt)).then((n)=>n.cmdPluginInit(rt(p),{cwd:i,out:u,err:a}));case"test":return await Promise.resolve().then(() => (st(),pt)).then((n)=>n.cmdPluginTest(rt(p)[0],{cwd:i,home:o,out:u,err:a}));case"list":case"ls":{let{plugins:n,warnings:c}=E(i,{home:o});if(n.length===0)u(`no plugins. add one: rovecode plugin add <folder|git-url> (user: ${w("user",i,o)}, project: ${Ge(i,w("project",i,o))||"."})`);for(let r of n)u(Kt(r));for(let r of c)a(`warning: ${r}`);return 0}case"add":{let n=l;if(!n)return a(M),2;let c=await ot(n,{cwd:i,home:o,scope:s,force:Qt(p,"--force"),...t.spawn?{spawn:t.spawn}:{}});if(!c.ok)return a(`plugin add: ${c.error}`),1;u(`added ${c.name}@${c.manifest.version} (${c.scope}) \u2192 ${c.dir}`);for(let r of Y(c.manifest))u(` ${r}`);if(c.scope==="project")u(` trusted on this machine (recorded in ${V(o)}); a change to its files will ask again`);return u("restart rovecode to load it \u2014 plugins are read once per process, like hooks"),0}case"remove":case"rm":{if(!l)return a(M),2;let n=ut(l,{cwd:i,home:o,scope:s});if(!n.ok)return a(`plugin remove: ${n.error}`),1;return u(`removed ${l} (${s}) from ${n.dir}`),0}case"enable":case"disable":{if(!l)return a(M),2;if(!E(i,{home:o}).plugins.some((r)=>r.name===l))a(`warning: no installed plugin named "${l}" \u2014 the setting is recorded anyway`);let c=at(l,m==="enable",o);return u(`${l} ${m}d (${c})`),0}case"trust":{if(!l)return a(M),2;let n=E(i,{home:o}).plugins.find((r)=>r.name===l&&r.scope==="project");if(!n)return a(`plugin trust: no project plugin "${l}" under ${w("project",i,o)}`),1;if(n.manifest===null){a(`plugin trust: "${l}" is broken \u2014 fix it first:`);for(let r of n.problems)a(` ${r}`);return 1}let c=lt(l,{cwd:i,home:o});if(!c.ok)return a(`plugin trust: ${c.error}`),1;u(`trusted ${l}@${n.manifest.version} \u2014 ${O(n.dir).length} files, digest ${c.digest.slice(0,12)}\u2026`);for(let r of Y(n.manifest))u(` ${r}`);return u("it loads on the next start; `rovecode plugin show "+l+"` lists every file it brings"),0}case"untrust":{if(!l)return a(M),2;return u(nt(l,{cwd:i,home:o})?`untrusted ${l}`:`${l} was not trusted`),0}case"show":case"info":{if(!l)return a(M),2;let n=E(i,{home:o}).plugins.find((c)=>c.name===l);if(!n)return a(`plugin show: no plugin "${l}"`),1;if(u(Kt(n)),u(` folder: ${n.dir}`),n.digest)u(` digest: ${n.digest}`);if(n.manifest)for(let c of Y(n.manifest))u(` ${c}`);for(let c of O(n.dir))u(` - ${c}`);for(let c of n.problems)u(` ! ${c}`);if(n.status==="untrusted")u(` run \`rovecode plugin trust ${n.name}\` after reading the files above`);return 0}case"help":case"--help":case"-h":return u(M),0;default:return a(`unknown plugin command "${m}"
|
|
55
|
+
${M}`),2}}function Kt(e){let t=e.manifest?`@${e.manifest.version}`:"",i=e.manifest?.description?` \u2014 ${e.manifest.description}`:"";return`${(e.name+t).padEnd(28)} ${e.scope.padEnd(8)} ${e.status.padEnd(9)}${i}`.trimEnd()}async function to(e,t={}){let i=t.home??K(),o=E(e,{home:i,state:g(i)}),u=await S(o.plugins,{cwd:e,home:i,...t.timeoutMs!==void 0?{timeoutMs:t.timeoutMs}:{}});return{plugins:u.plugins,warnings:[...o.warnings,...u.warnings]}}function eo(e){if(e.length===0)return null;let t=(o)=>e.filter((u)=>u.status===o).map((u)=>u.name),i=[];for(let o of["active","untrusted","disabled","broken"]){let u=t(o);if(u.length)i.push(`${u.length} ${o} (${u.join(", ")})`)}return`plugins: ${i.join(" \xB7 ")}`}export{nt as untrustPlugin,lt as trustPlugin,eo as summarizePlugins,V as statePath,at as setPluginEnabled,w as scopeRoot,I as saveState,ut as removePlugin,U as pluginRoots,O as pluginFiles,D as pluginDigest,P as parseManifest,g as loadState,to as loadPlugins,zt as isGitSource,E as discoverPlugins,Y as contributions,Te as cmdPlugin,ot as addPlugin,S as activatePlugins,M as PLUGIN_USAGE,_ as PLUGIN_API_VERSION,h as MANIFEST_FILE,At as DEFAULT_PLUGIN_TIMEOUT_MS};
|