@ciandt-flow/cli 2.1.1-beta.231 → 2.1.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/index.js +3 -3
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -113,7 +113,7 @@ If a marketplace is needed, enter the source (owner/repo or URL), or press Enter
|
|
|
113
113
|
This will run: ${i}
|
|
114
114
|
[y/N] `))return ls.debug(`[${e}] Installation cancelled by user`),T("Operation cancelled."),0}let o=r.silent?void 0:Ea({text:`Adding MCP "${h(e)}"...`}).start();try{let s=await we(n);return o?.stop(),s.exitCode!==0?(Hn(r,{name:e,action:"add",message:s.stderr||"Command failed",exitCode:s.exitCode}),!r.silent&&r.verbose&&s.stdout&&T(`stdout: ${s.stdout}`),1):(ku(r,{name:e,actionPastTense:"added",command:n,durationMs:s.duration_ms,stdout:s.stdout}),0)}catch(s){return o?.stop(),Hn(r,{name:e,action:"add",message:Q(s)}),1}}async function $u(e,t){if(!await fe())return 1;ls.debug(`[${e}] Starting MCP remove`);let r=qi(e,t.scope);if(!t.force){let o=h(e),s=h(r);if(!await gt(`Remove MCP "${o}"?
|
|
115
115
|
This will run: ${s}
|
|
116
|
-
[y/N] `))return ls.debug(`[${e}] Removal cancelled by user`),T("Operation cancelled."),0}let n=t.silent?void 0:Ea({text:`Removing MCP "${h(e)}"...`}).start();try{let o=await we(r);return n?.stop(),o.exitCode!==0?(Hn(t,{name:e,action:"remove",message:o.stderr||"Command failed",exitCode:o.exitCode}),!t.silent&&t.verbose&&o.stdout&&T(`stdout: ${o.stdout}`),1):(ku(t,{name:e,actionPastTense:"removed",command:r,durationMs:o.duration_ms,stdout:o.stdout}),0)}catch(o){return n?.stop(),Hn(t,{name:e,action:"remove",message:Q(o)}),1}}function Mu({selectedItem:e,selectedCatalogItem:t,items:r,closeMenu:n,clampIndex:o,notify:s}){let i=I("pluginHandlers"),a=S(C=>C.setLoading),{install:l,uninstall:u,toggle:c,update:d}=Tu(),p=async(C,k,$)=>{a(true,C),n();try{await k(),o(r.length),s($,"success");}catch(O){let G=O instanceof Error?O.message:"Something went wrong";i.error(`[withLoading] ${C} failed: ${G}`),s(G,"error");}finally{a(false);}};return {handleInstall:(C,k)=>{e&&t&&p(`Installing ${e.name}...`,()=>l(t,{scope:C,...k!==void 0?{providerId:k}:{}}),"\u2713 Installed successfully");},handleUninstall:C=>{e&&p(`Uninstalling ${e.name}...`,()=>u(e.name,C),"\u2713 Uninstalled");},handleToggleStatus:C=>{if(!e)return;let k=e.status==="enabled";p(k?`Disabling ${e.name}...`:`Enabling ${e.name}...`,()=>c(e.name,C),k?"\u2713 Disabled":"\u2713 Enabled");},handleUpdate:()=>{if(!e)return;let C=t?` to v${t.version}`:"";(async()=>{a(true,`Updating ${e.name}${C}...`),n();try{await d(e.name),o(r.length),s(`\u2713 Updated ${e.name}${C}`,"success");}catch($){if($ instanceof zt)s($.message,"info");else {let O=$ instanceof Error?$.message:"Something went wrong";i.error(`[handleUpdate] ${e.name} failed: ${O}`),s(O,"error");}}finally{a(false);}})();},handleBatchUpdate:C=>{if(C.length===0)return;let k=C.length;(async()=>{a(true,`Updating ${k} plugin${k>1?"s":""}...`),n();try{let O=[];for(let M of C)O.push(await d(M.name).then(()=>({status:"fulfilled",value:void 0}),x=>({status:"rejected",reason:x})));let G=O.filter(M=>M.status==="fulfilled").length,he=O.map((M,x)=>M.status==="rejected"?C[x].name:null).filter(M=>M!==null);o(r.length),he.length===0?s(`\u2713 Updated ${G}/${k} plugin${k>1?"s":""}`,"success"):(i.error(`[handleBatchUpdate] failed: ${he.join(", ")}`),s(`Updated ${G}/${k}; failed: ${he.join(", ")}`,G>0?"info":"error"));}finally{a(false);}})();},handleMcpConfigUninstall:C=>{e&&p(`Removing MCP ${e.name}...`,async()=>{let k=qi(e.name,C),$=await we(k);if($.exitCode!==0)throw new Error($.stderr||"MCP removal failed");ue.getState().loadFromDisk();},"\u2713 MCP removed");}}}var cs=I("api:bundle"),en=class extends Error{constructor(t){super(`Bundle '${t}' not found in your tenant. Verify the name with whoever shared the command.`),this.name="BundleNotFoundError";}},Jn=class extends Error{constructor(){super("The server encountered an error while fetching the bundle. Please try again later."),this.name="BundleServerError";}};async function us(e){let t=encodeURIComponent(e);cs.debug(`Fetching bundle by name "${e}"`);let r;try{r=await mt().get(`v1/use-cases/by-name/${t}`).json(),cs.debug(`API returned ${r.length} result(s) for "${e}"`);}catch(n){if(n instanceof HTTPError){let o=n.response.status;throw cs.error(`HTTP error fetching bundle '${e}' [status=${o}]`),o===StatusCodes.NOT_FOUND?new en(e):o===StatusCodes.INTERNAL_SERVER_ERROR?new Jn:new Error(`Server error (${o}) \u2014 please try again later.`)}throw cs.error(`Unexpected error fetching bundle '${e}': ${n instanceof Error?n.message:String(n)}`),n}if(r.length===0)throw new en(e);return r[0]}function Ru({closeMenu:e,notify:t}){let r=S(a=>a.bundleInstallFlow);return {handleBundleInstallStart:a=>{let{setLoading:l,setBundleInstallFlow:u}=S.getState();l(true,"Loading bundle..."),us(a).then(c=>{l(false),S.getState().actionMenuOpen&&u({phase:"detail",bundle:c});}).catch(c=>{l(false),t(c instanceof Error?c.message:"Failed to load bundle","error");});},handleBundleDetailConfirm:()=>{if(!r||r.phase!=="detail")return;let{setBundleInstallFlow:a,setFocus:l}=S.getState();a({phase:"installing",bundle:r.bundle}),l("bundleInstallProgress");},handleBundleDetailBack:()=>{let{setBundleInstallFlow:a}=S.getState();a(null),e();},handleBundleInstallComplete:a=>{S.getState().setBundleInstallFlow(null),e(),ue.getState().loadFromDisk(),t(`\u2713 Installed ${a.installed} of ${a.total} artifacts`,"success");}}}var Gn=["local","project","user"],Yy=new Set(["--transport","--scope","-s"]);function _u(e){let t=e.split(/\s+/).filter(Boolean),r=t.indexOf("add");if(r===-1)return null;let n=r+1;for(;n<t.length;){let o=t[n];if(Yy.has(o))n+=2;else if(o.startsWith("-"))n+=1;else return o.replace(/^["']|["']$/g,"")}return null}function br(e,t){return t?`${e}::${t}`:e}function Yi(e){return e===re?pn:kr}function Du(e){return {name:h(e.name),version:e.version?h(e.version):e.version,description:e.description?h(e.description):e.description,authorName:e.author?.name?h(e.author.name):e.author?.name,updateAvailable:e.updateAvailable,type:e.type??"bundle",origin:e.origin??pn}}function Zi(e,t){let r=Yi(e.marketplace);return {name:h(e.name),version:e.version?h(e.version):e.version,description:e.description?h(e.description):e.description,authorName:e.author?.name?h(e.author.name):e.author?.name,status:e.status,scope:e.scope,marketplace:e.marketplace,updateAvailable:e.updateAvailable,installedAt:e.installedAt,type:t?.type??e.type??"bundle",origin:t?.origin??r}}function Ou(e){let t=new Map;for(let r of e){if(!r.scope)continue;let n=t.get(r.scope)??[];n.push(r),t.set(r.scope,n);}return Gn.filter(r=>t.has(r)).map(r=>({scope:r,label:mn[r].label,pathHint:mn[r].pathHint,items:t.get(r)??[]}))}function Nu(e){let t=r=>{if(!r)return 1/0;let n=Gn.indexOf(r);return n===-1?1/0:n};return [...e].sort((r,n)=>t(r.scope)-t(n.scope))}function Bu({catalog:e,installedItems:t,activeTab:r,catalogFilters:n,searchQuery:o}){let s=useMemo(()=>new Set(t.map(f=>br(f.name,f.author?.name))),[t]),i=useMemo(()=>new Set(t.filter(f=>f.type==="mcp").map(f=>f.name.toLowerCase())),[t]),a=useMemo(()=>{let f=new Map(e.map(y=>[br(y.name,y.author?.name),y])),g=new Map(e.map(y=>[y.name,y]));return t.map(y=>{let w=f.get(br(y.name,y.author?.name))??g.get(y.name),P=w?.version,C=!!P&&!!y.version&&Te(y.version,P);return {...y,updateAvailable:C,catalogItem:w}})},[t,e]),l=useMemo(()=>r==="discover"?e.filter(f=>{if(s.has(br(f.name,f.author?.name)))return false;if(f.type==="mcp"){let g=f.installCommand?_u(f.installCommand)?.toLowerCase():null;if(i.has(f.name.toLowerCase())||g&&i.has(g))return false}return true}).map(f=>Du(f)):r==="updates"?a.filter(f=>f.updateAvailable).map(f=>Zi(f,f.catalogItem)):a.map(f=>Zi(f,f.catalogItem)),[r,e,s,i,a]),u=useMemo(()=>l.filter(f=>{let g=f.type??"bundle";if(!n.types.has(g))return false;let y=f.origin??"internal";return n.origins.has(y)}),[l,n]),c=useMemo(()=>{let{types:f}=n;if(f.size===1){if(f.has("skill"))return "skills";if(f.has("mcp"))return "MCPs";if(f.has("bundle"))return "bundles"}return "items"},[n]),d=useMemo(()=>r==="installed"?o?`No ${c} found for '${o}' \u2014 explore the Discover tab!`:`No ${c} installed \u2014 explore the Discover tab!`:r==="updates"?o?`No ${c} found for '${o}' \u2014 all up to date!`:"All up to date \u2014 nothing to update":o?`No ${c} found for '${o}'`:`No ${c} available in the catalog`,[r,o,c]),p=useMemo(()=>{let f=new Map(e.map(y=>[br(y.name,y.author?.name),y])),g=new Map(e.map(y=>[y.name,y]));return y=>y?f.get(br(y.name,y.authorName))??g.get(y.name)??null:null},[e]),m=useMemo(()=>a.filter(f=>f.updateAvailable).length,[a]);return {items:u,emptyMessage:d,getSelectedCatalogItem:p,outdatedCount:m}}function Qi(){let[e,t]=useState([]),[r,n]=useState(true),[o,s]=useState(null),[i,a]=useState(null),l=useRef(false),u=S(d=>d.catalogVersion),c=useCallback(async()=>{n(true),s(null),a(null);try{let{items:d,failures:p}=await pc();if(t(d),p.length>0){let m=p.map(f=>f.adapterName).join(", ");a(`Some catalogs failed to load: ${m}`);}l.current||(l.current=!0,b(v.CLI_CATALOG_VIEWED,{interface:"tui",filter_type:"all",result_count:d.length}).catch(()=>{}));}catch(d){s(d instanceof Error?d:new Error(String(d))),t([]);}finally{n(false);}},[]);return useEffect(()=>{c();},[c,u]),{catalog:e,isLoading:r,error:o,partialError:i,refetch:c}}function Uu(){return {items:ue(t=>t.installedItems)}}var rh=I("catalog");function ju(){let e=S(Z=>Z.bundleInstallFlow),t=S(Z=>Z.activeTab),r=S(Z=>Z.notification),n=S(Z=>Z.loading),o=S(Z=>Z.loadingMessage),s=S(Z=>Z.catalogError),i=S(Z=>Z.setCatalogError),a=S(Z=>Z.catalogFilters),l=Oe(Z=>Z.query),{catalog:u,isLoading:c,error:d,refetch:p}=Qi(),{items:m}=Uu(),f=ue(Z=>Z.loadFromDisk),{items:g,emptyMessage:y,getSelectedCatalogItem:w,outdatedCount:P}=Bu({catalog:u,installedItems:m,activeTab:t,catalogFilters:a,searchQuery:l}),{actionMenuOpen:C,closeMenu:k,selectedIndex:$,clampIndex:O,filteredItems:G}=Iu({listLength:g.length}),he=G(g),M=useMemo(()=>t!=="installed"&&t!=="updates"?he:Nu(he),[t,he]),x=useMemo(()=>t==="installed"||t==="updates"?Ou(M):[],[t,M]),A=M[$]??null,F=useMemo(()=>w(A),[w,A]),{notify:W}=bu(),{handleInstall:Et,handleUninstall:dn,handleToggleStatus:L,handleUpdate:N,handleBatchUpdate:V,handleMcpConfigUninstall:Ie}=Mu({selectedItem:A,selectedCatalogItem:F,items:g,closeMenu:k,clampIndex:O,notify:W}),{handleBundleInstallStart:Ns,handleBundleDetailConfirm:Gp,handleBundleDetailBack:Wp,handleBundleInstallComplete:zp}=Ru({closeMenu:k,notify:W}),Xp=useCallback(()=>V(M),[V,M]);return useEffect(()=>{f();},[]),useEffect(()=>{O(M.length);},[M.length,O]),useEffect(()=>{d&&(rh.error(`[catalog] ${d instanceof Error?d.message:String(d)}`),i("Failed to load catalog"));},[d]),jsxs(Box,{flexDirection:"column",borderStyle:"round",paddingX:1,children:[jsx(Nr,{}),jsx(Al,{outdatedCount:P}),t==="marketplaces"&&Gt()?jsx(Box,{flexDirection:"column",flexGrow:1,children:jsx(hu,{})}):jsx(Jl,{filteredItems:M,groups:x,emptyMessage:y,onBatchUpdate:Xp}),(n||c)&&jsx(Mo,{message:n?o:"Loading catalog..."}),s&&!c&&t==="discover"&&jsx(Lo,{message:s,onRetry:()=>{i(null),p();},onBack:()=>i(null)}),r&&jsx(Gl,{message:r.message,type:r.type}),C&&A&&(t==="discover"?F?.type==="bundle"?e?.phase==="installing"?jsx(nu,{bundle:e.bundle,onComplete:zp}):jsx(Jc,{itemName:A.name,bundle:e?.phase==="detail"?e.bundle:void 0,onInstall:()=>Ns(A.name),onConfirm:Gp,onClose:e?.phase==="detail"?Wp:k}):jsx(Vc,{itemName:A.name,itemType:F?.type,onInstall:Et,onClose:k}):A.type==="mcp"?jsx(Yc,{itemName:A.name,itemScope:A.scope??"user",onUninstall:Ie,onClose:k}):jsx(zc,{itemName:A.name,itemScope:A.scope??"user",itemStatus:A.status??"enabled",updateAvailable:A.updateAvailable??false,catalogVersion:F?.version,onUninstall:dn,onToggleStatus:Z=>L(Z),onUpdate:N,onClose:k})),jsx($o,{})]})}var _=create((e,t)=>({starterKits:[],selectedStarterKitIndex:0,selectedStarterKit:null,plugins:[],pluginCursorIndex:0,step:"starterKitList",isLoadingStarterKits:false,starterKitsError:null,successCount:0,failedCount:0,summaryActionIndex:0,setStarterKits:r=>e({starterKits:r}),setSelectedStarterKitIndex:r=>e({selectedStarterKitIndex:r}),selectStarterKit:r=>{let n=new Set(ue.getState().installedItems.map(o=>o.name));e({selectedStarterKit:r,plugins:r.plugins.map(o=>({name:o,selected:true,status:n.has(o)?"success":"pending",installed:n.has(o)})),pluginCursorIndex:0,step:"starterKitDetail"});},setPluginCursorIndex:r=>e({pluginCursorIndex:r}),setStep:r=>e({step:r}),setPluginStatus:(r,n,o)=>{let s=t().plugins.map(i=>i.name===r?{...i,status:n,error:o}:i);e({plugins:s});},setIsLoadingStarterKits:r=>e({isLoadingStarterKits:r}),setStarterKitsError:r=>e({starterKitsError:r}),setSummaryActionIndex:r=>e({summaryActionIndex:r}),computeSummary:()=>{let n=t().plugins.filter(o=>o.selected);e({successCount:n.filter(o=>o.status==="success").length,failedCount:n.filter(o=>o.status==="failed").length});},resetForRetry:()=>{let r=t().plugins.map(n=>n.status==="failed"?{...n,status:"pending",error:void 0}:n);e({plugins:r,step:"installing"});},goBackToList:()=>e({selectedStarterKit:null,plugins:[],pluginCursorIndex:0,step:"starterKitList"})}));var ih=3;function Vu(){let e=_(l=>l.setStarterKits),t=_(l=>l.setIsLoadingStarterKits),r=_(l=>l.setStarterKitsError),n=_(l=>l.setPluginStatus),o=_(l=>l.setStep),s=_(l=>l.computeSummary),i=useCallback(async()=>{t(true),r(null);try{let l=await Fo();e(l);}catch(l){r(l instanceof Error?l.message:String(l));}finally{t(false);}},[t,r,e]);useEffect(()=>{ue.getState().loadFromDisk(),i();},[i]);let a=useCallback(async()=>{let l=_.getState().plugins.filter(c=>c.selected&&c.status==="pending");for(let c of l){n(c.name,"installing");let d="",p=false;for(let m=1;m<=ih;m++)try{await Ee(c.name),n(c.name,"success"),p=!0;break}catch(f){if(f instanceof Ne){n(c.name,"success"),p=true;break}d=f instanceof Error?f.message:"Unknown error";}p||(n(c.name,"failed",d),b(v.CLI_TOOL_INSTALL_FAILED,{tool_id:c.name,tool_type:"skill",source:"internal",error_code:"install_failed",error_message:d,interface:H().interfaceType}).catch(()=>{}));}let u=pr();dr("summary_review"),b(v.CLI_STEP_COMPLETED,{step:"tool_installation",duration_ms:u}).catch(()=>{}),ue.getState().loadFromDisk(),s(),o("summary");},[n,s,o]);return {loadStarterKits:i,installSelected:a}}var Wn={cursorDelta:0,confirm:false,back:false};function Hu(e,t){return t.upArrow?{...Wn,cursorDelta:-1}:t.downArrow?{...Wn,cursorDelta:1}:t.escape?{...Wn,back:true}:t.return?{...Wn,confirm:true}:Wn}var ah={cursorDelta:0,select:false};function Ju(e,t){return t.upArrow?{cursorDelta:-1,select:false}:t.downArrow?{cursorDelta:1,select:false}:t.return?{cursorDelta:0,select:true}:ah}var Gu=vf.memo(function({starterKit:t,isSelected:r}){return jsxs(Box,{flexDirection:"column",paddingBottom:1,children:[jsxs(Box,{children:[jsx(Text,{color:r?"cyan":"gray",children:r?"\u203A ":"\u25CB "}),jsx(Text,{bold:r,color:r?"cyan":"white",children:h(t.name)}),jsxs(Text,{dimColor:true,children:[" \xB7 ",t.plugins.length," ",t.plugins.length===1?"plugin":"plugins"]})]}),jsx(Box,{paddingLeft:2,children:jsx(Text,{dimColor:true,children:h(t.description)})})]})});var sa=5;function Wu({onRetry:e}){let t=_(c=>c.starterKits),r=_(c=>c.selectedStarterKitIndex),n=_(c=>c.isLoadingStarterKits),o=_(c=>c.starterKitsError);if(n)return jsx(Mo,{message:"Loading Starter Kits..."});if(o)return jsx(Lo,{message:o,onRetry:e,onBack:e});if(t.length===0)return jsx(Br,{message:"No Starter Kits available."});let s=Math.max(0,r-Math.floor(sa/2)),i=Math.min(t.length,s+sa);i===t.length&&(s=Math.max(0,i-sa));let a=t.slice(s,i),l=s,u=t.length-i;return jsxs(Box,{flexDirection:"column",children:[jsx(Box,{paddingX:1,paddingBottom:1,children:jsx(Text,{bold:true,children:"Select a Starter Kit to get started"})}),l>0&&jsx(Box,{paddingX:2,children:jsxs(Text,{dimColor:true,children:["\u2191 ",l," more above"]})}),a.map((c,d)=>jsx(Gu,{starterKit:c,isSelected:s+d===r},c.slug)),u>0&&jsx(Box,{paddingX:2,children:jsxs(Text,{dimColor:true,children:["\u2193 ",u," more below"]})})]})}var Xu=vf.memo(function({plugin:t,isCursor:r}){return jsxs(Box,{children:[jsx(Text,{color:r?"cyan":"gray",children:r?"\u203A ":" "}),jsx(Text,{color:"cyan",children:"\u2022"}),jsxs(Text,{bold:r,color:r?"cyan":"white",children:[" ",h(t.name)]}),t.installed&&jsx(Text,{color:"green",children:" (installed)"})]})});var la=8;function qu(){let e=_(c=>c.selectedStarterKit),t=_(c=>c.plugins),r=_(c=>c.pluginCursorIndex),n=useRef(false);if(useEffect(()=>{e&&!n.current&&(n.current=true,b(v.CLI_KIT_DISPLAYED,{bundle_slug:e.slug,tool_count:t.length}).catch(()=>{}));},[e,t.length]),!e)return jsx(Text,{dimColor:true,children:"No Starter Kit selected."});let o=t.filter(c=>c.installed).length,s=Math.max(0,r-Math.floor(la/2)),i=Math.min(t.length,s+la);i===t.length&&(s=Math.max(0,i-la));let a=t.slice(s,i),l=s,u=t.length-i;return jsxs(Box,{flexDirection:"column",children:[jsxs(Box,{flexDirection:"column",paddingX:1,paddingBottom:1,children:[jsx(Text,{bold:true,color:"cyan",children:h(e.name)}),jsx(Text,{dimColor:true,children:h(e.description)})]}),jsx(Box,{paddingX:1,paddingBottom:1,children:jsxs(Text,{children:[t.length," plugins to install",o>0&&` \xB7 ${o} already installed`]})}),l>0&&jsx(Box,{paddingX:2,children:jsxs(Text,{dimColor:true,children:["\u2191 ",l," more above"]})}),a.map((c,d)=>jsx(Xu,{plugin:c,isCursor:s+d===r},c.name)),u>0&&jsx(Box,{paddingX:2,children:jsxs(Text,{dimColor:true,children:["\u2193 ",u," more below"]})})]})}var yh=["Retry failed","Continue anyway"];function Yu({name:e,status:t,error:r}){let n=h(e);return t==="installing"?jsxs(Box,{children:[jsx(Text,{color:"cyan",children:jsx(ru,{type:"dots"})}),jsxs(Text,{color:"cyan",children:[" ",n]})]}):t==="success"?jsx(Box,{children:jsxs(Text,{color:"green",children:["\u2713 ",n]})}):t==="failed"?jsxs(Box,{children:[jsxs(Text,{color:"red",children:["\u2717 ",n]}),r&&jsxs(Text,{dimColor:true,children:[" \u2014 ",h(r)]})]}):jsx(Box,{children:jsxs(Text,{dimColor:true,children:["\u25CB ",n]})})}function Zu({onComplete:e,onRetry:t}){let r=_(u=>u.plugins),n=_(u=>u.step),o=_(u=>u.successCount),s=_(u=>u.failedCount),i=_(u=>u.summaryActionIndex),a=r.filter(u=>u.selected),l=useRef(false);return useEffect(()=>{if(n==="summary"&&s===0&&!l.current){l.current=true;let u=setTimeout(e,1500);return ()=>clearTimeout(u)}},[n,s,e]),n==="installing"?jsxs(Box,{flexDirection:"column",children:[jsx(Box,{paddingX:1,paddingBottom:1,children:jsx(Text,{bold:true,children:"Installing plugins..."})}),jsx(Box,{flexDirection:"column",paddingX:1,children:a.map(u=>jsx(Yu,{name:u.name,status:u.status,error:u.error},u.name))})]}):jsxs(Box,{flexDirection:"column",children:[jsx(Box,{paddingX:1,paddingBottom:1,children:jsx(Text,{bold:true,children:"Installation Complete"})}),jsxs(Box,{flexDirection:"column",paddingX:1,paddingBottom:1,children:[o>0&&jsxs(Text,{color:"green",children:["\u2713 ",o," ",o===1?"plugin":"plugins"," installed successfully"]}),s>0&&jsxs(Text,{color:"red",children:["\u2717 ",s," ",s===1?"plugin":"plugins"," failed"]})]}),s>0&&jsx(Box,{flexDirection:"column",paddingX:1,paddingBottom:1,children:a.filter(u=>u.status==="failed").map(u=>jsx(Yu,{name:u.name,status:u.status,error:u.error},u.name))}),s>0&&jsx(Box,{flexDirection:"column",paddingX:1,children:yh.map((u,c)=>jsx(Box,{children:jsxs(Text,{bold:c===i,color:c===i?"cyan":void 0,children:[c===i?"\u203A ":" ",u]})},u))}),s===0&&jsx(Box,{paddingX:1,children:jsx(Text,{dimColor:true,children:"Proceeding to main screen..."})})]})}function Qu(){let e=_(x=>x.step),t=_(x=>x.starterKits),r=_(x=>x.selectedStarterKitIndex),n=_(x=>x.setSelectedStarterKitIndex),o=_(x=>x.selectStarterKit),s=_(x=>x.plugins),i=_(x=>x.pluginCursorIndex),a=_(x=>x.setPluginCursorIndex),l=_(x=>x.setStep),u=_(x=>x.summaryActionIndex),c=_(x=>x.setSummaryActionIndex),d=_(x=>x.failedCount),p=_(x=>x.resetForRetry),m=_(x=>x.goBackToList),f=S(x=>x.setScreen),g=S(x=>x.setFocus),y=S(x=>x.focus),w=Ge(x=>x.setJustAuthenticated),P=Ge(x=>x.justAuthenticated),{loadStarterKits:C,installSelected:k}=Vu(),$=useRef(false);useEffect(()=>{e==="starterKitList"?(g("starterKitList"),$.current||($.current=true,dr("bundle_selection"))):g(e==="starterKitDetail"?"starterKitDetail":"installProgress");},[e,g]);let O=useCallback(async()=>{let x=_.getState().selectedStarterKit;if(x){let F=await oe();F&&await Tt({...F,starterKit:x.slug});}b(v.CLI_STEP_COMPLETED,{step:"summary_review",duration_ms:pr()}).catch(()=>{});let{successCount:A}=_.getState();b(v.CLI_ONBOARDING_COMPLETED,{duration_ms:Ct(),tools_installed_count:A}).catch(()=>{}),w(false),g("verify"),f("verify");},[w,g,f]),G=useCallback(()=>{p(),k();},[p,k]),he=useCallback(()=>{C();},[C]),M=useCallback(()=>{g("verify"),f("verify");},[g,f]);return useInput((x,A)=>{if(A.escape)Po("esc"),M();else if(A.upArrow&&r>0)n(r-1);else if(A.downArrow&&r<t.length-1)n(r+1);else if(A.return&&t.length>0){let F=pr();o(t[r]),dr("kit_display"),b(v.CLI_STEP_COMPLETED,{step:"bundle_selection",duration_ms:F}).catch(()=>{});}},{isActive:y==="starterKitList"}),useInput((x,A)=>{let F=Hu(x,A);if(F.cursorDelta!==0){let W=i+F.cursorDelta;W>=0&&W<s.length&&a(W);}if(F.confirm){let W=_.getState().selectedStarterKit;W&&(async()=>(await oe())?.starterKit!==W.slug&&b(v.CLI_KIT_ACCEPTED,{bundle_slug:W.slug}).catch(()=>{}))();let Et=pr();dr("kit_confirmation"),b(v.CLI_STEP_COMPLETED,{step:"kit_display",duration_ms:Et}).catch(()=>{});let dn=pr();dr("tool_installation"),b(v.CLI_STEP_COMPLETED,{step:"kit_confirmation",duration_ms:dn}).catch(()=>{}),l("installing"),k();}if(F.back){let W=_.getState().selectedStarterKit;W&&b(v.CLI_KIT_REJECTED,{bundle_slug:W.slug}).catch(()=>{}),m();}},{isActive:y==="starterKitDetail"}),useInput((x,A)=>{if(d===0)return;let F=Ju(x,A);if(F.cursorDelta!==0){let W=u+F.cursorDelta;W>=0&&W<=1&&c(W);}F.select&&(u===0?G():O());},{isActive:y==="installProgress"&&e==="summary"}),jsxs(Box,{flexDirection:"column",borderStyle:"round",paddingX:1,children:[jsx(Nr,{}),jsxs(Box,{flexDirection:"column",paddingX:1,marginBottom:1,children:[jsx(Text,{dimColor:true,children:"The data collected during setup is used solely to improve"}),jsx(Text,{dimColor:true,children:"Flow's internal tools and will not be shared externally."}),!P&&jsx(Box,{marginTop:1,children:jsx(Text,{color:"yellow",children:"Welcome back! We noticed your Starter Kit is not set up yet. Choose a Starter Kit below to get your recommended tools."})})]}),jsxs(Box,{flexDirection:"column",flexGrow:1,children:[e==="starterKitList"&&jsx(Wu,{onRetry:he}),e==="starterKitDetail"&&jsx(qu,{}),(e==="installing"||e==="summary")&&jsx(Zu,{onComplete:O,onRetry:G})]}),jsx($o,{})]})}var vh=I("moduleState");function ws(){let e=process.env.FLOW_HOME??me__default.join(Le__default.homedir(),".flow");return me__default.join(e,"modules.json")}var bh={retries:5,minTimeout:50};async function ed(e,t){ve__default.mkdirSync(me__default.dirname(e),{recursive:true});let r=await og.lock(e+".lock",{realpath:false,retries:bh});try{return await t()}finally{await r();}}function td(){let e=ws();if(!ve__default.existsSync(e))return [];try{let t=JSON.parse(ve__default.readFileSync(e,"utf-8"));return t.schemaVersion!==1?(vh.warn(`modules.json has unknown schemaVersion ${t.schemaVersion}, resetting`),ve__default.rmSync(e,{force:!0}),[]):Array.isArray(t.modules)?t.modules.map(r=>({...r,name:r.name??null})):[]}catch{return ve__default.rmSync(e,{force:true}),[]}}function Pr(){return td()}function rd(e){let t=ws();ve__default.mkdirSync(me__default.dirname(t),{recursive:true});let r=`${t}.${randomUUID()}.tmp`,n={schemaVersion:1,modules:e};ve__default.writeFileSync(r,JSON.stringify(n,null,2),"utf-8"),ve__default.renameSync(r,t);}function et(e){return Pr().find(t=>t.alias===e)??null}async function xt(e){let t=ws();await ed(t,async()=>{let r=td(),n=r.findIndex(o=>o.alias===e.alias);n===-1?r.push(e):r[n]=e,rd(r);});}async function rn(){let e=ws();ve__default.existsSync(e)||await ed(e,async()=>{ve__default.existsSync(e)||rd([]);});}var Th=promisify(execFile);function sr(e,t){let r=e.platforms[process.platform];return !r||r.status!=="supported"?null:r.strategies.find(n=>n.type===t)??null}async function It(e){let t=process.platform==="win32"?"where":"which";try{return await Th(t,[e]),!0}catch{return false}}function Nt(){return process.platform==="win32"?"npm.cmd":"npm"}var nd=promisify(execFile),xs=class{type="npm";async isAvailable(){return It("npm")}async install(t){let r=await this.getInstalledVersion(t);return r?{success:true,version:r,method:"npm",durationMs:0}:this.runNpmInstall(t,false)}async update(t,r){return this.runNpmInstall(t,true)}async getInstalledVersion(t){let r=sr(t,"npm");if(!r)return null;try{let{stdout:n}=await nd(Nt(),["list","-g",r.package,"--depth=0","--json"],{shell:!0});return JSON.parse(n).dependencies?.[r.package]?.version??null}catch{return null}}async uninstall(t){return {success:false,error:{code:"NOT_IMPLEMENTED",message:"uninstall not implemented"},durationMs:0}}async runNpmInstall(t,r){let n=Date.now(),o=sr(t,"npm");if(!o)return {success:false,error:{code:"NPM_NOT_AVAILABLE",message:"No npm config for this module on this platform"},durationMs:Date.now()-n};let s=r?`${o.package}@latest`:o.package;try{return await nd(Nt(),["install","-g",s],{shell:!0}),{success:!0,version:await this.getInstalledVersion(t)??void 0,method:"npm",durationMs:Date.now()-n}}catch(i){return {success:false,error:{code:"NPM_INSTALL_FAILED",message:i instanceof Error?i.message:String(i)},durationMs:Date.now()-n}}}};var od=promisify(execFile),Mh=/^(\S+)\s+([\d]+\.[\d]+(?:\.[\d]+)*(?:[-_][^\s]+)?)/,Is=class{type="homebrew";async isAvailable(){return It("brew")}async install(t){return this.runBrewCommand(t,"install")}async update(t,r){return this.runBrewCommand(t,"upgrade")}async getInstalledVersion(t){let r=sr(t,"homebrew");return r?this.getVersionByFormula(r.formula):null}async uninstall(t){return {success:false,error:{code:"NOT_IMPLEMENTED",message:"uninstall not implemented"},durationMs:0}}async runBrewCommand(t,r){let n=Date.now(),o=sr(t,"homebrew");if(!o)return {success:false,error:{code:"HOMEBREW_NOT_AVAILABLE",message:"No homebrew config for this module on this platform"},durationMs:Date.now()-n};let s=r==="install"?"HOMEBREW_INSTALL_FAILED":"HOMEBREW_UPGRADE_FAILED";try{return await od("brew",[r,o.formula]),{success:!0,version:await this.getVersionByFormula(o.formula)??void 0,method:"homebrew",durationMs:Date.now()-n}}catch(i){return {success:false,error:{code:s,message:i instanceof Error?i.message:String(i)},durationMs:Date.now()-n}}}async getVersionByFormula(t){try{let{stdout:r}=await od("brew",["list","--versions",t]),n=r.trim().match(Mh);return n?n[2]:null}catch{return null}}};var nn=promisify(execFile),Dh=I("curlStrategy"),id=/([\d]+\.[\d]+(?:\.[\d]+)*(?:[-_][^\s]+)?)/;function ad(){let e=process.env.FLOW_HOME??me__default.join(Le__default.homedir(),".flow");return me__default.join(e,"bin")}var vs=class{type="curl";async isAvailable(){return It("curl")}async install(t){let r=Date.now(),n=sr(t,"curl");if(!n)return {success:false,error:{code:"CURL_NOT_AVAILABLE",message:"No curl config for this module on this platform"},durationMs:Date.now()-r};let o=typeof n.url=="function"?n.url(process.arch):n.url;return (n.mode??"binary")==="script"?this.installScript(o,n.checksumUrl,t,r):this.installBinary(o,n.checksumUrl,t,r)}async update(t,r){return this.install(t)}async getInstalledVersion(t){let r=me__default.join(ad(),t.binaryName);for(let n of [r,t.binaryName])try{let{stdout:o}=await nn(n,["--version"]),s=o.match(id);if(s)return s[1]}catch{}return null}async uninstall(t){return {success:false,error:{code:"NOT_IMPLEMENTED",message:"uninstall not implemented"},durationMs:0}}async installScript(t,r,n,o){let s=me__default.join(Le__default.tmpdir(),`flow-install-${randomUUID()}.sh`);try{if(await nn("curl",["-sSL","--fail","-o",s,t]),r||Dh.warn(`Installing script for "${n.alias}" without checksum verification \u2014 checksumUrl not provided`),r){let a=await this.validateChecksum(s,r);if(!a.valid){try{ve__default.unlinkSync(s);}catch{}return {success:!1,error:{code:"CHECKSUM_MISMATCH",message:a.message},durationMs:Date.now()-o}}}return ve__default.chmodSync(s,448),await nn("bash",[s]),{success:!0,version:await this.getInstalledVersion(n)??void 0,method:"curl",durationMs:Date.now()-o}}catch(i){return {success:false,error:{code:"CURL_SCRIPT_FAILED",message:i instanceof Error?i.message:String(i)},durationMs:Date.now()-o}}finally{try{ve__default.unlinkSync(s);}catch{}}}async installBinary(t,r,n,o){let s=ad(),i=me__default.join(s,n.binaryName),a=false;try{if(ve__default.mkdirSync(s,{recursive:!0}),a=!0,await nn("curl",["-L","--fail","-o",i,t]),r){let u=await this.validateChecksum(i,r);if(!u.valid)return ve__default.unlinkSync(i),{success:!1,error:{code:"CHECKSUM_MISMATCH",message:u.message},durationMs:Date.now()-o}}ve__default.chmodSync(i,493);let l=null;try{let{stdout:u}=await nn(i,["--version"]),c=u.match(id);l=c?c[1]:null;}catch{}return {success:!0,version:l??void 0,method:"curl",durationMs:Date.now()-o}}catch(l){if(a)try{ve__default.unlinkSync(i);}catch{}return {success:false,error:{code:"CURL_DOWNLOAD_FAILED",message:l instanceof Error?l.message:String(l)},durationMs:Date.now()-o}}}async validateChecksum(t,r){let n=me__default.join(Le__default.tmpdir(),`curl-checksum-${randomUUID()}`);try{await nn("curl",["-L","--fail","-o",n,r]);let o=ve__default.readFileSync(n,"utf-8").trim().split(/\s+/)[0],s=ve__default.readFileSync(t),i=createHash("sha256").update(s).digest("hex");return i!==o?{valid:!1,message:`SHA256 mismatch: expected ${o}, got ${i}`}:{valid:!0,message:""}}catch(o){return {valid:false,message:`Checksum validation failed: ${String(o)}`}}finally{try{ve__default.unlinkSync(n);}catch{}}}};var Ae=I("moduleInstaller");function Bt(e){switch(e){case "npm":return new xs;case "homebrew":return new Is;case "curl":return new vs}}async function qn(e,t,r){try{await b(v.CLI_MODULE_INSTALL_FAILED,{module_alias:e.alias,module_name:e.name,os:process.platform,error_code:r.code,error_message:r.message,trigger:t});}catch(n){Ae.warn(`Failed to emit install failed event: ${String(n)}`);}}async function sn(e,t,r){let n=Date.now(),o=e.platforms[process.platform];if(!o)return {success:false,error:{code:"PLATFORM_NOT_SUPPORTED",message:`Platform ${process.platform} is not listed for module ${e.alias}`},durationMs:Date.now()-n};if(o.status==="experimental"){Ae.warn(`Module "${e.alias}" has experimental support on ${process.platform}`);let l={code:"PLATFORM_EXPERIMENTAL",message:`Experimental support on ${process.platform} \u2014 install manually`};return await qn(e,t,l),{success:false,error:l,durationMs:Date.now()-n}}if(o.status!=="supported"){let l={code:"PLATFORM_NOT_SUPPORTED",message:`Module ${e.alias} is not supported on ${process.platform}`};return await qn(e,t,l),{success:false,error:l,durationMs:Date.now()-n}}if(!o.strategies.some(l=>l.type===r)){let l={code:"STRATEGY_NOT_FOUND",message:`Strategy "${r}" is not configured for module "${e.alias}" on ${process.platform}`};return await qn(e,t,l),{success:false,error:l,durationMs:Date.now()-n}}let s=Bt(r),i=false;try{i=await s.isAvailable();}catch(l){Ae.warn(`${r} availability check failed: ${String(l)}`);}if(!i){let l={code:"STRATEGY_NOT_AVAILABLE",message:`"${r}" is not installed on this system`};return await qn(e,t,l),{success:false,error:l,durationMs:Date.now()-n}}try{await b(v.CLI_MODULE_INSTALL_STARTED,{module_alias:e.alias,module_name:e.name,os:process.platform,cli_version:ae,trigger:t});}catch(l){Ae.warn(`Failed to emit install started event: ${String(l)}`);}let a;try{a=await s.install(e);}catch(l){let u=l instanceof Error?l.message:String(l);Ae.warn(`${r} install threw: ${u}`),a={success:false,error:{code:"INSTALL_THREW",message:u},durationMs:Date.now()-n};}if(a.success){await xt({alias:e.alias,name:e.name,installedVersion:a.version??null,installMethod:a.method??null,installedAt:new Date().toISOString(),lastChecked:new Date().toISOString()});try{await b(v.CLI_MODULE_INSTALL_COMPLETED,{module_alias:e.alias,module_name:e.name,installed_version:a.version??"unknown",duration_ms:a.durationMs,os:process.platform,trigger:t});}catch(u){Ae.warn(`Failed to emit install completed event: ${String(u)}`);}let l=await Nh(e,t);return l?{...a,pendingInteractiveSetup:l}:a}return await qn(e,t,a.error??{code:"UNKNOWN",message:"unknown error"}),a}async function Nh(e,t){if(!e.postInstall)return null;let r=t==="onboarding"?e.postInstall.onboarding:e.postInstall.onDemand;if(r==null)return null;let n;if(typeof r=="function"){let o=await oe(),s={credentials:o?{clientId:o.clientId,clientSecret:o.clientSecret,tenant:o.tenant}:null};try{n=r(s);}catch(i){return Ae.warn(`postInstall function threw: ${String(i)}`),null}}else n=r;if(n.length===0)return null;if((e.postInstall.mode??"non-interactive")==="interactive")return n[0]??null;for(let o of n){if(o.length===0)continue;let s=spawnSync(o[0],o.slice(1),{stdio:"pipe",env:process.env,encoding:"utf-8",shell:process.platform==="win32"});if(s.status!==0)return Ae.warn(`postInstall "${o.join(" ")}" exited with status ${s.status??"null"}`),s.stderr&&Ae.warn(s.stderr),null}return null}async function bs(e,t){let r=Date.now(),n=et(e.alias);if(!n?.installMethod)return {success:false,error:{code:"NOT_INSTALLED",message:`Module '${e.alias}' is not installed`},durationMs:Date.now()-r};let o=Bt(n.installMethod),s=n.installedVersion??"unknown";if(t==="command")try{await b(v.CLI_MODULE_INSTALL_STARTED,{module_alias:e.alias,module_name:e.name,os:process.platform,cli_version:ae,trigger:"command"});}catch(a){Ae.warn(`Failed to emit update started event: ${String(a)}`);}let i;try{i=await o.update(e,s);}catch(a){let l=a instanceof Error?a.message:String(a);Ae.warn(`${n.installMethod} update threw: ${l}`),i={success:false,error:{code:"UPDATE_THREW",message:l},durationMs:Date.now()-r};}if(i.success)if(await xt({...n,installedVersion:i.version??n.installedVersion,lastChecked:new Date().toISOString()}),t==="command")try{await b(v.CLI_MODULE_INSTALL_COMPLETED,{module_alias:e.alias,module_name:e.name,installed_version:i.version??"unknown",duration_ms:i.durationMs,os:process.platform,trigger:"command"});}catch(a){Ae.warn(`Failed to emit update completed event: ${String(a)}`);}else try{await b(v.CLI_MODULE_UPDATED,{module_alias:e.alias,from_version:s,to_version:i.version??"unknown",duration_ms:i.durationMs});}catch(a){Ae.warn(`Failed to emit module updated event: ${String(a)}`);}else if(t==="command")try{await b(v.CLI_MODULE_INSTALL_FAILED,{module_alias:e.alias,module_name:e.name,os:process.platform,error_code:i.error?.code??"UNKNOWN",error_message:i.error?.message??"unknown error",trigger:"command"});}catch(a){Ae.warn(`Failed to emit update failed event: ${String(a)}`);}return i}function Bh(e){let t=e.module.platforms[process.platform];return (t?.status==="supported"?t.strategies:[]).map(n=>n.type==="npm"?`npm install -g ${n.package}`:n.type==="homebrew"?`brew install ${n.formula}`:"curl (see docs)").join(" or ")}function ud(e){let[t,r]=useState(()=>e.map(c=>({alias:c.module.alias,name:c.module.name,status:"pending"}))),[n,o]=useState(false),s=useCallback((c,d)=>{r(p=>p.map(m=>m.alias===c?{...m,...d}:m));},[]),i=useCallback(async()=>{for(let c of e){let d=Bh(c);if(!c.selectedStrategy){let p=d?`No package manager available. Install manually: ${d}`:"No package manager available for this platform";s(c.module.alias,{status:"failed",error:p,manualInstallHint:d||void 0});continue}s(c.module.alias,{status:"installing"});try{let p=await sn(c.module,"onboarding",c.selectedStrategy);p.success?s(c.module.alias,{status:"installed",pendingSetupCommand:p.pendingInteractiveSetup?.join(" ")}):s(c.module.alias,{status:"failed",error:p.error?.message??"Installation failed",manualInstallHint:d});}catch(p){s(c.module.alias,{status:"failed",error:p instanceof Error?p.message:"Unknown error",manualInstallHint:d});}}o(true);},[e,s]),a=useMemo(()=>t.filter(c=>c.status==="installed").length,[t]),l=useMemo(()=>t.filter(c=>c.status==="failed").length,[t]),u=useMemo(()=>t.filter(c=>c.status==="skipped").length,[t]);return {modules:t,install:i,isComplete:n,installedCount:a,failedCount:l,skippedCount:u}}function jh(e){return e.filter(t=>t.module.platforms[process.platform]?.status==="supported").filter(t=>!t.alreadyInstalled).map(t=>({module:t.module,alreadyInstalled:t.alreadyInstalled,checked:!t.alreadyInstalled&&(t.availableStrategies.length>0||t.module.required===true),selectedStrategy:t.availableStrategies[0]??null,availableStrategies:t.availableStrategies}))}function gd(e,t){let[r,n]=useState(()=>jh(e)),[o,s]=useState(0),i=useRef(o);useEffect(()=>{i.current=o;},[o]);let a=useRef(r);useEffect(()=>{a.current=r;},[r]);let l=useCallback(d=>{n(p=>p.map(m=>m.module.alias!==d||m.module.required?m:{...m,checked:!m.checked}));},[]),u=useCallback((d,p)=>{n(m=>m.map(f=>f.module.alias===d?{...f,selectedStrategy:p}:f));},[]);useInput((d,p)=>{let m=i.current,f=a.current,g=p.upArrow||d==="[A",y=p.downArrow||d==="[B";if(g||y)g&&m>0?s(m-1):y&&m<f.length-1&&s(m+1);else if(d===" "){let w=f[m];w&&!w.module.required&&l(w.module.alias);}else if(p.tab){let w=f[m];if(w&&w.availableStrategies.length>1){let P=w.availableStrategies.indexOf(w.selectedStrategy??w.availableStrategies[0]),C=w.availableStrategies[(P+1)%w.availableStrategies.length];n(k=>k.map($=>$.module.alias===w.module.alias?{...$,selectedStrategy:C}:$));}}},{isActive:t});let c=useMemo(()=>r.filter(d=>d.checked),[r]);return {items:r,focusedIndex:o,toggle:l,setStrategy:u,confirmedItems:c}}function Kh(){return te.filter(e=>e.platforms[process.platform]?.status==="supported")}function hd(e){let t=Kh();return t.length>0&&t.every(r=>e.find(n=>n.module.alias===r.alias)?.alreadyInstalled===true)}var yd={alias:"metrics",required:true,name:"flow-ai-obs",binaryName:"flow-ai-obs",description:"AI usage telemetry and observability (hooks, OTEL, LLM proxy)",platforms:{darwin:{status:"supported",strategies:[{type:"npm",package:"@ciandt-flow/flow-ai-obs"}]},linux:{status:"supported",strategies:[{type:"npm",package:"@ciandt-flow/flow-ai-obs"}]},win32:{status:"supported",strategies:[{type:"npm",package:"@ciandt-flow/flow-ai-obs"}]}},versionCheck:{type:"npm-registry",package:"@ciandt-flow/flow-ai-obs"},versionCommand:["flow-ai-obs","--version"],hasOwnUpdateCheck:true,postInstall:{onboarding:e=>{if(!e.credentials)throw new Error("flow-ai-obs setup requires credentials");let{clientId:t,clientSecret:r,tenant:n}=e.credentials;return [["flow-ai-obs","auth","login","--client-id",t,"--client-secret",r,"--tenant",n],["flow-ai-obs","install"]]},onDemand:null,mode:"non-interactive"}},Vh={alias:"dashboard",name:"ccboard",binaryName:"ccboard",description:"Claude Code session monitoring dashboard",docs:"https://github.com/FlorianBruniaux/ccboard",platforms:{darwin:{status:"supported",strategies:[{type:"homebrew",formula:"ccboard"},{type:"curl",url:"https://raw.githubusercontent.com/FlorianBruniaux/ccboard/main/install.sh",mode:"script"}]},linux:{status:"supported",strategies:[{type:"curl",url:"https://raw.githubusercontent.com/FlorianBruniaux/ccboard/main/install.sh",mode:"script"}]},win32:{status:"experimental"}},versionCheck:{type:"github-releases",repo:"florianbruniaux/ccboard"},versionCommand:["ccboard","--version"],hasOwnUpdateCheck:false},te=Gt()?[yd,Vh]:[yd];var xd=null;function Id(){return xd}async function Es(){let t=Pr().filter(r=>r.installedVersion===null&&r.installMethod===null);for(let r of t){let n=te.find(i=>i.alias===r.alias);if(!n)continue;let{installedVersion:o,installMethod:s}=await vd(n);(o||s)&&await xt({...r,installedVersion:o,installMethod:s});}}async function vd(e){let t=e.platforms[process.platform];if(t?.status!=="supported")return {installedVersion:null,installMethod:null};for(let r of t.strategies)if(r.type!=="curl")try{let o=await Bt(r.type).getInstalledVersion(e);if(o)return {installedVersion:o,installMethod:r.type}}catch{}return {installedVersion:null,installMethod:null}}async function an(e){let t=await Promise.all(e.map(r=>Hh(r)));return xd=t,t}async function Hh(e){let t=Sd(e.versionCommand);t==="permission-denied"&&(Jh(e.versionCommand[0]),t=Sd(e.versionCommand));let r=t==="installed",n=e.platforms[process.platform],o=n?.status==="supported"?n.strategies:[],i=(await Promise.all(o.map(async a=>{try{return await Bt(a.type).isAvailable()?a.type:null}catch{return null}}))).filter(a=>a!==null);if(r&&!et(e.alias)){let{installedVersion:a,installMethod:l}=await vd(e);await xt({alias:e.alias,name:e.name,installedVersion:a,installMethod:l,installedAt:null,lastChecked:new Date().toISOString()});}return {module:e,alreadyInstalled:r,availableStrategies:i}}function Sd(e){if(e.length===0)return "not-found";try{let t=spawnSync(e[0],e.slice(1),{timeout:3e3,stdio:"pipe",shell:process.platform==="win32"});return t.status===0?"installed":t.status===126?"permission-denied":"not-found"}catch{return "not-found"}}function Jh(e){if(process.platform!=="win32")try{let t=spawnSync("which",[e],{stdio:"pipe"});if(t.status!==0)return;let r=t.stdout.toString().trim(),n=ve__default.realpathSync(r),{mode:o}=ve__default.statSync(n);ve__default.chmodSync(n,o|73);}catch{}}function Wh({module:e}){let t=h(e.name);return e.status==="installing"?jsxs(Box,{children:[jsx(Text,{color:"cyan",children:jsx(ru,{type:"dots"})}),jsxs(Text,{color:"cyan",children:[" ",t," \u2014 Installing..."]})]}):e.status==="installed"?jsxs(Box,{flexDirection:"column",children:[jsx(Box,{children:jsxs(Text,{color:"green",children:["\u2713 ",t]})}),e.pendingSetupCommand&&jsx(Box,{paddingLeft:2,children:jsxs(Text,{dimColor:true,children:["\u2139 Run '",h(e.pendingSetupCommand),"' to complete configuration"]})})]}):e.status==="failed"?jsxs(Box,{flexDirection:"column",children:[jsxs(Box,{children:[jsxs(Text,{color:"red",children:["\u2717 ",t]}),e.error&&jsxs(Text,{dimColor:true,children:[" \u2014 ",h(e.error)]})]}),e.manualInstallHint&&jsx(Box,{paddingLeft:2,children:jsxs(Text,{dimColor:true,children:["Install manually: ",h(e.manualInstallHint)]})})]}):e.status==="skipped"?jsx(Box,{children:jsxs(Text,{dimColor:true,children:["- ",t," (not supported on this platform)"]})}):jsx(Box,{children:jsxs(Text,{dimColor:true,children:["\u25CB ",t]})})}function zh({confirmedItems:e}){let t=S(f=>f.setScreen),r=S(f=>f.setFocus),{modules:n,install:o,isComplete:s,installedCount:i,failedCount:a,skippedCount:l}=ud(e),u=useRef(false),c=useRef(false);useEffect(()=>{u.current||(u.current=true,o());},[o]);let d=useCallback(()=>{rn().catch(()=>{}),r("list");let f=se().some(g=>g.name===ie);t(f?"main":"claudeMdSuggestion");},[r,t]);useEffect(()=>{if(s&&a===0&&!c.current){c.current=true;let f=setTimeout(d,1500);return ()=>clearTimeout(f)}},[s,a,d]),useInput((f,g)=>{g.return&&d();},{isActive:s});let p=s,m=[];return i>0&&m.push(jsxs(Text,{color:"green",children:[i," installed"]},"i")),a>0&&m.push(jsxs(Text,{color:"red",children:[a," failed"]},"f")),l>0&&m.push(jsxs(Text,{dimColor:true,children:[l," skipped"]},"s")),jsxs(Fragment,{children:[jsx(Box,{paddingX:1,paddingBottom:1,children:jsx(Text,{bold:true,children:s?"Modules ready":"Setting up modules..."})}),jsx(Box,{flexDirection:"column",paddingX:1,paddingBottom:1,children:n.map(f=>jsx(Wh,{module:f},f.alias))}),p&&jsxs(Fragment,{children:[jsx(Box,{paddingX:1,paddingBottom:1,children:m.reduce((f,g,y)=>(y>0&&f.push(jsx(Text,{children:" | "},`sep-${y}`)),f.push(g),f),[])}),jsx(Box,{paddingX:1,children:a>0?jsx(Text,{dimColor:true,children:"Press Enter to continue"}):jsx(Text,{dimColor:true,children:"Proceeding..."})})]})]})}function Xh({probeResults:e,onConfirm:t}){let r=S(m=>m.focus),n=S(m=>m.actionMenuOpen),o=S(m=>m.setActionMenuOpen),s=S(m=>m.setFocus),{items:i,focusedIndex:a,confirmedItems:l}=gd(e,r==="moduleSetup"),u=useCallback(()=>{o(false),s("moduleSetup");},[o,s]),c=useCallback(m=>{(m==="Install"||m==="Skip")&&t(l),u();},[l,t,u]);useInput((m,f)=>{f.return&&(o(true),s("actionMenu"));},{isActive:r==="moduleSetup"});let d=l.length>0?["Install","Cancel"]:["Skip","Cancel"],p=l.length>0?`Install ${l.length} module(s)?`:"No modules selected";return jsxs(Fragment,{children:[jsx(Box,{paddingX:1,paddingBottom:1,children:jsx(Text,{bold:true,children:"Configure modules"})}),jsx(Box,{flexDirection:"column",paddingX:1,paddingBottom:1,children:i.map((m,f)=>{let g=f===a,y=h(m.module.name);return m.availableStrategies.length===0?jsxs(Box,{children:[jsxs(Text,{dimColor:true,children:[" [ ] ",y," "]}),jsx(Text,{dimColor:true,children:"\u2014 no installer available"})]},m.module.alias):jsxs(Box,{flexDirection:"column",children:[jsxs(Box,{children:[jsxs(Text,{color:g?"cyan":void 0,children:[g?"\u25B6":" ",m.checked?" [\u2713] ":" [ ] ",y]}),m.module.required&&jsx(Text,{dimColor:true,children:" (required)"}),jsxs(Text,{dimColor:true,children:[" ",m.selectedStrategy??""]}),m.availableStrategies.length>1&&jsxs(Text,{dimColor:true,children:[" ","(",m.availableStrategies.indexOf(m.selectedStrategy??m.availableStrategies[0])+1,"/",m.availableStrategies.length," \u2194)"]})]}),m.module.description&&jsx(Box,{paddingLeft:6,children:jsx(Text,{dimColor:true,children:h(m.module.description)})})]},m.module.alias)})}),jsx(Box,{paddingX:1,children:jsx(Text,{dimColor:true,children:"\u2191\u2193 navigate \xB7 Space toggle \xB7 Tab change method \xB7 Enter confirm"})}),n&&jsx(ze,{itemName:p,actions:d,onAction:c,onClose:u})]})}function Pd(){let[e,t]=useState("loading"),[r,n]=useState([]),[o,s]=useState([]),i=S(c=>c.setFocus),a=S(c=>c.setScreen),l=useCallback(c=>{if(hd(c)){rn().catch(()=>{}),i("list");let p=se().some(m=>m.name===ie);a(p?"main":"claudeMdSuggestion");}else n(c),t("selection");},[i,a]);useEffect(()=>{let c=Id();if(c){l(c);return}an(te).then(l).catch(()=>{n([]),t("selection");});},[l]);let u=useCallback(c=>{s(c),t("installation");},[]);return jsxs(Box,{flexDirection:"column",borderStyle:"round",paddingX:1,children:[e==="loading"&&jsx(Box,{paddingX:1,paddingBottom:1,children:jsx(Text,{bold:true,children:"Setting up modules..."})}),e==="selection"&&jsx(Xh,{probeResults:r,onConfirm:u}),e==="installation"&&jsx(zh,{confirmedItems:o})]})}var Qh=I("ClaudeMdSuggestion"),eS=[`Install ${ie}`,"Skip for now"],tS=["Retry","Skip for now"];function kd(){let e=S(p=>p.setScreen),t=S(p=>p.setFocus),r=_(p=>p.successCount),[n,o]=useState("prompt"),[s,i]=useState(0),a=useRef(0),l=useCallback(()=>{t("list"),e("main");},[t,e]),u=useCallback(()=>{b(v.CLI_CLAUDE_MD_SKIPPED,{interface:"tui"}).catch(()=>{}),l();},[l]),c=useCallback(async()=>{a.current+=1,b(v.CLI_CLAUDE_MD_ACCEPTED,{interface:"tui",attempt:a.current}).catch(()=>{}),o("installing");try{await Ee(ie),o("installed");}catch(p){if(p instanceof Ne){o("installed");return}Qh.warn(`Failed to install ${ie}: ${p instanceof Error?p.message:p}`),o("error");}},[]),d=n==="error"?tS:eS;return useInput((p,m)=>{if(m.escape){n==="prompt"||n==="error"?u():n==="installed"&&l();return}if(n==="prompt"||n==="error"){m.upArrow&&s>0?i(s-1):m.downArrow&&s<d.length-1?i(s+1):m.return&&(s===0?(i(0),c()):u());return}n==="installed"&&m.return&&l();}),jsxs(Box,{flexDirection:"column",borderStyle:"round",paddingX:1,children:[jsx(Nr,{}),jsxs(Box,{flexDirection:"column",paddingX:1,gap:1,children:[jsx(Text,{color:"green",bold:true,children:r>0?"\u2713 Starter kit installed!":"\u2713 Setup complete!"}),n==="prompt"&&jsxs(Fragment,{children:[jsxs(Box,{flexDirection:"column",children:[jsx(Text,{bold:true,children:"Personalize your Claude Code"}),jsx(Text,{children:"This plugin helps Claude understand your preferences and work style."})]}),jsx(Cd,{options:d,cursorIndex:s}),jsx(Text,{dimColor:true,children:"You can always install it later from the catalog."})]}),n==="installing"&&jsxs(Box,{children:[jsx(Text,{color:"cyan",children:jsx(ru,{type:"dots"})}),jsxs(Text,{color:"cyan",children:[" Installing ",ie,"..."]})]}),n==="installed"&&jsxs(Fragment,{children:[jsxs(Text,{color:"green",bold:true,children:["\u2713 ",ie," installed!"]}),jsxs(Box,{flexDirection:"column",children:[jsx(Text,{children:"Open Claude in a new terminal or in VS Code and type:"}),jsxs(Text,{bold:true,color:"cyan",children:["/",ie]})]}),jsx(Text,{children:"Claude will guide you through the rest."}),jsx(Text,{dimColor:true,children:"Press Enter to continue to the catalog..."})]}),n==="error"&&jsxs(Fragment,{children:[jsxs(Text,{color:"red",bold:true,children:["\u2717 Failed to install ",ie]}),jsx(Cd,{options:d,cursorIndex:s}),jsx(Text,{dimColor:true,children:"You can always install it later from the catalog."})]})]})]})}function Cd({options:e,cursorIndex:t}){return jsx(Box,{flexDirection:"column",children:e.map((r,n)=>jsxs(Text,{bold:n===t,color:n===t?"cyan":void 0,children:[n===t?"\u203A ":" ",r]},r))})}var sS=promisify(execFile),Ps="@ciandt-flow/cli";async function Ad(){let e=ae;if(Xi.prerelease(e)||process.env.NODE_ENV==="development")return {currentVersion:e,latestVersion:e,isOutdated:false,packageName:Ps};try{let t=await fetch(`https://registry.npmjs.org/${Ps}/latest`);if(!t.ok)throw new Error(`Registry returned ${t.status}`);let n=(await t.json()).version;return {currentVersion:e,latestVersion:n,isOutdated:n!==e,packageName:Ps}}catch{return {currentVersion:e,latestVersion:e,isOutdated:false,packageName:Ps}}}async function Ts(e){try{return await sS(Nt(),["install","-g",e.packageName],{timeout:6e4,shell:!0}),{success:!0}}catch(t){return {success:false,error:String(t)}}}async function $d(e){let r=et(e.alias)?.installedVersion??null,n=null;try{if(e.versionCheck.type==="npm-registry"){let s=await fetch(`https://registry.npmjs.org/${e.versionCheck.package}/latest`);if(!s.ok)throw new Error(`Registry returned ${s.status}`);n=(await s.json()).version;}else if(e.versionCheck.type==="github-releases"){let s=await fetch(`https://api.github.com/repos/${e.versionCheck.repo}/releases/latest`);if(!s.ok)throw new Error(`GitHub returned ${s.status}`);n=(await s.json()).tag_name.replace(/^v/,"");}}catch{}let o=r!==null&&n!==null&&r!==n;return {moduleAlias:e.alias,currentVersion:r,latestVersion:n,isOutdated:o}}async function Md(e,t){let r=et(e.alias);if(!r?.installMethod)return {success:false,error:"Unknown install method"};let o=await Bt(r.installMethod).update(e,t.currentVersion??"");return o.success?(await xt({...r,installedVersion:o.version??r.installedVersion,lastChecked:new Date().toISOString()}),{success:true,newVersion:o.version}):{success:false,error:o.error?.message}}function Ld(e){let r=et(e.alias)?.installMethod,n=e.platforms[process.platform];if(n?.status==="supported"){if(r==="npm"){let o=n.strategies.find(s=>s.type==="npm");if(o?.type==="npm")return `npm install -g ${o.package}`}if(r==="homebrew"){let o=n.strategies.find(s=>s.type==="homebrew");if(o?.type==="homebrew")return `brew upgrade ${o.formula}`}}}function Rd(){let[e,t]=useState({outcome:"running",items:[{id:"cli",label:"@ciandt-flow/cli",status:"pending"},...te.map(n=>({id:n.alias,label:n.name,status:"pending"}))]}),r=useCallback((n,o)=>{t(s=>({...s,items:s.items.map(i=>i.id===n?{...i,...o}:i)}));},[]);return useEffect(()=>{async function n(){try{let[o,s,i]=await Promise.all([Ad(),an(te),Promise.all(te.map(l=>$d(l)))]);if(Es(),o.isOutdated){r("cli",{status:"updating",detail:`v${o.currentVersion} \u2192 v${o.latestVersion}`}),(await Ts(o)).success?(r("cli",{status:"updated",detail:`v${o.currentVersion} \u2192 v${o.latestVersion}`}),t(u=>({...u,outcome:"cli-updated"}))):(r("cli",{status:"error",detail:`v${o.currentVersion} \u2192 v${o.latestVersion}`,manualCommand:`npm install -g ${o.packageName}`}),t(u=>({...u,outcome:"cli-update-failed"})));return}r("cli",{status:"ok",detail:`v${o.currentVersion}`});let a=s.some(l=>!l.alreadyInstalled);for(let l of s)l.alreadyInstalled||r(l.module.alias,{status:"missing"});if(a){t(l=>({...l,outcome:"module-missing"}));return}for(let l of i){let u=te.find(d=>d.alias===l.moduleAlias);if(!u)continue;if(!l.isOutdated){r(l.moduleAlias,{status:"ok",detail:l.currentVersion?`v${l.currentVersion}`:void 0});continue}r(l.moduleAlias,{status:"updating",detail:`v${l.currentVersion} \u2192 v${l.latestVersion}`});let c=await Md(u,l);c.success?r(l.moduleAlias,{status:"updated",detail:`v${c.newVersion}`}):r(l.moduleAlias,{status:"error",detail:`v${l.currentVersion} \u2192 v${l.latestVersion}`,manualCommand:Ld(u)});}t(l=>({...l,items:l.items.map(u=>u.status==="pending"?{...u,status:"ok"}:u)})),await rn(),t(l=>({...l,outcome:"done"}));}catch{await rn(),t(o=>({...o,outcome:"done"}));}}n();},[r]),e}function dS({item:e}){return e.status==="pending"||e.status==="updating"?jsxs(Box,{children:[jsx(Text,{color:"cyan",children:jsx(ru,{type:"dots"})}),jsxs(Text,{color:"cyan",children:[" ",e.label,e.detail?` ${e.detail}...`:""]})]}):e.status==="ok"||e.status==="updated"?jsxs(Box,{children:[jsxs(Text,{color:"green",children:["\u2713 ",e.label]}),e.detail&&jsxs(Text,{dimColor:true,children:[" ",e.detail]})]}):e.status==="missing"?jsxs(Box,{children:[jsxs(Text,{color:"red",children:["\u2717 ",e.label]}),jsx(Text,{dimColor:true,children:" \u2014 not installed"})]}):jsxs(Box,{flexDirection:"column",children:[jsxs(Box,{children:[jsxs(Text,{color:"red",children:["\u2717 ",e.label]}),e.detail&&jsxs(Text,{dimColor:true,children:[" ",e.detail]})]}),e.manualCommand&&jsx(Box,{paddingLeft:2,children:jsxs(Text,{dimColor:true,children:["To update manually: ",e.manualCommand]})})]})}function pS({outcome:e}){return e==="done"?jsx(Text,{color:"green",children:"All good!"}):e==="cli-updated"||e==="cli-update-failed"?jsx(Text,{color:"yellow",children:"Restart the CLI to use the new version."}):null}function _d(){let{outcome:e,items:t}=Rd(),r=S(o=>o.setScreen),n=S(o=>o.setFocus);return useEffect(()=>{if(e==="done"){let o=setTimeout(()=>{let s=se().some(i=>i.name===ie);r(s?"main":"claudeMdSuggestion"),n("list");},1500);return ()=>clearTimeout(o)}if(e==="module-missing"){let o=setTimeout(()=>{r("moduleSetup"),n("moduleSetup");},500);return ()=>clearTimeout(o)}},[e,r,n]),jsxs(Box,{flexDirection:"column",paddingX:2,paddingY:1,children:[jsx(Box,{marginBottom:1,children:jsx(Text,{bold:true,children:"Checking environment..."})}),jsx(Box,{flexDirection:"column",gap:0,children:t.map(o=>jsx(dS,{item:o},o.id))}),e!=="running"&&jsx(Box,{marginTop:1,children:jsx(pS,{outcome:e})})]})}var yS={debug:"gray",info:"cyan",warn:"yellow",error:"red"},Dd=10;function Od(){let[e,t]=useState(Js());useEffect(()=>Va(()=>{t([...Js()]);}),[]);let r=e.slice(-Dd);return jsxs(Box,{flexDirection:"column",borderStyle:"single",borderColor:"cyan",paddingX:1,children:[jsxs(Text,{color:"cyan",bold:true,children:["Debug Log (last ",Dd,") \u2014 press Ctrl+D to close"]}),r.length===0?jsx(Text,{dimColor:true,children:"No log entries yet"}):r.map((n,o)=>jsxs(Text,{color:yS[n.level],children:["[",n.level.toUpperCase(),"] [",n.module,"] ",n.message]},o))]})}var xS=I("app"),IS={auth:xl,starterKitSetup:Qu,moduleSetup:Pd,claudeMdSuggestion:kd,verify:_d,main:ju};function Ud(){let{setScreen:e,setFocus:t}=S.getState();e("auth"),t("auth");}function Pn(e){let{setScreen:t,setFocus:r}=S.getState();!e.starterKit||e.starterKit.trim()===""?(t("starterKitSetup"),r("starterKitList")):(t("verify"),r("verify"));}function Fd(){b(v.CLI_SESSION_STARTED,{cli_version:ae,os:process.platform,node_version:process.version,duration_ms:Ct(),interface:"tui"}).catch(()=>{});}async function Kd(){let e=await oe();if(e&&hl()&&await Ht()){let{clientSecret:n,...o}=e;Ge.getState().setCredentials(o),Fd(),Pn(e);return}if(!e){Ud();return}try{await Jt();}catch(n){xS.debug(`Token validation failed: ${String(n)}`),Ud();return}Fd();let{clientSecret:t,...r}=e;Ge.getState().setCredentials(r),Pn(e);}function Vd(){let{columns:e,rows:t}=useWindowSize(),r=S(a=>a.screen),n=IS[r],{pendingExit:o}=pl(),s=S(a=>a.debugPanelOpen),i=!!process.env.DEBUG;return useInput((a,l)=>{if(i&&l.ctrl&&a==="d"){let u=S.getState().debugPanelOpen;S.getState().setDebugPanelOpen(!u);}}),n?jsxs(Box,{flexDirection:"column",width:e,height:t,children:[jsx(n,{}),i&&s&&jsx(Od,{}),o&&jsx(Box,{paddingX:1,children:jsx(Text,{color:"yellow",children:"Press Ctrl+C again to quit"})})]}):jsxs(Text,{color:"red",children:["Unknown screen: ",r]})}async function va(e,t={}){let r=To({clientId:e.clientId,clientSecret:e.clientSecret,tenant:e.tenant},t);return Co(r),await Tt(e),{jwt:r.jwt,previousToken:r.previousToken,hadExistingFile:r.hadExistingFile}}var ut=I("auth");function Jd(){De.clearFallbackFile(),xo();}var vS=3,Hd=3,Gd=` \u2139 The data collected during setup is used solely to improve
|
|
116
|
+
[y/N] `))return ls.debug(`[${e}] Removal cancelled by user`),T("Operation cancelled."),0}let n=t.silent?void 0:Ea({text:`Removing MCP "${h(e)}"...`}).start();try{let o=await we(r);return n?.stop(),o.exitCode!==0?(Hn(t,{name:e,action:"remove",message:o.stderr||"Command failed",exitCode:o.exitCode}),!t.silent&&t.verbose&&o.stdout&&T(`stdout: ${o.stdout}`),1):(ku(t,{name:e,actionPastTense:"removed",command:r,durationMs:o.duration_ms,stdout:o.stdout}),0)}catch(o){return n?.stop(),Hn(t,{name:e,action:"remove",message:Q(o)}),1}}function Mu({selectedItem:e,selectedCatalogItem:t,items:r,closeMenu:n,clampIndex:o,notify:s}){let i=I("pluginHandlers"),a=S(C=>C.setLoading),{install:l,uninstall:u,toggle:c,update:d}=Tu(),p=async(C,k,$)=>{a(true,C),n();try{await k(),o(r.length),s($,"success");}catch(O){let G=O instanceof Error?O.message:"Something went wrong";i.error(`[withLoading] ${C} failed: ${G}`),s(G,"error");}finally{a(false);}};return {handleInstall:(C,k)=>{e&&t&&p(`Installing ${e.name}...`,()=>l(t,{scope:C,...k!==void 0?{providerId:k}:{}}),"\u2713 Installed successfully");},handleUninstall:C=>{e&&p(`Uninstalling ${e.name}...`,()=>u(e.name,C),"\u2713 Uninstalled");},handleToggleStatus:C=>{if(!e)return;let k=e.status==="enabled";p(k?`Disabling ${e.name}...`:`Enabling ${e.name}...`,()=>c(e.name,C),k?"\u2713 Disabled":"\u2713 Enabled");},handleUpdate:()=>{if(!e)return;let C=t?` to v${t.version}`:"";(async()=>{a(true,`Updating ${e.name}${C}...`),n();try{await d(e.name),o(r.length),s(`\u2713 Updated ${e.name}${C}`,"success");}catch($){if($ instanceof zt)s($.message,"info");else {let O=$ instanceof Error?$.message:"Something went wrong";i.error(`[handleUpdate] ${e.name} failed: ${O}`),s(O,"error");}}finally{a(false);}})();},handleBatchUpdate:C=>{if(C.length===0)return;let k=C.length;(async()=>{a(true,`Updating ${k} plugin${k>1?"s":""}...`),n();try{let O=[];for(let M of C)O.push(await d(M.name).then(()=>({status:"fulfilled",value:void 0}),x=>({status:"rejected",reason:x})));let G=O.filter(M=>M.status==="fulfilled").length,he=O.map((M,x)=>M.status==="rejected"?C[x].name:null).filter(M=>M!==null);o(r.length),he.length===0?s(`\u2713 Updated ${G}/${k} plugin${k>1?"s":""}`,"success"):(i.error(`[handleBatchUpdate] failed: ${he.join(", ")}`),s(`Updated ${G}/${k}; failed: ${he.join(", ")}`,G>0?"info":"error"));}finally{a(false);}})();},handleMcpConfigUninstall:C=>{e&&p(`Removing MCP ${e.name}...`,async()=>{let k=qi(e.name,C),$=await we(k);if($.exitCode!==0)throw new Error($.stderr||"MCP removal failed");ue.getState().loadFromDisk();},"\u2713 MCP removed");}}}var cs=I("api:bundle"),en=class extends Error{constructor(t){super(`Bundle '${t}' not found in your tenant. Verify the name with whoever shared the command.`),this.name="BundleNotFoundError";}},Jn=class extends Error{constructor(){super("The server encountered an error while fetching the bundle. Please try again later."),this.name="BundleServerError";}};async function us(e){let t=encodeURIComponent(e);cs.debug(`Fetching bundle by name "${e}"`);let r;try{r=await mt().get(`v1/use-cases/by-name/${t}`).json(),cs.debug(`API returned ${r.length} result(s) for "${e}"`);}catch(n){if(n instanceof HTTPError){let o=n.response.status;throw cs.error(`HTTP error fetching bundle '${e}' [status=${o}]`),o===StatusCodes.NOT_FOUND?new en(e):o===StatusCodes.INTERNAL_SERVER_ERROR?new Jn:new Error(`Server error (${o}) \u2014 please try again later.`)}throw cs.error(`Unexpected error fetching bundle '${e}': ${n instanceof Error?n.message:String(n)}`),n}if(r.length===0)throw new en(e);return r[0]}function Ru({closeMenu:e,notify:t}){let r=S(a=>a.bundleInstallFlow);return {handleBundleInstallStart:a=>{let{setLoading:l,setBundleInstallFlow:u}=S.getState();l(true,"Loading bundle..."),us(a).then(c=>{l(false),S.getState().actionMenuOpen&&u({phase:"detail",bundle:c});}).catch(c=>{l(false),t(c instanceof Error?c.message:"Failed to load bundle","error");});},handleBundleDetailConfirm:()=>{if(!r||r.phase!=="detail")return;let{setBundleInstallFlow:a,setFocus:l}=S.getState();a({phase:"installing",bundle:r.bundle}),l("bundleInstallProgress");},handleBundleDetailBack:()=>{let{setBundleInstallFlow:a}=S.getState();a(null),e();},handleBundleInstallComplete:a=>{S.getState().setBundleInstallFlow(null),e(),ue.getState().loadFromDisk(),t(`\u2713 Installed ${a.installed} of ${a.total} artifacts`,"success");}}}var Gn=["local","project","user"],Yy=new Set(["--transport","--scope","-s"]);function _u(e){let t=e.split(/\s+/).filter(Boolean),r=t.indexOf("add");if(r===-1)return null;let n=r+1;for(;n<t.length;){let o=t[n];if(Yy.has(o))n+=2;else if(o.startsWith("-"))n+=1;else return o.replace(/^["']|["']$/g,"")}return null}function br(e,t){return t?`${e}::${t}`:e}function Yi(e){return e===re?pn:kr}function Du(e){return {name:h(e.name),version:e.version?h(e.version):e.version,description:e.description?h(e.description):e.description,authorName:e.author?.name?h(e.author.name):e.author?.name,updateAvailable:e.updateAvailable,type:e.type??"bundle",origin:e.origin??pn}}function Zi(e,t){let r=Yi(e.marketplace);return {name:h(e.name),version:e.version?h(e.version):e.version,description:e.description?h(e.description):e.description,authorName:e.author?.name?h(e.author.name):e.author?.name,status:e.status,scope:e.scope,marketplace:e.marketplace,updateAvailable:e.updateAvailable,installedAt:e.installedAt,type:t?.type??e.type??"bundle",origin:t?.origin??r}}function Ou(e){let t=new Map;for(let r of e){if(!r.scope)continue;let n=t.get(r.scope)??[];n.push(r),t.set(r.scope,n);}return Gn.filter(r=>t.has(r)).map(r=>({scope:r,label:mn[r].label,pathHint:mn[r].pathHint,items:t.get(r)??[]}))}function Nu(e){let t=r=>{if(!r)return 1/0;let n=Gn.indexOf(r);return n===-1?1/0:n};return [...e].sort((r,n)=>t(r.scope)-t(n.scope))}function Bu({catalog:e,installedItems:t,activeTab:r,catalogFilters:n,searchQuery:o}){let s=useMemo(()=>new Set(t.map(f=>br(f.name,f.author?.name))),[t]),i=useMemo(()=>new Set(t.filter(f=>f.type==="mcp").map(f=>f.name.toLowerCase())),[t]),a=useMemo(()=>{let f=new Map(e.map(y=>[br(y.name,y.author?.name),y])),g=new Map(e.map(y=>[y.name,y]));return t.map(y=>{let w=f.get(br(y.name,y.author?.name))??g.get(y.name),P=w?.version,C=!!P&&!!y.version&&Te(y.version,P);return {...y,updateAvailable:C,catalogItem:w}})},[t,e]),l=useMemo(()=>r==="discover"?e.filter(f=>{if(s.has(br(f.name,f.author?.name)))return false;if(f.type==="mcp"){let g=f.installCommand?_u(f.installCommand)?.toLowerCase():null;if(i.has(f.name.toLowerCase())||g&&i.has(g))return false}return true}).map(f=>Du(f)):r==="updates"?a.filter(f=>f.updateAvailable).map(f=>Zi(f,f.catalogItem)):a.map(f=>Zi(f,f.catalogItem)),[r,e,s,i,a]),u=useMemo(()=>l.filter(f=>{let g=f.type??"bundle";if(!n.types.has(g))return false;let y=f.origin??"internal";return n.origins.has(y)}),[l,n]),c=useMemo(()=>{let{types:f}=n;if(f.size===1){if(f.has("skill"))return "skills";if(f.has("mcp"))return "MCPs";if(f.has("bundle"))return "bundles"}return "items"},[n]),d=useMemo(()=>r==="installed"?o?`No ${c} found for '${o}' \u2014 explore the Discover tab!`:`No ${c} installed \u2014 explore the Discover tab!`:r==="updates"?o?`No ${c} found for '${o}' \u2014 all up to date!`:"All up to date \u2014 nothing to update":o?`No ${c} found for '${o}'`:`No ${c} available in the catalog`,[r,o,c]),p=useMemo(()=>{let f=new Map(e.map(y=>[br(y.name,y.author?.name),y])),g=new Map(e.map(y=>[y.name,y]));return y=>y?f.get(br(y.name,y.authorName))??g.get(y.name)??null:null},[e]),m=useMemo(()=>a.filter(f=>f.updateAvailable).length,[a]);return {items:u,emptyMessage:d,getSelectedCatalogItem:p,outdatedCount:m}}function Qi(){let[e,t]=useState([]),[r,n]=useState(true),[o,s]=useState(null),[i,a]=useState(null),l=useRef(false),u=S(d=>d.catalogVersion),c=useCallback(async()=>{n(true),s(null),a(null);try{let{items:d,failures:p}=await pc();if(t(d),p.length>0){let m=p.map(f=>f.adapterName).join(", ");a(`Some catalogs failed to load: ${m}`);}l.current||(l.current=!0,b(v.CLI_CATALOG_VIEWED,{interface:"tui",filter_type:"all",result_count:d.length}).catch(()=>{}));}catch(d){s(d instanceof Error?d:new Error(String(d))),t([]);}finally{n(false);}},[]);return useEffect(()=>{c();},[c,u]),{catalog:e,isLoading:r,error:o,partialError:i,refetch:c}}function Uu(){return {items:ue(t=>t.installedItems)}}var rh=I("catalog");function ju(){let e=S(Z=>Z.bundleInstallFlow),t=S(Z=>Z.activeTab),r=S(Z=>Z.notification),n=S(Z=>Z.loading),o=S(Z=>Z.loadingMessage),s=S(Z=>Z.catalogError),i=S(Z=>Z.setCatalogError),a=S(Z=>Z.catalogFilters),l=Oe(Z=>Z.query),{catalog:u,isLoading:c,error:d,refetch:p}=Qi(),{items:m}=Uu(),f=ue(Z=>Z.loadFromDisk),{items:g,emptyMessage:y,getSelectedCatalogItem:w,outdatedCount:P}=Bu({catalog:u,installedItems:m,activeTab:t,catalogFilters:a,searchQuery:l}),{actionMenuOpen:C,closeMenu:k,selectedIndex:$,clampIndex:O,filteredItems:G}=Iu({listLength:g.length}),he=G(g),M=useMemo(()=>t!=="installed"&&t!=="updates"?he:Nu(he),[t,he]),x=useMemo(()=>t==="installed"||t==="updates"?Ou(M):[],[t,M]),A=M[$]??null,F=useMemo(()=>w(A),[w,A]),{notify:W}=bu(),{handleInstall:Et,handleUninstall:dn,handleToggleStatus:L,handleUpdate:N,handleBatchUpdate:V,handleMcpConfigUninstall:Ie}=Mu({selectedItem:A,selectedCatalogItem:F,items:g,closeMenu:k,clampIndex:O,notify:W}),{handleBundleInstallStart:Ns,handleBundleDetailConfirm:Gp,handleBundleDetailBack:Wp,handleBundleInstallComplete:zp}=Ru({closeMenu:k,notify:W}),Xp=useCallback(()=>V(M),[V,M]);return useEffect(()=>{f();},[]),useEffect(()=>{O(M.length);},[M.length,O]),useEffect(()=>{d&&(rh.error(`[catalog] ${d instanceof Error?d.message:String(d)}`),i("Failed to load catalog"));},[d]),jsxs(Box,{flexDirection:"column",borderStyle:"round",paddingX:1,children:[jsx(Nr,{}),jsx(Al,{outdatedCount:P}),t==="marketplaces"&&Gt()?jsx(Box,{flexDirection:"column",flexGrow:1,children:jsx(hu,{})}):jsx(Jl,{filteredItems:M,groups:x,emptyMessage:y,onBatchUpdate:Xp}),(n||c)&&jsx(Mo,{message:n?o:"Loading catalog..."}),s&&!c&&t==="discover"&&jsx(Lo,{message:s,onRetry:()=>{i(null),p();},onBack:()=>i(null)}),r&&jsx(Gl,{message:r.message,type:r.type}),C&&A&&(t==="discover"?F?.type==="bundle"?e?.phase==="installing"?jsx(nu,{bundle:e.bundle,onComplete:zp}):jsx(Jc,{itemName:A.name,bundle:e?.phase==="detail"?e.bundle:void 0,onInstall:()=>Ns(A.name),onConfirm:Gp,onClose:e?.phase==="detail"?Wp:k}):jsx(Vc,{itemName:A.name,itemType:F?.type,onInstall:Et,onClose:k}):A.type==="mcp"?jsx(Yc,{itemName:A.name,itemScope:A.scope??"user",onUninstall:Ie,onClose:k}):jsx(zc,{itemName:A.name,itemScope:A.scope??"user",itemStatus:A.status??"enabled",updateAvailable:A.updateAvailable??false,catalogVersion:F?.version,onUninstall:dn,onToggleStatus:Z=>L(Z),onUpdate:N,onClose:k})),jsx($o,{})]})}var _=create((e,t)=>({starterKits:[],selectedStarterKitIndex:0,selectedStarterKit:null,plugins:[],pluginCursorIndex:0,step:"starterKitList",isLoadingStarterKits:false,starterKitsError:null,successCount:0,failedCount:0,summaryActionIndex:0,setStarterKits:r=>e({starterKits:r}),setSelectedStarterKitIndex:r=>e({selectedStarterKitIndex:r}),selectStarterKit:r=>{let n=new Set(ue.getState().installedItems.map(o=>o.name));e({selectedStarterKit:r,plugins:r.plugins.map(o=>({name:o,selected:true,status:n.has(o)?"success":"pending",installed:n.has(o)})),pluginCursorIndex:0,step:"starterKitDetail"});},setPluginCursorIndex:r=>e({pluginCursorIndex:r}),setStep:r=>e({step:r}),setPluginStatus:(r,n,o)=>{let s=t().plugins.map(i=>i.name===r?{...i,status:n,error:o}:i);e({plugins:s});},setIsLoadingStarterKits:r=>e({isLoadingStarterKits:r}),setStarterKitsError:r=>e({starterKitsError:r}),setSummaryActionIndex:r=>e({summaryActionIndex:r}),computeSummary:()=>{let n=t().plugins.filter(o=>o.selected);e({successCount:n.filter(o=>o.status==="success").length,failedCount:n.filter(o=>o.status==="failed").length});},resetForRetry:()=>{let r=t().plugins.map(n=>n.status==="failed"?{...n,status:"pending",error:void 0}:n);e({plugins:r,step:"installing"});},goBackToList:()=>e({selectedStarterKit:null,plugins:[],pluginCursorIndex:0,step:"starterKitList"})}));var ih=3;function Vu(){let e=_(l=>l.setStarterKits),t=_(l=>l.setIsLoadingStarterKits),r=_(l=>l.setStarterKitsError),n=_(l=>l.setPluginStatus),o=_(l=>l.setStep),s=_(l=>l.computeSummary),i=useCallback(async()=>{t(true),r(null);try{let l=await Fo();e(l);}catch(l){r(l instanceof Error?l.message:String(l));}finally{t(false);}},[t,r,e]);useEffect(()=>{ue.getState().loadFromDisk(),i();},[i]);let a=useCallback(async()=>{let l=_.getState().plugins.filter(c=>c.selected&&c.status==="pending");for(let c of l){n(c.name,"installing");let d="",p=false;for(let m=1;m<=ih;m++)try{await Ee(c.name),n(c.name,"success"),p=!0;break}catch(f){if(f instanceof Ne){n(c.name,"success"),p=true;break}d=f instanceof Error?f.message:"Unknown error";}p||(n(c.name,"failed",d),b(v.CLI_TOOL_INSTALL_FAILED,{tool_id:c.name,tool_type:"skill",source:"internal",error_code:"install_failed",error_message:d,interface:H().interfaceType}).catch(()=>{}));}let u=pr();dr("summary_review"),b(v.CLI_STEP_COMPLETED,{step:"tool_installation",duration_ms:u}).catch(()=>{}),ue.getState().loadFromDisk(),s(),o("summary");},[n,s,o]);return {loadStarterKits:i,installSelected:a}}var Wn={cursorDelta:0,confirm:false,back:false};function Hu(e,t){return t.upArrow?{...Wn,cursorDelta:-1}:t.downArrow?{...Wn,cursorDelta:1}:t.escape?{...Wn,back:true}:t.return?{...Wn,confirm:true}:Wn}var ah={cursorDelta:0,select:false};function Ju(e,t){return t.upArrow?{cursorDelta:-1,select:false}:t.downArrow?{cursorDelta:1,select:false}:t.return?{cursorDelta:0,select:true}:ah}var Gu=vf.memo(function({starterKit:t,isSelected:r}){return jsxs(Box,{flexDirection:"column",paddingBottom:1,children:[jsxs(Box,{children:[jsx(Text,{color:r?"cyan":"gray",children:r?"\u203A ":"\u25CB "}),jsx(Text,{bold:r,color:r?"cyan":"white",children:h(t.name)}),jsxs(Text,{dimColor:true,children:[" \xB7 ",t.plugins.length," ",t.plugins.length===1?"plugin":"plugins"]})]}),jsx(Box,{paddingLeft:2,children:jsx(Text,{dimColor:true,children:h(t.description)})})]})});var sa=5;function Wu({onRetry:e}){let t=_(c=>c.starterKits),r=_(c=>c.selectedStarterKitIndex),n=_(c=>c.isLoadingStarterKits),o=_(c=>c.starterKitsError);if(n)return jsx(Mo,{message:"Loading Starter Kits..."});if(o)return jsx(Lo,{message:o,onRetry:e,onBack:e});if(t.length===0)return jsx(Br,{message:"No Starter Kits available."});let s=Math.max(0,r-Math.floor(sa/2)),i=Math.min(t.length,s+sa);i===t.length&&(s=Math.max(0,i-sa));let a=t.slice(s,i),l=s,u=t.length-i;return jsxs(Box,{flexDirection:"column",children:[jsx(Box,{paddingX:1,paddingBottom:1,children:jsx(Text,{bold:true,children:"Select a Starter Kit to get started"})}),l>0&&jsx(Box,{paddingX:2,children:jsxs(Text,{dimColor:true,children:["\u2191 ",l," more above"]})}),a.map((c,d)=>jsx(Gu,{starterKit:c,isSelected:s+d===r},c.slug)),u>0&&jsx(Box,{paddingX:2,children:jsxs(Text,{dimColor:true,children:["\u2193 ",u," more below"]})})]})}var Xu=vf.memo(function({plugin:t,isCursor:r}){return jsxs(Box,{children:[jsx(Text,{color:r?"cyan":"gray",children:r?"\u203A ":" "}),jsx(Text,{color:"cyan",children:"\u2022"}),jsxs(Text,{bold:r,color:r?"cyan":"white",children:[" ",h(t.name)]}),t.installed&&jsx(Text,{color:"green",children:" (installed)"})]})});var la=8;function qu(){let e=_(c=>c.selectedStarterKit),t=_(c=>c.plugins),r=_(c=>c.pluginCursorIndex),n=useRef(false);if(useEffect(()=>{e&&!n.current&&(n.current=true,b(v.CLI_KIT_DISPLAYED,{bundle_slug:e.slug,tool_count:t.length}).catch(()=>{}));},[e,t.length]),!e)return jsx(Text,{dimColor:true,children:"No Starter Kit selected."});let o=t.filter(c=>c.installed).length,s=Math.max(0,r-Math.floor(la/2)),i=Math.min(t.length,s+la);i===t.length&&(s=Math.max(0,i-la));let a=t.slice(s,i),l=s,u=t.length-i;return jsxs(Box,{flexDirection:"column",children:[jsxs(Box,{flexDirection:"column",paddingX:1,paddingBottom:1,children:[jsx(Text,{bold:true,color:"cyan",children:h(e.name)}),jsx(Text,{dimColor:true,children:h(e.description)})]}),jsx(Box,{paddingX:1,paddingBottom:1,children:jsxs(Text,{children:[t.length," plugins to install",o>0&&` \xB7 ${o} already installed`]})}),l>0&&jsx(Box,{paddingX:2,children:jsxs(Text,{dimColor:true,children:["\u2191 ",l," more above"]})}),a.map((c,d)=>jsx(Xu,{plugin:c,isCursor:s+d===r},c.name)),u>0&&jsx(Box,{paddingX:2,children:jsxs(Text,{dimColor:true,children:["\u2193 ",u," more below"]})})]})}var yh=["Retry failed","Continue anyway"];function Yu({name:e,status:t,error:r}){let n=h(e);return t==="installing"?jsxs(Box,{children:[jsx(Text,{color:"cyan",children:jsx(ru,{type:"dots"})}),jsxs(Text,{color:"cyan",children:[" ",n]})]}):t==="success"?jsx(Box,{children:jsxs(Text,{color:"green",children:["\u2713 ",n]})}):t==="failed"?jsxs(Box,{children:[jsxs(Text,{color:"red",children:["\u2717 ",n]}),r&&jsxs(Text,{dimColor:true,children:[" \u2014 ",h(r)]})]}):jsx(Box,{children:jsxs(Text,{dimColor:true,children:["\u25CB ",n]})})}function Zu({onComplete:e,onRetry:t}){let r=_(u=>u.plugins),n=_(u=>u.step),o=_(u=>u.successCount),s=_(u=>u.failedCount),i=_(u=>u.summaryActionIndex),a=r.filter(u=>u.selected),l=useRef(false);return useEffect(()=>{if(n==="summary"&&s===0&&!l.current){l.current=true;let u=setTimeout(e,1500);return ()=>clearTimeout(u)}},[n,s,e]),n==="installing"?jsxs(Box,{flexDirection:"column",children:[jsx(Box,{paddingX:1,paddingBottom:1,children:jsx(Text,{bold:true,children:"Installing plugins..."})}),jsx(Box,{flexDirection:"column",paddingX:1,children:a.map(u=>jsx(Yu,{name:u.name,status:u.status,error:u.error},u.name))})]}):jsxs(Box,{flexDirection:"column",children:[jsx(Box,{paddingX:1,paddingBottom:1,children:jsx(Text,{bold:true,children:"Installation Complete"})}),jsxs(Box,{flexDirection:"column",paddingX:1,paddingBottom:1,children:[o>0&&jsxs(Text,{color:"green",children:["\u2713 ",o," ",o===1?"plugin":"plugins"," installed successfully"]}),s>0&&jsxs(Text,{color:"red",children:["\u2717 ",s," ",s===1?"plugin":"plugins"," failed"]})]}),s>0&&jsx(Box,{flexDirection:"column",paddingX:1,paddingBottom:1,children:a.filter(u=>u.status==="failed").map(u=>jsx(Yu,{name:u.name,status:u.status,error:u.error},u.name))}),s>0&&jsx(Box,{flexDirection:"column",paddingX:1,children:yh.map((u,c)=>jsx(Box,{children:jsxs(Text,{bold:c===i,color:c===i?"cyan":void 0,children:[c===i?"\u203A ":" ",u]})},u))}),s===0&&jsx(Box,{paddingX:1,children:jsx(Text,{dimColor:true,children:"Proceeding to main screen..."})})]})}function Qu(){let e=_(x=>x.step),t=_(x=>x.starterKits),r=_(x=>x.selectedStarterKitIndex),n=_(x=>x.setSelectedStarterKitIndex),o=_(x=>x.selectStarterKit),s=_(x=>x.plugins),i=_(x=>x.pluginCursorIndex),a=_(x=>x.setPluginCursorIndex),l=_(x=>x.setStep),u=_(x=>x.summaryActionIndex),c=_(x=>x.setSummaryActionIndex),d=_(x=>x.failedCount),p=_(x=>x.resetForRetry),m=_(x=>x.goBackToList),f=S(x=>x.setScreen),g=S(x=>x.setFocus),y=S(x=>x.focus),w=Ge(x=>x.setJustAuthenticated),P=Ge(x=>x.justAuthenticated),{loadStarterKits:C,installSelected:k}=Vu(),$=useRef(false);useEffect(()=>{e==="starterKitList"?(g("starterKitList"),$.current||($.current=true,dr("bundle_selection"))):g(e==="starterKitDetail"?"starterKitDetail":"installProgress");},[e,g]);let O=useCallback(async()=>{let x=_.getState().selectedStarterKit;if(x){let F=await oe();F&&await Tt({...F,starterKit:x.slug});}b(v.CLI_STEP_COMPLETED,{step:"summary_review",duration_ms:pr()}).catch(()=>{});let{successCount:A}=_.getState();b(v.CLI_ONBOARDING_COMPLETED,{duration_ms:Ct(),tools_installed_count:A}).catch(()=>{}),w(false),g("verify"),f("verify");},[w,g,f]),G=useCallback(()=>{p(),k();},[p,k]),he=useCallback(()=>{C();},[C]),M=useCallback(()=>{g("verify"),f("verify");},[g,f]);return useInput((x,A)=>{if(A.escape)Po("esc"),M();else if(A.upArrow&&r>0)n(r-1);else if(A.downArrow&&r<t.length-1)n(r+1);else if(A.return&&t.length>0){let F=pr();o(t[r]),dr("kit_display"),b(v.CLI_STEP_COMPLETED,{step:"bundle_selection",duration_ms:F}).catch(()=>{});}},{isActive:y==="starterKitList"}),useInput((x,A)=>{let F=Hu(x,A);if(F.cursorDelta!==0){let W=i+F.cursorDelta;W>=0&&W<s.length&&a(W);}if(F.confirm){let W=_.getState().selectedStarterKit;W&&(async()=>(await oe())?.starterKit!==W.slug&&b(v.CLI_KIT_ACCEPTED,{bundle_slug:W.slug}).catch(()=>{}))();let Et=pr();dr("kit_confirmation"),b(v.CLI_STEP_COMPLETED,{step:"kit_display",duration_ms:Et}).catch(()=>{});let dn=pr();dr("tool_installation"),b(v.CLI_STEP_COMPLETED,{step:"kit_confirmation",duration_ms:dn}).catch(()=>{}),l("installing"),k();}if(F.back){let W=_.getState().selectedStarterKit;W&&b(v.CLI_KIT_REJECTED,{bundle_slug:W.slug}).catch(()=>{}),m();}},{isActive:y==="starterKitDetail"}),useInput((x,A)=>{if(d===0)return;let F=Ju(x,A);if(F.cursorDelta!==0){let W=u+F.cursorDelta;W>=0&&W<=1&&c(W);}F.select&&(u===0?G():O());},{isActive:y==="installProgress"&&e==="summary"}),jsxs(Box,{flexDirection:"column",borderStyle:"round",paddingX:1,children:[jsx(Nr,{}),jsxs(Box,{flexDirection:"column",paddingX:1,marginBottom:1,children:[jsx(Text,{dimColor:true,children:"The data collected during setup is used solely to improve"}),jsx(Text,{dimColor:true,children:"Flow's internal tools and will not be shared externally."}),!P&&jsx(Box,{marginTop:1,children:jsx(Text,{color:"yellow",children:"Welcome back! We noticed your Starter Kit is not set up yet. Choose a Starter Kit below to get your recommended tools."})})]}),jsxs(Box,{flexDirection:"column",flexGrow:1,children:[e==="starterKitList"&&jsx(Wu,{onRetry:he}),e==="starterKitDetail"&&jsx(qu,{}),(e==="installing"||e==="summary")&&jsx(Zu,{onComplete:O,onRetry:G})]}),jsx($o,{})]})}var vh=I("moduleState");function ws(){let e=process.env.FLOW_HOME??me__default.join(Le__default.homedir(),".flow");return me__default.join(e,"modules.json")}var bh={retries:5,minTimeout:50};async function ed(e,t){ve__default.mkdirSync(me__default.dirname(e),{recursive:true});let r=await og.lock(e+".lock",{realpath:false,retries:bh});try{return await t()}finally{await r();}}function td(){let e=ws();if(!ve__default.existsSync(e))return [];try{let t=JSON.parse(ve__default.readFileSync(e,"utf-8"));return t.schemaVersion!==1?(vh.warn(`modules.json has unknown schemaVersion ${t.schemaVersion}, resetting`),ve__default.rmSync(e,{force:!0}),[]):Array.isArray(t.modules)?t.modules.map(r=>({...r,name:r.name??null})):[]}catch{return ve__default.rmSync(e,{force:true}),[]}}function Pr(){return td()}function rd(e){let t=ws();ve__default.mkdirSync(me__default.dirname(t),{recursive:true});let r=`${t}.${randomUUID()}.tmp`,n={schemaVersion:1,modules:e};ve__default.writeFileSync(r,JSON.stringify(n,null,2),"utf-8"),ve__default.renameSync(r,t);}function et(e){return Pr().find(t=>t.alias===e)??null}async function xt(e){let t=ws();await ed(t,async()=>{let r=td(),n=r.findIndex(o=>o.alias===e.alias);n===-1?r.push(e):r[n]=e,rd(r);});}async function rn(){let e=ws();ve__default.existsSync(e)||await ed(e,async()=>{ve__default.existsSync(e)||rd([]);});}var Th=promisify(execFile);function sr(e,t){let r=e.platforms[process.platform];return !r||r.status!=="supported"?null:r.strategies.find(n=>n.type===t)??null}async function It(e){let t=process.platform==="win32"?"where":"which";try{return await Th(t,[e]),!0}catch{return false}}function Nt(){return process.platform==="win32"?"npm.cmd":"npm"}var nd=promisify(execFile),xs=class{type="npm";async isAvailable(){return It("npm")}async install(t){let r=await this.getInstalledVersion(t);return r?{success:true,version:r,method:"npm",durationMs:0}:this.runNpmInstall(t,false)}async update(t,r){return this.runNpmInstall(t,true)}async getInstalledVersion(t){let r=sr(t,"npm");if(!r)return null;try{let{stdout:n}=await nd(Nt(),["list","-g",r.package,"--depth=0","--json"],{shell:process.platform==="win32"});return JSON.parse(n).dependencies?.[r.package]?.version??null}catch{return null}}async uninstall(t){return {success:false,error:{code:"NOT_IMPLEMENTED",message:"uninstall not implemented"},durationMs:0}}async runNpmInstall(t,r){let n=Date.now(),o=sr(t,"npm");if(!o)return {success:false,error:{code:"NPM_NOT_AVAILABLE",message:"No npm config for this module on this platform"},durationMs:Date.now()-n};let s=r?`${o.package}@latest`:o.package;try{return await nd(Nt(),["install","-g",s],{shell:process.platform==="win32"}),{success:!0,version:await this.getInstalledVersion(t)??void 0,method:"npm",durationMs:Date.now()-n}}catch(i){return {success:false,error:{code:"NPM_INSTALL_FAILED",message:i instanceof Error?i.message:String(i)},durationMs:Date.now()-n}}}};var od=promisify(execFile),Mh=/^(\S+)\s+([\d]+\.[\d]+(?:\.[\d]+)*(?:[-_][^\s]+)?)/,Is=class{type="homebrew";async isAvailable(){return It("brew")}async install(t){return this.runBrewCommand(t,"install")}async update(t,r){return this.runBrewCommand(t,"upgrade")}async getInstalledVersion(t){let r=sr(t,"homebrew");return r?this.getVersionByFormula(r.formula):null}async uninstall(t){return {success:false,error:{code:"NOT_IMPLEMENTED",message:"uninstall not implemented"},durationMs:0}}async runBrewCommand(t,r){let n=Date.now(),o=sr(t,"homebrew");if(!o)return {success:false,error:{code:"HOMEBREW_NOT_AVAILABLE",message:"No homebrew config for this module on this platform"},durationMs:Date.now()-n};let s=r==="install"?"HOMEBREW_INSTALL_FAILED":"HOMEBREW_UPGRADE_FAILED";try{return await od("brew",[r,o.formula]),{success:!0,version:await this.getVersionByFormula(o.formula)??void 0,method:"homebrew",durationMs:Date.now()-n}}catch(i){return {success:false,error:{code:s,message:i instanceof Error?i.message:String(i)},durationMs:Date.now()-n}}}async getVersionByFormula(t){try{let{stdout:r}=await od("brew",["list","--versions",t]),n=r.trim().match(Mh);return n?n[2]:null}catch{return null}}};var nn=promisify(execFile),Dh=I("curlStrategy"),id=/([\d]+\.[\d]+(?:\.[\d]+)*(?:[-_][^\s]+)?)/;function ad(){let e=process.env.FLOW_HOME??me__default.join(Le__default.homedir(),".flow");return me__default.join(e,"bin")}var vs=class{type="curl";async isAvailable(){return It("curl")}async install(t){let r=Date.now(),n=sr(t,"curl");if(!n)return {success:false,error:{code:"CURL_NOT_AVAILABLE",message:"No curl config for this module on this platform"},durationMs:Date.now()-r};let o=typeof n.url=="function"?n.url(process.arch):n.url;return (n.mode??"binary")==="script"?this.installScript(o,n.checksumUrl,t,r):this.installBinary(o,n.checksumUrl,t,r)}async update(t,r){return this.install(t)}async getInstalledVersion(t){let r=me__default.join(ad(),t.binaryName);for(let n of [r,t.binaryName])try{let{stdout:o}=await nn(n,["--version"]),s=o.match(id);if(s)return s[1]}catch{}return null}async uninstall(t){return {success:false,error:{code:"NOT_IMPLEMENTED",message:"uninstall not implemented"},durationMs:0}}async installScript(t,r,n,o){let s=me__default.join(Le__default.tmpdir(),`flow-install-${randomUUID()}.sh`);try{if(await nn("curl",["-sSL","--fail","-o",s,t]),r||Dh.warn(`Installing script for "${n.alias}" without checksum verification \u2014 checksumUrl not provided`),r){let a=await this.validateChecksum(s,r);if(!a.valid){try{ve__default.unlinkSync(s);}catch{}return {success:!1,error:{code:"CHECKSUM_MISMATCH",message:a.message},durationMs:Date.now()-o}}}return ve__default.chmodSync(s,448),await nn("bash",[s]),{success:!0,version:await this.getInstalledVersion(n)??void 0,method:"curl",durationMs:Date.now()-o}}catch(i){return {success:false,error:{code:"CURL_SCRIPT_FAILED",message:i instanceof Error?i.message:String(i)},durationMs:Date.now()-o}}finally{try{ve__default.unlinkSync(s);}catch{}}}async installBinary(t,r,n,o){let s=ad(),i=me__default.join(s,n.binaryName),a=false;try{if(ve__default.mkdirSync(s,{recursive:!0}),a=!0,await nn("curl",["-L","--fail","-o",i,t]),r){let u=await this.validateChecksum(i,r);if(!u.valid)return ve__default.unlinkSync(i),{success:!1,error:{code:"CHECKSUM_MISMATCH",message:u.message},durationMs:Date.now()-o}}ve__default.chmodSync(i,493);let l=null;try{let{stdout:u}=await nn(i,["--version"]),c=u.match(id);l=c?c[1]:null;}catch{}return {success:!0,version:l??void 0,method:"curl",durationMs:Date.now()-o}}catch(l){if(a)try{ve__default.unlinkSync(i);}catch{}return {success:false,error:{code:"CURL_DOWNLOAD_FAILED",message:l instanceof Error?l.message:String(l)},durationMs:Date.now()-o}}}async validateChecksum(t,r){let n=me__default.join(Le__default.tmpdir(),`curl-checksum-${randomUUID()}`);try{await nn("curl",["-L","--fail","-o",n,r]);let o=ve__default.readFileSync(n,"utf-8").trim().split(/\s+/)[0],s=ve__default.readFileSync(t),i=createHash("sha256").update(s).digest("hex");return i!==o?{valid:!1,message:`SHA256 mismatch: expected ${o}, got ${i}`}:{valid:!0,message:""}}catch(o){return {valid:false,message:`Checksum validation failed: ${String(o)}`}}finally{try{ve__default.unlinkSync(n);}catch{}}}};var Ae=I("moduleInstaller");function Bt(e){switch(e){case "npm":return new xs;case "homebrew":return new Is;case "curl":return new vs}}async function qn(e,t,r){try{await b(v.CLI_MODULE_INSTALL_FAILED,{module_alias:e.alias,module_name:e.name,os:process.platform,error_code:r.code,error_message:r.message,trigger:t});}catch(n){Ae.warn(`Failed to emit install failed event: ${String(n)}`);}}async function sn(e,t,r){let n=Date.now(),o=e.platforms[process.platform];if(!o)return {success:false,error:{code:"PLATFORM_NOT_SUPPORTED",message:`Platform ${process.platform} is not listed for module ${e.alias}`},durationMs:Date.now()-n};if(o.status==="experimental"){Ae.warn(`Module "${e.alias}" has experimental support on ${process.platform}`);let l={code:"PLATFORM_EXPERIMENTAL",message:`Experimental support on ${process.platform} \u2014 install manually`};return await qn(e,t,l),{success:false,error:l,durationMs:Date.now()-n}}if(o.status!=="supported"){let l={code:"PLATFORM_NOT_SUPPORTED",message:`Module ${e.alias} is not supported on ${process.platform}`};return await qn(e,t,l),{success:false,error:l,durationMs:Date.now()-n}}if(!o.strategies.some(l=>l.type===r)){let l={code:"STRATEGY_NOT_FOUND",message:`Strategy "${r}" is not configured for module "${e.alias}" on ${process.platform}`};return await qn(e,t,l),{success:false,error:l,durationMs:Date.now()-n}}let s=Bt(r),i=false;try{i=await s.isAvailable();}catch(l){Ae.warn(`${r} availability check failed: ${String(l)}`);}if(!i){let l={code:"STRATEGY_NOT_AVAILABLE",message:`"${r}" is not installed on this system`};return await qn(e,t,l),{success:false,error:l,durationMs:Date.now()-n}}try{await b(v.CLI_MODULE_INSTALL_STARTED,{module_alias:e.alias,module_name:e.name,os:process.platform,cli_version:ae,trigger:t});}catch(l){Ae.warn(`Failed to emit install started event: ${String(l)}`);}let a;try{a=await s.install(e);}catch(l){let u=l instanceof Error?l.message:String(l);Ae.warn(`${r} install threw: ${u}`),a={success:false,error:{code:"INSTALL_THREW",message:u},durationMs:Date.now()-n};}if(a.success){await xt({alias:e.alias,name:e.name,installedVersion:a.version??null,installMethod:a.method??null,installedAt:new Date().toISOString(),lastChecked:new Date().toISOString()});try{await b(v.CLI_MODULE_INSTALL_COMPLETED,{module_alias:e.alias,module_name:e.name,installed_version:a.version??"unknown",duration_ms:a.durationMs,os:process.platform,trigger:t});}catch(u){Ae.warn(`Failed to emit install completed event: ${String(u)}`);}let l=await Nh(e,t);return l?{...a,pendingInteractiveSetup:l}:a}return await qn(e,t,a.error??{code:"UNKNOWN",message:"unknown error"}),a}async function Nh(e,t){if(!e.postInstall)return null;let r=t==="onboarding"?e.postInstall.onboarding:e.postInstall.onDemand;if(r==null)return null;let n;if(typeof r=="function"){let o=await oe(),s={credentials:o?{clientId:o.clientId,clientSecret:o.clientSecret,tenant:o.tenant}:null};try{n=r(s);}catch(i){return Ae.warn(`postInstall function threw: ${String(i)}`),null}}else n=r;if(n.length===0)return null;if((e.postInstall.mode??"non-interactive")==="interactive")return n[0]??null;for(let o of n){if(o.length===0)continue;let s=spawnSync(o[0],o.slice(1),{stdio:"pipe",env:process.env,encoding:"utf-8",shell:process.platform==="win32"});if(s.status!==0)return Ae.warn(`postInstall "${o.join(" ")}" exited with status ${s.status??"null"}`),s.stderr&&Ae.warn(s.stderr),null}return null}async function bs(e,t){let r=Date.now(),n=et(e.alias);if(!n?.installMethod)return {success:false,error:{code:"NOT_INSTALLED",message:`Module '${e.alias}' is not installed`},durationMs:Date.now()-r};let o=Bt(n.installMethod),s=n.installedVersion??"unknown";if(t==="command")try{await b(v.CLI_MODULE_INSTALL_STARTED,{module_alias:e.alias,module_name:e.name,os:process.platform,cli_version:ae,trigger:"command"});}catch(a){Ae.warn(`Failed to emit update started event: ${String(a)}`);}let i;try{i=await o.update(e,s);}catch(a){let l=a instanceof Error?a.message:String(a);Ae.warn(`${n.installMethod} update threw: ${l}`),i={success:false,error:{code:"UPDATE_THREW",message:l},durationMs:Date.now()-r};}if(i.success)if(await xt({...n,installedVersion:i.version??n.installedVersion,lastChecked:new Date().toISOString()}),t==="command")try{await b(v.CLI_MODULE_INSTALL_COMPLETED,{module_alias:e.alias,module_name:e.name,installed_version:i.version??"unknown",duration_ms:i.durationMs,os:process.platform,trigger:"command"});}catch(a){Ae.warn(`Failed to emit update completed event: ${String(a)}`);}else try{await b(v.CLI_MODULE_UPDATED,{module_alias:e.alias,from_version:s,to_version:i.version??"unknown",duration_ms:i.durationMs});}catch(a){Ae.warn(`Failed to emit module updated event: ${String(a)}`);}else if(t==="command")try{await b(v.CLI_MODULE_INSTALL_FAILED,{module_alias:e.alias,module_name:e.name,os:process.platform,error_code:i.error?.code??"UNKNOWN",error_message:i.error?.message??"unknown error",trigger:"command"});}catch(a){Ae.warn(`Failed to emit update failed event: ${String(a)}`);}return i}function Bh(e){let t=e.module.platforms[process.platform];return (t?.status==="supported"?t.strategies:[]).map(n=>n.type==="npm"?`npm install -g ${n.package}`:n.type==="homebrew"?`brew install ${n.formula}`:"curl (see docs)").join(" or ")}function ud(e){let[t,r]=useState(()=>e.map(c=>({alias:c.module.alias,name:c.module.name,status:"pending"}))),[n,o]=useState(false),s=useCallback((c,d)=>{r(p=>p.map(m=>m.alias===c?{...m,...d}:m));},[]),i=useCallback(async()=>{for(let c of e){let d=Bh(c);if(!c.selectedStrategy){let p=d?`No package manager available. Install manually: ${d}`:"No package manager available for this platform";s(c.module.alias,{status:"failed",error:p,manualInstallHint:d||void 0});continue}s(c.module.alias,{status:"installing"});try{let p=await sn(c.module,"onboarding",c.selectedStrategy);p.success?s(c.module.alias,{status:"installed",pendingSetupCommand:p.pendingInteractiveSetup?.join(" ")}):s(c.module.alias,{status:"failed",error:p.error?.message??"Installation failed",manualInstallHint:d});}catch(p){s(c.module.alias,{status:"failed",error:p instanceof Error?p.message:"Unknown error",manualInstallHint:d});}}o(true);},[e,s]),a=useMemo(()=>t.filter(c=>c.status==="installed").length,[t]),l=useMemo(()=>t.filter(c=>c.status==="failed").length,[t]),u=useMemo(()=>t.filter(c=>c.status==="skipped").length,[t]);return {modules:t,install:i,isComplete:n,installedCount:a,failedCount:l,skippedCount:u}}function jh(e){return e.filter(t=>t.module.platforms[process.platform]?.status==="supported").filter(t=>!t.alreadyInstalled).map(t=>({module:t.module,alreadyInstalled:t.alreadyInstalled,checked:!t.alreadyInstalled&&(t.availableStrategies.length>0||t.module.required===true),selectedStrategy:t.availableStrategies[0]??null,availableStrategies:t.availableStrategies}))}function gd(e,t){let[r,n]=useState(()=>jh(e)),[o,s]=useState(0),i=useRef(o);useEffect(()=>{i.current=o;},[o]);let a=useRef(r);useEffect(()=>{a.current=r;},[r]);let l=useCallback(d=>{n(p=>p.map(m=>m.module.alias!==d||m.module.required?m:{...m,checked:!m.checked}));},[]),u=useCallback((d,p)=>{n(m=>m.map(f=>f.module.alias===d?{...f,selectedStrategy:p}:f));},[]);useInput((d,p)=>{let m=i.current,f=a.current,g=p.upArrow||d==="[A",y=p.downArrow||d==="[B";if(g||y)g&&m>0?s(m-1):y&&m<f.length-1&&s(m+1);else if(d===" "){let w=f[m];w&&!w.module.required&&l(w.module.alias);}else if(p.tab){let w=f[m];if(w&&w.availableStrategies.length>1){let P=w.availableStrategies.indexOf(w.selectedStrategy??w.availableStrategies[0]),C=w.availableStrategies[(P+1)%w.availableStrategies.length];n(k=>k.map($=>$.module.alias===w.module.alias?{...$,selectedStrategy:C}:$));}}},{isActive:t});let c=useMemo(()=>r.filter(d=>d.checked),[r]);return {items:r,focusedIndex:o,toggle:l,setStrategy:u,confirmedItems:c}}function Kh(){return te.filter(e=>e.platforms[process.platform]?.status==="supported")}function hd(e){let t=Kh();return t.length>0&&t.every(r=>e.find(n=>n.module.alias===r.alias)?.alreadyInstalled===true)}var yd={alias:"metrics",required:true,name:"flow-ai-obs",binaryName:"flow-ai-obs",description:"AI usage telemetry and observability (hooks, OTEL, LLM proxy)",platforms:{darwin:{status:"supported",strategies:[{type:"npm",package:"@ciandt-flow/flow-ai-obs"}]},linux:{status:"supported",strategies:[{type:"npm",package:"@ciandt-flow/flow-ai-obs"}]},win32:{status:"supported",strategies:[{type:"npm",package:"@ciandt-flow/flow-ai-obs"}]}},versionCheck:{type:"npm-registry",package:"@ciandt-flow/flow-ai-obs"},versionCommand:["flow-ai-obs","--version"],hasOwnUpdateCheck:true,postInstall:{onboarding:e=>{if(!e.credentials)throw new Error("flow-ai-obs setup requires credentials");let{clientId:t,clientSecret:r,tenant:n}=e.credentials;return [["flow-ai-obs","auth","login","--client-id",t,"--client-secret",r,"--tenant",n],["flow-ai-obs","install"]]},onDemand:null,mode:"non-interactive"}},Vh={alias:"dashboard",name:"ccboard",binaryName:"ccboard",description:"Claude Code session monitoring dashboard",docs:"https://github.com/FlorianBruniaux/ccboard",platforms:{darwin:{status:"supported",strategies:[{type:"homebrew",formula:"ccboard"},{type:"curl",url:"https://raw.githubusercontent.com/FlorianBruniaux/ccboard/main/install.sh",mode:"script"}]},linux:{status:"supported",strategies:[{type:"curl",url:"https://raw.githubusercontent.com/FlorianBruniaux/ccboard/main/install.sh",mode:"script"}]},win32:{status:"experimental"}},versionCheck:{type:"github-releases",repo:"florianbruniaux/ccboard"},versionCommand:["ccboard","--version"],hasOwnUpdateCheck:false},te=Gt()?[yd,Vh]:[yd];var xd=null;function Id(){return xd}async function Es(){let t=Pr().filter(r=>r.installedVersion===null&&r.installMethod===null);for(let r of t){let n=te.find(i=>i.alias===r.alias);if(!n)continue;let{installedVersion:o,installMethod:s}=await vd(n);(o||s)&&await xt({...r,installedVersion:o,installMethod:s});}}async function vd(e){let t=e.platforms[process.platform];if(t?.status!=="supported")return {installedVersion:null,installMethod:null};for(let r of t.strategies)if(r.type!=="curl")try{let o=await Bt(r.type).getInstalledVersion(e);if(o)return {installedVersion:o,installMethod:r.type}}catch{}return {installedVersion:null,installMethod:null}}async function an(e){let t=await Promise.all(e.map(r=>Hh(r)));return xd=t,t}async function Hh(e){let t=Sd(e.versionCommand);t==="permission-denied"&&(Jh(e.versionCommand[0]),t=Sd(e.versionCommand));let r=t==="installed",n=e.platforms[process.platform],o=n?.status==="supported"?n.strategies:[],i=(await Promise.all(o.map(async a=>{try{return await Bt(a.type).isAvailable()?a.type:null}catch{return null}}))).filter(a=>a!==null);if(r&&!et(e.alias)){let{installedVersion:a,installMethod:l}=await vd(e);await xt({alias:e.alias,name:e.name,installedVersion:a,installMethod:l,installedAt:null,lastChecked:new Date().toISOString()});}return {module:e,alreadyInstalled:r,availableStrategies:i}}function Sd(e){if(e.length===0)return "not-found";try{let t=spawnSync(e[0],e.slice(1),{timeout:3e3,stdio:"pipe",shell:process.platform==="win32"});return t.status===0?"installed":t.status===126?"permission-denied":"not-found"}catch{return "not-found"}}function Jh(e){if(process.platform!=="win32")try{let t=spawnSync("which",[e],{stdio:"pipe"});if(t.status!==0)return;let r=t.stdout.toString().trim(),n=ve__default.realpathSync(r),{mode:o}=ve__default.statSync(n);ve__default.chmodSync(n,o|73);}catch{}}function Wh({module:e}){let t=h(e.name);return e.status==="installing"?jsxs(Box,{children:[jsx(Text,{color:"cyan",children:jsx(ru,{type:"dots"})}),jsxs(Text,{color:"cyan",children:[" ",t," \u2014 Installing..."]})]}):e.status==="installed"?jsxs(Box,{flexDirection:"column",children:[jsx(Box,{children:jsxs(Text,{color:"green",children:["\u2713 ",t]})}),e.pendingSetupCommand&&jsx(Box,{paddingLeft:2,children:jsxs(Text,{dimColor:true,children:["\u2139 Run '",h(e.pendingSetupCommand),"' to complete configuration"]})})]}):e.status==="failed"?jsxs(Box,{flexDirection:"column",children:[jsxs(Box,{children:[jsxs(Text,{color:"red",children:["\u2717 ",t]}),e.error&&jsxs(Text,{dimColor:true,children:[" \u2014 ",h(e.error)]})]}),e.manualInstallHint&&jsx(Box,{paddingLeft:2,children:jsxs(Text,{dimColor:true,children:["Install manually: ",h(e.manualInstallHint)]})})]}):e.status==="skipped"?jsx(Box,{children:jsxs(Text,{dimColor:true,children:["- ",t," (not supported on this platform)"]})}):jsx(Box,{children:jsxs(Text,{dimColor:true,children:["\u25CB ",t]})})}function zh({confirmedItems:e}){let t=S(f=>f.setScreen),r=S(f=>f.setFocus),{modules:n,install:o,isComplete:s,installedCount:i,failedCount:a,skippedCount:l}=ud(e),u=useRef(false),c=useRef(false);useEffect(()=>{u.current||(u.current=true,o());},[o]);let d=useCallback(()=>{rn().catch(()=>{}),r("list");let f=se().some(g=>g.name===ie);t(f?"main":"claudeMdSuggestion");},[r,t]);useEffect(()=>{if(s&&a===0&&!c.current){c.current=true;let f=setTimeout(d,1500);return ()=>clearTimeout(f)}},[s,a,d]),useInput((f,g)=>{g.return&&d();},{isActive:s});let p=s,m=[];return i>0&&m.push(jsxs(Text,{color:"green",children:[i," installed"]},"i")),a>0&&m.push(jsxs(Text,{color:"red",children:[a," failed"]},"f")),l>0&&m.push(jsxs(Text,{dimColor:true,children:[l," skipped"]},"s")),jsxs(Fragment,{children:[jsx(Box,{paddingX:1,paddingBottom:1,children:jsx(Text,{bold:true,children:s?"Modules ready":"Setting up modules..."})}),jsx(Box,{flexDirection:"column",paddingX:1,paddingBottom:1,children:n.map(f=>jsx(Wh,{module:f},f.alias))}),p&&jsxs(Fragment,{children:[jsx(Box,{paddingX:1,paddingBottom:1,children:m.reduce((f,g,y)=>(y>0&&f.push(jsx(Text,{children:" | "},`sep-${y}`)),f.push(g),f),[])}),jsx(Box,{paddingX:1,children:a>0?jsx(Text,{dimColor:true,children:"Press Enter to continue"}):jsx(Text,{dimColor:true,children:"Proceeding..."})})]})]})}function Xh({probeResults:e,onConfirm:t}){let r=S(m=>m.focus),n=S(m=>m.actionMenuOpen),o=S(m=>m.setActionMenuOpen),s=S(m=>m.setFocus),{items:i,focusedIndex:a,confirmedItems:l}=gd(e,r==="moduleSetup"),u=useCallback(()=>{o(false),s("moduleSetup");},[o,s]),c=useCallback(m=>{(m==="Install"||m==="Skip")&&t(l),u();},[l,t,u]);useInput((m,f)=>{f.return&&(o(true),s("actionMenu"));},{isActive:r==="moduleSetup"});let d=l.length>0?["Install","Cancel"]:["Skip","Cancel"],p=l.length>0?`Install ${l.length} module(s)?`:"No modules selected";return jsxs(Fragment,{children:[jsx(Box,{paddingX:1,paddingBottom:1,children:jsx(Text,{bold:true,children:"Configure modules"})}),jsx(Box,{flexDirection:"column",paddingX:1,paddingBottom:1,children:i.map((m,f)=>{let g=f===a,y=h(m.module.name);return m.availableStrategies.length===0?jsxs(Box,{children:[jsxs(Text,{dimColor:true,children:[" [ ] ",y," "]}),jsx(Text,{dimColor:true,children:"\u2014 no installer available"})]},m.module.alias):jsxs(Box,{flexDirection:"column",children:[jsxs(Box,{children:[jsxs(Text,{color:g?"cyan":void 0,children:[g?"\u25B6":" ",m.checked?" [\u2713] ":" [ ] ",y]}),m.module.required&&jsx(Text,{dimColor:true,children:" (required)"}),jsxs(Text,{dimColor:true,children:[" ",m.selectedStrategy??""]}),m.availableStrategies.length>1&&jsxs(Text,{dimColor:true,children:[" ","(",m.availableStrategies.indexOf(m.selectedStrategy??m.availableStrategies[0])+1,"/",m.availableStrategies.length," \u2194)"]})]}),m.module.description&&jsx(Box,{paddingLeft:6,children:jsx(Text,{dimColor:true,children:h(m.module.description)})})]},m.module.alias)})}),jsx(Box,{paddingX:1,children:jsx(Text,{dimColor:true,children:"\u2191\u2193 navigate \xB7 Space toggle \xB7 Tab change method \xB7 Enter confirm"})}),n&&jsx(ze,{itemName:p,actions:d,onAction:c,onClose:u})]})}function Pd(){let[e,t]=useState("loading"),[r,n]=useState([]),[o,s]=useState([]),i=S(c=>c.setFocus),a=S(c=>c.setScreen),l=useCallback(c=>{if(hd(c)){rn().catch(()=>{}),i("list");let p=se().some(m=>m.name===ie);a(p?"main":"claudeMdSuggestion");}else n(c),t("selection");},[i,a]);useEffect(()=>{let c=Id();if(c){l(c);return}an(te).then(l).catch(()=>{n([]),t("selection");});},[l]);let u=useCallback(c=>{s(c),t("installation");},[]);return jsxs(Box,{flexDirection:"column",borderStyle:"round",paddingX:1,children:[e==="loading"&&jsx(Box,{paddingX:1,paddingBottom:1,children:jsx(Text,{bold:true,children:"Setting up modules..."})}),e==="selection"&&jsx(Xh,{probeResults:r,onConfirm:u}),e==="installation"&&jsx(zh,{confirmedItems:o})]})}var Qh=I("ClaudeMdSuggestion"),eS=[`Install ${ie}`,"Skip for now"],tS=["Retry","Skip for now"];function kd(){let e=S(p=>p.setScreen),t=S(p=>p.setFocus),r=_(p=>p.successCount),[n,o]=useState("prompt"),[s,i]=useState(0),a=useRef(0),l=useCallback(()=>{t("list"),e("main");},[t,e]),u=useCallback(()=>{b(v.CLI_CLAUDE_MD_SKIPPED,{interface:"tui"}).catch(()=>{}),l();},[l]),c=useCallback(async()=>{a.current+=1,b(v.CLI_CLAUDE_MD_ACCEPTED,{interface:"tui",attempt:a.current}).catch(()=>{}),o("installing");try{await Ee(ie),o("installed");}catch(p){if(p instanceof Ne){o("installed");return}Qh.warn(`Failed to install ${ie}: ${p instanceof Error?p.message:p}`),o("error");}},[]),d=n==="error"?tS:eS;return useInput((p,m)=>{if(m.escape){n==="prompt"||n==="error"?u():n==="installed"&&l();return}if(n==="prompt"||n==="error"){m.upArrow&&s>0?i(s-1):m.downArrow&&s<d.length-1?i(s+1):m.return&&(s===0?(i(0),c()):u());return}n==="installed"&&m.return&&l();}),jsxs(Box,{flexDirection:"column",borderStyle:"round",paddingX:1,children:[jsx(Nr,{}),jsxs(Box,{flexDirection:"column",paddingX:1,gap:1,children:[jsx(Text,{color:"green",bold:true,children:r>0?"\u2713 Starter kit installed!":"\u2713 Setup complete!"}),n==="prompt"&&jsxs(Fragment,{children:[jsxs(Box,{flexDirection:"column",children:[jsx(Text,{bold:true,children:"Personalize your Claude Code"}),jsx(Text,{children:"This plugin helps Claude understand your preferences and work style."})]}),jsx(Cd,{options:d,cursorIndex:s}),jsx(Text,{dimColor:true,children:"You can always install it later from the catalog."})]}),n==="installing"&&jsxs(Box,{children:[jsx(Text,{color:"cyan",children:jsx(ru,{type:"dots"})}),jsxs(Text,{color:"cyan",children:[" Installing ",ie,"..."]})]}),n==="installed"&&jsxs(Fragment,{children:[jsxs(Text,{color:"green",bold:true,children:["\u2713 ",ie," installed!"]}),jsxs(Box,{flexDirection:"column",children:[jsx(Text,{children:"Open Claude in a new terminal or in VS Code and type:"}),jsxs(Text,{bold:true,color:"cyan",children:["/",ie]})]}),jsx(Text,{children:"Claude will guide you through the rest."}),jsx(Text,{dimColor:true,children:"Press Enter to continue to the catalog..."})]}),n==="error"&&jsxs(Fragment,{children:[jsxs(Text,{color:"red",bold:true,children:["\u2717 Failed to install ",ie]}),jsx(Cd,{options:d,cursorIndex:s}),jsx(Text,{dimColor:true,children:"You can always install it later from the catalog."})]})]})]})}function Cd({options:e,cursorIndex:t}){return jsx(Box,{flexDirection:"column",children:e.map((r,n)=>jsxs(Text,{bold:n===t,color:n===t?"cyan":void 0,children:[n===t?"\u203A ":" ",r]},r))})}var sS=promisify(execFile),Ps="@ciandt-flow/cli";async function Ad(){let e=ae;if(Xi.prerelease(e)||process.env.NODE_ENV==="development")return {currentVersion:e,latestVersion:e,isOutdated:false,packageName:Ps};try{let t=await fetch(`https://registry.npmjs.org/${Ps}/latest`);if(!t.ok)throw new Error(`Registry returned ${t.status}`);let n=(await t.json()).version;return {currentVersion:e,latestVersion:n,isOutdated:n!==e,packageName:Ps}}catch{return {currentVersion:e,latestVersion:e,isOutdated:false,packageName:Ps}}}async function Ts(e){try{return await sS(Nt(),["install","-g",e.packageName],{timeout:6e4,shell:process.platform==="win32"}),{success:!0}}catch(t){return {success:false,error:String(t)}}}async function $d(e){let r=et(e.alias)?.installedVersion??null,n=null;try{if(e.versionCheck.type==="npm-registry"){let s=await fetch(`https://registry.npmjs.org/${e.versionCheck.package}/latest`);if(!s.ok)throw new Error(`Registry returned ${s.status}`);n=(await s.json()).version;}else if(e.versionCheck.type==="github-releases"){let s=await fetch(`https://api.github.com/repos/${e.versionCheck.repo}/releases/latest`);if(!s.ok)throw new Error(`GitHub returned ${s.status}`);n=(await s.json()).tag_name.replace(/^v/,"");}}catch{}let o=r!==null&&n!==null&&r!==n;return {moduleAlias:e.alias,currentVersion:r,latestVersion:n,isOutdated:o}}async function Md(e,t){let r=et(e.alias);if(!r?.installMethod)return {success:false,error:"Unknown install method"};let o=await Bt(r.installMethod).update(e,t.currentVersion??"");return o.success?(await xt({...r,installedVersion:o.version??r.installedVersion,lastChecked:new Date().toISOString()}),{success:true,newVersion:o.version}):{success:false,error:o.error?.message}}function Ld(e){let r=et(e.alias)?.installMethod,n=e.platforms[process.platform];if(n?.status==="supported"){if(r==="npm"){let o=n.strategies.find(s=>s.type==="npm");if(o?.type==="npm")return `npm install -g ${o.package}`}if(r==="homebrew"){let o=n.strategies.find(s=>s.type==="homebrew");if(o?.type==="homebrew")return `brew upgrade ${o.formula}`}}}function Rd(){let[e,t]=useState({outcome:"running",items:[{id:"cli",label:"@ciandt-flow/cli",status:"pending"},...te.map(n=>({id:n.alias,label:n.name,status:"pending"}))]}),r=useCallback((n,o)=>{t(s=>({...s,items:s.items.map(i=>i.id===n?{...i,...o}:i)}));},[]);return useEffect(()=>{async function n(){try{let[o,s,i]=await Promise.all([Ad(),an(te),Promise.all(te.map(l=>$d(l)))]);if(Es(),o.isOutdated){r("cli",{status:"updating",detail:`v${o.currentVersion} \u2192 v${o.latestVersion}`}),(await Ts(o)).success?(r("cli",{status:"updated",detail:`v${o.currentVersion} \u2192 v${o.latestVersion}`}),t(u=>({...u,outcome:"cli-updated"}))):(r("cli",{status:"error",detail:`v${o.currentVersion} \u2192 v${o.latestVersion}`,manualCommand:`npm install -g ${o.packageName}`}),t(u=>({...u,outcome:"cli-update-failed"})));return}r("cli",{status:"ok",detail:`v${o.currentVersion}`});let a=s.some(l=>!l.alreadyInstalled);for(let l of s)l.alreadyInstalled||r(l.module.alias,{status:"missing"});if(a){t(l=>({...l,outcome:"module-missing"}));return}for(let l of i){let u=te.find(d=>d.alias===l.moduleAlias);if(!u)continue;if(!l.isOutdated){r(l.moduleAlias,{status:"ok",detail:l.currentVersion?`v${l.currentVersion}`:void 0});continue}r(l.moduleAlias,{status:"updating",detail:`v${l.currentVersion} \u2192 v${l.latestVersion}`});let c=await Md(u,l);c.success?r(l.moduleAlias,{status:"updated",detail:`v${c.newVersion}`}):r(l.moduleAlias,{status:"error",detail:`v${l.currentVersion} \u2192 v${l.latestVersion}`,manualCommand:Ld(u)});}t(l=>({...l,items:l.items.map(u=>u.status==="pending"?{...u,status:"ok"}:u)})),await rn(),t(l=>({...l,outcome:"done"}));}catch{await rn(),t(o=>({...o,outcome:"done"}));}}n();},[r]),e}function dS({item:e}){return e.status==="pending"||e.status==="updating"?jsxs(Box,{children:[jsx(Text,{color:"cyan",children:jsx(ru,{type:"dots"})}),jsxs(Text,{color:"cyan",children:[" ",e.label,e.detail?` ${e.detail}...`:""]})]}):e.status==="ok"||e.status==="updated"?jsxs(Box,{children:[jsxs(Text,{color:"green",children:["\u2713 ",e.label]}),e.detail&&jsxs(Text,{dimColor:true,children:[" ",e.detail]})]}):e.status==="missing"?jsxs(Box,{children:[jsxs(Text,{color:"red",children:["\u2717 ",e.label]}),jsx(Text,{dimColor:true,children:" \u2014 not installed"})]}):jsxs(Box,{flexDirection:"column",children:[jsxs(Box,{children:[jsxs(Text,{color:"red",children:["\u2717 ",e.label]}),e.detail&&jsxs(Text,{dimColor:true,children:[" ",e.detail]})]}),e.manualCommand&&jsx(Box,{paddingLeft:2,children:jsxs(Text,{dimColor:true,children:["To update manually: ",e.manualCommand]})})]})}function pS({outcome:e}){return e==="done"?jsx(Text,{color:"green",children:"All good!"}):e==="cli-updated"||e==="cli-update-failed"?jsx(Text,{color:"yellow",children:"Restart the CLI to use the new version."}):null}function _d(){let{outcome:e,items:t}=Rd(),r=S(o=>o.setScreen),n=S(o=>o.setFocus);return useEffect(()=>{if(e==="done"){let o=setTimeout(()=>{let s=se().some(i=>i.name===ie);r(s?"main":"claudeMdSuggestion"),n("list");},1500);return ()=>clearTimeout(o)}if(e==="module-missing"){let o=setTimeout(()=>{r("moduleSetup"),n("moduleSetup");},500);return ()=>clearTimeout(o)}},[e,r,n]),jsxs(Box,{flexDirection:"column",paddingX:2,paddingY:1,children:[jsx(Box,{marginBottom:1,children:jsx(Text,{bold:true,children:"Checking environment..."})}),jsx(Box,{flexDirection:"column",gap:0,children:t.map(o=>jsx(dS,{item:o},o.id))}),e!=="running"&&jsx(Box,{marginTop:1,children:jsx(pS,{outcome:e})})]})}var yS={debug:"gray",info:"cyan",warn:"yellow",error:"red"},Dd=10;function Od(){let[e,t]=useState(Js());useEffect(()=>Va(()=>{t([...Js()]);}),[]);let r=e.slice(-Dd);return jsxs(Box,{flexDirection:"column",borderStyle:"single",borderColor:"cyan",paddingX:1,children:[jsxs(Text,{color:"cyan",bold:true,children:["Debug Log (last ",Dd,") \u2014 press Ctrl+D to close"]}),r.length===0?jsx(Text,{dimColor:true,children:"No log entries yet"}):r.map((n,o)=>jsxs(Text,{color:yS[n.level],children:["[",n.level.toUpperCase(),"] [",n.module,"] ",n.message]},o))]})}var xS=I("app"),IS={auth:xl,starterKitSetup:Qu,moduleSetup:Pd,claudeMdSuggestion:kd,verify:_d,main:ju};function Ud(){let{setScreen:e,setFocus:t}=S.getState();e("auth"),t("auth");}function Pn(e){let{setScreen:t,setFocus:r}=S.getState();!e.starterKit||e.starterKit.trim()===""?(t("starterKitSetup"),r("starterKitList")):(t("verify"),r("verify"));}function Fd(){b(v.CLI_SESSION_STARTED,{cli_version:ae,os:process.platform,node_version:process.version,duration_ms:Ct(),interface:"tui"}).catch(()=>{});}async function Kd(){let e=await oe();if(e&&hl()&&await Ht()){let{clientSecret:n,...o}=e;Ge.getState().setCredentials(o),Fd(),Pn(e);return}if(!e){Ud();return}try{await Jt();}catch(n){xS.debug(`Token validation failed: ${String(n)}`),Ud();return}Fd();let{clientSecret:t,...r}=e;Ge.getState().setCredentials(r),Pn(e);}function Vd(){let{columns:e,rows:t}=useWindowSize(),r=S(a=>a.screen),n=IS[r],{pendingExit:o}=pl(),s=S(a=>a.debugPanelOpen),i=!!process.env.DEBUG;return useInput((a,l)=>{if(i&&l.ctrl&&a==="d"){let u=S.getState().debugPanelOpen;S.getState().setDebugPanelOpen(!u);}}),n?jsxs(Box,{flexDirection:"column",width:e,height:t,children:[jsx(n,{}),i&&s&&jsx(Od,{}),o&&jsx(Box,{paddingX:1,children:jsx(Text,{color:"yellow",children:"Press Ctrl+C again to quit"})})]}):jsxs(Text,{color:"red",children:["Unknown screen: ",r]})}async function va(e,t={}){let r=To({clientId:e.clientId,clientSecret:e.clientSecret,tenant:e.tenant},t);return Co(r),await Tt(e),{jwt:r.jwt,previousToken:r.previousToken,hadExistingFile:r.hadExistingFile}}var ut=I("auth");function Jd(){De.clearFallbackFile(),xo();}var vS=3,Hd=3,Gd=` \u2139 The data collected during setup is used solely to improve
|
|
117
117
|
Flow's internal tools and will not be shared externally.
|
|
118
118
|
`;function Tr(e,t={}){return new Promise((r,n)=>{let{masked:o=false,defaultValue:s=""}=t;process.stdout.write(e+s);let i=s,a=c=>{if(c===""){l(),n(new Error("SIGINT"));return}if(c==="\r"||c===`
|
|
119
119
|
`){l(),process.stdout.write(`
|
|
@@ -219,7 +219,7 @@ This will run: ${i}
|
|
|
219
219
|
`);return process.stdout.write(`
|
|
220
220
|
`),T("Specify a skill name to remove: flow skills remove <name>"),1}let n=cn(e),o=ar(r),s=join(o,n);try{await stat(s);}catch{return E(`Skill "${h(e)}" is not installed.`),1}if(!t.force&&!await Lw(`Remove skill "${h(n)}"?`))return T("Cancelled."),0;try{return await rm$1(s,{recursive:!0,force:!0}),await vp(n,r),await Mw(n),ne(`Skill "${h(n)}" removed.`),0}catch(i){return E(`Failed to remove skill: ${i instanceof Error?i.message:String(i)}`),1}}var Os=I("transfer"),Aa=1;function Dw(e){return e.marketplace&&e.marketplace!==re?`${e.name}@${e.marketplace}`:e.name}function Ow(e,t){let r=e.filter(o=>t.has(o.name)),n=e.filter(o=>!t.has(o.name));r.length>0&&T(`Already installed (${r.length}): ${r.map(o=>o.name).join(", ")}`),T(`To install (${n.length}): ${n.length>0?n.map(o=>o.name).join(", "):"none"}`);}function Lp(e){let t=me__default.resolve(e.output);try{let r=se(),n={version:Aa,exportedAt:new Date().toISOString(),plugins:r.map(o=>({name:o.name,marketplace:o.marketplace,scope:o.scope,...o.type!==void 0?{type:o.type}:{}}))};return ve__default.writeFileSync(t,JSON.stringify(n,null,2),"utf-8"),ne(`Exported ${r.length} plugin(s) to ${t}`),0}catch(r){let n=Q(r);return Os.error(`Export failed: ${n}`),E(`Failed to export plugins: ${n}`),1}}async function Rp(e,t={}){if(!await fe())return 1;let r;try{let a=ve__default.readFileSync(me__default.resolve(e),"utf-8");r=JSON.parse(a);}catch(a){return E(`Failed to read import file "${e}": ${Q(a)}`),1}if(r.version!==Aa)return E(`Unsupported export format version ${r.version??"(none)"} \u2014 expected ${Aa}`),1;if(!Array.isArray(r.plugins))return E('Invalid export file format: missing or invalid "plugins" array'),1;if(r.plugins.length===0)return T("No plugins to import"),0;let n=[],o=[],s=0;for(let[a,l]of r.plugins.entries())if(!l?.name||typeof l.name!="string"){let u=`entry[${a}]`;Os.warn(`Skipping ${u}: missing or invalid name`),o.push({name:u,error:"missing or invalid name"});}else l.type==="mcp"?(Os.debug(`[${l.name}] Skipping MCP entry`),s++):n.push(l);if(s>0&&T(`Skipping ${s} MCP(s) \u2014 use 'flow mcp add' to install them manually`),t.diff||t.dryRun){let a=new Set(se().map(l=>l.name));Ow(n,a);}if(t.dryRun)return T("Dry-run mode: no plugins were installed"),0;if(n.length===0){T(`
|
|
221
221
|
Import summary: 0 installed, ${o.length} failed`);for(let a of o)E(` ${a.name}: ${a.error}`);return o.length>0?1:0}T(`Importing ${n.length} plugin(s)...`);let i=0;for(let a of n){let l=t.scope??a.scope??"user",u=Dw(a);Os.debug(`[${a.name}] Installing as "${u}" in scope "${l}"`),await As([u],{scope:l,force:t.force})===0?i++:o.push({name:a.name,error:"installation failed"});}T(`
|
|
222
|
-
Import summary: ${i} installed, ${o.length} failed`);for(let a of o)E(` ${a.name}: ${a.error}`);return o.length>0?1:0}function B(e){process.exitCode=e,setTimeout(()=>process.exit(e),100).unref();}var Bw=I("moduleProxy");function Uw(e){if(!process.stdin.isTTY)return Promise.resolve(false);let t=Ni.createInterface({input:process.stdin,output:process.stdout});return new Promise(r=>{t.question(h(e),n=>{t.close(),r(!["n","no"].includes(n.toLowerCase().trim()));});})}async function _p(e,t){let r=Date.now(),o=spawnSync(e.binaryName,t,{stdio:"inherit",env:process.env}).status??1;await b(v.CLI_MODULE_PROXY_EXECUTED,{module_alias:e.alias,exit_code:o,duration_ms:Date.now()-r,subcommand:t[0]??null}).catch(s=>{Bw.warn(`Failed to emit proxy executed event: ${String(s)}`);}),B(o);}async function Op(e,t){let r=te.find(o=>o.alias===e);if(!r){E(`Unknown module alias: '${e}'`),B(1);return}if(!await It(r.binaryName)){E(`Module '${e}' (${r.binaryName}) is not installed.`);let o=r.platforms[process.platform];if(!o||o.status!=="supported"){await b(v.CLI_MODULE_NOT_FOUND,{module_alias:e,action_taken:"install_not_supported"}).catch(()=>{}),B(1);return}let s=(await Promise.all(o.strategies.map(async a=>{try{return await Bt(a.type).isAvailable()?a.type:null}catch{return null}}))).find(a=>a!==null)??null;if(!s){E(`No supported installation method available for '${e}' on this platform.`),B(1);return}if(await Uw("Would you like to install it now? [Y/n] ")){await b(v.CLI_MODULE_NOT_FOUND,{module_alias:e,action_taken:"install_accepted"}).catch(()=>{});let a=await sn(r,"inline",s);if(!a.success){E(`Failed to install '${e}': ${a.error?.message??"unknown error"}`),B(1);return}await _p(r,t);}else T(`To install manually, run: flow modules install ${e}`),await b(v.CLI_MODULE_NOT_FOUND,{module_alias:e,action_taken:"install_declined"}).catch(()=>{}),B(1);return}await _p(r,t);}var Vw=promisify(execFile);async function Hw(e){try{if(e.versionCheck.type==="npm-registry"){let{stdout:n}=await Vw(Nt(),["view",e.versionCheck.package,"version"],{timeout:5e3,shell
|
|
222
|
+
Import summary: ${i} installed, ${o.length} failed`);for(let a of o)E(` ${a.name}: ${a.error}`);return o.length>0?1:0}function B(e){process.exitCode=e,setTimeout(()=>process.exit(e),100).unref();}var Bw=I("moduleProxy");function Uw(e){if(!process.stdin.isTTY)return Promise.resolve(false);let t=Ni.createInterface({input:process.stdin,output:process.stdout});return new Promise(r=>{t.question(h(e),n=>{t.close(),r(!["n","no"].includes(n.toLowerCase().trim()));});})}async function _p(e,t){let r=Date.now(),o=spawnSync(e.binaryName,t,{stdio:"inherit",env:process.env}).status??1;await b(v.CLI_MODULE_PROXY_EXECUTED,{module_alias:e.alias,exit_code:o,duration_ms:Date.now()-r,subcommand:t[0]??null}).catch(s=>{Bw.warn(`Failed to emit proxy executed event: ${String(s)}`);}),B(o);}async function Op(e,t){let r=te.find(o=>o.alias===e);if(!r){E(`Unknown module alias: '${e}'`),B(1);return}if(!await It(r.binaryName)){E(`Module '${e}' (${r.binaryName}) is not installed.`);let o=r.platforms[process.platform];if(!o||o.status!=="supported"){await b(v.CLI_MODULE_NOT_FOUND,{module_alias:e,action_taken:"install_not_supported"}).catch(()=>{}),B(1);return}let s=(await Promise.all(o.strategies.map(async a=>{try{return await Bt(a.type).isAvailable()?a.type:null}catch{return null}}))).find(a=>a!==null)??null;if(!s){E(`No supported installation method available for '${e}' on this platform.`),B(1);return}if(await Uw("Would you like to install it now? [Y/n] ")){await b(v.CLI_MODULE_NOT_FOUND,{module_alias:e,action_taken:"install_accepted"}).catch(()=>{});let a=await sn(r,"inline",s);if(!a.success){E(`Failed to install '${e}': ${a.error?.message??"unknown error"}`),B(1);return}await _p(r,t);}else T(`To install manually, run: flow modules install ${e}`),await b(v.CLI_MODULE_NOT_FOUND,{module_alias:e,action_taken:"install_declined"}).catch(()=>{}),B(1);return}await _p(r,t);}var Vw=promisify(execFile);async function Hw(e){try{if(e.versionCheck.type==="npm-registry"){let{stdout:n}=await Vw(Nt(),["view",e.versionCheck.package,"version"],{timeout:5e3,shell:process.platform==="win32"});return String(n).trim()||null}let t=new AbortController,r=setTimeout(()=>t.abort(),5e3);try{let n={"User-Agent":`flow-plugins-cli/${ae}`,Accept:"application/vnd.github+json"};process.env.GITHUB_TOKEN&&(n.Authorization=`Bearer ${process.env.GITHUB_TOKEN}`);let o=await fetch(`https://api.github.com/repos/${e.versionCheck.repo}/releases/latest`,{signal:t.signal,headers:n});return o.ok?(await o.json()).tag_name?.replace(/^v/,"")??null:null}finally{clearTimeout(r);}}catch{return null}}function Jw(e,t,r,n){return n?.status==="experimental"?"experimental":!n||n.status!=="supported"||!e?"not_installed":t&&r&&Te(t,r)?"outdated":"installed"}async function $a(){let e=await Promise.all(te.map(async t=>{let[r,n]=await Promise.all([It(t.binaryName),Hw(t)]),s=et(t.alias)?.installedVersion??null,i=t.platforms[process.platform],a=Jw(r,s,n,i),l=s??"\u2014";return [t.name,t.alias,l,a,process.platform]}));return Rr(["Name","Alias","Version","Status","Platform"],e),0}async function Up(e){let t=te.find(i=>i.alias===e);if(!t)return E(`Unknown module alias: '${e}'`),1;let[r]=await an([t]);if(r.alreadyInstalled){let i=et(t.alias),a=i?.installedVersion?` (v${i.installedVersion})`:"";return T(`Module ${t.name} already installed${a}. Use: flow modules update ${e}`),0}if(r.availableStrategies.length===0){let i=t.platforms[process.platform],a=t.docs?` See: ${t.docs}`:"";return !i||i.status!=="supported"?E(`Module ${t.name} is not supported on ${process.platform}.${a}`):E(`No installation method available for ${t.name} on ${process.platform}.${a}`),1}let n=r.availableStrategies[0],o=Ea({text:`Installing ${t.name}...`}).start(),s;try{s=await sn(t,"on_demand",n);}finally{o.stop();}return s.success?(ne(`${t.name} v${s.version??"unknown"} installed`),s.pendingInteractiveSetup&&spawnSync(s.pendingInteractiveSetup[0],s.pendingInteractiveSetup.slice(1),{stdio:"inherit"}),0):(E(s.error?.message??"Installation failed"),1)}async function Np(e,t){let r=Ea({text:`Updating ${e.name}...`}).start(),n;try{n=await bs(e,"command");}catch(o){return r.error(`${e.name}: ${o instanceof Error?o.message:String(o)}`),"error"}if(n.success){let o=n.version??"unknown";return o===t?(r.success(`${e.name}: already up to date (v${t})`),"up_to_date"):(r.success(`${e.name}: v${t} \u2192 v${o}`),"success")}return r.error(`${e.name}: ${n.error?.message??"Update failed"}`),"error"}async function Fp(e){if(e!==null){let n=te.find(i=>i.alias===e);if(!n)return E(`Unknown module alias: '${e}'`),1;let o=et(n.alias);return o?.installMethod?await Np(n,o.installedVersion??"unknown")==="error"?1:0:(E(`Module '${e}' not installed. Run: flow modules install ${e}`),1)}let t=Pr().filter(n=>n.installMethod!==null);if(t.length===0)return T("No installed modules to update."),0;let r=0;for(let n of t){let o=te.find(i=>i.alias===n.alias);if(!o)continue;await Np(o,n.installedVersion??"unknown")==="error"&&(r=1);}return r}function jp(e){let t=new Command;t.enablePositionalOptions(),t.name("flow").description("FlowSetup CLI \u2014 Manage Flow plugins in your Claude Code").version(`@ciandt-flow/cli v${ae}`,"-V, --version","Display the CLI version").addHelpText("after",`
|
|
223
223
|
Without arguments, opens the interactive interface (TUI).
|
|
224
224
|
Use 'flow <command> --help' for details on each command.`).action(async()=>{await e();});let r=new Command("setup").description("Configure the CLI by detecting Claude Code credentials");r.command("init").description("Initialize the Flow CLI configuration").addHelpText("after",`
|
|
225
225
|
Examples:
|
|
@@ -315,7 +315,7 @@ Examples:
|
|
|
315
315
|
$ flow modules install dashboard`).action(async c=>{let d=await Up(c);B(d);}),u.command("update").description("Update an installed module, or all installed modules").argument("[alias]","Module alias to update (omit to update all installed)").addHelpText("after",`
|
|
316
316
|
Examples:
|
|
317
317
|
$ flow modules update
|
|
318
|
-
$ flow modules update metrics`).action(async c=>{let d=await Fp(c??null);B(d);}),t.addCommand(u);for(let c of te)t.command(c.alias).description(c.description).helpOption(false).allowUnknownOption().passThroughOptions().argument("[passthrough...]","Arguments forwarded to the module binary").action(async d=>{await Op(c.alias,d);});return t.hook("preAction",()=>{Es();}),t}function zw(){return me__default.join(Le__default.homedir(),".claude","settings.json")}function Vp(){let e=zw();try{if(!ve__default.existsSync(e))return !0;let r=JSON.parse(ve__default.readFileSync(e,"utf-8")).flowCli?.autoUpdate;return r===!1?!1:r==="modules-only"?"modules-only":!0}catch{return true}}var ex=I("updateChecker"),tx=promisify(execFile),rx=1440*60*1e3,Hp=3e4;function nx(){let e=process.env.FLOW_HOME??me__default.join(Le__default.homedir(),".flow");return me__default.join(e,"update.lock")}async function Jp(e){try{let{stdout:t}=await tx(Nt(),["view",e,"version"],{timeout:Hp,shell
|
|
318
|
+
$ flow modules update metrics`).action(async c=>{let d=await Fp(c??null);B(d);}),t.addCommand(u);for(let c of te)t.command(c.alias).description(c.description).helpOption(false).allowUnknownOption().passThroughOptions().argument("[passthrough...]","Arguments forwarded to the module binary").action(async d=>{await Op(c.alias,d);});return t.hook("preAction",()=>{Es();}),t}function zw(){return me__default.join(Le__default.homedir(),".claude","settings.json")}function Vp(){let e=zw();try{if(!ve__default.existsSync(e))return !0;let r=JSON.parse(ve__default.readFileSync(e,"utf-8")).flowCli?.autoUpdate;return r===!1?!1:r==="modules-only"?"modules-only":!0}catch{return true}}var ex=I("updateChecker"),tx=promisify(execFile),rx=1440*60*1e3,Hp=3e4;function nx(){let e=process.env.FLOW_HOME??me__default.join(Le__default.homedir(),".flow");return me__default.join(e,"update.lock")}async function Jp(e){try{let{stdout:t}=await tx(Nt(),["view",e,"version"],{timeout:Hp,shell:process.platform==="win32"});return String(t).trim()||null}catch{return null}}async function ox(e){let t=new AbortController,r=setTimeout(()=>t.abort(),Hp);try{let n=await fetch(`https://api.github.com/repos/${e}/releases/latest`,{signal:t.signal});return n.ok?(await n.json()).tag_name?.replace(/^v/,"")??null:null}catch{return null}finally{clearTimeout(r);}}async function sx(e){return e.versionCheck.type==="npm-registry"?Jp(e.versionCheck.package):ox(e.versionCheck.repo)}async function ix(){let e=await Jp("@ciandt-flow/cli");return e&&Te(ae,e)?(Ts({currentVersion:ae,latestVersion:e,isOutdated:true,packageName:"@ciandt-flow/cli"}).catch(()=>{}),e):null}async function ax(){let e=Pr().filter(t=>t.installMethod!==null);await Promise.all(e.map(async t=>{let r=te.find(i=>i.alias===t.alias);if(!r||r.hasOwnUpdateCheck)return;let n=Date.now(),o=t.lastChecked?new Date(t.lastChecked).getTime():0;if(n-o<rx)return;let s=await sx(r);try{await xt({...t,lastChecked:new Date().toISOString()});}catch(i){ex.warn(`Failed to update lastChecked for ${t.alias}: ${String(i)}`);}s&&t.installedVersion&&Te(t.installedVersion,s)&&bs(r,"background").catch(()=>{});}));}async function La(){let e=Vp();if(e===false)return;let t=nx();ve__default.mkdirSync(me__default.dirname(t),{recursive:true});let r=null;try{r=await og.lock(t,{realpath:!1,retries:0});}catch{return}try{if(e!=="modules-only"){let n=await ix().catch(()=>null);n&&process.stdout.write(`
|
|
319
319
|
\u26A0 @ciandt-flow/cli v${n} installing in background.
|
|
320
320
|
Restart flow to apply the update.
|
|
321
321
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ciandt-flow/cli",
|
|
3
|
-
"version": "2.1.1
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"description": "TUI for browsing and installing Claude Code plugins from the Flow ecosystem",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"email": "flow@ciandt.com"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@tanstack/react-query": "5.100.
|
|
53
|
+
"@tanstack/react-query": "5.100.14",
|
|
54
54
|
"boxen": "8.0.1",
|
|
55
55
|
"chalk": "5.6.2",
|
|
56
56
|
"commander": "11.1.0",
|
|
@@ -59,20 +59,20 @@
|
|
|
59
59
|
"execa": "9.6.1",
|
|
60
60
|
"extract-zip": "2.0.1",
|
|
61
61
|
"http-status-codes": "2.3.0",
|
|
62
|
-
"ink": "7.0.
|
|
62
|
+
"ink": "7.0.4",
|
|
63
63
|
"ink-big-text": "2.0.0",
|
|
64
64
|
"ink-gradient": "4.0.0",
|
|
65
65
|
"ink-spinner": "5.0.0",
|
|
66
66
|
"jsonwebtoken": "9.0.3",
|
|
67
67
|
"ky": "2.0.2",
|
|
68
68
|
"proper-lockfile": "4.1.2",
|
|
69
|
-
"react": "19.2.
|
|
70
|
-
"react-dom": "19.2.
|
|
71
|
-
"semver": "7.
|
|
69
|
+
"react": "19.2.6",
|
|
70
|
+
"react-dom": "19.2.6",
|
|
71
|
+
"semver": "7.8.1",
|
|
72
72
|
"simple-git": "3.36.0",
|
|
73
|
-
"yaml": "2.
|
|
73
|
+
"yaml": "2.9.0",
|
|
74
74
|
"yocto-spinner": "1.2.0",
|
|
75
|
-
"zustand": "5.0.
|
|
75
|
+
"zustand": "5.0.13"
|
|
76
76
|
},
|
|
77
77
|
"devDependencies": {
|
|
78
78
|
"@changesets/changelog-github": "^0.7.0",
|