opencode-teammate 0.2.0-next.3 → 0.2.0-next.5
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/dist/bin/mate +28 -28
- package/dist/plugin.js +79 -285
- package/dist/shared/plugin-hr00ebgs.js +257 -0
- package/dist/utils/config/define.d.ts +9 -0
- package/dist/utils/config/define.js +17 -0
- package/package.json +6 -2
package/dist/bin/mate
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
var
|
|
4
|
-
`){J();for(let
|
|
5
|
-
`)if(
|
|
6
|
-
`)&&((
|
|
7
|
-
`+
|
|
3
|
+
var f1=Object.defineProperty;var g=(w,$)=>{for(var G in $)f1(w,G,{get:$[G],enumerable:!0,configurable:!0,set:(B)=>$[G]=()=>B})};var E=(w,$)=>()=>(w&&($=w(w=0)),$);var Ow=(w,$,G)=>{if($!=null){if(typeof $!=="object"&&typeof $!=="function")throw TypeError('Object expected to be assigned to "using" declaration');let B;if(G)B=$[Symbol.asyncDispose];if(B===void 0)B=$[Symbol.dispose];if(typeof B!=="function")throw TypeError("Object not disposable");w.push([G,B,$])}else if(G)w.push([G]);return $},Qw=(w,$,G)=>{let B=(Z)=>$=G?new SuppressedError(Z,$,"An error was suppressed during disposal"):(G=!0,Z),W=(Z)=>{while(Z=w.pop())try{var J=Z[1]&&Z[1].call(Z[2]);if(Z[0])return Promise.resolve(J).then(W,(N)=>(B(N),W()))}catch(N){B(N)}if(G)throw $};return W()};function M(w){return($)=>{if(!process.stdout.isTTY||process.env.NO_COLOR)return $;return`\x1B[${w}m${$}\x1B[0m`}}function z1(w){return w.replace(/\x1b\[[0-9;]*m/g,"")}async function Tw(w){process.stdout.write(w);for await(let $ of console)return $;return""}async function J$(w,$={}){let G=$.default?` (${$.default})`:"",B=`${w}${G} `;while(!0){let Z=(await Tw(B)).trim()||$.default||"";if($.schema){let J=await $.schema["~standard"].validate(Z);if(J.issues){console.error(q.red("Invalid input:"));for(let N of J.issues)console.error(q.dim(` \u2022 ${N.message}`));console.error();continue}return J.value}if($.validate){let J=$.validate(Z);if(J===!0)return Z;else if(typeof J==="string"){console.error(`\u2717 ${J}`);continue}else{console.error("\u2717 Invalid input");continue}}return Z}}async function N$(w,$={}){let G=$.default===!0?"Y/n":$.default===!1?"y/N":"y/n",B=`${w} (${G}) `;while(!0){let Z=(await Tw(B)).trim().toLowerCase();if(!Z&&$.default!==void 0)return $.default;if(Z==="y"||Z==="yes")return!0;if(Z==="n"||Z==="no")return!1;console.error("\u2717 Please answer with y/yes or n/no")}}async function Mw(w,$){let{options:G,default:B}=$,W=B?G.findIndex((Z)=>Z.value===B):0;if(W===-1)W=0;return console.log(w),process.stdout.write(K1),F$(G,W),new Promise((Z)=>{process.stdin.setRawMode(!0),process.stdin.resume();let J=()=>{process.stdin.setRawMode(!1),process.stdin.pause(),process.stdout.write(S1)};process.stdin.on("data",(N)=>{let Y=N.toString();if(Y==="\x1B[A")W=Math.max(0,W-1),F$(G,W);else if(Y==="\x1B[B")W=Math.min(G.length-1,W+1),F$(G,W);else if(Y==="\r"||Y===`
|
|
4
|
+
`){J();for(let X=0;X<G.length;X++)process.stdout.write(`${d}1A${Dw}`);let O=G[W];if(O)console.log(`\u2713 ${O.label}`),Z(O.value)}else if(Y==="\x03"||Y==="\x1B")J(),process.exit(0)})})}function F$(w,$){for(let G=0;G<w.length;G++)process.stdout.write(`${d}1A`);w.forEach((G,B)=>{process.stdout.write(Dw+V1);let W=B===$?"\u276F ":" ",Z=G.hint?` (${G.hint})`:"";console.log(`${W}${G.label}${Z}`)})}async function Y$(w,$={}){return process.stdout.write(w+" "),new Promise((G)=>{let B="";process.stdin.setRawMode(!0),process.stdin.resume();let W=()=>{process.stdin.setRawMode(!1),process.stdin.pause(),console.log()};process.stdin.on("data",async(Z)=>{let J=Z.toString();if(J==="\r"||J===`
|
|
5
|
+
`)if(W(),$.schema){let N=await $.schema["~standard"].validate(B);if(N.issues){console.error(q.red("Invalid input:"));for(let Y of N.issues)console.error(q.dim(` \u2022 ${Y.message}`));console.error(),Y$(w,$).then(G);return}G(N.value)}else if($.validate){let N=$.validate(B);if(N===!0)G(B);else console.error(`\u2717 ${typeof N==="string"?N:"Invalid input"}`),Y$(w,$).then(G)}else G(B);else if(J==="\x03")W(),process.exit(0);else if(J==="\x7F"||J==="\b"){if(B.length>0)B=B.slice(0,-1),process.stdout.write("\b \b")}else if(J.length===1&&J>=" ")B+=J,process.stdout.write("*")})})}function q1(w){let $=typeof w==="string"?{text:w}:w||{},G=!1,B=0,W=null,Z=$.text||"",J=(Y,O)=>{process.stdout.write(`${Lw}${Ew}${Y} ${O}`)},N={start(Y){if(G)return;if(G=!0,Y!==void 0)Z=Y;process.stdout.write("\x1B[?25l"),W=setInterval(()=>{let O=I$[B];J(O,Z),B=(B+1)%I$.length},80)},stop(Y){if(!G)return;if(G=!1,W)clearInterval(W),W=null;if(process.stdout.write(Lw+Ew),process.stdout.write("\x1B[?25h"),Y)console.log(Y)},succeed(Y){this.stop(),console.log(`\u2705 ${Y||Z}`)},fail(Y){this.stop(),console.log(`\u274C ${Y||Z}`)},warn(Y){this.stop(),console.log(`\u26A0\uFE0F ${Y||Z}`)},info(Y){this.stop(),console.log(`\u2139\uFE0F ${Y||Z}`)},update(Y){if(Z=Y,G)J(I$[B],Z)}};return process.on("exit",()=>N.stop()),process.on("SIGINT",()=>{N.stop(),process.exit(0)}),N}var T,q,R1="\x1B",d,Dw,V1,K1,S1,I$,Lw="\x1B[2K",Ew="\x1B[G",hG,U$;var X$=E(()=>{T={black:30,red:31,green:32,yellow:33,blue:34,magenta:35,cyan:36,white:37,gray:90,brightRed:91,brightGreen:92,brightYellow:93,brightBlue:94,brightMagenta:95,brightCyan:96,brightWhite:97,bgRed:41,bgGreen:42,bgYellow:43,bgBlue:44,bgMagenta:45,bgCyan:46,bgWhite:47,bold:1,dim:2,italic:3,underline:4,strikethrough:9,reset:0};q={black:M(T.black),red:M(T.red),green:M(T.green),yellow:M(T.yellow),blue:M(T.blue),magenta:M(T.magenta),cyan:M(T.cyan),white:M(T.white),gray:M(T.gray),brightRed:M(T.brightRed),brightGreen:M(T.brightGreen),brightYellow:M(T.brightYellow),brightBlue:M(T.brightBlue),brightMagenta:M(T.brightMagenta),brightCyan:M(T.brightCyan),brightWhite:M(T.brightWhite),bgRed:M(T.bgRed),bgGreen:M(T.bgGreen),bgYellow:M(T.bgYellow),bgBlue:M(T.bgBlue),bgMagenta:M(T.bgMagenta),bgCyan:M(T.bgCyan),bgWhite:M(T.bgWhite),bold:M(T.bold),dim:M(T.dim),italic:M(T.italic),underline:M(T.underline),strikethrough:M(T.strikethrough),reset:M(T.reset),strip:z1},d=`${R1}[`,Dw=`${d}2K`,V1=`${d}G`,K1=`${d}?25l`,S1=`${d}?25h`;I$=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];hG={prompt:Object.assign(J$,{confirm:N$,select:Mw,password:Y$,text:(w,$)=>J$(w,$),multiselect:async(w,$)=>{let{options:G}=$,B=[];console.log(w);for(let W of G)if(await N$(`Select ${W.label}?`,{default:!1}))B.push(W.value);return B}}),spinner:q1,colors:q},U$=Object.assign(J$,{confirm:N$,select:Mw,password:Y$,text:(w,$)=>J$(w,$),multiselect:async(w,$)=>{let{options:G}=$,B=[];console.log(w);for(let W of G)if(await N$(`Select ${W.label}?`,{default:!1}))B.push(W.value);return B}})});function zw(w){return Array.isArray(w)?w.slice():[w]}function Rw(w,$){if(!w)return{};return w.reduce((G,B)=>{let W=$(B);return G[W]=(G[W]??0)+1,G},{})}function A$(w,$){return(w==null?void 0:w.length)>0?w[0]:$}function O$(w){return(w==null?void 0:w.filter(($)=>!!$))??[]}function Vw(w){return new Promise(($)=>setTimeout($,w))}function Kw(w){return(...$)=>{try{let G=w(...$);return k1(G)?G.then((B)=>[void 0,B],(B)=>[B,void 0]):[void 0,G]}catch(G){return[G,void 0]}}}function j$(){let w,$,G=new Promise((B,W)=>{w=B,$=W});return{resolve:w,reject:$,promise:G}}function $$(...w){return(...$)=>{return w.slice(1).reduce((G,B)=>B(G),w[0](...$))}}function H1(){}function Sw(w,$){return new j1($).parse(w)}function h$(w,$){if(!w||!$)return w??$??{};let G=Object.getPrototypeOf(w),B=G?{...w}:Object.assign(Object.create(G),w);for(let W of Object.keys($))B[W]=fw(w[W])&&fw($[W])?h$(w[W],$[W]):$[W];return B}function y(w,$){if(!w)return[];let G=Object.entries(w);if(G.length===0)return[];return G.reduce((B,W)=>{return B.push($(W[0],W[1])),B},[])}function qw(w,$=(G)=>G===void 0){if(!w)return{};return Object.keys(w).reduce((G,B)=>{if(!$(w[B]))G[B]=w[B];return G},{})}function P1(w){if(!w||w.length===0)return"";let $=w.toLowerCase();return $.substring(0,1).toUpperCase()+$.substring(1,$.length)}function m(w,...$){var G;if(v(w)){if($.length>0)return m(w.reduce((Z,J,N)=>{var Y;let O=String($[N]??""),X=O.includes(`
|
|
6
|
+
`)&&((Y=J.match(/[ \t]*(?=[^\n]*$)/))==null?void 0:Y[0]);if(X)O=O.replace(/\n(?=[^\n]*?\S)/g,`
|
|
7
|
+
`+X);return Z+J+O},""));w=w[0]}let B=$[0]??((G=w.match(/^[ \t]*(?=\S)/m))==null?void 0:G[0]);return(B?w.replace(new RegExp(`^${B}`,"gm"),""):w).replace(/^[ \t]*\n|\n[ \t]*$/g,"")}function Hw(w){if(!w)return"";return w.split(/(?=[A-Z])|[\.\-\s_]/).map(($)=>$.trim()).filter(($)=>!!$).map(($)=>P1($.toLowerCase())).join(" ")}function f(w,$){if(!w)throw $ instanceof Error?$:Error($??"Assertion failed")}function Fw(w){return typeof w==="boolean"}function x1(w){return jw(w,"[object Date]")}function P(w){if(typeof w!=="object"||w===null)return!w||w===!0;if(x1(w))return Number.isNaN(w.getTime());let $=w.length;if(_w($))return $===0;let G=w.size;if(_w(G))return G===0;return Object.keys(w).length===0}function C1(w){return typeof w==="function"}function Iw(w){return w===null||w===void 0}function _w(w){return typeof w==="number"&&!Number.isNaN(w)}function w$(w){return jw(w,"[object Object]")}function fw(w){if(typeof w!=="object"||w===null)return!1;let $=Object.getPrototypeOf(w);return $===Object.prototype||$===null||Object.getPrototypeOf($)===null}function k1(w){return!!w&&C1(w.then)}function Aw(w){return typeof w==="string"}function jw(w,$){return Object.prototype.toString.call(w)===$}var F1=class{constructor({units:w,short:$}){this.units=w,this.short=$}parse(w){var $;let G=w.match(/^(-?\d+(?:\.\d+)?) ?(\w+)?s?$/);if(!G)throw Error(`Invalid quantity, cannot parse: ${w}`);let B=G[2];B=(($=this.short)==null?void 0:$[B])||B;let W=Number.parseFloat(G[1]);if(Math.abs(W)>1&&B.endsWith("s"))B=B.substring(0,B.length-1);if(!this.units[B])throw Error(`Invalid unit: ${B}, makes sure it is one of: ${Object.keys(this.units).join(", ")}`);return W*this.units[B]}},I1,A1,j1,h1=class{constructor(w,$,G){this.semaphore=w,this.request=$,this.weight=G}release(){this.semaphore.release(this),this.release=H1}},Q$=class{constructor(w){if(this.maxCapacity=w,this.queue=[],w<=0)throw Error("maxCapacity must be > 0");this.capacity=w}get queueLength(){return this.queue.length}async acquire({signal:w,weight:$=1}={}){if($<=0)throw Error("weight must be > 0");if($>this.maxCapacity)throw Error("weight must be \u2264 maxCapacity");let G=j$(),B=new h1(this,G,$);if(w){let W=()=>{let J=this.queue.indexOf(B);if(J>=0)this.queue.splice(J,1),G.reject(w.reason)};w.addEventListener("abort",W);let Z=()=>{w.removeEventListener("abort",W)};G.promise.then(Z,Z)}if(this.capacity<$)this.queue.push(B),await G.promise;else this.capacity-=$;return B}reject(w){this.acquire=()=>Promise.reject(w),this.queue.forEach(($)=>$.request.reject(w)),this.queue=[]}release(w){this.capacity+=w.weight;let $=this.queue[0];if($&&this.capacity>=$.weight)this.capacity-=$.weight,this.queue.shift(),$.request.resolve()}},v;var H=E(()=>{I1={week:604800000,day:86400000,hour:3600000,minute:60000,second:1000,millisecond:1},A1={w:"week",d:"day",h:"hour",m:"minute",s:"second",ms:"millisecond"},j1=class w extends F1{constructor($){super({units:{...w.units,...$==null?void 0:$.units},short:{...w.shortUnits,...$==null?void 0:$.short}})}static get units(){return I1}static get shortUnits(){return A1}};v=(()=>Array.isArray)()});async function*P$(w,$){let G=Sw($?.interval??"1s");while(!0){let B=await w();if(Array.isArray(B)){if(P(B)&&$?.exitOnEmpty)break;yield*B}else if(B===void 0&&$?.exitOnEmpty)break;else yield B;await Vw(G)}}async function u(w,$){for await(let G of P$(w,$))if(G)return G;throw Error("Timeout: waiting for condition")}var L$=E(()=>{H()});var Pw=()=>{};var xw=({onRequest:w,onSseError:$,onSseEvent:G,responseTransformer:B,responseValidator:W,sseDefaultRetryDelay:Z,sseMaxRetryAttempts:J,sseMaxRetryDelay:N,sseSleepFn:Y,url:O,...X})=>{let Q,K=Y??((L)=>new Promise((_)=>setTimeout(_,L)));return{stream:async function*(){let L=Z??3000,_=0,j=X.signal??new AbortController().signal;while(!0){if(j.aborted)break;_++;let a=X.headers instanceof Headers?X.headers:new Headers(X.headers);if(Q!==void 0)a.set("Last-Event-ID",Q);try{let k={redirect:"follow",...X,body:X.serializedBody,headers:a,signal:j},h=new Request(O,k);if(w)h=await w(O,k);let R=await(X.fetch??globalThis.fetch)(h);if(!R.ok)throw Error(`SSE failed: ${R.status} ${R.statusText}`);if(!R.body)throw Error("No body in SSE response");let S=R.body.pipeThrough(new TextDecoderStream).getReader(),e="",Jw=()=>{try{S.cancel()}catch{}};j.addEventListener("abort",Jw);try{while(!0){let{done:D1,value:T1}=await S.read();if(D1)break;e+=T1,e=e.replace(/\r\n/g,`
|
|
8
8
|
`).replace(/\r/g,`
|
|
9
|
-
`);let
|
|
9
|
+
`);let Nw=e.split(`
|
|
10
10
|
|
|
11
|
-
`);
|
|
12
|
-
`),Z$=[],
|
|
13
|
-
`);try{k=JSON.parse(j),Ww=!0}catch{k=j}}if(Ww){if(B)await B(k);if(W)k=await W(k)}if(G?.({data:k,event:Gw,id:O,retry:E}),Z$.length)yield k}}}finally{x.removeEventListener("abort",$w),S.releaseLock()}break}catch(C){if($?.(C),J!==void 0&&K>=J)break;let A=Math.min(E*2**(K-1),Y??30000);await R(A)}}}()}};var FG=(w)=>{switch(w){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},IG=(w)=>{switch(w){case"form":return",";case"pipeDelimited":return"|";case"spaceDelimited":return"%20";default:return","}},jG=(w)=>{switch(w){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},E$=({allowReserved:w,explode:$,name:G,style:W,value:B})=>{if(!$){let Y=(w?B:B.map((N)=>encodeURIComponent(N))).join(IG(W));switch(W){case"label":return`.${Y}`;case"matrix":return`;${G}=${Y}`;case"simple":return Y;default:return`${G}=${Y}`}}let Z=FG(W),J=B.map((Y)=>{if(W==="label"||W==="simple")return w?Y:encodeURIComponent(Y);return u({allowReserved:w,name:G,value:Y})}).join(Z);return W==="label"||W==="matrix"?Z+J:J},u=({allowReserved:w,name:$,value:G})=>{if(G===void 0||G===null)return"";if(typeof G==="object")throw Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");return`${$}=${w?G:encodeURIComponent(G)}`},D$=({allowReserved:w,explode:$,name:G,style:W,value:B,valueOnly:Z})=>{if(B instanceof Date)return Z?B.toISOString():`${G}=${B.toISOString()}`;if(W!=="deepObject"&&!$){let N=[];Object.entries(B).forEach(([U,O])=>{N=[...N,U,w?O:encodeURIComponent(O)]});let Q=N.join(",");switch(W){case"form":return`${G}=${Q}`;case"label":return`.${Q}`;case"matrix":return`;${G}=${Q}`;default:return Q}}let J=jG(W),Y=Object.entries(B).map(([N,Q])=>u({allowReserved:w,name:W==="deepObject"?`${G}[${N}]`:N,value:Q})).join(J);return W==="label"||W==="matrix"?J+Y:Y};function x$(w){let $=w.body!==void 0;if($&&w.bodySerializer){if("serializedBody"in w)return w.serializedBody!==void 0&&w.serializedBody!==""?w.serializedBody:null;return w.body!==""?w.body:null}if($)return w.body;return}var hG,AG=({path:w,url:$})=>{let G=$,W=$.match(hG);if(W)for(let B of W){let Z=!1,J=B.substring(1,B.length-1),Y="simple";if(J.endsWith("*"))Z=!0,J=J.substring(0,J.length-1);if(J.startsWith("."))J=J.substring(1),Y="label";else if(J.startsWith(";"))J=J.substring(1),Y="matrix";let N=w[J];if(N===void 0||N===null)continue;if(Array.isArray(N)){G=G.replace(B,E$({explode:Z,name:J,style:Y,value:N}));continue}if(typeof N==="object"){G=G.replace(B,D$({explode:Z,name:J,style:Y,value:N,valueOnly:!0}));continue}if(Y==="matrix"){G=G.replace(B,`;${u({name:J,value:N})}`);continue}let Q=encodeURIComponent(Y==="label"?`.${N}`:N);G=G.replace(B,Q)}return G},Fw=({baseUrl:w,path:$,query:G,querySerializer:W,url:B})=>{let Z=B.startsWith("/")?B:`/${B}`,J=(w??"")+Z;if($)J=AG({path:$,url:J});let Y=G?W(G):"";if(Y.startsWith("?"))Y=Y.substring(1);if(Y)J+=`?${Y}`;return J};var C$=L(()=>{hG=/\{[^{}]+\}/g});var Iw=async(w,$)=>{let G=typeof $==="function"?await $(w):$;if(!G)return;if(w.scheme==="bearer")return`Bearer ${G}`;if(w.scheme==="basic")return`Basic ${btoa(G)}`;return G};var k$;var b$=L(()=>{k$={bodySerializer:(w)=>JSON.stringify(w,($,G)=>typeof G==="bigint"?G.toString():G)}});class z${fns=[];clear(){this.fns=[]}eject(w){let $=this.getInterceptorIndex(w);if(this.fns[$])this.fns[$]=null}exists(w){let $=this.getInterceptorIndex(w);return Boolean(this.fns[$])}getInterceptorIndex(w){if(typeof w==="number")return this.fns[w]?w:-1;return this.fns.indexOf(w)}update(w,$){let G=this.getInterceptorIndex(w);if(this.fns[G])return this.fns[G]=$,w;return!1}use(w){return this.fns.push(w),this.fns.length-1}}var jw=({parameters:w={},...$}={})=>{return(W)=>{let B=[];if(W&&typeof W==="object")for(let Z in W){let J=W[Z];if(J===void 0||J===null)continue;let Y=w[Z]||$;if(Array.isArray(J)){let N=E$({allowReserved:Y.allowReserved,explode:!0,name:Z,style:"form",value:J,...Y.array});if(N)B.push(N)}else if(typeof J==="object"){let N=D$({allowReserved:Y.allowReserved,explode:!0,name:Z,style:"deepObject",value:J,...Y.object});if(N)B.push(N)}else{let N=u({allowReserved:Y.allowReserved,name:Z,value:J});if(N)B.push(N)}}return B.join("&")}},hw=(w)=>{if(!w)return"stream";let $=w.split(";")[0]?.trim();if(!$)return;if($.startsWith("application/json")||$.endsWith("+json"))return"json";if($==="multipart/form-data")return"formData";if(["application/","audio/","image/","video/"].some((G)=>$.startsWith(G)))return"blob";if($.startsWith("text/"))return"text";return},PG=(w,$)=>{if(!$)return!1;if(w.headers.has($)||w.query?.[$]||w.headers.get("Cookie")?.includes(`${$}=`))return!0;return!1},Aw=async({security:w,...$})=>{for(let G of w){if(PG($,G.name))continue;let W=await Iw(G,$.auth);if(!W)continue;let B=G.name??"Authorization";switch(G.in){case"query":if(!$.query)$.query={};$.query[B]=W;break;case"cookie":$.headers.append("Cookie",`${B}=${W}`);break;case"header":default:$.headers.set(B,W);break}}},g$=(w)=>Fw({baseUrl:w.baseUrl,path:w.path,query:w.query,querySerializer:typeof w.querySerializer==="function"?w.querySerializer:jw(w.querySerializer),url:w.url}),c$=(w,$)=>{let G={...w,...$};if(G.baseUrl?.endsWith("/"))G.baseUrl=G.baseUrl.substring(0,G.baseUrl.length-1);return G.headers=T$(w.headers,$.headers),G},xG=(w)=>{let $=[];return w.forEach((G,W)=>{$.push([W,G])}),$},T$=(...w)=>{let $=new Headers;for(let G of w){if(!G)continue;let W=G instanceof Headers?xG(G):Object.entries(G);for(let[B,Z]of W)if(Z===null)$.delete(B);else if(Array.isArray(Z))for(let J of Z)$.append(B,J);else if(Z!==void 0)$.set(B,typeof Z==="object"?JSON.stringify(Z):Z)}return $},Pw=()=>({error:new z$,request:new z$,response:new z$}),CG,kG,a=(w={})=>({...k$,headers:kG,parseAs:"auto",querySerializer:CG,...w});var v$=L(()=>{b$();C$();CG=jw({allowReserved:!1,array:{explode:!0,style:"form"},object:{explode:!0,style:"deepObject"}}),kG={"Content-Type":"application/json"}});var e=(w={})=>{let $=c$(a(),w),G=()=>({...$}),W=(Q)=>{return $=c$($,Q),G()},B=Pw(),Z=async(Q)=>{let U={...$,...Q,fetch:Q.fetch??$.fetch??globalThis.fetch,headers:T$($.headers,Q.headers),serializedBody:void 0};if(U.security)await Aw({...U,security:U.security});if(U.requestValidator)await U.requestValidator(U);if(U.body!==void 0&&U.bodySerializer)U.serializedBody=U.bodySerializer(U.body);if(U.body===void 0||U.serializedBody==="")U.headers.delete("Content-Type");let O=g$(U);return{opts:U,url:O}},J=async(Q)=>{let{opts:U,url:O}=await Z(Q),R={redirect:"follow",...U,body:x$(U)},M=new Request(O,R);for(let V of B.request.fns)if(V)M=await V(M,U);let I=U.fetch,E;try{E=await I(M)}catch(V){let _=V;for(let S of B.error.fns)if(S)_=await S(V,void 0,M,U);if(_=_||{},U.throwOnError)throw _;return U.responseStyle==="data"?void 0:{error:_,request:M,response:void 0}}for(let V of B.response.fns)if(V)E=await V(E,M,U);let K={request:M,response:E};if(E.ok){let V=(U.parseAs==="auto"?hw(E.headers.get("Content-Type")):U.parseAs)??"json";if(E.status===204||E.headers.get("Content-Length")==="0"){let S;switch(V){case"arrayBuffer":case"blob":case"text":S=await E[V]();break;case"formData":S=new FormData;break;case"stream":S=E.body;break;case"json":default:S={};break}return U.responseStyle==="data"?S:{data:S,...K}}let _;switch(V){case"arrayBuffer":case"blob":case"formData":case"text":_=await E[V]();break;case"json":{let S=await E.text();_=S?JSON.parse(S):{};break}case"stream":return U.responseStyle==="data"?E.body:{data:E.body,...K}}if(V==="json"){if(U.responseValidator)await U.responseValidator(_);if(U.responseTransformer)_=await U.responseTransformer(_)}return U.responseStyle==="data"?_:{data:_,...K}}let x=await E.text(),r;try{r=JSON.parse(x)}catch{}let C=r??x,A=C;for(let V of B.error.fns)if(V)A=await V(C,E,M,U);if(A=A||{},U.throwOnError)throw A;return U.responseStyle==="data"?void 0:{error:A,...K}},Y=(Q)=>(U)=>J({...U,method:Q}),N=(Q)=>async(U)=>{let{opts:O,url:R}=await Z(U);return Hw({...O,body:O.body,headers:O.headers,method:Q,onRequest:async(M,I)=>{let E=new Request(M,I);for(let K of B.request.fns)if(K)E=await K(E,O);return E},serializedBody:x$(O),url:R})};return{buildUrl:g$,connect:Y("CONNECT"),delete:Y("DELETE"),get:Y("GET"),getConfig:G,head:Y("HEAD"),interceptors:B,options:Y("OPTIONS"),patch:Y("PATCH"),post:Y("POST"),put:Y("PUT"),request:J,setConfig:W,sse:{connect:N("CONNECT"),delete:N("DELETE"),get:N("GET"),head:N("HEAD"),options:N("OPTIONS"),patch:N("PATCH"),post:N("POST"),put:N("PUT"),trace:N("TRACE")},trace:Y("TRACE")}};var d$=L(()=>{C$();v$()});var bG,gG,xw=(w,$)=>{if(!$)$=new Map;for(let G of w)if("in"in G){if(G.key)$.set(G.key,{in:G.in,map:G.map})}else if("key"in G)$.set(G.key,{map:G.map});else if(G.args)xw(G.args,$);return $},cG=(w)=>{for(let[$,G]of Object.entries(w))if(G&&typeof G==="object"&&!Object.keys(G).length)delete w[$]},X=(w,$)=>{let G={body:{},headers:{},path:{},query:{}},W=xw($),B;for(let[Z,J]of w.entries()){if($[Z])B=$[Z];if(!B)continue;if("in"in B)if(B.key){let Y=W.get(B.key),N=Y.map||B.key;if(Y.in)G[Y.in][N]=J}else G.body=J;else for(let[Y,N]of Object.entries(J??{})){let Q=W.get(Y);if(Q)if(Q.in){let U=Q.map||Y;G[Q.in][U]=N}else G[Q.map]=N;else{let U=gG.find(([O])=>Y.startsWith(O));if(U){let[O,R]=U;G[R][Y.slice(O.length)]=N}else if("allowExtra"in B&&B.allowExtra){for(let[O,R]of Object.entries(B.allowExtra))if(R){G[O][Y]=N;break}}}}}return cG(G),G};var Cw=L(()=>{bG={$body_:"body",$headers_:"headers",$path_:"path",$query_:"query"},gG=Object.entries(bG)});var y$=L(()=>{b$();Cw();d$();v$()});var kw;var bw=L(()=>{y$();kw=e(a({baseUrl:"http://localhost:4096"}))});class D{client;constructor(w){this.client=w?.client??kw}}class gw{defaultKey="default";instances=new Map;get(w){let $=this.instances.get(w??this.defaultKey);if(!$)throw Error('No SDK client found. Create one with "new OpencodeClient()" to fix this error.');return $}set(w,$){this.instances.set($??this.defaultKey,w)}}var cw,vw,dw,yw,mw,uw,lw,pw,nw,iw,rw,ow,sw,tw,aw,ew,$0,w0,G0,W0,B0,Z0,J0,Y0,N0,X0,U0,Q0,O0,L0,M$;var E0=L(()=>{bw();y$();cw=class cw extends D{get(w){return(w?.client??this.client).get({url:"/global/config",...w})}update(w,$){let G=X([w],[{args:[{key:"config",map:"body"}]}]);return($?.client??this.client).patch({url:"/global/config",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}};vw=class vw extends D{health(w){return(w?.client??this.client).get({url:"/global/health",...w})}event(w){return(w?.client??this.client).sse.get({url:"/global/event",...w})}dispose(w){return(w?.client??this.client).post({url:"/global/dispose",...w})}_config;get config(){return this._config??=new cw({client:this.client})}};dw=class dw extends D{remove(w,$){let G=X([w],[{args:[{in:"path",key:"providerID"}]}]);return($?.client??this.client).delete({url:"/auth/{providerID}",...$,...G})}set(w,$){let G=X([w],[{args:[{in:"path",key:"providerID"},{key:"auth",map:"body"}]}]);return($?.client??this.client).put({url:"/auth/{providerID}",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}};yw=class yw extends D{list(w,$){let G=X([w],[{args:[{in:"query",key:"directory"}]}]);return($?.client??this.client).get({url:"/project",...$,...G})}current(w,$){let G=X([w],[{args:[{in:"query",key:"directory"}]}]);return($?.client??this.client).get({url:"/project/current",...$,...G})}update(w,$){let G=X([w],[{args:[{in:"path",key:"projectID"},{in:"query",key:"directory"},{in:"body",key:"name"},{in:"body",key:"icon"},{in:"body",key:"commands"}]}]);return($?.client??this.client).patch({url:"/project/{projectID}",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}};mw=class mw extends D{list(w,$){let G=X([w],[{args:[{in:"query",key:"directory"}]}]);return($?.client??this.client).get({url:"/pty",...$,...G})}create(w,$){let G=X([w],[{args:[{in:"query",key:"directory"},{in:"body",key:"command"},{in:"body",key:"args"},{in:"body",key:"cwd"},{in:"body",key:"title"},{in:"body",key:"env"}]}]);return($?.client??this.client).post({url:"/pty",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}remove(w,$){let G=X([w],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"directory"}]}]);return($?.client??this.client).delete({url:"/pty/{ptyID}",...$,...G})}get(w,$){let G=X([w],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"directory"}]}]);return($?.client??this.client).get({url:"/pty/{ptyID}",...$,...G})}update(w,$){let G=X([w],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"directory"},{in:"body",key:"title"},{in:"body",key:"size"}]}]);return($?.client??this.client).put({url:"/pty/{ptyID}",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}connect(w,$){let G=X([w],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"directory"}]}]);return($?.client??this.client).get({url:"/pty/{ptyID}/connect",...$,...G})}};uw=class uw extends D{get(w,$){let G=X([w],[{args:[{in:"query",key:"directory"}]}]);return($?.client??this.client).get({url:"/config",...$,...G})}update(w,$){let G=X([w],[{args:[{in:"query",key:"directory"},{key:"config",map:"body"}]}]);return($?.client??this.client).patch({url:"/config",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}providers(w,$){let G=X([w],[{args:[{in:"query",key:"directory"}]}]);return($?.client??this.client).get({url:"/config/providers",...$,...G})}};lw=class lw extends D{ids(w,$){let G=X([w],[{args:[{in:"query",key:"directory"}]}]);return($?.client??this.client).get({url:"/experimental/tool/ids",...$,...G})}list(w,$){let G=X([w],[{args:[{in:"query",key:"directory"},{in:"query",key:"provider"},{in:"query",key:"model"}]}]);return($?.client??this.client).get({url:"/experimental/tool",...$,...G})}};pw=class pw extends D{remove(w,$){let G=X([w],[{args:[{in:"query",key:"directory"},{key:"worktreeRemoveInput",map:"body"}]}]);return($?.client??this.client).delete({url:"/experimental/worktree",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}list(w,$){let G=X([w],[{args:[{in:"query",key:"directory"}]}]);return($?.client??this.client).get({url:"/experimental/worktree",...$,...G})}create(w,$){let G=X([w],[{args:[{in:"query",key:"directory"},{key:"worktreeCreateInput",map:"body"}]}]);return($?.client??this.client).post({url:"/experimental/worktree",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}reset(w,$){let G=X([w],[{args:[{in:"query",key:"directory"},{key:"worktreeResetInput",map:"body"}]}]);return($?.client??this.client).post({url:"/experimental/worktree/reset",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}};nw=class nw extends D{list(w,$){let G=X([w],[{args:[{in:"query",key:"directory"}]}]);return($?.client??this.client).get({url:"/experimental/resource",...$,...G})}};iw=class iw extends D{_resource;get resource(){return this._resource??=new nw({client:this.client})}};rw=class rw extends D{list(w,$){let G=X([w],[{args:[{in:"query",key:"directory"},{in:"query",key:"roots"},{in:"query",key:"start"},{in:"query",key:"search"},{in:"query",key:"limit"}]}]);return($?.client??this.client).get({url:"/session",...$,...G})}create(w,$){let G=X([w],[{args:[{in:"query",key:"directory"},{in:"body",key:"parentID"},{in:"body",key:"title"},{in:"body",key:"permission"}]}]);return($?.client??this.client).post({url:"/session",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}status(w,$){let G=X([w],[{args:[{in:"query",key:"directory"}]}]);return($?.client??this.client).get({url:"/session/status",...$,...G})}delete(w,$){let G=X([w],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"}]}]);return($?.client??this.client).delete({url:"/session/{sessionID}",...$,...G})}get(w,$){let G=X([w],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"}]}]);return($?.client??this.client).get({url:"/session/{sessionID}",...$,...G})}update(w,$){let G=X([w],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"body",key:"title"},{in:"body",key:"time"}]}]);return($?.client??this.client).patch({url:"/session/{sessionID}",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}children(w,$){let G=X([w],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"}]}]);return($?.client??this.client).get({url:"/session/{sessionID}/children",...$,...G})}todo(w,$){let G=X([w],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"}]}]);return($?.client??this.client).get({url:"/session/{sessionID}/todo",...$,...G})}init(w,$){let G=X([w],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"body",key:"modelID"},{in:"body",key:"providerID"},{in:"body",key:"messageID"}]}]);return($?.client??this.client).post({url:"/session/{sessionID}/init",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}fork(w,$){let G=X([w],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"body",key:"messageID"}]}]);return($?.client??this.client).post({url:"/session/{sessionID}/fork",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}abort(w,$){let G=X([w],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"}]}]);return($?.client??this.client).post({url:"/session/{sessionID}/abort",...$,...G})}unshare(w,$){let G=X([w],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"}]}]);return($?.client??this.client).delete({url:"/session/{sessionID}/share",...$,...G})}share(w,$){let G=X([w],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"}]}]);return($?.client??this.client).post({url:"/session/{sessionID}/share",...$,...G})}diff(w,$){let G=X([w],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"messageID"}]}]);return($?.client??this.client).get({url:"/session/{sessionID}/diff",...$,...G})}summarize(w,$){let G=X([w],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"body",key:"providerID"},{in:"body",key:"modelID"},{in:"body",key:"auto"}]}]);return($?.client??this.client).post({url:"/session/{sessionID}/summarize",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}messages(w,$){let G=X([w],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"limit"}]}]);return($?.client??this.client).get({url:"/session/{sessionID}/message",...$,...G})}prompt(w,$){let G=X([w],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"body",key:"messageID"},{in:"body",key:"model"},{in:"body",key:"agent"},{in:"body",key:"noReply"},{in:"body",key:"tools"},{in:"body",key:"system"},{in:"body",key:"variant"},{in:"body",key:"parts"}]}]);return($?.client??this.client).post({url:"/session/{sessionID}/message",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}message(w,$){let G=X([w],[{args:[{in:"path",key:"sessionID"},{in:"path",key:"messageID"},{in:"query",key:"directory"}]}]);return($?.client??this.client).get({url:"/session/{sessionID}/message/{messageID}",...$,...G})}promptAsync(w,$){let G=X([w],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"body",key:"messageID"},{in:"body",key:"model"},{in:"body",key:"agent"},{in:"body",key:"noReply"},{in:"body",key:"tools"},{in:"body",key:"system"},{in:"body",key:"variant"},{in:"body",key:"parts"}]}]);return($?.client??this.client).post({url:"/session/{sessionID}/prompt_async",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}command(w,$){let G=X([w],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"body",key:"messageID"},{in:"body",key:"agent"},{in:"body",key:"model"},{in:"body",key:"arguments"},{in:"body",key:"command"},{in:"body",key:"variant"},{in:"body",key:"parts"}]}]);return($?.client??this.client).post({url:"/session/{sessionID}/command",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}shell(w,$){let G=X([w],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"body",key:"agent"},{in:"body",key:"model"},{in:"body",key:"command"}]}]);return($?.client??this.client).post({url:"/session/{sessionID}/shell",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}revert(w,$){let G=X([w],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"body",key:"messageID"},{in:"body",key:"partID"}]}]);return($?.client??this.client).post({url:"/session/{sessionID}/revert",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}unrevert(w,$){let G=X([w],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"}]}]);return($?.client??this.client).post({url:"/session/{sessionID}/unrevert",...$,...G})}};ow=class ow extends D{delete(w,$){let G=X([w],[{args:[{in:"path",key:"sessionID"},{in:"path",key:"messageID"},{in:"path",key:"partID"},{in:"query",key:"directory"}]}]);return($?.client??this.client).delete({url:"/session/{sessionID}/message/{messageID}/part/{partID}",...$,...G})}update(w,$){let G=X([w],[{args:[{in:"path",key:"sessionID"},{in:"path",key:"messageID"},{in:"path",key:"partID"},{in:"query",key:"directory"},{key:"part",map:"body"}]}]);return($?.client??this.client).patch({url:"/session/{sessionID}/message/{messageID}/part/{partID}",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}};sw=class sw extends D{respond(w,$){let G=X([w],[{args:[{in:"path",key:"sessionID"},{in:"path",key:"permissionID"},{in:"query",key:"directory"},{in:"body",key:"response"}]}]);return($?.client??this.client).post({url:"/session/{sessionID}/permissions/{permissionID}",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}reply(w,$){let G=X([w],[{args:[{in:"path",key:"requestID"},{in:"query",key:"directory"},{in:"body",key:"reply"},{in:"body",key:"message"}]}]);return($?.client??this.client).post({url:"/permission/{requestID}/reply",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}list(w,$){let G=X([w],[{args:[{in:"query",key:"directory"}]}]);return($?.client??this.client).get({url:"/permission",...$,...G})}};tw=class tw extends D{list(w,$){let G=X([w],[{args:[{in:"query",key:"directory"}]}]);return($?.client??this.client).get({url:"/question",...$,...G})}reply(w,$){let G=X([w],[{args:[{in:"path",key:"requestID"},{in:"query",key:"directory"},{in:"body",key:"answers"}]}]);return($?.client??this.client).post({url:"/question/{requestID}/reply",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}reject(w,$){let G=X([w],[{args:[{in:"path",key:"requestID"},{in:"query",key:"directory"}]}]);return($?.client??this.client).post({url:"/question/{requestID}/reject",...$,...G})}};aw=class aw extends D{authorize(w,$){let G=X([w],[{args:[{in:"path",key:"providerID"},{in:"query",key:"directory"},{in:"body",key:"method"}]}]);return($?.client??this.client).post({url:"/provider/{providerID}/oauth/authorize",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}callback(w,$){let G=X([w],[{args:[{in:"path",key:"providerID"},{in:"query",key:"directory"},{in:"body",key:"method"},{in:"body",key:"code"}]}]);return($?.client??this.client).post({url:"/provider/{providerID}/oauth/callback",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}};ew=class ew extends D{list(w,$){let G=X([w],[{args:[{in:"query",key:"directory"}]}]);return($?.client??this.client).get({url:"/provider",...$,...G})}auth(w,$){let G=X([w],[{args:[{in:"query",key:"directory"}]}]);return($?.client??this.client).get({url:"/provider/auth",...$,...G})}_oauth;get oauth(){return this._oauth??=new aw({client:this.client})}};$0=class $0 extends D{text(w,$){let G=X([w],[{args:[{in:"query",key:"directory"},{in:"query",key:"pattern"}]}]);return($?.client??this.client).get({url:"/find",...$,...G})}files(w,$){let G=X([w],[{args:[{in:"query",key:"directory"},{in:"query",key:"query"},{in:"query",key:"dirs"},{in:"query",key:"type"},{in:"query",key:"limit"}]}]);return($?.client??this.client).get({url:"/find/file",...$,...G})}symbols(w,$){let G=X([w],[{args:[{in:"query",key:"directory"},{in:"query",key:"query"}]}]);return($?.client??this.client).get({url:"/find/symbol",...$,...G})}};w0=class w0 extends D{list(w,$){let G=X([w],[{args:[{in:"query",key:"directory"},{in:"query",key:"path"}]}]);return($?.client??this.client).get({url:"/file",...$,...G})}read(w,$){let G=X([w],[{args:[{in:"query",key:"directory"},{in:"query",key:"path"}]}]);return($?.client??this.client).get({url:"/file/content",...$,...G})}status(w,$){let G=X([w],[{args:[{in:"query",key:"directory"}]}]);return($?.client??this.client).get({url:"/file/status",...$,...G})}};G0=class G0 extends D{remove(w,$){let G=X([w],[{args:[{in:"path",key:"name"},{in:"query",key:"directory"}]}]);return($?.client??this.client).delete({url:"/mcp/{name}/auth",...$,...G})}start(w,$){let G=X([w],[{args:[{in:"path",key:"name"},{in:"query",key:"directory"}]}]);return($?.client??this.client).post({url:"/mcp/{name}/auth",...$,...G})}callback(w,$){let G=X([w],[{args:[{in:"path",key:"name"},{in:"query",key:"directory"},{in:"body",key:"code"}]}]);return($?.client??this.client).post({url:"/mcp/{name}/auth/callback",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}authenticate(w,$){let G=X([w],[{args:[{in:"path",key:"name"},{in:"query",key:"directory"}]}]);return($?.client??this.client).post({url:"/mcp/{name}/auth/authenticate",...$,...G})}};W0=class W0 extends D{status(w,$){let G=X([w],[{args:[{in:"query",key:"directory"}]}]);return($?.client??this.client).get({url:"/mcp",...$,...G})}add(w,$){let G=X([w],[{args:[{in:"query",key:"directory"},{in:"body",key:"name"},{in:"body",key:"config"}]}]);return($?.client??this.client).post({url:"/mcp",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}connect(w,$){let G=X([w],[{args:[{in:"path",key:"name"},{in:"query",key:"directory"}]}]);return($?.client??this.client).post({url:"/mcp/{name}/connect",...$,...G})}disconnect(w,$){let G=X([w],[{args:[{in:"path",key:"name"},{in:"query",key:"directory"}]}]);return($?.client??this.client).post({url:"/mcp/{name}/disconnect",...$,...G})}_auth;get auth(){return this._auth??=new G0({client:this.client})}};B0=class B0 extends D{next(w,$){let G=X([w],[{args:[{in:"query",key:"directory"}]}]);return($?.client??this.client).get({url:"/tui/control/next",...$,...G})}response(w,$){let G=X([w],[{args:[{in:"query",key:"directory"},{key:"body",map:"body"}]}]);return($?.client??this.client).post({url:"/tui/control/response",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}};Z0=class Z0 extends D{appendPrompt(w,$){let G=X([w],[{args:[{in:"query",key:"directory"},{in:"body",key:"text"}]}]);return($?.client??this.client).post({url:"/tui/append-prompt",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}openHelp(w,$){let G=X([w],[{args:[{in:"query",key:"directory"}]}]);return($?.client??this.client).post({url:"/tui/open-help",...$,...G})}openSessions(w,$){let G=X([w],[{args:[{in:"query",key:"directory"}]}]);return($?.client??this.client).post({url:"/tui/open-sessions",...$,...G})}openThemes(w,$){let G=X([w],[{args:[{in:"query",key:"directory"}]}]);return($?.client??this.client).post({url:"/tui/open-themes",...$,...G})}openModels(w,$){let G=X([w],[{args:[{in:"query",key:"directory"}]}]);return($?.client??this.client).post({url:"/tui/open-models",...$,...G})}submitPrompt(w,$){let G=X([w],[{args:[{in:"query",key:"directory"}]}]);return($?.client??this.client).post({url:"/tui/submit-prompt",...$,...G})}clearPrompt(w,$){let G=X([w],[{args:[{in:"query",key:"directory"}]}]);return($?.client??this.client).post({url:"/tui/clear-prompt",...$,...G})}executeCommand(w,$){let G=X([w],[{args:[{in:"query",key:"directory"},{in:"body",key:"command"}]}]);return($?.client??this.client).post({url:"/tui/execute-command",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}showToast(w,$){let G=X([w],[{args:[{in:"query",key:"directory"},{in:"body",key:"title"},{in:"body",key:"message"},{in:"body",key:"variant"},{in:"body",key:"duration"}]}]);return($?.client??this.client).post({url:"/tui/show-toast",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}publish(w,$){let G=X([w],[{args:[{in:"query",key:"directory"},{key:"body",map:"body"}]}]);return($?.client??this.client).post({url:"/tui/publish",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}selectSession(w,$){let G=X([w],[{args:[{in:"query",key:"directory"},{in:"body",key:"sessionID"}]}]);return($?.client??this.client).post({url:"/tui/select-session",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}_control;get control(){return this._control??=new B0({client:this.client})}};J0=class J0 extends D{dispose(w,$){let G=X([w],[{args:[{in:"query",key:"directory"}]}]);return($?.client??this.client).post({url:"/instance/dispose",...$,...G})}};Y0=class Y0 extends D{get(w,$){let G=X([w],[{args:[{in:"query",key:"directory"}]}]);return($?.client??this.client).get({url:"/path",...$,...G})}};N0=class N0 extends D{get(w,$){let G=X([w],[{args:[{in:"query",key:"directory"}]}]);return($?.client??this.client).get({url:"/vcs",...$,...G})}};X0=class X0 extends D{list(w,$){let G=X([w],[{args:[{in:"query",key:"directory"}]}]);return($?.client??this.client).get({url:"/command",...$,...G})}};U0=class U0 extends D{log(w,$){let G=X([w],[{args:[{in:"query",key:"directory"},{in:"body",key:"service"},{in:"body",key:"level"},{in:"body",key:"message"},{in:"body",key:"extra"}]}]);return($?.client??this.client).post({url:"/log",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}agents(w,$){let G=X([w],[{args:[{in:"query",key:"directory"}]}]);return($?.client??this.client).get({url:"/agent",...$,...G})}skills(w,$){let G=X([w],[{args:[{in:"query",key:"directory"}]}]);return($?.client??this.client).get({url:"/skill",...$,...G})}};Q0=class Q0 extends D{status(w,$){let G=X([w],[{args:[{in:"query",key:"directory"}]}]);return($?.client??this.client).get({url:"/lsp",...$,...G})}};O0=class O0 extends D{status(w,$){let G=X([w],[{args:[{in:"query",key:"directory"}]}]);return($?.client??this.client).get({url:"/formatter",...$,...G})}};L0=class L0 extends D{subscribe(w,$){let G=X([w],[{args:[{in:"query",key:"directory"}]}]);return($?.client??this.client).sse.get({url:"/event",...$,...G})}};M$=class M$ extends D{static __registry=new gw;constructor(w){super(w);M$.__registry.set(this,w?.key)}_global;get global(){return this._global??=new vw({client:this.client})}_auth;get auth(){return this._auth??=new dw({client:this.client})}_project;get project(){return this._project??=new yw({client:this.client})}_pty;get pty(){return this._pty??=new mw({client:this.client})}_config;get config(){return this._config??=new uw({client:this.client})}_tool;get tool(){return this._tool??=new lw({client:this.client})}_worktree;get worktree(){return this._worktree??=new pw({client:this.client})}_experimental;get experimental(){return this._experimental??=new iw({client:this.client})}_session;get session(){return this._session??=new rw({client:this.client})}_part;get part(){return this._part??=new ow({client:this.client})}_permission;get permission(){return this._permission??=new sw({client:this.client})}_question;get question(){return this._question??=new tw({client:this.client})}_provider;get provider(){return this._provider??=new ew({client:this.client})}_find;get find(){return this._find??=new $0({client:this.client})}_file;get file(){return this._file??=new w0({client:this.client})}_mcp;get mcp(){return this._mcp??=new W0({client:this.client})}_tui;get tui(){return this._tui??=new Z0({client:this.client})}_instance;get instance(){return this._instance??=new J0({client:this.client})}_path;get path(){return this._path??=new Y0({client:this.client})}_vcs;get vcs(){return this._vcs??=new N0({client:this.client})}_command;get command(){return this._command??=new X0({client:this.client})}_app;get app(){return this._app??=new U0({client:this.client})}_lsp;get lsp(){return this._lsp??=new Q0({client:this.client})}_formatter;get formatter(){return this._formatter??=new O0({client:this.client})}_event;get event(){return this._event??=new L0({client:this.client})}}});function m$(w){if(!w?.fetch)w={...w,fetch:(W)=>{return W.timeout=!1,fetch(W)}};if(w?.directory){let W=/[^\x00-\x7F]/.test(w.directory)?encodeURIComponent(w.directory):w.directory;w.headers={...w.headers,"x-opencode-directory":W}}let $=e(w);return new M$({client:$})}var D0=L(()=>{d$();E0();qw()});async function T0(w){if(w.loopUpForDesktopServer){let $=await vG();if($){let G=m$(A$(w,$??{}));if((await G.global.health()).data?.healthy)return G;else console.warn("Desktop server is not healthy, re-launch Opencode app")}else console.warn("Desktop server is not registered, launch Opencode app")}return m$(w)}async function vG(){if(!await z0.exists())return;let $=await z0.json();return dG($)}function dG(w){return{baseUrl:`http://${w.hostname}:${w.port}`,headers:{Authorization:`Basic ${btoa(`${w.username}:${w.password}`)}`}}}var z0,N5;var M0=L(()=>{D0();F();z0=Bun.file(`${Bun.env.HOME}/Library/Application Support/ai.opencode.desktop/store.json`),N5={client:Bun.env.OPENCODE_CLIENT??"unknown",password:Bun.env.OPENCODE_SERVER_PASSWORD,username:Bun.env.OPENCODE_SERVER_USERNAME}});async function f0(w,$){let{data:G}=await w.project.current({directory:$??process.cwd()});if(G&&G.id!=="global")return G.worktree;let{data:W,error:B}=await w.project.list();return f(B===void 0,`Failed to list projects: ${B}`),f(W,"No projects found"),f(W.length>0,`No projects found: ${W.length}`),X$.select("Select a project",{options:W.map((Z)=>({label:Z.name??Z.worktree,value:Z.worktree,hint:Z.name?`${Z.worktree} - ${Z.id.slice(0,5)}`:Z.id.slice(0,5)}))})}function _0(w){return w.name??w.worktree}var u$=L(()=>{U$();F()});var $$,l$;var p$=L(()=>{$$=class $$ extends Error{output;constructor(w,$){let G=w.stdout.toString().trim()||void 0,B=(w.stderr.toString().trim()||void 0)??G??"Unknown shell error";super(B,{cause:$.cause});this.output=w}};l$=class l$ extends Error{exitCode;constructor(w){let $=w.exitCode;super(`Exited with code '${$}'`);this.exitCode=$}}});var H={};b(H,{use:()=>yG,create:()=>V0});function yG(w){if(w instanceof Bun.$.Shell)return V0(w);if(R0 in w)return w;throw Error("Invalid client input")}function V0(w){let $=w,W=Object.assign((B,...Z)=>{let J=0,Y=[...B],N=Z.flatMap((O,R)=>{if(!t(O))return[O];let M=d(Mw(O),(E,K)=>{if(_w(K))return`--${E}`;if(g(K))return`--${E}=${Q$(K).join(",")}`;return`--${E}='${String(K)}'`});if(P(M))return[""];let I=M.length-1;return Y.splice(R+1+J,0,...Array(I).fill(" ")),J+=I,M}),Q=Object.assign(Y,{raw:[...Y]}),U=$(Q,...N);return mG(U)},{[R0]:!0,cwd(B){return $=$.cwd(B),W},env(B){return $=$.env(B),W}});return W}function mG(w){return{json:async($)=>{let G=await w.quiet($?.quiet).nothrow(),[W,B]=await zw(()=>G.json())();if(B)return B;throw new $$(G,{cause:W})},text:async($)=>{let G=await w.quiet($?.quiet).nothrow(),W=G.stdout.toString().trim()||void 0;if(G.exitCode!==0)return[new $$(G,{cause:new l$(G)}),W];return[void 0,W]}}}var R0;var S0=L(()=>{F();p$();R0=Symbol("shell_client")});var w$=L(()=>{S0();p$()});var h={};b(h,{use:()=>uG,update:()=>_$,show:()=>nG,list:()=>n$,find:()=>K$,close:()=>pG,claim:()=>lG});async function uG(w,$,G){if("status"in $&&!G?.force)return $;return j$(await n$(w,{...G,ids:[$.id]}))}async function _$(w,$,G={}){let B=await H.use(w)`bd update ${$.id} ${G} --json`.json(),[Z]=B;return f(Z,`Issue '${$.id}' not found`),Z}async function lG(w,$,G={}){let B=await H.use(w)`bd update ${$.id} ${G} --claim --json`.json(),[Z]=B;return f(Z,`Issue '${$.id}' not found`),Z}async function pG(w,$,G={}){let B=await H.use(w)`bd close ${$.id} ${G} --json`.json(),[Z]=B;return f(Z,`Issue '${$.id}' not found`),Z}async function nG(w,$){return H.use(w)`bd show ${$.id}`.text()}var n$,K$;var V$=L(()=>{F();w$();n$=Object.assign(async(w,$={})=>{if(P($.ids))return[];return await H.use(w)`bd list ${$} --json`.json()},{ready:async(w,$={})=>{return await H.use(w)`bd ready ${$} --json`.json()}});((T5)=>{async function w($,G,W){return(await n$($,W)).find((Z)=>Z.external_ref===G)}T5.byExternalRef=w})(K$||={})});var l={};b(l,{use:()=>oG,stuck:()=>iG,state:()=>i$,done:()=>rG});async function iG(w,$,G){let W=await i$(w,$,"stuck");return await _$(w,{id:W.agent},{"add-label":q0(G.context),description:G.reason}),W}async function rG(w,$,G={}){let W=await i$(w,$,"done");return await _$(w,{id:W.agent},{"add-label":q0(G.context),description:""}),W}async function i$(w,$,G){return await H.use(w)`bd agent state gram-${$} ${G} --json`.json()}async function oG(w,$){let G=H.use(w),W="slug"in $?`gram-${$.slug}`:$.id;return await G`bd agent show ${W} --json`.json()}function q0(w){if(!w)return;let $=Q$(d(w,(G,W)=>W&&`${G}:${W}`));return P($)?void 0:$}var H0=L(()=>{F();w$();V$()});var p={};b(p,{update:()=>tG,find:()=>F0,create:()=>sG});async function sG(w,$){let G=H.use(w),W={title:$.title,description:$.description,"external-ref":$.file};return await G`bd create --type epic ${W} --json`.json()}async function tG(w,$,G){let W=H.use(w),B={title:G.title,description:G.description,"external-ref":G.file},Z=await W`bd update ${$.id} --type epic ${B} --json`.json(),[J]=Z;return f(J,`Issue '${$.id}' not found`),J}var F0;var I0=L(()=>{F();w$();V$();((_5)=>{function w($,G){return K$.byExternalRef($,G,{type:"epic"})}_5.byExternalRef=w})(F0||={})});var h0=L(()=>{w$()});var G$=L(()=>{H0();I0();V$();h0()});var n={};b(n,{watch:()=>x0,use:()=>eG,scan:()=>C0,MARKDOWN:()=>o$,Frontmatter:()=>aG});import*as P0 from"fs";import*as S$ from"path";import{z as A0}from"zod";function eG(w){if(w.watch)return x0(w);else return C0(w)}async function*x0(w){let $=new Map,G=[],W,B=P0.watch(w.target,async(Z,J)=>{if(Z==="change"&&J){if(!o$.match(J))return;if(w.ignore?.match(J))return;let Y=r$(w.target,J),N=Bun.hash(await Y.file.text());if($.get(J)===N)return;if($.set(J,N),G.push(r$(w.target,J)),W)W.resolve(J),W=void 0}});try{while(!0){let Z=G.shift();if(Z)yield Z;else W=h$(),await W.promise}}finally{B.close()}}async function*C0(w){for await(let $ of o$.scan({cwd:w.target})){if(w.ignore?.match($))continue;yield r$(w.target,$)}}function r$(w,$){let G=S$.join(w,$);return{filename:$,filepath:S$.parse(G),file:Bun.file(G)}}var o$,aG;var k0=L(()=>{F();o$=new Bun.Glob("**/*.md"),aG=A0.object({issue:A0.string().optional()})});var s$=L(()=>{k0()});function g0(w,$){let G=$?.delimiter??"---";if(!w.trimStart().startsWith(G))return{metadata:{},content:w};let W=w.split(`
|
|
14
|
-
`),
|
|
15
|
-
`),
|
|
16
|
-
`).replace(/^\n+/,"");return{metadata:
|
|
17
|
-
${
|
|
18
|
-
`}function
|
|
19
|
-
${w}`}function
|
|
20
|
-
`),
|
|
21
|
-
`;else if(
|
|
22
|
-
`,
|
|
23
|
-
`);
|
|
24
|
-
`}else if(
|
|
25
|
-
`;for(let J of Z)if(
|
|
26
|
-
${
|
|
27
|
-
`}else
|
|
28
|
-
`;return
|
|
29
|
-
Spec: ${
|
|
30
|
-
`},
|
|
11
|
+
`);e=Nw.pop()??"";for(let M1 of Nw){let _1=M1.split(`
|
|
12
|
+
`),Z$=[],Yw;for(let I of _1)if(I.startsWith("data:"))Z$.push(I.replace(/^data:\s*/,""));else if(I.startsWith("event:"))Yw=I.replace(/^event:\s*/,"");else if(I.startsWith("id:"))Q=I.replace(/^id:\s*/,"");else if(I.startsWith("retry:")){let Xw=Number.parseInt(I.replace(/^retry:\s*/,""),10);if(!Number.isNaN(Xw))L=Xw}let b,Uw=!1;if(Z$.length){let I=Z$.join(`
|
|
13
|
+
`);try{b=JSON.parse(I),Uw=!0}catch{b=I}}if(Uw){if(W)await W(b);if(B)b=await B(b)}if(G?.({data:b,event:Yw,id:Q,retry:L}),Z$.length)yield b}}}finally{j.removeEventListener("abort",Jw),S.releaseLock()}break}catch(k){if($?.(k),J!==void 0&&_>=J)break;let h=Math.min(L*2**(_-1),N??30000);await K(h)}}}()}};var b1=(w)=>{switch(w){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},g1=(w)=>{switch(w){case"form":return",";case"pipeDelimited":return"|";case"spaceDelimited":return"%20";default:return","}},v1=(w)=>{switch(w){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},E$=({allowReserved:w,explode:$,name:G,style:B,value:W})=>{if(!$){let N=(w?W:W.map((Y)=>encodeURIComponent(Y))).join(g1(B));switch(B){case"label":return`.${N}`;case"matrix":return`;${G}=${N}`;case"simple":return N;default:return`${G}=${N}`}}let Z=b1(B),J=W.map((N)=>{if(B==="label"||B==="simple")return w?N:encodeURIComponent(N);return l({allowReserved:w,name:G,value:N})}).join(Z);return B==="label"||B==="matrix"?Z+J:J},l=({allowReserved:w,name:$,value:G})=>{if(G===void 0||G===null)return"";if(typeof G==="object")throw Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");return`${$}=${w?G:encodeURIComponent(G)}`},D$=({allowReserved:w,explode:$,name:G,style:B,value:W,valueOnly:Z})=>{if(W instanceof Date)return Z?W.toISOString():`${G}=${W.toISOString()}`;if(B!=="deepObject"&&!$){let Y=[];Object.entries(W).forEach(([X,Q])=>{Y=[...Y,X,w?Q:encodeURIComponent(Q)]});let O=Y.join(",");switch(B){case"form":return`${G}=${O}`;case"label":return`.${O}`;case"matrix":return`;${G}=${O}`;default:return O}}let J=v1(B),N=Object.entries(W).map(([Y,O])=>l({allowReserved:w,name:B==="deepObject"?`${G}[${Y}]`:Y,value:O})).join(J);return B==="label"||B==="matrix"?J+N:N};function x$(w){let $=w.body!==void 0;if($&&w.bodySerializer){if("serializedBody"in w)return w.serializedBody!==void 0&&w.serializedBody!==""?w.serializedBody:null;return w.body!==""?w.body:null}if($)return w.body;return}var c1,d1=({path:w,url:$})=>{let G=$,B=$.match(c1);if(B)for(let W of B){let Z=!1,J=W.substring(1,W.length-1),N="simple";if(J.endsWith("*"))Z=!0,J=J.substring(0,J.length-1);if(J.startsWith("."))J=J.substring(1),N="label";else if(J.startsWith(";"))J=J.substring(1),N="matrix";let Y=w[J];if(Y===void 0||Y===null)continue;if(Array.isArray(Y)){G=G.replace(W,E$({explode:Z,name:J,style:N,value:Y}));continue}if(typeof Y==="object"){G=G.replace(W,D$({explode:Z,name:J,style:N,value:Y,valueOnly:!0}));continue}if(N==="matrix"){G=G.replace(W,`;${l({name:J,value:Y})}`);continue}let O=encodeURIComponent(N==="label"?`.${Y}`:Y);G=G.replace(W,O)}return G},Cw=({baseUrl:w,path:$,query:G,querySerializer:B,url:W})=>{let Z=W.startsWith("/")?W:`/${W}`,J=(w??"")+Z;if($)J=d1({path:$,url:J});let N=G?B(G):"";if(N.startsWith("?"))N=N.substring(1);if(N)J+=`?${N}`;return J};var C$=E(()=>{c1=/\{[^{}]+\}/g});var kw=async(w,$)=>{let G=typeof $==="function"?await $(w):$;if(!G)return;if(w.scheme==="bearer")return`Bearer ${G}`;if(w.scheme==="basic")return`Basic ${btoa(G)}`;return G};var k$;var b$=E(()=>{k$={bodySerializer:(w)=>JSON.stringify(w,($,G)=>typeof G==="bigint"?G.toString():G)}});class T${fns=[];clear(){this.fns=[]}eject(w){let $=this.getInterceptorIndex(w);if(this.fns[$])this.fns[$]=null}exists(w){let $=this.getInterceptorIndex(w);return Boolean(this.fns[$])}getInterceptorIndex(w){if(typeof w==="number")return this.fns[w]?w:-1;return this.fns.indexOf(w)}update(w,$){let G=this.getInterceptorIndex(w);if(this.fns[G])return this.fns[G]=$,w;return!1}use(w){return this.fns.push(w),this.fns.length-1}}var bw=({parameters:w={},...$}={})=>{return(B)=>{let W=[];if(B&&typeof B==="object")for(let Z in B){let J=B[Z];if(J===void 0||J===null)continue;let N=w[Z]||$;if(Array.isArray(J)){let Y=E$({allowReserved:N.allowReserved,explode:!0,name:Z,style:"form",value:J,...N.array});if(Y)W.push(Y)}else if(typeof J==="object"){let Y=D$({allowReserved:N.allowReserved,explode:!0,name:Z,style:"deepObject",value:J,...N.object});if(Y)W.push(Y)}else{let Y=l({allowReserved:N.allowReserved,name:Z,value:J});if(Y)W.push(Y)}}return W.join("&")}},gw=(w)=>{if(!w)return"stream";let $=w.split(";")[0]?.trim();if(!$)return;if($.startsWith("application/json")||$.endsWith("+json"))return"json";if($==="multipart/form-data")return"formData";if(["application/","audio/","image/","video/"].some((G)=>$.startsWith(G)))return"blob";if($.startsWith("text/"))return"text";return},y1=(w,$)=>{if(!$)return!1;if(w.headers.has($)||w.query?.[$]||w.headers.get("Cookie")?.includes(`${$}=`))return!0;return!1},vw=async({security:w,...$})=>{for(let G of w){if(y1($,G.name))continue;let B=await kw(G,$.auth);if(!B)continue;let W=G.name??"Authorization";switch(G.in){case"query":if(!$.query)$.query={};$.query[W]=B;break;case"cookie":$.headers.append("Cookie",`${W}=${B}`);break;case"header":default:$.headers.set(W,B);break}}},g$=(w)=>Cw({baseUrl:w.baseUrl,path:w.path,query:w.query,querySerializer:typeof w.querySerializer==="function"?w.querySerializer:bw(w.querySerializer),url:w.url}),v$=(w,$)=>{let G={...w,...$};if(G.baseUrl?.endsWith("/"))G.baseUrl=G.baseUrl.substring(0,G.baseUrl.length-1);return G.headers=M$(w.headers,$.headers),G},m1=(w)=>{let $=[];return w.forEach((G,B)=>{$.push([B,G])}),$},M$=(...w)=>{let $=new Headers;for(let G of w){if(!G)continue;let B=G instanceof Headers?m1(G):Object.entries(G);for(let[W,Z]of B)if(Z===null)$.delete(W);else if(Array.isArray(Z))for(let J of Z)$.append(W,J);else if(Z!==void 0)$.set(W,typeof Z==="object"?JSON.stringify(Z):Z)}return $},cw=()=>({error:new T$,request:new T$,response:new T$}),u1,l1,G$=(w={})=>({...k$,headers:l1,parseAs:"auto",querySerializer:u1,...w});var c$=E(()=>{b$();C$();u1=bw({allowReserved:!1,array:{explode:!0,style:"form"},object:{explode:!0,style:"deepObject"}}),l1={"Content-Type":"application/json"}});var B$=(w={})=>{let $=v$(G$(),w),G=()=>({...$}),B=(O)=>{return $=v$($,O),G()},W=cw(),Z=async(O)=>{let X={...$,...O,fetch:O.fetch??$.fetch??globalThis.fetch,headers:M$($.headers,O.headers),serializedBody:void 0};if(X.security)await vw({...X,security:X.security});if(X.requestValidator)await X.requestValidator(X);if(X.body!==void 0&&X.bodySerializer)X.serializedBody=X.bodySerializer(X.body);if(X.body===void 0||X.serializedBody==="")X.headers.delete("Content-Type");let Q=g$(X);return{opts:X,url:Q}},J=async(O)=>{let{opts:X,url:Q}=await Z(O),K={redirect:"follow",...X,body:x$(X)},z=new Request(Q,K);for(let V of W.request.fns)if(V)z=await V(z,X);let x=X.fetch,L;try{L=await x(z)}catch(V){let R=V;for(let S of W.error.fns)if(S)R=await S(V,void 0,z,X);if(R=R||{},X.throwOnError)throw R;return X.responseStyle==="data"?void 0:{error:R,request:z,response:void 0}}for(let V of W.response.fns)if(V)L=await V(L,z,X);let _={request:z,response:L};if(L.ok){let V=(X.parseAs==="auto"?gw(L.headers.get("Content-Type")):X.parseAs)??"json";if(L.status===204||L.headers.get("Content-Length")==="0"){let S;switch(V){case"arrayBuffer":case"blob":case"text":S=await L[V]();break;case"formData":S=new FormData;break;case"stream":S=L.body;break;case"json":default:S={};break}return X.responseStyle==="data"?S:{data:S,..._}}let R;switch(V){case"arrayBuffer":case"blob":case"formData":case"text":R=await L[V]();break;case"json":{let S=await L.text();R=S?JSON.parse(S):{};break}case"stream":return X.responseStyle==="data"?L.body:{data:L.body,..._}}if(V==="json"){if(X.responseValidator)await X.responseValidator(R);if(X.responseTransformer)R=await X.responseTransformer(R)}return X.responseStyle==="data"?R:{data:R,..._}}let j=await L.text(),a;try{a=JSON.parse(j)}catch{}let k=a??j,h=k;for(let V of W.error.fns)if(V)h=await V(k,L,z,X);if(h=h||{},X.throwOnError)throw h;return X.responseStyle==="data"?void 0:{error:h,..._}},N=(O)=>(X)=>J({...X,method:O}),Y=(O)=>async(X)=>{let{opts:Q,url:K}=await Z(X);return xw({...Q,body:Q.body,headers:Q.headers,method:O,onRequest:async(z,x)=>{let L=new Request(z,x);for(let _ of W.request.fns)if(_)L=await _(L,Q);return L},serializedBody:x$(Q),url:K})};return{buildUrl:g$,connect:N("CONNECT"),delete:N("DELETE"),get:N("GET"),getConfig:G,head:N("HEAD"),interceptors:W,options:N("OPTIONS"),patch:N("PATCH"),post:N("POST"),put:N("PUT"),request:J,setConfig:B,sse:{connect:Y("CONNECT"),delete:Y("DELETE"),get:Y("GET"),head:Y("HEAD"),options:Y("OPTIONS"),patch:Y("PATCH"),post:Y("POST"),put:Y("PUT"),trace:Y("TRACE")},trace:N("TRACE")}};var d$=E(()=>{C$();c$()});var p1,n1,dw=(w,$)=>{if(!$)$=new Map;for(let G of w)if("in"in G){if(G.key)$.set(G.key,{in:G.in,map:G.map})}else if("key"in G)$.set(G.key,{map:G.map});else if(G.args)dw(G.args,$);return $},i1=(w)=>{for(let[$,G]of Object.entries(w))if(G&&typeof G==="object"&&!Object.keys(G).length)delete w[$]},U=(w,$)=>{let G={body:{},headers:{},path:{},query:{}},B=dw($),W;for(let[Z,J]of w.entries()){if($[Z])W=$[Z];if(!W)continue;if("in"in W)if(W.key){let N=B.get(W.key),Y=N.map||W.key;if(N.in)G[N.in][Y]=J}else G.body=J;else for(let[N,Y]of Object.entries(J??{})){let O=B.get(N);if(O)if(O.in){let X=O.map||N;G[O.in][X]=Y}else G[O.map]=Y;else{let X=n1.find(([Q])=>N.startsWith(Q));if(X){let[Q,K]=X;G[K][N.slice(Q.length)]=Y}else if("allowExtra"in W&&W.allowExtra){for(let[Q,K]of Object.entries(W.allowExtra))if(K){G[Q][N]=Y;break}}}}}return i1(G),G};var yw=E(()=>{p1={$body_:"body",$headers_:"headers",$path_:"path",$query_:"query"},n1=Object.entries(p1)});var y$=E(()=>{b$();yw();d$();c$()});var mw;var uw=E(()=>{y$();mw=B$(G$({baseUrl:"http://localhost:4096"}))});class D{client;constructor(w){this.client=w?.client??mw}}class lw{defaultKey="default";instances=new Map;get(w){let $=this.instances.get(w??this.defaultKey);if(!$)throw Error('No SDK client found. Create one with "new OpencodeClient()" to fix this error.');return $}set(w,$){this.instances.set($??this.defaultKey,w)}}var pw,nw,iw,rw,ow,sw,tw,aw,ew,$0,w0,G0,B0,W0,Z0,J0,N0,Y0,U0,X0,O0,Q0,L0,E0,D0,T0,M0,_0,f0,z0,_$;var R0=E(()=>{uw();y$();pw=class pw extends D{get(w){return(w?.client??this.client).get({url:"/global/config",...w})}update(w,$){let G=U([w],[{args:[{key:"config",map:"body"}]}]);return($?.client??this.client).patch({url:"/global/config",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}};nw=class nw extends D{health(w){return(w?.client??this.client).get({url:"/global/health",...w})}event(w){return(w?.client??this.client).sse.get({url:"/global/event",...w})}dispose(w){return(w?.client??this.client).post({url:"/global/dispose",...w})}_config;get config(){return this._config??=new pw({client:this.client})}};iw=class iw extends D{remove(w,$){let G=U([w],[{args:[{in:"path",key:"providerID"}]}]);return($?.client??this.client).delete({url:"/auth/{providerID}",...$,...G})}set(w,$){let G=U([w],[{args:[{in:"path",key:"providerID"},{key:"auth",map:"body"}]}]);return($?.client??this.client).put({url:"/auth/{providerID}",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}};rw=class rw extends D{list(w,$){let G=U([w],[{args:[{in:"query",key:"directory"}]}]);return($?.client??this.client).get({url:"/project",...$,...G})}current(w,$){let G=U([w],[{args:[{in:"query",key:"directory"}]}]);return($?.client??this.client).get({url:"/project/current",...$,...G})}update(w,$){let G=U([w],[{args:[{in:"path",key:"projectID"},{in:"query",key:"directory"},{in:"body",key:"name"},{in:"body",key:"icon"},{in:"body",key:"commands"}]}]);return($?.client??this.client).patch({url:"/project/{projectID}",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}};ow=class ow extends D{list(w,$){let G=U([w],[{args:[{in:"query",key:"directory"}]}]);return($?.client??this.client).get({url:"/pty",...$,...G})}create(w,$){let G=U([w],[{args:[{in:"query",key:"directory"},{in:"body",key:"command"},{in:"body",key:"args"},{in:"body",key:"cwd"},{in:"body",key:"title"},{in:"body",key:"env"}]}]);return($?.client??this.client).post({url:"/pty",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}remove(w,$){let G=U([w],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"directory"}]}]);return($?.client??this.client).delete({url:"/pty/{ptyID}",...$,...G})}get(w,$){let G=U([w],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"directory"}]}]);return($?.client??this.client).get({url:"/pty/{ptyID}",...$,...G})}update(w,$){let G=U([w],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"directory"},{in:"body",key:"title"},{in:"body",key:"size"}]}]);return($?.client??this.client).put({url:"/pty/{ptyID}",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}connect(w,$){let G=U([w],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"directory"}]}]);return($?.client??this.client).get({url:"/pty/{ptyID}/connect",...$,...G})}};sw=class sw extends D{get(w,$){let G=U([w],[{args:[{in:"query",key:"directory"}]}]);return($?.client??this.client).get({url:"/config",...$,...G})}update(w,$){let G=U([w],[{args:[{in:"query",key:"directory"},{key:"config",map:"body"}]}]);return($?.client??this.client).patch({url:"/config",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}providers(w,$){let G=U([w],[{args:[{in:"query",key:"directory"}]}]);return($?.client??this.client).get({url:"/config/providers",...$,...G})}};tw=class tw extends D{ids(w,$){let G=U([w],[{args:[{in:"query",key:"directory"}]}]);return($?.client??this.client).get({url:"/experimental/tool/ids",...$,...G})}list(w,$){let G=U([w],[{args:[{in:"query",key:"directory"},{in:"query",key:"provider"},{in:"query",key:"model"}]}]);return($?.client??this.client).get({url:"/experimental/tool",...$,...G})}};aw=class aw extends D{remove(w,$){let G=U([w],[{args:[{in:"query",key:"directory"},{key:"worktreeRemoveInput",map:"body"}]}]);return($?.client??this.client).delete({url:"/experimental/worktree",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}list(w,$){let G=U([w],[{args:[{in:"query",key:"directory"}]}]);return($?.client??this.client).get({url:"/experimental/worktree",...$,...G})}create(w,$){let G=U([w],[{args:[{in:"query",key:"directory"},{key:"worktreeCreateInput",map:"body"}]}]);return($?.client??this.client).post({url:"/experimental/worktree",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}reset(w,$){let G=U([w],[{args:[{in:"query",key:"directory"},{key:"worktreeResetInput",map:"body"}]}]);return($?.client??this.client).post({url:"/experimental/worktree/reset",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}};ew=class ew extends D{list(w,$){let G=U([w],[{args:[{in:"query",key:"directory"}]}]);return($?.client??this.client).get({url:"/experimental/resource",...$,...G})}};$0=class $0 extends D{_resource;get resource(){return this._resource??=new ew({client:this.client})}};w0=class w0 extends D{list(w,$){let G=U([w],[{args:[{in:"query",key:"directory"},{in:"query",key:"roots"},{in:"query",key:"start"},{in:"query",key:"search"},{in:"query",key:"limit"}]}]);return($?.client??this.client).get({url:"/session",...$,...G})}create(w,$){let G=U([w],[{args:[{in:"query",key:"directory"},{in:"body",key:"parentID"},{in:"body",key:"title"},{in:"body",key:"permission"}]}]);return($?.client??this.client).post({url:"/session",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}status(w,$){let G=U([w],[{args:[{in:"query",key:"directory"}]}]);return($?.client??this.client).get({url:"/session/status",...$,...G})}delete(w,$){let G=U([w],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"}]}]);return($?.client??this.client).delete({url:"/session/{sessionID}",...$,...G})}get(w,$){let G=U([w],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"}]}]);return($?.client??this.client).get({url:"/session/{sessionID}",...$,...G})}update(w,$){let G=U([w],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"body",key:"title"},{in:"body",key:"time"}]}]);return($?.client??this.client).patch({url:"/session/{sessionID}",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}children(w,$){let G=U([w],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"}]}]);return($?.client??this.client).get({url:"/session/{sessionID}/children",...$,...G})}todo(w,$){let G=U([w],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"}]}]);return($?.client??this.client).get({url:"/session/{sessionID}/todo",...$,...G})}init(w,$){let G=U([w],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"body",key:"modelID"},{in:"body",key:"providerID"},{in:"body",key:"messageID"}]}]);return($?.client??this.client).post({url:"/session/{sessionID}/init",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}fork(w,$){let G=U([w],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"body",key:"messageID"}]}]);return($?.client??this.client).post({url:"/session/{sessionID}/fork",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}abort(w,$){let G=U([w],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"}]}]);return($?.client??this.client).post({url:"/session/{sessionID}/abort",...$,...G})}unshare(w,$){let G=U([w],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"}]}]);return($?.client??this.client).delete({url:"/session/{sessionID}/share",...$,...G})}share(w,$){let G=U([w],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"}]}]);return($?.client??this.client).post({url:"/session/{sessionID}/share",...$,...G})}diff(w,$){let G=U([w],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"messageID"}]}]);return($?.client??this.client).get({url:"/session/{sessionID}/diff",...$,...G})}summarize(w,$){let G=U([w],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"body",key:"providerID"},{in:"body",key:"modelID"},{in:"body",key:"auto"}]}]);return($?.client??this.client).post({url:"/session/{sessionID}/summarize",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}messages(w,$){let G=U([w],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"limit"}]}]);return($?.client??this.client).get({url:"/session/{sessionID}/message",...$,...G})}prompt(w,$){let G=U([w],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"body",key:"messageID"},{in:"body",key:"model"},{in:"body",key:"agent"},{in:"body",key:"noReply"},{in:"body",key:"tools"},{in:"body",key:"system"},{in:"body",key:"variant"},{in:"body",key:"parts"}]}]);return($?.client??this.client).post({url:"/session/{sessionID}/message",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}message(w,$){let G=U([w],[{args:[{in:"path",key:"sessionID"},{in:"path",key:"messageID"},{in:"query",key:"directory"}]}]);return($?.client??this.client).get({url:"/session/{sessionID}/message/{messageID}",...$,...G})}promptAsync(w,$){let G=U([w],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"body",key:"messageID"},{in:"body",key:"model"},{in:"body",key:"agent"},{in:"body",key:"noReply"},{in:"body",key:"tools"},{in:"body",key:"system"},{in:"body",key:"variant"},{in:"body",key:"parts"}]}]);return($?.client??this.client).post({url:"/session/{sessionID}/prompt_async",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}command(w,$){let G=U([w],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"body",key:"messageID"},{in:"body",key:"agent"},{in:"body",key:"model"},{in:"body",key:"arguments"},{in:"body",key:"command"},{in:"body",key:"variant"},{in:"body",key:"parts"}]}]);return($?.client??this.client).post({url:"/session/{sessionID}/command",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}shell(w,$){let G=U([w],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"body",key:"agent"},{in:"body",key:"model"},{in:"body",key:"command"}]}]);return($?.client??this.client).post({url:"/session/{sessionID}/shell",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}revert(w,$){let G=U([w],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"body",key:"messageID"},{in:"body",key:"partID"}]}]);return($?.client??this.client).post({url:"/session/{sessionID}/revert",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}unrevert(w,$){let G=U([w],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"}]}]);return($?.client??this.client).post({url:"/session/{sessionID}/unrevert",...$,...G})}};G0=class G0 extends D{delete(w,$){let G=U([w],[{args:[{in:"path",key:"sessionID"},{in:"path",key:"messageID"},{in:"path",key:"partID"},{in:"query",key:"directory"}]}]);return($?.client??this.client).delete({url:"/session/{sessionID}/message/{messageID}/part/{partID}",...$,...G})}update(w,$){let G=U([w],[{args:[{in:"path",key:"sessionID"},{in:"path",key:"messageID"},{in:"path",key:"partID"},{in:"query",key:"directory"},{key:"part",map:"body"}]}]);return($?.client??this.client).patch({url:"/session/{sessionID}/message/{messageID}/part/{partID}",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}};B0=class B0 extends D{respond(w,$){let G=U([w],[{args:[{in:"path",key:"sessionID"},{in:"path",key:"permissionID"},{in:"query",key:"directory"},{in:"body",key:"response"}]}]);return($?.client??this.client).post({url:"/session/{sessionID}/permissions/{permissionID}",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}reply(w,$){let G=U([w],[{args:[{in:"path",key:"requestID"},{in:"query",key:"directory"},{in:"body",key:"reply"},{in:"body",key:"message"}]}]);return($?.client??this.client).post({url:"/permission/{requestID}/reply",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}list(w,$){let G=U([w],[{args:[{in:"query",key:"directory"}]}]);return($?.client??this.client).get({url:"/permission",...$,...G})}};W0=class W0 extends D{list(w,$){let G=U([w],[{args:[{in:"query",key:"directory"}]}]);return($?.client??this.client).get({url:"/question",...$,...G})}reply(w,$){let G=U([w],[{args:[{in:"path",key:"requestID"},{in:"query",key:"directory"},{in:"body",key:"answers"}]}]);return($?.client??this.client).post({url:"/question/{requestID}/reply",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}reject(w,$){let G=U([w],[{args:[{in:"path",key:"requestID"},{in:"query",key:"directory"}]}]);return($?.client??this.client).post({url:"/question/{requestID}/reject",...$,...G})}};Z0=class Z0 extends D{authorize(w,$){let G=U([w],[{args:[{in:"path",key:"providerID"},{in:"query",key:"directory"},{in:"body",key:"method"}]}]);return($?.client??this.client).post({url:"/provider/{providerID}/oauth/authorize",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}callback(w,$){let G=U([w],[{args:[{in:"path",key:"providerID"},{in:"query",key:"directory"},{in:"body",key:"method"},{in:"body",key:"code"}]}]);return($?.client??this.client).post({url:"/provider/{providerID}/oauth/callback",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}};J0=class J0 extends D{list(w,$){let G=U([w],[{args:[{in:"query",key:"directory"}]}]);return($?.client??this.client).get({url:"/provider",...$,...G})}auth(w,$){let G=U([w],[{args:[{in:"query",key:"directory"}]}]);return($?.client??this.client).get({url:"/provider/auth",...$,...G})}_oauth;get oauth(){return this._oauth??=new Z0({client:this.client})}};N0=class N0 extends D{text(w,$){let G=U([w],[{args:[{in:"query",key:"directory"},{in:"query",key:"pattern"}]}]);return($?.client??this.client).get({url:"/find",...$,...G})}files(w,$){let G=U([w],[{args:[{in:"query",key:"directory"},{in:"query",key:"query"},{in:"query",key:"dirs"},{in:"query",key:"type"},{in:"query",key:"limit"}]}]);return($?.client??this.client).get({url:"/find/file",...$,...G})}symbols(w,$){let G=U([w],[{args:[{in:"query",key:"directory"},{in:"query",key:"query"}]}]);return($?.client??this.client).get({url:"/find/symbol",...$,...G})}};Y0=class Y0 extends D{list(w,$){let G=U([w],[{args:[{in:"query",key:"directory"},{in:"query",key:"path"}]}]);return($?.client??this.client).get({url:"/file",...$,...G})}read(w,$){let G=U([w],[{args:[{in:"query",key:"directory"},{in:"query",key:"path"}]}]);return($?.client??this.client).get({url:"/file/content",...$,...G})}status(w,$){let G=U([w],[{args:[{in:"query",key:"directory"}]}]);return($?.client??this.client).get({url:"/file/status",...$,...G})}};U0=class U0 extends D{remove(w,$){let G=U([w],[{args:[{in:"path",key:"name"},{in:"query",key:"directory"}]}]);return($?.client??this.client).delete({url:"/mcp/{name}/auth",...$,...G})}start(w,$){let G=U([w],[{args:[{in:"path",key:"name"},{in:"query",key:"directory"}]}]);return($?.client??this.client).post({url:"/mcp/{name}/auth",...$,...G})}callback(w,$){let G=U([w],[{args:[{in:"path",key:"name"},{in:"query",key:"directory"},{in:"body",key:"code"}]}]);return($?.client??this.client).post({url:"/mcp/{name}/auth/callback",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}authenticate(w,$){let G=U([w],[{args:[{in:"path",key:"name"},{in:"query",key:"directory"}]}]);return($?.client??this.client).post({url:"/mcp/{name}/auth/authenticate",...$,...G})}};X0=class X0 extends D{status(w,$){let G=U([w],[{args:[{in:"query",key:"directory"}]}]);return($?.client??this.client).get({url:"/mcp",...$,...G})}add(w,$){let G=U([w],[{args:[{in:"query",key:"directory"},{in:"body",key:"name"},{in:"body",key:"config"}]}]);return($?.client??this.client).post({url:"/mcp",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}connect(w,$){let G=U([w],[{args:[{in:"path",key:"name"},{in:"query",key:"directory"}]}]);return($?.client??this.client).post({url:"/mcp/{name}/connect",...$,...G})}disconnect(w,$){let G=U([w],[{args:[{in:"path",key:"name"},{in:"query",key:"directory"}]}]);return($?.client??this.client).post({url:"/mcp/{name}/disconnect",...$,...G})}_auth;get auth(){return this._auth??=new U0({client:this.client})}};O0=class O0 extends D{next(w,$){let G=U([w],[{args:[{in:"query",key:"directory"}]}]);return($?.client??this.client).get({url:"/tui/control/next",...$,...G})}response(w,$){let G=U([w],[{args:[{in:"query",key:"directory"},{key:"body",map:"body"}]}]);return($?.client??this.client).post({url:"/tui/control/response",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}};Q0=class Q0 extends D{appendPrompt(w,$){let G=U([w],[{args:[{in:"query",key:"directory"},{in:"body",key:"text"}]}]);return($?.client??this.client).post({url:"/tui/append-prompt",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}openHelp(w,$){let G=U([w],[{args:[{in:"query",key:"directory"}]}]);return($?.client??this.client).post({url:"/tui/open-help",...$,...G})}openSessions(w,$){let G=U([w],[{args:[{in:"query",key:"directory"}]}]);return($?.client??this.client).post({url:"/tui/open-sessions",...$,...G})}openThemes(w,$){let G=U([w],[{args:[{in:"query",key:"directory"}]}]);return($?.client??this.client).post({url:"/tui/open-themes",...$,...G})}openModels(w,$){let G=U([w],[{args:[{in:"query",key:"directory"}]}]);return($?.client??this.client).post({url:"/tui/open-models",...$,...G})}submitPrompt(w,$){let G=U([w],[{args:[{in:"query",key:"directory"}]}]);return($?.client??this.client).post({url:"/tui/submit-prompt",...$,...G})}clearPrompt(w,$){let G=U([w],[{args:[{in:"query",key:"directory"}]}]);return($?.client??this.client).post({url:"/tui/clear-prompt",...$,...G})}executeCommand(w,$){let G=U([w],[{args:[{in:"query",key:"directory"},{in:"body",key:"command"}]}]);return($?.client??this.client).post({url:"/tui/execute-command",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}showToast(w,$){let G=U([w],[{args:[{in:"query",key:"directory"},{in:"body",key:"title"},{in:"body",key:"message"},{in:"body",key:"variant"},{in:"body",key:"duration"}]}]);return($?.client??this.client).post({url:"/tui/show-toast",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}publish(w,$){let G=U([w],[{args:[{in:"query",key:"directory"},{key:"body",map:"body"}]}]);return($?.client??this.client).post({url:"/tui/publish",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}selectSession(w,$){let G=U([w],[{args:[{in:"query",key:"directory"},{in:"body",key:"sessionID"}]}]);return($?.client??this.client).post({url:"/tui/select-session",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}_control;get control(){return this._control??=new O0({client:this.client})}};L0=class L0 extends D{dispose(w,$){let G=U([w],[{args:[{in:"query",key:"directory"}]}]);return($?.client??this.client).post({url:"/instance/dispose",...$,...G})}};E0=class E0 extends D{get(w,$){let G=U([w],[{args:[{in:"query",key:"directory"}]}]);return($?.client??this.client).get({url:"/path",...$,...G})}};D0=class D0 extends D{get(w,$){let G=U([w],[{args:[{in:"query",key:"directory"}]}]);return($?.client??this.client).get({url:"/vcs",...$,...G})}};T0=class T0 extends D{list(w,$){let G=U([w],[{args:[{in:"query",key:"directory"}]}]);return($?.client??this.client).get({url:"/command",...$,...G})}};M0=class M0 extends D{log(w,$){let G=U([w],[{args:[{in:"query",key:"directory"},{in:"body",key:"service"},{in:"body",key:"level"},{in:"body",key:"message"},{in:"body",key:"extra"}]}]);return($?.client??this.client).post({url:"/log",...$,...G,headers:{"Content-Type":"application/json",...$?.headers,...G.headers}})}agents(w,$){let G=U([w],[{args:[{in:"query",key:"directory"}]}]);return($?.client??this.client).get({url:"/agent",...$,...G})}skills(w,$){let G=U([w],[{args:[{in:"query",key:"directory"}]}]);return($?.client??this.client).get({url:"/skill",...$,...G})}};_0=class _0 extends D{status(w,$){let G=U([w],[{args:[{in:"query",key:"directory"}]}]);return($?.client??this.client).get({url:"/lsp",...$,...G})}};f0=class f0 extends D{status(w,$){let G=U([w],[{args:[{in:"query",key:"directory"}]}]);return($?.client??this.client).get({url:"/formatter",...$,...G})}};z0=class z0 extends D{subscribe(w,$){let G=U([w],[{args:[{in:"query",key:"directory"}]}]);return($?.client??this.client).sse.get({url:"/event",...$,...G})}};_$=class _$ extends D{static __registry=new lw;constructor(w){super(w);_$.__registry.set(this,w?.key)}_global;get global(){return this._global??=new nw({client:this.client})}_auth;get auth(){return this._auth??=new iw({client:this.client})}_project;get project(){return this._project??=new rw({client:this.client})}_pty;get pty(){return this._pty??=new ow({client:this.client})}_config;get config(){return this._config??=new sw({client:this.client})}_tool;get tool(){return this._tool??=new tw({client:this.client})}_worktree;get worktree(){return this._worktree??=new aw({client:this.client})}_experimental;get experimental(){return this._experimental??=new $0({client:this.client})}_session;get session(){return this._session??=new w0({client:this.client})}_part;get part(){return this._part??=new G0({client:this.client})}_permission;get permission(){return this._permission??=new B0({client:this.client})}_question;get question(){return this._question??=new W0({client:this.client})}_provider;get provider(){return this._provider??=new J0({client:this.client})}_find;get find(){return this._find??=new N0({client:this.client})}_file;get file(){return this._file??=new Y0({client:this.client})}_mcp;get mcp(){return this._mcp??=new X0({client:this.client})}_tui;get tui(){return this._tui??=new Q0({client:this.client})}_instance;get instance(){return this._instance??=new L0({client:this.client})}_path;get path(){return this._path??=new E0({client:this.client})}_vcs;get vcs(){return this._vcs??=new D0({client:this.client})}_command;get command(){return this._command??=new T0({client:this.client})}_app;get app(){return this._app??=new M0({client:this.client})}_lsp;get lsp(){return this._lsp??=new _0({client:this.client})}_formatter;get formatter(){return this._formatter??=new f0({client:this.client})}_event;get event(){return this._event??=new z0({client:this.client})}}});function m$(w){if(!w?.fetch)w={...w,fetch:(B)=>{return B.timeout=!1,fetch(B)}};if(w?.directory){let B=/[^\x00-\x7F]/.test(w.directory)?encodeURIComponent(w.directory):w.directory;w.headers={...w.headers,"x-opencode-directory":B}}let $=B$(w);return new _$({client:$})}var V0=E(()=>{d$();R0();Pw()});async function S0(w){if(w.loopUpForDesktopServer){let $=await r1();if($){let G=m$(h$(w,$??{}));if((await G.global.health()).data?.healthy)return G;else console.warn("Desktop server is not healthy, re-launch Opencode app")}else console.warn("Desktop server is not registered, launch Opencode app")}return m$(w)}async function r1(){if(!await K0.exists())return;let $=await K0.json();return o1($)}function o1(w){return{baseUrl:`http://${w.hostname}:${w.port}`,headers:{Authorization:`Basic ${btoa(`${w.username}:${w.password}`)}`}}}var K0,R5;var q0=E(()=>{V0();H();K0=Bun.file(`${Bun.env.HOME}/Library/Application Support/ai.opencode.desktop/store.json`),R5={client:Bun.env.OPENCODE_CLIENT??"unknown",password:Bun.env.OPENCODE_SERVER_PASSWORD,username:Bun.env.OPENCODE_SERVER_USERNAME}});async function H0(w,$){let{data:G}=await w.project.current({directory:$??process.cwd()});if(G&&G.id!=="global")return G.worktree;let{data:B,error:W}=await w.project.list();return f(W===void 0,`Failed to list projects: ${W}`),f(B,"No projects found"),f(B.length>0,`No projects found: ${B.length}`),U$.select("Select a project",{options:B.map((Z)=>({label:Z.name??Z.worktree,value:Z.worktree,hint:Z.name?`${Z.worktree} - ${Z.id.slice(0,5)}`:Z.id.slice(0,5)}))})}function F0(w){return w.name??w.worktree}var u$=E(()=>{X$();H()});var W$,l$;var p$=E(()=>{W$=class W$ extends Error{output;constructor(w,$){let G=w.stdout.toString().trim()||void 0,W=(w.stderr.toString().trim()||void 0)??G??"Unknown shell error";super(W,{cause:$.cause});this.output=w}};l$=class l$ extends Error{exitCode;constructor(w){let $=w.exitCode;super(`Exited with code '${$}'`);this.exitCode=$}}});var F={};g(F,{use:()=>s1,create:()=>A0});function s1(w){if(w instanceof Bun.$.Shell)return A0(w);if(j0 in w)return w;throw Error("Invalid client input")}function A0(w){let $=w,B=Object.assign((W,...Z)=>{let J=0,N=[...W],Y=Z.flatMap((Q,K)=>{if(!w$(Q))return[Q];let z=y(qw(Q),(L,_)=>{if(Fw(_))return`--${L}`;if(v(_))return`--${L}=${O$(_).join(",")}`;return`--${L}='${String(_)}'`});if(P(z))return[""];let x=z.length-1;return N.splice(K+1+J,0,...Array(x).fill(" ")),J+=x,z}),O=Object.assign(N,{raw:[...N]}),X=$(O,...Y);return t1(X)},{[j0]:!0,cwd(W){return $=$.cwd(W),B},env(W){return $=$.env(W),B}});return B}function t1(w){return{json:async($)=>{let G=await w.quiet($?.quiet).nothrow(),[B,W]=await Kw(()=>G.json())();if(W)return W;throw new W$(G,{cause:B})},text:async($)=>{let G=await w.quiet($?.quiet).nothrow(),B=G.stdout.toString().trim()||void 0;if(G.exitCode!==0)return[new W$(G,{cause:new l$(G)}),B];return[void 0,B]}}}var j0;var h0=E(()=>{H();p$();j0=Symbol("shell_client")});var f$=E(()=>{h0();p$()});var A={};g(A,{use:()=>a1,update:()=>p,show:()=>wG,list:()=>i$,find:()=>z$,create:()=>r$,close:()=>$G,claim:()=>e1});async function a1(w,$,G){if("status"in $&&!G?.force)return $;return A$(await i$(w,{...G,ids:[$.id]}))}async function p(w,$,G={}){let W=await F.use(w)`bd update ${$.id} ${G} --json`.json(),[Z]=W;return f(Z,`Issue '${$.id}' not found`),Z}async function r$(w,$){return await F.use(w)`bd create ${$} --json`.json()}async function e1(w,$,G={}){let W=await F.use(w)`bd update ${$.id} ${G} --claim --json`.json(),[Z]=W;return f(Z,`Issue '${$.id}' not found`),Z}async function $G(w,$,G={}){let W=await F.use(w)`bd close ${$.id} ${G} --json`.json(),[Z]=W;return f(Z,`Issue '${$.id}' not found`),Z}async function wG(w,$){return F.use(w)`bd show ${$.id}`.text()}var i$,z$;var R$=E(()=>{H();f$();i$=Object.assign(async(w,$={})=>{if(P($.ids))return[];return await F.use(w)`bd list ${$} --json`.json()},{ready:async(w,$={})=>{return await F.use(w)`bd ready ${$} --json`.json()}});((j5)=>{async function w($,G,B){return(await i$($,B)).find((Z)=>Z.external_ref===G)}j5.byExternalRef=w})(z$||={})});var n={};g(n,{use:()=>WG,stuck:()=>GG,state:()=>o$,done:()=>BG});async function GG(w,$,G){let B=await o$(w,$,"stuck");return await p(w,{id:B.agent},{"add-label":P0(G.context),description:G.reason}),B}async function BG(w,$,G={}){let B=await o$(w,$,"done");return await p(w,{id:B.agent},{"add-label":P0(G.context),description:""}),B}async function o$(w,$,G){return await F.use(w)`bd agent state gram-${$} ${G} --json`.json()}async function WG(w,$){let G=F.use(w),B="slug"in $?`gram-${$.slug}`:$.id;return await G`bd agent show ${B} --json`.json()}function P0(w){if(!w)return;let $=O$(y(w,(G,B)=>B&&`${G}:${B}`));return P($)?void 0:$}var x0=E(()=>{H();f$();R$()});var k0=E(()=>{f$()});var V$=E(()=>{x0();R$();k0()});var i={};g(i,{update:()=>NG,find:()=>g0,create:()=>JG,SpecificationInput:()=>ZG,Specification:()=>b0});import{z as C}from"zod";async function JG(w,$){let G=await r$(w,{type:"epic",title:$.title,description:$.description,"external-ref":$.file});return t$(G)}async function NG(w,$,G){let B=await p(w,{id:$.issueId},{type:"epic",title:G.title,description:G.description,"external-ref":G.file});return t$(B)}function t$(w){return b0.parse({issueId:w.id,file:w.external_ref,title:w.title,description:w.description})}var b0,ZG,g0;var v0=E(()=>{R$();b0=C.object({issueId:C.string(),file:C.string(),title:C.string(),description:C.string().optional()}),ZG=C.object({file:C.string(),title:C.string(),description:C.string().optional()});((x5)=>{async function w($,G){let B=await z$.byExternalRef($,G,{type:"epic"});return B&&t$(B)}x5.byFile=w})(g0||={})});var r={};g(r,{watch:()=>y0,use:()=>XG,scan:()=>m0,Frontmatter:()=>UG});import*as d0 from"fs";import*as K$ from"path";import{z as c0}from"zod";function XG(w){if(w.watch)return y0(w);else return m0(w)}async function*y0(w){let $=u0(w.targets),G=new Map,B=[],W,Z=d0.watch(w.cwd,async(J,N)=>{if(J==="change"&&N){if(!$.match(N))return;let Y=a$(w.cwd,N),O=Bun.hash(await Y.file.text());if(G.get(N)===O)return;if(G.set(N,O),B.push(a$(w.cwd,N)),W)W.resolve(N),W=void 0}});try{while(!0){let J=B.shift();if(J)yield J;else W=j$(),await W.promise}}finally{Z.close()}}async function*m0(w){let{targets:$,isIgnored:G}=u0(w.targets);for(let B of $)for await(let W of B.scan({cwd:w.cwd})){if(G(W))continue;yield a$(w.cwd,W)}}function u0(w){let $=[],G=[];for(let W of zw(w))if(W.startsWith("!"))G.push(new Bun.Glob(W));else $.push(new Bun.Glob(W));f(!P($),"At least one target is required");function B(W){return!YG.match(W)||G.every((Z)=>!Z.match(W))}return{targets:$,isIgnored:B,match:(W)=>!B(W)&&$.some((Z)=>Z.match(W))}}function a$(w,$){let G=K$.join(w,$);return{filename:$,filepath:K$.parse(G),file:Bun.file(G)}}var YG,UG;var l0=E(()=>{H();YG=new Bun.Glob("**/*.md"),UG=c0.object({issue:c0.string().optional()})});var e$=E(()=>{v0();l0()});function n0(w,$){let G=$?.delimiter??"---";if(!w.trimStart().startsWith(G))return{metadata:{},content:w};let B=w.split(`
|
|
14
|
+
`),W=-1,Z=-1;for(let X=0;X<B.length;X++)if(B[X]?.trim()===G){W=X;break}if(W===-1)return{metadata:{},content:w};for(let X=W+1;X<B.length;X++)if(B[X]?.trim()===G){Z=X;break}if(Z===-1)return{metadata:{},content:w};let N=B.slice(W+1,Z).join(`
|
|
15
|
+
`),Y=QG(N),O=B.slice(Z+1).join(`
|
|
16
|
+
`).replace(/^\n+/,"");return{metadata:Y,content:O}}function OG(w,$){let G=$?.delimiter??"---",B=$w(w);return`${G}
|
|
17
|
+
${B}${G}
|
|
18
|
+
`}function i0(w,$,G){return`${OG($,G)}
|
|
19
|
+
${w}`}function QG(w){let $={},G=w.split(`
|
|
20
|
+
`),B=[{obj:$,indent:-1}];for(let W of G){if(!W.trim()||W.trim().startsWith("#"))continue;let Z=W.length-(W.trimStart()?.length??0),J=W.trim();while(B.length>1){let Q=B[B.length-1];if(!Q||Z>Q.indent)break;B.pop()}let N=J.indexOf(":");if(N===-1)continue;let Y=J.substring(0,N).trim(),O=J.substring(N+1).trim(),X=B[B.length-1]?.obj;if(!X)continue;if(O===""){let Q={};X[Y]=Q,B.push({obj:Q,indent:Z})}else if(X)X[Y]=LG(O)}return $}function LG(w){if(w.startsWith('"')&&w.endsWith('"')||w.startsWith("'")&&w.endsWith("'"))return w.slice(1,-1);if(w==="true")return!0;if(w==="false")return!1;if(w==="null"||w==="~")return null;let $=Number(w);if(!Number.isNaN($)&&w!=="")return $;return w}function $w(w,$=0){let G=" ".repeat($),B="";for(let[W,Z]of Object.entries(w))if(Iw(Z))B+=`${G}${W}: null
|
|
21
|
+
`;else if(w$(Z)&&!v(Z))B+=`${G}${W}:
|
|
22
|
+
`,B+=$w(Z,$+1);else if(Aw(Z)){let J=Z.includes(":")||Z.includes("#")||Z.includes(`
|
|
23
|
+
`);B+=`${G}${W}: ${J?`"${Z}"`:Z}
|
|
24
|
+
`}else if(v(Z)){B+=`${G}${W}:
|
|
25
|
+
`;for(let J of Z)if(w$(J)&&!v(J))B+=`${G}-
|
|
26
|
+
${$w(J,$+2)}`;else B+=`${G} - ${J}
|
|
27
|
+
`}else B+=`${G}${W}: ${Z}
|
|
28
|
+
`;return B}var r0=E(()=>{H()});import*as S$ from"path";async function*o0(w){let $=Bun.$.cwd(w.project);for await(let G of w.source){let{file:B,filepath:W}=G,{metadata:Z,content:J}=n0(await B.text()),N=S$.relative(w.project,S$.format(W)),Y={file:N,title:Hw(W.name),description:m`
|
|
29
|
+
Spec: ${N}
|
|
30
|
+
`},O=r.Frontmatter.safeParse(Z),X=O.success&&O.data.issue?{issueId:O.data.issue}:await i.find.byFile($,Y.file),Q=X?await i.update($,X,Y):await i.create($,Y),K=Object.assign({},Z,{issue:Q.issueId});await Bun.write(B,i0(J,K)),yield{asset:G,spec:Q}}}var s0=E(()=>{H();e$();r0()});import*as ww from"fs/promises";async function t0(w){let{client:$,directory:G}=w,B=await DG.acquire();try{let W=await $.project.current({directory:G});f(W.data,`Failed to initialize environment: ${W.error}`);let Z=F0(W.data);if(!W.data.commands?.start){let N=await U$.confirm(`Opencode project ${Z} does not have a start command. Do you want to continue?`,{default:!1});f(N,"Failed to initialize environment: user asked to stop")}let J=await $.worktree.create({directory:G,worktreeCreateInput:{name:w.name}});return f(J.data,`Failed to initialize worktree: ${JSON.stringify(J.error)}`),J.data}finally{B.release()}}async function a0(w){let{client:$,directory:G}=w,B=await $.worktree.remove({directory:G,worktreeRemoveInput:{directory:w.worktreeDirectory}});return f(B.data,`Failed to remove worktree: ${JSON.stringify(B.error)}`),console.log("Worktree removed"),B.data}async function e0(w){return(await Promise.all([ww.exists(`${w.directory}/.opencode`),ww.exists(`${w.directory}/.git`)])).every((G)=>G)}var DG;var $1=E(()=>{X$();H();u$();DG=new Q$(1)});var{$:MG}=globalThis.Bun;var q$;var w1=E(()=>{L$();$1();q$=class q${client;directory;worktree;ready;constructor(w,$,G){this.client=w;this.directory=$;this.worktree=G;this.ready=u(()=>e0(G),{interval:"100ms"})}get $(){return MG.cwd(this.worktree.directory)}static async init(w){let $=await t0(w),G=new q$(w.client,w.directory,$);return await G.ready,G}async[Symbol.asyncDispose](){await a0({client:this.client,directory:this.directory,worktreeDirectory:this.worktree.directory}).catch((w)=>console.error(w))}}});async function G1(w){let Y=[];try{let $=zG(w.issue.id);$(`Start working on ${w.issue.id}...`);const G=Ow(Y,await q$.init({client:w.client,directory:w.directory,name:w.issue.id}),1);$(`Environment ready: ${G.worktree.directory}`);let B=await A.claim(G.$,w.issue);$(`Issue claimed: ${B.id}`);let W=await w.client.session.create({directory:G.worktree.directory,title:`${B.id}: ${B.title}`});f(W.data,`Failed to start the session: ${JSON.stringify(W.error)}`);$(`Session: ${W.data.id}`);let Z=await w.client.session.command({sessionID:W.data.id,directory:G.worktree.directory,command:"fake_work",arguments:`${B.id}`});f(Z.data,`Failed to send the /work command: ${JSON.stringify(Z.error)}`);let J=await n.use(G.$,W.data);while(J.agent_state!=="done"){if(J.agent_state==="stuck")$(`Agent is stuck: ${J.title}`),await u(async()=>{return J=await n.use(G.$,W.data),J.agent_state!=="stuck"},{interval:"1s"}),$(`Agent is ready to continue: ${J.agent_state}`);else{$(`Agent needs follow up, '${J.agent_state}'...`);let z=await w.client.session.prompt({sessionID:W.data.id,directory:G.worktree.directory,parts:[fG(J.agent_state)]});f(z.data,`Failed to follow up: ${JSON.stringify(z.error)}`)}J=await n.use(G.$,W.data)}$("Agent work is done");let N=await w.client.session.messages({sessionID:W.data.id,directory:G.worktree.directory});f(N.data,`Failed to fetch session messages: ${N.error}`);$(`Session messages: ${N.data.length}`);B=await A.close(G.$,w.issue,{reason:"Completed"});f(B,"Failed to close the issue");return B}catch(O){var X=O,Q=1}finally{var K=Qw(Y,X,Q);K&&await K}}function fG(w){return{type:"text",text:m`
|
|
31
31
|
You are currently registered as '${w}'.
|
|
32
32
|
- If you are done with the task please notify via the i_am_done tool.
|
|
33
33
|
- If you are stuck and need human help, please notify via the i_am_stuck tool.
|
|
34
34
|
- If you need more time to work on the task, please continue working and update your status when needed.
|
|
35
|
-
`}}function
|
|
36
|
-
`)}}})});import{createCLI as
|
|
35
|
+
`}}function zG(w){return($)=>{console.log(`[work:${w}] ${$}`)}}var B1=E(()=>{H();V$();w1();L$()});var W1=()=>{};var Z1=E(()=>{H();V$();W1()});var Gw=E(()=>{s0();B1();Z1()});import{loadConfig as VG}from"c12";async function H$(w){let{config:$,_configFile:G}=await VG({name:"teammate",cwd:w.cwd,configFile:w.configFile,overrides:w.overries,packageJson:!1});return console.debug(`Config loaded from: ${G}`),$}var Bw=()=>{};var Y1={};g(Y1,{default:()=>SG});import{defineCommand as KG,option as o}from"@bunli/core";import{z as s}from"zod";var SG,qG;var U1=E(()=>{X$();H();L$();q0();u$();V$();Gw();Bw();SG=KG({name:"work",alias:["ralph"],description:"Starts RALPH loop on opened tasks",options:{concurrency:o(s.coerce.number().min(1).default(1),{description:"How many workers can be spawned at the same time",short:"c"}),task:o(s.string().optional(),{description:"Task (including subtasks) to work on. When not provided, workers can be spawned for any ready tasks.",short:"t"}),"wait-on-idle":o(s.boolean().default(!1),{description:"If no task is available, wait for one to become available."}),"max-dispatches":o(s.coerce.number().min(1).default(1/0),{description:"Limit the number of tasks that can be dispatched to workers.",short:"n"}),project:o(s.string().optional(),{description:"Project to work on. When not provided, workers can be spawned for any ready tasks.",short:"p"}),config:o(s.string().optional(),{description:"Teammate config file to use",short:"c"})},handler:async({cwd:w,flags:$,colors:G})=>{let{project:B=w}=await H$({configFile:$.config,overries:{project:$.project}}),W=await S0({loopUpForDesktopServer:!0}),Z=await H0(W,B),J=Bun.$.cwd(Z),N=new Set,{"wait-on-idle":Y,"max-dispatches":O}=$,X=P$(()=>A.list.ready(J,{parent:$.task}),{interval:"1 second",exitOnEmpty:!Y}),Q=new Q$($.concurrency);for await(let L of X){let _=await Q.acquire();if(N.add(L.id),G1({client:W,directory:Z,issue:L}).catch((j)=>console.error(j)).finally(()=>_.release()),N.size>=O)break}await u(async()=>Q.queueLength===0&&Q.maxCapacity===Q.capacity,{interval:"1 second"});let K=await A.list(J,{all:!0,ids:Array.from(N.values())}),z=Rw(K,(L)=>L.status),x=y(z,(L,_)=>{return(qG[L]??G.reset)(`${_} ${L}`)});console.log(G.gray(`Dispatched: ${G.italic(Array.from(N.values()).join(", "))}`)),console.log(`Tasks: ${x.join(", ")}`)}}),qG={open:$$(q.yellow,q.italic),in_progress:$$(q.yellow,q.italic),blocked:$$(q.red,q.bold,q.underline),deferred:q.red,closed:$$(q.green,q.bold)}});var X1={};g(X1,{default:()=>FG});import{defineCommand as HG,option as Ww}from"@bunli/core";import{z as Zw}from"zod";import*as t from"path";var FG;var O1=E(()=>{Bw();Gw();e$();FG=HG({name:"sync",description:"Syncs the specifications with beads epics",options:{target:Ww(Zw.string().transform((w)=>t.resolve(w)).optional(),{description:"Specification file or directory to sync"}),watch:Ww(Zw.boolean().default(!1),{description:"Watch target for changes",short:"w"}),config:Ww(Zw.string().optional(),{description:"Teammate config file to use",short:"c"})},handler:async({flags:w,cwd:$,colors:G,spinner:B})=>{let{specifications:W,project:Z=$}=await H$({configFile:w.config,overries:{specifications:w.target}}),J=o0({project:Z,source:r.use({cwd:Z,targets:W,watch:w.watch})});if(w.watch)B("Watching for changes...").start();for await(let N of J){let{asset:Y,spec:O}=N,X=t.relative(Z,t.format(Y.filepath));process.stdout.write(`\r\x1B[K${G.bold(X)}: ${O.issueId}
|
|
36
|
+
`)}}})});import{createCLI as AG}from"@bunli/core";var Q1={work:()=>Promise.resolve().then(() => (U1(),Y1)),spec:{sync:()=>Promise.resolve().then(() => (O1(),X1))}};var L1="0.2.0-next.5";var E1=await AG({name:"mate",version:L1,commands:{directory:`${import.meta.dir}/commands`}});await E1.load(Q1);await E1.run();
|
package/dist/plugin.js
CHANGED
|
@@ -1,261 +1,26 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
import {
|
|
3
|
+
Semaphore,
|
|
4
|
+
__export,
|
|
5
|
+
all,
|
|
6
|
+
assert,
|
|
7
|
+
dedent,
|
|
8
|
+
first,
|
|
9
|
+
isArray,
|
|
10
|
+
isBoolean,
|
|
11
|
+
isEmpty,
|
|
12
|
+
isObject,
|
|
13
|
+
listify,
|
|
14
|
+
objectify,
|
|
15
|
+
shake,
|
|
16
|
+
sift,
|
|
17
|
+
toResult,
|
|
18
|
+
tryit
|
|
19
|
+
} from "./shared/plugin-hr00ebgs.js";
|
|
12
20
|
|
|
13
21
|
// src/assets/index.ts
|
|
14
22
|
var {Glob, $ } = globalThis.Bun;
|
|
15
23
|
import * as path from "path";
|
|
16
|
-
|
|
17
|
-
// node_modules/radashi/dist/radashi.js
|
|
18
|
-
function first(array, defaultValue) {
|
|
19
|
-
return (array == null ? undefined : array.length) > 0 ? array[0] : defaultValue;
|
|
20
|
-
}
|
|
21
|
-
function objectify(array, getKey, getValue = (item) => item) {
|
|
22
|
-
return array.reduce((acc, item, i) => {
|
|
23
|
-
acc[getKey(item, i)] = getValue(item, i);
|
|
24
|
-
return acc;
|
|
25
|
-
}, {});
|
|
26
|
-
}
|
|
27
|
-
function sift(array) {
|
|
28
|
-
return (array == null ? undefined : array.filter((x) => !!x)) ?? [];
|
|
29
|
-
}
|
|
30
|
-
async function all(input) {
|
|
31
|
-
const errors = [];
|
|
32
|
-
const onError = (err) => {
|
|
33
|
-
errors.push(err);
|
|
34
|
-
};
|
|
35
|
-
let output;
|
|
36
|
-
if (isArray(input)) {
|
|
37
|
-
output = await Promise.all(input.map((value) => Promise.resolve(value).catch(onError)));
|
|
38
|
-
} else {
|
|
39
|
-
output = { ...input };
|
|
40
|
-
await Promise.all(Object.keys(output).map(async (key) => {
|
|
41
|
-
output[key] = await Promise.resolve(output[key]).catch(onError);
|
|
42
|
-
}));
|
|
43
|
-
}
|
|
44
|
-
if (errors.length > 0) {
|
|
45
|
-
throw new AggregateErrorOrPolyfill(errors);
|
|
46
|
-
}
|
|
47
|
-
return output;
|
|
48
|
-
}
|
|
49
|
-
async function toResult(promise) {
|
|
50
|
-
try {
|
|
51
|
-
const result = await promise;
|
|
52
|
-
return [undefined, result];
|
|
53
|
-
} catch (error) {
|
|
54
|
-
if (isError(error)) {
|
|
55
|
-
return [error, undefined];
|
|
56
|
-
}
|
|
57
|
-
throw error;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
function tryit(func) {
|
|
61
|
-
return (...args) => {
|
|
62
|
-
try {
|
|
63
|
-
const result = func(...args);
|
|
64
|
-
return isPromise(result) ? result.then((value) => [undefined, value], (err) => [err, undefined]) : [undefined, result];
|
|
65
|
-
} catch (err) {
|
|
66
|
-
return [err, undefined];
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
function withResolvers() {
|
|
71
|
-
let resolve;
|
|
72
|
-
let reject;
|
|
73
|
-
const promise = new Promise((res, rej) => {
|
|
74
|
-
resolve = res;
|
|
75
|
-
reject = rej;
|
|
76
|
-
});
|
|
77
|
-
return { resolve, reject, promise };
|
|
78
|
-
}
|
|
79
|
-
function noop() {}
|
|
80
|
-
function listify(obj, toItem) {
|
|
81
|
-
if (!obj) {
|
|
82
|
-
return [];
|
|
83
|
-
}
|
|
84
|
-
const entries = Object.entries(obj);
|
|
85
|
-
if (entries.length === 0) {
|
|
86
|
-
return [];
|
|
87
|
-
}
|
|
88
|
-
return entries.reduce((acc, entry) => {
|
|
89
|
-
acc.push(toItem(entry[0], entry[1]));
|
|
90
|
-
return acc;
|
|
91
|
-
}, []);
|
|
92
|
-
}
|
|
93
|
-
function shake(obj, filter = (value) => value === undefined) {
|
|
94
|
-
if (!obj) {
|
|
95
|
-
return {};
|
|
96
|
-
}
|
|
97
|
-
return Object.keys(obj).reduce((acc, key) => {
|
|
98
|
-
if (!filter(obj[key])) {
|
|
99
|
-
acc[key] = obj[key];
|
|
100
|
-
}
|
|
101
|
-
return acc;
|
|
102
|
-
}, {});
|
|
103
|
-
}
|
|
104
|
-
var AggregateErrorOrPolyfill = /* @__PURE__ */ (() => globalThis.AggregateError ?? class AggregateError extends Error {
|
|
105
|
-
constructor(errors = []) {
|
|
106
|
-
var _a, _b;
|
|
107
|
-
super();
|
|
108
|
-
const name = ((_a = errors.find((e) => e.name)) == null ? undefined : _a.name) ?? "";
|
|
109
|
-
this.name = `AggregateError(${name}...)`;
|
|
110
|
-
this.message = `AggregateError with ${errors.length} errors`;
|
|
111
|
-
this.stack = ((_b = errors.find((e) => e.stack)) == null ? undefined : _b.stack) ?? this.stack;
|
|
112
|
-
this.errors = errors;
|
|
113
|
-
}
|
|
114
|
-
})();
|
|
115
|
-
var SemaphorePermit = class {
|
|
116
|
-
constructor(semaphore, request, weight) {
|
|
117
|
-
this.semaphore = semaphore;
|
|
118
|
-
this.request = request;
|
|
119
|
-
this.weight = weight;
|
|
120
|
-
}
|
|
121
|
-
release() {
|
|
122
|
-
this.semaphore.release(this);
|
|
123
|
-
this.release = noop;
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
var Semaphore = class {
|
|
127
|
-
constructor(maxCapacity) {
|
|
128
|
-
this.maxCapacity = maxCapacity;
|
|
129
|
-
this.queue = [];
|
|
130
|
-
if (maxCapacity <= 0) {
|
|
131
|
-
throw new Error("maxCapacity must be > 0");
|
|
132
|
-
}
|
|
133
|
-
this.capacity = maxCapacity;
|
|
134
|
-
}
|
|
135
|
-
get queueLength() {
|
|
136
|
-
return this.queue.length;
|
|
137
|
-
}
|
|
138
|
-
async acquire({
|
|
139
|
-
signal,
|
|
140
|
-
weight = 1
|
|
141
|
-
} = {}) {
|
|
142
|
-
if (weight <= 0) {
|
|
143
|
-
throw new Error("weight must be > 0");
|
|
144
|
-
}
|
|
145
|
-
if (weight > this.maxCapacity) {
|
|
146
|
-
throw new Error("weight must be \u2264 maxCapacity");
|
|
147
|
-
}
|
|
148
|
-
const request = withResolvers();
|
|
149
|
-
const permit = new SemaphorePermit(this, request, weight);
|
|
150
|
-
if (signal) {
|
|
151
|
-
const abort = () => {
|
|
152
|
-
const index = this.queue.indexOf(permit);
|
|
153
|
-
if (index >= 0) {
|
|
154
|
-
this.queue.splice(index, 1);
|
|
155
|
-
request.reject(signal.reason);
|
|
156
|
-
}
|
|
157
|
-
};
|
|
158
|
-
signal.addEventListener("abort", abort);
|
|
159
|
-
const cleanup = () => {
|
|
160
|
-
signal.removeEventListener("abort", abort);
|
|
161
|
-
};
|
|
162
|
-
request.promise.then(cleanup, cleanup);
|
|
163
|
-
}
|
|
164
|
-
if (this.capacity < weight) {
|
|
165
|
-
this.queue.push(permit);
|
|
166
|
-
await request.promise;
|
|
167
|
-
} else {
|
|
168
|
-
this.capacity -= weight;
|
|
169
|
-
}
|
|
170
|
-
return permit;
|
|
171
|
-
}
|
|
172
|
-
reject(error) {
|
|
173
|
-
this.acquire = () => Promise.reject(error);
|
|
174
|
-
this.queue.forEach((permit) => permit.request.reject(error));
|
|
175
|
-
this.queue = [];
|
|
176
|
-
}
|
|
177
|
-
release(permit) {
|
|
178
|
-
this.capacity += permit.weight;
|
|
179
|
-
const nextPermit = this.queue[0];
|
|
180
|
-
if (nextPermit && this.capacity >= nextPermit.weight) {
|
|
181
|
-
this.capacity -= nextPermit.weight;
|
|
182
|
-
this.queue.shift();
|
|
183
|
-
nextPermit.request.resolve();
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
};
|
|
187
|
-
function dedent(text, ...values) {
|
|
188
|
-
var _a;
|
|
189
|
-
if (isArray(text)) {
|
|
190
|
-
if (values.length > 0) {
|
|
191
|
-
return dedent(text.reduce((acc, input, i) => {
|
|
192
|
-
var _a2;
|
|
193
|
-
let value = String(values[i] ?? "");
|
|
194
|
-
const indent2 = value.includes(`
|
|
195
|
-
`) && ((_a2 = input.match(/[ \t]*(?=[^\n]*$)/)) == null ? undefined : _a2[0]);
|
|
196
|
-
if (indent2) {
|
|
197
|
-
value = value.replace(/\n(?=[^\n]*?\S)/g, `
|
|
198
|
-
` + indent2);
|
|
199
|
-
}
|
|
200
|
-
return acc + input + value;
|
|
201
|
-
}, ""));
|
|
202
|
-
}
|
|
203
|
-
text = text[0];
|
|
204
|
-
}
|
|
205
|
-
const indent = values[0] ?? ((_a = text.match(/^[ \t]*(?=\S)/m)) == null ? undefined : _a[0]);
|
|
206
|
-
const output = indent ? text.replace(new RegExp(`^${indent}`, "gm"), "") : text;
|
|
207
|
-
return output.replace(/^[ \t]*\n|\n[ \t]*$/g, "");
|
|
208
|
-
}
|
|
209
|
-
function assert(condition, message) {
|
|
210
|
-
if (!condition) {
|
|
211
|
-
throw message instanceof Error ? message : new Error(message ?? "Assertion failed");
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
var isArray = /* @__PURE__ */ (() => Array.isArray)();
|
|
215
|
-
function isBoolean(value) {
|
|
216
|
-
return typeof value === "boolean";
|
|
217
|
-
}
|
|
218
|
-
function isDate(value) {
|
|
219
|
-
return isTagged(value, "[object Date]");
|
|
220
|
-
}
|
|
221
|
-
function isEmpty(value) {
|
|
222
|
-
if (typeof value !== "object" || value === null) {
|
|
223
|
-
return !value || value === true;
|
|
224
|
-
}
|
|
225
|
-
if (isDate(value)) {
|
|
226
|
-
return Number.isNaN(value.getTime());
|
|
227
|
-
}
|
|
228
|
-
const length = value.length;
|
|
229
|
-
if (isNumber(length)) {
|
|
230
|
-
return length === 0;
|
|
231
|
-
}
|
|
232
|
-
const size = value.size;
|
|
233
|
-
if (isNumber(size)) {
|
|
234
|
-
return size === 0;
|
|
235
|
-
}
|
|
236
|
-
const keys2 = Object.keys(value).length;
|
|
237
|
-
return keys2 === 0;
|
|
238
|
-
}
|
|
239
|
-
function isError(value) {
|
|
240
|
-
return isTagged(value, "[object Error]");
|
|
241
|
-
}
|
|
242
|
-
function isFunction(value) {
|
|
243
|
-
return typeof value === "function";
|
|
244
|
-
}
|
|
245
|
-
function isNumber(value) {
|
|
246
|
-
return typeof value === "number" && !Number.isNaN(value);
|
|
247
|
-
}
|
|
248
|
-
function isObject(value) {
|
|
249
|
-
return isTagged(value, "[object Object]");
|
|
250
|
-
}
|
|
251
|
-
function isPromise(value) {
|
|
252
|
-
return !!value && isFunction(value.then);
|
|
253
|
-
}
|
|
254
|
-
function isTagged(value, tag) {
|
|
255
|
-
return Object.prototype.toString.call(value) === tag;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
// src/assets/index.ts
|
|
259
24
|
var MARKDOWNS = new Glob("**/*.md");
|
|
260
25
|
async function install(destination) {
|
|
261
26
|
const $$ = $.cwd(destination);
|
|
@@ -2917,19 +2682,20 @@ class ChainError extends Error {
|
|
|
2917
2682
|
}
|
|
2918
2683
|
}
|
|
2919
2684
|
|
|
2920
|
-
// src/adapters/
|
|
2685
|
+
// src/adapters/specifications/issues.ts
|
|
2921
2686
|
import { z } from "zod";
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2687
|
+
|
|
2688
|
+
// src/adapters/beads/issues.ts
|
|
2689
|
+
var exports_issues = {};
|
|
2690
|
+
__export(exports_issues, {
|
|
2691
|
+
use: () => use2,
|
|
2692
|
+
update: () => update,
|
|
2693
|
+
show: () => show,
|
|
2694
|
+
list: () => list,
|
|
2695
|
+
find: () => find,
|
|
2696
|
+
create: () => create2,
|
|
2697
|
+
close: () => close,
|
|
2698
|
+
claim: () => claim
|
|
2933
2699
|
});
|
|
2934
2700
|
|
|
2935
2701
|
// src/utils/shell/client.ts
|
|
@@ -3029,16 +2795,6 @@ function createPromise(shell) {
|
|
|
3029
2795
|
};
|
|
3030
2796
|
}
|
|
3031
2797
|
// src/adapters/beads/issues.ts
|
|
3032
|
-
var exports_issues = {};
|
|
3033
|
-
__export(exports_issues, {
|
|
3034
|
-
use: () => use2,
|
|
3035
|
-
update: () => update,
|
|
3036
|
-
show: () => show,
|
|
3037
|
-
list: () => list,
|
|
3038
|
-
find: () => find,
|
|
3039
|
-
close: () => close,
|
|
3040
|
-
claim: () => claim
|
|
3041
|
-
});
|
|
3042
2798
|
var list = Object.assign(async (client2, options = {}) => {
|
|
3043
2799
|
if (isEmpty(options.ids))
|
|
3044
2800
|
return [];
|
|
@@ -3067,6 +2823,11 @@ async function update(client2, input, options = {}) {
|
|
|
3067
2823
|
assert(issue, `Issue '${input.id}' not found`);
|
|
3068
2824
|
return issue;
|
|
3069
2825
|
}
|
|
2826
|
+
async function create2(client2, options) {
|
|
2827
|
+
const $2 = exports_client.use(client2);
|
|
2828
|
+
const issue = await $2`bd create ${options} --json`.json();
|
|
2829
|
+
return issue;
|
|
2830
|
+
}
|
|
3070
2831
|
async function claim(client2, input, options = {}) {
|
|
3071
2832
|
const $2 = exports_client.use(client2);
|
|
3072
2833
|
const issues = await $2`bd update ${input.id} ${options} --claim --json`.json();
|
|
@@ -3094,7 +2855,48 @@ var find;
|
|
|
3094
2855
|
find.byExternalRef = byExternalRef;
|
|
3095
2856
|
})(find ||= {});
|
|
3096
2857
|
|
|
2858
|
+
// src/adapters/specifications/issues.ts
|
|
2859
|
+
var Specification = z.object({
|
|
2860
|
+
issueId: z.string(),
|
|
2861
|
+
file: z.string(),
|
|
2862
|
+
title: z.string(),
|
|
2863
|
+
description: z.string().optional()
|
|
2864
|
+
});
|
|
2865
|
+
var SpecificationInput = z.object({
|
|
2866
|
+
file: z.string(),
|
|
2867
|
+
title: z.string(),
|
|
2868
|
+
description: z.string().optional()
|
|
2869
|
+
});
|
|
2870
|
+
var find2;
|
|
2871
|
+
((find) => {
|
|
2872
|
+
async function byFile(client2, ref) {
|
|
2873
|
+
const issue = await find.byExternalRef(client2, ref, { type: "epic" });
|
|
2874
|
+
return issue && createFromIssue(issue);
|
|
2875
|
+
}
|
|
2876
|
+
find.byFile = byFile;
|
|
2877
|
+
})(find2 ||= {});
|
|
2878
|
+
function createFromIssue(issue) {
|
|
2879
|
+
return Specification.parse({
|
|
2880
|
+
issueId: issue.id,
|
|
2881
|
+
file: issue.external_ref,
|
|
2882
|
+
title: issue.title,
|
|
2883
|
+
description: issue.description
|
|
2884
|
+
});
|
|
2885
|
+
}
|
|
2886
|
+
// src/adapters/specifications/assets.ts
|
|
2887
|
+
import { z as z2 } from "zod";
|
|
2888
|
+
var MARKDOWN = new Bun.Glob("**/*.md");
|
|
2889
|
+
var Frontmatter = z2.object({
|
|
2890
|
+
issue: z2.string().optional()
|
|
2891
|
+
});
|
|
3097
2892
|
// src/adapters/beads/agents.ts
|
|
2893
|
+
var exports_agents = {};
|
|
2894
|
+
__export(exports_agents, {
|
|
2895
|
+
use: () => use3,
|
|
2896
|
+
stuck: () => stuck,
|
|
2897
|
+
state: () => state,
|
|
2898
|
+
done: () => done
|
|
2899
|
+
});
|
|
3098
2900
|
async function stuck(client2, slug, options) {
|
|
3099
2901
|
const agent = await state(client2, slug, "stuck");
|
|
3100
2902
|
await update(client2, { id: agent.agent }, {
|
|
@@ -3128,14 +2930,6 @@ function createContextLabels(context2) {
|
|
|
3128
2930
|
const labels = sift(listify(context2, (key, value) => value && `${key}:${value}`));
|
|
3129
2931
|
return isEmpty(labels) ? undefined : labels;
|
|
3130
2932
|
}
|
|
3131
|
-
// src/adapters/beads/specifications.ts
|
|
3132
|
-
var find2;
|
|
3133
|
-
((find) => {
|
|
3134
|
-
function byExternalRef(client2, ref) {
|
|
3135
|
-
return find.byExternalRef(client2, ref, { type: "epic" });
|
|
3136
|
-
}
|
|
3137
|
-
find.byExternalRef = byExternalRef;
|
|
3138
|
-
})(find2 ||= {});
|
|
3139
2933
|
// src/adapters/beads/config.ts
|
|
3140
2934
|
var exports_config = {};
|
|
3141
2935
|
__export(exports_config, {
|
|
@@ -3531,11 +3325,11 @@ function createLog(command) {
|
|
|
3531
3325
|
return (message) => {};
|
|
3532
3326
|
}
|
|
3533
3327
|
// node_modules/@opencode-ai/plugin/dist/tool.js
|
|
3534
|
-
import { z as
|
|
3328
|
+
import { z as z3 } from "zod";
|
|
3535
3329
|
function tool(input) {
|
|
3536
3330
|
return input;
|
|
3537
3331
|
}
|
|
3538
|
-
tool.schema =
|
|
3332
|
+
tool.schema = z3;
|
|
3539
3333
|
// src/tools/i-am-stuck.ts
|
|
3540
3334
|
var createIAmStuck = (client2) => tool({
|
|
3541
3335
|
description: dedent`
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __export = (target, all) => {
|
|
4
|
+
for (var name in all)
|
|
5
|
+
__defProp(target, name, {
|
|
6
|
+
get: all[name],
|
|
7
|
+
enumerable: true,
|
|
8
|
+
configurable: true,
|
|
9
|
+
set: (newValue) => all[name] = () => newValue
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
// node_modules/radashi/dist/radashi.js
|
|
14
|
+
function castArrayIfExists(value) {
|
|
15
|
+
return Array.isArray(value) ? value.slice() : value != null ? [value] : value;
|
|
16
|
+
}
|
|
17
|
+
function first(array, defaultValue) {
|
|
18
|
+
return (array == null ? undefined : array.length) > 0 ? array[0] : defaultValue;
|
|
19
|
+
}
|
|
20
|
+
function objectify(array, getKey, getValue = (item) => item) {
|
|
21
|
+
return array.reduce((acc, item, i) => {
|
|
22
|
+
acc[getKey(item, i)] = getValue(item, i);
|
|
23
|
+
return acc;
|
|
24
|
+
}, {});
|
|
25
|
+
}
|
|
26
|
+
function sift(array) {
|
|
27
|
+
return (array == null ? undefined : array.filter((x) => !!x)) ?? [];
|
|
28
|
+
}
|
|
29
|
+
async function all(input) {
|
|
30
|
+
const errors = [];
|
|
31
|
+
const onError = (err) => {
|
|
32
|
+
errors.push(err);
|
|
33
|
+
};
|
|
34
|
+
let output;
|
|
35
|
+
if (isArray(input)) {
|
|
36
|
+
output = await Promise.all(input.map((value) => Promise.resolve(value).catch(onError)));
|
|
37
|
+
} else {
|
|
38
|
+
output = { ...input };
|
|
39
|
+
await Promise.all(Object.keys(output).map(async (key) => {
|
|
40
|
+
output[key] = await Promise.resolve(output[key]).catch(onError);
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
if (errors.length > 0) {
|
|
44
|
+
throw new AggregateErrorOrPolyfill(errors);
|
|
45
|
+
}
|
|
46
|
+
return output;
|
|
47
|
+
}
|
|
48
|
+
async function toResult(promise) {
|
|
49
|
+
try {
|
|
50
|
+
const result = await promise;
|
|
51
|
+
return [undefined, result];
|
|
52
|
+
} catch (error) {
|
|
53
|
+
if (isError(error)) {
|
|
54
|
+
return [error, undefined];
|
|
55
|
+
}
|
|
56
|
+
throw error;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function tryit(func) {
|
|
60
|
+
return (...args) => {
|
|
61
|
+
try {
|
|
62
|
+
const result = func(...args);
|
|
63
|
+
return isPromise(result) ? result.then((value) => [undefined, value], (err) => [err, undefined]) : [undefined, result];
|
|
64
|
+
} catch (err) {
|
|
65
|
+
return [err, undefined];
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function withResolvers() {
|
|
70
|
+
let resolve;
|
|
71
|
+
let reject;
|
|
72
|
+
const promise = new Promise((res, rej) => {
|
|
73
|
+
resolve = res;
|
|
74
|
+
reject = rej;
|
|
75
|
+
});
|
|
76
|
+
return { resolve, reject, promise };
|
|
77
|
+
}
|
|
78
|
+
function noop() {}
|
|
79
|
+
function listify(obj, toItem) {
|
|
80
|
+
if (!obj) {
|
|
81
|
+
return [];
|
|
82
|
+
}
|
|
83
|
+
const entries = Object.entries(obj);
|
|
84
|
+
if (entries.length === 0) {
|
|
85
|
+
return [];
|
|
86
|
+
}
|
|
87
|
+
return entries.reduce((acc, entry) => {
|
|
88
|
+
acc.push(toItem(entry[0], entry[1]));
|
|
89
|
+
return acc;
|
|
90
|
+
}, []);
|
|
91
|
+
}
|
|
92
|
+
function shake(obj, filter = (value) => value === undefined) {
|
|
93
|
+
if (!obj) {
|
|
94
|
+
return {};
|
|
95
|
+
}
|
|
96
|
+
return Object.keys(obj).reduce((acc, key) => {
|
|
97
|
+
if (!filter(obj[key])) {
|
|
98
|
+
acc[key] = obj[key];
|
|
99
|
+
}
|
|
100
|
+
return acc;
|
|
101
|
+
}, {});
|
|
102
|
+
}
|
|
103
|
+
var AggregateErrorOrPolyfill = /* @__PURE__ */ (() => globalThis.AggregateError ?? class AggregateError extends Error {
|
|
104
|
+
constructor(errors = []) {
|
|
105
|
+
var _a, _b;
|
|
106
|
+
super();
|
|
107
|
+
const name = ((_a = errors.find((e) => e.name)) == null ? undefined : _a.name) ?? "";
|
|
108
|
+
this.name = `AggregateError(${name}...)`;
|
|
109
|
+
this.message = `AggregateError with ${errors.length} errors`;
|
|
110
|
+
this.stack = ((_b = errors.find((e) => e.stack)) == null ? undefined : _b.stack) ?? this.stack;
|
|
111
|
+
this.errors = errors;
|
|
112
|
+
}
|
|
113
|
+
})();
|
|
114
|
+
var SemaphorePermit = class {
|
|
115
|
+
constructor(semaphore, request, weight) {
|
|
116
|
+
this.semaphore = semaphore;
|
|
117
|
+
this.request = request;
|
|
118
|
+
this.weight = weight;
|
|
119
|
+
}
|
|
120
|
+
release() {
|
|
121
|
+
this.semaphore.release(this);
|
|
122
|
+
this.release = noop;
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
var Semaphore = class {
|
|
126
|
+
constructor(maxCapacity) {
|
|
127
|
+
this.maxCapacity = maxCapacity;
|
|
128
|
+
this.queue = [];
|
|
129
|
+
if (maxCapacity <= 0) {
|
|
130
|
+
throw new Error("maxCapacity must be > 0");
|
|
131
|
+
}
|
|
132
|
+
this.capacity = maxCapacity;
|
|
133
|
+
}
|
|
134
|
+
get queueLength() {
|
|
135
|
+
return this.queue.length;
|
|
136
|
+
}
|
|
137
|
+
async acquire({
|
|
138
|
+
signal,
|
|
139
|
+
weight = 1
|
|
140
|
+
} = {}) {
|
|
141
|
+
if (weight <= 0) {
|
|
142
|
+
throw new Error("weight must be > 0");
|
|
143
|
+
}
|
|
144
|
+
if (weight > this.maxCapacity) {
|
|
145
|
+
throw new Error("weight must be \u2264 maxCapacity");
|
|
146
|
+
}
|
|
147
|
+
const request = withResolvers();
|
|
148
|
+
const permit = new SemaphorePermit(this, request, weight);
|
|
149
|
+
if (signal) {
|
|
150
|
+
const abort = () => {
|
|
151
|
+
const index = this.queue.indexOf(permit);
|
|
152
|
+
if (index >= 0) {
|
|
153
|
+
this.queue.splice(index, 1);
|
|
154
|
+
request.reject(signal.reason);
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
signal.addEventListener("abort", abort);
|
|
158
|
+
const cleanup = () => {
|
|
159
|
+
signal.removeEventListener("abort", abort);
|
|
160
|
+
};
|
|
161
|
+
request.promise.then(cleanup, cleanup);
|
|
162
|
+
}
|
|
163
|
+
if (this.capacity < weight) {
|
|
164
|
+
this.queue.push(permit);
|
|
165
|
+
await request.promise;
|
|
166
|
+
} else {
|
|
167
|
+
this.capacity -= weight;
|
|
168
|
+
}
|
|
169
|
+
return permit;
|
|
170
|
+
}
|
|
171
|
+
reject(error) {
|
|
172
|
+
this.acquire = () => Promise.reject(error);
|
|
173
|
+
this.queue.forEach((permit) => permit.request.reject(error));
|
|
174
|
+
this.queue = [];
|
|
175
|
+
}
|
|
176
|
+
release(permit) {
|
|
177
|
+
this.capacity += permit.weight;
|
|
178
|
+
const nextPermit = this.queue[0];
|
|
179
|
+
if (nextPermit && this.capacity >= nextPermit.weight) {
|
|
180
|
+
this.capacity -= nextPermit.weight;
|
|
181
|
+
this.queue.shift();
|
|
182
|
+
nextPermit.request.resolve();
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
function dedent(text, ...values) {
|
|
187
|
+
var _a;
|
|
188
|
+
if (isArray(text)) {
|
|
189
|
+
if (values.length > 0) {
|
|
190
|
+
return dedent(text.reduce((acc, input, i) => {
|
|
191
|
+
var _a2;
|
|
192
|
+
let value = String(values[i] ?? "");
|
|
193
|
+
const indent2 = value.includes(`
|
|
194
|
+
`) && ((_a2 = input.match(/[ \t]*(?=[^\n]*$)/)) == null ? undefined : _a2[0]);
|
|
195
|
+
if (indent2) {
|
|
196
|
+
value = value.replace(/\n(?=[^\n]*?\S)/g, `
|
|
197
|
+
` + indent2);
|
|
198
|
+
}
|
|
199
|
+
return acc + input + value;
|
|
200
|
+
}, ""));
|
|
201
|
+
}
|
|
202
|
+
text = text[0];
|
|
203
|
+
}
|
|
204
|
+
const indent = values[0] ?? ((_a = text.match(/^[ \t]*(?=\S)/m)) == null ? undefined : _a[0]);
|
|
205
|
+
const output = indent ? text.replace(new RegExp(`^${indent}`, "gm"), "") : text;
|
|
206
|
+
return output.replace(/^[ \t]*\n|\n[ \t]*$/g, "");
|
|
207
|
+
}
|
|
208
|
+
function assert(condition, message) {
|
|
209
|
+
if (!condition) {
|
|
210
|
+
throw message instanceof Error ? message : new Error(message ?? "Assertion failed");
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
var isArray = /* @__PURE__ */ (() => Array.isArray)();
|
|
214
|
+
function isBoolean(value) {
|
|
215
|
+
return typeof value === "boolean";
|
|
216
|
+
}
|
|
217
|
+
function isDate(value) {
|
|
218
|
+
return isTagged(value, "[object Date]");
|
|
219
|
+
}
|
|
220
|
+
function isEmpty(value) {
|
|
221
|
+
if (typeof value !== "object" || value === null) {
|
|
222
|
+
return !value || value === true;
|
|
223
|
+
}
|
|
224
|
+
if (isDate(value)) {
|
|
225
|
+
return Number.isNaN(value.getTime());
|
|
226
|
+
}
|
|
227
|
+
const length = value.length;
|
|
228
|
+
if (isNumber(length)) {
|
|
229
|
+
return length === 0;
|
|
230
|
+
}
|
|
231
|
+
const size = value.size;
|
|
232
|
+
if (isNumber(size)) {
|
|
233
|
+
return size === 0;
|
|
234
|
+
}
|
|
235
|
+
const keys2 = Object.keys(value).length;
|
|
236
|
+
return keys2 === 0;
|
|
237
|
+
}
|
|
238
|
+
function isError(value) {
|
|
239
|
+
return isTagged(value, "[object Error]");
|
|
240
|
+
}
|
|
241
|
+
function isFunction(value) {
|
|
242
|
+
return typeof value === "function";
|
|
243
|
+
}
|
|
244
|
+
function isNumber(value) {
|
|
245
|
+
return typeof value === "number" && !Number.isNaN(value);
|
|
246
|
+
}
|
|
247
|
+
function isObject(value) {
|
|
248
|
+
return isTagged(value, "[object Object]");
|
|
249
|
+
}
|
|
250
|
+
function isPromise(value) {
|
|
251
|
+
return !!value && isFunction(value.then);
|
|
252
|
+
}
|
|
253
|
+
function isTagged(value, tag) {
|
|
254
|
+
return Object.prototype.toString.call(value) === tag;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
export { __export, castArrayIfExists, first, objectify, sift, all, toResult, tryit, listify, shake, Semaphore, dedent, assert, isArray, isBoolean, isEmpty, isObject };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
type Config = z.output<typeof Config>;
|
|
3
|
+
type ConfigInput = z.input<typeof Config>;
|
|
4
|
+
/**
|
|
5
|
+
* Helper function to define configuration with type safety
|
|
6
|
+
* Parses and validates config, applying defaults
|
|
7
|
+
*/
|
|
8
|
+
declare function defineConfig(config: ConfigInput): Config;
|
|
9
|
+
export { defineConfig, ConfigInput, Config };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
castArrayIfExists
|
|
4
|
+
} from "../../shared/plugin-hr00ebgs.js";
|
|
5
|
+
|
|
6
|
+
// src/utils/config/define.ts
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
var Config = z.object({
|
|
9
|
+
specifications: z.union([z.string(), z.string().array()]).default(["specs/**/*.md", "!specs/thoughts/*"]).describe("Glob pattern for specification files").transform((value) => castArrayIfExists(value)),
|
|
10
|
+
project: z.string().optional().describe("Project directory")
|
|
11
|
+
});
|
|
12
|
+
function defineConfig(config) {
|
|
13
|
+
return Config.parse(config);
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
defineConfig
|
|
17
|
+
};
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-teammate",
|
|
3
|
-
"version": "0.2.0-next.
|
|
3
|
+
"version": "0.2.0-next.5",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Hugo Fqt",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
9
|
"url": "git+https://github.com/hugo082/opencode-teammate.git",
|
|
10
|
-
"sha": "
|
|
10
|
+
"sha": "4c2c20d"
|
|
11
11
|
},
|
|
12
12
|
"bin": {
|
|
13
13
|
"mate": "./dist/bin/mate"
|
|
@@ -21,9 +21,13 @@
|
|
|
21
21
|
"main": "./dist/plugin.js",
|
|
22
22
|
"module": "./dist/plugin.js",
|
|
23
23
|
"types": "./dist/plugin.d.ts",
|
|
24
|
+
"exports": {
|
|
25
|
+
"./config": "./dist/utils/config/define.js"
|
|
26
|
+
},
|
|
24
27
|
"dependencies": {
|
|
25
28
|
"@bunli/core": "^0.5.4",
|
|
26
29
|
"bunli": "^0.5.3",
|
|
30
|
+
"c12": "^4.0.0-beta.2",
|
|
27
31
|
"radashi": "~12.7.1",
|
|
28
32
|
"zod": "^4.3.6"
|
|
29
33
|
}
|