@tech-leads-club/agent-skills 1.4.1 → 1.4.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.
package/README.md CHANGED
@@ -68,7 +68,7 @@ packages/skills-catalog/skills/
68
68
 
69
69
  ## 🛡️ Security & Trust
70
70
 
71
- Your environment's safety is our top priority. Unlike open marketplaces where **13.4% of skills contain critical issues**, `agent-skills` is a managed, hardened library: 100% open source (no binaries), static analysis in CI/CD, immutable integrity via lockfiles and content hashing, and human-curated prompts. The CLI uses defense-in-depth (sanitization, path isolation, symlink guards, atomic lockfile, audit trail); every skill is scanned with [mcp-scan](https://github.com/invariantlabs-ai/mcp-scan) before publishing.
71
+ Your environment's safety is our top priority. Unlike open marketplaces where **13.4% of skills contain critical issues**, `agent-skills` is a managed, hardened library: 100% open source (no binaries), static analysis in CI/CD, immutable integrity via lockfiles and content hashing, and human-curated prompts. The CLI uses defense-in-depth (sanitization, path isolation, symlink guards, atomic lockfile, audit trail); every skill is scanned with [Snyk Agent Scan](https://github.com/snyk/agent-scan) (formerly mcp-scan) before publishing.
72
72
 
73
73
  → **Full threat model, implementation details, and vulnerability reporting:** [SECURITY.md](SECURITY.md)
74
74
 
package/index.js CHANGED
@@ -1,12 +1,13 @@
1
1
  #!/usr/bin/env node
2
- var qs=Object.defineProperty;var q=(e,t)=>()=>(e&&(t=e(e=0)),t);var Bt=(e,t)=>{for(var o in t)qs(e,o,{get:t[o],enumerable:!0})};import{existsSync as xn}from"node:fs";import{dirname as Js,join as yn,parse as Qs,resolve as Zs}from"node:path";function Oe(e=process.cwd()){let t=Zs(e),o=Qs(t).root;for(;t!==o;){if((xn(yn(t,"package.json"))||xn(yn(t,".git")))&&!t.endsWith("packages/cli"))return t;t=Js(t)}return e}var bo=q(()=>{"use strict"});import{existsSync as v,readdirSync as el}from"node:fs";import{homedir as tl}from"node:os";import{join as b}from"node:path";function So(){return Object.entries(no).filter(([,e])=>e.detectInstalled()).map(([e])=>e)}function Ne(e){return no[e]}function bn(){return Object.keys(no).sort((e,t)=>no[e].displayName.localeCompare(no[t].displayName))}var D,Y,no,kn,io=q(()=>{"use strict";bo();D=tl(),Y=Oe(),no={cursor:{name:"cursor",displayName:"Cursor",description:"AI-first code editor built on VS Code",skillsDir:".cursor/skills",globalSkillsDir:b(D,".cursor/skills"),detectInstalled:()=>v(b(D,".cursor"))||v(b(Y,".cursor"))},"claude-code":{name:"claude-code",displayName:"Claude Code",description:"Anthropic's agentic coding tool",skillsDir:".claude/skills",globalSkillsDir:b(D,".claude/skills"),detectInstalled:()=>v(b(D,".claude"))||v(b(Y,".claude"))},"github-copilot":{name:"github-copilot",displayName:"GitHub Copilot",description:"AI pair programmer by GitHub/Microsoft",skillsDir:".github/skills",globalSkillsDir:b(D,".copilot/skills"),detectInstalled:()=>v(b(D,".copilot"))||v(b(Y,".github"))},windsurf:{name:"windsurf",displayName:"Windsurf",description:"AI IDE with Cascade flow (Codeium)",skillsDir:".windsurf/skills",globalSkillsDir:b(D,".codeium/windsurf/skills"),detectInstalled:()=>v(b(D,".codeium/windsurf"))||v(b(Y,".windsurf"))},cline:{name:"cline",displayName:"Cline",description:"Autonomous AI coding agent for VS Code",skillsDir:".cline/skills",globalSkillsDir:b(D,".cline/skills"),detectInstalled:()=>v(b(D,".cline"))||v(b(Y,".cline"))||kn("saoudrizwan","claude-dev")},aider:{name:"aider",displayName:"Aider",description:"AI pair programming in terminal",skillsDir:".aider/skills",globalSkillsDir:b(D,".aider/skills"),detectInstalled:()=>v(b(D,".aider"))||v(b(Y,".aider"))},codex:{name:"codex",displayName:"OpenAI Codex",description:"OpenAI's coding agent",skillsDir:".codex/skills",globalSkillsDir:b(D,".codex/skills"),detectInstalled:()=>v(b(D,".codex"))||v(b(Y,".codex"))},gemini:{name:"gemini",displayName:"Gemini CLI",description:"Google's AI coding assistant",skillsDir:".gemini/skills",globalSkillsDir:b(D,".gemini/skills"),detectInstalled:()=>v(b(D,".gemini"))||v(b(Y,".gemini"))},antigravity:{name:"antigravity",displayName:"Antigravity",description:"Google's agentic coding (VS Code)",skillsDir:".agent/skills",globalSkillsDir:b(D,".gemini/antigravity/skills"),detectInstalled:()=>v(b(D,".gemini/antigravity"))||v(b(Y,".agent"))},roo:{name:"roo",displayName:"Roo Code",description:"AI coding assistant for VS Code",skillsDir:".roo/skills",globalSkillsDir:b(D,".roo/skills"),detectInstalled:()=>v(b(D,".roo"))||v(b(Y,".roo"))||kn("RooVetGit","roo-cline")},kilocode:{name:"kilocode",displayName:"Kilo Code",description:"AI coding agent with auto-launch",skillsDir:".kilocode/skills",globalSkillsDir:b(D,".kilocode/skills"),detectInstalled:()=>v(b(D,".kilocode"))||v(b(Y,".kilocode"))},trae:{name:"trae",displayName:"TRAE",description:"AI IDE with SOLO mode and custom agents",skillsDir:".trae/skills",globalSkillsDir:b(D,".trae/skills"),detectInstalled:()=>v(b(D,".trae"))||v(b(Y,".trae"))},kiro:{name:"kiro",displayName:"Kiro",description:"AI Agent with workspace and global skill scopes",skillsDir:".kiro/skills",globalSkillsDir:b(D,".kiro/skills"),detectInstalled:()=>v(b(D,".kiro"))||v(b(Y,".kiro"))},"amazon-q":{name:"amazon-q",displayName:"Amazon Q",description:"AWS AI coding assistant",skillsDir:".amazonq/skills",globalSkillsDir:b(D,".amazonq/skills"),detectInstalled:()=>v(b(D,".amazonq"))||v(b(Y,".amazonq"))},augment:{name:"augment",displayName:"Augment",description:"AI code assistant with context engine",skillsDir:".augment/skills",globalSkillsDir:b(D,".augment/skills"),detectInstalled:()=>v(b(D,".augment"))||v(b(Y,".augment"))},tabnine:{name:"tabnine",displayName:"Tabnine",description:"AI code completions with privacy focus",skillsDir:".tabnine/skills",globalSkillsDir:b(D,".tabnine/skills"),detectInstalled:()=>v(b(D,".tabnine"))||v(b(Y,".tabnine"))},opencode:{name:"opencode",displayName:"OpenCode",description:"Open-source AI coding terminal",skillsDir:".opencode/skills",globalSkillsDir:b(D,".config/opencode/skills"),detectInstalled:()=>v(b(D,".config/opencode"))||v(b(Y,".opencode"))||v(b(Y,".config/opencode"))},sourcegraph:{name:"sourcegraph",displayName:"Sourcegraph Cody",description:"AI assistant with codebase context",skillsDir:".sourcegraph/skills",globalSkillsDir:b(D,".sourcegraph/skills"),detectInstalled:()=>v(b(D,".sourcegraph"))||v(b(Y,".sourcegraph"))},droid:{name:"droid",displayName:"Droid (Factory.ai)",description:"AI software engineer by Factory.ai",skillsDir:".factory/skills",globalSkillsDir:b(D,".factory/skills"),detectInstalled:()=>v(b(D,".factory"))||v(b(Y,".factory"))}};kn=(e,t)=>{let o=[b(D,".vscode/extensions"),b(D,".vscode-server/extensions"),b(D,".vscode-oss/extensions")];for(let r of o)if(v(r))try{if(el(r).some(s=>s.startsWith(`${e}.${t}-`)))return!0}catch{}return!1}});var Lt,To,mr,Tn,pr,ft,fr,gr,hr,xr,wn,Cn,An,In,Dn,We,Ee=q(()=>{"use strict";Lt="@tech-leads-club/agent-skills",To="@tech-leads-club/skills-catalog",mr=".agent-skills",Tn="cache.json",pr=".skill-meta.json",ft=".agents",fr="skills",gr=".skill-lock.json",hr=".skill-lock.json.backup",xr=".agent-skills",wn="audit.log",Cn=".cache",An="agent-skills",In="skills",Dn="registry.json",We={UPDATE_AVAILABLE:(e,t)=>`Update available: ${e} \u2192 ${t}`,TIP_INSTALL_UPDATE:"Tip: Install globally to update:",TIP_INSTALL_ACCESS:"Tip: Install globally for easier access:",UPDATE_COMMAND:`npm update -g ${Lt}`,INSTALL_COMMAND:`npm install -g ${Lt}`,DESCRIPTION:"Curated skills to power up your coding agents"}});import{appendFile as sl,mkdir as ll,readFile as al}from"node:fs/promises";import{homedir as yr}from"node:os";import{join as vn}from"node:path";function wo(e=yr()){return vn(e,xr,wn)}async function kr(e,t=yr()){try{let o=wo(t),r=vn(t,xr);await ll(r,{recursive:!0});let i=JSON.stringify({...e,timestamp:new Date().toISOString()})+`
3
- `;await sl(o,i,"utf-8")}catch{}}async function Bn(e,t=yr()){try{let o=wo(t),s=(await al(o,"utf-8")).trim().split(`
4
- `).filter(Boolean).map(l=>{try{return JSON.parse(l)}catch{return null}}).filter(l=>l!==null).reverse();return e?s.slice(0,e):s}catch{return[]}}var br=q(()=>{"use strict";Ee()});import{execSync as cl}from"node:child_process";import{existsSync as dl}from"node:fs";import{join as ul}from"node:path";function ml(){try{return cl("npm root -g",{encoding:"utf-8"}).trim()}catch{return null}}function Sr(){let e=ml();if(!e)return!1;let t=ul(e,Lt);return dl(t)}var Tr=q(()=>{"use strict";Ee()});var Rt,Pt,wr,Cr,Ln=q(()=>{"use strict";Rt="uncategorized",Pt=/^\(([a-z][a-z0-9-]*)\)$/,wr="_category.json",Cr={id:Rt,name:"Uncategorized",description:"Skills without a specific category",priority:999}});var Rn,Pn=q(()=>{"use strict";Rn=["cursor","claude-code","github-copilot","windsurf","cline","aider","codex","gemini","antigravity","roo","kilocode","amazon-q","augment","tabnine","opencode","sourcegraph","droid","trae","kiro"]});function so(e){return e.split("-").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}var Mn=q(()=>{"use strict"});var Co=q(()=>{"use strict";Ln();Pn();Mn()});var Gn={};Bt(Gn,{addSkillToLock:()=>Ir,getAllLockedSkills:()=>Tl,getSkillFromLock:()=>Do,readSkillLock:()=>lo,removeSkillFromLock:()=>Io,writeSkillLock:()=>Ar});import{mkdir as pl,readFile as On,rename as fl,unlink as gl,writeFile as _n}from"node:fs/promises";import{homedir as Nn}from"node:os";import{dirname as hl,join as Ao}from"node:path";import{z as de}from"zod";function $n(e){if(e)return Ao(Nn(),ft,gr);let t=Oe();return Ao(t,ft,gr)}function bl(e){if(e)return Ao(Nn(),ft,hr);let t=Oe();return Ao(t,ft,hr)}function Un(){return{version:Fn,skills:{}}}function Sl(e){try{let t=kl.parse(e);return t.version===1?{version:Fn,skills:Object.fromEntries(Object.entries(t.skills).map(([o,r])=>[o,{...r,agents:r.agents||[],method:r.method||"copy",global:r.global??!1}]))}:t}catch{return Un()}}async function lo(e=!1){let t=$n(e);try{let o=await On(t,"utf-8"),r=JSON.parse(o);return Sl(r)}catch{return Un()}}async function Ar(e,t=!1){let o=$n(t),r=bl(t),i=`${o}.tmp`;try{try{let s=await On(o,"utf-8");await _n(r,s,"utf-8")}catch{}await pl(hl(o),{recursive:!0}),await _n(i,JSON.stringify(e,null,2),"utf-8"),await fl(i,o)}catch(s){try{await gl(i)}catch{}throw s}}async function Ir(e,t,o={}){let r=await lo(o.global),i=new Date().toISOString(),s=r.skills[e];r.skills[e]={name:e,source:o.source||"local",contentHash:o.contentHash??s?.contentHash,installedAt:s?.installedAt??i,updatedAt:i,agents:t,method:o.method||"copy",global:o.global??!1,version:o.version},await Ar(r,o.global)}async function Io(e,t=!1){let o=await lo(t);return e in o.skills?(delete o.skills[e],await Ar(o,t),!0):!1}async function Do(e,t=!1){return(await lo(t)).skills[e]??null}async function Tl(e=!1){return(await lo(e)).skills}var Fn,xl,yl,kl,Dr=q(()=>{"use strict";Co();Ee();bo();Fn=2,xl=de.enum(Rn),yl=de.object({name:de.string(),source:de.string(),contentHash:de.string().optional(),installedAt:de.string(),updatedAt:de.string(),agents:de.array(xl).optional(),method:de.enum(["copy","symlink"]).optional(),global:de.boolean().optional(),version:de.string().optional()}),kl=de.object({version:de.number(),skills:de.record(de.string(),yl)})});import El from"ky";import{existsSync as gt,mkdirSync as vo,readFileSync as Vn,rmSync as Er,writeFileSync as vr}from"node:fs";import{homedir as vl}from"node:os";import{join as Ce}from"node:path";import Bl from"package-json";function Kn(){gt(we.cacheDir)||vo(we.cacheDir,{recursive:!0}),gt(we.skillsCacheDir)||vo(we.skillsCacheDir,{recursive:!0})}function Rl(e){return Date.now()-e<Mt.cacheTtlMs}function Hn(){if(!gt(we.registryCacheFile))return null;try{let e=Vn(we.registryCacheFile,"utf-8");return JSON.parse(e)}catch{return null}}function Pl(e){let t={fetchedAt:Date.now(),registry:e};vr(we.registryCacheFile,JSON.stringify(t,null,2))}async function Xn(e,t){try{return await jn.get(e)}catch(o){if(t)try{return await jn.get(t)}catch{}throw o}}async function Yn(){if(process.env.SKILLS_CDN_REF)return process.env.SKILLS_CDN_REF;if(Eo)return Eo;try{return Eo=(await Bl(To,{version:"latest"})).version,Eo}catch{return"latest"}}function Wn(e){let t=`https://cdn.jsdelivr.net/npm/${To}@${e}`,o=`https://unpkg.com/${To}@${e}`;return{registry:`${t}/skills-registry.json`,fallbackRegistry:`${o}/skills-registry.json`,skillsBase:`${t}/skills`,fallbackSkillsBase:`${o}/skills`}}async function ao(e=!1){Kn();let t=await Yn();if(!e){let o=Hn(),r=o&&t!=="latest"&&o.registry.version!==t;if(o&&Rl(o.fetchedAt)&&!r)return o.registry}try{let o=Wn(t),i=await(await Xn(o.registry,o.fallbackRegistry)).json();return Pl(i),i}catch(o){let r=Hn();return r?r.registry:(console.error(`Failed to fetch registry: ${o instanceof Error?o.message:o}`),null)}}function Ml(e){return Ll.reduce((t,o)=>t.replace(o,""),e).trim()}function _l(e,t){let o=Ce(e,".");return Ce(t,".").startsWith(o)}function st(e){let t=Ml(e);if(!t)throw new Error("Invalid skill name");return Ce(we.skillsCacheDir,t)}function Br(e){try{let t=st(e);return gt(Ce(t,"SKILL.md"))}catch{return!1}}function Ol(e,t){try{let o=Ce(st(e),pr);vr(o,JSON.stringify(t,null,2))}catch{}}function zn(e){try{let t=Ce(st(e),pr);return gt(t)?JSON.parse(Vn(t,"utf-8")):null}catch{return null}}async function Lr(e){if(!Br(e))return!0;let t=await Ot(e);if(!t?.contentHash)return!1;let o=zn(e);return o?.contentHash?o.contentHash!==t.contentHash:!0}function qn(e){return zn(e)?.contentHash}async function Bo(e){let t=[],o=[];for(let r of e)await Lr(r)?t.push(r):o.push(r);return{toUpdate:t,upToDate:o}}async function Nl(e,t,o){let r=Ce(o,t);if(!_l(o,r))return console.error(`Security: Skipping suspicious file path: ${t}`),!1;let i=Ce(r,"..");gt(i)||vo(i,{recursive:!0});let s=Wn(await Yn()),l=`${s.skillsBase}/${e.path}/${t}`,d=`${s.fallbackSkillsBase}/${e.path}/${t}`,c=await Xn(l,d);if(!c.ok)throw new Error(`Failed to download ${t}: HTTP ${c.status}`);return vr(r,await c.text()),!0}async function Fl(e){let t=st(e.name);Kn(),gt(t)||vo(t,{recursive:!0});try{let o=[...e.files],r=0;for(let i=0;i<o.length;i+=Mt.maxConcurrentDownloads){let s=o.slice(i,i+Mt.maxConcurrentDownloads),l=await Promise.all(s.map(d=>Nl(e,d,t)));r+=l.filter(Boolean).length}if(r<o.length)throw new Error(`Only ${r}/${o.length} files downloaded successfully`);return e.contentHash&&Ol(e.name,{contentHash:e.contentHash,downloadedAt:Date.now()}),t}catch(o){return console.error(`Failed to download skill ${e.name}: ${o instanceof Error?o.message:o}`),null}}async function _t(){let e=await ao();return e?e.skills.map(t=>({name:t.name,description:t.description,path:Br(t.name)?st(t.name):"",category:t.category})):[]}async function Ot(e){return(await ao())?.skills.find(o=>o.name===e)??null}async function $l(){return(await ao())?.deprecated??[]}async function Lo(){let e=await $l();return new Map(e.map(t=>[t.name,t]))}async function ht(e){if(Br(e))return st(e);let t=await Ot(e);return t?Fl(t):null}function Jn(){try{Er(we.cacheDir,{recursive:!0,force:!0})}catch{}}function Ul(e){try{Er(Ce(we.skillsCacheDir,e),{recursive:!0,force:!0})}catch{}}function Qn(){try{Er(we.registryCacheFile,{force:!0})}catch{}}async function co(e){return Ul(e),ht(e)}function Rr(){return we.cacheDir}var Mt,we,Ll,jn,Eo,ze=q(()=>{"use strict";Ee();Mt={cacheTtlMs:864e5,fetchTimeoutMs:15e3,maxRetries:3,retryBaseDelayMs:500,maxConcurrentDownloads:10},we={cacheDir:Ce(vl(),Cn,An),get registryCacheFile(){return Ce(this.cacheDir,Dn)},get skillsCacheDir(){return Ce(this.cacheDir,In)}},Ll=[/[/\\]/g,/\.\./g,/[<>:"|?*]/g];jn=El.create({timeout:Mt.fetchTimeoutMs,retry:{limit:Mt.maxRetries,methods:["get"],statusCodes:[408,429,500,502,503,504],backoffLimit:1e4,delay:e=>Mt.retryBaseDelayMs*Math.pow(2,e-1),jitter:!0,retryOnTimeout:!0}});Eo=null});import{cp as Gl,lstat as Pr,mkdir as ri,readdir as Hl,readlink as ni,rm as Ft,symlink as jl}from"node:fs/promises";import{homedir as Vl,platform as Kl}from"node:os";import{join as pe,normalize as Zn,relative as Xl,resolve as mo,sep as Yl}from"node:path";var ei,Mr,po,ti,Wl,zl,uo,ql,Nt,oi,Jl,Ql,Zl,Ro,_r,ea,fo,$t=q(()=>{"use strict";Ee();io();br();Tr();Dr();bo();ze();ei=pe(ft,fr),Mr=e=>(e.replace(/[/\\]/g,"").replace(/[\0:*?"<>|]/g,"").replace(/^[.\s]+|[.\s]+$/g,"").replace(/\.{2,}/g,"").replace(/^\.+/,"")||"unnamed-skill").substring(0,255),po=(e,t)=>{let o=Zn(mo(e)),r=Zn(mo(t));return r.startsWith(o+Yl)||r===o},ti=async(e,t)=>{try{await Wl(t,e),await ri(pe(t,".."),{recursive:!0});let o=Xl(pe(t,".."),e),r=Kl()==="win32"?"junction":void 0;return await jl(o,t,r),!0}catch{return!1}},Wl=async(e,t)=>{try{if((await Pr(e)).isSymbolicLink()){let r=await ni(e);if(mo(r)===mo(t))return;await Ft(e)}else await Ft(e,{recursive:!0})}catch(o){o?.code==="ELOOP"&&await Ft(e,{force:!0}).catch(()=>{})}},zl=async(e,t)=>{try{if((await Pr(e)).isSymbolicLink()){let r=await ni(e),i=mo(pe(e,".."),r);return po(t,i)}return!0}catch{return!0}},uo=async(e,t)=>{await Ft(t,{recursive:!0,force:!0}),await ri(pe(t,".."),{recursive:!0}),await Gl(e,t,{recursive:!0})},ql=(e,t)=>`${e}-${t?"global":"local"}`,Nt=(e,t,o={})=>({agent:e.config.displayName,skill:e.skill.name,path:e.skillTargetPath,method:t,success:!0,...o}),oi=(e,t,o)=>({agent:e.config.displayName,skill:e.skill.name,path:e.skillTargetPath,method:t,success:!1,error:o instanceof Error?o.message:String(o)}),Jl={"symlink-global":async e=>await ti(e.skill.path,e.skillTargetPath)?Nt(e,"symlink"):(await uo(e.skill.path,e.skillTargetPath),Nt(e,"copy",{symlinkFailed:!0})),"symlink-local":async e=>{let t=pe(e.projectRoot,fr,e.safeSkillName);return await uo(e.skill.path,t),await ti(t,e.skillTargetPath)?Nt(e,"symlink",{usedGlobalSymlink:!1}):(await uo(e.skill.path,e.skillTargetPath),Nt(e,"copy",{symlinkFailed:!0}))},"copy-global":async e=>(await uo(e.skill.path,e.skillTargetPath),Nt(e,"copy")),"copy-local":async e=>(await uo(e.skill.path,e.skillTargetPath),Nt(e,"copy"))},Ql=(e,t,o,r)=>r||po(e,t)||po(o,t)?null:"Security: Invalid skill destination path",Zl=async(e,t,o,r,i,s)=>{let l=Ne(t),d=Mr(e.name),c=pe(o,d),u={skill:e,config:l,safeSkillName:d,skillTargetPath:c,projectRoot:i},g=Ql(o,c,i,s);if(g)return oi(u,r,g);try{let f=ql(r,s);return await Jl[f](u)}catch(f){return oi(u,r,f)}},Ro=async(e,t)=>{let o=Oe(),r=[];for(let i of t.agents){let s=Ne(i),l=t.global?s.globalSkillsDir:pe(o,s.skillsDir);for(let d of e){let c=await Zl(d,i,l,t.method,o,t.global);r.push(c),c.success&&await Ir(d.name,[i],{source:"local",contentHash:qn(d.name),method:t.method,global:t.global})}}return await kr({action:"install",skillName:e.map(i=>i.name).join(", "),agents:t.agents.map(i=>Ne(i).displayName),success:r.filter(i=>i.success).length,failed:r.filter(i=>!i.success).length,details:r.map(i=>({skill:i.skill,agent:i.agent,success:i.success,error:i.error,path:i.path}))}),r},_r=async(e,t)=>{let o=Ne(e),r=t?o.globalSkillsDir:pe(Oe(),o.skillsDir);try{return(await Hl(r,{withFileTypes:!0})).filter(s=>s.isDirectory()||s.isSymbolicLink()).map(s=>s.name)}catch{return[]}},ea=(e,t={})=>{let o=Mr(e),r=t.global?Vl():Oe(),i=pe(r,ei,o);if(!po(pe(r,ei),i))throw new Error("Invalid skill name: potential path traversal detected");return i},fo=async(e,t,o={})=>{let r=Mr(e),i=Oe(),s=await Do(e,!0);if(s||(s=await Do(e,!1)),!s&&!o.force)return t.map(c=>({skill:e,agent:Ne(c).displayName,success:!1,error:"Skill not found in lockfile"}));let l=ea(e,o);await Ft(l,{recursive:!0,force:!0}).catch(()=>{});let d=await Promise.all(t.map(async c=>{let u=Ne(c),g=pe(i,u.skillsDir,r),f=pe(u.globalSkillsDir,r),h=o.global===void 0?[g,f]:o.global?[f]:[g],m=!1,p;for(let w of h){let B=w.startsWith(u.globalSkillsDir)?u.globalSkillsDir:pe(i,u.skillsDir);if(!po(B,w)){p="Security: Invalid removal path";continue}if(!await zl(w,B)){p="Security: Symlink points outside allowed directory";continue}try{await Pr(w),await Ft(w,{recursive:!0,force:!0}),m=!0}catch(_){_.code!=="ENOENT"&&!p&&(p=_ instanceof Error?_.message:String(_))}}return{skill:e,agent:u.displayName,success:m,error:m?void 0:p||"Skill not found"}}));return d.some(c=>c.success)&&(await Io(e,!0).catch(()=>{}),await Io(e,!1).catch(()=>{})),await kr({action:"remove",skillName:e,agents:t.map(c=>Ne(c).displayName),success:d.filter(c=>c.success).length,failed:d.filter(c=>!c.success).length,forced:o.force,details:d.map(c=>({skill:c.skill,agent:c.agent,success:c.success,error:c.error}))}),d}});var hs={};Bt(hs,{runCliInstall:()=>au});import Me from"chalk";async function su(e,t){let o=await _t(),r=[];for(let i of e){let s=o.find(d=>d.name===i);if(!s){console.error(Me.red(`\u274C Skill "${i}" not found`));continue}let l=t?await co(i):await ht(i);l?r.push({...s,path:l}):console.error(Me.red(`\u274C Failed to download skill "${i}"`))}return r}function lu(e){let t=e.filter(r=>r.success),o=e.filter(r=>!r.success);t.length>0&&(console.log(Me.green(`
5
- \u2705 Successfully installed ${t.length} skill(s):`)),t.forEach(r=>{console.log(Me.dim(` \u2022 ${r.skill} \u2192 ${r.agent} (${r.method})`))})),o.length>0&&(console.log(Me.red(`
6
- \u274C Failed to install ${o.length} skill(s):`)),o.forEach(r=>{console.log(Me.dim(` \u2022 ${r.skill} \u2192 ${r.agent}: ${r.error}`))}))}async function au(e){(!e.skill||e.skill.length===0)&&(console.error(Me.red("\u274C --skill is required in CLI mode")),console.error(Me.dim("Usage: agent-skills install --skill <name1> [name2...] [--agent <agents...>] [--global] [--symlink]")),process.exit(1));let t=Array.isArray(e.skill)?e.skill:[e.skill];console.log(Me.blue(`\u23F3 Loading ${t.length} skill(s) from catalog...`));let o=await su(t,e.force||!1);o.length===0&&(console.error(Me.red("\u274C No skills were successfully downloaded")),process.exit(1));let r=e.agent||["cursor","claude-code","windsurf"],i=e.symlink?"symlink":"copy";console.log(Me.blue(`\u23F3 Installing ${o.length} skill(s) to ${r.length} agent(s)...`));let s={agents:r,skills:o.map(d=>d.name),method:i,global:e.global||!1},l=await Ro(o,s);lu(l),l.some(d=>!d.success)&&process.exit(1)}var xs=q(()=>{"use strict";$t();ze()});var ys={};Bt(ys,{runCliRemove:()=>cu});import Ve from"chalk";async function cu(e){(!e.skill||e.skill.length===0)&&(console.error(Ve.red("\u274C --skill is required in CLI mode")),console.error(Ve.dim("Usage: agent-skills remove --skill <name1> [name2...] [--agent <agents...>] [--global] [--force]")),process.exit(1));let t=Array.isArray(e.skill)?e.skill:[e.skill],o=e.agent||["cursor","claude-code","windsurf"];e.force&&console.log(Ve.yellow("\u26A0\uFE0F Force mode enabled - bypassing lockfile check")),console.log(Ve.blue(`\u23F3 Removing ${t.length} skill(s) from ${o.length} agent(s)...`));let r=0,i=0,s=!1;for(let l of t){let d=await fo(l,o,{global:e.global,force:e.force}),c=d.filter(g=>g.success),u=d.filter(g=>!g.success);c.length>0&&(console.log(Ve.green(`\u2705 ${l}: Removed from ${c.length} agent(s)`)),c.forEach(g=>console.log(Ve.dim(` \u2022 ${g.agent}`))),r+=c.length),u.length>0&&(console.log(Ve.red(`\u274C ${l}: Failed to remove from ${u.length} agent(s)`)),u.forEach(g=>console.log(Ve.dim(` \u2022 ${g.agent}: ${g.error}`))),i+=u.length,u.some(g=>g.error?.includes("lockfile"))&&(s=!0))}console.log(Ve.dim(`
2
+ var gl=Object.defineProperty;var R=(e,t)=>()=>(e&&(t=e(e=0)),t);var Mt=(e,t)=>{for(var o in t)gl(e,o,{get:t[o],enumerable:!0})};import{existsSync as Tn}from"node:fs";import{dirname as pl,join as wn,parse as fl,resolve as hl}from"node:path";function Ne(e=process.cwd()){let t=hl(e),o=fl(t).root;for(;t!==o;){if((Tn(wn(t,"package.json"))||Tn(wn(t,".git")))&&!t.endsWith("packages/cli"))return t;t=pl(t)}return e}var wo=R(()=>{"use strict"});import{existsSync as v,readdirSync as yl}from"node:fs";import{homedir as xl}from"node:os";import{join as S}from"node:path";function Ao(){return Object.entries(lo).filter(([,e])=>e.detectInstalled()).map(([e])=>e)}function Fe(e){return lo[e]}function In(){return Object.keys(lo).sort((e,t)=>lo[e].displayName.localeCompare(lo[t].displayName))}var D,z,lo,An,ao=R(()=>{"use strict";wo();D=xl(),z=Ne(),lo={cursor:{name:"cursor",displayName:"Cursor",description:"AI-first code editor built on VS Code",skillsDir:".cursor/skills",globalSkillsDir:S(D,".cursor/skills"),detectInstalled:()=>v(S(D,".cursor"))||v(S(z,".cursor"))},"claude-code":{name:"claude-code",displayName:"Claude Code",description:"Anthropic's agentic coding tool",skillsDir:".claude/skills",globalSkillsDir:S(D,".claude/skills"),detectInstalled:()=>v(S(D,".claude"))||v(S(z,".claude"))},"github-copilot":{name:"github-copilot",displayName:"GitHub Copilot",description:"AI pair programmer by GitHub/Microsoft",skillsDir:".github/skills",globalSkillsDir:S(D,".copilot/skills"),detectInstalled:()=>v(S(D,".copilot"))||v(S(z,".github"))},windsurf:{name:"windsurf",displayName:"Windsurf",description:"AI IDE with Cascade flow (Codeium)",skillsDir:".windsurf/skills",globalSkillsDir:S(D,".codeium/windsurf/skills"),detectInstalled:()=>v(S(D,".codeium/windsurf"))||v(S(z,".windsurf"))},cline:{name:"cline",displayName:"Cline",description:"Autonomous AI coding agent for VS Code",skillsDir:".cline/skills",globalSkillsDir:S(D,".cline/skills"),detectInstalled:()=>v(S(D,".cline"))||v(S(z,".cline"))||An("saoudrizwan","claude-dev")},aider:{name:"aider",displayName:"Aider",description:"AI pair programming in terminal",skillsDir:".aider/skills",globalSkillsDir:S(D,".aider/skills"),detectInstalled:()=>v(S(D,".aider"))||v(S(z,".aider"))},codex:{name:"codex",displayName:"OpenAI Codex",description:"OpenAI's coding agent",skillsDir:".codex/skills",globalSkillsDir:S(D,".codex/skills"),detectInstalled:()=>v(S(D,".codex"))||v(S(z,".codex"))},gemini:{name:"gemini",displayName:"Gemini CLI",description:"Google's AI coding assistant",skillsDir:".gemini/skills",globalSkillsDir:S(D,".gemini/skills"),detectInstalled:()=>v(S(D,".gemini"))||v(S(z,".gemini"))},antigravity:{name:"antigravity",displayName:"Antigravity",description:"Google's agentic coding (VS Code)",skillsDir:".agent/skills",globalSkillsDir:S(D,".gemini/antigravity/skills"),detectInstalled:()=>v(S(D,".gemini/antigravity"))||v(S(z,".agent"))},roo:{name:"roo",displayName:"Roo Code",description:"AI coding assistant for VS Code",skillsDir:".roo/skills",globalSkillsDir:S(D,".roo/skills"),detectInstalled:()=>v(S(D,".roo"))||v(S(z,".roo"))||An("RooVetGit","roo-cline")},kilocode:{name:"kilocode",displayName:"Kilo Code",description:"AI coding agent with auto-launch",skillsDir:".kilocode/skills",globalSkillsDir:S(D,".kilocode/skills"),detectInstalled:()=>v(S(D,".kilocode"))||v(S(z,".kilocode"))},trae:{name:"trae",displayName:"TRAE",description:"AI IDE with SOLO mode and custom agents",skillsDir:".trae/skills",globalSkillsDir:S(D,".trae/skills"),detectInstalled:()=>v(S(D,".trae"))||v(S(z,".trae"))},kiro:{name:"kiro",displayName:"Kiro",description:"AI Agent with workspace and global skill scopes",skillsDir:".kiro/skills",globalSkillsDir:S(D,".kiro/skills"),detectInstalled:()=>v(S(D,".kiro"))||v(S(z,".kiro"))},"amazon-q":{name:"amazon-q",displayName:"Amazon Q",description:"AWS AI coding assistant",skillsDir:".amazonq/skills",globalSkillsDir:S(D,".amazonq/skills"),detectInstalled:()=>v(S(D,".amazonq"))||v(S(z,".amazonq"))},augment:{name:"augment",displayName:"Augment",description:"AI code assistant with context engine",skillsDir:".augment/skills",globalSkillsDir:S(D,".augment/skills"),detectInstalled:()=>v(S(D,".augment"))||v(S(z,".augment"))},tabnine:{name:"tabnine",displayName:"Tabnine",description:"AI code completions with privacy focus",skillsDir:".tabnine/skills",globalSkillsDir:S(D,".tabnine/skills"),detectInstalled:()=>v(S(D,".tabnine"))||v(S(z,".tabnine"))},opencode:{name:"opencode",displayName:"OpenCode",description:"Open-source AI coding terminal",skillsDir:".opencode/skills",globalSkillsDir:S(D,".config/opencode/skills"),detectInstalled:()=>v(S(D,".config/opencode"))||v(S(z,".opencode"))||v(S(z,".config/opencode"))},sourcegraph:{name:"sourcegraph",displayName:"Sourcegraph Cody",description:"AI assistant with codebase context",skillsDir:".sourcegraph/skills",globalSkillsDir:S(D,".sourcegraph/skills"),detectInstalled:()=>v(S(D,".sourcegraph"))||v(S(z,".sourcegraph"))},droid:{name:"droid",displayName:"Droid (Factory.ai)",description:"AI software engineer by Factory.ai",skillsDir:".factory/skills",globalSkillsDir:S(D,".factory/skills"),detectInstalled:()=>v(S(D,".factory"))||v(S(z,".factory"))}};An=(e,t)=>{let o=[S(D,".vscode/extensions"),S(D,".vscode-server/extensions"),S(D,".vscode-oss/extensions")];for(let r of o)if(v(r))try{if(yl(r).some(s=>s.startsWith(`${e}.${t}-`)))return!0}catch{}return!1}});var _t,Io,xr,En,kr,ft,Sr,br,Cr,Tr,vn,Pn,Bn,Ln,Rn,We,ve=R(()=>{"use strict";_t="@tech-leads-club/agent-skills",Io="@tech-leads-club/skills-catalog",xr=".agent-skills",En="cache.json",kr=".skill-meta.json",ft=".agents",Sr="skills",br=".skill-lock.json",Cr=".skill-lock.json.backup",Tr=".agent-skills",vn="audit.log",Pn=".cache",Bn="agent-skills",Ln="skills",Rn="registry.json",We={UPDATE_AVAILABLE:(e,t)=>`Update available: ${e} \u2192 ${t}`,TIP_INSTALL_UPDATE:"Tip: Install globally to update:",TIP_INSTALL_ACCESS:"Tip: Install globally for easier access:",UPDATE_COMMAND:`npm update -g ${_t}`,INSTALL_COMMAND:`npm install -g ${_t}`,DESCRIPTION:"Curated skills to power up your coding agents"}});import{appendFile as Tl,mkdir as wl,readFile as Al}from"node:fs/promises";import{homedir as wr}from"node:os";import{join as _n}from"node:path";function Do(e=wr()){return _n(e,Tr,vn)}async function Ar(e,t=wr()){try{let o=Do(t),r=_n(t,Tr);await wl(r,{recursive:!0});let i=JSON.stringify({...e,timestamp:new Date().toISOString()})+`
3
+ `;await Tl(o,i,"utf-8")}catch{}}async function On(e,t=wr()){try{let o=Do(t),s=(await Al(o,"utf-8")).trim().split(`
4
+ `).filter(Boolean).map(l=>{try{return JSON.parse(l)}catch{return null}}).filter(l=>l!==null).reverse();return e?s.slice(0,e):s}catch{return[]}}var Ir=R(()=>{"use strict";ve()});import{execSync as Il}from"node:child_process";import{existsSync as Dl}from"node:fs";import{join as El}from"node:path";function vl(){try{return Il("npm root -g",{encoding:"utf-8"}).trim()}catch{return null}}function Dr(){let e=vl();if(!e)return!1;let t=El(e,_t);return Dl(t)}var Er=R(()=>{"use strict";ve()});var ht,yt,Eo,vo,Tu,xt=R(()=>{"use strict";ht="uncategorized",yt=/^\(([a-z][a-z0-9-]*)\)$/,Eo="_category.json",vo={id:ht,name:"Uncategorized",description:"Skills without a specific category",priority:999},Tu=1440*60*1e3});var Nn=R(()=>{"use strict"});var Fn=R(()=>{"use strict"});var Un=R(()=>{"use strict"});var $n=R(()=>{"use strict"});var Gn=R(()=>{"use strict"});var Hn=R(()=>{"use strict"});var jn=R(()=>{"use strict";Nn();Fn();Un();$n();Gn();Hn()});var Po,vr=R(()=>{"use strict";Po=["cursor","claude-code","github-copilot","windsurf","cline","aider","codex","gemini","antigravity","roo","kilocode","amazon-q","augment","tabnine","opencode","sourcegraph","droid","trae","kiro"]});function Ot(e){return e.split("-").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}var Pr=R(()=>{"use strict";xt()});var co=R(()=>{"use strict"});var Vn=R(()=>{"use strict";co()});var Xn=R(()=>{"use strict";xt()});var Yn=R(()=>{"use strict";xt();Pr();co()});var zn=R(()=>{"use strict";xt()});import{z as de}from"zod";var Pl,Bl,ng,Wn=R(()=>{"use strict";xt();vr();co();Pl=de.enum(Po),Bl=de.object({name:de.string(),source:de.string(),contentHash:de.string().optional(),installedAt:de.string(),updatedAt:de.string(),agents:de.array(Pl).optional(),method:de.enum(["copy","symlink"]).optional(),global:de.boolean().optional(),version:de.string().optional()}),ng=de.object({version:de.number(),skills:de.record(de.string(),Bl)})});function Ll(e){if(!e.startsWith("---"))return e;let t=0;for(;t<e.length;){let o=e.indexOf(`
5
+ `,t),r=o===-1?e.length:o,i=e[r-1]==="\r"?r-1:r,s=e.slice(t,i);if(t===0){if(s!=="---")return e}else if(s==="---")return e.slice(o===-1?e.length:o+1).trimStart();if(o===-1)return e;t=o+1}return e}function qn(e){let o=Ll(e).split(`
6
+ `),r=[],i=0;for(;i<o.length;){let s=o[i];if(s.startsWith("```")){let c=s.slice(3).trim(),m=[];for(i++;i<o.length&&!o[i].startsWith("```");)m.push(o[i]),i++;r.push({type:"code-block",language:c,lines:m}),i++;continue}if(s.trim()===""){r.push({type:"blank"}),i++;continue}if(/^(-{3,}|_{3,}|\*{3,})$/.test(s.trim())){r.push({type:"hr"}),i++;continue}let l=s.match(/^(#{1,3})\s+(.+)$/);if(l){r.push({type:"heading",level:l[1].length,text:l[2]}),i++;continue}let d=s.match(/^(\s*)([-*]|\d+\.)\s+(.+)$/);if(d){let c=Math.floor(d[1].length/2);r.push({type:"list-item",text:d[3],indent:c}),i++;continue}r.push({type:"paragraph",text:s}),i++}return r}var Jn=R(()=>{"use strict"});var Qn=R(()=>{"use strict";Vn();Xn();Yn();zn();Wn();Jn();co()});var mo=R(()=>{"use strict";xt();jn();vr();Pr();Qn()});var ii={};Mt(ii,{addSkillToLock:()=>Lr,getAllLockedSkills:()=>Hl,getSkillFromLock:()=>Ro,readSkillLock:()=>uo,removeSkillFromLock:()=>Lo,writeSkillLock:()=>Br});import{mkdir as Rl,readFile as ei,rename as Ml,unlink as _l,writeFile as Zn}from"node:fs/promises";import{homedir as ti}from"node:os";import{dirname as Ol,join as Bo}from"node:path";import{z as me}from"zod";function ri(e){if(e)return Bo(ti(),ft,br);let t=Ne();return Bo(t,ft,br)}function $l(e){if(e)return Bo(ti(),ft,Cr);let t=Ne();return Bo(t,ft,Cr)}function ni(){return{version:oi,skills:{}}}function Gl(e){try{let t=Ul.parse(e);return t.version===1?{version:oi,skills:Object.fromEntries(Object.entries(t.skills).map(([o,r])=>[o,{...r,agents:r.agents||[],method:r.method||"copy",global:r.global??!1}]))}:t}catch{return ni()}}async function uo(e=!1){let t=ri(e);try{let o=await ei(t,"utf-8"),r=JSON.parse(o);return Gl(r)}catch{return ni()}}async function Br(e,t=!1){let o=ri(t),r=$l(t),i=`${o}.tmp`;try{try{let s=await ei(o,"utf-8");await Zn(r,s,"utf-8")}catch{}await Rl(Ol(o),{recursive:!0}),await Zn(i,JSON.stringify(e,null,2),"utf-8"),await Ml(i,o)}catch(s){try{await _l(i)}catch{}throw s}}async function Lr(e,t,o={}){let r=await uo(o.global),i=new Date().toISOString(),s=r.skills[e];r.skills[e]={name:e,source:o.source||"local",contentHash:o.contentHash??s?.contentHash,installedAt:s?.installedAt??i,updatedAt:i,agents:t,method:o.method||"copy",global:o.global??!1,version:o.version},await Br(r,o.global)}async function Lo(e,t=!1){let o=await uo(t);return e in o.skills?(delete o.skills[e],await Br(o,t),!0):!1}async function Ro(e,t=!1){return(await uo(t)).skills[e]??null}async function Hl(e=!1){return(await uo(e)).skills}var oi,Nl,Fl,Ul,Rr=R(()=>{"use strict";mo();ve();wo();oi=2,Nl=me.enum(Po),Fl=me.object({name:me.string(),source:me.string(),contentHash:me.string().optional(),installedAt:me.string(),updatedAt:me.string(),agents:me.array(Nl).optional(),method:me.enum(["copy","symlink"]).optional(),global:me.boolean().optional(),version:me.string().optional()}),Ul=me.object({version:me.number(),skills:me.record(me.string(),Fl)})});import zl from"ky";import{existsSync as kt,mkdirSync as _o,readFileSync as ai,rmSync as Mr,writeFileSync as _r}from"node:fs";import{homedir as Wl}from"node:os";import{join as Ae}from"node:path";import ql from"package-json";function ci(){kt(we.cacheDir)||_o(we.cacheDir,{recursive:!0}),kt(we.skillsCacheDir)||_o(we.skillsCacheDir,{recursive:!0})}function Ql(e){return Date.now()-e<Nt.cacheTtlMs}function si(){if(!kt(we.registryCacheFile))return null;try{let e=ai(we.registryCacheFile,"utf-8");return JSON.parse(e)}catch{return null}}function Zl(e){let t={fetchedAt:Date.now(),registry:e};_r(we.registryCacheFile,JSON.stringify(t,null,2))}async function di(e,t){try{return await li.get(e)}catch(o){if(t)try{return await li.get(t)}catch{}throw o}}async function mi(){if(process.env.SKILLS_CDN_REF)return process.env.SKILLS_CDN_REF;if(Mo)return Mo;try{return Mo=(await ql(Io,{version:"latest"})).version,Mo}catch{return"latest"}}function ui(e){let t=`https://cdn.jsdelivr.net/npm/${Io}@${e}`,o=`https://unpkg.com/${Io}@${e}`;return{registry:`${t}/skills-registry.json`,fallbackRegistry:`${o}/skills-registry.json`,skillsBase:`${t}/skills`,fallbackSkillsBase:`${o}/skills`}}async function go(e=!1){ci();let t=await mi();if(!e){let o=si(),r=o&&t!=="latest"&&o.registry.version!==t;if(o&&Ql(o.fetchedAt)&&!r)return o.registry}try{let o=ui(t),i=await(await di(o.registry,o.fallbackRegistry)).json();return Zl(i),i}catch(o){let r=si();return r?r.registry:(console.error(`Failed to fetch registry: ${o instanceof Error?o.message:o}`),null)}}function ea(e){return Jl.reduce((t,o)=>t.replace(o,""),e).trim()}function ta(e,t){let o=Ae(e,".");return Ae(t,".").startsWith(o)}function lt(e){let t=ea(e);if(!t)throw new Error("Invalid skill name");return Ae(we.skillsCacheDir,t)}function Or(e){try{let t=lt(e);return kt(Ae(t,"SKILL.md"))}catch{return!1}}function oa(e,t){try{let o=Ae(lt(e),kr);_r(o,JSON.stringify(t,null,2))}catch{}}function gi(e){try{let t=Ae(lt(e),kr);return kt(t)?JSON.parse(ai(t,"utf-8")):null}catch{return null}}async function Nr(e){if(!Or(e))return!0;let t=await Ut(e);if(!t?.contentHash)return!1;let o=gi(e);return o?.contentHash?o.contentHash!==t.contentHash:!0}function pi(e){return gi(e)?.contentHash}async function Oo(e){let t=[],o=[];for(let r of e)await Nr(r)?t.push(r):o.push(r);return{toUpdate:t,upToDate:o}}async function ra(e,t,o){let r=Ae(o,t);if(!ta(o,r))return console.error(`Security: Skipping suspicious file path: ${t}`),!1;let i=Ae(r,"..");kt(i)||_o(i,{recursive:!0});let s=ui(await mi()),l=`${s.skillsBase}/${e.path}/${t}`,d=`${s.fallbackSkillsBase}/${e.path}/${t}`,c=await di(l,d);if(!c.ok)throw new Error(`Failed to download ${t}: HTTP ${c.status}`);return _r(r,await c.text()),!0}async function na(e){let t=lt(e.name);ci(),kt(t)||_o(t,{recursive:!0});try{let o=[...e.files],r=0;for(let i=0;i<o.length;i+=Nt.maxConcurrentDownloads){let s=o.slice(i,i+Nt.maxConcurrentDownloads),l=await Promise.all(s.map(d=>ra(e,d,t)));r+=l.filter(Boolean).length}if(r<o.length)throw new Error(`Only ${r}/${o.length} files downloaded successfully`);return e.contentHash&&oa(e.name,{contentHash:e.contentHash,downloadedAt:Date.now()}),t}catch(o){return console.error(`Failed to download skill ${e.name}: ${o instanceof Error?o.message:o}`),null}}async function Ft(){let e=await go();return e?e.skills.map(t=>({name:t.name,description:t.description,path:Or(t.name)?lt(t.name):"",category:t.category})):[]}async function Ut(e){return(await go())?.skills.find(o=>o.name===e)??null}async function ia(){return(await go())?.deprecated??[]}async function No(){let e=await ia();return new Map(e.map(t=>[t.name,t]))}async function St(e){if(Or(e))return lt(e);let t=await Ut(e);return t?na(t):null}function fi(){try{Mr(we.cacheDir,{recursive:!0,force:!0})}catch{}}function sa(e){try{Mr(Ae(we.skillsCacheDir,e),{recursive:!0,force:!0})}catch{}}function hi(){try{Mr(we.registryCacheFile,{force:!0})}catch{}}async function po(e){return sa(e),St(e)}function Fr(){return we.cacheDir}var Nt,we,Jl,li,Mo,qe=R(()=>{"use strict";ve();Nt={cacheTtlMs:864e5,fetchTimeoutMs:15e3,maxRetries:3,retryBaseDelayMs:500,maxConcurrentDownloads:10},we={cacheDir:Ae(Wl(),Pn,Bn),get registryCacheFile(){return Ae(this.cacheDir,Rn)},get skillsCacheDir(){return Ae(this.cacheDir,Ln)}},Jl=[/[/\\]/g,/\.\./g,/[<>:"|?*]/g];li=zl.create({timeout:Nt.fetchTimeoutMs,retry:{limit:Nt.maxRetries,methods:["get"],statusCodes:[408,429,500,502,503,504],backoffLimit:1e4,delay:e=>Nt.retryBaseDelayMs*Math.pow(2,e-1),jitter:!0,retryOnTimeout:!0}});Mo=null});import{cp as la,lstat as Ur,mkdir as bi,readdir as aa,readlink as Ci,rm as Gt,symlink as ca}from"node:fs/promises";import{homedir as da,platform as ma}from"node:os";import{join as pe,normalize as yi,relative as ua,resolve as ho,sep as ga}from"node:path";var xi,$r,yo,ki,pa,fa,fo,ha,$t,Si,ya,xa,ka,Fo,Gr,Sa,xo,Ht=R(()=>{"use strict";ve();ao();Ir();Er();Rr();wo();qe();xi=pe(ft,Sr),$r=e=>(e.replace(/[/\\]/g,"").replace(/[\0:*?"<>|]/g,"").replace(/^[.\s]+|[.\s]+$/g,"").replace(/\.{2,}/g,"").replace(/^\.+/,"")||"unnamed-skill").substring(0,255),yo=(e,t)=>{let o=yi(ho(e)),r=yi(ho(t));return r.startsWith(o+ga)||r===o},ki=async(e,t)=>{try{await pa(t,e),await bi(pe(t,".."),{recursive:!0});let o=ua(pe(t,".."),e),r=ma()==="win32"?"junction":void 0;return await ca(o,t,r),!0}catch{return!1}},pa=async(e,t)=>{try{if((await Ur(e)).isSymbolicLink()){let r=await Ci(e);if(ho(r)===ho(t))return;await Gt(e)}else await Gt(e,{recursive:!0})}catch(o){o?.code==="ELOOP"&&await Gt(e,{force:!0}).catch(()=>{})}},fa=async(e,t)=>{try{if((await Ur(e)).isSymbolicLink()){let r=await Ci(e),i=ho(pe(e,".."),r);return yo(t,i)}return!0}catch{return!0}},fo=async(e,t)=>{await Gt(t,{recursive:!0,force:!0}),await bi(pe(t,".."),{recursive:!0}),await la(e,t,{recursive:!0})},ha=(e,t)=>`${e}-${t?"global":"local"}`,$t=(e,t,o={})=>({agent:e.config.displayName,skill:e.skill.name,path:e.skillTargetPath,method:t,success:!0,...o}),Si=(e,t,o)=>({agent:e.config.displayName,skill:e.skill.name,path:e.skillTargetPath,method:t,success:!1,error:o instanceof Error?o.message:String(o)}),ya={"symlink-global":async e=>await ki(e.skill.path,e.skillTargetPath)?$t(e,"symlink"):(await fo(e.skill.path,e.skillTargetPath),$t(e,"copy",{symlinkFailed:!0})),"symlink-local":async e=>{let t=pe(e.projectRoot,Sr,e.safeSkillName);return await fo(e.skill.path,t),await ki(t,e.skillTargetPath)?$t(e,"symlink",{usedGlobalSymlink:!1}):(await fo(e.skill.path,e.skillTargetPath),$t(e,"copy",{symlinkFailed:!0}))},"copy-global":async e=>(await fo(e.skill.path,e.skillTargetPath),$t(e,"copy")),"copy-local":async e=>(await fo(e.skill.path,e.skillTargetPath),$t(e,"copy"))},xa=(e,t,o,r)=>r||yo(e,t)||yo(o,t)?null:"Security: Invalid skill destination path",ka=async(e,t,o,r,i,s)=>{let l=Fe(t),d=$r(e.name),c=pe(o,d),m={skill:e,config:l,safeSkillName:d,skillTargetPath:c,projectRoot:i},f=xa(o,c,i,s);if(f)return Si(m,r,f);try{let p=ha(r,s);return await ya[p](m)}catch(p){return Si(m,r,p)}},Fo=async(e,t)=>{let o=Ne(),r=[];for(let i of t.agents){let s=Fe(i),l=t.global?s.globalSkillsDir:pe(o,s.skillsDir);for(let d of e){let c=await ka(d,i,l,t.method,o,t.global);r.push(c),c.success&&await Lr(d.name,[i],{source:"local",contentHash:pi(d.name),method:t.method,global:t.global})}}return await Ar({action:"install",skillName:e.map(i=>i.name).join(", "),agents:t.agents.map(i=>Fe(i).displayName),success:r.filter(i=>i.success).length,failed:r.filter(i=>!i.success).length,details:r.map(i=>({skill:i.skill,agent:i.agent,success:i.success,error:i.error,path:i.path}))}),r},Gr=async(e,t)=>{let o=Fe(e),r=t?o.globalSkillsDir:pe(Ne(),o.skillsDir);try{return(await aa(r,{withFileTypes:!0})).filter(s=>s.isDirectory()||s.isSymbolicLink()).map(s=>s.name)}catch{return[]}},Sa=(e,t={})=>{let o=$r(e),r=t.global?da():Ne(),i=pe(r,xi,o);if(!yo(pe(r,xi),i))throw new Error("Invalid skill name: potential path traversal detected");return i},xo=async(e,t,o={})=>{let r=$r(e),i=Ne(),s=await Ro(e,!0);if(s||(s=await Ro(e,!1)),!s&&!o.force)return t.map(c=>({skill:e,agent:Fe(c).displayName,success:!1,error:"Skill not found in lockfile"}));let l=Sa(e,o);await Gt(l,{recursive:!0,force:!0}).catch(()=>{});let d=await Promise.all(t.map(async c=>{let m=Fe(c),f=pe(i,m.skillsDir,r),p=pe(m.globalSkillsDir,r),h=o.global===void 0?[f,p]:o.global?[p]:[f],u=!1,g;for(let T of h){let P=T.startsWith(m.globalSkillsDir)?m.globalSkillsDir:pe(i,m.skillsDir);if(!yo(P,T)){g="Security: Invalid removal path";continue}if(!await fa(T,P)){g="Security: Symlink points outside allowed directory";continue}try{await Ur(T),await Gt(T,{recursive:!0,force:!0}),u=!0}catch(O){O.code!=="ENOENT"&&!g&&(g=O instanceof Error?O.message:String(O))}}return{skill:e,agent:m.displayName,success:u,error:u?void 0:g||"Skill not found"}}));return d.some(c=>c.success)&&(await Lo(e,!0).catch(()=>{}),await Lo(e,!1).catch(()=>{})),await Ar({action:"remove",skillName:e,agents:t.map(c=>Fe(c).displayName),success:d.filter(c=>c.success).length,failed:d.filter(c=>!c.success).length,forced:o.force,details:d.map(c=>({skill:c.skill,agent:c.agent,success:c.success,error:c.error}))}),d}});var Rs={};Mt(Rs,{runCliInstall:()=>Dm});import _e from"chalk";async function Am(e,t){let o=await Ft(),r=[];for(let i of e){let s=o.find(d=>d.name===i);if(!s){console.error(_e.red(`\u274C Skill "${i}" not found`));continue}let l=t?await po(i):await St(i);l?r.push({...s,path:l}):console.error(_e.red(`\u274C Failed to download skill "${i}"`))}return r}function Im(e){let t=e.filter(r=>r.success),o=e.filter(r=>!r.success);t.length>0&&(console.log(_e.green(`
7
+ \u2705 Successfully installed ${t.length} skill(s):`)),t.forEach(r=>{console.log(_e.dim(` \u2022 ${r.skill} \u2192 ${r.agent} (${r.method})`))})),o.length>0&&(console.log(_e.red(`
8
+ \u274C Failed to install ${o.length} skill(s):`)),o.forEach(r=>{console.log(_e.dim(` \u2022 ${r.skill} \u2192 ${r.agent}: ${r.error}`))}))}async function Dm(e){(!e.skill||e.skill.length===0)&&(console.error(_e.red("\u274C --skill is required in CLI mode")),console.error(_e.dim("Usage: agent-skills install --skill <name1> [name2...] [--agent <agents...>] [--global] [--symlink]")),process.exit(1));let t=Array.isArray(e.skill)?e.skill:[e.skill];console.log(_e.blue(`\u23F3 Loading ${t.length} skill(s) from catalog...`));let o=await Am(t,e.force||!1);o.length===0&&(console.error(_e.red("\u274C No skills were successfully downloaded")),process.exit(1));let r=e.agent||["cursor","claude-code","windsurf"],i=e.symlink?"symlink":"copy";console.log(_e.blue(`\u23F3 Installing ${o.length} skill(s) to ${r.length} agent(s)...`));let s={agents:r,skills:o.map(d=>d.name),method:i,global:e.global||!1},l=await Fo(o,s);Im(l),l.some(d=>!d.success)&&process.exit(1)}var Ms=R(()=>{"use strict";Ht();qe()});var _s={};Mt(_s,{runCliRemove:()=>Em});import Ve from"chalk";async function Em(e){(!e.skill||e.skill.length===0)&&(console.error(Ve.red("\u274C --skill is required in CLI mode")),console.error(Ve.dim("Usage: agent-skills remove --skill <name1> [name2...] [--agent <agents...>] [--global] [--force]")),process.exit(1));let t=Array.isArray(e.skill)?e.skill:[e.skill],o=e.agent||["cursor","claude-code","windsurf"];e.force&&console.log(Ve.yellow("\u26A0\uFE0F Force mode enabled - bypassing lockfile check")),console.log(Ve.blue(`\u23F3 Removing ${t.length} skill(s) from ${o.length} agent(s)...`));let r=0,i=0,s=!1;for(let l of t){let d=await xo(l,o,{global:e.global,force:e.force}),c=d.filter(f=>f.success),m=d.filter(f=>!f.success);c.length>0&&(console.log(Ve.green(`\u2705 ${l}: Removed from ${c.length} agent(s)`)),c.forEach(f=>console.log(Ve.dim(` \u2022 ${f.agent}`))),r+=c.length),m.length>0&&(console.log(Ve.red(`\u274C ${l}: Failed to remove from ${m.length} agent(s)`)),m.forEach(f=>console.log(Ve.dim(` \u2022 ${f.agent}: ${f.error}`))),i+=m.length,m.some(f=>f.error?.includes("lockfile"))&&(s=!0))}console.log(Ve.dim(`
7
9
  ${r} succeeded, ${i} failed`)),s&&!e.force&&console.log(Ve.yellow(`
8
- \u{1F4A1} Tip: Use --force to bypass lockfile check`)),i>0&&process.exit(1)}var ks=q(()=>{"use strict";$t()});var bs={};Bt(bs,{runCliUpdate:()=>du});import ce from"chalk";async function du(e){if(console.log(ce.blue("\u23F3 Fetching latest registry...")),await ao(!0),e.skill){if(!await Lr(e.skill)){console.log(ce.green(`\u2705 ${e.skill} is already up to date`));return}console.log(ce.blue(`\u23F3 Updating ${e.skill}...`)),await co(e.skill)?console.log(ce.green(`\u2705 Updated ${e.skill}`)):(console.error(ce.red(`\u274C Failed to update ${e.skill}`)),process.exit(1))}else{let{readSkillLock:t}=await Promise.resolve().then(()=>(Dr(),Gn)),o=await t(),r=Object.keys(o.skills);if(r.length===0){console.log(ce.yellow("No installed skills found. Run agent-skills install first."));return}let{toUpdate:i,upToDate:s}=await Bo(r);if(i.length===0){console.log(ce.green(`\u2705 All ${s.length} installed skills are up to date`));return}console.log(ce.blue(`\u23F3 Updating ${i.length} of ${r.length} skills...`));let l=0,d=0;for(let h of i)await co(h)?l++:(d++,console.error(ce.red(` \u274C Failed to update ${h}`)));console.log(ce.green(`\u2705 ${l} updated, ${s.length} already up to date${d>0?ce.red(`, ${d} failed`):""}`));let c=await Lo(),u=await _t(),g=new Set(u.map(h=>h.name)),f=r.filter(h=>c.has(h)||!g.has(h));if(f.length>0){console.log(""),console.log(ce.yellow(`\u26A0 ${f.length} deprecated skill${f.length>1?"s":""} detected:`));let h={withEntry:(m,p)=>{console.log(ce.yellow(` \u203A ${m} \u2014 ${p.message}`)),p.alternatives?.length&&console.log(ce.dim(` Try: agent-skills install --skill ${p.alternatives.join(", ")}`))},noEntry:m=>{console.log(ce.yellow(` \u203A ${m} \u2014 no longer available in the registry`))}};f.forEach(m=>{let p=c.get(m);h[p?"withEntry":"noEntry"](m,p)}),console.log(ce.dim(" Run: agent-skills remove --skill <name> to clean up"))}}}var Ss=q(()=>{"use strict";ze()});var Ts={};Bt(Ts,{runCliCache:()=>uu});import Et from"chalk";function uu(e){e.clear?(Jn(),console.log(Et.green("\u2705 Cache cleared"))):e.clearRegistry?(Qn(),console.log(Et.green("\u2705 Registry cache cleared"))):e.path?console.log(Rr()):(console.log(Et.bold("Cache management:")),console.log(` ${Et.blue("--clear")} Clear all cached skills and registry`),console.log(` ${Et.blue("--clear-registry")} Clear only the registry cache`),console.log(` ${Et.blue("--path")} Show cache directory path`),console.log(),console.log(Et.dim(`Cache location: ${Rr()}`)))}var ws=q(()=>{"use strict";ze()});import{Box as mt,Text as De}from"ink";import{Fragment as pu,jsx as pt,jsxs as be}from"react/jsx-runtime";function Cs({entries:e,limit:t=10}){let o=e.slice(0,t);return o.length===0?pt(mt,{flexDirection:"column",paddingY:1,children:pt(De,{dimColor:!0,children:"No audit log entries found"})}):be(mt,{flexDirection:"column",paddingY:1,children:[be(mt,{marginBottom:1,children:[pt(De,{bold:!0,color:"cyan",children:"\u{1F4CB} Audit Log"}),be(De,{dimColor:!0,children:[" (showing ",o.length," most recent)"]})]}),o.map((r,i)=>{let s=r.timestamp?new Date(r.timestamp):new Date,l=r.timestamp?mu(s):"unknown time",d=r.action==="install"?"green":r.action==="remove"?"red":"yellow",c=r.failed===0?"\u2713":r.success>0?"\u26A0":"\u2717";return be(mt,{flexDirection:"column",marginBottom:1,paddingLeft:2,children:[be(mt,{children:[be(De,{color:d,bold:!0,children:[c," ",r.action.toUpperCase()]}),be(De,{dimColor:!0,children:[" \u2022 ",l]})]}),be(mt,{paddingLeft:2,children:[pt(De,{children:"Skills: "}),pt(De,{color:"cyan",children:r.skillName})]}),be(mt,{paddingLeft:2,children:[pt(De,{children:"Agents: "}),pt(De,{dimColor:!0,children:r.agents.join(", ")})]}),be(mt,{paddingLeft:2,children:[be(De,{color:"green",children:["\u2713 ",r.success]}),r.failed>0&&be(pu,{children:[pt(De,{children:" \u2022 "}),be(De,{color:"red",children:["\u2717 ",r.failed]})]})]})]},i)})]})}function mu(e){let t=Math.floor((Date.now()-e.getTime())/1e3);return t<60?"just now":t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:t<604800?`${Math.floor(t/86400)}d ago`:e.toLocaleDateString()}var As=q(()=>{"use strict"});var Is={};Bt(Is,{runCliAudit:()=>hu});import{render as fu}from"ink";import gu from"react";async function hu(e){if(e.path){console.log(wo());return}let t=e.limit?parseInt(e.limit,10):10,o=await Bn(t);fu(gu.createElement(Cs,{entries:o,limit:t}))}var Ds=q(()=>{"use strict";As();br()});import{Command as xu}from"commander";import{render as eo}from"ink";import to from"react";import{Box as cn,useApp as ou}from"ink";import{useEffect as ru,useState as nu}from"react";io();import{useEffect as ol,useMemo as rl,useState as ur}from"react";function Sn(){let[e,t]=ur([]),[o,r]=ur([]),[i,s]=ur(!0),l=rl(()=>bn(),[]);return ol(()=>{let c=setTimeout(()=>{let u=So();r(u),t(u),s(!1)},800);return()=>clearTimeout(c)},[]),{allAgents:l,installedAgents:o,selectedAgents:e,setSelectedAgents:t,toggleAgent:c=>{t(u=>u.includes(c)?u.filter(g=>g!==c):[...u,c])},loading:i}}import{useEffect as Hu,useState as ju}from"react";Ee();import{useMemo as nl,useState as il}from"react";function En(e,t){let[o,r]=il(""),i=nl(()=>{if(!o.trim())return e;let s=o.toLowerCase().split(/\s+/).filter(l=>l.length>0);return e.filter(l=>{let d=t.keys.map(c=>{let u=l[c];return typeof u=="string"?u.toLowerCase():""}).join(" ");return s.every(c=>d.includes(c))})},[o,e,t.keys]);return{query:o,setQuery:r,filtered:i,hasFilter:o.trim().length>0}}$t();import{useState as Mo}from"react";Co();import{existsSync as Nr,readdirSync as li,readFileSync as la}from"node:fs";import{join as Po}from"node:path";import{existsSync as ta}from"node:fs";import{dirname as oa,join as ii}from"node:path";import{fileURLToPath as ra}from"node:url";var na=ra(import.meta.url),ia=oa(na);function Or(){return ii(sa(),"packages","skills-catalog","skills")}function si(){let e=Or();return ta(e)?e:null}function sa(){return ii(ia,"..","..","..","..")}ze();var lt={mode:null,localDir:null};function aa(e){return Pt.test(e)}function ca(e){return e.match(Pt)?.[1]??null}function da(e){let t=e.match(/^---\n([\s\S]*?)\n---/);if(!t)return{};let o=t[1],r=o.match(/^name:\s*(.+)$/m),i=o.match(/^description:\s*(.+)$/m);return{name:r?.[1]?.trim(),description:i?.[1]?.trim()}}function ai(e,t){let o=Po(e,"SKILL.md");if(!Nr(o))return null;let r=la(o,"utf-8"),{name:i,description:s}=da(r),l=e.split("/").pop()??"";return{name:i??l,description:s??"No description",path:e,category:t}}function ua(e,t){return Nr(e)?li(e,{withFileTypes:!0}).filter(o=>o.isDirectory()).map(o=>ai(Po(e,o.name),t)).filter(o=>o!==null):[]}function ci(e){return Nr(e)?li(e,{withFileTypes:!0}).filter(o=>o.isDirectory()).flatMap(o=>{if(aa(o.name)){let i=ca(o.name);return i?ua(Po(e,o.name),i):[]}let r=ai(Po(e,o.name),Rt);return r?[r]:[]}):[]}function ma(){if(lt.mode)return lt.mode;let e=si();return e?(lt.localDir=e,lt.mode="local","local"):(lt.mode="remote","remote")}function Fr(){return ma()==="local"&&lt.localDir!==null}function pa(){return Fr()?ci(lt.localDir):[]}async function di(){return Fr()?ci(lt.localDir):_t()}function fa(e){return pa().find(t=>t.name===e)}async function ui(e){if(Fr())return fa(e)??null;let t=await Ot(e);if(!t)return null;let o=await ht(e);return o?{name:t.name,description:t.description,path:o,category:t.category}:null}function _o(){let[e,t]=Mo({current:0,total:0,skill:""}),[o,r]=Mo([]),[i,s]=Mo(!1),[l,d]=Mo(null);return{install:async(u,g)=>{s(!0),d(null),t({current:0,total:u.length*g.agents.length,skill:"Downloading..."});let f=[];for(let h of u){let m=h.path?h:await ui(h.name);m&&f.push(m)}t({current:0,total:f.length*g.agents.length,skill:"Installing..."});try{let h=await Ro(f,g);return r(h),h}catch(h){return d(h instanceof Error?h.message:String(h)),[]}finally{s(!1)}},progress:e,results:o,installing:i,error:l}}import{useInput as ga}from"ink";import{useCallback as ha,useRef as xa,useState as ya}from"react";var Oo=["up","up","down","down","left","right","left","right","b","a"];function mi(){let[e,t]=ya(!1),o=xa([]);ga((i,s)=>{if(e)return;let l=null;if(s.upArrow?l="up":s.downArrow?l="down":s.leftArrow?l="left":s.rightArrow?l="right":i.toLowerCase()==="b"?l="b":i.toLowerCase()==="a"&&(l="a"),!l){o.current=[];return}o.current.push(l),o.current.length>Oo.length&&(o.current=o.current.slice(-Oo.length)),o.current.length===Oo.length&&o.current.every((d,c)=>d===Oo[c])&&(t(!0),o.current=[])});let r=ha(()=>{t(!1),o.current=[]},[]);return{activated:e,reset:r}}$t();import{useState as No}from"react";function pi(){let[e,t]=No({current:0,total:0,skill:""}),[o,r]=No([]),[i,s]=No(!1),[l,d]=No(null);return{remove:async(g,f,h=!1)=>{s(!0),t({current:0,total:f.length,skill:g}),d(null);try{let m=await fo(g,f,{global:h});return r(p=>[...p,...m]),m}catch(m){return d(m instanceof Error?m.message:String(m)),[]}finally{s(!1)}},removeMultiple:async g=>{s(!0);let f=g.reduce((h,m)=>h+m.agents.length,0);t({current:0,total:f,skill:"Initializing..."}),r([]),d(null);try{let h=0;for(let m of g){t({current:h,total:f,skill:m.name});let p=await fo(m.name,m.agents,{});r(w=>[...w,...p]),h+=m.agents.length}}catch(h){d(h instanceof Error?h.message:String(h))}finally{s(!1)}},progress:e,results:o,removing:i,error:l}}ze();import{readFileSync as ka}from"node:fs";import{join as ba}from"node:path";import{useEffect as Sa,useState as Fo}from"react";function fi(e){let[t,o]=Fo(null),[r,i]=Fo(null),[s,l]=Fo(!1),[d,c]=Fo(null);return Sa(()=>{if(!e){o(null),i(null),l(!1),c(null);return}let u=!0;return l(!0),c(null),(async()=>{try{let[f,h]=await Promise.all([Ot(e).catch(()=>null),ht(e).catch(()=>null)]);if(!u)return;f&&o(f);let m=h??st(e);try{let p=ka(ba(m,"SKILL.md"),"utf-8");i(p)}catch{c("Failed to load skill content")}}catch(f){u&&c(f instanceof Error?f.message:String(f))}finally{u&&l(!1)}})(),()=>{u=!1}},[e]),{metadata:t,content:r,loading:s,error:d}}import{useEffect as va,useState as Uo}from"react";Co();import{existsSync as gi,readdirSync as Ta,readFileSync as wa,writeFileSync as cp}from"node:fs";import{join as Ca}from"node:path";function hi(){return Or()}function Aa(){let e=hi(),t=Ca(e,wr);if(!gi(t))return{};try{let o=wa(t,"utf-8");return JSON.parse(o)}catch{return{}}}function Ia(e){let t=e.match(Pt);return t?t[1]:null}function Da(e){return Pt.test(e)}function Ea(){let e=hi();if(!gi(e))return[];let t=Aa(),o=Ta(e,{withFileTypes:!0}),r=[],i=0;for(let s of o){if(!s.isDirectory()||!Da(s.name))continue;let l=Ia(s.name);if(!l)continue;let d=t[s.name]??{};r.push({id:l,name:d.name??so(l),description:d.description,priority:d.priority??i}),i++}return r.sort((s,l)=>s.name.localeCompare(l.name)),r}function $o(e){let t=Ea();if(t.length===0){let s=new Set(e.map(l=>l.category).filter(Boolean));t=Array.from(s).map((l,d)=>({id:l,name:so(l),priority:d}))}let o=new Map;for(let s of t)o.set(s,[]);o.set(Cr,[]);for(let s of e){let l=s.category??Rt,d=t.find(g=>g.id===l);!d&&l!==Rt&&(d={id:l,name:so(l),priority:999},t.push(d),o.set(d,[]));let c=d??Cr,u=o.get(c)??[];u.push(s),o.set(c,u)}for(let[s,l]of o)l.length===0&&o.delete(s);let r=new Map,i=Array.from(o.keys()).sort((s,l)=>s.name.localeCompare(l.name));for(let s of i){let l=o.get(s);l&&(l.sort((d,c)=>d.name.localeCompare(c.name)),r.set(s,l))}return r}function at(){let[e,t]=Uo([]),[o,r]=Uo(!0),[i,s]=Uo(null),[l,d]=Uo(new Map);return va(()=>{let c=!0;return(async()=>{try{let g=await di();c&&(t(g),d($o(g)))}catch(g){c&&s(g instanceof Error?g.message:String(g))}finally{c&&r(!1)}})(),()=>{c=!1}},[]),{skills:e,loading:o,error:i,groupedSkills:l}}import{useState as Ba}from"react";function xi(e){let[t,o]=Ba(1);return{step:t,next:()=>o(l=>Math.min(l+1,e)),back:()=>o(l=>Math.max(l-1,1)),goTo:l=>o(l),isFirst:t===1,isLast:t===e,progress:t/e}}import{Box as yt,Text as jo}from"ink";import za from"ink-big-text";import Gr from"ink-gradient";import{useEffect as qa,useState as ki}from"react";import{Box as $r,Text as go}from"ink";import{memo as La}from"react";var n={primary:"#3b82f6",primaryLight:"#60a5fa",primaryDark:"#1e3a8a",accent:"#06b6d4",accentLight:"#22d3ee",success:"#22c55e",warning:"#f59e0b",error:"#ef4444",text:"#f8fafc",textDim:"#94a3b8",textMuted:"#64748b",border:"#334155",bg:"#0f172a",bgLight:"#1e293b"};var a={bar:"\u2502",barEnd:"\u2514",radioActive:"\u25CF",radioInactive:"\u25CB",checkboxActive:"\u25FC",checkboxInactive:"\u25FB",diamond:"\u25C6",arrow:"\u203A",arrowRight:"\u2192",arrowUp:"\u2191",arrowDown:"\u2193",dot:"\xB7",bullet:"\u25B8",check:"\u2713",cross:"\u2717",star:"\u2605",sparkle:"\u2726",installed:"\u25CF",warning:"\u26A0",info:"\u2139"};import{jsx as Ho,jsxs as Go}from"react/jsx-runtime";var ct=La(function({hints:t,status:o}){return Ho($r,{marginTop:1,borderStyle:"round",borderColor:n.border,paddingX:1,children:Go($r,{justifyContent:"space-between",width:"100%",children:[Ho(go,{children:t.map((r,i)=>Go(go,{children:[i>0&&Go(go,{color:n.textDim,children:[" ",a.dot," "]}),Ho(go,{color:r.color??n.accent,bold:!0,children:r.key}),Go(go,{color:n.textDim,children:[" ",r.label]})]},r.key))}),o&&Ho($r,{children:o})]})})});import{Box as xt,Text as Fe,useInput as Ra}from"ink";import{useMemo as Pa,useState as yi}from"react";import{Fragment as Ma,jsx as qe,jsxs as Je}from"react/jsx-runtime";function Qe({items:e,onSelect:t,onCancel:o,initialIndex:r=0,itemLimit:i=10,hideFooter:s,footerRight:l}){let[d,c]=yi(r),[u,g]=yi(0);Ra((h,m)=>{m.upArrow&&(c(p=>Math.max(0,p-1)),d<=u&&g(p=>Math.max(0,p-1))),m.downArrow&&(c(p=>Math.min(e.length-1,p+1)),d>=u+i-1&&g(p=>Math.min(e.length-i,p+1))),m.return&&t(e[d].value),m.escape&&o&&o()});let f=Pa(()=>e.slice(u,u+i),[e,u,i]);return Je(xt,{flexDirection:"column",children:[f.map((h,m)=>{let p=m+u===d;return Je(xt,{backgroundColor:p?n.bgLight:void 0,paddingX:1,children:[qe(xt,{width:2,children:qe(Fe,{color:p?n.accent:n.textMuted,children:p?a.bullet:" "})}),Je(Fe,{color:p?n.accent:n.text,bold:p,children:[p?a.radioActive:a.radioInactive," ",h.label]}),p&&h.hint&&Je(Fe,{color:n.textDim,children:[" ",a.dot," ",h.hint]})]},`${h.label}-${m}`)}),e.length>i&&qe(xt,{marginTop:1,paddingX:1,children:Je(Fe,{color:n.textDim,children:[a.arrowUp,a.arrowDown," ",u+1,"-",Math.min(u+i,e.length)," of ",e.length]})}),!s&&qe(xt,{marginTop:1,borderStyle:"round",borderColor:n.border,paddingX:1,children:Je(xt,{justifyContent:"space-between",width:"100%",children:[Je(Fe,{children:[qe(Fe,{color:n.success,bold:!0,children:"enter"}),qe(Fe,{color:n.textDim,children:" select"}),o&&Je(Ma,{children:[Je(Fe,{color:n.textDim,children:[" ",a.dot," "]}),qe(Fe,{color:n.warning,bold:!0,children:"esc"}),qe(Fe,{color:n.textDim,children:" back"})]})]}),l&&qe(xt,{children:l})]})})]})}import{Box as Ze,Text as ve,useInput as _a,useStdout as Oa}from"ink";import{useCallback as Na,useEffect as Fa,useRef as $a,useState as Ua}from"react";import{jsx as ue,jsxs as ho}from"react/jsx-runtime";var Ga=100,et=16,Ha=50,ja=10,Va=30,Ka=5,Xa=["BANKRUPT. Your burn rate was too high.","DOWN ROUND. Valuation dropped to zero.","RUNWAY EXPIRED. Back to living with parents.","SERVER COSTS > REVENUE. You are cooked.","AUDIT FAILED. Too much tech debt."],Ya=["ACQUIRED BY BIG TECH. Golden handcuffs on.","SERIES B SECURED. Keep burning cash!","IPO SUCCESSFUL. Time to buy a yacht.","PROFITABLE? No, but the vibes are great."],Ut=[["AGI_SOON","100x_DEV","LOVABLE","HYPE"],["DEEPSEEK","GEMINI","GPT","V0_DEV"],["TAB_SPAM","NO_READ","TRUST_ME","YOLO"],["SLOP","SPAGHETTI","ANY_TYPE","BUG"]];function Wa(e){let t=[],r=Math.max(...Ut.flat().map(l=>l.length))+4,i=Ut[0].length*r,s=Math.floor((e-i)/2);for(let l=0;l<Ut.length;l++)for(let d=0;d<Ut[l].length;d++){let c=Ut[l][d];t.push({x:Math.max(0,s+d*r),y:1+l*2,label:c,width:c.length,alive:!0})}return t}function Ur({onExit:e}){let{stdout:t}=Oa(),o=t?.columns??80,r=Math.max(60,Math.min(o-4,Ga)),i=$a(""),[s,l]=Ua(()=>({player:{x:Math.floor(r/2),y:et-1},playerBullets:[],enemyBullets:[],invaders:Wa(r),score:0,lives:5,gameOver:!1,won:!1,invaderDirection:1,tickCount:0,flash:!1,glitch:!1,rateLimited:0}));if((s.gameOver||s.won)&&!i.current){let f=s.won?Ya:Xa;i.current=f[Math.floor(Math.random()*f.length)]}_a((f,h)=>{if(s.gameOver||s.won){(h.return||h.escape)&&e();return}if(h.escape){e();return}l(m=>{let p=m.player.x;h.leftArrow&&(p=Math.max(0,m.player.x-2)),h.rightArrow&&(p=Math.min(r-1,m.player.x+2));let w=m.playerBullets,B=m.rateLimited;return f===" "&&B===0&&(m.playerBullets.length>=2?(B=Va,w=[]):w=[...m.playerBullets,{x:p,y:m.player.y-1}]),{...m,player:{...m.player,x:p},playerBullets:w,rateLimited:B}})});let d=Na(()=>{l(f=>{if(f.gameOver||f.won)return f;let h=f.tickCount+1,m=f.score,p=f.lives,w=f.gameOver,B=!1,_=!1,F=f.rateLimited>0?f.rateLimited-1:0,k=f.invaders.filter(y=>y.alive),T=Ut.flat().length,A=k.length/T,S=Math.max(2,Math.floor(ja*A)+1),L=.02+.08*(1-A),O=f.playerBullets.map(y=>({...y,y:y.y-1})).filter(y=>y.y>=0),V=f.enemyBullets.map(y=>({...y,y:y.y+1})).filter(y=>y.y<et),I=f.invaders.map(y=>({...y}));for(let y of O)if(y.y!==-1){for(let E of I)if(E.alive&&y.y===E.y&&y.x>=E.x&&y.x<E.x+E.width){E.alive=!1,y.y=-1,m+=100,B=!0;break}}if(O=O.filter(y=>y.y!==-1),V.some(y=>y.x===f.player.x&&y.y===f.player.y)&&(p-=1,B=!0,_=!0,V=[],p<=0&&(w=!0)),I.every(y=>!y.alive))return{...f,won:!0,score:m+p*1e3,invaders:I};if(k.length>0){let y=k.filter(E=>{let Q=f.player.x>=E.x-1&&f.player.x<=E.x+E.width+1;return Math.random()<(Q?L*Ka:L)});if(y.length>0){let E=y[Math.floor(Math.random()*y.length)];V.push({x:E.x+Math.floor(E.width/2),y:E.y+1})}}let C=f.invaderDirection;if(h%S===0){let y=I.filter(Z=>Z.alive).map(Z=>Z.x),E=Math.min(...y);Math.max(...I.filter(Z=>Z.alive).map(Z=>Z.x+Z.width))>=r-2&&C===1&&(C=-1),E<=0&&C===-1&&(C=1),I.forEach(Z=>Z.alive&&(Z.x+=C))}return h%45===0&&(I.forEach(y=>y.alive&&(y.y+=1)),I.some(y=>y.alive&&y.y>=et-1)&&(w=!0)),{...f,playerBullets:O,enemyBullets:V,invaders:I,score:m,lives:p,gameOver:w,invaderDirection:C,tickCount:h,flash:B,glitch:_,rateLimited:F}})},[r]);Fa(()=>{let f=setInterval(d,Ha);return()=>clearInterval(f)},[d]);let c=()=>{let f=Array.from({length:et},()=>Array(r).fill(" "));s.invaders.forEach(p=>{if(p.alive)for(let w=0;w<p.width;w++)p.x+w<r&&p.y<et&&(f[p.y][p.x+w]=s.glitch?"?":p.label[w])}),s.playerBullets.forEach(p=>{p.x<r&&p.y<et&&(f[p.y][p.x]="$")}),s.enemyBullets.forEach(p=>{p.x<r&&p.y<et&&(f[p.y][p.x]="*")});let{x:h,y:m}=s.player;return h<r&&m<et&&(f[m][h]=s.rateLimited>0?"X":"^"),f.map(p=>p.join("")).join(`
9
- `)},u=s.rateLimited>0?n.error:n.accent,g=s.glitch?n.warning:s.flash?n.error:n.success;return ue(Ze,{width:"100%",alignItems:"center",flexDirection:"column",children:ho(Ze,{width:r+4,flexDirection:"column",alignItems:"center",children:[ho(Ze,{width:r,flexDirection:"row",paddingX:1,children:[ue(Ze,{width:"35%",children:ue(ve,{color:u,bold:!0,children:s.rateLimited>0?`LIMIT (${s.rateLimited})`:`$${s.score}k`})}),ue(Ze,{width:"30%",justifyContent:"center",children:ue(ve,{color:n.warning,bold:!0,children:"VIBE INVADERS"})}),ue(Ze,{width:"35%",justifyContent:"flex-end",children:ho(ve,{color:n.success,bold:!0,children:["RUNWAY: ","$".repeat(s.lives)]})})]}),ue(Ze,{borderStyle:"round",borderColor:s.rateLimited>0?n.error:n.border,flexDirection:"column",width:r+2,height:et+2,children:ue(ve,{color:s.gameOver?n.error:g,children:c()})}),ue(Ze,{marginTop:0,width:r+2,justifyContent:"center",borderStyle:"round",borderColor:n.accent,children:s.gameOver||s.won?ho(ve,{color:s.won?n.success:n.error,bold:!0,children:[i.current," Val: $",s.score,"k"]}):ho(Ze,{gap:1,children:[ue(ve,{color:n.accent,children:"\u2190\u2192"}),ue(ve,{children:" move "}),ue(ve,{color:n.accent,children:"spc"}),ue(ve,{children:" shoot "}),ue(ve,{color:n.accent,children:"esc"}),ue(ve,{children:" quit"})]})})]})})}import{jsx as me,jsxs as Hr}from"react/jsx-runtime";var Ja=[{label:"Vibe Invaders",value:"invaders",hint:"Fight vibe-coding!"},{label:"Back",value:"back",hint:"Return to CLI"}],bi="\u2591".repeat(56);function jr({onExit:e}){let[t,o]=ki("menu"),[r,i]=ki(!0);qa(()=>{let l=setInterval(()=>i(d=>!d),600);return()=>clearInterval(l)},[]);let s=l=>{if(l==="back"){e();return}o(l)};return t==="invaders"?me(Ur,{onExit:()=>o("menu")}):Hr(yt,{flexDirection:"column",alignItems:"center",children:[me(yt,{marginBottom:0,children:me(Gr,{name:"cristal",children:me(jo,{children:bi})})}),me(yt,{marginBottom:0,children:me(Gr,{name:"pastel",children:me(za,{text:"ARCADE",font:"chrome"})})}),me(yt,{marginBottom:0,children:me(Gr,{name:"cristal",children:me(jo,{children:bi})})}),me(yt,{marginBottom:1,marginTop:1,children:Hr(jo,{color:r?n.warning:n.bg,bold:!0,children:[a.sparkle," SECRET UNLOCKED ",a.sparkle]})}),me(yt,{marginBottom:1,children:Hr(jo,{color:n.textDim,children:[a.diamond," Choose your adventure ",a.diamond]})}),me(yt,{width:50,children:me(Qe,{items:Ja,onSelect:s,onCancel:e,hideFooter:!0})}),me(ct,{hints:[{key:"\u2191\u2193",label:"navigate"},{key:"\u23CE",label:"select"},{key:"esc",label:"back",color:n.warning}]})]})}import{Box as vi,Text as Ko,useInput as Tc}from"ink";import{Box as tt,Text as Ae}from"ink";import Di from"ink-big-text";import Kr from"ink-gradient";import{useAtomValue as kc}from"jotai";import{useMemo as bc}from"react";Tr();import{atom as fc}from"jotai";import{unwrap as gc}from"jotai/utils";Ee();import{mkdir as Qa,readFile as Za,writeFile as ec}from"node:fs/promises";import{homedir as tc}from"node:os";import{dirname as oc,join as rc}from"node:path";function Si(){return rc(tc(),mr,Tn)}function nc(e){if(typeof e!="object"||e===null)return null;let t=e;return typeof t.lastUpdateCheck!="number"?null:{lastUpdateCheck:t.lastUpdateCheck,latestVersion:t.latestVersion??null}}async function Ti(){let e=Si();try{let t=await Za(e,"utf-8"),o=JSON.parse(t);return nc(o)}catch{return null}}async function wi(e){let t=Si(),o={lastUpdateCheck:Date.now(),latestVersion:e};await Qa(oc(t),{recursive:!0}),await ec(t,JSON.stringify(o,null,2),"utf-8")}Ee();import uc from"package-json";import{createRequire as ic}from"node:module";import{dirname as sc,join as lc}from"node:path";import{fileURLToPath as ac}from"node:url";var cc=ac(import.meta.url),dc=sc(cc),Ci=ic(import.meta.url),Vo;try{Vo=Ci("./package.json")}catch{Vo=Ci(lc(dc,"../../package.json"))}var Gt=Vo.version||"0.0.0",kf=Vo.description||"CLI to install and manage skills for AI coding agents";async function Ai(e){try{if(mc(e))return null;let t=await uc(Lt,{version:"latest"});return t.version!==e?t.version:null}catch{return null}}function mc(e){return/-(alpha|beta|rc|snapshot|dev|canary|next)/i.test(e)}function Vr(){return Gt}Ee();async function hc(e){let t=await Ti(),o=t&&t.latestVersion!==e?t.latestVersion:null;try{let r=await Promise.race([Ai(e),new Promise((i,s)=>setTimeout(()=>s(new Error("timeout")),3e3))]);return wi(r??e).catch(()=>{}),r}catch{return o}}var xc=async()=>{let e=Vr(),[t,o]=await Promise.all([hc(e).catch(()=>null),Promise.resolve(Sr()).catch(()=>!1)]);return{updateAvailable:t,currentVersion:e,isGlobal:o,isLoading:!1}},yc=fc(xc()),Ii=gc(yc,e=>e??{updateAvailable:null,currentVersion:Vr(),isGlobal:!1,isLoading:!0});Ee();import{jsx as te,jsxs as ot}from"react/jsx-runtime";var Ei=["#1e3a8a","#3b82f6","#0ea5e9","#06b6d4","#22d3ee"],Sc="\u2500",P=({notification:e})=>{let t=kc(Ii),o=bc(()=>{if(e)return e;let{updateAvailable:r,currentVersion:i,isGlobal:s,isLoading:l}=t;return l?null:r&&!s?ot(tt,{flexDirection:"column",alignItems:"center",children:[ot(Ae,{color:"yellow",children:[a.warning," ",We.UPDATE_AVAILABLE(i,r)]}),ot(Ae,{color:"blue",children:[a.info," ",We.TIP_INSTALL_UPDATE," ",te(Ae,{bold:!0,children:We.INSTALL_COMMAND})]})]}):r?ot(Ae,{color:"yellow",children:[a.warning," ",We.UPDATE_AVAILABLE(i,r)," (run"," ",te(Ae,{bold:!0,children:We.UPDATE_COMMAND}),")"]}):s?null:ot(Ae,{color:"blue",children:[a.info," ",We.TIP_INSTALL_ACCESS," ",te(Ae,{bold:!0,children:We.INSTALL_COMMAND})]})},[e,t]);return ot(tt,{flexDirection:"column",paddingBottom:1,children:[ot(tt,{flexDirection:"column",alignItems:"center",marginBottom:1,children:[te(tt,{marginBottom:-1,children:te(Kr,{colors:["#1e3a8a","#3b82f6"],children:te(Di,{text:"TLC",font:"tiny"})})}),te(tt,{children:te(Kr,{colors:Ei,children:te(Di,{text:"AGENT SKILLS",font:"block"})})}),ot(tt,{marginTop:-1,alignItems:"center",children:[te(Ae,{color:"#334155",children:"\u2500\u2500\u2500\u2500\u2500\u2500 "}),ot(Ae,{color:"white",bold:!0,children:["VERSION ",Gt]}),te(Ae,{color:"#334155",children:" \u2500\u2500\u2500\u2500\u2500\u2500"})]}),te(tt,{marginTop:1,children:te(Ae,{color:"#64748b",italic:!0,children:We.DESCRIPTION})}),o&&te(tt,{marginTop:1,children:o})]}),te(tt,{marginTop:o?0:1,justifyContent:"center",children:te(Kr,{colors:Ei,children:te(Ae,{children:Sc.repeat(60)})})})]})};import{jsx as xo,jsxs as Xr}from"react/jsx-runtime";function Bi({onSelect:e,onBack:t,onCredits:o}){let r=[{label:"Install new skills",value:"install",hint:"browse and select skills to install"},{label:"Update existing skills",value:"update",hint:"check for content changes"},{label:"Remove installed skills",value:"remove",hint:"uninstall skills from agents"}];Tc(s=>{s==="c"&&o&&o()});let i=Xr(Ko,{children:[xo(Ko,{color:n.accent,bold:!0,children:"c"}),xo(Ko,{color:n.textDim,children:" credits"})]});return Xr(vi,{flexDirection:"column",paddingX:1,children:[xo(P,{}),xo(vi,{marginBottom:1,children:Xr(Ko,{bold:!0,color:n.primary,children:[a.diamond," What would you like to do?"]})}),xo(Qe,{items:r,onSelect:e,onCancel:t,footerRight:i})]})}import{Box as Kt,Text as Yr,useInput as Rc,useStdout as Pc}from"ink";import Mc from"ink-spinner";import{useState as _c}from"react";import{Box as Be,Text as Ht,useInput as Dc}from"ink";import{useEffect as Ec}from"react";import{useEffect as wc,useState as Cc}from"react";import{Fragment as Ac,jsx as Ic}from"react/jsx-runtime";var Li=({visible:e,duration:t=250,children:o})=>{let[r,i]=Cc(e?1:0);return wc(()=>{if(e&&r===1||!e&&r===0)return;let s=Date.now(),l=r,d=e?1:0,u=setInterval(()=>{let f=Date.now()-s,h=Math.min(f/t,1),m=l+(e?h:-h)*Math.abs(d-l),p=Math.max(0,Math.min(1,m));i(p),h>=1&&(clearInterval(u),i(d))},16);return()=>{clearInterval(u)}},[e,t]),!e&&r<=.05?null:Ic(Ac,{children:o})};import{jsx as oe,jsxs as Xo}from"react/jsx-runtime";var jt=({visible:e,onDismiss:t,shortcuts:o})=>{Dc(()=>{e&&t()},{isActive:e}),Ec(()=>{let u;return e&&(u=setTimeout(()=>{t()},8e3)),()=>{u&&clearTimeout(u)}},[e,t]);let r=Math.ceil(o.length/2),i=o.slice(0,r),s=o.slice(r),l=({label:u})=>oe(Be,{flexShrink:0,children:oe(Ht,{backgroundColor:n.bgLight,color:n.accent,bold:!0,children:` ${u} `})}),d=({entry:u})=>Xo(Be,{marginBottom:0,gap:1,children:[oe(Be,{width:10,justifyContent:"flex-end",flexShrink:0,children:oe(l,{label:u.key})}),oe(Ht,{color:n.textDim,children:u.description})]}),c="\u2500".repeat(48);return oe(Li,{visible:e,duration:200,children:Xo(Be,{borderStyle:"round",borderColor:n.border,backgroundColor:n.bg,paddingX:2,paddingY:1,flexDirection:"column",width:56,children:[oe(Be,{justifyContent:"center",marginBottom:1,children:Xo(Ht,{color:n.accent,bold:!0,children:[a.sparkle," Keyboard Shortcuts"]})}),oe(Be,{justifyContent:"center",children:oe(Ht,{color:n.border,children:c})}),Xo(Be,{marginTop:1,gap:2,children:[oe(Be,{flexDirection:"column",gap:1,flexGrow:1,children:i.map(u=>oe(d,{entry:u},u.key))}),oe(Be,{flexDirection:"column",gap:1,flexGrow:1,children:s.map(u=>oe(d,{entry:u},u.key))})]}),oe(Be,{justifyContent:"center",marginTop:1,children:oe(Ht,{color:n.border,children:c})}),oe(Be,{marginTop:1,justifyContent:"center",children:oe(Ht,{color:n.textMuted,children:"press any key to dismiss"})})]})})};import{Box as kt,Text as rt,useInput as vc}from"ink";import{useEffect as Bc,useRef as Lc,useState as Yo}from"react";import{jsx as Le,jsxs as bt}from"react/jsx-runtime";function Vt({items:e,onSubmit:t,onCancel:o,onChange:r,initialSelected:i=[],limit:s=10}){let[l,d]=Yo(i),[c,u]=Yo(0),[g,f]=Yo(0),[h,m]=Yo(!1),p=Lc(i);Bc(()=>{let k=p.current;(k.length!==i.length||k.some((A,S)=>A!==i[S]))&&(d(i),p.current=i)},[i]),vc((k,T)=>{if(k==="?"){m(L=>!L);return}if(h){m(!1);return}if(T.return){t(l);return}if(T.escape&&o){o();return}let A=c,S=g;if(T.upArrow?A=c>0?c-1:e.length-1:T.downArrow&&(A=c<e.length-1?c+1:0),A<S?S=A:A>=S+s&&(S=A-s+1),T.upArrow&&c===0?S=Math.max(0,e.length-s):T.downArrow&&c===e.length-1&&(S=0),A!==c&&(u(A),f(S)),k===" "){let L=e[c];if(l.includes(L.value)){let O=l.filter(V=>V!==L.value);d(O),r?.(O)}else{let O=[...l,L.value];d(O),r?.(O)}}if(k==="a"&&T.ctrl)if(l.length===e.length)d([]),r?.([]);else{let L=e.map(O=>O.value);d(L),r?.(L)}});let w=e.slice(g,g+s),B=g>0,_=e.length>g+s,F=[{key:"\u2191/\u2193",description:"Navigate"},{key:"space",description:"Toggle selection"},{key:"enter",description:"Confirm"},{key:"ctrl+a",description:"Select all / none"},...o?[{key:"esc",description:"Cancel"}]:[]];return h?Le(kt,{flexDirection:"column",flexGrow:1,alignItems:"center",justifyContent:"center",children:Le(jt,{visible:h,onDismiss:()=>m(!1),shortcuts:F})}):bt(kt,{flexDirection:"column",children:[B&&Le(kt,{justifyContent:"center",marginBottom:1,children:bt(rt,{color:n.textDim,children:[a.arrowUp," ",a.arrowUp," ",a.arrowUp]})}),w.map((k,T)=>{let A=T+g,S=A===c,L=l.includes(k.value),O=S?a.bullet:" ",V=L?n.success:n.accent,I=L?a.checkboxActive:a.checkboxInactive,C=L?n.success:n.textMuted,y=S?n.primary:L?n.primaryLight:n.text;return bt(kt,{backgroundColor:S?n.bgLight:void 0,paddingX:1,children:[Le(kt,{width:2,children:Le(rt,{color:V,children:O})}),Le(kt,{width:2,children:Le(rt,{color:C,children:I})}),Le(rt,{color:y,bold:S,children:k.label}),k.hint&&bt(rt,{color:L?n.success:n.textDim,children:[" ",a.dot," ",k.hint]})]},`${String(k.value)}-${A}`)}),_&&Le(kt,{justifyContent:"center",marginTop:1,children:bt(rt,{color:n.textDim,children:[a.arrowDown," ",a.arrowDown," ",a.arrowDown]})}),Le(ct,{hints:[{key:"space",label:"toggle"},{key:"enter",label:"confirm",color:n.success},...o?[{key:"esc",label:"back",color:n.warning}]:[],{key:"?",label:"help"}],status:l.length>0?bt(rt,{children:[bt(rt,{color:n.success,bold:!0,children:[a.checkboxActive," ",l.length]}),Le(rt,{color:n.textDim,children:" selected"})]}):void 0})]})}io();import{Fragment as Ri,jsx as $e,jsxs as St}from"react/jsx-runtime";var Oc=28;function Xt({onSelect:e,onBack:t}){let{stdout:o}=Pc(),r=o?.rows??40,i=Math.max(3,r-Oc),{allAgents:s,installedAgents:l,selectedAgents:d,setSelectedAgents:c,loading:u}=Sn(),g=[{key:"space",description:"Toggle selection"},{key:"enter",description:"Confirm"},{key:"ctrl+a",description:"Select all"},{key:"esc",description:"Go back"}],[f,h]=_c(!1);Rc(p=>{p==="?"&&h(w=>!w)});let m=s.map(p=>{let w=Ne(p),B=l.includes(p);return{label:w.displayName,value:p,hint:B?`${a.check} detected`:void 0}});return u?St(Kt,{flexDirection:"column",paddingX:1,children:[$e(P,{}),$e(Kt,{marginTop:1,children:St(Yr,{color:n.accent,children:[$e(Mc,{type:"dots"})," Scanning for installed agents..."]})})]}):St(Kt,{flexDirection:"column",paddingX:1,minHeight:20,children:[$e(P,{}),f?St(Ri,{children:[$e(Kt,{flexDirection:"column",flexGrow:1,alignItems:"center",justifyContent:"center",children:$e(jt,{visible:f,onDismiss:()=>h(!1),shortcuts:g})}),$e(ct,{hints:[{key:"space",label:"toggle"},{key:"enter",label:"confirm",color:n.success},...t?[{key:"esc",label:"back",color:n.warning}]:[],{key:"?",label:"help"}]})]}):St(Ri,{children:[$e(Kt,{marginBottom:1,children:St(Yr,{bold:!0,color:n.primary,children:[a.diamond," Where do you want to install skills?"]})}),$e(Kt,{marginBottom:1,children:St(Yr,{color:n.textDim,children:[l.length," agents detected on this machine"]})}),$e(Vt,{items:m,initialSelected:d,onSubmit:e,onCancel:t,onChange:c,limit:i})]})]})}import{Box as dt,Text as G,useInput as jc,useStdout as Vc}from"ink";import Fi from"ink-big-text";import Zo from"ink-gradient";import{existsSync as Kc}from"node:fs";import{dirname as $i,join as Xc}from"node:path";import{fileURLToPath as Yc}from"node:url";import{useCallback as Wc,useEffect as Qo,useMemo as zc,useRef as Ui,useState as Yt}from"react";import{execSync as Nc,spawn as Wo}from"node:child_process";import{platform as Fc}from"node:os";function $c(e){try{return Nc(`which ${e}`,{stdio:"ignore"}),!0}catch{return!1}}function Uc(e){let t=[{cmd:"mpv",args:["--no-video","--no-terminal",e]},{cmd:"ffplay",args:["-nodisp","-autoexit","-loglevel","quiet",e]},{cmd:"paplay",args:[e]},{cmd:"aplay",args:[e]}];for(let{cmd:o,args:r}of t)if($c(o))return Wo(o,r,{stdio:"ignore"});return Wo("mpv",["--no-video","--no-terminal",e],{stdio:"ignore"})}function Pi(e){try{let t=Fc(),o;return t==="darwin"?o=Wo("afplay",[e],{stdio:"ignore"}):t==="win32"?o=Wo("powershell",["-c",`(New-Object Media.SoundPlayer "${e}").PlaySync()`],{stdio:"ignore"}):o=Uc(e),o.on("error",()=>{}),o}catch{return null}}function zo(e){e&&!e.killed&&e.kill()}import Mi from"ky";var _i="https://api.github.com/repos/tech-leads-club/agent-skills",Gc=`${_i}/contributors`,qo=null,Jo=null;async function Oi(){if(qo)return qo;try{return qo=(await Mi.get(Gc,{headers:{Accept:"application/vnd.github.v3+json"},timeout:1e4}).json()).filter(({login:t})=>!Hc(t)).map(({login:t,avatar_url:o,contributions:r})=>({login:t,avatarUrl:o,contributions:r})),qo}catch{return[]}}async function Ni(){if(Jo!==null)return Jo;try{return Jo=(await Mi.get(_i,{headers:{Accept:"application/vnd.github.v3+json"},timeout:1e4}).json()).stargazers_count,Jo}catch{return 0}}function Hc(e){return e.endsWith("[bot]")}import{jsx as N,jsxs as Re}from"react/jsx-runtime";var qc=220,Jr=52,Wt=["#1e3a8a","#3b82f6","#0ea5e9","#06b6d4","#22d3ee"],Jc=14,qr=500,Hi=60,Wr="\u2500".repeat(Jr-4),Gi=40,zr=["#f59e0b","#ef4444","#ec4899","#a855f7"],Qc={1:{badge:`${a.star}${a.star}${a.star}`,color:"#f59e0b"},2:{badge:`${a.star}${a.star}`,color:"#c0c0c0"},3:{badge:a.star,color:"#cd7f32"}};function Zc(e,t){let o=[];o.push({type:"blank"}),o.push({type:"text",text:"A Tech Leads Club Production",color:"#94a3b8"}),o.push({type:"blank"}),o.push({type:"blank"}),o.push({type:"gradient",text:`${a.sparkle} C O N T R I B U T O R S ${a.sparkle}`,gradientColors:zr}),o.push({type:"gradient",text:Wr,gradientColors:Wt}),o.push({type:"blank"});for(let i=0;i<e.length;i++){let s=e[i];o.push({type:"contributor",rank:i+1,login:s.login,contributions:s.contributions})}o.push({type:"blank"}),o.push({type:"blank"}),o.push({type:"gradient",text:`${a.star} S T A T S ${a.star}`,gradientColors:zr}),o.push({type:"gradient",text:Wr,gradientColors:Wt}),o.push({type:"blank"}),t>0&&o.push({type:"text",text:`${a.star} GitHub Stars \xB7\xB7\xB7\xB7\xB7 ${t}`,color:"#f59e0b",bold:!0}),o.push({type:"text",text:`${a.diamond} Contributors \xB7\xB7\xB7\xB7\xB7 ${e.length}`,color:"#06b6d4"});let r=e.reduce((i,s)=>i+s.contributions,0);return o.push({type:"text",text:`${a.check} Contributions \xB7\xB7\xB7\xB7 ${r}`,color:"#22c55e"}),o.push({type:"blank"}),o.push({type:"blank"}),o.push({type:"gradient",text:`${a.sparkle} S P E C I A L T H A N K S ${a.sparkle}`,gradientColors:zr}),o.push({type:"gradient",text:Wr,gradientColors:Wt}),o.push({type:"blank"}),o.push({type:"text",text:"To every contributor, stargazer,",color:"#94a3b8"}),o.push({type:"text",text:"and community member who makes",color:"#94a3b8"}),o.push({type:"text",text:"this project possible.",color:"#94a3b8"}),o.push({type:"blank"}),o.push({type:"text",text:"Built with \u2665 by the community",color:"#ef4444"}),o.push({type:"blank"}),o.push({type:"gradient",text:"github.com/tech-leads-club/agent-skills",gradientColors:Wt}),o.push({type:"blank"}),o.push({type:"blank"}),o.push({type:"blank"}),o}function ed(){try{let e=$i(Yc(import.meta.url));for(let t=0;t<5;t++){let o=Xc(e,"assets","chiptune.mp3");if(Kc(o))return o;e=$i(e)}return null}catch{return null}}function td({rank:e,login:t,contributions:o}){let r=Qc[e],i=r?.color??"#e2e8f0",s=e.toString().padStart(2),l=`@${t}`,d=`${o}`,c=r?` ${r.badge}`:"",u=5+l.length+c.length+1+d.length,g=Math.max(2,Jr-4-u),f="\xB7".repeat(g);return Re(G,{children:[Re(G,{color:"#64748b",children:[s,". "]}),N(G,{color:i,bold:!!r,children:l}),N(G,{color:r?.color??"#94a3b8",children:c}),Re(G,{color:"#334155",children:[" ",f," "]}),N(G,{color:"#22c55e",bold:!0,children:d})]})}function od({line:e}){switch(e.type){case"blank":return N(G,{children:" "});case"text":return N(G,{color:e.color,bold:e.bold,children:e.text});case"gradient":return N(Zo,{colors:[...e.gradientColors],children:N(G,{children:e.text})});case"contributor":return N(td,{rank:e.rank,login:e.login,contributions:e.contributions})}}function rd({speed:e,paused:t}){if(t)return Re(G,{color:n.warning,bold:!0,children:[" ",a.bar,a.bar," PAUSED"]});let o=Math.round((qr-e)/(qr-Hi)*4)+1,r="\u25AE".repeat(o)+"\u25AF".repeat(5-o);return Re(G,{color:n.textMuted,children:[" ",r]})}function er({onExit:e}){let{stdout:t}=Vc(),o=t?.rows??24,r=Math.max(6,o-Jc-4),[i,s]=Yt([]),[l,d]=Yt(0),[c,u]=Yt(!0),[g,f]=Yt(0),[h,m]=Yt(qc),[p,w]=Yt(!1),B=Ui(null),_=Ui(null);Qo(()=>{Promise.all([Oi(),Ni()]).then(([C,y])=>{s(C),d(y),u(!1)})},[]),Qo(()=>{let C=ed();return C&&(B.current=Pi(C)),()=>{zo(B.current)}},[]);let F=zc(()=>Zc(i,l),[i,l]),k=F.length+r,T=g>=k,A=Wc(()=>{f(C=>C>=k?C:C+1)},[k]);if(Qo(()=>{if(c||p||T){_.current&&clearInterval(_.current),_.current=null;return}return _.current=setInterval(A,h),()=>{_.current&&clearInterval(_.current)}},[c,p,T,h,A]),Qo(()=>{if(!T)return;let C=setTimeout(()=>{zo(B.current),e()},3e3);return()=>clearTimeout(C)},[T,e]),jc((C,y)=>{if(y.escape){zo(B.current),e();return}if(C===" "){w(E=>!E);return}if(y.upArrow){m(E=>Math.max(Hi,E-Gi));return}if(y.downArrow){m(E=>Math.min(qr,E+Gi));return}}),c)return N(dt,{flexDirection:"column",alignItems:"center",padding:2,children:N(G,{color:n.accent,children:"Loading contributors..."})});let S={type:"blank"},L=Array(r).fill(S),O=Array(r).fill(S),I=[...L,...F,...O].slice(g,g+r);return Re(dt,{flexDirection:"column",alignItems:"center",children:[N(dt,{marginBottom:-1,children:N(Zo,{colors:["#1e3a8a","#3b82f6"],children:N(Fi,{text:"TLC",font:"tiny"})})}),N(dt,{children:N(Zo,{colors:[...Wt],children:N(Fi,{text:"AGENT SKILLS",font:"block"})})}),N(dt,{children:N(Zo,{colors:[...Wt],children:N(G,{children:"\u2500".repeat(60)})})}),N(dt,{flexDirection:"column",alignItems:"center",height:r,width:Jr,children:I.map((C,y)=>N(dt,{justifyContent:"center",children:N(od,{line:C})},`cl-${g}-${y}`))}),Re(dt,{marginTop:1,gap:2,children:[Re(G,{children:[N(G,{color:n.accent,bold:!0,children:"space"}),N(G,{color:n.textDim,children:" pause"})]}),N(G,{color:n.textMuted,children:a.dot}),Re(G,{children:[Re(G,{color:n.accent,bold:!0,children:[a.arrowUp,a.arrowDown]}),N(G,{color:n.textDim,children:" speed"})]}),N(rd,{speed:h,paused:p}),N(G,{color:n.textMuted,children:a.dot}),Re(G,{children:[N(G,{color:n.warning,bold:!0,children:"esc"}),N(G,{color:n.textDim,children:" back"})]})]})]})}import{Box as he,Text as W,useInput as nd}from"ink";import{useState as Qr}from"react";import{jsx as $,jsxs as xe}from"react/jsx-runtime";function ji({onConfirm:e,onBack:t,initialMethod:o="copy",initialGlobal:r=!1}){let[i,s]=Qr("method"),[l,d]=Qr(o),[c,u]=Qr(r);return i==="method"?xe(he,{flexDirection:"column",paddingX:1,children:[$(P,{}),$(he,{marginBottom:1,children:xe(W,{bold:!0,color:n.primary,children:[a.diamond," Choose installation method:"]})}),$(Qe,{items:[{label:"Copy",value:"copy",hint:"independent copies (recommended)"},{label:"Symlink",value:"symlink",hint:"shared source (may not work with all agents)"}],onSelect:g=>{d(g),s("scope")},onCancel:t})]}):i==="scope"?xe(he,{flexDirection:"column",paddingX:1,children:[$(P,{}),$(he,{marginBottom:1,children:xe(W,{bold:!0,color:n.primary,children:[a.diamond," Choose installation scope:"]})}),$(Qe,{items:[{label:"Local",value:!1,hint:"this project only"},{label:"Global",value:!0,hint:"user home directory"}],onSelect:g=>{u(g),s("confirm")},onCancel:()=>s("method")})]}):$(id,{method:l,isGlobal:c,onConfirm:()=>e({method:l,global:c}),onBack:()=>s("scope")})}function id({method:e,isGlobal:t,onConfirm:o,onBack:r}){return nd((i,s)=>{(s.return||i==="y"||i==="Y")&&o(),(s.escape||i==="n"||i==="N")&&r()}),xe(he,{flexDirection:"column",paddingX:1,children:[$(P,{}),xe(he,{flexDirection:"column",borderStyle:"round",borderColor:n.accent,paddingX:2,paddingY:1,children:[$(he,{marginBottom:1,children:xe(W,{bold:!0,color:n.accent,children:[a.diamond," Ready to install"]})}),xe(he,{children:[$(he,{width:10,children:$(W,{color:n.textDim,children:"Method"})}),$(W,{color:n.text,bold:!0,children:e==="copy"?"Copy":"Symlink"}),xe(W,{color:n.textMuted,children:[" ",a.dot," ",e==="copy"?"Recommended":"Developer mode"]})]}),xe(he,{children:[$(he,{width:10,children:$(W,{color:n.textDim,children:"Scope"})}),$(W,{color:n.text,bold:!0,children:t?"Global":"Local"}),xe(W,{color:n.textMuted,children:[" ",a.dot," ",t?"User home":"This project"]})]})]}),$(he,{marginTop:1,borderStyle:"round",borderColor:n.border,paddingX:1,children:$(he,{justifyContent:"space-between",width:"100%",children:xe(W,{children:[$(W,{color:n.success,bold:!0,children:"Y"}),$(W,{color:n.textDim,children:" / "}),$(W,{color:n.success,bold:!0,children:"enter"}),$(W,{color:n.textDim,children:" confirm"}),xe(W,{color:n.textDim,children:[" ",a.dot," "]}),$(W,{color:n.warning,bold:!0,children:"N"}),$(W,{color:n.textDim,children:" / "}),$(W,{color:n.warning,bold:!0,children:"esc"}),$(W,{color:n.textDim,children:" back"})]})})})]})}import{Box as At,Text as It,useInput as Yd}from"ink";import Wd from"ink-spinner";import{useAtom as us,useAtomValue as zd,useSetAtom as qd}from"jotai";import{useEffect as Jd,useMemo as Qd,useState as Ct}from"react";io();$t();import{atom as Vi}from"jotai";import{unwrap as sd}from"jotai/utils";var ld=async()=>{let e=So(),t={};for(let o of e){let[r,i]=await Promise.all([_r(o,!1).catch(()=>[]),_r(o,!0).catch(()=>[])]);for(let s of new Set([...r,...i]))t[s]||(t[s]=[]),t[s].includes(o)||t[s].push(o)}return t},Zr=Vi(0),ad=Vi(async e=>(e(Zr),ld())),Ue=sd(ad,e=>e??{});import{atom as Ki}from"jotai";var tr=Ki([]),Xi=Ki([]);import{Box as Ge,Text as ie,useInput as cd}from"ink";import{jsx as se,jsxs as Pe}from"react/jsx-runtime";function or({results:e,onExit:t,title:o="Installation Complete",successLabel:r="succeeded"}){cd((m,p)=>{(p.return||p.escape)&&t()});let i=new Set(e.filter(m=>m.success).map(m=>m.skill)),s=new Set(e.filter(m=>!m.success).map(m=>m.skill)),l=i.size,d=s.size,c=l===0&&d>0,u=d>0,g=c?n.error:u?n.warning:n.success,f=c?`${a.cross} Installation Failed`:u?`${a.warning} Partially Installed`:`${a.check} ${o}`,h=c?n.error:u?n.warning:n.success;return Pe(Ge,{flexDirection:"column",paddingX:1,children:[se(P,{}),Pe(Ge,{flexDirection:"column",borderStyle:"round",borderColor:g,paddingX:2,paddingY:1,children:[se(Ge,{marginBottom:1,children:se(ie,{color:h,bold:!0,children:f})}),e.map((m,p)=>Pe(Ge,{flexDirection:"column",children:[Pe(Ge,{paddingX:1,children:[se(Ge,{width:2,children:se(ie,{color:m.success?n.success:n.error,children:m.success?a.check:a.cross})}),se(ie,{color:m.success?n.text:n.error,children:m.skill}),Pe(ie,{color:n.textDim,children:[" ",a.arrow," ",m.agent]})]}),!m.success&&m.error&&se(Ge,{paddingLeft:4,children:se(ie,{color:n.error,dimColor:!0,children:m.error})})]},p)),(l>0||d>0)&&se(Ge,{marginTop:1,children:Pe(ie,{color:n.textDim,children:[l>0&&Pe(ie,{color:n.success,children:[l," ",r]}),l>0&&d>0&&Pe(ie,{children:[" ",a.dot," "]}),d>0&&Pe(ie,{color:n.error,children:[d," failed"]})]})}),se(Ge,{marginTop:1,children:Pe(ie,{color:n.textDim,children:["View details: ",se(ie,{color:n.accent,children:"agent-skills audit"})]})})]}),se(Ge,{marginTop:1,borderStyle:"round",borderColor:n.border,paddingX:1,children:Pe(ie,{children:[se(ie,{color:n.success,bold:!0,children:"enter"}),se(ie,{color:n.textDim,children:" / "}),se(ie,{color:n.warning,bold:!0,children:"esc"}),se(ie,{color:n.textDim,children:" exit"})]})})]})}import{Box as K,Text as U,useInput as pd}from"ink";import fd from"ink-spinner";import{useAtomValue as Yi}from"jotai";import{useMemo as en,useState as tn}from"react";ze();import{atom as dd}from"jotai";import{unwrap as ud}from"jotai/utils";var md=dd(async()=>Lo()),zt=ud(md,e=>e??new Map);import{jsx as M,jsxs as j}from"react/jsx-runtime";function rr({selectedAgents:e,onExit:t}){let[o,r]=tn(e||[]),{removeMultiple:i,progress:s,results:l}=pi(),d=Yi(Ue),c=Yi(zt),[u,g]=tn(e?"select":"agent-select"),[f,h]=tn([]),m=e||o,p=en(()=>{let k={};return Object.entries(d).forEach(([T,A])=>{let S=A.filter(L=>m.includes(L));S.length>0&&(k[T]=S)}),k},[d,m]),w=en(()=>Object.keys(p),[p]),B=en(()=>w.map(k=>{let T=c instanceof Map&&c.has(k),A=`${p[k].length} agents: ${p[k].join(", ")}`,S=T?`${A} \u26A0 deprecated`:A;return{label:k,value:k,hint:S}}),[w,p,c]);if(pd((k,T)=>{u==="done"&&(T.return||T.escape)&&t(),w.length===0&&T.escape&&t()}),u==="agent-select")return M(Xt,{onSelect:k=>{r(k),g("select")},onBack:t});if(w.length===0)return j(K,{flexDirection:"column",paddingX:1,children:[M(P,{}),M(K,{borderStyle:"round",borderColor:n.warning,paddingX:2,paddingY:1,children:M(U,{color:n.warning,children:"No skills found to remove for the selected agents."})}),M(K,{marginTop:1,borderStyle:"round",borderColor:n.border,paddingX:1,children:j(U,{children:[M(U,{color:n.warning,bold:!0,children:"esc"}),M(U,{color:n.textDim,children:" exit"})]})})]});let _=k=>{k.length!==0&&(h(k),g("confirm"))},F=async()=>{g("removing");let k=f.map(T=>({name:T,agents:p[T]||[]}));await i(k),g("done")};if(u==="select")return j(K,{flexDirection:"column",paddingX:1,children:[M(P,{}),M(K,{marginBottom:1,children:j(U,{bold:!0,color:n.error,children:[a.diamond," Select skills to remove:"]})}),M(Vt,{items:B,onSubmit:_,onCancel:t})]});if(u==="confirm")return j(K,{flexDirection:"column",paddingX:1,children:[M(P,{}),j(K,{flexDirection:"column",borderStyle:"round",borderColor:n.error,paddingX:2,paddingY:1,children:[M(K,{marginBottom:1,children:j(U,{color:n.error,bold:!0,children:[a.cross," Remove ",f.length," skill",f.length>1?"s":"","?"]})}),f.map(k=>j(K,{paddingX:1,children:[M(K,{width:2,children:M(U,{color:n.error,children:a.dot})}),M(U,{color:n.textDim,children:k})]},k))]}),M(K,{marginTop:1,children:M(Qe,{items:[{label:"Yes, remove them",value:"yes"},{label:"No, cancel",value:"no"}],onSelect:k=>{k==="yes"?F():g("select")}})})]});if(u==="removing")return j(K,{flexDirection:"column",paddingX:1,children:[M(P,{}),j(K,{marginTop:1,children:[j(U,{color:n.accent,children:[M(fd,{type:"dots"})," "]}),M(U,{children:"Removing skills..."})]}),M(K,{marginTop:1,paddingX:2,children:j(U,{color:n.textDim,children:[a.arrow," ",s.skill," (",s.current,"/",s.total,")"]})})]});if(u==="done"){let k=l.filter(S=>S.success).length,T=l.filter(S=>!S.success).length,A=k===0;return j(K,{flexDirection:"column",paddingX:1,children:[M(P,{}),j(K,{flexDirection:"column",borderStyle:"round",borderColor:A?n.error:n.success,paddingX:2,paddingY:1,children:[M(K,{marginBottom:1,children:j(U,{color:A?n.error:n.success,bold:!0,children:[A?a.cross:a.check," ",A?"Removal Failed":"Removal Complete"]})}),l.map((S,L)=>j(K,{paddingX:1,children:[M(K,{width:2,children:M(U,{color:S.success?n.success:n.error,children:S.success?a.check:a.cross})}),M(U,{color:S.success?n.text:n.error,children:S.skill}),j(U,{color:n.textDim,children:[" ",a.arrow," ",S.agent]}),!S.success&&S.error&&j(U,{color:n.error,children:[" (",S.error,")"]})]},L)),(k>0||T>0)&&M(K,{marginTop:1,children:j(U,{color:n.textDim,children:[k>0&&j(U,{color:n.success,children:[k," succeeded"]}),k>0&&T>0&&j(U,{children:[" ",a.dot," "]}),T>0&&j(U,{color:n.error,children:[T," failed"]})]})})]}),M(K,{marginTop:1,borderStyle:"round",borderColor:n.border,paddingX:1,children:j(U,{children:[M(U,{color:n.success,bold:!0,children:"enter"}),M(U,{color:n.textDim,children:" / "}),M(U,{color:n.warning,bold:!0,children:"esc"}),M(U,{color:n.textDim,children:" exit"})]})})]})}return null}import{Box as J,Text as Ie,useInput as Nd,useStdout as Fd}from"ink";import{useAtomValue as sn}from"jotai";import{useMemo as ln,useState as nt}from"react";import{Box as zi,Text as qt}from"ink";import{useMemo as gd}from"react";function Wi(e,t){return e>0?`(${e}/${t})`:`(${t})`}import{jsx as nr,jsxs as ir}from"react/jsx-runtime";var qi=({name:e,totalCount:t,installedCount:o=0,isExpanded:r=!1,isFocused:i=!1})=>{let s=gd(()=>Wi(o,t),[o,t]),l=r?"\u25BE":"\u25B8";return ir(zi,{children:[nr(zi,{width:2,children:i?nr(qt,{color:n.accent,children:a.bullet}):nr(qt,{children:" "})}),ir(qt,{color:i?n.accent:n.primaryLight,bold:!0,children:[l," "]}),nr(qt,{color:i?n.accent:n.text,bold:!0,children:e}),ir(qt,{color:o>0?n.success:n.textMuted,children:[" ",s]}),!r&&i&&ir(qt,{color:n.textDim,children:[" ",a.dot," press space to expand"]})]})};import{Box as Ph,Text as Mh,useInput as _h}from"ink";import{useState as Nh}from"react";import{jsx as Uh,jsxs as Gh}from"react/jsx-runtime";import{Box as sr,Text as Ji}from"ink";import hd from"ink-text-input";import{jsx as Jt,jsxs as xd}from"react/jsx-runtime";var Qi=({query:e,onChange:t,total:o,filtered:r,isLoading:i=!1,focus:s=!0})=>xd(sr,{borderStyle:"round",borderColor:s?n.accent:n.border,paddingX:1,children:[Jt(sr,{marginRight:1,children:Jt(Ji,{children:"\u{1F50D}"})}),Jt(sr,{flexGrow:1,children:Jt(hd,{value:e,onChange:t,placeholder:"Type to filter skills...",focus:s})}),Jt(sr,{marginLeft:1,children:Jt(Ji,{color:n.textDim,children:i?"Loading...":`${r}/${o} skills`})})]});import{Box as Tt,Text as lr}from"ink";import{Box as yd,Text as kd}from"ink";import{jsx as Td,jsxs as Sd}from"react/jsx-runtime";var bd={installed:{icon:a.check,label:"installed",color:n.success,bg:"#052e16"},update:{icon:a.arrowUp,label:"update",color:n.warning,bg:"#422006"},new:{icon:a.sparkle,label:"new",color:n.accent,bg:"#083344"},deprecated:{icon:a.warning,label:"deprecated",color:n.warning,bg:"#422006"}};function Zi({status:e}){let t=bd[e];return t?Td(yd,{children:Sd(kd,{backgroundColor:t.bg,color:t.color,children:[" ",t.icon," ",t.label," "]})}):null}import{jsx as He,jsxs as es}from"react/jsx-runtime";function ts({name:e,description:t,status:o,selected:r=!1,focused:i=!1,readOnly:s=!1}){let l=o==="installed",d=l?a.checkboxActive:r?a.checkboxActive:a.checkboxInactive,c=l?n.textMuted:r?n.success:n.textMuted,u=i?a.bullet:" ",g=l?n.textMuted:r?n.success:n.accent,f=l?n.textDim:i?n.primary:r?n.primaryLight:n.text,h=n.textMuted,m=i?n.bgLight:void 0;return es(Tt,{flexDirection:"column",backgroundColor:m,children:[es(Tt,{children:[He(Tt,{width:2,flexShrink:0,children:He(lr,{color:g,children:u})}),!s&&He(Tt,{width:2,flexShrink:0,children:He(lr,{color:c,children:d})}),He(Tt,{flexGrow:1,children:He(lr,{bold:!0,color:f,children:e})}),o&&He(Tt,{marginLeft:1,flexShrink:0,children:He(Zi,{status:o})})]}),He(Tt,{paddingLeft:s?2:4,children:He(lr,{color:h,wrap:"truncate",children:t})})]})}import je from"chalk";import{Box as wt,Text as re,useInput as Cd,useStdout as Ad}from"ink";import Id from"ink-spinner";import is,{useCallback as Dd,useEffect as Ed,useMemo as vd,useRef as rn,useState as Bd}from"react";var on={web:"#3b82f6",devops:"#10b981",data:"#8b5cf6",mobile:"#f59e0b",testing:"#ef4444",ai:"#06b6d4",security:"#ec4899",default:"#64748b"};function os(e){return Object.prototype.hasOwnProperty.call(on,e)?on[e]:on.default}function wd(e){if(!e.startsWith("---"))return e;let t=e.indexOf("---",3);return t===-1?e:e.slice(t+3).trimStart()}function rs(e){let o=wd(e).split(`
10
- `),r=[],i=0;for(;i<o.length;){let s=o[i];if(s.startsWith("```")){let c=s.slice(3).trim(),u=[];for(i++;i<o.length&&!o[i].startsWith("```");)u.push(o[i]),i++;r.push({type:"code-block",language:c,lines:u}),i++;continue}if(s.trim()===""){r.push({type:"blank"}),i++;continue}if(/^(-{3,}|_{3,}|\*{3,})$/.test(s.trim())){r.push({type:"hr"}),i++;continue}let l=s.match(/^(#{1,3})\s+(.+)$/);if(l){r.push({type:"heading",level:l[1].length,text:l[2]}),i++;continue}let d=s.match(/^(\s*)([-*]|\d+\.)\s+(.+)$/);if(d){let c=Math.floor(d[1].length/2);r.push({type:"list-item",text:d[3],indent:c}),i++;continue}r.push({type:"paragraph",text:s}),i++}return r}import{Fragment as _d,jsx as fe,jsxs as ke}from"react/jsx-runtime";var Ld=6,Rd=2,Pd=2,ye={h1:e=>je.hex(n.primary).bold(e),h2:e=>je.hex(n.primaryLight).bold(e),h3:e=>je.hex(n.accent).bold(e),text:e=>je.hex(n.textDim)(e),muted:e=>je.hex(n.textMuted)(e),code:e=>je.hex(n.accent)(e),border:e=>je.hex(n.border)(e),bold:e=>je.hex(n.text).bold(e),dim:e=>je.dim(e),indicator:e=>je.hex(n.textDim)(e)};function ns(e){return e.replace(/\*\*(.+?)\*\*/g,(t,o)=>ye.bold(o)).replace(/\*(.+?)\*/g,(t,o)=>ye.dim(o)).replace(/`(.+?)`/g,(t,o)=>ye.code(o))}function Md(e){let t=[];for(let o of e)switch(o.type){case"heading":{let r=o.level===1?a.diamond:o.level===2?a.arrow:a.dot,i=o.level===1?ye.h1:o.level===2?ye.h2:ye.h3;o.level===1&&t.length>0&&t.push(""),t.push(i(`${r} ${o.text}`));break}case"paragraph":t.push(ye.text(ns(o.text)));break;case"list-item":{let r=" ".repeat(o.indent);t.push(`${r}${ye.muted(a.bullet)} ${ye.text(ns(o.text))}`);break}case"code-block":o.language&&t.push(ye.dim(` ${o.language}`));for(let r of o.lines)t.push(` ${ye.border(a.bar)} ${ye.code(r)}`);break;case"hr":t.push(ye.border("\u2500".repeat(30)));break;case"blank":t.push("");break}return t}var ss=is.memo(({skill:e,metadata:t})=>{let o=os(e.category??"default"),r=t?.author?` ${a.dot} @${t.author}`:"",i=t?.files?.length?` ${a.dot} ${t.files.length} file${t.files.length!==1?"s":""}`:"";return ke(wt,{flexDirection:"column",marginBottom:1,children:[ke(re,{bold:!0,color:n.text,children:[a.sparkle," ",e.name]}),ke(re,{children:[fe(re,{color:o,bold:!0,children:e.category}),ke(re,{color:n.textDim,children:[r,i]})]}),fe(re,{color:n.textDim,wrap:"truncate",children:e.description})]})});ss.displayName="MetadataHeader";var nn=is.memo(({skill:e,expanded:t=!1,onClose:o,onToggleExpand:r})=>{let{metadata:i,content:s,loading:l,error:d}=fi(e?.name??null),{stdout:c}=Ad(),[u,g]=Bd(0),f=c?.rows??24,h=vd(()=>s?Md(rs(s)):[],[s]),m=Math.max(10,f-17),p=Math.max(3,m-Ld-Rd),w=Math.max(1,p-Pd),B=Math.max(0,h.length-w),_=B>0,F=_?Math.round((u+w)/h.length*100):100,k=rn(B);k.current=B;let T=rn(o);T.current=o;let A=rn(r);A.current=r;let S=Dd((I,C)=>{C.upArrow?g(y=>Math.max(0,y-1)):C.downArrow?g(y=>Math.min(k.current,y+1)):I==="f"?A.current?.():(C.escape||C.tab||C.leftArrow)&&T.current()},[]);if(Cd(S),Ed(()=>{g(0)},[e?.name]),!e)return null;let L=u>0,O=u+w<h.length,V=h.slice(u,u+w);return ke(wt,{flexDirection:"column",borderStyle:"round",borderColor:n.accent,paddingX:1,flexGrow:1,children:[ke(wt,{children:[ke(re,{bold:!0,color:n.accent,children:[a.info," Skill Details"]}),fe(wt,{flexGrow:1}),ke(re,{color:n.textMuted,children:[_&&ke(re,{color:n.textDim,children:[F,"% ",a.dot," "]}),fe(re,{color:n.accent,bold:!0,children:"\u2191\u2193"})," ","scroll ",a.dot," ",fe(re,{color:n.accent,bold:!0,children:"f"})," ",t?"compact":"expand"," ",a.dot," ",fe(re,{color:n.accent,bold:!0,children:"Esc"})," ","close"]})]}),fe(re,{color:n.border,wrap:"truncate",children:"\u2500".repeat(200)}),l?fe(wt,{alignItems:"center",justifyContent:"center",flexGrow:1,children:ke(re,{color:n.accent,children:[fe(Id,{type:"dots"})," Loading\u2026"]})}):d?fe(wt,{alignItems:"center",justifyContent:"center",flexGrow:1,children:ke(re,{color:n.error,children:[a.cross," ",d]})}):ke(_d,{children:[fe(ss,{skill:e,metadata:i}),ke(wt,{flexDirection:"column",height:p,overflowY:"hidden",children:[L&&fe(re,{color:n.textDim,children:` ${a.arrowUp} ${a.arrowUp} ${a.arrowUp}`}),fe(re,{children:V.join(`
11
- `)}),O&&fe(re,{color:n.textDim,children:` ${a.arrowDown} ${a.arrowDown} ${a.arrowDown}`})]})]})]})});nn.displayName="SkillDetailPanel";function Od(){return{width:process.stdout.columns||80,height:process.stdout.rows||24}}function ls(){let{width:e,height:t}=Od();return e>=80&&t>=24}import{Fragment as jd,jsx as H,jsxs as le}from"react/jsx-runtime";var $d=5,Ud=24,Gd=.35,Hd=e=>{let t=[{key:"/",description:"Filter skills"},{key:"\u2190/\u2192",description:"Collapse / expand"},{key:"tab/\u2192",description:"Skill details"},{key:"f",description:"Expand / compact panel"}],o={key:"esc",description:e?"Exit / close panel":"Back / close panel"};return e?[...t,o]:[...t,{key:"space",description:"Toggle / expand"},{key:"enter",description:"Install selected"},{key:"ctrl+a",description:"Select all"},o]},ar=({onInstall:e,onExit:t,overrideSkills:o,readOnly:r=!1})=>{let{skills:i,loading:s,error:l}=at(),{stdout:d}=Fd(),c=sn(tr),u=sn(Ue),g=sn(zt),f=o||i,h=o?!1:s,{query:m,setQuery:p,filtered:w}=En(f,{keys:["name","description","category"]}),[B,_]=nt(new Set),[F,k]=nt("list"),[T,A]=nt(0),[S,L]=nt(0),[O,V]=nt(!1),[I,C]=nt(!1),[y,E]=nt(null),[Q,Z]=nt(!1),[yo,Xe]=nt(null),ee=ls(),_e=d?.rows??40,dr=d?.columns??120,Ye=Math.max($d,_e-Ud),Es=Math.max(30,Math.round(dr*Gd)),vs=Math.max(10,_e-17),un=m.trim().length>0,mn=ln(()=>$o(w),[w]);ln(()=>{m&&V(!0)},[m]);let oo=x=>un||yo===x,pn=x=>{Xe(oo(x)?null:x)},Se=ln(()=>{let x=[];for(let[R,Te]of mn.entries()){let vt=Te.filter(ro=>{let ko=u[ro.name]||[];return c.length>0?ko.some(hn=>c.includes(hn)):ko.length>0}).length;x.push({type:"header",category:R.name,categoryId:R.id,count:Te.length,installedCount:vt}),oo(R.name)&&Te.forEach(ro=>x.push({type:"skill",skill:ro}))}return x},[mn,yo,un,u,c]),Bs=()=>C(x=>!x),Ls=()=>{if(O){V(!1),p(""),k("list");return}t?.()},Rs=()=>{let x=w.map(R=>R.name);_(B.size===x.length?new Set:new Set(x))},Ps=x=>{(x.downArrow||x.return)&&Se.length>0&&(k("list"),A(0))},Ms=()=>{if(T===0&&O){k("search");return}let x=Math.max(0,T-1);A(x),x<S&&L(x)},_s=()=>{let x=Math.min(Se.length-1,T+1);A(x),x>=S+Ye&&L(x-Ye+1)},Os=()=>{let x=Se[T];if(x.type==="header"){pn(x.category);return}if(x.type==="skill"&&!r){if((c.length>0?u[x.skill.name]?.some(vt=>c.includes(vt))??!1:(u[x.skill.name]?.length??0)>0)&&!o)return;let Te=new Set(B);Te.has(x.skill.name)?Te.delete(x.skill.name):Te.add(x.skill.name),_(Te)}},Ns=()=>{let x=Se[T];if(x.type==="header"){pn(x.category);return}if(r)return;let R=f.filter(Te=>B.has(Te.name));R.length>0&&e?.(R)},fn=x=>{let R=Se[T];if(R.type==="skill"&&ee){E(R.skill),Z(!1);return}!x&&R.type==="header"&&!oo(R.category)&&Xe(R.category)},Fs=()=>{let x=Se[T];x.type==="header"&&oo(x.category)&&Xe(null)},$s=(x,R)=>x.length===1&&!R.ctrl&&!R.meta&&!R.upArrow&&!R.downArrow&&!R.leftArrow&&!R.rightArrow;Nd((x,R)=>{if(x==="?")return Bs();if(I)return C(!1);if(R.escape)return Ls();if(!O&&x==="/"){V(!0),k("search");return}if(x==="a"&&R.ctrl&&!r)return Rs();if(F==="search")return Ps(R);if(F==="list"){if(R.upArrow)return Ms();if(R.downArrow)return _s();if(x===" ")return Os();if(R.return)return Ns();if(R.tab)return fn(!0);if(R.rightArrow)return fn(!1);if(R.leftArrow)return Fs();$s(x,R)&&(V(!0),k("search"),p(x))}},{isActive:!y});let Us=Se.slice(S,S+Ye),Gs=S>0,Hs=S+Ye<Se.length,js=Se.length<=Ye?100:Math.round((S+Ye)/Se.length*100),Vs=!y||!Q;if(h)return le(J,{flexDirection:"column",paddingX:1,children:[H(P,{}),H(J,{flexDirection:"column",alignItems:"center",justifyContent:"center",paddingY:4,children:H(Ie,{color:n.accent,children:"Loading skills..."})})]});if(l||!h&&f.length===0)return le(J,{flexDirection:"column",paddingX:1,minHeight:20,children:[H(P,{}),le(J,{flexDirection:"column",alignItems:"center",justifyContent:"center",flexGrow:1,children:[le(J,{flexDirection:"column",borderStyle:"round",borderColor:n.error,paddingX:3,paddingY:2,alignItems:"center",children:[le(Ie,{color:n.error,bold:!0,children:[a.cross," No Skills Available"]}),H(J,{marginTop:1,children:H(Ie,{color:n.textDim,children:"Check your internet connection and try again"})}),l&&H(J,{marginTop:1,children:H(Ie,{color:n.textMuted,dimColor:!0,children:l})})]}),H(J,{marginTop:2,children:le(Ie,{color:n.textDim,children:["Press"," ",H(Ie,{color:n.accent,bold:!0,children:"Esc"})," ","to exit"]})})]})]});let Ks=(x,R)=>{let Te=S+R,vt=F==="list"&&Te===T;if(x.type==="header")return H(J,{marginTop:R===0?0:1,children:H(qi,{name:x.category,categoryId:x.categoryId,totalCount:x.count,installedCount:x.installedCount,isExpanded:oo(x.category),isFocused:vt})},`cat-${x.category}`);let ro=B.has(x.skill.name),ko=c.length>0?u[x.skill.name]?.some(zs=>c.includes(zs))??!1:(u[x.skill.name]?.length??0)>0,Ws=g instanceof Map&&g.has(x.skill.name)?"deprecated":ko?"installed":null;return H(ts,{name:x.skill.name,description:x.skill.description,status:Ws,selected:ro,focused:vt,readOnly:r},x.skill.name)},gn=x=>H(J,{justifyContent:"center",marginBottom:x==="up"?1:0,marginTop:x==="down"?1:0,children:le(Ie,{color:n.textDim,children:[x==="up"?a.arrowUp:a.arrowDown," ",x==="up"?a.arrowUp:a.arrowDown," ",x==="up"?a.arrowUp:a.arrowDown]})}),Xs=()=>y?[{key:"\u2191/\u2193",label:"scroll"},{key:"f",label:Q?"compact":"expand"},{key:"Esc",label:"close",color:n.warning}]:r?[{key:"/",label:"filter"},{key:"tab",label:"detail"},{key:"esc",label:"exit",color:n.warning},{key:"?",label:"help"}]:[{key:"space",label:"toggle"},{key:"enter",label:"install",color:n.success},{key:"/",label:"filter"},{key:"tab",label:"detail"},{key:"esc",label:"exit",color:n.warning},{key:"?",label:"help"}],Ys=()=>{if(!y)return le(jd,{children:[!r&&B.size>0&&le(Ie,{children:[le(Ie,{color:n.success,bold:!0,children:[a.checkboxActive," ",B.size]}),H(Ie,{color:n.textDim,children:" selected"})]}),Se.length>Ye&&le(Ie,{color:n.textDim,children:[!r&&B.size>0?` ${a.dot} `:"",js,"%"]})]})};return le(J,{flexDirection:"column",paddingX:1,minHeight:20,children:[H(P,{}),I?H(J,{flexDirection:"column",flexGrow:1,alignItems:"center",justifyContent:"center",children:H(jt,{visible:I,onDismiss:()=>C(!1),shortcuts:Hd(r)})}):le(J,{flexDirection:"row",height:y?vs:void 0,flexGrow:y?0:1,overflow:"hidden",children:[Vs&&le(J,{flexDirection:"column",flexGrow:1,flexShrink:1,children:[O&&H(J,{marginBottom:1,children:H(Qi,{query:m,onChange:x=>{p(x),A(0),L(0)},total:f.length,filtered:w.length,isLoading:h,focus:F==="search"})}),le(J,{flexDirection:"column",flexGrow:1,children:[Gs&&gn("up"),Us.map(Ks),Hs&&gn("down"),Se.length===0&&H(J,{paddingY:1,children:le(Ie,{color:n.textMuted,children:['No skills match "',m,'"']})})]})]},"skill-list"),y&&H(J,{flexDirection:"column",width:Q?void 0:Es,flexGrow:Q?1:0,flexShrink:0,children:H(nn,{skill:y,expanded:Q,onClose:()=>{E(null),Z(!1)},onToggleExpand:()=>Z(x=>!x)})},"detail-panel")]}),H(ct,{hints:Xs(),status:Ys()})]})};import{Box as ge,Text as ae,useInput as Vd}from"ink";import as from"ink-spinner";import{useAtomValue as cs}from"jotai";import{useEffect as Kd,useMemo as ds,useState as Qt}from"react";ze();import{jsx as X,jsxs as z}from"react/jsx-runtime";function cr({selectedAgents:e,onExit:t}){let[o,r]=Qt(!1),[i,s]=Qt(!1),[l,d]=Qt(!1),[c,u]=Qt(e||[]),[g,f]=Qt(!e),[h,m]=Qt([]),{install:p,progress:w,results:B,installing:_}=_o(),F=cs(Ue),k=cs(zt),{skills:T,loading:A}=at(),S=e||c,L=ds(()=>{if(A)return[];let I=new Set(Object.keys(F));return T.filter(C=>I.has(C.name)?(F[C.name]||[]).some(E=>S.includes(E)):!1)},[F,T,A,S]),O=ds(()=>{if(A||!(k instanceof Map)||k.size===0)return[];let I=new Set(Object.keys(F)),C=new Set(T.map(E=>E.name)),y=[];for(let E of I)k.has(E)?y.push({name:E,entry:k.get(E)}):C.has(E)||y.push({name:E});return y},[F,T,A,k]);if(Kd(()=>{if(L.length===0){r(!1),s(!0);return}r(!0),(async()=>{let C=L.map(Q=>Q.name),{toUpdate:y}=await Bo(C),E=L.filter(Q=>y.includes(Q.name));m(E),r(!1),s(!0)})()},[L]),Vd((I,C)=>{C.escape&&!_&&!l&&!o&&i&&h.length===0&&t()}),g)return X(Xt,{onSelect:I=>{u(I),f(!1)},onBack:t});let V=async I=>{if(I.length===0)return;let C=new Set;I.forEach(y=>{(F[y.name]||[]).forEach(Q=>{S.includes(Q)&&C.add(Q)})}),await p(I,{agents:Array.from(C),method:"copy",global:!1,skills:I.map(y=>y.name),isUpdate:!0}),d(!0)};return l?X(or,{results:B,onExit:t,title:"Skills Updated Successfully",successLabel:"updated"}):_?z(ge,{flexDirection:"column",paddingX:1,children:[X(P,{}),z(ge,{marginTop:1,children:[z(ae,{color:n.accent,children:[X(as,{type:"dots"})," "]}),X(ae,{children:"Updating skills..."})]}),X(ge,{marginTop:1,paddingX:2,children:z(ae,{color:n.textDim,children:[a.arrow," ",w.skill," (",w.current,"/",w.total,")"]})})]}):A||o?z(ge,{flexDirection:"column",paddingX:1,children:[X(P,{}),X(ge,{marginTop:1,children:z(ae,{color:n.accent,children:[X(as,{type:"dots"})," ",o?"Checking for updates...":"Loading..."]})})]}):i&&h.length===0?z(ge,{flexDirection:"column",paddingX:1,children:[X(P,{}),X(ge,{borderStyle:"round",borderColor:n.success,paddingX:2,paddingY:1,children:z(ae,{color:n.success,children:[a.check," All installed skills are up to date!"]})}),O.length>0&&z(ge,{flexDirection:"column",marginTop:1,borderStyle:"round",borderColor:n.warning,paddingX:2,paddingY:1,children:[X(ge,{marginBottom:1,children:z(ae,{color:n.warning,bold:!0,children:[a.warning," ",O.length," deprecated skill",O.length>1?"s":""," detected:"]})}),O.map(I=>z(ge,{flexDirection:"column",paddingX:1,marginBottom:1,children:[z(ae,{color:n.warning,children:[a.arrow," ",I.name]}),I.entry?.message&&z(ae,{color:n.textDim,children:[" ",I.entry.message]}),!I.entry&&X(ae,{color:n.textDim,children:" No longer available in the registry"}),I.entry?.alternatives&&I.entry.alternatives.length>0&&z(ae,{color:n.textDim,children:[" ","Try: agent-skills install --skill ",I.entry.alternatives.join(", ")]})]},I.name)),z(ae,{color:n.textMuted,children:["Run: agent-skills remove --skill ","<name>"," to clean up"]})]}),X(ge,{marginTop:1,borderStyle:"round",borderColor:n.border,paddingX:1,children:z(ae,{children:[X(ae,{color:n.warning,bold:!0,children:"esc"}),X(ae,{color:n.textDim,children:" exit"})]})})]}):X(Xd,{skills:h,installedSkills:F,selectedAgents:S,onUpdate:V,onExit:t})}function Xd({skills:e,installedSkills:t,selectedAgents:o,onUpdate:r,onExit:i}){let s=e.map(c=>{let g=(t[c.name]||[]).filter(f=>o.includes(f));return{label:c.name,value:c.name,hint:`${g.length} agent${g.length>1?"s":""}: ${g.join(", ")}`}}),l=e.map(c=>c.name),d=c=>{let u=e.filter(g=>c.includes(g.name));r(u)};return z(ge,{flexDirection:"column",paddingX:1,children:[X(P,{}),X(ge,{marginBottom:1,children:z(ae,{bold:!0,color:n.primary,children:[a.diamond," Select skills to update:"]})}),X(ge,{marginBottom:1,children:z(ae,{color:n.textDim,children:[e.length," installed skill",e.length>1?"s":""," found ",a.dot," all pre-selected"]})}),X(Vt,{items:s,initialSelected:l,onSubmit:d,onCancel:i})]})}import{jsx as ne,jsxs as it}from"react/jsx-runtime";function ms({onExit:e}){let{step:t,next:o,back:r}=xi(5),[i,s]=us(tr),[l,d]=us(Xi),c=qd(Zr),u=zd(Ue),[g,f]=Ct("install"),[h,m]=Ct(!1),[p,w]=Ct(!1),[B,_]=Ct(!1),[F,k]=Ct({method:"copy",global:!1}),{skills:T}=at(),{install:A,progress:S,results:L,installing:O}=_o(),[V,I]=Ct(!1),[C,y]=Ct(!1),E=ee=>{ee.length!==0&&(s(ee),o())},Q=ee=>{if(f(ee),ee==="update"){w(!0);return}if(ee==="remove"){_(!0);return}o()},Z=ee=>{ee.length!==0&&(d(ee),o())},yo=ee=>{k(ee),o()},Xe=Qd(()=>{if(g==="install")return;let ee=new Set;return Object.entries(u).forEach(([_e,dr])=>{dr.some(Ye=>i.includes(Ye))&&ee.add(_e)}),T.filter(_e=>ee.has(_e.name))},[g,u,T,i]);return Jd(()=>{(async()=>t===5&&!V&&!C&&(I(!0),await A(l,{agents:i,skills:l.map(_e=>_e.name),method:F.method,global:F.global}),y(!0),c(_e=>_e+1)))()},[t,V,C,A,l,i,c]),t===5?C?ne(or,{results:L,onExit:e,title:"Installation Complete",successLabel:"installed"}):it(At,{flexDirection:"column",paddingX:1,children:[ne(P,{}),it(At,{marginTop:1,children:[it(It,{color:n.accent,children:[ne(Wd,{type:"dots"})," "]}),it(It,{children:["Installing ",l.length," skills to ",i.length," agents..."]})]}),O&&ne(At,{marginTop:1,paddingX:2,children:it(It,{color:n.textDim,children:[a.arrow," ",S.skill," (",S.current,"/",S.total,")"]})})]}):p?ne(cr,{selectedAgents:i,onExit:()=>w(!1)}):B?ne(rr,{selectedAgents:i,onExit:()=>_(!1)}):h?ne(er,{onExit:()=>m(!1)}):it(At,{flexDirection:"column",children:[t===1&&ne(Xt,{onSelect:E,onBack:e}),t===2&&ne(Bi,{onSelect:Q,onBack:r,onCredits:()=>m(!0)}),t===3&&(g==="install"||Xe&&Xe.length>0)&&ne(ar,{onInstall:Z,onExit:r,overrideSkills:Xe}),t===3&&g==="update"&&Xe&&Xe.length===0&&ne(Zd,{onBack:r}),t===4&&ne(ji,{onConfirm:yo,onBack:r,initialMethod:"copy",initialGlobal:!1})]})}function Zd({onBack:e}){return Yd((t,o)=>{(o.escape||t==="b"||o.backspace)&&e()}),it(At,{flexDirection:"column",paddingX:1,children:[ne(P,{}),ne(At,{borderColor:n.success,borderStyle:"round",paddingX:2,paddingY:1,children:it(It,{color:n.success,bold:!0,children:[a.check," All skills are up to date on selected agents"]})}),ne(At,{marginTop:1,borderStyle:"round",borderColor:n.border,paddingX:1,children:it(It,{children:[ne(It,{color:n.warning,bold:!0,children:"esc"}),ne(It,{color:n.textDim,children:" back"})]})})]})}import{Box as ps,Text as an}from"ink";import{useAtomValue as eu}from"jotai";import{useMemo as tu}from"react";import{jsx as Zt,jsxs as fs}from"react/jsx-runtime";function gs({onExit:e}){let t=eu(Ue),{skills:o,loading:r}=at(),i=tu(()=>{if(r)return[];let s=new Set(Object.keys(t));return o.filter(l=>s.has(l.name))},[t,o,r]);return r?fs(ps,{flexDirection:"column",padding:1,children:[Zt(P,{}),Zt(an,{children:"Loading..."})]}):i.length===0?fs(ps,{flexDirection:"column",padding:1,children:[Zt(P,{}),Zt(an,{color:n.warning,children:"No skills installed."}),Zt(an,{color:n.textDim,children:"(Press any key to exit)"})]}):Zt(ar,{onExit:e,readOnly:!0,overrideSkills:i})}import{jsx as ut,jsxs as iu}from"react/jsx-runtime";var Dt=({command:e="install"})=>{let{exit:t}=ou(),[o,r]=nu(e==="arcade"),{activated:i,reset:s}=mi();return ru(()=>{i&&!o&&(r(!0),s())},[i,o,s]),e==="credits"?ut(cn,{flexDirection:"column",padding:1,children:ut(er,{onExit:t})}):o?ut(cn,{flexDirection:"column",padding:1,children:ut(jr,{onExit:()=>{e==="arcade"?t():r(!1)}})}):iu(cn,{flexDirection:"column",padding:1,children:[e==="list"&&ut(gs,{onExit:t}),e==="remove"&&ut(rr,{onExit:t}),e==="update"&&ut(cr,{onExit:t}),(e==="install"||!e)&&ut(ms,{onExit:t})]})};var Ke=new xu;Ke.name("agent-skills").description("CLI to install and manage skills for AI coding agents").version(Gt);Ke.action(()=>{eo(to.createElement(Dt,{command:"install"}))});Ke.command("install").description("Install skills (interactive by default)").option("-g, --global","Install globally to user home",!1).option("-s, --skill <names...>","Install one or more skills").option("-a, --agent <agents...>","Target specific agents").option("--symlink","Use symlink instead of copy",!1).option("-f, --force","Force re-download skills (bypass cache)",!1).action(async e=>{if(dn(e)){eo(to.createElement(Dt,{command:"install"}));return}let{runCliInstall:t}=await Promise.resolve().then(()=>(xs(),hs));await t(e)});Ke.command("list").alias("ls").description("List available/installed agent skills").action(()=>{eo(to.createElement(Dt,{command:"list"}))});Ke.command("remove").alias("rm").description("Remove installed skills").option("-g, --global","Remove from global installation",!1).option("-s, --skill <names...>","Remove one or more skills").option("-a, --agent <agents...>","Target specific agents").option("-f, --force","Force removal even if not in lockfile",!1).action(async e=>{if(dn(e)){eo(to.createElement(Dt,{command:"remove"}));return}let{runCliRemove:t}=await Promise.resolve().then(()=>(ks(),ys));await t(e)});Ke.command("update").description("Update installed skills to the latest version").option("-s, --skill <name>","Update a specific skill").action(async e=>{if(dn(e)){eo(to.createElement(Dt,{command:"update"}));return}let{runCliUpdate:t}=await Promise.resolve().then(()=>(Ss(),bs));await t(e)});Ke.command("cache").description("Manage the skills cache").option("--clear","Clear all cached skills and registry").option("--clear-registry","Clear only the registry cache").option("--path","Show cache directory path").action(async e=>{let{runCliCache:t}=await Promise.resolve().then(()=>(ws(),Ts));t(e)});Ke.command("credits").description("Show project contributors and credits").action(()=>{eo(to.createElement(Dt,{command:"credits"}))});Ke.command("audit").description("View audit log of skill operations").option("-n, --limit <number>","Number of entries to show","10").option("--path","Show audit log file path").action(async e=>{let{runCliAudit:t}=await Promise.resolve().then(()=>(Ds(),Is));await t(e)});Ke.parse(process.argv);function dn(e){return Object.keys(e).filter(o=>o!=="parent").length===0}
10
+ \u{1F4A1} Tip: Use --force to bypass lockfile check`)),i>0&&process.exit(1)}var Os=R(()=>{"use strict";Ht()});var Ns={};Mt(Ns,{runCliUpdate:()=>vm});import ce from"chalk";async function vm(e){if(console.log(ce.blue("\u23F3 Fetching latest registry...")),await go(!0),e.skill){if(!await Nr(e.skill)){console.log(ce.green(`\u2705 ${e.skill} is already up to date`));return}console.log(ce.blue(`\u23F3 Updating ${e.skill}...`)),await po(e.skill)?console.log(ce.green(`\u2705 Updated ${e.skill}`)):(console.error(ce.red(`\u274C Failed to update ${e.skill}`)),process.exit(1))}else{let{readSkillLock:t}=await Promise.resolve().then(()=>(Rr(),ii)),o=await t(),r=Object.keys(o.skills);if(r.length===0){console.log(ce.yellow("No installed skills found. Run agent-skills install first."));return}let{toUpdate:i,upToDate:s}=await Oo(r);if(i.length===0){console.log(ce.green(`\u2705 All ${s.length} installed skills are up to date`));return}console.log(ce.blue(`\u23F3 Updating ${i.length} of ${r.length} skills...`));let l=0,d=0;for(let h of i)await po(h)?l++:(d++,console.error(ce.red(` \u274C Failed to update ${h}`)));console.log(ce.green(`\u2705 ${l} updated, ${s.length} already up to date${d>0?ce.red(`, ${d} failed`):""}`));let c=await No(),m=await Ft(),f=new Set(m.map(h=>h.name)),p=r.filter(h=>c.has(h)||!f.has(h));if(p.length>0){console.log(""),console.log(ce.yellow(`\u26A0 ${p.length} deprecated skill${p.length>1?"s":""} detected:`));let h={withEntry:(u,g)=>{console.log(ce.yellow(` \u203A ${u} \u2014 ${g.message}`)),g.alternatives?.length&&console.log(ce.dim(` Try: agent-skills install --skill ${g.alternatives.join(", ")}`))},noEntry:u=>{console.log(ce.yellow(` \u203A ${u} \u2014 no longer available in the registry`))}};p.forEach(u=>{let g=c.get(u);h[g?"withEntry":"noEntry"](u,g)}),console.log(ce.dim(" Run: agent-skills remove --skill <name> to clean up"))}}}var Fs=R(()=>{"use strict";qe()});var Us={};Mt(Us,{runCliCache:()=>Pm});import Lt from"chalk";function Pm(e){e.clear?(fi(),console.log(Lt.green("\u2705 Cache cleared"))):e.clearRegistry?(hi(),console.log(Lt.green("\u2705 Registry cache cleared"))):e.path?console.log(Fr()):(console.log(Lt.bold("Cache management:")),console.log(` ${Lt.blue("--clear")} Clear all cached skills and registry`),console.log(` ${Lt.blue("--clear-registry")} Clear only the registry cache`),console.log(` ${Lt.blue("--path")} Show cache directory path`),console.log(),console.log(Lt.dim(`Cache location: ${Fr()}`)))}var $s=R(()=>{"use strict";qe()});import{Box as gt,Text as Ee}from"ink";import{Fragment as Lm,jsx as pt,jsxs as be}from"react/jsx-runtime";function Gs({entries:e,limit:t=10}){let o=e.slice(0,t);return o.length===0?pt(gt,{flexDirection:"column",paddingY:1,children:pt(Ee,{dimColor:!0,children:"No audit log entries found"})}):be(gt,{flexDirection:"column",paddingY:1,children:[be(gt,{marginBottom:1,children:[pt(Ee,{bold:!0,color:"cyan",children:"\u{1F4CB} Audit Log"}),be(Ee,{dimColor:!0,children:[" (showing ",o.length," most recent)"]})]}),o.map((r,i)=>{let s=r.timestamp?new Date(r.timestamp):new Date,l=r.timestamp?Bm(s):"unknown time",d=r.action==="install"?"green":r.action==="remove"?"red":"yellow",c=r.failed===0?"\u2713":r.success>0?"\u26A0":"\u2717";return be(gt,{flexDirection:"column",marginBottom:1,paddingLeft:2,children:[be(gt,{children:[be(Ee,{color:d,bold:!0,children:[c," ",r.action.toUpperCase()]}),be(Ee,{dimColor:!0,children:[" \u2022 ",l]})]}),be(gt,{paddingLeft:2,children:[pt(Ee,{children:"Skills: "}),pt(Ee,{color:"cyan",children:r.skillName})]}),be(gt,{paddingLeft:2,children:[pt(Ee,{children:"Agents: "}),pt(Ee,{dimColor:!0,children:r.agents.join(", ")})]}),be(gt,{paddingLeft:2,children:[be(Ee,{color:"green",children:["\u2713 ",r.success]}),r.failed>0&&be(Lm,{children:[pt(Ee,{children:" \u2022 "}),be(Ee,{color:"red",children:["\u2717 ",r.failed]})]})]})]},i)})]})}function Bm(e){let t=Math.floor((Date.now()-e.getTime())/1e3);return t<60?"just now":t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:t<604800?`${Math.floor(t/86400)}d ago`:e.toLocaleDateString()}var Hs=R(()=>{"use strict"});var js={};Mt(js,{runCliAudit:()=>_m});import{render as Rm}from"ink";import Mm from"react";async function _m(e){if(e.path){console.log(Do());return}let t=e.limit?parseInt(e.limit,10):10,o=await On(t);Rm(Mm.createElement(Gs,{entries:o,limit:t}))}var Ks=R(()=>{"use strict";Hs();Ir()});import{Command as Om}from"commander";import{render as ro}from"ink";import no from"react";import{Box as fn,useApp as bm}from"ink";import{useEffect as Cm,useState as Tm}from"react";ao();import{useEffect as kl,useMemo as Sl,useState as yr}from"react";function Dn(){let[e,t]=yr([]),[o,r]=yr([]),[i,s]=yr(!0),l=Sl(()=>In(),[]);return kl(()=>{let c=setTimeout(()=>{let m=Ao();r(m),t(m),s(!1)},800);return()=>clearTimeout(c)},[]),{allAgents:l,installedAgents:o,selectedAgents:e,setSelectedAgents:t,toggleAgent:c=>{t(m=>m.includes(c)?m.filter(f=>f!==c):[...m,c])},loading:i}}import{useEffect as lu,useState as au}from"react";ve();import{useMemo as bl,useState as Cl}from"react";function Mn(e,t){let[o,r]=Cl(""),i=bl(()=>{if(!o.trim())return e;let s=o.toLowerCase().split(/\s+/).filter(l=>l.length>0);return e.filter(l=>{let d=t.keys.map(c=>{let m=l[c];return typeof m=="string"?m.toLowerCase():""}).join(" ");return s.every(c=>d.includes(c))})},[o,e,t.keys]);return{query:o,setQuery:r,filtered:i,hasFilter:o.trim().length>0}}Ht();import{useState as $o}from"react";mo();import{existsSync as jr,readdirSync as Ai,readFileSync as Da}from"node:fs";import{join as Uo}from"node:path";import{existsSync as ba}from"node:fs";import{dirname as Ca,join as Ti}from"node:path";import{fileURLToPath as Ta}from"node:url";var wa=Ta(import.meta.url),Aa=Ca(wa);function Hr(){return Ti(Ia(),"packages","skills-catalog","skills")}function wi(){let e=Hr();return ba(e)?e:null}function Ia(){return Ti(Aa,"..","..","..","..")}qe();var at={mode:null,localDir:null};function Ea(e){return yt.test(e)}function va(e){return e.match(yt)?.[1]??null}function Pa(e){let t=e.match(/^---\n([\s\S]*?)\n---/);if(!t)return{};let o=t[1],r=o.match(/^name:\s*(.+)$/m),i=o.match(/^description:\s*(.+)$/m);return{name:r?.[1]?.trim(),description:i?.[1]?.trim()}}function Ii(e,t){let o=Uo(e,"SKILL.md");if(!jr(o))return null;let r=Da(o,"utf-8"),{name:i,description:s}=Pa(r),l=e.split("/").pop()??"";return{name:i??l,description:s??"No description",path:e,category:t}}function Ba(e,t){return jr(e)?Ai(e,{withFileTypes:!0}).filter(o=>o.isDirectory()).map(o=>Ii(Uo(e,o.name),t)).filter(o=>o!==null):[]}function Di(e){return jr(e)?Ai(e,{withFileTypes:!0}).filter(o=>o.isDirectory()).flatMap(o=>{if(Ea(o.name)){let i=va(o.name);return i?Ba(Uo(e,o.name),i):[]}let r=Ii(Uo(e,o.name),ht);return r?[r]:[]}):[]}function La(){if(at.mode)return at.mode;let e=wi();return e?(at.localDir=e,at.mode="local","local"):(at.mode="remote","remote")}function Kr(){return La()==="local"&&at.localDir!==null}function Ra(){return Kr()?Di(at.localDir):[]}async function Ei(){return Kr()?Di(at.localDir):Ft()}function Ma(e){return Ra().find(t=>t.name===e)}async function vi(e){if(Kr())return Ma(e)??null;let t=await Ut(e);if(!t)return null;let o=await St(e);return o?{name:t.name,description:t.description,path:o,category:t.category}:null}function Go(){let[e,t]=$o({current:0,total:0,skill:""}),[o,r]=$o([]),[i,s]=$o(!1),[l,d]=$o(null);return{install:async(m,f)=>{s(!0),d(null),t({current:0,total:m.length*f.agents.length,skill:"Downloading..."});let p=[];for(let h of m){let u=h.path?h:await vi(h.name);u&&p.push(u)}t({current:0,total:p.length*f.agents.length,skill:"Installing..."});try{let h=await Fo(p,f);return r(h),h}catch(h){return d(h instanceof Error?h.message:String(h)),[]}finally{s(!1)}},progress:e,results:o,installing:i,error:l}}import{useInput as _a}from"ink";import{useCallback as Oa,useRef as Na,useState as Fa}from"react";var Ho=["up","up","down","down","left","right","left","right","b","a"];function Pi(){let[e,t]=Fa(!1),o=Na([]);_a((i,s)=>{if(e)return;let l=null;if(s.upArrow?l="up":s.downArrow?l="down":s.leftArrow?l="left":s.rightArrow?l="right":i.toLowerCase()==="b"?l="b":i.toLowerCase()==="a"&&(l="a"),!l){o.current=[];return}o.current.push(l),o.current.length>Ho.length&&(o.current=o.current.slice(-Ho.length)),o.current.length===Ho.length&&o.current.every((d,c)=>d===Ho[c])&&(t(!0),o.current=[])});let r=Oa(()=>{t(!1),o.current=[]},[]);return{activated:e,reset:r}}Ht();import{useState as jo}from"react";function Bi(){let[e,t]=jo({current:0,total:0,skill:""}),[o,r]=jo([]),[i,s]=jo(!1),[l,d]=jo(null);return{remove:async(f,p,h=!1)=>{s(!0),t({current:0,total:p.length,skill:f}),d(null);try{let u=await xo(f,p,{global:h});return r(g=>[...g,...u]),u}catch(u){return d(u instanceof Error?u.message:String(u)),[]}finally{s(!1)}},removeMultiple:async f=>{s(!0);let p=f.reduce((h,u)=>h+u.agents.length,0);t({current:0,total:p,skill:"Initializing..."}),r([]),d(null);try{let h=0;for(let u of f){t({current:h,total:p,skill:u.name});let g=await xo(u.name,u.agents,{});r(T=>[...T,...g]),h+=u.agents.length}}catch(h){d(h instanceof Error?h.message:String(h))}finally{s(!1)}},progress:e,results:o,removing:i,error:l}}qe();import{readFileSync as Ua}from"node:fs";import{join as $a}from"node:path";import{useEffect as Ga,useState as Ko}from"react";function Li(e){let[t,o]=Ko(null),[r,i]=Ko(null),[s,l]=Ko(!1),[d,c]=Ko(null);return Ga(()=>{if(!e){o(null),i(null),l(!1),c(null);return}let m=!0;return l(!0),c(null),(async()=>{try{let[p,h]=await Promise.all([Ut(e).catch(()=>null),St(e).catch(()=>null)]);if(!m)return;p&&o(p);let u=h??lt(e);try{let g=Ua($a(u,"SKILL.md"),"utf-8");i(g)}catch{c("Failed to load skill content")}}catch(p){m&&c(p instanceof Error?p.message:String(p))}finally{m&&l(!1)}})(),()=>{m=!1}},[e]),{metadata:t,content:r,loading:s,error:d}}import{useEffect as Wa,useState as Xo}from"react";mo();import{existsSync as Ri,readdirSync as Ha,readFileSync as ja,writeFileSync as kp}from"node:fs";import{join as Ka}from"node:path";function Mi(){return Hr()}function Va(){let e=Mi(),t=Ka(e,Eo);if(!Ri(t))return{};try{let o=ja(t,"utf-8");return JSON.parse(o)}catch{return{}}}function Xa(e){let t=e.match(yt);return t?t[1]:null}function Ya(e){return yt.test(e)}function za(){let e=Mi();if(!Ri(e))return[];let t=Va(),o=Ha(e,{withFileTypes:!0}),r=[],i=0;for(let s of o){if(!s.isDirectory()||!Ya(s.name))continue;let l=Xa(s.name);if(!l)continue;let d=t[s.name]??{};r.push({id:l,name:d.name??Ot(l),description:d.description,priority:d.priority??i}),i++}return r.sort((s,l)=>s.name.localeCompare(l.name)),r}function Vo(e){let t=za();if(t.length===0){let s=new Set(e.map(l=>l.category).filter(Boolean));t=Array.from(s).map((l,d)=>({id:l,name:Ot(l),priority:d}))}let o=new Map;for(let s of t)o.set(s,[]);o.set(vo,[]);for(let s of e){let l=s.category??ht,d=t.find(f=>f.id===l);!d&&l!==ht&&(d={id:l,name:Ot(l),priority:999},t.push(d),o.set(d,[]));let c=d??vo,m=o.get(c)??[];m.push(s),o.set(c,m)}for(let[s,l]of o)l.length===0&&o.delete(s);let r=new Map,i=Array.from(o.keys()).sort((s,l)=>s.name.localeCompare(l.name));for(let s of i){let l=o.get(s);l&&(l.sort((d,c)=>d.name.localeCompare(c.name)),r.set(s,l))}return r}function ct(){let[e,t]=Xo([]),[o,r]=Xo(!0),[i,s]=Xo(null),[l,d]=Xo(new Map);return Wa(()=>{let c=!0;return(async()=>{try{let f=await Ei();c&&(t(f),d(Vo(f)))}catch(f){c&&s(f instanceof Error?f.message:String(f))}finally{c&&r(!1)}})(),()=>{c=!1}},[]),{skills:e,loading:o,error:i,groupedSkills:l}}import{useState as qa}from"react";function _i(e){let[t,o]=qa(1);return{step:t,next:()=>o(l=>Math.min(l+1,e)),back:()=>o(l=>Math.max(l-1,1)),goTo:l=>o(l),isFirst:t===1,isLast:t===e,progress:t/e}}import{Box as Ct,Text as Wo}from"ink";import fc from"ink-big-text";import Yr from"ink-gradient";import{useEffect as hc,useState as Ni}from"react";import{Box as Vr,Text as ko}from"ink";import{memo as Ja}from"react";var n={primary:"#3b82f6",primaryLight:"#60a5fa",primaryDark:"#1e3a8a",accent:"#06b6d4",accentLight:"#22d3ee",success:"#22c55e",warning:"#f59e0b",error:"#ef4444",text:"#f8fafc",textDim:"#94a3b8",textMuted:"#64748b",border:"#334155",bg:"#0f172a",bgLight:"#1e293b"};var a={bar:"\u2502",barEnd:"\u2514",radioActive:"\u25CF",radioInactive:"\u25CB",checkboxActive:"\u25FC",checkboxInactive:"\u25FB",diamond:"\u25C6",arrow:"\u203A",arrowRight:"\u2192",arrowUp:"\u2191",arrowDown:"\u2193",dot:"\xB7",bullet:"\u25B8",check:"\u2713",cross:"\u2717",star:"\u2605",sparkle:"\u2726",installed:"\u25CF",warning:"\u26A0",info:"\u2139"};import{jsx as zo,jsxs as Yo}from"react/jsx-runtime";var dt=Ja(function({hints:t,status:o}){return zo(Vr,{marginTop:1,borderStyle:"round",borderColor:n.border,paddingX:1,children:Yo(Vr,{justifyContent:"space-between",width:"100%",children:[zo(ko,{children:t.map((r,i)=>Yo(ko,{children:[i>0&&Yo(ko,{color:n.textDim,children:[" ",a.dot," "]}),zo(ko,{color:r.color??n.accent,bold:!0,children:r.key}),Yo(ko,{color:n.textDim,children:[" ",r.label]})]},r.key))}),o&&zo(Vr,{children:o})]})})});import{Box as bt,Text as Ue,useInput as Qa}from"ink";import{useMemo as Za,useState as Oi}from"react";import{Fragment as ec,jsx as Je,jsxs as Qe}from"react/jsx-runtime";function Ze({items:e,onSelect:t,onCancel:o,initialIndex:r=0,itemLimit:i=10,hideFooter:s,footerRight:l}){let[d,c]=Oi(r),[m,f]=Oi(0);Qa((h,u)=>{u.upArrow&&(c(g=>Math.max(0,g-1)),d<=m&&f(g=>Math.max(0,g-1))),u.downArrow&&(c(g=>Math.min(e.length-1,g+1)),d>=m+i-1&&f(g=>Math.min(e.length-i,g+1))),u.return&&t(e[d].value),u.escape&&o&&o()});let p=Za(()=>e.slice(m,m+i),[e,m,i]);return Qe(bt,{flexDirection:"column",children:[p.map((h,u)=>{let g=u+m===d;return Qe(bt,{backgroundColor:g?n.bgLight:void 0,paddingX:1,children:[Je(bt,{width:2,children:Je(Ue,{color:g?n.accent:n.textMuted,children:g?a.bullet:" "})}),Qe(Ue,{color:g?n.accent:n.text,bold:g,children:[g?a.radioActive:a.radioInactive," ",h.label]}),g&&h.hint&&Qe(Ue,{color:n.textDim,children:[" ",a.dot," ",h.hint]})]},`${h.label}-${u}`)}),e.length>i&&Je(bt,{marginTop:1,paddingX:1,children:Qe(Ue,{color:n.textDim,children:[a.arrowUp,a.arrowDown," ",m+1,"-",Math.min(m+i,e.length)," of ",e.length]})}),!s&&Je(bt,{marginTop:1,borderStyle:"round",borderColor:n.border,paddingX:1,children:Qe(bt,{justifyContent:"space-between",width:"100%",children:[Qe(Ue,{children:[Je(Ue,{color:n.success,bold:!0,children:"enter"}),Je(Ue,{color:n.textDim,children:" select"}),o&&Qe(ec,{children:[Qe(Ue,{color:n.textDim,children:[" ",a.dot," "]}),Je(Ue,{color:n.warning,bold:!0,children:"esc"}),Je(Ue,{color:n.textDim,children:" back"})]})]}),l&&Je(bt,{children:l})]})})]})}import{Box as et,Text as Pe,useInput as tc,useStdout as oc}from"ink";import{useCallback as rc,useEffect as nc,useRef as ic,useState as sc}from"react";import{jsx as ue,jsxs as So}from"react/jsx-runtime";var lc=100,tt=16,ac=50,cc=10,dc=30,mc=5,uc=["BANKRUPT. Your burn rate was too high.","DOWN ROUND. Valuation dropped to zero.","RUNWAY EXPIRED. Back to living with parents.","SERVER COSTS > REVENUE. You are cooked.","AUDIT FAILED. Too much tech debt."],gc=["ACQUIRED BY BIG TECH. Golden handcuffs on.","SERIES B SECURED. Keep burning cash!","IPO SUCCESSFUL. Time to buy a yacht.","PROFITABLE? No, but the vibes are great."],jt=[["AGI_SOON","100x_DEV","LOVABLE","HYPE"],["DEEPSEEK","GEMINI","GPT","V0_DEV"],["TAB_SPAM","NO_READ","TRUST_ME","YOLO"],["SLOP","SPAGHETTI","ANY_TYPE","BUG"]];function pc(e){let t=[],r=Math.max(...jt.flat().map(l=>l.length))+4,i=jt[0].length*r,s=Math.floor((e-i)/2);for(let l=0;l<jt.length;l++)for(let d=0;d<jt[l].length;d++){let c=jt[l][d];t.push({x:Math.max(0,s+d*r),y:1+l*2,label:c,width:c.length,alive:!0})}return t}function Xr({onExit:e}){let{stdout:t}=oc(),o=t?.columns??80,r=Math.max(60,Math.min(o-4,lc)),i=ic(""),[s,l]=sc(()=>({player:{x:Math.floor(r/2),y:tt-1},playerBullets:[],enemyBullets:[],invaders:pc(r),score:0,lives:5,gameOver:!1,won:!1,invaderDirection:1,tickCount:0,flash:!1,glitch:!1,rateLimited:0}));if((s.gameOver||s.won)&&!i.current){let p=s.won?gc:uc;i.current=p[Math.floor(Math.random()*p.length)]}tc((p,h)=>{if(s.gameOver||s.won){(h.return||h.escape)&&e();return}if(h.escape){e();return}l(u=>{let g=u.player.x;h.leftArrow&&(g=Math.max(0,u.player.x-2)),h.rightArrow&&(g=Math.min(r-1,u.player.x+2));let T=u.playerBullets,P=u.rateLimited;return p===" "&&P===0&&(u.playerBullets.length>=2?(P=dc,T=[]):T=[...u.playerBullets,{x:g,y:u.player.y-1}]),{...u,player:{...u.player,x:g},playerBullets:T,rateLimited:P}})});let d=rc(()=>{l(p=>{if(p.gameOver||p.won)return p;let h=p.tickCount+1,u=p.score,g=p.lives,T=p.gameOver,P=!1,O=!1,U=p.rateLimited>0?p.rateLimited-1:0,k=p.invaders.filter(x=>x.alive),C=jt.flat().length,A=k.length/C,b=Math.max(2,Math.floor(cc*A)+1),B=.02+.08*(1-A),N=p.playerBullets.map(x=>({...x,y:x.y-1})).filter(x=>x.y>=0),V=p.enemyBullets.map(x=>({...x,y:x.y+1})).filter(x=>x.y<tt),I=p.invaders.map(x=>({...x}));for(let x of N)if(x.y!==-1){for(let E of I)if(E.alive&&x.y===E.y&&x.x>=E.x&&x.x<E.x+E.width){E.alive=!1,x.y=-1,u+=100,P=!0;break}}if(N=N.filter(x=>x.y!==-1),V.some(x=>x.x===p.player.x&&x.y===p.player.y)&&(g-=1,P=!0,O=!0,V=[],g<=0&&(T=!0)),I.every(x=>!x.alive))return{...p,won:!0,score:u+g*1e3,invaders:I};if(k.length>0){let x=k.filter(E=>{let Q=p.player.x>=E.x-1&&p.player.x<=E.x+E.width+1;return Math.random()<(Q?B*mc:B)});if(x.length>0){let E=x[Math.floor(Math.random()*x.length)];V.push({x:E.x+Math.floor(E.width/2),y:E.y+1})}}let w=p.invaderDirection;if(h%b===0){let x=I.filter(Z=>Z.alive).map(Z=>Z.x),E=Math.min(...x);Math.max(...I.filter(Z=>Z.alive).map(Z=>Z.x+Z.width))>=r-2&&w===1&&(w=-1),E<=0&&w===-1&&(w=1),I.forEach(Z=>Z.alive&&(Z.x+=w))}return h%45===0&&(I.forEach(x=>x.alive&&(x.y+=1)),I.some(x=>x.alive&&x.y>=tt-1)&&(T=!0)),{...p,playerBullets:N,enemyBullets:V,invaders:I,score:u,lives:g,gameOver:T,invaderDirection:w,tickCount:h,flash:P,glitch:O,rateLimited:U}})},[r]);nc(()=>{let p=setInterval(d,ac);return()=>clearInterval(p)},[d]);let c=()=>{let p=Array.from({length:tt},()=>Array(r).fill(" "));s.invaders.forEach(g=>{if(g.alive)for(let T=0;T<g.width;T++)g.x+T<r&&g.y<tt&&(p[g.y][g.x+T]=s.glitch?"?":g.label[T])}),s.playerBullets.forEach(g=>{g.x<r&&g.y<tt&&(p[g.y][g.x]="$")}),s.enemyBullets.forEach(g=>{g.x<r&&g.y<tt&&(p[g.y][g.x]="*")});let{x:h,y:u}=s.player;return h<r&&u<tt&&(p[u][h]=s.rateLimited>0?"X":"^"),p.map(g=>g.join("")).join(`
11
+ `)},m=s.rateLimited>0?n.error:n.accent,f=s.glitch?n.warning:s.flash?n.error:n.success;return ue(et,{width:"100%",alignItems:"center",flexDirection:"column",children:So(et,{width:r+4,flexDirection:"column",alignItems:"center",children:[So(et,{width:r,flexDirection:"row",paddingX:1,children:[ue(et,{width:"35%",children:ue(Pe,{color:m,bold:!0,children:s.rateLimited>0?`LIMIT (${s.rateLimited})`:`$${s.score}k`})}),ue(et,{width:"30%",justifyContent:"center",children:ue(Pe,{color:n.warning,bold:!0,children:"VIBE INVADERS"})}),ue(et,{width:"35%",justifyContent:"flex-end",children:So(Pe,{color:n.success,bold:!0,children:["RUNWAY: ","$".repeat(s.lives)]})})]}),ue(et,{borderStyle:"round",borderColor:s.rateLimited>0?n.error:n.border,flexDirection:"column",width:r+2,height:tt+2,children:ue(Pe,{color:s.gameOver?n.error:f,children:c()})}),ue(et,{marginTop:0,width:r+2,justifyContent:"center",borderStyle:"round",borderColor:n.accent,children:s.gameOver||s.won?So(Pe,{color:s.won?n.success:n.error,bold:!0,children:[i.current," Val: $",s.score,"k"]}):So(et,{gap:1,children:[ue(Pe,{color:n.accent,children:"\u2190\u2192"}),ue(Pe,{children:" move "}),ue(Pe,{color:n.accent,children:"spc"}),ue(Pe,{children:" shoot "}),ue(Pe,{color:n.accent,children:"esc"}),ue(Pe,{children:" quit"})]})})]})})}import{jsx as ge,jsxs as zr}from"react/jsx-runtime";var yc=[{label:"Vibe Invaders",value:"invaders",hint:"Fight vibe-coding!"},{label:"Back",value:"back",hint:"Return to CLI"}],Fi="\u2591".repeat(56);function Wr({onExit:e}){let[t,o]=Ni("menu"),[r,i]=Ni(!0);hc(()=>{let l=setInterval(()=>i(d=>!d),600);return()=>clearInterval(l)},[]);let s=l=>{if(l==="back"){e();return}o(l)};return t==="invaders"?ge(Xr,{onExit:()=>o("menu")}):zr(Ct,{flexDirection:"column",alignItems:"center",children:[ge(Ct,{marginBottom:0,children:ge(Yr,{name:"cristal",children:ge(Wo,{children:Fi})})}),ge(Ct,{marginBottom:0,children:ge(Yr,{name:"pastel",children:ge(fc,{text:"ARCADE",font:"chrome"})})}),ge(Ct,{marginBottom:0,children:ge(Yr,{name:"cristal",children:ge(Wo,{children:Fi})})}),ge(Ct,{marginBottom:1,marginTop:1,children:zr(Wo,{color:r?n.warning:n.bg,bold:!0,children:[a.sparkle," SECRET UNLOCKED ",a.sparkle]})}),ge(Ct,{marginBottom:1,children:zr(Wo,{color:n.textDim,children:[a.diamond," Choose your adventure ",a.diamond]})}),ge(Ct,{width:50,children:ge(Ze,{items:yc,onSelect:s,onCancel:e,hideFooter:!0})}),ge(dt,{hints:[{key:"\u2191\u2193",label:"navigate"},{key:"\u23CE",label:"select"},{key:"esc",label:"back",color:n.warning}]})]})}import{Box as Yi,Text as Jo,useInput as Hc}from"ink";import{Box as ot,Text as Ie}from"ink";import Vi from"ink-big-text";import Jr from"ink-gradient";import{useAtomValue as Uc}from"jotai";import{useMemo as $c}from"react";Er();import{atom as Mc}from"jotai";import{unwrap as _c}from"jotai/utils";ve();import{mkdir as xc,readFile as kc,writeFile as Sc}from"node:fs/promises";import{homedir as bc}from"node:os";import{dirname as Cc,join as Tc}from"node:path";function Ui(){return Tc(bc(),xr,En)}function wc(e){if(typeof e!="object"||e===null)return null;let t=e;return typeof t.lastUpdateCheck!="number"?null:{lastUpdateCheck:t.lastUpdateCheck,latestVersion:t.latestVersion??null}}async function $i(){let e=Ui();try{let t=await kc(e,"utf-8"),o=JSON.parse(t);return wc(o)}catch{return null}}async function Gi(e){let t=Ui(),o={lastUpdateCheck:Date.now(),latestVersion:e};await xc(Cc(t),{recursive:!0}),await Sc(t,JSON.stringify(o,null,2),"utf-8")}ve();import Bc from"package-json";import{createRequire as Ac}from"node:module";import{dirname as Ic,join as Dc}from"node:path";import{fileURLToPath as Ec}from"node:url";var vc=Ec(import.meta.url),Pc=Ic(vc),Hi=Ac(import.meta.url),qo;try{qo=Hi("./package.json")}catch{qo=Hi(Dc(Pc,"../../package.json"))}var Kt=qo.version||"0.0.0",vf=qo.description||"CLI to install and manage skills for AI coding agents";async function ji(e){try{if(Lc(e))return null;let t=await Bc(_t,{version:"latest"});return t.version!==e?t.version:null}catch{return null}}function Lc(e){return/-(alpha|beta|rc|snapshot|dev|canary|next)/i.test(e)}function qr(){return Kt}ve();async function Oc(e){let t=await $i(),o=t&&t.latestVersion!==e?t.latestVersion:null;try{let r=await Promise.race([ji(e),new Promise((i,s)=>setTimeout(()=>s(new Error("timeout")),3e3))]);return Gi(r??e).catch(()=>{}),r}catch{return o}}var Nc=async()=>{let e=qr(),[t,o]=await Promise.all([Oc(e).catch(()=>null),Promise.resolve(Dr()).catch(()=>!1)]);return{updateAvailable:t,currentVersion:e,isGlobal:o,isLoading:!1}},Fc=Mc(Nc()),Ki=_c(Fc,e=>e??{updateAvailable:null,currentVersion:qr(),isGlobal:!1,isLoading:!0});ve();import{jsx as te,jsxs as rt}from"react/jsx-runtime";var Xi=["#1e3a8a","#3b82f6","#0ea5e9","#06b6d4","#22d3ee"],Gc="\u2500",M=({notification:e})=>{let t=Uc(Ki),o=$c(()=>{if(e)return e;let{updateAvailable:r,currentVersion:i,isGlobal:s,isLoading:l}=t;return l?null:r&&!s?rt(ot,{flexDirection:"column",alignItems:"center",children:[rt(Ie,{color:"yellow",children:[a.warning," ",We.UPDATE_AVAILABLE(i,r)]}),rt(Ie,{color:"blue",children:[a.info," ",We.TIP_INSTALL_UPDATE," ",te(Ie,{bold:!0,children:We.INSTALL_COMMAND})]})]}):r?rt(Ie,{color:"yellow",children:[a.warning," ",We.UPDATE_AVAILABLE(i,r)," (run"," ",te(Ie,{bold:!0,children:We.UPDATE_COMMAND}),")"]}):s?null:rt(Ie,{color:"blue",children:[a.info," ",We.TIP_INSTALL_ACCESS," ",te(Ie,{bold:!0,children:We.INSTALL_COMMAND})]})},[e,t]);return rt(ot,{flexDirection:"column",paddingBottom:1,children:[rt(ot,{flexDirection:"column",alignItems:"center",marginBottom:1,children:[te(ot,{marginBottom:-1,children:te(Jr,{colors:["#1e3a8a","#3b82f6"],children:te(Vi,{text:"TLC",font:"tiny"})})}),te(ot,{children:te(Jr,{colors:Xi,children:te(Vi,{text:"AGENT SKILLS",font:"block"})})}),rt(ot,{marginTop:-1,alignItems:"center",children:[te(Ie,{color:"#334155",children:"\u2500\u2500\u2500\u2500\u2500\u2500 "}),rt(Ie,{color:"white",bold:!0,children:["VERSION ",Kt]}),te(Ie,{color:"#334155",children:" \u2500\u2500\u2500\u2500\u2500\u2500"})]}),te(ot,{marginTop:1,children:te(Ie,{color:"#64748b",italic:!0,children:We.DESCRIPTION})}),o&&te(ot,{marginTop:1,children:o})]}),te(ot,{marginTop:o?0:1,justifyContent:"center",children:te(Jr,{colors:Xi,children:te(Ie,{children:Gc.repeat(60)})})})]})};import{jsx as bo,jsxs as Qr}from"react/jsx-runtime";function zi({onSelect:e,onBack:t,onCredits:o}){let r=[{label:"Install new skills",value:"install",hint:"browse and select skills to install"},{label:"Update existing skills",value:"update",hint:"check for content changes"},{label:"Remove installed skills",value:"remove",hint:"uninstall skills from agents"}];Hc(s=>{s==="c"&&o&&o()});let i=Qr(Jo,{children:[bo(Jo,{color:n.accent,bold:!0,children:"c"}),bo(Jo,{color:n.textDim,children:" credits"})]});return Qr(Yi,{flexDirection:"column",paddingX:1,children:[bo(M,{}),bo(Yi,{marginBottom:1,children:Qr(Jo,{bold:!0,color:n.primary,children:[a.diamond," What would you like to do?"]})}),bo(Ze,{items:r,onSelect:e,onCancel:t,footerRight:i})]})}import{Box as zt,Text as Zr,useInput as Qc,useStdout as Zc}from"ink";import ed from"ink-spinner";import{useState as td}from"react";import{Box as Be,Text as Vt,useInput as Yc}from"ink";import{useEffect as zc}from"react";import{useEffect as jc,useState as Kc}from"react";import{Fragment as Vc,jsx as Xc}from"react/jsx-runtime";var Wi=({visible:e,duration:t=250,children:o})=>{let[r,i]=Kc(e?1:0);return jc(()=>{if(e&&r===1||!e&&r===0)return;let s=Date.now(),l=r,d=e?1:0,m=setInterval(()=>{let p=Date.now()-s,h=Math.min(p/t,1),u=l+(e?h:-h)*Math.abs(d-l),g=Math.max(0,Math.min(1,u));i(g),h>=1&&(clearInterval(m),i(d))},16);return()=>{clearInterval(m)}},[e,t]),!e&&r<=.05?null:Xc(Vc,{children:o})};import{jsx as oe,jsxs as Qo}from"react/jsx-runtime";var Xt=({visible:e,onDismiss:t,shortcuts:o})=>{Yc(()=>{e&&t()},{isActive:e}),zc(()=>{let m;return e&&(m=setTimeout(()=>{t()},8e3)),()=>{m&&clearTimeout(m)}},[e,t]);let r=Math.ceil(o.length/2),i=o.slice(0,r),s=o.slice(r),l=({label:m})=>oe(Be,{flexShrink:0,children:oe(Vt,{backgroundColor:n.bgLight,color:n.accent,bold:!0,children:` ${m} `})}),d=({entry:m})=>Qo(Be,{marginBottom:0,gap:1,children:[oe(Be,{width:10,justifyContent:"flex-end",flexShrink:0,children:oe(l,{label:m.key})}),oe(Vt,{color:n.textDim,children:m.description})]}),c="\u2500".repeat(48);return oe(Wi,{visible:e,duration:200,children:Qo(Be,{borderStyle:"round",borderColor:n.border,backgroundColor:n.bg,paddingX:2,paddingY:1,flexDirection:"column",width:56,children:[oe(Be,{justifyContent:"center",marginBottom:1,children:Qo(Vt,{color:n.accent,bold:!0,children:[a.sparkle," Keyboard Shortcuts"]})}),oe(Be,{justifyContent:"center",children:oe(Vt,{color:n.border,children:c})}),Qo(Be,{marginTop:1,gap:2,children:[oe(Be,{flexDirection:"column",gap:1,flexGrow:1,children:i.map(m=>oe(d,{entry:m},m.key))}),oe(Be,{flexDirection:"column",gap:1,flexGrow:1,children:s.map(m=>oe(d,{entry:m},m.key))})]}),oe(Be,{justifyContent:"center",marginTop:1,children:oe(Vt,{color:n.border,children:c})}),oe(Be,{marginTop:1,justifyContent:"center",children:oe(Vt,{color:n.textMuted,children:"press any key to dismiss"})})]})})};import{Box as Tt,Text as nt,useInput as Wc}from"ink";import{useEffect as qc,useRef as Jc,useState as Zo}from"react";import{jsx as Le,jsxs as wt}from"react/jsx-runtime";function Yt({items:e,onSubmit:t,onCancel:o,onChange:r,initialSelected:i=[],limit:s=10}){let[l,d]=Zo(i),[c,m]=Zo(0),[f,p]=Zo(0),[h,u]=Zo(!1),g=Jc(i);qc(()=>{let k=g.current;(k.length!==i.length||k.some((A,b)=>A!==i[b]))&&(d(i),g.current=i)},[i]),Wc((k,C)=>{if(k==="?"){u(B=>!B);return}if(h){u(!1);return}if(C.return){t(l);return}if(C.escape&&o){o();return}let A=c,b=f;if(C.upArrow?A=c>0?c-1:e.length-1:C.downArrow&&(A=c<e.length-1?c+1:0),A<b?b=A:A>=b+s&&(b=A-s+1),C.upArrow&&c===0?b=Math.max(0,e.length-s):C.downArrow&&c===e.length-1&&(b=0),A!==c&&(m(A),p(b)),k===" "){let B=e[c];if(l.includes(B.value)){let N=l.filter(V=>V!==B.value);d(N),r?.(N)}else{let N=[...l,B.value];d(N),r?.(N)}}if(k==="a"&&C.ctrl)if(l.length===e.length)d([]),r?.([]);else{let B=e.map(N=>N.value);d(B),r?.(B)}});let T=e.slice(f,f+s),P=f>0,O=e.length>f+s,U=[{key:"\u2191/\u2193",description:"Navigate"},{key:"space",description:"Toggle selection"},{key:"enter",description:"Confirm"},{key:"ctrl+a",description:"Select all / none"},...o?[{key:"esc",description:"Cancel"}]:[]];return h?Le(Tt,{flexDirection:"column",flexGrow:1,alignItems:"center",justifyContent:"center",children:Le(Xt,{visible:h,onDismiss:()=>u(!1),shortcuts:U})}):wt(Tt,{flexDirection:"column",children:[P&&Le(Tt,{justifyContent:"center",marginBottom:1,children:wt(nt,{color:n.textDim,children:[a.arrowUp," ",a.arrowUp," ",a.arrowUp]})}),T.map((k,C)=>{let A=C+f,b=A===c,B=l.includes(k.value),N=b?a.bullet:" ",V=B?n.success:n.accent,I=B?a.checkboxActive:a.checkboxInactive,w=B?n.success:n.textMuted,x=b?n.primary:B?n.primaryLight:n.text;return wt(Tt,{backgroundColor:b?n.bgLight:void 0,paddingX:1,children:[Le(Tt,{width:2,children:Le(nt,{color:V,children:N})}),Le(Tt,{width:2,children:Le(nt,{color:w,children:I})}),Le(nt,{color:x,bold:b,children:k.label}),k.hint&&wt(nt,{color:B?n.success:n.textDim,children:[" ",a.dot," ",k.hint]})]},`${String(k.value)}-${A}`)}),O&&Le(Tt,{justifyContent:"center",marginTop:1,children:wt(nt,{color:n.textDim,children:[a.arrowDown," ",a.arrowDown," ",a.arrowDown]})}),Le(dt,{hints:[{key:"space",label:"toggle"},{key:"enter",label:"confirm",color:n.success},...o?[{key:"esc",label:"back",color:n.warning}]:[],{key:"?",label:"help"}],status:l.length>0?wt(nt,{children:[wt(nt,{color:n.success,bold:!0,children:[a.checkboxActive," ",l.length]}),Le(nt,{color:n.textDim,children:" selected"})]}):void 0})]})}ao();import{Fragment as qi,jsx as $e,jsxs as At}from"react/jsx-runtime";var od=28;function Wt({onSelect:e,onBack:t}){let{stdout:o}=Zc(),r=o?.rows??40,i=Math.max(3,r-od),{allAgents:s,installedAgents:l,selectedAgents:d,setSelectedAgents:c,loading:m}=Dn(),f=[{key:"space",description:"Toggle selection"},{key:"enter",description:"Confirm"},{key:"ctrl+a",description:"Select all"},{key:"esc",description:"Go back"}],[p,h]=td(!1);Qc(g=>{g==="?"&&h(T=>!T)});let u=s.map(g=>{let T=Fe(g),P=l.includes(g);return{label:T.displayName,value:g,hint:P?`${a.check} detected`:void 0}});return m?At(zt,{flexDirection:"column",paddingX:1,children:[$e(M,{}),$e(zt,{marginTop:1,children:At(Zr,{color:n.accent,children:[$e(ed,{type:"dots"})," Scanning for installed agents..."]})})]}):At(zt,{flexDirection:"column",paddingX:1,minHeight:20,children:[$e(M,{}),p?At(qi,{children:[$e(zt,{flexDirection:"column",flexGrow:1,alignItems:"center",justifyContent:"center",children:$e(Xt,{visible:p,onDismiss:()=>h(!1),shortcuts:f})}),$e(dt,{hints:[{key:"space",label:"toggle"},{key:"enter",label:"confirm",color:n.success},...t?[{key:"esc",label:"back",color:n.warning}]:[],{key:"?",label:"help"}]})]}):At(qi,{children:[$e(zt,{marginBottom:1,children:At(Zr,{bold:!0,color:n.primary,children:[a.diamond," Where do you want to install skills?"]})}),$e(zt,{marginBottom:1,children:At(Zr,{color:n.textDim,children:[l.length," agents detected on this machine"]})}),$e(Yt,{items:u,initialSelected:d,onSubmit:e,onCancel:t,onChange:c,limit:i})]})]})}import{Box as mt,Text as H,useInput as cd,useStdout as dd}from"ink";import os from"ink-big-text";import ir from"ink-gradient";import{existsSync as md}from"node:fs";import{dirname as rs,join as ud}from"node:path";import{fileURLToPath as gd}from"node:url";import{useCallback as pd,useEffect as nr,useMemo as fd,useRef as ns,useState as qt}from"react";import{execSync as rd,spawn as er}from"node:child_process";import{platform as nd}from"node:os";function id(e){try{return rd(`which ${e}`,{stdio:"ignore"}),!0}catch{return!1}}function sd(e){let t=[{cmd:"mpv",args:["--no-video","--no-terminal",e]},{cmd:"ffplay",args:["-nodisp","-autoexit","-loglevel","quiet",e]},{cmd:"paplay",args:[e]},{cmd:"aplay",args:[e]}];for(let{cmd:o,args:r}of t)if(id(o))return er(o,r,{stdio:"ignore"});return er("mpv",["--no-video","--no-terminal",e],{stdio:"ignore"})}function Ji(e){try{let t=nd(),o;return t==="darwin"?o=er("afplay",[e],{stdio:"ignore"}):t==="win32"?o=er("powershell",["-c",`(New-Object Media.SoundPlayer "${e}").PlaySync()`],{stdio:"ignore"}):o=sd(e),o.on("error",()=>{}),o}catch{return null}}function tr(e){e&&!e.killed&&e.kill()}import Qi from"ky";var Zi="https://api.github.com/repos/tech-leads-club/agent-skills",ld=`${Zi}/contributors`,or=null,rr=null;async function es(){if(or)return or;try{return or=(await Qi.get(ld,{headers:{Accept:"application/vnd.github.v3+json"},timeout:1e4}).json()).filter(({login:t})=>!ad(t)).map(({login:t,avatar_url:o,contributions:r})=>({login:t,avatarUrl:o,contributions:r})),or}catch{return[]}}async function ts(){if(rr!==null)return rr;try{return rr=(await Qi.get(Zi,{headers:{Accept:"application/vnd.github.v3+json"},timeout:1e4}).json()).stargazers_count,rr}catch{return 0}}function ad(e){return e.endsWith("[bot]")}import{jsx as F,jsxs as Re}from"react/jsx-runtime";var hd=220,rn=52,Jt=["#1e3a8a","#3b82f6","#0ea5e9","#06b6d4","#22d3ee"],yd=14,on=500,ss=60,en="\u2500".repeat(rn-4),is=40,tn=["#f59e0b","#ef4444","#ec4899","#a855f7"],xd={1:{badge:`${a.star}${a.star}${a.star}`,color:"#f59e0b"},2:{badge:`${a.star}${a.star}`,color:"#c0c0c0"},3:{badge:a.star,color:"#cd7f32"}};function kd(e,t){let o=[];o.push({type:"blank"}),o.push({type:"text",text:"A Tech Leads Club Production",color:"#94a3b8"}),o.push({type:"blank"}),o.push({type:"blank"}),o.push({type:"gradient",text:`${a.sparkle} C O N T R I B U T O R S ${a.sparkle}`,gradientColors:tn}),o.push({type:"gradient",text:en,gradientColors:Jt}),o.push({type:"blank"});for(let i=0;i<e.length;i++){let s=e[i];o.push({type:"contributor",rank:i+1,login:s.login,contributions:s.contributions})}o.push({type:"blank"}),o.push({type:"blank"}),o.push({type:"gradient",text:`${a.star} S T A T S ${a.star}`,gradientColors:tn}),o.push({type:"gradient",text:en,gradientColors:Jt}),o.push({type:"blank"}),t>0&&o.push({type:"text",text:`${a.star} GitHub Stars \xB7\xB7\xB7\xB7\xB7 ${t}`,color:"#f59e0b",bold:!0}),o.push({type:"text",text:`${a.diamond} Contributors \xB7\xB7\xB7\xB7\xB7 ${e.length}`,color:"#06b6d4"});let r=e.reduce((i,s)=>i+s.contributions,0);return o.push({type:"text",text:`${a.check} Contributions \xB7\xB7\xB7\xB7 ${r}`,color:"#22c55e"}),o.push({type:"blank"}),o.push({type:"blank"}),o.push({type:"gradient",text:`${a.sparkle} S P E C I A L T H A N K S ${a.sparkle}`,gradientColors:tn}),o.push({type:"gradient",text:en,gradientColors:Jt}),o.push({type:"blank"}),o.push({type:"text",text:"To every contributor, stargazer,",color:"#94a3b8"}),o.push({type:"text",text:"and community member who makes",color:"#94a3b8"}),o.push({type:"text",text:"this project possible.",color:"#94a3b8"}),o.push({type:"blank"}),o.push({type:"text",text:"Built with \u2665 by the community",color:"#ef4444"}),o.push({type:"blank"}),o.push({type:"gradient",text:"github.com/tech-leads-club/agent-skills",gradientColors:Jt}),o.push({type:"blank"}),o.push({type:"blank"}),o.push({type:"blank"}),o}function Sd(){try{let e=rs(gd(import.meta.url));for(let t=0;t<5;t++){let o=ud(e,"assets","chiptune.mp3");if(md(o))return o;e=rs(e)}return null}catch{return null}}function bd({rank:e,login:t,contributions:o}){let r=xd[e],i=r?.color??"#e2e8f0",s=e.toString().padStart(2),l=`@${t}`,d=`${o}`,c=r?` ${r.badge}`:"",m=5+l.length+c.length+1+d.length,f=Math.max(2,rn-4-m),p="\xB7".repeat(f);return Re(H,{children:[Re(H,{color:"#64748b",children:[s,". "]}),F(H,{color:i,bold:!!r,children:l}),F(H,{color:r?.color??"#94a3b8",children:c}),Re(H,{color:"#334155",children:[" ",p," "]}),F(H,{color:"#22c55e",bold:!0,children:d})]})}function Cd({line:e}){switch(e.type){case"blank":return F(H,{children:" "});case"text":return F(H,{color:e.color,bold:e.bold,children:e.text});case"gradient":return F(ir,{colors:[...e.gradientColors],children:F(H,{children:e.text})});case"contributor":return F(bd,{rank:e.rank,login:e.login,contributions:e.contributions})}}function Td({speed:e,paused:t}){if(t)return Re(H,{color:n.warning,bold:!0,children:[" ",a.bar,a.bar," PAUSED"]});let o=Math.round((on-e)/(on-ss)*4)+1,r="\u25AE".repeat(o)+"\u25AF".repeat(5-o);return Re(H,{color:n.textMuted,children:[" ",r]})}function sr({onExit:e}){let{stdout:t}=dd(),o=t?.rows??24,r=Math.max(6,o-yd-4),[i,s]=qt([]),[l,d]=qt(0),[c,m]=qt(!0),[f,p]=qt(0),[h,u]=qt(hd),[g,T]=qt(!1),P=ns(null),O=ns(null);nr(()=>{Promise.all([es(),ts()]).then(([w,x])=>{s(w),d(x),m(!1)})},[]),nr(()=>{let w=Sd();return w&&(P.current=Ji(w)),()=>{tr(P.current)}},[]);let U=fd(()=>kd(i,l),[i,l]),k=U.length+r,C=f>=k,A=pd(()=>{p(w=>w>=k?w:w+1)},[k]);if(nr(()=>{if(c||g||C){O.current&&clearInterval(O.current),O.current=null;return}return O.current=setInterval(A,h),()=>{O.current&&clearInterval(O.current)}},[c,g,C,h,A]),nr(()=>{if(!C)return;let w=setTimeout(()=>{tr(P.current),e()},3e3);return()=>clearTimeout(w)},[C,e]),cd((w,x)=>{if(x.escape){tr(P.current),e();return}if(w===" "){T(E=>!E);return}if(x.upArrow){u(E=>Math.max(ss,E-is));return}if(x.downArrow){u(E=>Math.min(on,E+is));return}}),c)return F(mt,{flexDirection:"column",alignItems:"center",padding:2,children:F(H,{color:n.accent,children:"Loading contributors..."})});let b={type:"blank"},B=Array(r).fill(b),N=Array(r).fill(b),I=[...B,...U,...N].slice(f,f+r);return Re(mt,{flexDirection:"column",alignItems:"center",children:[F(mt,{marginBottom:-1,children:F(ir,{colors:["#1e3a8a","#3b82f6"],children:F(os,{text:"TLC",font:"tiny"})})}),F(mt,{children:F(ir,{colors:[...Jt],children:F(os,{text:"AGENT SKILLS",font:"block"})})}),F(mt,{children:F(ir,{colors:[...Jt],children:F(H,{children:"\u2500".repeat(60)})})}),F(mt,{flexDirection:"column",alignItems:"center",height:r,width:rn,children:I.map((w,x)=>F(mt,{justifyContent:"center",children:F(Cd,{line:w})},`cl-${f}-${x}`))}),Re(mt,{marginTop:1,gap:2,children:[Re(H,{children:[F(H,{color:n.accent,bold:!0,children:"space"}),F(H,{color:n.textDim,children:" pause"})]}),F(H,{color:n.textMuted,children:a.dot}),Re(H,{children:[Re(H,{color:n.accent,bold:!0,children:[a.arrowUp,a.arrowDown]}),F(H,{color:n.textDim,children:" speed"})]}),F(Td,{speed:h,paused:g}),F(H,{color:n.textMuted,children:a.dot}),Re(H,{children:[F(H,{color:n.warning,bold:!0,children:"esc"}),F(H,{color:n.textDim,children:" back"})]})]})]})}import{Box as ye,Text as W,useInput as wd}from"ink";import{useState as nn}from"react";import{jsx as $,jsxs as xe}from"react/jsx-runtime";function ls({onConfirm:e,onBack:t,initialMethod:o="copy",initialGlobal:r=!1}){let[i,s]=nn("method"),[l,d]=nn(o),[c,m]=nn(r);return i==="method"?xe(ye,{flexDirection:"column",paddingX:1,children:[$(M,{}),$(ye,{marginBottom:1,children:xe(W,{bold:!0,color:n.primary,children:[a.diamond," Choose installation method:"]})}),$(Ze,{items:[{label:"Copy",value:"copy",hint:"independent copies (recommended)"},{label:"Symlink",value:"symlink",hint:"shared source (may not work with all agents)"}],onSelect:f=>{d(f),s("scope")},onCancel:t})]}):i==="scope"?xe(ye,{flexDirection:"column",paddingX:1,children:[$(M,{}),$(ye,{marginBottom:1,children:xe(W,{bold:!0,color:n.primary,children:[a.diamond," Choose installation scope:"]})}),$(Ze,{items:[{label:"Local",value:!1,hint:"this project only"},{label:"Global",value:!0,hint:"user home directory"}],onSelect:f=>{m(f),s("confirm")},onCancel:()=>s("method")})]}):$(Ad,{method:l,isGlobal:c,onConfirm:()=>e({method:l,global:c}),onBack:()=>s("scope")})}function Ad({method:e,isGlobal:t,onConfirm:o,onBack:r}){return wd((i,s)=>{(s.return||i==="y"||i==="Y")&&o(),(s.escape||i==="n"||i==="N")&&r()}),xe(ye,{flexDirection:"column",paddingX:1,children:[$(M,{}),xe(ye,{flexDirection:"column",borderStyle:"round",borderColor:n.accent,paddingX:2,paddingY:1,children:[$(ye,{marginBottom:1,children:xe(W,{bold:!0,color:n.accent,children:[a.diamond," Ready to install"]})}),xe(ye,{children:[$(ye,{width:10,children:$(W,{color:n.textDim,children:"Method"})}),$(W,{color:n.text,bold:!0,children:e==="copy"?"Copy":"Symlink"}),xe(W,{color:n.textMuted,children:[" ",a.dot," ",e==="copy"?"Recommended":"Developer mode"]})]}),xe(ye,{children:[$(ye,{width:10,children:$(W,{color:n.textDim,children:"Scope"})}),$(W,{color:n.text,bold:!0,children:t?"Global":"Local"}),xe(W,{color:n.textMuted,children:[" ",a.dot," ",t?"User home":"This project"]})]})]}),$(ye,{marginTop:1,borderStyle:"round",borderColor:n.border,paddingX:1,children:$(ye,{justifyContent:"space-between",width:"100%",children:xe(W,{children:[$(W,{color:n.success,bold:!0,children:"Y"}),$(W,{color:n.textDim,children:" / "}),$(W,{color:n.success,bold:!0,children:"enter"}),$(W,{color:n.textDim,children:" confirm"}),xe(W,{color:n.textDim,children:[" ",a.dot," "]}),$(W,{color:n.warning,bold:!0,children:"N"}),$(W,{color:n.textDim,children:" / "}),$(W,{color:n.warning,bold:!0,children:"esc"}),$(W,{color:n.textDim,children:" back"})]})})})]})}import{Box as vt,Text as Pt,useInput as um}from"ink";import gm from"ink-spinner";import{useAtom as Es,useAtomValue as pm,useSetAtom as fm}from"jotai";import{useEffect as hm,useMemo as ym,useState as Et}from"react";ao();Ht();import{atom as as}from"jotai";import{unwrap as Id}from"jotai/utils";var Dd=async()=>{let e=Ao(),t={};for(let o of e){let[r,i]=await Promise.all([Gr(o,!1).catch(()=>[]),Gr(o,!0).catch(()=>[])]);for(let s of new Set([...r,...i]))t[s]||(t[s]=[]),t[s].includes(o)||t[s].push(o)}return t},sn=as(0),Ed=as(async e=>(e(sn),Dd())),Ge=Id(Ed,e=>e??{});import{atom as cs}from"jotai";var lr=cs([]),ds=cs([]);import{Box as He,Text as ie,useInput as vd}from"ink";import{jsx as se,jsxs as Me}from"react/jsx-runtime";function ar({results:e,onExit:t,title:o="Installation Complete",successLabel:r="succeeded"}){vd((u,g)=>{(g.return||g.escape)&&t()});let i=new Set(e.filter(u=>u.success).map(u=>u.skill)),s=new Set(e.filter(u=>!u.success).map(u=>u.skill)),l=i.size,d=s.size,c=l===0&&d>0,m=d>0,f=c?n.error:m?n.warning:n.success,p=c?`${a.cross} Installation Failed`:m?`${a.warning} Partially Installed`:`${a.check} ${o}`,h=c?n.error:m?n.warning:n.success;return Me(He,{flexDirection:"column",paddingX:1,children:[se(M,{}),Me(He,{flexDirection:"column",borderStyle:"round",borderColor:f,paddingX:2,paddingY:1,children:[se(He,{marginBottom:1,children:se(ie,{color:h,bold:!0,children:p})}),e.map((u,g)=>Me(He,{flexDirection:"column",children:[Me(He,{paddingX:1,children:[se(He,{width:2,children:se(ie,{color:u.success?n.success:n.error,children:u.success?a.check:a.cross})}),se(ie,{color:u.success?n.text:n.error,children:u.skill}),Me(ie,{color:n.textDim,children:[" ",a.arrow," ",u.agent]})]}),!u.success&&u.error&&se(He,{paddingLeft:4,children:se(ie,{color:n.error,dimColor:!0,children:u.error})})]},g)),(l>0||d>0)&&se(He,{marginTop:1,children:Me(ie,{color:n.textDim,children:[l>0&&Me(ie,{color:n.success,children:[l," ",r]}),l>0&&d>0&&Me(ie,{children:[" ",a.dot," "]}),d>0&&Me(ie,{color:n.error,children:[d," failed"]})]})}),se(He,{marginTop:1,children:Me(ie,{color:n.textDim,children:["View details: ",se(ie,{color:n.accent,children:"agent-skills audit"})]})})]}),se(He,{marginTop:1,borderStyle:"round",borderColor:n.border,paddingX:1,children:Me(ie,{children:[se(ie,{color:n.success,bold:!0,children:"enter"}),se(ie,{color:n.textDim,children:" / "}),se(ie,{color:n.warning,bold:!0,children:"esc"}),se(ie,{color:n.textDim,children:" exit"})]})})]})}import{Box as X,Text as G,useInput as Rd}from"ink";import Md from"ink-spinner";import{useAtomValue as ms}from"jotai";import{useMemo as ln,useState as an}from"react";qe();import{atom as Pd}from"jotai";import{unwrap as Bd}from"jotai/utils";var Ld=Pd(async()=>No()),Qt=Bd(Ld,e=>e??new Map);import{jsx as _,jsxs as K}from"react/jsx-runtime";function cr({selectedAgents:e,onExit:t}){let[o,r]=an(e||[]),{removeMultiple:i,progress:s,results:l}=Bi(),d=ms(Ge),c=ms(Qt),[m,f]=an(e?"select":"agent-select"),[p,h]=an([]),u=e||o,g=ln(()=>{let k={};return Object.entries(d).forEach(([C,A])=>{let b=A.filter(B=>u.includes(B));b.length>0&&(k[C]=b)}),k},[d,u]),T=ln(()=>Object.keys(g),[g]),P=ln(()=>T.map(k=>{let C=c instanceof Map&&c.has(k),A=`${g[k].length} agents: ${g[k].join(", ")}`,b=C?`${A} \u26A0 deprecated`:A;return{label:k,value:k,hint:b}}),[T,g,c]);if(Rd((k,C)=>{m==="done"&&(C.return||C.escape)&&t(),T.length===0&&C.escape&&t()}),m==="agent-select")return _(Wt,{onSelect:k=>{r(k),f("select")},onBack:t});if(T.length===0)return K(X,{flexDirection:"column",paddingX:1,children:[_(M,{}),_(X,{borderStyle:"round",borderColor:n.warning,paddingX:2,paddingY:1,children:_(G,{color:n.warning,children:"No skills found to remove for the selected agents."})}),_(X,{marginTop:1,borderStyle:"round",borderColor:n.border,paddingX:1,children:K(G,{children:[_(G,{color:n.warning,bold:!0,children:"esc"}),_(G,{color:n.textDim,children:" exit"})]})})]});let O=k=>{k.length!==0&&(h(k),f("confirm"))},U=async()=>{f("removing");let k=p.map(C=>({name:C,agents:g[C]||[]}));await i(k),f("done")};if(m==="select")return K(X,{flexDirection:"column",paddingX:1,children:[_(M,{}),_(X,{marginBottom:1,children:K(G,{bold:!0,color:n.error,children:[a.diamond," Select skills to remove:"]})}),_(Yt,{items:P,onSubmit:O,onCancel:t})]});if(m==="confirm")return K(X,{flexDirection:"column",paddingX:1,children:[_(M,{}),K(X,{flexDirection:"column",borderStyle:"round",borderColor:n.error,paddingX:2,paddingY:1,children:[_(X,{marginBottom:1,children:K(G,{color:n.error,bold:!0,children:[a.cross," Remove ",p.length," skill",p.length>1?"s":"","?"]})}),p.map(k=>K(X,{paddingX:1,children:[_(X,{width:2,children:_(G,{color:n.error,children:a.dot})}),_(G,{color:n.textDim,children:k})]},k))]}),_(X,{marginTop:1,children:_(Ze,{items:[{label:"Yes, remove them",value:"yes"},{label:"No, cancel",value:"no"}],onSelect:k=>{k==="yes"?U():f("select")}})})]});if(m==="removing")return K(X,{flexDirection:"column",paddingX:1,children:[_(M,{}),K(X,{marginTop:1,children:[K(G,{color:n.accent,children:[_(Md,{type:"dots"})," "]}),_(G,{children:"Removing skills..."})]}),_(X,{marginTop:1,paddingX:2,children:K(G,{color:n.textDim,children:[a.arrow," ",s.skill," (",s.current,"/",s.total,")"]})})]});if(m==="done"){let k=l.filter(b=>b.success).length,C=l.filter(b=>!b.success).length,A=k===0;return K(X,{flexDirection:"column",paddingX:1,children:[_(M,{}),K(X,{flexDirection:"column",borderStyle:"round",borderColor:A?n.error:n.success,paddingX:2,paddingY:1,children:[_(X,{marginBottom:1,children:K(G,{color:A?n.error:n.success,bold:!0,children:[A?a.cross:a.check," ",A?"Removal Failed":"Removal Complete"]})}),l.map((b,B)=>K(X,{paddingX:1,children:[_(X,{width:2,children:_(G,{color:b.success?n.success:n.error,children:b.success?a.check:a.cross})}),_(G,{color:b.success?n.text:n.error,children:b.skill}),K(G,{color:n.textDim,children:[" ",a.arrow," ",b.agent]}),!b.success&&b.error&&K(G,{color:n.error,children:[" (",b.error,")"]})]},B)),(k>0||C>0)&&_(X,{marginTop:1,children:K(G,{color:n.textDim,children:[k>0&&K(G,{color:n.success,children:[k," succeeded"]}),k>0&&C>0&&K(G,{children:[" ",a.dot," "]}),C>0&&K(G,{color:n.error,children:[C," failed"]})]})})]}),_(X,{marginTop:1,borderStyle:"round",borderColor:n.border,paddingX:1,children:K(G,{children:[_(G,{color:n.success,bold:!0,children:"enter"}),_(G,{color:n.textDim,children:" / "}),_(G,{color:n.warning,bold:!0,children:"esc"}),_(G,{color:n.textDim,children:" exit"})]})})]})}return null}import{Box as J,Text as De,useInput as om,useStdout as rm}from"ink";import{useAtomValue as un}from"jotai";import{useMemo as gn,useState as it}from"react";import{Box as gs,Text as Zt}from"ink";import{useMemo as _d}from"react";function us(e,t){return e>0?`(${e}/${t})`:`(${t})`}import{jsx as dr,jsxs as mr}from"react/jsx-runtime";var ps=({name:e,totalCount:t,installedCount:o=0,isExpanded:r=!1,isFocused:i=!1})=>{let s=_d(()=>us(o,t),[o,t]),l=r?"\u25BE":"\u25B8";return mr(gs,{children:[dr(gs,{width:2,children:i?dr(Zt,{color:n.accent,children:a.bullet}):dr(Zt,{children:" "})}),mr(Zt,{color:i?n.accent:n.primaryLight,bold:!0,children:[l," "]}),dr(Zt,{color:i?n.accent:n.text,bold:!0,children:e}),mr(Zt,{color:o>0?n.success:n.textMuted,children:[" ",s]}),!r&&i&&mr(Zt,{color:n.textDim,children:[" ",a.dot," press space to expand"]})]})};import{Box as jy,Text as Ky,useInput as Vy}from"ink";import{useState as Yy}from"react";import{jsx as qy,jsxs as Jy}from"react/jsx-runtime";import{Box as ur,Text as fs}from"ink";import Od from"ink-text-input";import{jsx as eo,jsxs as Nd}from"react/jsx-runtime";var hs=({query:e,onChange:t,total:o,filtered:r,isLoading:i=!1,focus:s=!0})=>Nd(ur,{borderStyle:"round",borderColor:s?n.accent:n.border,paddingX:1,children:[eo(ur,{marginRight:1,children:eo(fs,{children:"\u{1F50D}"})}),eo(ur,{flexGrow:1,children:eo(Od,{value:e,onChange:t,placeholder:"Type to filter skills...",focus:s})}),eo(ur,{marginLeft:1,children:eo(fs,{color:n.textDim,children:i?"Loading...":`${r}/${o} skills`})})]});import{Box as It,Text as gr}from"ink";import{Box as Fd,Text as Ud}from"ink";import{jsx as Hd,jsxs as Gd}from"react/jsx-runtime";var $d={installed:{icon:a.check,label:"installed",color:n.success,bg:"#052e16"},update:{icon:a.arrowUp,label:"update",color:n.warning,bg:"#422006"},new:{icon:a.sparkle,label:"new",color:n.accent,bg:"#083344"},deprecated:{icon:a.warning,label:"deprecated",color:n.warning,bg:"#422006"}};function ys({status:e}){let t=$d[e];return t?Hd(Fd,{children:Gd(Ud,{backgroundColor:t.bg,color:t.color,children:[" ",t.icon," ",t.label," "]})}):null}import{jsx as je,jsxs as xs}from"react/jsx-runtime";function ks({name:e,description:t,status:o,selected:r=!1,focused:i=!1,readOnly:s=!1}){let l=o==="installed",d=l?a.checkboxActive:r?a.checkboxActive:a.checkboxInactive,c=l?n.textMuted:r?n.success:n.textMuted,m=i?a.bullet:" ",f=l?n.textMuted:r?n.success:n.accent,p=l?n.textDim:i?n.primary:r?n.primaryLight:n.text,h=n.textMuted,u=i?n.bgLight:void 0;return xs(It,{flexDirection:"column",backgroundColor:u,children:[xs(It,{children:[je(It,{width:2,flexShrink:0,children:je(gr,{color:f,children:m})}),!s&&je(It,{width:2,flexShrink:0,children:je(gr,{color:c,children:d})}),je(It,{flexGrow:1,children:je(gr,{bold:!0,color:p,children:e})}),o&&je(It,{marginLeft:1,flexShrink:0,children:je(ys,{status:o})})]}),je(It,{paddingLeft:s?2:4,children:je(gr,{color:h,wrap:"truncate",children:t})})]})}import Ke from"chalk";import{Box as Dt,Text as re,useInput as jd,useStdout as Kd}from"ink";import Vd from"ink-spinner";import Cs,{useCallback as Xd,useEffect as Yd,useMemo as zd,useRef as dn,useState as Wd}from"react";var cn={web:"#3b82f6",devops:"#10b981",data:"#8b5cf6",mobile:"#f59e0b",testing:"#ef4444",ai:"#06b6d4",security:"#ec4899",default:"#64748b"};function Ss(e){return Object.prototype.hasOwnProperty.call(cn,e)?cn[e]:cn.default}mo();import{Fragment as em,jsx as fe,jsxs as Se}from"react/jsx-runtime";var qd=6,Jd=2,Qd=2,ke={h1:e=>Ke.hex(n.primary).bold(e),h2:e=>Ke.hex(n.primaryLight).bold(e),h3:e=>Ke.hex(n.accent).bold(e),text:e=>Ke.hex(n.textDim)(e),muted:e=>Ke.hex(n.textMuted)(e),code:e=>Ke.hex(n.accent)(e),border:e=>Ke.hex(n.border)(e),bold:e=>Ke.hex(n.text).bold(e),dim:e=>Ke.dim(e),indicator:e=>Ke.hex(n.textDim)(e)};function bs(e){return e.replace(/\*\*(.+?)\*\*/g,(t,o)=>ke.bold(o)).replace(/\*(.+?)\*/g,(t,o)=>ke.dim(o)).replace(/`(.+?)`/g,(t,o)=>ke.code(o))}function Zd(e){let t=[];for(let o of e)switch(o.type){case"heading":{let r=o.level===1?a.diamond:o.level===2?a.arrow:a.dot,i=o.level===1?ke.h1:o.level===2?ke.h2:ke.h3;o.level===1&&t.length>0&&t.push(""),t.push(i(`${r} ${o.text}`));break}case"paragraph":t.push(ke.text(bs(o.text)));break;case"list-item":{let r=" ".repeat(o.indent);t.push(`${r}${ke.muted(a.bullet)} ${ke.text(bs(o.text))}`);break}case"code-block":o.language&&t.push(ke.dim(` ${o.language}`));for(let r of o.lines)t.push(` ${ke.border(a.bar)} ${ke.code(r)}`);break;case"hr":t.push(ke.border("\u2500".repeat(30)));break;case"blank":t.push("");break}return t}var Ts=Cs.memo(({skill:e,metadata:t})=>{let o=Ss(e.category??"default"),r=t?.author?` ${a.dot} @${t.author}`:"",i=t?.files?.length?` ${a.dot} ${t.files.length} file${t.files.length!==1?"s":""}`:"";return Se(Dt,{flexDirection:"column",marginBottom:1,children:[Se(re,{bold:!0,color:n.text,children:[a.sparkle," ",e.name]}),Se(re,{children:[fe(re,{color:o,bold:!0,children:e.category}),Se(re,{color:n.textDim,children:[r,i]})]}),fe(re,{color:n.textDim,wrap:"truncate",children:e.description})]})});Ts.displayName="MetadataHeader";var mn=Cs.memo(({skill:e,expanded:t=!1,onClose:o,onToggleExpand:r})=>{let{metadata:i,content:s,loading:l,error:d}=Li(e?.name??null),{stdout:c}=Kd(),[m,f]=Wd(0),p=c?.rows??24,h=zd(()=>s?Zd(qn(s)):[],[s]),u=Math.max(10,p-17),g=Math.max(3,u-qd-Jd),T=Math.max(1,g-Qd),P=Math.max(0,h.length-T),O=P>0,U=O?Math.round((m+T)/h.length*100):100,k=dn(P);k.current=P;let C=dn(o);C.current=o;let A=dn(r);A.current=r;let b=Xd((I,w)=>{w.upArrow?f(x=>Math.max(0,x-1)):w.downArrow?f(x=>Math.min(k.current,x+1)):I==="f"?A.current?.():(w.escape||w.tab||w.leftArrow)&&C.current()},[]);if(jd(b),Yd(()=>{f(0)},[e?.name]),!e)return null;let B=m>0,N=m+T<h.length,V=h.slice(m,m+T);return Se(Dt,{flexDirection:"column",borderStyle:"round",borderColor:n.accent,paddingX:1,flexGrow:1,children:[Se(Dt,{children:[Se(re,{bold:!0,color:n.accent,children:[a.info," Skill Details"]}),fe(Dt,{flexGrow:1}),Se(re,{color:n.textMuted,children:[O&&Se(re,{color:n.textDim,children:[U,"% ",a.dot," "]}),fe(re,{color:n.accent,bold:!0,children:"\u2191\u2193"})," ","scroll ",a.dot," ",fe(re,{color:n.accent,bold:!0,children:"f"})," ",t?"compact":"expand"," ",a.dot," ",fe(re,{color:n.accent,bold:!0,children:"Esc"})," ","close"]})]}),fe(re,{color:n.border,wrap:"truncate",children:"\u2500".repeat(200)}),l?fe(Dt,{alignItems:"center",justifyContent:"center",flexGrow:1,children:Se(re,{color:n.accent,children:[fe(Vd,{type:"dots"})," Loading\u2026"]})}):d?fe(Dt,{alignItems:"center",justifyContent:"center",flexGrow:1,children:Se(re,{color:n.error,children:[a.cross," ",d]})}):Se(em,{children:[fe(Ts,{skill:e,metadata:i}),Se(Dt,{flexDirection:"column",height:g,overflowY:"hidden",children:[B&&fe(re,{color:n.textDim,children:` ${a.arrowUp} ${a.arrowUp} ${a.arrowUp}`}),fe(re,{children:V.join(`
12
+ `)}),N&&fe(re,{color:n.textDim,children:` ${a.arrowDown} ${a.arrowDown} ${a.arrowDown}`})]})]})]})});mn.displayName="SkillDetailPanel";function tm(){return{width:process.stdout.columns||80,height:process.stdout.rows||24}}function ws(){let{width:e,height:t}=tm();return e>=80&&t>=24}import{Fragment as am,jsx as j,jsxs as le}from"react/jsx-runtime";var nm=5,im=24,sm=.35,lm=e=>{let t=[{key:"/",description:"Filter skills"},{key:"\u2190/\u2192",description:"Collapse / expand"},{key:"tab/\u2192",description:"Skill details"},{key:"f",description:"Expand / compact panel"}],o={key:"esc",description:e?"Exit / close panel":"Back / close panel"};return e?[...t,o]:[...t,{key:"space",description:"Toggle / expand"},{key:"enter",description:"Install selected"},{key:"ctrl+a",description:"Select all"},o]},pr=({onInstall:e,onExit:t,overrideSkills:o,readOnly:r=!1})=>{let{skills:i,loading:s,error:l}=ct(),{stdout:d}=rm(),c=un(lr),m=un(Ge),f=un(Qt),p=o||i,h=o?!1:s,{query:u,setQuery:g,filtered:T}=Mn(p,{keys:["name","description","category"]}),[P,O]=it(new Set),[U,k]=it("list"),[C,A]=it(0),[b,B]=it(0),[N,V]=it(!1),[I,w]=it(!1),[x,E]=it(null),[Q,Z]=it(!1),[Co,Ye]=it(null),ee=ws(),Oe=d?.rows??40,hr=d?.columns??120,ze=Math.max(nm,Oe-im),Vs=Math.max(30,Math.round(hr*sm)),Xs=Math.max(10,Oe-17),yn=u.trim().length>0,xn=gn(()=>Vo(T),[T]);gn(()=>{u&&V(!0)},[u]);let io=y=>yn||Co===y,kn=y=>{Ye(io(y)?null:y)},Ce=gn(()=>{let y=[];for(let[L,Te]of xn.entries()){let Rt=Te.filter(so=>{let To=m[so.name]||[];return c.length>0?To.some(Cn=>c.includes(Cn)):To.length>0}).length;y.push({type:"header",category:L.name,categoryId:L.id,count:Te.length,installedCount:Rt}),io(L.name)&&Te.forEach(so=>y.push({type:"skill",skill:so}))}return y},[xn,Co,yn,m,c]),Ys=()=>w(y=>!y),zs=()=>{if(N){V(!1),g(""),k("list");return}t?.()},Ws=()=>{let y=T.map(L=>L.name);O(P.size===y.length?new Set:new Set(y))},qs=y=>{(y.downArrow||y.return)&&Ce.length>0&&(k("list"),A(0))},Js=()=>{if(C===0&&N){k("search");return}let y=Math.max(0,C-1);A(y),y<b&&B(y)},Qs=()=>{let y=Math.min(Ce.length-1,C+1);A(y),y>=b+ze&&B(y-ze+1)},Zs=()=>{let y=Ce[C];if(y.type==="header"){kn(y.category);return}if(y.type==="skill"&&!r){if((c.length>0?m[y.skill.name]?.some(Rt=>c.includes(Rt))??!1:(m[y.skill.name]?.length??0)>0)&&!o)return;let Te=new Set(P);Te.has(y.skill.name)?Te.delete(y.skill.name):Te.add(y.skill.name),O(Te)}},el=()=>{let y=Ce[C];if(y.type==="header"){kn(y.category);return}if(r)return;let L=p.filter(Te=>P.has(Te.name));L.length>0&&e?.(L)},Sn=y=>{let L=Ce[C];if(L.type==="skill"&&ee){E(L.skill),Z(!1);return}!y&&L.type==="header"&&!io(L.category)&&Ye(L.category)},tl=()=>{let y=Ce[C];y.type==="header"&&io(y.category)&&Ye(null)},ol=(y,L)=>y.length===1&&!L.ctrl&&!L.meta&&!L.upArrow&&!L.downArrow&&!L.leftArrow&&!L.rightArrow;om((y,L)=>{if(y==="?")return Ys();if(I)return w(!1);if(L.escape)return zs();if(!N&&y==="/"){V(!0),k("search");return}if(y==="a"&&L.ctrl&&!r)return Ws();if(U==="search")return qs(L);if(U==="list"){if(L.upArrow)return Js();if(L.downArrow)return Qs();if(y===" ")return Zs();if(L.return)return el();if(L.tab)return Sn(!0);if(L.rightArrow)return Sn(!1);if(L.leftArrow)return tl();ol(y,L)&&(V(!0),k("search"),g(y))}},{isActive:!x});let rl=Ce.slice(b,b+ze),nl=b>0,il=b+ze<Ce.length,sl=Ce.length<=ze?100:Math.round((b+ze)/Ce.length*100),ll=!x||!Q;if(h)return le(J,{flexDirection:"column",paddingX:1,children:[j(M,{}),j(J,{flexDirection:"column",alignItems:"center",justifyContent:"center",paddingY:4,children:j(De,{color:n.accent,children:"Loading skills..."})})]});if(l||!h&&p.length===0)return le(J,{flexDirection:"column",paddingX:1,minHeight:20,children:[j(M,{}),le(J,{flexDirection:"column",alignItems:"center",justifyContent:"center",flexGrow:1,children:[le(J,{flexDirection:"column",borderStyle:"round",borderColor:n.error,paddingX:3,paddingY:2,alignItems:"center",children:[le(De,{color:n.error,bold:!0,children:[a.cross," No Skills Available"]}),j(J,{marginTop:1,children:j(De,{color:n.textDim,children:"Check your internet connection and try again"})}),l&&j(J,{marginTop:1,children:j(De,{color:n.textMuted,dimColor:!0,children:l})})]}),j(J,{marginTop:2,children:le(De,{color:n.textDim,children:["Press"," ",j(De,{color:n.accent,bold:!0,children:"Esc"})," ","to exit"]})})]})]});let al=(y,L)=>{let Te=b+L,Rt=U==="list"&&Te===C;if(y.type==="header")return j(J,{marginTop:L===0?0:1,children:j(ps,{name:y.category,categoryId:y.categoryId,totalCount:y.count,installedCount:y.installedCount,isExpanded:io(y.category),isFocused:Rt})},`cat-${y.category}`);let so=P.has(y.skill.name),To=c.length>0?m[y.skill.name]?.some(ul=>c.includes(ul))??!1:(m[y.skill.name]?.length??0)>0,ml=f instanceof Map&&f.has(y.skill.name)?"deprecated":To?"installed":null;return j(ks,{name:y.skill.name,description:y.skill.description,status:ml,selected:so,focused:Rt,readOnly:r},y.skill.name)},bn=y=>j(J,{justifyContent:"center",marginBottom:y==="up"?1:0,marginTop:y==="down"?1:0,children:le(De,{color:n.textDim,children:[y==="up"?a.arrowUp:a.arrowDown," ",y==="up"?a.arrowUp:a.arrowDown," ",y==="up"?a.arrowUp:a.arrowDown]})}),cl=()=>x?[{key:"\u2191/\u2193",label:"scroll"},{key:"f",label:Q?"compact":"expand"},{key:"Esc",label:"close",color:n.warning}]:r?[{key:"/",label:"filter"},{key:"tab",label:"detail"},{key:"esc",label:"exit",color:n.warning},{key:"?",label:"help"}]:[{key:"space",label:"toggle"},{key:"enter",label:"install",color:n.success},{key:"/",label:"filter"},{key:"tab",label:"detail"},{key:"esc",label:"exit",color:n.warning},{key:"?",label:"help"}],dl=()=>{if(!x)return le(am,{children:[!r&&P.size>0&&le(De,{children:[le(De,{color:n.success,bold:!0,children:[a.checkboxActive," ",P.size]}),j(De,{color:n.textDim,children:" selected"})]}),Ce.length>ze&&le(De,{color:n.textDim,children:[!r&&P.size>0?` ${a.dot} `:"",sl,"%"]})]})};return le(J,{flexDirection:"column",paddingX:1,minHeight:20,children:[j(M,{}),I?j(J,{flexDirection:"column",flexGrow:1,alignItems:"center",justifyContent:"center",children:j(Xt,{visible:I,onDismiss:()=>w(!1),shortcuts:lm(r)})}):le(J,{flexDirection:"row",height:x?Xs:void 0,flexGrow:x?0:1,overflow:"hidden",children:[ll&&le(J,{flexDirection:"column",flexGrow:1,flexShrink:1,children:[N&&j(J,{marginBottom:1,children:j(hs,{query:u,onChange:y=>{g(y),A(0),B(0)},total:p.length,filtered:T.length,isLoading:h,focus:U==="search"})}),le(J,{flexDirection:"column",flexGrow:1,children:[nl&&bn("up"),rl.map(al),il&&bn("down"),Ce.length===0&&j(J,{paddingY:1,children:le(De,{color:n.textMuted,children:['No skills match "',u,'"']})})]})]},"skill-list"),x&&j(J,{flexDirection:"column",width:Q?void 0:Vs,flexGrow:Q?1:0,flexShrink:0,children:j(mn,{skill:x,expanded:Q,onClose:()=>{E(null),Z(!1)},onToggleExpand:()=>Z(y=>!y)})},"detail-panel")]}),j(dt,{hints:cl(),status:dl()})]})};import{Box as he,Text as ae,useInput as cm}from"ink";import As from"ink-spinner";import{useAtomValue as Is}from"jotai";import{useEffect as dm,useMemo as Ds,useState as to}from"react";qe();import{jsx as Y,jsxs as q}from"react/jsx-runtime";function fr({selectedAgents:e,onExit:t}){let[o,r]=to(!1),[i,s]=to(!1),[l,d]=to(!1),[c,m]=to(e||[]),[f,p]=to(!e),[h,u]=to([]),{install:g,progress:T,results:P,installing:O}=Go(),U=Is(Ge),k=Is(Qt),{skills:C,loading:A}=ct(),b=e||c,B=Ds(()=>{if(A)return[];let I=new Set(Object.keys(U));return C.filter(w=>I.has(w.name)?(U[w.name]||[]).some(E=>b.includes(E)):!1)},[U,C,A,b]),N=Ds(()=>{if(A||!(k instanceof Map)||k.size===0)return[];let I=new Set(Object.keys(U)),w=new Set(C.map(E=>E.name)),x=[];for(let E of I)k.has(E)?x.push({name:E,entry:k.get(E)}):w.has(E)||x.push({name:E});return x},[U,C,A,k]);if(dm(()=>{if(B.length===0){r(!1),s(!0);return}r(!0),(async()=>{let w=B.map(Q=>Q.name),{toUpdate:x}=await Oo(w),E=B.filter(Q=>x.includes(Q.name));u(E),r(!1),s(!0)})()},[B]),cm((I,w)=>{w.escape&&!O&&!l&&!o&&i&&h.length===0&&t()}),f)return Y(Wt,{onSelect:I=>{m(I),p(!1)},onBack:t});let V=async I=>{if(I.length===0)return;let w=new Set;I.forEach(x=>{(U[x.name]||[]).forEach(Q=>{b.includes(Q)&&w.add(Q)})}),await g(I,{agents:Array.from(w),method:"copy",global:!1,skills:I.map(x=>x.name),isUpdate:!0}),d(!0)};return l?Y(ar,{results:P,onExit:t,title:"Skills Updated Successfully",successLabel:"updated"}):O?q(he,{flexDirection:"column",paddingX:1,children:[Y(M,{}),q(he,{marginTop:1,children:[q(ae,{color:n.accent,children:[Y(As,{type:"dots"})," "]}),Y(ae,{children:"Updating skills..."})]}),Y(he,{marginTop:1,paddingX:2,children:q(ae,{color:n.textDim,children:[a.arrow," ",T.skill," (",T.current,"/",T.total,")"]})})]}):A||o?q(he,{flexDirection:"column",paddingX:1,children:[Y(M,{}),Y(he,{marginTop:1,children:q(ae,{color:n.accent,children:[Y(As,{type:"dots"})," ",o?"Checking for updates...":"Loading..."]})})]}):i&&h.length===0?q(he,{flexDirection:"column",paddingX:1,children:[Y(M,{}),Y(he,{borderStyle:"round",borderColor:n.success,paddingX:2,paddingY:1,children:q(ae,{color:n.success,children:[a.check," All installed skills are up to date!"]})}),N.length>0&&q(he,{flexDirection:"column",marginTop:1,borderStyle:"round",borderColor:n.warning,paddingX:2,paddingY:1,children:[Y(he,{marginBottom:1,children:q(ae,{color:n.warning,bold:!0,children:[a.warning," ",N.length," deprecated skill",N.length>1?"s":""," detected:"]})}),N.map(I=>q(he,{flexDirection:"column",paddingX:1,marginBottom:1,children:[q(ae,{color:n.warning,children:[a.arrow," ",I.name]}),I.entry?.message&&q(ae,{color:n.textDim,children:[" ",I.entry.message]}),!I.entry&&Y(ae,{color:n.textDim,children:" No longer available in the registry"}),I.entry?.alternatives&&I.entry.alternatives.length>0&&q(ae,{color:n.textDim,children:[" ","Try: agent-skills install --skill ",I.entry.alternatives.join(", ")]})]},I.name)),q(ae,{color:n.textMuted,children:["Run: agent-skills remove --skill ","<name>"," to clean up"]})]}),Y(he,{marginTop:1,borderStyle:"round",borderColor:n.border,paddingX:1,children:q(ae,{children:[Y(ae,{color:n.warning,bold:!0,children:"esc"}),Y(ae,{color:n.textDim,children:" exit"})]})})]}):Y(mm,{skills:h,installedSkills:U,selectedAgents:b,onUpdate:V,onExit:t})}function mm({skills:e,installedSkills:t,selectedAgents:o,onUpdate:r,onExit:i}){let s=e.map(c=>{let f=(t[c.name]||[]).filter(p=>o.includes(p));return{label:c.name,value:c.name,hint:`${f.length} agent${f.length>1?"s":""}: ${f.join(", ")}`}}),l=e.map(c=>c.name),d=c=>{let m=e.filter(f=>c.includes(f.name));r(m)};return q(he,{flexDirection:"column",paddingX:1,children:[Y(M,{}),Y(he,{marginBottom:1,children:q(ae,{bold:!0,color:n.primary,children:[a.diamond," Select skills to update:"]})}),Y(he,{marginBottom:1,children:q(ae,{color:n.textDim,children:[e.length," installed skill",e.length>1?"s":""," found ",a.dot," all pre-selected"]})}),Y(Yt,{items:s,initialSelected:l,onSubmit:d,onCancel:i})]})}import{jsx as ne,jsxs as st}from"react/jsx-runtime";function vs({onExit:e}){let{step:t,next:o,back:r}=_i(5),[i,s]=Es(lr),[l,d]=Es(ds),c=fm(sn),m=pm(Ge),[f,p]=Et("install"),[h,u]=Et(!1),[g,T]=Et(!1),[P,O]=Et(!1),[U,k]=Et({method:"copy",global:!1}),{skills:C}=ct(),{install:A,progress:b,results:B,installing:N}=Go(),[V,I]=Et(!1),[w,x]=Et(!1),E=ee=>{ee.length!==0&&(s(ee),o())},Q=ee=>{if(p(ee),ee==="update"){T(!0);return}if(ee==="remove"){O(!0);return}o()},Z=ee=>{ee.length!==0&&(d(ee),o())},Co=ee=>{k(ee),o()},Ye=ym(()=>{if(f==="install")return;let ee=new Set;return Object.entries(m).forEach(([Oe,hr])=>{hr.some(ze=>i.includes(ze))&&ee.add(Oe)}),C.filter(Oe=>ee.has(Oe.name))},[f,m,C,i]);return hm(()=>{(async()=>t===5&&!V&&!w&&(I(!0),await A(l,{agents:i,skills:l.map(Oe=>Oe.name),method:U.method,global:U.global}),x(!0),c(Oe=>Oe+1)))()},[t,V,w,A,l,i,c]),t===5?w?ne(ar,{results:B,onExit:e,title:"Installation Complete",successLabel:"installed"}):st(vt,{flexDirection:"column",paddingX:1,children:[ne(M,{}),st(vt,{marginTop:1,children:[st(Pt,{color:n.accent,children:[ne(gm,{type:"dots"})," "]}),st(Pt,{children:["Installing ",l.length," skills to ",i.length," agents..."]})]}),N&&ne(vt,{marginTop:1,paddingX:2,children:st(Pt,{color:n.textDim,children:[a.arrow," ",b.skill," (",b.current,"/",b.total,")"]})})]}):g?ne(fr,{selectedAgents:i,onExit:()=>T(!1)}):P?ne(cr,{selectedAgents:i,onExit:()=>O(!1)}):h?ne(sr,{onExit:()=>u(!1)}):st(vt,{flexDirection:"column",children:[t===1&&ne(Wt,{onSelect:E,onBack:e}),t===2&&ne(zi,{onSelect:Q,onBack:r,onCredits:()=>u(!0)}),t===3&&(f==="install"||Ye&&Ye.length>0)&&ne(pr,{onInstall:Z,onExit:r,overrideSkills:Ye}),t===3&&f==="update"&&Ye&&Ye.length===0&&ne(xm,{onBack:r}),t===4&&ne(ls,{onConfirm:Co,onBack:r,initialMethod:"copy",initialGlobal:!1})]})}function xm({onBack:e}){return um((t,o)=>{(o.escape||t==="b"||o.backspace)&&e()}),st(vt,{flexDirection:"column",paddingX:1,children:[ne(M,{}),ne(vt,{borderColor:n.success,borderStyle:"round",paddingX:2,paddingY:1,children:st(Pt,{color:n.success,bold:!0,children:[a.check," All skills are up to date on selected agents"]})}),ne(vt,{marginTop:1,borderStyle:"round",borderColor:n.border,paddingX:1,children:st(Pt,{children:[ne(Pt,{color:n.warning,bold:!0,children:"esc"}),ne(Pt,{color:n.textDim,children:" back"})]})})]})}import{Box as Ps,Text as pn}from"ink";import{useAtomValue as km}from"jotai";import{useMemo as Sm}from"react";import{jsx as oo,jsxs as Bs}from"react/jsx-runtime";function Ls({onExit:e}){let t=km(Ge),{skills:o,loading:r}=ct(),i=Sm(()=>{if(r)return[];let s=new Set(Object.keys(t));return o.filter(l=>s.has(l.name))},[t,o,r]);return r?Bs(Ps,{flexDirection:"column",padding:1,children:[oo(M,{}),oo(pn,{children:"Loading..."})]}):i.length===0?Bs(Ps,{flexDirection:"column",padding:1,children:[oo(M,{}),oo(pn,{color:n.warning,children:"No skills installed."}),oo(pn,{color:n.textDim,children:"(Press any key to exit)"})]}):oo(pr,{onExit:e,readOnly:!0,overrideSkills:i})}import{jsx as ut,jsxs as wm}from"react/jsx-runtime";var Bt=({command:e="install"})=>{let{exit:t}=bm(),[o,r]=Tm(e==="arcade"),{activated:i,reset:s}=Pi();return Cm(()=>{i&&!o&&(r(!0),s())},[i,o,s]),e==="credits"?ut(fn,{flexDirection:"column",padding:1,children:ut(sr,{onExit:t})}):o?ut(fn,{flexDirection:"column",padding:1,children:ut(Wr,{onExit:()=>{e==="arcade"?t():r(!1)}})}):wm(fn,{flexDirection:"column",padding:1,children:[e==="list"&&ut(Ls,{onExit:t}),e==="remove"&&ut(cr,{onExit:t}),e==="update"&&ut(fr,{onExit:t}),(e==="install"||!e)&&ut(vs,{onExit:t})]})};var Xe=new Om;Xe.name("agent-skills").description("CLI to install and manage skills for AI coding agents").version(Kt);Xe.action(()=>{ro(no.createElement(Bt,{command:"install"}))});Xe.command("install").description("Install skills (interactive by default)").option("-g, --global","Install globally to user home",!1).option("-s, --skill <names...>","Install one or more skills").option("-a, --agent <agents...>","Target specific agents").option("--symlink","Use symlink instead of copy",!1).option("-f, --force","Force re-download skills (bypass cache)",!1).action(async e=>{if(hn(e)){ro(no.createElement(Bt,{command:"install"}));return}let{runCliInstall:t}=await Promise.resolve().then(()=>(Ms(),Rs));await t(e)});Xe.command("list").alias("ls").description("List available/installed agent skills").action(()=>{ro(no.createElement(Bt,{command:"list"}))});Xe.command("remove").alias("rm").description("Remove installed skills").option("-g, --global","Remove from global installation",!1).option("-s, --skill <names...>","Remove one or more skills").option("-a, --agent <agents...>","Target specific agents").option("-f, --force","Force removal even if not in lockfile",!1).action(async e=>{if(hn(e)){ro(no.createElement(Bt,{command:"remove"}));return}let{runCliRemove:t}=await Promise.resolve().then(()=>(Os(),_s));await t(e)});Xe.command("update").description("Update installed skills to the latest version").option("-s, --skill <name>","Update a specific skill").action(async e=>{if(hn(e)){ro(no.createElement(Bt,{command:"update"}));return}let{runCliUpdate:t}=await Promise.resolve().then(()=>(Fs(),Ns));await t(e)});Xe.command("cache").description("Manage the skills cache").option("--clear","Clear all cached skills and registry").option("--clear-registry","Clear only the registry cache").option("--path","Show cache directory path").action(async e=>{let{runCliCache:t}=await Promise.resolve().then(()=>($s(),Us));t(e)});Xe.command("credits").description("Show project contributors and credits").action(()=>{ro(no.createElement(Bt,{command:"credits"}))});Xe.command("audit").description("View audit log of skill operations").option("-n, --limit <number>","Number of entries to show","10").option("--path","Show audit log file path").action(async e=>{let{runCliAudit:t}=await Promise.resolve().then(()=>(Ks(),js));await t(e)});Xe.parse(process.argv);function hn(e){return Object.keys(e).filter(o=>o!=="parent").length===0}
12
13
  //# sourceMappingURL=index.js.map