agent-skill-manager 1.5.0 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,15 +1,15 @@
1
1
  #!/usr/bin/env bun
2
2
  // @bun
3
- import{a as R,c as I,d as _0,e as d,f as F0,g as A0,h as p,i as E0,j as Y,k as g,l as T0,m as x,n as o,o as L0,q as H0,r as I0,s as n}from"./chunk-sx2p5bqv.js";import{A as F,B as O0,t as E,u as T,v as M0,w as A,x as j0,y as c,z as v}from"./chunk-zh7g5bam.js";import{execFile as w0}from"child_process";import{promisify as y0}from"util";import{mkdtemp as N0,readdir as l,readFile as N,rm as y,cp as S0,access as h,stat as i,lstat as b0,symlink as D0,mkdir as P0}from"fs/promises";import{join as L,relative as f0}from"path";import{tmpdir as k0}from"os";var s=y0(w0),h0=/^[a-zA-Z0-9_-]+$/,v0=/^[a-zA-Z0-9._-]+$/,u0=/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/,t=128,m0=/^https?:\/\/github\.com\/([^/]+)\/([^/]+?)(?:\/tree\/(.+))?\/?$/;function a($){let Q=m0.exec($);if(Q){let[,j,W,O]=Q,B=W.endsWith(".git")?W.slice(0,-4):W;$=`github:${j}/${B}${O?`#${O}`:""}`}if(!$.startsWith("github:"))throw Error(`Invalid source format. Got: "${$}"
3
+ import{a as N,c as R,d as A0,e as g,f as E0,g as L0,h as o,i as T0,j as Y,k as n,l as H0,m as y,n as t,o as I0,q as C0,r as R0,s as l}from"./chunk-95dyppsz.js";import{A as F,B as F0,t as L,u as T,v as O0,w as E,x as _0,y as p,z as m}from"./chunk-zh7g5bam.js";import{execFile as N0}from"child_process";import{promisify as S0}from"util";import{mkdtemp as b0,readdir as s,readFile as b,rm as S,cp as D0,access as u,stat as a,lstat as f0,symlink as k0,mkdir as P0}from"fs/promises";import{join as H,relative as h0}from"path";import{tmpdir as v0}from"os";var e=S0(N0),u0=/^[a-zA-Z0-9_-]+$/,m0=/^[a-zA-Z0-9._-]+$/,c0=/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/,i=128,d0=/^https?:\/\/github\.com\/([^/]+)\/([^/]+?)(?:\/tree\/(.+))?\/?$/;function r($){let Q=d0.exec($);if(Q){let[,M,G,B]=Q,_=G.endsWith(".git")?G.slice(0,-4):G;$=`github:${M}/${_}${B?`#${B}`:""}`}if(!$.startsWith("github:"))throw Error(`Invalid source format. Got: "${$}"
4
4
  Supported formats:
5
5
  github:owner/repo[#ref]
6
- https://github.com/owner/repo`);let K=$.slice(7),q=K.indexOf("#"),Z,V=null;if(q!==-1){if(Z=K.slice(0,q),V=K.slice(q+1),!V)throw Error("Invalid source: ref cannot be empty after #")}else Z=K;let X=Z.indexOf("/");if(X===-1)throw Error(`Invalid source: format must be github:owner/repo. Got: "${$}"`);let z=Z.slice(0,X),J=Z.slice(X+1);if(!z)throw Error("Invalid source: owner cannot be empty");if(!J)throw Error("Invalid source: repo cannot be empty");if(!h0.test(z))throw Error(`Invalid source: owner contains invalid characters: "${z}". Allowed: [a-zA-Z0-9_-]`);if(!v0.test(J))throw Error(`Invalid source: repo contains invalid characters: "${J}". Allowed: [a-zA-Z0-9._-]`);let U={owner:z,repo:J,ref:V,cloneUrl:`https://github.com/${z}/${J}.git`};return A(`install: parsed source owner=${z} repo=${J} ref=${V}`),U}function S($){if(!$)throw Error("Invalid skill name: name cannot be empty");if($.includes("\x00"))throw Error("Invalid skill name: contains unsafe characters (null byte)");if($.includes(".."))throw Error("Invalid skill name: contains unsafe characters (..)");if($.includes("/")||$.includes("\\"))throw Error("Invalid skill name: contains unsafe characters (path separator)");if($.startsWith("."))throw Error("Invalid skill name: must not start with a dot");if($.length>t)throw Error(`Invalid skill name: exceeds maximum length of ${t} characters`);if(!u0.test($))throw Error(`Invalid skill name: "${$}" does not match allowed pattern [a-zA-Z0-9][a-zA-Z0-9._-]*`);return $}async function e(){try{await s("git",["--version"]),A("install: git available")}catch{throw Error("git is required for installing skills. Install git from https://git-scm.com")}}async function r($){A(`install: cloning ${$.cloneUrl}${$.ref?` (ref: ${$.ref})`:""}`);let Q=await N0(L(k0(),"asm-install-")),K=["clone","--depth","1"];if($.ref)K.push("--branch",$.ref);K.push($.cloneUrl,Q);try{await s("git",K,{timeout:60000})}catch(q){await D(Q);let Z=q.killed?"Clone timed out after 60 seconds":`Clone failed: ${q.stderr||q.message}`;throw Error(Z)}return Q}async function b($){let Q=L($,"SKILL.md"),K;try{K=await N(Q,"utf-8")}catch{throw Error("Not a valid skill: SKILL.md not found in repository root")}let q=R(K),Z=$.split("/").pop()||"unknown",V=q.name||Z,X=q.version||"0.0.0";return A(`install: validated skill "${V}" v${X}`),{name:V,version:X,description:(q.description||"").replace(/\s*\n\s*/g," ").trim()}}async function $0($,Q=3){let K=[];async function q(Z,V,X){let z;try{z=await l(Z)}catch{return}for(let J of z){if(J===".git"||J==="node_modules")continue;let U=L(Z,J);try{if(!(await i(U)).isDirectory())continue}catch{continue}let j=V?`${V}/${J}`:J,W=X+1,O=L(U,"SKILL.md");try{let B=await N(O,"utf-8"),G=R(B);K.push({relPath:j,name:G.name||J,version:G.version||"0.0.0",description:(G.description||"").replace(/\s*\n\s*/g," ").trim()})}catch{if(W<Q)await q(U,j,W)}}}return await q($,"",0),K.sort((Z,V)=>Z.name.localeCompare(V.name)),K}var c0=[{category:"Shell commands",pattern:/\b(bash|sh\s+-c)\b/},{category:"Shell commands",pattern:/\bexec\(/},{category:"Shell commands",pattern:/\bchild_process\b/},{category:"Shell commands",pattern:/\bBun\.spawn\b/},{category:"Code execution",pattern:/\beval\(/},{category:"Code execution",pattern:/\bFunction\(/},{category:"Code execution",pattern:/\bnew\s+Function\b/},{category:"Credentials",pattern:/\b(API_KEY|SECRET|TOKEN|PASSWORD)\s*[=:]/},{category:"External URLs",pattern:/https?:\/\//}],d0=new Set([".png",".jpg",".jpeg",".gif",".ico",".bmp",".webp",".mp3",".mp4",".wav",".avi",".mov",".zip",".tar",".gz",".bz2",".7z",".exe",".dll",".so",".dylib",".woff",".woff2",".ttf",".eot",".pdf",".doc",".docx"]);async function p0($){let Q=[];async function K(q,Z){let V;try{V=await l(q)}catch{return}for(let X of V){if(X===".git")continue;if(X==="node_modules")continue;let z=L(q,X),J=Z?`${Z}/${X}`:X;try{let U=await i(z);if(U.isDirectory())await K(z,J);else if(U.isFile()){let j=X.includes(".")?`.${X.split(".").pop().toLowerCase()}`:"";if(d0.has(j))continue;if(U.size>524288)continue;try{let W=await N(z,"utf-8");Q.push({relPath:J,content:W})}catch{}}}catch{continue}}}return await K($,""),Q}async function Q0($){let Q=[],K=await p0($);for(let{relPath:q,content:Z}of K){let V=Z.split(`
7
- `);for(let X=0;X<V.length;X++)for(let{category:z,pattern:J}of c0)if(J.test(V[X])){let U=V[X].trim();Q.push({category:z,file:q,line:X+1,match:U.length>100?U.slice(0,100)+"…":U})}}return Q}async function u($){let Q=`github:${$.source.owner}/${$.source.repo}${$.source.ref?`#${$.source.ref}`:""}`;if($.force)try{await h($.targetDir),await y($.targetDir,{recursive:!0,force:!0})}catch{}let K=$.sourceDir;try{await S0(K,$.targetDir,{recursive:!0})}catch(z){throw Error(`Failed to install: ${z.message}`)}let q=L($.targetDir,".git");try{await y(q,{recursive:!0,force:!0})}catch{}A(`install: copied files to ${$.targetDir}`);let Z=L($.targetDir,"SKILL.md");try{await h(Z)}catch{throw Error("Installation verification failed: SKILL.md not found at target")}let V=await N(Z,"utf-8"),X=R(V);return{success:!0,path:$.targetDir,name:X.name||$.skillName,version:X.version||"0.0.0",provider:$.providerLabel,source:Q}}async function Z0($,Q){let K=await u($);for(let q of Q){if(q.name===$.providerName)continue;let Z=v(q.global),V=L(Z,$.skillName);await P0(Z,{recursive:!0});try{if((await b0(V)).isSymbolicLink())await y(V);else{A(`install: skipping ${V} — existing non-symlink directory`);continue}}catch{}let X=f0(Z,$.targetDir);await D0(X,V,"dir"),A(`install: symlinked ${V} ${X}`)}return K.provider=`All (${Q.map((q)=>q.label).join(", ")})`,K}async function D($){try{await y($,{recursive:!0,force:!0})}catch{}}async function P($,Q,K){let q=$.providers.filter((X)=>X.enabled);if(q.length===0)throw Error("No providers are enabled. Enable a provider in your config.");if(Q==="all")return{provider:q.find((z)=>z.name==="agents")||q[0],allProviders:q};if(Q){let X=$.providers.find((z)=>z.name===Q);if(!X){let z=$.providers.map((J)=>J.name).join(", ");throw Error(`Unknown provider: "${Q}". Valid providers: ${z}, all`)}if(!X.enabled)throw Error(`Provider "${Q}" is disabled. Enable it in your config or choose another provider.`);return{provider:X,allProviders:null}}if(q.length===1)return{provider:q[0],allProviders:null};if(!K){let X=q.map((z)=>z.name).join(", ");throw Error(`--provider is required in non-interactive mode. Available: ${X}, all`)}console.error(`
6
+ https://github.com/owner/repo`);let K=$.slice(7),q=K.indexOf("#"),Z,V=null;if(q!==-1){if(Z=K.slice(0,q),V=K.slice(q+1),!V)throw Error("Invalid source: ref cannot be empty after #")}else Z=K;let X=Z.indexOf("/");if(X===-1)throw Error(`Invalid source: format must be github:owner/repo. Got: "${$}"`);let z=Z.slice(0,X),J=Z.slice(X+1);if(!z)throw Error("Invalid source: owner cannot be empty");if(!J)throw Error("Invalid source: repo cannot be empty");if(!u0.test(z))throw Error(`Invalid source: owner contains invalid characters: "${z}". Allowed: [a-zA-Z0-9_-]`);if(!m0.test(J))throw Error(`Invalid source: repo contains invalid characters: "${J}". Allowed: [a-zA-Z0-9._-]`);let W={owner:z,repo:J,ref:V,cloneUrl:`https://github.com/${z}/${J}.git`};return E(`install: parsed source -> owner=${z} repo=${J} ref=${V}`),W}function D($){if(!$)throw Error("Invalid skill name: name cannot be empty");if($.includes("\x00"))throw Error("Invalid skill name: contains unsafe characters (null byte)");if($.includes(".."))throw Error("Invalid skill name: contains unsafe characters (..)");if($.includes("/")||$.includes("\\"))throw Error("Invalid skill name: contains unsafe characters (path separator)");if($.startsWith("."))throw Error("Invalid skill name: must not start with a dot");if($.length>i)throw Error(`Invalid skill name: exceeds maximum length of ${i} characters`);if(!c0.test($))throw Error(`Invalid skill name: "${$}" does not match allowed pattern [a-zA-Z0-9][a-zA-Z0-9._-]*`);return $}async function $0(){try{await e("git",["--version"]),E("install: git available")}catch{throw Error("git is required for installing skills. Install git from https://git-scm.com")}}async function Q0($){E(`install: cloning ${$.cloneUrl}${$.ref?` (ref: ${$.ref})`:""}`);let Q=await b0(H(v0(),"asm-install-")),K=["clone","--depth","1"];if($.ref)K.push("--branch",$.ref);K.push($.cloneUrl,Q);try{await e("git",K,{timeout:60000})}catch(q){await k(Q);let Z=q.killed?"Clone timed out after 60 seconds":`Clone failed: ${q.stderr||q.message}`;throw Error(Z)}return Q}async function f($){let Q=H($,"SKILL.md"),K;try{K=await b(Q,"utf-8")}catch{throw Error("Not a valid skill: SKILL.md not found in repository root")}let q=N(K),Z=$.split("/").pop()||"unknown",V=q.name||Z,X=q.version||"0.0.0";return E(`install: validated skill "${V}" v${X}`),{name:V,version:X,description:(q.description||"").replace(/\s*\n\s*/g," ").trim()}}async function Z0($,Q=3){let K=[];async function q(Z,V,X){let z;try{z=await s(Z)}catch{return}for(let J of z){if(J===".git"||J==="node_modules")continue;let W=H(Z,J);try{if(!(await a(W)).isDirectory())continue}catch{continue}let M=V?`${V}/${J}`:J,G=X+1,B=H(W,"SKILL.md");try{let _=await b(B,"utf-8"),U=N(_);K.push({relPath:M,name:U.name||J,version:U.version||"0.0.0",description:(U.description||"").replace(/\s*\n\s*/g," ").trim()})}catch{if(G<Q)await q(W,M,G)}}}return await q($,"",0),K.sort((Z,V)=>Z.name.localeCompare(V.name)),K}var p0=[{category:"Shell commands",pattern:/\b(bash|sh\s+-c)\b/},{category:"Shell commands",pattern:/\bexec\(/},{category:"Shell commands",pattern:/\bchild_process\b/},{category:"Shell commands",pattern:/\bBun\.spawn\b/},{category:"Code execution",pattern:/\beval\(/},{category:"Code execution",pattern:/\bFunction\(/},{category:"Code execution",pattern:/\bnew\s+Function\b/},{category:"Credentials",pattern:/\b(API_KEY|SECRET|TOKEN|PASSWORD)\s*[=:]/},{category:"External URLs",pattern:/https?:\/\//}],g0=new Set([".png",".jpg",".jpeg",".gif",".ico",".bmp",".webp",".mp3",".mp4",".wav",".avi",".mov",".zip",".tar",".gz",".bz2",".7z",".exe",".dll",".so",".dylib",".woff",".woff2",".ttf",".eot",".pdf",".doc",".docx"]);async function o0($){let Q=[];async function K(q,Z){let V;try{V=await s(q)}catch{return}for(let X of V){if(X===".git")continue;if(X==="node_modules")continue;let z=H(q,X),J=Z?`${Z}/${X}`:X;try{let W=await a(z);if(W.isDirectory())await K(z,J);else if(W.isFile()){let M=X.includes(".")?`.${X.split(".").pop().toLowerCase()}`:"";if(g0.has(M))continue;if(W.size>524288)continue;try{let G=await b(z,"utf-8");Q.push({relPath:J,content:G})}catch{}}}catch{continue}}}return await K($,""),Q}async function K0($){let Q=[],K=await o0($);for(let{relPath:q,content:Z}of K){let V=Z.split(`
7
+ `);for(let X=0;X<V.length;X++)for(let{category:z,pattern:J}of p0)if(J.test(V[X])){let W=V[X].trim();Q.push({category:z,file:q,line:X+1,match:W.length>100?W.slice(0,100)+"…":W})}}return Q}async function c($){let Q=`github:${$.source.owner}/${$.source.repo}${$.source.ref?`#${$.source.ref}`:""}`;if($.force)try{await u($.targetDir),await S($.targetDir,{recursive:!0,force:!0})}catch{}let K=$.sourceDir;try{await D0(K,$.targetDir,{recursive:!0})}catch(z){throw Error(`Failed to install: ${z.message}`)}let q=H($.targetDir,".git");try{await S(q,{recursive:!0,force:!0})}catch{}E(`install: copied files to ${$.targetDir}`);let Z=H($.targetDir,"SKILL.md");try{await u(Z)}catch{throw Error("Installation verification failed: SKILL.md not found at target")}let V=await b(Z,"utf-8"),X=N(V);return{success:!0,path:$.targetDir,name:X.name||$.skillName,version:X.version||"0.0.0",provider:$.providerLabel,source:Q}}async function q0($,Q){let K=await c($);for(let q of Q){if(q.name===$.providerName)continue;let Z=m(q.global),V=H(Z,$.skillName);await P0(Z,{recursive:!0});try{if((await f0(V)).isSymbolicLink())await S(V);else{E(`install: skipping ${V} — existing non-symlink directory`);continue}}catch{}let X=h0(Z,$.targetDir);await k0(X,V,"dir"),E(`install: symlinked ${V} -> ${X}`)}return K.provider=`All (${Q.map((q)=>q.label).join(", ")})`,K}async function k($){try{await S($,{recursive:!0,force:!0})}catch{}}async function P($,Q,K){let q=$.providers.filter((X)=>X.enabled);if(q.length===0)throw Error("No providers are enabled. Enable a provider in your config.");if(Q==="all")return{provider:q.find((z)=>z.name==="agents")||q[0],allProviders:q};if(Q){let X=$.providers.find((z)=>z.name===Q);if(!X){let z=$.providers.map((J)=>J.name).join(", ");throw Error(`Unknown provider: "${Q}". Valid providers: ${z}, all`)}if(!X.enabled)throw Error(`Provider "${Q}" is disabled. Enable it in your config or choose another provider.`);return{provider:X,allProviders:null}}if(q.length===1)return{provider:q[0],allProviders:null};if(!K){let X=q.map((z)=>z.name).join(", ");throw Error(`--provider is required in non-interactive mode. Available: ${X}, all`)}console.error(`
8
8
  Select a provider:`);for(let X=0;X<q.length;X++)console.error(` ${X+1}) ${q[X].label} (${q[X].name})`);console.error(` ${q.length+1}) All providers (shared .agents/skills/ + symlinks)`),process.stderr.write(`
9
9
  Enter number: `);let Z=await new Promise((X)=>{let z="";process.stdin.setEncoding("utf-8"),process.stdin.on("data",(J)=>{if(z+=J,z.includes(`
10
- `))process.stdin.removeAllListeners("data"),X(z.trim())}),process.stdin.resume()}),V=parseInt(Z,10)-1;if(V===q.length)return{provider:q.find((z)=>z.name==="agents")||q[0],allProviders:q};if(isNaN(V)||V<0||V>=q.length)throw Error("Invalid selection. Aborting.");return{provider:q[V],allProviders:null}}function K0($,Q,K,q,Z,V){let X=v(Z.global),z=L(X,q);return{source:$,tempDir:Q,sourceDir:K,targetDir:z,skillName:q,force:V,providerName:Z.name,providerLabel:Z.label}}async function q0($,Q){try{if(await h($),A(`install: target ${$} — conflict (exists)${Q?", force overwrite":""}`),!Q)throw Error(`Skill already exists at: ${$}
11
- Use --force to overwrite.`)}catch(K){if(K.message?.includes("--force"))throw K;A(`install: target ${$} — no conflict`)}}import{readFile as g0}from"fs/promises";import{join as o0}from"path";var V0=500;function n0($){let Q=$.split(`
12
- `),K=!1,q=!1;for(let Z of Q){if(Z.trim()==="---")if(!K){K=!0;continue}else{q=!0;continue}if(q&&Z.trim().length>0)return!0}return!1}async function X0($){let Q=[];if(!$.description||$.description.trim()==="")Q.push({category:"missing-description",message:"Skill has no description in SKILL.md frontmatter"});if(!$.version||$.version==="0.0.0")Q.push({category:"missing-version",message:"Skill has no version (or default 0.0.0) in SKILL.md frontmatter"});try{let q=o0($.path,"SKILL.md"),Z=await g0(q,"utf-8");if(!n0(Z))Q.push({category:"empty-body",message:"SKILL.md contains only frontmatter with no body content"})}catch{}let K=$.fileCount;if(K!==void 0&&K>V0)Q.push({category:"high-file-count",message:`Skill has ${K} files (threshold: ${V0})`});return Q}function Y0($){let Q=$.map((K)=>({name:K.name,version:K.version,dirName:K.dirName,provider:K.provider,scope:K.scope,path:K.path,isSymlink:K.isSymlink,symlinkTarget:K.symlinkTarget}));return{version:1,exportedAt:new Date().toISOString(),skills:Q}}import{mkdir as t0,writeFile as l0,access as i0}from"fs/promises";import{join as s0}from"path";function a0($){return`---
10
+ `))process.stdin.removeAllListeners("data"),process.stdin.pause(),X(z.trim())}),process.stdin.resume()}),V=parseInt(Z,10)-1;if(V===q.length)return{provider:q.find((z)=>z.name==="agents")||q[0],allProviders:q};if(isNaN(V)||V<0||V>=q.length)throw Error("Invalid selection. Aborting.");return{provider:q[V],allProviders:null}}function V0($,Q,K,q,Z,V){let X=m(Z.global),z=H(X,q);return{source:$,tempDir:Q,sourceDir:K,targetDir:z,skillName:q,force:V,providerName:Z.name,providerLabel:Z.label}}async function X0($,Q){try{if(await u($),E(`install: target ${$} — conflict (exists)${Q?", force overwrite":""}`),!Q)throw Error(`Skill already exists at: ${$}
11
+ Use --force to overwrite.`)}catch(K){if(K.message?.includes("--force"))throw K;E(`install: target ${$} — no conflict`)}}import{readFile as n0}from"fs/promises";import{join as t0}from"path";var Y0=500;function l0($){let Q=$.split(`
12
+ `),K=!1,q=!1;for(let Z of Q){if(Z.trim()==="---")if(!K){K=!0;continue}else{q=!0;continue}if(q&&Z.trim().length>0)return!0}return!1}async function z0($){let Q=[];if(!$.description||$.description.trim()==="")Q.push({category:"missing-description",message:"Skill has no description in SKILL.md frontmatter"});if(!$.version||$.version==="0.0.0")Q.push({category:"missing-version",message:"Skill has no version (or default 0.0.0) in SKILL.md frontmatter"});try{let q=t0($.path,"SKILL.md"),Z=await n0(q,"utf-8");if(!l0(Z))Q.push({category:"empty-body",message:"SKILL.md contains only frontmatter with no body content"})}catch{}let K=$.fileCount;if(K!==void 0&&K>Y0)Q.push({category:"high-file-count",message:`Skill has ${K} files (threshold: ${Y0})`});return Q}function J0($){let Q=$.map((K)=>({name:K.name,version:K.version,dirName:K.dirName,provider:K.provider,scope:K.scope,path:K.path,isSymlink:K.isSymlink,symlinkTarget:K.symlinkTarget}));return{version:1,exportedAt:new Date().toISOString(),skills:Q}}import{mkdir as i0,writeFile as s0,access as a0}from"fs/promises";import{join as e0}from"path";function r0($){return`---
13
13
  name: ${$}
14
14
  version: 0.1.0
15
15
  description: ""
@@ -27,8 +27,8 @@ as instructions for when and how to use this skill.
27
27
  ## Instructions
28
28
 
29
29
  - Step-by-step instructions for the agent
30
- `}async function z0($,Q){await t0(Q,{recursive:!0});let K=s0(Q,"SKILL.md"),q=a0($);await l0(K,q,"utf-8")}async function J0($){try{return await i0($),!0}catch{return!1}}import{readdir as e0,stat as r0}from"fs/promises";import{join as $1}from"path";async function Q1($){let Q=0;try{let q=(await e0($,{recursive:!0})).map(async(V)=>{try{let X=await r0($1($,V));if(X.isFile())return X.size}catch{}return 0});Q=(await Promise.all(q)).reduce((V,X)=>V+X,0)}catch{}return Q}async function U0($,Q){let K={},q={global:0,project:0},Z={},V=$.map(async(J)=>{K[J.provider]=(K[J.provider]||0)+1,q[J.scope]++;let U=await Q1(J.path);return Z[J.path]=U,U}),z=(await Promise.all(V)).reduce((J,U)=>J+U,0);return{totalSkills:$.length,byProvider:K,byScope:q,totalDiskBytes:z,perSkillDiskBytes:Z,duplicateGroups:Q.duplicateGroups.length,duplicateInstances:Q.totalDuplicateInstances}}function Z1($){if($<1024)return`${$} B`;if($<1048576)return`${($/1024).toFixed(1)} KB`;if($<1073741824)return`${($/1048576).toFixed(1)} MB`;return`${($/1073741824).toFixed(1)} GB`}function W0($){let Q=[],K=(q,Z)=>`${Y.bold(q+":")} ${Z}`;Q.push(Y.bold("Skill Statistics")),Q.push(""),Q.push(K("Total Skills",String($.totalSkills))),Q.push(K("Disk Usage",Z1($.totalDiskBytes))),Q.push(""),Q.push(Y.bold("By Provider:"));for(let[q,Z]of Object.entries($.byProvider).sort((V,X)=>X[1]-V[1]))Q.push(` ${q}: ${Z}`);if(Q.push(""),Q.push(Y.bold("By Scope:")),Q.push(` global: ${$.byScope.global}`),Q.push(` project: ${$.byScope.project}`),Q.push(""),Q.push(Y.bold("Duplicates:")),$.duplicateGroups>0)Q.push(` ${Y.yellow(`${$.duplicateGroups} group(s), ${$.duplicateInstances} total instance(s)`)}`);else Q.push(` ${Y.green("None")}`);return Q.join(`
31
- `)}import{access as K1,lstat as q1,readFile as V1,rm as X1,symlink as Y1}from"fs/promises";import{join as B0}from"path";async function G0($){let Q;try{Q=await q1($)}catch{throw Error(`Path does not exist: ${$}`)}if(!Q.isDirectory())throw Error(`Path is not a directory: ${$}`);let K=B0($,"SKILL.md"),q;try{q=await V1(K,"utf-8")}catch{throw Error(`No SKILL.md found in ${$}`)}let Z=R(q);if(!Z.name)throw Error(`Invalid SKILL.md in ${$}: missing "name" in frontmatter`);return{name:Z.name,version:Z.version||"0.0.0"}}async function f($,Q,K,q){let Z=B0(Q,K),V=!1;try{await K1(Z),V=!0}catch{}if(V){if(!q)throw Error(`Target already exists: ${Z}. Use --force to overwrite.`);await X1(Z,{recursive:!0,force:!0})}await Y1($,Z,"dir")}function z1($){let Q=$.slice(2),K={command:null,subcommand:null,positional:[],flags:{help:!1,version:!1,json:!1,yes:!1,noColor:!1,scope:"both",sort:"name",provider:null,name:null,force:!1,path:null,all:!1,verbose:!1}},q=0;while(q<Q.length){let Z=Q[q];if(Z==="--help"||Z==="-h")K.flags.help=!0;else if(Z==="--version"||Z==="-v")K.flags.version=!0;else if(Z==="--json")K.flags.json=!0;else if(Z==="--yes"||Z==="-y")K.flags.yes=!0;else if(Z==="--no-color")K.flags.noColor=!0;else if(Z==="--scope"||Z==="-s"){q++;let V=Q[q];if(V==="global"||V==="project"||V==="both")K.flags.scope=V;else M(`Invalid scope: "${V}". Must be global, project, or both.`),process.exit(2)}else if(Z==="--sort"){q++;let V=Q[q];if(V==="name"||V==="version"||V==="location")K.flags.sort=V;else M(`Invalid sort: "${V}". Must be name, version, or location.`),process.exit(2)}else if(Z==="--provider"||Z==="-p")q++,K.flags.provider=Q[q]||null;else if(Z==="--name")q++,K.flags.name=Q[q]||null;else if(Z==="--force"||Z==="-f")K.flags.force=!0;else if(Z==="--path")q++,K.flags.path=Q[q]||null;else if(Z==="--all")K.flags.all=!0;else if(Z==="--verbose"||Z==="-V")K.flags.verbose=!0;else if(Z.startsWith("-"))M(`Unknown option: ${Z}`),console.error('Run "asm --help" for usage.'),process.exit(2);else if(!K.command)K.command=Z;else if(!K.subcommand)K.subcommand=Z;else K.positional.push(Z);q++}return K}function M($){console.error(Y.red(`Error: ${$}`))}function J1(){console.log(`${Y.blueBold("agent-skill-manager")} (${Y.bold("asm")}) ${n}
30
+ `}async function U0($,Q){await i0(Q,{recursive:!0});let K=e0(Q,"SKILL.md"),q=r0($);await s0(K,q,"utf-8")}async function W0($){try{return await a0($),!0}catch{return!1}}import{readdir as $1,stat as Q1}from"fs/promises";import{join as Z1}from"path";async function K1($){let Q=0;try{let q=(await $1($,{recursive:!0})).map(async(V)=>{try{let X=await Q1(Z1($,V));if(X.isFile())return X.size}catch{}return 0});Q=(await Promise.all(q)).reduce((V,X)=>V+X,0)}catch{}return Q}async function G0($,Q){let K={},q={global:0,project:0},Z={},V=$.map(async(J)=>{K[J.provider]=(K[J.provider]||0)+1,q[J.scope]++;let W=await K1(J.path);return Z[J.path]=W,W}),z=(await Promise.all(V)).reduce((J,W)=>J+W,0);return{totalSkills:$.length,byProvider:K,byScope:q,totalDiskBytes:z,perSkillDiskBytes:Z,duplicateGroups:Q.duplicateGroups.length,duplicateInstances:Q.totalDuplicateInstances}}function q1($){if($<1024)return`${$} B`;if($<1048576)return`${($/1024).toFixed(1)} KB`;if($<1073741824)return`${($/1048576).toFixed(1)} MB`;return`${($/1073741824).toFixed(1)} GB`}function B0($){let Q=[],K=(q,Z)=>`${Y.bold(q+":")} ${Z}`;Q.push(Y.bold("Skill Statistics")),Q.push(""),Q.push(K("Total Skills",String($.totalSkills))),Q.push(K("Disk Usage",q1($.totalDiskBytes))),Q.push(""),Q.push(Y.bold("By Provider:"));for(let[q,Z]of Object.entries($.byProvider).sort((V,X)=>X[1]-V[1]))Q.push(` ${q}: ${Z}`);if(Q.push(""),Q.push(Y.bold("By Scope:")),Q.push(` global: ${$.byScope.global}`),Q.push(` project: ${$.byScope.project}`),Q.push(""),Q.push(Y.bold("Duplicates:")),$.duplicateGroups>0)Q.push(` ${Y.yellow(`${$.duplicateGroups} group(s), ${$.duplicateInstances} total instance(s)`)}`);else Q.push(` ${Y.green("None")}`);return Q.join(`
31
+ `)}import{access as V1,lstat as X1,readFile as Y1,rm as z1,symlink as J1}from"fs/promises";import{join as M0}from"path";async function j0($){let Q;try{Q=await X1($)}catch{throw Error(`Path does not exist: ${$}`)}if(!Q.isDirectory())throw Error(`Path is not a directory: ${$}`);let K=M0($,"SKILL.md"),q;try{q=await Y1(K,"utf-8")}catch{throw Error(`No SKILL.md found in ${$}`)}let Z=N(q);if(!Z.name)throw Error(`Invalid SKILL.md in ${$}: missing "name" in frontmatter`);return{name:Z.name,version:Z.version||"0.0.0"}}async function h($,Q,K,q){let Z=M0(Q,K),V=!1;try{await V1(Z),V=!0}catch{}if(V){if(!q)throw Error(`Target already exists: ${Z}. Use --force to overwrite.`);await z1(Z,{recursive:!0,force:!0})}await J1($,Z,"dir")}function U1($){let Q=$.slice(2),K={command:null,subcommand:null,positional:[],flags:{help:!1,version:!1,json:!1,yes:!1,noColor:!1,scope:"both",sort:"name",provider:null,name:null,force:!1,path:null,all:!1,verbose:!1}},q=0;while(q<Q.length){let Z=Q[q];if(Z==="--help"||Z==="-h")K.flags.help=!0;else if(Z==="--version"||Z==="-v")K.flags.version=!0;else if(Z==="--json")K.flags.json=!0;else if(Z==="--yes"||Z==="-y")K.flags.yes=!0;else if(Z==="--no-color")K.flags.noColor=!0;else if(Z==="--scope"||Z==="-s"){q++;let V=Q[q];if(V==="global"||V==="project"||V==="both")K.flags.scope=V;else j(`Invalid scope: "${V}". Must be global, project, or both.`),process.exit(2)}else if(Z==="--sort"){q++;let V=Q[q];if(V==="name"||V==="version"||V==="location")K.flags.sort=V;else j(`Invalid sort: "${V}". Must be name, version, or location.`),process.exit(2)}else if(Z==="--provider"||Z==="-p")q++,K.flags.provider=Q[q]||null;else if(Z==="--name")q++,K.flags.name=Q[q]||null;else if(Z==="--force"||Z==="-f")K.flags.force=!0;else if(Z==="--path")q++,K.flags.path=Q[q]||null;else if(Z==="--all")K.flags.all=!0;else if(Z==="--verbose"||Z==="-V")K.flags.verbose=!0;else if(Z.startsWith("-"))j(`Unknown option: ${Z}`),console.error('Run "asm --help" for usage.'),process.exit(2);else if(!K.command)K.command=Z;else if(!K.subcommand)K.subcommand=Z;else K.positional.push(Z);q++}return K}function j($){console.error(Y.red(`Error: ${$}`))}function W1(){console.log(`${Y.blueBold("agent-skill-manager")} (${Y.bold("asm")}) ${l}
32
32
 
33
33
  Interactive TUI and CLI for managing installed skills for AI coding agents.
34
34
 
@@ -60,7 +60,7 @@ ${Y.bold("Global Options:")}
60
60
  --no-color Disable ANSI colors
61
61
  --sort <field> Sort by: name, version, or location (default: name)
62
62
  -y, --yes Skip confirmation prompts
63
- -V, --verbose Show debug output`)}function U1(){console.log(`${Y.bold("Usage:")} asm list [options]
63
+ -V, --verbose Show debug output`)}function G1(){console.log(`${Y.bold("Usage:")} asm list [options]
64
64
 
65
65
  List all discovered skills.
66
66
 
@@ -69,7 +69,7 @@ ${Y.bold("Options:")}
69
69
  -s, --scope <s> Filter: global, project, or both (default: both)
70
70
  --json Output as JSON array
71
71
  --no-color Disable ANSI colors
72
- -V, --verbose Show debug output`)}function W1(){console.log(`${Y.bold("Usage:")} asm search <query> [options]
72
+ -V, --verbose Show debug output`)}function B1(){console.log(`${Y.bold("Usage:")} asm search <query> [options]
73
73
 
74
74
  Search skills by name, description, or provider.
75
75
 
@@ -78,7 +78,7 @@ ${Y.bold("Options:")}
78
78
  -s, --scope <s> Filter: global, project, or both (default: both)
79
79
  --json Output as JSON array
80
80
  --no-color Disable ANSI colors
81
- -V, --verbose Show debug output`)}function B1(){console.log(`${Y.bold("Usage:")} asm inspect <skill-name> [options]
81
+ -V, --verbose Show debug output`)}function M1(){console.log(`${Y.bold("Usage:")} asm inspect <skill-name> [options]
82
82
 
83
83
  Show detailed information for a skill. The <skill-name> is the directory name.
84
84
 
@@ -86,7 +86,7 @@ ${Y.bold("Options:")}
86
86
  -s, --scope <s> Filter: global, project, or both (default: both)
87
87
  --json Output as JSON object
88
88
  --no-color Disable ANSI colors
89
- -V, --verbose Show debug output`)}function G1(){console.log(`${Y.bold("Usage:")} asm uninstall <skill-name> [options]
89
+ -V, --verbose Show debug output`)}function j1(){console.log(`${Y.bold("Usage:")} asm uninstall <skill-name> [options]
90
90
 
91
91
  Remove a skill and its associated rule files.
92
92
 
@@ -94,7 +94,7 @@ ${Y.bold("Options:")}
94
94
  -y, --yes Skip confirmation prompt
95
95
  -s, --scope <s> Filter: global, project, or both (default: both)
96
96
  --no-color Disable ANSI colors
97
- -V, --verbose Show debug output`)}function M1(){console.log(`${Y.bold("Usage:")} asm audit [subcommand] [options]
97
+ -V, --verbose Show debug output`)}function O1(){console.log(`${Y.bold("Usage:")} asm audit [subcommand] [options]
98
98
 
99
99
  Detect and optionally remove duplicate skills.
100
100
 
@@ -105,7 +105,7 @@ ${Y.bold("Options:")}
105
105
  --json Output as JSON
106
106
  -y, --yes Auto-remove duplicates, keeping one instance per group
107
107
  --no-color Disable ANSI colors
108
- -V, --verbose Show debug output`)}function j1(){console.log(`${Y.bold("Usage:")} asm config <subcommand>
108
+ -V, --verbose Show debug output`)}function _1(){console.log(`${Y.bold("Usage:")} asm config <subcommand>
109
109
 
110
110
  Manage configuration.
111
111
 
@@ -116,15 +116,15 @@ ${Y.bold("Subcommands:")}
116
116
  edit Open config in $EDITOR
117
117
 
118
118
  ${Y.bold("Options:")}
119
- -V, --verbose Show debug output`)}async function C0($){for(let Q of $)Q.warnings=await X0(Q)}async function O1($){if($.flags.help){U1();return}let Q=await F(),K=await I(Q,$.flags.scope);await C0(K);let q=d(K,$.flags.sort);if($.flags.json)console.log(x(q));else{let Z=g(q),V=q.filter((X)=>X.warnings&&X.warnings.length>0);if(V.length>0)Z+=`
120
- ${Y.yellow(`⚠ ${V.length} skill${V.length===1?"":"s"} with warnings use --json for details`)}`;console.log(Z)}}async function _1($){if($.flags.help){W1();return}let Q=$.subcommand;if(!Q)M("Missing required argument: <query>"),console.error('Run "asm search --help" for usage.'),process.exit(2);let K=await F(),q=await I(K,$.flags.scope),Z=_0(q,Q),V=d(Z,$.flags.sort);if($.flags.json)console.log(x(V));else console.log(g(V))}async function F1($){if($.flags.help){B1();return}let Q=$.subcommand;if(!Q)M("Missing required argument: <skill-name>"),console.error('Run "asm inspect --help" for usage.'),process.exit(2);let K=await F(),Z=(await I(K,$.flags.scope)).filter((V)=>V.dirName===Q);if(Z.length===0)M(`Skill "${Q}" not found.`),process.exit(1);if(await C0(Z),$.flags.json)console.log(x(Z.length===1?Z[0]:Z));else for(let V=0;V<Z.length;V++){if(V>0)console.log(`
121
- `+"".repeat(40)+`
122
- `);console.log(await T0(Z[V]))}}async function A1($){if($.flags.help){G1();return}let Q=$.subcommand;if(!Q)M("Missing required argument: <skill-name>"),console.error('Run "asm uninstall --help" for usage.'),process.exit(2);let K=await F(),q=await I(K,$.flags.scope),Z=A0(Q,q,K),V=await E0(Z);if(V.length===0)M(`Skill "${Q}" not found or nothing to remove.`),process.exit(1);console.error(Y.bold("Removal plan:"));for(let z of V)console.error(` ${Y.red("•")} ${z}`);if(!$.flags.yes){if(!process.stdin.isTTY)M("Cannot prompt for confirmation in non-interactive mode. Use --yes to skip."),process.exit(2);process.stderr.write(`
123
- ${Y.bold("Proceed with removal?")} [y/N] `);let z=await C();if(z.toLowerCase()!=="y"&&z.toLowerCase()!=="yes")console.error("Aborted."),process.exit(0)}let X=await p(Z);for(let z of X)console.error(z);console.error(Y.green(`
124
- Done.`))}function C(){return new Promise(($)=>{let Q="",K=!1;function q(){process.stdin.removeListener("data",V),process.stdin.removeListener("end",X),clearTimeout(z)}function Z(J){if(K)return;K=!0,q(),$(J)}function V(J){if(Q+=J,Q.includes(`
125
- `))Z(Q.trim())}function X(){Z(Q.trim())}let z=setTimeout(()=>{Z(Q.trim())},30000);process.stdin.setEncoding("utf-8"),process.stdin.on("data",V),process.stdin.on("end",X),process.stdin.resume()})}async function E1($){if($.flags.help){M1();return}let Q=$.subcommand??"duplicates";if(Q!=="duplicates")M(`Unknown audit subcommand: "${Q}". Use: duplicates`),process.exit(2);let K=await F(),q=await I(K,"both"),Z=o(q);if($.flags.json){console.log(I0(Z));return}if(console.log(H0(Z)),$.flags.yes&&Z.duplicateGroups.length>0){console.error(Y.bold(`
126
- Auto-removing duplicates...`));for(let V of Z.duplicateGroups){let X=L0(V.instances);for(let z=1;z<X.length;z++){let J=X[z],U=F0(J,K),j=await p(U);for(let W of j)console.error(W)}}console.error(Y.green(`
127
- Done.`))}}async function T1($){if($.flags.help){j1();return}let Q=$.subcommand;if(!Q)M("Missing subcommand. Use: show, path, reset, or edit."),console.error('Run "asm config --help" for usage.'),process.exit(2);switch(Q){case"show":{let K=await F();console.log(x(K));break}case"path":{console.log(c());break}case"reset":{if(!$.flags.yes){if(!process.stdin.isTTY)M("Cannot prompt for confirmation in non-interactive mode. Use --yes to skip."),process.exit(2);process.stderr.write(`${Y.bold("Reset config to defaults?")} [y/N] `);let q=await C();if(q.toLowerCase()!=="y"&&q.toLowerCase()!=="yes")console.error("Aborted."),process.exit(0)}let K=j0();await O0(K),console.error(Y.green("Config reset to defaults."));break}case"edit":{let K=process.env.VISUAL||process.env.EDITOR||"vi",q=c();await F();let{spawn:Z}=await import("child_process");await new Promise((V,X)=>{let z=Z(K,[q],{stdio:"inherit"});z.on("close",()=>V()),z.on("error",X)});break}default:M(`Unknown config subcommand: "${Q}". Use: show, path, reset, or edit.`),process.exit(2)}}function L1(){console.log(`${Y.bold("Usage:")} asm install <source> [options]
119
+ -V, --verbose Show debug output`)}async function x0($){for(let Q of $)Q.warnings=await z0(Q)}async function F1($){if($.flags.help){G1();return}let Q=await F(),K=await R(Q,$.flags.scope);await x0(K);let q=g(K,$.flags.sort);if($.flags.json)console.log(y(q));else{let Z=n(q),V=q.filter((X)=>X.warnings&&X.warnings.length>0);if(V.length>0)Z+=`
120
+ ${Y.yellow(`${V.length} skill${V.length===1?"":"s"} with warnings -- use --json for details`)}`;console.log(Z)}}async function A1($){if($.flags.help){B1();return}let Q=$.subcommand;if(!Q)j("Missing required argument: <query>"),console.error('Run "asm search --help" for usage.'),process.exit(2);let K=await F(),q=await R(K,$.flags.scope),Z=A0(q,Q),V=g(Z,$.flags.sort);if($.flags.json)console.log(y(V));else console.log(n(V))}async function E1($){if($.flags.help){M1();return}let Q=$.subcommand;if(!Q)j("Missing required argument: <skill-name>"),console.error('Run "asm inspect --help" for usage.'),process.exit(2);let K=await F(),Z=(await R(K,$.flags.scope)).filter((V)=>V.dirName===Q);if(Z.length===0)j(`Skill "${Q}" not found.`),process.exit(1);if(await x0(Z),$.flags.json)console.log(y(Z.length===1?Z[0]:Z));else for(let V=0;V<Z.length;V++){if(V>0)console.log(`
121
+ `+"-".repeat(40)+`
122
+ `);console.log(await H0(Z[V]))}}async function L1($){if($.flags.help){j1();return}let Q=$.subcommand;if(!Q)j("Missing required argument: <skill-name>"),console.error('Run "asm uninstall --help" for usage.'),process.exit(2);let K=await F(),q=await R(K,$.flags.scope),Z=L0(Q,q,K),V=await T0(Z);if(V.length===0)j(`Skill "${Q}" not found or nothing to remove.`),process.exit(1);console.error(Y.bold("Removal plan:"));for(let z of V)console.error(` ${Y.red("•")} ${z}`);if(!$.flags.yes){if(!process.stdin.isTTY)j("Cannot prompt for confirmation in non-interactive mode. Use --yes to skip."),process.exit(2);process.stderr.write(`
123
+ ${Y.bold("Proceed with removal?")} [y/N] `);let z=await w();if(z.toLowerCase()!=="y"&&z.toLowerCase()!=="yes")console.error("Aborted."),process.exit(0)}let X=await o(Z);for(let z of X)console.error(z);console.error(Y.green(`
124
+ Done.`))}function w(){return new Promise(($)=>{let Q="",K=!1;function q(){process.stdin.removeListener("data",V),process.stdin.removeListener("end",X),process.stdin.pause(),clearTimeout(z)}function Z(J){if(K)return;K=!0,q(),$(J)}function V(J){if(Q+=J,Q.includes(`
125
+ `))Z(Q.trim())}function X(){Z(Q.trim())}let z=setTimeout(()=>{Z(Q.trim())},30000);process.stdin.setEncoding("utf-8"),process.stdin.on("data",V),process.stdin.on("end",X),process.stdin.resume()})}async function T1($){if($.flags.help){O1();return}let Q=$.subcommand??"duplicates";if(Q!=="duplicates")j(`Unknown audit subcommand: "${Q}". Use: duplicates`),process.exit(2);let K=await F(),q=await R(K,"both"),Z=t(q);if($.flags.json){console.log(R0(Z));return}if(console.log(C0(Z)),$.flags.yes&&Z.duplicateGroups.length>0){console.error(Y.bold(`
126
+ Auto-removing duplicates...`));for(let V of Z.duplicateGroups){let X=I0(V.instances);for(let z=1;z<X.length;z++){let J=X[z],W=E0(J,K),M=await o(W);for(let G of M)console.error(G)}}console.error(Y.green(`
127
+ Done.`))}}async function H1($){if($.flags.help){_1();return}let Q=$.subcommand;if(!Q)j("Missing subcommand. Use: show, path, reset, or edit."),console.error('Run "asm config --help" for usage.'),process.exit(2);switch(Q){case"show":{let K=await F();console.log(y(K));break}case"path":{console.log(p());break}case"reset":{if(!$.flags.yes){if(!process.stdin.isTTY)j("Cannot prompt for confirmation in non-interactive mode. Use --yes to skip."),process.exit(2);process.stderr.write(`${Y.bold("Reset config to defaults?")} [y/N] `);let q=await w();if(q.toLowerCase()!=="y"&&q.toLowerCase()!=="yes")console.error("Aborted."),process.exit(0)}let K=_0();await F0(K),console.error(Y.green("Config reset to defaults."));break}case"edit":{let K=process.env.VISUAL||process.env.EDITOR||"vi",q=p();await F();let{spawn:Z}=await import("child_process");await new Promise((V,X)=>{let z=Z(K,[q],{stdio:"inherit"});z.on("close",()=>V()),z.on("error",X)});break}default:j(`Unknown config subcommand: "${Q}". Use: show, path, reset, or edit.`),process.exit(2)}}function I1(){console.log(`${Y.bold("Usage:")} asm install <source> [options]
128
128
 
129
129
  Install a skill from a GitHub repository.
130
130
 
@@ -156,29 +156,30 @@ ${Y.bold("Multi-skill repo:")}
156
156
  asm install github:user/skills --all -p claude -y
157
157
  asm install github:user/skills --all -p all -y ${Y.dim("(all skills, all providers)")}
158
158
  asm install https://github.com/user/skills --all
159
- asm install github:user/skills ${Y.dim("(interactive picker)")}`)}async function m($,Q,K,q,Z,V,X,z,J){let U=await b(Z);console.error(`Found skill: ${U.name} v${U.version}`);let j=await Q0(Z),W=Z===q?null:Z.split("/").pop(),O=V||W||K.repo,B=S(O),G=K0(K,q,Z,B,z,$.flags.force);if(await q0(G.targetDir,G.force),console.error(`
160
- ${Y.bold("Install preview:")}`),console.error(` Name: ${U.name}`),console.error(` Version: ${U.version}`),console.error(` Description: ${U.description||"(none)"}`),console.error(` Source: ${Q}`),J)console.error(` Provider: All (${J.map((_)=>_.label).join(", ")})`),console.error(` Primary: ${z.label} (${z.name})`),console.error(` Symlinks: ${J.filter((_)=>_.name!==z.name).map((_)=>_.label).join(", ")}`);else console.error(` Provider: ${z.label} (${z.name})`);if(console.error(` Target: ${G.targetDir}`),j.length>0){console.error(`
161
- ${Y.yellow(Y.bold("Security warnings:"))}`);let _=new Map;for(let w of j){let H=_.get(w.category)||[];H.push(w),_.set(w.category,H)}for(let[w,H]of _){console.error(`
162
- ${Y.yellow(`[${w}]`)} (${H.length} match${H.length>1?"es":""})`);for(let k of H.slice(0,5))console.error(` ${Y.dim(k.file)}:${k.line} ${k.match}`);if(H.length>5)console.error(` ... and ${H.length-5} more`)}}if(!$.flags.yes&&!$.flags.all){if(!process.stdin.isTTY)M("Cannot prompt for confirmation in non-interactive mode. Use --yes to skip."),process.exit(2);process.stderr.write(`
163
- ${Y.bold("Proceed with installation?")} [y/N] `);let _=await C();if(_.toLowerCase()!=="y"&&_.toLowerCase()!=="yes")console.error("Aborted."),process.exit(0)}if(console.error(`
164
- Installing to ${G.targetDir}...`),J)return await Z0(G,J);return await u(G)}async function H1($){if($.flags.help){L1();return}let Q=$.subcommand;if(!Q)M("Missing required argument: <source>"),console.error('Run "asm install --help" for usage.'),process.exit(2);let K=null,q=()=>{if(K)D(K).finally(()=>process.exit(1));else process.exit(1)};process.on("SIGINT",q),process.on("SIGTERM",q);try{let Z=a(Q);console.error(`Parsing source: ${Q}`),await e(),console.error(`Cloning ${Z.cloneUrl}${Z.ref?` (ref: ${Z.ref})`:""}...`),K=await r(Z);let V=await F(),{provider:X,allProviders:z}=await P(V,$.flags.provider,!!process.stdin.isTTY),{join:J}=await import("path"),U=[];if($.flags.path){let j=J(K,$.flags.path);try{await b(j)}catch{throw Error(`No SKILL.md found at path "${$.flags.path}" in the repository.`)}let W=await m($,Q,Z,K,j,$.flags.name,V,X,z);U.push(W)}else{let j=!1;try{await b(K),j=!0}catch{}if(j){let W=await m($,Q,Z,K,K,$.flags.name,V,X,z);U.push(W)}else{console.error("No SKILL.md at repository root. Scanning for skills...");let W=await $0(K);if(W.length===0)throw Error("No skills found in this repository. Skills must have a SKILL.md file.");console.error(`Found ${W.length} skill(s):
165
- `);for(let B=0;B<W.length;B++)if(console.error(` ${Y.bold(`${B+1})`)} ${W[B].name} v${W[B].version} ${Y.dim(`(${W[B].relPath})`)}`),W[B].description)console.error(` ${W[B].description}`);let O;if($.flags.all){if(O=W.map((B)=>B.relPath),console.error(`
166
- Installing all ${O.length} skills...`),!$.flags.yes){if(!process.stdin.isTTY)M("Cannot prompt for confirmation in non-interactive mode. Use --yes to skip."),process.exit(2);process.stderr.write(`
167
- ${Y.bold(`Install all ${O.length} skills?`)} [y/N] `);let B=await C();if(B.toLowerCase()!=="y"&&B.toLowerCase()!=="yes")console.error("Aborted."),process.exit(0)}}else if(process.stdin.isTTY){process.stderr.write(`
168
- Enter skill number (or "all"): `);let B=await C();if(B.toLowerCase()==="all")O=W.map((G)=>G.relPath);else{let G=parseInt(B,10)-1;if(isNaN(G)||G<0||G>=W.length)throw Error("Invalid selection. Aborting.");O=[W[G].relPath]}}else M(`Repository contains ${W.length} skills. Use --path <subdir> to pick one or --all to install all.
159
+ asm install github:user/skills ${Y.dim("(interactive picker)")}`)}async function d($,Q,K,q,Z,V,X,z,J,W){let M=await f(Z),G=W!==void 0,B=await K0(Z),_=Z===q?null:Z.split("/").pop(),U=V||_||K.repo,A=D(U),I=V0(K,q,Z,A,z,$.flags.force);if(await X0(I.targetDir,I.force),G){let O=`[${W.index}/${W.total}]`,x=B.length>0?` ${Y.yellow(`(${B.length} warning${B.length>1?"s":""})`)}`:"";console.error(`${Y.dim(O)} ${Y.bold(M.name)} v${M.version}${x}`)}else{if(console.error(`Found skill: ${M.name} v${M.version}`),console.error(`
160
+ ${Y.bold("Install preview:")}`),console.error(` Name: ${M.name}`),console.error(` Version: ${M.version}`),M.description)console.error(` Description: ${M.description}`);if(console.error(` Source: ${Q}`),J)console.error(` Provider: All (${J.map((O)=>O.label).join(", ")})`),console.error(` Primary: ${z.label} (${z.name})`),console.error(` Symlinks: ${J.filter((O)=>O.name!==z.name).map((O)=>O.label).join(", ")}`);else console.error(` Provider: ${z.label} (${z.name})`);if(console.error(` Target: ${I.targetDir}`),B.length>0){console.error(`
161
+ ${Y.yellow(Y.bold("Security warnings:"))}`);let O=new Map;for(let x of B){let C=O.get(x.category)||[];C.push(x),O.set(x.category,C)}for(let[x,C]of O){console.error(`
162
+ ${Y.yellow(`[${x}]`)} (${C.length} match${C.length>1?"es":""})`);for(let v of C.slice(0,5))console.error(` ${Y.dim(v.file)}:${v.line} -- ${v.match}`);if(C.length>5)console.error(` ... and ${C.length-5} more`)}}if(!$.flags.yes&&!$.flags.all){if(!process.stdin.isTTY)j("Cannot prompt for confirmation in non-interactive mode. Use --yes to skip."),process.exit(2);process.stderr.write(`
163
+ ${Y.bold("Proceed with installation?")} [y/N] `);let O=await w();if(O.toLowerCase()!=="y"&&O.toLowerCase()!=="yes")console.error("Aborted."),process.exit(0)}}if(!G)console.error(`
164
+ Installing to ${I.targetDir}...`);if(J)return await q0(I,J);return await c(I)}async function C1($){if($.flags.help){I1();return}let Q=$.subcommand;if(!Q)j("Missing required argument: <source>"),console.error('Run "asm install --help" for usage.'),process.exit(2);let K=null,q=()=>{if(K)k(K).finally(()=>process.exit(1));else process.exit(1)};process.on("SIGINT",q),process.on("SIGTERM",q);try{let Z=r(Q);console.error(`Parsing source: ${Q}`),await $0(),console.error(`Cloning ${Z.cloneUrl}${Z.ref?` (ref: ${Z.ref})`:""}...`),K=await Q0(Z);let V=await F(),{provider:X,allProviders:z}=await P(V,$.flags.provider,!!process.stdin.isTTY),{join:J}=await import("path"),W=[];if($.flags.path){let M=J(K,$.flags.path);try{await f(M)}catch{throw Error(`No SKILL.md found at path "${$.flags.path}" in the repository.`)}let G=await d($,Q,Z,K,M,$.flags.name,V,X,z);W.push(G)}else{let M=!1;try{await f(K),M=!0}catch{}if(M){let G=await d($,Q,Z,K,K,$.flags.name,V,X,z);W.push(G)}else{console.error("No SKILL.md at repository root. Scanning for skills...");let G=await Z0(K);if(G.length===0)throw Error("No skills found in this repository. Skills must have a SKILL.md file.");console.error(`Found ${G.length} skill(s):
165
+ `);for(let U=0;U<G.length;U++)if(console.error(` ${Y.bold(`${U+1})`)} ${G[U].name} v${G[U].version} ${Y.dim(`(${G[U].relPath})`)}`),G[U].description)console.error(` ${G[U].description}`);let B;if($.flags.all){if(B=G.map((U)=>U.relPath),console.error(`
166
+ Installing all ${B.length} skills...`),!$.flags.yes){if(!process.stdin.isTTY)j("Cannot prompt for confirmation in non-interactive mode. Use --yes to skip."),process.exit(2);process.stderr.write(`
167
+ ${Y.bold(`Install all ${B.length} skills?`)} [y/N] `);let U=await w();if(U.toLowerCase()!=="y"&&U.toLowerCase()!=="yes")console.error("Aborted."),process.exit(0)}}else if(process.stdin.isTTY){process.stderr.write(`
168
+ Enter skill number (or "all"): `);let U=await w();if(U.toLowerCase()==="all")B=G.map((A)=>A.relPath);else{let A=parseInt(U,10)-1;if(isNaN(A)||A<0||A>=G.length)throw Error("Invalid selection. Aborting.");B=[G[A].relPath]}}else j(`Repository contains ${G.length} skills. Use --path <subdir> to pick one or --all to install all.
169
169
  Available skills:
170
- ${W.map((B)=>` --path ${B.relPath}`).join(`
171
- `)}`),process.exit(2);for(let B of O){let G=J(K,B);console.error(`
172
- ${"".repeat(40)}`);try{let _=await m($,Q,Z,K,G,O.length===1?$.flags.name:null,V,X,z);U.push(_),console.error(Y.green(`✓ Installed "${_.name}" to ${_.path}`))}catch(_){if(console.error(Y.red(`✗ Failed to install from ${B}: ${_.message}`)),O.length===1)throw _}}}}if(process.removeListener("SIGINT",q),process.removeListener("SIGTERM",q),$.flags.json)console.log(JSON.stringify(U.length===1?U[0]:U,null,2));else if(U.length===1)console.error(Y.green(`
173
- ✓ Installed "${U[0].name}" to ${U[0].path}`));else console.error(`
174
- ${Y.green(`✓ Installed ${U.length} skill(s) successfully.`)}`)}catch(Z){if(process.removeListener("SIGINT",q),process.removeListener("SIGTERM",q),$.flags.json)console.log(JSON.stringify({success:!1,error:Z.message},null,2));else M(Z.message);process.exit(1)}finally{if(K)await D(K)}}function I1(){console.log(`${Y.bold("Usage:")} asm export [options]
170
+ ${G.map((U)=>` --path ${U.relPath}`).join(`
171
+ `)}`),process.exit(2);if(B.length>1){if(console.error(`
172
+ ${Y.bold("Install settings:")}`),console.error(` Source: ${Q}`),z)console.error(` Provider: All (${z.map((U)=>U.label).join(", ")})`),console.error(` Primary: ${X.label} (${X.name})`),console.error(` Symlinks: ${z.filter((U)=>U.name!==X.name).map((U)=>U.label).join(", ")}`);else console.error(` Provider: ${X.label} (${X.name})`);console.error("")}let _=[];for(let U=0;U<B.length;U++){let A=B[U],I=J(K,A);try{let O=await d($,Q,Z,K,I,B.length===1?$.flags.name:null,V,X,z,B.length>1?{index:U+1,total:B.length}:void 0);W.push(O)}catch(O){if(_.push(A),console.error(Y.red(` x Failed: ${A} -- ${O.message}`)),B.length===1)throw O}}if(B.length>1&&_.length>0){console.error(`
173
+ ${Y.yellow(`${_.length} skill(s) failed to install:`)}`);for(let U of _)console.error(` - ${U}`)}}}if(process.removeListener("SIGINT",q),process.removeListener("SIGTERM",q),$.flags.json)console.log(JSON.stringify(W.length===1?W[0]:W,null,2));else if(W.length===1)console.error(Y.green(`
174
+ Done! Installed "${W[0].name}" to ${W[0].path}`));else console.error(`
175
+ ${Y.green(`Done! Installed ${W.length} skill(s) successfully.`)}`)}catch(Z){if(process.removeListener("SIGINT",q),process.removeListener("SIGTERM",q),$.flags.json)console.log(JSON.stringify({success:!1,error:Z.message},null,2));else j(Z.message);process.exit(1)}finally{if(K)await k(K)}}function R1(){console.log(`${Y.bold("Usage:")} asm export [options]
175
176
 
176
177
  Export skill inventory as a portable JSON manifest.
177
178
 
178
179
  ${Y.bold("Options:")}
179
180
  -s, --scope <s> Filter: global, project, or both (default: both)
180
181
  --no-color Disable ANSI colors
181
- -V, --verbose Show debug output`)}async function C1($){if($.flags.help){I1();return}let Q=await F(),K=await I(Q,$.flags.scope),q=Y0(K);console.log(JSON.stringify(q,null,2))}function x1(){console.log(`${Y.bold("Usage:")} asm init <name> [options]
182
+ -V, --verbose Show debug output`)}async function x1($){if($.flags.help){R1();return}let Q=await F(),K=await R(Q,$.flags.scope),q=J0(K);console.log(JSON.stringify(q,null,2))}function w1(){console.log(`${Y.bold("Usage:")} asm init <name> [options]
182
183
 
183
184
  Scaffold a new skill directory with a SKILL.md template.
184
185
 
@@ -187,8 +188,8 @@ ${Y.bold("Options:")}
187
188
  --path <dir> Scaffold in specified directory instead of provider path
188
189
  -f, --force Overwrite if skill already exists
189
190
  --no-color Disable ANSI colors
190
- -V, --verbose Show debug output`)}async function R1($){if($.flags.help){x1();return}let Q=$.subcommand;if(!Q)M("Missing required argument: <name>"),console.error('Run "asm init --help" for usage.'),process.exit(2);let K=S(Q),q;if($.flags.path){let{resolve:Z}=await import("path");q=Z($.flags.path)}else{let Z=await F(),{provider:V}=await P(Z,$.flags.provider,!!process.stdin.isTTY),{join:X}=await import("path"),{resolveProviderPath:z}=await import("./chunk-zh7g5bam.js"),J=z(Z.providers.find((U)=>U.name===V.name).global);q=X(J,K)}if(await J0(q)){if(!$.flags.force){if(!process.stdin.isTTY)M(`Directory already exists: ${q}. Use --force to overwrite.`),process.exit(2);process.stderr.write(`${Y.yellow(`Directory already exists: ${q}`)}
191
- ${Y.bold("Overwrite?")} [y/N] `);let Z=await C();if(Z.toLowerCase()!=="y"&&Z.toLowerCase()!=="yes")console.error("Aborted."),process.exit(0)}}await z0(K,q),console.error(Y.green(`✓ Created skill "${K}" at ${q}`))}function w1(){console.log(`${Y.bold("Usage:")} asm stats [options]
191
+ -V, --verbose Show debug output`)}async function y1($){if($.flags.help){w1();return}let Q=$.subcommand;if(!Q)j("Missing required argument: <name>"),console.error('Run "asm init --help" for usage.'),process.exit(2);let K=D(Q),q;if($.flags.path){let{resolve:Z}=await import("path");q=Z($.flags.path)}else{let Z=await F(),{provider:V}=await P(Z,$.flags.provider,!!process.stdin.isTTY),{join:X}=await import("path"),{resolveProviderPath:z}=await import("./chunk-zh7g5bam.js"),J=z(Z.providers.find((W)=>W.name===V.name).global);q=X(J,K)}if(await W0(q)){if(!$.flags.force){if(!process.stdin.isTTY)j(`Directory already exists: ${q}. Use --force to overwrite.`),process.exit(2);process.stderr.write(`${Y.yellow(`Directory already exists: ${q}`)}
192
+ ${Y.bold("Overwrite?")} [y/N] `);let Z=await w();if(Z.toLowerCase()!=="y"&&Z.toLowerCase()!=="yes")console.error("Aborted."),process.exit(0)}}await U0(K,q),console.error(Y.green(`Done! Created skill "${K}" at ${q}`))}function N1(){console.log(`${Y.bold("Usage:")} asm stats [options]
192
193
 
193
194
  Show aggregate skill metrics dashboard.
194
195
 
@@ -196,7 +197,7 @@ ${Y.bold("Options:")}
196
197
  --json Output as JSON
197
198
  -s, --scope <s> Filter: global, project, or both (default: both)
198
199
  --no-color Disable ANSI colors
199
- -V, --verbose Show debug output`)}async function y1($){if($.flags.help){w1();return}let Q=await F(),K=await I(Q,$.flags.scope);if(K.length===0){console.log("No skills found.");return}let q=o(K),Z=await U0(K,q);if($.flags.json)console.log(x(Z));else console.log(W0(Z))}function N1(){console.log(`${Y.bold("Usage:")} asm link <path> [options]
200
+ -V, --verbose Show debug output`)}async function S1($){if($.flags.help){N1();return}let Q=await F(),K=await R(Q,$.flags.scope);if(K.length===0){console.log("No skills found.");return}let q=t(K),Z=await G0(K,q);if($.flags.json)console.log(y(Z));else console.log(B0(Z))}function b1(){console.log(`${Y.bold("Usage:")} asm link <path> [options]
200
201
 
201
202
  Symlink a local skill directory into an agent's skill folder.
202
203
 
@@ -206,5 +207,5 @@ ${Y.bold("Options:")}
206
207
  -f, --force Overwrite if target already exists
207
208
  --json Output as JSON
208
209
  --no-color Disable ANSI colors
209
- -V, --verbose Show debug output`)}async function S1($){if($.flags.help){N1();return}let Q=$.subcommand;if(!Q)M("Missing required argument: <path>"),console.error('Run "asm link --help" for usage.'),process.exit(2);let{resolve:K,basename:q}=await import("path"),Z=K(Q),V=await G0(Z),X=$.flags.name?S($.flags.name):q(Z),z=await F(),{provider:J}=await P(z,$.flags.provider,!!process.stdin.isTTY),{resolveProviderPath:U}=await import("./chunk-zh7g5bam.js"),j=U(z.providers.find((B)=>B.name===J.name).global),{join:W}=await import("path"),O=W(j,X);if(!$.flags.force){let B=!1;try{let{access:G}=await import("fs/promises");await G(O),B=!0}catch{}if(B){if(!process.stdin.isTTY)M(`Target already exists: ${O}. Use --force to overwrite.`),process.exit(2);process.stderr.write(`${Y.yellow(`Target already exists: ${O}`)}
210
- ${Y.bold("Overwrite?")} [y/N] `);let G=await C();if(G.toLowerCase()!=="y"&&G.toLowerCase()!=="yes")console.error("Aborted."),process.exit(0);await f(Z,j,X,!0)}else await f(Z,j,X,!1)}else await f(Z,j,X,!0);if($.flags.json)console.log(x({success:!0,name:X,symlinkPath:O,targetPath:Z}));else console.error(Y.green(`✓ Linked "${X}" ${Z}`)),console.error(` Symlink: ${O}`),console.error(Y.dim(` If you move or delete the source, run "asm uninstall ${X}" to clean up.`))}async function x0($){let Q=z1($);if(Q.flags.noColor)globalThis.__CLI_NO_COLOR=!0;if(Q.flags.verbose)M0(!0);if(Q.flags.version){console.log(`asm ${n}`);return}if(!Q.command&&Q.flags.help){J1();return}if(!Q.command)return;switch(Q.command){case"list":await O1(Q);break;case"search":await _1(Q);break;case"inspect":await F1(Q);break;case"uninstall":await A1(Q);break;case"audit":await E1(Q);break;case"install":await H1(Q);break;case"config":await T1(Q);break;case"export":await C1(Q);break;case"init":await R1(Q);break;case"stats":await y1(Q);break;case"link":await S1(Q);break;default:M(`Unknown command: "${Q.command}"`),console.error('Run "asm --help" for usage.'),process.exit(2)}}function R0($){let Q=$.slice(2);if(Q.length===0)return!1;let K=["list","search","inspect","uninstall","audit","config","install","export","init","stats","link"],q=Q[0];if(K.includes(q))return!0;if(q==="--help"||q==="-h")return!0;if(q==="--version"||q==="-v")return!0;if(q.startsWith("-")||q.length>0)return!0;return!1}if(R0(process.argv))await x0(process.argv);else await import("./chunk-qfn7hb5z.js");
210
+ -V, --verbose Show debug output`)}async function D1($){if($.flags.help){b1();return}let Q=$.subcommand;if(!Q)j("Missing required argument: <path>"),console.error('Run "asm link --help" for usage.'),process.exit(2);let{resolve:K,basename:q}=await import("path"),Z=K(Q),V=await j0(Z),X=$.flags.name?D($.flags.name):q(Z),z=await F(),{provider:J}=await P(z,$.flags.provider,!!process.stdin.isTTY),{resolveProviderPath:W}=await import("./chunk-zh7g5bam.js"),M=W(z.providers.find((_)=>_.name===J.name).global),{join:G}=await import("path"),B=G(M,X);if(!$.flags.force){let _=!1;try{let{access:U}=await import("fs/promises");await U(B),_=!0}catch{}if(_){if(!process.stdin.isTTY)j(`Target already exists: ${B}. Use --force to overwrite.`),process.exit(2);process.stderr.write(`${Y.yellow(`Target already exists: ${B}`)}
211
+ ${Y.bold("Overwrite?")} [y/N] `);let U=await w();if(U.toLowerCase()!=="y"&&U.toLowerCase()!=="yes")console.error("Aborted."),process.exit(0);await h(Z,M,X,!0)}else await h(Z,M,X,!1)}else await h(Z,M,X,!0);if($.flags.json)console.log(y({success:!0,name:X,symlinkPath:B,targetPath:Z}));else console.error(Y.green(`Done! Linked "${X}" -> ${Z}`)),console.error(` Symlink: ${B}`),console.error(Y.dim(` If you move or delete the source, run "asm uninstall ${X}" to clean up.`))}async function w0($){let Q=U1($);if(Q.flags.noColor)globalThis.__CLI_NO_COLOR=!0;if(Q.flags.verbose)O0(!0);if(Q.flags.version){console.log(`asm ${l}`);return}if(!Q.command&&Q.flags.help){W1();return}if(!Q.command)return;switch(Q.command){case"list":await F1(Q);break;case"search":await A1(Q);break;case"inspect":await E1(Q);break;case"uninstall":await L1(Q);break;case"audit":await T1(Q);break;case"install":await C1(Q);break;case"config":await H1(Q);break;case"export":await x1(Q);break;case"init":await y1(Q);break;case"stats":await S1(Q);break;case"link":await D1(Q);break;default:j(`Unknown command: "${Q.command}"`),console.error('Run "asm --help" for usage.'),process.exit(2)}}function y0($){let Q=$.slice(2);if(Q.length===0)return!1;let K=["list","search","inspect","uninstall","audit","config","install","export","init","stats","link"],q=Q[0];if(K.includes(q))return!0;if(q==="--help"||q==="-h")return!0;if(q==="--version"||q==="-v")return!0;if(q.startsWith("-")||q.length>0)return!0;return!1}if(y0(process.argv))await w0(process.argv);else await import("./chunk-9pkjdwkv.js");
@@ -0,0 +1,8 @@
1
+ import{w as I,z as X}from"./chunk-zh7g5bam.js";import{readdir as P,stat as C,lstat as N,readlink as R,readFile as K,realpath as _}from"fs/promises";import{join as H,resolve as w}from"path";function U(o){let c={},t=o.split(`
2
+ `),$=!1,S=!1,j=null,A=[],B="none",f=-1;function L(){if(j){let p=A.join(" ").trim();if(p)c[j]=p;j=null,A=[],B="none",f=-1}}for(let p of t){if(p.trim()==="---")if(!S){S=!0,$=!0;continue}else{L();break}if(!$)continue;if(B!=="none"&&j){let G=p.replace(/^\s*/,""),z=p.length-G.length;if(z>0&&G.length>0){if(f===-1)f=z;A.push(G);continue}else if(G.length===0)continue;else L()}let v=p.match(/^(\w[\w-]*):\s*(.*?)\s*$/);if(v){L();let G=v[1],z=v[2];if(z==="|"||z===">")j=G,A=[],B=z==="|"?"literal":"folded";else if(z==="|+"||z===">+"||z==="|-"||z===">-")j=G,A=[],B=z.startsWith("|")?"literal":"folded";else{let T=z.replace(/^["']|["']$/g,"");if(T)c[G]=T}}}return L(),c}function E(o,c){let t=[];for(let $ of o.providers){if(!$.enabled){I(`scan: skipping disabled provider "${$.name}"`);continue}if(c==="global"||c==="both"){let S=X($.global);I(`scan: adding location ${S} (${$.label}, global)`),t.push({dir:S,location:`global-${$.name}`,scope:"global",providerName:$.name,providerLabel:$.label})}if(c==="project"||c==="both"){let S=X($.project);I(`scan: adding location ${S} (${$.label}, project)`),t.push({dir:S,location:`project-${$.name}`,scope:"project",providerName:$.name,providerLabel:$.label})}}for(let $ of o.customPaths)if(c===$.scope||c==="both"){let S=X($.path);I(`scan: adding custom location ${S} (${$.label}, ${$.scope})`),t.push({dir:S,location:`${$.scope}-custom`,scope:$.scope,providerName:"custom",providerLabel:$.label})}return t}async function O(o){try{return(await P(o,{recursive:!0})).length}catch{return 0}}async function M(o){let c=[];I(`scanning: ${o.dir} (${o.location})`);let t;try{t=await P(o.dir)}catch{return I(`scanning: ${o.dir} — not found, skipping`),c}for(let $ of t){let S=H(o.dir,$);try{if(!(await C(S)).isDirectory()){I(` skip: "${$}" — not a directory`);continue}}catch{I(` skip: "${$}" — stat failed`);continue}let j=H(S,"SKILL.md"),A;try{A=await K(j,"utf-8")}catch{I(` skip: "${$}" — no SKILL.md`);continue}let B=U(A),f=!1,L=null;try{if((await N(S)).isSymbolicLink())f=!0,L=await R(S)}catch{}let p=w(S),v;try{v=await _(S)}catch{v=p}c.push({name:B.name||$,version:B.version||"0.0.0",description:(B.description||"").replace(/\s*\n\s*/g," ").trim(),dirName:$,path:p,originalPath:S,location:o.location,scope:o.scope,provider:o.providerName,providerLabel:o.providerLabel,isSymlink:f,symlinkTarget:L,realPath:v})}return I(`found ${c.length} skill(s) in ${o.dir}`),c}async function Ao(o,c){let t=E(o,c);return(await Promise.all(t.map(M))).flat()}function Bo(o,c){if(!c.trim())return o;let t=c.toLowerCase();return o.filter(($)=>$.name.toLowerCase().includes(t)||$.description.toLowerCase().includes(t)||$.location.toLowerCase().includes(t)||$.providerLabel.toLowerCase().includes(t))}function h(o,c){let t=o.split("."),$=c.split("."),S=Math.max(t.length,$.length);for(let j=0;j<S;j++){let A=parseInt(t[j]??"0",10),B=parseInt($[j]??"0",10);if(isNaN(A)||isNaN(B))return o.localeCompare(c);if(A!==B)return A-B}return 0}function vo(o,c){let t=[...o];switch(c){case"name":t.sort(($,S)=>$.name.localeCompare(S.name));break;case"version":t.sort(($,S)=>h($.version,S.version));break;case"location":t.sort(($,S)=>$.location.localeCompare(S.location));break}return t}import{rm as q,readFile as D,writeFile as F,access as x,lstat as V}from"fs/promises";import{join as y,resolve as Z,dirname as n}from"path";import{homedir as m}from"os";var r=m();function b(o,c){let t={directories:[],ruleFiles:[],agentsBlocks:[]};t.directories.push({path:o.originalPath,isSymlink:o.isSymlink});let $=o.dirName;if(o.scope==="project")t.ruleFiles.push(Z(".cursor","rules",`${$}.mdc`),Z(".windsurf","rules",`${$}.md`),Z(".github","instructions",`${$}.instructions.md`)),t.agentsBlocks.push({file:Z("AGENTS.md"),skillName:$});if(o.scope==="global"){for(let A of c.providers){if(!A.enabled)continue;let B=X(A.global),f=y(n(B),"AGENTS.md");t.agentsBlocks.push({file:f,skillName:$})}let S=y(r,".codex","AGENTS.md");if(!t.agentsBlocks.some((A)=>A.file===S))t.agentsBlocks.push({file:S,skillName:$})}return t}function Xo(o,c,t){let $=c.filter((f)=>f.dirName===o);if($.length===0)return{directories:[],ruleFiles:[],agentsBlocks:[]};let S={directories:[],ruleFiles:[],agentsBlocks:[]},j=new Set,A=new Set,B=new Set;for(let f of $){let L=b(f,t);for(let p of L.directories)if(!j.has(p.path))j.add(p.path),S.directories.push(p);for(let p of L.ruleFiles)if(!A.has(p))A.add(p),S.ruleFiles.push(p);for(let p of L.agentsBlocks){let v=`${p.file}::${p.skillName}`;if(!B.has(v))B.add(v),S.agentsBlocks.push(p)}}return S}async function Y(o){try{return await x(o),!0}catch{return!1}}async function a(o,c){if(!await Y(o))return;let t=await D(o,"utf-8");for(let $ of["agent-skill-manager","skill-manager","pskills"]){let S=`<!-- ${$}: ${c} -->`,j=`<!-- /${$}: ${c} -->`,A=t.indexOf(S),B=t.indexOf(j);if(A===-1||B===-1)continue;let f=A;if(f>0&&t[f-1]===`
3
+ `)f--;let p=B+j.length;if(p<t.length&&t[p]===`
4
+ `)p++;t=t.slice(0,f)+t.slice(p)}await F(o,t,"utf-8")}async function Yo(o){let c=[];for(let t of o.directories)try{if(t.isSymlink)await q(t.path),c.push(`Removed symlink: ${t.path}`);else await q(t.path,{recursive:!0,force:!0}),c.push(`Removed directory: ${t.path}`)}catch($){c.push(`Failed to remove ${t.path}: ${$.message}`)}for(let t of o.ruleFiles)if(await Y(t))try{await q(t),c.push(`Removed rule file: ${t}`)}catch($){c.push(`Failed to remove ${t}: ${$.message}`)}for(let t of o.agentsBlocks)try{await a(t.file,t.skillName),c.push(`Cleaned AGENTS.md block in: ${t.file}`)}catch($){c.push(`Failed to clean AGENTS.md block: ${$.message}`)}return c}async function Zo(o){let c=[];for(let t of o.directories)if(await Y(t.path)){let S=(await V(t.path)).isSymbolicLink()?"symlink":"directory";c.push(`${t.path} (${S})`)}for(let t of o.ruleFiles)if(await Y(t))c.push(t);for(let t of o.agentsBlocks)if(await Y(t.file)){let $=await D(t.file,"utf-8");if($.includes(`<!-- agent-skill-manager: ${t.skillName} -->`)||$.includes(`<!-- skill-manager: ${t.skillName} -->`)||$.includes(`<!-- pskills: ${t.skillName} -->`))c.push(`${t.file} (AGENTS.md block)`)}return c}var Q=()=>{if(process.env.NO_COLOR!==void 0)return!1;if(globalThis.__CLI_NO_COLOR)return!1;if(!process.stdout.isTTY)return!1;return!0},W={bold:(o)=>Q()?`\x1B[1m${o}\x1B[0m`:o,cyan:(o)=>Q()?`\x1B[36m${o}\x1B[0m`:o,green:(o)=>Q()?`\x1B[32m${o}\x1B[0m`:o,yellow:(o)=>Q()?`\x1B[33m${o}\x1B[0m`:o,dim:(o)=>Q()?`\x1B[2m${o}\x1B[0m`:o,red:(o)=>Q()?`\x1B[31m${o}\x1B[0m`:o,blueBold:(o)=>Q()?`\x1B[1m\x1B[34m${o}\x1B[0m`:o};function To(o){if(o.length===0)return"No skills found.";let c=["Name","Version","Provider","Scope","Type","Path"],t=o.map((f)=>[f.name,f.version,f.providerLabel,f.scope,f.isSymlink?"symlink":"directory",f.path]),$=c.map((f,L)=>Math.max(f.length,...t.map((p)=>p[L].length))),S=(f,L)=>f.padEnd(L),j=c.map((f,L)=>S(f,$[L])).join(" "),A=$.map((f)=>"-".repeat(f)).join("--"),B=t.map((f)=>f.map((L,p)=>S(L,$[p])).join(" "));return[Q()?W.bold(j):j,A,...B].join(`
5
+ `)}async function Uo(o){let c=[],t=(S,j)=>`${Q()?W.bold(S+":"):S+":"} ${j}`;if(c.push(t("Name",o.name)),c.push(t("Version",o.version)),c.push(t("Provider",o.providerLabel)),c.push(t("Scope",o.scope)),c.push(t("Location",o.location)),c.push(t("Path",o.path)),c.push(t("Type",o.isSymlink?"symlink":"directory")),o.isSymlink&&o.symlinkTarget)c.push(t("Symlink Target",o.symlinkTarget));let $=o.fileCount??await O(o.path);if(c.push(t("File Count",String($))),o.description)c.push(""),c.push(t("Description",o.description));if(o.warnings&&o.warnings.length>0){c.push(""),c.push(Q()?W.bold("Warnings:"):"Warnings:");for(let S of o.warnings)c.push(` ${Q()?W.yellow("!"):"!"} [${S.category}] ${S.message}`)}return c.join(`
6
+ `)}function Ho(o){return JSON.stringify(o,null,2)}function yo(o){let c=[],t=new Set,$=new Map,S=[];for(let f of o){let L=$.get(f.realPath);if(L){if(f.isSymlink)continue;if(L.isSymlink)S[S.indexOf(L)]=f,$.set(f.realPath,f);else S.push(f)}else $.set(f.realPath,f),S.push(f)}let j=new Map;for(let f of S){let L=j.get(f.dirName)??[];L.push(f),j.set(f.dirName,L)}for(let[f,L]of j)if(new Set(L.map((v)=>v.location)).size>=2){c.push({key:f,reason:"same-dirName",instances:L});for(let v of L)t.add(v.path)}let A=new Map;for(let f of S){if(!f.name)continue;let L=A.get(f.name)??[];L.push(f),A.set(f.name,L)}for(let[f,L]of A){if(new Set(L.map((z)=>z.dirName)).size<2)continue;let v=L.filter((z)=>!t.has(z.path));if(v.length<2)continue;if(new Set(v.map((z)=>z.dirName)).size<2)continue;c.push({key:f,reason:"same-frontmatterName",instances:v})}c.sort((f,L)=>{if(f.reason!==L.reason)return f.reason==="same-dirName"?-1:1;return f.key.localeCompare(L.key)});let B=c.reduce((f,L)=>f+L.instances.length,0);return{scannedAt:new Date().toISOString(),totalSkills:o.length,duplicateGroups:c,totalDuplicateInstances:B}}function u(o){return[...o].sort((c,t)=>{if(c.scope!==t.scope)return c.scope==="global"?-1:1;let $=c.providerLabel.localeCompare(t.providerLabel);if($!==0)return $;return c.path.localeCompare(t.path)})}function d(o){return o==="same-dirName"?"same dirName":"same name"}function Do(o){if(o.duplicateGroups.length===0)return W.green("No duplicate skills found.");let c=[];c.push(W.bold(`Found ${o.duplicateGroups.length} duplicate group(s) (${o.totalDuplicateInstances} total instances):`)),c.push("");for(let t of o.duplicateGroups){c.push(W.yellow(` Group: "${t.key}" (${d(t.reason)})`));let $=u(t.instances);for(let S=0;S<$.length;S++){let j=$[S],A=S===0?W.green(" (recommended keep)"):"";c.push(` ${W.dim("•")} ${j.path} [${j.providerLabel}/${j.scope}]${A}`)}c.push("")}return c.join(`
7
+ `)}function go(o){return JSON.stringify(o,null,2)}import{readFileSync as i}from"fs";import{resolve as k,dirname as s}from"path";import{fileURLToPath as e}from"url";import{execSync as l}from"child_process";var oo=s(e(import.meta.url)),g="1.5.1";try{let o=i(k(oo,"../../package.json"),"utf-8");g=JSON.parse(o).version}catch{}var J="dad0bf2";try{J=l("git rev-parse --short HEAD",{encoding:"utf-8"}).trim()||J}catch{}var to=g,co=J,wo=`v${to} (${co})`;
8
+ export{U as a,O as b,Ao as c,Bo as d,vo as e,b as f,Xo as g,Yo as h,Zo as i,W as j,To as k,Uo as l,Ho as m,yo as n,u as o,d as p,Do as q,go as r,wo as s};