opencode-teammate 0.2.0-next.7 → 0.2.0-next.8

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 CHANGED
@@ -13,10 +13,9 @@ var H1=Object.defineProperty;var P=(w,$)=>{for(var O in $)H1(w,O,{get:$[O],enume
13
13
  `)if(B(),$.schema){let E=await $.schema["~standard"].validate(f);if(E.issues){console.error(q.red("Invalid input:"));for(let U of E.issues)console.error(q.dim(` \u2022 ${U.message}`));console.error(),S$(w,$).then(O);return}O(E.value)}else if($.validate){let E=$.validate(f);if(E===!0)O(f);else console.error(`\u2717 ${typeof E==="string"?E:"Invalid input"}`),S$(w,$).then(O)}else O(f);else if(N==="\x03")B(),process.exit(0);else if(N==="\x7F"||N==="\b"){if(f.length>0)f=f.slice(0,-1),process.stdout.write("\b \b")}else if(N.length===1&&N>=" ")f+=N,process.stdout.write("*")})})}function LO(w){let $=typeof w==="string"?{text:w}:w||{},O=!1,f=0,B=null,G=$.text||"",N=(U,Z)=>{process.stdout.write(`${h0}${j0}${U} ${Z}`)},E={start(U){if(O)return;if(O=!0,U!==void 0)G=U;process.stdout.write("\x1B[?25l"),B=setInterval(()=>{let Z=p$[f];N(Z,G),f=(f+1)%p$.length},80)},stop(U){if(!O)return;if(O=!1,B)clearInterval(B),B=null;if(process.stdout.write(h0+j0),process.stdout.write("\x1B[?25h"),U)console.log(U)},succeed(U){this.stop(),console.log(`\u2705 ${U||G}`)},fail(U){this.stop(),console.log(`\u274C ${U||G}`)},warn(U){this.stop(),console.log(`\u26A0\uFE0F ${U||G}`)},info(U){this.stop(),console.log(`\u2139\uFE0F ${U||G}`)},update(U){if(G=U,O)N(p$[f],G)}};return process.on("exit",()=>E.stop()),process.on("SIGINT",()=>{E.stop(),process.exit(0)}),E}var D,q,UO="\x1B",p,A0,WO,JO,ZO,p$,h0="\x1B[2K",j0="\x1B[G",gf,M$;var R$=Y(()=>{D={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:_(D.black),red:_(D.red),green:_(D.green),yellow:_(D.yellow),blue:_(D.blue),magenta:_(D.magenta),cyan:_(D.cyan),white:_(D.white),gray:_(D.gray),brightRed:_(D.brightRed),brightGreen:_(D.brightGreen),brightYellow:_(D.brightYellow),brightBlue:_(D.brightBlue),brightMagenta:_(D.brightMagenta),brightCyan:_(D.brightCyan),brightWhite:_(D.brightWhite),bgRed:_(D.bgRed),bgGreen:_(D.bgGreen),bgYellow:_(D.bgYellow),bgBlue:_(D.bgBlue),bgMagenta:_(D.bgMagenta),bgCyan:_(D.bgCyan),bgWhite:_(D.bgWhite),bold:_(D.bold),dim:_(D.dim),italic:_(D.italic),underline:_(D.underline),strikethrough:_(D.strikethrough),reset:_(D.reset),strip:EO},p=`${UO}[`,A0=`${p}2K`,WO=`${p}G`,JO=`${p}?25l`,ZO=`${p}?25h`;p$=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];gf={prompt:Object.assign(_$,{confirm:T$,select:x0,password:S$,text:(w,$)=>_$(w,$),multiselect:async(w,$)=>{let{options:O}=$,f=[];console.log(w);for(let B of O)if(await T$(`Select ${B.label}?`,{default:!1}))f.push(B.value);return f}}),spinner:LO,colors:q},M$=Object.assign(_$,{confirm:T$,select:x0,password:S$,text:(w,$)=>_$(w,$),multiselect:async(w,$)=>{let{options:O}=$,f=[];console.log(w);for(let B of O)if(await T$(`Select ${B.label}?`,{default:!1}))f.push(B.value);return f}})});async function*n$(w,$){let O=T0($?.interval??"1s");while(!0){let f=await w();if(Array.isArray(f)){if(x(f)&&$?.exitOnEmpty)break;yield*f}else if(f===void 0&&$?.exitOnEmpty)break;else yield f;await D0(O)}}async function n(w,$){for await(let O of n$(w,$))if(O)return O;throw Error("Timeout: waiting for condition")}var V$=Y(()=>{H()});async function k0(w,$){let{data:O}=await w.project.current({directory:$??process.cwd()});if(O&&O.id!=="global")return O.worktree;let{data:f,error:B}=await w.project.list();return T(B===void 0,`Failed to list projects: ${B}`),T(f,"No projects found"),T(f.length>0,`No projects found: ${f.length}`),M$.select("Select a project",{options:f.map((G)=>({label:G.name??G.worktree,value:G.worktree,hint:G.name?`${G.worktree} - ${G.id.slice(0,5)}`:G.id.slice(0,5)}))})}function b0(w){return w.name??w.worktree}var i$=Y(()=>{R$();H()});var N$,r$;var o$=Y(()=>{N$=class N$ extends Error{output;constructor(w,$){let O=w.stdout.toString().trim()||void 0,B=(w.stderr.toString().trim()||void 0)??O??"Unknown shell error";super(B,{cause:$.cause});this.output=w}};r$=class r$ extends Error{exitCode;constructor(w){let $=w.exitCode;super(`Exited with code '${$}'`);this.exitCode=$}}});var I={};P(I,{use:()=>YO,create:()=>c0});function YO(w){if(w instanceof Bun.$.Shell)return c0(w);if(d0 in w)return w;throw Error("Invalid client input")}function c0(w){let $=w,f=Object.assign((B,...G)=>{let N=0,E=[...B],U=G.flatMap((L,z)=>{if(!G$(L))return[L];let M=m(S0(L),(X,S)=>{if(R0(S))return`--${X}`;if(d(S))return`--${X}=${Y$(S).join(",")}`;return`--${X}='${String(S)}'`});if(x(M))return[""];let F=M.length-1;return E.splice(z+1+N,0,...Array(F).fill(" ")),N+=F,M}),Z=Object.assign(E,{raw:[...E]}),J=$(Z,...U);return XO(J)},{[d0]:!0,cwd(B){return $=$.cwd(B),f},env(B){return $=$.env(B),f}});return f}function XO(w){return{json:async($)=>{let O=await w.quiet($?.quiet).nothrow(),[f,B]=await _0(()=>O.json())();if(B)return B;throw new N$(O,{cause:f})},text:async($)=>{let O=await w.quiet($?.quiet).nothrow(),f=O.stdout.toString().trim()||void 0;if(O.exitCode!==0)return[new N$(O,{cause:new r$(O)}),f];return[void 0,f]}}}var d0;var v0=Y(()=>{H();o$();d0=Symbol("shell_client")});var z$=Y(()=>{v0();o$()});var j={};P(j,{use:()=>QO,update:()=>i,show:()=>TO,list:()=>t$,find:()=>K$,create:()=>a$,close:()=>_O,claim:()=>DO});async function QO(w,$,O){if("status"in $&&!O?.force)return $;return v$(await t$(w,{...O,ids:[$.id]}))}async function i(w,$,O={}){let B=await I.use(w)`bd update ${$.id} ${O} --json`.json(),[G]=B;return T(G,`Issue '${$.id}' not found`),G}async function a$(w,$){return await I.use(w)`bd create ${$} --json`.json()}async function DO(w,$,O={}){let B=await I.use(w)`bd update ${$.id} ${O} --claim --json`.json(),[G]=B;return T(G,`Issue '${$.id}' not found`),G}async function _O(w,$,O={}){let B=await I.use(w)`bd close ${$.id} ${O} --json`.json(),[G]=B;return T(G,`Issue '${$.id}' not found`),G}async function TO(w,$){return I.use(w)`bd show ${$.id}`.text()}var t$,K$;var q$=Y(()=>{H();z$();t$=Object.assign(async(w,$={})=>{if(x($.ids))return[];return await I.use(w)`bd list ${$} --json`.json()},{ready:async(w,$={})=>{return await I.use(w)`bd ready ${$} --json`.json()}});((rf)=>{async function w($,O,f){return(await t$($,f)).find((G)=>G.external_ref===O)}rf.byExternalRef=w})(K$||={})});var r={};P(r,{use:()=>RO,stuck:()=>SO,state:()=>e$,done:()=>MO});async function SO(w,$,O){let f=await e$(w,$,"stuck");return await i(w,{id:f.agent},{"add-label":y0(O.context),description:O.reason}),f}async function MO(w,$,O={}){let f=await e$(w,$,"done");return await i(w,{id:f.agent},{"add-label":y0(O.context),description:""}),f}async function e$(w,$,O){return await I.use(w)`bd agent state gram-${$} ${O} --json`.json()}async function RO(w,$){let O=I.use(w),f="slug"in $?`gram-${$.slug}`:$.id;return await O`bd agent show ${f} --json`.json()}function y0(w){if(!w)return;let $=Y$(m(w,(O,f)=>f&&`${O}:${f}`));return x($)?void 0:$}var m0=Y(()=>{H();z$();q$()});var l0=Y(()=>{z$()});var F$=Y(()=>{m0();q$();l0()});var o={};P(o,{update:()=>KO,find:()=>n0,create:()=>zO,SpecificationInput:()=>VO,Specification:()=>p0});import{z as k}from"zod";async function zO(w,$){let O=await a$(w,{type:"epic",title:$.title,description:$.description,"external-ref":$.file});return ww(O)}async function KO(w,$,O){let f=await i(w,{id:$.issueId},{type:"epic",title:O.title,description:O.description,"external-ref":O.file});return ww(f)}function ww(w){return p0.parse({issueId:w.id,file:w.external_ref,title:w.title,description:w.description})}var p0,VO,n0;var i0=Y(()=>{q$();p0=k.object({issueId:k.string(),file:k.string(),title:k.string(),description:k.string().optional()}),VO=k.object({file:k.string(),title:k.string(),description:k.string().optional()});((tf)=>{async function w($,O){let f=await K$.byExternalRef($,O,{type:"epic"});return f&&ww(f)}tf.byFile=w})(n0||={})});var s={};P(s,{watch:()=>s0,use:()=>HO,scan:()=>t0,Frontmatter:()=>FO});import*as o0 from"fs";import*as H$ from"path";import{z as r0}from"zod";function HO(w){if(w.watch)return s0(w);else return t0(w)}async function*s0(w){let $=a0(w.targets),O=new Map,f=[],B,G=o0.watch(w.cwd,async(N,E)=>{if(N==="change"&&E){if(!$.match(E))return;let U=Ow(w.cwd,E),Z=Bun.hash(await U.file.text());if(O.get(E)===Z)return;if(O.set(E,Z),f.push(Ow(w.cwd,E)),B)B.resolve(E),B=void 0}});try{while(!0){let N=f.shift();if(N)yield N;else B=y$(),await B.promise}}finally{G.close()}}async function*t0(w){let{targets:$,isIgnored:O}=a0(w.targets);for(let f of $)for await(let B of f.scan({cwd:w.cwd})){if(O(B))continue;yield Ow(w.cwd,B)}}function a0(w){let $=[],O=[];for(let B of X0(w))if(B.startsWith("!"))O.push(new Bun.Glob(B));else $.push(new Bun.Glob(B));T(!x($),"At least one target is required");function f(B){return!qO.match(B)||O.every((G)=>!G.match(B))}return{targets:$,isIgnored:f,match:(B)=>!f(B)&&$.some((G)=>G.match(B))}}function Ow(w,$){let O=H$.join(w,$);return{filename:$,filepath:H$.parse(O),file:Bun.file(O)}}var qO,FO;var e0=Y(()=>{H();qO=new Bun.Glob("**/*.md"),FO=r0.object({issue:r0.string().optional()})});var fw=Y(()=>{i0();e0()});function w1(w,$){let O=$?.delimiter??"---";if(!w.trimStart().startsWith(O))return{metadata:{},content:w};let f=w.split(`
14
14
  `),B=-1,G=-1;for(let J=0;J<f.length;J++)if(f[J]?.trim()===O){B=J;break}if(B===-1)return{metadata:{},content:w};for(let J=B+1;J<f.length;J++)if(f[J]?.trim()===O){G=J;break}if(G===-1)return{metadata:{},content:w};let E=f.slice(B+1,G).join(`
15
15
  `),U=hO(E),Z=f.slice(G+1).join(`
16
- `).replace(/^\n+/,"");return{metadata:U,content:Z}}function IO(w,$){let O=$?.delimiter??"---",f=Bw(w);return`${O}
16
+ `);return{metadata:U,content:Z}}function IO(w,$){let O=$?.delimiter??"---",f=Bw(w);return`${O}
17
17
  ${f}${O}
18
- `}function O1(w,$,O){return`${IO($,O)}
19
- ${w}`}function hO(w){let $={},O=w.split(`
18
+ `}function O1(w,$,O){return`${IO($,O)}${w}`}function hO(w){let $={},O=w.split(`
20
19
  `),f=[{obj:$,indent:-1}];for(let B of O){if(!B.trim()||B.trim().startsWith("#"))continue;let G=B.length-(B.trimStart()?.length??0),N=B.trim();while(f.length>1){let L=f[f.length-1];if(!L||G>L.indent)break;f.pop()}let E=N.indexOf(":");if(E===-1)continue;let U=N.substring(0,E).trim(),Z=N.substring(E+1).trim(),J=f[f.length-1]?.obj;if(!J)continue;if(Z===""){let L={};J[U]=L,f.push({obj:L,indent:G})}else if(J)J[U]=jO(Z)}return $}function jO(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 Bw(w,$=0){let O=" ".repeat($),f="";for(let[B,G]of Object.entries(w))if(V0(G))f+=`${O}${B}: null
21
20
  `;else if(G$(G)&&!d(G))f+=`${O}${B}:
22
21
  `,f+=Bw(G,$+1);else if(z0(G)){let N=G.includes(":")||G.includes("#")||G.includes(`
@@ -33,4 +32,4 @@ ${Bw(N,$+2)}`;else f+=`${O} - ${N}
33
32
  - If you are stuck and need human help, please notify via the i_am_stuck tool.
34
33
  - If you need more time to work on the task, please continue working and update your status when needed.
35
34
  `}}function gO(w){return($)=>{console.log(`[work:${w}] ${$}`)}}var L1=Y(()=>{H();F$();J1();V$()});var Y1=()=>{};var X1=Y(()=>{H();F$();Y1()});var Nw=Y(()=>{G1();L1();X1()});var D1={};P(D1,{default:()=>vO});import{defineCommand as dO,option as t}from"@bunli/core";import{z as a}from"zod";var vO,yO;var _1=Y(()=>{R$();H();V$();m$();i$();F$();Nw();D$();vO=dO({name:"work",alias:["ralph"],description:"Starts RALPH loop on opened tasks",options:{concurrency:t(a.coerce.number().min(1).default(1),{description:"How many workers can be spawned at the same time",short:"c"}),task:t(a.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":t(a.boolean().default(!1),{description:"If no task is available, wait for one to become available."}),"max-dispatches":t(a.coerce.number().min(1).default(1/0),{description:"Limit the number of tasks that can be dispatched to workers.",short:"n"}),project:t(a.string().optional(),{description:"Project to work on. When not provided, workers can be spawned for any ready tasks.",short:"p"}),config:t(a.string().optional(),{description:"Teammate config file to use",short:"c"})},handler:async({flags:w,colors:$})=>{let O=await l({configFile:w.config,overries:{project:w.project}}),f=await y.use(O),B=await k0(f,O.project),G=Bun.$.cwd(B),N=new Set,{"wait-on-idle":E,"max-dispatches":U}=w,Z=n$(()=>j.list.ready(G,{parent:w.task}),{interval:"1 second",exitOnEmpty:!E}),J=new X$(w.concurrency);for await(let F of Z){let X=await J.acquire();if(N.add(F.id),Z1({client:f,directory:B,issue:F}).catch((S)=>console.error(S)).finally(()=>X.release()),N.size>=U)break}await n(async()=>J.queueLength===0&&J.maxCapacity===J.capacity,{interval:"1 second"});let L=await j.list(G,{all:!0,ids:Array.from(N.values())}),z=Q0(L,(F)=>F.status),M=m(z,(F,X)=>{return(yO[F]??$.reset)(`${X} ${F}`)});console.log($.gray(`Dispatched: ${$.italic(Array.from(N.values()).join(", "))}`)),console.log(`Tasks: ${M.join(", ")}`)}}),yO={open:B$(q.yellow,q.italic),in_progress:B$(q.yellow,q.italic),blocked:B$(q.red,q.bold,q.underline),deferred:q.red,closed:B$(q.green,q.bold)}});var T1={};P(T1,{default:()=>uO});import{defineCommand as mO,option as Ew}from"@bunli/core";import{z as Uw}from"zod";import*as e from"path";var uO;var S1=Y(()=>{D$();Nw();fw();uO=mO({name:"sync",description:"Syncs the specifications with beads epics",options:{target:Ew(Uw.string().transform((w)=>e.resolve(w)).optional(),{description:"Specification file or directory to sync"}),watch:Ew(Uw.boolean().default(!1),{description:"Watch target for changes",short:"w"}),config:Ew(Uw.string().optional(),{description:"Teammate config file to use",short:"c"})},handler:async({flags:w,colors:$,spinner:O})=>{let{specifications:f,project:B}=await l({configFile:w.config,overries:{specifications:w.target}}),G=B1({project:B,source:s.use({cwd:B,targets:f,watch:w.watch})});if(w.watch)O("Watching for changes...").start();for await(let N of G){let{asset:E,spec:U}=N,Z=e.relative(B,e.format(E.filepath));process.stdout.write(`\r\x1B[K${$.bold(Z)}: ${U.issueId}
36
- `)}}})});import{createCLI as pO}from"@bunli/core";var M1={health:()=>Promise.resolve().then(() => (I0(),H0)),work:()=>Promise.resolve().then(() => (_1(),D1)),spec:{sync:()=>Promise.resolve().then(() => (S1(),T1))}};var R1="0.2.0-next.7";var V1=await pO({name:"mate",version:R1,commands:{directory:`${import.meta.dir}/commands`}});await V1.load(M1);await V1.run();
35
+ `)}}})});import{createCLI as pO}from"@bunli/core";var M1={health:()=>Promise.resolve().then(() => (I0(),H0)),work:()=>Promise.resolve().then(() => (_1(),D1)),spec:{sync:()=>Promise.resolve().then(() => (S1(),T1))}};var R1="0.2.0-next.8";var V1=await pO({name:"mate",version:R1,commands:{directory:`${import.meta.dir}/commands`}});await V1.load(M1);await V1.run();
@@ -3111,7 +3111,7 @@ function extract(content, options) {
3111
3111
  `);
3112
3112
  const metadata = parseYAML(yamlContent);
3113
3113
  const remainingContent = lines.slice(endIndex + 1).join(`
3114
- `).replace(/^\n+/, "");
3114
+ `);
3115
3115
  return { metadata, content: remainingContent };
3116
3116
  }
3117
3117
  function stringify(data, options) {
@@ -3123,8 +3123,7 @@ ${yamlContent}${delimiter}
3123
3123
  }
3124
3124
  function apply(content, data, options) {
3125
3125
  const frontmatter = stringify(data, options);
3126
- return `${frontmatter}
3127
- ${content}`;
3126
+ return `${frontmatter}${content}`;
3128
3127
  }
3129
3128
  function parseYAML(yaml) {
3130
3129
  const result = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-teammate",
3
- "version": "0.2.0-next.7",
3
+ "version": "0.2.0-next.8",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "files": [
@@ -26,7 +26,7 @@
26
26
  "repository": {
27
27
  "type": "git",
28
28
  "url": "git+https://github.com/hugo082/opencode-teammate.git",
29
- "sha": "36d9276"
29
+ "sha": "09721b2"
30
30
  },
31
31
  "bin": {
32
32
  "mate": "./dist/bin/mate"