@easbot/skills 0.3.13 → 0.3.16

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.
Files changed (62) hide show
  1. package/README.en.md +432 -125
  2. package/README.md +427 -125
  3. package/dist/chunks/blob-RYNC3CVY.cjs +1 -0
  4. package/dist/chunks/{blob-3PZEQWTP.mjs → blob-WZAGX4RO.mjs} +1 -1
  5. package/dist/chunks/chunk-5DAHAO55.mjs +3 -0
  6. package/dist/chunks/{chunk-4D5RQDWJ.mjs → chunk-6OLPTZDO.mjs} +2 -2
  7. package/dist/chunks/{chunk-ZBKGF7PA.mjs → chunk-BQ6QWQEM.mjs} +1 -1
  8. package/dist/chunks/chunk-BWDTT6SA.cjs +3 -0
  9. package/dist/chunks/chunk-DNE3XPCJ.cjs +2 -0
  10. package/dist/chunks/chunk-HI5IN4UL.mjs +265 -0
  11. package/dist/chunks/chunk-HOK3SUH4.cjs +22 -0
  12. package/dist/chunks/{chunk-5BL3KG26.cjs → chunk-IJI72D6W.cjs} +2 -2
  13. package/dist/chunks/{chunk-ISMGLHYS.cjs → chunk-JUNIAQ2A.cjs} +1 -1
  14. package/dist/chunks/{chunk-CY6UI6SJ.cjs → chunk-LJ63Q26N.cjs} +1 -1
  15. package/dist/chunks/{chunk-S6YNGR7S.cjs → chunk-Q2MOP5ZW.cjs} +2 -2
  16. package/dist/chunks/chunk-S5OLAC7X.cjs +265 -0
  17. package/dist/chunks/chunk-UUZB3HCD.mjs +22 -0
  18. package/dist/chunks/chunk-Y6D5Z6AU.mjs +1 -0
  19. package/dist/chunks/chunk-ZJS7IO5V.mjs +2 -0
  20. package/dist/chunks/cli-handler-2G4ZYO2S.cjs +1 -0
  21. package/dist/chunks/cli-handler-F4DUEULA.mjs +1 -0
  22. package/dist/chunks/installer-3ZLHOVAO.cjs +1 -0
  23. package/dist/chunks/{installer-REG45DC2.mjs → installer-UUEXYC7I.mjs} +1 -1
  24. package/dist/chunks/{interfaces-UIS44Q7A.cjs → interfaces-T3TO7GQW.cjs} +1 -1
  25. package/dist/chunks/local-lock-KNX2RUIV.cjs +1 -0
  26. package/dist/chunks/local-lock-UYZTKIET.mjs +1 -0
  27. package/dist/chunks/scan-6EBCZDVK.cjs +1 -0
  28. package/dist/chunks/scan-BZA5LEZN.mjs +1 -0
  29. package/dist/chunks/skill-lock-CDMLVBYH.mjs +1 -0
  30. package/dist/chunks/skill-lock-WPACLO4W.cjs +1 -0
  31. package/dist/chunks/store-2ULHEVHS.cjs +1 -0
  32. package/dist/chunks/{store-IVDLGLET.mjs → store-FRXO6UWU.mjs} +1 -1
  33. package/dist/chunks/telemetry-TAVF3FAM.cjs +1 -0
  34. package/dist/cli.cjs +1 -1
  35. package/dist/cli.mjs +1 -1
  36. package/dist/index.cjs +1 -1
  37. package/dist/index.d.cts +3 -2
  38. package/dist/index.d.ts +3 -2
  39. package/dist/index.mjs +1 -1
  40. package/package.json +7 -8
  41. package/dist/chunks/blob-ZDEX2HRV.cjs +0 -1
  42. package/dist/chunks/chunk-5W7HC7BY.mjs +0 -22
  43. package/dist/chunks/chunk-CXH3OTTQ.cjs +0 -22
  44. package/dist/chunks/chunk-K2XGYOXP.mjs +0 -267
  45. package/dist/chunks/chunk-ML6B4IQL.mjs +0 -1
  46. package/dist/chunks/chunk-NKIQLESR.mjs +0 -3
  47. package/dist/chunks/chunk-ROCFLAYZ.mjs +0 -2
  48. package/dist/chunks/chunk-RVR3DSD2.cjs +0 -2
  49. package/dist/chunks/chunk-SXUY2J75.cjs +0 -3
  50. package/dist/chunks/chunk-UJWB7QQ6.cjs +0 -267
  51. package/dist/chunks/cli-handler-667TYY4I.cjs +0 -1
  52. package/dist/chunks/cli-handler-YSDUNKKZ.mjs +0 -1
  53. package/dist/chunks/installer-SOVGUW3M.cjs +0 -1
  54. package/dist/chunks/local-lock-AWD3LLEY.mjs +0 -1
  55. package/dist/chunks/local-lock-GIZDVF3X.cjs +0 -1
  56. package/dist/chunks/scan-57D2H7LP.cjs +0 -1
  57. package/dist/chunks/scan-WAXGJM5N.mjs +0 -1
  58. package/dist/chunks/skill-lock-DZMA75MY.mjs +0 -1
  59. package/dist/chunks/skill-lock-XTWQYBRG.cjs +0 -1
  60. package/dist/chunks/store-F7PGGZIO.cjs +0 -1
  61. package/dist/chunks/telemetry-LCGTSJDM.cjs +0 -1
  62. /package/dist/chunks/{chunk-VRHWDHQV.cjs → chunk-BWPPLYIF.cjs} +0 -0
@@ -1,22 +0,0 @@
1
- import {k}from'./chunk-ML6B4IQL.mjs';import {p,m as m$1,o}from'./chunk-RWZ4LFSN.mjs';import {b as b$1,c,d as d$1,l}from'./chunk-ROCFLAYZ.mjs';import {a,d,b as b$2}from'./chunk-ZYDDQV73.mjs';import {b}from'./chunk-WQGSYA5D.mjs';import {rm,mkdtemp,readFile,rename,mkdir,writeFile,rmdir,cp,readdir,stat}from'fs/promises';import {dirname,join,normalize,resolve,sep,basename,relative,isAbsolute}from'path';import {createHash}from'crypto';import {existsSync}from'fs';import he from'simple-git';import {Filesystem,Glob,Wildcard}from'@easbot/utils';import {tmpdir}from'os';import {execFile}from'child_process';import {promisify}from'util';import {gunzipSync,inflateRawSync}from'zlib';var N=6;function pe(n){let t=n.indexOf(":");return t<0||t===n.length-1?null:{marketId:n.slice(0,t),pluginSlug:n.slice(t+1)}}function de(n){let t=pe(n);return t?`plugins/${t.pluginSlug}`:null}function vt(n,t,e){if(!n.marketId||!n.pluginId)return null;let r=de(n.pluginId);return r?`${t.replace(/\\/g,"/").replace(/\/+$/,"")}/${n.marketId}/${r}/${e}`:null}var At=3e5,nt=(()=>{let n=process.env.SKILLS_CLONE_TIMEOUT;if(!n)return At;let t=Number.parseInt(n,10);return Number.isFinite(t)&&t>0?t:At})(),Wt=promisify(execFile),L=class extends Error{constructor(e,r,s=false,i=false){super(e);b(this,"url");b(this,"isTimeout");b(this,"isAuthError");this.name="GitCloneError",this.url=r,this.isTimeout=s,this.isAuthError=i;}};function be(n){let t=n.match(/^git@github\.com:([^/]+)\/([^/]+?)(?:\.git)?$/i);if(t){let e=t[1],r=t[2];return {owner:e,repo:r,slug:`${e}/${r}`,sshUrl:`git@github.com:${e}/${r}.git`}}try{let e=new URL(n);if(e.hostname!=="github.com")return null;let r=e.pathname.match(/^\/([^/]+)\/([^/]+?)(?:\.git)?\/?$/);if(!r)return null;let s=r[1],i=r[2];return {owner:s,repo:i,slug:`${s}/${i}`,sshUrl:`git@github.com:${s}/${i}.git`}}catch{return null}}function Pe(n){try{let t=new URL(n);return t.protocol==="https:"&&t.hostname==="github.com"}catch{return false}}function Ut(n){let t=n.toLowerCase();return t.includes("saml sso")||t.includes("enforced sso")||t.includes("enabled or enforced saml")||t.includes("re-authorize the oauth application")}function Le(n){return n.includes("Authentication failed")||n.includes("could not read Username")||n.includes("Permission denied")||n.includes("Repository not found")||n.includes("requested URL returned error: 403")||Ut(n)}function et(n){let t={...process.env};return delete t.GIT_ASKPASS,delete t.GIT_EDITOR,delete t.GIT_SEQUENCE_EDITOR,delete t.GIT_PAGER,delete t.GIT_SSH_COMMAND,delete t.GIT_CONFIG_GLOBAL,delete t.GIT_CONFIG_SYSTEM,delete t.PAGER,delete t.EDITOR,delete t.VISUAL,t.GIT_TERMINAL_PROMPT="0",t.GIT_LFS_SKIP_SMUDGE="1",Object.assign(t,n),he({timeout:{block:nt},config:["filter.lfs.required=false","protocol.version=2","remote.origin.promisor=false"]}).env(t)}async function Kt(n){try{await rm(n,{recursive:!0,force:!0});}catch{}await mkdir(n,{recursive:true});}async function Ie(n,t,e){let r=n.slug;try{let{stdout:i,stderr:o}=await Wt("gh",["auth","status","-h","github.com"],{timeout:5e3,env:{...process.env,GIT_TERMINAL_PROMPT:"0"}}),l=`${i}${o}`;/Git operations protocol:\s+ssh/i.test(l)&&(r=n.sshUrl);}catch{return false}return await Wt("gh",["repo","clone",r,t,"--",...e?["--depth=1","--branch",e]:["--depth=1"]],{timeout:nt,env:{...process.env,GIT_TERMINAL_PROMPT:"0"}}),true}function ve(n,t,e){return t&&Ut(e)?`GitHub blocked HTTPS access to ${n} because the organization enforces SAML SSO.
2
- skills tried your existing git credentials and available fallbacks, but none succeeded.
3
- - Re-authorize your GitHub credentials/app for that org's SSO policy
4
- - Or rerun with SSH: easbot skills add ${t.sshUrl}
5
- - Verify access with: gh auth status -h github.com or ssh -T git@github.com`:t?`Authentication failed for ${n}.
6
- - For private repos, ensure you have access
7
- - Retry with SSH: easbot skills add ${t.sshUrl}
8
- - Check access with: gh auth status -h github.com or ssh -T git@github.com`:`Authentication failed for ${n}.
9
- - For private repos, ensure you have access
10
- - For SSH: Check your keys with 'ssh -T git@github.com'
11
- - For HTTPS: Run 'gh auth login' or configure git credentials`}async function Dt(n,t,e){if(e){await Filesystem.mkdir(dirname(e),{recursive:true});let o=t?["--depth","1","--branch",t]:["--depth","1"];try{return await et().clone(n,e,o),e}catch(l){throw await rm(e,{recursive:true,force:true}).catch(()=>{}),l}}let r=await mkdtemp(join(tmpdir(),"skills-")),s=t?["--depth","1","--branch",t]:["--depth","1"],i=be(n);try{return await et().clone(n,r,s),r}catch(o){let l=o instanceof Error?o.message:String(o),a=l.includes("block timeout")||l.includes("timed out"),c=Le(l);if(a){try{await rm(r,{recursive:!0,force:!0});}catch{}let f=Math.round(nt/1e3);throw new L(`Clone timed out after ${f}s. Common causes:
12
- - Large repository: raise the timeout with SKILLS_CLONE_TIMEOUT=600000 (10m)
13
- - Slow network: retry, or clone manually and pass the local path to 'skills add'
14
- - Private repo without credentials: ensure auth is configured
15
- - For SSH: ssh-add -l (to check loaded keys)
16
- - For HTTPS: gh auth status (if using GitHub CLI)`,n,true,false)}if(c&&i&&Pe(n)){try{if(await Kt(r),await Ie(i,r,t))return r}catch{}try{return await Kt(r),await et({GIT_SSH_COMMAND:process.env.GIT_SSH_COMMAND??"ssh -o BatchMode=yes"}).clone(i.sshUrl,r,s),r}catch{}}try{await rm(r,{recursive:!0,force:!0});}catch{}if(c)throw new L(ve(n,i,l),n,false,true);let u=l.includes("filter.smudge")?`
17
- - The repo defines a smudge/clean filter that Git considers unsafe.
18
- Enable it with: git config --global protocol.allowUnsafeFilter true
19
- Or upgrade Git, or unset filter.<driver>.* in the source repo.`:"";throw new L(`Failed to clone ${n}: ${l}${u}`,n,false,false)}}async function $n(n){let t=normalize(resolve(n)),e=normalize(resolve(tmpdir()));if(!t.startsWith(e+sep)&&t!==e)throw new Error("Attempted to clean up directory outside of temp directory");await rm(n,{recursive:true,force:true});}function j(n){if(n.type==="local")return null;let t=n.url.match(/^git@[^:]+:(.+)$/);if(t){let e=t[1];return e=e.replace(/\.git$/,""),e.includes("/")?e:null}if(n.url.startsWith("ssh://"))try{let r=new URL(n.url).pathname.slice(1);return r=r.replace(/\.git$/,""),r.includes("/")?r:null}catch{return null}if(!n.url.startsWith("http://")&&!n.url.startsWith("https://"))return null;try{let r=new URL(n.url).pathname.slice(1);if(r=r.replace(/\.git$/,""),r.includes("/"))return r}catch{}return null}function Nn(n){let t=n.match(/^([^/]+)\/([^/]+)$/);return t?{owner:t[1],repo:t[2]}:null}async function Un(n,t){try{let e=await fetch(`https://api.github.com/repos/${n}/${t}`);return e.ok?(await e.json()).private===!0:null}catch{return null}}async function Tt(n,t){try{let e=await fetch(`https://api.github.com/repos/${n}/${t}`,{headers:{Accept:"application/vnd.github+json"}});if(!e.ok)return null;let r=await e.json();return typeof r.default_branch=="string"&&r.default_branch.length>0?r.default_branch:null}catch{return null}}function O(n){let e=n.replace(/\\/g,"/").split("/");for(let r of e)if(r==="..")throw new Error(`Unsafe subpath: "${n}" contains path traversal segments. Subpaths must not contain ".." components.`);return n}function Ae(n){return isAbsolute(n)||n.startsWith("./")||n.startsWith("../")||n==="."||n===".."||/^[a-zA-Z]:[/\\]/.test(n)}var We={"coinbase/agentWallet":"coinbase/agentic-wallet-skills"};function rt(n){try{return decodeURIComponent(n)}catch{return n}}function Ke(n){if(n.startsWith("github:")||n.startsWith("gitlab:")||n.startsWith("git@")||/^ssh:\/\/.+\.git(?:$|[/?])/i.test(n))return true;if(n.startsWith("http://")||n.startsWith("https://"))try{let t=new URL(n),e=t.pathname;if(t.hostname==="github.com")return /^\/[^/]+\/[^/]+(?:\.git)?(?:\/tree\/[^/]+(?:\/.*)?)?\/?$/.test(e);if(t.hostname==="gitlab.com")return /^\/.+?\/[^/]+(?:\.git)?(?:\/-\/tree\/[^/]+(?:\/.*)?)?\/?$/.test(e)}catch{}return /^https?:\/\/.+\.git(?:$|[/?])/i.test(n)?true:!n.includes(":")&&!n.startsWith(".")&&!n.startsWith("/")&&/^([^/]+)\/([^/]+)(?:\/(.+)|@(.+))?$/.test(n)}function Ne(n){let t=n.indexOf("#");if(t<0)return {inputWithoutFragment:n};let e=n.slice(0,t),r=n.slice(t+1);if(!r)return {inputWithoutFragment:e};if(!Ke(e))return {inputWithoutFragment:n};let s=r.indexOf("@");if(s===-1)return {inputWithoutFragment:e,ref:rt(r)};let i=r.slice(0,s),o=r.slice(s+1);return {inputWithoutFragment:e,ref:i?rt(i):void 0,subpath:o?rt(o):void 0}}function Ct(n,t,e){return t?`${n}#${t}${e?`@${e}`:""}`:n}function Ft(n){if(Ae(n)){let d=resolve(n);return {type:"local",url:d,localPath:d}}let{inputWithoutFragment:t,ref:e,subpath:r}=Ne(n);n=t;let s=We[n];s&&(n=s);let i=n.match(/^github:(.+)$/);if(i)return Ft(Ct(i[1],e,r));let o=n.match(/^gitlab:(.+)$/);if(o)return Ft(Ct(`https://gitlab.com/${o[1]}`,e,r));let l=n.match(/github\.com\/([^/]+)\/([^/]+)\/tree\/([^/]+)\/(.+)/);if(l){let[,d,g,w,x]=l;return {type:"github",url:`https://github.com/${d}/${g}.git`,ref:w||e,subpath:x&&O(x)}}let a=n.match(/github\.com\/([^/]+)\/([^/]+)\/tree\/([^/]+)$/);if(a){let[,d,g,w]=a;return {type:"github",url:`https://github.com/${d}/${g}.git`,ref:w||e}}let c=n.match(/github\.com\/([^/]+)\/([^/]+)/);if(c){let[,d,g]=c,w=g.replace(/\.git$/,"");return {type:"github",url:`https://github.com/${d}/${w}.git`,...e?{ref:e}:{}}}let u=n.match(/^(https?):\/\/([^/]+)\/(.+?)\/-\/tree\/([^/]+)\/(.+)/);if(u){let[,d,g,w,x,k]=u;if(g!=="github.com"&&w)return {type:"gitlab",url:`${d}://${g}/${w.replace(/\.git$/,"")}.git`,ref:x||e,subpath:k&&O(k)}}let f=n.match(/^(https?):\/\/([^/]+)\/(.+?)\/-\/tree\/([^/]+)$/);if(f){let[,d,g,w,x]=f;if(g!=="github.com"&&w)return {type:"gitlab",url:`${d}://${g}/${w.replace(/\.git$/,"")}.git`,ref:x||e}}let h=n.match(/gitlab\.com\/(.+?)(?:\.git)?\/?$/);if(h){let d=h[1];if(d.includes("/"))return {type:"gitlab",url:`https://gitlab.com/${d}.git`,...e?{ref:e}:{}}}let y=n.match(/^([^/@]+)\/([^/@]+)@(.+)?$/);if(y&&!n.includes(":")&&!n.startsWith(".")&&!n.startsWith("/")){let d=y[1],g=y[2],w=y[3];if(!w)return {type:"github",url:`https://github.com/${d}/${g}.git`,...e?{ref:e}:{}};let x=O(w);return {type:"github",url:`https://github.com/${d}/${g}.git`,...e?{ref:e}:{},...x?{subpath:x}:{}}}let E=n.match(/^([^/@]+)\/([^/@]+)(?:\/(.+?))?\/?$/);if(E&&!n.includes(":")&&!n.startsWith(".")&&!n.startsWith("/")){let[,d,g,w]=E;return {type:"github",url:`https://github.com/${d}/${g}.git`,...e?{ref:e}:{},subpath:r??(w&&O(w))}}return Ue(n)?{type:"well-known",url:n}:{type:"git",url:n,...e?{ref:e}:{},...r?{subpath:r}:{}}}function Ue(n){if(!n.startsWith("http://")&&!n.startsWith("https://"))return false;try{let t=new URL(n);return !(["github.com","gitlab.com","raw.githubusercontent.com"].includes(t.hostname)||n.endsWith(".git"))}catch{return false}}var Mt="https://schemas.agentskills.io/discovery/0.2.0/schema.json",Te=/\/schemas\/agent-skills\/index\.v1\.json$/,Me=50*1024*1024,_e=1e3;function ze(n,t){let e=n.skillPath;if(typeof e=="string"&&e.trim()!==""&&e!==null)return e.replace(/^\/+/,"").replace(/\/+$/,"");if(typeof n.sourceUrl=="string"&&n.sourceUrl)try{let s=new URL(n.sourceUrl).pathname,i=/\/\.well-known\/(?:agent-skills|skills)\/(.*?)\/SKILL\.md$/,o=s.match(i);if(o?.[1])return o[1];let l=s.match(/^(.*?)\/[^/]+\/SKILL\.md$/);if(l?.[1])return l[1]}catch{}if(typeof n.installName=="string"&&n.installName){let r=n.installName.lastIndexOf("@");if(r>=0){let s=n.installName.slice(r+1);if(s.includes("/"))return s.replace(/^\/+/,"")}}return t}var it=class{constructor(){b(this,"id","well-known");b(this,"displayName","Well-Known Skills");b(this,"WELL_KNOWN_PATHS",[".well-known/agent-skills",".well-known/skills"]);b(this,"INDEX_FILE","index.json");}match(t){if(!t.startsWith("http://")&&!t.startsWith("https://"))return {matches:false};try{let e=new URL(t);return ["github.com","gitlab.com","huggingface.co"].includes(e.hostname)?{matches:!1}:{matches:!0,sourceIdentifier:`wellknown/${e.hostname}`}}catch{return {matches:false}}}async fetchIndex(t){return (await this.fetchIndexCandidates(t))[0]??null}async fetchIndexCandidates(t){try{let e=new URL(t),r=e.pathname.replace(/\/$/,""),s=[],i=r.match(/\/\.well-known\/(agent-skills|skills)\/?$/);if(i?.[1]){let l=`.well-known/${i[1]}`;s.push({indexUrl:`${e.protocol}//${e.host}${r}/${this.INDEX_FILE}`,baseUrl:`${e.protocol}//${e.host}${r.replace(/\/\.well-known\/(?:agent-skills|skills)$/,"")}`,wellKnownPath:l});}for(let l of this.WELL_KNOWN_PATHS)s.push({indexUrl:`${e.protocol}//${e.host}${r}/${l}/${this.INDEX_FILE}`,baseUrl:`${e.protocol}//${e.host}${r}`,wellKnownPath:l}),r&&r!==""&&s.push({indexUrl:`${e.protocol}//${e.host}/${l}/${this.INDEX_FILE}`,baseUrl:`${e.protocol}//${e.host}`,wellKnownPath:l});let o=[];for(let{indexUrl:l,baseUrl:a,wellKnownPath:c}of s)try{let u=await fetch(l);if(!u.ok)continue;let f=await u.json(),h=this.normalizeIndex(f,l,c);if(!h)continue;o.push({index:h.index,entries:h.entries,resolvedBaseUrl:a,resolvedWellKnownPath:c,indexUrl:l});}catch{}return o}catch{return []}}normalizeIndex(t,e,r){if(!t||typeof t!="object")return null;let s=t;if(!Array.isArray(s.skills))return null;let i=s.$schema;if(i===Mt){let a=[],c=[];for(let u of s.skills){if(!this.isValidSkillEntryV2(u))continue;let f=new URL(u.url,e).toString();a.push({version:"0.2.0",name:u.name,description:u.description,type:u.type,artifactUrl:f,digest:u.digest,indexEntry:u}),c.push(u);}return a.length===0?null:{index:{$schema:Mt,skills:c},entries:a}}if(typeof i=="string"&&Te.test(i)){let a=[],c=[];for(let u of s.skills){if(!this.isValidSkillEntryEasbotV1(u))continue;let f=new URL(u.sourceUrl,e).toString();a.push({version:"easbot-v1",name:u.name,description:u.description,skillMdUrl:f,installName:u.installName,indexEntry:u}),c.push(u);}return a.length===0?null:{index:{$schema:i,skills:c},entries:a}}if(i!==void 0)return null;let o=[],l=[];for(let a of s.skills){if(!this.isValidSkillEntryV1(a))return null;o.push(a),l.push({version:"0.1.0",name:a.name,description:a.description,files:a.files,baseUrl:this.getLegacySkillBaseUrl(e,r),wellKnownPath:r,indexEntry:a});}return {index:{skills:o},entries:l}}getLegacySkillBaseUrl(t,e){let r=new URL(t),s=`/${e}/${this.INDEX_FILE}`;return `${r.protocol}//${r.host}${r.pathname.slice(0,-s.length)}`}isValidSkillName(t){return !(typeof t!="string"||t.length===0||t.length>64||!/^[a-z0-9-]+$/.test(t)||t.startsWith("-")||t.endsWith("-")||t.includes("--"))}isSafeLegacyFilePath(t){return !(typeof t!="string"||t.length===0||t.startsWith("/")||t.startsWith("\\")||t.includes("..")||t.includes("\0"))}isValidSkillEntryEasbotV1(t){if(!t||typeof t!="object")return false;let e=t;if(!this.isValidSkillName(e.name)||typeof e.description!="string"||!e.description||e.description.length>1024||typeof e.sourceUrl!="string"||!e.sourceUrl)return false;try{new URL(e.sourceUrl,"https://easbot.cn/.well-known/agent-skills/index.json");}catch{return false}return true}isValidSkillEntryV1(t){if(!t||typeof t!="object")return false;let e=t;if(!this.isValidSkillName(e.name)||typeof e.description!="string"||!e.description||!Array.isArray(e.files)||e.files.length===0)return false;for(let s of e.files)if(!this.isSafeLegacyFilePath(s))return false;return e.files.some(s=>typeof s=="string"&&s.toLowerCase()==="skill.md")}isValidSkillEntryV2(t){if(!t||typeof t!="object")return false;let e=t;if(!this.isValidSkillName(e.name)||typeof e.description!="string"||!e.description||e.description.length>1024||e.type!=="skill-md"&&e.type!=="archive"||typeof e.url!="string"||!e.url||typeof e.digest!="string"||!/^sha256:[a-f0-9]{64}$/.test(e.digest))return false;try{new URL(e.url,"https://example.com/.well-known/agent-skills/index.json");}catch{return false}return true}async fetchSkill(t){try{let e=new URL(t),r=await this.fetchIndexCandidates(t);for(let s of r){let{entries:i}=s,o=null,l=e.pathname.match(/\/.well-known\/(?:agent-skills|skills)\/([^/]+)\/?$/);if(l?.[1]&&l[1]!=="index.json"?o=l[1]:i.length===1&&(o=i[0].name),!o)continue;let a=i.find(u=>u.name===o);if(!a)continue;let c=await this.fetchSkillByEntry(a);if(c)return c}return null}catch{return null}}async fetchSkillByEntry(t,e,r){return typeof t=="string"?e?this.fetchLegacySkillByEntry({version:"0.1.0",name:e.name,description:e.description,files:e.files,baseUrl:t,wellKnownPath:r??this.WELL_KNOWN_PATHS[0],indexEntry:e}):null:t.version==="0.1.0"?this.fetchLegacySkillByEntry(t):t.version==="easbot-v1"?this.fetchEasbotV1SkillByEntry(t):this.fetchArtifactSkillByEntry(t)}async fetchEasbotV1SkillByEntry(t){try{let e=await fetch(t.skillMdUrl);if(!e.ok)return null;let r=await e.text(),{data:s}=a(r);if(typeof s.name!="string"||typeof s.description!="string")return null;let i=new Map;i.set("SKILL.md",r);let o=ze(t.indexEntry,s.name);return this.createSkill({name:s.name,description:s.description,content:r,installName:o,sourceUrl:t.skillMdUrl,metadata:s.metadata,files:i,indexEntry:t.indexEntry})}catch{return null}}async fetchLegacySkillByEntry(t){try{let e=`${t.baseUrl.replace(/\/$/,"")}/${t.wellKnownPath}/${t.name}`,r=`${e}/SKILL.md`,s=await fetch(r);if(!s.ok)return null;let i=await s.text(),{data:o}=a(i);if(typeof o.name!="string"||typeof o.description!="string")return null;let l=new Map;l.set("SKILL.md",i);let c=t.files.filter(f=>f.toLowerCase()!=="skill.md").map(async f=>{try{let h=`${e}/${f}`,y=await fetch(h);if(y.ok){let E=await y.arrayBuffer();return {path:f,content:new Uint8Array(E)}}}catch{}return null}),u=await Promise.all(c);for(let f of u)f&&l.set(f.path,f.content);return this.createSkill({name:o.name,description:o.description,content:i,installName:t.name,sourceUrl:r,metadata:o.metadata,files:l,indexEntry:t.indexEntry})}catch{return null}}async fetchArtifactSkillByEntry(t){try{let e=await fetch(t.artifactUrl);if(!e.ok)return null;let r=e.headers.get("content-type")??"",s=new Uint8Array(await e.arrayBuffer());if(this.computeDigest(s)!==t.digest)return null;if(t.type==="skill-md"){let c=new TextDecoder().decode(s),{data:u}=a(c);if(typeof u.name!="string"||typeof u.description!="string")return null;let f=new Map;return f.set("SKILL.md",c),this.createSkill({name:u.name,description:u.description,content:c,installName:t.name,sourceUrl:t.artifactUrl,metadata:u.metadata,files:f,indexEntry:t.indexEntry})}let i=this.extractArchive(s,t.artifactUrl,r),o=i.get("SKILL.md");if(!o)return null;let l=typeof o=="string"?o:new TextDecoder().decode(o);i.set("SKILL.md",l);let{data:a$1}=a(l);return typeof a$1.name!="string"||typeof a$1.description!="string"?null:this.createSkill({name:a$1.name,description:a$1.description,content:l,installName:t.name,sourceUrl:t.artifactUrl,metadata:a$1.metadata,files:i,indexEntry:t.indexEntry})}catch{return null}}createSkill(t){return {name:b$1(t.name),description:b$1(t.description),content:t.content,installName:t.installName,sourceUrl:t.sourceUrl,metadata:t.metadata&&typeof t.metadata=="object"?t.metadata:void 0,files:t.files,indexEntry:t.indexEntry}}async fetchAllSkills(t){try{let e=await this.fetchIndexCandidates(t);for(let r of e){let s=r.entries.map(l=>this.fetchSkillByEntry(l)),o=(await Promise.all(s)).filter(l=>l!==null);if(o.length>0)return o}return []}catch{return []}}computeDigest(t){return `sha256:${createHash("sha256").update(t).digest("hex")}`}extractArchive(t,e,r){if(this.isZipArchive(t,e,r))return this.extractZip(t);if(this.isTarGzArchive(t,e,r))return this.extractTarGz(t);throw new Error("Unsupported archive format")}isZipArchive(t,e,r){return r.includes("application/zip")||e.toLowerCase().endsWith(".zip")||t[0]===80&&t[1]===75}isTarGzArchive(t,e,r){let s=e.toLowerCase();return r.includes("application/gzip")||r.includes("application/x-gzip")||s.endsWith(".tar.gz")||s.endsWith(".tgz")||t[0]===31&&t[1]===139}normalizeArchivePath(t){if(!t||t.includes("\0")||t.startsWith("/")||t.startsWith("\\")||/^[A-Za-z]:/.test(t)||t.includes("\\"))return null;let e=t.split("/").filter(Boolean);return e.length===0||e.some(r=>r==="."||r==="..")?null:e.join("/")}addArchiveFile(t,e,r,s){let i=this.normalizeArchivePath(e);if(!i)throw new Error(`Unsafe archive path: ${e}`);if(s.bytes+=r.byteLength,s.bytes>Me)throw new Error("Archive exceeds maximum unpacked size");if(t.size>=_e)throw new Error("Archive contains too many files");t.set(i,r);}extractTarGz(t){let e=gunzipSync(Buffer.from(t)),r=new Map,s={bytes:0},i=0;for(;i+512<=e.length;){let o=e.subarray(i,i+512);if(o.every(E=>E===0))break;let l=this.readTarString(o,0,100),a=this.readTarString(o,124,12).trim(),c=o[156],u=this.readTarString(o,345,155),f=u?`${u}/${l}`:l,h=Number.parseInt(a||"0",8);if(!Number.isFinite(h)||h<0)throw new Error("Invalid tar entry size");if(i+=512,c===50||c===49)throw new Error("Archive links are not supported");if(c===0||c===48){let E=e.subarray(i,i+h);this.addArchiveFile(r,f,new Uint8Array(E),s);}i+=Math.ceil(h/512)*512;}if(!r.has("SKILL.md"))throw new Error("Archive missing root SKILL.md");return r}readTarString(t,e,r){let s=t.subarray(e,e+r),i=s.indexOf(0);return new TextDecoder().decode(i>=0?s.subarray(0,i):s)}extractZip(t){let e=Buffer.from(t),r=this.findZipEndOfCentralDirectory(e);if(r<0)throw new Error("Invalid zip archive");let s=e.readUInt16LE(r+10),i=e.readUInt32LE(r+16),o=new Map,l={bytes:0},a=i;for(let c=0;c<s;c++){if(e.readUInt32LE(a)!==33639248)throw new Error("Invalid zip directory");let u=e.readUInt16LE(a+8),f=e.readUInt16LE(a+10),h=e.readUInt32LE(a+20),y=e.readUInt32LE(a+24),E=e.readUInt16LE(a+28),d=e.readUInt16LE(a+30),g=e.readUInt16LE(a+32),w=e.readUInt32LE(a+38),x=e.readUInt32LE(a+42),k=a+46,S=e.subarray(k,k+E),b=new TextDecoder(u&2048?"utf-8":void 0).decode(S);if(a=k+E+d+g,b.endsWith("/"))continue;if(u&1)throw new Error("Encrypted zip entries are not supported");let M=w>>>16&61440;if(M===40960||M===4096)throw new Error("Archive links are not supported");if(e.readUInt32LE(x)!==67324752)throw new Error("Invalid zip local header");let _=e.readUInt16LE(x+26),fe=e.readUInt16LE(x+28),wt=x+30+_+fe,yt=e.subarray(wt,wt+h),z;if(f===0)z=yt;else if(f===8)z=inflateRawSync(yt);else throw new Error(`Unsupported zip compression method: ${f}`);if(z.byteLength!==y)throw new Error("Zip entry size mismatch");this.addArchiveFile(o,b,new Uint8Array(z),l);}if(!o.has("SKILL.md"))throw new Error("Archive missing root SKILL.md");return o}findZipEndOfCentralDirectory(t){let e=Math.max(0,t.length-65535-22);for(let r=t.length-22;r>=e;r--)if(t.readUInt32LE(r)===101010256)return r;return -1}toRawUrl(t){try{let e=new URL(t);if(t.toLowerCase().endsWith("/skill.md"))return t;let r=this.WELL_KNOWN_PATHS[0],s=e.pathname.match(/\/.well-known\/(?:agent-skills|skills)\/([^/]+)\/?$/);if(s?.[1]){let o=e.pathname.replace(/\/.well-known\/(?:agent-skills|skills)\/.*$/,"");return `${e.protocol}//${e.host}${o}/${r}/${s[1]}/SKILL.md`}let i=e.pathname.replace(/\/$/,"");return `${e.protocol}//${e.host}${i}/${r}/${this.INDEX_FILE}`}catch{return t}}getSourceIdentifier(t){try{return new URL(t).hostname.replace(/^www\./,"")}catch{return "unknown"}}async hasSkillsIndex(t){return await this.fetchIndex(t)!==null}},_t=new it;function st(n,t){let e=normalize(resolve(t)),r=normalize(resolve(n));return r.startsWith(e+sep)||r===e}function V(n){return n.startsWith("./")}async function Ot(n){let t=new Map;try{let e=await readFile(join(n,".claude-plugin/marketplace.json"),"utf-8"),r=JSON.parse(e),s=r.metadata?.pluginRoot;if(s===void 0||V(s))for(let o of r.plugins??[]){if(!o.name||typeof o.source!="string"&&o.source!==void 0||o.source!==void 0&&!V(o.source))continue;let l=join(n,s??"",o.source??"");if(st(l,n)&&o.skills&&o.skills.length>0)for(let a of o.skills){if(!V(a))continue;let c=join(l,a);st(c,n)&&t.set(resolve(c),o.name);}}}catch{}try{let e=await readFile(join(n,".claude-plugin/plugin.json"),"utf-8"),r=JSON.parse(e);if(r.name&&r.skills&&r.skills.length>0)for(let s of r.skills){if(!V(s))continue;let i=join(n,s);st(i,n)&&t.set(resolve(i),r.name);}}catch{}return t}var Ge=["node_modules",".git","dist","build","__pycache__"];async function Be(n){let t=join(n,".gitignore");try{let e=await readFile(t,"utf-8");return Glob.parseGitignoreContent(e)}catch{return []}}function ot(n){return n.toLowerCase().replace(/[\s_]+/g,"-")}function qe(n){return n.split(sep).join("/").replace(/\/+/g,"/")}function Xe(){let n=process.env.INSTALL_INTERNAL_SKILLS;return n==="1"||n==="true"}async function Jt(n){try{let t=join(n,"SKILL.md");return (await stat(t)).isFile()}catch{return false}}async function Vt(n,t){try{let e=await readFile(n,"utf-8"),{data:r}=a(e);if(!r.name||!r.description||typeof r.name!="string"||typeof r.description!="string")return null;let s=r.metadata&&typeof r.metadata=="object"&&!Array.isArray(r.metadata)?r.metadata:void 0;return s?.internal===!0&&!Xe()&&!t?.includeInternal?null:{name:b$1(r.name),description:b$1(r.description),path:dirname(n),rawContent:e,metadata:s}}catch{return null}}async function Zt(n,t=0,e=5){if(t>e)return [];try{let[r,s]=await Promise.all([Jt(n),readdir(n,{withFileTypes:!0}).catch(()=>[])]),i=r?[n]:[],o=await Promise.all(s.filter(l=>l.isDirectory()&&!Ge.includes(l.name)).map(l=>Zt(join(n,l.name),t+1,e)));return [...i,...o.flat()]}catch{return []}}function Je(n,t){let e=normalize(resolve(n)),r=normalize(resolve(join(n,t)));return r.startsWith(e+sep)||r===e}async function ct(n,t,e){let r=[],s=new Set,i=await q(n),o=new Set(Object.keys(i.skills).map(ot));if(t&&!Je(n,t))throw new Error(`Invalid subpath: "${t}" resolves outside the repository directory. Subpath must not contain ".." segments that escape the base path.`);let l=t?join(n,t):n,a=await Ot(l),c=k=>{let S=resolve(k.path);return a.has(S)&&(k.pluginName=a.get(S)),k},u=k(),f=k=>{if(o.size===0)return false;let S=qe(relative(n,k.path));if(!u.some(_=>S===_||S.startsWith(`${_}/`)))return false;let kt=ot(k.name),M=ot(basename(k.path));return o.has(kt)||o.has(M)},h=async k=>{if(!await Jt(k))return false;let S=await Vt(join(k,"SKILL.md"),e);return !S||s.has(S.name)||f(S)||(S=c(S),r.push(S),s.add(S.name)),true},y=t?t.replace(/^\/+|\/+$/g,"").split("/").filter(k=>k.length>0):[],E=y.length>0?`**/${y.join("/")}/**/SKILL.md`:"**/SKILL.md",d=await Glob.scan(E,{cwd:l,absolute:true,ignore:[...Glob.DEFAULT_IGNORE_PATTERNS,...await Be(l)]}),g="/",w=l.split(sep).join(g);d.sort((k,S)=>k.split(g).length-S.split(g).length);let x=[];for(let k of d){if(x.some(b=>k.startsWith(`${b}${g}`)||k===b))continue;let S=dirname(k);if(await h(S)){let b=S.split(sep).join(g);if(b===w)continue;x.push(b);}}if(r.length===0||e?.fullDepth){let k=await Zt(l);for(let S of k){let b=await Vt(join(S,"SKILL.md"),e);b&&!s.has(b.name)&&!f(b)&&(b=c(b),r.push(b),s.add(b.name));}}return r}function Ze(n){return n.name||(n.path?basename(n.path):"")}function rr(n,t){let e=t.map(r=>r.toLowerCase());return n.filter(r=>{let s=r.name.toLowerCase(),i=Ze(r).toLowerCase();return e.some(o=>o===s||o===i)})}var Yt="*";function ir(n,t){if(!n||n.length===0)return [];let e=new Set(t),r=[];for(let s of n)if(s!==Yt){if(s.includes("/")||s.includes("**")){r.push(s);continue}Qt.test(s)?t.some(i=>Wildcard.match(i,s))||r.push(s):e.has(s)||r.push(s);}return r}function sr(n,t){let e={wildcard:false,matched:[],invalid:[]};if(!n||n.length===0)return e;let r=new Set(t),s=new Set;for(let i of n){if(i===Yt){e.wildcard=true;continue}if(i.includes("/")||i.includes("**")){e.invalid.push(i);continue}if(Qt.test(i))for(let o of t)Wildcard.match(o,i)&&s.add(o);else r.has(i)?s.add(i):e.invalid.push(i);}return e.matched=Array.from(s),e}var Qt=/[*?[{}]/;var ut="houjallen/agent-skills";async function Er(n){let t=n.defaultPlugin;if(!t||typeof t.marketId!="string"||t.marketId.length===0)return ut;let e=n.markets[t.marketId];if(!e)return ut;let r=e.localPath??e.url;if(!r)return ut;let s=r;return e.subpath&&(s=`${s}@${e.subpath}`),e.ref&&(s=`${s}#${e.ref}`),s}function en(n){if(!n||typeof n!="object"||Array.isArray(n))return null;let t=n;if(typeof t.marketId!="string"||t.marketId.length===0)return null;let e={marketId:t.marketId};return typeof t.pluginId=="string"&&t.pluginId.length>0&&(e.pluginId=t.pluginId),e}function m(n){return Filesystem.normalize(n)}function ft(n){if(n==="general"||n==="coder"||n==="all")return n}function nn({scope:n}){let t=n==="project"?p():m$1(),e=Filesystem.join(t,n==="project"?".easbot":"easbot","skills");return Filesystem.normalize(e)}function T(){return Filesystem.join(m$1(),"skills","store")}function ie(){return Filesystem.join(T(),"index.json")}function X(n){let t=`${n.type}|${n.url}|${n.ref??""}`;return createHash("sha256").update(t).digest("hex")}function se(n){let t=X(n);return Filesystem.join(T(),t)}function D(){return Filesystem.join(o(),"skills","cache")}function rn(n,t,e){if(e&&e.length>0)return U(e);let r=sn(n);if(r)return r;if(t?.includes("/")){let s=t.split("/")[0];if(s)return U(s)}return "default"}function sn(n){let t=n.localPath??n.url;if(!t)return null;if(n.type==="well-known")try{let s=new URL(t),i=s.hostname.replace(/^www\./,"").replace(/\./g,"-"),o=s.pathname.replace(/^\/+/,"").split("/")[0]||"";return o&&!i.endsWith(`-${o}`)?U(`${i}-${o}`):U(i)}catch{return null}let e=t.match(/^(?:https?:\/\/[^/]+\/|git@[^:]+:)([^/]+)\/([^/]+?)(?:\.git)?\/?$/);if(e)return U(e[2]??"");let r=t.split(/[\\/]/).filter(Boolean).pop();return r?U(r.replace(/\.git$/,"")):null}function U(n){let t=n.trim().replace(/[:\\/\0]/g,"-").replace(/\.git$/,"").replace(/\s+/g,"-");return t.length>64&&(t=t.slice(0,64)),t.length>0?t:"default"}function gt(n){if(n.type==="well-known")return on(n.url);let t=j(n);if(t)return Filesystem.join(D(),n.type,t);let e=createHash("sha256").update(n.url).digest("hex").slice(0,16);return Filesystem.join(D(),n.type,`unknown-${e}`)}function on(n){let t,e;try{let r=new URL(n);t=r.hostname.replace(/^www\./,"");let s=r.pathname.match(/\/\.well-known\/(agent-skills|skills)/);s?.[1]?e=`.well-known/${s[1]}`:e=".well-known/agent-skills";}catch{let r=createHash("sha256").update(n).digest("hex").slice(0,16);return Filesystem.join(D(),"wellknown",`unknown-${r}`)}return Filesystem.join(D(),"wellknown",t,e)}async function oe(n){n.skillNames??[];if(n.type==="local")return ln(n);let e=n.mode??"install",{cacheDir:r,source:s,cloneError:i}=await an(n,e);return {tempDir:r,cacheHit:false,source:s,cloneError:i}}var dt=class extends Error{constructor(e){super(`Local source path does not exist: ${e}`);b(this,"localPath",e);this.name="LocalPathNotFoundError";}};async function ln(n,t){let e=n.localPath??n.url;if(!existsSync(e))throw new dt(e);let r=se(n);return existsSync(r)&&await le(r)?{tempDir:r,cacheHit:true,source:"local-cp",cloneError:null}:{tempDir:e,cacheHit:false,source:"local-cp",cloneError:null}}async function an(n,t){let e=n.ref;if(!e){let l=j(n);if(l){let[a,c]=l.split("/");if(a&&c){let u=await Tt(a,c);u&&(e=u);}}}e||(e="HEAD");let r=gt(n);if(n.type==="well-known")return existsSync(r)?{cacheDir:r,source:"cache-pull",cloneError:null}:(await Filesystem.mkdir(m(r),{recursive:true}),await pn(n.url,r),{cacheDir:r,source:"well-known-fetch",cloneError:null});if(existsSync(r))try{let l=he(r);return t==="update"?(await l.fetch(),await l.checkout(e),{cacheDir:r,source:"cache-pull",cloneError:null}):(await l.checkout(e),{cacheDir:r,source:"cache-pull",cloneError:null})}catch{return {cacheDir:r,source:"cache-pull",cloneError:null}}async function s(l,a,c){return Dt(l,a,c)}let i=null,o=null;try{return await Filesystem.mkdir(m(Filesystem.dirname(r)),{recursive:!0}),i=`${r}.clone-tmp`,await s(n.url,e,i),await rename(m(i),m(r)),{cacheDir:r,source:"cache-clone",cloneError:null}}catch(l){return l instanceof L?o=l:l instanceof Error&&(o=new L(`Failed to clone ${n.url}: ${l.message}`,n.url,false,false)),await Filesystem.mkdir(m(r),{recursive:true}).catch(()=>{}),{cacheDir:r,source:"cache-pull",cloneError:o}}finally{if(i)try{await rm(m(i),{recursive:!0,force:!0});}catch{}}}async function W(){let n=m(ie()),t;try{t=await Filesystem.readText(n);}catch{return {version:6,markets:{}}}let e;try{e=JSON.parse(t);}catch{try{await rename(m(n),`${m(n)}.corrupt-${Date.now()}`);}catch{}return {version:6,markets:{}}}let r=e;if(r.version!==6||!r.markets)return {version:6,markets:{}};let s={version:6,markets:r.markets};if("defaultPlugin"in r){let i=en(r.defaultPlugin);i&&(s.defaultPlugin=i);}return s}async function Q(n){await Filesystem.writeJson(m(ie()),n);}async function br(){let n=await W(),t={};for(let e of Object.values(n.markets))for(let r of Object.values(e.plugins))for(let[s,i]of Object.entries(r.skills))t[s]={marketId:e.id,pluginId:r.id,pluginName:r.name,storePath:e.storePath,pluginSlug:r.id.split(":").slice(1).join(":")||r.id,url:e.url,type:e.type,localPath:e.localPath,subpath:e.subpath,ref:e.ref,addedAt:e.addedAt,skillPath:i.skillPath,computedHash:i.computedHash,sourceKey:e.id,sourcePath:e.localPath??e.storePath};return t}async function Pr(n,t,e,r,s){let i=await W(),o=i.markets[n];o||(o={...s,id:n,addedAt:s.addedAt??new Date().toISOString(),plugins:{}},i.markets[n]=o);let l=o.plugins[t];l||(l={id:t,name:t.split(":").slice(1).join(":")||t,skills:{}},o.plugins[t]=l),l.skills[e]=r,await Q(i);}async function cn(){let n=await W(),t=[];for(let e of Object.values(n.markets))for(let r of Object.values(e.plugins))for(let s of Object.values(r.skills))t.push({skillName:s.name,marketId:e.id,pluginId:r.id,entry:s});return t.sort((e,r)=>{let s=e.marketId.localeCompare(r.marketId);if(s!==0)return s;let i=e.pluginId.localeCompare(r.pluginId);return i!==0?i:e.skillName.localeCompare(r.skillName)}),t}async function un(n){return (await cn()).filter(e=>e.skillName===n)}async function Lr(n,t,e){let s=(await W()).markets[n];if(!s)return;let i=s.plugins[t];if(!i)return;let o=i.skills[e];if(o)return {skillName:o.name,marketId:n,pluginId:t,entry:o}}async function Ir(n,t,e){let r=await W(),s=r.markets[n];if(!s)return false;let i=s.plugins[t];return !i||!(e in i.skills)?false:(delete i.skills[e],await Q(r),true)}async function fn(n){let t=await un(n);if(t.length===0)return [];let e=await W(),r=[];for(let s of t){let i=e.markets[s.marketId]?.plugins[s.pluginId];i&&n in i.skills&&(delete i.skills[n],r.push(s));}return r.length>0&&await Q(e),r}async function vr(n,t,e,r,s,i,o){await J([{skillName:n,parsed:t,sourceKey:e,sourcePath:r,storePath:s,skillPath:i,...o&&{computedHash:o}}]);}async function J(n){if(n.length===0)return;let t=await W(),e=new Date().toISOString();for(let i of n){let o=i.sourceKey,l=rn(i.parsed,i.skillPath,i.pluginName),a=`${o}:${l}`,c=t.markets[o];if(!c){let h=i.parsed.type==="local"?i.parsed.localPath??i.parsed.url:gt(i.parsed);c={id:o,type:i.parsed.type,url:i.parsed.url,localPath:i.parsed.localPath,subpath:i.parsed.subpath,ref:i.parsed.ref,storePath:i.storePath,cachePath:h,addedAt:e,plugins:{}},t.markets[o]=c;}let u=c.plugins[a];u||(u={id:a,name:l,sourcePath:i.parsed.subpath,skills:{}},c.plugins[a]=u);let f={name:i.skillName,description:i.description??"",skillPath:i.skillPath,computedHash:i.computedHash};i.scope&&(f.scope=i.scope),i.snapshotHash&&(f.snapshotHash=i.snapshotHash),u.skills[i.skillName]=f;}let r=new Set,s=new Map;for(let i of n)r.add(i.sourceKey),i.marketSnapshotHash&&s.set(i.sourceKey,i.marketSnapshotHash);for(let i of r){let o=t.markets[i];if(!o)continue;let l=s.get(i);if(l){o.snapshotHash=l;continue}let a=[];for(let c of Object.values(o.plugins))for(let u of Object.values(c.skills))a.push({name:u.name,snapshotHash:u.snapshotHash});o.snapshotHash=d(a);}await Q(t);}async function $r(n){return (await fn(n)).length>0}async function pn(n,t){let e;try{e=await _t.fetchAllSkills(n);}catch{return}if(e.length!==0)for(let r of e)try{await dn(r,t);}catch{}}async function dn(n,t){let e=Filesystem.join(t,n.installName),r=Filesystem.normalize(e),s=Filesystem.normalize(t);if(!r.startsWith(`${s}/`)&&r!==s)throw new Error(`Unsafe skill dir: ${n.installName}`);await mkdir(m(e),{recursive:true});for(let[i,o]of n.files){let l=Filesystem.join(e,i),a=Filesystem.normalize(l);if(!a.startsWith(`${r}/`)&&a!==r||i.includes("\0"))continue;let c=dirname(m(l));c!==m(e)&&await mkdir(c,{recursive:true}),await writeFile(m(l),typeof o=="string"?o:Buffer.from(o));}}async function Rr(n){return (await oe({type:"git",url:n.url,ref:n.ref})).tempDir}async function Ar(n,t={}){let e=se(n),r=false;if(existsSync(e)&&(r=await le(e),!r))try{await rmdir(m(e));}catch{}if(r){let c=await ct(e,void 0,{includeInternal:t.includeInternal,fullDepth:t.fullDepth});if(c.length>0){let f=await Promise.all(c.map(async h=>{let y=pt(e,h.path);return {skillName:h.name,parsed:n,sourceKey:X(n),sourcePath:e,storePath:e,skillPath:y,description:h.description,scope:ft(h.metadata?.scope),...h.pluginName&&{pluginName:h.pluginName},computedHash:await b$2(h.path)}}));await J(f);}let u=n.type==="local"?"local-cp":"cache-pull";return {storeDir:e,cacheHit:true,source:u,skills:c,blobSkills:[],cloneError:null}}let s=[];if(n.type==="github"&&!t.fullDepth){let c$1=j(n),u=c$1?.split("/")[0]?.toLowerCase(),f=!!c$1&&Object.hasOwn(c,c$1.toLowerCase());if(c$1&&u&&(f||d$1.includes(u))){let h=await l(c$1,{subpath:n.subpath,ref:n.ref,includeInternal:t.includeInternal});if(h&&h.skills.length>0){await hn(h.skills,e);let y=h.skills.map(d=>({...d,path:Filesystem.join(e,d.repoSubpath??"",d.name,"SKILL.md")})),E=await Promise.all(y.map(async(d,g)=>{let w=h.skills[g],x=`${w.repoSubpath??""}${w.repoSubpath?"/":""}${w.name}`;return {skillName:d.name,parsed:n,sourceKey:X(n),sourcePath:e,storePath:e,skillPath:x,description:d.description,scope:ft(d.metadata?.scope),...d.pluginName&&{pluginName:d.pluginName},computedHash:await b$2(Filesystem.dirname(d.path)),snapshotHash:w.snapshotHash,marketSnapshotHash:h.snapshotHash}}));return await J(E),s=h.skills,{storeDir:e,cacheHit:false,source:"blob-fetch",skills:y,blobSkills:s,cloneError:null}}}}let i=await oe(n);await Filesystem.mkdir(m(e),{recursive:true}).catch(()=>{});let o=await ct(i.tempDir,void 0,{includeInternal:t.includeInternal,fullDepth:t.fullDepth}),l$1=[],a=Filesystem.normalize(e).replace(/\\/g,"/");for(let c of o){let u=pt(i.tempDir,c.path),f=Filesystem.join(e,u),h=`${pt(i.tempDir,c.path)}/SKILL.md`,y=Filesystem.normalize(f).replace(/\\/g,"/"),E="/",d=a.endsWith(E)?a:a+E;if(!y.startsWith(d)&&y!==a)throw new Error(`[INVARIANT 0048-yyy] cp target escapes storeRoot: target=${y} storeRoot=${a}
20
- source skill path=${c.path} (parsed.type=${n.type})
21
- \u4E1A\u52A1\u4EFB\u4F55\u65F6\u5019\u4E0D\u80FD\u64CD\u4F5C\u7528\u6237\u7684 local \u76EE\u5F55\u6216\u6587\u4EF6\u3002`);let g;try{await Filesystem.mkdir(m(Filesystem.dirname(f)),{recursive:!0}),await cp(m(c.path),m(f),{recursive:!0}),g=await b$2(f);}catch{}c.path=f,l$1.push({skill:c,skillRel:u,sourceSkillPath:h,targetPath:f,computedHash:g});}if(l$1.length>0){let c=l$1.filter(u=>u.computedHash).map(u=>({skillName:u.skill.name,parsed:n,sourceKey:X(n),sourcePath:i.tempDir,storePath:e,skillPath:u.skillRel,description:u.skill.description,scope:ft(u.skill.metadata?.scope),...u.skill.pluginName&&{pluginName:u.skill.pluginName},computedHash:u.computedHash}));await J(c);}return {storeDir:e,cacheHit:i.cacheHit,source:i.source,skills:o,blobSkills:[],cloneError:i.cloneError??null}}async function hn(n,t){let e=Filesystem.normalize(t);for(let r of n){let s=Filesystem.join(t,r.repoSubpath??"",r.name),i=Filesystem.normalize(s);if(!(!i.startsWith(`${e}/`)&&i!==e))try{await mkdir(m(s),{recursive:!0});for(let o of r.files){let l=Filesystem.join(s,o.path),a=Filesystem.normalize(l);if(!a.startsWith(`${i}/`)&&a!==i||o.path.includes("\0"))continue;let c=dirname(m(l));c!==m(s)&&await mkdir(c,{recursive:!0}),await writeFile(m(l),o.contents,"utf-8");}}catch{}}}function pt(n,t){let r=Filesystem.normalize(n).replace(/\\/g,"/"),s=Filesystem.normalize(t).replace(/\\/g,"/"),i=r.toLowerCase();return s.toLowerCase().startsWith(`${i}/`)?s.slice(i.length+1):""}async function le(n){try{return (await readdir(m(n))).length>0}catch{return false}}function Wr(n){try{let t=Filesystem.normalize(n);for(let e of [D(),T()]){let r=Filesystem.normalize(e);if(t===r||t.startsWith(`${r}/`))return !0}return !1}catch{return false}}async function Kr({cachePath:n,skillName:t,scope:e}){let r=Filesystem.join(nn({scope:e}),t);return existsSync(r)&&await rm(m(r),{recursive:true,force:true}),await cp(m(n),m(r),{recursive:true}),r}async function Nr(n){let t=gt(n);existsSync(t)&&await rm(m(t),{recursive:true,force:true});}async function Ur(){let n=D();existsSync(n)&&await rm(m(n),{recursive:true,force:true});}var wn="skills-lock.json",ae=4;function ce(n){return join(n||process.cwd(),wn)}function Hr(n,t){return n?vt(n,T(),t):null}async function q(n){let t=ce(n);try{let e=await readFile(t,"utf-8"),r=JSON.parse(e);return typeof r.version!="number"||!r.skills||r.version<ae?mt():r}catch{return mt()}}async function ue(n,t){let e=ce(t),r={};for(let o of Object.keys(n.skills).sort())r[o]=n.skills[o];let s={version:n.version,skills:r},i=JSON.stringify(s,null,2)+`
22
- `;await writeFile(e,i,"utf-8");}async function Or(n,t,e){let r=await q(e),s=new Date().toISOString(),i=r.skills[n];r.skills[n]={...t,installedAt:i?.installedAt??s,updatedAt:s},await ue(r,e);}async function jr(n,t){let e=await q(t);return n in e.skills?(delete e.skills[n],await ue(e,t),true):false}function mt(){return {version:ae,skills:{}}}export{vr as $,ct as A,Ze as B,rr as C,ir as D,sr as E,ut as F,Er as G,en as H,nn as I,T as J,ie as K,X as L,se as M,D as N,rn as O,gt as P,oe as Q,dt as R,W as S,Q as T,br as U,Pr as V,cn as W,un as X,Lr as Y,Ir as Z,fn as _,j as a,J as aa,Nn as b,$r as ba,Un as c,Rr as ca,O as d,Ar as da,Ft as e,pt as ea,At as f,le as fa,L as g,Wr as ga,be as h,Kr as ha,Pe as i,Nr as ia,Ut as j,Ur as ja,Dt as k,$n as l,it as m,_t as n,N as o,vt as p,ae as q,ce as r,Hr as s,q as t,ue as u,Or as v,jr as w,Xe as x,Vt as y,Je as z};
@@ -1,22 +0,0 @@
1
- 'use strict';var chunkISMGLHYS_cjs=require('./chunk-ISMGLHYS.cjs'),chunkXGUPIAAF_cjs=require('./chunk-XGUPIAAF.cjs'),chunkRVR3DSD2_cjs=require('./chunk-RVR3DSD2.cjs'),chunkE7AHWFZN_cjs=require('./chunk-E7AHWFZN.cjs'),chunkVRHWDHQV_cjs=require('./chunk-VRHWDHQV.cjs'),promises=require('fs/promises'),path=require('path'),crypto=require('crypto'),fs=require('fs'),de=require('simple-git'),utils=require('@easbot/utils'),os=require('os'),child_process=require('child_process'),util=require('util'),zlib=require('zlib');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var de__default=/*#__PURE__*/_interopDefault(de);var K=6;function fe(n){let t=n.indexOf(":");return t<0||t===n.length-1?null:{marketId:n.slice(0,t),pluginSlug:n.slice(t+1)}}function pe(n){let t=fe(n);return t?`plugins/${t.pluginSlug}`:null}function It(n,t,e){if(!n.marketId||!n.pluginId)return null;let r=pe(n.pluginId);return r?`${t.replace(/\\/g,"/").replace(/\/+$/,"")}/${n.marketId}/${r}/${e}`:null}var Rt=3e5,et=(()=>{let n=process.env.SKILLS_CLONE_TIMEOUT;if(!n)return Rt;let t=Number.parseInt(n,10);return Number.isFinite(t)&&t>0?t:Rt})(),At=util.promisify(child_process.execFile),L=class extends Error{constructor(e,r,s=false,i=false){super(e);chunkVRHWDHQV_cjs.b(this,"url");chunkVRHWDHQV_cjs.b(this,"isTimeout");chunkVRHWDHQV_cjs.b(this,"isAuthError");this.name="GitCloneError",this.url=r,this.isTimeout=s,this.isAuthError=i;}};function Ee(n){let t=n.match(/^git@github\.com:([^/]+)\/([^/]+?)(?:\.git)?$/i);if(t){let e=t[1],r=t[2];return {owner:e,repo:r,slug:`${e}/${r}`,sshUrl:`git@github.com:${e}/${r}.git`}}try{let e=new URL(n);if(e.hostname!=="github.com")return null;let r=e.pathname.match(/^\/([^/]+)\/([^/]+?)(?:\.git)?\/?$/);if(!r)return null;let s=r[1],i=r[2];return {owner:s,repo:i,slug:`${s}/${i}`,sshUrl:`git@github.com:${s}/${i}.git`}}catch{return null}}function be(n){try{let t=new URL(n);return t.protocol==="https:"&&t.hostname==="github.com"}catch{return false}}function Nt(n){let t=n.toLowerCase();return t.includes("saml sso")||t.includes("enforced sso")||t.includes("enabled or enforced saml")||t.includes("re-authorize the oauth application")}function Pe(n){return n.includes("Authentication failed")||n.includes("could not read Username")||n.includes("Permission denied")||n.includes("Repository not found")||n.includes("requested URL returned error: 403")||Nt(n)}function tt(n){let t={...process.env};return delete t.GIT_ASKPASS,delete t.GIT_EDITOR,delete t.GIT_SEQUENCE_EDITOR,delete t.GIT_PAGER,delete t.GIT_SSH_COMMAND,delete t.GIT_CONFIG_GLOBAL,delete t.GIT_CONFIG_SYSTEM,delete t.PAGER,delete t.EDITOR,delete t.VISUAL,t.GIT_TERMINAL_PROMPT="0",t.GIT_LFS_SKIP_SMUDGE="1",Object.assign(t,n),de__default.default({timeout:{block:et},config:["filter.lfs.required=false","protocol.version=2","remote.origin.promisor=false"]}).env(t)}async function Wt(n){try{await promises.rm(n,{recursive:!0,force:!0});}catch{}await promises.mkdir(n,{recursive:true});}async function Le(n,t,e){let r=n.slug;try{let{stdout:i,stderr:o}=await At("gh",["auth","status","-h","github.com"],{timeout:5e3,env:{...process.env,GIT_TERMINAL_PROMPT:"0"}}),l=`${i}${o}`;/Git operations protocol:\s+ssh/i.test(l)&&(r=n.sshUrl);}catch{return false}return await At("gh",["repo","clone",r,t,"--",...e?["--depth=1","--branch",e]:["--depth=1"]],{timeout:et,env:{...process.env,GIT_TERMINAL_PROMPT:"0"}}),true}function Ie(n,t,e){return t&&Nt(e)?`GitHub blocked HTTPS access to ${n} because the organization enforces SAML SSO.
2
- skills tried your existing git credentials and available fallbacks, but none succeeded.
3
- - Re-authorize your GitHub credentials/app for that org's SSO policy
4
- - Or rerun with SSH: easbot skills add ${t.sshUrl}
5
- - Verify access with: gh auth status -h github.com or ssh -T git@github.com`:t?`Authentication failed for ${n}.
6
- - For private repos, ensure you have access
7
- - Retry with SSH: easbot skills add ${t.sshUrl}
8
- - Check access with: gh auth status -h github.com or ssh -T git@github.com`:`Authentication failed for ${n}.
9
- - For private repos, ensure you have access
10
- - For SSH: Check your keys with 'ssh -T git@github.com'
11
- - For HTTPS: Run 'gh auth login' or configure git credentials`}async function Ut(n,t,e){if(e){await utils.Filesystem.mkdir(path.dirname(e),{recursive:true});let o=t?["--depth","1","--branch",t]:["--depth","1"];try{return await tt().clone(n,e,o),e}catch(l){throw await promises.rm(e,{recursive:true,force:true}).catch(()=>{}),l}}let r=await promises.mkdtemp(path.join(os.tmpdir(),"skills-")),s=t?["--depth","1","--branch",t]:["--depth","1"],i=Ee(n);try{return await tt().clone(n,r,s),r}catch(o){let l=o instanceof Error?o.message:String(o),a=l.includes("block timeout")||l.includes("timed out"),c=Pe(l);if(a){try{await promises.rm(r,{recursive:!0,force:!0});}catch{}let f=Math.round(et/1e3);throw new L(`Clone timed out after ${f}s. Common causes:
12
- - Large repository: raise the timeout with SKILLS_CLONE_TIMEOUT=600000 (10m)
13
- - Slow network: retry, or clone manually and pass the local path to 'skills add'
14
- - Private repo without credentials: ensure auth is configured
15
- - For SSH: ssh-add -l (to check loaded keys)
16
- - For HTTPS: gh auth status (if using GitHub CLI)`,n,true,false)}if(c&&i&&be(n)){try{if(await Wt(r),await Le(i,r,t))return r}catch{}try{return await Wt(r),await tt({GIT_SSH_COMMAND:process.env.GIT_SSH_COMMAND??"ssh -o BatchMode=yes"}).clone(i.sshUrl,r,s),r}catch{}}try{await promises.rm(r,{recursive:!0,force:!0});}catch{}if(c)throw new L(Ie(n,i,l),n,false,true);let u=l.includes("filter.smudge")?`
17
- - The repo defines a smudge/clean filter that Git considers unsafe.
18
- Enable it with: git config --global protocol.allowUnsafeFilter true
19
- Or upgrade Git, or unset filter.<driver>.* in the source repo.`:"";throw new L(`Failed to clone ${n}: ${l}${u}`,n,false,false)}}async function vn(n){let t=path.normalize(path.resolve(n)),e=path.normalize(path.resolve(os.tmpdir()));if(!t.startsWith(e+path.sep)&&t!==e)throw new Error("Attempted to clean up directory outside of temp directory");await promises.rm(n,{recursive:true,force:true});}function O(n){if(n.type==="local")return null;let t=n.url.match(/^git@[^:]+:(.+)$/);if(t){let e=t[1];return e=e.replace(/\.git$/,""),e.includes("/")?e:null}if(n.url.startsWith("ssh://"))try{let r=new URL(n.url).pathname.slice(1);return r=r.replace(/\.git$/,""),r.includes("/")?r:null}catch{return null}if(!n.url.startsWith("http://")&&!n.url.startsWith("https://"))return null;try{let r=new URL(n.url).pathname.slice(1);if(r=r.replace(/\.git$/,""),r.includes("/"))return r}catch{}return null}function Kn(n){let t=n.match(/^([^/]+)\/([^/]+)$/);return t?{owner:t[1],repo:t[2]}:null}async function Nn(n,t){try{let e=await fetch(`https://api.github.com/repos/${n}/${t}`);return e.ok?(await e.json()).private===!0:null}catch{return null}}async function Ft(n,t){try{let e=await fetch(`https://api.github.com/repos/${n}/${t}`,{headers:{Accept:"application/vnd.github+json"}});if(!e.ok)return null;let r=await e.json();return typeof r.default_branch=="string"&&r.default_branch.length>0?r.default_branch:null}catch{return null}}function H(n){let e=n.replace(/\\/g,"/").split("/");for(let r of e)if(r==="..")throw new Error(`Unsafe subpath: "${n}" contains path traversal segments. Subpaths must not contain ".." components.`);return n}function Re(n){return path.isAbsolute(n)||n.startsWith("./")||n.startsWith("../")||n==="."||n===".."||/^[a-zA-Z]:[/\\]/.test(n)}var Ae={"coinbase/agentWallet":"coinbase/agentic-wallet-skills"};function nt(n){try{return decodeURIComponent(n)}catch{return n}}function We(n){if(n.startsWith("github:")||n.startsWith("gitlab:")||n.startsWith("git@")||/^ssh:\/\/.+\.git(?:$|[/?])/i.test(n))return true;if(n.startsWith("http://")||n.startsWith("https://"))try{let t=new URL(n),e=t.pathname;if(t.hostname==="github.com")return /^\/[^/]+\/[^/]+(?:\.git)?(?:\/tree\/[^/]+(?:\/.*)?)?\/?$/.test(e);if(t.hostname==="gitlab.com")return /^\/.+?\/[^/]+(?:\.git)?(?:\/-\/tree\/[^/]+(?:\/.*)?)?\/?$/.test(e)}catch{}return /^https?:\/\/.+\.git(?:$|[/?])/i.test(n)?true:!n.includes(":")&&!n.startsWith(".")&&!n.startsWith("/")&&/^([^/]+)\/([^/]+)(?:\/(.+)|@(.+))?$/.test(n)}function Ke(n){let t=n.indexOf("#");if(t<0)return {inputWithoutFragment:n};let e=n.slice(0,t),r=n.slice(t+1);if(!r)return {inputWithoutFragment:e};if(!We(e))return {inputWithoutFragment:n};let s=r.indexOf("@");if(s===-1)return {inputWithoutFragment:e,ref:nt(r)};let i=r.slice(0,s),o=r.slice(s+1);return {inputWithoutFragment:e,ref:i?nt(i):void 0,subpath:o?nt(o):void 0}}function Dt(n,t,e){return t?`${n}#${t}${e?`@${e}`:""}`:n}function Ct(n){if(Re(n)){let d=path.resolve(n);return {type:"local",url:d,localPath:d}}let{inputWithoutFragment:t,ref:e,subpath:r}=Ke(n);n=t;let s=Ae[n];s&&(n=s);let i=n.match(/^github:(.+)$/);if(i)return Ct(Dt(i[1],e,r));let o=n.match(/^gitlab:(.+)$/);if(o)return Ct(Dt(`https://gitlab.com/${o[1]}`,e,r));let l=n.match(/github\.com\/([^/]+)\/([^/]+)\/tree\/([^/]+)\/(.+)/);if(l){let[,d,g,w,x]=l;return {type:"github",url:`https://github.com/${d}/${g}.git`,ref:w||e,subpath:x&&H(x)}}let a=n.match(/github\.com\/([^/]+)\/([^/]+)\/tree\/([^/]+)$/);if(a){let[,d,g,w]=a;return {type:"github",url:`https://github.com/${d}/${g}.git`,ref:w||e}}let c=n.match(/github\.com\/([^/]+)\/([^/]+)/);if(c){let[,d,g]=c,w=g.replace(/\.git$/,"");return {type:"github",url:`https://github.com/${d}/${w}.git`,...e?{ref:e}:{}}}let u=n.match(/^(https?):\/\/([^/]+)\/(.+?)\/-\/tree\/([^/]+)\/(.+)/);if(u){let[,d,g,w,x,k]=u;if(g!=="github.com"&&w)return {type:"gitlab",url:`${d}://${g}/${w.replace(/\.git$/,"")}.git`,ref:x||e,subpath:k&&H(k)}}let f=n.match(/^(https?):\/\/([^/]+)\/(.+?)\/-\/tree\/([^/]+)$/);if(f){let[,d,g,w,x]=f;if(g!=="github.com"&&w)return {type:"gitlab",url:`${d}://${g}/${w.replace(/\.git$/,"")}.git`,ref:x||e}}let h=n.match(/gitlab\.com\/(.+?)(?:\.git)?\/?$/);if(h){let d=h[1];if(d.includes("/"))return {type:"gitlab",url:`https://gitlab.com/${d}.git`,...e?{ref:e}:{}}}let y=n.match(/^([^/@]+)\/([^/@]+)@(.+)?$/);if(y&&!n.includes(":")&&!n.startsWith(".")&&!n.startsWith("/")){let d=y[1],g=y[2],w=y[3];if(!w)return {type:"github",url:`https://github.com/${d}/${g}.git`,...e?{ref:e}:{}};let x=H(w);return {type:"github",url:`https://github.com/${d}/${g}.git`,...e?{ref:e}:{},...x?{subpath:x}:{}}}let E=n.match(/^([^/@]+)\/([^/@]+)(?:\/(.+?))?\/?$/);if(E&&!n.includes(":")&&!n.startsWith(".")&&!n.startsWith("/")){let[,d,g,w]=E;return {type:"github",url:`https://github.com/${d}/${g}.git`,...e?{ref:e}:{},subpath:r??(w&&H(w))}}return Ne(n)?{type:"well-known",url:n}:{type:"git",url:n,...e?{ref:e}:{},...r?{subpath:r}:{}}}function Ne(n){if(!n.startsWith("http://")&&!n.startsWith("https://"))return false;try{let t=new URL(n);return !(["github.com","gitlab.com","raw.githubusercontent.com"].includes(t.hostname)||n.endsWith(".git"))}catch{return false}}var Tt="https://schemas.agentskills.io/discovery/0.2.0/schema.json",Fe=/\/schemas\/agent-skills\/index\.v1\.json$/,Te=50*1024*1024,Me=1e3;function _e(n,t){let e=n.skillPath;if(typeof e=="string"&&e.trim()!==""&&e!==null)return e.replace(/^\/+/,"").replace(/\/+$/,"");if(typeof n.sourceUrl=="string"&&n.sourceUrl)try{let s=new URL(n.sourceUrl).pathname,i=/\/\.well-known\/(?:agent-skills|skills)\/(.*?)\/SKILL\.md$/,o=s.match(i);if(o?.[1])return o[1];let l=s.match(/^(.*?)\/[^/]+\/SKILL\.md$/);if(l?.[1])return l[1]}catch{}if(typeof n.installName=="string"&&n.installName){let r=n.installName.lastIndexOf("@");if(r>=0){let s=n.installName.slice(r+1);if(s.includes("/"))return s.replace(/^\/+/,"")}}return t}var rt=class{constructor(){chunkVRHWDHQV_cjs.b(this,"id","well-known");chunkVRHWDHQV_cjs.b(this,"displayName","Well-Known Skills");chunkVRHWDHQV_cjs.b(this,"WELL_KNOWN_PATHS",[".well-known/agent-skills",".well-known/skills"]);chunkVRHWDHQV_cjs.b(this,"INDEX_FILE","index.json");}match(t){if(!t.startsWith("http://")&&!t.startsWith("https://"))return {matches:false};try{let e=new URL(t);return ["github.com","gitlab.com","huggingface.co"].includes(e.hostname)?{matches:!1}:{matches:!0,sourceIdentifier:`wellknown/${e.hostname}`}}catch{return {matches:false}}}async fetchIndex(t){return (await this.fetchIndexCandidates(t))[0]??null}async fetchIndexCandidates(t){try{let e=new URL(t),r=e.pathname.replace(/\/$/,""),s=[],i=r.match(/\/\.well-known\/(agent-skills|skills)\/?$/);if(i?.[1]){let l=`.well-known/${i[1]}`;s.push({indexUrl:`${e.protocol}//${e.host}${r}/${this.INDEX_FILE}`,baseUrl:`${e.protocol}//${e.host}${r.replace(/\/\.well-known\/(?:agent-skills|skills)$/,"")}`,wellKnownPath:l});}for(let l of this.WELL_KNOWN_PATHS)s.push({indexUrl:`${e.protocol}//${e.host}${r}/${l}/${this.INDEX_FILE}`,baseUrl:`${e.protocol}//${e.host}${r}`,wellKnownPath:l}),r&&r!==""&&s.push({indexUrl:`${e.protocol}//${e.host}/${l}/${this.INDEX_FILE}`,baseUrl:`${e.protocol}//${e.host}`,wellKnownPath:l});let o=[];for(let{indexUrl:l,baseUrl:a,wellKnownPath:c}of s)try{let u=await fetch(l);if(!u.ok)continue;let f=await u.json(),h=this.normalizeIndex(f,l,c);if(!h)continue;o.push({index:h.index,entries:h.entries,resolvedBaseUrl:a,resolvedWellKnownPath:c,indexUrl:l});}catch{}return o}catch{return []}}normalizeIndex(t,e,r){if(!t||typeof t!="object")return null;let s=t;if(!Array.isArray(s.skills))return null;let i=s.$schema;if(i===Tt){let a=[],c=[];for(let u of s.skills){if(!this.isValidSkillEntryV2(u))continue;let f=new URL(u.url,e).toString();a.push({version:"0.2.0",name:u.name,description:u.description,type:u.type,artifactUrl:f,digest:u.digest,indexEntry:u}),c.push(u);}return a.length===0?null:{index:{$schema:Tt,skills:c},entries:a}}if(typeof i=="string"&&Fe.test(i)){let a=[],c=[];for(let u of s.skills){if(!this.isValidSkillEntryEasbotV1(u))continue;let f=new URL(u.sourceUrl,e).toString();a.push({version:"easbot-v1",name:u.name,description:u.description,skillMdUrl:f,installName:u.installName,indexEntry:u}),c.push(u);}return a.length===0?null:{index:{$schema:i,skills:c},entries:a}}if(i!==void 0)return null;let o=[],l=[];for(let a of s.skills){if(!this.isValidSkillEntryV1(a))return null;o.push(a),l.push({version:"0.1.0",name:a.name,description:a.description,files:a.files,baseUrl:this.getLegacySkillBaseUrl(e,r),wellKnownPath:r,indexEntry:a});}return {index:{skills:o},entries:l}}getLegacySkillBaseUrl(t,e){let r=new URL(t),s=`/${e}/${this.INDEX_FILE}`;return `${r.protocol}//${r.host}${r.pathname.slice(0,-s.length)}`}isValidSkillName(t){return !(typeof t!="string"||t.length===0||t.length>64||!/^[a-z0-9-]+$/.test(t)||t.startsWith("-")||t.endsWith("-")||t.includes("--"))}isSafeLegacyFilePath(t){return !(typeof t!="string"||t.length===0||t.startsWith("/")||t.startsWith("\\")||t.includes("..")||t.includes("\0"))}isValidSkillEntryEasbotV1(t){if(!t||typeof t!="object")return false;let e=t;if(!this.isValidSkillName(e.name)||typeof e.description!="string"||!e.description||e.description.length>1024||typeof e.sourceUrl!="string"||!e.sourceUrl)return false;try{new URL(e.sourceUrl,"https://easbot.cn/.well-known/agent-skills/index.json");}catch{return false}return true}isValidSkillEntryV1(t){if(!t||typeof t!="object")return false;let e=t;if(!this.isValidSkillName(e.name)||typeof e.description!="string"||!e.description||!Array.isArray(e.files)||e.files.length===0)return false;for(let s of e.files)if(!this.isSafeLegacyFilePath(s))return false;return e.files.some(s=>typeof s=="string"&&s.toLowerCase()==="skill.md")}isValidSkillEntryV2(t){if(!t||typeof t!="object")return false;let e=t;if(!this.isValidSkillName(e.name)||typeof e.description!="string"||!e.description||e.description.length>1024||e.type!=="skill-md"&&e.type!=="archive"||typeof e.url!="string"||!e.url||typeof e.digest!="string"||!/^sha256:[a-f0-9]{64}$/.test(e.digest))return false;try{new URL(e.url,"https://example.com/.well-known/agent-skills/index.json");}catch{return false}return true}async fetchSkill(t){try{let e=new URL(t),r=await this.fetchIndexCandidates(t);for(let s of r){let{entries:i}=s,o=null,l=e.pathname.match(/\/.well-known\/(?:agent-skills|skills)\/([^/]+)\/?$/);if(l?.[1]&&l[1]!=="index.json"?o=l[1]:i.length===1&&(o=i[0].name),!o)continue;let a=i.find(u=>u.name===o);if(!a)continue;let c=await this.fetchSkillByEntry(a);if(c)return c}return null}catch{return null}}async fetchSkillByEntry(t,e,r){return typeof t=="string"?e?this.fetchLegacySkillByEntry({version:"0.1.0",name:e.name,description:e.description,files:e.files,baseUrl:t,wellKnownPath:r??this.WELL_KNOWN_PATHS[0],indexEntry:e}):null:t.version==="0.1.0"?this.fetchLegacySkillByEntry(t):t.version==="easbot-v1"?this.fetchEasbotV1SkillByEntry(t):this.fetchArtifactSkillByEntry(t)}async fetchEasbotV1SkillByEntry(t){try{let e=await fetch(t.skillMdUrl);if(!e.ok)return null;let r=await e.text(),{data:s}=chunkE7AHWFZN_cjs.a(r);if(typeof s.name!="string"||typeof s.description!="string")return null;let i=new Map;i.set("SKILL.md",r);let o=_e(t.indexEntry,s.name);return this.createSkill({name:s.name,description:s.description,content:r,installName:o,sourceUrl:t.skillMdUrl,metadata:s.metadata,files:i,indexEntry:t.indexEntry})}catch{return null}}async fetchLegacySkillByEntry(t){try{let e=`${t.baseUrl.replace(/\/$/,"")}/${t.wellKnownPath}/${t.name}`,r=`${e}/SKILL.md`,s=await fetch(r);if(!s.ok)return null;let i=await s.text(),{data:o}=chunkE7AHWFZN_cjs.a(i);if(typeof o.name!="string"||typeof o.description!="string")return null;let l=new Map;l.set("SKILL.md",i);let c=t.files.filter(f=>f.toLowerCase()!=="skill.md").map(async f=>{try{let h=`${e}/${f}`,y=await fetch(h);if(y.ok){let E=await y.arrayBuffer();return {path:f,content:new Uint8Array(E)}}}catch{}return null}),u=await Promise.all(c);for(let f of u)f&&l.set(f.path,f.content);return this.createSkill({name:o.name,description:o.description,content:i,installName:t.name,sourceUrl:r,metadata:o.metadata,files:l,indexEntry:t.indexEntry})}catch{return null}}async fetchArtifactSkillByEntry(t){try{let e=await fetch(t.artifactUrl);if(!e.ok)return null;let r=e.headers.get("content-type")??"",s=new Uint8Array(await e.arrayBuffer());if(this.computeDigest(s)!==t.digest)return null;if(t.type==="skill-md"){let c=new TextDecoder().decode(s),{data:u}=chunkE7AHWFZN_cjs.a(c);if(typeof u.name!="string"||typeof u.description!="string")return null;let f=new Map;return f.set("SKILL.md",c),this.createSkill({name:u.name,description:u.description,content:c,installName:t.name,sourceUrl:t.artifactUrl,metadata:u.metadata,files:f,indexEntry:t.indexEntry})}let i=this.extractArchive(s,t.artifactUrl,r),o=i.get("SKILL.md");if(!o)return null;let l=typeof o=="string"?o:new TextDecoder().decode(o);i.set("SKILL.md",l);let{data:a}=chunkE7AHWFZN_cjs.a(l);return typeof a.name!="string"||typeof a.description!="string"?null:this.createSkill({name:a.name,description:a.description,content:l,installName:t.name,sourceUrl:t.artifactUrl,metadata:a.metadata,files:i,indexEntry:t.indexEntry})}catch{return null}}createSkill(t){return {name:chunkRVR3DSD2_cjs.b(t.name),description:chunkRVR3DSD2_cjs.b(t.description),content:t.content,installName:t.installName,sourceUrl:t.sourceUrl,metadata:t.metadata&&typeof t.metadata=="object"?t.metadata:void 0,files:t.files,indexEntry:t.indexEntry}}async fetchAllSkills(t){try{let e=await this.fetchIndexCandidates(t);for(let r of e){let s=r.entries.map(l=>this.fetchSkillByEntry(l)),o=(await Promise.all(s)).filter(l=>l!==null);if(o.length>0)return o}return []}catch{return []}}computeDigest(t){return `sha256:${crypto.createHash("sha256").update(t).digest("hex")}`}extractArchive(t,e,r){if(this.isZipArchive(t,e,r))return this.extractZip(t);if(this.isTarGzArchive(t,e,r))return this.extractTarGz(t);throw new Error("Unsupported archive format")}isZipArchive(t,e,r){return r.includes("application/zip")||e.toLowerCase().endsWith(".zip")||t[0]===80&&t[1]===75}isTarGzArchive(t,e,r){let s=e.toLowerCase();return r.includes("application/gzip")||r.includes("application/x-gzip")||s.endsWith(".tar.gz")||s.endsWith(".tgz")||t[0]===31&&t[1]===139}normalizeArchivePath(t){if(!t||t.includes("\0")||t.startsWith("/")||t.startsWith("\\")||/^[A-Za-z]:/.test(t)||t.includes("\\"))return null;let e=t.split("/").filter(Boolean);return e.length===0||e.some(r=>r==="."||r==="..")?null:e.join("/")}addArchiveFile(t,e,r,s){let i=this.normalizeArchivePath(e);if(!i)throw new Error(`Unsafe archive path: ${e}`);if(s.bytes+=r.byteLength,s.bytes>Te)throw new Error("Archive exceeds maximum unpacked size");if(t.size>=Me)throw new Error("Archive contains too many files");t.set(i,r);}extractTarGz(t){let e=zlib.gunzipSync(Buffer.from(t)),r=new Map,s={bytes:0},i=0;for(;i+512<=e.length;){let o=e.subarray(i,i+512);if(o.every(E=>E===0))break;let l=this.readTarString(o,0,100),a=this.readTarString(o,124,12).trim(),c=o[156],u=this.readTarString(o,345,155),f=u?`${u}/${l}`:l,h=Number.parseInt(a||"0",8);if(!Number.isFinite(h)||h<0)throw new Error("Invalid tar entry size");if(i+=512,c===50||c===49)throw new Error("Archive links are not supported");if(c===0||c===48){let E=e.subarray(i,i+h);this.addArchiveFile(r,f,new Uint8Array(E),s);}i+=Math.ceil(h/512)*512;}if(!r.has("SKILL.md"))throw new Error("Archive missing root SKILL.md");return r}readTarString(t,e,r){let s=t.subarray(e,e+r),i=s.indexOf(0);return new TextDecoder().decode(i>=0?s.subarray(0,i):s)}extractZip(t){let e=Buffer.from(t),r=this.findZipEndOfCentralDirectory(e);if(r<0)throw new Error("Invalid zip archive");let s=e.readUInt16LE(r+10),i=e.readUInt32LE(r+16),o=new Map,l={bytes:0},a=i;for(let c=0;c<s;c++){if(e.readUInt32LE(a)!==33639248)throw new Error("Invalid zip directory");let u=e.readUInt16LE(a+8),f=e.readUInt16LE(a+10),h=e.readUInt32LE(a+20),y=e.readUInt32LE(a+24),E=e.readUInt16LE(a+28),d=e.readUInt16LE(a+30),g=e.readUInt16LE(a+32),w=e.readUInt32LE(a+38),x=e.readUInt32LE(a+42),k=a+46,S=e.subarray(k,k+E),b=new TextDecoder(u&2048?"utf-8":void 0).decode(S);if(a=k+E+d+g,b.endsWith("/"))continue;if(u&1)throw new Error("Encrypted zip entries are not supported");let T=w>>>16&61440;if(T===40960||T===4096)throw new Error("Archive links are not supported");if(e.readUInt32LE(x)!==67324752)throw new Error("Invalid zip local header");let M=e.readUInt16LE(x+26),ue=e.readUInt16LE(x+28),kt=x+30+M+ue,wt=e.subarray(kt,kt+h),_;if(f===0)_=wt;else if(f===8)_=zlib.inflateRawSync(wt);else throw new Error(`Unsupported zip compression method: ${f}`);if(_.byteLength!==y)throw new Error("Zip entry size mismatch");this.addArchiveFile(o,b,new Uint8Array(_),l);}if(!o.has("SKILL.md"))throw new Error("Archive missing root SKILL.md");return o}findZipEndOfCentralDirectory(t){let e=Math.max(0,t.length-65535-22);for(let r=t.length-22;r>=e;r--)if(t.readUInt32LE(r)===101010256)return r;return -1}toRawUrl(t){try{let e=new URL(t);if(t.toLowerCase().endsWith("/skill.md"))return t;let r=this.WELL_KNOWN_PATHS[0],s=e.pathname.match(/\/.well-known\/(?:agent-skills|skills)\/([^/]+)\/?$/);if(s?.[1]){let o=e.pathname.replace(/\/.well-known\/(?:agent-skills|skills)\/.*$/,"");return `${e.protocol}//${e.host}${o}/${r}/${s[1]}/SKILL.md`}let i=e.pathname.replace(/\/$/,"");return `${e.protocol}//${e.host}${i}/${r}/${this.INDEX_FILE}`}catch{return t}}getSourceIdentifier(t){try{return new URL(t).hostname.replace(/^www\./,"")}catch{return "unknown"}}async hasSkillsIndex(t){return await this.fetchIndex(t)!==null}},Mt=new rt;function it(n,t){let e=path.normalize(path.resolve(t)),r=path.normalize(path.resolve(n));return r.startsWith(e+path.sep)||r===e}function j(n){return n.startsWith("./")}async function Ht(n){let t=new Map;try{let e=await promises.readFile(path.join(n,".claude-plugin/marketplace.json"),"utf-8"),r=JSON.parse(e),s=r.metadata?.pluginRoot;if(s===void 0||j(s))for(let o of r.plugins??[]){if(!o.name||typeof o.source!="string"&&o.source!==void 0||o.source!==void 0&&!j(o.source))continue;let l=path.join(n,s??"",o.source??"");if(it(l,n)&&o.skills&&o.skills.length>0)for(let a of o.skills){if(!j(a))continue;let c=path.join(l,a);it(c,n)&&t.set(path.resolve(c),o.name);}}}catch{}try{let e=await promises.readFile(path.join(n,".claude-plugin/plugin.json"),"utf-8"),r=JSON.parse(e);if(r.name&&r.skills&&r.skills.length>0)for(let s of r.skills){if(!j(s))continue;let i=path.join(n,s);it(i,n)&&t.set(path.resolve(i),r.name);}}catch{}return t}var Ve=["node_modules",".git","dist","build","__pycache__"];async function Ge(n){let t=path.join(n,".gitignore");try{let e=await promises.readFile(t,"utf-8");return utils.Glob.parseGitignoreContent(e)}catch{return []}}function st(n){return n.toLowerCase().replace(/[\s_]+/g,"-")}function Be(n){return n.split(path.sep).join("/").replace(/\/+/g,"/")}function qe(){let n=process.env.INSTALL_INTERNAL_SKILLS;return n==="1"||n==="true"}async function Xt(n){try{let t=path.join(n,"SKILL.md");return (await promises.stat(t)).isFile()}catch{return false}}async function jt(n,t){try{let e=await promises.readFile(n,"utf-8"),{data:r}=chunkE7AHWFZN_cjs.a(e);if(!r.name||!r.description||typeof r.name!="string"||typeof r.description!="string")return null;let s=r.metadata&&typeof r.metadata=="object"&&!Array.isArray(r.metadata)?r.metadata:void 0;return s?.internal===!0&&!qe()&&!t?.includeInternal?null:{name:chunkRVR3DSD2_cjs.b(r.name),description:chunkRVR3DSD2_cjs.b(r.description),path:path.dirname(n),rawContent:e,metadata:s}}catch{return null}}async function Jt(n,t=0,e=5){if(t>e)return [];try{let[r,s]=await Promise.all([Xt(n),promises.readdir(n,{withFileTypes:!0}).catch(()=>[])]),i=r?[n]:[],o=await Promise.all(s.filter(l=>l.isDirectory()&&!Ve.includes(l.name)).map(l=>Jt(path.join(n,l.name),t+1,e)));return [...i,...o.flat()]}catch{return []}}function Xe(n,t){let e=path.normalize(path.resolve(n)),r=path.normalize(path.resolve(path.join(n,t)));return r.startsWith(e+path.sep)||r===e}async function at(n,t,e){let r=[],s=new Set,i=await B(n),o=new Set(Object.keys(i.skills).map(st));if(t&&!Xe(n,t))throw new Error(`Invalid subpath: "${t}" resolves outside the repository directory. Subpath must not contain ".." segments that escape the base path.`);let l=t?path.join(n,t):n,a=await Ht(l),c=k=>{let S=path.resolve(k.path);return a.has(S)&&(k.pluginName=a.get(S)),k},u=chunkISMGLHYS_cjs.k(),f=k=>{if(o.size===0)return false;let S=Be(path.relative(n,k.path));if(!u.some(M=>S===M||S.startsWith(`${M}/`)))return false;let mt=st(k.name),T=st(path.basename(k.path));return o.has(mt)||o.has(T)},h=async k=>{if(!await Xt(k))return false;let S=await jt(path.join(k,"SKILL.md"),e);return !S||s.has(S.name)||f(S)||(S=c(S),r.push(S),s.add(S.name)),true},y=t?t.replace(/^\/+|\/+$/g,"").split("/").filter(k=>k.length>0):[],E=y.length>0?`**/${y.join("/")}/**/SKILL.md`:"**/SKILL.md",d=await utils.Glob.scan(E,{cwd:l,absolute:true,ignore:[...utils.Glob.DEFAULT_IGNORE_PATTERNS,...await Ge(l)]}),g="/",w=l.split(path.sep).join(g);d.sort((k,S)=>k.split(g).length-S.split(g).length);let x=[];for(let k of d){if(x.some(b=>k.startsWith(`${b}${g}`)||k===b))continue;let S=path.dirname(k);if(await h(S)){let b=S.split(path.sep).join(g);if(b===w)continue;x.push(b);}}if(r.length===0||e?.fullDepth){let k=await Jt(l);for(let S of k){let b=await jt(path.join(S,"SKILL.md"),e);b&&!s.has(b.name)&&!f(b)&&(b=c(b),r.push(b),s.add(b.name));}}return r}function Je(n){return n.name||(n.path?path.basename(n.path):"")}function nr(n,t){let e=t.map(r=>r.toLowerCase());return n.filter(r=>{let s=r.name.toLowerCase(),i=Je(r).toLowerCase();return e.some(o=>o===s||o===i)})}var Zt="*";function rr(n,t){if(!n||n.length===0)return [];let e=new Set(t),r=[];for(let s of n)if(s!==Zt){if(s.includes("/")||s.includes("**")){r.push(s);continue}Yt.test(s)?t.some(i=>utils.Wildcard.match(i,s))||r.push(s):e.has(s)||r.push(s);}return r}function ir(n,t){let e={wildcard:false,matched:[],invalid:[]};if(!n||n.length===0)return e;let r=new Set(t),s=new Set;for(let i of n){if(i===Zt){e.wildcard=true;continue}if(i.includes("/")||i.includes("**")){e.invalid.push(i);continue}if(Yt.test(i))for(let o of t)utils.Wildcard.match(o,i)&&s.add(o);else r.has(i)?s.add(i):e.invalid.push(i);}return e.matched=Array.from(s),e}var Yt=/[*?[{}]/;var ct="houjallen/agent-skills";async function xr(n){let t=n.defaultPlugin;if(!t||typeof t.marketId!="string"||t.marketId.length===0)return ct;let e=n.markets[t.marketId];if(!e)return ct;let r=e.localPath??e.url;if(!r)return ct;let s=r;return e.subpath&&(s=`${s}@${e.subpath}`),e.ref&&(s=`${s}#${e.ref}`),s}function tn(n){if(!n||typeof n!="object"||Array.isArray(n))return null;let t=n;if(typeof t.marketId!="string"||t.marketId.length===0)return null;let e={marketId:t.marketId};return typeof t.pluginId=="string"&&t.pluginId.length>0&&(e.pluginId=t.pluginId),e}function m(n){return utils.Filesystem.normalize(n)}function ut(n){if(n==="general"||n==="coder"||n==="all")return n}function en({scope:n}){let t=n==="project"?chunkXGUPIAAF_cjs.p():chunkXGUPIAAF_cjs.m(),e=utils.Filesystem.join(t,n==="project"?".easbot":"easbot","skills");return utils.Filesystem.normalize(e)}function F(){return utils.Filesystem.join(chunkXGUPIAAF_cjs.m(),"skills","store")}function re(){return utils.Filesystem.join(F(),"index.json")}function q(n){let t=`${n.type}|${n.url}|${n.ref??""}`;return crypto.createHash("sha256").update(t).digest("hex")}function ie(n){let t=q(n);return utils.Filesystem.join(F(),t)}function U(){return utils.Filesystem.join(chunkXGUPIAAF_cjs.o(),"skills","cache")}function nn(n,t,e){if(e&&e.length>0)return N(e);let r=rn(n);if(r)return r;if(t?.includes("/")){let s=t.split("/")[0];if(s)return N(s)}return "default"}function rn(n){let t=n.localPath??n.url;if(!t)return null;if(n.type==="well-known")try{let s=new URL(t),i=s.hostname.replace(/^www\./,"").replace(/\./g,"-"),o=s.pathname.replace(/^\/+/,"").split("/")[0]||"";return o&&!i.endsWith(`-${o}`)?N(`${i}-${o}`):N(i)}catch{return null}let e=t.match(/^(?:https?:\/\/[^/]+\/|git@[^:]+:)([^/]+)\/([^/]+?)(?:\.git)?\/?$/);if(e)return N(e[2]??"");let r=t.split(/[\\/]/).filter(Boolean).pop();return r?N(r.replace(/\.git$/,"")):null}function N(n){let t=n.trim().replace(/[:\\/\0]/g,"-").replace(/\.git$/,"").replace(/\s+/g,"-");return t.length>64&&(t=t.slice(0,64)),t.length>0?t:"default"}function ht(n){if(n.type==="well-known")return sn(n.url);let t=O(n);if(t)return utils.Filesystem.join(U(),n.type,t);let e=crypto.createHash("sha256").update(n.url).digest("hex").slice(0,16);return utils.Filesystem.join(U(),n.type,`unknown-${e}`)}function sn(n){let t,e;try{let r=new URL(n);t=r.hostname.replace(/^www\./,"");let s=r.pathname.match(/\/\.well-known\/(agent-skills|skills)/);s?.[1]?e=`.well-known/${s[1]}`:e=".well-known/agent-skills";}catch{let r=crypto.createHash("sha256").update(n).digest("hex").slice(0,16);return utils.Filesystem.join(U(),"wellknown",`unknown-${r}`)}return utils.Filesystem.join(U(),"wellknown",t,e)}async function se(n){n.skillNames??[];if(n.type==="local")return on(n);let e=n.mode??"install",{cacheDir:r,source:s,cloneError:i}=await ln(n,e);return {tempDir:r,cacheHit:false,source:s,cloneError:i}}var pt=class extends Error{constructor(e){super(`Local source path does not exist: ${e}`);chunkVRHWDHQV_cjs.b(this,"localPath",e);this.name="LocalPathNotFoundError";}};async function on(n,t){let e=n.localPath??n.url;if(!fs.existsSync(e))throw new pt(e);let r=ie(n);return fs.existsSync(r)&&await oe(r)?{tempDir:r,cacheHit:true,source:"local-cp",cloneError:null}:{tempDir:e,cacheHit:false,source:"local-cp",cloneError:null}}async function ln(n,t){let e=n.ref;if(!e){let l=O(n);if(l){let[a,c]=l.split("/");if(a&&c){let u=await Ft(a,c);u&&(e=u);}}}e||(e="HEAD");let r=ht(n);if(n.type==="well-known")return fs.existsSync(r)?{cacheDir:r,source:"cache-pull",cloneError:null}:(await utils.Filesystem.mkdir(m(r),{recursive:true}),await fn(n.url,r),{cacheDir:r,source:"well-known-fetch",cloneError:null});if(fs.existsSync(r))try{let l=de__default.default(r);return t==="update"?(await l.fetch(),await l.checkout(e),{cacheDir:r,source:"cache-pull",cloneError:null}):(await l.checkout(e),{cacheDir:r,source:"cache-pull",cloneError:null})}catch{return {cacheDir:r,source:"cache-pull",cloneError:null}}async function s(l,a,c){return Ut(l,a,c)}let i=null,o=null;try{return await utils.Filesystem.mkdir(m(utils.Filesystem.dirname(r)),{recursive:!0}),i=`${r}.clone-tmp`,await s(n.url,e,i),await promises.rename(m(i),m(r)),{cacheDir:r,source:"cache-clone",cloneError:null}}catch(l){return l instanceof L?o=l:l instanceof Error&&(o=new L(`Failed to clone ${n.url}: ${l.message}`,n.url,false,false)),await utils.Filesystem.mkdir(m(r),{recursive:true}).catch(()=>{}),{cacheDir:r,source:"cache-pull",cloneError:o}}finally{if(i)try{await promises.rm(m(i),{recursive:!0,force:!0});}catch{}}}async function A(){let n=m(re()),t;try{t=await utils.Filesystem.readText(n);}catch{return {version:6,markets:{}}}let e;try{e=JSON.parse(t);}catch{try{await promises.rename(m(n),`${m(n)}.corrupt-${Date.now()}`);}catch{}return {version:6,markets:{}}}let r=e;if(r.version!==6||!r.markets)return {version:6,markets:{}};let s={version:6,markets:r.markets};if("defaultPlugin"in r){let i=tn(r.defaultPlugin);i&&(s.defaultPlugin=i);}return s}async function Y(n){await utils.Filesystem.writeJson(m(re()),n);}async function Er(){let n=await A(),t={};for(let e of Object.values(n.markets))for(let r of Object.values(e.plugins))for(let[s,i]of Object.entries(r.skills))t[s]={marketId:e.id,pluginId:r.id,pluginName:r.name,storePath:e.storePath,pluginSlug:r.id.split(":").slice(1).join(":")||r.id,url:e.url,type:e.type,localPath:e.localPath,subpath:e.subpath,ref:e.ref,addedAt:e.addedAt,skillPath:i.skillPath,computedHash:i.computedHash,sourceKey:e.id,sourcePath:e.localPath??e.storePath};return t}async function br(n,t,e,r,s){let i=await A(),o=i.markets[n];o||(o={...s,id:n,addedAt:s.addedAt??new Date().toISOString(),plugins:{}},i.markets[n]=o);let l=o.plugins[t];l||(l={id:t,name:t.split(":").slice(1).join(":")||t,skills:{}},o.plugins[t]=l),l.skills[e]=r,await Y(i);}async function an(){let n=await A(),t=[];for(let e of Object.values(n.markets))for(let r of Object.values(e.plugins))for(let s of Object.values(r.skills))t.push({skillName:s.name,marketId:e.id,pluginId:r.id,entry:s});return t.sort((e,r)=>{let s=e.marketId.localeCompare(r.marketId);if(s!==0)return s;let i=e.pluginId.localeCompare(r.pluginId);return i!==0?i:e.skillName.localeCompare(r.skillName)}),t}async function cn(n){return (await an()).filter(e=>e.skillName===n)}async function Pr(n,t,e){let s=(await A()).markets[n];if(!s)return;let i=s.plugins[t];if(!i)return;let o=i.skills[e];if(o)return {skillName:o.name,marketId:n,pluginId:t,entry:o}}async function Lr(n,t,e){let r=await A(),s=r.markets[n];if(!s)return false;let i=s.plugins[t];return !i||!(e in i.skills)?false:(delete i.skills[e],await Y(r),true)}async function un(n){let t=await cn(n);if(t.length===0)return [];let e=await A(),r=[];for(let s of t){let i=e.markets[s.marketId]?.plugins[s.pluginId];i&&n in i.skills&&(delete i.skills[n],r.push(s));}return r.length>0&&await Y(e),r}async function Ir(n,t,e,r,s,i,o){await X([{skillName:n,parsed:t,sourceKey:e,sourcePath:r,storePath:s,skillPath:i,...o&&{computedHash:o}}]);}async function X(n){if(n.length===0)return;let t=await A(),e=new Date().toISOString();for(let i of n){let o=i.sourceKey,l=nn(i.parsed,i.skillPath,i.pluginName),a=`${o}:${l}`,c=t.markets[o];if(!c){let h=i.parsed.type==="local"?i.parsed.localPath??i.parsed.url:ht(i.parsed);c={id:o,type:i.parsed.type,url:i.parsed.url,localPath:i.parsed.localPath,subpath:i.parsed.subpath,ref:i.parsed.ref,storePath:i.storePath,cachePath:h,addedAt:e,plugins:{}},t.markets[o]=c;}let u=c.plugins[a];u||(u={id:a,name:l,sourcePath:i.parsed.subpath,skills:{}},c.plugins[a]=u);let f={name:i.skillName,description:i.description??"",skillPath:i.skillPath,computedHash:i.computedHash};i.scope&&(f.scope=i.scope),i.snapshotHash&&(f.snapshotHash=i.snapshotHash),u.skills[i.skillName]=f;}let r=new Set,s=new Map;for(let i of n)r.add(i.sourceKey),i.marketSnapshotHash&&s.set(i.sourceKey,i.marketSnapshotHash);for(let i of r){let o=t.markets[i];if(!o)continue;let l=s.get(i);if(l){o.snapshotHash=l;continue}let a=[];for(let c of Object.values(o.plugins))for(let u of Object.values(c.skills))a.push({name:u.name,snapshotHash:u.snapshotHash});o.snapshotHash=chunkE7AHWFZN_cjs.d(a);}await Y(t);}async function vr(n){return (await un(n)).length>0}async function fn(n,t){let e;try{e=await Mt.fetchAllSkills(n);}catch{return}if(e.length!==0)for(let r of e)try{await pn(r,t);}catch{}}async function pn(n,t){let e=utils.Filesystem.join(t,n.installName),r=utils.Filesystem.normalize(e),s=utils.Filesystem.normalize(t);if(!r.startsWith(`${s}/`)&&r!==s)throw new Error(`Unsafe skill dir: ${n.installName}`);await promises.mkdir(m(e),{recursive:true});for(let[i,o]of n.files){let l=utils.Filesystem.join(e,i),a=utils.Filesystem.normalize(l);if(!a.startsWith(`${r}/`)&&a!==r||i.includes("\0"))continue;let c=path.dirname(m(l));c!==m(e)&&await promises.mkdir(c,{recursive:true}),await promises.writeFile(m(l),typeof o=="string"?o:Buffer.from(o));}}async function $r(n){return (await se({type:"git",url:n.url,ref:n.ref})).tempDir}async function Rr(n,t={}){let e=ie(n),r=false;if(fs.existsSync(e)&&(r=await oe(e),!r))try{await promises.rmdir(m(e));}catch{}if(r){let c=await at(e,void 0,{includeInternal:t.includeInternal,fullDepth:t.fullDepth});if(c.length>0){let f=await Promise.all(c.map(async h=>{let y=ft(e,h.path);return {skillName:h.name,parsed:n,sourceKey:q(n),sourcePath:e,storePath:e,skillPath:y,description:h.description,scope:ut(h.metadata?.scope),...h.pluginName&&{pluginName:h.pluginName},computedHash:await chunkE7AHWFZN_cjs.b(h.path)}}));await X(f);}let u=n.type==="local"?"local-cp":"cache-pull";return {storeDir:e,cacheHit:true,source:u,skills:c,blobSkills:[],cloneError:null}}let s=[];if(n.type==="github"&&!t.fullDepth){let c=O(n),u=c?.split("/")[0]?.toLowerCase(),f=!!c&&Object.hasOwn(chunkRVR3DSD2_cjs.c,c.toLowerCase());if(c&&u&&(f||chunkRVR3DSD2_cjs.d.includes(u))){let h=await chunkRVR3DSD2_cjs.l(c,{subpath:n.subpath,ref:n.ref,includeInternal:t.includeInternal});if(h&&h.skills.length>0){await dn(h.skills,e);let y=h.skills.map(d=>({...d,path:utils.Filesystem.join(e,d.repoSubpath??"",d.name,"SKILL.md")})),E=await Promise.all(y.map(async(d,g)=>{let w=h.skills[g],x=`${w.repoSubpath??""}${w.repoSubpath?"/":""}${w.name}`;return {skillName:d.name,parsed:n,sourceKey:q(n),sourcePath:e,storePath:e,skillPath:x,description:d.description,scope:ut(d.metadata?.scope),...d.pluginName&&{pluginName:d.pluginName},computedHash:await chunkE7AHWFZN_cjs.b(utils.Filesystem.dirname(d.path)),snapshotHash:w.snapshotHash,marketSnapshotHash:h.snapshotHash}}));return await X(E),s=h.skills,{storeDir:e,cacheHit:false,source:"blob-fetch",skills:y,blobSkills:s,cloneError:null}}}}let i=await se(n);await utils.Filesystem.mkdir(m(e),{recursive:true}).catch(()=>{});let o=await at(i.tempDir,void 0,{includeInternal:t.includeInternal,fullDepth:t.fullDepth}),l=[],a=utils.Filesystem.normalize(e).replace(/\\/g,"/");for(let c of o){let u=ft(i.tempDir,c.path),f=utils.Filesystem.join(e,u),h=`${ft(i.tempDir,c.path)}/SKILL.md`,y=utils.Filesystem.normalize(f).replace(/\\/g,"/"),E="/",d=a.endsWith(E)?a:a+E;if(!y.startsWith(d)&&y!==a)throw new Error(`[INVARIANT 0048-yyy] cp target escapes storeRoot: target=${y} storeRoot=${a}
20
- source skill path=${c.path} (parsed.type=${n.type})
21
- \u4E1A\u52A1\u4EFB\u4F55\u65F6\u5019\u4E0D\u80FD\u64CD\u4F5C\u7528\u6237\u7684 local \u76EE\u5F55\u6216\u6587\u4EF6\u3002`);let g;try{await utils.Filesystem.mkdir(m(utils.Filesystem.dirname(f)),{recursive:!0}),await promises.cp(m(c.path),m(f),{recursive:!0}),g=await chunkE7AHWFZN_cjs.b(f);}catch{}c.path=f,l.push({skill:c,skillRel:u,sourceSkillPath:h,targetPath:f,computedHash:g});}if(l.length>0){let c=l.filter(u=>u.computedHash).map(u=>({skillName:u.skill.name,parsed:n,sourceKey:q(n),sourcePath:i.tempDir,storePath:e,skillPath:u.skillRel,description:u.skill.description,scope:ut(u.skill.metadata?.scope),...u.skill.pluginName&&{pluginName:u.skill.pluginName},computedHash:u.computedHash}));await X(c);}return {storeDir:e,cacheHit:i.cacheHit,source:i.source,skills:o,blobSkills:[],cloneError:i.cloneError??null}}async function dn(n,t){let e=utils.Filesystem.normalize(t);for(let r of n){let s=utils.Filesystem.join(t,r.repoSubpath??"",r.name),i=utils.Filesystem.normalize(s);if(!(!i.startsWith(`${e}/`)&&i!==e))try{await promises.mkdir(m(s),{recursive:!0});for(let o of r.files){let l=utils.Filesystem.join(s,o.path),a=utils.Filesystem.normalize(l);if(!a.startsWith(`${i}/`)&&a!==i||o.path.includes("\0"))continue;let c=path.dirname(m(l));c!==m(s)&&await promises.mkdir(c,{recursive:!0}),await promises.writeFile(m(l),o.contents,"utf-8");}}catch{}}}function ft(n,t){let r=utils.Filesystem.normalize(n).replace(/\\/g,"/"),s=utils.Filesystem.normalize(t).replace(/\\/g,"/"),i=r.toLowerCase();return s.toLowerCase().startsWith(`${i}/`)?s.slice(i.length+1):""}async function oe(n){try{return (await promises.readdir(m(n))).length>0}catch{return false}}function Ar(n){try{let t=utils.Filesystem.normalize(n);for(let e of [U(),F()]){let r=utils.Filesystem.normalize(e);if(t===r||t.startsWith(`${r}/`))return !0}return !1}catch{return false}}async function Wr({cachePath:n,skillName:t,scope:e}){let r=utils.Filesystem.join(en({scope:e}),t);return fs.existsSync(r)&&await promises.rm(m(r),{recursive:true,force:true}),await promises.cp(m(n),m(r),{recursive:true}),r}async function Kr(n){let t=ht(n);fs.existsSync(t)&&await promises.rm(m(t),{recursive:true,force:true});}async function Nr(){let n=U();fs.existsSync(n)&&await promises.rm(m(n),{recursive:true,force:true});}var kn="skills-lock.json",le=4;function ae(n){return path.join(n||process.cwd(),kn)}function zr(n,t){return n?It(n,F(),t):null}async function B(n){let t=ae(n);try{let e=await promises.readFile(t,"utf-8"),r=JSON.parse(e);return typeof r.version!="number"||!r.skills||r.version<le?gt():r}catch{return gt()}}async function ce(n,t){let e=ae(t),r={};for(let o of Object.keys(n.skills).sort())r[o]=n.skills[o];let s={version:n.version,skills:r},i=JSON.stringify(s,null,2)+`
22
- `;await promises.writeFile(e,i,"utf-8");}async function Hr(n,t,e){let r=await B(e),s=new Date().toISOString(),i=r.skills[n];r.skills[n]={...t,installedAt:i?.installedAt??s,updatedAt:s},await ce(r,e);}async function Or(n,t){let e=await B(t);return n in e.skills?(delete e.skills[n],await ce(e,t),true):false}function gt(){return {version:le,skills:{}}}exports.$=Ir;exports.A=at;exports.B=Je;exports.C=nr;exports.D=rr;exports.E=ir;exports.F=ct;exports.G=xr;exports.H=tn;exports.I=en;exports.J=F;exports.K=re;exports.L=q;exports.M=ie;exports.N=U;exports.O=nn;exports.P=ht;exports.Q=se;exports.R=pt;exports.S=A;exports.T=Y;exports.U=Er;exports.V=br;exports.W=an;exports.X=cn;exports.Y=Pr;exports.Z=Lr;exports._=un;exports.a=O;exports.aa=X;exports.b=Kn;exports.ba=vr;exports.c=Nn;exports.ca=$r;exports.d=H;exports.da=Rr;exports.e=Ct;exports.ea=ft;exports.f=Rt;exports.fa=oe;exports.g=L;exports.ga=Ar;exports.h=Ee;exports.ha=Wr;exports.i=be;exports.ia=Kr;exports.j=Nt;exports.ja=Nr;exports.k=Ut;exports.l=vn;exports.m=rt;exports.n=Mt;exports.o=K;exports.p=It;exports.q=le;exports.r=ae;exports.s=zr;exports.t=B;exports.u=ce;exports.v=Hr;exports.w=Or;exports.x=qe;exports.y=jt;exports.z=Xe;