@stacknet/rackutils 0.3.2 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,11 @@
1
- 'use strict';var react=require('react'),lucideReact=require('lucide-react'),clsx=require('clsx'),tailwindMerge=require('tailwind-merge'),jsxRuntime=require('react/jsx-runtime');function C(...n){return tailwindMerge.twMerge(clsx.clsx(n))}async function k(n,e,i,r){let a={"Content-Type":"application/json",...i?.headers};r&&(a.Authorization=`Bearer ${r}`);let l=await fetch(`${n}${e}`,{...i,headers:a});if(!l.ok){let t=`HTTP ${l.status}`;try{let s=await l.json();s.error&&(t=s.error);}catch{}throw new Error(t)}return l.json()}function L(n){let e=n.indexOf(":");return {mode:n.slice(0,e),cid:n.slice(e+1)}}function z(n){let e=n.apiBaseUrl,i=n.authorMid,r=n.ownerMid,a=n.apiKey,l=n.stacknetUrl||n.apiBaseUrl;return react.useMemo(()=>({async listRepos(t,s){let c=new URLSearchParams;(t||r)&&c.set("owner",t||r),s?.limit&&c.set("limit",String(s.limit)),s?.cursor&&c.set("cursor",s.cursor);let d=c.toString()?`?${c}`:"",u=await k(e,`/api/rack/repos${d}`,void 0,a);return {items:u.repos||[],pagination:u.pagination||{total:(u.repos||[]).length,limit:50,has_more:false,next_cursor:null}}},async initRepo(t){return k(e,"/api/rack/init",{method:"POST",body:JSON.stringify({...t,owner_mid:r})},a)},async push(t,s){return k(e,`/api/rack/${t}/push`,{method:"POST",body:JSON.stringify({...s,author_mid:i})},a)},async getTree(t,s="main"){let c=await k(e,`/api/rack/${t}/tree/${s}`,void 0,a);return {tree:c.tree,commit_cid:c.commit_cid}},async getBlob(t,s){return (await k(e,`/api/rack/${t}/blob/${s}`,void 0,a)).content},async getLog(t,s,c){let d=new URLSearchParams;s&&d.set("ref",s),c&&d.set("max_count",String(c));let u=d.toString()?`?${d}`:"";return (await k(e,`/api/rack/${t}/log${u}`,void 0,a)).commits||[]},async getBranches(t){return (await k(e,`/api/rack/${t}/branches`,void 0,a)).branches||[]},async createBranch(t,s,c){return k(e,`/api/rack/${t}/branch`,{method:"POST",body:JSON.stringify({branch_name:s,from_ref:c})},a)},async merge(t,s,c){return k(e,`/api/rack/${t}/merge`,{method:"POST",body:JSON.stringify({source_branch:s,target_branch:c})},a)},async getDiff(t,s,c){return (await k(e,`/api/rack/${t}/diff/${s}/${c}`,void 0,a)).diff?.entries||[]},async starRepo(t){return k(e,`/api/rack/${t}/star`,{method:"POST"},a)},async unstarRepo(t){return k(e,`/api/rack/${t}/star`,{method:"DELETE"},a)},async getStarInfo(t){return k(e,`/api/rack/${t}/stars`,void 0,a)},async getSkillStats(t){let s={meta:null,tokenCount:null,usageCount:null};try{let{tree:c}=await this.getTree(t,"main");if(!c?.entries)return s;if(c.entries["META.json"]){let h=L(c.entries["META.json"]).cid,g=await this.getBlob(t,h);s.meta=JSON.parse(g);}let d=0,u=Object.values(c.entries).map(async h=>{try{let g=L(h).cid,m=await this.getBlob(t,g);d+=m.length;}catch{}});await Promise.all(u),d>0&&(s.tokenCount=Math.ceil(d/4)),s.meta?.skill_id&&(s.usageCount=await this.getSkillUsageCount(s.meta.skill_id));}catch{}return s},async getSkillUsageCount(t){try{let s=await fetch(`${l}/v1/skills/${encodeURIComponent(t)}`);if(s.ok){let d=await s.json();return d.usage_count??d.usageCount??null}let c=await fetch(`${l}/v1/skills?scope=public`);if(c.ok){let u=((await c.json()).skills||[]).find(h=>h.name===t||h.id===t);if(u)return u.usage_count??u.usageCount??0}return 0}catch{return null}},async getTensorStats(t){let s={meta:null,sizeMB:null};try{let{tree:c}=await this.getTree(t,"main");if(!c?.entries)return s;if(c.entries["TENSOR_META.json"]){let d=L(c.entries["TENSOR_META.json"]).cid,u=await this.getBlob(t,d);s.meta=JSON.parse(u),s.sizeMB=s.meta?.tensor_size_mb??null;}}catch{}return s},async getNetworkStats(){try{return (await k(e,"/api/rack/stats",void 0,a)).stats||null}catch{return null}},async getTrending(t=5,s=1,c){try{let d=new URLSearchParams({limit:String(t),days:String(s)});c&&d.set("cursor",c);let u=await k(e,`/api/rack/trending?${d}`,void 0,a);return {items:u.trending||[],pagination:u.pagination||{total:(u.trending||[]).length,limit:t,has_more:!1,next_cursor:null}}}catch{return {items:[],pagination:{total:0,limit:t,has_more:false,next_cursor:null}}}}}),[e,i,r,a,l])}function K(n,e={}){let{pageSize:i=50,owner:r}=e,a=z(n),[l,t]=react.useState([]),[s,c]=react.useState(null),[d,u]=react.useState(false),[h,g]=react.useState(null),m=react.useRef(null),b=react.useRef(true),v=react.useCallback(async(y,T=false)=>{u(true),g(null);try{let R=await a.listRepos(r,{limit:i,cursor:y||void 0});b.current&&(t(E=>T?[...E,...R.items]:R.items),c(R.pagination),m.current=R.pagination.next_cursor);}catch(R){b.current&&g(R.message);}finally{b.current&&u(false);}},[a,r,i]),S=react.useCallback(async()=>{!m.current||d||await v(m.current,true);},[v,d]),p=react.useCallback(async()=>{m.current=null,await v(void 0,false);},[v]);return react.useEffect(()=>(b.current=true,v(),()=>{b.current=false;}),[v]),{repos:l,hasMore:s?.has_more??false,total:s?.total??0,loading:d,error:h,loadMore:S,reset:p,pagination:s}}function be(n){return Object.entries(n).map(([e,i])=>{let r=i.indexOf(":"),a=r>0?i.slice(0,r):"100644",l=r>0?i.slice(r+1):i;return {path:e,mode:a,cid:l,isDir:a==="040000"}}).sort((e,i)=>e.isDir!==i.isDir?e.isDir?-1:1:e.path.localeCompare(i.path))}function Y(n,e,i="main"){let r=z(n),[a,l]=react.useState([]),[t,s]=react.useState(false),[c,d]=react.useState(null),u=react.useRef(true),h=react.useCallback(async()=>{if(e)try{u.current&&(s(!0),d(null));let{tree:m}=await r.getTree(e,i);u.current&&l(be(m.entries));}catch(m){u.current&&d(m instanceof Error?m.message:"Failed to load tree");}finally{u.current&&s(false);}},[r,e,i]);react.useEffect(()=>(u.current=true,h(),()=>{u.current=false;}),[h]);let g=react.useCallback(async m=>{if(!e)throw new Error("No repo selected");return r.getBlob(e,m)},[r,e]);return {entries:a,loading:t,error:c,refresh:h,getFileContent:g}}var ve=/^(https?:\/\/|mailto:|\/[^/])/i;function ye(n){let e=n.trim();return ve.test(e)?e:null}function _(n){let e=[],i=/(`[^`]+`)|(\*\*(.+?)\*\*)|(\*(.+?)\*)|(_(.+?)_)|(\[([^\]]+)\]\(([^)]+)\))/g,r=0,a,l=0;for(;(a=i.exec(n))!==null;){a.index>r&&e.push(n.slice(r,a.index));let t=`i${l++}`;if(a[1])e.push(jsxRuntime.jsx("code",{className:"rounded bg-muted px-1.5 py-0.5 text-[0.85em] font-mono text-pink-400",children:a[1].slice(1,-1)},t));else if(a[2])e.push(jsxRuntime.jsx("strong",{children:a[3]},t));else if(a[4])e.push(jsxRuntime.jsx("em",{children:a[5]},t));else if(a[6])e.push(jsxRuntime.jsx("em",{children:a[7]},t));else if(a[8]){let s=ye(a[10]);s?e.push(jsxRuntime.jsx("a",{href:s,className:"text-blue-400 underline hover:text-blue-300",target:"_blank",rel:"noopener noreferrer",children:a[9]},t)):e.push(a[9]);}r=a.index+a[0].length;}return r<n.length&&e.push(n.slice(r)),e.length>0?e:[n]}function ke(n){let e=n.split(`
2
- `),i=[],r=0;for(;r<e.length;){let a=e[r];if(a.trim()===""){r++;continue}if(/^(-{3,}|\*{3,}|_{3,})$/.test(a.trim())){i.push({type:"hr"}),r++;continue}let l=a.match(/^(#{1,6})\s+(.+)/);if(l){i.push({type:"heading",level:l[1].length,content:l[2]}),r++;continue}if(a.trim().startsWith("```")){let s=a.trim().slice(3).trim(),c=[];for(r++;r<e.length&&!e[r].trim().startsWith("```");)c.push(e[r]),r++;i.push({type:"code",content:c.join(`
3
- `),lang:s||void 0}),r++;continue}if(/^\s*[-*+]\s/.test(a)){let s=[];for(;r<e.length&&/^\s*[-*+]\s/.test(e[r]);)s.push(e[r].replace(/^\s*[-*+]\s+/,"")),r++;i.push({type:"ul",items:s});continue}if(/^\s*\d+[.)]\s/.test(a)){let s=[];for(;r<e.length&&/^\s*\d+[.)]\s/.test(e[r]);)s.push(e[r].replace(/^\s*\d+[.)]\s+/,"")),r++;i.push({type:"ol",items:s});continue}let t=[];for(;r<e.length&&e[r].trim()!==""&&!e[r].match(/^#{1,6}\s/)&&!e[r].trim().startsWith("```")&&!/^\s*[-*+]\s/.test(e[r])&&!/^\s*\d+[.)]\s/.test(e[r]);)t.push(e[r]),r++;t.length>0&&i.push({type:"paragraph",content:t.join(" ")});}return i}var Ne={1:"text-2xl font-bold mt-6 mb-3",2:"text-xl font-bold mt-5 mb-2",3:"text-lg font-semibold mt-4 mb-2",4:"text-base font-semibold mt-3 mb-1",5:"text-sm font-semibold mt-2 mb-1",6:"text-sm font-medium mt-2 mb-1"};function Re(n,e){switch(n.type){case "hr":return jsxRuntime.jsx("hr",{className:"my-4 border-border"},`b${e}`);case "heading":{let i=Math.min(Math.max(n.level||1,1),6),r=`h${i}`;return jsxRuntime.jsx(r,{className:C("text-foreground",Ne[i]),children:_(n.content||"")},`b${e}`)}case "paragraph":return jsxRuntime.jsx("p",{className:"mb-3 leading-relaxed text-foreground",children:_(n.content||"")},`b${e}`);case "code":return jsxRuntime.jsx("pre",{className:"mb-3 overflow-x-auto rounded-lg bg-muted p-4 text-sm font-mono leading-relaxed text-foreground",children:jsxRuntime.jsx("code",{children:n.content})},`b${e}`);case "ul":return jsxRuntime.jsx("ul",{className:"mb-3 ml-5 list-disc space-y-1 text-foreground",children:n.items?.map((i,r)=>jsxRuntime.jsx("li",{className:"leading-relaxed",children:_(i)},`li${e}-${r}`))},`b${e}`);case "ol":return jsxRuntime.jsx("ol",{className:"mb-3 ml-5 list-decimal space-y-1 text-foreground",children:n.items?.map((i,r)=>jsxRuntime.jsx("li",{className:"leading-relaxed",children:_(i)},`li${e}-${r}`))},`b${e}`);default:return null}}function D({content:n,className:e}){let i=ke(n);return jsxRuntime.jsx("div",{className:C("text-sm",e),children:i.map((r,a)=>Re(r,a))})}function ne({open:n,className:e}){return jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 20 20",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",className:C("shrink-0 transition-transform duration-150",n?"rotate-0":"-rotate-90",e),children:jsxRuntime.jsx("path",{d:"M16.134 6.16a.5.5 0 1 1 .732.68l-6.5 7-.077.068a.5.5 0 0 1-.655-.068l-6.5-7-.062-.08a.5.5 0 0 1 .718-.667l.076.067L10 12.767z"})})}function X({size:n=20,className:e}){return jsxRuntime.jsx("svg",{width:n,height:n,viewBox:"0 0 20 20",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",className:e,children:jsxRuntime.jsx("path",{d:"M8.5 2a6.5 6.5 0 0 1 4.935 10.728l4.419 4.419.064.078a.5.5 0 0 1-.693.693l-.079-.064-4.419-4.42A6.5 6.5 0 1 1 8.5 2m0 1a5.5 5.5 0 1 0 0 11 5.5 5.5 0 0 0 0-11"})})}function O({size:n=20,className:e}){return jsxRuntime.jsx("svg",{width:n,height:n,viewBox:"0 0 20 20",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",className:e,children:jsxRuntime.jsx("path",{d:"M15.147 4.146a.5.5 0 0 1 .707.707L10.707 10l5.147 5.147a.5.5 0 0 1-.63.771l-.078-.064L10 10.707l-5.146 5.147a.5.5 0 0 1-.708-.707L9.293 10 4.146 4.853a.5.5 0 0 1 .708-.707L10 9.293z"})})}function re({size:n=20,className:e}){return jsxRuntime.jsx("svg",{width:n,height:n,viewBox:"0 0 20 20",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",className:e,children:jsxRuntime.jsx("path",{d:"M10 3a.5.5 0 0 1 .5.5v6h6l.1.01a.5.5 0 0 1 0 .98l-.1.01h-6v6a.5.5 0 0 1-1 0v-6h-6a.5.5 0 0 1 0-1h6v-6A.5.5 0 0 1 10 3"})})}function Pe(){return jsxRuntime.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",className:"shrink-0",children:jsxRuntime.jsx("path",{d:"M6.5 3A2.5 2.5 0 0 0 4 5.5v9A2.5 2.5 0 0 0 6.5 17h7a2.5 2.5 0 0 0 2.5-2.5v-7A2.5 2.5 0 0 0 13.5 5H11V3.5a.5.5 0 0 0-1 0V5H6.5ZM5 5.5A1.5 1.5 0 0 1 6.5 4H9v1H6.5A1.5 1.5 0 0 0 5 6.5v8A1.5 1.5 0 0 0 6.5 16h7a1.5 1.5 0 0 0 1.5-1.5v-7A1.5 1.5 0 0 0 13.5 6H11V4h2.5A2.5 2.5 0 0 1 16 6.5v8a2.5 2.5 0 0 1-2.5 2.5h-7A2.5 2.5 0 0 1 4 14.5v-9Z"})})}function Te(){return jsxRuntime.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",className:"shrink-0",children:jsxRuntime.jsx("path",{d:"M5.5 3A2.5 2.5 0 0 0 3 5.5v9A2.5 2.5 0 0 0 5.5 17h9a2.5 2.5 0 0 0 2.5-2.5v-9A2.5 2.5 0 0 0 14.5 3h-9ZM4 5.5A1.5 1.5 0 0 1 5.5 4h9A1.5 1.5 0 0 1 16 5.5v9a1.5 1.5 0 0 1-1.5 1.5h-9A1.5 1.5 0 0 1 4 14.5v-9ZM7 7.5a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 0 1h-5a.5.5 0 0 1-.5-.5Zm0 3a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 0 1h-5a.5.5 0 0 1-.5-.5Zm0 3a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 0 1h-3a.5.5 0 0 1-.5-.5Z"})})}function Ee(){return jsxRuntime.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",className:"shrink-0",children:jsxRuntime.jsx("path",{d:"M10 2a.5.5 0 0 1 .354.146l3 3a.5.5 0 0 1-.708.708L10.5 3.707V12.5a.5.5 0 0 1-1 0V3.707L7.354 5.854a.5.5 0 1 1-.708-.708l3-3A.5.5 0 0 1 10 2ZM4 13.5a.5.5 0 0 1 1 0v1A1.5 1.5 0 0 0 6.5 16h7a1.5 1.5 0 0 0 1.5-1.5v-1a.5.5 0 0 1 1 0v1a2.5 2.5 0 0 1-2.5 2.5h-7A2.5 2.5 0 0 1 4 14.5v-1Z"})})}function se(){let[n,e]=react.useState(false);return react.useEffect(()=>{if(typeof window>"u")return;let i=()=>e(window.innerWidth<768);return i(),window.addEventListener("resize",i),()=>window.removeEventListener("resize",i)},[]),n}function oe({onClose:n,children:e,title:i}){let r=se(),a=react.useRef(n);return a.current=n,react.useEffect(()=>{let l=t=>{t.key==="Escape"&&a.current();};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[]),r?jsxRuntime.jsxs("div",{className:"fixed inset-0 z-50 flex items-end justify-center",onClick:n,children:[jsxRuntime.jsx("div",{className:"fixed inset-0 bg-black/50"}),jsxRuntime.jsxs("div",{className:"relative z-10 w-full max-h-[90vh] overflow-y-auto rounded-t-2xl bg-[#1a1a1a] p-5 pb-8 animate-in slide-in-from-bottom duration-200",onClick:l=>l.stopPropagation(),children:[jsxRuntime.jsx("div",{className:"mx-auto mb-4 h-1 w-10 rounded-full bg-zinc-600"}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-5",children:[jsxRuntime.jsx("h2",{className:"text-lg font-semibold text-foreground",children:i}),jsxRuntime.jsx("button",{onClick:n,className:"rounded p-1 text-muted-foreground hover:text-foreground",children:jsxRuntime.jsx(O,{size:20})})]}),e]})]}):jsxRuntime.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",onClick:n,children:[jsxRuntime.jsx("div",{className:"fixed inset-0 bg-black/50"}),jsxRuntime.jsxs("div",{className:"relative z-10 w-full max-w-lg overflow-y-auto rounded-2xl bg-[#1a1a1a] p-6 shadow-2xl animate-in fade-in zoom-in-95 duration-150",onClick:l=>l.stopPropagation(),children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-5",children:[jsxRuntime.jsx("h2",{className:"text-lg font-semibold text-foreground",children:i}),jsxRuntime.jsx("button",{onClick:n,className:"rounded p-1 text-muted-foreground hover:text-foreground",children:jsxRuntime.jsx(O,{size:20})})]}),e]})]})}function Me(n){let e=n.split(`
4
- `),i="",r="",l=false;for(let t=0;t<e.length;t++){let s=e[t].trim();if(t===0&&s==="---"){l=true;continue}if(l){s==="---"&&(l=false,true);continue}if(!i){let c=s.match(/^#{1,2}\s+(.+)/);if(c){i=c[1].trim();continue}}if(i&&!r){if(!s||s.startsWith("#")||s==="---"||s==="***"||s==="___")continue;r=s.replace(/\*\*/g,"").replace(/`/g,"").trim();break}}return i?{title:i,description:r}:null}function $e({onClose:n,onCreated:e,config:i}){let[r,a]=react.useState(""),[l,t]=react.useState(""),[s,c]=react.useState(""),[d,u]=react.useState(false),[h,g]=react.useState(null),[m,b]=react.useState(false),v=p=>{if(c(p),!r.trim()&&!l.trim()&&p.trim().length>10){let y=Me(p);y&&(a(y.title.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")),t(y.description),b(true));}};return jsxRuntime.jsx(oe,{title:"Write skill instructions",onClose:n,children:jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"space-y-1.5",children:[jsxRuntime.jsx("label",{htmlFor:"skill-name",className:"text-sm text-muted-foreground",children:"Skill name"}),jsxRuntime.jsx("input",{id:"skill-name",value:r,onChange:p=>a(p.target.value),placeholder:"weekly-status-report",className:"w-full rounded-lg border border-zinc-700 bg-[#252525] px-3 py-2.5 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-zinc-500"})]}),jsxRuntime.jsxs("div",{className:"space-y-1.5",children:[jsxRuntime.jsx("label",{htmlFor:"skill-desc",className:"text-sm text-muted-foreground",children:"Description"}),jsxRuntime.jsx("textarea",{id:"skill-desc",value:l,onChange:p=>t(p.target.value),placeholder:"Generate weekly status reports from recent work.",rows:3,className:"w-full rounded-lg border border-zinc-700 bg-[#252525] px-3 py-2.5 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-zinc-500"})]}),jsxRuntime.jsxs("div",{className:"space-y-1.5",children:[jsxRuntime.jsx("label",{htmlFor:"skill-instructions",className:"text-sm text-muted-foreground",children:"Instructions"}),jsxRuntime.jsx("textarea",{id:"skill-instructions",value:s,onChange:p=>v(p.target.value),placeholder:"Summarize my recent work in three sections: wins, blockers, and next steps.",rows:8,className:"w-full rounded-lg border border-zinc-700 bg-[#252525] px-3 py-2.5 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-zinc-500"})]}),h&&jsxRuntime.jsx("p",{className:"text-sm text-red-500",children:h}),jsxRuntime.jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[jsxRuntime.jsx("button",{onClick:n,className:"rounded-lg border border-zinc-700 px-4 py-2 text-sm text-foreground hover:bg-zinc-800",children:"Cancel"}),jsxRuntime.jsx("button",{onClick:async()=>{if(r.trim()){u(true),g(null);try{let p=i.apiBaseUrl||"",y=m?s.trim():`# ${r.trim()}
1
+ 'use strict';var react=require('react'),lucideReact=require('lucide-react'),clsx=require('clsx'),tailwindMerge=require('tailwind-merge'),jsxRuntime=require('react/jsx-runtime');function C(...r){return tailwindMerge.twMerge(clsx.clsx(r))}async function k(r,e,i,s){let a={"Content-Type":"application/json",...i?.headers};s&&(a.Authorization=`Bearer ${s}`);let l=await fetch(`${r}${e}`,{...i,headers:a});if(!l.ok){let t=`HTTP ${l.status}`;try{let n=await l.json();n.error&&(t=n.error);}catch{}throw new Error(t)}return l.json()}function z(r){let e=r.indexOf(":");return {mode:r.slice(0,e),cid:r.slice(e+1)}}function _(r){let e=r.apiBaseUrl,i=r.authorMid,s=r.ownerMid,a=r.apiKey,l=r.stacknetUrl||r.apiBaseUrl;return react.useMemo(()=>({async listRepos(t,n){let c=new URLSearchParams;(t||s)&&c.set("owner",t||s),n?.limit&&c.set("limit",String(n.limit)),n?.cursor&&c.set("cursor",n.cursor);let d=c.toString()?`?${c}`:"",u=await k(e,`/api/rack/repos${d}`,void 0,a);return {items:u.repos||[],pagination:u.pagination||{total:(u.repos||[]).length,limit:50,has_more:false,next_cursor:null}}},async initRepo(t){return k(e,"/api/rack/init",{method:"POST",body:JSON.stringify({...t,owner_mid:s})},a)},async push(t,n){return k(e,`/api/rack/${t}/push`,{method:"POST",body:JSON.stringify({...n,author_mid:i})},a)},async getTree(t,n="main"){let c=await k(e,`/api/rack/${t}/tree/${n}`,void 0,a);return {tree:c.tree,commit_cid:c.commit_cid}},async getBlob(t,n){return (await k(e,`/api/rack/${t}/blob/${n}`,void 0,a)).content},async getLog(t,n,c){let d=new URLSearchParams;n&&d.set("ref",n),c&&d.set("max_count",String(c));let u=d.toString()?`?${d}`:"";return (await k(e,`/api/rack/${t}/log${u}`,void 0,a)).commits||[]},async getBranches(t){return (await k(e,`/api/rack/${t}/branches`,void 0,a)).branches||[]},async createBranch(t,n,c){return k(e,`/api/rack/${t}/branch`,{method:"POST",body:JSON.stringify({branch_name:n,from_ref:c})},a)},async merge(t,n,c){return k(e,`/api/rack/${t}/merge`,{method:"POST",body:JSON.stringify({source_branch:n,target_branch:c})},a)},async getDiff(t,n,c){return (await k(e,`/api/rack/${t}/diff/${n}/${c}`,void 0,a)).diff?.entries||[]},async starRepo(t){return k(e,`/api/rack/${t}/star`,{method:"POST"},a)},async unstarRepo(t){return k(e,`/api/rack/${t}/star`,{method:"DELETE"},a)},async getStarInfo(t){return k(e,`/api/rack/${t}/stars`,void 0,a)},async getSkillStats(t){let n={meta:null,tokenCount:null,usageCount:null};try{let{tree:c}=await this.getTree(t,"main");if(!c?.entries)return n;if(c.entries["META.json"]){let h=z(c.entries["META.json"]).cid,g=await this.getBlob(t,h);n.meta=JSON.parse(g);}let d=0,u=Object.values(c.entries).map(async h=>{try{let g=z(h).cid,m=await this.getBlob(t,g);d+=m.length;}catch{}});await Promise.all(u),d>0&&(n.tokenCount=Math.ceil(d/4)),n.meta?.skill_id&&(n.usageCount=await this.getSkillUsageCount(n.meta.skill_id));}catch{}return n},async getSkillUsageCount(t){try{let n=await fetch(`${l}/v1/skills/${encodeURIComponent(t)}`);if(n.ok){let d=await n.json();return d.usage_count??d.usageCount??null}let c=await fetch(`${l}/v1/skills?scope=public`);if(c.ok){let u=((await c.json()).skills||[]).find(h=>h.name===t||h.id===t);if(u)return u.usage_count??u.usageCount??0}return 0}catch{return null}},async getTensorStats(t){let n={meta:null,sizeMB:null};try{let{tree:c}=await this.getTree(t,"main");if(!c?.entries)return n;if(c.entries["TENSOR_META.json"]){let d=z(c.entries["TENSOR_META.json"]).cid,u=await this.getBlob(t,d);n.meta=JSON.parse(u),n.sizeMB=n.meta?.tensor_size_mb??null;}}catch{}return n},async getLooopStats(t){let n={meta:null,fileCount:null};try{let{tree:c}=await this.getTree(t,"main");if(!c?.entries)return n;if(c.entries["LOOOP_META.json"]){let d=z(c.entries["LOOOP_META.json"]).cid,u=await this.getBlob(t,d);n.meta=JSON.parse(u);}n.fileCount=Object.keys(c.entries).length;}catch{}return n},async getNetworkStats(){try{return (await k(e,"/api/rack/stats",void 0,a)).stats||null}catch{return null}},async getTrending(t=5,n=1,c){try{let d=new URLSearchParams({limit:String(t),days:String(n)});c&&d.set("cursor",c);let u=await k(e,`/api/rack/trending?${d}`,void 0,a);return {items:u.trending||[],pagination:u.pagination||{total:(u.trending||[]).length,limit:t,has_more:!1,next_cursor:null}}}catch{return {items:[],pagination:{total:0,limit:t,has_more:false,next_cursor:null}}}}}),[e,i,s,a,l])}function K(r,e={}){let{pageSize:i=50,owner:s}=e,a=_(r),[l,t]=react.useState([]),[n,c]=react.useState(null),[d,u]=react.useState(false),[h,g]=react.useState(null),m=react.useRef(null),y=react.useRef(true),b=react.useCallback(async(v,T=false)=>{u(true),g(null);try{let R=await a.listRepos(s,{limit:i,cursor:v||void 0});y.current&&(t(E=>T?[...E,...R.items]:R.items),c(R.pagination),m.current=R.pagination.next_cursor);}catch(R){y.current&&g(R.message);}finally{y.current&&u(false);}},[a,s,i]),S=react.useCallback(async()=>{!m.current||d||await b(m.current,true);},[b,d]),p=react.useCallback(async()=>{m.current=null,await b(void 0,false);},[b]);return react.useEffect(()=>(y.current=true,b(),()=>{y.current=false;}),[b]),{repos:l,hasMore:n?.has_more??false,total:n?.total??0,loading:d,error:h,loadMore:S,reset:p,pagination:n}}function ye(r){return Object.entries(r).map(([e,i])=>{let s=i.indexOf(":"),a=s>0?i.slice(0,s):"100644",l=s>0?i.slice(s+1):i;return {path:e,mode:a,cid:l,isDir:a==="040000"}}).sort((e,i)=>e.isDir!==i.isDir?e.isDir?-1:1:e.path.localeCompare(i.path))}function Y(r,e,i="main"){let s=_(r),[a,l]=react.useState([]),[t,n]=react.useState(false),[c,d]=react.useState(null),u=react.useRef(true),h=react.useCallback(async()=>{if(e)try{u.current&&(n(!0),d(null));let{tree:m}=await s.getTree(e,i);u.current&&l(ye(m.entries));}catch(m){u.current&&d(m instanceof Error?m.message:"Failed to load tree");}finally{u.current&&n(false);}},[s,e,i]);react.useEffect(()=>(u.current=true,h(),()=>{u.current=false;}),[h]);let g=react.useCallback(async m=>{if(!e)throw new Error("No repo selected");return s.getBlob(e,m)},[s,e]);return {entries:a,loading:t,error:c,refresh:h,getFileContent:g}}var be=/^(https?:\/\/|mailto:|\/[^/])/i;function ve(r){let e=r.trim();return be.test(e)?e:null}function L(r){let e=[],i=/(`[^`]+`)|(\*\*(.+?)\*\*)|(\*(.+?)\*)|(_(.+?)_)|(\[([^\]]+)\]\(([^)]+)\))/g,s=0,a,l=0;for(;(a=i.exec(r))!==null;){a.index>s&&e.push(r.slice(s,a.index));let t=`i${l++}`;if(a[1])e.push(jsxRuntime.jsx("code",{className:"rounded bg-muted px-1.5 py-0.5 text-[0.85em] font-mono text-pink-400",children:a[1].slice(1,-1)},t));else if(a[2])e.push(jsxRuntime.jsx("strong",{children:a[3]},t));else if(a[4])e.push(jsxRuntime.jsx("em",{children:a[5]},t));else if(a[6])e.push(jsxRuntime.jsx("em",{children:a[7]},t));else if(a[8]){let n=ve(a[10]);n?e.push(jsxRuntime.jsx("a",{href:n,className:"text-blue-400 underline hover:text-blue-300",target:"_blank",rel:"noopener noreferrer",children:a[9]},t)):e.push(a[9]);}s=a.index+a[0].length;}return s<r.length&&e.push(r.slice(s)),e.length>0?e:[r]}function ke(r){let e=r.split(`
2
+ `),i=[],s=0;for(;s<e.length;){let a=e[s];if(a.trim()===""){s++;continue}if(/^(-{3,}|\*{3,}|_{3,})$/.test(a.trim())){i.push({type:"hr"}),s++;continue}let l=a.match(/^(#{1,6})\s+(.+)/);if(l){i.push({type:"heading",level:l[1].length,content:l[2]}),s++;continue}if(a.trim().startsWith("```")){let n=a.trim().slice(3).trim(),c=[];for(s++;s<e.length&&!e[s].trim().startsWith("```");)c.push(e[s]),s++;i.push({type:"code",content:c.join(`
3
+ `),lang:n||void 0}),s++;continue}if(/^\s*[-*+]\s/.test(a)){let n=[];for(;s<e.length&&/^\s*[-*+]\s/.test(e[s]);)n.push(e[s].replace(/^\s*[-*+]\s+/,"")),s++;i.push({type:"ul",items:n});continue}if(/^\s*\d+[.)]\s/.test(a)){let n=[];for(;s<e.length&&/^\s*\d+[.)]\s/.test(e[s]);)n.push(e[s].replace(/^\s*\d+[.)]\s+/,"")),s++;i.push({type:"ol",items:n});continue}let t=[];for(;s<e.length&&e[s].trim()!==""&&!e[s].match(/^#{1,6}\s/)&&!e[s].trim().startsWith("```")&&!/^\s*[-*+]\s/.test(e[s])&&!/^\s*\d+[.)]\s/.test(e[s]);)t.push(e[s]),s++;t.length>0&&i.push({type:"paragraph",content:t.join(" ")});}return i}var Ne={1:"text-2xl font-bold mt-6 mb-3",2:"text-xl font-bold mt-5 mb-2",3:"text-lg font-semibold mt-4 mb-2",4:"text-base font-semibold mt-3 mb-1",5:"text-sm font-semibold mt-2 mb-1",6:"text-sm font-medium mt-2 mb-1"};function Re(r,e){switch(r.type){case "hr":return jsxRuntime.jsx("hr",{className:"my-4 border-border"},`b${e}`);case "heading":{let i=Math.min(Math.max(r.level||1,1),6),s=`h${i}`;return jsxRuntime.jsx(s,{className:C("text-foreground",Ne[i]),children:L(r.content||"")},`b${e}`)}case "paragraph":return jsxRuntime.jsx("p",{className:"mb-3 leading-relaxed text-foreground",children:L(r.content||"")},`b${e}`);case "code":return jsxRuntime.jsx("pre",{className:"mb-3 overflow-x-auto rounded-lg bg-muted p-4 text-sm font-mono leading-relaxed text-foreground",children:jsxRuntime.jsx("code",{children:r.content})},`b${e}`);case "ul":return jsxRuntime.jsx("ul",{className:"mb-3 ml-5 list-disc space-y-1 text-foreground",children:r.items?.map((i,s)=>jsxRuntime.jsx("li",{className:"leading-relaxed",children:L(i)},`li${e}-${s}`))},`b${e}`);case "ol":return jsxRuntime.jsx("ol",{className:"mb-3 ml-5 list-decimal space-y-1 text-foreground",children:r.items?.map((i,s)=>jsxRuntime.jsx("li",{className:"leading-relaxed",children:L(i)},`li${e}-${s}`))},`b${e}`);default:return null}}function U({content:r,className:e}){let i=ke(r);return jsxRuntime.jsx("div",{className:C("text-sm",e),children:i.map((s,a)=>Re(s,a))})}function ne({open:r,className:e}){return jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 20 20",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",className:C("shrink-0 transition-transform duration-150",r?"rotate-0":"-rotate-90",e),children:jsxRuntime.jsx("path",{d:"M16.134 6.16a.5.5 0 1 1 .732.68l-6.5 7-.077.068a.5.5 0 0 1-.655-.068l-6.5-7-.062-.08a.5.5 0 0 1 .718-.667l.076.067L10 12.767z"})})}function X({size:r=20,className:e}){return jsxRuntime.jsx("svg",{width:r,height:r,viewBox:"0 0 20 20",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",className:e,children:jsxRuntime.jsx("path",{d:"M8.5 2a6.5 6.5 0 0 1 4.935 10.728l4.419 4.419.064.078a.5.5 0 0 1-.693.693l-.079-.064-4.419-4.42A6.5 6.5 0 1 1 8.5 2m0 1a5.5 5.5 0 1 0 0 11 5.5 5.5 0 0 0 0-11"})})}function j({size:r=20,className:e}){return jsxRuntime.jsx("svg",{width:r,height:r,viewBox:"0 0 20 20",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",className:e,children:jsxRuntime.jsx("path",{d:"M15.147 4.146a.5.5 0 0 1 .707.707L10.707 10l5.147 5.147a.5.5 0 0 1-.63.771l-.078-.064L10 10.707l-5.146 5.147a.5.5 0 0 1-.708-.707L9.293 10 4.146 4.853a.5.5 0 0 1 .708-.707L10 9.293z"})})}function re({size:r=20,className:e}){return jsxRuntime.jsx("svg",{width:r,height:r,viewBox:"0 0 20 20",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",className:e,children:jsxRuntime.jsx("path",{d:"M10 3a.5.5 0 0 1 .5.5v6h6l.1.01a.5.5 0 0 1 0 .98l-.1.01h-6v6a.5.5 0 0 1-1 0v-6h-6a.5.5 0 0 1 0-1h6v-6A.5.5 0 0 1 10 3"})})}function Pe(){return jsxRuntime.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",className:"shrink-0",children:jsxRuntime.jsx("path",{d:"M6.5 3A2.5 2.5 0 0 0 4 5.5v9A2.5 2.5 0 0 0 6.5 17h7a2.5 2.5 0 0 0 2.5-2.5v-7A2.5 2.5 0 0 0 13.5 5H11V3.5a.5.5 0 0 0-1 0V5H6.5ZM5 5.5A1.5 1.5 0 0 1 6.5 4H9v1H6.5A1.5 1.5 0 0 0 5 6.5v8A1.5 1.5 0 0 0 6.5 16h7a1.5 1.5 0 0 0 1.5-1.5v-7A1.5 1.5 0 0 0 13.5 6H11V4h2.5A2.5 2.5 0 0 1 16 6.5v8a2.5 2.5 0 0 1-2.5 2.5h-7A2.5 2.5 0 0 1 4 14.5v-9Z"})})}function Te(){return jsxRuntime.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",className:"shrink-0",children:jsxRuntime.jsx("path",{d:"M5.5 3A2.5 2.5 0 0 0 3 5.5v9A2.5 2.5 0 0 0 5.5 17h9a2.5 2.5 0 0 0 2.5-2.5v-9A2.5 2.5 0 0 0 14.5 3h-9ZM4 5.5A1.5 1.5 0 0 1 5.5 4h9A1.5 1.5 0 0 1 16 5.5v9a1.5 1.5 0 0 1-1.5 1.5h-9A1.5 1.5 0 0 1 4 14.5v-9ZM7 7.5a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 0 1h-5a.5.5 0 0 1-.5-.5Zm0 3a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 0 1h-5a.5.5 0 0 1-.5-.5Zm0 3a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 0 1h-3a.5.5 0 0 1-.5-.5Z"})})}function Ee(){return jsxRuntime.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",className:"shrink-0",children:jsxRuntime.jsx("path",{d:"M10 2a.5.5 0 0 1 .354.146l3 3a.5.5 0 0 1-.708.708L10.5 3.707V12.5a.5.5 0 0 1-1 0V3.707L7.354 5.854a.5.5 0 1 1-.708-.708l3-3A.5.5 0 0 1 10 2ZM4 13.5a.5.5 0 0 1 1 0v1A1.5 1.5 0 0 0 6.5 16h7a1.5 1.5 0 0 0 1.5-1.5v-1a.5.5 0 0 1 1 0v1a2.5 2.5 0 0 1-2.5 2.5h-7A2.5 2.5 0 0 1 4 14.5v-1Z"})})}function se(){let[r,e]=react.useState(false);return react.useEffect(()=>{if(typeof window>"u")return;let i=()=>e(window.innerWidth<768);return i(),window.addEventListener("resize",i),()=>window.removeEventListener("resize",i)},[]),r}function oe({onClose:r,children:e,title:i}){let s=se(),a=react.useRef(r);return a.current=r,react.useEffect(()=>{let l=t=>{t.key==="Escape"&&a.current();};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[]),s?jsxRuntime.jsxs("div",{className:"fixed inset-0 z-50 flex items-end justify-center",onClick:r,children:[jsxRuntime.jsx("div",{className:"fixed inset-0 bg-black/50"}),jsxRuntime.jsxs("div",{className:"relative z-10 w-full max-h-[90vh] overflow-y-auto rounded-t-2xl bg-[#1a1a1a] p-5 pb-8 animate-in slide-in-from-bottom duration-200",onClick:l=>l.stopPropagation(),children:[jsxRuntime.jsx("div",{className:"mx-auto mb-4 h-1 w-10 rounded-full bg-zinc-600"}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-5",children:[jsxRuntime.jsx("h2",{className:"text-lg font-semibold text-foreground",children:i}),jsxRuntime.jsx("button",{onClick:r,className:"rounded p-1 text-muted-foreground hover:text-foreground",children:jsxRuntime.jsx(j,{size:20})})]}),e]})]}):jsxRuntime.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",onClick:r,children:[jsxRuntime.jsx("div",{className:"fixed inset-0 bg-black/50"}),jsxRuntime.jsxs("div",{className:"relative z-10 w-full max-w-lg overflow-y-auto rounded-2xl bg-[#1a1a1a] p-6 shadow-2xl animate-in fade-in zoom-in-95 duration-150",onClick:l=>l.stopPropagation(),children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-5",children:[jsxRuntime.jsx("h2",{className:"text-lg font-semibold text-foreground",children:i}),jsxRuntime.jsx("button",{onClick:r,className:"rounded p-1 text-muted-foreground hover:text-foreground",children:jsxRuntime.jsx(j,{size:20})})]}),e]})]})}function Me(r){let e=r.split(`
4
+ `),i="",s="",l=false;for(let t=0;t<e.length;t++){let n=e[t].trim();if(t===0&&n==="---"){l=true;continue}if(l){n==="---"&&(l=false,true);continue}if(!i){let c=n.match(/^#{1,2}\s+(.+)/);if(c){i=c[1].trim();continue}}if(i&&!s){if(!n||n.startsWith("#")||n==="---"||n==="***"||n==="___")continue;s=n.replace(/\*\*/g,"").replace(/`/g,"").trim();break}}return i?{title:i,description:s}:null}function $e({onClose:r,onCreated:e,config:i}){let[s,a]=react.useState(""),[l,t]=react.useState(""),[n,c]=react.useState(""),[d,u]=react.useState(false),[h,g]=react.useState(null),[m,y]=react.useState(false),b=p=>{if(c(p),!s.trim()&&!l.trim()&&p.trim().length>10){let v=Me(p);v&&(a(v.title.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")),t(v.description),y(true));}};return jsxRuntime.jsx(oe,{title:"Write skill instructions",onClose:r,children:jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"space-y-1.5",children:[jsxRuntime.jsx("label",{htmlFor:"skill-name",className:"text-sm text-muted-foreground",children:"Skill name"}),jsxRuntime.jsx("input",{id:"skill-name",value:s,onChange:p=>a(p.target.value),placeholder:"weekly-status-report",className:"w-full rounded-lg border border-zinc-700 bg-[#252525] px-3 py-2.5 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-zinc-500"})]}),jsxRuntime.jsxs("div",{className:"space-y-1.5",children:[jsxRuntime.jsx("label",{htmlFor:"skill-desc",className:"text-sm text-muted-foreground",children:"Description"}),jsxRuntime.jsx("textarea",{id:"skill-desc",value:l,onChange:p=>t(p.target.value),placeholder:"Generate weekly status reports from recent work.",rows:3,className:"w-full rounded-lg border border-zinc-700 bg-[#252525] px-3 py-2.5 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-zinc-500"})]}),jsxRuntime.jsxs("div",{className:"space-y-1.5",children:[jsxRuntime.jsx("label",{htmlFor:"skill-instructions",className:"text-sm text-muted-foreground",children:"Instructions"}),jsxRuntime.jsx("textarea",{id:"skill-instructions",value:n,onChange:p=>b(p.target.value),placeholder:"Summarize my recent work in three sections: wins, blockers, and next steps.",rows:8,className:"w-full rounded-lg border border-zinc-700 bg-[#252525] px-3 py-2.5 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-zinc-500"})]}),h&&jsxRuntime.jsx("p",{className:"text-sm text-red-500",children:h}),jsxRuntime.jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[jsxRuntime.jsx("button",{onClick:r,className:"rounded-lg border border-zinc-700 px-4 py-2 text-sm text-foreground hover:bg-zinc-800",children:"Cancel"}),jsxRuntime.jsx("button",{onClick:async()=>{if(s.trim()){u(true),g(null);try{let p=i.apiBaseUrl||"",v=m?n.trim():`# ${s.trim()}
5
5
 
6
6
  ${l.trim()}
7
7
 
8
8
  ---
9
9
 
10
- ${s.trim()}`,T=await fetch(`${p}/api/skills`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:r.trim(),description:l.trim(),skill_md:y,content_type:"code"})});if(!T.ok){let R=`Failed to register skill (${T.status})`;try{let E=await T.json();E.error&&(R=E.error);}catch{}throw new Error(R)}e?.(),n();}catch(p){g(p instanceof Error?p.message:"Failed to create skill");}finally{u(false);}}},disabled:d||!r.trim(),className:"rounded-lg bg-zinc-600 px-4 py-2 text-sm font-medium text-white hover:bg-zinc-500 disabled:opacity-50",children:d?"Creating...":"Create"})]})]})})}function ze({onClose:n,onCreated:e,config:i}){let r=react.useRef(null),[a,l]=react.useState(false),[t,s]=react.useState(false),[c,d]=react.useState(null),u=async g=>{s(true),d(null);try{let m=await g.text(),b=i.apiBaseUrl||"",v=g.name.replace(/\.[^.]+$/,"").replace(/[^a-zA-Z0-9-_]/g,"-"),S=await fetch(`${b}/api/skills`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:v,skill_md:m,content_type:"code"})});if(!S.ok){let p=`Failed to register skill (${S.status})`;try{let y=await S.json();y.error&&(p=y.error);}catch{}throw new Error(p)}e?.(),n();}catch(m){d(m instanceof Error?m.message:"Upload failed");}finally{s(false);}};return jsxRuntime.jsx(oe,{title:"Upload skill",onClose:n,children:jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{onDragOver:g=>{g.preventDefault(),l(true);},onDragLeave:()=>l(false),onDrop:g=>{g.preventDefault(),l(false);let m=g.dataTransfer.files[0];m&&u(m);},onClick:()=>r.current?.click(),className:C("flex cursor-pointer flex-col items-center justify-center gap-3 rounded-xl border-2 border-dashed p-10 transition-colors",a?"border-zinc-400 bg-zinc-800/50":"border-zinc-700 hover:border-zinc-500"),children:[jsxRuntime.jsx("div",{className:"rounded-lg border border-zinc-600 p-2",children:jsxRuntime.jsx(re,{size:20,className:"text-muted-foreground"})}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:t?"Uploading...":"Drag and drop or click to upload"})]}),jsxRuntime.jsx("input",{ref:r,type:"file",accept:".md,.zip,.skill,.txt,.yml,.yaml",className:"hidden","aria-label":"Upload skill file",onChange:g=>{let m=g.target.files?.[0];m&&u(m);}}),c&&jsxRuntime.jsx("p",{className:"text-sm text-red-500",children:c}),jsxRuntime.jsxs("div",{className:"space-y-2 text-xs text-muted-foreground",children:[jsxRuntime.jsx("p",{className:"font-medium text-foreground/70",children:"File requirements"}),jsxRuntime.jsxs("ul",{className:"list-disc pl-5 space-y-1",children:[jsxRuntime.jsx("li",{children:".md file must contain skill name and description formatted in YAML"}),jsxRuntime.jsx("li",{children:".zip or .skill file must include a SKILL.md file"})]})]})]})})}function Ie({onClose:n,onSelect:e}){let i=se(),r=react.useRef(null),a=react.useRef(n);a.current=n,react.useEffect(()=>{if(i)return;let t=s=>{r.current&&s.target instanceof Node&&!r.current.contains(s.target)&&a.current();};return document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[i]);let l=[{id:"create-with-geoff",icon:jsxRuntime.jsx(Pe,{}),label:"Create with Geoff"},{id:"write",icon:jsxRuntime.jsx(Te,{}),label:"Write skill instructions"},{id:"upload",icon:jsxRuntime.jsx(Ee,{}),label:"Upload a skill"}];return i?jsxRuntime.jsxs("div",{className:"fixed inset-0 z-50 flex items-end",onClick:n,children:[jsxRuntime.jsx("div",{className:"fixed inset-0 bg-black/50"}),jsxRuntime.jsxs("div",{className:"relative z-10 w-full rounded-t-2xl bg-[#1a1a1a] p-4 pb-8 animate-in slide-in-from-bottom duration-200",onClick:t=>t.stopPropagation(),children:[jsxRuntime.jsx("div",{className:"mx-auto mb-3 h-1 w-10 rounded-full bg-zinc-600"}),l.map(t=>jsxRuntime.jsxs("button",{onClick:()=>{e(t.id),n();},className:"flex w-full items-center gap-3 rounded-lg px-4 py-3 text-sm text-foreground transition-colors hover:bg-zinc-800",children:[t.icon,t.label]},t.id))]})]}):jsxRuntime.jsx("div",{ref:r,className:"absolute right-2 top-11 z-50 w-56 overflow-hidden rounded-xl border border-zinc-700 bg-[#2a2a2a] shadow-xl animate-in fade-in zoom-in-95 duration-100",children:l.map(t=>jsxRuntime.jsxs("button",{onClick:()=>{e(t.id),n();},className:"flex w-full items-center gap-3 px-4 py-3 text-sm text-foreground transition-colors hover:bg-zinc-700/50",children:[t.icon,t.label]},t.id))})}function _e({entry:n,selected:e,onSelect:i,depth:r=0}){return jsxRuntime.jsxs("button",{onClick:()=>i(n),className:C("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm transition-colors",e?"bg-[#141414] text-foreground":"text-muted-foreground hover:bg-muted/50 hover:text-foreground"),style:{paddingLeft:`${8+r*16}px`},children:[jsxRuntime.jsx("span",{className:"truncate flex-1",children:n.path.split("/").pop()}),n.isDir&&jsxRuntime.jsx(ne,{className:"ml-auto text-muted-foreground"})]})}function Be({repo:n,selected:e,expanded:i,onSelect:r,onToggle:a,children:l}){return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("button",{onClick:()=>{r(),a();},className:C("flex w-full items-center gap-2 rounded-md px-2 py-2 text-left text-sm font-medium transition-colors",e?"bg-[#141414] text-foreground":"text-muted-foreground hover:bg-muted/50 hover:text-foreground"),children:[jsxRuntime.jsx(ne,{open:i}),jsxRuntime.jsx(lucideReact.FileText,{className:"h-4 w-4 shrink-0"}),jsxRuntime.jsx("span",{className:"truncate",children:n.name})]}),i&&l]})}function Le({entry:n,content:e,loading:i,repoName:r}){let[a,l]=react.useState(false),t=react.useRef(null);react.useEffect(()=>()=>{t.current&&clearTimeout(t.current);},[]);let[s,c]=react.useState(false),d=async()=>{if(e)try{await navigator.clipboard.writeText(e),l(!0),c(!1),t.current&&clearTimeout(t.current),t.current=setTimeout(()=>l(!1),2e3);}catch{c(true),t.current&&clearTimeout(t.current),t.current=setTimeout(()=>c(false),2e3);}};if(!n)return jsxRuntime.jsx("div",{className:"flex h-full items-center justify-center text-sm text-muted-foreground",children:"Select a file to view its content"});if(i)return jsxRuntime.jsx("div",{className:"flex h-full items-center justify-center",children:jsxRuntime.jsx(lucideReact.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})});let u=n.path.split("/").pop()||n.path,h=/\.(md|mdx)$/i.test(u);return jsxRuntime.jsxs("div",{className:"flex h-full flex-col px-3",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[jsxRuntime.jsx("h3",{className:"text-sm sm:text-lg font-semibold text-foreground",children:u}),jsxRuntime.jsx("button",{onClick:d,"aria-label":"Copy file content",className:C("rounded p-1 transition-colors",a?"text-green-500":s?"text-red-500":"text-muted-foreground hover:text-foreground"),children:jsxRuntime.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",className:"shrink-0",children:jsxRuntime.jsx("path",{d:"M12.5 3A1.5 1.5 0 0 1 14 4.5V6h1.5A1.5 1.5 0 0 1 17 7.5v8a1.5 1.5 0 0 1-1.5 1.5h-8A1.5 1.5 0 0 1 6 15.5V14H4.5A1.5 1.5 0 0 1 3 12.5v-8A1.5 1.5 0 0 1 4.5 3zm1.5 9.5a1.5 1.5 0 0 1-1.5 1.5H7v1.5a.5.5 0 0 0 .5.5h8a.5.5 0 0 0 .5-.5v-8a.5.5 0 0 0-.5-.5H14zM4.5 4a.5.5 0 0 0-.5.5v8a.5.5 0 0 0 .5.5h8a.5.5 0 0 0 .5-.5v-8a.5.5 0 0 0-.5-.5z"})})})]}),jsxRuntime.jsx("div",{className:"flex-1 overflow-auto p-4",children:h?jsxRuntime.jsx(D,{content:e||""}):jsxRuntime.jsx("pre",{className:"whitespace-pre-wrap text-sm text-foreground font-mono leading-relaxed",children:e||""})})]})}function Ae({config:n,category:e,className:i,style:r}){let{repos:a,loading:l,error:t,reset:d}=K(n,{pageSize:50}),[u,h]=react.useState(null),[g,m]=react.useState(null),[b,v]=react.useState(null),[S,p]=react.useState(null),[y,T]=react.useState(false),[R,E]=react.useState(""),[ie,H]=react.useState(false),[W,J]=react.useState(false),[V,B]=react.useState(null),le=a.find(w=>w.repo_id===u),{entries:ce,getFileContent:Z}=Y(n,g),q=a.filter(w=>!R||w.name.toLowerCase().includes(R.toLowerCase())),ue=react.useCallback(async w=>{if(!w.isDir){v(w),T(true);try{let P=await Z(w.cid);p(P);}catch(P){let me=P instanceof Error?P.message:"Unknown error";p(`Failed to load file: ${me}`);}finally{T(false);}}},[Z]);react.useEffect(()=>{a.length>0&&!u&&(h(a[0].repo_id),m(a[0].repo_id));},[a,u]);let de=w=>{w==="create-with-geoff"?window.open(`https://www.geoff.ai/?p=${encodeURIComponent("Let's create a skill together using your skill-creator skill. First ask me what the skill should do.")}`,"_blank","noopener,noreferrer"):B(w);};return jsxRuntime.jsxs("div",{className:C("flex flex-1 h-full min-h-0",i),style:r,children:[jsxRuntime.jsxs("div",{className:"relative flex w-96 shrink-0 flex-col border-r",children:[jsxRuntime.jsx("div",{className:"flex h-12 items-center gap-2 px-3",children:ie?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex flex-1 items-center gap-2 rounded-md border bg-muted/50 px-2 py-1",children:[jsxRuntime.jsx(X,{size:16,className:"shrink-0 text-muted-foreground"}),jsxRuntime.jsx("input",{type:"text",value:R,onChange:w=>E(w.target.value),placeholder:"Search",autoFocus:true,"aria-label":"Search items",className:"flex-1 bg-transparent text-xs text-foreground placeholder:text-muted-foreground focus:outline-none"})]}),jsxRuntime.jsx("button",{onClick:()=>{H(false),E("");},className:"rounded p-1 text-muted-foreground hover:text-foreground",children:jsxRuntime.jsx(O,{size:16})})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("h3",{className:"flex-1 text-sm sm:text-lg font-semibold text-foreground capitalize",children:e||"Items"}),jsxRuntime.jsx("button",{onClick:()=>H(true),className:"rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground","aria-label":"Search",children:jsxRuntime.jsx(X,{size:20})}),jsxRuntime.jsx("button",{onClick:()=>J(!W),className:"rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground","aria-label":"Add new",children:jsxRuntime.jsx(re,{size:20})})]})}),W&&jsxRuntime.jsx(Ie,{onClose:()=>J(false),onSelect:de}),jsxRuntime.jsx("div",{className:"flex-1 overflow-y-auto p-2",children:l?jsxRuntime.jsx("div",{className:"flex items-center justify-center py-8",children:jsxRuntime.jsx(lucideReact.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):t?jsxRuntime.jsx("p",{className:"px-2 py-4 text-xs text-red-500",children:t}):q.length===0?jsxRuntime.jsx("p",{className:"px-2 py-4 text-xs text-muted-foreground",children:R?"No matching items":"No items yet"}):jsxRuntime.jsx("div",{className:"space-y-0.5",children:q.map(w=>jsxRuntime.jsx(Be,{repo:w,selected:u===w.repo_id,expanded:g===w.repo_id,onSelect:()=>{h(w.repo_id),v(null),p(null);},onToggle:()=>m(g===w.repo_id?null:w.repo_id),children:jsxRuntime.jsx("div",{className:"ml-10 pl-1",children:ce.map(P=>jsxRuntime.jsx(_e,{entry:P,selected:b?.path===P.path,onSelect:ue,depth:P.path.split("/").length-1},P.path))})},w.repo_id))})})]}),jsxRuntime.jsx("div",{className:"flex-1 min-w-0",children:jsxRuntime.jsx(Le,{entry:b,content:S,loading:y,repoName:le?.name||""})}),V==="write"&&jsxRuntime.jsx($e,{config:n,onClose:()=>B(null),onCreated:d}),V==="upload"&&jsxRuntime.jsx(ze,{config:n,onClose:()=>B(null),onCreated:d})]})}async function ae(n,e,i,r){let a={"Content-Type":"application/json",...i?.headers};r&&(a.Authorization=`Bearer ${r}`);let l=await fetch(`${n}${e}`,{...i,headers:a});if(!l.ok){let t=`HTTP ${l.status}`;try{let s=await l.json();s.error&&(t=s.error);}catch{}throw new Error(t)}return l.json()}function je({config:n,repoId:e,onAuthRequired:i,className:r,style:a}){let l=n.apiBaseUrl,t=n.apiKey,[s,c]=react.useState({stars:0,starred:false,repo_id:e}),[d,u]=react.useState(false),[h,g]=react.useState(null),m=react.useRef(true),b=l.includes("/cpx/rack")?"":"/api/rack";react.useEffect(()=>(m.current=true,ae(l,`${b}/${e}/stars`,void 0,t).then(S=>{m.current&&c(S);}).catch(()=>{}),()=>{m.current=false;}),[l,e,t,b]);let v=react.useCallback(async S=>{if(S.preventDefault(),S.stopPropagation(),!t){i?.();return}u(true),g(null);try{let p=s.starred?"DELETE":"POST",y=await ae(l,`${b}/${e}/star`,{method:p},t);m.current&&c({stars:y.stars,starred:y.starred,repo_id:e});}catch(p){m.current&&g(p.message);}finally{m.current&&u(false);}},[l,e,t,s.starred,i]);return jsxRuntime.jsxs("button",{onClick:v,disabled:d,title:h||(s.starred?"Unstar (100k tokens)":"Star (100k tokens)"),className:r,style:{display:"inline-flex",alignItems:"center",gap:"4px",background:"none",border:"none",cursor:d?"wait":"pointer",padding:"4px 8px",fontSize:"12px",fontFamily:"inherit",color:s.starred?"#f59e0b":"#91918d",transition:"color 150ms",opacity:d?.5:1,...a},children:[jsxRuntime.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:s.starred?"currentColor":"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})}),jsxRuntime.jsx("span",{children:s.stars})]})}
11
- exports.Markdown=D;exports.RackBrowser=Ae;exports.StarButton=je;
10
+ ${n.trim()}`,T=await fetch(`${p}/api/skills`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:s.trim(),description:l.trim(),skill_md:v,content_type:"code"})});if(!T.ok){let R=`Failed to register skill (${T.status})`;try{let E=await T.json();E.error&&(R=E.error);}catch{}throw new Error(R)}e?.(),r();}catch(p){g(p instanceof Error?p.message:"Failed to create skill");}finally{u(false);}}},disabled:d||!s.trim(),className:"rounded-lg bg-zinc-600 px-4 py-2 text-sm font-medium text-white hover:bg-zinc-500 disabled:opacity-50",children:d?"Creating...":"Create"})]})]})})}function ze({onClose:r,onCreated:e,config:i}){let s=react.useRef(null),[a,l]=react.useState(false),[t,n]=react.useState(false),[c,d]=react.useState(null),u=async g=>{n(true),d(null);try{let m=await g.text(),y=i.apiBaseUrl||"",b=g.name.replace(/\.[^.]+$/,"").replace(/[^a-zA-Z0-9-_]/g,"-"),S=await fetch(`${y}/api/skills`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:b,skill_md:m,content_type:"code"})});if(!S.ok){let p=`Failed to register skill (${S.status})`;try{let v=await S.json();v.error&&(p=v.error);}catch{}throw new Error(p)}e?.(),r();}catch(m){d(m instanceof Error?m.message:"Upload failed");}finally{n(false);}};return jsxRuntime.jsx(oe,{title:"Upload skill",onClose:r,children:jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{onDragOver:g=>{g.preventDefault(),l(true);},onDragLeave:()=>l(false),onDrop:g=>{g.preventDefault(),l(false);let m=g.dataTransfer.files[0];m&&u(m);},onClick:()=>s.current?.click(),className:C("flex cursor-pointer flex-col items-center justify-center gap-3 rounded-xl border-2 border-dashed p-10 transition-colors",a?"border-zinc-400 bg-zinc-800/50":"border-zinc-700 hover:border-zinc-500"),children:[jsxRuntime.jsx("div",{className:"rounded-lg border border-zinc-600 p-2",children:jsxRuntime.jsx(re,{size:20,className:"text-muted-foreground"})}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:t?"Uploading...":"Drag and drop or click to upload"})]}),jsxRuntime.jsx("input",{ref:s,type:"file",accept:".md,.zip,.skill,.txt,.yml,.yaml",className:"hidden","aria-label":"Upload skill file",onChange:g=>{let m=g.target.files?.[0];m&&u(m);}}),c&&jsxRuntime.jsx("p",{className:"text-sm text-red-500",children:c}),jsxRuntime.jsxs("div",{className:"space-y-2 text-xs text-muted-foreground",children:[jsxRuntime.jsx("p",{className:"font-medium text-foreground/70",children:"File requirements"}),jsxRuntime.jsxs("ul",{className:"list-disc pl-5 space-y-1",children:[jsxRuntime.jsx("li",{children:".md file must contain skill name and description formatted in YAML"}),jsxRuntime.jsx("li",{children:".zip or .skill file must include a SKILL.md file"})]})]})]})})}function _e({onClose:r,onSelect:e}){let i=se(),s=react.useRef(null),a=react.useRef(r);a.current=r,react.useEffect(()=>{if(i)return;let t=n=>{s.current&&n.target instanceof Node&&!s.current.contains(n.target)&&a.current();};return document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[i]);let l=[{id:"create-with-geoff",icon:jsxRuntime.jsx(Pe,{}),label:"Create with Geoff"},{id:"write",icon:jsxRuntime.jsx(Te,{}),label:"Write skill instructions"},{id:"upload",icon:jsxRuntime.jsx(Ee,{}),label:"Upload a skill"}];return i?jsxRuntime.jsxs("div",{className:"fixed inset-0 z-50 flex items-end",onClick:r,children:[jsxRuntime.jsx("div",{className:"fixed inset-0 bg-black/50"}),jsxRuntime.jsxs("div",{className:"relative z-10 w-full rounded-t-2xl bg-[#1a1a1a] p-4 pb-8 animate-in slide-in-from-bottom duration-200",onClick:t=>t.stopPropagation(),children:[jsxRuntime.jsx("div",{className:"mx-auto mb-3 h-1 w-10 rounded-full bg-zinc-600"}),l.map(t=>jsxRuntime.jsxs("button",{onClick:()=>{e(t.id),r();},className:"flex w-full items-center gap-3 rounded-lg px-4 py-3 text-sm text-foreground transition-colors hover:bg-zinc-800",children:[t.icon,t.label]},t.id))]})]}):jsxRuntime.jsx("div",{ref:s,className:"absolute right-2 top-11 z-50 w-56 overflow-hidden rounded-xl border border-zinc-700 bg-[#2a2a2a] shadow-xl animate-in fade-in zoom-in-95 duration-100",children:l.map(t=>jsxRuntime.jsxs("button",{onClick:()=>{e(t.id),r();},className:"flex w-full items-center gap-3 px-4 py-3 text-sm text-foreground transition-colors hover:bg-zinc-700/50",children:[t.icon,t.label]},t.id))})}function Ie({entry:r,selected:e,onSelect:i,depth:s=0}){return jsxRuntime.jsxs("button",{onClick:()=>i(r),className:C("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm transition-colors",e?"bg-[#141414] text-foreground":"text-muted-foreground hover:bg-muted/50 hover:text-foreground"),style:{paddingLeft:`${8+s*16}px`},children:[jsxRuntime.jsx("span",{className:"truncate flex-1",children:r.path.split("/").pop()}),r.isDir&&jsxRuntime.jsx(ne,{className:"ml-auto text-muted-foreground"})]})}function Le({repo:r,selected:e,expanded:i,onSelect:s,onToggle:a,children:l}){return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("button",{onClick:()=>{s(),a();},className:C("flex w-full items-center gap-2 rounded-md px-2 py-2 text-left text-sm font-medium transition-colors",e?"bg-[#141414] text-foreground":"text-muted-foreground hover:bg-muted/50 hover:text-foreground"),children:[jsxRuntime.jsx(ne,{open:i}),jsxRuntime.jsx(lucideReact.FileText,{className:"h-4 w-4 shrink-0"}),jsxRuntime.jsx("span",{className:"truncate",children:r.name})]}),i&&l]})}function Be({entry:r,content:e,loading:i,repoName:s}){let[a,l]=react.useState(false),t=react.useRef(null);react.useEffect(()=>()=>{t.current&&clearTimeout(t.current);},[]);let[n,c]=react.useState(false),d=async()=>{if(e)try{await navigator.clipboard.writeText(e),l(!0),c(!1),t.current&&clearTimeout(t.current),t.current=setTimeout(()=>l(!1),2e3);}catch{c(true),t.current&&clearTimeout(t.current),t.current=setTimeout(()=>c(false),2e3);}};if(!r)return jsxRuntime.jsx("div",{className:"flex h-full items-center justify-center text-sm text-muted-foreground",children:"Select a file to view its content"});if(i)return jsxRuntime.jsx("div",{className:"flex h-full items-center justify-center",children:jsxRuntime.jsx(lucideReact.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})});let u=r.path.split("/").pop()||r.path,h=/\.(md|mdx)$/i.test(u);return jsxRuntime.jsxs("div",{className:"flex h-full flex-col px-3",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[jsxRuntime.jsx("h3",{className:"text-sm sm:text-lg font-semibold text-foreground",children:u}),jsxRuntime.jsx("button",{onClick:d,"aria-label":"Copy file content",className:C("rounded p-1 transition-colors",a?"text-green-500":n?"text-red-500":"text-muted-foreground hover:text-foreground"),children:jsxRuntime.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",className:"shrink-0",children:jsxRuntime.jsx("path",{d:"M12.5 3A1.5 1.5 0 0 1 14 4.5V6h1.5A1.5 1.5 0 0 1 17 7.5v8a1.5 1.5 0 0 1-1.5 1.5h-8A1.5 1.5 0 0 1 6 15.5V14H4.5A1.5 1.5 0 0 1 3 12.5v-8A1.5 1.5 0 0 1 4.5 3zm1.5 9.5a1.5 1.5 0 0 1-1.5 1.5H7v1.5a.5.5 0 0 0 .5.5h8a.5.5 0 0 0 .5-.5v-8a.5.5 0 0 0-.5-.5H14zM4.5 4a.5.5 0 0 0-.5.5v8a.5.5 0 0 0 .5.5h8a.5.5 0 0 0 .5-.5v-8a.5.5 0 0 0-.5-.5z"})})})]}),jsxRuntime.jsx("div",{className:"flex-1 overflow-auto p-4",children:h?jsxRuntime.jsx(U,{content:e||""}):jsxRuntime.jsx("pre",{className:"whitespace-pre-wrap text-sm text-foreground font-mono leading-relaxed",children:e||""})})]})}function Ae({config:r,category:e,className:i,style:s}){let{repos:a,loading:l,error:t,reset:d}=K(r,{pageSize:50}),[u,h]=react.useState(null),[g,m]=react.useState(null),[y,b]=react.useState(null),[S,p]=react.useState(null),[v,T]=react.useState(false),[R,E]=react.useState(""),[ie,H]=react.useState(false),[J,W]=react.useState(false),[V,B]=react.useState(null),le=a.find(w=>w.repo_id===u),{entries:ce,getFileContent:Z}=Y(r,g),q=a.filter(w=>!R||w.name.toLowerCase().includes(R.toLowerCase())),ue=react.useCallback(async w=>{if(!w.isDir){b(w),T(true);try{let P=await Z(w.cid);p(P);}catch(P){let me=P instanceof Error?P.message:"Unknown error";p(`Failed to load file: ${me}`);}finally{T(false);}}},[Z]);react.useEffect(()=>{a.length>0&&!u&&(h(a[0].repo_id),m(a[0].repo_id));},[a,u]);let de=w=>{w==="create-with-geoff"?window.open(`https://www.geoff.ai/?p=${encodeURIComponent("Let's create a skill together using your skill-creator skill. First ask me what the skill should do.")}`,"_blank","noopener,noreferrer"):B(w);};return jsxRuntime.jsxs("div",{className:C("flex flex-1 h-full min-h-0",i),style:s,children:[jsxRuntime.jsxs("div",{className:"relative flex w-96 shrink-0 flex-col border-r",children:[jsxRuntime.jsx("div",{className:"flex h-12 items-center gap-2 px-3",children:ie?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex flex-1 items-center gap-2 rounded-md border bg-muted/50 px-2 py-1",children:[jsxRuntime.jsx(X,{size:16,className:"shrink-0 text-muted-foreground"}),jsxRuntime.jsx("input",{type:"text",value:R,onChange:w=>E(w.target.value),placeholder:"Search",autoFocus:true,"aria-label":"Search items",className:"flex-1 bg-transparent text-xs text-foreground placeholder:text-muted-foreground focus:outline-none"})]}),jsxRuntime.jsx("button",{onClick:()=>{H(false),E("");},className:"rounded p-1 text-muted-foreground hover:text-foreground",children:jsxRuntime.jsx(j,{size:16})})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("h3",{className:"flex-1 text-sm sm:text-lg font-semibold text-foreground capitalize",children:e||"Items"}),jsxRuntime.jsx("button",{onClick:()=>H(true),className:"rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground","aria-label":"Search",children:jsxRuntime.jsx(X,{size:20})}),jsxRuntime.jsx("button",{onClick:()=>W(!J),className:"rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground","aria-label":"Add new",children:jsxRuntime.jsx(re,{size:20})})]})}),J&&jsxRuntime.jsx(_e,{onClose:()=>W(false),onSelect:de}),jsxRuntime.jsx("div",{className:"flex-1 overflow-y-auto p-2",children:l?jsxRuntime.jsx("div",{className:"flex items-center justify-center py-8",children:jsxRuntime.jsx(lucideReact.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):t?jsxRuntime.jsx("p",{className:"px-2 py-4 text-xs text-red-500",children:t}):q.length===0?jsxRuntime.jsx("p",{className:"px-2 py-4 text-xs text-muted-foreground",children:R?"No matching items":"No items yet"}):jsxRuntime.jsx("div",{className:"space-y-0.5",children:q.map(w=>jsxRuntime.jsx(Le,{repo:w,selected:u===w.repo_id,expanded:g===w.repo_id,onSelect:()=>{h(w.repo_id),b(null),p(null);},onToggle:()=>m(g===w.repo_id?null:w.repo_id),children:jsxRuntime.jsx("div",{className:"ml-10 pl-1",children:ce.map(P=>jsxRuntime.jsx(Ie,{entry:P,selected:y?.path===P.path,onSelect:ue,depth:P.path.split("/").length-1},P.path))})},w.repo_id))})})]}),jsxRuntime.jsx("div",{className:"flex-1 min-w-0",children:jsxRuntime.jsx(Be,{entry:y,content:S,loading:v,repoName:le?.name||""})}),V==="write"&&jsxRuntime.jsx($e,{config:r,onClose:()=>B(null),onCreated:d}),V==="upload"&&jsxRuntime.jsx(ze,{config:r,onClose:()=>B(null),onCreated:d})]})}async function ae(r,e,i,s){let a={"Content-Type":"application/json",...i?.headers};s&&(a.Authorization=`Bearer ${s}`);let l=await fetch(`${r}${e}`,{...i,headers:a});if(!l.ok){let t=`HTTP ${l.status}`;try{let n=await l.json();n.error&&(t=n.error);}catch{}throw new Error(t)}return l.json()}function De({config:r,repoId:e,onAuthRequired:i,className:s,style:a}){let l=r.apiBaseUrl,t=r.apiKey,[n,c]=react.useState({stars:0,starred:false,repo_id:e}),[d,u]=react.useState(false),[h,g]=react.useState(null),m=react.useRef(true),y=l.includes("/cpx/rack")?"":"/api/rack";react.useEffect(()=>(m.current=true,ae(l,`${y}/${e}/stars`,void 0,t).then(S=>{m.current&&c(S);}).catch(()=>{}),()=>{m.current=false;}),[l,e,t,y]);let b=react.useCallback(async S=>{if(S.preventDefault(),S.stopPropagation(),!t){i?.();return}u(true),g(null);try{let p=n.starred?"DELETE":"POST",v=await ae(l,`${y}/${e}/star`,{method:p},t);m.current&&c({stars:v.stars,starred:v.starred,repo_id:e});}catch(p){m.current&&g(p.message);}finally{m.current&&u(false);}},[l,e,t,n.starred,i]);return jsxRuntime.jsxs("button",{onClick:b,disabled:d,title:h||(n.starred?"Unstar (100k tokens)":"Star (100k tokens)"),className:s,style:{display:"inline-flex",alignItems:"center",gap:"4px",background:"none",border:"none",cursor:d?"wait":"pointer",padding:"4px 8px",fontSize:"12px",fontFamily:"inherit",color:n.starred?"#f59e0b":"#91918d",transition:"color 150ms",opacity:d?.5:1,...a},children:[jsxRuntime.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:n.starred?"currentColor":"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})}),jsxRuntime.jsx("span",{children:n.stars})]})}
11
+ exports.Markdown=U;exports.RackBrowser=Ae;exports.StarButton=De;
@@ -1,11 +1,11 @@
1
- import {useState,useCallback,useEffect,useRef,useMemo}from'react';import {Loader2,FileText}from'lucide-react';import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {jsx,jsxs,Fragment}from'react/jsx-runtime';function C(...n){return twMerge(clsx(n))}async function k(n,e,i,r){let a={"Content-Type":"application/json",...i?.headers};r&&(a.Authorization=`Bearer ${r}`);let l=await fetch(`${n}${e}`,{...i,headers:a});if(!l.ok){let t=`HTTP ${l.status}`;try{let s=await l.json();s.error&&(t=s.error);}catch{}throw new Error(t)}return l.json()}function L(n){let e=n.indexOf(":");return {mode:n.slice(0,e),cid:n.slice(e+1)}}function z(n){let e=n.apiBaseUrl,i=n.authorMid,r=n.ownerMid,a=n.apiKey,l=n.stacknetUrl||n.apiBaseUrl;return useMemo(()=>({async listRepos(t,s){let c=new URLSearchParams;(t||r)&&c.set("owner",t||r),s?.limit&&c.set("limit",String(s.limit)),s?.cursor&&c.set("cursor",s.cursor);let d=c.toString()?`?${c}`:"",u=await k(e,`/api/rack/repos${d}`,void 0,a);return {items:u.repos||[],pagination:u.pagination||{total:(u.repos||[]).length,limit:50,has_more:false,next_cursor:null}}},async initRepo(t){return k(e,"/api/rack/init",{method:"POST",body:JSON.stringify({...t,owner_mid:r})},a)},async push(t,s){return k(e,`/api/rack/${t}/push`,{method:"POST",body:JSON.stringify({...s,author_mid:i})},a)},async getTree(t,s="main"){let c=await k(e,`/api/rack/${t}/tree/${s}`,void 0,a);return {tree:c.tree,commit_cid:c.commit_cid}},async getBlob(t,s){return (await k(e,`/api/rack/${t}/blob/${s}`,void 0,a)).content},async getLog(t,s,c){let d=new URLSearchParams;s&&d.set("ref",s),c&&d.set("max_count",String(c));let u=d.toString()?`?${d}`:"";return (await k(e,`/api/rack/${t}/log${u}`,void 0,a)).commits||[]},async getBranches(t){return (await k(e,`/api/rack/${t}/branches`,void 0,a)).branches||[]},async createBranch(t,s,c){return k(e,`/api/rack/${t}/branch`,{method:"POST",body:JSON.stringify({branch_name:s,from_ref:c})},a)},async merge(t,s,c){return k(e,`/api/rack/${t}/merge`,{method:"POST",body:JSON.stringify({source_branch:s,target_branch:c})},a)},async getDiff(t,s,c){return (await k(e,`/api/rack/${t}/diff/${s}/${c}`,void 0,a)).diff?.entries||[]},async starRepo(t){return k(e,`/api/rack/${t}/star`,{method:"POST"},a)},async unstarRepo(t){return k(e,`/api/rack/${t}/star`,{method:"DELETE"},a)},async getStarInfo(t){return k(e,`/api/rack/${t}/stars`,void 0,a)},async getSkillStats(t){let s={meta:null,tokenCount:null,usageCount:null};try{let{tree:c}=await this.getTree(t,"main");if(!c?.entries)return s;if(c.entries["META.json"]){let h=L(c.entries["META.json"]).cid,g=await this.getBlob(t,h);s.meta=JSON.parse(g);}let d=0,u=Object.values(c.entries).map(async h=>{try{let g=L(h).cid,m=await this.getBlob(t,g);d+=m.length;}catch{}});await Promise.all(u),d>0&&(s.tokenCount=Math.ceil(d/4)),s.meta?.skill_id&&(s.usageCount=await this.getSkillUsageCount(s.meta.skill_id));}catch{}return s},async getSkillUsageCount(t){try{let s=await fetch(`${l}/v1/skills/${encodeURIComponent(t)}`);if(s.ok){let d=await s.json();return d.usage_count??d.usageCount??null}let c=await fetch(`${l}/v1/skills?scope=public`);if(c.ok){let u=((await c.json()).skills||[]).find(h=>h.name===t||h.id===t);if(u)return u.usage_count??u.usageCount??0}return 0}catch{return null}},async getTensorStats(t){let s={meta:null,sizeMB:null};try{let{tree:c}=await this.getTree(t,"main");if(!c?.entries)return s;if(c.entries["TENSOR_META.json"]){let d=L(c.entries["TENSOR_META.json"]).cid,u=await this.getBlob(t,d);s.meta=JSON.parse(u),s.sizeMB=s.meta?.tensor_size_mb??null;}}catch{}return s},async getNetworkStats(){try{return (await k(e,"/api/rack/stats",void 0,a)).stats||null}catch{return null}},async getTrending(t=5,s=1,c){try{let d=new URLSearchParams({limit:String(t),days:String(s)});c&&d.set("cursor",c);let u=await k(e,`/api/rack/trending?${d}`,void 0,a);return {items:u.trending||[],pagination:u.pagination||{total:(u.trending||[]).length,limit:t,has_more:!1,next_cursor:null}}}catch{return {items:[],pagination:{total:0,limit:t,has_more:false,next_cursor:null}}}}}),[e,i,r,a,l])}function K(n,e={}){let{pageSize:i=50,owner:r}=e,a=z(n),[l,t]=useState([]),[s,c]=useState(null),[d,u]=useState(false),[h,g]=useState(null),m=useRef(null),b=useRef(true),v=useCallback(async(y,T=false)=>{u(true),g(null);try{let R=await a.listRepos(r,{limit:i,cursor:y||void 0});b.current&&(t(E=>T?[...E,...R.items]:R.items),c(R.pagination),m.current=R.pagination.next_cursor);}catch(R){b.current&&g(R.message);}finally{b.current&&u(false);}},[a,r,i]),S=useCallback(async()=>{!m.current||d||await v(m.current,true);},[v,d]),p=useCallback(async()=>{m.current=null,await v(void 0,false);},[v]);return useEffect(()=>(b.current=true,v(),()=>{b.current=false;}),[v]),{repos:l,hasMore:s?.has_more??false,total:s?.total??0,loading:d,error:h,loadMore:S,reset:p,pagination:s}}function be(n){return Object.entries(n).map(([e,i])=>{let r=i.indexOf(":"),a=r>0?i.slice(0,r):"100644",l=r>0?i.slice(r+1):i;return {path:e,mode:a,cid:l,isDir:a==="040000"}}).sort((e,i)=>e.isDir!==i.isDir?e.isDir?-1:1:e.path.localeCompare(i.path))}function Y(n,e,i="main"){let r=z(n),[a,l]=useState([]),[t,s]=useState(false),[c,d]=useState(null),u=useRef(true),h=useCallback(async()=>{if(e)try{u.current&&(s(!0),d(null));let{tree:m}=await r.getTree(e,i);u.current&&l(be(m.entries));}catch(m){u.current&&d(m instanceof Error?m.message:"Failed to load tree");}finally{u.current&&s(false);}},[r,e,i]);useEffect(()=>(u.current=true,h(),()=>{u.current=false;}),[h]);let g=useCallback(async m=>{if(!e)throw new Error("No repo selected");return r.getBlob(e,m)},[r,e]);return {entries:a,loading:t,error:c,refresh:h,getFileContent:g}}var ve=/^(https?:\/\/|mailto:|\/[^/])/i;function ye(n){let e=n.trim();return ve.test(e)?e:null}function _(n){let e=[],i=/(`[^`]+`)|(\*\*(.+?)\*\*)|(\*(.+?)\*)|(_(.+?)_)|(\[([^\]]+)\]\(([^)]+)\))/g,r=0,a,l=0;for(;(a=i.exec(n))!==null;){a.index>r&&e.push(n.slice(r,a.index));let t=`i${l++}`;if(a[1])e.push(jsx("code",{className:"rounded bg-muted px-1.5 py-0.5 text-[0.85em] font-mono text-pink-400",children:a[1].slice(1,-1)},t));else if(a[2])e.push(jsx("strong",{children:a[3]},t));else if(a[4])e.push(jsx("em",{children:a[5]},t));else if(a[6])e.push(jsx("em",{children:a[7]},t));else if(a[8]){let s=ye(a[10]);s?e.push(jsx("a",{href:s,className:"text-blue-400 underline hover:text-blue-300",target:"_blank",rel:"noopener noreferrer",children:a[9]},t)):e.push(a[9]);}r=a.index+a[0].length;}return r<n.length&&e.push(n.slice(r)),e.length>0?e:[n]}function ke(n){let e=n.split(`
2
- `),i=[],r=0;for(;r<e.length;){let a=e[r];if(a.trim()===""){r++;continue}if(/^(-{3,}|\*{3,}|_{3,})$/.test(a.trim())){i.push({type:"hr"}),r++;continue}let l=a.match(/^(#{1,6})\s+(.+)/);if(l){i.push({type:"heading",level:l[1].length,content:l[2]}),r++;continue}if(a.trim().startsWith("```")){let s=a.trim().slice(3).trim(),c=[];for(r++;r<e.length&&!e[r].trim().startsWith("```");)c.push(e[r]),r++;i.push({type:"code",content:c.join(`
3
- `),lang:s||void 0}),r++;continue}if(/^\s*[-*+]\s/.test(a)){let s=[];for(;r<e.length&&/^\s*[-*+]\s/.test(e[r]);)s.push(e[r].replace(/^\s*[-*+]\s+/,"")),r++;i.push({type:"ul",items:s});continue}if(/^\s*\d+[.)]\s/.test(a)){let s=[];for(;r<e.length&&/^\s*\d+[.)]\s/.test(e[r]);)s.push(e[r].replace(/^\s*\d+[.)]\s+/,"")),r++;i.push({type:"ol",items:s});continue}let t=[];for(;r<e.length&&e[r].trim()!==""&&!e[r].match(/^#{1,6}\s/)&&!e[r].trim().startsWith("```")&&!/^\s*[-*+]\s/.test(e[r])&&!/^\s*\d+[.)]\s/.test(e[r]);)t.push(e[r]),r++;t.length>0&&i.push({type:"paragraph",content:t.join(" ")});}return i}var Ne={1:"text-2xl font-bold mt-6 mb-3",2:"text-xl font-bold mt-5 mb-2",3:"text-lg font-semibold mt-4 mb-2",4:"text-base font-semibold mt-3 mb-1",5:"text-sm font-semibold mt-2 mb-1",6:"text-sm font-medium mt-2 mb-1"};function Re(n,e){switch(n.type){case "hr":return jsx("hr",{className:"my-4 border-border"},`b${e}`);case "heading":{let i=Math.min(Math.max(n.level||1,1),6),r=`h${i}`;return jsx(r,{className:C("text-foreground",Ne[i]),children:_(n.content||"")},`b${e}`)}case "paragraph":return jsx("p",{className:"mb-3 leading-relaxed text-foreground",children:_(n.content||"")},`b${e}`);case "code":return jsx("pre",{className:"mb-3 overflow-x-auto rounded-lg bg-muted p-4 text-sm font-mono leading-relaxed text-foreground",children:jsx("code",{children:n.content})},`b${e}`);case "ul":return jsx("ul",{className:"mb-3 ml-5 list-disc space-y-1 text-foreground",children:n.items?.map((i,r)=>jsx("li",{className:"leading-relaxed",children:_(i)},`li${e}-${r}`))},`b${e}`);case "ol":return jsx("ol",{className:"mb-3 ml-5 list-decimal space-y-1 text-foreground",children:n.items?.map((i,r)=>jsx("li",{className:"leading-relaxed",children:_(i)},`li${e}-${r}`))},`b${e}`);default:return null}}function D({content:n,className:e}){let i=ke(n);return jsx("div",{className:C("text-sm",e),children:i.map((r,a)=>Re(r,a))})}function ne({open:n,className:e}){return jsx("svg",{width:"16",height:"16",viewBox:"0 0 20 20",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",className:C("shrink-0 transition-transform duration-150",n?"rotate-0":"-rotate-90",e),children:jsx("path",{d:"M16.134 6.16a.5.5 0 1 1 .732.68l-6.5 7-.077.068a.5.5 0 0 1-.655-.068l-6.5-7-.062-.08a.5.5 0 0 1 .718-.667l.076.067L10 12.767z"})})}function X({size:n=20,className:e}){return jsx("svg",{width:n,height:n,viewBox:"0 0 20 20",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",className:e,children:jsx("path",{d:"M8.5 2a6.5 6.5 0 0 1 4.935 10.728l4.419 4.419.064.078a.5.5 0 0 1-.693.693l-.079-.064-4.419-4.42A6.5 6.5 0 1 1 8.5 2m0 1a5.5 5.5 0 1 0 0 11 5.5 5.5 0 0 0 0-11"})})}function O({size:n=20,className:e}){return jsx("svg",{width:n,height:n,viewBox:"0 0 20 20",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",className:e,children:jsx("path",{d:"M15.147 4.146a.5.5 0 0 1 .707.707L10.707 10l5.147 5.147a.5.5 0 0 1-.63.771l-.078-.064L10 10.707l-5.146 5.147a.5.5 0 0 1-.708-.707L9.293 10 4.146 4.853a.5.5 0 0 1 .708-.707L10 9.293z"})})}function re({size:n=20,className:e}){return jsx("svg",{width:n,height:n,viewBox:"0 0 20 20",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",className:e,children:jsx("path",{d:"M10 3a.5.5 0 0 1 .5.5v6h6l.1.01a.5.5 0 0 1 0 .98l-.1.01h-6v6a.5.5 0 0 1-1 0v-6h-6a.5.5 0 0 1 0-1h6v-6A.5.5 0 0 1 10 3"})})}function Pe(){return jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",className:"shrink-0",children:jsx("path",{d:"M6.5 3A2.5 2.5 0 0 0 4 5.5v9A2.5 2.5 0 0 0 6.5 17h7a2.5 2.5 0 0 0 2.5-2.5v-7A2.5 2.5 0 0 0 13.5 5H11V3.5a.5.5 0 0 0-1 0V5H6.5ZM5 5.5A1.5 1.5 0 0 1 6.5 4H9v1H6.5A1.5 1.5 0 0 0 5 6.5v8A1.5 1.5 0 0 0 6.5 16h7a1.5 1.5 0 0 0 1.5-1.5v-7A1.5 1.5 0 0 0 13.5 6H11V4h2.5A2.5 2.5 0 0 1 16 6.5v8a2.5 2.5 0 0 1-2.5 2.5h-7A2.5 2.5 0 0 1 4 14.5v-9Z"})})}function Te(){return jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",className:"shrink-0",children:jsx("path",{d:"M5.5 3A2.5 2.5 0 0 0 3 5.5v9A2.5 2.5 0 0 0 5.5 17h9a2.5 2.5 0 0 0 2.5-2.5v-9A2.5 2.5 0 0 0 14.5 3h-9ZM4 5.5A1.5 1.5 0 0 1 5.5 4h9A1.5 1.5 0 0 1 16 5.5v9a1.5 1.5 0 0 1-1.5 1.5h-9A1.5 1.5 0 0 1 4 14.5v-9ZM7 7.5a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 0 1h-5a.5.5 0 0 1-.5-.5Zm0 3a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 0 1h-5a.5.5 0 0 1-.5-.5Zm0 3a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 0 1h-3a.5.5 0 0 1-.5-.5Z"})})}function Ee(){return jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",className:"shrink-0",children:jsx("path",{d:"M10 2a.5.5 0 0 1 .354.146l3 3a.5.5 0 0 1-.708.708L10.5 3.707V12.5a.5.5 0 0 1-1 0V3.707L7.354 5.854a.5.5 0 1 1-.708-.708l3-3A.5.5 0 0 1 10 2ZM4 13.5a.5.5 0 0 1 1 0v1A1.5 1.5 0 0 0 6.5 16h7a1.5 1.5 0 0 0 1.5-1.5v-1a.5.5 0 0 1 1 0v1a2.5 2.5 0 0 1-2.5 2.5h-7A2.5 2.5 0 0 1 4 14.5v-1Z"})})}function se(){let[n,e]=useState(false);return useEffect(()=>{if(typeof window>"u")return;let i=()=>e(window.innerWidth<768);return i(),window.addEventListener("resize",i),()=>window.removeEventListener("resize",i)},[]),n}function oe({onClose:n,children:e,title:i}){let r=se(),a=useRef(n);return a.current=n,useEffect(()=>{let l=t=>{t.key==="Escape"&&a.current();};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[]),r?jsxs("div",{className:"fixed inset-0 z-50 flex items-end justify-center",onClick:n,children:[jsx("div",{className:"fixed inset-0 bg-black/50"}),jsxs("div",{className:"relative z-10 w-full max-h-[90vh] overflow-y-auto rounded-t-2xl bg-[#1a1a1a] p-5 pb-8 animate-in slide-in-from-bottom duration-200",onClick:l=>l.stopPropagation(),children:[jsx("div",{className:"mx-auto mb-4 h-1 w-10 rounded-full bg-zinc-600"}),jsxs("div",{className:"flex items-center justify-between mb-5",children:[jsx("h2",{className:"text-lg font-semibold text-foreground",children:i}),jsx("button",{onClick:n,className:"rounded p-1 text-muted-foreground hover:text-foreground",children:jsx(O,{size:20})})]}),e]})]}):jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",onClick:n,children:[jsx("div",{className:"fixed inset-0 bg-black/50"}),jsxs("div",{className:"relative z-10 w-full max-w-lg overflow-y-auto rounded-2xl bg-[#1a1a1a] p-6 shadow-2xl animate-in fade-in zoom-in-95 duration-150",onClick:l=>l.stopPropagation(),children:[jsxs("div",{className:"flex items-center justify-between mb-5",children:[jsx("h2",{className:"text-lg font-semibold text-foreground",children:i}),jsx("button",{onClick:n,className:"rounded p-1 text-muted-foreground hover:text-foreground",children:jsx(O,{size:20})})]}),e]})]})}function Me(n){let e=n.split(`
4
- `),i="",r="",l=false;for(let t=0;t<e.length;t++){let s=e[t].trim();if(t===0&&s==="---"){l=true;continue}if(l){s==="---"&&(l=false,true);continue}if(!i){let c=s.match(/^#{1,2}\s+(.+)/);if(c){i=c[1].trim();continue}}if(i&&!r){if(!s||s.startsWith("#")||s==="---"||s==="***"||s==="___")continue;r=s.replace(/\*\*/g,"").replace(/`/g,"").trim();break}}return i?{title:i,description:r}:null}function $e({onClose:n,onCreated:e,config:i}){let[r,a]=useState(""),[l,t]=useState(""),[s,c]=useState(""),[d,u]=useState(false),[h,g]=useState(null),[m,b]=useState(false),v=p=>{if(c(p),!r.trim()&&!l.trim()&&p.trim().length>10){let y=Me(p);y&&(a(y.title.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")),t(y.description),b(true));}};return jsx(oe,{title:"Write skill instructions",onClose:n,children:jsxs("div",{className:"space-y-4",children:[jsxs("div",{className:"space-y-1.5",children:[jsx("label",{htmlFor:"skill-name",className:"text-sm text-muted-foreground",children:"Skill name"}),jsx("input",{id:"skill-name",value:r,onChange:p=>a(p.target.value),placeholder:"weekly-status-report",className:"w-full rounded-lg border border-zinc-700 bg-[#252525] px-3 py-2.5 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-zinc-500"})]}),jsxs("div",{className:"space-y-1.5",children:[jsx("label",{htmlFor:"skill-desc",className:"text-sm text-muted-foreground",children:"Description"}),jsx("textarea",{id:"skill-desc",value:l,onChange:p=>t(p.target.value),placeholder:"Generate weekly status reports from recent work.",rows:3,className:"w-full rounded-lg border border-zinc-700 bg-[#252525] px-3 py-2.5 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-zinc-500"})]}),jsxs("div",{className:"space-y-1.5",children:[jsx("label",{htmlFor:"skill-instructions",className:"text-sm text-muted-foreground",children:"Instructions"}),jsx("textarea",{id:"skill-instructions",value:s,onChange:p=>v(p.target.value),placeholder:"Summarize my recent work in three sections: wins, blockers, and next steps.",rows:8,className:"w-full rounded-lg border border-zinc-700 bg-[#252525] px-3 py-2.5 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-zinc-500"})]}),h&&jsx("p",{className:"text-sm text-red-500",children:h}),jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[jsx("button",{onClick:n,className:"rounded-lg border border-zinc-700 px-4 py-2 text-sm text-foreground hover:bg-zinc-800",children:"Cancel"}),jsx("button",{onClick:async()=>{if(r.trim()){u(true),g(null);try{let p=i.apiBaseUrl||"",y=m?s.trim():`# ${r.trim()}
1
+ import {useState,useCallback,useEffect,useRef,useMemo}from'react';import {Loader2,FileText}from'lucide-react';import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {jsx,jsxs,Fragment}from'react/jsx-runtime';function C(...r){return twMerge(clsx(r))}async function k(r,e,i,s){let a={"Content-Type":"application/json",...i?.headers};s&&(a.Authorization=`Bearer ${s}`);let l=await fetch(`${r}${e}`,{...i,headers:a});if(!l.ok){let t=`HTTP ${l.status}`;try{let n=await l.json();n.error&&(t=n.error);}catch{}throw new Error(t)}return l.json()}function z(r){let e=r.indexOf(":");return {mode:r.slice(0,e),cid:r.slice(e+1)}}function _(r){let e=r.apiBaseUrl,i=r.authorMid,s=r.ownerMid,a=r.apiKey,l=r.stacknetUrl||r.apiBaseUrl;return useMemo(()=>({async listRepos(t,n){let c=new URLSearchParams;(t||s)&&c.set("owner",t||s),n?.limit&&c.set("limit",String(n.limit)),n?.cursor&&c.set("cursor",n.cursor);let d=c.toString()?`?${c}`:"",u=await k(e,`/api/rack/repos${d}`,void 0,a);return {items:u.repos||[],pagination:u.pagination||{total:(u.repos||[]).length,limit:50,has_more:false,next_cursor:null}}},async initRepo(t){return k(e,"/api/rack/init",{method:"POST",body:JSON.stringify({...t,owner_mid:s})},a)},async push(t,n){return k(e,`/api/rack/${t}/push`,{method:"POST",body:JSON.stringify({...n,author_mid:i})},a)},async getTree(t,n="main"){let c=await k(e,`/api/rack/${t}/tree/${n}`,void 0,a);return {tree:c.tree,commit_cid:c.commit_cid}},async getBlob(t,n){return (await k(e,`/api/rack/${t}/blob/${n}`,void 0,a)).content},async getLog(t,n,c){let d=new URLSearchParams;n&&d.set("ref",n),c&&d.set("max_count",String(c));let u=d.toString()?`?${d}`:"";return (await k(e,`/api/rack/${t}/log${u}`,void 0,a)).commits||[]},async getBranches(t){return (await k(e,`/api/rack/${t}/branches`,void 0,a)).branches||[]},async createBranch(t,n,c){return k(e,`/api/rack/${t}/branch`,{method:"POST",body:JSON.stringify({branch_name:n,from_ref:c})},a)},async merge(t,n,c){return k(e,`/api/rack/${t}/merge`,{method:"POST",body:JSON.stringify({source_branch:n,target_branch:c})},a)},async getDiff(t,n,c){return (await k(e,`/api/rack/${t}/diff/${n}/${c}`,void 0,a)).diff?.entries||[]},async starRepo(t){return k(e,`/api/rack/${t}/star`,{method:"POST"},a)},async unstarRepo(t){return k(e,`/api/rack/${t}/star`,{method:"DELETE"},a)},async getStarInfo(t){return k(e,`/api/rack/${t}/stars`,void 0,a)},async getSkillStats(t){let n={meta:null,tokenCount:null,usageCount:null};try{let{tree:c}=await this.getTree(t,"main");if(!c?.entries)return n;if(c.entries["META.json"]){let h=z(c.entries["META.json"]).cid,g=await this.getBlob(t,h);n.meta=JSON.parse(g);}let d=0,u=Object.values(c.entries).map(async h=>{try{let g=z(h).cid,m=await this.getBlob(t,g);d+=m.length;}catch{}});await Promise.all(u),d>0&&(n.tokenCount=Math.ceil(d/4)),n.meta?.skill_id&&(n.usageCount=await this.getSkillUsageCount(n.meta.skill_id));}catch{}return n},async getSkillUsageCount(t){try{let n=await fetch(`${l}/v1/skills/${encodeURIComponent(t)}`);if(n.ok){let d=await n.json();return d.usage_count??d.usageCount??null}let c=await fetch(`${l}/v1/skills?scope=public`);if(c.ok){let u=((await c.json()).skills||[]).find(h=>h.name===t||h.id===t);if(u)return u.usage_count??u.usageCount??0}return 0}catch{return null}},async getTensorStats(t){let n={meta:null,sizeMB:null};try{let{tree:c}=await this.getTree(t,"main");if(!c?.entries)return n;if(c.entries["TENSOR_META.json"]){let d=z(c.entries["TENSOR_META.json"]).cid,u=await this.getBlob(t,d);n.meta=JSON.parse(u),n.sizeMB=n.meta?.tensor_size_mb??null;}}catch{}return n},async getLooopStats(t){let n={meta:null,fileCount:null};try{let{tree:c}=await this.getTree(t,"main");if(!c?.entries)return n;if(c.entries["LOOOP_META.json"]){let d=z(c.entries["LOOOP_META.json"]).cid,u=await this.getBlob(t,d);n.meta=JSON.parse(u);}n.fileCount=Object.keys(c.entries).length;}catch{}return n},async getNetworkStats(){try{return (await k(e,"/api/rack/stats",void 0,a)).stats||null}catch{return null}},async getTrending(t=5,n=1,c){try{let d=new URLSearchParams({limit:String(t),days:String(n)});c&&d.set("cursor",c);let u=await k(e,`/api/rack/trending?${d}`,void 0,a);return {items:u.trending||[],pagination:u.pagination||{total:(u.trending||[]).length,limit:t,has_more:!1,next_cursor:null}}}catch{return {items:[],pagination:{total:0,limit:t,has_more:false,next_cursor:null}}}}}),[e,i,s,a,l])}function K(r,e={}){let{pageSize:i=50,owner:s}=e,a=_(r),[l,t]=useState([]),[n,c]=useState(null),[d,u]=useState(false),[h,g]=useState(null),m=useRef(null),y=useRef(true),b=useCallback(async(v,T=false)=>{u(true),g(null);try{let R=await a.listRepos(s,{limit:i,cursor:v||void 0});y.current&&(t(E=>T?[...E,...R.items]:R.items),c(R.pagination),m.current=R.pagination.next_cursor);}catch(R){y.current&&g(R.message);}finally{y.current&&u(false);}},[a,s,i]),S=useCallback(async()=>{!m.current||d||await b(m.current,true);},[b,d]),p=useCallback(async()=>{m.current=null,await b(void 0,false);},[b]);return useEffect(()=>(y.current=true,b(),()=>{y.current=false;}),[b]),{repos:l,hasMore:n?.has_more??false,total:n?.total??0,loading:d,error:h,loadMore:S,reset:p,pagination:n}}function ye(r){return Object.entries(r).map(([e,i])=>{let s=i.indexOf(":"),a=s>0?i.slice(0,s):"100644",l=s>0?i.slice(s+1):i;return {path:e,mode:a,cid:l,isDir:a==="040000"}}).sort((e,i)=>e.isDir!==i.isDir?e.isDir?-1:1:e.path.localeCompare(i.path))}function Y(r,e,i="main"){let s=_(r),[a,l]=useState([]),[t,n]=useState(false),[c,d]=useState(null),u=useRef(true),h=useCallback(async()=>{if(e)try{u.current&&(n(!0),d(null));let{tree:m}=await s.getTree(e,i);u.current&&l(ye(m.entries));}catch(m){u.current&&d(m instanceof Error?m.message:"Failed to load tree");}finally{u.current&&n(false);}},[s,e,i]);useEffect(()=>(u.current=true,h(),()=>{u.current=false;}),[h]);let g=useCallback(async m=>{if(!e)throw new Error("No repo selected");return s.getBlob(e,m)},[s,e]);return {entries:a,loading:t,error:c,refresh:h,getFileContent:g}}var be=/^(https?:\/\/|mailto:|\/[^/])/i;function ve(r){let e=r.trim();return be.test(e)?e:null}function L(r){let e=[],i=/(`[^`]+`)|(\*\*(.+?)\*\*)|(\*(.+?)\*)|(_(.+?)_)|(\[([^\]]+)\]\(([^)]+)\))/g,s=0,a,l=0;for(;(a=i.exec(r))!==null;){a.index>s&&e.push(r.slice(s,a.index));let t=`i${l++}`;if(a[1])e.push(jsx("code",{className:"rounded bg-muted px-1.5 py-0.5 text-[0.85em] font-mono text-pink-400",children:a[1].slice(1,-1)},t));else if(a[2])e.push(jsx("strong",{children:a[3]},t));else if(a[4])e.push(jsx("em",{children:a[5]},t));else if(a[6])e.push(jsx("em",{children:a[7]},t));else if(a[8]){let n=ve(a[10]);n?e.push(jsx("a",{href:n,className:"text-blue-400 underline hover:text-blue-300",target:"_blank",rel:"noopener noreferrer",children:a[9]},t)):e.push(a[9]);}s=a.index+a[0].length;}return s<r.length&&e.push(r.slice(s)),e.length>0?e:[r]}function ke(r){let e=r.split(`
2
+ `),i=[],s=0;for(;s<e.length;){let a=e[s];if(a.trim()===""){s++;continue}if(/^(-{3,}|\*{3,}|_{3,})$/.test(a.trim())){i.push({type:"hr"}),s++;continue}let l=a.match(/^(#{1,6})\s+(.+)/);if(l){i.push({type:"heading",level:l[1].length,content:l[2]}),s++;continue}if(a.trim().startsWith("```")){let n=a.trim().slice(3).trim(),c=[];for(s++;s<e.length&&!e[s].trim().startsWith("```");)c.push(e[s]),s++;i.push({type:"code",content:c.join(`
3
+ `),lang:n||void 0}),s++;continue}if(/^\s*[-*+]\s/.test(a)){let n=[];for(;s<e.length&&/^\s*[-*+]\s/.test(e[s]);)n.push(e[s].replace(/^\s*[-*+]\s+/,"")),s++;i.push({type:"ul",items:n});continue}if(/^\s*\d+[.)]\s/.test(a)){let n=[];for(;s<e.length&&/^\s*\d+[.)]\s/.test(e[s]);)n.push(e[s].replace(/^\s*\d+[.)]\s+/,"")),s++;i.push({type:"ol",items:n});continue}let t=[];for(;s<e.length&&e[s].trim()!==""&&!e[s].match(/^#{1,6}\s/)&&!e[s].trim().startsWith("```")&&!/^\s*[-*+]\s/.test(e[s])&&!/^\s*\d+[.)]\s/.test(e[s]);)t.push(e[s]),s++;t.length>0&&i.push({type:"paragraph",content:t.join(" ")});}return i}var Ne={1:"text-2xl font-bold mt-6 mb-3",2:"text-xl font-bold mt-5 mb-2",3:"text-lg font-semibold mt-4 mb-2",4:"text-base font-semibold mt-3 mb-1",5:"text-sm font-semibold mt-2 mb-1",6:"text-sm font-medium mt-2 mb-1"};function Re(r,e){switch(r.type){case "hr":return jsx("hr",{className:"my-4 border-border"},`b${e}`);case "heading":{let i=Math.min(Math.max(r.level||1,1),6),s=`h${i}`;return jsx(s,{className:C("text-foreground",Ne[i]),children:L(r.content||"")},`b${e}`)}case "paragraph":return jsx("p",{className:"mb-3 leading-relaxed text-foreground",children:L(r.content||"")},`b${e}`);case "code":return jsx("pre",{className:"mb-3 overflow-x-auto rounded-lg bg-muted p-4 text-sm font-mono leading-relaxed text-foreground",children:jsx("code",{children:r.content})},`b${e}`);case "ul":return jsx("ul",{className:"mb-3 ml-5 list-disc space-y-1 text-foreground",children:r.items?.map((i,s)=>jsx("li",{className:"leading-relaxed",children:L(i)},`li${e}-${s}`))},`b${e}`);case "ol":return jsx("ol",{className:"mb-3 ml-5 list-decimal space-y-1 text-foreground",children:r.items?.map((i,s)=>jsx("li",{className:"leading-relaxed",children:L(i)},`li${e}-${s}`))},`b${e}`);default:return null}}function U({content:r,className:e}){let i=ke(r);return jsx("div",{className:C("text-sm",e),children:i.map((s,a)=>Re(s,a))})}function ne({open:r,className:e}){return jsx("svg",{width:"16",height:"16",viewBox:"0 0 20 20",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",className:C("shrink-0 transition-transform duration-150",r?"rotate-0":"-rotate-90",e),children:jsx("path",{d:"M16.134 6.16a.5.5 0 1 1 .732.68l-6.5 7-.077.068a.5.5 0 0 1-.655-.068l-6.5-7-.062-.08a.5.5 0 0 1 .718-.667l.076.067L10 12.767z"})})}function X({size:r=20,className:e}){return jsx("svg",{width:r,height:r,viewBox:"0 0 20 20",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",className:e,children:jsx("path",{d:"M8.5 2a6.5 6.5 0 0 1 4.935 10.728l4.419 4.419.064.078a.5.5 0 0 1-.693.693l-.079-.064-4.419-4.42A6.5 6.5 0 1 1 8.5 2m0 1a5.5 5.5 0 1 0 0 11 5.5 5.5 0 0 0 0-11"})})}function j({size:r=20,className:e}){return jsx("svg",{width:r,height:r,viewBox:"0 0 20 20",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",className:e,children:jsx("path",{d:"M15.147 4.146a.5.5 0 0 1 .707.707L10.707 10l5.147 5.147a.5.5 0 0 1-.63.771l-.078-.064L10 10.707l-5.146 5.147a.5.5 0 0 1-.708-.707L9.293 10 4.146 4.853a.5.5 0 0 1 .708-.707L10 9.293z"})})}function re({size:r=20,className:e}){return jsx("svg",{width:r,height:r,viewBox:"0 0 20 20",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",className:e,children:jsx("path",{d:"M10 3a.5.5 0 0 1 .5.5v6h6l.1.01a.5.5 0 0 1 0 .98l-.1.01h-6v6a.5.5 0 0 1-1 0v-6h-6a.5.5 0 0 1 0-1h6v-6A.5.5 0 0 1 10 3"})})}function Pe(){return jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",className:"shrink-0",children:jsx("path",{d:"M6.5 3A2.5 2.5 0 0 0 4 5.5v9A2.5 2.5 0 0 0 6.5 17h7a2.5 2.5 0 0 0 2.5-2.5v-7A2.5 2.5 0 0 0 13.5 5H11V3.5a.5.5 0 0 0-1 0V5H6.5ZM5 5.5A1.5 1.5 0 0 1 6.5 4H9v1H6.5A1.5 1.5 0 0 0 5 6.5v8A1.5 1.5 0 0 0 6.5 16h7a1.5 1.5 0 0 0 1.5-1.5v-7A1.5 1.5 0 0 0 13.5 6H11V4h2.5A2.5 2.5 0 0 1 16 6.5v8a2.5 2.5 0 0 1-2.5 2.5h-7A2.5 2.5 0 0 1 4 14.5v-9Z"})})}function Te(){return jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",className:"shrink-0",children:jsx("path",{d:"M5.5 3A2.5 2.5 0 0 0 3 5.5v9A2.5 2.5 0 0 0 5.5 17h9a2.5 2.5 0 0 0 2.5-2.5v-9A2.5 2.5 0 0 0 14.5 3h-9ZM4 5.5A1.5 1.5 0 0 1 5.5 4h9A1.5 1.5 0 0 1 16 5.5v9a1.5 1.5 0 0 1-1.5 1.5h-9A1.5 1.5 0 0 1 4 14.5v-9ZM7 7.5a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 0 1h-5a.5.5 0 0 1-.5-.5Zm0 3a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 0 1h-5a.5.5 0 0 1-.5-.5Zm0 3a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 0 1h-3a.5.5 0 0 1-.5-.5Z"})})}function Ee(){return jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",className:"shrink-0",children:jsx("path",{d:"M10 2a.5.5 0 0 1 .354.146l3 3a.5.5 0 0 1-.708.708L10.5 3.707V12.5a.5.5 0 0 1-1 0V3.707L7.354 5.854a.5.5 0 1 1-.708-.708l3-3A.5.5 0 0 1 10 2ZM4 13.5a.5.5 0 0 1 1 0v1A1.5 1.5 0 0 0 6.5 16h7a1.5 1.5 0 0 0 1.5-1.5v-1a.5.5 0 0 1 1 0v1a2.5 2.5 0 0 1-2.5 2.5h-7A2.5 2.5 0 0 1 4 14.5v-1Z"})})}function se(){let[r,e]=useState(false);return useEffect(()=>{if(typeof window>"u")return;let i=()=>e(window.innerWidth<768);return i(),window.addEventListener("resize",i),()=>window.removeEventListener("resize",i)},[]),r}function oe({onClose:r,children:e,title:i}){let s=se(),a=useRef(r);return a.current=r,useEffect(()=>{let l=t=>{t.key==="Escape"&&a.current();};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[]),s?jsxs("div",{className:"fixed inset-0 z-50 flex items-end justify-center",onClick:r,children:[jsx("div",{className:"fixed inset-0 bg-black/50"}),jsxs("div",{className:"relative z-10 w-full max-h-[90vh] overflow-y-auto rounded-t-2xl bg-[#1a1a1a] p-5 pb-8 animate-in slide-in-from-bottom duration-200",onClick:l=>l.stopPropagation(),children:[jsx("div",{className:"mx-auto mb-4 h-1 w-10 rounded-full bg-zinc-600"}),jsxs("div",{className:"flex items-center justify-between mb-5",children:[jsx("h2",{className:"text-lg font-semibold text-foreground",children:i}),jsx("button",{onClick:r,className:"rounded p-1 text-muted-foreground hover:text-foreground",children:jsx(j,{size:20})})]}),e]})]}):jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",onClick:r,children:[jsx("div",{className:"fixed inset-0 bg-black/50"}),jsxs("div",{className:"relative z-10 w-full max-w-lg overflow-y-auto rounded-2xl bg-[#1a1a1a] p-6 shadow-2xl animate-in fade-in zoom-in-95 duration-150",onClick:l=>l.stopPropagation(),children:[jsxs("div",{className:"flex items-center justify-between mb-5",children:[jsx("h2",{className:"text-lg font-semibold text-foreground",children:i}),jsx("button",{onClick:r,className:"rounded p-1 text-muted-foreground hover:text-foreground",children:jsx(j,{size:20})})]}),e]})]})}function Me(r){let e=r.split(`
4
+ `),i="",s="",l=false;for(let t=0;t<e.length;t++){let n=e[t].trim();if(t===0&&n==="---"){l=true;continue}if(l){n==="---"&&(l=false,true);continue}if(!i){let c=n.match(/^#{1,2}\s+(.+)/);if(c){i=c[1].trim();continue}}if(i&&!s){if(!n||n.startsWith("#")||n==="---"||n==="***"||n==="___")continue;s=n.replace(/\*\*/g,"").replace(/`/g,"").trim();break}}return i?{title:i,description:s}:null}function $e({onClose:r,onCreated:e,config:i}){let[s,a]=useState(""),[l,t]=useState(""),[n,c]=useState(""),[d,u]=useState(false),[h,g]=useState(null),[m,y]=useState(false),b=p=>{if(c(p),!s.trim()&&!l.trim()&&p.trim().length>10){let v=Me(p);v&&(a(v.title.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")),t(v.description),y(true));}};return jsx(oe,{title:"Write skill instructions",onClose:r,children:jsxs("div",{className:"space-y-4",children:[jsxs("div",{className:"space-y-1.5",children:[jsx("label",{htmlFor:"skill-name",className:"text-sm text-muted-foreground",children:"Skill name"}),jsx("input",{id:"skill-name",value:s,onChange:p=>a(p.target.value),placeholder:"weekly-status-report",className:"w-full rounded-lg border border-zinc-700 bg-[#252525] px-3 py-2.5 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-zinc-500"})]}),jsxs("div",{className:"space-y-1.5",children:[jsx("label",{htmlFor:"skill-desc",className:"text-sm text-muted-foreground",children:"Description"}),jsx("textarea",{id:"skill-desc",value:l,onChange:p=>t(p.target.value),placeholder:"Generate weekly status reports from recent work.",rows:3,className:"w-full rounded-lg border border-zinc-700 bg-[#252525] px-3 py-2.5 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-zinc-500"})]}),jsxs("div",{className:"space-y-1.5",children:[jsx("label",{htmlFor:"skill-instructions",className:"text-sm text-muted-foreground",children:"Instructions"}),jsx("textarea",{id:"skill-instructions",value:n,onChange:p=>b(p.target.value),placeholder:"Summarize my recent work in three sections: wins, blockers, and next steps.",rows:8,className:"w-full rounded-lg border border-zinc-700 bg-[#252525] px-3 py-2.5 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-zinc-500"})]}),h&&jsx("p",{className:"text-sm text-red-500",children:h}),jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[jsx("button",{onClick:r,className:"rounded-lg border border-zinc-700 px-4 py-2 text-sm text-foreground hover:bg-zinc-800",children:"Cancel"}),jsx("button",{onClick:async()=>{if(s.trim()){u(true),g(null);try{let p=i.apiBaseUrl||"",v=m?n.trim():`# ${s.trim()}
5
5
 
6
6
  ${l.trim()}
7
7
 
8
8
  ---
9
9
 
10
- ${s.trim()}`,T=await fetch(`${p}/api/skills`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:r.trim(),description:l.trim(),skill_md:y,content_type:"code"})});if(!T.ok){let R=`Failed to register skill (${T.status})`;try{let E=await T.json();E.error&&(R=E.error);}catch{}throw new Error(R)}e?.(),n();}catch(p){g(p instanceof Error?p.message:"Failed to create skill");}finally{u(false);}}},disabled:d||!r.trim(),className:"rounded-lg bg-zinc-600 px-4 py-2 text-sm font-medium text-white hover:bg-zinc-500 disabled:opacity-50",children:d?"Creating...":"Create"})]})]})})}function ze({onClose:n,onCreated:e,config:i}){let r=useRef(null),[a,l]=useState(false),[t,s]=useState(false),[c,d]=useState(null),u=async g=>{s(true),d(null);try{let m=await g.text(),b=i.apiBaseUrl||"",v=g.name.replace(/\.[^.]+$/,"").replace(/[^a-zA-Z0-9-_]/g,"-"),S=await fetch(`${b}/api/skills`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:v,skill_md:m,content_type:"code"})});if(!S.ok){let p=`Failed to register skill (${S.status})`;try{let y=await S.json();y.error&&(p=y.error);}catch{}throw new Error(p)}e?.(),n();}catch(m){d(m instanceof Error?m.message:"Upload failed");}finally{s(false);}};return jsx(oe,{title:"Upload skill",onClose:n,children:jsxs("div",{className:"space-y-4",children:[jsxs("div",{onDragOver:g=>{g.preventDefault(),l(true);},onDragLeave:()=>l(false),onDrop:g=>{g.preventDefault(),l(false);let m=g.dataTransfer.files[0];m&&u(m);},onClick:()=>r.current?.click(),className:C("flex cursor-pointer flex-col items-center justify-center gap-3 rounded-xl border-2 border-dashed p-10 transition-colors",a?"border-zinc-400 bg-zinc-800/50":"border-zinc-700 hover:border-zinc-500"),children:[jsx("div",{className:"rounded-lg border border-zinc-600 p-2",children:jsx(re,{size:20,className:"text-muted-foreground"})}),jsx("p",{className:"text-sm text-muted-foreground",children:t?"Uploading...":"Drag and drop or click to upload"})]}),jsx("input",{ref:r,type:"file",accept:".md,.zip,.skill,.txt,.yml,.yaml",className:"hidden","aria-label":"Upload skill file",onChange:g=>{let m=g.target.files?.[0];m&&u(m);}}),c&&jsx("p",{className:"text-sm text-red-500",children:c}),jsxs("div",{className:"space-y-2 text-xs text-muted-foreground",children:[jsx("p",{className:"font-medium text-foreground/70",children:"File requirements"}),jsxs("ul",{className:"list-disc pl-5 space-y-1",children:[jsx("li",{children:".md file must contain skill name and description formatted in YAML"}),jsx("li",{children:".zip or .skill file must include a SKILL.md file"})]})]})]})})}function Ie({onClose:n,onSelect:e}){let i=se(),r=useRef(null),a=useRef(n);a.current=n,useEffect(()=>{if(i)return;let t=s=>{r.current&&s.target instanceof Node&&!r.current.contains(s.target)&&a.current();};return document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[i]);let l=[{id:"create-with-geoff",icon:jsx(Pe,{}),label:"Create with Geoff"},{id:"write",icon:jsx(Te,{}),label:"Write skill instructions"},{id:"upload",icon:jsx(Ee,{}),label:"Upload a skill"}];return i?jsxs("div",{className:"fixed inset-0 z-50 flex items-end",onClick:n,children:[jsx("div",{className:"fixed inset-0 bg-black/50"}),jsxs("div",{className:"relative z-10 w-full rounded-t-2xl bg-[#1a1a1a] p-4 pb-8 animate-in slide-in-from-bottom duration-200",onClick:t=>t.stopPropagation(),children:[jsx("div",{className:"mx-auto mb-3 h-1 w-10 rounded-full bg-zinc-600"}),l.map(t=>jsxs("button",{onClick:()=>{e(t.id),n();},className:"flex w-full items-center gap-3 rounded-lg px-4 py-3 text-sm text-foreground transition-colors hover:bg-zinc-800",children:[t.icon,t.label]},t.id))]})]}):jsx("div",{ref:r,className:"absolute right-2 top-11 z-50 w-56 overflow-hidden rounded-xl border border-zinc-700 bg-[#2a2a2a] shadow-xl animate-in fade-in zoom-in-95 duration-100",children:l.map(t=>jsxs("button",{onClick:()=>{e(t.id),n();},className:"flex w-full items-center gap-3 px-4 py-3 text-sm text-foreground transition-colors hover:bg-zinc-700/50",children:[t.icon,t.label]},t.id))})}function _e({entry:n,selected:e,onSelect:i,depth:r=0}){return jsxs("button",{onClick:()=>i(n),className:C("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm transition-colors",e?"bg-[#141414] text-foreground":"text-muted-foreground hover:bg-muted/50 hover:text-foreground"),style:{paddingLeft:`${8+r*16}px`},children:[jsx("span",{className:"truncate flex-1",children:n.path.split("/").pop()}),n.isDir&&jsx(ne,{className:"ml-auto text-muted-foreground"})]})}function Be({repo:n,selected:e,expanded:i,onSelect:r,onToggle:a,children:l}){return jsxs("div",{children:[jsxs("button",{onClick:()=>{r(),a();},className:C("flex w-full items-center gap-2 rounded-md px-2 py-2 text-left text-sm font-medium transition-colors",e?"bg-[#141414] text-foreground":"text-muted-foreground hover:bg-muted/50 hover:text-foreground"),children:[jsx(ne,{open:i}),jsx(FileText,{className:"h-4 w-4 shrink-0"}),jsx("span",{className:"truncate",children:n.name})]}),i&&l]})}function Le({entry:n,content:e,loading:i,repoName:r}){let[a,l]=useState(false),t=useRef(null);useEffect(()=>()=>{t.current&&clearTimeout(t.current);},[]);let[s,c]=useState(false),d=async()=>{if(e)try{await navigator.clipboard.writeText(e),l(!0),c(!1),t.current&&clearTimeout(t.current),t.current=setTimeout(()=>l(!1),2e3);}catch{c(true),t.current&&clearTimeout(t.current),t.current=setTimeout(()=>c(false),2e3);}};if(!n)return jsx("div",{className:"flex h-full items-center justify-center text-sm text-muted-foreground",children:"Select a file to view its content"});if(i)return jsx("div",{className:"flex h-full items-center justify-center",children:jsx(Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})});let u=n.path.split("/").pop()||n.path,h=/\.(md|mdx)$/i.test(u);return jsxs("div",{className:"flex h-full flex-col px-3",children:[jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[jsx("h3",{className:"text-sm sm:text-lg font-semibold text-foreground",children:u}),jsx("button",{onClick:d,"aria-label":"Copy file content",className:C("rounded p-1 transition-colors",a?"text-green-500":s?"text-red-500":"text-muted-foreground hover:text-foreground"),children:jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",className:"shrink-0",children:jsx("path",{d:"M12.5 3A1.5 1.5 0 0 1 14 4.5V6h1.5A1.5 1.5 0 0 1 17 7.5v8a1.5 1.5 0 0 1-1.5 1.5h-8A1.5 1.5 0 0 1 6 15.5V14H4.5A1.5 1.5 0 0 1 3 12.5v-8A1.5 1.5 0 0 1 4.5 3zm1.5 9.5a1.5 1.5 0 0 1-1.5 1.5H7v1.5a.5.5 0 0 0 .5.5h8a.5.5 0 0 0 .5-.5v-8a.5.5 0 0 0-.5-.5H14zM4.5 4a.5.5 0 0 0-.5.5v8a.5.5 0 0 0 .5.5h8a.5.5 0 0 0 .5-.5v-8a.5.5 0 0 0-.5-.5z"})})})]}),jsx("div",{className:"flex-1 overflow-auto p-4",children:h?jsx(D,{content:e||""}):jsx("pre",{className:"whitespace-pre-wrap text-sm text-foreground font-mono leading-relaxed",children:e||""})})]})}function Ae({config:n,category:e,className:i,style:r}){let{repos:a,loading:l,error:t,reset:d}=K(n,{pageSize:50}),[u,h]=useState(null),[g,m]=useState(null),[b,v]=useState(null),[S,p]=useState(null),[y,T]=useState(false),[R,E]=useState(""),[ie,H]=useState(false),[W,J]=useState(false),[V,B]=useState(null),le=a.find(w=>w.repo_id===u),{entries:ce,getFileContent:Z}=Y(n,g),q=a.filter(w=>!R||w.name.toLowerCase().includes(R.toLowerCase())),ue=useCallback(async w=>{if(!w.isDir){v(w),T(true);try{let P=await Z(w.cid);p(P);}catch(P){let me=P instanceof Error?P.message:"Unknown error";p(`Failed to load file: ${me}`);}finally{T(false);}}},[Z]);useEffect(()=>{a.length>0&&!u&&(h(a[0].repo_id),m(a[0].repo_id));},[a,u]);let de=w=>{w==="create-with-geoff"?window.open(`https://www.geoff.ai/?p=${encodeURIComponent("Let's create a skill together using your skill-creator skill. First ask me what the skill should do.")}`,"_blank","noopener,noreferrer"):B(w);};return jsxs("div",{className:C("flex flex-1 h-full min-h-0",i),style:r,children:[jsxs("div",{className:"relative flex w-96 shrink-0 flex-col border-r",children:[jsx("div",{className:"flex h-12 items-center gap-2 px-3",children:ie?jsxs(Fragment,{children:[jsxs("div",{className:"flex flex-1 items-center gap-2 rounded-md border bg-muted/50 px-2 py-1",children:[jsx(X,{size:16,className:"shrink-0 text-muted-foreground"}),jsx("input",{type:"text",value:R,onChange:w=>E(w.target.value),placeholder:"Search",autoFocus:true,"aria-label":"Search items",className:"flex-1 bg-transparent text-xs text-foreground placeholder:text-muted-foreground focus:outline-none"})]}),jsx("button",{onClick:()=>{H(false),E("");},className:"rounded p-1 text-muted-foreground hover:text-foreground",children:jsx(O,{size:16})})]}):jsxs(Fragment,{children:[jsx("h3",{className:"flex-1 text-sm sm:text-lg font-semibold text-foreground capitalize",children:e||"Items"}),jsx("button",{onClick:()=>H(true),className:"rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground","aria-label":"Search",children:jsx(X,{size:20})}),jsx("button",{onClick:()=>J(!W),className:"rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground","aria-label":"Add new",children:jsx(re,{size:20})})]})}),W&&jsx(Ie,{onClose:()=>J(false),onSelect:de}),jsx("div",{className:"flex-1 overflow-y-auto p-2",children:l?jsx("div",{className:"flex items-center justify-center py-8",children:jsx(Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):t?jsx("p",{className:"px-2 py-4 text-xs text-red-500",children:t}):q.length===0?jsx("p",{className:"px-2 py-4 text-xs text-muted-foreground",children:R?"No matching items":"No items yet"}):jsx("div",{className:"space-y-0.5",children:q.map(w=>jsx(Be,{repo:w,selected:u===w.repo_id,expanded:g===w.repo_id,onSelect:()=>{h(w.repo_id),v(null),p(null);},onToggle:()=>m(g===w.repo_id?null:w.repo_id),children:jsx("div",{className:"ml-10 pl-1",children:ce.map(P=>jsx(_e,{entry:P,selected:b?.path===P.path,onSelect:ue,depth:P.path.split("/").length-1},P.path))})},w.repo_id))})})]}),jsx("div",{className:"flex-1 min-w-0",children:jsx(Le,{entry:b,content:S,loading:y,repoName:le?.name||""})}),V==="write"&&jsx($e,{config:n,onClose:()=>B(null),onCreated:d}),V==="upload"&&jsx(ze,{config:n,onClose:()=>B(null),onCreated:d})]})}async function ae(n,e,i,r){let a={"Content-Type":"application/json",...i?.headers};r&&(a.Authorization=`Bearer ${r}`);let l=await fetch(`${n}${e}`,{...i,headers:a});if(!l.ok){let t=`HTTP ${l.status}`;try{let s=await l.json();s.error&&(t=s.error);}catch{}throw new Error(t)}return l.json()}function je({config:n,repoId:e,onAuthRequired:i,className:r,style:a}){let l=n.apiBaseUrl,t=n.apiKey,[s,c]=useState({stars:0,starred:false,repo_id:e}),[d,u]=useState(false),[h,g]=useState(null),m=useRef(true),b=l.includes("/cpx/rack")?"":"/api/rack";useEffect(()=>(m.current=true,ae(l,`${b}/${e}/stars`,void 0,t).then(S=>{m.current&&c(S);}).catch(()=>{}),()=>{m.current=false;}),[l,e,t,b]);let v=useCallback(async S=>{if(S.preventDefault(),S.stopPropagation(),!t){i?.();return}u(true),g(null);try{let p=s.starred?"DELETE":"POST",y=await ae(l,`${b}/${e}/star`,{method:p},t);m.current&&c({stars:y.stars,starred:y.starred,repo_id:e});}catch(p){m.current&&g(p.message);}finally{m.current&&u(false);}},[l,e,t,s.starred,i]);return jsxs("button",{onClick:v,disabled:d,title:h||(s.starred?"Unstar (100k tokens)":"Star (100k tokens)"),className:r,style:{display:"inline-flex",alignItems:"center",gap:"4px",background:"none",border:"none",cursor:d?"wait":"pointer",padding:"4px 8px",fontSize:"12px",fontFamily:"inherit",color:s.starred?"#f59e0b":"#91918d",transition:"color 150ms",opacity:d?.5:1,...a},children:[jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:s.starred?"currentColor":"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})}),jsx("span",{children:s.stars})]})}
11
- export{D as Markdown,Ae as RackBrowser,je as StarButton};
10
+ ${n.trim()}`,T=await fetch(`${p}/api/skills`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:s.trim(),description:l.trim(),skill_md:v,content_type:"code"})});if(!T.ok){let R=`Failed to register skill (${T.status})`;try{let E=await T.json();E.error&&(R=E.error);}catch{}throw new Error(R)}e?.(),r();}catch(p){g(p instanceof Error?p.message:"Failed to create skill");}finally{u(false);}}},disabled:d||!s.trim(),className:"rounded-lg bg-zinc-600 px-4 py-2 text-sm font-medium text-white hover:bg-zinc-500 disabled:opacity-50",children:d?"Creating...":"Create"})]})]})})}function ze({onClose:r,onCreated:e,config:i}){let s=useRef(null),[a,l]=useState(false),[t,n]=useState(false),[c,d]=useState(null),u=async g=>{n(true),d(null);try{let m=await g.text(),y=i.apiBaseUrl||"",b=g.name.replace(/\.[^.]+$/,"").replace(/[^a-zA-Z0-9-_]/g,"-"),S=await fetch(`${y}/api/skills`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:b,skill_md:m,content_type:"code"})});if(!S.ok){let p=`Failed to register skill (${S.status})`;try{let v=await S.json();v.error&&(p=v.error);}catch{}throw new Error(p)}e?.(),r();}catch(m){d(m instanceof Error?m.message:"Upload failed");}finally{n(false);}};return jsx(oe,{title:"Upload skill",onClose:r,children:jsxs("div",{className:"space-y-4",children:[jsxs("div",{onDragOver:g=>{g.preventDefault(),l(true);},onDragLeave:()=>l(false),onDrop:g=>{g.preventDefault(),l(false);let m=g.dataTransfer.files[0];m&&u(m);},onClick:()=>s.current?.click(),className:C("flex cursor-pointer flex-col items-center justify-center gap-3 rounded-xl border-2 border-dashed p-10 transition-colors",a?"border-zinc-400 bg-zinc-800/50":"border-zinc-700 hover:border-zinc-500"),children:[jsx("div",{className:"rounded-lg border border-zinc-600 p-2",children:jsx(re,{size:20,className:"text-muted-foreground"})}),jsx("p",{className:"text-sm text-muted-foreground",children:t?"Uploading...":"Drag and drop or click to upload"})]}),jsx("input",{ref:s,type:"file",accept:".md,.zip,.skill,.txt,.yml,.yaml",className:"hidden","aria-label":"Upload skill file",onChange:g=>{let m=g.target.files?.[0];m&&u(m);}}),c&&jsx("p",{className:"text-sm text-red-500",children:c}),jsxs("div",{className:"space-y-2 text-xs text-muted-foreground",children:[jsx("p",{className:"font-medium text-foreground/70",children:"File requirements"}),jsxs("ul",{className:"list-disc pl-5 space-y-1",children:[jsx("li",{children:".md file must contain skill name and description formatted in YAML"}),jsx("li",{children:".zip or .skill file must include a SKILL.md file"})]})]})]})})}function _e({onClose:r,onSelect:e}){let i=se(),s=useRef(null),a=useRef(r);a.current=r,useEffect(()=>{if(i)return;let t=n=>{s.current&&n.target instanceof Node&&!s.current.contains(n.target)&&a.current();};return document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[i]);let l=[{id:"create-with-geoff",icon:jsx(Pe,{}),label:"Create with Geoff"},{id:"write",icon:jsx(Te,{}),label:"Write skill instructions"},{id:"upload",icon:jsx(Ee,{}),label:"Upload a skill"}];return i?jsxs("div",{className:"fixed inset-0 z-50 flex items-end",onClick:r,children:[jsx("div",{className:"fixed inset-0 bg-black/50"}),jsxs("div",{className:"relative z-10 w-full rounded-t-2xl bg-[#1a1a1a] p-4 pb-8 animate-in slide-in-from-bottom duration-200",onClick:t=>t.stopPropagation(),children:[jsx("div",{className:"mx-auto mb-3 h-1 w-10 rounded-full bg-zinc-600"}),l.map(t=>jsxs("button",{onClick:()=>{e(t.id),r();},className:"flex w-full items-center gap-3 rounded-lg px-4 py-3 text-sm text-foreground transition-colors hover:bg-zinc-800",children:[t.icon,t.label]},t.id))]})]}):jsx("div",{ref:s,className:"absolute right-2 top-11 z-50 w-56 overflow-hidden rounded-xl border border-zinc-700 bg-[#2a2a2a] shadow-xl animate-in fade-in zoom-in-95 duration-100",children:l.map(t=>jsxs("button",{onClick:()=>{e(t.id),r();},className:"flex w-full items-center gap-3 px-4 py-3 text-sm text-foreground transition-colors hover:bg-zinc-700/50",children:[t.icon,t.label]},t.id))})}function Ie({entry:r,selected:e,onSelect:i,depth:s=0}){return jsxs("button",{onClick:()=>i(r),className:C("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm transition-colors",e?"bg-[#141414] text-foreground":"text-muted-foreground hover:bg-muted/50 hover:text-foreground"),style:{paddingLeft:`${8+s*16}px`},children:[jsx("span",{className:"truncate flex-1",children:r.path.split("/").pop()}),r.isDir&&jsx(ne,{className:"ml-auto text-muted-foreground"})]})}function Le({repo:r,selected:e,expanded:i,onSelect:s,onToggle:a,children:l}){return jsxs("div",{children:[jsxs("button",{onClick:()=>{s(),a();},className:C("flex w-full items-center gap-2 rounded-md px-2 py-2 text-left text-sm font-medium transition-colors",e?"bg-[#141414] text-foreground":"text-muted-foreground hover:bg-muted/50 hover:text-foreground"),children:[jsx(ne,{open:i}),jsx(FileText,{className:"h-4 w-4 shrink-0"}),jsx("span",{className:"truncate",children:r.name})]}),i&&l]})}function Be({entry:r,content:e,loading:i,repoName:s}){let[a,l]=useState(false),t=useRef(null);useEffect(()=>()=>{t.current&&clearTimeout(t.current);},[]);let[n,c]=useState(false),d=async()=>{if(e)try{await navigator.clipboard.writeText(e),l(!0),c(!1),t.current&&clearTimeout(t.current),t.current=setTimeout(()=>l(!1),2e3);}catch{c(true),t.current&&clearTimeout(t.current),t.current=setTimeout(()=>c(false),2e3);}};if(!r)return jsx("div",{className:"flex h-full items-center justify-center text-sm text-muted-foreground",children:"Select a file to view its content"});if(i)return jsx("div",{className:"flex h-full items-center justify-center",children:jsx(Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})});let u=r.path.split("/").pop()||r.path,h=/\.(md|mdx)$/i.test(u);return jsxs("div",{className:"flex h-full flex-col px-3",children:[jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[jsx("h3",{className:"text-sm sm:text-lg font-semibold text-foreground",children:u}),jsx("button",{onClick:d,"aria-label":"Copy file content",className:C("rounded p-1 transition-colors",a?"text-green-500":n?"text-red-500":"text-muted-foreground hover:text-foreground"),children:jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",className:"shrink-0",children:jsx("path",{d:"M12.5 3A1.5 1.5 0 0 1 14 4.5V6h1.5A1.5 1.5 0 0 1 17 7.5v8a1.5 1.5 0 0 1-1.5 1.5h-8A1.5 1.5 0 0 1 6 15.5V14H4.5A1.5 1.5 0 0 1 3 12.5v-8A1.5 1.5 0 0 1 4.5 3zm1.5 9.5a1.5 1.5 0 0 1-1.5 1.5H7v1.5a.5.5 0 0 0 .5.5h8a.5.5 0 0 0 .5-.5v-8a.5.5 0 0 0-.5-.5H14zM4.5 4a.5.5 0 0 0-.5.5v8a.5.5 0 0 0 .5.5h8a.5.5 0 0 0 .5-.5v-8a.5.5 0 0 0-.5-.5z"})})})]}),jsx("div",{className:"flex-1 overflow-auto p-4",children:h?jsx(U,{content:e||""}):jsx("pre",{className:"whitespace-pre-wrap text-sm text-foreground font-mono leading-relaxed",children:e||""})})]})}function Ae({config:r,category:e,className:i,style:s}){let{repos:a,loading:l,error:t,reset:d}=K(r,{pageSize:50}),[u,h]=useState(null),[g,m]=useState(null),[y,b]=useState(null),[S,p]=useState(null),[v,T]=useState(false),[R,E]=useState(""),[ie,H]=useState(false),[J,W]=useState(false),[V,B]=useState(null),le=a.find(w=>w.repo_id===u),{entries:ce,getFileContent:Z}=Y(r,g),q=a.filter(w=>!R||w.name.toLowerCase().includes(R.toLowerCase())),ue=useCallback(async w=>{if(!w.isDir){b(w),T(true);try{let P=await Z(w.cid);p(P);}catch(P){let me=P instanceof Error?P.message:"Unknown error";p(`Failed to load file: ${me}`);}finally{T(false);}}},[Z]);useEffect(()=>{a.length>0&&!u&&(h(a[0].repo_id),m(a[0].repo_id));},[a,u]);let de=w=>{w==="create-with-geoff"?window.open(`https://www.geoff.ai/?p=${encodeURIComponent("Let's create a skill together using your skill-creator skill. First ask me what the skill should do.")}`,"_blank","noopener,noreferrer"):B(w);};return jsxs("div",{className:C("flex flex-1 h-full min-h-0",i),style:s,children:[jsxs("div",{className:"relative flex w-96 shrink-0 flex-col border-r",children:[jsx("div",{className:"flex h-12 items-center gap-2 px-3",children:ie?jsxs(Fragment,{children:[jsxs("div",{className:"flex flex-1 items-center gap-2 rounded-md border bg-muted/50 px-2 py-1",children:[jsx(X,{size:16,className:"shrink-0 text-muted-foreground"}),jsx("input",{type:"text",value:R,onChange:w=>E(w.target.value),placeholder:"Search",autoFocus:true,"aria-label":"Search items",className:"flex-1 bg-transparent text-xs text-foreground placeholder:text-muted-foreground focus:outline-none"})]}),jsx("button",{onClick:()=>{H(false),E("");},className:"rounded p-1 text-muted-foreground hover:text-foreground",children:jsx(j,{size:16})})]}):jsxs(Fragment,{children:[jsx("h3",{className:"flex-1 text-sm sm:text-lg font-semibold text-foreground capitalize",children:e||"Items"}),jsx("button",{onClick:()=>H(true),className:"rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground","aria-label":"Search",children:jsx(X,{size:20})}),jsx("button",{onClick:()=>W(!J),className:"rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground","aria-label":"Add new",children:jsx(re,{size:20})})]})}),J&&jsx(_e,{onClose:()=>W(false),onSelect:de}),jsx("div",{className:"flex-1 overflow-y-auto p-2",children:l?jsx("div",{className:"flex items-center justify-center py-8",children:jsx(Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):t?jsx("p",{className:"px-2 py-4 text-xs text-red-500",children:t}):q.length===0?jsx("p",{className:"px-2 py-4 text-xs text-muted-foreground",children:R?"No matching items":"No items yet"}):jsx("div",{className:"space-y-0.5",children:q.map(w=>jsx(Le,{repo:w,selected:u===w.repo_id,expanded:g===w.repo_id,onSelect:()=>{h(w.repo_id),b(null),p(null);},onToggle:()=>m(g===w.repo_id?null:w.repo_id),children:jsx("div",{className:"ml-10 pl-1",children:ce.map(P=>jsx(Ie,{entry:P,selected:y?.path===P.path,onSelect:ue,depth:P.path.split("/").length-1},P.path))})},w.repo_id))})})]}),jsx("div",{className:"flex-1 min-w-0",children:jsx(Be,{entry:y,content:S,loading:v,repoName:le?.name||""})}),V==="write"&&jsx($e,{config:r,onClose:()=>B(null),onCreated:d}),V==="upload"&&jsx(ze,{config:r,onClose:()=>B(null),onCreated:d})]})}async function ae(r,e,i,s){let a={"Content-Type":"application/json",...i?.headers};s&&(a.Authorization=`Bearer ${s}`);let l=await fetch(`${r}${e}`,{...i,headers:a});if(!l.ok){let t=`HTTP ${l.status}`;try{let n=await l.json();n.error&&(t=n.error);}catch{}throw new Error(t)}return l.json()}function De({config:r,repoId:e,onAuthRequired:i,className:s,style:a}){let l=r.apiBaseUrl,t=r.apiKey,[n,c]=useState({stars:0,starred:false,repo_id:e}),[d,u]=useState(false),[h,g]=useState(null),m=useRef(true),y=l.includes("/cpx/rack")?"":"/api/rack";useEffect(()=>(m.current=true,ae(l,`${y}/${e}/stars`,void 0,t).then(S=>{m.current&&c(S);}).catch(()=>{}),()=>{m.current=false;}),[l,e,t,y]);let b=useCallback(async S=>{if(S.preventDefault(),S.stopPropagation(),!t){i?.();return}u(true),g(null);try{let p=n.starred?"DELETE":"POST",v=await ae(l,`${y}/${e}/star`,{method:p},t);m.current&&c({stars:v.stars,starred:v.starred,repo_id:e});}catch(p){m.current&&g(p.message);}finally{m.current&&u(false);}},[l,e,t,n.starred,i]);return jsxs("button",{onClick:b,disabled:d,title:h||(n.starred?"Unstar (100k tokens)":"Star (100k tokens)"),className:s,style:{display:"inline-flex",alignItems:"center",gap:"4px",background:"none",border:"none",cursor:d?"wait":"pointer",padding:"4px 8px",fontSize:"12px",fontFamily:"inherit",color:n.starred?"#f59e0b":"#91918d",transition:"color 150ms",opacity:d?.5:1,...a},children:[jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:n.starred?"currentColor":"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})}),jsx("span",{children:n.stars})]})}
11
+ export{U as Markdown,Ae as RackBrowser,De as StarButton};
@@ -1 +1 @@
1
- 'use strict';var react=require('react');async function R(f,t,o,l){let c={"Content-Type":"application/json",...o?.headers};l&&(c.Authorization=`Bearer ${l}`);let p=await fetch(`${f}${t}`,{...o,headers:c});if(!p.ok){let e=`HTTP ${p.status}`;try{let r=await p.json();r.error&&(e=r.error);}catch{}throw new Error(e)}return p.json()}function T(f){let t=f.indexOf(":");return {mode:f.slice(0,t),cid:f.slice(t+1)}}function d(f){let t=f.apiBaseUrl,o=f.authorMid,l=f.ownerMid,c=f.apiKey,p=f.stacknetUrl||f.apiBaseUrl;return react.useMemo(()=>({async listRepos(e,r){let n=new URLSearchParams;(e||l)&&n.set("owner",e||l),r?.limit&&n.set("limit",String(r.limit)),r?.cursor&&n.set("cursor",r.cursor);let s=n.toString()?`?${n}`:"",a=await R(t,`/api/rack/repos${s}`,void 0,c);return {items:a.repos||[],pagination:a.pagination||{total:(a.repos||[]).length,limit:50,has_more:false,next_cursor:null}}},async initRepo(e){return R(t,"/api/rack/init",{method:"POST",body:JSON.stringify({...e,owner_mid:l})},c)},async push(e,r){return R(t,`/api/rack/${e}/push`,{method:"POST",body:JSON.stringify({...r,author_mid:o})},c)},async getTree(e,r="main"){let n=await R(t,`/api/rack/${e}/tree/${r}`,void 0,c);return {tree:n.tree,commit_cid:n.commit_cid}},async getBlob(e,r){return (await R(t,`/api/rack/${e}/blob/${r}`,void 0,c)).content},async getLog(e,r,n){let s=new URLSearchParams;r&&s.set("ref",r),n&&s.set("max_count",String(n));let a=s.toString()?`?${s}`:"";return (await R(t,`/api/rack/${e}/log${a}`,void 0,c)).commits||[]},async getBranches(e){return (await R(t,`/api/rack/${e}/branches`,void 0,c)).branches||[]},async createBranch(e,r,n){return R(t,`/api/rack/${e}/branch`,{method:"POST",body:JSON.stringify({branch_name:r,from_ref:n})},c)},async merge(e,r,n){return R(t,`/api/rack/${e}/merge`,{method:"POST",body:JSON.stringify({source_branch:r,target_branch:n})},c)},async getDiff(e,r,n){return (await R(t,`/api/rack/${e}/diff/${r}/${n}`,void 0,c)).diff?.entries||[]},async starRepo(e){return R(t,`/api/rack/${e}/star`,{method:"POST"},c)},async unstarRepo(e){return R(t,`/api/rack/${e}/star`,{method:"DELETE"},c)},async getStarInfo(e){return R(t,`/api/rack/${e}/stars`,void 0,c)},async getSkillStats(e){let r={meta:null,tokenCount:null,usageCount:null};try{let{tree:n}=await this.getTree(e,"main");if(!n?.entries)return r;if(n.entries["META.json"]){let i=T(n.entries["META.json"]).cid,u=await this.getBlob(e,i);r.meta=JSON.parse(u);}let s=0,a=Object.values(n.entries).map(async i=>{try{let u=T(i).cid,g=await this.getBlob(e,u);s+=g.length;}catch{}});await Promise.all(a),s>0&&(r.tokenCount=Math.ceil(s/4)),r.meta?.skill_id&&(r.usageCount=await this.getSkillUsageCount(r.meta.skill_id));}catch{}return r},async getSkillUsageCount(e){try{let r=await fetch(`${p}/v1/skills/${encodeURIComponent(e)}`);if(r.ok){let s=await r.json();return s.usage_count??s.usageCount??null}let n=await fetch(`${p}/v1/skills?scope=public`);if(n.ok){let a=((await n.json()).skills||[]).find(i=>i.name===e||i.id===e);if(a)return a.usage_count??a.usageCount??0}return 0}catch{return null}},async getTensorStats(e){let r={meta:null,sizeMB:null};try{let{tree:n}=await this.getTree(e,"main");if(!n?.entries)return r;if(n.entries["TENSOR_META.json"]){let s=T(n.entries["TENSOR_META.json"]).cid,a=await this.getBlob(e,s);r.meta=JSON.parse(a),r.sizeMB=r.meta?.tensor_size_mb??null;}}catch{}return r},async getNetworkStats(){try{return (await R(t,"/api/rack/stats",void 0,c)).stats||null}catch{return null}},async getTrending(e=5,r=1,n){try{let s=new URLSearchParams({limit:String(e),days:String(r)});n&&s.set("cursor",n);let a=await R(t,`/api/rack/trending?${s}`,void 0,c);return {items:a.trending||[],pagination:a.pagination||{total:(a.trending||[]).length,limit:e,has_more:!1,next_cursor:null}}}catch{return {items:[],pagination:{total:0,limit:e,has_more:false,next_cursor:null}}}}}),[t,o,l,c,p])}function Z(f){let t=d(f),o=react.useRef(t);o.current=t;let[l,c]=react.useState([]),[p,e]=react.useState(true),[r,n]=react.useState(null),s=react.useRef(true),a=react.useRef(null),i=react.useCallback(async()=>{a.current?.abort();let u=new AbortController;a.current=u;try{s.current&&(e(!0),n(null));let g=await o.current.listRepos();s.current&&!u.signal.aborted&&c(g.items);}catch(g){s.current&&!u.signal.aborted&&n(g instanceof Error?g.message:"Failed to load repos");}finally{s.current&&!u.signal.aborted&&e(false);}},[]);return react.useEffect(()=>(s.current=true,i(),()=>{s.current=false,a.current?.abort();}),[i]),{repos:l,loading:p,error:r,refresh:i}}function rt(f){return Object.entries(f).map(([t,o])=>{let l=o.indexOf(":"),c=l>0?o.slice(0,l):"100644",p=l>0?o.slice(l+1):o;return {path:t,mode:c,cid:p,isDir:c==="040000"}}).sort((t,o)=>t.isDir!==o.isDir?t.isDir?-1:1:t.path.localeCompare(o.path))}function nt(f,t,o="main"){let l=d(f),[c,p]=react.useState([]),[e,r]=react.useState(false),[n,s]=react.useState(null),a=react.useRef(true),i=react.useCallback(async()=>{if(t)try{a.current&&(r(!0),s(null));let{tree:g}=await l.getTree(t,o);a.current&&p(rt(g.entries));}catch(g){a.current&&s(g instanceof Error?g.message:"Failed to load tree");}finally{a.current&&r(false);}},[l,t,o]);react.useEffect(()=>(a.current=true,i(),()=>{a.current=false;}),[i]);let u=react.useCallback(async g=>{if(!t)throw new Error("No repo selected");return l.getBlob(t,g)},[l,t]);return {entries:c,loading:e,error:n,refresh:i,getFileContent:u}}function it(f){let t=d(f),[o,l]=react.useState(false),[c,p]=react.useState(null),e=react.useRef(true);return react.useEffect(()=>(e.current=true,()=>{e.current=false;}),[]),{push:react.useCallback(async(n,s,a,i)=>{try{return e.current&&(l(!0),p(null)),await t.push(n,{files:s,message:a,branch:i})}catch(u){let g=u instanceof Error?u.message:"Push failed";return e.current&&p(g),null}finally{e.current&&l(false);}},[t]),pushing:o,error:c}}function ut(f,t={}){let{pageSize:o=50,owner:l}=t,c=d(f),[p,e]=react.useState([]),[r,n]=react.useState(null),[s,a]=react.useState(false),[i,u]=react.useState(null),g=react.useRef(null),m=react.useRef(true),h=react.useCallback(async(W,G=false)=>{a(true),u(null);try{let S=await c.listRepos(l,{limit:o,cursor:W||void 0});m.current&&(e(Y=>G?[...Y,...S.items]:S.items),n(S.pagination),g.current=S.pagination.next_cursor);}catch(S){m.current&&u(S.message);}finally{m.current&&a(false);}},[c,l,o]),y=react.useCallback(async()=>{!g.current||s||await h(g.current,true);},[h,s]),k=react.useCallback(async()=>{g.current=null,await h(void 0,false);},[h]);return react.useEffect(()=>(m.current=true,h(),()=>{m.current=false;}),[h]),{repos:p,hasMore:r?.has_more??false,total:r?.total??0,loading:s,error:i,loadMore:y,reset:k,pagination:r}}var $="stacknet-rack-apikey";function ft(f){let t=f.stacknetUrl||f.apiBaseUrl,[o,l]=react.useState({authenticated:false}),[c,p]=react.useState(null),[e,r]=react.useState(false),n=react.useCallback(u=>({"Content-Type":"application/json",...u||f.apiKey?{Authorization:`Bearer ${u||f.apiKey}`}:{}}),[f.apiKey]),s=react.useCallback(async u=>{r(true);try{let g=await fetch(`${t}/health`,{headers:n(u)});if(!g.ok)throw new Error(`Authentication failed: ${g.status}`);let m={authenticated:!0,apiKey:u,permission:u.startsWith("gk_")?"write":"read"};l(m);try{localStorage.setItem($,u);}catch{}return m}catch(g){throw l({authenticated:false}),g}finally{r(false);}},[t,n]),a=react.useCallback(()=>{l({authenticated:false}),p(null);try{localStorage.removeItem($);}catch{}},[]),i=react.useCallback(async()=>{let u=o.apiKey||f.apiKey;if(!u)return null;try{let g=await fetch(`${t}/network/usage`,{headers:n(u)});if(!g.ok)return null;let m=await g.json(),h={planAllocation:m.plan_allocation??m.planAllocation??0,inferenceUsed:m.inference_used??m.inferenceUsed??0,ledgerSpent:m.ledger_spent??m.ledgerSpent??0,totalUsed:m.total_used??m.totalUsed??0,remaining:m.remaining??0,percent:m.percent??0,exceeded:m.exceeded??!1};return p(h),h}catch{return null}},[o.apiKey,f.apiKey,t,n]);return react.useEffect(()=>{let u=f.apiKey;if(u){l({authenticated:true,apiKey:u,permission:u.startsWith("gk_")?"write":"read"});return}try{let g=localStorage.getItem($);g&&l({authenticated:!0,apiKey:g,permission:g.startsWith("gk_")?"write":"read"});}catch{}},[f.apiKey]),{session:o,budget:c,loading:e,login:s,logout:a,refreshBudget:i}}var D=1e3,z=1e3,F=100;function J(f,t){if(f==="skill"){let c=F+Math.ceil(t/4);return {type:f,totalBytes:t,totalMegabytes:t/1e6,baseCost:c,multiplier:D,registrationCostTokens:c*D}}let o=Math.ceil(t/1e6),l=F+o;return {type:f,totalBytes:t,totalMegabytes:o,baseCost:l,multiplier:z,registrationCostTokens:l*z}}function gt(f){let t=f.stacknetUrl||f.apiBaseUrl,o=f.apiKey,[l,c]=react.useState(false),[p,e]=react.useState(null),r=react.useCallback(()=>{if(!o)throw new Error("API key required for registration. Call login() first.");return {"Content-Type":"application/json",Authorization:`Bearer ${o}`}},[o]),n=react.useCallback(async a=>{c(true),e(null);try{let i=await fetch(`${t}/skills`,{method:"POST",headers:r(),body:JSON.stringify(a)});if(!i.ok){let u=await i.json().catch(()=>({error:`HTTP ${i.status}`}));throw new Error(u.error||`Registration failed: ${i.status}`)}return await i.json()}catch(i){throw e(i.message),i}finally{c(false);}},[t,r]),s=react.useCallback(async a=>{c(true),e(null);try{let i=await fetch(`${t}/tensors`,{method:"POST",headers:r(),body:JSON.stringify(a)});if(!i.ok){let u=await i.json().catch(()=>({error:`HTTP ${i.status}`}));throw new Error(u.error||`Registration failed: ${i.status}`)}return await i.json()}catch(i){throw e(i.message),i}finally{c(false);}},[t,r]);return {registerSkill:n,registerTensor:s,estimateCost:J,registering:l,error:p}}function Rt(f,t){let o=d(f),[l,c]=react.useState({meta:null,tokenCount:null,usageCount:null}),[p,e]=react.useState(false),[r,n]=react.useState(null),s=react.useRef(true),a=react.useCallback(async()=>{if(t){e(true),n(null);try{let i=await o.getSkillStats(t);s.current&&c(i);}catch(i){s.current&&n(i.message);}finally{s.current&&e(false);}}},[o,t]);return react.useEffect(()=>(s.current=true,a(),()=>{s.current=false;}),[a]),{stats:l,loading:p,error:r,refresh:a}}function St(f,t){let o=d(f),[l,c]=react.useState({meta:null,sizeMB:null}),[p,e]=react.useState(false),[r,n]=react.useState(null),s=react.useRef(true),a=react.useCallback(async()=>{if(t){e(true),n(null);try{let i=await o.getTensorStats(t);s.current&&c(i);}catch(i){s.current&&n(i.message);}finally{s.current&&e(false);}}},[o,t]);return react.useEffect(()=>(s.current=true,a(),()=>{s.current=false;}),[a]),{stats:l,loading:p,error:r,refresh:a}}function Tt(f){let t=d(f),[o,l]=react.useState(null),[c,p]=react.useState(false),[e,r]=react.useState(null),n=react.useRef(true),s=react.useCallback(async()=>{p(true),r(null);try{let a=await t.getNetworkStats();n.current&&l(a);}catch(a){n.current&&r(a.message);}finally{n.current&&p(false);}},[t]);return react.useEffect(()=>(n.current=true,s(),()=>{n.current=false;}),[s]),{stats:o,loading:c,error:e,refresh:s}}function Et(f,t=5,o=1){let l=d(f),[c,p]=react.useState([]),[e,r]=react.useState(null),[n,s]=react.useState(false),[a,i]=react.useState(null),u=react.useRef(true),g=react.useRef(null),m=react.useCallback(async y=>{s(true),i(null),g.current=null;try{let k=await l.getTrending(t,y??o);u.current&&(p(k.items),r(k.pagination),g.current=k.pagination.next_cursor);}catch(k){u.current&&i(k.message);}finally{u.current&&s(false);}},[l,t,o]),h=react.useCallback(async()=>{if(!(!g.current||n)){s(true);try{let y=await l.getTrending(t,o,g.current);u.current&&(p(k=>[...k,...y.items]),r(y.pagination),g.current=y.pagination.next_cursor);}catch(y){u.current&&i(y.message);}finally{u.current&&s(false);}}},[l,t,o,n]);return react.useEffect(()=>(u.current=true,m(),()=>{u.current=false;}),[m]),{repos:c,hasMore:e?.has_more??false,total:e?.total??0,loading:n,error:a,refresh:m,loadMore:h}}function xt(f,t){let o=d(f),[l,c]=react.useState({stars:0,starred:false,repo_id:t||""}),[p,e]=react.useState(false),[r,n]=react.useState(null),s=react.useRef(true),a=react.useCallback(async()=>{if(t)try{let u=await o.getStarInfo(t);s.current&&c(u);}catch{}},[o,t]);react.useEffect(()=>(s.current=true,a(),()=>{s.current=false;}),[a]);let i=react.useCallback(async()=>{if(t){e(true),n(null);try{let u=l.starred?await o.unstarRepo(t):await o.starRepo(t);s.current&&c({stars:u.stars,starred:u.starred,repo_id:t});}catch(u){s.current&&n(u.message);}finally{s.current&&e(false);}}},[o,t,l.starred]);return {...l,loading:p,error:r,toggle:i,refresh:a}}exports.estimateCost=J;exports.useNetworkStats=Tt;exports.usePaginatedRepos=ut;exports.useRackClient=d;exports.useRackRegister=gt;exports.useRackSession=ft;exports.useRepoPush=it;exports.useRepoTree=nt;exports.useRepos=Z;exports.useSkillStats=Rt;exports.useStar=xt;exports.useTensorStats=St;exports.useTrending=Et;
1
+ 'use strict';var react=require('react');async function R(u,t,i,l){let c={"Content-Type":"application/json",...i?.headers};l&&(c.Authorization=`Bearer ${l}`);let p=await fetch(`${u}${t}`,{...i,headers:c});if(!p.ok){let e=`HTTP ${p.status}`;try{let r=await p.json();r.error&&(e=r.error);}catch{}throw new Error(e)}return p.json()}function w(u){let t=u.indexOf(":");return {mode:u.slice(0,t),cid:u.slice(t+1)}}function d(u){let t=u.apiBaseUrl,i=u.authorMid,l=u.ownerMid,c=u.apiKey,p=u.stacknetUrl||u.apiBaseUrl;return react.useMemo(()=>({async listRepos(e,r){let n=new URLSearchParams;(e||l)&&n.set("owner",e||l),r?.limit&&n.set("limit",String(r.limit)),r?.cursor&&n.set("cursor",r.cursor);let s=n.toString()?`?${n}`:"",a=await R(t,`/api/rack/repos${s}`,void 0,c);return {items:a.repos||[],pagination:a.pagination||{total:(a.repos||[]).length,limit:50,has_more:false,next_cursor:null}}},async initRepo(e){return R(t,"/api/rack/init",{method:"POST",body:JSON.stringify({...e,owner_mid:l})},c)},async push(e,r){return R(t,`/api/rack/${e}/push`,{method:"POST",body:JSON.stringify({...r,author_mid:i})},c)},async getTree(e,r="main"){let n=await R(t,`/api/rack/${e}/tree/${r}`,void 0,c);return {tree:n.tree,commit_cid:n.commit_cid}},async getBlob(e,r){return (await R(t,`/api/rack/${e}/blob/${r}`,void 0,c)).content},async getLog(e,r,n){let s=new URLSearchParams;r&&s.set("ref",r),n&&s.set("max_count",String(n));let a=s.toString()?`?${s}`:"";return (await R(t,`/api/rack/${e}/log${a}`,void 0,c)).commits||[]},async getBranches(e){return (await R(t,`/api/rack/${e}/branches`,void 0,c)).branches||[]},async createBranch(e,r,n){return R(t,`/api/rack/${e}/branch`,{method:"POST",body:JSON.stringify({branch_name:r,from_ref:n})},c)},async merge(e,r,n){return R(t,`/api/rack/${e}/merge`,{method:"POST",body:JSON.stringify({source_branch:r,target_branch:n})},c)},async getDiff(e,r,n){return (await R(t,`/api/rack/${e}/diff/${r}/${n}`,void 0,c)).diff?.entries||[]},async starRepo(e){return R(t,`/api/rack/${e}/star`,{method:"POST"},c)},async unstarRepo(e){return R(t,`/api/rack/${e}/star`,{method:"DELETE"},c)},async getStarInfo(e){return R(t,`/api/rack/${e}/stars`,void 0,c)},async getSkillStats(e){let r={meta:null,tokenCount:null,usageCount:null};try{let{tree:n}=await this.getTree(e,"main");if(!n?.entries)return r;if(n.entries["META.json"]){let f=w(n.entries["META.json"]).cid,o=await this.getBlob(e,f);r.meta=JSON.parse(o);}let s=0,a=Object.values(n.entries).map(async f=>{try{let o=w(f).cid,g=await this.getBlob(e,o);s+=g.length;}catch{}});await Promise.all(a),s>0&&(r.tokenCount=Math.ceil(s/4)),r.meta?.skill_id&&(r.usageCount=await this.getSkillUsageCount(r.meta.skill_id));}catch{}return r},async getSkillUsageCount(e){try{let r=await fetch(`${p}/v1/skills/${encodeURIComponent(e)}`);if(r.ok){let s=await r.json();return s.usage_count??s.usageCount??null}let n=await fetch(`${p}/v1/skills?scope=public`);if(n.ok){let a=((await n.json()).skills||[]).find(f=>f.name===e||f.id===e);if(a)return a.usage_count??a.usageCount??0}return 0}catch{return null}},async getTensorStats(e){let r={meta:null,sizeMB:null};try{let{tree:n}=await this.getTree(e,"main");if(!n?.entries)return r;if(n.entries["TENSOR_META.json"]){let s=w(n.entries["TENSOR_META.json"]).cid,a=await this.getBlob(e,s);r.meta=JSON.parse(a),r.sizeMB=r.meta?.tensor_size_mb??null;}}catch{}return r},async getLooopStats(e){let r={meta:null,fileCount:null};try{let{tree:n}=await this.getTree(e,"main");if(!n?.entries)return r;if(n.entries["LOOOP_META.json"]){let s=w(n.entries["LOOOP_META.json"]).cid,a=await this.getBlob(e,s);r.meta=JSON.parse(a);}r.fileCount=Object.keys(n.entries).length;}catch{}return r},async getNetworkStats(){try{return (await R(t,"/api/rack/stats",void 0,c)).stats||null}catch{return null}},async getTrending(e=5,r=1,n){try{let s=new URLSearchParams({limit:String(e),days:String(r)});n&&s.set("cursor",n);let a=await R(t,`/api/rack/trending?${s}`,void 0,c);return {items:a.trending||[],pagination:a.pagination||{total:(a.trending||[]).length,limit:e,has_more:!1,next_cursor:null}}}catch{return {items:[],pagination:{total:0,limit:e,has_more:false,next_cursor:null}}}}}),[t,i,l,c,p])}function Z(u){let t=d(u),i=react.useRef(t);i.current=t;let[l,c]=react.useState([]),[p,e]=react.useState(true),[r,n]=react.useState(null),s=react.useRef(true),a=react.useRef(null),f=react.useCallback(async()=>{a.current?.abort();let o=new AbortController;a.current=o;try{s.current&&(e(!0),n(null));let g=await i.current.listRepos();s.current&&!o.signal.aborted&&c(g.items);}catch(g){s.current&&!o.signal.aborted&&n(g instanceof Error?g.message:"Failed to load repos");}finally{s.current&&!o.signal.aborted&&e(false);}},[]);return react.useEffect(()=>(s.current=true,f(),()=>{s.current=false,a.current?.abort();}),[f]),{repos:l,loading:p,error:r,refresh:f}}function rt(u){return Object.entries(u).map(([t,i])=>{let l=i.indexOf(":"),c=l>0?i.slice(0,l):"100644",p=l>0?i.slice(l+1):i;return {path:t,mode:c,cid:p,isDir:c==="040000"}}).sort((t,i)=>t.isDir!==i.isDir?t.isDir?-1:1:t.path.localeCompare(i.path))}function nt(u,t,i="main"){let l=d(u),[c,p]=react.useState([]),[e,r]=react.useState(false),[n,s]=react.useState(null),a=react.useRef(true),f=react.useCallback(async()=>{if(t)try{a.current&&(r(!0),s(null));let{tree:g}=await l.getTree(t,i);a.current&&p(rt(g.entries));}catch(g){a.current&&s(g instanceof Error?g.message:"Failed to load tree");}finally{a.current&&r(false);}},[l,t,i]);react.useEffect(()=>(a.current=true,f(),()=>{a.current=false;}),[f]);let o=react.useCallback(async g=>{if(!t)throw new Error("No repo selected");return l.getBlob(t,g)},[l,t]);return {entries:c,loading:e,error:n,refresh:f,getFileContent:o}}function it(u){let t=d(u),[i,l]=react.useState(false),[c,p]=react.useState(null),e=react.useRef(true);return react.useEffect(()=>(e.current=true,()=>{e.current=false;}),[]),{push:react.useCallback(async(n,s,a,f)=>{try{return e.current&&(l(!0),p(null)),await t.push(n,{files:s,message:a,branch:f})}catch(o){let g=o instanceof Error?o.message:"Push failed";return e.current&&p(g),null}finally{e.current&&l(false);}},[t]),pushing:i,error:c}}function ut(u,t={}){let{pageSize:i=50,owner:l}=t,c=d(u),[p,e]=react.useState([]),[r,n]=react.useState(null),[s,a]=react.useState(false),[f,o]=react.useState(null),g=react.useRef(null),m=react.useRef(true),h=react.useCallback(async(W,G=false)=>{a(true),o(null);try{let S=await c.listRepos(l,{limit:i,cursor:W||void 0});m.current&&(e(Y=>G?[...Y,...S.items]:S.items),n(S.pagination),g.current=S.pagination.next_cursor);}catch(S){m.current&&o(S.message);}finally{m.current&&a(false);}},[c,l,i]),y=react.useCallback(async()=>{!g.current||s||await h(g.current,true);},[h,s]),k=react.useCallback(async()=>{g.current=null,await h(void 0,false);},[h]);return react.useEffect(()=>(m.current=true,h(),()=>{m.current=false;}),[h]),{repos:p,hasMore:r?.has_more??false,total:r?.total??0,loading:s,error:f,loadMore:y,reset:k,pagination:r}}var O="stacknet-rack-apikey";function ft(u){let t=u.stacknetUrl||u.apiBaseUrl,[i,l]=react.useState({authenticated:false}),[c,p]=react.useState(null),[e,r]=react.useState(false),n=react.useCallback(o=>({"Content-Type":"application/json",...o||u.apiKey?{Authorization:`Bearer ${o||u.apiKey}`}:{}}),[u.apiKey]),s=react.useCallback(async o=>{r(true);try{let g=await fetch(`${t}/health`,{headers:n(o)});if(!g.ok)throw new Error(`Authentication failed: ${g.status}`);let m={authenticated:!0,apiKey:o,permission:o.startsWith("gk_")?"write":"read"};l(m);try{localStorage.setItem(O,o);}catch{}return m}catch(g){throw l({authenticated:false}),g}finally{r(false);}},[t,n]),a=react.useCallback(()=>{l({authenticated:false}),p(null);try{localStorage.removeItem(O);}catch{}},[]),f=react.useCallback(async()=>{let o=i.apiKey||u.apiKey;if(!o)return null;try{let g=await fetch(`${t}/network/usage`,{headers:n(o)});if(!g.ok)return null;let m=await g.json(),h={planAllocation:m.plan_allocation??m.planAllocation??0,inferenceUsed:m.inference_used??m.inferenceUsed??0,ledgerSpent:m.ledger_spent??m.ledgerSpent??0,totalUsed:m.total_used??m.totalUsed??0,remaining:m.remaining??0,percent:m.percent??0,exceeded:m.exceeded??!1};return p(h),h}catch{return null}},[i.apiKey,u.apiKey,t,n]);return react.useEffect(()=>{let o=u.apiKey;if(o){l({authenticated:true,apiKey:o,permission:o.startsWith("gk_")?"write":"read"});return}try{let g=localStorage.getItem(O);g&&l({authenticated:!0,apiKey:g,permission:g.startsWith("gk_")?"write":"read"});}catch{}},[u.apiKey]),{session:i,budget:c,loading:e,login:s,logout:a,refreshBudget:f}}var gt=1e3,J=1e3,pt=1e3,z=100;function F(u,t){if(u==="skill"||u==="looop"){let c=u==="skill"?gt:pt,p=z+Math.ceil(t/4);return {type:u,totalBytes:t,totalMegabytes:t/1e6,baseCost:p,multiplier:c,registrationCostTokens:p*c}}let i=Math.ceil(t/1e6),l=z+i;return {type:u,totalBytes:t,totalMegabytes:i,baseCost:l,multiplier:J,registrationCostTokens:l*J}}function mt(u){let t=u.stacknetUrl||u.apiBaseUrl,i=u.apiKey,[l,c]=react.useState(false),[p,e]=react.useState(null),r=react.useCallback(()=>{if(!i)throw new Error("API key required for registration. Call login() first.");return {"Content-Type":"application/json",Authorization:`Bearer ${i}`}},[i]),n=react.useCallback(async f=>{c(true),e(null);try{let o=await fetch(`${t}/skills`,{method:"POST",headers:r(),body:JSON.stringify(f)});if(!o.ok){let g=await o.json().catch(()=>({error:`HTTP ${o.status}`}));throw new Error(g.error||`Registration failed: ${o.status}`)}return await o.json()}catch(o){throw e(o.message),o}finally{c(false);}},[t,r]),s=react.useCallback(async f=>{c(true),e(null);try{let o=await fetch(`${t}/tensors`,{method:"POST",headers:r(),body:JSON.stringify(f)});if(!o.ok){let g=await o.json().catch(()=>({error:`HTTP ${o.status}`}));throw new Error(g.error||`Registration failed: ${o.status}`)}return await o.json()}catch(o){throw e(o.message),o}finally{c(false);}},[t,r]),a=react.useCallback(async f=>{c(true),e(null);try{let o=await fetch(`${t}/looops`,{method:"POST",headers:r(),body:JSON.stringify(f)});if(!o.ok){let g=await o.json().catch(()=>({error:`HTTP ${o.status}`}));throw new Error(g.error||`Registration failed: ${o.status}`)}return await o.json()}catch(o){throw e(o.message),o}finally{c(false);}},[t,r]);return {registerSkill:n,registerTensor:s,registerLooop:a,estimateCost:F,registering:l,error:p}}function yt(u,t){let i=d(u),[l,c]=react.useState({meta:null,tokenCount:null,usageCount:null}),[p,e]=react.useState(false),[r,n]=react.useState(null),s=react.useRef(true),a=react.useCallback(async()=>{if(t){e(true),n(null);try{let f=await i.getSkillStats(t);s.current&&c(f);}catch(f){s.current&&n(f.message);}finally{s.current&&e(false);}}},[i,t]);return react.useEffect(()=>(s.current=true,a(),()=>{s.current=false;}),[a]),{stats:l,loading:p,error:r,refresh:a}}function Pt(u,t){let i=d(u),[l,c]=react.useState({meta:null,sizeMB:null}),[p,e]=react.useState(false),[r,n]=react.useState(null),s=react.useRef(true),a=react.useCallback(async()=>{if(t){e(true),n(null);try{let f=await i.getTensorStats(t);s.current&&c(f);}catch(f){s.current&&n(f.message);}finally{s.current&&e(false);}}},[i,t]);return react.useEffect(()=>(s.current=true,a(),()=>{s.current=false;}),[a]),{stats:l,loading:p,error:r,refresh:a}}function Et(u,t){let i=d(u),[l,c]=react.useState({meta:null,fileCount:null}),[p,e]=react.useState(false),[r,n]=react.useState(null),s=react.useRef(true),a=react.useCallback(async()=>{if(t){e(true),n(null);try{let f=await i.getLooopStats(t);s.current&&c(f);}catch(f){s.current&&n(f.message);}finally{s.current&&e(false);}}},[i,t]);return react.useEffect(()=>(s.current=true,a(),()=>{s.current=false;}),[a]),{stats:l,loading:p,error:r,refresh:a}}function xt(u){let t=d(u),[i,l]=react.useState(null),[c,p]=react.useState(false),[e,r]=react.useState(null),n=react.useRef(true),s=react.useCallback(async()=>{p(true),r(null);try{let a=await t.getNetworkStats();n.current&&l(a);}catch(a){n.current&&r(a.message);}finally{n.current&&p(false);}},[t]);return react.useEffect(()=>(n.current=true,s(),()=>{n.current=false;}),[s]),{stats:i,loading:c,error:e,refresh:s}}function $t(u,t=5,i=1){let l=d(u),[c,p]=react.useState([]),[e,r]=react.useState(null),[n,s]=react.useState(false),[a,f]=react.useState(null),o=react.useRef(true),g=react.useRef(null),m=react.useCallback(async y=>{s(true),f(null),g.current=null;try{let k=await l.getTrending(t,y??i);o.current&&(p(k.items),r(k.pagination),g.current=k.pagination.next_cursor);}catch(k){o.current&&f(k.message);}finally{o.current&&s(false);}},[l,t,i]),h=react.useCallback(async()=>{if(!(!g.current||n)){s(true);try{let y=await l.getTrending(t,i,g.current);o.current&&(p(k=>[...k,...y.items]),r(y.pagination),g.current=y.pagination.next_cursor);}catch(y){o.current&&f(y.message);}finally{o.current&&s(false);}}},[l,t,i,n]);return react.useEffect(()=>(o.current=true,m(),()=>{o.current=false;}),[m]),{repos:c,hasMore:e?.has_more??false,total:e?.total??0,loading:n,error:a,refresh:m,loadMore:h}}function Nt(u,t){let i=d(u),[l,c]=react.useState({stars:0,starred:false,repo_id:t||""}),[p,e]=react.useState(false),[r,n]=react.useState(null),s=react.useRef(true),a=react.useCallback(async()=>{if(t)try{let o=await i.getStarInfo(t);s.current&&c(o);}catch{}},[i,t]);react.useEffect(()=>(s.current=true,a(),()=>{s.current=false;}),[a]);let f=react.useCallback(async()=>{if(t){e(true),n(null);try{let o=l.starred?await i.unstarRepo(t):await i.starRepo(t);s.current&&c({stars:o.stars,starred:o.starred,repo_id:t});}catch(o){s.current&&n(o.message);}finally{s.current&&e(false);}}},[i,t,l.starred]);return {...l,loading:p,error:r,toggle:f,refresh:a}}exports.estimateCost=F;exports.useLooopStats=Et;exports.useNetworkStats=xt;exports.usePaginatedRepos=ut;exports.useRackClient=d;exports.useRackRegister=mt;exports.useRackSession=ft;exports.useRepoPush=it;exports.useRepoTree=nt;exports.useRepos=Z;exports.useSkillStats=yt;exports.useStar=Nt;exports.useTensorStats=Pt;exports.useTrending=$t;
@@ -1,4 +1,4 @@
1
- import { PaginationParams, PaginatedResult, RepoInfo, InitResult, RepoFile, PushResult, RepoTree, RepoCommit, DiffEntry, StarResult, StarInfo, SkillStats, TensorStats, NetworkStats, TrendingRepo, RackConfig, TreeEntry, PaginationInfo, RackSession, TokenBudget, CostEstimate, SkillRegistrationInput, SkillRegistrationResult, TensorRegistrationInput, TensorRegistrationResult } from '../types/index.cjs';
1
+ import { PaginationParams, PaginatedResult, RepoInfo, InitResult, RepoFile, PushResult, RepoTree, RepoCommit, DiffEntry, StarResult, StarInfo, SkillStats, TensorStats, LooopStats, NetworkStats, TrendingRepo, RackConfig, TreeEntry, PaginationInfo, RackSession, TokenBudget, CostEstimate, SkillRegistrationInput, SkillRegistrationResult, TensorRegistrationInput, TensorRegistrationResult, LooopRegistrationInput, LooopRegistrationResult } from '../types/index.cjs';
2
2
 
3
3
  interface RackClient {
4
4
  listRepos: (owner?: string, pagination?: PaginationParams) => Promise<PaginatedResult<RepoInfo>>;
@@ -35,6 +35,7 @@ interface RackClient {
35
35
  getSkillStats: (repoId: string) => Promise<SkillStats>;
36
36
  getSkillUsageCount: (skillId: string) => Promise<number | null>;
37
37
  getTensorStats: (repoId: string) => Promise<TensorStats>;
38
+ getLooopStats: (repoId: string) => Promise<LooopStats>;
38
39
  getNetworkStats: () => Promise<NetworkStats | null>;
39
40
  getTrending: (limit?: number, days?: number, cursor?: string) => Promise<PaginatedResult<TrendingRepo>>;
40
41
  }
@@ -118,10 +119,10 @@ declare function useRackSession(config: RackConfig): {
118
119
  /**
119
120
  * Estimate registration cost before committing.
120
121
  *
121
- * Skills: (INIT_COST + ceil(totalBytes / 4)) × 1000
122
+ * Skills/Looops: (INIT_COST + ceil(totalBytes / 4)) × 1000
122
123
  * Tensors: (INIT_COST + ceil(totalMB)) × 1000 (MB-level, not token-level)
123
124
  */
124
- declare function estimateCost(type: 'skill' | 'tensor', totalBytes: number): CostEstimate;
125
+ declare function estimateCost(type: 'skill' | 'tensor' | 'looop', totalBytes: number): CostEstimate;
125
126
  /**
126
127
  * Hook for registering skills and tensors on StackNet.
127
128
  * Requires an authenticated session (API key).
@@ -129,6 +130,7 @@ declare function estimateCost(type: 'skill' | 'tensor', totalBytes: number): Cos
129
130
  declare function useRackRegister(config: RackConfig): {
130
131
  registerSkill: (input: SkillRegistrationInput) => Promise<SkillRegistrationResult>;
131
132
  registerTensor: (input: TensorRegistrationInput) => Promise<TensorRegistrationResult>;
133
+ registerLooop: (input: LooopRegistrationInput) => Promise<LooopRegistrationResult>;
132
134
  estimateCost: typeof estimateCost;
133
135
  registering: boolean;
134
136
  error: string | null;
@@ -154,6 +156,16 @@ declare function useTensorStats(config: RackConfig, repoId: string | null): {
154
156
  refresh: () => Promise<void>;
155
157
  };
156
158
 
159
+ /**
160
+ * Fetch looop stats (LOOOP_META.json, file count) for a looop repo.
161
+ */
162
+ declare function useLooopStats(config: RackConfig, repoId: string | null): {
163
+ stats: LooopStats;
164
+ loading: boolean;
165
+ error: string | null;
166
+ refresh: () => Promise<void>;
167
+ };
168
+
157
169
  /**
158
170
  * Fetch network-wide stats (repos, skills, tensors, stacks, stars, tokens, etc.)
159
171
  */
@@ -192,4 +204,4 @@ declare function useStar(config: RackConfig, repoId: string | null): {
192
204
  repo_id: string;
193
205
  };
194
206
 
195
- export { type RackClient, estimateCost, useNetworkStats, usePaginatedRepos, useRackClient, useRackRegister, useRackSession, useRepoPush, useRepoTree, useRepos, useSkillStats, useStar, useTensorStats, useTrending };
207
+ export { type RackClient, estimateCost, useLooopStats, useNetworkStats, usePaginatedRepos, useRackClient, useRackRegister, useRackSession, useRepoPush, useRepoTree, useRepos, useSkillStats, useStar, useTensorStats, useTrending };
@@ -1,4 +1,4 @@
1
- import { PaginationParams, PaginatedResult, RepoInfo, InitResult, RepoFile, PushResult, RepoTree, RepoCommit, DiffEntry, StarResult, StarInfo, SkillStats, TensorStats, NetworkStats, TrendingRepo, RackConfig, TreeEntry, PaginationInfo, RackSession, TokenBudget, CostEstimate, SkillRegistrationInput, SkillRegistrationResult, TensorRegistrationInput, TensorRegistrationResult } from '../types/index.js';
1
+ import { PaginationParams, PaginatedResult, RepoInfo, InitResult, RepoFile, PushResult, RepoTree, RepoCommit, DiffEntry, StarResult, StarInfo, SkillStats, TensorStats, LooopStats, NetworkStats, TrendingRepo, RackConfig, TreeEntry, PaginationInfo, RackSession, TokenBudget, CostEstimate, SkillRegistrationInput, SkillRegistrationResult, TensorRegistrationInput, TensorRegistrationResult, LooopRegistrationInput, LooopRegistrationResult } from '../types/index.js';
2
2
 
3
3
  interface RackClient {
4
4
  listRepos: (owner?: string, pagination?: PaginationParams) => Promise<PaginatedResult<RepoInfo>>;
@@ -35,6 +35,7 @@ interface RackClient {
35
35
  getSkillStats: (repoId: string) => Promise<SkillStats>;
36
36
  getSkillUsageCount: (skillId: string) => Promise<number | null>;
37
37
  getTensorStats: (repoId: string) => Promise<TensorStats>;
38
+ getLooopStats: (repoId: string) => Promise<LooopStats>;
38
39
  getNetworkStats: () => Promise<NetworkStats | null>;
39
40
  getTrending: (limit?: number, days?: number, cursor?: string) => Promise<PaginatedResult<TrendingRepo>>;
40
41
  }
@@ -118,10 +119,10 @@ declare function useRackSession(config: RackConfig): {
118
119
  /**
119
120
  * Estimate registration cost before committing.
120
121
  *
121
- * Skills: (INIT_COST + ceil(totalBytes / 4)) × 1000
122
+ * Skills/Looops: (INIT_COST + ceil(totalBytes / 4)) × 1000
122
123
  * Tensors: (INIT_COST + ceil(totalMB)) × 1000 (MB-level, not token-level)
123
124
  */
124
- declare function estimateCost(type: 'skill' | 'tensor', totalBytes: number): CostEstimate;
125
+ declare function estimateCost(type: 'skill' | 'tensor' | 'looop', totalBytes: number): CostEstimate;
125
126
  /**
126
127
  * Hook for registering skills and tensors on StackNet.
127
128
  * Requires an authenticated session (API key).
@@ -129,6 +130,7 @@ declare function estimateCost(type: 'skill' | 'tensor', totalBytes: number): Cos
129
130
  declare function useRackRegister(config: RackConfig): {
130
131
  registerSkill: (input: SkillRegistrationInput) => Promise<SkillRegistrationResult>;
131
132
  registerTensor: (input: TensorRegistrationInput) => Promise<TensorRegistrationResult>;
133
+ registerLooop: (input: LooopRegistrationInput) => Promise<LooopRegistrationResult>;
132
134
  estimateCost: typeof estimateCost;
133
135
  registering: boolean;
134
136
  error: string | null;
@@ -154,6 +156,16 @@ declare function useTensorStats(config: RackConfig, repoId: string | null): {
154
156
  refresh: () => Promise<void>;
155
157
  };
156
158
 
159
+ /**
160
+ * Fetch looop stats (LOOOP_META.json, file count) for a looop repo.
161
+ */
162
+ declare function useLooopStats(config: RackConfig, repoId: string | null): {
163
+ stats: LooopStats;
164
+ loading: boolean;
165
+ error: string | null;
166
+ refresh: () => Promise<void>;
167
+ };
168
+
157
169
  /**
158
170
  * Fetch network-wide stats (repos, skills, tensors, stacks, stars, tokens, etc.)
159
171
  */
@@ -192,4 +204,4 @@ declare function useStar(config: RackConfig, repoId: string | null): {
192
204
  repo_id: string;
193
205
  };
194
206
 
195
- export { type RackClient, estimateCost, useNetworkStats, usePaginatedRepos, useRackClient, useRackRegister, useRackSession, useRepoPush, useRepoTree, useRepos, useSkillStats, useStar, useTensorStats, useTrending };
207
+ export { type RackClient, estimateCost, useLooopStats, useNetworkStats, usePaginatedRepos, useRackClient, useRackRegister, useRackSession, useRepoPush, useRepoTree, useRepos, useSkillStats, useStar, useTensorStats, useTrending };