opencode-teammate 0.1.0 → 0.2.0-next.1
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 +36 -0
- package/dist/plugin.d.ts +222 -0
- package/dist/plugin.js +3634 -0
- package/package.json +17 -23
- package/.bunli/commands.gen.ts +0 -87
- package/.github/workflows/ci.yml +0 -31
- package/.github/workflows/release.yml +0 -140
- package/.oxfmtrc.json +0 -3
- package/.oxlintrc.json +0 -4
- package/.zed/settings.json +0 -76
- package/bunli.config.ts +0 -11
- package/bunup.config.ts +0 -31
- package/src/adapters/assets/index.ts +0 -1
- package/src/adapters/assets/specifications.ts +0 -70
- package/src/adapters/beads/agents.ts +0 -105
- package/src/adapters/beads/config.ts +0 -17
- package/src/adapters/beads/index.ts +0 -4
- package/src/adapters/beads/issues.ts +0 -156
- package/src/adapters/beads/specifications.ts +0 -55
- package/src/adapters/environments/index.ts +0 -43
- package/src/adapters/environments/worktrees.ts +0 -78
- package/src/adapters/teammates/index.ts +0 -15
- package/src/assets/agent/planner.md +0 -196
- package/src/assets/command/brainstorm.md +0 -60
- package/src/assets/command/specify.md +0 -135
- package/src/assets/command/work.md +0 -247
- package/src/assets/index.ts +0 -37
- package/src/cli/commands/manifest.ts +0 -6
- package/src/cli/commands/spec/sync.ts +0 -47
- package/src/cli/commands/work.ts +0 -110
- package/src/cli/index.ts +0 -11
- package/src/plugin.ts +0 -45
- package/src/tools/i-am-done.ts +0 -44
- package/src/tools/i-am-stuck.ts +0 -49
- package/src/tools/index.ts +0 -2
- package/src/use-cases/index.ts +0 -5
- package/src/use-cases/inject-beads-issue.ts +0 -97
- package/src/use-cases/sync-specifications.ts +0 -48
- package/src/use-cases/sync-teammates.ts +0 -35
- package/src/use-cases/track-specs.ts +0 -91
- package/src/use-cases/work-on-issue.ts +0 -110
- package/src/utils/chain.ts +0 -60
- package/src/utils/frontmatter.spec.ts +0 -491
- package/src/utils/frontmatter.ts +0 -317
- package/src/utils/opencode.ts +0 -102
- package/src/utils/polling.ts +0 -41
- package/src/utils/projects.ts +0 -35
- package/src/utils/shell/client.spec.ts +0 -106
- package/src/utils/shell/client.ts +0 -117
- package/src/utils/shell/error.ts +0 -29
- package/src/utils/shell/index.ts +0 -2
- package/tsconfig.json +0 -9
package/dist/bin/mate
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
// @bun
|
|
3
|
+
var UG=Object.defineProperty;var b=(w,$)=>{for(var G in $)UG(w,G,{get:$[G],enumerable:!0,configurable:!0,set:(W)=>$[G]=()=>W})};var L=(w,$)=>()=>(w&&($=w(w=0)),$);var Zw=(w,$,G)=>{if($!=null){if(typeof $!=="object"&&typeof $!=="function")throw TypeError('Object expected to be assigned to "using" declaration');let W;if(G)W=$[Symbol.asyncDispose];if(W===void 0)W=$[Symbol.dispose];if(typeof W!=="function")throw TypeError("Object not disposable");w.push([G,W,$])}else if(G)w.push([G]);return $},Jw=(w,$,G)=>{let W=(Z)=>$=G?new SuppressedError(Z,$,"An error was suppressed during disposal"):(G=!0,Z),B=(Z)=>{while(Z=w.pop())try{var J=Z[1]&&Z[1].call(Z[2]);if(Z[0])return Promise.resolve(J).then(B,(Y)=>(W(Y),B()))}catch(Y){W(Y)}if(G)throw $};return B()};function T(w){return($)=>{if(!process.stdout.isTTY||process.env.NO_COLOR)return $;return`\x1B[${w}m${$}\x1B[0m`}}function QG(w){return w.replace(/\x1b\[[0-9;]*m/g,"")}async function Uw(w){process.stdout.write(w);for await(let $ of console)return $;return""}async function J$(w,$={}){let G=$.default?` (${$.default})`:"",W=`${w}${G} `;while(!0){let Z=(await Uw(W)).trim()||$.default||"";if($.schema){let J=await $.schema["~standard"].validate(Z);if(J.issues){console.error(q.red("Invalid input:"));for(let Y of J.issues)console.error(q.dim(` \u2022 ${Y.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 Y$(w,$={}){let G=$.default===!0?"Y/n":$.default===!1?"y/N":"y/n",W=`${w} (${G}) `;while(!0){let Z=(await Uw(W)).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 Qw(w,$){let{options:G,default:W}=$,B=W?G.findIndex((Z)=>Z.value===W):0;if(B===-1)B=0;return console.log(w),process.stdout.write(EG),F$(G,B),new Promise((Z)=>{process.stdin.setRawMode(!0),process.stdin.resume();let J=()=>{process.stdin.setRawMode(!1),process.stdin.pause(),process.stdout.write(DG)};process.stdin.on("data",(Y)=>{let N=Y.toString();if(N==="\x1B[A")B=Math.max(0,B-1),F$(G,B);else if(N==="\x1B[B")B=Math.min(G.length-1,B+1),F$(G,B);else if(N==="\r"||N===`
|
|
4
|
+
`){J();for(let U=0;U<G.length;U++)process.stdout.write(`${v}1A${Xw}`);let Q=G[B];if(Q)console.log(`\u2713 ${Q.label}`),Z(Q.value)}else if(N==="\x03"||N==="\x1B")J(),process.exit(0)})})}function F$(w,$){for(let G=0;G<w.length;G++)process.stdout.write(`${v}1A`);w.forEach((G,W)=>{process.stdout.write(Xw+LG);let B=W===$?"\u276F ":" ",Z=G.hint?` (${G.hint})`:"";console.log(`${B}${G.label}${Z}`)})}async function N$(w,$={}){return process.stdout.write(w+" "),new Promise((G)=>{let W="";process.stdin.setRawMode(!0),process.stdin.resume();let B=()=>{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(B(),$.schema){let Y=await $.schema["~standard"].validate(W);if(Y.issues){console.error(q.red("Invalid input:"));for(let N of Y.issues)console.error(q.dim(` \u2022 ${N.message}`));console.error(),N$(w,$).then(G);return}G(Y.value)}else if($.validate){let Y=$.validate(W);if(Y===!0)G(W);else console.error(`\u2717 ${typeof Y==="string"?Y:"Invalid input"}`),N$(w,$).then(G)}else G(W);else if(J==="\x03")B(),process.exit(0);else if(J==="\x7F"||J==="\b"){if(W.length>0)W=W.slice(0,-1),process.stdout.write("\b \b")}else if(J.length===1&&J>=" ")W+=J,process.stdout.write("*")})})}function zG(w){let $=typeof w==="string"?{text:w}:w||{},G=!1,W=0,B=null,Z=$.text||"",J=(N,Q)=>{process.stdout.write(`${Yw}${Nw}${N} ${Q}`)},Y={start(N){if(G)return;if(G=!0,N!==void 0)Z=N;process.stdout.write("\x1B[?25l"),B=setInterval(()=>{let Q=I$[W];J(Q,Z),W=(W+1)%I$.length},80)},stop(N){if(!G)return;if(G=!1,B)clearInterval(B),B=null;if(process.stdout.write(Yw+Nw),process.stdout.write("\x1B[?25h"),N)console.log(N)},succeed(N){this.stop(),console.log(`\u2705 ${N||Z}`)},fail(N){this.stop(),console.log(`\u274C ${N||Z}`)},warn(N){this.stop(),console.log(`\u26A0\uFE0F ${N||Z}`)},info(N){this.stop(),console.log(`\u2139\uFE0F ${N||Z}`)},update(N){if(Z=N,G)J(I$[W],Z)}};return process.on("exit",()=>Y.stop()),process.on("SIGINT",()=>{Y.stop(),process.exit(0)}),Y}var z,q,OG="\x1B",v,Xw,LG,EG,DG,I$,Yw="\x1B[2K",Nw="\x1B[G",M1,X$;var U$=L(()=>{z={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:T(z.black),red:T(z.red),green:T(z.green),yellow:T(z.yellow),blue:T(z.blue),magenta:T(z.magenta),cyan:T(z.cyan),white:T(z.white),gray:T(z.gray),brightRed:T(z.brightRed),brightGreen:T(z.brightGreen),brightYellow:T(z.brightYellow),brightBlue:T(z.brightBlue),brightMagenta:T(z.brightMagenta),brightCyan:T(z.brightCyan),brightWhite:T(z.brightWhite),bgRed:T(z.bgRed),bgGreen:T(z.bgGreen),bgYellow:T(z.bgYellow),bgBlue:T(z.bgBlue),bgMagenta:T(z.bgMagenta),bgCyan:T(z.bgCyan),bgWhite:T(z.bgWhite),bold:T(z.bold),dim:T(z.dim),italic:T(z.italic),underline:T(z.underline),strikethrough:T(z.strikethrough),reset:T(z.reset),strip:QG},v=`${OG}[`,Xw=`${v}2K`,LG=`${v}G`,EG=`${v}?25l`,DG=`${v}?25h`;I$=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];M1={prompt:Object.assign(J$,{confirm:Y$,select:Qw,password:N$,text:(w,$)=>J$(w,$),multiselect:async(w,$)=>{let{options:G}=$,W=[];console.log(w);for(let B of G)if(await Y$(`Select ${B.label}?`,{default:!1}))W.push(B.value);return W}}),spinner:zG,colors:q},X$=Object.assign(J$,{confirm:Y$,select:Qw,password:N$,text:(w,$)=>J$(w,$),multiselect:async(w,$)=>{let{options:G}=$,W=[];console.log(w);for(let B of G)if(await Y$(`Select ${B.label}?`,{default:!1}))W.push(B.value);return W}})});function Ew(w,$){if(!w)return{};return w.reduce((G,W)=>{let B=$(W);return G[B]=(G[B]??0)+1,G},{})}function j$(w,$){return(w==null?void 0:w.length)>0?w[0]:$}function Q$(w){return(w==null?void 0:w.filter(($)=>!!$))??[]}function Dw(w){return new Promise(($)=>setTimeout($,w))}function zw(w){return(...$)=>{try{let G=w(...$);return HG(G)?G.then((W)=>[void 0,W],(W)=>[W,void 0]):[void 0,G]}catch(G){return[G,void 0]}}}function h$(){let w,$,G=new Promise((W,B)=>{w=W,$=B});return{resolve:w,reject:$,promise:G}}function s(...w){return(...$)=>{return w.slice(1).reduce((G,W)=>W(G),w[0](...$))}}function TG(){}function Tw(w,$){return new KG($).parse(w)}function A$(w,$){if(!w||!$)return w??$??{};let G=Object.getPrototypeOf(w),W=G?{...w}:Object.assign(Object.create(G),w);for(let B of Object.keys($))W[B]=Lw(w[B])&&Lw($[B])?A$(w[B],$[B]):$[B];return W}function d(w,$){if(!w)return[];let G=Object.entries(w);if(G.length===0)return[];return G.reduce((W,B)=>{return W.push($(B[0],B[1])),W},[])}function Mw(w,$=(G)=>G===void 0){if(!w)return{};return Object.keys(w).reduce((G,W)=>{if(!$(w[W]))G[W]=w[W];return G},{})}function RG(w){if(!w||w.length===0)return"";let $=w.toLowerCase();return $.substring(0,1).toUpperCase()+$.substring(1,$.length)}function y(w,...$){var G;if(g(w)){if($.length>0)return y(w.reduce((Z,J,Y)=>{var N;let Q=String($[Y]??""),U=Q.includes(`
|
|
6
|
+
`)&&((N=J.match(/[ \t]*(?=[^\n]*$)/))==null?void 0:N[0]);if(U)Q=Q.replace(/\n(?=[^\n]*?\S)/g,`
|
|
7
|
+
`+U);return Z+J+Q},""));w=w[0]}let W=$[0]??((G=w.match(/^[ \t]*(?=\S)/m))==null?void 0:G[0]);return(W?w.replace(new RegExp(`^${W}`,"gm"),""):w).replace(/^[ \t]*\n|\n[ \t]*$/g,"")}function fw(w){if(!w)return"";return w.split(/(?=[A-Z])|[\.\-\s_]/).map(($)=>$.trim()).filter(($)=>!!$).map(($)=>RG($.toLowerCase())).join(" ")}function f(w,$){if(!w)throw $ instanceof Error?$:Error($??"Assertion failed")}function _w(w){return typeof w==="boolean"}function SG(w){return Rw(w,"[object Date]")}function P(w){if(typeof w!=="object"||w===null)return!w||w===!0;if(SG(w))return Number.isNaN(w.getTime());let $=w.length;if(Ow($))return $===0;let G=w.size;if(Ow(G))return G===0;return Object.keys(w).length===0}function qG(w){return typeof w==="function"}function Kw(w){return w===null||w===void 0}function Ow(w){return typeof w==="number"&&!Number.isNaN(w)}function t(w){return Rw(w,"[object Object]")}function Lw(w){if(typeof w!=="object"||w===null)return!1;let $=Object.getPrototypeOf(w);return $===Object.prototype||$===null||Object.getPrototypeOf($)===null}function HG(w){return!!w&&qG(w.then)}function Vw(w){return typeof w==="string"}function Rw(w,$){return Object.prototype.toString.call(w)===$}var MG=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 W=G[2];W=(($=this.short)==null?void 0:$[W])||W;let B=Number.parseFloat(G[1]);if(Math.abs(B)>1&&W.endsWith("s"))W=W.substring(0,W.length-1);if(!this.units[W])throw Error(`Invalid unit: ${W}, makes sure it is one of: ${Object.keys(this.units).join(", ")}`);return B*this.units[W]}},fG,_G,KG,VG=class{constructor(w,$,G){this.semaphore=w,this.request=$,this.weight=G}release(){this.semaphore.release(this),this.release=TG}},O$=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=h$(),W=new VG(this,G,$);if(w){let B=()=>{let J=this.queue.indexOf(W);if(J>=0)this.queue.splice(J,1),G.reject(w.reason)};w.addEventListener("abort",B);let Z=()=>{w.removeEventListener("abort",B)};G.promise.then(Z,Z)}if(this.capacity<$)this.queue.push(W),await G.promise;else this.capacity-=$;return W}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()}},g;var F=L(()=>{fG={week:604800000,day:86400000,hour:3600000,minute:60000,second:1000,millisecond:1},_G={w:"week",d:"day",h:"hour",m:"minute",s:"second",ms:"millisecond"},KG=class w extends MG{constructor($){super({units:{...w.units,...$==null?void 0:$.units},short:{...w.shortUnits,...$==null?void 0:$.short}})}static get units(){return fG}static get shortUnits(){return _G}};g=(()=>Array.isArray)()});async function*P$(w,$){let G=Tw($?.interval??"1s");while(!0){let W=await w();if(Array.isArray(W)){if(P(W)&&$?.exitOnEmpty)break;yield*W}else if(W===void 0&&$?.exitOnEmpty)break;else yield W;await Dw(G)}}async function m(w,$){for await(let G of P$(w,$))if(G)return G;throw Error("Timeout: waiting for condition")}var L$=L(()=>{F()});var qw=()=>{};var Hw=({onRequest:w,onSseError:$,onSseEvent:G,responseTransformer:W,responseValidator:B,sseDefaultRetryDelay:Z,sseMaxRetryAttempts:J,sseMaxRetryDelay:Y,sseSleepFn:N,url:Q,...U})=>{let O,R=N??((E)=>new Promise((K)=>setTimeout(K,E)));return{stream:async function*(){let E=Z??3000,K=0,x=U.signal??new AbortController().signal;while(!0){if(x.aborted)break;K++;let r=U.headers instanceof Headers?U.headers:new Headers(U.headers);if(O!==void 0)r.set("Last-Event-ID",O);try{let C={redirect:"follow",...U,body:U.serializedBody,headers:r,signal:x},A=new Request(Q,C);if(w)A=await w(Q,C);let _=await(U.fetch??globalThis.fetch)(A);if(!_.ok)throw Error(`SSE failed: ${_.status} ${_.statusText}`);if(!_.body)throw Error("No body in SSE response");let S=_.body.pipeThrough(new TextDecoderStream).getReader(),o="",$w=()=>{try{S.cancel()}catch{}};x.addEventListener("abort",$w);try{while(!0){let{done:JG,value:YG}=await S.read();if(JG)break;o+=YG,o=o.replace(/\r\n/g,`
|
|
8
|
+
`).replace(/\r/g,`
|
|
9
|
+
`);let ww=o.split(`
|
|
10
|
+
|
|
11
|
+
`);o=ww.pop()??"";for(let NG of ww){let XG=NG.split(`
|
|
12
|
+
`),Z$=[],Gw;for(let j of XG)if(j.startsWith("data:"))Z$.push(j.replace(/^data:\s*/,""));else if(j.startsWith("event:"))Gw=j.replace(/^event:\s*/,"");else if(j.startsWith("id:"))O=j.replace(/^id:\s*/,"");else if(j.startsWith("retry:")){let Bw=Number.parseInt(j.replace(/^retry:\s*/,""),10);if(!Number.isNaN(Bw))E=Bw}let k,Ww=!1;if(Z$.length){let j=Z$.join(`
|
|
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
|
+
`),B=-1,Z=-1;for(let U=0;U<W.length;U++)if(W[U]?.trim()===G){B=U;break}if(B===-1)return{metadata:{},content:w};for(let U=B+1;U<W.length;U++)if(W[U]?.trim()===G){Z=U;break}if(Z===-1)return{metadata:{},content:w};let Y=W.slice(B+1,Z).join(`
|
|
15
|
+
`),N=w1(Y),Q=W.slice(Z+1).join(`
|
|
16
|
+
`).replace(/^\n+/,"");return{metadata:N,content:Q}}function $1(w,$){let G=$?.delimiter??"---",W=t$(w);return`${G}
|
|
17
|
+
${W}${G}
|
|
18
|
+
`}function c0(w,$,G){return`${$1($,G)}
|
|
19
|
+
${w}`}function w1(w){let $={},G=w.split(`
|
|
20
|
+
`),W=[{obj:$,indent:-1}];for(let B of G){if(!B.trim()||B.trim().startsWith("#"))continue;let Z=B.length-(B.trimStart()?.length??0),J=B.trim();while(W.length>1){let O=W[W.length-1];if(!O||Z>O.indent)break;W.pop()}let Y=J.indexOf(":");if(Y===-1)continue;let N=J.substring(0,Y).trim(),Q=J.substring(Y+1).trim(),U=W[W.length-1]?.obj;if(!U)continue;if(Q===""){let O={};U[N]=O,W.push({obj:O,indent:Z})}else if(U)U[N]=G1(Q)}return $}function G1(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 t$(w,$=0){let G=" ".repeat($),W="";for(let[B,Z]of Object.entries(w))if(Kw(Z))W+=`${G}${B}: null
|
|
21
|
+
`;else if(t(Z)&&!g(Z))W+=`${G}${B}:
|
|
22
|
+
`,W+=t$(Z,$+1);else if(Vw(Z)){let J=Z.includes(":")||Z.includes("#")||Z.includes(`
|
|
23
|
+
`);W+=`${G}${B}: ${J?`"${Z}"`:Z}
|
|
24
|
+
`}else if(g(Z)){W+=`${G}${B}:
|
|
25
|
+
`;for(let J of Z)if(t(J)&&!g(J))W+=`${G}-
|
|
26
|
+
${t$(J,$+2)}`;else W+=`${G} - ${J}
|
|
27
|
+
`}else W+=`${G}${B}: ${Z}
|
|
28
|
+
`;return W}var v0=L(()=>{F()});import*as q$ from"path";async function*d0(w){let $=Bun.$.cwd(w.project);for await(let G of w.source){let{file:W,filepath:B}=G,{metadata:Z,content:J}=g0(await W.text()),Y=q$.relative(w.project,q$.format(B)),N={file:Y,title:fw(B.name),description:y`
|
|
29
|
+
Spec: ${Y}
|
|
30
|
+
`},Q=n.Frontmatter.safeParse(Z),U=Q.success&&Q.data.issue?{id:Q.data.issue}:await p.find.byExternalRef($,N.file),O=U?await p.update($,U,N):await p.create($,N),R=Object.assign({},Z,{issue:O.id});await Bun.write(W,c0(J,R)),yield{asset:G,issue:O}}}var y0=L(()=>{F();s$();G$();v0()});import*as a$ from"fs/promises";async function m0(w){let{client:$,directory:G}=w,W=await B1.acquire();try{let B=await $.project.current({directory:G});f(B.data,`Failed to initialize environment: ${B.error}`);let Z=_0(B.data);if(!B.data.commands?.start){let Y=await X$.confirm(`Opencode project ${Z} does not have a start command. Do you want to continue?`,{default:!1});f(Y,"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{W.release()}}async function u0(w){let{client:$,directory:G}=w,W=await $.worktree.remove({directory:G,worktreeRemoveInput:{directory:w.worktreeDirectory}});return f(W.data,`Failed to remove worktree: ${JSON.stringify(W.error)}`),console.log("Worktree removed"),W.data}async function l0(w){return(await Promise.all([a$.exists(`${w.directory}/.opencode`),a$.exists(`${w.directory}/.git`)])).every((G)=>G)}var B1;var p0=L(()=>{U$();F();u$();B1=new O$(1)});var{$:J1}=globalThis.Bun;var H$;var n0=L(()=>{L$();p0();H$=class H${client;directory;worktree;ready;constructor(w,$,G){this.client=w;this.directory=$;this.worktree=G;this.ready=m(()=>l0(G),{interval:"100ms"})}get $(){return J1.cwd(this.worktree.directory)}static async init(w){let $=await m0(w),G=new H$(w.client,w.directory,$);return await G.ready,G}async[Symbol.asyncDispose](){await u0({client:this.client,directory:this.directory,worktreeDirectory:this.worktree.directory}).catch((w)=>console.error(w))}}});async function i0(w){let N=[];try{let $=X1(w.issue.id);$(`Start working on ${w.issue.id}...`);const G=Zw(N,await H$.init({client:w.client,directory:w.directory,name:w.issue.id}),1);$(`Environment ready: ${G.worktree.directory}`);let W=await h.claim(G.$,w.issue);$(`Issue claimed: ${W.id}`);let B=await w.client.session.create({directory:G.worktree.directory,title:`${W.id}: ${W.title}`});f(B.data,`Failed to start the session: ${JSON.stringify(B.error)}`);$(`Session: ${B.data.id}`);let Z=await w.client.session.command({sessionID:B.data.id,directory:G.worktree.directory,command:"fake_work",arguments:`${W.id}`});f(Z.data,`Failed to send the /work command: ${JSON.stringify(Z.error)}`);let J=await l.use(G.$,B.data);while(J.agent_state!=="done"){if(J.agent_state==="stuck")$(`Agent is stuck: ${J.title}`),await m(async()=>{return J=await l.use(G.$,B.data),J.agent_state!=="stuck"},{interval:"1s"}),$(`Agent is ready to continue: ${J.agent_state}`);else{$(`Agent needs follow up, '${J.agent_state}'...`);let M=await w.client.session.prompt({sessionID:B.data.id,directory:G.worktree.directory,parts:[N1(J.agent_state)]});f(M.data,`Failed to follow up: ${JSON.stringify(M.error)}`)}J=await l.use(G.$,B.data)}$("Agent work is done");let Y=await w.client.session.messages({sessionID:B.data.id,directory:G.worktree.directory});f(Y.data,`Failed to fetch session messages: ${Y.error}`);$(`Session messages: ${Y.data.length}`);W=await h.close(G.$,w.issue,{reason:"Completed"});f(W,"Failed to close the issue");return W}catch(Q){var U=Q,O=1}finally{var R=Jw(N,U,O);R&&await R}}function N1(w){return{type:"text",text:y`
|
|
31
|
+
You are currently registered as '${w}'.
|
|
32
|
+
- If you are done with the task please notify via the i_am_done tool.
|
|
33
|
+
- If you are stuck and need human help, please notify via the i_am_stuck tool.
|
|
34
|
+
- If you need more time to work on the task, please continue working and update your status when needed.
|
|
35
|
+
`}}function X1(w){return($)=>{console.log(`[work:${w}] ${$}`)}}var r0=L(()=>{F();G$();n0();L$()});var o0=()=>{};var s0=L(()=>{F();G$();o0()});var e$=L(()=>{y0();r0();s0()});var a0={};b(a0,{default:()=>O1});import{defineCommand as Q1,option as W$}from"@bunli/core";import{z as B$}from"zod";var O1,L1;var e0=L(()=>{U$();F();L$();M0();u$();G$();e$();O1=Q1({name:"work",alias:["ralph"],description:"Starts RALPH loop on opened tasks",options:{concurrency:W$(B$.coerce.number().min(1).default(1),{description:"How many workers can be spawned at the same time",short:"c"}),task:W$(B$.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":W$(B$.boolean().default(!1),{description:"If no task is available, wait for one to become available."}),"max-dispatches":W$(B$.coerce.number().min(1).default(1/0),{description:"Limit the number of tasks that can be dispatched to workers.",short:"n"}),project:W$(B$.string().optional(),{description:"Project to work on. When not provided, workers can be spawned for any ready tasks.",short:"p"})},handler:async({flags:w,colors:$})=>{let G=await T0({loopUpForDesktopServer:!0}),W=await f0(G,w.project),B=Bun.$.cwd(W),Z=new Set,{"wait-on-idle":J,"max-dispatches":Y}=w,N=P$(()=>h.list.ready(B,{parent:w.task}),{interval:"1 second",exitOnEmpty:!J}),Q=new O$(w.concurrency);for await(let M of N){let I=await Q.acquire();if(Z.add(M.id),i0({client:G,directory:W,issue:M}).catch((E)=>console.error(E)).finally(()=>I.release()),Z.size>=Y)break}await m(async()=>Q.queueLength===0&&Q.maxCapacity===Q.capacity,{interval:"1 second"});let U=await h.list(B,{all:!0,ids:Array.from(Z.values())}),O=Ew(U,(M)=>M.status),R=d(O,(M,I)=>{return(L1[M]??$.reset)(`${I} ${M}`)});console.log($.gray(`Dispatched: ${$.italic(Array.from(Z.values()).join(", "))}`)),console.log(`Tasks: ${R.join(", ")}`)}}),L1={open:s(q.yellow,q.italic),in_progress:s(q.yellow,q.italic),blocked:s(q.red,q.bold,q.underline),deferred:q.red,closed:s(q.green,q.bold)}});var GG={};b(GG,{default:()=>D1});import{defineCommand as E1,option as $G}from"@bunli/core";import{z as wG}from"zod";import*as i from"path";var D1;var WG=L(()=>{e$();s$();D1=E1({name:"sync",description:"Syncs the specifications with beads epics",options:{target:$G(wG.string().transform((w)=>i.resolve(w)).optional(),{description:"Specification file or directory to sync",short:"t"}),watch:$G(wG.boolean().default(!1),{description:"Watch target for changes",short:"w"})},handler:async({flags:w,cwd:$,colors:G,spinner:W})=>{let Z=d0({project:"/Users/hugo/arion/d-gram",source:n.use({target:w.target??$,ignore:new Bun.Glob("thoughts/**/*.md"),watch:w.watch})});if(w.watch)W("Watching for changes...").start();for await(let J of Z){let{asset:Y,issue:N}=J,Q=i.relative("/Users/hugo/arion/d-gram",i.format(Y.filepath));process.stdout.write(`\r\x1B[K${G.bold(Q)}: ${N.id}
|
|
36
|
+
`)}}})});import{createCLI as z1}from"@bunli/core";var BG={work:()=>Promise.resolve().then(() => (e0(),a0)),spec:{sync:()=>Promise.resolve().then(() => (WG(),GG))}};var ZG=await z1();await ZG.load(BG);await ZG.run();
|
package/dist/plugin.d.ts
ADDED
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import { Event, createOpencodeClient, Project, Model, Provider, Permission, UserMessage, Message, Part, Auth, Config } from "@opencode-ai/sdk";
|
|
2
|
+
import { BunShell } from "./shell";
|
|
3
|
+
import { ToolDefinition } from "./tool";
|
|
4
|
+
import "./tool";
|
|
5
|
+
type ProviderContext = {
|
|
6
|
+
source: "env" | "config" | "custom" | "api";
|
|
7
|
+
info: Provider;
|
|
8
|
+
options: Record<string, any>;
|
|
9
|
+
};
|
|
10
|
+
type PluginInput = {
|
|
11
|
+
client: ReturnType<typeof createOpencodeClient>;
|
|
12
|
+
project: Project;
|
|
13
|
+
directory: string;
|
|
14
|
+
worktree: string;
|
|
15
|
+
serverUrl: URL;
|
|
16
|
+
$: BunShell;
|
|
17
|
+
};
|
|
18
|
+
type Plugin = (input: PluginInput) => Promise<Hooks>;
|
|
19
|
+
type AuthHook = {
|
|
20
|
+
provider: string;
|
|
21
|
+
loader?: (auth: () => Promise<Auth>, provider: Provider) => Promise<Record<string, any>>;
|
|
22
|
+
methods: ({
|
|
23
|
+
type: "oauth";
|
|
24
|
+
label: string;
|
|
25
|
+
prompts?: Array<{
|
|
26
|
+
type: "text";
|
|
27
|
+
key: string;
|
|
28
|
+
message: string;
|
|
29
|
+
placeholder?: string;
|
|
30
|
+
validate?: (value: string) => string | undefined;
|
|
31
|
+
condition?: (inputs: Record<string, string>) => boolean;
|
|
32
|
+
} | {
|
|
33
|
+
type: "select";
|
|
34
|
+
key: string;
|
|
35
|
+
message: string;
|
|
36
|
+
options: Array<{
|
|
37
|
+
label: string;
|
|
38
|
+
value: string;
|
|
39
|
+
hint?: string;
|
|
40
|
+
}>;
|
|
41
|
+
condition?: (inputs: Record<string, string>) => boolean;
|
|
42
|
+
}>;
|
|
43
|
+
authorize(inputs?: Record<string, string>): Promise<AuthOuathResult>;
|
|
44
|
+
} | {
|
|
45
|
+
type: "api";
|
|
46
|
+
label: string;
|
|
47
|
+
prompts?: Array<{
|
|
48
|
+
type: "text";
|
|
49
|
+
key: string;
|
|
50
|
+
message: string;
|
|
51
|
+
placeholder?: string;
|
|
52
|
+
validate?: (value: string) => string | undefined;
|
|
53
|
+
condition?: (inputs: Record<string, string>) => boolean;
|
|
54
|
+
} | {
|
|
55
|
+
type: "select";
|
|
56
|
+
key: string;
|
|
57
|
+
message: string;
|
|
58
|
+
options: Array<{
|
|
59
|
+
label: string;
|
|
60
|
+
value: string;
|
|
61
|
+
hint?: string;
|
|
62
|
+
}>;
|
|
63
|
+
condition?: (inputs: Record<string, string>) => boolean;
|
|
64
|
+
}>;
|
|
65
|
+
authorize?(inputs?: Record<string, string>): Promise<{
|
|
66
|
+
type: "success";
|
|
67
|
+
key: string;
|
|
68
|
+
provider?: string;
|
|
69
|
+
} | {
|
|
70
|
+
type: "failed";
|
|
71
|
+
}>;
|
|
72
|
+
})[];
|
|
73
|
+
};
|
|
74
|
+
type AuthOuathResult = {
|
|
75
|
+
url: string;
|
|
76
|
+
instructions: string;
|
|
77
|
+
} & ({
|
|
78
|
+
method: "auto";
|
|
79
|
+
callback(): Promise<({
|
|
80
|
+
type: "success";
|
|
81
|
+
provider?: string;
|
|
82
|
+
} & ({
|
|
83
|
+
refresh: string;
|
|
84
|
+
access: string;
|
|
85
|
+
expires: number;
|
|
86
|
+
accountId?: string;
|
|
87
|
+
} | {
|
|
88
|
+
key: string;
|
|
89
|
+
})) | {
|
|
90
|
+
type: "failed";
|
|
91
|
+
}>;
|
|
92
|
+
} | {
|
|
93
|
+
method: "code";
|
|
94
|
+
callback(code: string): Promise<({
|
|
95
|
+
type: "success";
|
|
96
|
+
provider?: string;
|
|
97
|
+
} & ({
|
|
98
|
+
refresh: string;
|
|
99
|
+
access: string;
|
|
100
|
+
expires: number;
|
|
101
|
+
accountId?: string;
|
|
102
|
+
} | {
|
|
103
|
+
key: string;
|
|
104
|
+
})) | {
|
|
105
|
+
type: "failed";
|
|
106
|
+
}>;
|
|
107
|
+
});
|
|
108
|
+
interface Hooks {
|
|
109
|
+
event?: (input: {
|
|
110
|
+
event: Event;
|
|
111
|
+
}) => Promise<void>;
|
|
112
|
+
config?: (input: Config) => Promise<void>;
|
|
113
|
+
tool?: {
|
|
114
|
+
[key: string]: ToolDefinition;
|
|
115
|
+
};
|
|
116
|
+
auth?: AuthHook;
|
|
117
|
+
/**
|
|
118
|
+
* Called when a new message is received
|
|
119
|
+
*/
|
|
120
|
+
"chat.message"?: (input: {
|
|
121
|
+
sessionID: string;
|
|
122
|
+
agent?: string;
|
|
123
|
+
model?: {
|
|
124
|
+
providerID: string;
|
|
125
|
+
modelID: string;
|
|
126
|
+
};
|
|
127
|
+
messageID?: string;
|
|
128
|
+
variant?: string;
|
|
129
|
+
}, output: {
|
|
130
|
+
message: UserMessage;
|
|
131
|
+
parts: Part[];
|
|
132
|
+
}) => Promise<void>;
|
|
133
|
+
/**
|
|
134
|
+
* Modify parameters sent to LLM
|
|
135
|
+
*/
|
|
136
|
+
"chat.params"?: (input: {
|
|
137
|
+
sessionID: string;
|
|
138
|
+
agent: string;
|
|
139
|
+
model: Model;
|
|
140
|
+
provider: ProviderContext;
|
|
141
|
+
message: UserMessage;
|
|
142
|
+
}, output: {
|
|
143
|
+
temperature: number;
|
|
144
|
+
topP: number;
|
|
145
|
+
topK: number;
|
|
146
|
+
options: Record<string, any>;
|
|
147
|
+
}) => Promise<void>;
|
|
148
|
+
"chat.headers"?: (input: {
|
|
149
|
+
sessionID: string;
|
|
150
|
+
agent: string;
|
|
151
|
+
model: Model;
|
|
152
|
+
provider: ProviderContext;
|
|
153
|
+
message: UserMessage;
|
|
154
|
+
}, output: {
|
|
155
|
+
headers: Record<string, string>;
|
|
156
|
+
}) => Promise<void>;
|
|
157
|
+
"permission.ask"?: (input: Permission, output: {
|
|
158
|
+
status: "ask" | "deny" | "allow";
|
|
159
|
+
}) => Promise<void>;
|
|
160
|
+
"command.execute.before"?: (input: {
|
|
161
|
+
command: string;
|
|
162
|
+
sessionID: string;
|
|
163
|
+
arguments: string;
|
|
164
|
+
}, output: {
|
|
165
|
+
parts: Part[];
|
|
166
|
+
}) => Promise<void>;
|
|
167
|
+
"tool.execute.before"?: (input: {
|
|
168
|
+
tool: string;
|
|
169
|
+
sessionID: string;
|
|
170
|
+
callID: string;
|
|
171
|
+
}, output: {
|
|
172
|
+
args: any;
|
|
173
|
+
}) => Promise<void>;
|
|
174
|
+
"shell.env"?: (input: {
|
|
175
|
+
cwd: string;
|
|
176
|
+
}, output: {
|
|
177
|
+
env: Record<string, string>;
|
|
178
|
+
}) => Promise<void>;
|
|
179
|
+
"tool.execute.after"?: (input: {
|
|
180
|
+
tool: string;
|
|
181
|
+
sessionID: string;
|
|
182
|
+
callID: string;
|
|
183
|
+
}, output: {
|
|
184
|
+
title: string;
|
|
185
|
+
output: string;
|
|
186
|
+
metadata: any;
|
|
187
|
+
}) => Promise<void>;
|
|
188
|
+
"experimental.chat.messages.transform"?: (input: {}, output: {
|
|
189
|
+
messages: {
|
|
190
|
+
info: Message;
|
|
191
|
+
parts: Part[];
|
|
192
|
+
}[];
|
|
193
|
+
}) => Promise<void>;
|
|
194
|
+
"experimental.chat.system.transform"?: (input: {
|
|
195
|
+
sessionID?: string;
|
|
196
|
+
model: Model;
|
|
197
|
+
}, output: {
|
|
198
|
+
system: string[];
|
|
199
|
+
}) => Promise<void>;
|
|
200
|
+
/**
|
|
201
|
+
* Called before session compaction starts. Allows plugins to customize
|
|
202
|
+
* the compaction prompt.
|
|
203
|
+
*
|
|
204
|
+
* - `context`: Additional context strings appended to the default prompt
|
|
205
|
+
* - `prompt`: If set, replaces the default compaction prompt entirely
|
|
206
|
+
*/
|
|
207
|
+
"experimental.session.compacting"?: (input: {
|
|
208
|
+
sessionID: string;
|
|
209
|
+
}, output: {
|
|
210
|
+
context: string[];
|
|
211
|
+
prompt?: string;
|
|
212
|
+
}) => Promise<void>;
|
|
213
|
+
"experimental.text.complete"?: (input: {
|
|
214
|
+
sessionID: string;
|
|
215
|
+
messageID: string;
|
|
216
|
+
partID: string;
|
|
217
|
+
}, output: {
|
|
218
|
+
text: string;
|
|
219
|
+
}) => Promise<void>;
|
|
220
|
+
}
|
|
221
|
+
declare const TeammatePlugin: Plugin;
|
|
222
|
+
export { TeammatePlugin as default, TeammatePlugin };
|