@caveman-ai/cli 4.0.1 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/learn-tui.js CHANGED
@@ -1,61 +1,63 @@
1
1
  // Bundled interactive UI. @clack/prompts remains a build-time dependency only.
2
- var ee=Object.create;var It=Object.defineProperty;var se=Object.getOwnPropertyDescriptor;var ie=Object.getOwnPropertyNames;var re=Object.getPrototypeOf,ne=Object.prototype.hasOwnProperty;var oe=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(s){throw e=0,s}};var ae=(t,e,s,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of ie(e))!ne.call(t,o)&&o!==s&&It(t,o,{get:()=>e[o],enumerable:!(i=se(e,o))||i.enumerable});return t};var St=(t,e,s)=>(s=t!=null?ee(re(t)):{},ae(e||!t||!t.__esModule?It(s,"default",{value:t,enumerable:!0}):s,t));var dt=oe((us,Nt)=>{"use strict";var pt={to(t,e){return e?`\x1B[${e+1};${t+1}H`:`\x1B[${t+1}G`},move(t,e){let s="";return t<0?s+=`\x1B[${-t}D`:t>0&&(s+=`\x1B[${t}C`),e<0?s+=`\x1B[${-e}A`:e>0&&(s+=`\x1B[${e}B`),s},up:(t=1)=>`\x1B[${t}A`,down:(t=1)=>`\x1B[${t}B`,forward:(t=1)=>`\x1B[${t}C`,backward:(t=1)=>`\x1B[${t}D`,nextLine:(t=1)=>"\x1B[E".repeat(t),prevLine:(t=1)=>"\x1B[F".repeat(t),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},Ie={up:(t=1)=>"\x1B[S".repeat(t),down:(t=1)=>"\x1B[T".repeat(t)},Se={screen:"\x1B[2J",up:(t=1)=>"\x1B[1J".repeat(t),down:(t=1)=>"\x1B[J".repeat(t),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines(t){let e="";for(let s=0;s<t;s++)e+=this.line+(s<t-1?pt.up():"");return t&&(e+=pt.left),e}};Nt.exports={cursor:pt,scroll:Ie,erase:Se,beep:"\x07"}});import{styleText as be}from"node:util";import{stdout as gt,stdin as Dt}from"node:process";import*as j from"node:readline";import _e from"node:readline";var bt=(()=>{let t=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return e=>{let s=0;for(t.lastIndex=0;t.test(e);)s+=1;return e.length-s}})(),_t=t=>t===12288||t>=65281&&t<=65376||t>=65504&&t<=65510,xt=t=>t===8987||t===9001||t>=12272&&t<=12287||t>=12289&&t<=12350||t>=12441&&t<=12543||t>=12549&&t<=12591||t>=12593&&t<=12686||t>=12688&&t<=12771||t>=12783&&t<=12830||t>=12832&&t<=12871||t>=12880&&t<=19903||t>=65040&&t<=65049||t>=65072&&t<=65106||t>=65108&&t<=65126||t>=65128&&t<=65131||t>=127488&&t<=127490||t>=127504&&t<=127547||t>=127552&&t<=127560||t>=131072&&t<=196605||t>=196608&&t<=262141;var ue=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,le=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,Ct=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,ce=/\t{1,1000}/y,Et=new RegExp("[\\u{1F1E6}-\\u{1F1FF}]{2}|\\u{1F3F4}[\\u{E0061}-\\u{E007A}]{2}[\\u{E0030}-\\u{E0039}\\u{E0061}-\\u{E007A}]{1,3}\\u{E007F}|(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|\\p{Emoji_Presentation})(?:\\u200D(?:\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|\\p{Emoji_Presentation}|\\p{Emoji}\\uFE0F\\u20E3?))*","yu"),he=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,pe=new RegExp("\\p{M}+","gu"),de={limit:1/0,ellipsis:""},Tt=(t,e={},s={})=>{let i=e.limit??1/0,o=e.ellipsis??"",u=e?.ellipsisWidth??(o?Tt(o,de,s).width:0),n=0,r=s.controlWidth??0,l=s.tabWidth??8,d=s.emojiWidth??2,g=2,h=s.regularWidth??1,p=s.wideWidth??g,m=[[he,h],[ue,n],[le,r],[ce,l],[Et,d],[Ct,p]],c=0,$=0,b=t.length,A=0,R=!1,L=b,F=Math.max(0,i-u),v=0,_=0,I=0,S=0;t:for(;;){if(_>v||$>=b&&$>c){let x=t.slice(v,_)||t.slice(c,$);A=0;for(let P of x.replaceAll(pe,"")){let E=P.codePointAt(0)||0;if(_t(E)?S=g:xt(E)?S=p:S=h,I+S>F&&(L=Math.min(L,Math.max(v,c)+A)),I+S>i){R=!0;break t}A+=P.length,I+=S}v=_=0}if($>=b)break t;for(let x=0,P=m.length;x<P;x++){let[E,Y]=m[x];if(E.lastIndex=$,E.test(t)){if(A=E===Ct?bt(t.slice($,E.lastIndex)):E===Et?1:E.lastIndex-$,S=A*Y,I+S>F&&(L=Math.min(L,$+Math.floor((F-I)/Y))),I+S>i){R=!0;break t}I+=S,v=c,_=$,$=c=E.lastIndex;continue t}}$+=1}return{width:R?F:I,index:R?L:b,truncated:R,ellipsed:R&&i>=u}},Mt=Tt;var me={limit:1/0,ellipsis:"",ellipsisWidth:0},ge=(t,e={})=>Mt(t,me,e).width,T=ge;var X="\x1B",Ot="\x9B",fe=39,ct="\x07",Rt="[",$e="]",Pt="m",ht=`${$e}8;;`,At=new RegExp(`(?:\\${Rt}(?<code>\\d+)m|\\${ht}(?<uri>.*)${ct})`,"y"),Ft=t=>{if(t>=30&&t<=37||t>=90&&t<=97)return 39;if(t>=40&&t<=47||t>=100&&t<=107)return 49;if(t===1||t===2)return 22;if(t===3)return 23;if(t===4)return 24;if(t===7)return 27;if(t===8)return 28;if(t===9)return 29;if(t===0)return 0},Lt=t=>`${X}${Rt}${t}${Pt}`,Vt=t=>`${X}${ht}${t}${ct}`,lt=(t,e,s)=>{let i=e[Symbol.iterator](),o=!1,u=!1,n=t.at(-1),r=n===void 0?0:T(n),l=i.next(),d=i.next(),g=0;for(;!l.done;){let h=l.value,p=T(h);r+p<=s?t[t.length-1]+=h:(t.push(h),r=0),(h===X||h===Ot)&&(o=!0,u=e.startsWith(ht,g+1)),o?u?h===ct&&(o=!1,u=!1):h===Pt&&(o=!1):(r+=p,r===s&&!d.done&&(t.push(""),r=0)),l=d,d=i.next(),g+=h.length}n=t.at(-1),!r&&n!==void 0&&n.length&&t.length>1&&(t[t.length-2]+=t.pop())},ve=t=>{let e=t.split(" "),s=e.length;for(;s&&!T(e[s-1]);)s--;return s===e.length?t:e.slice(0,s).join(" ")+e.slice(s).join("")},ye=(t,e,s={})=>{if(s.trim!==!1&&t.trim()==="")return"";let i="",o,u,n=t.split(" "),r=[""],l=0;for(let h=0;h<n.length;h++){let p=n[h];if(s.trim!==!1){let c=r.at(-1)??"",$=c.trimStart();c.length!==$.length&&(r[r.length-1]=$,l=T($))}h!==0&&(l>=e&&(s.wordWrap===!1||s.trim===!1)&&(r.push(""),l=0),(l||s.trim===!1)&&(r[r.length-1]+=" ",l++));let m=T(p);if(s.hard&&m>e){let c=e-l,$=1+Math.floor((m-c-1)/e);Math.floor((m-1)/e)<$&&r.push(""),lt(r,p,e),l=T(r.at(-1)??"");continue}if(l+m>e&&l&&m){if(s.wordWrap===!1&&l<e){lt(r,p,e),l=T(r.at(-1)??"");continue}r.push(""),l=0}if(l+m>e&&s.wordWrap===!1){lt(r,p,e),l=T(r.at(-1)??"");continue}r[r.length-1]+=p,l+=m}s.trim!==!1&&(r=r.map(h=>ve(h)));let d=r.join(`
3
- `),g=!1;for(let h=0;h<d.length;h++){let p=d[h];if(i+=p,g)g=!1;else if(g=p>="\uD800"&&p<="\uDBFF",g)continue;if(p===X||p===Ot){At.lastIndex=h+1;let c=At.exec(d)?.groups;if(c?.code!==void 0){let $=Number.parseFloat(c.code);o=$===fe?void 0:$}else c?.uri!==void 0&&(u=c.uri.length===0?void 0:c.uri)}if(d[h+1]===`
4
- `){u&&(i+=Vt(""));let m=o?Ft(o):void 0;o&&m&&(i+=Lt(m))}else p===`
5
- `&&(o&&Ft(o)&&(i+=Lt(o)),u&&(i+=Vt(u)))}return i},we=/\r?\n/;function N(t,e,s){return String(t).normalize().split(we).map(i=>ye(i,e,s)).join(`
6
- `)}var M=St(dt(),1);import{ReadStream as kt}from"node:tty";function Z(t,e,s){if(!s.some(n=>!n.disabled))return t;let i=t+e,o=Math.max(s.length-1,0),u=i<0?o:i>o?0:i;return s[u]?.disabled?Z(u,e<0?-1:1,s):u}var xe=["up","down","left","right","space","enter","cancel"],Ce=["January","February","March","April","May","June","July","August","September","October","November","December"],C={actions:new Set(xe),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["","cancel"],["escape","cancel"]]),messages:{cancel:"Canceled",error:"Something went wrong"},withGuide:!0,date:{monthNames:[...Ce],messages:{required:"Please enter a valid date",invalidMonth:"There are only 12 months in a year",invalidDay:(t,e)=>`There are only ${t} days in ${e}`,afterMin:t=>`Date must be on or after ${t.toISOString().slice(0,10)}`,beforeMax:t=>`Date must be on or before ${t.toISOString().slice(0,10)}`}}};function ft(t,e){if(typeof t=="string")return C.aliases.get(t)===e;for(let s of t)if(s!==void 0&&ft(s,e))return!0;return!1}function Ee(t,e){if(t===e)return;let s=t.split(`
2
+ var se=Object.create;var bt=Object.defineProperty;var ie=Object.getOwnPropertyDescriptor;var re=Object.getOwnPropertyNames;var ne=Object.getPrototypeOf,oe=Object.prototype.hasOwnProperty;var ae=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(s){throw e=0,s}};var ue=(t,e,s,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of re(e))!oe.call(t,n)&&n!==s&&bt(t,n,{get:()=>e[n],enumerable:!(i=ie(e,n))||i.enumerable});return t};var It=(t,e,s)=>(s=t!=null?se(ne(t)):{},ue(e||!t||!t.__esModule?bt(s,"default",{value:t,enumerable:!0}):s,t));var mt=ae((ls,Nt)=>{"use strict";var dt={to(t,e){return e?`\x1B[${e+1};${t+1}H`:`\x1B[${t+1}G`},move(t,e){let s="";return t<0?s+=`\x1B[${-t}D`:t>0&&(s+=`\x1B[${t}C`),e<0?s+=`\x1B[${-e}A`:e>0&&(s+=`\x1B[${e}B`),s},up:(t=1)=>`\x1B[${t}A`,down:(t=1)=>`\x1B[${t}B`,forward:(t=1)=>`\x1B[${t}C`,backward:(t=1)=>`\x1B[${t}D`,nextLine:(t=1)=>"\x1B[E".repeat(t),prevLine:(t=1)=>"\x1B[F".repeat(t),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},Ie={up:(t=1)=>"\x1B[S".repeat(t),down:(t=1)=>"\x1B[T".repeat(t)},Se={screen:"\x1B[2J",up:(t=1)=>"\x1B[1J".repeat(t),down:(t=1)=>"\x1B[J".repeat(t),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines(t){let e="";for(let s=0;s<t;s++)e+=this.line+(s<t-1?dt.up():"");return t&&(e+=dt.left),e}};Nt.exports={cursor:dt,scroll:Ie,erase:Se,beep:"\x07"}});import{styleText as _e}from"node:util";import{stdout as gt,stdin as Dt}from"node:process";import*as j from"node:readline";import xe from"node:readline";var St=(()=>{let t=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return e=>{let s=0;for(t.lastIndex=0;t.test(e);)s+=1;return e.length-s}})(),_t=t=>t===12288||t>=65281&&t<=65376||t>=65504&&t<=65510,xt=t=>t===8987||t===9001||t>=12272&&t<=12287||t>=12289&&t<=12350||t>=12441&&t<=12543||t>=12549&&t<=12591||t>=12593&&t<=12686||t>=12688&&t<=12771||t>=12783&&t<=12830||t>=12832&&t<=12871||t>=12880&&t<=19903||t>=65040&&t<=65049||t>=65072&&t<=65106||t>=65108&&t<=65126||t>=65128&&t<=65131||t>=127488&&t<=127490||t>=127504&&t<=127547||t>=127552&&t<=127560||t>=131072&&t<=196605||t>=196608&&t<=262141;var le=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,ce=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,Ct=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,he=/\t{1,1000}/y,Et=new RegExp("[\\u{1F1E6}-\\u{1F1FF}]{2}|\\u{1F3F4}[\\u{E0061}-\\u{E007A}]{2}[\\u{E0030}-\\u{E0039}\\u{E0061}-\\u{E007A}]{1,3}\\u{E007F}|(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|\\p{Emoji_Presentation})(?:\\u200D(?:\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|\\p{Emoji_Presentation}|\\p{Emoji}\\uFE0F\\u20E3?))*","yu"),pe=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,de=new RegExp("\\p{M}+","gu"),me={limit:1/0,ellipsis:""},Tt=(t,e={},s={})=>{let i=e.limit??1/0,n=e.ellipsis??"",u=e?.ellipsisWidth??(n?Tt(n,me,s).width:0),o=0,r=s.controlWidth??0,l=s.tabWidth??8,h=s.emojiWidth??2,g=2,p=s.regularWidth??1,d=s.wideWidth??g,m=[[pe,p],[le,o],[ce,r],[he,l],[Et,h],[Ct,d]],c=0,$=0,S=t.length,A=0,R=!1,L=S,F=Math.max(0,i-u),v=0,x=0,b=0,I=0;t:for(;;){if(x>v||$>=S&&$>c){let C=t.slice(v,x)||t.slice(c,$);A=0;for(let P of C.replaceAll(de,"")){let E=P.codePointAt(0)||0;if(_t(E)?I=g:xt(E)?I=d:I=p,b+I>F&&(L=Math.min(L,Math.max(v,c)+A)),b+I>i){R=!0;break t}A+=P.length,b+=I}v=x=0}if($>=S)break t;for(let C=0,P=m.length;C<P;C++){let[E,J]=m[C];if(E.lastIndex=$,E.test(t)){if(A=E===Ct?St(t.slice($,E.lastIndex)):E===Et?1:E.lastIndex-$,I=A*J,b+I>F&&(L=Math.min(L,$+Math.floor((F-b)/J))),b+I>i){R=!0;break t}b+=I,v=c,x=$,$=c=E.lastIndex;continue t}}$+=1}return{width:R?F:b,index:R?L:S,truncated:R,ellipsed:R&&i>=u}},Mt=Tt;var ge={limit:1/0,ellipsis:"",ellipsisWidth:0},fe=(t,e={})=>Mt(t,ge,e).width,T=fe;var X="\x1B",Ot="\x9B",$e=39,ht="\x07",Rt="[",ve="]",Pt="m",pt=`${ve}8;;`,At=new RegExp(`(?:\\${Rt}(?<code>\\d+)m|\\${pt}(?<uri>.*)${ht})`,"y"),Ft=t=>{if(t>=30&&t<=37||t>=90&&t<=97)return 39;if(t>=40&&t<=47||t>=100&&t<=107)return 49;if(t===1||t===2)return 22;if(t===3)return 23;if(t===4)return 24;if(t===7)return 27;if(t===8)return 28;if(t===9)return 29;if(t===0)return 0},Lt=t=>`${X}${Rt}${t}${Pt}`,Vt=t=>`${X}${pt}${t}${ht}`,ct=(t,e,s)=>{let i=e[Symbol.iterator](),n=!1,u=!1,o=t.at(-1),r=o===void 0?0:T(o),l=i.next(),h=i.next(),g=0;for(;!l.done;){let p=l.value,d=T(p);r+d<=s?t[t.length-1]+=p:(t.push(p),r=0),(p===X||p===Ot)&&(n=!0,u=e.startsWith(pt,g+1)),n?u?p===ht&&(n=!1,u=!1):p===Pt&&(n=!1):(r+=d,r===s&&!h.done&&(t.push(""),r=0)),l=h,h=i.next(),g+=p.length}o=t.at(-1),!r&&o!==void 0&&o.length&&t.length>1&&(t[t.length-2]+=t.pop())},ye=t=>{let e=t.split(" "),s=e.length;for(;s&&!T(e[s-1]);)s--;return s===e.length?t:e.slice(0,s).join(" ")+e.slice(s).join("")},we=(t,e,s={})=>{if(s.trim!==!1&&t.trim()==="")return"";let i="",n,u,o=t.split(" "),r=[""],l=0;for(let p=0;p<o.length;p++){let d=o[p];if(s.trim!==!1){let c=r.at(-1)??"",$=c.trimStart();c.length!==$.length&&(r[r.length-1]=$,l=T($))}p!==0&&(l>=e&&(s.wordWrap===!1||s.trim===!1)&&(r.push(""),l=0),(l||s.trim===!1)&&(r[r.length-1]+=" ",l++));let m=T(d);if(s.hard&&m>e){let c=e-l,$=1+Math.floor((m-c-1)/e);Math.floor((m-1)/e)<$&&r.push(""),ct(r,d,e),l=T(r.at(-1)??"");continue}if(l+m>e&&l&&m){if(s.wordWrap===!1&&l<e){ct(r,d,e),l=T(r.at(-1)??"");continue}r.push(""),l=0}if(l+m>e&&s.wordWrap===!1){ct(r,d,e),l=T(r.at(-1)??"");continue}r[r.length-1]+=d,l+=m}s.trim!==!1&&(r=r.map(p=>ye(p)));let h=r.join(`
3
+ `),g=!1;for(let p=0;p<h.length;p++){let d=h[p];if(i+=d,g)g=!1;else if(g=d>="\uD800"&&d<="\uDBFF",g)continue;if(d===X||d===Ot){At.lastIndex=p+1;let c=At.exec(h)?.groups;if(c?.code!==void 0){let $=Number.parseFloat(c.code);n=$===$e?void 0:$}else c?.uri!==void 0&&(u=c.uri.length===0?void 0:c.uri)}if(h[p+1]===`
4
+ `){u&&(i+=Vt(""));let m=n?Ft(n):void 0;n&&m&&(i+=Lt(m))}else d===`
5
+ `&&(n&&Ft(n)&&(i+=Lt(n)),u&&(i+=Vt(u)))}return i},be=/\r?\n/;function N(t,e,s){return String(t).normalize().split(be).map(i=>we(i,e,s)).join(`
6
+ `)}var M=It(mt(),1);import{ReadStream as kt}from"node:tty";function Z(t,e,s){if(!s.some(o=>!o.disabled))return t;let i=t+e,n=Math.max(s.length-1,0),u=i<0?n:i>n?0:i;return s[u]?.disabled?Z(u,e<0?-1:1,s):u}var Ce=["up","down","left","right","space","enter","cancel"],Ee=["January","February","March","April","May","June","July","August","September","October","November","December"],_={actions:new Set(Ce),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["","cancel"],["escape","cancel"]]),messages:{cancel:"Canceled",error:"Something went wrong"},withGuide:!0,accessible:void 0,date:{monthNames:[...Ee],messages:{required:"Please enter a valid date",invalidMonth:"There are only 12 months in a year",invalidDay:(t,e)=>`There are only ${t} days in ${e}`,afterMin:t=>`Date must be on or after ${t.toISOString().slice(0,10)}`,beforeMax:t=>`Date must be on or before ${t.toISOString().slice(0,10)}`}}};function Te(t){if(t!==void 0)return t;if(_.accessible!==void 0)return _.accessible;let e=process.env.ACCESSIBLE;return e!==void 0&&e!==""&&e!=="0"&&e!=="false"}function ft(t,e){if(typeof t=="string")return _.aliases.get(t)===e;for(let s of t)if(s!==void 0&&ft(s,e))return!0;return!1}function Me(t,e){if(t===e)return;let s=t.split(`
7
7
  `),i=e.split(`
8
- `),o=Math.max(s.length,i.length),u=[];for(let n=0;n<o;n++)s[n]!==i[n]&&u.push(n);return{lines:u,numLinesBefore:s.length,numLinesAfter:i.length,numLines:o}}var Te=globalThis.process.platform.startsWith("win"),mt=Symbol("clack:cancel");function U(t){return t===mt}function Q(t,e){let s=t;s.isTTY&&s.setRawMode(e)}function Gt({input:t=Dt,output:e=gt,overwrite:s=!0,hideCursor:i=!0}={}){let o=j.createInterface({input:t,output:e,prompt:"",tabSize:1});j.emitKeypressEvents(t,o),t instanceof kt&&t.isTTY&&t.setRawMode(!0);let u=(n,{name:r,sequence:l})=>{let d=String(n);if(ft([d,r,l],"cancel")){i&&e.write(M.cursor.show),process.exit(0);return}if(!s)return;j.moveCursor(e,r==="return"?0:-1,r==="return"?-1:0,()=>{j.clearLine(e,1,()=>{t.once("keypress",u)})})};return i&&e.write(M.cursor.hide),t.once("keypress",u),()=>{t.off("keypress",u),i&&e.write(M.cursor.show),t instanceof kt&&t.isTTY&&!Te&&t.setRawMode(!1),o.terminal=!1,o.close()}}var H=t=>"columns"in t&&typeof t.columns=="number"?t.columns:80,$t=t=>"rows"in t&&typeof t.rows=="number"?t.rows:20;function st(t,e,s,i=s,o=s,u){let n=H(t??gt);return N(e,n-s.length,{hard:!0,trim:!1}).split(`
9
- `).map((r,l,d)=>{let g=u?u(r,l):r;return l===0?`${i}${g}`:l===d.length-1?`${o}${g}`:`${s}${g}`}).join(`
10
- `)}function jt(t,e){if("~standard"in t){let s=t["~standard"].validate(e);if(s instanceof Promise)throw new TypeError("Schema validation must be synchronous. Update `validate()` and remove any asynchronous logic.");return s.issues?.at(0)?.message}return t(e)}var tt=class{input;output;_abortSignal;rl;opts;_render;_track=!1;_prevFrame="";_subscribers=new Map;_cursor=0;state="initial";error="";value;userInput="";constructor(e,s=!0){let{input:i=Dt,output:o=gt,render:u,signal:n,...r}=e;this.opts=r,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=u.bind(this),this._track=s,this._abortSignal=n,this.input=i,this.output=o}unsubscribe(){this._subscribers.clear()}setSubscriber(e,s){let i=this._subscribers.get(e)??[];i.push(s),this._subscribers.set(e,i)}on(e,s){this.setSubscriber(e,{cb:s})}once(e,s){this.setSubscriber(e,{cb:s,once:!0})}emit(e,...s){let i=this._subscribers.get(e)??[],o=[];for(let u of i)u.cb(...s),u.once&&o.push(()=>i.splice(i.indexOf(u),1));for(let u of o)u()}prompt(){return new Promise(e=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),e(mt);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}this.rl=_e.createInterface({input:this.input,tabSize:2,prompt:"",escapeCodeTimeout:50,terminal:!0}),this.rl.prompt(),this.opts.initialUserInput!==void 0&&this._setUserInput(this.opts.initialUserInput,!0),this.input.on("keypress",this.onKeypress),Q(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(M.cursor.show),this.output.off("resize",this.render),Q(this.input,!1),e(this.value)}),this.once("cancel",()=>{this.output.write(M.cursor.show),this.output.off("resize",this.render),Q(this.input,!1),e(mt)})})}_isActionKey(e,s){return e===" "}_shouldSubmit(e,s){return!0}_setValue(e){this.value=e,this.emit("value",this.value)}_setUserInput(e,s){this.userInput=e??"",this.emit("userInput",this.userInput),s&&this._track&&this.rl&&(this.rl.write(this.userInput),this._cursor=this.rl.cursor)}_clearUserInput(){this.rl?.write(null,{ctrl:!0,name:"u"}),this._setUserInput("")}onKeypress(e,s){if(this._track&&s.name!=="return"&&(s.name&&this._isActionKey(e,s)&&this.rl?.write(null,{ctrl:!0,name:"h"}),this._cursor=this.rl?.cursor??0,this._setUserInput(this.rl?.line)),this.state==="error"&&(this.state="active"),s?.name&&(!this._track&&C.aliases.has(s.name)&&this.emit("cursor",C.aliases.get(s.name)),C.actions.has(s.name)&&this.emit("cursor",s.name)),e&&(e.toLowerCase()==="y"||e.toLowerCase()==="n")&&this.emit("confirm",e.toLowerCase()==="y"),this.emit("key",e,s),s?.name==="return"&&this._shouldSubmit(e,s)){if(this.opts.validate){let i=jt(this.opts.validate,this.value);i&&(this.error=i instanceof Error?i.message:i,this.state="error",this.rl?.write(this.userInput))}this.state!=="error"&&(this.state="submit")}ft([e,s?.name,s?.sequence],"cancel")&&(this.state="cancel"),(this.state==="submit"||this.state==="cancel")&&this.emit("finalize"),this.render(),(this.state==="submit"||this.state==="cancel")&&this.close()}close(){this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(`
8
+ `),n=Math.max(s.length,i.length),u=[];for(let o=0;o<n;o++)s[o]!==i[o]&&u.push(o);return{lines:u,numLinesBefore:s.length,numLinesAfter:i.length,numLines:n}}var Ae=globalThis.process.platform.startsWith("win"),tt=Symbol("clack:cancel");function B(t){return t===tt}function Q(t,e){let s=t;s.isTTY&&s.setRawMode(e)}function Gt({input:t=Dt,output:e=gt,overwrite:s=!0,hideCursor:i=!0}={}){let n=j.createInterface({input:t,output:e,prompt:"",tabSize:1});j.emitKeypressEvents(t,n),t instanceof kt&&t.isTTY&&t.setRawMode(!0);let u=(o,{name:r,sequence:l})=>{let h=String(o);if(ft([h,r,l],"cancel")){i&&e.write(M.cursor.show),process.exit(0);return}if(!s)return;j.moveCursor(e,r==="return"?0:-1,r==="return"?-1:0,()=>{j.clearLine(e,1,()=>{t.once("keypress",u)})})};return i&&e.write(M.cursor.hide),t.once("keypress",u),()=>{t.off("keypress",u),i&&e.write(M.cursor.show),t instanceof kt&&t.isTTY&&!Ae&&t.setRawMode(!1),n.terminal=!1,n.close()}}var H=t=>"columns"in t&&typeof t.columns=="number"?t.columns:80,$t=t=>"rows"in t&&typeof t.rows=="number"?t.rows:20;function it(t,e,s,i=s,n=s,u){let o=H(t??gt);return N(e,o-s.length,{hard:!0,trim:!1}).split(`
9
+ `).map((r,l,h)=>{let g=u?u(r,l):r;return l===0?`${i}${g}`:l===h.length-1?`${n}${g}`:`${s}${g}`}).join(`
10
+ `)}function jt(t,e){if("~standard"in t){let s=t["~standard"].validate(e);return s instanceof Promise?s.then(i=>i.issues?.at(0)?.message):s.issues?.at(0)?.message}return t(e)}var et=class{input;output;_abortSignal;rl;opts;_render;_track=!1;_prevFrame="";_subscribers=new Map;_cursor=0;state="initial";error="";value;userInput="";get accessible(){return Te(this.opts.accessible)}constructor(e,s=!0){let{input:i=Dt,output:n=gt,render:u,signal:o,...r}=e;this.opts=r,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=u.bind(this),this._track=s,this._abortSignal=o,this.input=i,this.output=n}unsubscribe(){this._subscribers.clear()}setSubscriber(e,s){let i=this._subscribers.get(e)??[];i.push(s),this._subscribers.set(e,i)}on(e,s){this.setSubscriber(e,{cb:s})}once(e,s){this.setSubscriber(e,{cb:s,once:!0})}emit(e,...s){let i=this._subscribers.get(e)??[],n=[];for(let u of i)u.cb(...s),u.once&&n.push(()=>i.splice(i.indexOf(u),1));for(let u of n)u()}prompt(){return new Promise(e=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),e(tt);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}this.rl=xe.createInterface({input:this.input,tabSize:2,prompt:"",escapeCodeTimeout:50,terminal:!0}),this.rl.prompt(),this.opts.initialUserInput!==void 0&&this._setUserInput(this.opts.initialUserInput,!0),this.input.on("keypress",this.onKeypress),Q(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(M.cursor.show),this.output.off("resize",this.render),Q(this.input,!1),e(this.value)}),this.once("cancel",()=>{this.output.write(M.cursor.show),this.output.off("resize",this.render),Q(this.input,!1),e(tt)})})}_isActionKey(e,s){return e===" "}_shouldSubmit(e,s){return!0}_setValue(e){this.value=e,this.emit("value",this.value)}_setUserInput(e,s){this.userInput=e??"",this.emit("userInput",this.userInput),s&&this._track&&this.rl&&(this.rl.write(this.userInput),this._cursor=this.rl.cursor)}_clearUserInput(){this.rl?.write(null,{ctrl:!0,name:"u"}),this._setUserInput("")}async onKeypress(e,s){if(this.state!=="validating"){if(this._track&&s.name!=="return"&&(s.name&&this._isActionKey(e,s)&&this.rl?.write(null,{ctrl:!0,name:"h"}),this._cursor=this.rl?.cursor??0,this._setUserInput(this.rl?.line)),this.state==="error"&&(this.state="active"),s?.name&&(!this._track&&_.aliases.has(s.name)&&this.emit("cursor",_.aliases.get(s.name)),_.actions.has(s.name)&&this.emit("cursor",s.name)),e&&(e.toLowerCase()==="y"||e.toLowerCase()==="n")&&this.emit("confirm",e.toLowerCase()==="y"),this.emit("key",e,s),s?.name==="return"&&this._shouldSubmit(e,s)){if(this.opts.validate){let i=jt(this.opts.validate,this.value),n;i instanceof Promise?(this.state="validating",this.render(),n=await i):n=i,n&&(this.error=n instanceof Error?n.message:n,this.state="error",this.rl?.write(this.userInput))}this.state!=="error"&&(this.state="submit")}ft([e,s?.name,s?.sequence],"cancel")&&(this.state="cancel"),(this.state==="submit"||this.state==="cancel")&&this.emit("finalize"),this.render(),(this.state==="submit"||this.state==="cancel")&&this.close()}}close(){this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(`
11
11
  `),Q(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let e=N(this._prevFrame,process.stdout.columns,{hard:!0,trim:!1}).split(`
12
- `).length-1;this.output.write(M.cursor.move(-999,e*-1))}render(){let e=N(this._render(this)??"",process.stdout.columns,{hard:!0,trim:!1});if(e!==this._prevFrame){if(this.state==="initial")this.output.write(M.cursor.hide);else{let s=Ee(this._prevFrame,e),i=$t(this.output);if(this.restoreCursor(),s){let o=Math.max(0,s.numLinesAfter-i),u=Math.max(0,s.numLinesBefore-i),n=s.lines.find(r=>r>=o);if(n===void 0){this._prevFrame=e;return}if(s.lines.length===1){this.output.write(M.cursor.move(0,n-u)),this.output.write(M.erase.lines(1));let r=e.split(`
13
- `);this.output.write(r[n]),this._prevFrame=e,this.output.write(M.cursor.move(0,r.length-n-1));return}else if(s.lines.length>1){if(o<u)n=o;else{let l=n-u;l>0&&this.output.write(M.cursor.move(0,l))}this.output.write(M.erase.down());let r=e.split(`
14
- `).slice(n);this.output.write(r.join(`
15
- `)),this._prevFrame=e;return}}this.output.write(M.erase.down())}this.output.write(e),this.state==="initial"&&(this.state="active"),this._prevFrame=e}}};var Wt=class extends tt{options;cursor=0;get _selectedValue(){return this.options[this.cursor]}changeValue(){let e=this._selectedValue;this.value=e===void 0?void 0:e.value}constructor(e){super(e,!1),this.options=e.options;let s=this.options.findIndex(({value:o})=>o===e.initialValue),i=s===-1?0:s;this.cursor=this.options[i]?.disabled?Z(i,1,this.options):i,this.changeValue(),this.on("cursor",o=>{switch(o){case"left":case"up":this.cursor=Z(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=Z(this.cursor,1,this.options);break}this.changeValue()})}};var et=class extends tt{get userInputWithCursor(){if(this.state==="submit")return this.userInput;let e=this.userInput;if(this.cursor>=e.length)return`${this.userInput}\u2588`;let s=e.slice(0,this.cursor),i=e.slice(this.cursor,this.cursor+1),o=e.slice(this.cursor+1);return`${s}${be("inverse",i)}${o}`}get cursor(){return this._cursor}constructor(e){super({...e,initialUserInput:e.initialUserInput??e.initialValue}),this.on("userInput",s=>{this._setValue(s)}),this.on("finalize",()=>{this.value||(this.value=e.defaultValue),this.value===void 0&&(this.value="")})}};import{styleText as a,stripVTControlCharacters as Es}from"node:util";import O from"node:process";var q=St(dt(),1);function Me(){return O.platform!=="win32"?O.env.TERM!=="linux":!!O.env.CI||!!O.env.WT_SESSION||!!O.env.TERMINUS_SUBLIME||O.env.ConEmuTask==="{cmd::Cmder}"||O.env.TERM_PROGRAM==="Terminus-Sublime"||O.env.TERM_PROGRAM==="vscode"||O.env.TERM==="xterm-256color"||O.env.TERM==="alacritty"||O.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var vt=Me(),Ae=()=>process.env.CI==="true";var f=(t,e)=>vt?t:e,Fe=f("\u25C6","*"),Ht=f("\u25A0","x"),qt=f("\u25B2","x"),rt=f("\u25C7","o"),Le=f("\u250C","T"),y=f("\u2502","|"),B=f("\u2514","\u2014"),Fs=f("\u2510","T"),Ls=f("\u2518","\u2014"),Ve=f("\u25CF",">"),Ut=f("\u25CB"," "),Vs=f("\u25FB","[\u2022]"),Os=f("\u25FC","[+]"),Rs=f("\u25FB","[ ]"),Ps=f("\u25AA","\u2022"),Bt=f("\u2500","-"),Oe=f("\u256E","+"),Re=f("\u251C","+"),Pe=f("\u256F","+"),Ne=f("\u2570","+"),Ns=f("\u256D","+"),ke=f("\u25CF","\u2022"),De=f("\u25C6","*"),Ge=f("\u25B2","!"),je=f("\u25A0","x"),Jt=t=>{switch(t){case"initial":case"active":return a("cyan",Fe);case"cancel":return a("red",Ht);case"error":return a("yellow",qt);case"submit":return a("green",rt)}},We=t=>{switch(t){case"initial":case"active":return a("cyan",y);case"cancel":return a("red",y);case"error":return a("yellow",y);case"submit":return a("green",y)}};function Ue(t,e){let s=[`${e?`${a("cyan",y)} `:""}${t.join(" \u2022 ")}`];return e&&s.push(a("cyan",B)),s}var Kt=(t,e,s,i,o,u=!1)=>{let n=e,r=0;if(u)for(let l=i-1;l>=s;l--){let d=t[l];if(d&&(n-=d.length),r++,n<=o)break}else for(let l=s;l<i;l++){let d=t[l];if(d&&(n-=d.length),r++,n<=o)break}return{lineCount:n,removals:r}},Be=({cursor:t,options:e,style:s,output:i=process.stdout,maxItems:o=Number.POSITIVE_INFINITY,columnPadding:u=0,rowPadding:n=4})=>{let r=H(i)-u,l=$t(i),d=a("dim","..."),g=Math.max(l-n,0),h=Math.max(Math.min(o,g),5),p=0;t>=h-3&&(p=Math.max(Math.min(t-h+3,e.length-h),0));let m=h<e.length&&p>0,c=h<e.length&&p+h<e.length,$=Math.min(p+h,e.length),b=[],A=0;m&&A++,c&&A++;let R=p+(m?1:0),L=$-(c?1:0);for(let v=R;v<L;v++){let _=e[v],I=_?s(_,v===t):"",S=N(I,r,{hard:!0,trim:!1}).split(`
16
- `);b.push(S),A+=S.length}if(A>g){let v=0,_=0,I=A,S=t-R,x=g,P=()=>Kt(b,I,0,S,x),E=()=>Kt(b,I,S+1,b.length,x,!0);m?({lineCount:I,removals:v}=P(),I>x&&(c||(x-=1),{lineCount:I,removals:_}=E())):(c||(x-=1),{lineCount:I,removals:_}=E(),I>x&&(x-=1,{lineCount:I,removals:v}=P())),v>0&&(m=!0,b.splice(0,v)),_>0&&(c=!0,b.splice(b.length-_,_))}let F=[];m&&F.push(d);for(let v of b)for(let _ of v)F.push(_);return c&&F.push(d),F};var ks=[`${a("dim","\u2191/\u2193")} to navigate`,`${a("dim","Space:")} select`,`${a("dim","Enter:")} confirm`];var G={message:(t=[],{symbol:e=a("gray",y),secondarySymbol:s=a("gray",y),output:i=process.stdout,spacing:o=1,withGuide:u}={})=>{let n=[],r=u??C.withGuide,l=r?s:"",d=r?`${e} `:"",g=r?`${s} `:"";for(let p=0;p<o;p++)n.push(l);let h=Array.isArray(t)?t:t.split(`
17
- `);if(h.length>0){let[p,...m]=h;p.length>0?n.push(`${d}${p}`):n.push(r?e:"");for(let c of m)c.length>0?n.push(`${g}${c}`):n.push(r?s:"")}i.write(`${n.join(`
12
+ `).length-1;this.output.write(M.cursor.move(-999,e*-1))}render(){let e=N(this._render(this)??"",process.stdout.columns,{hard:!0,trim:!1});if(e!==this._prevFrame){if(this.state==="initial")this.output.write(M.cursor.hide);else{let s=Me(this._prevFrame,e),i=$t(this.output);if(this.restoreCursor(),s){let n=Math.max(0,s.numLinesAfter-i),u=Math.max(0,s.numLinesBefore-i),o=s.lines.find(r=>r>=n);if(o===void 0){this._prevFrame=e;return}if(s.lines.length===1){this.output.write(M.cursor.move(0,o-u)),this.output.write(M.erase.lines(1));let r=e.split(`
13
+ `);this.output.write(r[o]),this._prevFrame=e,this.output.write(M.cursor.move(0,r.length-o-1));return}else if(s.lines.length>1){if(n<u)o=n;else{let l=o-u;l>0&&this.output.write(M.cursor.move(0,l))}this.output.write(M.erase.down());let r=e.split(`
14
+ `).slice(o);this.output.write(r.join(`
15
+ `)),this._prevFrame=e;return}}this.output.write(M.erase.down())}this.output.write(e),this.state==="initial"&&(this.state="active"),this._prevFrame=e}}};var Ut=class extends et{options;cursor=0;get _selectedValue(){return this.options[this.cursor]}changeValue(){let e=this._selectedValue;this.value=e===void 0?void 0:e.value}constructor(e){super(e,!1),this.options=e.options;let s=this.options.findIndex(({value:n})=>n===e.initialValue),i=s===-1?0:s;this.cursor=this.options[i]?.disabled?Z(i,1,this.options):i,this.changeValue(),this.on("cursor",n=>{switch(n){case"left":case"up":this.cursor=Z(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=Z(this.cursor,1,this.options);break}this.changeValue()})}};var st=class extends et{get userInputWithCursor(){if(this.state==="submit")return this.userInput;let e=this.userInput;if(this.cursor>=e.length)return`${this.userInput}\u2588`;let s=e.slice(0,this.cursor),i=e.slice(this.cursor,this.cursor+1),n=e.slice(this.cursor+1);return`${s}${_e("inverse",i)}${n}`}get cursor(){return this._cursor}constructor(e){super({...e,initialUserInput:e.initialUserInput??e.initialValue}),this.on("userInput",s=>{this._setValue(s)}),this.on("finalize",()=>{this.value||(this.value=e.defaultValue),this.value===void 0&&(this.value="")})}};import{styleText as a,stripVTControlCharacters as Ts}from"node:util";import O from"node:process";var q=It(mt(),1);function Fe(){return O.platform!=="win32"?O.env.TERM!=="linux":!!O.env.CI||!!O.env.WT_SESSION||!!O.env.TERMINUS_SUBLIME||O.env.ConEmuTask==="{cmd::Cmder}"||O.env.TERM_PROGRAM==="Terminus-Sublime"||O.env.TERM_PROGRAM==="vscode"||O.env.TERM==="xterm-256color"||O.env.TERM==="alacritty"||O.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var vt=Fe(),Le=()=>process.env.CI==="true";var f=(t,e)=>vt?t:e,Wt=f("\u25C6","*"),qt=f("\u25A0","x"),Yt=f("\u25B2","x"),nt=f("\u25C7","o"),Ve=f("\u250C","T"),y=f("\u2502","|"),U=f("\u2514","\u2014"),Ls=f("\u2510","T"),Vs=f("\u2518","\u2014"),Oe=f("\u25CF",">"),Bt=f("\u25CB"," "),Os=f("\u25FB","[\u2022]"),Rs=f("\u25FC","[+]"),Ps=f("\u25FB","[ ]"),Ns=f("\u25AA","\u2022"),Kt=f("\u2500","-"),Re=f("\u256E","+"),Pe=f("\u251C","+"),Ne=f("\u256F","+"),ke=f("\u2570","+"),ks=f("\u256D","+"),De=f("\u25CF","\u2022"),Ge=f("\u25C6","*"),je=f("\u25B2","!"),Ue=f("\u25A0","x"),Jt=t=>{switch(t){case"initial":case"active":return a("cyan",Wt);case"cancel":return a("red",qt);case"error":return a("yellow",Yt);case"submit":return a("green",nt);case"validating":return a("dim",Wt)}},We=t=>{switch(t){case"initial":case"active":return a("cyan",y);case"cancel":return a("red",y);case"error":return a("yellow",y);case"submit":return a("green",y)}};function Be(t,e){let s=[`${e?`${a("cyan",y)} `:""}${t.join(" \u2022 ")}`];return e&&s.push(a("cyan",U)),s}var Ht=(t,e,s,i,n,u=!1)=>{let o=e,r=0;if(u)for(let l=i-1;l>=s;l--){let h=t[l];if(h&&(o-=h.length),r++,o<=n)break}else for(let l=s;l<i;l++){let h=t[l];if(h&&(o-=h.length),r++,o<=n)break}return{lineCount:o,removals:r}},Ke=({cursor:t,options:e,style:s,output:i=process.stdout,maxItems:n=Number.POSITIVE_INFINITY,columnPadding:u=0,rowPadding:o=4})=>{let r=H(i)-u,l=$t(i),h=a("dim","..."),g=Math.max(l-o,0),p=Math.max(Math.min(n,g),5),d=0;t>=p-3&&(d=Math.max(Math.min(t-p+3,e.length-p),0));let m=p<e.length&&d>0,c=p<e.length&&d+p<e.length,$=Math.min(d+p,e.length),S=[],A=0;m&&A++,c&&A++;let R=d+(m?1:0),L=$-(c?1:0);for(let v=R;v<L;v++){let x=e[v],b=x?s(x,v===t):"",I=N(b,r,{hard:!0,trim:!1}).split(`
16
+ `);S.push(I),A+=I.length}if(A>g){let v=0,x=0,b=A,I=t-R,C=g,P=()=>Ht(S,b,0,I,C),E=()=>Ht(S,b,I+1,S.length,C,!0);m?({lineCount:b,removals:v}=P(),b>C&&(c||(C-=1),{lineCount:b,removals:x}=E())):(c||(C-=1),{lineCount:b,removals:x}=E(),b>C&&(C-=1,{lineCount:b,removals:v}=P())),v>0&&(m=!0,S.splice(0,v)),x>0&&(c=!0,S.splice(S.length-x,x))}let F=[];m&&F.push(h);for(let v of S)for(let x of v)F.push(x);return c&&F.push(h),F};var Ds=[`${a("dim","\u2191/\u2193")} to navigate`,`${a("dim","Space:")} select`,`${a("dim","Enter:")} confirm`];var G={message:(t=[],{symbol:e=a("gray",y),secondarySymbol:s=a("gray",y),output:i=process.stdout,spacing:n=1,withGuide:u}={})=>{let o=[],r=u??_.withGuide,l=r?s:"",h=r?`${e} `:"",g=r?`${s} `:"";for(let d=0;d<n;d++)o.push(l);let p=Array.isArray(t)?t:t.split(`
17
+ `);if(p.length>0){let[d,...m]=p;d.length>0?o.push(`${h}${d}`):o.push(r?e:"");for(let c of m)c.length>0?o.push(`${g}${c}`):o.push(r?s:"")}i.write(`${o.join(`
18
18
  `)}
19
- `)},info:(t,e)=>{G.message(t,{...e,symbol:a("blue",ke)})},success:(t,e)=>{G.message(t,{...e,symbol:a("green",De)})},step:(t,e)=>{G.message(t,{...e,symbol:a("green",rt)})},warn:(t,e)=>{G.message(t,{...e,symbol:a("yellow",Ge)})},warning:(t,e)=>{G.warn(t,e)},error:(t,e)=>{G.message(t,{...e,symbol:a("red",je)})}},nt=(t="",e)=>{let s=e?.output??process.stdout,i=e?.withGuide??C.withGuide?`${a("gray",B)} `:"";s.write(`${i}${a("red",t)}
19
+ `)},info:(t,e)=>{G.message(t,{...e,symbol:a("blue",De)})},success:(t,e)=>{G.message(t,{...e,symbol:a("green",Ge)})},step:(t,e)=>{G.message(t,{...e,symbol:a("green",nt)})},warn:(t,e)=>{G.message(t,{...e,symbol:a("yellow",je)})},warning:(t,e)=>{G.warn(t,e)},error:(t,e)=>{G.message(t,{...e,symbol:a("red",Ue)})}},ot=(t="",e)=>{let s=e?.output??process.stdout,i=e?.withGuide??_.withGuide?`${a("gray",U)} `:"";s.write(`${i}${a("red",t)}
20
20
 
21
- `)},Yt=(t="",e)=>{let s=e?.output??process.stdout,i=e?.withGuide??C.withGuide?`${a("gray",Le)} `:"";s.write(`${i}${t}
22
- `)},J=(t="",e)=>{let s=e?.output??process.stdout,i=e?.withGuide??C.withGuide?`${a("gray",y)}
23
- ${a("gray",B)} `:"";s.write(`${i}${t}
21
+ `)},zt=(t="",e)=>{let s=e?.output??process.stdout,i=e?.withGuide??_.withGuide?`${a("gray",Ve)} `:"";s.write(`${i}${t}
22
+ `)},Y=(t="",e)=>{let s=e?.output??process.stdout,i=e?.withGuide??_.withGuide?`${a("gray",y)}
23
+ ${a("gray",U)} `:"";s.write(`${i}${t}
24
24
 
25
- `)};var Ke=t=>t,He=(t,e,s)=>{let i={hard:!0,trim:!1},o=N(t,e,i).split(`
26
- `),u=o.reduce((l,d)=>Math.max(T(d),l),0),n=o.map(s).reduce((l,d)=>Math.max(T(d),l),0),r=e-(n-u);return N(t,r,i)},ot=(t="",e="",s)=>{let i=s?.output??O.stdout,o=s?.withGuide??C.withGuide,u=s?.format??Ke,n=["",...He(t,H(i)-6,u).split(`
27
- `).map(u),""],r=T(e),l=Math.max(n.reduce((p,m)=>{let c=T(m);return c>p?c:p},0),r)+2,d=n.map(p=>`${a("gray",y)} ${p}${" ".repeat(l-T(p))}${a("gray",y)}`).join(`
28
- `),g=o?`${a("gray",y)}
29
- `:"",h=o?Re:Ne;i.write(`${g}${a("green",rt)} ${a("reset",e)} ${a("gray",Bt.repeat(Math.max(l-r-1,1))+Oe)}
30
- ${d}
31
- ${a("gray",h+Bt.repeat(l+2)+Pe)}
32
- `)};var qe=t=>a("magenta",t),zt=({indicator:t="dots",onCancel:e,output:s=process.stdout,cancelMessage:i,errorMessage:o,frames:u=vt?["\u25D2","\u25D0","\u25D3","\u25D1"]:["\u2022","o","O","0"],delay:n=vt?80:120,signal:r,...l}={})=>{let d=Ae(),g,h,p=!1,m=!1,c="",$,b=performance.now(),A=H(s),R=l?.styleFrame??qe,L=w=>{let V=w>1?o??C.messages.error:i??C.messages.cancel;m=w===1,p&&(K(V,w),m&&typeof e=="function"&&e())},F=()=>L(2),v=()=>L(1),_=()=>{process.on("uncaughtExceptionMonitor",F),process.on("unhandledRejection",F),process.on("SIGINT",v),process.on("SIGTERM",v),process.on("exit",L),r&&r.addEventListener("abort",v)},I=()=>{process.removeListener("uncaughtExceptionMonitor",F),process.removeListener("unhandledRejection",F),process.removeListener("SIGINT",v),process.removeListener("SIGTERM",v),process.removeListener("exit",L),r&&r.removeEventListener("abort",v)},S=()=>{if($===void 0)return;d&&s.write(`
25
+ `)};var He=t=>t,qe=(t,e,s)=>{let i={hard:!0,trim:!1},n=N(t,e,i).split(`
26
+ `),u=n.reduce((l,h)=>Math.max(T(h),l),0),o=n.map(s).reduce((l,h)=>Math.max(T(h),l),0),r=e-(o-u);return N(t,r,i)},at=(t="",e="",s)=>{let i=s?.output??O.stdout,n=s?.withGuide??_.withGuide,u=s?.format??He,o=["",...qe(t,H(i)-6,u).split(`
27
+ `).map(u),""],r=T(e),l=Math.max(o.reduce((d,m)=>{let c=T(m);return c>d?c:d},0),r)+2,h=o.map(d=>`${a("gray",y)} ${d}${" ".repeat(l-T(d))}${a("gray",y)}`).join(`
28
+ `),g=n?`${a("gray",y)}
29
+ `:"",p=n?Pe:ke;i.write(`${g}${a("green",nt)} ${a("reset",e)} ${a("gray",Kt.repeat(Math.max(l-r-1,1))+Re)}
30
+ ${h}
31
+ ${a("gray",p+Kt.repeat(l+2)+Ne)}
32
+ `)};var Ye=t=>a("magenta",t),Xt=({indicator:t="dots",onCancel:e,output:s=process.stdout,cancelMessage:i,errorMessage:n,frames:u=vt?["\u25D2","\u25D0","\u25D3","\u25D1"]:["\u2022","o","O","0"],delay:o=vt?80:120,signal:r,...l}={})=>{let h=Le(),g,p,d=!1,m=!1,c="",$,S=performance.now(),A=H(s),R=l?.styleFrame??Ye,L=w=>{let V=w>1?n??_.messages.error:i??_.messages.cancel;m=w===1,d&&(K(V,w),m&&typeof e=="function"&&e())},F=()=>L(2),v=()=>L(1),x=()=>{process.on("uncaughtExceptionMonitor",F),process.on("unhandledRejection",F),process.on("SIGINT",v),process.on("SIGTERM",v),process.on("exit",L),r&&r.addEventListener("abort",v)},b=()=>{process.removeListener("uncaughtExceptionMonitor",F),process.removeListener("unhandledRejection",F),process.removeListener("SIGINT",v),process.removeListener("SIGTERM",v),process.removeListener("exit",L),r&&r.removeEventListener("abort",v)},I=()=>{if($===void 0)return;h&&s.write(`
33
33
  `);let w=N($,A,{hard:!0,trim:!1}).split(`
34
- `);w.length>1&&s.write(q.cursor.up(w.length-1)),s.write(q.cursor.to(0)),s.write(q.erase.down())},x=w=>w.replace(/\.+$/,""),P=w=>{let V=(performance.now()-w)/1e3,k=Math.floor(V/60),D=Math.floor(V%60);return k>0?`[${k}m ${D}s]`:`[${D}s]`},E=l.withGuide??C.withGuide,Y=(w="")=>{p=!0,g=Gt({output:s}),c=x(w),b=performance.now(),E&&s.write(`${a("gray",y)}
35
- `);let V=0,k=0;_(),h=setInterval(()=>{if(d&&c===$)return;S(),$=c;let D=R(u[V]),z;if(d)z=`${D} ${c}...`;else if(t==="timer")z=`${D} ${c} ${P(b)}`;else{let te=".".repeat(Math.floor(k)).slice(0,3);z=`${D} ${c}${te}`}let Zt=N(z,A,{hard:!0,trim:!1});s.write(Zt),V=V+1<u.length?V+1:0,k=k<4?k+.125:0},n)},K=(w="",V=0,k=!1)=>{if(!p)return;p=!1,clearInterval(h),S();let D=V===0?a("green",rt):V===1?a("red",Ht):a("red",qt);c=w??c,k||(t==="timer"?s.write(`${D} ${c} ${P(b)}
34
+ `);w.length>1&&s.write(q.cursor.up(w.length-1)),s.write(q.cursor.to(0)),s.write(q.erase.down())},C=w=>w.replace(/\.+$/,""),P=w=>{let V=(performance.now()-w)/1e3,k=Math.floor(V/60),D=Math.floor(V%60);return k>0?`[${k}m ${D}s]`:`[${D}s]`},E=l.withGuide??_.withGuide,J=(w="")=>{d=!0,g=Gt({output:s}),c=C(w),S=performance.now(),E&&s.write(`${a("gray",y)}
35
+ `);let V=0,k=0;x(),p=setInterval(()=>{if(h&&c===$)return;I(),$=c;let D=R(u[V]),z;if(h)z=`${D} ${c}...`;else if(t==="timer")z=`${D} ${c} ${P(S)}`;else{let ee=".".repeat(Math.floor(k)).slice(0,3);z=`${D} ${c}${ee}`}let te=N(z,A,{hard:!0,trim:!1});s.write(te),V=V+1<u.length?V+1:0,k=k<4?k+.125:0},o)},K=(w="",V=0,k=!1)=>{if(!d)return;d=!1,clearInterval(p),I();let D=V===0?a("green",nt):V===1?a("red",qt):a("red",Yt);c=w??c,k||(t==="timer"?s.write(`${D} ${c} ${P(S)}
36
36
  `):s.write(`${D} ${c}
37
- `)),I(),g()};return{start:Y,stop:(w="")=>K(w,0),message:(w="")=>{c=x(w??c)},cancel:(w="")=>K(w,1),error:(w="")=>K(w,2),clear:()=>K("",0,!0),get isCancelled(){return m}}},Ds={light:f("\u2500","-"),heavy:f("\u2501","="),block:f("\u2588","#")};var Je=[`${a("dim","\u2191/\u2193")} to navigate`,`${a("dim","Enter:")} confirm`],it=(t,e)=>t.includes(`
37
+ `)),b(),g()};return{start:J,stop:(w="")=>K(w,0),message:(w="")=>{c=C(w??c)},cancel:(w="")=>K(w,1),error:(w="")=>K(w,2),clear:()=>K("",0,!0),get isCancelled(){return m}}},Gs={light:f("\u2500","-"),heavy:f("\u2501","="),block:f("\u2588","#")};var Je=[`${a("dim","\u2191/\u2193")} to navigate`,`${a("dim","Enter:")} confirm`],rt=(t,e)=>t.includes(`
38
38
  `)?t.split(`
39
39
  `).map(s=>e(s)).join(`
40
- `):e(t),yt=t=>{let e=(i,o)=>{if(i===void 0)return"";let u=i.label??String(i.value);switch(o){case"disabled":return`${a("gray",Ut)} ${it(u,n=>a("gray",n))}${i.hint?` ${a("dim",`(${i.hint??"disabled"})`)}`:""}`;case"selected":return`${it(u,n=>a("dim",n))}`;case"active":return`${a("green",Ve)} ${u}${i.hint?` ${a("dim",`(${i.hint})`)}`:""}`;case"cancelled":return`${it(u,n=>a(["strikethrough","dim"],n))}`;default:return`${a("dim",Ut)} ${it(u,n=>a("dim",n))}`}},s=t.showInstructions??!0;return new Wt({options:t.options,signal:t.signal,input:t.input,output:t.output,initialValue:t.initialValue,render(){let i=t.withGuide??C.withGuide,o=`${Jt(this.state)} `,u=`${We(this.state)} `,n=st(t.output,t.message,u,o),r=`${i?`${a("gray",y)}
41
- `:""}${n}
42
- `;switch(this.state){case"submit":{let l=i?`${a("gray",y)} `:"",d=st(t.output,e(this.options[this.cursor],"selected"),l);return`${r}${d}`}case"cancel":{let l=i?`${a("gray",y)} `:"",d=st(t.output,e(this.options[this.cursor],"cancelled"),l);return`${r}${d}${i?`
43
- ${a("gray",y)}`:""}`}default:{let l=i?`${a("cyan",y)} `:"",d=r.split(`
44
- `).length,g=s?Ue(Je,i):i?[a("cyan",B)]:[],h=g.join(`
45
- `),p=g.length+1;return`${r}${l}${Be({output:t.output,cursor:this.cursor,options:this.options,maxItems:t.maxItems,columnPadding:l.length,rowPadding:d+p,style:(m,c)=>e(m,m.disabled?"disabled":c?"active":"inactive")}).join(`
40
+ `):e(t),yt=t=>{let e=(i,n)=>{if(i===void 0)return"";let u=i.label??String(i.value);switch(n){case"disabled":return`${a("gray",Bt)} ${rt(u,o=>a("gray",o))}${i.hint?` ${a("dim",`(${i.hint??"disabled"})`)}`:""}`;case"selected":return`${rt(u,o=>a("dim",o))}`;case"active":return`${a("green",Oe)} ${u}${i.hint?` ${a("dim",`(${i.hint})`)}`:""}`;case"cancelled":return`${rt(u,o=>a(["strikethrough","dim"],o))}`;default:return`${a("dim",Bt)} ${rt(u,o=>a("dim",o))}`}},s=t.showInstructions??!0;return new Ut({options:t.options,signal:t.signal,input:t.input,output:t.output,initialValue:t.initialValue,render(){let i=t.withGuide??_.withGuide,n=`${Jt(this.state)} `,u=`${We(this.state)} `,o=it(t.output,t.message,u,n),r=`${i?`${a("gray",y)}
41
+ `:""}${o}
42
+ `;switch(this.state){case"submit":{let l=i?`${a("gray",y)} `:"",h=it(t.output,e(this.options[this.cursor],"selected"),l);return`${r}${h}`}case"cancel":{let l=i?`${a("gray",y)} `:"",h=it(t.output,e(this.options[this.cursor],"cancelled"),l);return`${r}${h}${i?`
43
+ ${a("gray",y)}`:""}`}default:{let l=i?`${a("cyan",y)} `:"",h=r.split(`
44
+ `).length,g=s?Be(Je,i):i?[a("cyan",U)]:[],p=g.join(`
45
+ `),d=g.length+1;return`${r}${l}${Ke({output:t.output,cursor:this.cursor,options:this.options,maxItems:t.maxItems,columnPadding:l.length,rowPadding:h+d,style:(m,c)=>e(m,m.disabled?"disabled":c?"active":"inactive")}).join(`
46
46
  ${l}`)}
47
- ${h}
48
- `}}}}).prompt()};var Gs=`${a("gray",y)} `;var Xt=t=>new et({validate:t.validate,placeholder:t.placeholder,defaultValue:t.defaultValue,initialValue:t.initialValue,output:t.output,signal:t.signal,input:t.input,render(){let e=t?.withGuide??C.withGuide,s=`${`${e?`${a("gray",y)}
47
+ ${p}
48
+ `}}}}).prompt()};var js=`${a("gray",y)} `;var Qt=t=>new st({validate:t.validate,placeholder:t.placeholder,defaultValue:t.defaultValue,initialValue:t.initialValue,output:t.output,signal:t.signal,input:t.input,render(){let e=t?.withGuide??_.withGuide,s=`${`${e?`${a("gray",y)}
49
49
  `:""}${Jt(this.state)} `}${t.message}
50
- `,i=t.placeholder&&t.placeholder.length>0?a("inverse",t.placeholder[0])+a("dim",t.placeholder.slice(1)):a(["inverse","hidden"],"_"),o=this.userInput?this.userInputWithCursor:i,u=this.value??"";switch(this.state){case"error":{let n=this.error?` ${a("yellow",this.error)}`:"",r=e?`${a("yellow",y)} `:"",l=e?a("yellow",B):"";return`${s.trim()}
51
- ${r}${o}
52
- ${l}${n}
53
- `}case"submit":{let n=u?` ${a("dim",u)}`:"",r=e?a("gray",y):"";return`${s}${r}${n}`}case"cancel":{let n=u?` ${a(["strikethrough","dim"],u)}`:"",r=e?a("gray",y):"";return`${s}${r}${n}${u.trim()?`
54
- ${r}`:""}`}default:{let n=e?`${a("cyan",y)} `:"",r=e?a("cyan",B):"";return`${s}${n}${o}
50
+ `,i=t.placeholder&&t.placeholder.length>0?a("inverse",t.placeholder[0])+a("dim",t.placeholder.slice(1)):a(["inverse","hidden"],"_"),n=this.userInput?this.userInputWithCursor:i,u=this.value??"";switch(this.state){case"validating":{let o=e?`${a("cyan",y)} `:"",r=e?a("cyan",U):"",l=a("dim",n),h=a("dim","Validating...");return`${s}${o}${l}
51
+ ${r} ${h}
52
+ `}case"error":{let o=this.error?` ${a("yellow",this.error)}`:"",r=e?`${a("yellow",y)} `:"",l=e?a("yellow",U):"";return`${s.trim()}
53
+ ${r}${n}
54
+ ${l}${o}
55
+ `}case"submit":{let o=u?`${e?" ":""}${a("dim",u)}`:"",r=e?a("gray",y):"";return`${s}${r}${o}`}case"cancel":{let o=u?` ${a(["strikethrough","dim"],u)}`:"",r=e?a("gray",y):"";return`${s}${r}${o}${u.trim()?`
56
+ ${r}`:""}`}default:{let o=e?`${a("cyan",y)} `:"",r=e?a("cyan",U):"";return`${s}${o}${n}
55
57
  ${r}
56
- `}}}}).prompt();var ze=!process.env.NO_COLOR&&!!process.stdout.isTTY,ut=(t,e)=>ze?`\x1B[${t}m${e}\x1B[0m`:e,at=t=>ut("1",t),W=t=>ut("2",t),wt=t=>ut("32",t),Xe=t=>ut("33",t);function Qe(t,e=24){let s=Math.max(0,Math.min(100,Math.round(t))),i=Math.round(s/100*e);return`${"\u2501".repeat(i)}${"\u2500".repeat(e-i)}`}function Ze(t){return[at(t.title),wt(t.detail),...t.action?[W(t.action)]:[]].join(`
57
- `)}function Qt(t){let e=t.confirmed&&t.confirmed>0?W(`${t.confirmed} fix${t.confirmed===1?"":"es"} measured since you applied them \u2014 run caveman learn --all`):void 0;if(t.score===null)return[t.sessions,...t.status?[t.status]:[],...(t.trend??[]).map(W),...e?[e]:[]].join(`
58
- `);let s=Math.max(0,Math.min(100,Math.round(t.score)));return[`${wt(Qe(s))} ${at(`${s}/100`)}`,...e?[e]:[],W(t.scope),t.sessions,...t.diff?[Xe(t.diff)]:[],...(t.trend??[]).map(W)].join(`
59
- `)}function Ws(){let t=zt();return{start(e){t.start(e)},update(e){t.message(e)},stop(e){t.stop(e)},fail(e){t.error(e)}}}async function Us(t){let e=await yt({message:"Implement findings with",options:t});return U(e)?(nt("Implementation cancelled"),null):e}async function Bs(t){if(Yt(`${wt(at(" CAVEMAN "))} ${W("LEARN / LOCAL SETUP")}`),t.score!==null?ot(Qt(t),"SETUP SCORE"):ot(Qt(t),"LEARN RESULT"),t.moves.length>0){let i=t.moves.map((o,u)=>`${W(String(u+1).padStart(2,"0"))} ${Ze(o)}`);ot(i.join(`
58
+ `}}}}).prompt();var Xe=!process.env.NO_COLOR&&!!process.stdout.isTTY,lt=(t,e)=>Xe?`\x1B[${t}m${e}\x1B[0m`:e,ut=t=>lt("1",t),W=t=>lt("2",t),wt=t=>lt("32",t),Qe=t=>lt("33",t);function Ze(t,e=24){let s=Math.max(0,Math.min(100,Math.round(t))),i=Math.round(s/100*e);return`${"\u2501".repeat(i)}${"\u2500".repeat(e-i)}`}function ts(t){return[ut(t.title),wt(t.detail),...t.action?[W(t.action)]:[]].join(`
59
+ `)}function Zt(t){let e=t.confirmed&&t.confirmed>0?W(`${t.confirmed} fix${t.confirmed===1?"":"es"} measured since you applied them \u2014 run caveman learn --all`):void 0;if(t.score===null)return[t.sessions,...t.status?[t.status]:[],...(t.trend??[]).map(W),...e?[e]:[]].join(`
60
+ `);let s=Math.max(0,Math.min(100,Math.round(t.score)));return[`${wt(Ze(s))} ${ut(`${s}/100`)}`,...e?[e]:[],W(t.scope),t.sessions,...t.diff?[Qe(t.diff)]:[],...(t.trend??[]).map(W)].join(`
61
+ `)}function Ws(){let t=Xt();return{start(e){t.start(e)},update(e){t.message(e)},stop(e){t.stop(e)},fail(e){t.error(e)}}}async function Bs(t){let e=await yt({message:"Implement findings with",options:t});return B(e)?(ot("Implementation cancelled"),null):e}async function Ks(t){if(zt(`${wt(ut(" CAVEMAN "))} ${W("LEARN / LOCAL SETUP")}`),t.score!==null?at(Zt(t),"SETUP SCORE"):at(Zt(t),"LEARN RESULT"),t.moves.length>0){let i=t.moves.map((n,u)=>`${W(String(u+1).padStart(2,"0"))} ${ts(n)}`);at(i.join(`
60
62
 
61
- `),"TOP FINDINGS")}t.protected&&G.warn(`${at("Needed")} ${t.protected}`),t.memory&&G.info(t.memory);let e=[];t.moves.length>0&&e.push({value:"implement",label:"Implement with agent",hint:"Claude Code or Codex \xB7 asks before every edit"}),t.findings>0&&e.push({value:"details",label:`Show all ${t.findings} findings`,hint:"ids, evidence, and suggested fixes"}),e.push({value:"report",label:"Open visual report",hint:t.report},{value:"done",label:"Done"});let s=await yt({message:"Choose next step",initialValue:t.moves.length>0?"implement":"report",options:e});if(U(s))return nt("Done"),{action:"done"};if(s==="implement"){let i=await Xt({message:"Anything the agent should focus on?",placeholder:"Press Enter to work through all top findings",defaultValue:""});return U(i)?(nt("Implementation cancelled"),{action:"done"}):(J("Opening implementation agent"),i.trim()?{action:"implement",focus:i.trim()}:{action:"implement"})}else s==="details"?J("Showing complete findings"):s==="report"?J("Opening local report"):J(`Saved report \xB7 ${t.report}`);return{action:s}}export{Ws as createLearnProgress,Ze as learnMoveBody,Qe as learnScoreBar,Qt as learnScoreBody,Bs as renderLearnTui,Us as selectLearnAgent};
63
+ `),"TOP FINDINGS")}t.protected&&G.warn(`${ut("Needed")} ${t.protected}`),t.memory&&G.info(t.memory);let e=[];t.moves.length>0&&e.push({value:"implement",label:"Implement with agent",hint:"Claude Code or Codex \xB7 asks before every edit"}),t.findings>0&&e.push({value:"details",label:`Show all ${t.findings} findings`,hint:"ids, evidence, and suggested fixes"}),e.push({value:"report",label:"Open visual report",hint:t.report},{value:"done",label:"Done"});let s=await yt({message:"Choose next step",initialValue:t.moves.length>0?"implement":"report",options:e});if(B(s))return ot("Done"),{action:"done"};if(s==="implement"){let i=await Qt({message:"Anything the agent should focus on?",placeholder:"Press Enter to work through all top findings",defaultValue:""});return B(i)?(ot("Implementation cancelled"),{action:"done"}):(Y("Opening implementation agent"),i.trim()?{action:"implement",focus:i.trim()}:{action:"implement"})}else s==="details"?Y("Showing complete findings"):s==="report"?Y("Opening local report"):Y(`Saved report \xB7 ${t.report}`);return{action:s}}export{Ws as createLearnProgress,ts as learnMoveBody,Ze as learnScoreBar,Zt as learnScoreBody,Ks as renderLearnTui,Bs as selectLearnAgent};
@@ -43,6 +43,9 @@ export async function modulesDoctor() {
43
43
  const down = await h.runtimeDown();
44
44
  if (down)
45
45
  failures.push(down);
46
+ const store = h.recoveryStoreProblem();
47
+ if (store)
48
+ failures.push(store);
46
49
  const wired = h.nativeAgents().filter((agent) => agent.wired);
47
50
  for (const agent of wired) {
48
51
  const state = h.agentState(agent.id);
@@ -82,10 +82,16 @@ export function verifiedProviderRoute(gateway, api, provider, originalBaseUrl, p
82
82
  const upstream = endpoint(mount);
83
83
  if (!upstream || family === 'gemini')
84
84
  return undefined;
85
- const suffix = family === 'openai' ? '/v1' : '';
86
- if (compatTarget(upstream, suffix + operation) !== expected)
87
- return undefined;
88
- return trimTrailingSlashes(gateway) + `/compat/${provider}${suffix}`;
85
+ // A mount forwards any path after /compat/<name>, so an OpenAI base with no
86
+ // /v1 (DeepSeek's api.deepseek.com, Z.ai's .../paas/v4) is served without
87
+ // one. Trying /v1 first keeps every route that verified before unchanged.
88
+ const suffixes = family === 'openai' ? ['/v1', ''] : [''];
89
+ for (const suffix of suffixes) {
90
+ if (compatTarget(upstream, suffix + operation) === expected) {
91
+ return trimTrailingSlashes(gateway) + `/compat/${provider}${suffix}`;
92
+ }
93
+ }
94
+ return undefined;
89
95
  }
90
96
  const upstream = endpoint(published?.provider_upstreams?.[family]);
91
97
  if (!upstream)
@@ -103,7 +109,7 @@ export function verifiedProviderRoute(gateway, api, provider, originalBaseUrl, p
103
109
  // preserving them in an overlay alone does not make the proxy forward them.
104
110
  const COPIED_HEADERS = ["content-type", "content-encoding", "accept", "accept-encoding", "idempotency-key", "openai-organization", "openai-project", "session_id", "x-session-id", "x-client-request-id", "x-session-affinity", "anthropic-version", "anthropic-beta", "api-version", "user-agent"];
105
111
  const COMPAT_HEADERS = {
106
- openrouter: ["http-referer", "x-openrouter-title", "x-openrouter-categories"],
112
+ openrouter: ["http-referer", "x-title", "x-openrouter-title", "x-openrouter-categories"],
107
113
  nvidia: ["x-billing-invoke-origin"],
108
114
  opencode: ["x-opencode-session", "x-opencode-client", "x-opencode-project", "x-opencode-request"],
109
115
  "opencode-go": ["x-opencode-session", "x-opencode-client", "x-opencode-project", "x-opencode-request"],
@@ -12,7 +12,6 @@ export const RESERVED_VERBS = new Set([
12
12
  "convert",
13
13
  "costs",
14
14
  "deploy",
15
- "dev",
16
15
  "disable",
17
16
  "doctor",
18
17
  "enable",
@@ -1,6 +1,6 @@
1
- // Pinned mirror of cloud/internal/verifiedmethod.Methods(). DO NOT EDIT.
2
- // The receipt runtime contract test fails if this list drifts from the Go
3
- // registry that signs and ingests billable receipts.
1
+ // Pinned mirror of the Caveman Cloud verified-method registry. DO NOT EDIT.
2
+ // Where that Go registry (which signs and ingests billable receipts) is present,
3
+ // the receipts runtime test fails if this list drifts from it.
4
4
  export const VERIFIED_SAVINGS_METHODS = [
5
5
  "provider_causal_cache",
6
6
  "provider_causal_cache_bedrock",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@caveman-ai/cli",
3
- "version": "4.0.1",
3
+ "version": "4.2.0",
4
4
  "description": "Caveman CLI — wrap coding agents with recoverable local context compression and truthful metering (`caveman claude`), then drive Caveman Cloud from terminal. Compression and metering run in companion Go binaries: run `caveman setup` to see install state. Local savings stay inferred until verified.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -28,9 +28,9 @@
28
28
  ],
29
29
  "dependencies": {},
30
30
  "devDependencies": {
31
- "@clack/prompts": "1.7.0",
32
- "@types/node": "24.10.1",
33
- "esbuild": "0.28.1",
31
+ "@clack/prompts": "1.8.1",
32
+ "@types/node": "24.19.2",
33
+ "esbuild": "0.28.2",
34
34
  "typescript": "5.9.3"
35
35
  },
36
36
  "scripts": {