klaudius 0.29.1 → 0.30.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.
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as d,m as $,n as ne,p as k}from"./chunk-
|
|
1
|
+
import{a as d,m as $,n as ne,p as k}from"./chunk-LF3CA26Y.js";import{useEffect as Ue,useMemo as Ne,useRef as ee,useState as I}from"react";import{Box as h,Text as w,useApp as De,useInput as Ve}from"ink";import{Box as ie,Text as be}from"ink";import{jsx as se,jsxs as ve}from"react/jsx-runtime";var he={pending:"\u25CB",current:"\u25C9",done:"\u2713",skipped:"\xB7"},Be={pending:void 0,current:"cyan",done:"green",skipped:void 0};function ce({items:e}){return se(ie,{flexDirection:"column",width:28,flexShrink:0,children:e.map(r=>{let o=r.status==="skipped"||r.status==="pending";return se(ie,{children:ve(be,{color:Be[r.status],bold:r.status==="current",dimColor:o&&r.status!=="current",children:[he[r.status]," ",r.title]})},r.id)})})}import{useEffect as ye,useState as ae}from"react";import{Box as H,Text as N,useInput as we}from"ink";import ke from"ink-text-input";import{jsx as E,jsxs as X}from"react/jsx-runtime";function le({spec:e,masked:r,onSubmit:o,onBack:t}){let p=typeof e.initialValue=="string"?e.initialValue:"",s=r&&p.length>0,[c,x]=ae(s?"":p),[f,i]=ae(null);ye(()=>(d("TextPromptUI:mount",{masked:r,message:e.message.slice(0,60),initial:typeof e.initialValue=="string"?e.initialValue.slice(0,30):null}),()=>{d("TextPromptUI:unmount")}),[r,e.message,e.initialValue]),we((n,S)=>{d("TextPromptUI:useInput fired",{input:n,ctrl:S.ctrl,escape:S.escape,return:S.return}),S.escape&&t()});let P=n=>{d("TextPromptUI:handleSubmit",{raw:n.slice(0,30)});let S=n.length===0&&s?p:n;if(e.validate){let B=e.validate(S);if(B){d("TextPromptUI:validate failed",{err:B}),i(B);return}}i(null),o(S)};return X(H,{flexDirection:"column",children:[X(N,{children:[E(N,{color:"cyan",children:"?"})," ",e.message]}),X(H,{children:[E(N,{color:"green",children:"\u203A "}),E(ke,{value:c,onChange:x,onSubmit:P,placeholder:s?"type or paste a new value \u2014 or press Enter to keep the current one":e.placeholder,mask:r?"\u2022":void 0})]}),f&&E(H,{marginTop:0,children:E(N,{color:"red",children:f})})]})}import{useState as Ie}from"react";import{Box as G,Text as D,useInput as Ae}from"ink";import{jsx as V,jsxs as K}from"react/jsx-runtime";function pe({spec:e,onSubmit:r,onBack:o}){let t=e.options??[],p=typeof e.initialValue=="string"?Math.max(0,t.findIndex(x=>x.value===e.initialValue)):0,[s,c]=Ie(p===-1?0:p);return Ae((x,f)=>{if(f.escape)o();else if(f.upArrow)c(i=>(i-1+t.length)%t.length);else if(f.downArrow)c(i=>(i+1)%t.length);else if(f.return){let i=t[s];i&&r(i.value)}}),K(G,{flexDirection:"column",children:[K(D,{children:[V(D,{color:"cyan",children:"?"})," ",e.message]}),V(G,{flexDirection:"column",marginTop:0,children:t.map((x,f)=>{let i=f===s;return K(D,{color:i?"cyan":void 0,bold:i,children:[i?"\u25CF ":"\u25CB ",x.label]},x.value)})}),V(G,{marginTop:1,children:V(D,{dimColor:!0,children:"Use the \u2191 \u2193 arrow keys to choose, then press Enter"})})]})}import{useState as Re}from"react";import{Box as q,Text as A,useInput as Ce}from"ink";import{jsx as W,jsxs as z}from"react/jsx-runtime";function ue({spec:e,onSubmit:r,onBack:o}){let[t,p]=Re(typeof e.initialValue=="boolean"?e.initialValue:!0);return Ce((s,c)=>{c.escape?o():c.leftArrow||c.rightArrow?p(x=>!x):s==="y"||s==="Y"?p(!0):s==="n"||s==="N"?p(!1):c.return&&r(t)}),z(q,{flexDirection:"column",children:[z(A,{children:[W(A,{color:"cyan",children:"?"})," ",e.message]}),z(q,{marginTop:0,children:[z(A,{color:t?"cyan":void 0,bold:t,children:[t?"\u25CF ":"\u25CB ","Yes"]}),W(A,{children:" "}),z(A,{color:t?void 0:"cyan",bold:!t,children:[t?"\u25CB ":"\u25CF ","No"]})]}),W(q,{marginTop:1,children:W(A,{dimColor:!0,children:"Use the \u2190 \u2192 arrow keys (or y / n) to choose, then press Enter"})})]})}import{useState as me}from"react";import{Box as J,Text as O,useInput as Ee}from"ink";import{jsx as M,jsxs as Q}from"react/jsx-runtime";function de({spec:e,onSubmit:r,onBack:o}){let t=e.options??[],p=new Set(typeof e.initialValue=="string"?e.initialValue.split(",").map(i=>i.trim()).filter(Boolean):[]),[s,c]=me(0),[x,f]=me(p);return Ee((i,P)=>{if(P.escape)o();else if(P.upArrow)c(n=>(n-1+t.length)%t.length);else if(P.downArrow)c(n=>(n+1)%t.length);else if(i===" "){let n=t[s];n&&f(S=>{let B=new Set(S);return B.has(n.value)?B.delete(n.value):B.add(n.value),B})}else P.return&&r(t.map(n=>n.value).filter(n=>x.has(n)).join(","))}),Q(J,{flexDirection:"column",children:[Q(O,{children:[M(O,{color:"cyan",children:"?"})," ",e.message]}),M(J,{flexDirection:"column",marginTop:0,children:t.map((i,P)=>{let n=P===s,S=x.has(i.value);return Q(O,{color:n?"cyan":void 0,bold:n,children:[n?"\u203A ":" ",S?"\u25C9 ":"\u25EF ",i.label]},i.value)})}),M(J,{marginTop:1,children:M(O,{dimColor:!0,children:"\u2191 \u2193 to move, Space to tick/untick, Enter to confirm (ticking none is fine)"})})]})}import{Box as fe,Text as ge}from"ink";import{jsx as Z,jsxs as ze}from"react/jsx-runtime";function _({title:e,body:r}){let o=r.split(`
|
|
2
2
|
`);return ze(fe,{flexDirection:"column",borderStyle:"round",borderColor:"gray",paddingX:1,children:[Z(ge,{color:"cyan",bold:!0,children:e}),Z(fe,{flexDirection:"column",marginTop:0,children:o.map((t,p)=>Z(ge,{dimColor:!1,children:t.length===0?" ":t},p))})]})}import{jsx as l,jsxs as U}from"react/jsx-runtime";function yt({defaults:e,onComplete:r,onlySection:o,banner:t}){let{exit:p}=De(),s=ee({...e}),c=ee(new Map),[,x]=I(0),f=()=>x(u=>u+1),[i,P]=I(null),[n,S]=I(null),[B,te]=I([]),[F,re]=I(null),[oe,xe]=I(!1),[j,Se]=I({current:0,total:0}),R=()=>{let u=c.current;for(let g of k){let Y=g.isApplicable(s.current),a=u.get(g.id);Y?o&&g.id!==o?a!=="current"&&u.set(g.id,"done"):(a==="skipped"||!a)&&u.set(g.id,"pending"):u.set(g.id,"skipped")}};c.current.size===0&&R();let L=ee(!1);Ue(()=>{if(d("WizardApp:useEffect fired",{startedAlready:L.current}),L.current){d("WizardApp:useEffect returning early (startedRef true)");return}L.current=!0,d("WizardApp:orchestrator starting");let u=0,g=a=>{let v=++u;return d("orchestrator:promptFn called",{id:v,type:a.type,message:a.message.slice(0,60)}),re(null),new Promise((T,m)=>{S({id:v,spec:a,resolve:y=>{d("orchestrator:prompt resolved",{id:v,type:a.type,value:typeof y=="string"?y.slice(0,30):y}),T(y)},reject:y=>{d("orchestrator:prompt rejected",{id:v,reason:y.message}),m(y)}})})},Y=a=>{te(v=>[...v,a])};return(async()=>{try{let a=o?k.filter(m=>m.id===o):k,v=()=>a.filter(m=>m.isApplicable(s.current)).length,T=0;for(;T<a.length;){let m=a[T];if(!m.isApplicable(s.current)){c.current.set(m.id,"skipped"),T++,R(),f();continue}te([]);for(let b of k)b.id===m.id?c.current.set(b.id,"current"):c.current.get(b.id)==="current"&&c.current.set(b.id,"pending");P(m.id);let y=a.slice(0,T+1).filter(b=>b.isApplicable(s.current)).length;Se({current:y,total:v()}),f();try{let b=await m.execute(s.current,{prompt:g,info:Y});s.current={...s.current,...b},c.current.set(m.id,"done"),R(),T++}catch(b){if(b instanceof $){if(o&&m.clearOnSkip){for(let Te of m.clearOnSkip)s.current[Te]=void 0;c.current.set(m.id,"skipped"),R(),T++;continue}if(o)continue;c.current.set(m.id,"pending");let C=T-1;for(;C>=0&&!a[C].isApplicable(s.current);)C--;C<0||(T=C,c.current.set(a[T].id,"pending")),R(),f();continue}throw b}}d("orchestrator:all sections done, calling onComplete + exit"),xe(!0),S(null),P(null),f(),await new Promise(m=>setTimeout(m,200)),r(s.current),p()}catch(a){d("orchestrator:caught error",{name:a?.name,message:a?.message}),a instanceof ne&&(p(),process.exit(0));let v=a instanceof Error?a.message:String(a);re(`Setup error: ${v}`),f()}})(),()=>{d("WizardApp:useEffect cleanup ran (component unmounting)")}},[p,r]),Ve((u,g)=>{d("WizardApp:useInput fired",{input:u,ctrl:g.ctrl,escape:g.escape,return:g.return}),g.ctrl&&u==="c"&&(d("WizardApp:Ctrl+C \u2192 exiting"),p(),process.exit(0))});let Pe=Ne(()=>k.map(u=>({id:u.id,title:u.title,status:c.current.get(u.id)??"pending"})),[i,oe,F]);return U(h,{flexDirection:"column",paddingY:1,children:[U(h,{marginBottom:1,children:[l(w,{bold:!0,color:"cyan",children:"Klaudius setup"}),l(w,{dimColor:!0,children:" \xB7 "}),l(w,{dimColor:!0,children:j.total>0?`Step ${j.current} of ${j.total}`:"Loading\u2026"})]}),U(h,{children:[l(ce,{items:Pe}),U(h,{flexDirection:"column",flexGrow:1,marginLeft:2,children:[t&&U(h,{marginBottom:1,borderStyle:"round",borderColor:"red",paddingX:1,flexDirection:"column",children:[l(w,{color:"red",bold:!0,children:"\u26A0 Heads up"}),l(w,{children:t})]}),!o&&i!==null&&i!=="ai-agent"&&l(h,{marginBottom:1,children:l(w,{color:"green",children:"Nothing here is permanent, you can customize any of this later."})}),B.map((u,g)=>l(h,{marginBottom:1,children:l(_,{title:u.title,body:u.body})},g)),n?.spec.note&&l(h,{marginBottom:1,children:l(_,{title:n.spec.note.title,body:n.spec.note.body})}),n&&Oe(n),F&&l(h,{marginTop:1,children:l(w,{color:"red",children:F})}),oe&&l(h,{marginTop:1,children:l(w,{color:"green",bold:!0,children:"\u2713 Setup complete. Continuing\u2026"})})]})]}),l(h,{marginTop:1,children:l(w,{dimColor:!0,children:We(o,i)})})]})}function We(e,r){if(e){let o=k.find(t=>t.id===r);return o?.clearOnSkip&&o.clearOnSkip.length>0?"\u21B5 confirm esc skip this section ctrl-c cancel":"\u21B5 confirm ctrl-c cancel"}return"\u21B5 confirm esc back to previous section ctrl-c cancel"}function Oe(e){let r=t=>e.resolve(t),o=()=>e.reject(new $);switch(e.spec.type){case"text":case"password":return l(le,{spec:e.spec,masked:e.spec.type==="password",onSubmit:r,onBack:o},e.id);case"select":return l(pe,{spec:e.spec,onSubmit:r,onBack:o},e.id);case"multiselect":return l(de,{spec:e.spec,onSubmit:r,onBack:o},e.id);case"confirm":return l(ue,{spec:e.spec,onSubmit:r,onBack:o},e.id)}}export{yt as WizardApp};
|