agent-skill-manager 1.3.0 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -0
- package/dist/agent-skill-manager.js +148 -121
- package/dist/chunk-221zx7k2.js +8 -0
- package/dist/chunk-8e2d1703.js +8 -0
- package/dist/chunk-c662hngs.js +90 -0
- package/dist/chunk-dg0nqb63.js +90 -0
- package/dist/chunk-e2gf6qhq.js +8 -0
- package/dist/chunk-my862t5h.js +90 -0
- package/dist/chunk-njbwyyw5.js +9 -0
- package/dist/chunk-pgv8xpxb.js +90 -0
- package/dist/chunk-s1gskd5a.js +8 -0
- package/dist/chunk-t21tdjjx.js +90 -0
- package/dist/chunk-y00s0dtt.js +9 -0
- package/dist/chunk-yvfqvjev.js +90 -0
- package/dist/chunk-zh7g5bam.js +3 -0
- package/package.json +5 -3
|
@@ -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.4.0";try{let o=i(k(oo,"../../package.json"),"utf-8");g=JSON.parse(o).version}catch{}var J="ad04bee";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};
|
|
@@ -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.4.0";try{let o=i(k(oo,"../../package.json"),"utf-8");g=JSON.parse(o).version}catch{}var J="b9eef6a";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};
|